Search in sources :

Example 16 with ListSelectionEvent

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

the class PythonSdkDetailsDialog method addListeners.

private void addListeners() {
    myListener = new SdkModel.Listener() {

        @Override
        public void sdkAdded(Sdk sdk) {
        }

        @Override
        public void beforeSdkRemove(Sdk sdk) {
        }

        @Override
        public void sdkChanged(Sdk sdk, String previousName) {
            refreshSdkList();
        }

        @Override
        public void sdkHomeSelected(Sdk sdk, String newSdkHome) {
        }
    };
    myProjectSdksModel.addListener(myListener);
    mySdkList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent event) {
            updateOkButton();
        }
    });
}
Also used : SdkModel(com.intellij.openapi.projectRoots.SdkModel) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Sdk(com.intellij.openapi.projectRoots.Sdk) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 17 with ListSelectionEvent

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

the class AbstractTableView method setToolbarActions.

public final void setToolbarActions(final AnAction... actions) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    for (final AnAction action : actions) {
        actionGroup.add(action);
    }
    if (getHelpId() != null) {
        actionGroup.add(Separator.getInstance());
        actionGroup.add(new ContextHelpAction(getHelpId()));
    }
    final ActionManager actionManager = ActionManager.getInstance();
    final ToolbarPosition position = getToolbarPosition();
    final ActionToolbar myActionToolbar = actionManager.createActionToolbar(ActionPlaces.PROJECT_VIEW_TOOLBAR, actionGroup, position == ToolbarPosition.TOP || position == ToolbarPosition.BOTTOM);
    myActionToolbar.setTargetComponent(myInnerPanel);
    final JComponent toolbarComponent = myActionToolbar.getComponent();
    final MatteBorder matteBorder = BorderFactory.createMatteBorder(0, 0, position == ToolbarPosition.TOP ? 1 : 0, 0, JBColor.DARK_GRAY);
    toolbarComponent.setBorder(BorderFactory.createCompoundBorder(matteBorder, toolbarComponent.getBorder()));
    getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            myActionToolbar.updateActionsImmediately();
        }
    });
    add(toolbarComponent, position.getPosition());
}
Also used : MatteBorder(javax.swing.border.MatteBorder) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ContextHelpAction(com.intellij.ide.actions.ContextHelpAction) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 18 with ListSelectionEvent

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

the class ToBeMergedDialog method initUI.

private void initUI() {
    final ListSelectionListener selectionListener = e -> {
        List<SvnChangeList> changeLists = myRevisionsList.getSelectedObjects();
        myAlreadyMerged.clear();
        for (SvnChangeList changeList : changeLists) {
            myAlreadyMerged.addAll(getAlreadyMergedPaths(changeList));
        }
        myRepositoryChangesBrowser.setChangesToDisplay(collectChanges(changeLists, false));
        mySplitter.doLayout();
        myRepositoryChangesBrowser.repaint();
    };
    final MyListCellRenderer listCellRenderer = new MyListCellRenderer();
    myRevisionsList = new TableView<SvnChangeList>() {

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            return listCellRenderer;
        }

        @Override
        public void valueChanged(ListSelectionEvent e) {
            super.valueChanged(e);
            selectionListener.valueChanged(e);
        }
    };
    myRevisionsList.setExpandableItemsEnabled(false);
    new TableViewSpeedSearch<SvnChangeList>(myRevisionsList) {

        @Override
        protected String getItemText(@NotNull SvnChangeList element) {
            return element.getComment();
        }
    };
    myRevisionsList.setModelAndUpdateColumns(myRevisionsModel);
    myRevisionsList.setTableHeader(null);
    myRevisionsList.setShowGrid(false);
    final AbstractBaseTagMouseListener mouseListener = new AbstractBaseTagMouseListener() {

        @Override
        public Object getTagAt(@NotNull MouseEvent e) {
            JTable table = (JTable) e.getSource();
            int row = table.rowAtPoint(e.getPoint());
            int column = table.columnAtPoint(e.getPoint());
            if (row == -1 || column == -1)
                return null;
            listCellRenderer.customizeCellRenderer(table, table.getValueAt(row, column), table.isRowSelected(row));
            return listCellRenderer.myRenderer.getFragmentTagAt(e.getPoint().x - table.getCellRect(row, column, false).x);
        }
    };
    mouseListener.installOn(myRevisionsList);
    myMore100Action = new MoreXAction(100);
    myMore500Action = new MoreXAction(500);
    BorderLayoutPanel panel = JBUI.Panels.simplePanel().addToCenter(ScrollPaneFactory.createScrollPane(myRevisionsList)).addToTop(createToolbar().getComponent());
    mySplitter = new Splitter(false, 0.7f);
    mySplitter.setFirstComponent(panel);
    myRepositoryChangesBrowser = new RepositoryChangesBrowser(myMergeContext.getProject(), Collections.<SvnChangeList>emptyList(), emptyList(), null);
    myRepositoryChangesBrowser.getDiffAction().registerCustomShortcutSet(myRepositoryChangesBrowser.getDiffAction().getShortcutSet(), myRevisionsList);
    setChangesDecorator();
    mySplitter.setSecondComponent(myRepositoryChangesBrowser);
    mySplitter.setDividerWidth(2);
    addRevisionListListeners();
    myPanel.add(mySplitter, BorderLayout.CENTER);
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) AllIcons(com.intellij.icons.AllIcons) MessageType(com.intellij.openapi.ui.MessageType) CommittedChangesTreeBrowser.collectChanges(com.intellij.openapi.vcs.changes.committed.CommittedChangesTreeBrowser.collectChanges) Change(com.intellij.openapi.vcs.changes.Change) MergeChecker(org.jetbrains.idea.svn.mergeinfo.MergeChecker) ColumnInfo(com.intellij.util.ui.ColumnInfo) MergeCalculatorTask.getBunchSize(org.jetbrains.idea.svn.integrate.MergeCalculatorTask.getBunchSize) TableCellRenderer(javax.swing.table.TableCellRenderer) Collections.singletonList(java.util.Collections.singletonList) Task(com.intellij.openapi.progress.Task) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) JBUI(com.intellij.util.ui.JBUI) Collections.synchronizedMap(java.util.Collections.synchronizedMap) CommittedChangeListRenderer(com.intellij.openapi.vcs.changes.committed.CommittedChangeListRenderer) VcsException(com.intellij.openapi.vcs.VcsException) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ContainerUtilRt.newHashSet(com.intellij.util.containers.ContainerUtilRt.newHashSet) TableView(com.intellij.ui.table.TableView) KeyEvent(java.awt.event.KeyEvent) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) AbstractBaseTagMouseListener(com.intellij.openapi.vcs.changes.issueLinks.AbstractBaseTagMouseListener) java.util(java.util) KeyAdapter(java.awt.event.KeyAdapter) ContainerUtil(com.intellij.util.containers.ContainerUtil) MergeCalculatorTask.loadChangeLists(org.jetbrains.idea.svn.integrate.MergeCalculatorTask.loadChangeLists) SvnMergeInfoCache(org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) ListTableModel(com.intellij.util.ui.ListTableModel) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList) Splitter(com.intellij.openapi.ui.Splitter) ListMergeStatus(org.jetbrains.idea.svn.mergeinfo.ListMergeStatus) ChangeNodeDecorator(com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator) PopupUtil(com.intellij.openapi.ui.popup.util.PopupUtil) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) ChangesBrowserNodeRenderer(com.intellij.openapi.vcs.changes.ui.ChangesBrowserNodeRenderer) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) RepositoryChangesBrowser(com.intellij.openapi.vcs.changes.committed.RepositoryChangesBrowser) Pair(com.intellij.openapi.util.Pair) ObjectUtils(com.intellij.util.ObjectUtils) ListSelectionListener(javax.swing.event.ListSelectionListener) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) TableCellRenderer(javax.swing.table.TableCellRenderer) MouseEvent(java.awt.event.MouseEvent) Splitter(com.intellij.openapi.ui.Splitter) RepositoryChangesBrowser(com.intellij.openapi.vcs.changes.committed.RepositoryChangesBrowser) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) ListSelectionEvent(javax.swing.event.ListSelectionEvent) NotNull(org.jetbrains.annotations.NotNull) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) ListSelectionListener(javax.swing.event.ListSelectionListener) AbstractBaseTagMouseListener(com.intellij.openapi.vcs.changes.issueLinks.AbstractBaseTagMouseListener) Collections.singletonList(java.util.Collections.singletonList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList)

Example 19 with ListSelectionEvent

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

the class CreateResourceBundleDialogComponent method createUIComponents.

@SuppressWarnings("unchecked")
private void createUIComponents() {
    final JBList projectExistLocalesList = new JBList();
    final MyExistLocalesListModel existLocalesListModel = new MyExistLocalesListModel();
    projectExistLocalesList.setModel(existLocalesListModel);
    projectExistLocalesList.setCellRenderer(getLocaleRenderer());
    myProjectExistLocalesPanel = ToolbarDecorator.createDecorator(projectExistLocalesList).disableRemoveAction().disableUpDownActions().createPanel();
    myProjectExistLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder("Project locales", false));
    final JBList localesToAddList = new JBList();
    final List<Locale> locales;
    final List<Locale> restrictedLocales;
    if (myResourceBundle == null) {
        locales = Collections.singletonList(PropertiesUtil.DEFAULT_LOCALE);
        restrictedLocales = Collections.emptyList();
    } else {
        locales = Collections.emptyList();
        restrictedLocales = ContainerUtil.map(myResourceBundle.getPropertiesFiles(), PropertiesFile::getLocale);
    }
    myLocalesModel = new CollectionListModel<Locale>(locales) {

        @Override
        public void add(@NotNull List<? extends Locale> elements) {
            final List<Locale> currentItems = getItems();
            elements = ContainerUtil.filter(elements, locale -> !restrictedLocales.contains(locale) && !currentItems.contains(locale));
            super.add(elements);
        }
    };
    localesToAddList.setModel(myLocalesModel);
    localesToAddList.setCellRenderer(getLocaleRenderer());
    localesToAddList.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            projectExistLocalesList.clearSelection();
        }
    });
    projectExistLocalesList.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            localesToAddList.clearSelection();
        }
    });
    myNewBundleLocalesPanel = ToolbarDecorator.createDecorator(localesToAddList).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final String rawAddedLocales = Messages.showInputDialog(myProject, PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.message"), PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.title"), null, null, new InputValidatorEx() {

                @Nullable
                @Override
                public String getErrorText(String inputString) {
                    return checkInput(inputString) ? null : "Invalid locales";
                }

                @Override
                public boolean checkInput(String inputString) {
                    return extractLocalesFromString(inputString) != null;
                }

                @Override
                public boolean canClose(String inputString) {
                    return checkInput(inputString);
                }
            });
            if (rawAddedLocales != null) {
                final List<Locale> locales = extractLocalesFromString(rawAddedLocales);
                LOG.assertTrue(locales != null);
                myLocalesModel.add(locales);
            }
        }
    }).setAddActionName("Add locales by suffix").disableUpDownActions().createPanel();
    myNewBundleLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder("Locales to add", false));
    myAddLocaleFromExistButton = new JButton(AllIcons.Actions.Forward);
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
            if (clickCount == 1) {
                myLocalesModel.add(ContainerUtil.map(projectExistLocalesList.getSelectedValues(), o -> (Locale) o));
                return true;
            }
            return false;
        }
    }.installOn(myAddLocaleFromExistButton);
    projectExistLocalesList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            final List<Locale> currentItems = myLocalesModel.getItems();
            for (Object o : projectExistLocalesList.getSelectedValues()) {
                Locale l = (Locale) o;
                if (!restrictedLocales.contains(l) && !currentItems.contains(l)) {
                    myAddLocaleFromExistButton.setEnabled(true);
                    return;
                }
            }
            myAddLocaleFromExistButton.setEnabled(false);
        }
    });
    myAddLocaleFromExistButton.setEnabled(false);
    myAddAllButton = new JButton("Add All");
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
            if (clickCount == 1) {
                myLocalesModel.add(existLocalesListModel.getLocales());
            }
            return false;
        }
    }.installOn(myAddAllButton);
}
Also used : ListSelectionEvent(javax.swing.event.ListSelectionEvent) InputValidatorEx(com.intellij.openapi.ui.InputValidatorEx) ListSelectionListener(javax.swing.event.ListSelectionListener) JBList(com.intellij.ui.components.JBList) JBList(com.intellij.ui.components.JBList)

Example 20 with ListSelectionEvent

use of javax.swing.event.ListSelectionEvent in project zaproxy by zaproxy.

the class SearchPanel method initialize.

/**
	 * This method initializes this
	 */
private void initialize() {
    resultsModel = new SearchResultsTableModel();
    resultsTable = new SearchResultsTable(resultsModel);
    resultsTable.setName(HTTP_MESSAGE_CONTAINER_NAME);
    resultsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                SearchResult searchResult = resultsTable.getSelectedSearchResult();
                if (searchResult == null) {
                    return;
                }
                displayMessage(resultsTable.getSelectedSearchResult());
                // Get the focus back so that the arrow keys work
                resultsTable.requestFocusInWindow();
            }
        }
    });
    this.setLayout(new CardLayout());
    //this.setSize(474, 251);
    this.setName(Constant.messages.getString("search.panel.title"));
    // 'magnifying glass' icon
    this.setIcon(new ImageIcon(SearchPanel.class.getResource("/resource/icon/16/049.png")));
    this.add(getPanelCommand(), getPanelCommand().getName());
    this.setShowByDefault(true);
}
Also used : CardLayout(java.awt.CardLayout) ImageIcon(javax.swing.ImageIcon) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener)

Aggregations

ListSelectionEvent (javax.swing.event.ListSelectionEvent)129 ListSelectionListener (javax.swing.event.ListSelectionListener)120 ActionEvent (java.awt.event.ActionEvent)35 JScrollPane (javax.swing.JScrollPane)32 ActionListener (java.awt.event.ActionListener)29 JPanel (javax.swing.JPanel)28 MouseEvent (java.awt.event.MouseEvent)25 BorderLayout (java.awt.BorderLayout)21 JButton (javax.swing.JButton)20 Dimension (java.awt.Dimension)18 JLabel (javax.swing.JLabel)18 JBList (com.intellij.ui.components.JBList)16 MouseAdapter (java.awt.event.MouseAdapter)15 FlowLayout (java.awt.FlowLayout)11 Insets (java.awt.Insets)11 JList (javax.swing.JList)11 NotNull (org.jetbrains.annotations.NotNull)11 KeyAdapter (java.awt.event.KeyAdapter)10 KeyEvent (java.awt.event.KeyEvent)10 ArrayList (java.util.ArrayList)10