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