Search in sources :

Example 6 with CustomSashForm

use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by dbeaver.

the class PostgreBackupWizardPageObjects method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    Group objectsGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_object_group_object, 1, GridData.FILL_HORIZONTAL, 0);
    objectsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    SashForm sash = new CustomSashForm(objectsGroup, SWT.VERTICAL);
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        Composite catPanel = UIUtils.createComposite(sash, 1);
        catPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        schemasTable = new Table(catPanel, SWT.BORDER | SWT.CHECK);
        schemasTable.addListener(SWT.Selection, event -> {
            TableItem item = (TableItem) event.item;
            PostgreSchema catalog = (PostgreSchema) item.getData();
            if (event.detail == SWT.CHECK) {
                schemasTable.select(schemasTable.indexOf(item));
                checkedObjects.remove(catalog);
            }
            loadTables(catalog);
            updateState();
        });
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 50;
        schemasTable.setLayoutData(gd);
        Composite buttonsPanel = UIUtils.createComposite(catPanel, 3);
        buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        new Label(buttonsPanel, SWT.NONE).setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
        createCheckButtons(buttonsPanel, schemasTable);
    }
    {
        Composite tablesPanel = UIUtils.createComposite(sash, 1);
        tablesPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        tablesTable = new Table(tablesPanel, SWT.BORDER | SWT.CHECK);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 50;
        tablesTable.setLayoutData(gd);
        tablesTable.addListener(SWT.Selection, event -> {
            if (event.detail == SWT.CHECK) {
                updateCheckedTables();
                updateState();
            }
        });
        Composite buttonsPanel = UIUtils.createComposite(tablesPanel, 3);
        buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        exportViewsCheck = UIUtils.createCheckbox(buttonsPanel, PostgreMessages.wizard_backup_page_object_checkbox_show_view, false);
        exportViewsCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                wizard.getSettings().setShowViews(exportViewsCheck.getSelection());
                loadTables(null);
            }
        });
        exportViewsCheck.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
        createCheckButtons(buttonsPanel, tablesTable);
    }
    setControl(composite);
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) java.util(java.util) SashForm(org.eclipse.swt.custom.SashForm) PostgreTableContainer(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableContainer) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) IStatus(org.eclipse.core.runtime.IStatus) DBeaverIcons(org.jkiss.dbeaver.ui.DBeaverIcons) UIUtils(org.jkiss.dbeaver.ui.UIUtils) PostgreTableBase(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase) Log(org.jkiss.dbeaver.Log) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) PostgreMessages(org.jkiss.dbeaver.ext.postgresql.PostgreMessages) JDBCTable(org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable) GridData(org.eclipse.swt.layout.GridData) PostgreDatabaseBackupInfo(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema) DBUtils(org.jkiss.dbeaver.model.DBUtils) org.eclipse.swt.widgets(org.eclipse.swt.widgets) Status(org.eclipse.core.runtime.Status) AbstractNativeToolWizardPage(org.jkiss.dbeaver.tasks.ui.nativetool.AbstractNativeToolWizardPage) List(java.util.List) DBIcon(org.jkiss.dbeaver.model.DBIcon) DBException(org.jkiss.dbeaver.DBException) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) SashForm(org.eclipse.swt.custom.SashForm) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) JDBCTable(org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)

Example 7 with CustomSashForm

use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by dbeaver.

the class MySQLExportWizardPageObjects method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    Group objectsGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_objects, 1, GridData.FILL_HORIZONTAL, 0);
    objectsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    SashForm sash = new CustomSashForm(objectsGroup, SWT.VERTICAL);
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        Composite catPanel = UIUtils.createComposite(sash, 1);
        catPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        catalogTable = new Table(catPanel, SWT.BORDER | SWT.CHECK);
        catalogTable.addListener(SWT.Selection, event -> {
            TableItem item = (TableItem) event.item;
            if (item != null) {
                MySQLCatalog catalog = (MySQLCatalog) item.getData();
                if (event.detail == SWT.CHECK) {
                    catalogTable.select(catalogTable.indexOf(item));
                    checkedObjects.remove(catalog);
                }
                loadTables(catalog);
                updateState();
            }
        });
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 50;
        catalogTable.setLayoutData(gd);
        Composite buttonsPanel = UIUtils.createComposite(catPanel, 3);
        buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        new Label(buttonsPanel, SWT.NONE).setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
        createCheckButtons(buttonsPanel, catalogTable);
    }
    {
        Composite tablesPanel = UIUtils.createComposite(sash, 1);
        tablesPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        tablesTable = new Table(tablesPanel, SWT.BORDER | SWT.CHECK);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 50;
        tablesTable.setLayoutData(gd);
        tablesTable.addListener(SWT.Selection, event -> {
            if (event.detail == SWT.CHECK) {
                updateCheckedTables();
                updateState();
            }
        });
        Composite buttonsPanel = UIUtils.createComposite(tablesPanel, 3);
        buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        exportViewsCheck = UIUtils.createCheckbox(buttonsPanel, "Show views", false);
        exportViewsCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                wizard.getSettings().setShowViews(exportViewsCheck.getSelection());
                loadTables(null);
            }
        });
        exportViewsCheck.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
        createCheckButtons(buttonsPanel, tablesTable);
    }
    loadSettings();
    setControl(composite);
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) java.util(java.util) MySQLDatabaseExportInfo(org.jkiss.dbeaver.ext.mysql.tasks.MySQLDatabaseExportInfo) SashForm(org.eclipse.swt.custom.SashForm) MySQLTableBase(org.jkiss.dbeaver.ext.mysql.model.MySQLTableBase) AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) IStatus(org.eclipse.core.runtime.IStatus) DBeaverIcons(org.jkiss.dbeaver.ui.DBeaverIcons) UIUtils(org.jkiss.dbeaver.ui.UIUtils) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) GridData(org.eclipse.swt.layout.GridData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) DBUtils(org.jkiss.dbeaver.model.DBUtils) org.eclipse.swt.widgets(org.eclipse.swt.widgets) Status(org.eclipse.core.runtime.Status) MySQLUIMessages(org.jkiss.dbeaver.ext.mysql.ui.internal.MySQLUIMessages) List(java.util.List) MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog) DBIcon(org.jkiss.dbeaver.model.DBIcon) DBException(org.jkiss.dbeaver.DBException) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SashForm(org.eclipse.swt.custom.SashForm) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 8 with CustomSashForm

use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by dbeaver.

the class ErrorPresentation method createPresentation.

@Override
public void createPresentation(@NotNull IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    CustomSashForm partDivider = UIUtils.createPartDivider(controller.getSite().getPart(), parent, SWT.HORIZONTAL);
    partDivider.setLayoutData(new GridData(GridData.FILL_BOTH));
    errorComposite = UIUtils.createComposite(partDivider, 1);
    errorComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    statusPart = new StatusPart(errorComposite, status);
    for (Control child : errorComposite.getChildren()) {
        if (child instanceof Text) {
            TextEditorUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), child);
        }
    }
    sqlPanel = UIUtils.createComposite(partDivider, 1);
    sqlPanel.setLayout(new FillLayout());
    UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
    try {
        editorPanel = serviceSQL.createSQLPanel(controller.getSite(), sqlPanel, controller, "SQL", true, sqlText);
        if (editorPanel instanceof TextViewer) {
            textWidget = ((TextViewer) editorPanel).getTextWidget();
        }
    } catch (DBException e) {
        textWidget = new StyledText(sqlPanel, SWT.BORDER | SWT.READ_ONLY);
        textWidget.setText(sqlText);
    }
    try {
        boolean widthSet = false;
        IDialogSettings viewSettings = ResultSetUtils.getViewerSettings(SETTINGS_SECTION_ERROR_PANEL);
        String errorWidth = viewSettings.get(PROP_ERROR_WIDTH);
        if (errorWidth != null) {
            String[] widthStrs = errorWidth.split(":");
            if (widthStrs.length == 2) {
                partDivider.setWeights(new int[] { Integer.parseInt(widthStrs[0]), Integer.parseInt(widthStrs[1]) });
            }
            widthSet = true;
        }
        if (!widthSet) {
            partDivider.setWeights(new int[] { 700, 300 });
        }
        partDivider.addCustomSashFormListener((firstControlWeight, secondControlWeight) -> {
            int[] weights = partDivider.getWeights();
            viewSettings.put(PROP_ERROR_WIDTH, weights[0] + ":" + weights[1]);
        });
    } catch (Throwable e) {
        log.debug(e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) StyledText(org.eclipse.swt.custom.StyledText) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) TextViewer(org.eclipse.jface.text.TextViewer) Control(org.eclipse.swt.widgets.Control) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) UIServiceSQL(org.jkiss.dbeaver.runtime.ui.UIServiceSQL) StatusPart(org.eclipse.ui.internal.part.StatusPart)

Aggregations

GridData (org.eclipse.swt.layout.GridData)8 CustomSashForm (org.jkiss.dbeaver.ui.controls.CustomSashForm)8 List (java.util.List)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 DBException (org.jkiss.dbeaver.DBException)6 java.util (java.util)4 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)4 SWT (org.eclipse.swt.SWT)4 SashForm (org.eclipse.swt.custom.SashForm)4 org.eclipse.swt.widgets (org.eclipse.swt.widgets)4 DBIcon (org.jkiss.dbeaver.model.DBIcon)4 DBUtils (org.jkiss.dbeaver.model.DBUtils)4 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)4 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)4 DBWorkbench (org.jkiss.dbeaver.runtime.DBWorkbench)4 DBeaverIcons (org.jkiss.dbeaver.ui.DBeaverIcons)4 UIUtils (org.jkiss.dbeaver.ui.UIUtils)4 CommonUtils (org.jkiss.utils.CommonUtils)4