Search in sources :

Example 6 with DBNNode

use of org.jkiss.dbeaver.model.navigator.DBNNode in project dbeaver by serge-rider.

the class AbstractSearchResultsPage method populateObjects.

public void populateObjects(DBRProgressMonitor monitor, Collection<OBJECT_TYPE> objects) {
    if (itemList != null && !itemList.isDisposed()) {
        List<DBNNode> nodes = new ArrayList<>(objects.size());
        for (OBJECT_TYPE object : objects) {
            nodes.add(getNodeFromObject(object));
        }
        TreeViewer itemsViewer = (TreeViewer) itemList.getItemsViewer();
        Collection<DBNNode> oldNodes = itemList.getListData();
        List<DBNNode> newNodes = new ArrayList<>();
        if (!CommonUtils.isEmpty(oldNodes)) {
            newNodes.addAll(oldNodes);
        }
        newNodes.addAll(nodes);
        ((ResultsContentProvider) itemsViewer.getContentProvider()).rebuildObjectTree(newNodes);
        itemList.appendListData(nodes);
        itemsViewer.expandAll();
    }
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 7 with DBNNode

use of org.jkiss.dbeaver.model.navigator.DBNNode in project dbeaver by serge-rider.

the class SearchMetadataQuery method run.

@Override
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
    try {
        List<DBSObjectType> objectTypes = params.getObjectTypes();
        String objectNameMask = params.getObjectNameMask();
        if (params.getMatchType() == SearchMetadataConstants.MATCH_INDEX_STARTS_WITH) {
            if (!objectNameMask.endsWith("%")) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                objectNameMask = objectNameMask + "%";
            }
        } else if (params.getMatchType() == SearchMetadataConstants.MATCH_INDEX_CONTAINS) {
            if (!objectNameMask.startsWith("%")) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                objectNameMask = "%" + objectNameMask;
            }
            if (!objectNameMask.endsWith("%")) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                objectNameMask = objectNameMask + "%";
            }
        }
        DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
        DBRProgressMonitor localMonitor = RuntimeUtils.makeMonitor(monitor);
        Collection<DBSObjectReference> objects = structureAssistant.findObjectsByMask(localMonitor, params.getParentObject(), objectTypes.toArray(new DBSObjectType[objectTypes.size()]), objectNameMask, params.isCaseSensitive(), true, params.getMaxResults());
        for (DBSObjectReference reference : objects) {
            if (monitor.isCanceled()) {
                break;
            }
            try {
                DBSObject object = reference.resolveObject(localMonitor);
                if (object != null) {
                    DBNNode node = navigatorModel.getNodeByObject(localMonitor, object, false);
                    if (node != null) {
                        searchResult.addObjects(Collections.singletonList(node));
                    }
                }
            } catch (DBException e) {
                log.error(e);
            }
        }
        return Status.OK_STATUS;
    } catch (DBException e) {
        return GeneralUtils.makeExceptionStatus(e);
    }
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBException(org.jkiss.dbeaver.DBException) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) DBSObjectType(org.jkiss.dbeaver.model.struct.DBSObjectType) DBSObjectReference(org.jkiss.dbeaver.model.struct.DBSObjectReference) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 8 with DBNNode

use of org.jkiss.dbeaver.model.navigator.DBNNode in project dbeaver by serge-rider.

the class DataImportHandler method chooseProducer.

@Override
protected IDataTransferProducer chooseProducer(ExecutionEvent event, IDataTransferConsumer consumer) {
    final DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
    final DBNNode rootNode = DBeaverCore.getInstance().getLiveProjects().size() == 1 ? navigatorModel.getRoot().getProject(DBeaverCore.getInstance().getProjectRegistry().getActiveProject()) : navigatorModel.getRoot();
    DBNNode node = BrowseObjectDialog.selectObject(HandlerUtil.getActiveShell(event), "Select source container for '" + consumer.getTargetName() + "'", rootNode, null, new Class[] { DBSObjectContainer.class, DBSDataContainer.class }, new Class[] { DBSDataContainer.class });
    if (node instanceof DBNDatabaseNode) {
        DBSObject object = ((DBNDatabaseNode) node).getObject();
        if (object instanceof DBSDataContainer) {
            return new DatabaseTransferProducer((DBSDataContainer) object);
        }
    }
    return null;
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) DatabaseTransferProducer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 9 with DBNNode

use of org.jkiss.dbeaver.model.navigator.DBNNode in project dbeaver by serge-rider.

the class EntityEditor method createTopRightControl.

@Override
protected Control createTopRightControl(Composite composite) {
    // Path
    ToolBar breadcrumbsPanel = new ToolBar(composite, SWT.HORIZONTAL | SWT.RIGHT);
    breadcrumbsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Make base node path
    DBNDatabaseNode node = getEditorInput().getNavigatorNode();
    List<DBNDatabaseNode> nodeList = new ArrayList<>();
    for (DBNNode n = node; n != null; n = n.getParentNode()) {
        if (n instanceof DBNDatabaseNode) {
            nodeList.add(0, (DBNDatabaseNode) n);
        }
    }
    for (final DBNDatabaseNode databaseNode : nodeList) {
        createPathRow(breadcrumbsPanel, databaseNode);
    }
    return breadcrumbsPanel;
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) GridData(org.eclipse.swt.layout.GridData) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)

Example 10 with DBNNode

use of org.jkiss.dbeaver.model.navigator.DBNNode in project dbeaver by serge-rider.

the class NavigatorHandlerObjectRename method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structSelection = (IStructuredSelection) selection;
        Object element = structSelection.getFirstElement();
        if (element instanceof DBNNode) {
            renameNode(HandlerUtil.getActiveWorkbenchWindow(event), (DBNNode) element, null);
        }
    }
    return null;
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) ISelection(org.eclipse.jface.viewers.ISelection) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)40 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)19 DBException (org.jkiss.dbeaver.DBException)13 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)12 ISelection (org.eclipse.jface.viewers.ISelection)9 ArrayList (java.util.ArrayList)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 GridData (org.eclipse.swt.layout.GridData)5 DBNDatabaseFolder (org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder)5 DBNResource (org.jkiss.dbeaver.model.navigator.DBNResource)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IFile (org.eclipse.core.resources.IFile)4 DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)4 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)4 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 DBNDatabaseItem (org.jkiss.dbeaver.model.navigator.DBNDatabaseItem)3 CSmartCombo (org.jkiss.dbeaver.ui.controls.CSmartCombo)3 IProject (org.eclipse.core.resources.IProject)2