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));
}
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();
}
}
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);
}
}
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());
}
}
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;
}
Aggregations