Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-02-01 14:50:46 +0000
committervlorenzo2013-02-01 14:50:46 +0000
commitfa4d60e2b89f96e0e226ccdb67ce474b02cc31cd (patch)
tree49996b280a4a0e12626c1cd153aa962dc4b11407
parentfae109e4ddcfdf1613bd15fca93fe7ed1af8f3cc (diff)
downloadorg.eclipse.papyrus-fa4d60e2b89f96e0e226ccdb67ce474b02cc31cd.tar.gz
org.eclipse.papyrus-fa4d60e2b89f96e0e226ccdb67ce474b02cc31cd.tar.xz
org.eclipse.papyrus-fa4d60e2b89f96e0e226ccdb67ce474b02cc31cd.zip
399714: [EMF-Compare] Papyrus must provide an editor to compare 2 elements of 2 opened models
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399714
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/content/transactional/viewer/PapyrusTransactionalModelContentMergeViewer.java37
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/structural/viewer/PapyrusCustomizableParameterizedStructureMergeViewer.java25
2 files changed, 53 insertions, 9 deletions
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/content/transactional/viewer/PapyrusTransactionalModelContentMergeViewer.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/content/transactional/viewer/PapyrusTransactionalModelContentMergeViewer.java
index a4a211ed226..b5718a1464a 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/content/transactional/viewer/PapyrusTransactionalModelContentMergeViewer.java
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/content/transactional/viewer/PapyrusTransactionalModelContentMergeViewer.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.compare.ui.internal.ModelComparator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.workspace.ui.actions.RedoActionWrapper;
import org.eclipse.emf.workspace.ui.actions.UndoActionWrapper;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
@@ -81,8 +82,18 @@ public class PapyrusTransactionalModelContentMergeViewer extends PapyrusCustomiz
@Override
protected void createToolItems(final ToolBarManager tbm) {
super.createToolItems(tbm);
+ final Action undoAction = getUndoAction();
+ final Action redoAction = getRedoAction();
+ tbm.insert(0, new ActionContributionItem(undoAction));
+ tbm.insert(1, new ActionContributionItem(redoAction));
+
+ tbm.insert(2, new Separator("undo_redo_group")); //$NON-NLS-1$
+
+ initializeIActionField(tbm);
+ }
+
+ protected Action getUndoAction() {
final UndoActionWrapper undoAction = new UndoActionWrapper();
- final RedoActionWrapper redoAction = new RedoActionWrapper();
//we need that the editor will be created to get it and initialize the actions
Display.getCurrent().asyncExec(new Runnable() {
@@ -90,22 +101,32 @@ public class PapyrusTransactionalModelContentMergeViewer extends PapyrusCustomiz
public void run() {
IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
undoAction.setActiveWorkbenchPart(editorPart);
- redoAction.setActiveWorkbenchPart(editorPart);
+
}
});
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
undoAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
- redoAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
- tbm.insert(0, new ActionContributionItem(undoAction));
- tbm.insert(1, new ActionContributionItem(redoAction));
+ return undoAction;
+ }
- tbm.insert(2, new Separator("undo_redo_group")); //$NON-NLS-1$
+ protected Action getRedoAction() {
+ final RedoActionWrapper redoAction = new RedoActionWrapper();
- initializeIActionField(tbm);
- }
+ //we need that the editor will be created to get it and initialize the actions
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ redoAction.setActiveWorkbenchPart(editorPart);
+ }
+ });
+
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ redoAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
+ return redoAction;
+ }
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/structural/viewer/PapyrusCustomizableParameterizedStructureMergeViewer.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/structural/viewer/PapyrusCustomizableParameterizedStructureMergeViewer.java
index 4a6008cd6e9..283fc4bc7ff 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/structural/viewer/PapyrusCustomizableParameterizedStructureMergeViewer.java
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.ui/src/org/eclipse/papyrus/infra/emf/compare/ui/structural/viewer/PapyrusCustomizableParameterizedStructureMergeViewer.java
@@ -160,8 +160,31 @@ public class PapyrusCustomizableParameterizedStructureMergeViewer extends Parame
final ParameterizedStructureContentProvider contentProvider = new ParameterizedStructureContentProvider(compareConfiguration, getDefaultOrdering(), getDefaultFilters()) {
@Override
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof ModelCompareInput) {
+ return super.getElements(((ModelCompareInput)inputElement).getDiff());
+ }
+ return super.getElements(inputElement);
+ }
+
+ @Override
public boolean hasChildren(Object element) {
- return super.getChildren(element).length != 0;
+ if(element != null) {
+ Object[] children = getChildren(element);
+ if(children != null) {
+ return children.length != 0;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ Object[] child = super.getChildren(parentElement);
+ if(child != null) {
+ return child;
+ }
+ return new Object[0];
}
};
return contentProvider;

Back to the top