Search in sources :

Example 1 with Color

use of org.eclipse.swt.graphics.Color in project cogtool by cogtool.

the class ScalableFrameFigure method setWidgetColor.

/**
     * Change the color for the temporary widget
     * @param color new color, in the toolkit-independent format
     */
public void setWidgetColor(int color) {
    figureColor.dispose();
    figureColor = new Color(null, GraphicsUtil.getRGBFromColor(color));
}
Also used : Color(org.eclipse.swt.graphics.Color)

Example 2 with Color

use of org.eclipse.swt.graphics.Color in project cogtool by cogtool.

the class PERTChartOperatorBar method paint.

//  ----------- UI METHODS _------------------------------------------------
@Override
public void paint(Graphics g) {
    g.pushState();
    try {
        Color drawColor = (selected) ? selectedColor : color;
        Rectangle bds = getBounds();
        g.setBackgroundColor(drawColor);
        g.setForegroundColor(ColorConstants.black);
        g.fillRectangle(bds);
        if (!selected) {
            g.setForegroundColor(ColorConstants.white);
        }
        // don't display it.  This avoids unnecessary (& illegible) visual clutter
        if (name != null) {
            String minVisibleName = name;
            if (name.length() > 3) {
                minVisibleName = name.substring(0, 3);
            }
            Dimension textDim = FigureUtilities.getTextExtents(minVisibleName, g.getFont());
            if (textDim.width < (bds.width - 5)) {
                if (textDim.height < (bds.height - 5)) {
                    g.drawText(name, bds.x + 2, bds.y + 2);
                }
            }
        }
        g.setForegroundColor(ColorConstants.black);
        if (!isCascade()) {
            g.drawRectangle(new Rectangle(bds.x, bds.y, bds.width - 1, bds.height - 1));
        }
    } finally {
        g.popState();
    }
}
Also used : Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 3 with Color

use of org.eclipse.swt.graphics.Color in project cogtool by cogtool.

the class ProjectUIModel method populateRow.

protected void populateRow(AUndertaking undertaking, final TreeItem row) {
    taskTreeItems.put(undertaking, row);
    row.addListener(SWT.Dispose, onDisposeRow);
    // TODO: This is creating a new handler instance for each row
    // TODO: reuse a single instance by looking up TreeItem in taskTreeItems?
    AlertHandler handler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            AUndertaking task = (AUndertaking) row.getData();
            row.setText(0, SWTStringUtil.insertEllipsis(task.getName(), 300, StringUtil.EQUAL, tree.getFont()));
            setRowBackground(task, row);
        }
    };
    row.setData(undertaking);
    undertaking.addHandler(this, NameChangeAlert.class, handler);
    row.setText(getTaskRowStrings(undertaking));
    Color bkg = setRowBackground(undertaking, row);
    int numCols = tree.getColumnCount();
    for (int i = 0; i < numCols; i++) {
        row.setBackground(i, bkg);
    }
    if (undertaking.isTaskGroup()) {
        TaskGroup group = (TaskGroup) undertaking;
        setGroupAlertHandlers(group, row);
        addTasks(group.getUndertakings().iterator(), row);
    }
    row.setExpanded(true);
    if (rowHook != null) {
        rowHook.onRowCreation(row);
    }
}
Also used : AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) Color(org.eclipse.swt.graphics.Color) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) TaskGroup(edu.cmu.cs.hcii.cogtool.model.TaskGroup) EventObject(java.util.EventObject)

Example 4 with Color

use of org.eclipse.swt.graphics.Color in project tdi-studio-se by Talend.

the class AbstractHL7MetadataTableEditorView method configurePatternColumn.

/**
     * DOC amaumont Comment method "configurePatternColumn".
     * 
     * @param tableViewerCreator
     */
protected void configurePatternColumn(TableViewerCreator<B> tableViewerCreator) {
    if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA && showPatternColumn) {
        final TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
        //$NON-NLS-1$
        String patternTitle = Messages.getString("MetadataTableEditorView.PatternTitle");
        column.setTitle(patternTitle);
        column.setToolTipHeader(patternTitle);
        column.setId(ID_COLUMN_PATTERN);
        column.setBeanPropertyAccessors(getPatternAccessor());
        column.setModifiable(!isReadOnly());
        column.setWeight(16);
        final ColumnCellModifier columnCellModifier = new ColumnCellModifier(column) {

            public boolean canModify(Object bean) {
                boolean typeIsDate = currentBeanHasJavaDateType(bean) && !isReadOnly();
                return typeIsDate;
            }
        };
        column.setColorProvider(new IColumnColorProvider() {

            public Color getBackgroundColor(Object bean) {
                if (!columnCellModifier.canModify(bean)) {
                    return READONLY_CELL_BG_COLOR;
                }
                return null;
            }

            public Color getForegroundColor(Object bean) {
                return null;
            }
        });
        column.setLabelProvider(new IColumnLabelProvider() {

            /*
                 * (non-Javadoc)
                 * 
                 * @see org.talend.commons.ui.swt.tableviewer.behavior.IColumnLabelProvider#getLabel(java.lang.Object)
                 */
            public String getLabel(Object bean) {
                if (!currentBeanHasJavaDateType(bean)) {
                    //$NON-NLS-1$
                    return "";
                }
                return null;
            }
        });
        column.setColumnCellModifier(columnCellModifier);
        JavaSimpleDateFormatProposalProvider proposalProvider = new JavaSimpleDateFormatProposalProvider();
        TextCellEditorWithProposal patternCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), column);
        ContentProposalAdapterExtended contentProposalAdapter = patternCellEditor.getContentProposalAdapter();
        contentProposalAdapter.setFilterStyle(ContentProposalAdapterExtended.FILTER_NONE);
        contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapterExtended.PROPOSAL_INSERT);
        patternCellEditor.setContentProposalProvider(proposalProvider);
        column.setCellEditor(patternCellEditor, CellEditorValueAdapterFactory.getNullToEmptyStringTextAdapater());
    }
}
Also used : IColumnLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnLabelProvider) ContentProposalAdapterExtended(org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended) TextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal) Color(org.eclipse.swt.graphics.Color) JavaSimpleDateFormatProposalProvider(org.talend.core.ui.proposal.JavaSimpleDateFormatProposalProvider) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) IColumnColorProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider) ColumnCellModifier(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier)

Example 5 with Color

use of org.eclipse.swt.graphics.Color in project tdi-studio-se by Talend.

the class AbstractHL7MetadataTableEditorView method configureDbTypeColumn.

/**
     * DOC amaumont Comment method "initDbTypeColumn".
     * 
     * @param tableViewerCreator
     */
private TableViewerCreatorColumn configureDbTypeColumn(final TableViewerCreator<B> tableViewerCreator) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MetadataTableEditorView.DBTypeTitle"));
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.DBTypeTitle"));
    column.setId(ID_COLUMN_DBTYPE);
    column.setBeanPropertyAccessors(getDbTypeAccessor());
    column.setModifiable(dbTypeColumnWritable && !isReadOnly());
    column.setWeight(10);
    column.setMinimumWidth(60);
    if (dbTypeColumnWritable) {
        CellEditorValueAdapter comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor();
        String[] arrayDbTypes = new String[0];
        //$NON-NLS-1$
        arrayDbTypes = MetadataTalendType.getDbTypes(getCurrentDbms());
        // System.out.println("currentDbms:" + getCurrentDbms() + "
        // dbTypes:" + arrayDbTypes);
        ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayDbTypes, SWT.READ_ONLY);
        CCombo typeCombo = (CCombo) typeComboEditor.getControl();
        typeCombo.setEditable(false);
        column.setCellEditor(typeComboEditor, comboValueAdapter);
    } else {
        column.setColorProvider(new IColumnColorProvider() {

            public Color getBackgroundColor(Object bean) {
                return READONLY_CELL_BG_COLOR;
            }

            public Color getForegroundColor(Object bean) {
                return null;
            }
        });
    }
    return column;
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) Color(org.eclipse.swt.graphics.Color) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) IColumnColorProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider)

Aggregations

Color (org.eclipse.swt.graphics.Color)1008 Point (org.eclipse.swt.graphics.Point)145 RGB (org.eclipse.swt.graphics.RGB)127 GridData (org.eclipse.swt.layout.GridData)120 Composite (org.eclipse.swt.widgets.Composite)118 Rectangle (org.eclipse.swt.graphics.Rectangle)116 Image (org.eclipse.swt.graphics.Image)115 GridLayout (org.eclipse.swt.layout.GridLayout)99 Display (org.eclipse.swt.widgets.Display)97 Test (org.junit.Test)95 Font (org.eclipse.swt.graphics.Font)86 Label (org.eclipse.swt.widgets.Label)79 GC (org.eclipse.swt.graphics.GC)74 SelectionEvent (org.eclipse.swt.events.SelectionEvent)65 Shell (org.eclipse.swt.widgets.Shell)54 ArrayList (java.util.ArrayList)51 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)51 StyleRange (org.eclipse.swt.custom.StyleRange)49 TableItem (org.eclipse.swt.widgets.TableItem)48 Button (org.eclipse.swt.widgets.Button)45