public void processSelection(IWorkbenchPart targetPart, ISelection selection) { this.activeTargetPart = targetPart; if (targetPart != null) { ISelectionProvider selectionProvider = ((WorkbenchPart) targetPart).getSite().getSelectionProvider(); if (selectionProvider != null && selectionProvider.getSelection() != null && !selectionProvider.getSelection().isEmpty()) selection = selectionProvider.getSelection(); if (selection == null || selection.isEmpty()) return; } treePaths = null; treePath = null; sel = null; sels = null; model = null; if (selection instanceof ITreeSelection) { treePaths = ((ITreeSelection) selection).getPaths(); treePath = ((ITreeSelection) selection).getPaths()[0]; sel = DBNodeFactory.dbNode(treePath); sels = DBNodeFactory.dbNodes(treePaths); } else if (selection instanceof IStructuredSelection) { Object firstElement = ((IStructuredSelection) selection).getFirstElement(); if (firstElement instanceof ElementDB) sel = DBNodeFactory.dbNode(new ElementDB[] {(ElementDB) firstElement}); else if (firstElement instanceof ElementDBNode) sel = (ElementDBNode) firstElement; else if (firstElement instanceof ISelectionElementDBNode) { sels = ((ISelectionElementDBNode) firstElement).getSelectedDBNode(); sel = sels[0]; } if (sel != null) sels = new ElementDBNode[] {sel}; } if (sel != null) model = sel.model(); }
public ElementDBNode[] getSelectedDBNode() { ElementDBNode[] selectedElement = new ElementDBNode[1]; selectedElement[0] = DBNodeFactory.dbNode(SmartViewModelFactory.getPortModel(getPort())); return selectedElement; }