Search in sources :

Example 36 with TextFieldWithBrowseButton

use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-plugins by JetBrains.

the class DartTestConfigurationEditorForm method applyEditorTo.

@Override
protected void applyEditorTo(@NotNull final DartTestRunConfiguration configuration) throws ConfigurationException {
    final DartTestRunnerParameters parameters = configuration.getRunnerParameters();
    final DartTestRunnerParameters.Scope scope = (DartTestRunnerParameters.Scope) myScopeCombo.getSelectedItem();
    parameters.setScope(scope);
    TextFieldWithBrowseButton pathSource = scope == FOLDER ? myDirField : myFileField;
    parameters.setFilePath(StringUtil.nullize(FileUtil.toSystemIndependentName(pathSource.getText().trim())));
    parameters.setTestName(scope == GROUP_OR_TEST_BY_NAME ? StringUtil.nullize(myTestNameField.getText().trim()) : null);
    parameters.setTargetName(scope == FOLDER ? StringUtil.nullize(myTargetNameField.getText().trim()) : null);
    parameters.setTestRunnerOptions(StringUtil.nullize(myTestRunnerOptionsField.getText().trim()));
    parameters.setEnvs(myEnvironmentVariables.getEnvs());
    parameters.setIncludeParentEnvs(myEnvironmentVariables.isPassParentEnvs());
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) Scope(com.jetbrains.lang.dart.ide.runner.test.DartTestRunnerParameters.Scope) Scope(com.jetbrains.lang.dart.ide.runner.test.DartTestRunnerParameters.Scope) DartTestRunnerParameters(com.jetbrains.lang.dart.ide.runner.test.DartTestRunnerParameters)

Example 37 with TextFieldWithBrowseButton

use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-plugins by JetBrains.

the class FilesToPackageForm method initTable.

private void initTable() {
    myFilesToPackageTable = new JBTable();
    // otherwise model is not in sync with view
    myFilesToPackageTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    myFilesToPackageTable.setPreferredScrollableViewportSize(JBUI.size(400, 150));
    myFilesToPackageTable.setRowHeight(new JTextField("Fake").getPreferredSize().height + myFilesToPackageTable.getRowMargin());
    myFilesToPackageTable.setModel(new DefaultTableModel() {

        public int getColumnCount() {
            return Column.values().length;
        }

        public int getRowCount() {
            return myFilesToPackage.size();
        }

        public String getColumnName(int column) {
            return Column.values()[column].getColumnName();
        }

        public Class<?> getColumnClass(int column) {
            return Column.values()[column].getColumnClass();
        }

        public Object getValueAt(int row, int column) {
            return Column.values()[column].getValue(myFilesToPackage.get(row));
        }

        public void setValueAt(Object aValue, int row, int column) {
            Column.values()[column].setValue(myFilesToPackage, row, aValue);
        }
    });
    myFilesToPackageTable.getColumnModel().getColumn(0).setCellEditor(new AbstractTableCellEditor() {

        private CellEditorComponentWithBrowseButton<JTextField> myComponent;

        public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) {
            final ActionListener listener = new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    FileChooserDescriptor d = new FileChooserDescriptor(true, true, false, true, false, false);
                    VirtualFile initialFile = LocalFileSystem.getInstance().findFileByPath((String) getCellEditorValue());
                    VirtualFile file = FileChooser.chooseFile(d, myProject, initialFile);
                    if (file != null) {
                        myComponent.getChildComponent().setText(file.getPresentableUrl());
                    }
                }
            };
            myComponent = new CellEditorComponentWithBrowseButton<>(new TextFieldWithBrowseButton(listener), this);
            myComponent.getChildComponent().setText((String) value);
            return myComponent;
        }

        public Object getCellEditorValue() {
            return myComponent.getChildComponent().getText();
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) CellEditorComponentWithBrowseButton(com.intellij.util.ui.CellEditorComponentWithBrowseButton) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener)

Example 38 with TextFieldWithBrowseButton

use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project android by JetBrains.

the class NewModuleDialogFixture method setFileName.

@NotNull
public NewModuleDialogFixture setFileName(String name) {
    TextFieldWithBrowseButton panel = robot().finder().findByLabel(target(), "File name:", TextFieldWithBrowseButton.class);
    new JTextComponentFixture(robot(), robot().finder().findByType(panel, JTextField.class)).deleteText().enterText(name);
    return this;
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with TextFieldWithBrowseButton

use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-community by JetBrains.

the class DomGenPanel method createUIComponents.

private void createUIComponents() {
    mySchemaLocation = new TextFieldWithBrowseButton();
    final String title = "Choose XSD or DTD schema";
    mySchemaLocation.addBrowseFolderListener(title, "Make sure there are only necessary schemes in directory where your XSD or DTD schema is located", myProject, new FileTypeDescriptor(title, "xsd", "dtd"));
    mySchemaLocation.getTextField().setEditable(false);
    mySchemaLocation.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final File file = new File(mySchemaLocation.getText());
            if (file.exists() && file.getName().toLowerCase().endsWith(".xsd")) {
                final VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(file);
                if (vf != null) {
                    final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vf);
                    if (psiFile instanceof XmlFile) {
                        final XmlDocument xml = ((XmlFile) psiFile).getDocument();
                        if (xml != null) {
                            final XmlTag rootTag = xml.getRootTag();
                            if (rootTag != null) {
                                String target = null;
                                ArrayList<String> ns = new ArrayList<>();
                                for (XmlAttribute attr : rootTag.getAttributes()) {
                                    if ("targetNamespace".equals(attr.getName())) {
                                        target = attr.getValue();
                                    } else if (attr.getName().startsWith("xmlns")) {
                                        ns.add(attr.getValue());
                                    }
                                }
                                ns.remove(target);
                                if (target != null) {
                                    myNamespace.setText(target);
                                }
                                mySkipSchemas.setText(StringUtil.join(ArrayUtil.toStringArray(ns), "\n"));
                            }
                        }
                    }
                }
            }
        }
    });
    myOutputDir = new TextFieldWithBrowseButton();
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    myOutputDir.addBrowseFolderListener("Select Output Directory For Generated Files", "", myProject, descriptor);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlAttribute(com.intellij.psi.xml.XmlAttribute) XmlFile(com.intellij.psi.xml.XmlFile) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ArrayList(java.util.ArrayList) XmlDocument(com.intellij.psi.xml.XmlDocument) FileTypeDescriptor(com.intellij.openapi.fileChooser.FileTypeDescriptor) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener) PsiFile(com.intellij.psi.PsiFile) XmlFile(com.intellij.psi.xml.XmlFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile) XmlTag(com.intellij.psi.xml.XmlTag)

Example 40 with TextFieldWithBrowseButton

use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-community by JetBrains.

the class ShowUpdateInfoDialogAction method getUserText.

@NotNull
private static Pair<String, VirtualFile> getUserText(@NotNull Project project, @NotNull String title) {
    JTextArea textArea = new JTextArea(10, 50);
    UIUtil.addUndoRedoActions(textArea);
    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    JPanel panel = new JPanel(new BorderLayout(0, 10));
    panel.add(ScrollPaneFactory.createScrollPane(textArea), BorderLayout.CENTER);
    Disposable disposable = Disposer.newDisposable();
    FileTextField fileField = FileChooserFactory.getInstance().createFileTextField(BrowseFilesListener.SINGLE_FILE_DESCRIPTOR, disposable);
    TextFieldWithBrowseButton fileCompo = new TextFieldWithBrowseButton(fileField.getField());
    FileChooserDescriptor fileDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    fileCompo.addBrowseFolderListener("Patch File", "Patch file", project, fileDescriptor);
    panel.add(LabeledComponent.create(fileCompo, "Patch file:"), BorderLayout.SOUTH);
    DialogBuilder builder = new DialogBuilder(project);
    builder.addDisposable(disposable);
    builder.setCenterPanel(panel);
    builder.setPreferredFocusComponent(textArea);
    builder.setTitle(title);
    builder.addOkAction();
    builder.addCancelAction();
    return builder.showAndGet() ? Pair.create(textArea.getText(), fileField.getSelectedFile()) : Pair.empty();
}
Also used : Disposable(com.intellij.openapi.Disposable) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) FileTextField(com.intellij.openapi.fileChooser.FileTextField) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)59 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)22 NotNull (org.jetbrains.annotations.NotNull)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 ActionEvent (java.awt.event.ActionEvent)9 ActionListener (java.awt.event.ActionListener)8 JBLabel (com.intellij.ui.components.JBLabel)6 JBTextField (com.intellij.ui.components.JBTextField)6 DocumentEvent (javax.swing.event.DocumentEvent)6 File (java.io.File)5 Nullable (org.jetbrains.annotations.Nullable)5 FileTextField (com.intellij.openapi.fileChooser.FileTextField)4 ComboBox (com.intellij.openapi.ui.ComboBox)4 TextBrowseFolderListener (com.intellij.openapi.ui.TextBrowseFolderListener)4 DocumentListener (javax.swing.event.DocumentListener)4 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)3 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)3 ComponentWithBrowseButton (com.intellij.openapi.ui.ComponentWithBrowseButton)3 RawCommandLineEditor (com.intellij.ui.RawCommandLineEditor)3 JBCheckBox (com.intellij.ui.components.JBCheckBox)3