Search in sources :

Example 11 with Control

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);
            }
        }
    });
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) ProgressPageControl(org.jkiss.dbeaver.ui.controls.ProgressPageControl) Control(org.eclipse.swt.widgets.Control) ObjectCompilerLogViewer(org.jkiss.dbeaver.ui.controls.ObjectCompilerLogViewer) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 12 with Control

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;
}
Also used : Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection) SQLIdentifierDetector(org.jkiss.dbeaver.ui.editors.sql.syntax.SQLIdentifierDetector) Region(org.eclipse.jface.text.Region) Document(org.eclipse.jface.text.Document) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 13 with Control

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;
}
Also used : Control(org.eclipse.swt.widgets.Control) ERDEditorPart(org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction)

Example 14 with Control

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;
}
Also used : Control(org.eclipse.swt.widgets.Control) ERDEditorPart(org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart) SelectAllAction(org.eclipse.gef.ui.actions.SelectAllAction)

Example 15 with Control

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;
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) Layout(org.eclipse.swt.widgets.Layout) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout)

Aggregations

Control (org.eclipse.swt.widgets.Control)307 Point (org.eclipse.swt.graphics.Point)96 Composite (org.eclipse.swt.widgets.Composite)88 FormAttachment (org.eclipse.swt.layout.FormAttachment)57 FormData (org.eclipse.swt.layout.FormData)57 Button (org.eclipse.swt.widgets.Button)57 GridData (org.eclipse.swt.layout.GridData)55 Node (org.talend.designer.core.ui.editor.nodes.Node)46 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)45 CLabel (org.eclipse.swt.custom.CLabel)37 GridLayout (org.eclipse.swt.layout.GridLayout)37 Text (org.eclipse.swt.widgets.Text)36 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)33 GC (org.eclipse.swt.graphics.GC)31 Label (org.eclipse.swt.widgets.Label)31 SelectionEvent (org.eclipse.swt.events.SelectionEvent)28 CCombo (org.eclipse.swt.custom.CCombo)27 IElementParameter (org.talend.core.model.process.IElementParameter)25 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)24 StyledText (org.eclipse.swt.custom.StyledText)23