Search in sources :

Example 6 with ToolDescriptor

use of org.jkiss.dbeaver.tools.registry.ToolDescriptor in project dbeaver by dbeaver.

the class DataSourceToolsContributor method getAvailableTools.

private List<ToolDescriptor> getAvailableTools(IStructuredSelection selection) {
    List<DBSObject> objects = NavigatorUtils.getSelectedObjects(selection);
    List<ToolDescriptor> result = new ArrayList<>();
    if (!objects.isEmpty()) {
        for (ToolDescriptor descriptor : ToolsRegistry.getInstance().getTools()) {
            if (descriptor.isSingleton() && objects.size() > 1) {
                continue;
            }
            boolean applies = true;
            for (DBSObject object : objects) {
                if (!descriptor.appliesTo(object)) {
                    applies = false;
                    break;
                }
            }
            if (applies) {
                result.add(descriptor);
            }
        }
    }
    return result;
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ToolDescriptor(org.jkiss.dbeaver.tools.registry.ToolDescriptor)

Aggregations

ToolDescriptor (org.jkiss.dbeaver.tools.registry.ToolDescriptor)6 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)4 ISelection (org.eclipse.jface.viewers.ISelection)2 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 DBPEditorContribution (org.jkiss.dbeaver.model.connection.DBPEditorContribution)2 ToolGroupDescriptor (org.jkiss.dbeaver.tools.registry.ToolGroupDescriptor)2 EmptyListAction (org.jkiss.dbeaver.ui.actions.EmptyListAction)2 IDatabaseEditorInput (org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput)2 INavigatorModelView (org.jkiss.dbeaver.ui.navigator.INavigatorModelView)2