Search in sources :

Example 1 with DBPResourceHandlerDescriptor

use of org.jkiss.dbeaver.model.app.DBPResourceHandlerDescriptor in project dbeaver by serge-rider.

the class PrefPageProjectResourceSettings method performDefaults.

@Override
protected void performDefaults() {
    resourceTable.removeAll();
    DBPWorkspace workspace = DBWorkbench.getPlatform().getWorkspace();
    for (DBPResourceHandlerDescriptor descriptor : workspace.getResourceHandlerDescriptors()) {
        if (!descriptor.isManagable()) {
            continue;
        }
        TableItem item = new TableItem(resourceTable, SWT.NONE);
        item.setData(descriptor);
        final DBPImage icon = descriptor.getIcon();
        if (icon != null) {
            item.setImage(DBeaverIcons.getImage(icon));
        }
        item.setText(0, descriptor.getName());
        DBPProject projectMeta = getProjectMeta();
        String defaultRoot = projectMeta == null ? null : descriptor.getDefaultRoot(projectMeta);
        if (defaultRoot != null) {
            item.setText(1, defaultRoot);
        }
    }
    UIUtils.packColumns(resourceTable, true);
    super.performDefaults();
}
Also used : DBPWorkspace(org.jkiss.dbeaver.model.app.DBPWorkspace) DBPResourceHandlerDescriptor(org.jkiss.dbeaver.model.app.DBPResourceHandlerDescriptor) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPImage(org.jkiss.dbeaver.model.DBPImage)

Example 2 with DBPResourceHandlerDescriptor

use of org.jkiss.dbeaver.model.app.DBPResourceHandlerDescriptor in project dbeaver by serge-rider.

the class PrefPageProjectResourceSettings method performOk.

@Override
public boolean performOk() {
    java.util.List<IResource> refreshedResources = new ArrayList<>();
    // Save roots
    DBPProject projectMeta = getProjectMeta();
    if (projectMeta != null) {
        for (TableItem item : resourceTable.getItems()) {
            DBPResourceHandlerDescriptor descriptor = (DBPResourceHandlerDescriptor) item.getData();
            String rootPath = item.getText(1);
            if (!CommonUtils.equalObjects(descriptor.getDefaultRoot(projectMeta), rootPath)) {
                IResource oldResource = project.findMember(descriptor.getDefaultRoot(projectMeta));
                if (oldResource != null) {
                    refreshedResources.add(oldResource);
                }
                IResource newResource = project.findMember(rootPath);
                if (newResource != null) {
                    refreshedResources.add(newResource);
                }
                descriptor.setDefaultRoot(projectMeta, rootPath);
            }
        }
        if (!refreshedResources.isEmpty()) {
            for (IResource resource : refreshedResources) {
                DBNUtils.refreshNavigatorResource(resource, this);
            }
        }
    }
    return super.performOk();
}
Also used : DBPResourceHandlerDescriptor(org.jkiss.dbeaver.model.app.DBPResourceHandlerDescriptor) ArrayList(java.util.ArrayList) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) IResource(org.eclipse.core.resources.IResource)

Aggregations

DBPProject (org.jkiss.dbeaver.model.app.DBPProject)2 DBPResourceHandlerDescriptor (org.jkiss.dbeaver.model.app.DBPResourceHandlerDescriptor)2 ArrayList (java.util.ArrayList)1 IResource (org.eclipse.core.resources.IResource)1 DBPImage (org.jkiss.dbeaver.model.DBPImage)1 DBPWorkspace (org.jkiss.dbeaver.model.app.DBPWorkspace)1