List of usage examples for com.intellij.openapi.fileChooser FileChooserDialog PREFER_LAST_OVER_TO_SELECT
DataKey PREFER_LAST_OVER_TO_SELECT
To view the source code for com.intellij.openapi.fileChooser FileChooserDialog PREFER_LAST_OVER_TO_SELECT.
Click Source Link
From source file:org.dylanfoundry.deft.library.LibraryAttachDialog.java
License:Apache License
public LibraryAttachDialog(@Nullable Project project) { super(project, true); this.project = project; PropertiesComponent storage = PropertiesComponent.getInstance(project); boolean registryPathSet = storage.isValueSet(PROPERTY_REGISTRY_PATH); if (registryPathSet) { String value = storage.getValue(PROPERTY_REGISTRY_PATH); myDirectoryField.getTextField().setText(value); registryFile = value;/*ww w .j a v a 2 s . c o m*/ } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor(); descriptor.putUserData(FileChooserDialog.PREFER_LAST_OVER_TO_SELECT, Boolean.TRUE); myDirectoryField.addBrowseFolderListener("Choose registry", "Choose registry file for library", null, descriptor); myDirectoryField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!myDirectoryField.getTextField().getText().isEmpty()) { registryFile = myDirectoryField.getTextField().getText(); registryEntries.clear(); registryEntries.add(DeftRegistryInfo.parseRegistryEntry(registryFile)); matchedRegistryEntries.setListData( registryEntries.toArray(new DeftRegistryEntryInfo[registryEntries.size()])); } setOKActionEnabled(!registryEntries.isEmpty()); } }); setOKActionEnabled(false); init(); }
From source file:org.jetbrains.idea.maven.utils.RepositoryAttachDialog.java
License:Apache License
public RepositoryAttachDialog(Project project, boolean managed, final @javax.annotation.Nullable String initialFilter) { super(project, true); myProject = project;// w w w.ja v a2 s . c o m myManaged = managed; myProgressIcon.suspend(); myCaptionLabel.setText(XmlStringUtil.wrapInHtml( StringUtil.escapeXml("enter keyword, pattern or class name to search by or Maven coordinates," + "i.e. 'springframework', 'Logger' or 'org.hibernate:hibernate-core:3.5.0.GA':"))); myInfoLabel.setPreferredSize( new Dimension(myInfoLabel.getFontMetrics(myInfoLabel.getFont()).stringWidth("Showing: 1000"), myInfoLabel.getPreferredSize().height)); myComboComponent.setButtonIcon(AllIcons.Actions.Menu_find); myComboComponent.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performSearch(); } }); myCombobox = myComboComponent.getComboBox(); myCombobox.setModel(new CollectionComboBoxModel(myShownItems, null)); myCombobox.setEditable(true); final JTextField textField = (JTextField) myCombobox.getEditor().getEditorComponent(); textField.setColumns(20); if (initialFilter != null) { textField.setText(initialFilter); } textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (myProgressIcon.isDisposed()) return; updateComboboxSelection(false); } }); } }); myCombobox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final boolean popupVisible = myCombobox.isPopupVisible(); if (!myInUpdate && (!popupVisible || myCoordinates.isEmpty())) { performSearch(); } else { final String item = (String) myCombobox.getSelectedItem(); if (StringUtil.isNotEmpty(item)) { ((JTextField) myCombobox.getEditor().getEditorComponent()).setText(item); } } } }); final PropertiesComponent storage = PropertiesComponent.getInstance(myProject); final boolean pathValueSet = storage.isValueSet(PROPERTY_DOWNLOAD_TO_PATH); if (pathValueSet) { myDirectoryField.setText(storage.getValue(PROPERTY_DOWNLOAD_TO_PATH)); } myJavaDocCheckBox.setSelected( storage.isValueSet(PROPERTY_ATTACH_JAVADOC) && storage.isTrueValue(PROPERTY_ATTACH_JAVADOC)); mySourcesCheckBox.setSelected( storage.isValueSet(PROPERTY_ATTACH_SOURCES) && storage.isTrueValue(PROPERTY_ATTACH_SOURCES)); if (!myManaged) { if (!pathValueSet && myProject != null && !myProject.isDefault()) { final VirtualFile baseDir = myProject.getBaseDir(); if (baseDir != null) { myDirectoryField.setText(FileUtil.toSystemDependentName(baseDir.getPath() + "/lib")); } } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); descriptor.putUserData(FileChooserDialog.PREFER_LAST_OVER_TO_SELECT, Boolean.TRUE); myDirectoryField.addBrowseFolderListener( ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.title"), ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.description"), null, descriptor); } else { myDirectoryField.setVisible(false); } updateInfoLabel(); init(); }