Search in sources :

Example 11 with DatabaseNavigatorTree

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree in project dbeaver by dbeaver.

the class NavigatorHandlerConnectionFilter method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
    if (partSite != null && partSite.getPart() instanceof DatabaseNavigatorView) {
        DatabaseNavigatorTree navigatorTree = ((DatabaseNavigatorView) partSite.getPart()).getNavigatorTree();
        element.setIcon(DBeaverIcons.getImageDescriptor(navigatorTree.isFilterShowConnected() ? UIIcon.FILTER_RESET : UIIcon.FILTER_APPLY));
        String actionName = navigatorTree.isFilterShowConnected() ? "Show all" : "Show connected only";
        element.setText(actionName);
        element.setTooltip(actionName);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)

Example 12 with DatabaseNavigatorTree

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree in project dbeaver by dbeaver.

the class ObjectACLEditor method createPartControl.

public void createPartControl(Composite parent) {
    this.pageControl = new PageControl(parent);
    SashForm composite = UIUtils.createPartDivider(getSite().getPart(), this.pageControl, SWT.HORIZONTAL);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    roleOrObjectTable = new DatabaseNavigatorTree(composite, DBWorkbench.getPlatform().getNavigatorModel().getRoot(), SWT.MULTI | SWT.FULL_SELECTION, false, isRoleEditor() ? new DatabaseObjectFilter() : null);
    roleOrObjectTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    final TreeViewer treeViewer = roleOrObjectTable.getViewer();
    treeViewer.setLabelProvider(new DatabaseNavigatorLabelProvider(treeViewer) {

        @Override
        public Font getFont(Object element) {
            if (element instanceof DBNDatabaseNode) {
                DBSObject object = ((DBNDatabaseNode) element).getObject();
                if (object instanceof DBSSchema) {
                    String schemaPrefix = DBUtils.getQuotedIdentifier(object) + ".";
                    for (String tableName : privilegeMap.keySet()) {
                        if (tableName.startsWith(schemaPrefix)) {
                            return boldFont;
                        }
                    }
                } else if (getObjectPermissions(object) != null) {
                    return boldFont;
                }
            }
            return null;
        }
    });
    treeViewer.addSelectionChangedListener(event -> handleSelectionChange());
    treeViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof DBNNode && !(element instanceof DBNDatabaseNode)) {
                return false;
            }
            if (element instanceof DBNDatabaseFolder) {
                try {
                    String elementTypeName = ((DBNDatabaseFolder) element).getMeta().getType();
                    if (elementTypeName == null) {
                        return false;
                    }
                    Class<?> childType = Class.forName(elementTypeName);
                    return DBAPrivilegeOwner.class.isAssignableFrom(childType);
                } catch (ClassNotFoundException e) {
                    return false;
                }
            }
            return true;
        }
    });
    {
        permEditPanel = new Composite(composite, SWT.NONE);
        permEditPanel.setLayout(new GridLayout(1, true));
        permissionTable = new ObjectListControl<DBAPrivilege>(permEditPanel, SWT.FULL_SELECTION | SWT.CHECK, new ListContentProvider()) {

            @Override
            protected String getListConfigId(List<Class<?>> classList) {
                return ObjectACLEditor.this.getClass().getName();
            }

            @Override
            protected LoadingJob<Collection<DBAPrivilege>> createLoadService() {
                return null;
            }
        };
        permissionTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        /*
            UIUtils.createTableColumn(permissionTable, SWT.LEFT, "Permission");
            UIUtils.createTableColumn(permissionTable, SWT.CENTER, "With GRANT");
            UIUtils.createTableColumn(permissionTable, SWT.CENTER, "With Hierarchy");
            permissionTable.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (e.detail == SWT.CHECK) {
                        updateCurrentPrivileges(((TableItem) e.item).getChecked(), (DBAPrivilegeType) e.item.getData());
                    }
                }
            });

            if (!isRoleEditor()) {
                for (PRIVILEGE_TYPE pt : getACLManager().getPrivilegeTypes()) {
                    if (!pt.isValid() || !pt.supportsType(getDatabaseObject().getClass())) {
                        continue;
                    }
                    TableItem privItem = new TableItem(permissionTable, SWT.LEFT);
                    privItem.setText(0, pt.getName());
                    privItem.setData(pt);
                }
            }
*/
        Composite buttonPanel = new Composite(permEditPanel, SWT.NONE);
        buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        buttonPanel.setLayout(new RowLayout());
        UIUtils.createPushButton(buttonPanel, "Grant All", null, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
            /*
                    boolean hadNonChecked = false;
                    for (TableItem item : permissionTable.getItems()) {
                        if (!item.getChecked()) hadNonChecked = true;
                        item.setChecked(true);
                    }
                    if (hadNonChecked) updateCurrentPrivileges(true, null);
*/
            }
        });
        UIUtils.createPushButton(buttonPanel, "Revoke All", null, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
            /*
                    boolean hadChecked = false;
                    for (TableItem item : permissionTable.getItems()) {
                        if (item.getChecked()) hadChecked = true;
                        item.setChecked(false);
                    }
                    if (hadChecked) {
                        updateCurrentPrivileges(false, null);
                    }
*/
            }
        });
        objectDescriptionText = new Text(permEditPanel, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
        objectDescriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    pageControl.createOrSubstituteProgressPanel(getSite());
    updateObjectPermissions(null);
}
Also used : DatabaseNavigatorLabelProvider(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider) ObjectListControl(org.jkiss.dbeaver.ui.navigator.itemlist.ObjectListControl) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) SashForm(org.eclipse.swt.custom.SashForm) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ProgressPageControl(org.jkiss.dbeaver.ui.controls.ProgressPageControl) GridData(org.eclipse.swt.layout.GridData) Collection(java.util.Collection) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 13 with DatabaseNavigatorTree

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree in project dbeaver by dbeaver.

the class SearchMetadataPage method createControl.

@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    initializeDialogUnits(parent);
    Composite searchGroup = new Composite(parent, SWT.NONE);
    searchGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    searchGroup.setLayout(new GridLayout(3, false));
    setControl(searchGroup);
    UIUtils.createControlLabel(searchGroup, UISearchMessages.dialog_search_objects_label_object_name);
    searchText = new Combo(searchGroup, SWT.DROP_DOWN);
    searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (nameMask != null) {
        searchText.setText(nameMask);
    }
    for (String history : searchHistory) {
        searchText.add(history);
    }
    searchText.addModifyListener(e -> {
        nameMask = searchText.getText();
        updateEnablement();
    });
    Composite optionsGroup = new SashForm(searchGroup, SWT.NONE);
    GridLayout layout = new GridLayout(2, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    optionsGroup.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 3;
    optionsGroup.setLayoutData(gd);
    {
        Group sourceGroup = UIUtils.createControlGroup(optionsGroup, UISearchMessages.dialog_search_objects_group_objects_source, 1, GridData.FILL_BOTH, 0);
        gd = new GridData(GridData.FILL_BOTH);
        // gd.heightHint = 300;
        sourceGroup.setLayoutData(gd);
        DBPPlatform platform = DBWorkbench.getPlatform();
        final DBNProject projectNode = platform.getNavigatorModel().getRoot().getProjectNode(currentProject);
        DBNNode rootNode = projectNode == null ? platform.getNavigatorModel().getRoot() : projectNode.getDatabases();
        dataSourceTree = new DatabaseNavigatorTree(sourceGroup, rootNode, SWT.SINGLE);
        gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        dataSourceTree.setLayoutData(gd);
        dataSourceTree.getViewer().addFilter(new ViewerFilter() {

            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (element instanceof TreeNodeSpecial) {
                    return true;
                }
                if (element instanceof DBNNode) {
                    if (element instanceof DBNDatabaseFolder) {
                        DBNDatabaseFolder folder = (DBNDatabaseFolder) element;
                        Class<? extends DBSObject> folderItemsClass = folder.getChildrenClass();
                        return folderItemsClass != null && DBSObjectContainer.class.isAssignableFrom(folderItemsClass);
                    }
                    if (element instanceof DBNLocalFolder || element instanceof DBNProjectDatabases || element instanceof DBNDataSource || (element instanceof DBSWrapper && ((DBSWrapper) element).getObject() instanceof DBSObjectContainer)) {
                        return true;
                    }
                }
                return false;
            }
        });
        dataSourceTree.getViewer().addSelectionChangedListener(event -> {
            fillObjectTypes();
            updateEnablement();
            IStructuredSelection structSel = (IStructuredSelection) event.getSelection();
            Object object = structSel.isEmpty() ? null : structSel.getFirstElement();
            if (object instanceof DBNNode) {
                for (DBNNode node = (DBNNode) object; node != null; node = node.getParentNode()) {
                    if (node instanceof DBNDataSource) {
                        DBNDataSource dsNode = (DBNDataSource) node;
                        try {
                            dsNode.initializeNode(null, status -> {
                                if (status.isOK()) {
                                    UIUtils.asyncExec(() -> {
                                        if (!dataSourceTree.isDisposed()) {
                                            fillObjectTypes();
                                        }
                                    });
                                }
                            });
                        } catch (DBException e) {
                            // shouldn't be here
                            log.error(e);
                        }
                        break;
                    }
                }
            }
        });
    }
    {
        Group settingsGroup = UIUtils.createControlGroup(optionsGroup, "Settings", 2, GridData.FILL_BOTH, 0);
        gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        settingsGroup.setLayoutData(gd);
        {
            // new Label(searchGroup, SWT.NONE);
            UIUtils.createControlLabel(settingsGroup, UISearchMessages.dialog_search_objects_label_name_match);
            final Combo matchCombo = new Combo(settingsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
            matchCombo.add(UISearchMessages.dialog_search_objects_combo_starts_with, SearchMetadataConstants.MATCH_INDEX_STARTS_WITH);
            matchCombo.add(UISearchMessages.dialog_search_objects_combo_contains, SearchMetadataConstants.MATCH_INDEX_CONTAINS);
            matchCombo.add(UISearchMessages.dialog_search_objects_combo_like, SearchMetadataConstants.MATCH_INDEX_LIKE);
            matchCombo.select(0);
            matchCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            if (matchTypeIndex >= 0) {
                matchCombo.select(matchTypeIndex);
            }
            matchCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    matchTypeIndex = matchCombo.getSelectionIndex();
                }
            });
            matchCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            if (maxResults <= 0) {
                maxResults = 100;
            }
            final Spinner maxResultsSpinner = UIUtils.createLabelSpinner(settingsGroup, UISearchMessages.dialog_search_objects_spinner_max_results, maxResults, 1, 10000);
            maxResultsSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            maxResultsSpinner.addModifyListener(e -> maxResults = maxResultsSpinner.getSelection());
            maxResultsSpinner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            final Button caseCheckbox = UIUtils.createLabelCheckbox(settingsGroup, UISearchMessages.dialog_search_objects_case_sensitive, caseSensitive);
            caseCheckbox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    caseSensitive = caseCheckbox.getSelection();
                }
            });
            caseCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        }
        Label otLabel = UIUtils.createControlLabel(settingsGroup, UISearchMessages.dialog_search_objects_group_object_types);
        otLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
        typesTable = new Table(settingsGroup, SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
        typesTable.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // checkedTypes.clear();
                for (TableItem item : typesTable.getItems()) {
                    DBSObjectType objectType = (DBSObjectType) item.getData();
                    if (item.getChecked()) {
                        checkedTypes.add(objectType);
                    } else {
                        checkedTypes.remove(objectType);
                    }
                }
                updateEnablement();
            }
        });
        typesTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                TableItem[] selection = typesTable.getSelection();
                if (selection.length > 0) {
                    TableItem tableItem = selection[0];
                    tableItem.setChecked(!tableItem.getChecked());
                }
            }
        });
        typesTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        UIUtils.createTableColumn(typesTable, SWT.LEFT, UISearchMessages.dialog_search_objects_column_type);
        UIUtils.createTableColumn(typesTable, SWT.LEFT, UISearchMessages.dialog_search_objects_column_description);
    }
    UIUtils.asyncExec(this::loadState);
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) java.util(java.util) SashForm(org.eclipse.swt.custom.SashForm) org.jkiss.dbeaver.model.navigator(org.jkiss.dbeaver.model.navigator) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) UISearchMessages(org.jkiss.dbeaver.ui.search.internal.UISearchMessages) DefaultProgressMonitor(org.jkiss.dbeaver.model.runtime.DefaultProgressMonitor) DBeaverIcons(org.jkiss.dbeaver.ui.DBeaverIcons) UIUtils(org.jkiss.dbeaver.ui.UIUtils) NavigatorUtils(org.jkiss.dbeaver.ui.navigator.NavigatorUtils) TreeNodeSpecial(org.jkiss.dbeaver.ui.navigator.database.load.TreeNodeSpecial) DBPPlatform(org.jkiss.dbeaver.model.app.DBPPlatform) GridData(org.eclipse.swt.layout.GridData) AbstractSearchPage(org.jkiss.dbeaver.ui.search.AbstractSearchPage) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) org.jkiss.dbeaver.model.struct(org.jkiss.dbeaver.model.struct) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) Viewer(org.eclipse.jface.viewers.Viewer) DBUtils(org.jkiss.dbeaver.model.DBUtils) org.eclipse.swt.widgets(org.eclipse.swt.widgets) InvocationTargetException(java.lang.reflect.InvocationTargetException) MouseEvent(org.eclipse.swt.events.MouseEvent) List(java.util.List) DBException(org.jkiss.dbeaver.DBException) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MouseAdapter(org.eclipse.swt.events.MouseAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) DBException(org.jkiss.dbeaver.DBException) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBPPlatform(org.jkiss.dbeaver.model.app.DBPPlatform) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TreeNodeSpecial(org.jkiss.dbeaver.ui.navigator.database.load.TreeNodeSpecial) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) SashForm(org.eclipse.swt.custom.SashForm) GridData(org.eclipse.swt.layout.GridData)

Example 14 with DatabaseNavigatorTree

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree in project dbeaver by dbeaver.

the class SQLToolTaskObjectSelectorDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    Composite dialogArea = super.createDialogArea(parent);
    INavigatorFilter dsFilter = new INavigatorFilter() {

        @Override
        public boolean filterFolders() {
            return true;
        }

        @Override
        public boolean isLeafObject(Object object) {
            return object instanceof DBNDatabaseItem && taskType.appliesTo(((DBNDatabaseItem) object).getObject());
        }

        @Override
        public boolean select(Object element) {
            if (element instanceof DBNProject || element instanceof DBNProjectDatabases) {
                return true;
            }
            if (element instanceof DBNLocalFolder) {
                for (DBNDataSource ds : ((DBNLocalFolder) element).getNestedDataSources()) {
                    if (taskType.isDriverApplicable(ds.getDataSourceContainer().getDriver()) && (!showConnected || ds.getDataSourceContainer().isConnected())) {
                        return true;
                    }
                }
                return false;
            }
            if (element instanceof DBNDataSource) {
                if (showConnected && !((DBNDataSource) element).getDataSourceContainer().isConnected()) {
                    return false;
                }
                return taskType.isDriverApplicable(((DBNDataSource) element).getDataSourceContainer().getDriver());
            }
            if (element instanceof DBNDatabaseItem) {
                DBSObject object = ((DBNDatabaseItem) element).getObject();
                return (DBSObjectContainer.class.isAssignableFrom(object.getClass()) || (taskType.matchesEntityElements() && DBSEntity.class.isAssignableFrom(object.getClass())) || taskType.appliesTo(object));
            } else if (element instanceof DBNDatabaseFolder) {
                Class<? extends DBSObject> childrenClass = ((DBNDatabaseFolder) element).getChildrenClass();
                return childrenClass != null && (DBSObjectContainer.class.isAssignableFrom(childrenClass) || (taskType.matchesEntityElements() && DBSEntity.class.isAssignableFrom(childrenClass)) || taskType.matchesType(childrenClass));
            }
            return element instanceof TreeNodeSpecial;
        }
    };
    dataSourceTree = new DatabaseNavigatorTree(dialogArea, projectNode.getDatabases(), SWT.SINGLE | SWT.BORDER | SWT.CHECK, false, dsFilter);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 300;
    gd.widthHint = 400;
    dataSourceTree.setLayoutData(gd);
    dataSourceTree.getViewer().addSelectionChangedListener(event -> {
        updateSelectedObjects();
    });
    final Button showConnectedCheck = new Button(dialogArea, SWT.CHECK);
    showConnectedCheck.setText(UINavigatorMessages.label_show_connected);
    showConnectedCheck.setSelection(showConnected);
    showConnectedCheck.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showConnected = showConnectedCheck.getSelection();
            dataSourceTree.getViewer().refresh();
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) INavigatorFilter(org.jkiss.dbeaver.ui.navigator.INavigatorFilter) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) Button(org.eclipse.swt.widgets.Button) DBSObjectContainer(org.jkiss.dbeaver.model.struct.DBSObjectContainer) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity) TreeNodeSpecial(org.jkiss.dbeaver.ui.navigator.database.load.TreeNodeSpecial)

Example 15 with DatabaseNavigatorTree

use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree in project dbeaver by dbeaver.

the class ScriptsExportWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    String outDir = DBWorkbench.getPlatform().getPreferenceStore().getString(PREF_SCRIPTS_EXPORT_OUT_DIR);
    if (CommonUtils.isEmpty(outDir)) {
        outDir = RuntimeUtils.getUserHomeDir().getAbsolutePath();
    }
    Composite placeholder = UIUtils.createPlaceholder(parent, 1);
    placeholder.setLayout(new GridLayout(1, false));
    // Project list
    scriptsNavigator = new DatabaseNavigatorTree(placeholder, DBWorkbench.getPlatform().getNavigatorModel().getRoot(), SWT.BORDER | SWT.CHECK);
    GridData gd = new GridData(GridData.FILL_BOTH);
    scriptsNavigator.setLayoutData(gd);
    CheckboxTreeViewer viewer = (CheckboxTreeViewer) scriptsNavigator.getViewer();
    viewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateState();
        }
    });
    scriptsNavigator.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return element instanceof DBNResource && ((DBNResource) element).getResource() instanceof IContainer;
        }
    });
    // Output folder
    Composite generalSettings = UIUtils.createPlaceholder(placeholder, 3);
    generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    {
        overwriteCheck = UIUtils.createCheckbox(generalSettings, CoreMessages.dialog_project_export_wizard_page_checkbox_overwrite_files, false);
        gd = new GridData(GridData.BEGINNING);
        gd.horizontalSpan = 3;
        overwriteCheck.setLayoutData(gd);
        UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_project_export_wizard_page_label_directory);
        directoryText = new Text(generalSettings, SWT.BORDER);
        directoryText.setText(outDir);
        directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        directoryText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                updateState();
            }
        });
        Button openFolder = new Button(generalSettings, SWT.PUSH);
        openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
        openFolder.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
                dialog.setMessage(CoreMessages.dialog_project_export_wizard_page_dialog_choose_export_dir_message);
                dialog.setText(CoreMessages.dialog_project_export_wizard_page_dialog_choose_export_dir_text);
                String directory = directoryText.getText();
                if (!CommonUtils.isEmpty(directory)) {
                    dialog.setFilterPath(directory);
                }
                directory = dialog.open();
                if (directory != null) {
                    directoryText.setText(directory);
                }
            }
        });
    }
    setControl(placeholder);
    updateState();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) DBNResource(org.jkiss.dbeaver.model.navigator.DBNResource) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IContainer(org.eclipse.core.resources.IContainer) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

DatabaseNavigatorTree (org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)36 GridData (org.eclipse.swt.layout.GridData)28 Composite (org.eclipse.swt.widgets.Composite)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)14 Text (org.eclipse.swt.widgets.Text)13 GridLayout (org.eclipse.swt.layout.GridLayout)11 TreeNodeSpecial (org.jkiss.dbeaver.ui.navigator.database.load.TreeNodeSpecial)10 ModifyEvent (org.eclipse.swt.events.ModifyEvent)8 ModifyListener (org.eclipse.swt.events.ModifyListener)8 Button (org.eclipse.swt.widgets.Button)8 INavigatorFilter (org.jkiss.dbeaver.ui.navigator.INavigatorFilter)8 Viewer (org.eclipse.jface.viewers.Viewer)6 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)6 SashForm (org.eclipse.swt.custom.SashForm)6 DBNResource (org.jkiss.dbeaver.model.navigator.DBNResource)6 IContainer (org.eclipse.core.resources.IContainer)4 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)4 ICheckStateProvider (org.eclipse.jface.viewers.ICheckStateProvider)4