diff options
author | ptessier | 2014-11-17 13:04:37 +0000 |
---|---|---|
committer | ptessier | 2014-11-17 13:04:37 +0000 |
commit | 248fe695d2024758b63438aa8321b56deeef4312 (patch) | |
tree | 651875649f0b63cfb9200d6921a706de56632e54 /extraplugins/revision | |
parent | 397fd13342b0fa8b2f769cdd441760cad342ada7 (diff) | |
download | org.eclipse.papyrus-248fe695d2024758b63438aa8321b56deeef4312.tar.gz org.eclipse.papyrus-248fe695d2024758b63438aa8321b56deeef4312.tar.xz org.eclipse.papyrus-248fe695d2024758b63438aa8321b56deeef4312.zip |
447667: [Revision module] a module about revision model shall be
integrated to Papyrus
https://bugs.eclipse.org/bugs/show_bug.cgi?id=447667
# WARNING: head commit changed in the meantime
Merge branch 'master' of
ssh://ptessier@git.eclipse.org:29418/papyrus/org.eclipse.papyrus
Change-Id: If7d98e08ffbc8d5475218e258cd1802ab331c577
Diffstat (limited to 'extraplugins/revision')
11 files changed, 289 insertions, 173 deletions
diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/META-INF/MANIFEST.MF b/extraplugins/revision/org.eclipse.papyrus.revisiontool/META-INF/MANIFEST.MF index 17089e328bc..0f9fdab77fd 100644 --- a/extraplugins/revision/org.eclipse.papyrus.revisiontool/META-INF/MANIFEST.MF +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/META-INF/MANIFEST.MF @@ -20,10 +20,14 @@ Require-Bundle: org.eclipse.ui, org.eclipse.e4.ui.workbench.renderers.swt, org.eclipse.papyrus.infra.widgets, org.eclipse.papyrus.infra.services.labelprovider, - org.eclipse.papyrus.infra.emf;bundle-version="1.1.0" + org.eclipse.papyrus.infra.emf;bundle-version="1.1.0", + org.eclipse.emf.compare, + org.eclipse.emf.compare.rcp Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.eclipse.papyrus.revision.tool, org.eclipse.papyrus.revision.tool.core, + org.eclipse.papyrus.revision.tool.dialogs, + org.eclipse.papyrus.revision.tool.handlers, org.eclipse.papyrus.revision.tool.preference, org.eclipse.papyrus.revision.tool.ui Bundle-ActivationPolicy: lazy diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/plugin.xml b/extraplugins/revision/org.eclipse.papyrus.revisiontool/plugin.xml index 28e9fbddd05..76fad22d73e 100644 --- a/extraplugins/revision/org.eclipse.papyrus.revisiontool/plugin.xml +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/plugin.xml @@ -54,38 +54,26 @@ </extension>
<extension point="org.eclipse.papyrus.views.properties.context">
<context contextModel="properties/Review.ctx"/>
-</extension>
-<extension
- point="org.eclipse.ui.commands">
- <category
- id="org.eclipse.papyrus.revisiontool.commands.category"
- name="Sample Category">
- </category>
- <command
- categoryId="org.eclipse.papyrus.revisiontool.commands.category"
- id="org.eclipse.papyrus.revisiontool.commands.sampleCommand"
- name="Sample Command">
- </command>
-</extension>
+</extension> <extension
point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.papyrus.revision.tool.handlers.ReviewCreateHandler"
- commandId="org.eclipse.papyrus.revisiontool.commands.sampleCommand">
+ commandId="org.eclipse.papyrus.revisiontool.commands.ReviewCreateHandler">
</handler>
<handler
- class="org.eclipse.papyrus.revision.tool.handlers.DeleteReviewCreateHandler"
+ class="org.eclipse.papyrus.revision.tool.handlers.DeleteReviewHandler"
commandId="org.eclipse.papyrus.revisiontool.commands.deletereview">
</handler>
<handler
class="org.eclipse.papyrus.revision.tool.handlers.HookReviewHandler"
commandId="org.eclipse.papyrus.revisiontool.commands.hookreview">
- </handler>
+ </handler> </extension>
<extension
point="org.eclipse.ui.bindings">
<key
- commandId="org.eclipse.papyrus.revisiontool.commands.sampleCommand"
+ commandId="org.eclipse.papyrus.revisiontool.commands.ReviewCreateHandler"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+1">
@@ -113,7 +101,7 @@ label="New"
mnemonic="M">
<command
- commandId="org.eclipse.papyrus.revisiontool.commands.sampleCommand"
+ commandId="org.eclipse.papyrus.revisiontool.commands.ReviewCreateHandler"
icon="img/Add.png"
id="org.eclipse.papyrus.revisiontool.menus.sampleCommand"
label="Review"
@@ -161,6 +149,47 @@ style="push"
tooltip="Hook">
</command>
+ </menuContribution>
+ <menuContribution
+ locationURI="menu:org.eclipse.ui.main.menu?after=additions">
+ <menu
+ id="org.eclipse.papyrus.revisiontool.menus.revisionmenu"
+ label="Revision"
+ mnemonic="M">
+ <command
+ commandId="org.eclipse.papyrus.revisiontool.commands.revisionlaunch"
+ hoverIcon="Revision Mode"
+ label="Revision Mode"
+ style="toggle">
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.revision.tool.handlers.SaveSnapshotRevision"
+ hoverIcon="Save snapshot Revision Mode"
+ label="Save snapshot Revision Mode (TMP)"
+ style="push">
+ </command>
+ </menu>
</menuContribution> </extension>
+<extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.revision.tool.handlers.LaunchRevisionMode"
+ id="org.eclipse.papyrus.revisiontool.commands.revisionlaunch"
+ name="org.eclipse.papyrus.revisiontool.commands.revisionlaunch">
+ <state
+ class="org.eclipse.ui.handlers.RegistryToggleState:false"
+ id="org.eclipse.ui.commands.toggleState">
+ </state>
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.revision.tool.handlers.SaveSnapshotRevision"
+ id="org.eclipse.papyrus.revision.tool.handlers.SaveSnapshotRevision"
+ name="org.eclipse.papyrus.revision.tool.handlers.SaveSnapshotRevision">
+ <state
+ class="org.eclipse.ui.handlers.RegistryToggleState:false"
+ id="org.eclipse.ui.commands.toggleState">
+ </state>
+ </command>
+</extension>
</plugin>
diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/core/ReviewResourceManager.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/core/ReviewResourceManager.java index 1cc8c626a38..2766a404166 100644 --- a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/core/ReviewResourceManager.java +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/core/ReviewResourceManager.java @@ -13,17 +13,34 @@ *****************************************************************************/
package org.eclipse.papyrus.revision.tool.core;
+import java.io.IOException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.match.DefaultComparisonFactory;
+import org.eclipse.emf.compare.match.DefaultEqualityHelperFactory;
+import org.eclipse.emf.compare.match.DefaultMatchEngine;
+import org.eclipse.emf.compare.match.IComparisonFactory;
+import org.eclipse.emf.compare.match.IMatchEngine;
+import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
+import org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl;
+import org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.compare.utils.UseIdentifiers;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -71,6 +88,8 @@ public class ReviewResourceManager { protected ModelSet modelSet;
protected Model reviewModel;
protected Actor currentAuthor;
+ protected WorkingModelListener workingModelListener= new WorkingModelListener();
+ protected Model snapshotyModel;
/**
@@ -138,14 +157,14 @@ public class ReviewResourceManager { ((Comment)element).getOwnedComments().add(cmt);
}
else{ reviewModel.getOwnedComments().add(cmt);}
-
+
Stereotype review= cmt.getApplicableStereotype(I_ReviewStereotype.REVIEW_STEREOTYPE);
cmt.applyStereotype(review);
cmt.setValue(review, I_ReviewStereotype.COMMENT_SUBJECT_ATT, "subject");
-
+
Stereotype authorStereotype= theauthor.getApplicableStereotype(I_VersioningStereotype.AUTHOR_STEREOTYPE);
cmt.setValue(review, I_VersioningStereotype.VERSIONINGELEMENT_AUTHOR_ATT, theauthor.getStereotypeApplication(authorStereotype));
-
+
// add tthe date
Date today = new Date();
DateFormat shortDateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT);
@@ -386,4 +405,80 @@ public class ReviewResourceManager { return false;
}
+
+ protected void compare(final Model modelBefore, Model modelAfter) {
+
+ IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
+ IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
+ final IMatchEngine thematchEngine = new DefaultMatchEngine(matcher , comparisonFactory);
+ IMatchEngine.Factory.Registry registry = MatchEngineFactoryRegistryImpl.createStandaloneInstance();
+ IMatchEngine.Factory engineFactory = new MatchEngineFactoryImpl() {
+ public IMatchEngine getMatchEngine() {
+ return thematchEngine;
+ }
+ };
+ engineFactory.setRanking(20); // default engine ranking is 10, must be higher to override.
+ registry.add(engineFactory);
+ IComparisonScope scope = new DefaultComparisonScope(modelBefore,modelAfter,null);
+ final Comparison comparison = EMFCompare.builder().setMatchEngineFactoryRegistry(registry).build().compare(scope);
+ List<Diff> differences = comparison.getDifferences();
+ for (Diff diff : differences) {
+ final Diff diffRef= diff;
+ System.out.println(diff);
+ RecordingCommand cmd= new RecordingCommand(getDomain(), "createAReview") {
+ @Override
+ protected void doExecute() {
+ Actor theauthor= getCurrentAuthor();
+ Comment cmt= UMLFactory.eINSTANCE.createComment();
+ cmt.setBody("Your review");
+ reviewModel.getOwnedComments().add(cmt);
+
+ Stereotype review= cmt.getApplicableStereotype(I_ReviewStereotype.REVIEW_STEREOTYPE);
+ cmt.applyStereotype(review);
+ cmt.setValue(review, I_ReviewStereotype.COMMENT_SUBJECT_ATT, diffRef.getKind().getName()+ diffRef.getSource().getName());
+
+ Stereotype authorStereotype= theauthor.getApplicableStereotype(I_VersioningStereotype.AUTHOR_STEREOTYPE);
+ cmt.setValue(review, I_VersioningStereotype.VERSIONINGELEMENT_AUTHOR_ATT, theauthor.getStereotypeApplication(authorStereotype));
+
+ // add tthe date
+ Date today = new Date();
+ DateFormat shortDateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT);
+ cmt.setValue(review, I_VersioningStereotype.VERSIONINGELEMENT_DATE_ATT, shortDateFormat.format(today));
+ }
+ };
+ //getDomain().getCommandStack().execute(cmd);
+ }
+
+ RecordingCommand cmd= new RecordingCommand(getDomain(), "saveSnaphsot") {
+ @Override
+ protected void doExecute() {
+ URI umlModel_URI=getWorkingModel().eResource().getURI();
+ String tmpURI=umlModel_URI.toString().replaceAll(umlModel_URI.lastSegment().toString(), "diff.xmi");
+ URI reviewURI=URI.createURI(tmpURI);
+ Resource resourcesnapshot = getCurrentModelSet().createResource(reviewURI);
+ resourcesnapshot.getContents().add(comparison);
+ try {
+ resourcesnapshot.save(null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ };
+ getDomain().getCommandStack().execute(cmd);
+ }
+
+ public void saveDiff(){
+ compare(getWorkingModel(),snapshotyModel);
+ }
+ public void startModeRevision(){
+ snapshotyModel = EcoreUtil.copy(getWorkingModel());
+ UmlModel iumlModel=(UmlModel) getCurrentModelSet().getModel(UmlModel.MODEL_ID);
+ iumlModel.getResource().eAdapters().add(workingModelListener);
+ }
+ public void stopModelRevision(){
+ UmlModel iumlModel=(UmlModel) getCurrentModelSet().getModel(UmlModel.MODEL_ID);
+ iumlModel.getResource().eAdapters().remove(workingModelListener);
+ compare(snapshotyModel,getWorkingModel());
+ }
}
diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/core/WorkingModelListener.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/core/WorkingModelListener.java new file mode 100644 index 00000000000..790317b5035 --- /dev/null +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/core/WorkingModelListener.java @@ -0,0 +1,16 @@ +package org.eclipse.papyrus.revision.tool.core;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+
+
+public class WorkingModelListener extends EContentAdapter {
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ // TODO Auto-generated method stub
+ super.notifyChanged(notification);
+ System.err.println("J'ecoute "+ notification);
+ }
+
+}
diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/DeleteReviewHandler.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/DeleteReviewHandler.java index 44548ade97d..5d7a96ca78b 100644 --- a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/DeleteReviewHandler.java +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/DeleteReviewHandler.java @@ -33,11 +33,11 @@ import org.eclipse.uml2.uml.UMLFactory; * @see org.eclipse.core.commands.IHandler * @see org.eclipse.core.commands.AbstractHandler */ -public class DeleteReviewCreateHandler extends AbstractHandler { +public class DeleteReviewHandler extends RevisionAbstractHandler { /** * The constructor. */ - public DeleteReviewCreateHandler() { + public DeleteReviewHandler() { } /** @@ -62,48 +62,4 @@ public class DeleteReviewCreateHandler extends AbstractHandler { return null; } - /** - * getSelected element in the diagram or in hte model explorer - * @return Element or null - */ - protected Element getSelection(){ - org.eclipse.uml2.uml.Element selectedElement =null; - ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - ISelection selection = selectionService.getSelection(); - - if(selection instanceof IStructuredSelection) { - Object selectedobject = ((IStructuredSelection)selection).getFirstElement(); - if (selectedobject instanceof org.eclipse.uml2.uml.Element){ - selectedElement=(Element)selectedobject; - } - - return selectedElement; - } - return null; - } - /** - * getSelected element in the diagram or in hte model explorer - * @return Element or null - */ - protected ArrayList<Element> getSelectionSet(){ - ArrayList<Element> selectedSet =new ArrayList<Element>(); - ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - ISelection selection = selectionService.getSelection(); - - //look for papyrus - - if(selection instanceof IStructuredSelection) { - @SuppressWarnings("rawtypes") - Iterator selectedobjectIteractor = ((IStructuredSelection)selection).iterator(); - while (selectedobjectIteractor.hasNext()) { - Object currentSelection = selectedobjectIteractor.next(); - if (currentSelection instanceof org.eclipse.uml2.uml.Element){ - selectedSet.add((Element)currentSelection); - } - } - - - } - return selectedSet; - } } diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/HookReviewHandler.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/HookReviewHandler.java index 88005e31beb..999e5e362e6 100644 --- a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/HookReviewHandler.java +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/HookReviewHandler.java @@ -29,7 +29,7 @@ import org.eclipse.uml2.uml.UMLPackage; * @see org.eclipse.core.commands.IHandler * @see org.eclipse.core.commands.AbstractHandler */ -public class HookReviewHandler extends AbstractHandler { +public class HookReviewHandler extends RevisionAbstractHandler { protected static final String CHOOSE_ELEMENT_TO_COMMENT = "Choose Element to comment"; /** * The constructor. @@ -76,48 +76,4 @@ public class HookReviewHandler extends AbstractHandler { return null; } - /** - * getSelected element in the diagram or in hte model explorer - * @return Element or null - */ - protected Element getSelection(){ - org.eclipse.uml2.uml.Element selectedElement =null; - ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - ISelection selection = selectionService.getSelection(); - - if(selection instanceof IStructuredSelection) { - Object selectedobject = ((IStructuredSelection)selection).getFirstElement(); - if (selectedobject instanceof org.eclipse.uml2.uml.Element){ - selectedElement=(Element)selectedobject; - } - - return selectedElement; - } - return null; - } - /** - * getSelected element in the diagram or in hte model explorer - * @return Element or null - */ - protected ArrayList<Element> getSelectionSet(){ - ArrayList<Element> selectedSet =new ArrayList<Element>(); - ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - ISelection selection = selectionService.getSelection(); - - //look for papyrus - - if(selection instanceof IStructuredSelection) { - @SuppressWarnings("rawtypes") - Iterator selectedobjectIteractor = ((IStructuredSelection)selection).iterator(); - while (selectedobjectIteractor.hasNext()) { - Object currentSelection = selectedobjectIteractor.next(); - if (currentSelection instanceof org.eclipse.uml2.uml.Element){ - selectedSet.add((Element)currentSelection); - } - } - - - } - return selectedSet; - } } diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/LaunchRevisionMode.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/LaunchRevisionMode.java new file mode 100644 index 00000000000..9e588e32040 --- /dev/null +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/LaunchRevisionMode.java @@ -0,0 +1,32 @@ +package org.eclipse.papyrus.revision.tool.handlers;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.revision.tool.ui.ReviewsEditor;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class LaunchRevisionMode extends RevisionAbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ Command command = event.getCommand();
+ boolean oldValue = HandlerUtil.toggleCommandState(command);
+ IWorkbenchPart part=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.papyrus.revisiontool.commentview");
+ if( part instanceof ReviewsEditor){
+ if(oldValue==false){
+ //now the revison mode is activated
+
+ ((ReviewsEditor)part).getReviewResourceManager().startModeRevision();
+ }
+ else{
+ ((ReviewsEditor)part).getReviewResourceManager().stopModelRevision();
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/ReviewCreateHandler.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/ReviewCreateHandler.java index 11063119545..100455ce0f3 100644 --- a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/ReviewCreateHandler.java +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/ReviewCreateHandler.java @@ -1,23 +1,10 @@ package org.eclipse.papyrus.revision.tool.handlers; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.papyrus.revision.tool.ui.ReviewsEditor; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.uml2.uml.Element; /** @@ -25,7 +12,7 @@ import org.eclipse.uml2.uml.Element; * @see org.eclipse.core.commands.IHandler * @see org.eclipse.core.commands.AbstractHandler */ -public class ReviewCreateHandler extends AbstractHandler { +public class ReviewCreateHandler extends RevisionAbstractHandler { /** * The constructor. */ @@ -46,48 +33,5 @@ public class ReviewCreateHandler extends AbstractHandler { return null; } - /** - * getSelected element in the diagram or in hte model explorer - * @return Element or null - */ - protected Element getSelection(){ - org.eclipse.uml2.uml.Element selectedElement =null; - ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - ISelection selection = selectionService.getSelection(); - - if(selection instanceof IStructuredSelection) { - Object selectedobject = ((IStructuredSelection)selection).getFirstElement(); - if (selectedobject instanceof org.eclipse.uml2.uml.Element){ - selectedElement=(Element)selectedobject; - } - - return selectedElement; - } - return null; - } - /** - * getSelected element in the diagram or in hte model explorer - * @return Element or null - */ - protected ArrayList<Element> getSelectionSet(){ - ArrayList<Element> selectedSet =new ArrayList<Element>(); - ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - ISelection selection = selectionService.getSelection(); - - //look for papyrus - - if(selection instanceof IStructuredSelection) { - @SuppressWarnings("rawtypes") - Iterator selectedobjectIteractor = ((IStructuredSelection)selection).iterator(); - while (selectedobjectIteractor.hasNext()) { - Object currentSelection = selectedobjectIteractor.next(); - if (currentSelection instanceof org.eclipse.uml2.uml.Element){ - selectedSet.add((Element)currentSelection); - } - } - - - } - return selectedSet; - } + } diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/RevisionAbstractHandler.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/RevisionAbstractHandler.java new file mode 100644 index 00000000000..0a9a4549cc2 --- /dev/null +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/RevisionAbstractHandler.java @@ -0,0 +1,62 @@ +package org.eclipse.papyrus.revision.tool.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Element;
+
+public abstract class RevisionAbstractHandler extends AbstractHandler {
+
+ public RevisionAbstractHandler() {
+ super();
+ }
+ /**
+ * getSelected element in the diagram or in hte model explorer
+ * @return Element or null
+ */
+ protected Element getSelection(){
+ org.eclipse.uml2.uml.Element selectedElement =null;
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ ISelection selection = selectionService.getSelection();
+
+ if(selection instanceof IStructuredSelection) {
+ Object selectedobject = ((IStructuredSelection)selection).getFirstElement();
+ if (selectedobject instanceof org.eclipse.uml2.uml.Element){
+ selectedElement=(Element)selectedobject;
+ }
+
+ return selectedElement;
+ }
+ return null;
+ }
+ /**
+ * getSelected element in the diagram or in hte model explorer
+ * @return Element or null
+ */
+ protected ArrayList<Element> getSelectionSet(){
+ ArrayList<Element> selectedSet =new ArrayList<Element>();
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ ISelection selection = selectionService.getSelection();
+
+ //look for papyrus
+
+ if(selection instanceof IStructuredSelection) {
+ @SuppressWarnings("rawtypes")
+ Iterator selectedobjectIteractor = ((IStructuredSelection)selection).iterator();
+ while (selectedobjectIteractor.hasNext()) {
+ Object currentSelection = selectedobjectIteractor.next();
+ if (currentSelection instanceof org.eclipse.uml2.uml.Element){
+ selectedSet.add((Element)currentSelection);
+ }
+ }
+
+
+ }
+ return selectedSet;
+ }
+}
\ No newline at end of file diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/SaveSnapshotRevision.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/SaveSnapshotRevision.java new file mode 100644 index 00000000000..34a09a7ad13 --- /dev/null +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/handlers/SaveSnapshotRevision.java @@ -0,0 +1,24 @@ +package org.eclipse.papyrus.revision.tool.handlers;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.revision.tool.ui.ReviewsEditor;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class SaveSnapshotRevision extends RevisionAbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchPart part=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.papyrus.revisiontool.commentview");
+ if( part instanceof ReviewsEditor){
+
+ ((ReviewsEditor)part).getReviewResourceManager().saveDiff();
+ }
+ return null;
+ }
+
+}
diff --git a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/ui/ReviewsEditor.java b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/ui/ReviewsEditor.java index f8b39321aae..b3497e009c6 100644 --- a/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/ui/ReviewsEditor.java +++ b/extraplugins/revision/org.eclipse.papyrus.revisiontool/src/org/eclipse/papyrus/revision/tool/ui/ReviewsEditor.java @@ -31,7 +31,6 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.papyrus.revision.tool.Activator;
import org.eclipse.papyrus.revision.tool.core.ReviewResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
@@ -45,7 +44,6 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.PropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.eclipse.uml2.uml.Element;
|