@RequiredDispatchThread @Nullable @Override public JComponent createComponent() { myList = new CheckBoxList<>(); myList.setBorder(null); EarlyAccessProgramDescriptor[] extensions = EarlyAccessProgramDescriptor.EP_NAME.getExtensions(); Arrays.sort(extensions, (o1, o2) -> { if (o1.isAvailable() && !o2.isAvailable()) { return -1; } else if (o2.isAvailable() && !o1.isAvailable()) { return 1; } return o1.getName().compareToIgnoreCase(o2.getName()); }); myList.setItems(Arrays.asList(extensions), EarlyAccessProgramDescriptor::getName, desc -> EarlyAccessProgramManager.is(desc.getClass())); myList.setCellRenderer(new EarlyAccessCellRender()); return JBUI.Panels.simplePanel().addToTop(createWarningPanel()).addToCenter(ScrollPaneFactory.createScrollPane(myList, true)); }
public CheckBoxListModelEditor(@NotNull Function<T, String> toNameConverter, @NotNull String emptyText) { this.toNameConverter = toNameConverter; list = new CheckBoxList<T>(); list.setEmptyText(emptyText); // toolbar decorator is responsible for border list.setBorder(null); toolbarDecorator = ToolbarDecorator.createDecorator(list); }
public PyModuleDependenciesConfigurable(Module module) { myModule = module; myDependenciesList = new CheckBoxList<Module>(); resetModel(); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDependenciesList, new EditableListModelDecorator((DefaultListModel) myDependenciesList.getModel())); decorator.disableRemoveAction(); myListHolderPanel.add(decorator.createPanel(), BorderLayout.CENTER); }
public void testDirectoryAsImportProjectPath() { myFromPantsControl.onLinkedProjectPathChange(getProjectPath() + File.separator + "examples/src/java/org/pantsbuild/example/hello"); updateSettingsBasedOnGuiStates(); CheckBoxList<String> checkBoxList = getTargetSpecCheckBoxList(); assertFalse("Check box list should be disabled, but it is not.", checkBoxList.isEnabled()); assertEquals( ContainerUtil.newArrayList("examples/src/java/org/pantsbuild/example/hello/::"), myFromPantsControl.getProjectSettings().getTargetSpecs() ); }
public void testBuildFileAsImportProjectPath() { myFromPantsControl.onLinkedProjectPathChange( getProjectPath() + File.separator + "examples/src/java/org/pantsbuild/example/hello/main/BUILD" ); updateSettingsBasedOnGuiStates(); // Checkbox is made, but it none of the targets should be selected. assertEquals( "None of the target specs should be selected, but some are.", ContainerUtil.emptyList(), myFromPantsControl.getProjectSettings().getTargetSpecs() ); CheckBoxList<String> checkBoxList = getTargetSpecCheckBoxList(); assertTrue("Check box list should be enabled, but it is not.", checkBoxList.isEnabled()); // Simulate checking all the boxes. for (int i = 0; i < checkBoxList.getItemsCount(); i++) { String target = checkBoxList.getItemAt(i); checkBoxList.setItemSelected(target, true); } updateSettingsBasedOnGuiStates(); // Now project setting should contain all the targets in the BUILD file. assertEquals( ContainerUtil.newArrayList( "examples/src/java/org/pantsbuild/example/hello/main:main", "examples/src/java/org/pantsbuild/example/hello/main:readme", "examples/src/java/org/pantsbuild/example/hello/main:main-bin" ), myFromPantsControl.getProjectSettings().getTargetSpecs() ); }
private void focus(final CheckBoxList list) { list.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (list.getItemsCount() > 0 && list.getSelectedIndex() == -1) { list.setSelectedIndex(0); //list.removeSelectionInterval(0, 0); list.removeFocusListener(this); } } }); }
private static void setItems(Collection<String> localBranches, Set<String> localBranchesCopy, final CheckBoxList list) { // order final Map<String, Boolean> localBranchesState = new TreeMap<String, Boolean>(); for (String localBranch : localBranches) { localBranchesState.put(localBranch, localBranchesCopy.contains(localBranch)); } list.setStringItems(localBranchesState); }
public CustomizeSelectTemplateStepPanel(MultiMap<String, String> predefinedTemplates) { myPredefinedTemplates = predefinedTemplates; setLayout(new BorderLayout()); myCheckBoxList = new CheckBoxList<>(); myCheckBoxList.setItems(new ArrayList<>(predefinedTemplates.keySet()), s -> s); add(ScrollPaneFactory.createScrollPane(myCheckBoxList, true), BorderLayout.CENTER); }
@RequiredDispatchThread @Nullable @Override public JComponent createComponent() { PostfixTemplateProvider postfixTemplateProvider = myExtensionPoint.getInstance(); if (postfixTemplateProvider == null) { return null; } OnePixelSplitter splitter = new OnePixelSplitter(); splitter.setSplitterProportionKey("PostfixTemplatesChildConfigurable.splitter"); myCheckBoxList = new CheckBoxList<>(); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myCheckBoxList, true)); myPostfixDescriptionPanel = new PostfixDescriptionPanel(); JPanel component = myPostfixDescriptionPanel.getComponent(); component.setBorder(JBUI.Borders.empty(0, 8, 0, 0)); splitter.setSecondComponent(component); myCheckBoxList.setItems(new ArrayList<>(postfixTemplateProvider.getTemplates()), PostfixTemplate::getPresentableName, postfixTemplate -> Boolean.TRUE); myCheckBoxList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { PostfixTemplate itemAt = myCheckBoxList.getItemAt(myCheckBoxList.getSelectedIndex()); myPostfixDescriptionPanel.reset(PostfixTemplateMetaData.createMetaData(itemAt)); } }); return splitter; }
public CheckBoxList<T> getList() { return list; }
/** * @return the GUI component to select target specs. */ private CheckBoxList<String> getTargetSpecCheckBoxList() { return ((PantsProjectSettingsControl) myFromPantsControl.getProjectSettingsControl()).myTargetSpecsBox; }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { CheckBoxList checkBoxList = (CheckBoxList)list; EarlyAccessProgramDescriptor earlyAccessProgramDescriptor = (EarlyAccessProgramDescriptor)checkBoxList.getItemAt(index); JCheckBox checkbox = (JCheckBox)value; checkbox.setEnabled(list.isEnabled()); checkbox.setFocusPainted(false); checkbox.setBorderPainted(true); if (earlyAccessProgramDescriptor == null) { return checkbox; } else { checkbox.setEnabled(earlyAccessProgramDescriptor.isAvailable()); JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, true, true)) { @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); return new Dimension(Math.min(size.width, 200), size.height); } }; panel.setEnabled(earlyAccessProgramDescriptor.isAvailable()); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(checkbox, BorderLayout.WEST); if (earlyAccessProgramDescriptor.isRestartRequired()) { JBLabel comp = new JBLabel("Restart required"); comp.setForeground(JBColor.GRAY); topPanel.add(comp, BorderLayout.EAST); } panel.add(topPanel); panel.setBorder(new CustomLineBorder(0, 0, 1, 0)); String description = StringUtil.notNullizeIfEmpty(earlyAccessProgramDescriptor.getDescription(), "Description is not available"); JTextPane textPane = new JTextPane(); textPane.setText(description); textPane.setEditable(false); if (!earlyAccessProgramDescriptor.isAvailable()) { textPane.setForeground(JBColor.GRAY); } panel.add(textPane); return panel; } }
private void createUIComponents() { myList = new CheckBoxList<GutterIconDescriptor>() { @Override protected JComponent adjustRendering(JComponent rootComponent, JCheckBox checkBox, int index, boolean selected, boolean hasFocus) { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder()); GutterIconDescriptor descriptor = myList.getItemAt(index); Icon icon = descriptor == null ? null : descriptor.getIcon(); JLabel label = new JLabel(icon == null ? EmptyIcon.ICON_16 : icon); label.setOpaque(true); label.setPreferredSize(new Dimension(25, -1)); label.setHorizontalAlignment(SwingConstants.CENTER); panel.add(label, BorderLayout.WEST); panel.add(checkBox, BorderLayout.CENTER); panel.setBackground(getBackground(false)); label.setBackground(getBackground(selected)); if (!checkBox.isOpaque()) { checkBox.setOpaque(true); } checkBox.setBorder(null); PluginDescriptor pluginDescriptor = myFirstDescriptors.get(descriptor); if (pluginDescriptor instanceof IdeaPluginDescriptor) { SeparatorWithText separator = new SeparatorWithText(); String name = ((IdeaPluginDescriptor)pluginDescriptor).getName(); separator.setCaption("IDEA CORE".equals(name) ? "Common" : name); panel.add(separator, BorderLayout.NORTH); } return panel; } @Nullable @Override protected Point findPointRelativeToCheckBox(int x, int y, @Nonnull JCheckBox checkBox, int index) { return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index); } }; myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); myList.setBorder(BorderFactory.createEmptyBorder()); new ListSpeedSearch(myList, (Convertor<Object, String>)o -> o instanceof JCheckBox ? ((JCheckBox)o).getText() : null); }