Java Examples for javax.swing.DefaultCellEditor

The following java examples will help you to understand the usage of javax.swing.DefaultCellEditor. These source code samples are taken from different open source projects.

Example 1
Project: jdk7u-jdk-master  File: javax_swing_DefaultCellEditor.java View source code
protected void validate(DefaultCellEditor before, DefaultCellEditor after) {
    String text = ((JTextComponent) after.getComponent()).getText();
    if (!text.equals(((JTextComponent) before.getComponent()).getText()))
        throw new Error("Invalid text in component: " + text);
}
Example 2
Project: ManagedRuntimeInitiative-master  File: javax_swing_DefaultCellEditor.java View source code
protected void validate(DefaultCellEditor before, DefaultCellEditor after) {
    String text = ((JTextComponent) after.getComponent()).getText();
    if (!text.equals(((JTextComponent) before.getComponent()).getText()))
        throw new Error("Invalid text in component: " + text);
}
Example 3
Project: openjdk8-jdk-master  File: javax_swing_DefaultCellEditor.java View source code
protected void validate(DefaultCellEditor before, DefaultCellEditor after) {
    String text = ((JTextComponent) after.getComponent()).getText();
    if (!text.equals(((JTextComponent) before.getComponent()).getText()))
        throw new Error("Invalid text in component: " + text);
}
Example 4
Project: openjdk-master  File: TAB.java View source code
static void initTest(Container contentPane) {
    // Take the dummy data from SwingSet.
    final String[] names = { "First Name", "Last Name", "Favorite Color", "Favorite Number", "Vegetarian" };
    final Object[][] data = { { "Mark", "Andrews", "Red", new Integer(2), new Boolean(true) }, { "Tom", "Ball", "Blue", new Integer(99), new Boolean(false) }, { "Alan", "Chung", "Green", new Integer(838), new Boolean(false) }, { "Jeff", "Dinkins", "Turquois", new Integer(8), new Boolean(true) }, { "Amy", "Fowler", "Yellow", new Integer(3), new Boolean(false) }, { "Brian", "Gerhold", "Green", new Integer(0), new Boolean(false) }, { "James", "Gosling", "Pink", new Integer(21), new Boolean(false) }, { "David", "Karlton", "Red", new Integer(1), new Boolean(false) }, { "Dave", "Kloba", "Yellow", new Integer(14), new Boolean(false) }, { "Peter", "Korn", "Purple", new Integer(12), new Boolean(false) }, { "Phil", "Milne", "Purple", new Integer(3), new Boolean(false) }, { "Dave", "Moore", "Green", new Integer(88), new Boolean(false) }, { "Hans", "Muller", "Maroon", new Integer(5), new Boolean(false) }, { "Rick", "Levenson", "Blue", new Integer(2), new Boolean(false) }, { "Tim", "Prinzing", "Blue", new Integer(22), new Boolean(false) }, { "Chester", "Rose", "Black", new Integer(0), new Boolean(false) }, { "Ray", "Ryan", "Gray", new Integer(77), new Boolean(false) }, { "Georges", "Saab", "Red", new Integer(4), new Boolean(false) }, { "Willie", "Walker", "Phthalo Blue", new Integer(4), new Boolean(false) }, { "Kathy", "Walrath", "Blue", new Integer(8), new Boolean(false) }, { "Arnaud", "Weber", "Green", new Integer(44), new Boolean(false) } };
    // Create a model of the data.
    TableModel dataModel = new AbstractTableModel() {

        // These methods always need to be implemented.
        public int getColumnCount() {
            return names.length;
        }

        public int getRowCount() {
            return data.length;
        }

        public Object getValueAt(int row, int col) {
            return data[row][col];
        }

        // The default implementations of these methods in
        // AbstractTableModel would work, but we can refine them.
        public String getColumnName(int column) {
            return names[column];
        }

        public Class getColumnClass(int c) {
            return getValueAt(0, c).getClass();
        }

        public boolean isCellEditable(int row, int col) {
            return true;
        }

        public void setValueAt(Object aValue, int row, int column) {
            System.out.println("Setting value to: " + aValue);
            data[row][column] = aValue;
        }
    };
    // Create the table
    JTable tableView = new JTable(dataModel);
    // Turn off auto-resizing so that we can set column sizes programmatically.
    // In this mode, all columns will get their preferred widths, as set blow.
    tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    // Create a combo box to show that you can use one in a table.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Red");
    comboBox.addItem("Orange");
    comboBox.addItem("Yellow");
    comboBox.addItem("Green");
    comboBox.addItem("Blue");
    comboBox.addItem("Indigo");
    comboBox.addItem("Violet");
    TableColumn colorColumn = tableView.getColumn("Favorite Color");
    // Use the combo box as the editor in the "Favorite Color" column.
    colorColumn.setCellEditor(new DefaultCellEditor(comboBox));
    // Set a pink background and tooltip for the Color column renderer.
    DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer();
    colorColumnRenderer.setBackground(Color.pink);
    colorColumnRenderer.setToolTipText("Click for combo box");
    colorColumn.setCellRenderer(colorColumnRenderer);
    // Set a tooltip for the header of the colors column.
    TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
        ((DefaultTableCellRenderer) headerRenderer).setToolTipText("Hi Mom!");
    // Set the width of the "Vegetarian" column.
    TableColumn vegetarianColumn = tableView.getColumn("Vegetarian");
    vegetarianColumn.setPreferredWidth(100);
    // Show the values in the "Favorite Number" column in different colors.
    TableColumn numbersColumn = tableView.getColumn("Favorite Number");
    DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() {

        public void setValue(Object value) {
            int cellValue = (value instanceof Number) ? ((Number) value).intValue() : 0;
            setForeground((cellValue > 30) ? Color.black : Color.red);
            setText((value == null) ? "" : value.toString());
        }
    };
    numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT);
    numbersColumn.setCellRenderer(numberColumnRenderer);
    numbersColumn.setPreferredWidth(110);
    // Finish setting up the table.
    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED));
    scrollpane.setPreferredSize(new Dimension(430, 200));
    contentPane.add(scrollpane);
}
Example 5
Project: statalign-master  File: VueBPList.java View source code
private void init() {
    Object[] col = { "Sec.Str.", "5' partner", "3' partner", "5' edge", "3' edge", "Orientation", "Remove" };
    columns = new ArrayList<Object>();
    for (int i = 0; i < col.length; i++) {
        columns.add(col[i]);
    }
    _backup = new ArrayList<Double>();
    data = new ArrayList<ModeleBP>();
    for (ModeleBP ms : _vp.getRNA().getAllBPs()) {
        data.add(ms);
    }
    Collections.sort(data);
    _tm = new BPTableModel();
    table = new JTable(_tm);
    table.setDefaultRenderer(Color.class, new ColorRenderer(true));
    table.setDefaultRenderer(Actions.class, new ActionRenderer());
    table.setDefaultEditor(ModeleBP.Edge.class, new DefaultCellEditor(new JComboBox(ModeleBP.Edge.values())));
    table.setDefaultEditor(ModeleBP.Stericity.class, new DefaultCellEditor(new JComboBox(ModeleBP.Stericity.values())));
    table.setDefaultEditor(Actions.class, new ActionEditor(this));
    table.setPreferredScrollableViewportSize(new Dimension(500, 500));
    table.getModel().addTableModelListener(this);
    table.setRowHeight(25);
    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane);
    // content panes must be opaque
    setOpaque(true);
    this.doLayout();
    JOptionPane.showMessageDialog(_vp, this, "Base pairs Edition", JOptionPane.PLAIN_MESSAGE);
}
Example 6
Project: GdxStudio-master  File: PropertyPanel.java View source code
@Override
public void update(String... names) {
    rowCount = 0;
    super.update("Name", "" + SceneEditor.selectedActor.getName(), "X", "" + SceneEditor.selectedActor.getX(), "Y", "" + SceneEditor.selectedActor.getY(), "Width", "" + SceneEditor.selectedActor.getWidth(), "Height", "" + SceneEditor.selectedActor.getHeight(), "OriginX", "" + SceneEditor.selectedActor.getOriginX(), "OriginY", "" + SceneEditor.selectedActor.getOriginY(), "Rotation", "" + SceneEditor.selectedActor.getRotation(), "Z-Index", "" + SceneEditor.selectedActor.getZIndex(), "Color", "" + SceneEditor.selectedActor.getColor().toString(), "Touchable", "" + SceneEditor.selectedActor.getTouchable().toString(), "Visible", "" + SceneEditor.selectedActor.isVisible());
    editors.set(12, createTextFieldEditor());
    editors.set(13, createTextFieldEditor());
    editors.set(14, createTextFieldEditor());
    editors.set(15, createTextFieldEditor());
    /* From here it varies for each type */
    if (SceneEditor.selectedActor instanceof ImageJson) {
        addRow("Texture", "" + // row 7
        ((ImageJson) SceneEditor.selectedActor).getTexName());
        texcombo.removeAllItems();
        for (String tex : Asset.texMap.keys()) texcombo.addItem(tex);
        editors.set(12, new DefaultCellEditor(texcombo));
    }
    /* FONTS */
    if (SceneEditor.selectedActor instanceof Label) {
        addRow("Font", "" + // row 7
        Asset.fontMap.getKey(// row 7
        ((Label) SceneEditor.selectedActor).getStyle().font, // row 7
        false));
        addRow("Text", "" + ((Label) SceneEditor.selectedActor).getText());
        fontcombo.removeAllItems();
        for (String font : Asset.fontMap.keys()) fontcombo.addItem(font);
        editors.set(12, new DefaultCellEditor(fontcombo));
    }
    if (SceneEditor.selectedActor instanceof TextButton) {
        addRow("Text", "" + ((TextButton) SceneEditor.selectedActor).getText());
    }
    if (SceneEditor.selectedActor instanceof TextField) {
        addRow("Text", "" + ((TextField) SceneEditor.selectedActor).getText());
        addRow("MessageText", "" + ((TextField) SceneEditor.selectedActor).getMessageText());
    //addRow("Password", ""+((TextFieldJson)Sink.selectedActor).getPasswordMode()});
    }
    if (SceneEditor.selectedActor instanceof CheckBox)
        addRow("Text", "" + ((CheckBox) SceneEditor.selectedActor).getText());
    if (SceneEditor.selectedActor instanceof Dialog) {
        editors.set(12, createBooleanEditor());
        editors.set(13, createBooleanEditor());
        editors.set(14, createBooleanEditor());
        addRow("Modal", "" + //7
        ((Dialog) SceneEditor.selectedActor).isModal());
        addRow("Moveble", "" + //8
        ((Dialog) SceneEditor.selectedActor).isMovable());
        addRow("Resizable", "" + //9
        ((Dialog) SceneEditor.selectedActor).isResizable());
        addRow("Text", "" + ((Dialog) SceneEditor.selectedActor).getTitle());
    }
    if (SceneEditor.selectedActor instanceof Touchpad) {
        addRow("Deadzone", "" + Serializer.TouchpadSerializer.deadZoneRadius);
    }
    if (SceneEditor.selectedActor instanceof Slider) {
        Slider slider = ((Slider) SceneEditor.selectedActor);
        addRow("Min", "" + slider.getMinValue());
        addRow("Max", "" + slider.getMaxValue());
        addRow("Step", "" + slider.getStepSize());
        addRow("Value", "" + slider.getValue());
    }
    if (SceneEditor.selectedActor instanceof Sprite) {
        Sprite sprite = ((Sprite) SceneEditor.selectedActor);
        editors.set(12, createBooleanEditor());
        editors.set(13, createBooleanEditor());
        addRow("Active", "" + sprite.isAnimationActive);
        addRow("Looping", "" + sprite.isAnimationLooping);
        addRow("Duration", "" + sprite.getDuration());
        addRow("Textures", "" + sprite.toString());
    }
    int value = getRowCount();
    for (int i = 0; i < noOfRows - value; i++) addRow("", "");
}
Example 7
Project: eclipselink.runtime-master  File: ComboBoxTableCellRenderer.java View source code
protected JComboBox buildComboBox() {
    final JComboBox result = new JComboBox() {

        private boolean fakeFocus;

        public boolean hasFocus() {
            return fakeFocus || super.hasFocus();
        }

        public void paint(Graphics g) {
            fakeFocus = ComboBoxTableCellRenderer.this.fakeFocusFlag;
            super.paint(g);
            fakeFocus = false;
        }

        //wrap the renderer to deal with the prototypeDisplayValue
        public void setRenderer(final ListCellRenderer aRenderer) {
            super.setRenderer(new ListCellRenderer() {

                public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                    if (value == prototypeLabel) {
                        return prototypeLabel;
                    }
                    return aRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
        }

        public int getSelectedIndex() {
            boolean listNotCached = !listIsCached();
            if (listNotCached) {
                cacheList();
            }
            int index = super.getSelectedIndex();
            if (listNotCached) {
                uncacheList();
            }
            return index;
        }
    };
    // see javax.swing.DefaultCellEditor for usage
    result.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    result.addActionListener(this.buildActionListener());
    result.addPopupMenuListener(this.buildPopupMenuListener());
    //These are used to workaround problems with Swing trying to
    //determine the size of a comboBox with a large model
    result.setPrototypeDisplayValue(prototypeLabel);
    getListBox(result).setPrototypeCellValue(prototypeLabel);
    return result;
}
Example 8
Project: snap-desktop-master  File: SpectrumChooser.java View source code
private JTable createBandsTable(int index) {
    DisplayableSpectrum spectrum = spectra[index];
    final Band[] spectralBands = spectrum.getSpectralBands();
    Object[][] spectrumData = new Object[spectralBands.length][band_columns.length];
    for (int i = 0; i < spectralBands.length; i++) {
        Band spectralBand = spectralBands[i];
        final boolean selected = spectrum.isBandSelected(i) && spectrum.isSelected();
        spectrumData[i][band_selected_index] = selected;
        spectrumData[i][band_name_index] = spectralBand.getName();
        spectrumData[i][band_description_index] = spectralBand.getDescription();
        spectrumData[i][band_wavelength_index] = spectralBand.getSpectralWavelength();
        spectrumData[i][band_bandwidth_ndex] = spectralBand.getSpectralBandwidth();
        spectrumData[i][band_unit_index] = spectralBand.getUnit();
    }
    final BandTableModel bandTableModel = new BandTableModel(spectrumData, band_columns);
    bandTableModel.addTableModelListener( e -> {
        e.getSource();
        if (e.getColumn() == band_selected_index) {
            final DisplayableSpectrum spectrum1 = spectra[index];
            final int bandRow = e.getFirstRow();
            final Boolean selected = (Boolean) bandTableModel.getValueAt(bandRow, e.getColumn());
            spectrum1.setBandSelected(bandRow, selected);
            if (!selectionChangeLock) {
                selectionChangeLock = true;
                selectionAdmin.setBandSelected(index, bandRow, selected);
                selectionAdmin.updateSpectrumSelectionState(index, selectionAdmin.getState(index));
                tristateCheckBoxes[index].setState(selectionAdmin.getState(index));
                spectrum1.setSelected(selectionAdmin.isSpectrumSelected(index));
                selectionChangeLock = false;
            }
        }
    });
    JTable bandsTable = new JTable(bandTableModel);
    bandsTable.setRowSorter(new TableRowSorter<>(bandTableModel));
    final TableColumn selectionColumn = bandsTable.getColumnModel().getColumn(band_selected_index);
    final JCheckBox selectionCheckBox = new JCheckBox();
    selectionColumn.setCellEditor(new DefaultCellEditor(selectionCheckBox));
    selectionColumn.setMinWidth(20);
    selectionColumn.setMaxWidth(20);
    BooleanRenderer booleanRenderer = new BooleanRenderer();
    selectionColumn.setCellRenderer(booleanRenderer);
    final TableColumn wavelengthColumn = bandsTable.getColumnModel().getColumn(band_wavelength_index);
    wavelengthColumn.setCellRenderer(new DecimalTableCellRenderer(new DecimalFormat("###0.0##")));
    final TableColumn bandwidthColumn = bandsTable.getColumnModel().getColumn(band_bandwidth_ndex);
    bandwidthColumn.setCellRenderer(new DecimalTableCellRenderer(new DecimalFormat("###0.0##")));
    return bandsTable;
}
Example 9
Project: freemind-mmx-master  File: AttributeTable.java View source code
/**
     * 
     */
public Component prepareEditor(TableCellEditor tce, int row, int col) {
    ComboBoxModel model;
    JComboBox comboBox = (JComboBox) ((DefaultCellEditor) tce).getComponent();
    MindMapNode node = getAttributeTableModel().getNode();
    AttributeRegistry attributes = node.getMap().getRegistry().getAttributes();
    switch(col) {
        case 0:
            model = attributes.getComboBoxModel();
            comboBox.setEditable(!attributes.isRestricted());
            break;
        case 1:
            String attrName = getAttributeTableModel().getValueAt(row, 0).toString();
            model = attributes.getDefaultComboBoxModel(attrName);
            comboBox.setEditable(!attributes.isRestricted(attrName));
            break;
        default:
            model = getDefaultComboBoxModel();
    }
    comboBox.setModel(model);
    model.setSelectedItem(getValueAt(row, col));
    comboBox.addFocusListener(focusListener);
    comboBox.getEditor().getEditorComponent().addFocusListener(focusListener);
    Component editor = super.prepareEditor(tce, row, col);
    updateFontSize(editor, getZoom());
    return editor;
}
Example 10
Project: slumdroid-master  File: GuiAnalyzer.java View source code
/**
	 * Creates the layout.
	 */
private void createLayout() {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    resetAll();
    try {
        processGuiTree = new ProcessGuiTree(theFile.toString());
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
    int numWidgets = processGuiTree.getNumWidgets();
    colId = new Object[numWidgets];
    Object[] colWidgets = new Object[numWidgets];
    Object[] colName = new Object[numWidgets];
    Object[] colValue = new Object[numWidgets];
    colType = new Object[numWidgets];
    Object[] colScreen = new Object[numWidgets];
    Object[] colInteraction = new Object[numWidgets];
    Object[] colSimpleType = new Object[numWidgets];
    int item = 0;
    Collection<WidgetState> WidgetsColl = processGuiTree.getWidgets().values();
    for (WidgetState widget : WidgetsColl) {
        colId[item] = widget.getId();
        colWidgets[item] = widget.getType();
        colName[item] = widget.getName();
        colValue[item] = widget.getValue();
        colType[item] = widget.getTextType();
        colInteraction[item] = processGuiTree.getInteractions().get(widget.getId());
        colSimpleType[item] = widget.getSimpleType();
        colScreen[item] = new JButton(processGuiTree.getScreens().get(widget.getId()));
        item++;
    }
    tabelModel.addColumn("Id", colId);
    tabelModel.addColumn("Widgets Type", colWidgets);
    tabelModel.addColumn("Simple Type", colSimpleType);
    tabelModel.addColumn("Name", colName);
    tabelModel.addColumn("Valid Input", colValue);
    tabelModel.addColumn("Text Type", colType);
    tabelModel.addColumn("Interactions", colInteraction);
    tabelModel.addColumn("Perturbation", new String[] { "" });
    tabelModel.addColumn("Screenshot", colScreen);
    // ComboBox
    JComboBox<String> comboBox = new JComboBox<String>(comboValues);
    jTableInfo.getColumnModel().getColumn(7).setCellEditor(new DefaultCellEditor(comboBox));
    jTableInfo.getColumnModel().getColumn(7).setCellRenderer(new ComboBoxRenderer(comboValues));
    comboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent event) {
            changeWidgetInfo();
        }
    });
    jTableInfo.setRowHeight(20);
    jTableInfo.getColumnModel().getColumn(8).setMinWidth(0);
    jTableInfo.getColumnModel().getColumn(8).setMaxWidth(0);
    jTableInfo.getColumnModel().getColumn(8).setWidth(0);
    jTableInfo.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            changeWidgetInfo();
        }
    });
    firstImage();
}
Example 11
Project: ProjectLibre-master  File: ResourceMappingDialog.java View source code
public void addColumn(TableColumn tc) {
    if (columnIndex == 0) {
        //$NON-NLS-1$
        tc.setHeaderValue(//$NON-NLS-1$
        Messages.getString("ResourceMappingDialog.ImportedResources"));
        tc.setPreferredWidth(150);
    } else {
        //$NON-NLS-1$
        tc.setHeaderValue(//$NON-NLS-1$
        Messages.getString("ResourceMappingDialog.ServerResources"));
        tc.setPreferredWidth(150);
        //				tc.setCellEditor(new ListComboBoxCellEditor(new DefaultComboBoxModel(form.getResources())));
        tc.setCellEditor(new DefaultCellEditor(editorCombo));
    }
    tc.setCellRenderer(new DefaultTableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focused, int row, int column) {
            setEnabled(table == null || table.isEnabled());
            super.getTableCellRendererComponent(table, value, selected, focused, row, column);
            return this;
        }
    });
    super.addColumn(tc);
    columnIndex++;
}
Example 12
Project: compomics-utilities-master  File: MsConvertParametersDialog.java View source code
/**
     * Sets up the GUI components.
     *
     * @param msConvertParameters parameters to display on the interface,
     * ignored if null
     */
private void setUpGUI(MsConvertParameters msConvertParameters) {
    filtersTableScrollPane.getViewport().setOpaque(false);
    filtersTable.getTableHeader().setReorderingAllowed(false);
    if (msConvertParameters != null) {
        outputFormatCmb.setSelectedItem(msConvertParameters.getMsFormat());
        filters = (HashMap<Integer, String>) msConvertParameters.getFiltersMap().clone();
    } else {
        outputFormatCmb.setSelectedItem(MsFormat.mzML);
        filters = new HashMap<Integer, String>(2);
    }
    filterIndexes = new ArrayList<Integer>(filters.keySet());
    Collections.sort(filterIndexes);
    DefaultTableModel tableModel = new FiltersTableModel();
    filtersTable.setModel(tableModel);
    TableColumnModel tableColumnModel = filtersTable.getColumnModel();
    tableColumnModel.getColumn(0).setMinWidth(50);
    tableColumnModel.getColumn(0).setMaxWidth(50);
    TableColumn filterColumn = tableColumnModel.getColumn(1);
    filterColumn.setMinWidth(200);
    filterColumn.setMaxWidth(200);
    JComboBox comboBox = new JComboBox(ProteoWizardFilter.values());
    filterColumn.setCellEditor(new DefaultCellEditor(comboBox));
    for (final ProteoWizardFilter tempFilter : ProteoWizardFilter.values()) {
        JMenuItem tempFilterMenuItem = new javax.swing.JMenuItem(tempFilter.name);
        tempFilterMenuItem.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                if (!filters.containsKey(tempFilter.number)) {
                    filters.put(tempFilter.number, "");
                    updateTable();
                }
            }
        });
        addFilterMenu.add(tempFilterMenuItem);
    }
    outputFormatCmb.setRenderer(new AlignedListCellRenderer(SwingConstants.CENTER));
    utilitiesUserPreferences = UtilitiesUserPreferences.loadUserPreferences();
    if (utilitiesUserPreferences.getProteoWizardPath() == null) {
        int option = JOptionPane.showConfirmDialog(this, "Cannot find ProteoWizard. Do you want to download it now?", "Download ProteoWizard?", JOptionPane.YES_NO_OPTION);
        if (option == JOptionPane.YES_OPTION) {
            openWebPage();
        }
    }
    // display the current path
    if (utilitiesUserPreferences != null) {
        installationJTextField.setText(utilitiesUserPreferences.getProteoWizardPath());
        lastSelectedFolder = utilitiesUserPreferences.getProteoWizardPath();
    }
}
Example 13
Project: breakout-master  File: ObjectTreeTable.java View source code
@Override
public TableCellEditor getCellEditor(int row, int column) {
    Node node = getNodeAt(row);
    Class<?> valueClass = node.getValue() == null ? null : node.getValue().getClass();
    Class<?> storageClass = node.getStorageClass();
    if (node.getValue() instanceof Enum) {
        DefaultSelector<Object> selector = new DefaultSelector<Object>();
        selector.setAvailableValues(Arrays.asList(valueClass.getEnumConstants()));
        selector.comboBox().setRenderer(new ComboBoxCellRenderer());
        return new DefaultCellEditor(selector.comboBox());
    } else if (storageClass.isEnum()) {
        DefaultSelector<Object> selector = new DefaultSelector<Object>();
        selector.setAvailableValues(Arrays.asList(storageClass.getEnumConstants()));
        selector.comboBox().setRenderer(new ComboBoxCellRenderer());
        return new DefaultCellEditor(selector.comboBox());
    } else if (enumlikeTypes.containsKey(valueClass)) {
        DefaultSelector<Object> selector = new DefaultSelector<Object>();
        selector.setAvailableValues(enumlikeTypes.get(valueClass));
        selector.comboBox().setRenderer(new ComboBoxCellRenderer());
        return new DefaultCellEditor(selector.comboBox());
    } else if (enumlikeTypes.containsKey(storageClass)) {
        DefaultSelector<Object> selector = new DefaultSelector<Object>();
        selector.setAvailableValues(enumlikeTypes.get(storageClass));
        selector.comboBox().setRenderer(new ComboBoxCellRenderer());
        return new DefaultCellEditor(selector.comboBox());
    } else if (valueClass == boolean.class || valueClass == Boolean.class || storageClass == boolean.class || storageClass == Boolean.class) {
        return new DefaultCellEditor(new JCheckBox());
    } else if (valueClass == Date.class || storageClass == Date.class) {
        DateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        DatePickerCellEditor datePicker = new DatePickerCellEditor(format);
        datePicker.setClickCountToStart(0);
        return datePicker;
    }
    return super.getCellEditor(row, column);
}
Example 14
Project: Desktop-master  File: AttributeTable.java View source code
@SuppressWarnings("serial")
public TableCellEditor getCellEditor(final int row, final int col, EventObject e) {
    if (dce != null) {
        dce.stopCellEditing();
    }
    if (col == 1) {
        final MTextController textController = (MTextController) TextController.getController();
        if (e instanceof KeyEvent) {
            final KeyEvent kev = (KeyEvent) e;
            textController.getEventQueue().setFirstEvent(kev);
        }
        final IAttributeTableModel model = (IAttributeTableModel) getModel();
        final String text = getValueForEdit(row, col);
        final DialogTableCellEditor dialogTableCellEditor = new DialogTableCellEditor();
        EditNodeBase base = textController.getEditNodeBase(model.getNode(), text, dialogTableCellEditor.getEditControl(), false);
        if (base != null) {
            dialogTableCellEditor.setEditBase(base);
            return dialogTableCellEditor;
        }
    }
    final JComboBox comboBox;
    if (dce == null) {
        comboBox = new JComboBox();
        comboBox.addFocusListener(AttributeTable.focusListener);
        comboBox.getEditor().getEditorComponent().addFocusListener(AttributeTable.focusListener);
        comboBox.setRenderer(new TypedListCellRenderer());
        dce = new DefaultCellEditor(comboBox) {

            public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) {
                return super.getTableCellEditorComponent(table, ((AttributeTable) table).getValueForEdit(row, col), isSelected, row, col);
            }
        };
        dce.setClickCountToStart(CLICK_COUNT_TO_START);
    }
    return dce;
}
Example 15
Project: geotoolkit-master  File: JColorMapPane.java View source code
private void postParse() {
    guiTable.setModel(model);
    guiInvert.setEnabled(true);
    guiMinSpinner.setEnabled(true);
    guiMaxSpinner.setEnabled(true);
    if (model instanceof InterpolateColorModel) {
        guiMethod.setSelectedItem(Interpolate.class);
        setPalettes(PALETTES);
        guiTable.getColumnModel().getColumn(0).setCellRenderer(new NumberAlignRenderer());
        guiTable.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(new JTextField()));
        guiTable.getColumnModel().getColumn(1).setCellRenderer(new ColorCellRenderer());
        guiTable.getColumnModel().getColumn(1).setCellEditor(new ColorCellEditor());
        guiTable.getColumnModel().getColumn(2).setCellRenderer(new DeleteRenderer());
        guiTable.getColumnModel().getColumn(2).setCellEditor(new DeleteEditor());
        guiTable.getColumnExt(2).setMaxWidth(20);
        final InterpolateColorModel icm = (InterpolateColorModel) model;
        //restore NaN and min/max values
        boolean hasNaN = false;
        double min = Double.NaN;
        double max = Double.NaN;
        for (int i = 0, n = icm.points.size(); i < n; i++) {
            final double v = icm.points.get(i).getData().doubleValue();
            if (!Double.isNaN(v)) {
                min = Double.isNaN(min) ? v : Math.min(v, min);
                max = Double.isNaN(max) ? v : Math.max(v, max);
            } else {
                hasNaN = true;
            }
        }
        if (!Double.isNaN(min)) {
            guiMinSpinner.setValue(min);
            guiMaxSpinner.setValue(max);
        }
        guiNbStep.setValue(icm.points.size() - (hasNaN ? 1 : 0));
        guiNaN.setSelected(hasNaN);
    } else if (model instanceof CategorizeColorModel) {
        guiMethod.setSelectedItem(Categorize.class);
        setPalettes(PALETTES);
        guiTable.getColumnModel().getColumn(0).setCellRenderer(new NumberAlignRenderer());
        guiTable.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(new JTextField()));
        guiTable.getColumnModel().getColumn(1).setCellRenderer(new ColorCellRenderer());
        guiTable.getColumnModel().getColumn(1).setCellEditor(new ColorCellEditor());
        guiTable.getColumnModel().getColumn(2).setCellRenderer(new NumberAlignRenderer());
        guiTable.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(new JTextField()));
        guiTable.getColumnModel().getColumn(3).setCellRenderer(new DeleteRenderer());
        guiTable.getColumnModel().getColumn(3).setCellEditor(new DeleteEditor());
        guiTable.getColumnExt(3).setMaxWidth(20);
        final CategorizeColorModel ccm = (CategorizeColorModel) model;
        //restore NaN and min/max values
        boolean hasNaN = false;
        double min = Double.NaN;
        double max = Double.NaN;
        for (int i = 0, n = ccm.ths.size(); i < n; i++) {
            final Entry<Expression, Expression> exps = ccm.ths.get(i);
            Object val = exps.getKey().evaluate(n, Number.class);
            if (val instanceof Number) {
                final double v = ((Number) val).doubleValue();
                if (!Double.isNaN(v)) {
                    if (!Double.isInfinite(v)) {
                        min = Double.isNaN(min) ? v : Math.min(v, min);
                        max = Double.isNaN(max) ? v : Math.max(v, max);
                    }
                } else {
                    hasNaN = true;
                }
            }
        }
        if (!Double.isNaN(min)) {
            guiMinSpinner.setValue(min);
            guiMaxSpinner.setValue(max);
        }
        guiNbStep.setValue(ccm.ths.size() - (hasNaN ? 2 : 1));
        guiNaN.setSelected(hasNaN);
    } else if (model instanceof JenksColorModel) {
        guiMethod.setSelectedItem(Jenks.class);
        final JenksColorModel jcm = (JenksColorModel) model;
        setPalettes(PALETTES_NAMED);
        if (jcm.getPaletteName() != null) {
            guiPalette.setSelectedItem(jcm.getPaletteName());
        } else {
            guiPalette.setSelectedItem(0);
        }
        guiNbStep.setValue(jcm.getNbSteps());
        guiInvert.setEnabled(false);
        guiMinSpinner.setEnabled(false);
        guiMaxSpinner.setEnabled(false);
    }
    //disable and hide value table for jenks method
    guiAddOne.setVisible(!(model instanceof JenksColorModel));
    guiRemoveAll.setVisible(!(model instanceof JenksColorModel));
    guiTableScroll.setVisible(!(model instanceof JenksColorModel));
    guiJenksMessage.setVisible(model instanceof JenksColorModel);
    guiNoDataLabel.setVisible(model instanceof JenksColorModel);
    noDataContainer.setVisible(model instanceof JenksColorModel);
    if (layer instanceof CoverageMapLayer) {
        guiLblPalette.setVisible(true);
        guiPalette.setVisible(true);
        guiBand.setVisible(true);
        guiLblBand.setVisible(true);
        guiNaN.setVisible(true);
        guiInvert.setVisible(true);
        guiGenerate.setVisible(true);
        guiLblStep.setVisible(true);
        guiNbStep.setVisible(true);
    } else {
        guiLblPalette.setVisible(false);
        guiPalette.setVisible(false);
        guiBand.setVisible(false);
        guiLblBand.setVisible(false);
        guiNaN.setVisible(false);
        guiInvert.setVisible(false);
        guiGenerate.setVisible(false);
        guiLblStep.setVisible(false);
        guiNbStep.setVisible(false);
    }
    revalidate();
    repaint();
    //add a listener on the model to propage even
    model.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            firePropertyChange(PROPERTY_UPDATED, null, create());
        }
    });
}