Search in sources :

Example 1 with AbstractImportExportSettings

use of org.jkiss.dbeaver.tasks.nativetool.AbstractImportExportSettings in project dbeaver by serge-rider.

the class NativeToolConfigPanel method createControl.

@Override
public void createControl(Composite parent, TaskConfigurationWizard wizard, Runnable propertyChangeListener) {
    ieWizard = (AbstractNativeToolWizard) wizard;
    {
        Group databasesGroup = UIUtils.createControlGroup(parent, TaskNativeUIMessages.tools_wizard_database_group_title, 1, GridData.FILL_BOTH, 0);
        selectorPanel = new DatabaseObjectsSelectorPanel(databasesGroup, false, this.runnableContext) {

            @Override
            protected boolean isDatabaseFolderVisible(DBNDatabaseFolder folder) {
                return folder.getChildrenClass() == objectClass;
            }

            @Override
            protected boolean isDatabaseObjectVisible(DBSObject obj) {
                return objectClass.isInstance(obj);
            }

            @Override
            protected void onSelectionChange(Object element) {
                selectedObject = element instanceof DBSWrapper && objectClass.isInstance(((DBSWrapper) element).getObject()) ? objectClass.cast(((DBSWrapper) element).getObject()) : null;
                AbstractNativeToolSettings settings = ieWizard.getSettings();
                List<DBSObject> databaseObjects = settings.getDatabaseObjects();
                databaseObjects.clear();
                if (selectedObject != null) {
                    databaseObjects.add(selectedObject);
                }
                if (settings instanceof AbstractImportExportSettings) {
                    ((AbstractImportExportSettings) settings).fillExportObjectsFromInput();
                }
                updateHomeSelector();
                propertyChangeListener.run();
            }

            @Override
            protected boolean isFolderVisible(DBNLocalFolder folder) {
                for (DBNDataSource ds : folder.getNestedDataSources()) {
                    if (isDataSourceVisible(ds)) {
                        return true;
                    }
                }
                return false;
            }

            @Override
            protected boolean isDataSourceVisible(DBNDataSource dataSource) {
                try {
                    return providerClass.isInstance(dataSource.getDataSourceContainer().getDriver().getDataSourceProvider());
                } catch (Exception e) {
                    log.debug(e);
                    return false;
                }
            }
        };
    }
    {
        Composite clientGroup = UIUtils.createControlGroup((Composite) parent, TaskNativeUIMessages.tools_wizard_client_group_title, 1, GridData.FILL_HORIZONTAL, 0);
        homesSelector = new ClientHomesSelector(clientGroup, TaskNativeUIMessages.tools_wizard_client_group_client);
        homesSelector.addSelectionChangedListener(event -> propertyChangeListener.run());
        homesSelector.getPanel().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) TaskConfigurationWizard(org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizard) CommonUtils(org.jkiss.utils.CommonUtils) org.jkiss.dbeaver.model.navigator(org.jkiss.dbeaver.model.navigator) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBTTaskType(org.jkiss.dbeaver.model.task.DBTTaskType) ClientHomesSelector(org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector) DBPDataSourceProvider(org.jkiss.dbeaver.model.DBPDataSourceProvider) DBRRunnableContext(org.jkiss.dbeaver.model.runtime.DBRRunnableContext) DBSWrapper(org.jkiss.dbeaver.model.struct.DBSWrapper) DBTTaskConfigPanel(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigPanel) Group(org.eclipse.swt.widgets.Group) AbstractNativeToolSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolSettings) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) InvocationTargetException(java.lang.reflect.InvocationTargetException) AbstractImportExportSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractImportExportSettings) DatabaseObjectsSelectorPanel(org.jkiss.dbeaver.ui.navigator.database.DatabaseObjectsSelectorPanel) List(java.util.List) TaskNativeUIMessages(org.jkiss.dbeaver.tasks.ui.nativetool.internal.TaskNativeUIMessages) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) Log(org.jkiss.dbeaver.Log) GridData(org.eclipse.swt.layout.GridData) Collections(java.util.Collections) Group(org.eclipse.swt.widgets.Group) DBSWrapper(org.jkiss.dbeaver.model.struct.DBSWrapper) Composite(org.eclipse.swt.widgets.Composite) AbstractImportExportSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractImportExportSettings) AbstractNativeToolSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolSettings) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ClientHomesSelector(org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector) GridData(org.eclipse.swt.layout.GridData) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseObjectsSelectorPanel(org.jkiss.dbeaver.ui.navigator.database.DatabaseObjectsSelectorPanel)

Example 2 with AbstractImportExportSettings

use of org.jkiss.dbeaver.tasks.nativetool.AbstractImportExportSettings in project dbeaver by dbeaver.

the class NativeToolConfigPanel method createControl.

@Override
public void createControl(Composite parent, TaskConfigurationWizard wizard, Runnable propertyChangeListener) {
    ieWizard = (AbstractNativeToolWizard) wizard;
    {
        Group databasesGroup = UIUtils.createControlGroup(parent, TaskNativeUIMessages.tools_wizard_database_group_title, 1, GridData.FILL_BOTH, 0);
        selectorPanel = new DatabaseObjectsSelectorPanel(databasesGroup, false, this.runnableContext) {

            @Override
            protected boolean isDatabaseFolderVisible(DBNDatabaseFolder folder) {
                return folder.getChildrenClass() == objectClass;
            }

            @Override
            protected boolean isDatabaseObjectVisible(DBSObject obj) {
                return objectClass.isInstance(obj);
            }

            @Override
            protected void onSelectionChange(Object element) {
                selectedObject = element instanceof DBSWrapper && objectClass.isInstance(((DBSWrapper) element).getObject()) ? objectClass.cast(((DBSWrapper) element).getObject()) : null;
                AbstractNativeToolSettings settings = ieWizard.getSettings();
                List<DBSObject> databaseObjects = settings.getDatabaseObjects();
                databaseObjects.clear();
                if (selectedObject != null) {
                    databaseObjects.add(selectedObject);
                }
                if (settings instanceof AbstractImportExportSettings) {
                    ((AbstractImportExportSettings) settings).fillExportObjectsFromInput();
                }
                updateHomeSelector();
                propertyChangeListener.run();
            }

            @Override
            protected boolean isFolderVisible(DBNLocalFolder folder) {
                for (DBNDataSource ds : folder.getNestedDataSources()) {
                    if (isDataSourceVisible(ds)) {
                        return true;
                    }
                }
                return false;
            }

            @Override
            protected boolean isDataSourceVisible(DBNDataSource dataSource) {
                try {
                    return providerClass.isInstance(dataSource.getDataSourceContainer().getDriver().getDataSourceProvider());
                } catch (Exception e) {
                    log.debug(e);
                    return false;
                }
            }
        };
    }
    {
        Composite clientGroup = UIUtils.createControlGroup((Composite) parent, TaskNativeUIMessages.tools_wizard_client_group_title, 1, GridData.FILL_HORIZONTAL, 0);
        homesSelector = new ClientHomesSelector(clientGroup, TaskNativeUIMessages.tools_wizard_client_group_client);
        homesSelector.addSelectionChangedListener(event -> propertyChangeListener.run());
        homesSelector.getPanel().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) TaskConfigurationWizard(org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizard) CommonUtils(org.jkiss.utils.CommonUtils) org.jkiss.dbeaver.model.navigator(org.jkiss.dbeaver.model.navigator) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBTTaskType(org.jkiss.dbeaver.model.task.DBTTaskType) ClientHomesSelector(org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector) DBPDataSourceProvider(org.jkiss.dbeaver.model.DBPDataSourceProvider) DBRRunnableContext(org.jkiss.dbeaver.model.runtime.DBRRunnableContext) DBSWrapper(org.jkiss.dbeaver.model.struct.DBSWrapper) DBTTaskConfigPanel(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigPanel) Group(org.eclipse.swt.widgets.Group) AbstractNativeToolSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolSettings) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) InvocationTargetException(java.lang.reflect.InvocationTargetException) AbstractImportExportSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractImportExportSettings) DatabaseObjectsSelectorPanel(org.jkiss.dbeaver.ui.navigator.database.DatabaseObjectsSelectorPanel) List(java.util.List) TaskNativeUIMessages(org.jkiss.dbeaver.tasks.ui.nativetool.internal.TaskNativeUIMessages) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) Log(org.jkiss.dbeaver.Log) GridData(org.eclipse.swt.layout.GridData) Collections(java.util.Collections) Group(org.eclipse.swt.widgets.Group) DBSWrapper(org.jkiss.dbeaver.model.struct.DBSWrapper) Composite(org.eclipse.swt.widgets.Composite) AbstractImportExportSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractImportExportSettings) AbstractNativeToolSettings(org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolSettings) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ClientHomesSelector(org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector) GridData(org.eclipse.swt.layout.GridData) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseObjectsSelectorPanel(org.jkiss.dbeaver.ui.navigator.database.DatabaseObjectsSelectorPanel)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Collections (java.util.Collections)2 List (java.util.List)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 Log (org.jkiss.dbeaver.Log)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 DBPDataSourceProvider (org.jkiss.dbeaver.model.DBPDataSourceProvider)2 org.jkiss.dbeaver.model.navigator (org.jkiss.dbeaver.model.navigator)2 DBRRunnableContext (org.jkiss.dbeaver.model.runtime.DBRRunnableContext)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 DBSWrapper (org.jkiss.dbeaver.model.struct.DBSWrapper)2 DBTTaskType (org.jkiss.dbeaver.model.task.DBTTaskType)2 DBWorkbench (org.jkiss.dbeaver.runtime.DBWorkbench)2 AbstractImportExportSettings (org.jkiss.dbeaver.tasks.nativetool.AbstractImportExportSettings)2 AbstractNativeToolSettings (org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolSettings)2 DBTTaskConfigPanel (org.jkiss.dbeaver.tasks.ui.DBTTaskConfigPanel)2 TaskNativeUIMessages (org.jkiss.dbeaver.tasks.ui.nativetool.internal.TaskNativeUIMessages)2 TaskConfigurationWizard (org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizard)2