Java Code Examples for javax.swing.DefaultCellEditor

The following examples show how to use javax.swing.DefaultCellEditor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u_jdk   Source File: Test6505027.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 2
Source Project: mars-sim   Source File: TableRenderDemo.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void setUpSportColumn(JTable table,
                             TableColumn sportColumn) {
    //Set up the editor for the sport cells.
    JComboBox<String> comboBox = new JComboBox<String>();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Knitting");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Pool");
    comboBox.addItem("None of the above");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));

    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
            new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
}
 
Example 3
Source Project: openAGV   Source File: ContinuousLoadPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param portalProvider The application's portal provider.
 * @param eventSource Where components can register for events.
 */
@Inject
public ContinuousLoadPanel(SharedKernelServicePortalProvider portalProvider,
                           @ApplicationEventBus EventSource eventSource) {
  this.portalProvider = requireNonNull(portalProvider, "portalProvider");
  this.eventSource = requireNonNull(eventSource, "eventSource");

  initComponents();

  JComboBox<TransportOrderData.Deadline> deadlineComboBox = new JComboBox<>();
  deadlineComboBox.addItem(null);
  for (TransportOrderData.Deadline i : TransportOrderData.Deadline.values()) {
    deadlineComboBox.addItem(i);
  }
  DefaultCellEditor deadlineEditor = new DefaultCellEditor(deadlineComboBox);
  toTable.setDefaultEditor(TransportOrderData.Deadline.class, deadlineEditor);

  toTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
  doTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
}
 
Example 4
Source Project: openAGV   Source File: ContinuousLoadPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void buildTableModels(TransportOrderData transportOrder) {
  requireNonNull(transportOrder, "transportOrder");

  // Drive orders
  locationsComboBox.removeAllItems();
  operationTypesComboBox.removeAllItems();
  SortedSet<Location> sortedLocationSet = new TreeSet<>(Comparators.objectsByName());
  sortedLocationSet.addAll(objectService.fetchObjects(Location.class));
  for (Location i : sortedLocationSet) {
    locationsComboBox.addItem(i.getReference());
  }
  locationsComboBox.addItemListener((ItemEvent e) -> locationsComboBoxItemStateChanged(e));
  doTable.setModel(new DriveOrderTableModel(transportOrder.getDriveOrders()));
  doTable.setDefaultEditor(TCSObjectReference.class, new DefaultCellEditor(locationsComboBox));
  doTable.setDefaultEditor(String.class, new DefaultCellEditor(operationTypesComboBox));

  // Properties
  propertyTable.setModel(new PropertyTableModel(transportOrder.getProperties()));
}
 
Example 5
Source Project: openjdk-8   Source File: Test6505027.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 6
Source Project: dragonwell8_jdk   Source File: Test6505027.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 7
Source Project: nextreports-designer   Source File: DesignerTablePanel.java    License: Apache License 2.0 6 votes vote down vote up
public void updateGroupByItems(int dragRow, int dropRow) {
    MyRow drag_row = (MyRow) model.getObjectForRow(dragRow);
    JComboBox groupByComboDrag = (JComboBox) ((DefaultCellEditor) table.getCellEditor(dragRow, 6)).getComponent();

    MyRow drop_row = (MyRow) model.getObjectForRow(dropRow);
    JComboBox groupByComboDrop = (JComboBox) ((DefaultCellEditor) table.getCellEditor(dropRow, 6)).getComponent();

    String sDrag = (String) groupByComboDrag.getItemAt(0);
    String sDrop = (String) groupByComboDrop.getItemAt(0);

    if ("".equals(sDrag) && !sDrag.equals(sDrop)) {
        groupByComboDrop.insertItemAt("", 0);
        groupByComboDrag.removeItem("");
    }

    if ("".equals(sDrop) && !sDrop.equals(sDrag)) {
        groupByComboDrag.insertItemAt("", 0);
        groupByComboDrop.removeItem("");
    }
}
 
Example 8
Source Project: TencentKona-8   Source File: Test6505027.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 9
private void setupTableModel() {

    tablemodelParameterValues = new ParameterTableModel(dataFiles, parameterValues);
    tableParameterValues.setModel(tablemodelParameterValues);

    for (int columnIndex =
        0; columnIndex < (tablemodelParameterValues.getColumnCount() - 1); columnIndex++) {
      UserParameter<?, ?> parameter = tablemodelParameterValues.getParameter(columnIndex + 1);
      if (parameter instanceof ComboParameter) {
        Object choices[] = ((ComboParameter<?>) parameter).getChoices();
        tableParameterValues.getColumnModel().getColumn(columnIndex + 1)
            .setCellEditor(new DefaultCellEditor(new JComboBox<Object>(choices)));
      }
    }

  }
 
Example 10
Source Project: jdk8u60   Source File: Test6505027.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 11
Source Project: LGoodDatePicker   Source File: InternalUtilities.java    License: MIT License 6 votes vote down vote up
/**
 * setDefaultTableEditorsClicks, This sets the number of clicks required to start the default
 * table editors in the supplied table. Typically you would set the table editors to start after
 * 1 click or 2 clicks, as desired.
 *
 * The default table editors of the table editors that are supplied by the JTable class, for
 * Objects, Numbers, and Booleans. Note, the editor which is used to edit Objects, is the same
 * editor used for editing Strings.
 */
public static void setDefaultTableEditorsClicks(JTable table, int clickCountToStart) {
    TableCellEditor editor;
    editor = table.getDefaultEditor(Object.class);
    if (editor instanceof DefaultCellEditor) {
        ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
    }
    editor = table.getDefaultEditor(Number.class);
    if (editor instanceof DefaultCellEditor) {
        ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
    }
    editor = table.getDefaultEditor(Boolean.class);
    if (editor instanceof DefaultCellEditor) {
        ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
    }
}
 
Example 12
Source Project: marathonv5   Source File: TableRenderDemo.java    License: Apache License 2.0 6 votes vote down vote up
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
    // Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Knitting");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Pool");
    comboBox.addItem("None of the above");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));

    // Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
}
 
Example 13
Source Project: jdk8u-jdk   Source File: Test6505027.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 14
Source Project: netbeans   Source File: CodeSetupPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if(showParamTypes) {
        String paramName = (String) tableModel.getValueAt(row, 0);
        Class type = (column == 2) ? (Class) tableModel.getValueAt(row, 1) : Boolean.class;

        if (Enum.class.isAssignableFrom(type)) {
            JComboBox combo = new JComboBox(type.getEnumConstants());
            return new DefaultCellEditor(combo);
        } else if (type == Boolean.class || type == Boolean.TYPE) {
            JCheckBox cb = new JCheckBox();
            cb.setHorizontalAlignment(JLabel.CENTER);
            cb.setBorderPainted(true);
            return new DefaultCellEditor(cb);
        } else if (paramName.toLowerCase().contains(Constants.PASSWORD)) {
            return new DefaultCellEditor(new JPasswordField());
        }
    }

    return super.getCellEditor(row, column);
}
 
Example 15
Source Project: lucene-solr   Source File: QueryParserPaneProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setRangeSearchableFields(Collection<String> rangeSearchableFields) {
  pointRangeQueryTable.setModel(new PointTypesTableModel(rangeSearchableFields));
  pointRangeQueryTable.setShowGrid(true);
  String[] numTypes = Arrays.stream(PointTypesTableModel.NumType.values())
      .map(PointTypesTableModel.NumType::name)
      .toArray(String[]::new);
  JComboBox<String> numTypesCombo = new JComboBox<>(numTypes);
  numTypesCombo.setRenderer((list, value, index, isSelected, cellHasFocus) -> new JLabel(value));
  pointRangeQueryTable.getColumnModel().getColumn(PointTypesTableModel.Column.TYPE.getIndex()).setCellEditor(new DefaultCellEditor(numTypesCombo));
  pointRangeQueryTable.getColumnModel().getColumn(PointTypesTableModel.Column.TYPE.getIndex()).setCellRenderer(
      (table, value, isSelected, hasFocus, row, column) -> new JLabel((String) value)
  );
  pointRangeQueryTable.getColumnModel().getColumn(PointTypesTableModel.Column.FIELD.getIndex()).setPreferredWidth(PointTypesTableModel.Column.FIELD.getColumnWidth());
  pointRangeQueryTable.setPreferredScrollableViewportSize(pointRangeQueryTable.getPreferredSize());

  // set default type to Integer
  for (int i = 0; i < rangeSearchableFields.size(); i++) {
    pointRangeQueryTable.setValueAt(PointTypesTableModel.NumType.INT.name(), i, PointTypesTableModel.Column.TYPE.getIndex());
  }

}
 
Example 16
Source Project: netbeans   Source File: DDTable.java    License: Apache License 2.0 6 votes vote down vote up
DDTable(String[] headers, String titleKey, Editable editable) {
    super(new Object[0][headers.length], headers);
    this.headers = headers;
    this.titleKey = titleKey;
    this.editable = editable;
    this.darkerColor = getBackground().darker();

    setModel(new DDTableModel(headers, editable));
    setColors(editable);
    this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setIntercellSpacing(new Dimension(margin, margin));
    DefaultCellEditor dce = new DefaultCellEditor(new CellText(this));
    dce.setClickCountToStart(1);
    getColumnModel().getColumn(0).setCellEditor(dce);
    getColumnModel().getColumn(1).setCellEditor(dce);
}
 
Example 17
@Override
public void actionPerformed(ActionEvent e) {
    associationModel.addAlias("...");
    removeButton.setEnabled(true);
    aliasNameScrollPane.repaint();
    int rowIndex = 0;
    for (String aliasName : associationModel.getAliasNames()) {
        if (aliasName.equals("...")) {
            break;
        }
        rowIndex++;
    }
    DefaultCellEditor editor = (DefaultCellEditor) aliasNames.getCellEditor(rowIndex, 0);
    aliasNames.editCellAt(rowIndex, 0);
    final JTextField textField = (JTextField) editor.getComponent();
    textField.requestFocus();
    textField.selectAll();
}
 
Example 18
@Override
public TableCellEditor getCellEditor(int row, int column) {
	List<String> usedTypes = new LinkedList<String>();
	for (int i = 0; i < Ontology.VALUE_TYPE_NAMES.length; i++) {
		if ((i != Ontology.ATTRIBUTE_VALUE) && (i != Ontology.FILE_PATH)
				&& (!Ontology.ATTRIBUTE_VALUE_TYPE.isA(i, Ontology.DATE_TIME))) {
			usedTypes.add(Ontology.ATTRIBUTE_VALUE_TYPE.mapIndex(i));
		}
	}
	String[] valueTypes = new String[usedTypes.size()];
	int vCounter = 0;
	for (String type : usedTypes) {
		valueTypes[vCounter++] = type;
	}
	JComboBox<String> typeBox = new JComboBox<>(valueTypes);
	typeBox.setBackground(javax.swing.UIManager.getColor("Table.cellBackground"));
	return new DefaultCellEditor(typeBox);
}
 
Example 19
Source Project: hottub   Source File: Test6505027.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 20
Source Project: ramus   Source File: TableCellEditorFactory.java    License: GNU General Public License v3.0 6 votes vote down vote up
private TableCellEditor createBaseQualifierEditor() {
    List<Qualifier> qualifiers = engine.getQualifiers();
    Collections.sort(qualifiers, new Comparator<Qualifier>() {
        @Override
        public int compare(Qualifier o1, Qualifier o2) {
            return collator.compare(o1.getName(), o2.getName());
        }
    });

    JComboBox box = new JComboBox();

    box.addItem(null);
    for (Qualifier qualifier : qualifiers)
        box.addItem(qualifier);

    return new DefaultCellEditor(box);
}
 
Example 21
Source Project: portmapper   Source File: EditPresetDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
private Component getPortsPanel() {
    final ActionMap actionMap = app.getContext().getActionMap(this.getClass(), this);

    final JPanel portsPanel = new JPanel(new MigLayout("", "", ""));
    portsPanel.setBorder(
            BorderFactory.createTitledBorder(app.getResourceMap().getString("preset_dialog.ports.title")));

    tableModel = new PortsTableModel(app, ports);
    portsTable = new JTable(tableModel);
    portsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    portsTable.getSelectionModel()
            .addListSelectionListener(e -> firePropertyChange(PROPERTY_PORT_SELECTED, false, isPortSelected()));
    final JComboBox<Protocol> protocolComboBox = new JComboBox<>();
    protocolComboBox.addItem(Protocol.TCP);
    protocolComboBox.addItem(Protocol.UDP);
    portsTable.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(protocolComboBox));

    portsPanel.add(new JScrollPane(portsTable), "spany 3");

    portsPanel.add(new JButton(actionMap.get(ACTION_ADD_PORT)), "wrap");
    portsPanel.add(new JButton(actionMap.get(ACTION_ADD_PORT_RANGE)), "wrap");
    portsPanel.add(new JButton(actionMap.get(ACTION_REMOVE_PORT)), "wrap");

    return portsPanel;
}
 
Example 22
Source Project: gameserver   Source File: GamedataEditorRenderFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public TableCellEditor getCellEditor(int row, int column, 
		String columnName, TableModel tableModel, JTable table) {
	if ( "value".equals(columnName) || "default".equals(columnName) ) {
		int modelColIndex = table.convertColumnIndexToModel(column);
		int modelRowIndex = table.convertRowIndexToModel(row);
		Object value =  this.tableModel.getValueAt(modelRowIndex, modelColIndex);
		if ( value instanceof BasicDBList ) {
			MongoDBArrayEditor editor =  new MongoDBArrayEditor();
			editor.setDBObject((BasicDBList)value);
			return editor;
		} else {
			JXTextField field = new JXTextField(value.toString());
			field.setPreferredSize(new Dimension(100, 36));
			field.setBorder(null);
			return new DefaultCellEditor(field);
		}
	}
	return null;
}
 
Example 23
Source Project: constellation   Source File: MappingPanel.java    License: Apache License 2.0 5 votes vote down vote up
private static void setColumn(final JTable table, final int columnIndex, final ArrayList<String> values0) {
    // Copy the list of labels into a String[] with a leading "" as the default "no choice" value.
    final String[] values = new String[values0.size() + 1];
    values[0] = "";
    for (int i = 0; i < values0.size(); i++) {
        values[i + 1] = values0.get(i);
    }

    final TableColumn tcol = table.getColumnModel().getColumn(columnIndex);
    tcol.setCellRenderer(new MappingCellRenderer(values));
    tcol.setCellEditor(new DefaultCellEditor(new JComboBox<>(values)));
}
 
Example 24
Source Project: openAGV   Source File: DriverGUI.java    License: Apache License 2.0 5 votes vote down vote up
private void initCommAdaptersComboBox(VehicleEntry vehicleEntry,
                                      int rowIndex,
                                      SingleCellEditor adapterCellEditor) {
  final CommAdapterComboBox comboBox = new CommAdapterComboBox();
  commAdapterRegistry.findFactoriesFor(vehicleEntry.getVehicle())
      .forEach(factory -> comboBox.addItem(factory));
  // Set the selection to the attached comm adapter, (The vehicle is already attached to a comm
  // adapter due to auto attachment on startup.)
  comboBox.setSelectedItem(vehicleEntry.getCommAdapterFactory());
  comboBox.setRenderer(new AdapterFactoryCellRenderer());
  comboBox.addPopupMenuListener(new BoundsPopupMenuListener());
  comboBox.addItemListener((ItemEvent evt) -> {
    if (evt.getStateChange() == ItemEvent.DESELECTED) {
      return;
    }

    // If we selected a comm adapter that's already attached, do nothing.
    if (Objects.equals(evt.getItem(), vehicleEntry.getCommAdapterFactory())) {
      LOG.debug("{} is already attached to: {}", vehicleEntry.getVehicleName(), evt.getItem());
      return;
    }

    int reply = JOptionPane.showConfirmDialog(
        null,
        bundle.getString("CommAdapterComboBox.confirmation.driverChange.text"),
        bundle.getString("CommAdapterComboBox.confirmation.driverChange.title"),
        JOptionPane.YES_NO_OPTION);
    if (reply == JOptionPane.NO_OPTION) {
      return;
    }

    attachManager.attachAdapterToVehicle(getSelectedVehicleName(),
                                         (VehicleCommAdapterFactory) comboBox.getSelectedItem());
  });
  adapterCellEditor.setEditorAt(rowIndex, new DefaultCellEditor(comboBox));

  vehicleEntry.addPropertyChangeListener(comboBox);
}
 
Example 25
Source Project: openAGV   Source File: ContinuousLoadPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize() {
  if (isInitialized()) {
    return;
  }

  // Get a kernel reference.
  try {
    sharedPortal = portalProvider.register();
  }
  catch (ServiceUnavailableException exc) {
    LOG.warn("Kernel unavailable", exc);
    return;
  }

  objectService = (TCSObjectService) sharedPortal.getPortal().getPlantModelService();

  Set<Vehicle> vehicles = new TreeSet<>(Comparators.objectsByName());
  vehicles.addAll(objectService.fetchObjects(Vehicle.class));
  JComboBox<TCSObjectReference<Vehicle>> vehiclesComboBox = new JComboBox<>();
  vehiclesComboBox.addItem(null);
  vehiclesComboBox.setRenderer(new StringListCellRenderer<>(x -> x == null ? "" : x.getName()));
  for (Vehicle curVehicle : vehicles) {
    vehiclesComboBox.addItem(curVehicle.getReference());
  }
  DefaultCellEditor vehicleEditor = new DefaultCellEditor(vehiclesComboBox);
  toTable.setDefaultEditor(TCSObjectReference.class, vehicleEditor);
  toTable.setDefaultRenderer(
      TCSObjectReference.class,
      new StringTableCellRenderer<TCSObjectReference<?>>(x -> x == null ? "" : x.getName()));

  doTable.getSelectionModel().addListSelectionListener(event -> updateElementStates());
  propertyTable.getSelectionModel().addListSelectionListener(event -> updateElementStates());
  
  updateElementStates();

  initialized = true;
}
 
Example 26
Source Project: jdk1.8-source-analysis   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example 27
Source Project: jdk8u_jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example 28
Source Project: TencentKona-8   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example 29
Source Project: jdk8u60   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example 30
Source Project: JDKSourceCode1.8   Source File: SynthTreeUI.java    License: MIT License 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}