Search in sources :

Example 1 with DBEObjectEditor

use of org.jkiss.dbeaver.model.edit.DBEObjectEditor in project dbeaver by serge-rider.

the class NavigatorHandlerObjectOpen method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    if (!updateUI) {
        return;
    }
    final ISelectionProvider selectionProvider = UIUtils.getSelectionProvider(element.getServiceLocator());
    if (selectionProvider != null) {
        ISelection selection = selectionProvider.getSelection();
        DBNNode node = NavigatorUtils.getSelectedNode(selection);
        if (node != null) {
            String actionName = CoreMessages.actions_navigator_open;
            if (node instanceof DBNDataSource) {
                actionName = CoreMessages.actions_navigator_edit;
            } else if (node instanceof DBNDatabaseNode) {
                DBSObject object = ((DBNDatabaseNode) node).getObject();
                if (object != null) {
                    DBEObjectEditor objectManager = EntityEditorsRegistry.getInstance().getObjectManager(object.getClass(), DBEObjectEditor.class);
                    actionName = objectManager == null || !objectManager.canEditObject(object) ? CoreMessages.actions_navigator_view : CoreMessages.actions_navigator_edit;
                }
            }
            String label;
            if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() > 1) {
                label = actionName + CoreMessages.actions_navigator__objects;
            } else {
                //$NON-NLS-1$
                label = actionName + " " + node.getNodeType();
            }
            element.setText(label);
        }
    }
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) DBEObjectEditor(org.jkiss.dbeaver.model.edit.DBEObjectEditor) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 DBEObjectEditor (org.jkiss.dbeaver.model.edit.DBEObjectEditor)1 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)1