提交 515c68d3 编写于 作者: S serge-rider

#3236 QM log colors and transaction monitor background color configuration

上级 a3418284
......@@ -500,6 +500,8 @@ themeElementCategory.org.jkiss.dbeaver.ui.presentation.sql.description = SQL Edi
themeElementCategory.org.jkiss.dbeaver.ui.presentation.results.label = Database Query Results
themeElementCategory.org.jkiss.dbeaver.ui.presentation.datatypes.label = Resultset Data Types
themeElementCategory.org.jkiss.dbeaver.ui.presentation.results.description = SQL Editor
themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.label = Transactions
themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.description = Transactions colors
fontDefinition.org.jkiss.dbeaver.sql.resultset.font.label = Results grid font
fontDefinition.org.jkiss.dbeaver.sql.resultset.font.description = The grid font is used for result set cells, header and rows number.
......@@ -569,6 +571,13 @@ colorDefinition.org.jkiss.dbeaver.sql.editor.color.text.background.description =
colorDefinition.org.jkiss.dbeaver.sql.editor.color.disabled.background.label = SQL disabled background
colorDefinition.org.jkiss.dbeaver.sql.editor.color.disabled.background.description = SQL text background
colorDefinition.org.jkiss.dbeaver.txn.color.committed.background.label = Committed transaction
colorDefinition.org.jkiss.dbeaver.txn.color.committed.background.description = Committed transaction background
colorDefinition.org.jkiss.dbeaver.txn.color.reverted.background.label = Reverted transaction
colorDefinition.org.jkiss.dbeaver.txn.color.reverted.background.description = Reverted transaction background
colorDefinition.org.jkiss.dbeaver.txn.color.transaction.background.label = Active transaction
colorDefinition.org.jkiss.dbeaver.txn.color.transaction.background.description = Active transaction background
category.org.jkiss.dbeaver.core.export.resources.name = DBeaver
wizard.org.jkiss.dbeaver.core.wizard.export.project.name = Project
wizard.org.jkiss.dbeaver.core.wizard.export.project.description = DBeaver Project
......
......@@ -2833,27 +2833,14 @@
</extension>
<extension point="org.eclipse.ui.themes">
<themeElementCategory label="%themeElementCategory.org.jkiss.dbeaver.ui.presentation.sql.label" id="org.jkiss.dbeaver.ui.presentation.sql">
<description>%themeElementCategory.org.jkiss.dbeaver.ui.presentation.sql.description</description>
</themeElementCategory>
<themeElementCategory label="%themeElementCategory.org.jkiss.dbeaver.ui.presentation.results.label" id="org.jkiss.dbeaver.ui.presentation.results">
<description>%themeElementCategory.org.jkiss.dbeaver.ui.presentation.results.description</description>
</themeElementCategory>
<themeElementCategory label="%themeElementCategory.org.jkiss.dbeaver.ui.presentation.datatypes.label" id="org.jkiss.dbeaver.ui.presentation.results.datatypes" parentId="org.jkiss.dbeaver.ui.presentation.results">
<description>%themeElementCategory.org.jkiss.dbeaver.ui.presentation.datatypes.description</description>
</themeElementCategory>
<fontDefinition id="org.jkiss.dbeaver.sql.resultset.font" categoryId="org.jkiss.dbeaver.ui.presentation.results" label="%fontDefinition.org.jkiss.dbeaver.sql.resultset.font.label">
<description>%fontDefinition.org.jkiss.dbeaver.sql.resultset.font.description</description>
</fontDefinition>
<fontDefinition
id="org.jkiss.dbeaver.sql.editor.font.output"
categoryId="org.jkiss.dbeaver.ui.presentation.sql"
label="%fontDefinition.org.jkiss.dbeaver.sql.editor.font.output.label"
value="Courier New-regular-10">
<description>%fontDefinition.org.jkiss.dbeaver.sql.editor.font.output.description</description>
<fontValue os="linux" value="Monospace-regular-10"/>
<fontValue os="macosx" value="Courier-regular-11"/>
</fontDefinition>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.sql.resultset.color.selection.background.label"
categoryId="org.jkiss.dbeaver.ui.presentation.results"
......@@ -2961,6 +2948,10 @@
</colorDefinition>
<!-- Colors for data types -->
<themeElementCategory label="%themeElementCategory.org.jkiss.dbeaver.ui.presentation.datatypes.label" id="org.jkiss.dbeaver.ui.presentation.results.datatypes" parentId="org.jkiss.dbeaver.ui.presentation.results">
<description>%themeElementCategory.org.jkiss.dbeaver.ui.presentation.datatypes.description</description>
</themeElementCategory>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.sql.resultset.color.binary.foreground.label"
categoryId="org.jkiss.dbeaver.ui.presentation.results.datatypes"
......@@ -2998,6 +2989,20 @@
</colorDefinition>
<!-- Colors for SQL editor -->
<themeElementCategory label="%themeElementCategory.org.jkiss.dbeaver.ui.presentation.sql.label" id="org.jkiss.dbeaver.ui.presentation.sql">
<description>%themeElementCategory.org.jkiss.dbeaver.ui.presentation.sql.description</description>
</themeElementCategory>
<fontDefinition
id="org.jkiss.dbeaver.sql.editor.font.output"
categoryId="org.jkiss.dbeaver.ui.presentation.sql"
label="%fontDefinition.org.jkiss.dbeaver.sql.editor.font.output.label"
value="Courier New-regular-10">
<description>%fontDefinition.org.jkiss.dbeaver.sql.editor.font.output.description</description>
<fontValue os="linux" value="Monospace-regular-10"/>
<fontValue os="macosx" value="Courier-regular-11"/>
</fontDefinition>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.sql.editor.color.keyword.foreground.label"
categoryId="org.jkiss.dbeaver.ui.presentation.sql"
......@@ -3076,6 +3081,33 @@
<description>%colorDefinition.org.jkiss.dbeaver.sql.editor.color.disabled.background.description</description>
</colorDefinition>
<!-- Colors for transactions -->
<themeElementCategory label="%themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.label" id="org.jkiss.dbeaver.ui.presentation.qm">
<description>%themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.description</description>
</themeElementCategory>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.txn.color.committed.background.label"
categoryId="org.jkiss.dbeaver.ui.presentation.qm"
id="org.jkiss.dbeaver.txn.color.committed.background"
value="189, 254, 191">
<description>%colorDefinition.org.jkiss.dbeaver.txn.color.committed.background.description</description>
</colorDefinition>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.txn.color.reverted.background.label"
categoryId="org.jkiss.dbeaver.ui.presentation.qm"
id="org.jkiss.dbeaver.txn.color.reverted.background"
value="255, 99, 71">
<description>%colorDefinition.org.jkiss.dbeaver.txn.color.reverted.background.description</description>
</colorDefinition>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.txn.color.transaction.background.label"
categoryId="org.jkiss.dbeaver.ui.presentation.qm"
id="org.jkiss.dbeaver.txn.color.transaction.background"
value="255, 228, 181">
<description>%colorDefinition.org.jkiss.dbeaver.txn.color.transaction.background.description</description>
</colorDefinition>
</extension>
<extension point="org.eclipse.ui.exportWizards">
......
......@@ -27,7 +27,7 @@ import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
......@@ -39,7 +39,6 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
......@@ -88,11 +87,9 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
private static final String VIEWER_ID = "DBeaver.QM.LogViewer";
private static final int MIN_ENTRIES_PER_PAGE = 1;
public static final RGB COLOR_LIGHT_GREEN = new RGB(0xBD, 0xFE, 0xBF);
//189, 254, 191 #bdfebf
public static final RGB COLOR_LIGHT_RED = new RGB(0xFF, 0x63, 0x47);
public static final RGB COLOR_LIGHT_YELLOW = new RGB(0xFF, 0xE4, 0xB5);
public static final RGB COLOR_BLACK = new RGB(0x00, 0x00, 0x00);
public static final String COLOR_COMMITTED = "org.jkiss.dbeaver.txn.color.committed.background"; //= new RGB(0xBD, 0xFE, 0xBF);
public static final String COLOR_REVERTED = "org.jkiss.dbeaver.txn.color.reverted.background"; // = new RGB(0xFF, 0x63, 0x47);
public static final String COLOR_TRANSACTION = "org.jkiss.dbeaver.txn.color.transaction.background"; // = new RGB(0xFF, 0xE4, 0xB5);
private static abstract class LogColumn {
private final String id;
......@@ -320,7 +317,6 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
private final Color colorLightGreen;
private final Color colorLightRed;
private final Color colorLightYellow;
private final Color colorGray;
private final Font boldFont;
private DragSource dndSource;
......@@ -334,12 +330,12 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
this.site = site;
// Prepare colors
ISharedTextColors sharedColors = DBeaverUI.getSharedTextColors();
colorLightGreen = sharedColors.getColor(COLOR_LIGHT_GREEN);
colorLightRed = sharedColors.getColor(COLOR_LIGHT_RED);
colorLightYellow = sharedColors.getColor(COLOR_LIGHT_YELLOW);
colorGray = sharedColors.getColor(COLOR_BLACK);
ColorRegistry colorRegistry = site.getWorkbenchWindow().getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
colorLightGreen = colorRegistry.get(COLOR_COMMITTED);
colorLightRed = colorRegistry.get(COLOR_REVERTED);
colorLightYellow = colorRegistry.get(COLOR_TRANSACTION);
boldFont = UIUtils.makeBoldFont(parent.getFont());
boolean inDialog = UIUtils.isInDialog(parent);
......@@ -532,9 +528,11 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
private Color getObjectForeground(QMMetaEvent event)
{
/*
if (getObjectBackground(event) != null) {
return colorGray;
}
*/
/*
if (event.getObject() instanceof QMMStatementExecuteInfo) {
QMMStatementExecuteInfo exec = (QMMStatementExecuteInfo) event.getObject();
......
......@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
......@@ -55,9 +56,6 @@ public class TransactionMonitorToolbar {
private static final int MONITOR_UPDATE_DELAY = 250;
private static final RGB COLOR_FULL = QueryLogViewer.COLOR_LIGHT_RED;
private static final RGB COLOR_EMPTY = QueryLogViewer.COLOR_LIGHT_GREEN;
private IWorkbenchWindow workbenchWindow;
TransactionMonitorToolbar(IWorkbenchWindow workbenchWindow) {
......@@ -81,12 +79,7 @@ public class TransactionMonitorToolbar {
final IWorkbenchPage activePage = this.workbenchWindow.getActivePage();
if (activePage != null) {
activePage.addPartListener(partListener);
monitorPanel.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
activePage.removePartListener(partListener);
}
});
monitorPanel.addDisposeListener(e -> activePage.removePartListener(partListener));
}
return monitorPanel;
......@@ -118,12 +111,7 @@ public class TransactionMonitorToolbar {
MonitorPanel(Composite parent) {
super(parent, SWT.BORDER);
setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
paint(e);
}
});
addPaintListener(this::paint);
setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
setToolTipText("Transactions monitor");
......@@ -133,12 +121,9 @@ public class TransactionMonitorToolbar {
qmHandler = new QMEventsHandler(this);
QMUtils.registerHandler(qmHandler);
addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
QMUtils.unregisterHandler(qmHandler);
qmHandler = null;
}
addDisposeListener(e -> {
QMUtils.unregisterHandler(qmHandler);
qmHandler = null;
});
addMouseListener(new MouseAdapter() {
......@@ -167,6 +152,14 @@ public class TransactionMonitorToolbar {
private void paint(PaintEvent e) {
Color bg;
ColorRegistry colorRegistry = workbenchWindow.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
Color colorReverted = colorRegistry.get(QueryLogViewer.COLOR_REVERTED);
Color colorCommitted = colorRegistry.get(QueryLogViewer.COLOR_COMMITTED);
final RGB COLOR_FULL = colorReverted.getRGB();
final RGB COLOR_EMPTY = colorCommitted.getRGB();
final int updateCount = txnState == null ? 0 : txnState.getUpdateCount();
if (txnState == null || !txnState.isTransactionMode()) {
......@@ -216,15 +209,12 @@ public class TransactionMonitorToolbar {
monitor.done();
// Update UI
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
if (isDisposed()) {
return;
}
redraw();
updateToolTipText();
DBeaverUI.asyncExec(() -> {
if (isDisposed()) {
return;
}
redraw();
updateToolTipText();
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册