提交 6ab18588 编写于 作者: S serge-rider

Transaction monitor toolbar

上级 e2b8dd0e
......@@ -1594,8 +1594,18 @@
<command commandId="org.jkiss.dbeaver.core.txn.autocommit" icon="icons/sql/txn_auto.png" style="pulldown" id="org.jkiss.dbeaver.core.menu.txn">
<visibleWhen><reference definitionId="org.jkiss.dbeaver.core.ui.datasource.editor"/></visibleWhen>
</command>
<separator name="additions" visible="false"/>
<control class="org.jkiss.dbeaver.ui.controls.txn.TransactionMonitorToolbar$ToolbarContribution">
<visibleWhen><reference definitionId="org.jkiss.dbeaver.core.ui.datasource.editor"/></visibleWhen>
</control>
</toolbar>
<!--
<toolbar id="dbeaver-transaction-monitor" label="Transaction monitor">
<visibleWhen><reference definitionId="org.jkiss.dbeaver.core.ui.datasource.editor"/></visibleWhen>
<control class="org.jkiss.dbeaver.ui.controls.txn.TransactionMonitorToolbar$ToolbarContribution">
<visibleWhen><reference definitionId="org.jkiss.dbeaver.core.ui.datasource.editor"/></visibleWhen>
</control>
</toolbar>
-->
<toolbar id="dbeaver-datasource-selector" label="DataSource Selector">
<control class="org.jkiss.dbeaver.ui.perspective.DataSourceManagementToolbar$ToolbarContribution">
<visibleWhen><reference definitionId="org.jkiss.dbeaver.core.ui.datasource.editor"/></visibleWhen>
......
......@@ -454,7 +454,15 @@ public class UIUtils {
}
public static int getFontHeight(Control control) {
return control.getFont().getFontData()[0].getHeight();
return getFontHeight(control.getFont());
}
public static int getFontHeight(Font font) {
FontData[] fontData = font.getFontData();
if (fontData.length == 0) {
return 20;
}
return fontData[0].getHeight();
}
public static Font makeBoldFont(Font normalFont)
......@@ -1579,4 +1587,5 @@ public class UIUtils {
item.setPreferredSize(preferred);
return item;
}
}
......@@ -61,13 +61,6 @@ public class DataSourceAutoCommitHandler extends AbstractDataSourceHandler imple
public void run() {
// Save config
container.persistConfiguration();
DBeaverUI.syncExec(new Runnable() {
@Override
public void run() {
// Update actions
DataSourcePropertyTester.fireCommandRefresh(CoreCommands.CMD_TOGGLE_AUTOCOMMIT);
}
});
}
});
} catch (DBException e) {
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.txn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.ui.IActionConstants;
import org.jkiss.dbeaver.ui.UIUtils;
/**
* DataSource Toolbar
*/
public class TransactionMonitorToolbar {
private static final Log log = Log.getLog(TransactionMonitorToolbar.class);
private IWorkbenchWindow workbenchWindow;
public TransactionMonitorToolbar(IWorkbenchWindow workbenchWindow) {
this.workbenchWindow = workbenchWindow;
}
/*
private void dispose() {
IWorkbenchPage activePage = workbenchWindow.getActivePage();
if (activePage != null) {
pageClosed(activePage);
}
this.workbenchWindow.removePageListener(this);
}
*/
private Control createControl(Composite parent) {
return new MonitorPanel(parent);
}
private class MonitorPanel extends Composite {
private final Text txnText;
public MonitorPanel(Composite parent) {
super(parent, SWT.NONE);
//setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
paint(e);
}
});
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
//layout.marginWidth = 0;
setLayout(layout);
txnText = new Text(this, SWT.BORDER | SWT.SINGLE);
txnText.setEnabled(false);
txnText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
txnText.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
txnText.setText("");
GridData gd = new GridData();
gd.verticalAlignment = GridData.CENTER;
gd.grabExcessVerticalSpace = true;
gd.widthHint = UIUtils.getFontHeight(txnText) * 6;
txnText.setLayoutData(gd);
}
private void paint(PaintEvent e) {
//e.gc.drawRectangle(e.x, e.y, e.width, e.height);
}
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
return super.computeSize(wHint, hHint, changed);
}
}
public static class ToolbarContribution extends WorkbenchWindowControlContribution {
public ToolbarContribution() {
super(IActionConstants.TOOLBAR_TXN);
}
@Override
protected Control createControl(Composite parent) {
TransactionMonitorToolbar toolbar = new TransactionMonitorToolbar(DBeaverUI.getActiveWorkbenchWindow());
return toolbar.createControl(parent);
}
}
}
......@@ -27,6 +27,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils;
......@@ -1856,7 +1857,7 @@ public class HexEditControl extends Composite {
// very small sizes would compromise responsiveness in large windows, and they are too small
// to see anyway
if (font != null) {
int newSize = font.getFontData()[0].getHeight();
int newSize = UIUtils.getFontHeight(font);
if (newSize == 1 || newSize == 2)
throw new IllegalArgumentException("Font size is " + newSize + ", too small");
}
......
......@@ -80,7 +80,7 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
}
}
};
final int fontHeight = composite.getFont().getFontData()[0].getHeight();
final int fontHeight = UIUtils.getFontHeight(composite);
Composite addrGroup = UIUtils.createPlaceholder(composite, 2);
GridLayout gl = new GridLayout(2, false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册