use of org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder in project dbeaver by serge-rider.
the class NavigatorHandlerFilterConfig method configureFilters.
public static void configureFilters(Shell shell, DBNNode node) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
DBSObjectFilter objectFilter = folder.getNodeFilter(itemsMeta, true);
if (objectFilter == null) {
objectFilter = new DBSObjectFilter();
}
boolean globalFilter = folder.getValueObject() instanceof DBPDataSource;
String parentName = "?";
if (folder.getValueObject() instanceof DBSObject) {
parentName = ((DBSObject) folder.getValueObject()).getName();
}
EditObjectFilterDialog dialog = new EditObjectFilterDialog(shell, globalFilter ? "All " + node.getNodeType() : node.getNodeType() + " of " + parentName, objectFilter, globalFilter);
switch(dialog.open()) {
case IDialogConstants.OK_ID:
folder.setNodeFilter(itemsMeta, dialog.getFilter());
NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
break;
case EditObjectFilterDialog.SHOW_GLOBAL_FILTERS_ID:
objectFilter = folder.getDataSource().getContainer().getObjectFilter(folder.getChildrenClass(), null, false);
dialog = new EditObjectFilterDialog(shell, "All " + node.getNodeType(), objectFilter != null ? objectFilter : new DBSObjectFilter(), true);
if (dialog.open() == IDialogConstants.OK_ID) {
// Set global filter
folder.getDataSource().getContainer().setObjectFilter(folder.getChildrenClass(), null, dialog.getFilter());
folder.getDataSource().getContainer().persistConfiguration();
NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
}
break;
}
}
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder in project dbeaver by serge-rider.
the class NavigatorHandlerFilterConfig method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
configureFilters(HandlerUtil.getActiveShell(event), node);
}
return null;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder in project dbeaver by serge-rider.
the class ItemListControl method fillCustomActions.
@Override
protected void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
final DBNNode rootNode = getRootNode();
if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
contributionManager.add(new Action("Filter", DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {
@Override
public void run() {
NavigatorHandlerFilterConfig.configureFilters(getShell(), rootNode);
}
});
}
IWorkbenchSite workbenchSite = getWorkbenchSite();
if (workbenchSite != null) {
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REFRESH));
}
if (rootNode instanceof DBNDatabaseNode) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_OPEN));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_CREATE));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_DELETE));
}
if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
boolean hasReorder = false;
List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
for (Class<?> chilType : childrenTypes) {
if (EntityEditorsRegistry.getInstance().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
hasReorder = true;
break;
}
}
if (hasReorder) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_UP));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_DOWN));
}
}
if (workbenchSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart editor = ((MultiPageEditorSite) workbenchSite).getMultiPageEditor();
if (editor instanceof EntityEditor) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_SAVE, null, UIIcon.SAVE, null, true));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REVERT, null, UIIcon.RESET, null, true));
}
}
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder in project dbeaver by serge-rider.
the class NavigatorHandlerFilterClear method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
folder.setNodeFilter(itemsMeta, new DBSObjectFilter());
NavigatorHandlerRefresh.refreshNavigator(Collections.singleton(folder));
}
}
return null;
}
use of org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder in project dbeaver by serge-rider.
the class NavigatorHandlerFilterToggle method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
final DBSObjectFilter nodeFilter = folder.getNodeFilter(itemsMeta, true);
if (nodeFilter != null) {
nodeFilter.setEnabled(!nodeFilter.isEnabled());
NavigatorHandlerRefresh.refreshNavigator(Collections.singleton(folder));
}
}
}
return null;
}
Aggregations