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();
}
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();
}
Aggregations