Search in sources :

Example 6 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class StatusDetailsDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    Composite composite = super.createDialogArea(parent);
    if (!CommonUtils.isEmpty(warnings)) {
        // Create warnings table
        UIUtils.createControlLabel(composite, "Warnings");
        warnTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
        TableColumn exColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Exception");
        TableColumn msgColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Message");
        warnTable.setLinesVisible(true);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.minimumHeight = 100;
        warnTable.setLayoutData(gd);
        for (Throwable ex : warnings) {
            TableItem warnItem = new TableItem(warnTable, SWT.NONE);
            warnItem.setText(0, ex.getClass().getName());
            if (ex.getMessage() != null) {
                warnItem.setText(1, ex.getMessage());
            }
            warnItem.setData(ex);
        }
        exColumn.pack();
        msgColumn.pack();
        warnTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                openWarning();
            }
        });
        warnTable.addTraverseListener(new TraverseListener() {

            @Override
            public void keyTraversed(TraverseEvent e) {
                if (e.detail == SWT.TRAVERSE_RETURN) {
                    openWarning();
                    e.doit = false;
                }
            }
        });
    }
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Composite(org.eclipse.swt.widgets.Composite) TraverseListener(org.eclipse.swt.events.TraverseListener) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 7 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class TabbedFolderComposite method shiftPane.

private void shiftPane(FolderPane curPane, int shift) {
    // Set current height to heightHint
    for (FolderPane pane : folderPanes) {
        Rectangle bounds = pane.editorPane.getBounds();
        GridData gd = (GridData) pane.editorPane.getLayoutData();
        gd.heightHint = bounds.height;
    }
    FolderPane nextPane = getNextFolderPane(curPane);
    ((GridData) curPane.editorPane.getLayoutData()).heightHint += shift;
    ((GridData) nextPane.editorPane.getLayoutData()).heightHint -= shift;
    compositePane.layout();
/*
        if (shift < 0) {
            // Decrease self size and increase next pane's
            //nextPane.editorPane.
        } else {
            // Increase self size and decrease next pane's
        }
*/
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) GridData(org.eclipse.swt.layout.GridData)

Example 8 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class ResultSetFilterPanel method createObjectPanel.

@NotNull
private Control createObjectPanel(Shell popup) throws PartInitException {
    Composite panel = new Composite(popup, SWT.NONE);
    GridLayout gl = new GridLayout(2, false);
    //        gl.marginWidth = 0;
    gl.marginHeight = 0;
    //        gl.horizontalSpacing = 0;
    panel.setLayout(gl);
    Label iconLabel = new Label(panel, SWT.NONE);
    DBPImage activeObjectImage = getActiveObjectImage();
    if (activeObjectImage != null) {
        iconLabel.setImage(DBeaverIcons.getImage(activeObjectImage));
    }
    iconLabel.setToolTipText("Click to open query in editor");
    iconLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    iconLabel.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    iconLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            openEditorForActiveQuery();
        }
    });
    Composite editorPH = new Composite(panel, SWT.NONE);
    editorPH.setLayoutData(new GridData(GridData.FILL_BOTH));
    editorPH.setLayout(new FillLayout());
    final SQLEditorBase editor = new SQLEditorBase() {

        @Nullable
        @Override
        public DBCExecutionContext getExecutionContext() {
            return viewer.getExecutionContext();
        }

        @Override
        public void createPartControl(Composite parent) {
            super.createPartControl(parent);
            getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES).setEnabled(false);
        }
    };
    editor.setHasVerticalRuler(false);
    editor.init(new SubEditorSite(viewer.getSite()), new StringEditorInput(DEFAULT_QUERY_TEXT, getActiveQueryText(), true, GeneralUtils.getDefaultFileEncoding()));
    editor.createPartControl(editorPH);
    editor.reloadSyntaxRules();
    StyledText textWidget = editor.getTextViewer().getTextWidget();
    //textWidget.setAlwaysShowScrollBars(false);
    panel.setBackground(textWidget.getBackground());
    panel.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            editor.dispose();
        }
    });
    return textWidget;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) FillLayout(org.eclipse.swt.layout.FillLayout) StringEditorInput(org.jkiss.dbeaver.ui.editors.StringEditorInput) DBPImage(org.jkiss.dbeaver.model.DBPImage) SubEditorSite(org.jkiss.dbeaver.ui.editors.SubEditorSite) GridLayout(org.eclipse.swt.layout.GridLayout) SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) GridData(org.eclipse.swt.layout.GridData) NotNull(org.jkiss.code.NotNull)

Example 9 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class PrefPageSQLCompletion method createPreferenceContent.

@Override
protected Control createPreferenceContent(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    Composite composite2 = UIUtils.createPlaceholder(composite, 2);
    ((GridLayout) composite2.getLayout()).horizontalSpacing = 5;
    composite2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Content assistant
    {
        Composite assistGroup = UIUtils.createControlGroup(composite2, "SQL assistant/completion", 2, GridData.FILL_HORIZONTAL, 0);
        assistGroup.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));
        ((GridData) assistGroup.getLayoutData()).verticalSpan = 2;
        csAutoActivationCheck = UIUtils.createCheckbox(assistGroup, "Enable auto activation", "Enables content assistant auto activation (on text typing)", false, 2);
        UIUtils.createControlLabel(assistGroup, "Auto activation delay");
        csAutoActivationDelaySpinner = new Spinner(assistGroup, SWT.BORDER);
        csAutoActivationDelaySpinner.setSelection(0);
        csAutoActivationDelaySpinner.setDigits(0);
        csAutoActivationDelaySpinner.setIncrement(50);
        csAutoActivationDelaySpinner.setMinimum(0);
        csAutoActivationDelaySpinner.setMaximum(1000000);
        csAutoActivationDelaySpinner.setToolTipText("Delay before content assistant will run after typing trigger key");
        csAutoActivateOnKeystroke = UIUtils.createCheckbox(assistGroup, "Activate on typing", "Activate completion proposals on any letter typing.", false, 2);
        csAutoInsertCheck = UIUtils.createCheckbox(assistGroup, "Auto-insert proposal", "Enables the content assistant's auto insertion mode.\nIf enabled, the content assistant inserts a proposal automatically if it is the only proposal.\nIn the case of ambiguities, the user must make the choice.", false, 2);
        UIUtils.createControlLabel(assistGroup, "Insert case");
        csInsertCase = new Combo(assistGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
        csInsertCase.add("Default");
        csInsertCase.add("Upper case");
        csInsertCase.add("Lower case");
        csHideDuplicates = UIUtils.createCheckbox(assistGroup, "Hide duplicate names from non-active schemas", null, false, 2);
        csShortName = UIUtils.createCheckbox(assistGroup, "Use short object names (omit schema/catalog)", null, false, 2);
        csInsertSpace = UIUtils.createCheckbox(assistGroup, "Insert space after table/column names", null, false, 2);
    }
    return composite;
}
Also used : GridData(org.eclipse.swt.layout.GridData)

Example 10 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class PrefPageSQLFormat method createPreferenceContent.

@Override
protected Control createPreferenceContent(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 2, 5);
    // Autoclose
    {
        Composite acGroup = UIUtils.createControlGroup(composite, "Auto close", 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
        acSingleQuotesCheck = UIUtils.createCheckbox(acGroup, "Single quotes", false);
        acDoubleQuotesCheck = UIUtils.createCheckbox(acGroup, "Double quotes", false);
        acBracketsCheck = UIUtils.createCheckbox(acGroup, "Brackets", false);
    }
    {
        // Formatting
        Composite afGroup = UIUtils.createControlGroup(composite, "Auto format", 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
        afKeywordCase = UIUtils.createCheckbox(afGroup, "Convert keyword case", "Auto-convert keywords to upper/lower case on enter", false, 1);
        afExtractFromSource = UIUtils.createCheckbox(afGroup, "Extract SQL from source code", "On source code paste will remove all source language elements like quotes, +, \\n, etc", false, 1);
    }
    Composite formatterGroup = UIUtils.createControlGroup(composite, "Formatter", 1, GridData.FILL_BOTH, 0);
    ((GridData) formatterGroup.getLayoutData()).horizontalSpan = 2;
    {
        Composite formatterPanel = UIUtils.createPlaceholder(formatterGroup, 2);
        formatterPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        formatterSelector = UIUtils.createLabelCombo(formatterPanel, "Formatter", SWT.DROP_DOWN | SWT.READ_ONLY);
        formatterSelector.add(capitalizeCaseName(SQLTokenizedFormatter.FORMATTER_ID));
        formatterSelector.add(capitalizeCaseName(SQLExternalFormatter.FORMATTER_ID));
        formatterSelector.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                showFormatterSettings();
            }
        });
        formatterSelector.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    }
    // Default formatter settings
    {
        defaultGroup = UIUtils.createPlaceholder(formatterGroup, 2, 0);
        defaultGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        keywordCaseCombo = UIUtils.createLabelCombo(defaultGroup, "Keyword case", SWT.DROP_DOWN | SWT.READ_ONLY);
        keywordCaseCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        keywordCaseCombo.add("Database");
        for (DBPIdentifierCase c : DBPIdentifierCase.values()) {
            keywordCaseCombo.add(capitalizeCaseName(c.name()));
        }
        keywordCaseCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                performApply();
            }
        });
    }
    // External formatter
    {
        externalGroup = UIUtils.createPlaceholder(formatterGroup, 2);
        externalGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        externalCmdText = UIUtils.createLabelText(externalGroup, "Command line", "");
        externalCmdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        externalUseFile = UIUtils.createLabelCheckbox(externalGroup, "Use temp file", "Use temporary file to pass SQL text.\nTo pass file name in command line use parameter ${file}", false);
        externalTimeout = UIUtils.createLabelSpinner(externalGroup, "Exec timeout", "Time to wait until formatter process finish (ms)", 100, 100, 10000);
    }
    {
        // SQL preview
        Composite previewGroup = new Composite(formatterGroup, SWT.BORDER);
        previewGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
        previewGroup.setLayout(new FillLayout());
        sqlViewer = new SQLEditorBase() {

            @Override
            public DBCExecutionContext getExecutionContext() {
                final DBPDataSourceContainer container = getDataSourceContainer();
                if (container != null) {
                    final DBPDataSource dataSource = container.getDataSource();
                    if (dataSource != null) {
                        return dataSource.getDefaultContext(false);
                    }
                }
                return null;
            }
        };
        try {
            try (final InputStream sqlStream = getClass().getResourceAsStream(FORMAT_FILE_NAME)) {
                final String sqlText = ContentUtils.readToString(sqlStream, GeneralUtils.DEFAULT_ENCODING);
                IEditorSite subSite = new SubEditorSite(DBeaverUI.getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
                StringEditorInput sqlInput = new StringEditorInput("SQL preview", sqlText, true, GeneralUtils.getDefaultFileEncoding());
                sqlViewer.init(subSite, sqlInput);
            }
        } catch (Exception e) {
            log.error(e);
        }
        sqlViewer.createPartControl(previewGroup);
        Object text = sqlViewer.getAdapter(Control.class);
        if (text instanceof StyledText) {
            ((StyledText) text).setWordWrap(true);
        }
        sqlViewer.reloadSyntaxRules();
        previewGroup.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                sqlViewer.dispose();
            }
        });
    }
    return composite;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) StyledText(org.eclipse.swt.custom.StyledText) InputStream(java.io.InputStream) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DisposeEvent(org.eclipse.swt.events.DisposeEvent) StringEditorInput(org.jkiss.dbeaver.ui.editors.StringEditorInput) SubEditorSite(org.jkiss.dbeaver.ui.editors.SubEditorSite) SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPIdentifierCase(org.jkiss.dbeaver.model.DBPIdentifierCase) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) IEditorSite(org.eclipse.ui.IEditorSite)

Aggregations

GridData (org.eclipse.swt.layout.GridData)2385 GridLayout (org.eclipse.swt.layout.GridLayout)1659 Composite (org.eclipse.swt.widgets.Composite)1448 Label (org.eclipse.swt.widgets.Label)982 Button (org.eclipse.swt.widgets.Button)732 SelectionEvent (org.eclipse.swt.events.SelectionEvent)719 Text (org.eclipse.swt.widgets.Text)578 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)577 Group (org.eclipse.swt.widgets.Group)509 Combo (org.eclipse.swt.widgets.Combo)234 ModifyListener (org.eclipse.swt.events.ModifyListener)225 ModifyEvent (org.eclipse.swt.events.ModifyEvent)214 SelectionListener (org.eclipse.swt.events.SelectionListener)213 Table (org.eclipse.swt.widgets.Table)196 Point (org.eclipse.swt.graphics.Point)167 TableViewer (org.eclipse.jface.viewers.TableViewer)162 FillLayout (org.eclipse.swt.layout.FillLayout)134 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)118 Control (org.eclipse.swt.widgets.Control)117 Image (org.eclipse.swt.graphics.Image)114