Search in sources :

Example 11 with JBTextField

use of com.intellij.ui.components.JBTextField in project android by JetBrains.

the class ConfigureActivityStep method onProceeding.

@Override
protected void onProceeding() {
    getModel().getKeyValues().clear();
    for (Component component : myRootPanel.getComponents()) {
        if (component instanceof JBTextField) {
            JBTextField valueTextField = (JBTextField) component;
            getModel().getKeyValues().put((String) valueTextField.getClientProperty("param"), valueTextField.getText());
        }
    }
}
Also used : JBTextField(com.intellij.ui.components.JBTextField)

Example 12 with JBTextField

use of com.intellij.ui.components.JBTextField in project intellij-plugins by JetBrains.

the class PhoneGapRunConfigurationEditor method createEditor.

@NotNull
@Override
protected JComponent createEditor() {
    myExecutablePathField = PhoneGapUtil.createPhoneGapExecutableTextField(myProject);
    myWorkDirField = PhoneGapUtil.createPhoneGapWorkingDirectoryField(myProject);
    myPlatformField = new ComboBoxWithMoreOption(getDefaultPlatforms(), getNonDefaultPlatforms());
    myCommand = new ComboBox();
    myEnvComponent = new EnvironmentVariablesTextFieldWithBrowseButton();
    myEnvComponent.setPassParentEnvs(true);
    myHasTarget = new JBCheckBox("Specify target");
    myTarget = new PhoneGapTargetsPanel();
    myExtraArgsTextField = new JBTextField(15);
    myCommand.setMinimumAndPreferredWidth(200);
    myPlatformField.setMinimumAndPreferredWidth(200);
    myTarget.getTargetsField().setMinimumAndPreferredWidth(myPlatformField.getPreferredSize().width);
    myTarget.setDataProvider(new ReloadableComboBoxPanel.DataProvider<String>() {

        @NotNull
        @Override
        public Set<String> getCachedValues() {
            return ContainerUtil.newHashOrEmptySet(null);
        }

        @Override
        public void updateValuesAsynchronously() {
            if (!myTarget.isEnabled()) {
                processEmpty();
                return;
            }
            final String platform = getPlatformAsCodeFromField();
            final String command = (String) myCommand.getSelectedItem();
            final PhoneGapTargets targetsProvider = PhoneGapTargets.createTargetsList(myProject, platform);
            if (targetsProvider == null) {
                processEmpty();
                return;
            }
            ApplicationManager.getApplication().executeOnPooledThread(() -> {
                final String currentText = myTarget.getTargetsField().getText();
                final Set<String> targets = ContainerUtil.newLinkedHashSet(PhoneGapTargets.listTargets(targetsProvider, command));
                if (!StringUtil.isEmpty(currentText) && !targets.contains(currentText)) {
                    targets.add(currentText);
                }
                UIUtil.invokeLaterIfNeeded(() -> myTarget.onUpdateValues(targets));
            });
        }

        private void processEmpty() {
            myTarget.onUpdateValues(ContainerUtil.newHashOrEmptySet(null));
        }
    });
    setListenerForPlatforms();
    setListenerForCommand();
    setListenerForHasTarget();
    setListenerForExecutablePath();
    setCommandList();
    return FormBuilder.createFormBuilder().addLabeledComponent(PhoneGapBundle.message("phonegap.conf.executable.name"), myExecutablePathField).addLabeledComponent(PhoneGapBundle.message("phonegap.conf.work.dir.name"), myWorkDirField).addLabeledComponent(ExecutionBundle.message("environment.variables.component.title"), myEnvComponent).addLabeledComponent("Command:", myCommand).addLabeledComponent("Platform:", myPlatformField).addLabeledComponent(PhoneGapBundle.message("phonegap.conf.extra.args.name"), myExtraArgsTextField).addLabeledComponent(myHasTarget, myTarget.getMainPanel()).getPanel();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) ComboBox(com.intellij.openapi.ui.ComboBox) JBTextField(com.intellij.ui.components.JBTextField) NotNull(org.jetbrains.annotations.NotNull) JBCheckBox(com.intellij.ui.components.JBCheckBox) ReloadableComboBoxPanel(com.intellij.util.ui.ReloadableComboBoxPanel) EnvironmentVariablesTextFieldWithBrowseButton(com.intellij.execution.configuration.EnvironmentVariablesTextFieldWithBrowseButton) PhoneGapTargets(com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapTargets) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with JBTextField

use of com.intellij.ui.components.JBTextField in project intellij-community by JetBrains.

the class AbstractDescriptionAwareSchemesPanel method createInfoComponent.

@NotNull
@Override
protected JPanel createInfoComponent() {
    JPanel panel = new JPanel();
    myLayout = new CardLayout();
    panel.setLayout(myLayout);
    myDescriptionTextField = new JBTextField();
    myDescriptionTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            applyDescription();
        }
    });
    myDescriptionTextField.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            showDescription();
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(getConfigurableFocusComponent(), true);
            });
        }
    }, ESC_KEY_STROKE, JComponent.WHEN_FOCUSED);
    myDescriptionTextField.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            applyDescription();
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(getConfigurableFocusComponent(), true);
            });
        }
    }, ENTER_KEY_STROKE, JComponent.WHEN_FOCUSED);
    myDescriptionLabel = new DescriptionLabel();
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
            if (clickCount != 2) {
                return false;
            }
            editDescription(myDescriptionLabel.getText());
            return true;
        }
    }.installOn(myDescriptionLabel);
    myWarningLabel = new JLabel();
    panel.add(myDescriptionTextField, EDIT_DESCRIPTION_CARD);
    panel.add(myDescriptionLabel, SHOW_DESCRIPTION_CARD);
    panel.add(myWarningLabel, ERROR_CARD);
    myLayout.show(panel, ERROR_CARD);
    return panel;
}
Also used : JBTextField(com.intellij.ui.components.JBTextField) ClickListener(com.intellij.ui.ClickListener) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with JBTextField

use of com.intellij.ui.components.JBTextField in project intellij-community by JetBrains.

the class CopyFilesOrDirectoriesDialog method createNorthPanel.

@Override
protected JComponent createNorthPanel() {
    myInformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true);
    final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myInformationLabel).addVerticalGap(UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP);
    DocumentListener documentListener = new DocumentAdapter() {

        @Override
        public void textChanged(DocumentEvent event) {
            validateOKButton();
        }
    };
    if (myShowNewNameField) {
        myNewNameField = new JBTextField();
        myNewNameField.getDocument().addDocumentListener(documentListener);
        formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNewNameField);
    }
    if (myShowDirectoryField) {
        myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton();
        myTargetDirectoryField.setTextFieldPreferredWidth(MAX_PATH_LENGTH);
        final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS);
        if (recentEntries != null) {
            getTargetDirectoryComponent().setHistory(recentEntries);
        }
        final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
        myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("the.file.will.be.copied.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
        getTargetDirectoryComponent().addDocumentListener(new DocumentAdapter() {

            @Override
            protected void textChanged(DocumentEvent e) {
                validateOKButton();
            }
        });
        formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"), myTargetDirectoryField);
        String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));
        formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText));
    }
    final JPanel wrapper = new JPanel(new BorderLayout());
    wrapper.add(myOpenFilesInEditor, BorderLayout.EAST);
    formBuilder.addComponent(wrapper);
    return formBuilder.getPanel();
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) DocumentListener(javax.swing.event.DocumentListener) TextFieldWithHistoryWithBrowseButton(com.intellij.ui.TextFieldWithHistoryWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) JBTextField(com.intellij.ui.components.JBTextField) DocumentEvent(javax.swing.event.DocumentEvent)

Example 15 with JBTextField

use of com.intellij.ui.components.JBTextField in project android by JetBrains.

the class KeyValuePane method init.

public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) {
    GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2);
    setLayout(layout);
    GridConstraints constraints = new GridConstraints();
    constraints.setAnchor(GridConstraints.ANCHOR_WEST);
    constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    for (BuildFileKey property : properties) {
        constraints.setColumn(0);
        constraints.setFill(GridConstraints.FILL_NONE);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
        JBLabel label = new JBLabel(property.getDisplayName());
        add(label, constraints);
        constraints.setColumn(1);
        constraints.setFill(GridConstraints.FILL_HORIZONTAL);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW);
        JComponent component;
        switch(property.getType()) {
            case BOOLEAN:
                {
                    constraints.setFill(GridConstraints.FILL_NONE);
                    ComboBox comboBox = createComboBox(false);
                    comboBox.addItem("");
                    comboBox.addItem("true");
                    comboBox.addItem("false");
                    comboBox.setPrototypeDisplayValue("(false) ");
                    component = comboBox;
                    break;
                }
            case FILE:
            case FILE_AS_STRING:
                {
                    JBTextField textField = new JBTextField();
                    TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField);
                    FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false);
                    d.setShowFileSystemRoots(true);
                    fileField.addBrowseFolderListener(new TextBrowseFolderListener(d));
                    fileField.getTextField().getDocument().addDocumentListener(this);
                    component = fileField;
                    break;
                }
            case REFERENCE:
                {
                    constraints.setFill(GridConstraints.FILL_NONE);
                    ComboBox comboBox = createComboBox(true);
                    if (hasKnownValues(property)) {
                        for (String s : myKeysWithKnownValues.get(property).values()) {
                            comboBox.addItem(s);
                        }
                    }
                    // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference
                    // type wakes up and notifies us of its current values.
                    component = comboBox;
                    break;
                }
            case CLOSURE:
            case STRING:
            case INTEGER:
            default:
                {
                    if (hasKnownValues(property)) {
                        constraints.setFill(GridConstraints.FILL_NONE);
                        ComboBox comboBox = createComboBox(true);
                        for (String s : myKeysWithKnownValues.get(property).values()) {
                            comboBox.addItem(s);
                        }
                        component = comboBox;
                    } else {
                        JBTextField textField = new JBTextField();
                        textField.getDocument().addDocumentListener(this);
                        component = textField;
                    }
                    break;
                }
        }
        add(component, constraints);
        label.setLabelFor(component);
        myProperties.put(property, component);
        constraints.setRow(constraints.getRow() + 1);
    }
    constraints.setColumn(0);
    constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL);
    constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    add(new JBLabel(""), constraints);
    updateUiFromCurrentObject();
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) JBLabel(com.intellij.ui.components.JBLabel) ComboBox(com.intellij.openapi.ui.ComboBox) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) TextBrowseFolderListener(com.intellij.openapi.ui.TextBrowseFolderListener) JBTextField(com.intellij.ui.components.JBTextField) AndroidTargetHash.getAddonHashString(com.android.sdklib.AndroidTargetHash.getAddonHashString) BuildFileKey(com.android.tools.idea.gradle.parser.BuildFileKey)

Aggregations

JBTextField (com.intellij.ui.components.JBTextField)18 ComboBox (com.intellij.openapi.ui.ComboBox)6 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)5 JBLabel (com.intellij.ui.components.JBLabel)4 NotNull (org.jetbrains.annotations.NotNull)4 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)3 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)3 DocumentAdapter (com.intellij.ui.DocumentAdapter)3 JBCheckBox (com.intellij.ui.components.JBCheckBox)3 DocumentEvent (javax.swing.event.DocumentEvent)3 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)2 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)2 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)2 TabularLayout (com.android.tools.adtui.TabularLayout)1 BuildFileKeyType (com.android.tools.idea.gradle.parser.BuildFileKeyType)1 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 PhoneGapTargets (com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapTargets)1 EnvironmentVariablesTextFieldWithBrowseButton (com.intellij.execution.configuration.EnvironmentVariablesTextFieldWithBrowseButton)1 DependencyOnPlugin (com.intellij.externalDependencies.DependencyOnPlugin)1