List of usage examples for javax.swing DefaultCellEditor DefaultCellEditor
public DefaultCellEditor(final JComboBox<?> comboBox)
DefaultCellEditor
object that uses a combo box. From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private void addTreeSelectionListener(JTree theTree) { if (theTree == null) { return;//from w w w .jav a 2 s .co m } trees.add(theTree); theTree.setCellEditor(new DepositTreeEditor(theTree, new DefaultTreeCellRenderer(), new DefaultCellEditor( new TreeEditorField(applicationProperties.getApplicationData().getMaximumStructureLength())))); theTree.setUI(new CustomTreeUI()); theTree.setCellRenderer(new IconRenderer(currentIconDirectory)); theTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { treeValueChanged(evt); } }); }
From source file:org.esa.snap.ui.tooladapter.model.OperatorParametersTable.java
public OperatorParametersTable(ToolAdapterOperatorDescriptor operator, AppContext appContext) { logger = Logger.getLogger(OperatorParametersTable.class.getName()); this.operator = operator; this.appContext = appContext; propertiesValueUIDescriptorMap = new HashMap<>(); JComboBox typesComboBox = new JComboBox(typesMap.keySet().toArray()); comboCellEditor = new DefaultCellEditor(typesComboBox); comboCellRenderer = new DefaultTableCellRenderer(); labelTypeCellRenderer.setText(Bundle.Type_ProductList_Text()); List<TemplateParameterDescriptor> data = operator.getToolParameterDescriptors(); PropertySet propertySet = new OperatorParameterSupport(operator).getPropertySet(); //if there is an exception in the line above, can be because the default value does not match the type //TODO determine if (and which) param has a wrong type context = new BindingContext(propertySet); for (ToolParameterDescriptor paramDescriptor : data) { if (paramDescriptor.getName().equals(ToolAdapterConstants.TOOL_SOURCE_PRODUCT_ID)) { propertiesValueUIDescriptorMap.put(paramDescriptor, PropertyMemberUIWrapperFactory.buildEmptyPropertyWrapper()); } else {//w ww . j a va 2s . c o m propertiesValueUIDescriptorMap.put(paramDescriptor, PropertyMemberUIWrapperFactory .buildPropertyWrapper("defaultValue", paramDescriptor, operator, context, null)); } } tableRenderer = new MultiRenderer(); setModel(new OperatorParametersTableNewTableModel()); setAutoResizeMode(JTable.AUTO_RESIZE_OFF); for (int i = 0; i < widths.length; i++) { getColumnModel().getColumn(i).setPreferredWidth(widths[i]); } this.putClientProperty("JComboBox.isTableCellEditor", Boolean.FALSE); this.setRowHeight(20); }
From source file:org.executequery.gui.resultset.ResultSetTable.java
public ResultSetTable() { super();// w w w .j a va 2s . c o m setDefaultOptions(); final StringCellEditor stringCellEditor = new StringCellEditor(); stringCellEditor.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); defaultCellEditor = new DefaultCellEditor(stringCellEditor) { public Object getCellEditorValue() { return stringCellEditor.getValue(); } }; final MultiLineStringCellEditor multiLineStringCellEditor = new MultiLineStringCellEditor(); multiLineStringCellEditor.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); multiLineCellEditor = new DefaultCellEditor(multiLineStringCellEditor) { public Object getCellEditorValue() { return multiLineStringCellEditor.getValue(); } }; }
From source file:org.kuali.test.ui.base.BaseTable.java
/** * * @param config//from ww w. j a v a 2s.c om * @param col * @return */ protected TableCellEditor getTableCellEditor(TableConfiguration config, int col) { return new DefaultCellEditor(new JTextField()); }
From source file:org.kuali.test.ui.components.sqlquerypanel.SqlSelectPanel.java
private BaseTable getSelectColumnTable() { TableConfiguration tc = new TableConfiguration(); tc.setHeaders(new String[] { "table", "column", "function", "order", "asc/desc" }); tc.setPropertyNames(new String[] { "tableData", "columnData", "function", "order", "ascDesc" }); tc.setColumnTypes(new Class[] { TableData.class, ColumnData.class, String.class, String.class, String.class, String.class }); tc.setColumnWidths(new int[] { 30, 40, 15, 10, 15 }); tc.setTableName("sql-select-column-table"); tc.setDisplayName("Select Columns"); BaseTable retval = new BaseTable(tc) { @Override//from w w w . j a va 2s .c o m public boolean isCellEditable(int row, int column) { boolean retval = false; SelectColumnData scd = (SelectColumnData) getTableData().get(row); switch (column) { case 0: retval = true; break; case 1: retval = (scd.getTableData() != null); break; case 2: case 3: retval = (scd.getColumnData() != null); break; case 4: retval = ((scd.getColumnData() != null) && StringUtils.isNotBlank(scd.getOrder())); break; } return retval; } @Override protected String getTooltip(int row, int col) { String retval = null; if (col == 0) { SelectColumnData scd = (SelectColumnData) getTableData().get(row); if (scd != null) { TableData td = scd.getTableData(); if (td != null) { retval = getDbPanel().getTableDataTooltip(td); } } } return retval; } }; retval.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(new IntegerTextField())); retval.getColumnModel().getColumn(2).setCellEditor(new ComboBoxCellEditor(new JComboBox())); retval.getColumnModel().getColumn(2) .setCellRenderer(new ComboBoxTableCellRenderer(Constants.AGGREGATE_FUNCTIONS)); retval.getColumnModel().getColumn(4) .setCellEditor(new ComboBoxCellEditor(new JComboBox(Constants.ASC_DESC))); retval.getColumnModel().getColumn(4).setCellRenderer(new ComboBoxTableCellRenderer(Constants.ASC_DESC)); return retval; }
From source file:org.kuali.test.ui.components.sqlquerypanel.SqlWherePanel.java
/** * * @param mainframe//from w w w . j a va2 s . c o m * @param dbPanel */ public SqlWherePanel(TestCreator mainframe, DatabasePanel dbPanel) { super(mainframe, dbPanel, WhereColumnData.class); intCellEditor = new WhereValueCellEditor(dbPanel, new IntegerTextField()); floatCellEditor = new DefaultCellEditor(new FloatTextField()); dateCellEditor = new DateChooserCellEditor(); dateCellRenderer = new DateChooserCellEditor(); defaultCellEditor = new WhereValueCellEditor(dbPanel, new JTextField()); defaultCellRenderer = new DefaultTableCellRenderer(); initComponents(); }
From source file:org.kuali.test.ui.components.sqlquerypanel.WhereValueCellEditor.java
public WhereValueCellEditor(DatabasePanel dbPanel, JTextField tf) { super(new BorderLayout()); this.dbPanel = dbPanel; cellEditor = new DefaultCellEditor(tf); add(cellEditor.getComponent(), BorderLayout.CENTER); JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 2)); p.add(lookup = new SearchButton()); p.add(new JSeparator(JSeparator.VERTICAL)); if (dbPanel.isForCheckpoint()) { p.add(executionParameter = new SearchButton(Constants.ADD_PARAM_ICON)); executionParameter.addActionListener(this); }//w w w.j ava 2 s. c o m add(p, BorderLayout.EAST); lookup.setEnabled(false); lookup.addActionListener(this); }
From source file:org.nuclos.client.wizard.steps.NuclosEntityAttributeValueListShipStep.java
@Override protected void initComponents() { lstValues = new ArrayList<ValueList>(); this.setLayout(new BorderLayout(5, 5)); pnlName = new JPanel(); pnlName.setLayout(new BorderLayout(5, 5)); lbName = new JLabel( SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributevaluelist.7", "Name")); tfName = new JTextField(); tfName.setDocument(new LimitSpecialCharacterDocument(25)); pnlName.add(lbName, BorderLayout.WEST); pnlName.add(tfName, BorderLayout.CENTER); lbInfo = new JLabel(SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributevaluelist.1", "Entitt ist schon vorhanden. Bitte anderen Namen vergeben!")); lbInfo.setForeground(Color.RED); lbInfo.setVisible(false);/*w w w . jav a2 s . c o m*/ this.add(pnlName, BorderLayout.NORTH); this.add(subform, BorderLayout.CENTER); this.add(lbInfo, BorderLayout.SOUTH); subform.getSubformTable().setModel(new ValuelistTableModel()); JTextField textField = new JTextField(); textField.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter()); DefaultCellEditor editor = new DefaultCellEditor(textField); editor.setClickCountToStart(1); subform.getSubformTable().setDefaultEditor(String.class, editor); subform.getSubformTable().setDefaultEditor(Date.class, new DateEditor()); ListenerUtil.registerSubFormToolListener(subform, this, new SubForm.SubFormToolListener() { @Override public void toolbarAction(String actionCommand) { if (SubForm.ToolbarFunction.fromCommandString(actionCommand) == SubForm.ToolbarFunction.NEW) { ValuelistTableModel model = (ValuelistTableModel) subform.getSubformTable().getModel(); lstValues.add(new ValueList()); model.fireTableDataChanged(); } } }); tfName.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { doSomeWork(e); } @Override public void insertUpdate(DocumentEvent e) { doSomeWork(e); } @Override public void changedUpdate(DocumentEvent e) { doSomeWork(e); } private void doSomeWork(DocumentEvent e) { try { String s = e.getDocument().getText(0, e.getDocument().getLength()); model.getAttribute().setValueListName(s); if (s.length() == 0) NuclosEntityAttributeValueListShipStep.this.setComplete(false); else NuclosEntityAttributeValueListShipStep.this.setComplete(true); if (model.getAttribute().isValueListNew()) { for (EntityMetaDataVO voEntity : MetaDataClientProvider.getInstance().getAllEntities()) { if (s.equals(voEntity.getEntity()) || ("V_EO_" + s).equalsIgnoreCase(voEntity.getDbEntity())) { NuclosEntityAttributeValueListShipStep.this.setComplete(false); lbInfo.setVisible(true); break; } NuclosEntityAttributeValueListShipStep.this.setComplete(true); lbInfo.setVisible(false); } } } catch (BadLocationException e1) { LOG.info("doSomeWork failed: " + e1, e1); } } }); }
From source file:org.openconcerto.erp.core.finance.accounting.element.AssociationCompteAnalytiqueSQLElement.java
public JTable creerJTable(ClasseCompte ccTmp) { final AssociationAnalytiqueModel model = new AssociationAnalytiqueModel(ccTmp); final JTable table = new JTable(model); final Vector vect = model.getRepartitionsAxe(); table.getColumnModel().getColumn(0).setCellRenderer(new PlanComptableCellRenderer(0)); table.getColumnModel().getColumn(1).setCellRenderer(new PlanComptableCellRenderer(0)); for (int i = 0; i < vect.size(); i++) { final Vector rep = (Vector) vect.get(i); JComboBox combo = new JComboBox(); for (int j = 0; j < rep.size(); j++) { combo.addItem(rep.get(j));//from w w w. j a va2s.co m } table.getColumnModel().getColumn(i + 2).setCellEditor(new DefaultCellEditor(combo)); table.getColumnModel().getColumn(i + 2).setCellRenderer(new PlanComptableCellRenderer(0)); } table.getTableHeader().setReorderingAllowed(false); return table; }
From source file:org.openconcerto.task.TodoListPanel.java
private void initTable(int mode) { this.t.setBlockRepaint(true); this.t.setBlockEventOnColumn(true); this.model.setMode(mode); this.t.getColumnModel().getColumn(0).setCellRenderer(this.a); this.t.getColumnModel().getColumn(0).setCellEditor(this.a); this.t.setBlockEventOnColumn(true); setIconForColumn(0, this.iconTache); setIconForColumn(1, this.iconPriorite); this.t.setBlockEventOnColumn(true); this.t.getColumnModel().getColumn(1).setCellEditor(this.iconEditor); final JTextField textField = new JTextField() { @Override//from ww w .ja v a 2s . c o m public void paint(Graphics g) { super.paint(g); g.setColor(TodoListPanel.this.t.getGridColor()); g.fillRect(getWidth() - 19, 0, 1, getHeight()); g.setColor(new Color(250, 250, 250)); g.fillRect(getWidth() - 18, 0, 18, getHeight()); g.setColor(Color.BLACK); for (int i = 0; i < 3; i++) { int x = getWidth() - 14 + i * 4; int y = getHeight() - 5; g.fillRect(x, y, 1, 2); } } }; textField.setBorder(BorderFactory.createEmptyBorder()); final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(textField); textField.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (e.getX() > textField.getWidth() - 19) { TodoListElement l = getTaskAt( SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), TodoListPanel.this.t)); TodoListPanel.this.t.editingCanceled(new ChangeEvent(this)); JFrame f = new JFrame(TM.tr("details")); f.setContentPane(new TodoListElementEditorPanel(l)); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setSize(500, 200); f.setLocation(50, e.getYOnScreen() + TodoListPanel.this.t.getRowHeight()); f.setVisible(true); } } }); this.t.getColumnModel().getColumn(2).setCellEditor(defaultCellEditor); this.t.getColumnModel().getColumn(3).setMaxWidth(300); this.t.getColumnModel().getColumn(3).setMinWidth(100); this.timestampTableCellEditorCreated.stopCellEditing(); this.timestampTableCellEditorDone.stopCellEditing(); this.timestampTableCellEditorDeadLine.stopCellEditing(); if (this.model.getMode() == TodoListModel.EXTENDED_MODE) { this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererCreated); this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorCreated); this.t.getColumnModel().getColumn(4).setCellRenderer(this.timestampTableCellRendererDone); this.t.getColumnModel().getColumn(4).setCellEditor(this.timestampTableCellEditorDone); this.t.getColumnModel().getColumn(5).setCellRenderer(this.timestampTableCellRendererDeadLine); this.t.getColumnModel().getColumn(5).setCellEditor(this.timestampTableCellEditorDeadLine); } else { this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererDeadLine); this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorDeadLine); } final TableColumn userColumn = this.t.getColumnModel() .getColumn(this.t.getColumnModel().getColumnCount() - 1); userColumn.setCellRenderer(this.userTableCellRenderer); userColumn.setMaxWidth(150); userColumn.setMinWidth(100); t.setEnabled(false); initUserCellEditor(userColumn); this.t.setBlockEventOnColumn(false); this.t.setBlockRepaint(false); this.t.getColumnModel().getColumn(1).setCellRenderer(this.iconRenderer); // Better look this.t.setShowHorizontalLines(false); this.t.setGridColor(new Color(230, 230, 230)); this.t.setRowHeight(new JTextField(" ").getPreferredSize().height + 4); AlternateTableCellRenderer.UTILS.setAllColumns(this.t); this.t.repaint(); }