use of org.eclipse.ui.themes.ITheme in project dbeaver by dbeaver.
the class SQLEditorOutputViewer method refreshStyles.
void refreshStyles() {
ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
Font outputFont = currentTheme.getFontRegistry().get(SQLConstants.CONFIG_FONT_OUTPUT);
if (outputFont != null) {
this.text.setFont(outputFont);
}
this.text.setForeground(currentTheme.getColorRegistry().get(SQLConstants.CONFIG_COLOR_TEXT));
this.text.setBackground(currentTheme.getColorRegistry().get(SQLConstants.CONFIG_COLOR_BACKGROUND));
}
use of org.eclipse.ui.themes.ITheme in project dbeaver by dbeaver.
the class SQLEditorOutputConsoleViewer method refreshStyles.
public void refreshStyles() {
ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
Font outputFont = currentTheme.getFontRegistry().get(SQLConstants.CONFIG_FONT_OUTPUT);
if (outputFont != null) {
getTextWidget().setFont(outputFont);
}
getTextWidget().setForeground(UIStyles.getDefaultTextForeground());
getTextWidget().setBackground(UIStyles.getDefaultTextBackground());
}
use of org.eclipse.ui.themes.ITheme in project dbeaver by dbeaver.
the class UIStyles method getDefaultWidgetBackground.
public static Color getDefaultWidgetBackground() {
ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
Color color = theme.getColorRegistry().get("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START");
if (color == null) {
color = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
}
return color;
}
use of org.eclipse.ui.themes.ITheme in project dbeaver by dbeaver.
the class SQLRuleScanner method getColor.
private Color getColor(String colorKey, int colorDefault) {
ITheme currentTheme = themeManager.getCurrentTheme();
Color color = currentTheme.getColorRegistry().get(colorKey);
if (color == null) {
color = Display.getDefault().getSystemColor(colorDefault);
}
return color;
}
use of org.eclipse.ui.themes.ITheme in project arduino-eclipse-plugin by Sloeber.
the class SerialMonitor method createPartControl.
/**
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
@Override
public void createPartControl(Composite parent1) {
parent = parent1;
parent1.setLayout(new GridLayout());
GridLayout layout = new GridLayout(5, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
Composite top = new Composite(parent1, SWT.NONE);
top.setLayout(layout);
top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
serialPorts = new ComboViewer(top, SWT.READ_ONLY | SWT.DROP_DOWN);
GridData minSizeGridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
minSizeGridData.widthHint = 150;
serialPorts.getControl().setLayoutData(minSizeGridData);
serialPorts.setContentProvider(new IStructuredContentProvider() {
@Override
public void dispose() {
// no need to do something here
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// no need to do something here
}
@Override
public Object[] getElements(Object inputElement) {
@SuppressWarnings("unchecked") Map<Serial, SerialListener> items = (Map<Serial, SerialListener>) inputElement;
return items.keySet().toArray();
}
});
serialPorts.setLabelProvider(new LabelProvider());
serialPorts.setInput(serialConnections);
serialPorts.addSelectionChangedListener(new ComPortChanged(this));
sendString = new Text(top, SWT.SINGLE | SWT.BORDER);
sendString.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
lineTerminator = new ComboViewer(top, SWT.READ_ONLY | SWT.DROP_DOWN);
lineTerminator.setContentProvider(new ArrayContentProvider());
lineTerminator.setLabelProvider(new LabelProvider());
lineTerminator.setInput(SerialManager.listLineEndings());
lineTerminator.getCombo().select(MyPreferences.getLastUsedSerialLineEnd());
lineTerminator.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
MyPreferences.setLastUsedSerialLineEnd(lineTerminator.getCombo().getSelectionIndex());
}
});
send = new Button(top, SWT.BUTTON1);
send.setText(Messages.serialMonitorSend);
send.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = lineTerminator.getCombo().getSelectionIndex();
GetSelectedSerial().write(sendString.getText(), SerialManager.getLineEnding(index));
sendString.setText(new String());
sendString.setFocus();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// nothing needs to be done here
}
});
send.setEnabled(false);
reset = new Button(top, SWT.BUTTON1);
reset.setText(Messages.serialMonitorReset);
reset.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
GetSelectedSerial().reset();
sendString.setFocus();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// nothing needs to be done here
}
});
reset.setEnabled(false);
// register the combo as a Selection Provider
getSite().setSelectionProvider(serialPorts);
monitorOutput = new StyledText(top, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
monitorOutput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
monitorOutput.setEditable(false);
IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
ITheme currentTheme = themeManager.getCurrentTheme();
FontRegistry fontRegistry = currentTheme.getFontRegistry();
// $NON-NLS-1$
monitorOutput.setFont(fontRegistry.get("io.sloeber.serial.fontDefinition"));
monitorOutput.setText(Messages.serialMonitorNoInput + newLine);
monitorOutput.addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
// ignore
}
@Override
public void mouseDown(MouseEvent e) {
// If right button get selected text save it and start external tool
if (e.button == 3) {
String selectedText = monitorOutput.getSelectionText();
if (!selectedText.isEmpty()) {
IProject selectedProject = ProjectExplorerListener.getSelectedProject();
if (selectedProject != null) {
try {
ICConfigurationDescription activeCfg = CoreModel.getDefault().getProjectDescription(selectedProject).getActiveConfiguration();
String activeConfigName = activeCfg.getName();
IPath buildFolder = selectedProject.findMember(activeConfigName).getLocation();
// $NON-NLS-1$
File dumpFile = buildFolder.append("serialdump.txt").toFile();
FileUtils.writeStringToFile(dumpFile, selectedText, Charset.defaultCharset());
} catch (Exception e1) {
// ignore
e1.printStackTrace();
}
}
}
}
}
@Override
public void mouseDoubleClick(MouseEvent e) {
// ignore
}
});
parent.getShell().setDefaultButton(send);
makeActions();
contributeToActionBars();
}
Aggregations