Search in sources :

Example 6 with FixedSizeButton

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

the class PsiClassTableCellEditor method getTableCellEditorComponent.

public final Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    final Document document = JavaReferenceEditorUtil.createDocument(value == null ? "" : (String) value, myProject, true);
    myEditor = new EditorTextField(document, myProject, StdFileTypes.JAVA) {

        protected boolean shouldHaveBorder() {
            return false;
        }

        public void addNotify() {
            super.addNotify();
            final JComponent editorComponent = getEditor().getContentComponent();
            editorComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER");
            editorComponent.getActionMap().put("ENTER", new AbstractAction() {

                public void actionPerformed(ActionEvent e) {
                    stopCellEditing();
                }
            });
        }
    };
    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(myEditor);
    final FixedSizeButton button = new FixedSizeButton(myEditor);
    panel.add(button, BorderLayout.EAST);
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createInheritanceClassChooser(UIBundle.message("choose.class"), mySearchScope, null, true, true, Conditions.alwaysTrue());
            chooser.showDialog();
            final PsiClass psiClass = chooser.getSelected();
            if (psiClass != null) {
                myEditor.setText(psiClass.getQualifiedName());
            }
        }
    });
    panel.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            if (!e.isTemporary() && myEditor != null) {
                IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                    IdeFocusManager.getGlobalInstance().requestFocus(myEditor, true);
                });
            }
        }

        public void focusLost(FocusEvent e) {
        }
    });
    myEditor.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
        }

        public void focusLost(FocusEvent e) {
            if (!e.isTemporary()) {
                stopCellEditing();
            }
        }
    });
    return panel;
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) PsiClass(com.intellij.psi.PsiClass) Document(com.intellij.openapi.editor.Document) EditorTextField(com.intellij.ui.EditorTextField) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton)

Example 7 with FixedSizeButton

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

the class AbstractFieldPanel method createComponent.

public void createComponent() {
    removeAll();
    setLayout(new GridBagLayout());
    if (myLabelText != null) {
        myLabel = new JLabel(myLabelText);
        this.add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
        myLabel.setLabelFor(myComponent);
    }
    this.add(myComponent, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    if (myBrowseButtonActionListener != null) {
        FixedSizeButton browseButton = new FixedSizeButton(getComponent());
        myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(browseButton);
        browseButton.setFocusable(false);
        browseButton.addActionListener(myBrowseButtonActionListener);
        myButtons.add(browseButton);
        this.add(browseButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0));
    }
    if (myViewerDialogTitle != null) {
        final FixedSizeButton showViewerButton = new FixedSizeButton(getComponent());
        if (myBrowseButtonActionListener == null) {
            LOG.assertTrue(myDoClickAction == null);
            myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(showViewerButton);
        }
        showViewerButton.setFocusable(false);
        showViewerButton.setIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON);
        showViewerButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Viewer viewer = new Viewer();
                viewer.setTitle(myViewerDialogTitle);
                viewer.show();
            }
        });
        myButtons.add(showViewerButton);
        this.add(showViewerButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    }
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton)

Example 8 with FixedSizeButton

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

the class ExternalProjectPathField method createPanel.

@NotNull
public static MyPathAndProjectButtonPanel createPanel(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
    final EditorTextField textField = createTextField(project, externalSystemId);
    final FixedSizeButton selectRegisteredProjectButton = new FixedSizeButton();
    selectRegisteredProjectButton.setIcon(AllIcons.Actions.Module);
    String tooltipText = ExternalSystemBundle.message("run.configuration.tooltip.choose.registered.project", externalSystemId.getReadableName());
    selectRegisteredProjectButton.setToolTipText(tooltipText);
    selectRegisteredProjectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final Ref<JBPopup> popupRef = new Ref<>();
            final Tree tree = buildRegisteredProjectsTree(project, externalSystemId);
            tree.setBorder(IdeBorderFactory.createEmptyBorder(8));
            Runnable treeSelectionCallback = () -> {
                TreePath path = tree.getSelectionPath();
                if (path != null) {
                    Object lastPathComponent = path.getLastPathComponent();
                    if (lastPathComponent instanceof ExternalSystemNode) {
                        Object e1 = ((ExternalSystemNode) lastPathComponent).getDescriptor().getElement();
                        if (e1 instanceof ExternalProjectPojo) {
                            ExternalProjectPojo pojo = (ExternalProjectPojo) e1;
                            textField.setText(pojo.getPath());
                            Editor editor = textField.getEditor();
                            if (editor != null) {
                                collapseIfPossible(editor, externalSystemId, project);
                            }
                        }
                    }
                }
                popupRef.get().closeOk(null);
            };
            JBPopup popup = new PopupChooserBuilder(tree).setTitle(ExternalSystemBundle.message("run.configuration.title.choose.registered.project", externalSystemId.getReadableName())).setResizable(true).setItemChoosenCallback(treeSelectionCallback).setAutoselectOnMouseMove(true).setCloseOnEnter(false).createPopup();
            popupRef.set(popup);
            popup.showUnderneathOf(selectRegisteredProjectButton);
        }
    });
    return new MyPathAndProjectButtonPanel(textField, selectRegisteredProjectButton);
}
Also used : ActionEvent(java.awt.event.ActionEvent) ExternalSystemNode(com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemNode) Ref(com.intellij.openapi.util.Ref) ActionListener(java.awt.event.ActionListener) TreePath(javax.swing.tree.TreePath) EditorTextField(com.intellij.ui.EditorTextField) Tree(com.intellij.ui.treeStructure.Tree) ExternalSystemTasksTree(com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemTasksTree) Editor(com.intellij.openapi.editor.Editor) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder) JBPopup(com.intellij.openapi.ui.popup.JBPopup) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with FixedSizeButton

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

the class CommonProgramParametersPanel method createComponentWithMacroBrowse.

protected JComponent createComponentWithMacroBrowse(@NotNull final TextFieldWithBrowseButton textAccessor) {
    final FixedSizeButton button = new FixedSizeButton(textAccessor);
    button.setIcon(AllIcons.RunConfigurations.Variables);
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            List<String> macros = new SmartList<>(PathMacros.getInstance().getUserMacroNames());
            if (myModuleContext != null || myHasModuleMacro) {
                macros.add(PathMacroUtil.MODULE_DIR_MACRO_NAME);
            }
            final JList list = new JBList(ArrayUtil.toStringArray(macros));
            JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(() -> {
                final Object value = list.getSelectedValue();
                if (value instanceof String) {
                    textAccessor.setText('$' + ((String) value) + '$');
                }
            }).setMovable(false).setResizable(false).createPopup().showUnderneathOf(button);
        }
    });
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(textAccessor, BorderLayout.CENTER);
    panel.add(button, BorderLayout.EAST);
    return panel;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) SmartList(com.intellij.util.SmartList) JBList(com.intellij.ui.components.JBList) List(java.util.List) JBList(com.intellij.ui.components.JBList) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton)

Example 10 with FixedSizeButton

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

the class ArtifactEditorImpl method createUIComponents.

private void createUIComponents() {
    myShowContentCheckBox = new ThreeStateCheckBox();
    myShowSpecificContentOptionsButton = new FixedSizeButton(16);
}
Also used : ThreeStateCheckBox(com.intellij.util.ui.ThreeStateCheckBox) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton)

Aggregations

FixedSizeButton (com.intellij.openapi.ui.FixedSizeButton)18 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 ComboBox (com.intellij.openapi.ui.ComboBox)3 EditorTextField (com.intellij.ui.EditorTextField)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 JBScrollPane (com.intellij.ui.components.JBScrollPane)2 List (java.util.List)2 NotNull (org.jetbrains.annotations.NotNull)2 FileChooserDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.FileChooserDialogFixture)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 ExternalProjectPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)1 ExternalSystemNode (com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemNode)1 ExternalSystemTasksTree (com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemTasksTree)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1