Java Code Examples for org.netbeans.spi.project.ui.support.ProjectChooser#projectChooser()
The following examples show how to use
org.netbeans.spi.project.ui.support.ProjectChooser#projectChooser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectProblemsProviders.java From netbeans with Apache License 2.0 | 6 votes |
@Override @NonNull @NbBundle.Messages({ "LBL_BrokenLinksCustomizer_Resolve_Project=Browse Project \"{0}\"" }) public Future<ProjectProblemsProvider.Result> resolve() { ProjectProblemsProvider.Status result = ProjectProblemsProvider.Status.UNRESOLVED; final JFileChooser chooser = ProjectChooser.projectChooser(); chooser.setDialogTitle(LBL_BrokenLinksCustomizer_Resolve_Project(getDisplayId(type, id))); if (lastSelectedFile != null) { chooser.setSelectedFile(lastSelectedFile); } int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { updateReference(chooser.getSelectedFile()); lastSelectedFile = chooser.getSelectedFile(); result = ProjectProblemsProvider.Status.RESOLVED; } return new Done(ProjectProblemsProvider.Result.create(result)); }
Example 2
Source File: ApisupportAntUIUtils.java From netbeans with Apache License 2.0 | 6 votes |
public static Project chooseProject(Component parent) { JFileChooser chooser = ProjectChooser.projectChooser(); int option = chooser.showOpenDialog(parent); Project project = null; if (option == JFileChooser.APPROVE_OPTION) { File projectDir = chooser.getSelectedFile(); ApisupportAntUIUtils.setProjectChooserDirParent(projectDir); try { project = ProjectManager.getDefault().findProject( FileUtil.toFileObject(projectDir)); } catch (IOException e) { ErrorManager.getDefault().notify(ErrorManager.WARNING, e); } } return project; }
Example 3
Source File: SelectProjectPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void btnProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProjectActionPerformed JFileChooser chooser = ProjectChooser.projectChooser(); int res = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)); if (res == JFileChooser.APPROVE_OPTION) { File fil = chooser.getSelectedFile(); FileObject fo = FileUtil.toFileObject(fil); if (fo != null) { try { Project p = ProjectManager.getDefault().findProject(fo); DefaultComboBoxModel model = (DefaultComboBoxModel)comProject.getModel(); model.addElement(p); model.setSelectedItem(p); if (EMPTY == model.getElementAt(0)) { model.removeElement(EMPTY); } } catch (IOException exc) { ErrorManager.getDefault().notify(exc); } } } }
Example 4
Source File: CreateJobPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed JFileChooser chooser = ProjectChooser.projectChooser(); chooser.showOpenDialog(this); File dir = chooser.getSelectedFile(); if (dir != null) { FileObject d = FileUtil.toFileObject(dir); if (d != null) { try { Project p = ProjectManager.getDefault().findProject(d); if (p != null) { manuallyAddedProjects.add(p); updateProjectModel(); project.setSelectedItem(p); } } catch (IOException x) { Exceptions.printStackTrace(x); } } } }
Example 5
Source File: ChooseProjectWizardPanel.java From netbeans with Apache License 2.0 | 5 votes |
@Override public java.awt.Component getComponent() { if (projectChooser == null) { // create the UI component for the wizard step projectChooser = ProjectChooser.projectChooser(); projectChooser.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // wizard API: set the caption and index of this panel projectChooser.setName(PaletteUtils.getBundleString("CTL_SelectProject_Caption")); // NOI18N projectChooser.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, // NOI18N Integer.valueOf(0)); if (lastDirectoryUsed != null) projectChooser.setCurrentDirectory(new File(lastDirectoryUsed)); projectChooser.setControlButtonsAreShown(false); projectChooser.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent ev) { String propName = ev.getPropertyName(); if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(propName) || JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(propName)) cs.fireChange(); } }); } return projectChooser; }
Example 6
Source File: TypeChooserPanelImpl.java From netbeans with Apache License 2.0 | 5 votes |
private void browseModuleSuite(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseModuleSuite JFileChooser chooser = ProjectChooser.projectChooser(); int option = chooser.showOpenDialog(this); if (option == JFileChooser.APPROVE_OPTION) { File projectDir = chooser.getSelectedFile(); ApisupportAntUIUtils.setProjectChooserDirParent(projectDir); try { Project suite = ProjectManager.getDefault().findProject( FileUtil.toFileObject(projectDir)); if (suite != null) { String suiteDir = SuiteUtils.getSuiteDirectoryPath(suite); if (suiteDir != null) { // register for this session PlatformComponentFactory.addUserSuite(suiteDir); // add to current combobox moduleSuiteValue.addItem(suiteDir); moduleSuiteValue.setSelectedItem(suiteDir); } else { DialogDisplayer.getDefault().notify(new DialogDescriptor.Message( NbBundle.getMessage(BasicInfoVisualPanel.class, "MSG_NotRegularSuite", ProjectUtils.getInformation(suite).getDisplayName()))); } } } catch (IOException e) { ErrorManager.getDefault().notify(ErrorManager.WARNING, e); } } }
Example 7
Source File: SubprojectsGroupEditPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void masterProjectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_masterProjectButtonActionPerformed JFileChooser chooser = ProjectChooser.projectChooser(); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); if (f != null) { masterProjectField.setText(f.getAbsolutePath()); //firePropertyChange(PROP_READY, null, null); } } }
Example 8
Source File: NewGroupPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void masterProjectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_masterProjectButtonActionPerformed JFileChooser chooser = ProjectChooser.projectChooser(); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); if (f != null) { masterProjectField.setText(f.getAbsolutePath()); updateNameField(); firePropertyChange(PROP_READY, null, null); } } }
Example 9
Source File: AntArtifactChooser.java From netbeans with Apache License 2.0 | 4 votes |
/** Shows dialog with the artifact chooser * @return null if canceled selected jars if some jars selected */ static AntArtifactItem[] showDialog( String[] artifactTypes, Project master, Component parent ) { JFileChooser chooser = ProjectChooser.projectChooser(); chooser.setDialogTitle( NbBundle.getMessage( AntArtifactChooser.class, "LBL_AACH_Title" ) ); // NOI18N chooser.setApproveButtonText( NbBundle.getMessage( AntArtifactChooser.class, "LBL_AACH_SelectProject" ) ); // NOI18N chooser.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (AntArtifactChooser.class,"AD_AACH_SelectProject")); AntArtifactChooser accessory = new AntArtifactChooser( artifactTypes, chooser ); chooser.setAccessory( accessory ); chooser.setPreferredSize( new Dimension( 650, 380 ) ); File defaultFolder = null; FileObject defFo = master.getProjectDirectory(); if (defFo != null) { defFo = defFo.getParent(); if (defFo != null) { defaultFolder = FileUtil.toFile(defFo); } } chooser.setCurrentDirectory (getLastUsedArtifactFolder(defaultFolder)); int option = chooser.showOpenDialog( parent ); // Show the chooser if ( option == JFileChooser.APPROVE_OPTION ) { File dir = chooser.getSelectedFile(); dir = FileUtil.normalizeFile (dir); Project selectedProject = accessory.getProject( dir ); if ( selectedProject == null ) { return null; } if ( selectedProject.getProjectDirectory().equals( master.getProjectDirectory() ) ) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message( NbBundle.getMessage( AntArtifactChooser.class, "MSG_AACH_RefToItself" ), NotifyDescriptor.INFORMATION_MESSAGE ) ); return null; } if ( ProjectUtils.hasSubprojectCycles( master, selectedProject ) ) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message( NbBundle.getMessage( AntArtifactChooser.class, "MSG_AACH_Cycles" ), NotifyDescriptor.INFORMATION_MESSAGE ) ); return null; } boolean noSuitableOutput = true; for (String type : artifactTypes) { if (AntArtifactQuery.findArtifactsByType(selectedProject, type).length > 0) { noSuitableOutput = false; break; } } if (noSuitableOutput) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage (AntArtifactChooser.class,"MSG_NO_JAR_OUTPUT"))); return null; } setLastUsedArtifactFolder (FileUtil.normalizeFile(chooser.getCurrentDirectory())); Object[] tmp = new Object[accessory.jListArtifacts.getModel().getSize()]; int count = 0; for(int i = 0; i < tmp.length; i++) { if (accessory.jListArtifacts.isSelectedIndex(i)) { tmp[count] = accessory.jListArtifacts.getModel().getElementAt(i); count++; } } AntArtifactItem artifactItems[] = new AntArtifactItem[count]; System.arraycopy(tmp, 0, artifactItems, 0, count); return artifactItems; } else { return null; } }
Example 10
Source File: FormattingCustomizerPanel.java From netbeans with Apache License 2.0 | 4 votes |
private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed JFileChooser chooser = ProjectChooser.projectChooser(); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File f = FileUtil.normalizeFile(chooser.getSelectedFile()); FileObject fo = FileUtil.toFileObject(f); if (fo != null) { Object ret; try { final Project prjFrom = ProjectManager.getDefault().findProject(fo); if (prjFrom == pf.getProject()) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(FormattingCustomizerPanel.class, "MSG_CodeStyle_Import_Forbidden_From_The_Same_Project"), //NOI18N NotifyDescriptor.Message.PLAIN_MESSAGE)); return; } ret = ProjectManager.mutex().readAccess(new ExceptionAction<Object>() { public Object run() throws Exception { Preferences fromPrjPrefs = ProjectUtils.getPreferences(prjFrom, IndentUtils.class, true); if (!fromPrjPrefs.nodeExists(CODE_STYLE_PROFILE) || fromPrjPrefs.node(CODE_STYLE_PROFILE).get(USED_PROFILE, null) == null ) { return NbBundle.getMessage(FormattingCustomizerPanel.class, "MSG_No_CodeStyle_Info_To_Import"); //NOI18N } ProjectPreferencesFactory newPrefsFactory = new ProjectPreferencesFactory(pf.getProject()); Preferences toPrjPrefs = newPrefsFactory.projectPrefs; removeAllKidsAndKeys(toPrjPrefs); deepCopy(fromPrjPrefs, toPrjPrefs); // XXX: detect somehow if the basic options are overriden in fromPrjPrefs // and set the flag accordingly in toPrjPrefs //dump(fromPrjPrefs, "fromPrjPrefs"); //dump(toPrjPrefs, "toPrjPrefs"); return newPrefsFactory; } }); } catch (Exception e) { LOG.log(Level.INFO, null, e); ret = e; } if (ret instanceof ProjectPreferencesFactory) { String selectedMimeType = selector.getSelectedMimeType(); PreferencesCustomizer c = selector.getSelectedCustomizer(); String selectedCustomizerId = c != null ? c.getId() : null; pf.destroy(); pf = (ProjectPreferencesFactory) ret; selector = new CustomizerSelector(pf, false, allowedMimeTypes); panel.setSelector(selector); if (selectedMimeType != null) { selector.setSelectedMimeType(selectedMimeType); } if (selectedCustomizerId != null) { selector.setSelectedCustomizer(selectedCustomizerId); } DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(FormattingCustomizerPanel.class, "MSG_CodeStyle_Import_Successful"), //NOI18N NotifyDescriptor.Message.PLAIN_MESSAGE)); } else if (ret instanceof Exception) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(FormattingCustomizerPanel.class, "MSG_CodeStyle_Import_Failed"), //NOI18N NotifyDescriptor.Message.WARNING_MESSAGE)); } else { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( (String) ret, NotifyDescriptor.Message.PLAIN_MESSAGE)); } } } }