Search in sources :

Example 1 with DiffTreeViewer

use of org.eclipse.compare.structuremergeviewer.DiffTreeViewer in project tmdm-studio-se by Talend.

the class ResourceCompareInput method createDiffViewer.

@Override
public Viewer createDiffViewer(Composite parent) {
    fDiffViewer = new DiffTreeViewer(parent, getCompareConfiguration()) {

        @Override
        protected void fillContextMenu(IMenuManager manager) {
            if (fOpenAction == null) {
                fOpenAction = new Action() {

                    @Override
                    public void run() {
                        handleOpen(null);
                    }
                };
                // $NON-NLS-1$
                Utilities.initAction(fOpenAction, getBundle(), "action.CompareContents.");
            }
            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);
        }
    };
    fDiffViewer.getControl();
    return fDiffViewer;
}
Also used : DiffTreeViewer(org.eclipse.compare.structuremergeviewer.DiffTreeViewer) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) ISelection(org.eclipse.jface.viewers.ISelection) ITypedElement(org.eclipse.compare.ITypedElement) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ITypedElement (org.eclipse.compare.ITypedElement)1 DiffTreeViewer (org.eclipse.compare.structuremergeviewer.DiffTreeViewer)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1