use of org.eclipse.jface.resource.ColorRegistry in project dbeaver by dbeaver.
the class SpreadsheetPresentation method applyThemeSettings.
// /////////////////////////////////////////////
// Themes
@Override
protected void applyThemeSettings(ITheme currentTheme) {
Font rsFont = currentTheme.getFontRegistry().get(ThemeConstants.FONT_SQL_RESULT_SET);
if (rsFont != null) {
this.spreadsheet.setFont(rsFont);
}
final ColorRegistry colorRegistry = currentTheme.getColorRegistry();
Color previewBack = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_SET_PREVIEW_BACK);
if (previewBack != null) {
// this.previewPane.getViewPlaceholder().setBackground(previewBack);
// for (Control control : this.previewPane.getViewPlaceholder().getChildren()) {
// control.setBackground(previewBack);
// }
}
// this.foregroundDefault = currentTheme.getColorRegistry().get(ThemeConstants.COLOR_SQL_RESULT_CELL_FORE);
this.backgroundAdded = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_NEW_BACK);
this.backgroundDeleted = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_DELETED_BACK);
this.backgroundModified = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_MODIFIED_BACK);
this.backgroundOdd = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_ODD_BACK);
this.backgroundReadOnly = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_READ_ONLY);
this.foregroundSelected = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_SET_SELECTION_FORE);
this.backgroundSelected = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_SET_SELECTION_BACK);
this.backgroundMatched = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_MATCHED);
this.cellHeaderForeground = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_HEADER_FOREGROUND);
this.cellHeaderBackground = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_HEADER_BACKGROUND);
{
if (this.cellHeaderSelectionBackground != null) {
UIUtils.dispose(this.cellHeaderSelectionBackground);
this.cellHeaderSelectionBackground = null;
}
Color headerSelectionBackground = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_HEADER_SELECTED_BACKGROUND);
RGB cellSel = UIUtils.blend(headerSelectionBackground.getRGB(), new RGB(255, 255, 255), 50);
this.cellHeaderSelectionBackground = new Color(getSpreadsheet().getDisplay(), cellSel);
}
this.spreadsheet.setLineColor(colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_LINES_NORMAL));
this.spreadsheet.setLineSelectedColor(colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_LINES_SELECTED));
this.spreadsheet.recalculateSizes();
}
use of org.eclipse.jface.resource.ColorRegistry in project bndtools by bndtools.
the class ItalicStyler method applyStyles.
@Override
public void applyStyles(TextStyle textStyle) {
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
Font font = JFaceResources.getFontRegistry().getItalic(fontName);
if (fForegroundColorName != null) {
textStyle.foreground = colorRegistry.get(fForegroundColorName);
}
if (fBackgroundColorName != null) {
textStyle.background = colorRegistry.get(fBackgroundColorName);
}
textStyle.font = font;
}
use of org.eclipse.jface.resource.ColorRegistry in project arduino-eclipse-plugin by Sloeber.
the class PlotterView method createPartControl.
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new GridLayout(1, false));
IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
ITheme currentTheme = themeManager.getCurrentTheme();
ColorRegistry colorRegistry = currentTheme.getColorRegistry();
this.myPlotter = new // $NON-NLS-1$
MyPlotter(// $NON-NLS-1$
6, // $NON-NLS-1$
parent, // $NON-NLS-1$
SWT.NONE, // $NON-NLS-1$
colorRegistry.get("io.sloeber.plotter.color.background"), // $NON-NLS-1$
colorRegistry.get("io.sloeber.plotter.color.foreground"), // $NON-NLS-1$
colorRegistry.get("io.sloeber.plotter.color.grid"));
GridData theGriddata = new GridData(SWT.FILL, SWT.FILL, true, true);
theGriddata.horizontalSpan = 7;
this.myPlotter.setLayoutData(theGriddata);
for (int i = 0; i < this.myPlotter.getChannels(); i++) {
// $NON-NLS-1$
String colorID = "io.sloeber.plotter.color." + (1 + i);
Color color = colorRegistry.get(colorID);
this.myPlotter.setForeground(i, color);
}
int steadyPosition = this.myPlotter.getSize().x;
int tailSize = this.myPlotter.getSize().x - 10;
if (tailSize < -3) {
tailSize = -2;
}
for (int i = 0; i < 6; i++) {
this.myPlotter.setPercentage(i, false);
this.myPlotter.setSteady(i, true, steadyPosition);
this.myPlotter.setFade(i, false);
this.myPlotter.setTailFade(i, 0);
this.myPlotter.setConnect(i, false);
this.myPlotter.setLineWidth(i, 1);
this.myPlotter.setBaseOffset(i, 0);
this.myPlotter.setTailSize(i, tailSize);
this.myPlotter.SetChannelName(i, Messages.plotterViewChannel.replace(Messages.NUMBER, Integer.toString(i)));
}
PlotterView.this.myPlotter.setShowLabels(true);
Listener listener = new Listener() {
boolean inDrag = false;
boolean inSize = false;
int orgLowRange = 0;
int orgHighRange = 0;
int orgY = 0;
double valueAtScrollPoint = 0;
double scale = 1;
double orgHeight;
double scrollPointPercentage;
@Override
public void handleEvent(Event event) {
switch(event.type) {
case SWT.MouseDown:
if (!(this.inDrag || this.inSize)) {
this.orgLowRange = PlotterView.this.myPlotter.getRangeLowValue();
this.orgHighRange = PlotterView.this.myPlotter.getRangeHighValue();
this.scale = (((float) (PlotterView.this.myPlotter.getRangeHighValue() - PlotterView.this.myPlotter.getRangeLowValue())) / (float) PlotterView.this.myPlotter.getSize().y);
this.orgY = event.y;
switch(event.button) {
case 1:
this.inDrag = true;
break;
case 3:
this.orgHeight = (double) this.orgHighRange - this.orgLowRange;
this.scrollPointPercentage = (double) event.y / (double) PlotterView.this.myPlotter.getSize().y;
this.valueAtScrollPoint = this.orgHighRange - this.scrollPointPercentage * this.orgHeight;
this.inSize = true;
break;
default:
break;
}
}
break;
case SWT.MouseMove:
if (this.inDrag) {
PlotterView.this.myPlotter.setRange((int) (this.orgLowRange - (this.orgY - event.y) * this.scale), (int) (this.orgHighRange - (this.orgY - event.y) * this.scale));
PlotterView.this.myPlotter.setnewBackgroundImage();
}
if (this.inSize) {
double newscale = Math.max(this.scale * (1.0 + (this.orgY - event.y) * 0.01), 1.0);
int newHeight = (int) (this.orgHeight / this.scale * newscale);
int newHighValue = (int) (this.valueAtScrollPoint + this.scrollPointPercentage * newHeight);
PlotterView.this.myPlotter.setRange(newHighValue - newHeight, newHighValue);
PlotterView.this.myPlotter.setnewBackgroundImage();
}
break;
case SWT.MouseUp:
this.inDrag = false;
this.inSize = false;
break;
case SWT.MouseDoubleClick:
// save the data
FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.SAVE);
// $NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.csv" });
String fileName = dialog.open();
if (fileName != null && !fileName.isEmpty()) {
PlotterView.this.myPlotter.saveData(fileName);
}
this.inDrag = false;
this.inSize = false;
break;
default:
break;
}
}
};
this.myPlotter.addListener(SWT.MouseDown, listener);
this.myPlotter.addListener(SWT.MouseUp, listener);
this.myPlotter.addListener(SWT.MouseMove, listener);
this.myPlotter.addListener(SWT.MouseDoubleClick, listener);
this.myPlotter.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
int plotterWidth = PlotterView.this.myPlotter.getSize().x - 10;
for (int i = 0; i < PlotterView.this.myPlotter.getChannels(); i++) {
PlotterView.this.myPlotter.setSteady(i, true, plotterWidth);
PlotterView.this.myPlotter.setTailSize(i, plotterWidth);
}
PlotterView.this.myPlotter.setnewBackgroundImage();
PlotterView.this.myPlotter.redraw();
}
});
// I set this as starting range
this.myPlotter.setRange(0, 1050);
// $NON-NLS-1$
this.myPlotter.setStatus("Use the serial monitor to connect to a Serial port.");
this.myPlotter.setShowLabels(false);
this.myPlotter.setnewBackgroundImage();
registerSerialTracker();
}
Aggregations