Search in sources :

Example 61 with ChangeEvent

use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.

the class ToolEditorDialog method addListeners.

private void addListeners() {
    myOutputFiltersButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            OutputFiltersDialog dialog = new OutputFiltersDialog(myOutputFiltersButton, getData().getOutputFilters());
            if (dialog.showAndGet()) {
                myOutputFilters = dialog.getData();
            }
        }
    });
    myInsertCommandMacroButton.addActionListener(new InsertMacroActionListener(myTfCommand));
    myInsertParametersMacroButton.addActionListener(new InsertMacroActionListener(myParametersField));
    myInsertWorkingDirectoryMacroButton.addActionListener(new InsertMacroActionListener(myTfCommandWorkingDirectory));
    myNameField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        public void textChanged(DocumentEvent event) {
            handleOKButton();
        }
    });
    myUseConsoleCheckbox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            myShowConsoleOnStdOutCheckbox.setVisible(myUseConsoleCheckbox.isSelected());
            myShowConsoleOnStdErrCheckbox.setVisible(myUseConsoleCheckbox.isSelected());
        }
    });
}
Also used : ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) ChangeListener(javax.swing.event.ChangeListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 62 with ChangeEvent

use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.

the class ComboBoxVisibilityPanel method setVisibility.

@Override
public void setVisibility(V visibility) {
    myComboBox.setSelectedItem(visibility);
    myEventDispatcher.getMulticaster().stateChanged(new ChangeEvent(this));
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent)

Example 63 with ChangeEvent

use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.

the class AllFileTemplatesConfigurable method createComponent.

@Override
public JComponent createComponent() {
    myUIDisposable = Disposer.newDisposable();
    myTemplatesList = new FileTemplateTabAsList(TEMPLATES_TITLE) {

        @Override
        public void onTemplateSelected() {
            onListSelectionChanged();
        }
    };
    myIncludesList = new FileTemplateTabAsList(INCLUDES_TITLE) {

        @Override
        public void onTemplateSelected() {
            onListSelectionChanged();
        }
    };
    myCodeTemplatesList = new FileTemplateTabAsList(CODE_TITLE) {

        @Override
        public void onTemplateSelected() {
            onListSelectionChanged();
        }
    };
    myCurrentTab = myTemplatesList;
    final List<FileTemplateTab> allTabs = new ArrayList<>(Arrays.asList(myTemplatesList, myIncludesList, myCodeTemplatesList));
    final FileTemplateGroupDescriptorFactory[] factories = Extensions.getExtensions(FileTemplateGroupDescriptorFactory.EXTENSION_POINT_NAME);
    if (factories.length != 0) {
        myOtherTemplatesList = new FileTemplateTabAsTree(OTHER_TITLE) {

            @Override
            public void onTemplateSelected() {
                onListSelectionChanged();
            }

            @Override
            protected FileTemplateNode initModel() {
                SortedSet<FileTemplateGroupDescriptor> categories = new TreeSet<>((o1, o2) -> o1.getTitle().compareTo(o2.getTitle()));
                for (FileTemplateGroupDescriptorFactory templateGroupFactory : factories) {
                    ContainerUtil.addIfNotNull(categories, templateGroupFactory.getFileTemplatesDescriptor());
                }
                //noinspection HardCodedStringLiteral
                return new FileTemplateNode("ROOT", null, ContainerUtil.map2List(categories, s -> new FileTemplateNode(s)));
            }
        };
        allTabs.add(myOtherTemplatesList);
    }
    myEditor = new FileTemplateConfigurable(myProject);
    myEditor.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            onEditorChanged();
        }
    });
    myEditorComponent = myEditor.createComponent();
    myEditorComponent.setBorder(JBUI.Borders.empty(10, 0, 10, 10));
    myTabs = allTabs.toArray(new FileTemplateTab[allTabs.size()]);
    myTabbedPane = new TabbedPaneWrapper(myUIDisposable);
    myTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    myLeftPanel = new JPanel(new CardLayout());
    myLeftPanel.setBorder(JBUI.Borders.empty(10, 10, 10, 0));
    for (FileTemplateTab tab : myTabs) {
        myLeftPanel.add(ScrollPaneFactory.createScrollPane(tab.getComponent()), tab.getTitle());
        JPanel fakePanel = new JPanel();
        fakePanel.setPreferredSize(new Dimension(0, 0));
        myTabbedPane.addTab(tab.getTitle(), fakePanel);
    }
    myTabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            onTabChanged();
        }
    });
    DefaultActionGroup group = new DefaultActionGroup();
    AnAction removeAction = new AnAction(IdeBundle.message("action.remove.template"), null, AllIcons.General.Remove) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onRemove();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
            e.getPresentation().setEnabled(selectedItem != null && !isInternalTemplate(selectedItem.getName(), myCurrentTab.getTitle()));
        }
    };
    AnAction addAction = new AnAction(IdeBundle.message("action.create.template"), null, AllIcons.General.Add) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onAdd();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            e.getPresentation().setEnabled(!(myCurrentTab == myCodeTemplatesList || myCurrentTab == myOtherTemplatesList));
        }
    };
    AnAction cloneAction = new AnAction(IdeBundle.message("action.copy.template"), null, PlatformIcons.COPY_ICON) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onClone();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            e.getPresentation().setEnabled(myCurrentTab != myCodeTemplatesList && myCurrentTab != myOtherTemplatesList && myCurrentTab.getSelectedTemplate() != null);
        }
    };
    AnAction resetAction = new AnAction(IdeBundle.message("action.reset.to.default"), null, AllIcons.Actions.Reset) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onReset();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            final FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
            e.getPresentation().setEnabled(selectedItem instanceof BundledFileTemplate && !selectedItem.isDefault());
        }
    };
    group.add(addAction);
    group.add(removeAction);
    group.add(cloneAction);
    group.add(resetAction);
    addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myCurrentTab.getComponent());
    removeAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), myCurrentTab.getComponent());
    myToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
    myToolBar.setBorder(IdeBorderFactory.createEmptyBorder());
    JPanel toolbarPanel = new JPanel(new BorderLayout());
    toolbarPanel.add(myToolBar, BorderLayout.WEST);
    JComponent schemaComponent = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultCompactActionGroup(new ChangeSchemaCombo(this)), true).getComponent();
    JPanel schemaPanel = new JPanel(new BorderLayout());
    schemaPanel.add(schemaComponent, BorderLayout.EAST);
    schemaPanel.add(new JLabel("Schema:"), BorderLayout.WEST);
    toolbarPanel.add(schemaPanel, BorderLayout.EAST);
    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.add(myTabbedPane.getComponent(), BorderLayout.NORTH);
    Splitter splitter = new Splitter(false, 0.3f);
    splitter.setDividerWidth(JBUI.scale(10));
    splitter.setFirstComponent(myLeftPanel);
    splitter.setSecondComponent(myEditorComponent);
    centerPanel.add(splitter, BorderLayout.CENTER);
    myMainPanel = new JPanel(new BorderLayout());
    myMainPanel.add(toolbarPanel, BorderLayout.NORTH);
    myMainPanel.add(centerPanel, BorderLayout.CENTER);
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    final String tabName = propertiesComponent.getValue(CURRENT_TAB);
    if (selectTab(tabName)) {
    //final String selectedTemplateName = propertiesComponent.getValue(SELECTED_TEMPLATE);
    //for (FileTemplate template : myCurrentTab.getTemplates()) {
    //  if (Comparing.strEqual(template.getName(), selectedTemplateName)) {
    //    myCurrentTab.selectTemplate(template);
    //    break;
    //  }
    //}
    }
    return myMainPanel;
}
Also used : java.util(java.util) AllIcons(com.intellij.icons.AllIcons) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) ArrayUtil(com.intellij.util.ArrayUtil) URL(java.net.URL) com.intellij.ide.fileTemplates(com.intellij.ide.fileTemplates) ContainerUtil(com.intellij.util.containers.ContainerUtil) MessageFormat(java.text.MessageFormat) Comparing(com.intellij.openapi.util.Comparing) JBUI(com.intellij.util.ui.JBUI) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) ChangeListener(javax.swing.event.ChangeListener) Logger(com.intellij.openapi.diagnostic.Logger) Splitter(com.intellij.openapi.ui.Splitter) PlatformIcons(com.intellij.util.PlatformIcons) ChangeEvent(javax.swing.event.ChangeEvent) Extensions(com.intellij.openapi.extensions.Extensions) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) FileTemplateManager(com.intellij.ide.fileTemplates.FileTemplateManager) Configurable(com.intellij.openapi.options.Configurable) Disposable(com.intellij.openapi.Disposable) TestOnly(org.jetbrains.annotations.TestOnly) java.awt(java.awt) IdeBundle(com.intellij.ide.IdeBundle) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) ScrollPaneFactory(com.intellij.ui.ScrollPaneFactory) javax.swing(javax.swing) ChangeListener(javax.swing.event.ChangeListener) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) Splitter(com.intellij.openapi.ui.Splitter) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) ChangeEvent(javax.swing.event.ChangeEvent)

Example 64 with ChangeEvent

use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.

the class ChangeSignatureDialogBase method createParametersPanel.

protected JPanel createParametersPanel(boolean hasTabsInDialog) {
    myParametersTable = new TableView<ParameterTableModelItem>(myParametersTableModel) {

        @Override
        public void removeEditor() {
            clearEditorListeners();
            super.removeEditor();
        }

        @Override
        public void editingStopped(ChangeEvent e) {
            super.editingStopped(e);
            // to update disabled cells background
            repaint();
        }

        private void clearEditorListeners() {
            final TableCellEditor editor = getCellEditor();
            if (editor instanceof StringTableCellEditor) {
                final StringTableCellEditor ed = (StringTableCellEditor) editor;
                ed.clearListeners();
            } else if (editor instanceof CodeFragmentTableCellEditorBase) {
                ((CodeFragmentTableCellEditorBase) editor).clearListeners();
            }
        }

        @Override
        public Component prepareEditor(final TableCellEditor editor, final int row, final int column) {
            final DocumentAdapter listener = new DocumentAdapter() {

                @Override
                public void documentChanged(DocumentEvent e) {
                    final TableCellEditor ed = myParametersTable.getCellEditor();
                    if (ed != null) {
                        Object editorValue = ed.getCellEditorValue();
                        myParametersTableModel.setValueAtWithoutUpdate(editorValue, row, column);
                        updateSignature();
                    }
                }
            };
            if (editor instanceof StringTableCellEditor) {
                final StringTableCellEditor ed = (StringTableCellEditor) editor;
                ed.addDocumentListener(listener);
            } else if (editor instanceof CodeFragmentTableCellEditorBase) {
                ((CodeFragmentTableCellEditorBase) editor).addDocumentListener(listener);
            }
            return super.prepareEditor(editor, row, column);
        }

        @Override
        public void editingCanceled(ChangeEvent e) {
            super.editingCanceled(e);
        }
    };
    myParametersTable.setCellSelectionEnabled(true);
    myParametersTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myParametersTable.getSelectionModel().setSelectionInterval(0, 0);
    myParametersTable.setSurrendersFocusOnKeystroke(true);
    myPropagateParamChangesButton.setShortcut(CustomShortcutSet.fromString("alt G"));
    if (isListTableViewSupported()) {
        myParametersList = createParametersListTable();
        final JPanel buttonsPanel = ToolbarDecorator.createDecorator(myParametersList.getTable()).addExtraAction(myPropagateParamChangesButton).createPanel();
        myParametersList.getTable().getModel().addTableModelListener(mySignatureUpdater);
        return buttonsPanel;
    } else {
        final JPanel buttonsPanel = ToolbarDecorator.createDecorator(getTableComponent()).addExtraAction(myPropagateParamChangesButton).createPanel();
        myPropagateParamChangesButton.setEnabled(false);
        myPropagateParamChangesButton.setVisible(false);
        myParametersTable.setStriped(true);
        myParametersTableModel.addTableModelListener(mySignatureUpdater);
        customizeParametersTable(myParametersTable);
        return buttonsPanel;
    }
}
Also used : DocumentAdapter(com.intellij.openapi.editor.event.DocumentAdapter) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) ChangeEvent(javax.swing.event.ChangeEvent) TableCellEditor(javax.swing.table.TableCellEditor)

Example 65 with ChangeEvent

use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.

the class DocumentationComponent method createSettingsPanel.

private JComponent createSettingsPanel() {
    JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    result.add(new JLabel(ApplicationBundle.message("label.font.size")));
    myFontSizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, FontSize.values().length - 1, 3);
    myFontSizeSlider.setMinorTickSpacing(1);
    myFontSizeSlider.setPaintTicks(true);
    myFontSizeSlider.setPaintTrack(true);
    myFontSizeSlider.setSnapToTicks(true);
    UIUtil.setSliderIsFilled(myFontSizeSlider, true);
    result.add(myFontSizeSlider);
    result.setBorder(BorderFactory.createLineBorder(JBColor.border(), 1));
    myFontSizeSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (myIgnoreFontSizeSliderChange) {
                return;
            }
            setQuickDocFontSize(FontSize.values()[myFontSizeSlider.getValue()]);
            applyFontSize();
        }
    });
    String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel");
    result.setToolTipText(tooltipText);
    myFontSizeSlider.setToolTipText(tooltipText);
    result.setVisible(false);
    result.setOpaque(true);
    myFontSizeSlider.setOpaque(true);
    return result;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

ChangeEvent (javax.swing.event.ChangeEvent)245 ChangeListener (javax.swing.event.ChangeListener)206 JPanel (javax.swing.JPanel)60 ActionEvent (java.awt.event.ActionEvent)52 ActionListener (java.awt.event.ActionListener)47 JLabel (javax.swing.JLabel)40 Dimension (java.awt.Dimension)30 GridBagConstraints (java.awt.GridBagConstraints)27 GridBagLayout (java.awt.GridBagLayout)24 JCheckBox (javax.swing.JCheckBox)24 Insets (java.awt.Insets)22 JButton (javax.swing.JButton)21 JSlider (javax.swing.JSlider)21 PropertyChangeEvent (java.beans.PropertyChangeEvent)20 JSpinner (javax.swing.JSpinner)19 SpinnerNumberModel (javax.swing.SpinnerNumberModel)19 BorderLayout (java.awt.BorderLayout)18 PropertyChangeListener (java.beans.PropertyChangeListener)17 IOException (java.io.IOException)16 BoxLayout (javax.swing.BoxLayout)16