/** * Factory method for creating a differences viewer for the top left pane. * It is called from <code>createContents</code> and returns a <code>DiffTreeViewer</code>. * <p> * Subclasses may override if they need a different viewer. * </p> * * @param parent the SWT parent control under which to create the viewer's SWT controls * @return a compare viewer for the top left pane */ public Viewer createDiffViewer(Composite parent) { return new DiffTreeViewer(parent, fCompareConfiguration); }
/** * Copies one side of all {@code DiffNode}s in the current selection to the other side. * Called from the (internal) actions for copying the sides of a {@code DiffNode}. * Clients may override. * * @param leftToRight if {@code true} the left side is copied to the right side. * If {@code false} the right side is copied to the left side */ protected void copySelected(boolean leftToRight) { ISelection selection= getSelection(); if (selection instanceof IStructuredSelection) { Iterator<?> e= ((IStructuredSelection) selection).iterator(); while (e.hasNext()) { Object element= e.next(); if (element instanceof ICompareInput) copyOne((ICompareInput) element, leftToRight); } } }
/** * Expands to infinity all items in the selection. * * @since 2.0 */ protected void expandSelection() { ISelection selection= getSelection(); if (selection instanceof IStructuredSelection) { Iterator<?> elements= ((IStructuredSelection) selection).iterator(); while (elements.hasNext()) { Object next= elements.next(); expandToLevel(next, ALL_LEVELS); } } }
private void initialize(CompareConfiguration configuration) { Control tree= getControl(); tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); fPropertyChangeListener = event -> propertyChange(event); fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener); setContentProvider(new DiffViewerContentProvider()); setLabelProvider(diffViewerLabelProvider); addSelectionChangedListener(event -> updateActions()); setComparator(new DiffViewerComparator()); tbm.add(new Separator("navigation")); //$NON-NLS-1$ createToolItems(tbm); updateActions(); mm.addMenuListener( mm2 -> { fillContextMenu(mm2); if (mm2.isEmpty()) { if (fEmptyMenuAction == null) {
private TreeItem getNextItem(boolean next) { Control c= getControl(); if (!(c instanceof Tree) || c.isDisposed()) return null; Tree tree= (Tree) c; TreeItem item= null; TreeItem children[]= tree.getSelection(); if (children != null && children.length > 0) item= children[0]; if (item == null) { children= tree.getItems(); if (children != null && children.length > 0) { item= children[0]; if (item != null && item.getItemCount() <= 0) { return item; } } } while (true) { item= findNextPrev(item, next); if (item == null) break; if (item.getItemCount() <= 0) break; } return item; }
/** * Overridden to avoid expanding <code>DiffNode</code>s that shouldn't expand. * @param node the node to expand * @param level non-negative level, or <code>ALL_LEVELS</code> to collapse all levels of the tree */ protected void internalExpandToLevel(Widget node, int level) { Object data= node.getData(); if (dontExpand(data)) return; super.internalExpandToLevel(node, level); }
public void menuAboutToShow(IMenuManager mm2) { fillContextMenu(mm2); if (mm2.isEmpty()) { if (fEmptyMenuAction == null) { fEmptyMenuAction= new Action(Utilities.getString(fBundle, "emptyMenuItem")) { //$NON-NLS-1$ // left empty }; fEmptyMenuAction.setEnabled(false); } mm2.add(fEmptyMenuAction); } } }
/** * Overridden to call the <code>save</code> method on the structure creator after * nodes have been copied from one side to the other side of an input object. * * @param leftToRight if <code>true</code> the left side is copied to the right side. * If <code>false</code> the right side is copied to the left side */ protected void copySelected(boolean leftToRight) { super.copySelected(leftToRight); if (fStructureCreator != null) fStructureCreator.save( leftToRight ? fRightStructure.getStructureComparator() : fLeftStructure.getStructureComparator(), leftToRight ? fRightStructure.getInput() : fLeftStructure.getInput()); }
createChildren(item); int n= item.getItemCount(); if (n <= 0) createChildren(item);
private void initialize(CompareConfiguration configuration) { Control tree= getControl(); tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); setContentProvider(new DiffViewerContentProvider()); setLabelProvider(new DiffViewerLabelProvider()); addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent se) { setComparator(new DiffViewerComparator()); tbm.add(new Separator("navigation")); //$NON-NLS-1$ createToolItems(tbm); updateActions();
private TreeItem getNextItem(boolean next, boolean expand) { Control c= getControl(); if (!(c instanceof Tree) || c.isDisposed()) return null; Tree tree= (Tree) c; TreeItem item= null; TreeItem children[]= tree.getSelection(); if (children != null && children.length != 0) item= children[0]; if (item == null) { children= tree.getItems(); if (children != null && children.length != 0) { item= children[0]; if (item != null && item.getItemCount() <= 0) { return item; } } } while (true) { item= findNextPrev(item, next, expand); if (item == null) break; if (item.getItemCount() <= 0) break; } return item; }
/** * Overridden to avoid expanding {@code DiffNode}s that shouldn't expand. * * @param node the node to expand * @param level non-negative level, or {@code ALL_LEVELS} to collapse all levels of the tree */ @Override protected void internalExpandToLevel(Widget node, int level) { Object data= node.getData(); if (dontExpand(data)) return; super.internalExpandToLevel(node, level); }
@Override protected void fillContextMenu(IMenuManager manager) { if (fOpenAction == null) { fOpenAction= new Action() { @Override public void run() { handleOpen(null); } }; Utilities.initAction(fOpenAction, getBundle(), "action.CompareContents."); //$NON-NLS-1$ } boolean enable= false; ISelection selection= getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss= (IStructuredSelection)selection; if (ss.size() == 1) { Object element= ss.getFirstElement(); if (element instanceof MyDiffNode) { ITypedElement te= ((MyDiffNode) element).getId(); if (te != null) enable= !ITypedElement.FOLDER_TYPE.equals(te.getType()); } else enable= true; } } fOpenAction.setEnabled(enable); manager.add(fOpenAction); super.fillContextMenu(manager); } };
/** * Overridden to call the <code>save</code> method on the structure creator after * nodes have been copied from one side to the other side of an input object. * * @param leftToRight if <code>true</code> the left side is copied to the right side. * If <code>false</code> the right side is copied to the left side */ @Override protected void copySelected(boolean leftToRight) { super.copySelected(leftToRight); if (fStructureCreator != null) { fStructureCreator.save( leftToRight ? fRightStructure.getStructureComparator() : fLeftStructure.getStructureComparator(), leftToRight ? fRightStructure.getInput() : fLeftStructure.getInput()); } }
createChildren(item); int n= item.getItemCount(); if (n <= 0) if (expand) item.setExpanded(true); createChildren(item);
/** * Expands to infinity all items in the selection. * * @since 2.0 */ protected void expandSelection() { ISelection selection= getSelection(); if (selection instanceof IStructuredSelection) { Iterator elements= ((IStructuredSelection)selection).iterator(); while (elements.hasNext()) { Object next= elements.next(); expandToLevel(next, ALL_LEVELS); } } }
/** * Copies one side of all <code>DiffNode</code>s in the current selection to the other side. * Called from the (internal) actions for copying the sides of a <code>DiffNode</code>. * Clients may override. * * @param leftToRight if <code>true</code> the left side is copied to the right side. * If <code>false</code> the right side is copied to the left side */ protected void copySelected(boolean leftToRight) { ISelection selection= getSelection(); if (selection instanceof IStructuredSelection) { Iterator e= ((IStructuredSelection) selection).iterator(); while (e.hasNext()) { Object element= e.next(); if (element instanceof ICompareInput) copyOne((ICompareInput) element, leftToRight); } } }
/** * Factory method for creating a differences viewer for the top left pane. * It is called from <code>createContents</code> and returns a <code>DiffTreeViewer</code>. * <p> * Subclasses may override if they need a different viewer. * </p> * * @param parent the SWT parent control under which to create the viewer's SWT controls * @return a compare viewer for the top left pane */ public Viewer createDiffViewer(Composite parent) { return new DiffTreeViewer(parent, fCompareConfiguration); }