@NotNull @Override public Component getTableCellRendererComponent( @NotNull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { myTable = table; myRow = row; myColumn = column; boolean isEnabled = true; final DefaultMutableTreeNode node = (DefaultMutableTreeNode) ((TreeTable) table).getTree().getPathForRow(row).getLastPathComponent(); Option key = null; if (node instanceof MyTreeNode) { isEnabled = ((MyTreeNode) node).isEnabled(); key = ((MyTreeNode) node).getKey(); } if (!table.isEnabled()) { isEnabled = false; } Color background = table.getBackground(); if (value instanceof Boolean) { myCheckBox.setSelected(((Boolean) value).booleanValue()); myCheckBox.setBackground(background); myCheckBox.setEnabled(isEnabled); return myCheckBox; } else if (value instanceof String) { /* myComboBox.removeAllItems(); myComboBox.addItem(value); */ myComboBox.setText((String) value); myComboBox.setBackground(background); myComboBox.setEnabled(isEnabled); return myComboBox; } else if (value instanceof Integer) { if (key instanceof IntOption && ((IntOption) key).isDefaultValue(value)) { myIntLabel.setText(((IntOption) key).getDefaultValueText()); } else { myIntLabel.setText(value.toString()); } return myIntLabel; } myCheckBox.putClientProperty("JComponent.sizeVariant", "small"); myComboBox.putClientProperty("JComponent.sizeVariant", "small"); myEmptyLabel.setBackground(background); return myEmptyLabel; }
protected void customizeOptionsPanel() { if (myInsertOverrideAnnotationCheckbox != null && myIsInsertOverrideVisible) { CodeStyleSettings styleSettings = CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings(); myInsertOverrideAnnotationCheckbox.setSelected(styleSettings.INSERT_OVERRIDE_ANNOTATION); } if (myCopyJavadocCheckbox != null) { myCopyJavadocCheckbox.setSelected( PropertiesComponent.getInstance().isTrueValue(PROP_COPYJAVADOC)); } }
public MyValueEditor() { final ActionListener itemChoosen = new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { if (myCurrentNode != null) { myCurrentNode.setValue(getCellEditorValue()); somethingChanged(); } } }; myBooleanEditor.addActionListener(itemChoosen); myOptionsEditor.addActionListener(itemChoosen); myBooleanEditor.putClientProperty("JComponent.sizeVariant", "small"); myOptionsEditor.putClientProperty("JComponent.sizeVariant", "small"); }
private void updateComponents() { boolean archetypesEnabled = myUseArchetypeCheckBox.isSelected(); myAddArchetypeButton.setEnabled(archetypesEnabled); myArchetypesTree.setEnabled(archetypesEnabled); myArchetypesTree.setBackground( archetypesEnabled ? UIUtil.getListBackground() : UIUtil.getPanelBackground()); }
public void requestUpdate() { MavenArchetype selectedArch = getSelectedArchetype(); if (selectedArch == null) { selectedArch = myBuilder.getArchetype(); } if (selectedArch != null) myUseArchetypeCheckBox.setSelected(true); if (myArchetypesTree.getRowCount() == 0) updateArchetypesList(selectedArch); }
@Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { final DefaultMutableTreeNode defaultNode = (DefaultMutableTreeNode) ((TreeTable) table).getTree().getPathForRow(row).getLastPathComponent(); myCurrentEditor = null; myCurrentNode = null; if (defaultNode instanceof MyTreeNode) { MyTreeNode node = (MyTreeNode) defaultNode; myCurrentNode = node; if (node.getKey() instanceof BooleanOption) { myCurrentEditor = myBooleanEditor; myBooleanEditor.setSelected(node.getValue() == Boolean.TRUE); myBooleanEditor.setEnabled(node.isEnabled()); } else if (node.getKey() instanceof IntOption) { IntOption intOption = (IntOption) node.getKey(); myCurrentEditor = myIntOptionsEditor; myIntOptionsEditor.setText( intOption.isDefaultValue(node.getValue()) ? "" : node.getValue().toString()); myIntOptionsEditor.setMinValue(intOption.getMinValue()); myIntOptionsEditor.setMaxValue(intOption.getMaxValue()); myIntOptionsEditor.setDefaultValue(intOption.getDefaultValue()); } else { myCurrentEditor = myOptionsEditor; myOptionsEditor.setCell(table, row, column); myOptionsEditor.setText(String.valueOf(node.getValue())); myOptionsEditor.setOptions(((SelectionOption) node.getKey()).options); myOptionsEditor.setDefaultValue(node.getValue()); } } if (myCurrentEditor != null) { myCurrentEditor.setBackground(table.getBackground()); } return myCurrentEditor; }
@Override public Object getCellEditorValue() { if (myCurrentEditor == myOptionsEditor) { // new Alarm(Alarm.ThreadToUse.SWING_THREAD).addRequest(new Runnable() { // @Override // public void run() { // somethingChanged(); // } // }, 100); return myOptionsEditor.getEditorValue(); } else if (myCurrentEditor == myBooleanEditor) { return myBooleanEditor.isSelected(); } else if (myCurrentEditor == myIntOptionsEditor) { return myIntOptionsEditor.getPresentableValue(); } return null; }
@Override public void dispose() { PropertiesComponent instance = PropertiesComponent.getInstance(); instance.setValue(PROP_SORTED, Boolean.toString(isAlphabeticallySorted())); instance.setValue(PROP_SHOWCLASSES, Boolean.toString(myShowClasses)); if (myCopyJavadocCheckbox != null) { instance.setValue(PROP_COPYJAVADOC, Boolean.toString(myCopyJavadocCheckbox.isSelected())); } final Container contentPane = getContentPane(); if (contentPane != null) { contentPane.removeAll(); } mySelectedNodes.clear(); myElements = null; super.dispose(); }
public boolean isInsertOverrideAnnotation() { return myIsInsertOverrideVisible && myInsertOverrideAnnotationCheckbox.isSelected(); }
public boolean isCopyJavadoc() { return myCopyJavadocCheckbox.isSelected(); }
public void setCopyJavadocVisible(boolean state) { myCopyJavadocCheckbox.setVisible(state); }
public MavenArchetypesStep(MavenModuleBuilder builder, @Nullable StepAdapter step) { myBuilder = builder; myStep = step; Disposer.register(this, myLoadingIcon); myArchetypesTree = new Tree(); myArchetypesTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode())); JScrollPane archetypesScrollPane = ScrollPaneFactory.createScrollPane(myArchetypesTree); myArchetypesPanel.add(archetypesScrollPane, "archetypes"); JPanel loadingPanel = new JPanel(new GridBagLayout()); JPanel bp = new JPanel(new BorderLayout(10, 10)); bp.add(new JLabel("Loading archetype list..."), BorderLayout.NORTH); bp.add(myLoadingIcon, BorderLayout.CENTER); loadingPanel.add(bp, new GridBagConstraints()); myArchetypesPanel.add(ScrollPaneFactory.createScrollPane(loadingPanel), "loading"); ((CardLayout) myArchetypesPanel.getLayout()).show(myArchetypesPanel, "archetypes"); myUseArchetypeCheckBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateComponents(); archetypeMayBeChanged(); } }); myAddArchetypeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doAddArchetype(); } }); myArchetypesTree.setRootVisible(false); myArchetypesTree.setShowsRootHandles(true); myArchetypesTree.setCellRenderer(new MyRenderer()); myArchetypesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myArchetypesTree .getSelectionModel() .addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { updateArchetypeDescription(); archetypeMayBeChanged(); } }); new TreeSpeedSearch( myArchetypesTree, new Convertor<TreePath, String>() { public String convert(TreePath path) { MavenArchetype info = getArchetypeInfoFromPathComponent(path.getLastPathComponent()); return info.groupId + ":" + info.artifactId + ":" + info.version; } }) .setComparator(new SpeedSearchComparator(false)); myArchetypeDescriptionField.setEditable(false); myArchetypeDescriptionField.setBackground(UIUtil.getPanelBackground()); requestUpdate(); updateComponents(); }
@Nullable public MavenArchetype getSelectedArchetype() { if (!myUseArchetypeCheckBox.isSelected() || myArchetypesTree.isSelectionEmpty()) return null; return getArchetypeInfoFromPathComponent(myArchetypesTree.getLastSelectedPathComponent()); }