@Override public JComponent createOptionsPanel() { final JFormattedTextField valueField = prepareNumberEditor("m_limit"); final JComboBox comboBox = new ComboBox( new Object[] {Scope.NONE, Scope.PRIVATE, Scope.PACKAGE_LOCAL, Scope.PROTECTED}); comboBox.setRenderer( new ListCellRendererWrapper() { @Override public void customize( JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof Scope) setText(((Scope) value).getText()); } }); comboBox.setSelectedItem(ignoreScope); comboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ignoreScope = (Scope) comboBox.getSelectedItem(); } }); comboBox.setPrototypeDisplayValue(Scope.PROTECTED); final FormBuilder formBuilder = FormBuilder.createFormBuilder(); formBuilder.addLabeledComponent(getConfigurationLabel(), valueField); formBuilder.addLabeledComponent( InspectionGadgetsBundle.message("constructor.visibility.option"), comboBox); final JPanel panel = new JPanel(new BorderLayout()); panel.add(formBuilder.getPanel(), BorderLayout.NORTH); return panel; }
@Override protected JComponent createNorthPanel() { String currentName = myLibraryRootsComponent.getLibraryEditor().getName(); myNameField = new JTextField(currentName); myNameField.selectAll(); FormBuilder formBuilder = FormBuilder.createFormBuilder().addLabeledComponent("&Name:", myNameField); addNorthComponents(formBuilder); return formBuilder.addVerticalGap(10).getPanel(); }
public FrameworkGroupOptionsComponent( final FrameworkGroup<?> group, final FrameworkSupportModelBase model) { JPanel panel = new JPanel(new VerticalFlowLayout()); List<? extends FrameworkGroupVersion> versions = group.getGroupVersions(); if (!versions.isEmpty()) { final ComboBox versionsBox = new ComboBox(); versionsBox.setRenderer( new ListCellRendererWrapper<FrameworkGroupVersion>() { @Override public void customize( JList list, FrameworkGroupVersion value, int index, boolean selected, boolean hasFocus) { setText(value != null ? value.getPresentableName() : ""); } }); versionsBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { model.setSelectedVersion( group, (FrameworkGroupVersion) versionsBox.getSelectedItem()); } }); for (FrameworkGroupVersion version : versions) { versionsBox.addItem(version); } panel.add( FormBuilder.createFormBuilder().addLabeledComponent("Version:", versionsBox).getPanel()); } myMainPanel = panel; }
@Nullable @Override protected JComponent createCustomPanel() { myHostLabel = new JBLabel("Host:", SwingConstants.RIGHT); JPanel myHostPanel = new JPanel(new BorderLayout(5, 0)); myHostPanel.add(myURLText, BorderLayout.CENTER); myHostPanel.add(myShareUrlCheckBox, BorderLayout.EAST); myRepositoryLabel = new JBLabel("Repository:", SwingConstants.RIGHT); myRepoAuthor = new MyTextField("Repository Owner"); myRepoName = new MyTextField("Repository Name"); myRepoAuthor.setPreferredSize("SomelongNickname"); myRepoName.setPreferredSize("SomelongReponame-with-suffixes"); JPanel myRepoPanel = new JPanel(new GridBagLayout()); GridBag bag = new GridBag().setDefaultWeightX(1).setDefaultFill(GridBagConstraints.HORIZONTAL); myRepoPanel.add(myRepoAuthor, bag.nextLine().next()); myRepoPanel.add(new JLabel("/"), bag.next().fillCellNone().insets(0, 5, 0, 5).weightx(0)); myRepoPanel.add(myRepoName, bag.next()); myTokenLabel = new JBLabel("API Token:", SwingConstants.RIGHT); myToken = new MyTextField("OAuth2 token"); myTokenButton = new JButton("Create API token"); myTokenButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { generateToken(); doApply(); } }); JPanel myTokenPanel = new JPanel(); myTokenPanel.setLayout(new BorderLayout(5, 5)); myTokenPanel.add(myToken, BorderLayout.CENTER); myTokenPanel.add(myTokenButton, BorderLayout.EAST); installListener(myRepoAuthor); installListener(myRepoName); installListener(myToken); return FormBuilder.createFormBuilder() .setAlignLabelOnRight(true) .addLabeledComponent(myHostLabel, myHostPanel) .addLabeledComponent(myRepositoryLabel, myRepoPanel) .addLabeledComponent(myTokenLabel, myTokenPanel) .getPanel(); }
@Nullable @Override protected JComponent createCustomPanel() { myProjectLabel = new JBLabel("Project:", SwingConstants.RIGHT); myProjectCombobox = new ComboBox(-1); myProjectCombobox.addItemListener( new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { updateFilters(); } }); installListener(myProjectCombobox); myFilterLabel = new JBLabel("Filter:", SwingConstants.RIGHT); myFilterCombobox = new ComboBox(-1); installListener(myFilterCombobox); updateProjects(); return FormBuilder.createFormBuilder() .addLabeledComponent(myProjectLabel, myProjectCombobox) .addLabeledComponent(myFilterLabel, myFilterCombobox) .getPanel(); }
@Nullable @Override public JComponent createComponent() { final JBList dependenciesList = new JBList(); dependenciesList.setCellRenderer( new ColoredListCellRendererWrapper<DependencyOnPlugin>() { @Override protected void doCustomize( JList list, DependencyOnPlugin value, int index, boolean selected, boolean hasFocus) { if (value != null) { append( getPluginNameById(value.getPluginId()), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); String minVersion = value.getMinVersion(); String maxVersion = value.getMaxVersion(); if (minVersion != null || maxVersion != null) { append(", version "); } if (minVersion != null && minVersion.equals(maxVersion)) { append(minVersion, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } else if (minVersion != null && maxVersion != null) { append("between "); append(minVersion, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); append(" and "); append(maxVersion, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } else if (minVersion != null) { append("at least "); append(minVersion, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } else if (maxVersion != null) { append("at most "); append(maxVersion, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } } } }); dependenciesList.setModel(myListModel); JPanel dependenciesPanel = ToolbarDecorator.createDecorator(dependenciesList) .disableUpDownActions() .setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { replaceDependency( new DependencyOnPlugin("", null, null, null), dependenciesList); } }) .setEditAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { DependencyOnPlugin selected = (DependencyOnPlugin) dependenciesList.getSelectedValue(); if (selected != null) { replaceDependency(selected, dependenciesList); } } }) .createPanel(); return FormBuilder.createFormBuilder() .addLabeledComponentFillVertically( "Plugins which are required to work on this project.", dependenciesPanel) .getPanel(); }
@Nullable private DependencyOnPlugin editPluginDependency( @NotNull JComponent parent, @NotNull final DependencyOnPlugin original) { List<String> pluginIds = new ArrayList<String>(getPluginNameByIdMap().keySet()); if (!original.getPluginId().isEmpty() && !pluginIds.contains(original.getPluginId())) { pluginIds.add(original.getPluginId()); } Collections.sort( pluginIds, new Comparator<String>() { @Override public int compare(String o1, String o2) { return getPluginNameById(o1).compareToIgnoreCase(getPluginNameById(o2)); } }); final ComboBox pluginChooser = new ComboBox(ArrayUtilRt.toStringArray(pluginIds), 250); pluginChooser.setRenderer( new ListCellRendererWrapper<String>() { @Override public void customize( JList list, String value, int index, boolean selected, boolean hasFocus) { setText(getPluginNameById(value)); } }); new ComboboxSpeedSearch(pluginChooser) { @Override protected String getElementText(Object element) { return getPluginNameById((String) element); } }; pluginChooser.setSelectedItem(original.getPluginId()); final JBTextField minVersionField = new JBTextField(StringUtil.notNullize(original.getMinVersion())); final JBTextField maxVersionField = new JBTextField(StringUtil.notNullize(original.getMaxVersion())); final JBTextField channelField = new JBTextField(StringUtil.notNullize(original.getChannel())); minVersionField.getEmptyText().setText("<any>"); minVersionField.setColumns(10); maxVersionField.getEmptyText().setText("<any>"); maxVersionField.setColumns(10); channelField.setColumns(10); JPanel panel = FormBuilder.createFormBuilder() .addLabeledComponent("Plugin:", pluginChooser) .addLabeledComponent("Minimum version:", minVersionField) .addLabeledComponent("Maximum version:", maxVersionField) .addLabeledComponent("Channel:", channelField) .getPanel(); final DialogBuilder dialogBuilder = new DialogBuilder(parent).title("Required Plugin").centerPanel(panel); dialogBuilder.setPreferredFocusComponent(pluginChooser); pluginChooser.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogBuilder.setOkActionEnabled( !StringUtil.isEmpty((String) pluginChooser.getSelectedItem())); } }); if (dialogBuilder.show() == DialogWrapper.OK_EXIT_CODE) { return new DependencyOnPlugin( ((String) pluginChooser.getSelectedItem()), StringUtil.nullize(minVersionField.getText().trim()), StringUtil.nullize(maxVersionField.getText().trim()), StringUtil.nullize(channelField.getText().trim())); } return null; }