use of org.eclipse.swt.widgets.Control in project dbeaver by serge-rider.
the class SQLEditorNested method createPartControl.
@Override
public void createPartControl(Composite parent) {
pageControl = new EditorPageControl(parent, SWT.SHEET);
boolean hasCompiler = getCompileCommandId() != null;
if (hasCompiler) {
editorSash = new SashForm(pageControl.createContentContainer(), SWT.VERTICAL | SWT.SMOOTH);
super.createPartControl(editorSash);
editorControl = editorSash.getChildren()[0];
compileLog = new ObjectCompilerLogViewer(editorSash, false);
} else {
super.createPartControl(pageControl.createContentContainer());
}
// Create new or substitute progress control
pageControl.createOrSubstituteProgressPanel(getSite());
pageControl.setInfo("Source");
if (hasCompiler) {
editorSash.setWeights(new int[] { 70, 30 });
editorSash.setMaximizedControl(editorControl);
}
// Use focus to activate page control
final Control editorControl = getEditorControl();
assert editorControl != null;
editorControl.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (pageControl != null && !pageControl.isDisposed()) {
pageControl.activate(true);
}
}
@Override
public void focusLost(FocusEvent e) {
if (pageControl != null && !pageControl.isDisposed()) {
pageControl.activate(false);
}
}
});
}
use of org.eclipse.swt.widgets.Control in project dbeaver by serge-rider.
the class SQLEditorPropertyTester method test.
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (!(receiver instanceof SQLEditorBase)) {
return false;
}
SQLEditor editor = (SQLEditor) receiver;
final Control editorControl = editor.getEditorControl();
if (editorControl == null) {
return false;
}
boolean hasConnection = editor.getDataSourceContainer() != null;
switch(property) {
case PROP_CAN_EXECUTE:
// Do not check hasActiveQuery - sometimes jface don't update action enablement after cursor change/typing
return hasConnection;
/* && (!"statement".equals(expectedValue) || editor.hasActiveQuery())*/
case PROP_CAN_EXPLAIN:
return hasConnection && DBUtils.getAdapter(DBCQueryPlanner.class, editor.getDataSource()) != null;
case PROP_CAN_NAVIGATE:
{
// Check whether some word is under cursor
ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider == null) {
return false;
}
ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
Document document = editor.getDocument();
return selection != null && document != null && !new SQLIdentifierDetector(editor.getSyntaxManager().getStructSeparator(), editor.getSyntaxManager().getQuoteSymbol()).detectIdentifier(document, new Region(selection.getOffset(), selection.getLength())).isEmpty();
}
case PROP_CAN_EXPORT:
return hasConnection && editor.hasActiveQuery();
case PROP_HAS_SELECTION:
{
ISelection selection = editor.getSelectionProvider().getSelection();
return selection instanceof ITextSelection && ((ITextSelection) selection).getLength() > 0;
}
}
return false;
}
use of org.eclipse.swt.widgets.Control in project dbeaver by serge-rider.
the class ERDHandlerDelete method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME);
if (control != null) {
ERDEditorPart editor = ERDEditorAdapter.getEditor(control);
if (editor != null && !editor.isReadOnly()) {
DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) editor);
deleteAction.update();
if (deleteAction.isEnabled()) {
deleteAction.run();
}
}
}
return null;
}
use of org.eclipse.swt.widgets.Control in project dbeaver by serge-rider.
the class ERDHandlerSelectAll method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME);
if (control != null) {
ERDEditorPart editor = ERDEditorAdapter.getEditor(control);
if (editor != null) {
SelectAllAction selectAllAction = new SelectAllAction(editor);
selectAllAction.run();
}
}
return null;
}
use of org.eclipse.swt.widgets.Control in project dbeaver by serge-rider.
the class MultiPageAbstractEditor method setContainerStyles.
protected void setContainerStyles() {
Composite pageContainer = getContainer();
if (pageContainer instanceof CTabFolder) {
CTabFolder tabFolder = (CTabFolder) pageContainer;
tabFolder.setSimple(false);
tabFolder.setMRUVisible(true);
tabFolder.setTabPosition(SWT.TOP);
Control topRight = createTopRightControl(tabFolder);
if (topRight != null) {
Point trSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
tabFolder.setTabHeight(trSize.y);
tabFolder.setTopRight(topRight, SWT.RIGHT | SWT.WRAP);
}
// tabFolder.setSimple(false);
//tabFolder.setBorderVisible(true);
Layout parentLayout = tabFolder.getParent().getLayout();
if (parentLayout instanceof FillLayout) {
((FillLayout) parentLayout).marginHeight = 0;
// ((FillLayout)parentLayout).marginWidth = 5;
}
}
}
Aggregations