Search in sources :

Example 46 with TextFieldWithBrowseButton

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

the class JsonSchemaMappingsView method createUI.

private void createUI(final Project project) {
    myProject = project;
    myTableView = new TableView<>();
    myTableView.getTableHeader().setVisible(false);
    myDecorator = ToolbarDecorator.createDecorator(myTableView);
    myDecorator.setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final int[] rows = myTableView.getSelectedRows();
            if (rows != null && rows.length > 0) {
                int cnt = 0;
                for (int row : rows) {
                    myTableView.getListTableModel().removeRow(row - cnt);
                    ++cnt;
                }
                myTableView.getListTableModel().fireTableDataChanged();
                myTreeUpdater.run();
            }
        }
    }).setAddAction(new MyAddActionButtonRunnable(project)).disableUpDownActions();
    mySchemaField = new TextFieldWithBrowseButton();
    SwingHelper.installFileCompletionAndBrowseDialog(myProject, mySchemaField, JsonBundle.message("json.schema.add.schema.chooser.title"), FileChooserDescriptorFactory.createSingleFileDescriptor());
    attachNavigateToSchema();
    myError = SwingHelper.createHtmlLabel("Warning: conflicting mappings. <a href=\"#\">Show details</a>", null, s -> {
        final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(myErrorText, UIUtil.getBalloonWarningIcon(), MessageType.WARNING.getPopupBackground(), null);
        builder.setDisposable(this);
        builder.setHideOnClickOutside(true);
        builder.setCloseButtonEnabled(true);
        builder.createBalloon().showInCenterOf(myError);
    });
    final FormBuilder builder = FormBuilder.createFormBuilder();
    final JBLabel label = new JBLabel("JSON schema file:");
    builder.addLabeledComponent(label, mySchemaField);
    label.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
    mySchemaField.setBorder(JBUI.Borders.empty(0, 0, 0, 10));
    final JPanel wrapper = new JPanel(new BorderLayout());
    wrapper.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
    myErrorIcon = new JBLabel(UIUtil.getBalloonWarningIcon());
    wrapper.add(myErrorIcon, BorderLayout.WEST);
    wrapper.add(myError, BorderLayout.CENTER);
    builder.addComponent(wrapper);
    builder.addComponentFillVertically(myDecorator.createPanel(), 5);
    myComponent = builder.getPanel();
}
Also used : FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) Getter(com.intellij.openapi.util.Getter) MessageType(com.intellij.openapi.ui.MessageType) ActionListener(java.awt.event.ActionListener) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModalityState(com.intellij.openapi.application.ModalityState) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBLabel(com.intellij.ui.components.JBLabel) ArrayList(java.util.ArrayList) Balloon(com.intellij.openapi.ui.popup.Balloon) JBTextField(com.intellij.ui.components.JBTextField) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Disposer(com.intellij.openapi.util.Disposer) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) Project(com.intellij.openapi.project.Project) FileUtil(com.intellij.openapi.util.io.FileUtil) AnActionButton(com.intellij.ui.AnActionButton) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) JsonBundle(com.intellij.json.JsonBundle) StringUtil(com.intellij.openapi.util.text.StringUtil) TableView(com.intellij.ui.table.TableView) JBRadioButton(com.intellij.ui.components.JBRadioButton) ActionEvent(java.awt.event.ActionEvent) Disposable(com.intellij.openapi.Disposable) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) Nullable(org.jetbrains.annotations.Nullable) CommonShortcuts(com.intellij.openapi.actionSystem.CommonShortcuts) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) com.intellij.util.ui(com.intellij.util.ui) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) JBPanel(com.intellij.ui.components.JBPanel) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) Alarm(com.intellij.util.Alarm) javax.swing(javax.swing) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) JBLabel(com.intellij.ui.components.JBLabel) AnActionButton(com.intellij.ui.AnActionButton) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder)

Example 47 with TextFieldWithBrowseButton

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

the class ChoosePathDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setGap(3);
    JPanel panel = new JPanel(verticalLayout);
    if (description != null) {
        panel.add(new JLabel(description));
    }
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    FileTextField field = FileChooserFactory.getInstance().createFileTextField(descriptor, myDisposable);
    field.getField().setColumns(25);
    myPathField = new TextFieldWithBrowseButton(field.getField());
    myPathField.addBrowseFolderListener("Choose Destination Folder", "Choose folder", myProject, descriptor);
    myPathField.setText(defaultPath);
    panel.add(myPathField);
    return panel;
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) VerticalLayout(org.jdesktop.swingx.VerticalLayout) FileTextField(com.intellij.openapi.fileChooser.FileTextField)

Example 48 with TextFieldWithBrowseButton

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

the class MapExternalResourceDialog method createUIComponents.

private void createUIComponents() {
    FileTextField field = FileChooserFactory.getInstance().createFileTextField(FILE_CHOOSER_DESCRIPTOR, getDisposable());
    myFileTextField = new TextFieldWithBrowseButton(field.getField());
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileTextField(com.intellij.openapi.fileChooser.FileTextField)

Example 49 with TextFieldWithBrowseButton

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

the class AbstractCreateVirtualEnvDialog method setupDialog.

void setupDialog(Project project, final List<Sdk> allSdks) {
    myProject = project;
    final GridBagLayout layout = new GridBagLayout();
    myMainPanel = new JPanel(layout);
    myName = new JTextField();
    myDestination = new TextFieldWithBrowseButton();
    myMakeAvailableToAllProjectsCheckbox = new JBCheckBox(PyBundle.message("sdk.create.venv.dialog.make.available.to.all.projects"));
    if (project == null || project.isDefault() || !PlatformUtils.isPyCharm()) {
        myMakeAvailableToAllProjectsCheckbox.setSelected(true);
        myMakeAvailableToAllProjectsCheckbox.setVisible(false);
    }
    layoutPanel(allSdks);
    init();
    setOKActionEnabled(false);
    registerValidators(new FacetValidatorsManager() {

        public void registerValidator(FacetEditorValidator validator, JComponent... componentsToWatch) {
        }

        public void validate() {
            checkValid();
        }
    });
    myMainPanel.setPreferredSize(new Dimension(300, 50));
    checkValid();
    setInitialDestination();
    addUpdater(myName);
    new LocationNameFieldsBinding(project, myDestination, myName, myInitialPath, PyBundle.message("sdk.create.venv.dialog.select.venv.location"));
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FacetValidatorsManager(com.intellij.facet.ui.FacetValidatorsManager) LocationNameFieldsBinding(com.intellij.platform.LocationNameFieldsBinding) FacetEditorValidator(com.intellij.facet.ui.FacetEditorValidator) JBCheckBox(com.intellij.ui.components.JBCheckBox)

Example 50 with TextFieldWithBrowseButton

use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project azure-tools-for-java by Microsoft.

the class SparkSubmissionContentPanel method addMainClassNameLineItem.

private void addMainClassNameLineItem() {
    JLabel sparkMainClassLabel = new JLabel("Main class name");
    sparkMainClassLabel.setToolTipText("Application's java/spark main class");
    GridBagConstraints c31 = new GridBagConstraints();
    c31.gridx = 0;
    c31.gridy = 2;
    c31.insets = new Insets(margin, margin, margin, margin);
    add(sparkMainClassLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0));
    mainClassTextField = new TextFieldWithBrowseButton();
    mainClassTextField.setToolTipText("Application's java/spark main class");
    ManifestFileUtil.setupMainClassField(submitModel.getProject(), mainClassTextField);
    add(mainClassTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));
    errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()] = new JLabel("Main Class Name should not be null");
    errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()].setVisible(true);
    mainClassTextField.getTextField().getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(3, e.getDocument().getLength() == 0);
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(3, e.getDocument().getLength() == 0);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
        }
    });
    add(errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, margin, 0, margin), 0, 0));
}
Also used : DocumentListener(javax.swing.event.DocumentListener) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)51 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)20 NotNull (org.jetbrains.annotations.NotNull)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 ActionEvent (java.awt.event.ActionEvent)9 ActionListener (java.awt.event.ActionListener)8 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 JBLabel (com.intellij.ui.components.JBLabel)4 DocumentListener (javax.swing.event.DocumentListener)4 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)3 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)3 JBCheckBox (com.intellij.ui.components.JBCheckBox)3 ValidationResult (com.android.tools.idea.sdk.SdkPaths.ValidationResult)2 Disposable (com.intellij.openapi.Disposable)2 FileChooser.chooseFile (com.intellij.openapi.fileChooser.FileChooser.chooseFile)2