List of usage examples for com.intellij.openapi.fileChooser FileChooserDescriptorFactory createSingleFileOrFolderDescriptor
public static FileChooserDescriptor createSingleFileOrFolderDescriptor()
From source file:com.android.tools.idea.npw.deprecated.ImportSourceLocationStep.java
License:Apache License
private void setupSourceLocationControls() { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(); descriptor.setTitle("Select Source Location"); descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject"); mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor)); mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override/*from w w w . j av a2s. co m*/ protected void textChanged(DocumentEvent e) { invalidate(); } }); applyBackgroundOperationResult(checkPath(mySourceLocation.getText())); myErrorWarning.setIcon(null); myErrorWarning.setText(null); }
From source file:com.android.tools.idea.npw.importing.SourceToGradleModuleStep.java
License:Apache License
public SourceToGradleModuleStep(@NotNull SourceToGradleModuleModel model) { super(model, AndroidBundle.message("android.wizard.module.import.source.title")); //noinspection DialogTitleCapitalization - incorrectly detects "Gradle" as incorrectly capitalised mySourceLocation.addBrowseFolderListener( AndroidBundle.message("android.wizard.module.import.source.browse.title"), AndroidBundle.message("android.wizard.module.import.source.browse.description"), getModel().getProject(), FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor()); myBindings.bindTwoWay(new TextProperty(mySourceLocation.getTextField()), model.sourceLocation()); myBindings.bind(new VisibleProperty(myValidationProgress), myPageValidationResult.transform(PathValidationResult::isValidating)); myBindings.bind(new VisibleProperty(myErrorWarning), myPageValidationResult.transform(result -> result.getIcon() != null)); myBindings.bind(new TextProperty(myErrorWarning), myPageValidationResult.transform(PathValidationResult::getMessage)); myBindings.bind(new IconProperty(myErrorWarning), myPageValidationResult.transform(result -> Optional.ofNullable(result.getIcon()))); myErrorWarning.setBorder(BorderFactory.createEmptyBorder(16, 0, 0, 0)); myPanel.setBorder(new EmptyBorder(UIUtil.PANEL_REGULAR_INSETS)); myModulesPanel.bindPrimaryModuleEntryComponents(new PrimaryModuleImportSettings(), myRequiredModulesLabel); myModulesPanel.addPropertyChangeListener(ModulesTable.PROPERTY_SELECTED_MODULES, event -> { if (ModulesTable.PROPERTY_SELECTED_MODULES.equals(event.getPropertyName())) { updateStepStatus();/*from w w w . j a v a 2s.c o m*/ } }); AsyncValidator<?> validator = new AsyncValidator<PathValidationResult>( ApplicationManager.getApplication()) { @Override protected void showValidationResult(@NotNull PathValidationResult result) { applyValidationResult(result); } @NotNull @Override protected PathValidationResult validate() { myPageValidationResult.set(PathValidationResult.ofType(VALIDATING)); return checkPath(getModel().sourceLocation().get()); } }; myListeners.listen(model.sourceLocation(), source -> validator.invalidate()); }
From source file:com.android.tools.idea.wizard.ImportSourceLocationStep.java
License:Apache License
private void setupSourceLocationControls(@Nullable VirtualFile importSource) { if (importSource == null) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(); descriptor.setTitle("Select Source Location"); descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject"); mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor)); mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override//w w w. j a v a 2s . c om protected void textChanged(DocumentEvent e) { invalidate(); } }); } else { mySourceLocation.setVisible(false); myLocationLabel.setVisible(false); mySourceLocation.setText(importSource.getPath()); } applyBackgroundOperationResult(checkPath(mySourceLocation.getText())); myErrorWarning.setIcon(null); myErrorWarning.setText(null); }
From source file:com.intellij.coldFusion.mxunit.CfmlUnitRunConfigurationForm.java
License:Apache License
public CfmlUnitRunConfigurationForm(Project project) { myProject = project;// ww w. ja va2 s . c o m myMethodPanel.setVisible(false); myFileChooser = new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(null, null, myDirectoryOrFileField, project, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myDirectoryChooser = new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(null, null, myDirectoryOrFileField, project, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myMethodRadioButton.addChangeListener(myScopeChangeListener); myDirectoryRadioButton.addChangeListener(myScopeChangeListener); myComponentRadioButton.addChangeListener(myScopeChangeListener); }
From source file:com.intellij.diagnostic.logging.EditLogPatternDialog.java
License:Apache License
@Override protected JComponent createCenterPanel() { myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override//from www. jav a2 s .c om protected void textChanged(DocumentEvent e) { setOKActionEnabled(myFilePattern.getText() != null && myFilePattern.getText().length() > 0); } }); return myWholePanel; }
From source file:com.intellij.diagnostic.logging.LogConfigurationPanel.java
License:Apache License
public LogConfigurationPanel() { myModel = new ListTableModel<LogFileOptions>(IS_SHOW, FILE, IS_SKIP_CONTENT); myFilesTable = new TableView<LogFileOptions>(myModel); myFilesTable.getEmptyText().setText(DiagnosticBundle.message("log.monitor.no.files")); final JTableHeader tableHeader = myFilesTable.getTableHeader(); final FontMetrics fontMetrics = tableHeader.getFontMetrics(tableHeader.getFont()); int preferredWidth = fontMetrics.stringWidth(IS_SHOW.getName()) + 20; setUpColumnWidth(tableHeader, preferredWidth, 0); preferredWidth = fontMetrics.stringWidth(IS_SKIP_CONTENT.getName()) + 20; setUpColumnWidth(tableHeader, preferredWidth, 2); myFilesTable.setColumnSelectionAllowed(false); myFilesTable.setShowGrid(false);/*www . java 2s . co m*/ myFilesTable.setDragEnabled(false); myFilesTable.setShowHorizontalLines(false); myFilesTable.setShowVerticalLines(false); myFilesTable.setIntercellSpacing(new Dimension(0, 0)); myScrollPanel.add(ToolbarDecorator.createDecorator(myFilesTable).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { ArrayList<LogFileOptions> newList = new ArrayList<LogFileOptions>(myModel.getItems()); LogFileOptions newOptions = new LogFileOptions("", "", true, true, false); if (showEditorDialog(newOptions)) { newList.add(newOptions); myModel.setItems(newList); int index = myModel.getRowCount() - 1; myModel.fireTableRowsInserted(index, index); myFilesTable.setRowSelectionInterval(index, index); } } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { TableUtil.stopEditing(myFilesTable); final int[] selected = myFilesTable.getSelectedRows(); if (selected == null || selected.length == 0) return; for (int i = selected.length - 1; i >= 0; i--) { myModel.removeRow(selected[i]); } for (int i = selected.length - 1; i >= 0; i--) { int idx = selected[i]; myModel.fireTableRowsDeleted(idx, idx); } int selection = selected[0]; if (selection >= myModel.getRowCount()) { selection = myModel.getRowCount() - 1; } if (selection >= 0) { myFilesTable.setRowSelectionInterval(selection, selection); } myFilesTable.requestFocus(); } }).setEditAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final int selectedRow = myFilesTable.getSelectedRow(); final LogFileOptions selectedOptions = myFilesTable.getSelectedObject(); showEditorDialog(selectedOptions); myModel.fireTableDataChanged(); myFilesTable.setRowSelectionInterval(selectedRow, selectedRow); } }).setRemoveActionUpdater(new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { return myFilesTable.getSelectedRowCount() >= 1 && !myLog2Predefined.containsKey(myFilesTable.getSelectedObject()); } }).setEditActionUpdater(new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { return myFilesTable.getSelectedRowCount() >= 1 && !myLog2Predefined.containsKey(myFilesTable.getSelectedObject()) && myFilesTable.getSelectedObject() != null; } }).disableUpDownActions().createPanel(), BorderLayout.CENTER); myWholePanel.setPreferredSize(new Dimension(-1, 150)); myOutputFile.addBrowseFolderListener("Choose File to Save Console Output", "Console output would be saved to the specified file", null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myRedirectOutputCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myOutputFile.setEnabled(myRedirectOutputCb.isSelected()); } }); }
From source file:org.intellij.plugins.relaxNG.convert.ConvertSchemaSettingsImpl.java
License:Apache License
public ConvertSchemaSettingsImpl(Project project, @Nonnull SchemaType inputType, VirtualFile firstFile) { myProject = project;//from w ww .j av a 2 s .c om myInputType = inputType; final FileType type; switch (inputType) { case RNG: myOutputRng.setVisible(false); myOutputXsd.setSelected(true); type = XmlFileType.INSTANCE; break; case RNC: myOutputRnc.setVisible(false); myOutputRng.setSelected(true); type = RncFileType.getInstance(); break; case XSD: myOutputXsd.setVisible(false); myOutputRng.setSelected(true); type = XmlFileType.INSTANCE; break; case DTD: myOutputDtd.setVisible(false); myOutputRng.setSelected(true); type = DTDFileType.INSTANCE; break; case XML: myOutputRng.setSelected(true); type = XmlFileType.INSTANCE; break; default: assert false; type = null; } final Charset[] charsets = CharsetToolkit.getAvailableCharsets(); final List<String> suggestions = new ArrayList<>(charsets.length); for (Charset charset : charsets) { if (charset.canEncode()) { String name = charset.name(); suggestions.add(name); } } myEncoding.setModel(new DefaultComboBoxModel(suggestions.toArray())); final Charset charset = EncodingProjectManager.getInstance(project).getDefaultCharset(); myEncoding.setSelectedItem(charset.name()); final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(project); final int indent = styleSettings.getIndentSize(type); myIndent.setText(String.valueOf(indent)); myLineLength.setText(String.valueOf(styleSettings.getDefaultRightMargin())); final SchemaType outputType = getOutputType(); myLineLength.setEnabled(outputType == SchemaType.DTD || outputType == SchemaType.RNC); final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(); final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(firstFile); descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, module); myOutputDestination.addBrowseFolderListener("Schema Conversion Destination", "Please select the destination the generated file(s) should be placed at", project, descriptor); final JTextField tf = myOutputDestination.getTextField(); tf.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { myPropertyChangeSupport.firePropertyChange(OUTPUT_PATH, null, getOutputDestination()); } }); tf.setText(firstFile.getParent().getPath().replace('/', File.separatorChar)); final ItemListener listener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { final SchemaType type = getOutputType(); myPropertyChangeSupport.firePropertyChange(OUTPUT_TYPE, null, type); myLineLength.setEnabled(type == SchemaType.DTD || type == SchemaType.RNC); } } }; myOutputRng.addItemListener(listener); myOutputRnc.addItemListener(listener); myOutputXsd.addItemListener(listener); myOutputDtd.addItemListener(listener); if (inputType == SchemaType.DTD) { myInputOptions = AdvancedDtdOptions.prepareNamespaceMap(project, firstFile); } }
From source file:org.intellij.xquery.runner.ui.run.ContextItemPanel.java
License:Apache License
public ContextItemPanel(Project project) { contextItemEnabled = new JBCheckBox("Pass context item"); contextItemEnabled.setMnemonic(KeyEvent.VK_C); contextItemEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { contextItemEnabledChanged(); }// w w w . j a va 2s .co m }); contextItemOptionsPanel = new JPanel(new MigLayout("ins 0, gap 5, fill, flowx")); contextItemEditorField = new EditorTextField("", project, StdFileTypes.PLAIN_TEXT); contextItemEditorContent = new MyEditorTextFieldWithBrowseButton(project, contextItemEditorField); contextItemEditorContent.setButtonIcon(AllIcons.Actions.ShowViewer); contextItemPathField = new TextFieldWithBrowseButton(); contextItemPathField.addBrowseFolderListener("Choose file", null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor()); contextItemTypeField = new LabeledComponent<JComboBox>(); contextItemTypeField.setText("&Type"); contextItemTypeField.setLabelLocation("West"); contextItemTypeField.setComponent(new JComboBox()); editorRadioButton = new JRadioButton("Custom content"); editorRadioButton.setMnemonic(KeyEvent.VK_E); editorRadioButton.setSelected(true); editorRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { contextItemSourceChanged(); } }); fileRadioButton = new JRadioButton("Content from file"); fileRadioButton.setMnemonic(KeyEvent.VK_L); fileRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { contextItemSourceChanged(); } }); buttonGroup = new ButtonGroup(); buttonGroup.add(editorRadioButton); buttonGroup.add(fileRadioButton); setLayout(new MigLayout("ins 0, gap 5, fill, flowx")); add(contextItemEnabled, "shrinkx, top"); add(contextItemOptionsPanel, "growx, pushx"); contextItemTypeField.getComponent().setModel(typesModel); contextItemOptionsPanel.add(contextItemTypeField, "growx, pushx, wrap, span 2"); contextItemOptionsPanel.add(editorRadioButton); contextItemOptionsPanel.add(contextItemEditorContent, "growx, pushx, wrap"); contextItemOptionsPanel.add(fileRadioButton); contextItemOptionsPanel.add(contextItemPathField, "growx, pushx"); contextItemEnabledChanged(); contextItemSourceChanged(); populateTypesList(); new ComboboxSpeedSearch(contextItemTypeField.getComponent()); }
From source file:org.intellij.xquery.runner.ui.run.main.variables.ContextItemPanel.java
License:Apache License
protected void addPathFieldButtonListener() { contextItemPathField.addBrowseFolderListener("Choose file", null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor()); }
From source file:org.jetbrains.idea.svn.dialogs.browser.DiffOptionsDialog.java
License:Apache License
@Nullable private File selectFile(String title, String description) { FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(); fcd.setShowFileSystemRoots(true);/*from ww w . j a v a2s. c om*/ fcd.setTitle(title); fcd.setDescription(description); fcd.setHideIgnored(false); VirtualFile file = FileChooser.chooseFile(fcd, myBrowser, myProject, null); if (file == null) { return null; } return new File(file.getPath()); }