-
Notifications
You must be signed in to change notification settings - Fork 936
PoC: More prominent Open Folder (as a group) action #9631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
737a41f
93db08e
884b176
6bcb9b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.netbeans.modules.projectapi.nb; | ||
|
|
||
| import org.netbeans.api.project.Project; | ||
| import org.openide.filesystems.FileObject; | ||
| import org.openide.util.Lookup; | ||
| import org.openide.util.lookup.Lookups; | ||
|
|
||
| final class GenericPrj implements Project { | ||
| private final FileObject dir; | ||
| private final Lookup lkp; | ||
|
|
||
| public GenericPrj(FileObject dir) { | ||
| this.dir = dir; | ||
| this.lkp = Lookups.fixed(this); | ||
| } | ||
|
|
||
| @Override | ||
| public FileObject getProjectDirectory() { | ||
| return dir; | ||
| } | ||
|
|
||
| @Override | ||
| public Lookup getLookup() { | ||
| return lkp; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| package org.netbeans.modules.project.ui.groups; | ||
|
|
||
| import java.awt.HeadlessException; | ||
| import java.io.File; | ||
| import java.util.prefs.Preferences; | ||
| import javax.swing.JFileChooser; | ||
|
|
@@ -160,19 +161,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { | |
| }// </editor-fold>//GEN-END:initComponents | ||
|
|
||
| private void directoryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_directoryButtonActionPerformed | ||
| JFileChooser chooser = new JFileChooser(); | ||
| chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); | ||
| chooser.setMultiSelectionEnabled(false); | ||
| File start = ProjectChooser.getProjectsFolder(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Selecting File / Project Groups... menu item opens a dialog
The New group... button opens another dialog. One needs to choose Folder of Projects and Browse for it (that opens another dialog):
Only then one can click "Create Group" button. Which scans for all the projects in the given folder and opens them in Projects view (after closing all previous ones). |
||
| if (folderField.getText() != null && folderField.getText().trim().length() > 0) { | ||
| start = new File(folderField.getText().trim()); | ||
| } | ||
| chooser.setCurrentDirectory(start); | ||
| if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { | ||
| File f = chooser.getSelectedFile(); | ||
| if (f != null) { | ||
| folderField.setText(f.getAbsolutePath()); | ||
| } | ||
| File f = OpenFolderAsGroupAction.showWorkspaceFolderChooser(this, folderField.getText()); | ||
| if (f != null) { | ||
| folderField.setText(f.getAbsolutePath()); | ||
| } | ||
| }//GEN-LAST:event_directoryButtonActionPerformed | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.netbeans.modules.project.ui.groups; | ||
|
|
||
| import java.awt.HeadlessException; | ||
| import java.awt.event.ActionEvent; | ||
| import java.awt.event.ActionListener; | ||
| import java.io.File; | ||
| import javax.swing.JFileChooser; | ||
| import org.netbeans.spi.project.ui.support.ProjectChooser; | ||
| import org.openide.awt.ActionID; | ||
| import org.openide.awt.ActionReference; | ||
| import org.openide.awt.ActionRegistration; | ||
| import org.openide.filesystems.FileObject; | ||
| import org.openide.filesystems.FileUtil; | ||
| import org.openide.util.NbBundle.Messages; | ||
|
|
||
| @ActionID( | ||
| category = "Project", | ||
| id = "org.netbeans.modules.project.ui.groups.OpenFolderAsGroupAction" | ||
| ) | ||
| @ActionRegistration( | ||
| displayName = "#CTL_OpenFolderAsGroupAction", | ||
| lazy = true, asynchronous = true | ||
| ) | ||
| @ActionReference(path = "Menu/File", position = 1200, separatorAfter = 1250) | ||
| @Messages("CTL_OpenFolderAsGroupAction=Open Fol&der as Workspace...") | ||
| public final class OpenFolderAsGroupAction implements ActionListener { | ||
| @Override | ||
| public void actionPerformed(ActionEvent ev) { | ||
| File dir = showWorkspaceFolderChooser(null, null); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new Open Folder as Workspace... action provides the same function as is currently hidden in the Projects Group... dialog, but it is way more straightforward:
Just choose the new action, then select a folder in the file chooser and voilá! No change in NetBeans abilities, ... but now they are exposed to the world the way the (current development) world wants to see them |
||
| FileObject folder = FileUtil.toFileObject(dir); | ||
| if (folder != null) { | ||
| DirectoryGroup group = DirectoryGroup.create(folder.getNameExt(), folder); | ||
| Group.setActiveGroup(group, true); | ||
| } | ||
| } | ||
|
|
||
| static File showWorkspaceFolderChooser(java.awt.Component parent, final String hintPath) throws HeadlessException { | ||
| JFileChooser chooser = new JFileChooser(); | ||
| chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); | ||
| chooser.setMultiSelectionEnabled(false); | ||
| File start = ProjectChooser.getProjectsFolder(); | ||
| if (hintPath != null && hintPath.trim().length() > 0) { | ||
| start = new File(hintPath.trim()); | ||
| } | ||
| chooser.setCurrentDirectory(start); | ||
| final int result = chooser.showOpenDialog(parent); | ||
| File f = result == JFileChooser.APPROVE_OPTION ? chooser.getSelectedFile() : null; | ||
| return f; | ||
| } | ||
|
|
||
| } | ||




Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DirectoryGroupis visibleGenericPrjis created for itUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.