Example usage for org.eclipse.jface.viewers ColorCellEditor ColorCellEditor

List of usage examples for org.eclipse.jface.viewers ColorCellEditor ColorCellEditor

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ColorCellEditor ColorCellEditor.

Prototype

public ColorCellEditor(Composite parent) 

Source Link

Document

Creates a new color cell editor parented under the given control.

Usage

From source file:com.generalrobotix.ui.view.graph.SeriesDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new RowLayout(SWT.VERTICAL));
    RowData rowdata = new RowData();
    rowdata.height = 100;//  ww w .jav a  2  s.c o m
    rowdata.width = 600;

    Label label = new Label(composite, SWT.LEFT);
    label.setText(MessageBundle.get("dialog.graph.series.dataseries")); //$NON-NLS-1$
    tableviewer_ = new TableViewer(composite, SWT.FULL_SELECTION | SWT.BORDER);
    tableviewer_.getControl().setLayoutData(rowdata);
    Table table = tableviewer_.getTable();
    table.setFont(Activator.getDefault().getFont("preference_table"));
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setText(colNode);
    column.setWidth(100);
    column = new TableColumn(table, SWT.NONE);
    column.setText(colAttribute);
    column.setWidth(100);
    column = new TableColumn(table, SWT.NONE);
    column.setText(colIndex);
    column.setWidth(60);
    column = new TableColumn(table, SWT.NONE);
    column.setText(colColor);
    column.setWidth(60);
    column = new TableColumn(table, SWT.NONE);
    column.setText(colLegend);
    column.setWidth(280);

    String[] properties = new String[] { null, null, null, "color", "legend" }; //$NON-NLS-1$ //$NON-NLS-2$
    tableviewer_.setColumnProperties(properties);
    CellEditor[] editors = new CellEditor[] { null, null, null, new ColorCellEditor(table),
            new TextCellEditor(table) };
    tableviewer_.setCellEditors(editors);
    tableviewer_.setContentProvider(new ArrayContentProvider());
    tableviewer_.setLabelProvider(new MyLabelProvider());
    tableviewer_.setCellModifier(new MyCellModifier(tableviewer_));

    tableviewer_.setInput(tableModel_.getList());

    Composite line3 = new Composite(composite, SWT.NONE);
    line3.setLayout(new RowLayout());
    Group group0 = new Group(line3, SWT.NONE);
    group0.setText(ROBOT_MODEL);
    group0.setLayout(new FillLayout());
    comboModel_ = new Combo(group0, SWT.READ_ONLY);
    comboModel_.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            comboType_.removeAll();
            comboLink_.removeAll();
            comboAttr_.removeAll();

            Iterator<String> it = nodeMap.keySet().iterator();
            if (tableModel_.getRowCount() > 0) {
                String curAttr = currentGraph_.getTrendGraph().getDataItemInfoList()[0].dataItem.attribute;
                while (it.hasNext()) {
                    String key = it.next();
                    if (nodeMap.get(key).contains(curAttr))
                        comboType_.add(key);
                }
            } else {
                while (it.hasNext()) {
                    comboType_.add(it.next());
                }
            }
            comboType_.setEnabled(true);
            comboLink_.setEnabled(false);
            comboAttr_.setEnabled(false);
            setButton_.setEnabled(false);

            if (comboType_.getItemCount() > 0) {
                comboType_.select(0);
                comboType_.notifyListeners(SWT.Selection, null);
            }

        }
    });
    Group group1 = new Group(line3, SWT.NONE);
    group1.setText(DATA_TYPE);
    group1.setLayout(new FillLayout());
    comboType_ = new Combo(group1, SWT.READ_ONLY);
    comboType_.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {

            comboLink_.removeAll();
            comboAttr_.removeAll();

            String type = comboType_.getItem(comboType_.getSelectionIndex());
            String modelName = comboModel_.getItem(comboModel_.getSelectionIndex());
            Iterator<GrxModelItem> it = currentModels_.iterator();
            GrxModelItem model = null;
            while (it.hasNext()) {
                model = it.next();
                if (model.getName().equals(modelName))
                    break;
            }
            if (type.equals("Joint")) { //$NON-NLS-1$
                Vector<GrxLinkItem> li = model.links_;
                for (int i = 0; i < li.size(); i++)
                    comboLink_.add(li.get(i).getName());
            } else {
                String t = null;
                if (type.equals("ForceSensor")) //$NON-NLS-1$
                    t = "Force"; //$NON-NLS-1$
                else if (type.equals("Gyro")) //$NON-NLS-1$
                    t = "RateGyro"; //$NON-NLS-1$
                else if (type.equals("AccelerationSensor")) //$NON-NLS-1$
                    t = "Acceleration"; //$NON-NLS-1$
                String[] snames = model.getSensorNames(t);

                if (snames != null) {
                    for (int i = 0; i < snames.length; i++) {
                        comboLink_.add(snames[i]);
                    }
                }
            }
            comboLink_.setEnabled(true);
            comboAttr_.setEnabled(false);
            setButton_.setEnabled(false);

            if (comboLink_.getItemCount() > 0) {
                comboLink_.select(0);
                comboLink_.notifyListeners(SWT.Selection, null);
            }
        }
    });
    Group group2 = new Group(line3, SWT.NONE);
    group2.setText(LINK_NAME);
    group2.setLayout(new FillLayout());
    comboLink_ = new Combo(group2, SWT.READ_ONLY);
    comboLink_.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {

            comboAttr_.removeAll();

            String type = comboType_.getItem(comboType_.getSelectionIndex());
            List<String> l = nodeMap.get(type);
            if (type.equals("Joint")) {
                String modelName = comboModel_.getItem(comboModel_.getSelectionIndex());
                Iterator<GrxModelItem> it = currentModels_.iterator();
                GrxModelItem model = null;
                while (it.hasNext()) {
                    model = it.next();
                    if (model.getName().equals(modelName))
                        break;
                }
                String linkName = comboLink_.getItem(comboLink_.getSelectionIndex());
                boolean isControlJoint = false;
                if (model != null) {
                    GrxLinkItem link = model.getLink(linkName);
                    if (link != null)
                        if (link.jointType_.equals("rotate") || link.jointType_.equals("slide"))
                            isControlJoint = true;
                }
                if (tableModel_.getRowCount() > 0) {
                    String curAttr = (String) tableModel_.getValueAt(0, 1);
                    if (!isControlJoint)
                        if (curAttr.equals("translation") || curAttr.equals("attitude"))
                            comboAttr_.add(curAttr);
                        else
                            ;
                    else if (l.contains(curAttr))
                        comboAttr_.add(curAttr);
                    else
                        ;
                } else {
                    if (!isControlJoint) {
                        comboAttr_.add("translation");
                        comboAttr_.add("attitude");
                    } else {
                        Iterator<String> it0 = l.iterator();
                        while (it0.hasNext()) {
                            comboAttr_.add(it0.next());
                        }
                    }
                }
            } else {
                if (tableModel_.getRowCount() > 0) {
                    String curAttr = (String) tableModel_.getValueAt(0, 1);
                    if (l.contains(curAttr))
                        comboAttr_.add(curAttr);
                } else {
                    Iterator<String> it0 = l.iterator();
                    while (it0.hasNext())
                        comboAttr_.add(it0.next());
                }
            }
            comboAttr_.setEnabled(true);

            setButton_.setEnabled(comboAttr_.getItemCount() > 0);

            if (comboAttr_.getItemCount() > 0)
                comboAttr_.select(0);
        }
    });
    Group group3 = new Group(line3, SWT.NONE);
    group3.setText(ATTRIBUTE);
    group3.setLayout(new FillLayout());
    comboAttr_ = new Combo(group3, SWT.READ_ONLY);
    removeButton_ = new Button(line3, SWT.PUSH);
    removeButton_.setText(MessageBundle.get("dialog.graph.series.remove")); //$NON-NLS-1$
    removeButton_.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            int ind = tableviewer_.getTable().getSelectionIndex();
            if (ind < 0)
                return;

            tableModel_.removeRow(ind);
            tableviewer_.refresh();
            int cnt = tableModel_.getRowCount();
            if (cnt < 1) {
                _resetSelection();
                return;
            }
            if (ind >= cnt) {
                ind -= 1;
            }
            tableviewer_.getTable().select(ind);
        }
    });
    removeButton_.setEnabled(true);
    setButton_ = new Button(line3, SWT.PUSH);
    setButton_.setText(MessageBundle.get("dialog.graph.series.set")); //$NON-NLS-1$
    setButton_.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            int length = 1;
            String combo1 = (String) comboType_.getItem(comboType_.getSelectionIndex());
            if (combo1.equals("ForceSensor") || //$NON-NLS-1$
            combo1.equals("AccelerationSensor") || //$NON-NLS-1$
            combo1.equals("Gyro")) //$NON-NLS-1$
                length = 3;
            String model = comboModel_.getItem(comboModel_.getSelectionIndex());
            String link = comboLink_.getItem(comboLink_.getSelectionIndex());
            String attr = comboAttr_.getItem(comboAttr_.getSelectionIndex());
            if (combo1.equals("Joint") && (attr.equals("translation") || attr.equals("attitude")))
                length = 3;
            for (int i = 0; i < length; i++) {
                String legend = model + "." + link + "." + attr + (length > 1 ? "." + i : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                if (!tableModel_.contains(legend)) {
                    DataItemInfo newDataItemInfo = new DataItemInfo(
                            new DataItem(model, link, attr, length > 1 ? i : -1,
                                    comboType_.getItem(comboType_.getSelectionIndex())),
                            currentGraph_.getTrendGraph().getGraphColor(graphIndex), legend);
                    tableModel_.addRow(newDataItemInfo, legend);
                    tableviewer_.refresh();
                    graphIndex++;
                }
            }
            removeButton_.setEnabled(true);
            comboLink_.notifyListeners(SWT.Selection, null);
        }
    });
    _resetSelection();
    return composite;
}

From source file:com.google.devtools.depan.view_doc.eclipse.ui.widgets.EdgeDisplayTableControl.java

License:Apache License

public EdgeDisplayTableControl(Composite parent) {
    super(parent, SWT.NONE);
    setLayout(Widgets.buildContainerLayout(1));

    propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);

    // Layout embedded table
    Table propTable = propViewer.getTable();
    propTable.setLayoutData(Widgets.buildGrabFillData());

    // initialize the table
    propTable.setHeaderVisible(true);/*from   w  ww.j a  va  2s.co m*/
    propTable.setToolTipText("Edge Display Properties");
    EditColTableDef.setupTable(TABLE_DEF, propTable);

    // Configure cell editing
    CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length];
    cellEditors[INDEX_NAME] = null;
    cellEditors[INDEX_HEAD] = null;
    cellEditors[INDEX_TAIL] = null;
    cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable);
    cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable,
            toString(EdgeDisplayProperty.LineStyle.values(), true));
    cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable,
            toString(EdgeDisplayProperty.ArrowheadStyle.values(), true));

    propViewer.setCellEditors(cellEditors);
    propViewer.setLabelProvider(new EdgeDisplayLabelProvider());
    propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF));
    propViewer.setCellModifier(new EdgeDisplayCellModifier());
    propViewer.setContentProvider(ArrayContentProvider.getInstance());

    configSorters(propTable);
}

From source file:com.google.devtools.depan.view_doc.eclipse.ui.widgets.RelationDisplayTableControl.java

License:Apache License

public RelationDisplayTableControl(Composite parent) {
    super(parent, SWT.NONE);
    setLayout(Widgets.buildContainerLayout(1));

    propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);

    // Layout embedded table
    Table propTable = propViewer.getTable();
    propTable.setLayoutData(Widgets.buildGrabFillData());

    // initialize the table
    propTable.setHeaderVisible(true);//from  w  ww  . ja  va 2  s  .c om
    propTable.setToolTipText("Relations Display Properties");
    EditColTableDef.setupTable(TABLE_DEF, propTable);

    // Configure cell editing
    CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length];
    cellEditors[INDEX_NAME] = null;
    cellEditors[INDEX_SOURCE] = null;
    cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable);
    cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable,
            toString(EdgeDisplayProperty.LineStyle.values(), true));
    cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable,
            toString(EdgeDisplayProperty.ArrowheadStyle.values(), true));

    propViewer.setCellEditors(cellEditors);
    propViewer.setLabelProvider(new EdgeDisplayLabelProvider());
    propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF));
    propViewer.setCellModifier(new EdgeDisplayCellModifier());

    // TODO: Add column sorters, filters?
    configSorters(propTable);

    // Configure content last: use updateTable() to render relations
    propViewer.setContentProvider(ArrayContentProvider.getInstance());
}

From source file:de.uniluebeck.itm.spyglass.gui.databinding.ColorEditingSupport.java

License:Open Source License

/**
 * Constructor/*from  w w w  . j a v  a  2  s.c  o m*/
 *
 * @param viewer
 *            the column viewer
 * @param dbc
 *            the data binding context
 * @param elementName
 *            the name of the model's element
 *
 */
public ColorEditingSupport(final ColumnViewer viewer, final DataBindingContext dbc, final String elementName) {
    super(viewer, dbc);
    this.dbc = dbc;
    this.elementName = elementName;
    cellEditor = new ColorCellEditor(((TableViewer) viewer).getTable());
}

From source file:de.uniluebeck.itm.spyglass.plugin.nodesensorrange.NodeSensorRangeEditingSupport.java

License:Open Source License

public NodeSensorRangeEditingSupport(final ColumnViewer viewer, final DataBindingContext dbc,
        final String elementName) {

    super(viewer, dbc);

    this.dbc = dbc;
    this.elementName = elementName;

    final boolean isNumberTextField = NodeSensorRangeXMLConfig.PROPERTYNAME_LINE_WIDTH.equals(elementName)
            || NodeSensorRangeXMLConfig.PROPERTYNAME_BACKGROUND_ALPHA.equals(elementName);
    final boolean isColorField = NodeSensorRangeXMLConfig.PROPERTYNAME_BACKGROUND_R_G_B.equals(elementName)
            || NodeSensorRangeXMLConfig.PROPERTYNAME_COLOR_R_G_B.equals(elementName);

    if (isNumberTextField) {

        this.cellEditor = new TextCellEditor((Composite) viewer.getControl());

    } else if (isColorField) {

        this.cellEditor = new ColorCellEditor((Composite) viewer.getControl());

    } else if (NodeSensorRangeXMLConfig.PROPERTYNAME_RANGE_TYPE.equals(elementName)) {

        this.cellEditor = new ComboBoxCellEditor((Composite) viewer.getControl(),
                new String[] { "Circle", "Cone", "Rectangle" });

    }/* ww  w  .  j  av a2s. co m*/
}

From source file:era.foss.typeeditor.datatype.EnumColorEditingSupport.java

License:Open Source License

/**
 * Instantiates a new enum color editing support.
 *
 * @param viewer the viewer/* w  ww .  j  a  v a 2s .  co  m*/
 */
public EnumColorEditingSupport(ColumnViewer viewer) {
    super(viewer);
    colorCellEditor = new ColorCellEditor((Composite) viewer.getControl());
}

From source file:org.eclipse.e4.tools.properties.ColorPropertyDescriptor.java

License:Open Source License

/**
 * The <code>ColorPropertyDescriptor</code> implementation of this 
 * <code>IPropertyDescriptor</code> method creates and returns a new
 * <code>ColorCellEditor</code>.
 * <p>//from  ww w.  j  a va  2s .c  o  m
 * The editor is configured with the current validator if there is one.
 * </p>
 */
public CellEditor createPropertyEditor(Composite parent) {
    CellEditor editor = new ColorCellEditor(parent);
    if (getValidator() != null) {
        editor.setValidator(getValidator());
    }
    return editor;
}

From source file:org.eclipse.gmf.runtime.diagram.ui.properties.descriptors.NotationPropertyDescriptor.java

License:Open Source License

/**
 * Create a cell editor for a data value.
 * /*from   ww w .j  a  v  a 2s . co m*/
 * @param composite - parent composite @return - cell editor to edit
 * property value
 * 
 * @see <code> createPropertyEditor </code>
 */
protected CellEditor createDataTypeCellEditor(Composite composite) {

    if (isColor()) {
        return new ColorCellEditor(composite);
    }
    if (isGradient()) {
        return new GradientCellEditor(composite);
    }

    CellEditor cellEditor = super.createDataTypeCellEditor(composite);

    if (isFontHeight()) {
        cellEditor.setValidator(getPositiveIntegerValidator());
    }

    if (getFeature() == NotationPackage.eINSTANCE.getFillStyle_Transparency()) {
        cellEditor.setValidator(getIntegerIntervalValidator());
    }

    return cellEditor;
}

From source file:org.kalypso.ogc.gml.featureview.modfier.ColorModifier.java

License:Open Source License

@Override
public CellEditor createCellEditor(final Composite parent) {
    return new ColorCellEditor(parent);
}

From source file:org.kalypso.ui.editor.styleeditor.colorMapEntryTable.ColorMapEntryTable.java

License:Open Source License

/**
 * This function creates the cell editors for the table viewer.
 * /*from w ww.j av a  2  s.com*/
 * @param parent
 *          The parent table viewer.
 */
private void createEditors(final TableViewer parent) {
    /* Memory for the cell editors. */
    final CellEditor[] editors = new CellEditor[COLUMN_NAMES.length];

    /* Get the table. */
    final Table table = parent.getTable();

    /* Create the label cell editor. */
    final TextCellEditor labelEditor = new TextCellEditor(table);
    editors[0] = labelEditor;

    /* Create the quantity cell editor. */
    final TextCellEditor quantityEditor = new TextCellEditor(table);
    editors[1] = quantityEditor;

    /* Create the color cell editor. */
    editors[2] = new ColorCellEditor(table);

    /* Create the opacity cell editor. */
    final TextCellEditor opacityEditor = new TextCellEditor(table);
    editors[3] = opacityEditor;

    /* Configure the label cell editor. */
    final Text labelText = (Text) labelEditor.getControl();
    labelText.setTextLimit(100);

    /* Configure the quantity cell editor. */
    final Text quantityText = (Text) quantityEditor.getControl();
    quantityText.addVerifyListener(new VerifyListener() {
        /**
         * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
         */
        @Override
        public void verifyText(final VerifyEvent e) {
            if (e.text.matches(INTEGER_FIELD) || e.text.matches(FLOATING_POINT_FIELD))
                e.doit = true;
        }
    });

    /* Configure the opacity cell editor. */
    final Text opacityText = (Text) opacityEditor.getControl();
    opacityText.addVerifyListener(new VerifyListener() {
        /**
         * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
         */
        @Override
        public void verifyText(final VerifyEvent e) {
            if (e.text.matches(NON_NEGATIVE_INTEGER_FIELD) || e.text.matches(NON_NEGATIVE_FLOATING_POINT_FIELD))
                e.doit = true;
        }
    });

    /* Set the cell editors. */
    parent.setCellEditors(editors);
}