Search in sources :

Example 1 with MySQLCatalog

use of org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog in project dbeaver by serge-rider.

the class MySQLExportWizardPageObjects method saveState.

public void saveState() {
    wizard.objects.clear();
    for (TableItem item : catalogTable.getItems()) {
        if (item.getChecked()) {
            MySQLCatalog catalog = (MySQLCatalog) item.getData();
            MySQLDatabaseExportInfo info = new MySQLDatabaseExportInfo(catalog, checkedObjects.get(catalog));
            wizard.objects.add(info);
        }
    }
}
Also used : MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog)

Example 2 with MySQLCatalog

use of org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog in project dbeaver by serge-rider.

the class MySQLExportWizardPageObjects method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    Group objectsGroup = UIUtils.createControlGroup(composite, MySQLMessages.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.createPlaceholder(sash, 1);
        catPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        catalogTable = new Table(catPanel, SWT.BORDER | SWT.CHECK);
        catalogTable.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event 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.createPlaceholder(catPanel, 3, 5);
        buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        new Label(buttonsPanel, SWT.NONE).setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
        createCheckButtons(buttonsPanel, catalogTable);
    }
    final Button exportViewsCheck;
    {
        Composite tablesPanel = UIUtils.createPlaceholder(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, new Listener() {

            public void handleEvent(Event event) {
                if (event.detail == SWT.CHECK) {
                    updateCheckedTables();
                    updateState();
                }
            }
        });
        Composite buttonsPanel = UIUtils.createPlaceholder(tablesPanel, 3, 5);
        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.showViews = exportViewsCheck.getSelection();
                loadTables(null);
            }
        });
        exportViewsCheck.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
        createCheckButtons(buttonsPanel, tablesTable);
    }
    MySQLDataSource dataSource = null;
    Set<MySQLCatalog> activeCatalogs = new LinkedHashSet<>();
    for (DBSObject object : wizard.getDatabaseObjects()) {
        if (object instanceof MySQLCatalog) {
            activeCatalogs.add((MySQLCatalog) object);
            dataSource = ((MySQLCatalog) object).getDataSource();
        } else if (object instanceof MySQLTableBase) {
            MySQLCatalog catalog = ((MySQLTableBase) object).getContainer();
            dataSource = catalog.getDataSource();
            activeCatalogs.add(catalog);
            Set<MySQLTableBase> tables = checkedObjects.get(catalog);
            if (tables == null) {
                tables = new HashSet<>();
                checkedObjects.put(catalog, tables);
            }
            tables.add((MySQLTableBase) object);
            if (((MySQLTableBase) object).isView()) {
                wizard.showViews = true;
                exportViewsCheck.setSelection(true);
            }
        } else if (object.getDataSource() instanceof MySQLDataSource) {
            dataSource = (MySQLDataSource) object.getDataSource();
        }
    }
    if (dataSource != null) {
        boolean tablesLoaded = false;
        for (MySQLCatalog catalog : dataSource.getCatalogs()) {
            TableItem item = new TableItem(catalogTable, SWT.NONE);
            item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
            item.setText(0, catalog.getName());
            item.setData(catalog);
            if (activeCatalogs.contains(catalog)) {
                item.setChecked(true);
                catalogTable.select(catalogTable.indexOf(item));
                if (!tablesLoaded) {
                    loadTables(catalog);
                    tablesLoaded = true;
                }
            }
        }
    }
    updateState();
    setControl(composite);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SashForm(org.eclipse.swt.custom.SashForm) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) MySQLTableBase(org.jkiss.dbeaver.ext.mysql.model.MySQLTableBase) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) GridData(org.eclipse.swt.layout.GridData) MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 3 with MySQLCatalog

use of org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog in project dbeaver by serge-rider.

the class MySQLToolImport method execute.

@Override
public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException {
    for (DBSObject object : objects) {
        if (object instanceof MySQLCatalog) {
            ToolWizardDialog dialog = new ToolWizardDialog(window, new MySQLScriptExecuteWizard((MySQLCatalog) object, true));
            dialog.open();
        }
    }
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ToolWizardDialog(org.jkiss.dbeaver.ui.dialogs.tools.ToolWizardDialog) MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog)

Example 4 with MySQLCatalog

use of org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog in project dbeaver by serge-rider.

the class MySQLToolScript method execute.

@Override
public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException {
    for (DBSObject object : objects) {
        if (object instanceof MySQLCatalog) {
            ToolWizardDialog dialog = new ToolWizardDialog(window, new MySQLScriptExecuteWizard((MySQLCatalog) object, false));
            dialog.open();
        }
    }
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ToolWizardDialog(org.jkiss.dbeaver.ui.dialogs.tools.ToolWizardDialog) MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog)

Example 5 with MySQLCatalog

use of org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog in project dbeaver by serge-rider.

the class MySQLCatalogManager method addObjectCreateActions.

@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
    final MySQLCatalog catalog = command.getObject();
    final StringBuilder script = new StringBuilder("CREATE SCHEMA `" + catalog.getName() + "`");
    if (catalog.getDefaultCharset() != null) {
        script.append("\nDEFAULT CHARACTER SET ").append(catalog.getDefaultCharset().getName());
    }
    if (catalog.getDefaultCollation() != null) {
        script.append("\nDEFAULT COLLATE ").append(catalog.getDefaultCollation().getName());
    }
    actions.add(//$NON-NLS-2$
    new SQLDatabasePersistAction("Create schema", script.toString()));
}
Also used : MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Aggregations

MySQLCatalog (org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog)5 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)3 ToolWizardDialog (org.jkiss.dbeaver.ui.dialogs.tools.ToolWizardDialog)2 SashForm (org.eclipse.swt.custom.SashForm)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 MySQLDataSource (org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource)1 MySQLTableBase (org.jkiss.dbeaver.ext.mysql.model.MySQLTableBase)1 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)1 CustomSashForm (org.jkiss.dbeaver.ui.controls.CustomSashForm)1