@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value instanceof ListWithSelection) { ListWithSelection options = (ListWithSelection)value; //noinspection unchecked comboBox.setModel(new ListComboBoxModel(options)); if (options.getSelection() == null) { options.selectFirst(); } comboBox.setSelectedItem(options.getSelection()); } else { Enum enumValue = (Enum)value; Class enumClass = enumValue.getDeclaringClass(); //noinspection unchecked ComboBoxModel model = comboBox.getModel(); if (!(model instanceof EnumComboBoxModel && model.getSize() > 0 && ((Enum)model.getElementAt(0)).getDeclaringClass() == enumClass)) { //noinspection unchecked comboBox.setModel(new EnumComboBoxModel(enumClass)); } comboBox.setSelectedItem(value); } return comboBox; }
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { final ListWithSelection options = (ListWithSelection)value; if (options.getSelection() == null) { options.selectFirst(); } myComboBox.removeAllItems(); for (Object option : options) { //noinspection unchecked myComboBox.addItem(option); } myComboBox.setSelectedItem(options.getSelection()); return myPanel; }
@Override public JComponent getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value instanceof ListWithSelection) { final ListWithSelection tags = (ListWithSelection)value; if (tags.getSelection() == null) { tags.selectFirst(); } myCombo.removeAllItems(); for (Object tag : tags) { myCombo.addItem(tag); } myCombo.setSelectedItem(tags.getSelection()); } else { if (value != null) { LOG.error("value " + LogUtil.objectAndClass(value) + ", at " + row + ":" + column + ", in " + table.getModel()); } myCombo.removeAllItems(); myCombo.setSelectedIndex(-1); } return this; }
public JComponent getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value instanceof ListWithSelection) { final ListWithSelection tags = (ListWithSelection)value; if (tags.getSelection() == null) { tags.selectFirst(); } myCombo.removeAllItems(); for (Object tag : tags) { myCombo.addItem(tag); } myCombo.setSelectedItem(tags.getSelection()); } else { if (value != null) { LOG.error("value " + LogUtil.objectAndClass(value) + ", at " + row + ":" + column + ", in " + table.getModel()); } myCombo.removeAllItems(); myCombo.setSelectedIndex(-1); } return this; }
@Nullable private ListWithSelection<String> getLayers() { VirtualFile file = getSelectedFile(); Project project = getProject(); Module moduleForFile = file == null || project == null ? null : ModuleUtilCore.findModuleForFile(file, project); if (moduleForFile == null) { return null; } ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(moduleForFile); Map<String, ModuleRootLayer> layers = moduleRootManager.getLayers(); if (layers.size() == 1) { return null; } String currentLayerName = moduleRootManager.getCurrentLayerName(); return new ListWithSelection<String>(layers.keySet(), currentLayerName); }
private MyTableModel(List<Chunk<Module>> chunks) { for (final Chunk<Module> chunk : chunks) { final ListWithSelection<String> item = new ListWithSelection<String>(); for (final Module module : chunk.getNodes()) { item.add(module.getName()); } item.selectFirst(); myItems.add(new Pair<String, ListWithSelection>(createCycleName(chunk), item)); } }
public String[] getModuleRepresentatives() { final String[] names = new String[myItems.size()]; int index = 0; for (final Pair<String, ListWithSelection> pair : myItems) { names[index++] = (String)pair.getSecond().getSelection(); } return names; }
public Class getColumnClass(int columnIndex) { switch (columnIndex) { case NUMBER_COLUMN: return String.class; case NAME_COLUMN: return ListWithSelection.class; default: return super.getColumnClass(columnIndex); } }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value instanceof ListWithSelection) { value = ((ListWithSelection)value).getSelection(); } final JLabel component = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); component.setHorizontalAlignment(SwingConstants.CENTER); return component; }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { value = new ListWithSelection<Object>(Arrays.asList(value)); return INSTANCE.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); }
public Object getValueAt(int rowIndex, int columnIndex) { GitRebaseEntry e = myEntries.get(rowIndex); switch (columnIndex) { case ACTION_COLUMN: return new ListWithSelection<GitRebaseEntry.Action>(Arrays.asList(GitRebaseEntry.Action.values()), e.getAction()); case HASH_COLUMN: return e.getCommit(); case SUBJECT_COLUMN: return e.getSubject(); default: throw new IllegalArgumentException("Unsupported column index: " + columnIndex); } }
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { final ListWithSelection options = (ListWithSelection)value; if (options.getSelection() == null) { options.selectFirst(); } myComboBox.removeAllItems(); for (Iterator each = options.iterator(); each.hasNext();) { myComboBox.addItem(each.next()); } myComboBox.setSelectedItem(options.getSelection()); return myPanel; }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { value = new ListWithSelection<Object>(Arrays.asList(value)); return INSTANCE.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); }
/** * {@inheritDoc} */ public Object getValueAt(final int rowIndex, final int columnIndex) { GitRebaseEntry e = myEntries.get(rowIndex); switch (columnIndex) { case ACTION: return new ListWithSelection<GitRebaseEntry.Action>(Arrays.asList(GitRebaseEntry.Action.values()), e.getAction()); case COMMIT: return e.getCommit(); case SUBJECT: return e.getSubject(); default: throw new IllegalArgumentException("Unsupported column index: " + columnIndex); } }
public ListWithSelection<HandleType> getHandleType(){ return myHandleType; }
@Override public Class<?> getColumnClass(int columnIndex) { return columnIndex == ACTION_COLUMN ? ListWithSelection.class : String.class; }
/** * {@inheritDoc} */ @Override public Class<?> getColumnClass(final int columnIndex) { return columnIndex == ACTION ? ListWithSelection.class : String.class; }
private void update() { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { myActionEnabled = false; String toolTipText = null; String panelText = null; ListWithSelection<String> profiles = getLayers(); if (profiles != null) { myActionEnabled = true; toolTipText = "Module Layer: " + profiles.getSelection(); panelText = profiles.getSelection(); myComponent.setVisible(true); } myActionEnabled = profiles != null; myComponent.setVisible(profiles != null); myComponent.resetColor(); String toDoComment; if (myActionEnabled) { toDoComment = "Click to change"; myComponent.setForeground(UIUtil.getActiveTextColor()); myComponent.setTextAlignment(Component.LEFT_ALIGNMENT); } else { toDoComment = ""; myComponent.setForeground(UIUtil.getInactiveTextColor()); myComponent.setTextAlignment(Component.CENTER_ALIGNMENT); } myComponent.setToolTipText(String.format("%s%n%s", toolTipText, toDoComment)); myComponent.setText(panelText); if (myStatusBar != null) { myStatusBar.updateWidget(ID()); } } }); }