/** * Returns the current frame. * * @param flags a bit-wise OR of the frame source flag constants * @return the current frame */ protected Frame getCurrentFrame(int flags) { Object input = viewer.getInput(); TreeFrame frame = createFrame(input); if ((flags & IFrameSource.FULL_CONTEXT) != 0) { frame.setSelection(viewer.getSelection()); frame.setExpandedElements(viewer.getExpandedElements()); } return frame; }
/** * Returns the parent frame, or <code>null</code> if there is no parent frame. * * @param flags a bit-wise OR of the frame source flag constants * @return the parent frame, or <code>null</code> */ protected Frame getParentFrame(int flags) { Object input = viewer.getInput(); ITreeContentProvider provider = (ITreeContentProvider) viewer .getContentProvider(); Object parent = provider.getParent(input); if (parent == null) { return null; } TreeFrame frame = createFrame(parent); if ((flags & IFrameSource.FULL_CONTEXT) != 0) { frame.setSelection(viewer.getSelection()); // include current input in expanded set Object[] expanded = viewer.getExpandedElements(); Object[] newExpanded = new Object[expanded.length + 1]; System.arraycopy(expanded, 0, newExpanded, 0, expanded.length); newExpanded[newExpanded.length - 1] = input; frame.setExpandedElements(newExpanded); } return frame; }
/** * Returns the frame for the selection, or <code>null</code> if there is no * frame for the selection. * * @param flags a bit-wise OR of the frame source flag constants * @return the selection frame, or <code>null</code> */ protected Frame getSelectionFrame(int flags) { IStructuredSelection sel = (IStructuredSelection) viewer.getSelection(); if (sel.size() == 1) { Object o = sel.getFirstElement(); if (viewer.isExpandable(o)) { TreeFrame frame = createFrame(o); if ((flags & IFrameSource.FULL_CONTEXT) != 0) { frame.setSelection(viewer.getSelection()); frame.setExpandedElements(viewer.getExpandedElements()); } return frame; } } return null; }