List of usage examples for org.eclipse.jface.viewers TreeSelection equals
@Override
public boolean equals(Object obj)
From source file:objectview.EObjectFocusDomain.java
License:Open Source License
/** * Try to display the item of tree path in views in the greatest * accuracy possible. Returns longest tree path, which is actually * shown in the UI. //from w w w . j av a2s.c o m */ public TreePath focus(TreePath path, boolean tryActivate) { try { TreeSelection newFocus = new TreeSelection(path); if (tryActivate || !newFocus.equals(focus)) { focus = newFocus; TreePath shown = null; for (IObjectView objectView : getViews()) { TreePath tryShow = path; while (tryShow != null) { if (objectView.canShow(tryShow.getLastSegment())) { objectView.show(tryShow.getLastSegment(), tryActivate); if (shown == null || tryShow.getSegmentCount() > shown.getSegmentCount()) { shown = tryShow; } break; } tryShow = tryShow.getParentPath(); } } // Fire selection changed for (ISelectionChangedListener l : listeners) { l.selectionChanged(new SelectionChangedEvent(this, focus)); } return shown; } else { return canFocusUpTo(path); } } catch (Exception e) { //e.printStackTrace(); //throw new RuntimeException(e); return null; } }
From source file:org.absmodels.abs.plugin.navigator.NavigatorUtils.java
License:Open Source License
/** * Opens the file in an editor that corresponds to the given * TreeSelection. Only the first element of the selection will be * taken into account.//from w w w . ja va 2 s . com * * @param ts TreeSelection that is used as a base to find an appropriate editor * @throws PartInitException - if the editor could not be opened for highlighting */ public static void openEditor(TreeSelection ts) throws PartInitException { if (!ts.equals(TreeSelection.EMPTY)) { TreePath path = ts.getPaths()[0]; IProject project = getProject(path); if (project != null) { if (path.getLastSegment() instanceof InternalASTNode<?>) { InternalASTNode<?> node = (InternalASTNode<?>) path.getLastSegment(); openAndHighlightEditor(node); } else if (path.getLastSegment() instanceof ModulePath) { ModulePath mp = (ModulePath) path.getLastSegment(); if (mp.hasModuleWithDecls()) { InternalASTNode<ModuleDecl> moduleDecl = mp.getModuleDecl(); openAndHighlightEditor(moduleDecl); } } else if (path.getLastSegment() instanceof PackageAbsFile) { openABSEditorForFile((PackageAbsFile) path.getLastSegment()); } } } }
From source file:org.absmodels.abs.plugin.navigator.NavigatorUtils.java
License:Open Source License
public static IProject getProject(TreeSelection ts) { if (!ts.equals(TreeSelection.EMPTY)) { TreePath path = ts.getPaths()[0]; return getProject(path); }/* w w w. jav a 2s. co m*/ return null; }