private JComponent createActionPanel() { JPanel actions = new NonOpaquePanel(); actions.setBorder(JBUI.Borders.emptyLeft(10)); actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS)); ActionManager actionManager = ActionManager.getInstance(); ActionGroup quickStart = (ActionGroup) actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART); DefaultActionGroup group = new DefaultActionGroup(); collectAllActions(group, quickStart); for (AnAction action : group.getChildren(null)) { JPanel button = new JPanel(new BorderLayout()); button.setOpaque(false); button.setBorder(JBUI.Borders.empty(8, 20)); AnActionEvent e = AnActionEvent.createFromAnAction( action, null, ActionPlaces.WELCOME_SCREEN, DataManager.getInstance().getDataContext(this)); action.update(e); Presentation presentation = e.getPresentation(); if (presentation.isVisible()) { String text = presentation.getText(); if (text != null && text.endsWith("...")) { text = text.substring(0, text.length() - 3); } Icon icon = presentation.getIcon(); if (icon.getIconHeight() != JBUI.scale(16) || icon.getIconWidth() != JBUI.scale(16)) { icon = JBUI.emptyIcon(16); } action = wrapGroups(action); ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action)); link.setPaintUnderline(false); link.setNormalColor(getLinkNormalColor()); button.add(link); if (action instanceof WelcomePopupAction) { button.add(createArrow(link), BorderLayout.EAST); } installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true); actions.add(button); } } WelcomeScreenActionsPanel panel = new WelcomeScreenActionsPanel(); panel.actions.add(actions); return panel.root; }
private JComponent createRecentProjects() { JPanel panel = new JPanel(new BorderLayout()); panel.add(new NewRecentProjectPanel(this), BorderLayout.CENTER); panel.setBackground(getProjectsBackground()); panel.setBorder(new CustomLineBorder(getSeparatorColor(), JBUI.insetsRight(1))); return panel; }
@Override protected JComponent createTreePanel(final WatchDebuggerTree tree) { final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tree); decorator.setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { executeAction(DebuggerActions.NEW_WATCH, tree); } }); // TODO[den]: add "Add to watches action" on Mac if (!SystemInfo.isMac) { decorator.addExtraAction( AnActionButton.fromAction( ActionManager.getInstance().getAction(XDebuggerActions.ADD_TO_WATCH))); } decorator.setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { executeAction(DebuggerActions.REMOVE_WATCH, tree); } }); CustomLineBorder border = new CustomLineBorder( CaptionPanel.CNT_ACTIVE_BORDER_COLOR, SystemInfo.isMac ? 1 : 0, 0, SystemInfo.isMac ? 0 : 1, 0); decorator.setToolbarBorder(border); final JPanel panel = decorator.createPanel(); panel.setBorder(null); return panel; }
@Override public VcsDependentHistoryComponents getUICustomization( final VcsHistorySession session, JComponent forShortcutRegistration) { final ColumnInfo[] columns; final Consumer<VcsFileRevision> listener; final JComponent addComp; if (((SvnHistorySession) session).isHaveMergeSources()) { final MergeSourceColumnInfo mergeSourceColumn = new MergeSourceColumnInfo((SvnHistorySession) session); columns = new ColumnInfo[] {new CopyFromColumnInfo(), mergeSourceColumn}; final JPanel panel = new JPanel(new BorderLayout()); final JTextArea field = new JTextArea(); field.setEditable(false); field.setBackground(UIUtil.getComboBoxDisabledBackground()); field.setWrapStyleWord(true); listener = new Consumer<VcsFileRevision>() { @Override public void consume(VcsFileRevision vcsFileRevision) { field.setText(mergeSourceColumn.getText(vcsFileRevision)); } }; final MergeSourceDetailsAction sourceAction = new MergeSourceDetailsAction(); sourceAction.registerSelf(forShortcutRegistration); JPanel fieldPanel = new ToolbarDecorator() { @Override protected JComponent getComponent() { return field; } @Override protected void updateButtons() {} @Override protected void installDnDSupport() {} @Override protected boolean isModelEditable() { return false; } }.initPosition().addExtraAction(AnActionButton.fromAction(sourceAction)).createPanel(); fieldPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.TOP)); panel.add(fieldPanel, BorderLayout.CENTER); panel.add(new JLabel("Merge Sources:"), BorderLayout.NORTH); addComp = panel; } else { columns = new ColumnInfo[] {new CopyFromColumnInfo()}; addComp = null; listener = null; } return new VcsDependentHistoryComponents(columns, listener, addComp); }
public JComponent createComponent() { myList = new JBList(getListModel()); myList.setCellRenderer(createListCellRenderer(myList)); ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList) .disableUpDownActions() .setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final VirtualFile[] added = doAdd(); if (added.length > 0) { setModified(true); } requestDefaultFocus(); setSelectedRoots(added); } }) .setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { int[] idxs = myList.getSelectedIndices(); doRemoveItems(idxs, myList); } }) .setAddActionUpdater( new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { return myEnabled; } }) .setRemoveActionUpdater( new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { Object[] values = getSelectedRoots(); return values.length > 0 && myEnabled; } }); addToolbarButtons(toolbarDecorator); myPanel = toolbarDecorator.createPanel(); myPanel.setBorder(null); return myPanel; }
@Override protected JComponent getRowPresentation( ParameterTableModelItemBase<ParameterInfoImpl> item, boolean selected, final boolean focused) { final JPanel panel = new JPanel(new BorderLayout()); final String typeText = item.typeCodeFragment.getText(); final String separator = StringUtil.repeatSymbol(' ', getTypesMaxLength() - typeText.length() + 1); String text = typeText + separator + item.parameter.getName(); final String defaultValue = item.defaultValueCodeFragment.getText(); String tail = ""; if (StringUtil.isNotEmpty(defaultValue)) { tail += " default value = " + defaultValue; } if (item.parameter.isUseAnySingleVariable()) { if (StringUtil.isNotEmpty(defaultValue)) { tail += ";"; } tail += " Use any var."; } if (!StringUtil.isEmpty(tail)) { text += " //" + tail; } final EditorTextField field = new EditorTextField(" " + text, getProject(), getFileType()) { @Override protected boolean shouldHaveBorder() { return false; } }; Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); font = new Font(font.getFontName(), font.getStyle(), 12); field.setFont(font); if (selected && focused) { panel.setBackground(UIUtil.getTableSelectionBackground()); field.setAsRendererWithSelection( UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground()); } else { panel.setBackground(UIUtil.getTableBackground()); if (selected && !focused) { panel.setBorder(new DottedBorder(UIUtil.getTableForeground())); } } panel.add(field, BorderLayout.WEST); return panel; }
private JComponent createSettingsAndDocs() { JPanel panel = new NonOpaquePanel(new BorderLayout()); NonOpaquePanel toolbar = new NonOpaquePanel(); AnAction register = ActionManager.getInstance().getAction("Register"); boolean registeredVisible = false; if (register != null) { AnActionEvent e = AnActionEvent.createFromAnAction( register, null, ActionPlaces.WELCOME_SCREEN, DataManager.getInstance().getDataContext(this)); register.update(e); Presentation presentation = e.getPresentation(); if (presentation.isEnabled()) { ActionLink registerLink = new ActionLink("Register", register); registerLink.setNormalColor(getLinkNormalColor()); NonOpaquePanel button = new NonOpaquePanel(new BorderLayout()); button.setBorder(JBUI.Borders.empty(4, 10)); button.add(registerLink); installFocusable(button, register, KeyEvent.VK_UP, KeyEvent.VK_RIGHT, true); NonOpaquePanel wrap = new NonOpaquePanel(); wrap.setBorder(JBUI.Borders.emptyLeft(10)); wrap.add(button); panel.add(wrap, BorderLayout.WEST); registeredVisible = true; } } toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); toolbar.add( createActionLink( "Configure", IdeActions.GROUP_WELCOME_SCREEN_CONFIGURE, AllIcons.General.GearPlain, !registeredVisible)); toolbar.add(createActionLink("Get Help", IdeActions.GROUP_WELCOME_SCREEN_DOC, null, false)); panel.add(toolbar, BorderLayout.EAST); panel.setBorder(JBUI.Borders.empty(0, 0, 8, 11)); return panel; }
@NotNull private JComponent createHintComponent( @NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
public void setAdText(@NotNull final String s, int alignment) { if (myAdComponent == null) { myAdComponent = HintUtil.createAdComponent(s, BorderFactory.createEmptyBorder(1, 5, 1, 5), alignment); JPanel wrapper = new JPanel(new BorderLayout()) { @Override protected void paintComponent(Graphics g) { g.setColor(Gray._135); g.drawLine(0, 0, getWidth(), 0); super.paintComponent(g); } }; wrapper.setOpaque(false); wrapper.setBorder(new EmptyBorder(1, 0, 0, 0)); wrapper.add(myAdComponent, BorderLayout.CENTER); myContent.add(wrapper, BorderLayout.SOUTH); pack(false, true); } else { myAdComponent.setText(s); myAdComponent.setHorizontalAlignment(alignment); } }
public RegistryUi() { myContent.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP)); myModel = new MyTableModel(); myTable = new JBTable(myModel); myTable.setCellSelectionEnabled(true); myTable.setEnableAntialiasing(true); final MyRenderer r = new MyRenderer(); final TableColumn c0 = myTable.getColumnModel().getColumn(0); c0.setCellRenderer(r); c0.setMaxWidth(RESTART_ICON.getIconWidth() + 12); c0.setMinWidth(RESTART_ICON.getIconWidth() + 12); c0.setHeaderValue(null); final TableColumn c1 = myTable.getColumnModel().getColumn(1); c1.setCellRenderer(r); c1.setHeaderValue("Key"); final TableColumn c2 = myTable.getColumnModel().getColumn(2); c2.setCellRenderer(r); c2.setHeaderValue("Value"); c2.setCellEditor(new MyEditor()); myTable.setStriped(true); myDescriptionLabel = new JTextArea(3, 50); myDescriptionLabel.setEditable(false); final JScrollPane label = ScrollPaneFactory.createScrollPane(myDescriptionLabel); final JPanel descriptionPanel = new JPanel(new BorderLayout()); descriptionPanel.add(label, BorderLayout.CENTER); descriptionPanel.setBorder( IdeBorderFactory.createTitledBorder("Description", false, false, true)); myContent.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER); myContent.add(descriptionPanel, BorderLayout.SOUTH); myTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; final int selected = myTable.getSelectedRow(); if (selected != -1) { final RegistryValue value = myModel.getRegistryValue(selected); String desc = value.getDescription(); if (value.isRestartRequired()) { String required = "Requires IDE restart."; if (desc.endsWith(".")) { desc += required; } else { desc += (". " + required); } } myDescriptionLabel.setText(desc); } else { myDescriptionLabel.setText(null); } } }); myRestoreDefaultsAction = new RestoreDefaultsAction(); final DefaultActionGroup tbGroup = new DefaultActionGroup(); tbGroup.add(new EditAction()); tbGroup.add(new RevertAction()); final ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, tbGroup, true); tb.setTargetComponent(myTable); myContent.add(tb.getComponent(), BorderLayout.NORTH); new TableSpeedSearch(myTable).setComparator(new SpeedSearchComparator(false)); }
@NotNull protected List<Pair<String, JPanel>> createAdditionalPanels() { // this method is invoked before constructor body myExceptionsModel = new ExceptionsTableModel(myMethod.getMethod().getThrowsList()); myExceptionsModel.setTypeInfos(myMethod.getMethod()); final JBTable table = new JBTable(myExceptionsModel); table.setStriped(true); table.setRowHeight(20); table .getColumnModel() .getColumn(0) .setCellRenderer(new CodeFragmentTableCellRenderer(myProject)); final JavaCodeFragmentTableCellEditor cellEditor = new JavaCodeFragmentTableCellEditor(myProject); cellEditor.addDocumentListener( new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { final int row = table.getSelectedRow(); final int col = table.getSelectedColumn(); myExceptionsModel.setValueAt(cellEditor.getCellEditorValue(), row, col); updateSignature(); } }); table.getColumnModel().getColumn(0).setCellEditor(cellEditor); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getSelectionModel().setSelectionInterval(0, 0); table.setSurrendersFocusOnKeystroke(true); myPropExceptionsButton = new AnActionButton( RefactoringBundle.message("changeSignature.propagate.exceptions.title"), null, PlatformIcons.NEW_EXCEPTION) { @Override public void actionPerformed(AnActionEvent e) { final Ref<JavaCallerChooser> chooser = new Ref<JavaCallerChooser>(); Consumer<Set<PsiMethod>> callback = new Consumer<Set<PsiMethod>>() { @Override public void consume(Set<PsiMethod> psiMethods) { myMethodsToPropagateExceptions = psiMethods; myExceptionPropagationTree = chooser.get().getTree(); } }; chooser.set( new JavaCallerChooser( myMethod.getMethod(), myProject, RefactoringBundle.message("changeSignature.exception.caller.chooser"), myExceptionPropagationTree, callback)); chooser.get().show(); } }; myPropExceptionsButton.setShortcut(CustomShortcutSet.fromString("alt X")); final JPanel panel = ToolbarDecorator.createDecorator(table) .addExtraAction(myPropExceptionsButton) .createPanel(); panel.setBorder(IdeBorderFactory.createEmptyBorder(0)); myExceptionsModel.addTableModelListener(mySignatureUpdater); final ArrayList<Pair<String, JPanel>> result = new ArrayList<Pair<String, JPanel>>(); final String message = RefactoringBundle.message("changeSignature.exceptions.panel.border.title"); result.add(Pair.create(message, panel)); return result; }
protected JComponent createCenterPanel() { JPanel panel = new MyPanel(); myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel); Disposer.register(myDisposable, myUiUpdater); new UiNotifyConnector(panel, myUiUpdater); panel.setBorder(JBUI.Borders.empty()); createTree(); final DefaultActionGroup group = createActionGroup(); ActionToolbar toolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); toolBar.setTargetComponent(panel); final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(toolBar.getComponent(), BorderLayout.CENTER); myTextFieldAction = new TextFieldAction() { public void linkSelected(final LinkLabel aSource, final Object aLinkData) { toggleShowTextField(); } }; toolbarPanel.add(myTextFieldAction, BorderLayout.EAST); myPathTextFieldWrapper = new JPanel(new BorderLayout()); myPathTextFieldWrapper.setBorder(JBUI.Borders.emptyBottom(2)); myPathTextField = new FileTextFieldImpl.Vfs( FileChooserFactoryImpl.getMacroMap(), getDisposable(), new LocalFsFinder.FileChooserFilter(myChooserDescriptor, myFileSystemTree)) { protected void onTextChanged(final String newValue) { myUiUpdater.cancelAllUpdates(); updateTreeFromPath(newValue); } }; Disposer.register(myDisposable, myPathTextField); myPathTextFieldWrapper.add(myPathTextField.getField(), BorderLayout.CENTER); if (getRecentFiles().length > 0) { myPathTextFieldWrapper.add(createHistoryButton(), BorderLayout.EAST); } myNorthPanel = new JPanel(new BorderLayout()); myNorthPanel.add(toolbarPanel, BorderLayout.NORTH); updateTextFieldShowing(); panel.add(myNorthPanel, BorderLayout.NORTH); registerMouseListener(group); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree()); // scrollPane.setBorder(BorderFactory.createLineBorder(new Color(148, 154, 156))); panel.add(scrollPane, BorderLayout.CENTER); panel.setPreferredSize(JBUI.size(400)); panel.add( new JLabel( "<html><center><small><font color=gray>Drag and drop a file into the space above to quickly locate it in the tree.</font></small></center></html>", SwingConstants.CENTER), BorderLayout.SOUTH); ApplicationManager.getApplication() .getMessageBus() .connect(getDisposable()) .subscribe( ApplicationActivationListener.TOPIC, new ApplicationActivationListener.Adapter() { @Override public void applicationActivated(IdeFrame ideFrame) { ((SaveAndSyncHandlerImpl) SaveAndSyncHandler.getInstance()) .maybeRefresh(ModalityState.current()); } }); return panel; }
protected void reInitWholePanelIfNeeded() { if (!myToReInitWholePanel) return; myWholePanel = new JPanel(new BorderLayout()) { public void addNotify() { super.addNotify(); MasterDetailsComponent.this.addNotify(); TreeModel m = myTree.getModel(); if (m instanceof DefaultTreeModel) { DefaultTreeModel model = (DefaultTreeModel) m; for (int eachRow = 0; eachRow < myTree.getRowCount(); eachRow++) { TreePath eachPath = myTree.getPathForRow(eachRow); Object component = eachPath.getLastPathComponent(); if (component instanceof TreeNode) { model.nodeChanged((TreeNode) component); } } } } }; mySplitter.setHonorComponentsMinimumSize(true); myWholePanel.add(mySplitter, BorderLayout.CENTER); JPanel left = new JPanel(new BorderLayout()) { public Dimension getMinimumSize() { final Dimension original = super.getMinimumSize(); return new Dimension(Math.max(original.width, 100), original.height); } }; if (isNewProjectSettings()) { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree); DefaultActionGroup group = createToolbarActionGroup(); if (group != null) { decorator.setActionGroup(group); } // left.add(myNorthPanel, BorderLayout.NORTH); myMaster = decorator.setAsUsualTopToolbar().setPanelBorder(JBUI.Borders.empty()).createPanel(); myNorthPanel.setVisible(false); } else { left.add(myNorthPanel, BorderLayout.NORTH); myMaster = ScrollPaneFactory.createScrollPane(myTree); } left.add(myMaster, BorderLayout.CENTER); mySplitter.setFirstComponent(left); final JPanel right = new JPanel(new BorderLayout()); right.add(myDetails.getComponent(), BorderLayout.CENTER); if (!isNewProjectSettings()) { myWholePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } mySplitter.setSecondComponent(right); GuiUtils.replaceJSplitPaneWithIDEASplitter(myWholePanel); myToReInitWholePanel = false; }
@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); }