View | Details | Raw Unified | Return to bug 325610 | Differences between
and this patch

Collapse All | Expand All

(-)build.properties (-2 / +5 lines)
Lines 2-6 Link Here
2
output.. = bin/
2
output.. = bin/
3
bin.includes = META-INF/,\
3
bin.includes = META-INF/,\
4
               .,\
4
               .,\
5
               about.html,\
5
               plugin.xml,\
6
               plugin.properties
6
               icons/,\
7
               plugin.properties,\
8
               about.html
9
src.includes = icons/
(-)plugin.properties (+1 lines)
Lines 7-12 Link Here
7
# 
7
# 
8
# Contributors:
8
# Contributors:
9
#     CEA LIST - initial API and implementation
9
#     CEA LIST - initial API and implementation
10
#     Amine EL KOUHEN (CEA LIST) Amine.elkouhen@cea.fr - Added the Menu Extension File Monitoring and Decoration Service
10
###############################################################################
11
###############################################################################
11
pluginName=Papyrus Validation Integration (Incubation)
12
pluginName=Papyrus Validation Integration (Incubation)
12
pluginProvider=Eclipse Modeling Project
13
pluginProvider=Eclipse Modeling Project
(-)plugin.xml (+99 lines)
Lines 17-20 Link Here
17
            class="org.eclipse.papyrus.validation.preferences.Initializer">
17
            class="org.eclipse.papyrus.validation.preferences.Initializer">
18
      </initializer>
18
      </initializer>
19
   </extension>
19
   </extension>
20
   <extension
21
         point="org.eclipse.ui.menus">
22
      <menuContribution
23
            allPopups="false"
24
            locationURI="popup:org.eclipse.papyrus.modelexplorer.modelexplorer.popup">
25
         <menu
26
               icon="icons/etool16/validate.gif"
27
               id="org.eclipse.papyrus.modelexplorer.popup.validation"
28
               label="Validation">
29
         </menu>
30
      </menuContribution>
31
      <menuContribution
32
            allPopups="true"
33
            locationURI="popup:org.eclipse.papyrus.modelexplorer.popup.validation">
34
         <command
35
               commandId="org.eclipse.papyrus.validation.ValidateModelCommand"
36
               icon="icons/etool16/validate.gif"
37
               id="org.eclipse.papyrus.validation.ValidateModel"
38
               label="Validate model">
39
         </command>
40
         <command
41
               commandId="org.eclipse.papyrus.validation.ValidateSubtreeCommand"
42
               icon="icons/etool16/validate.gif"
43
               id="org.eclipse.papyrus.validation.ValidateSubtree"
44
               label="Validate subtree">
45
         </command>
46
         <command
47
               commandId="org.eclipse.papyrus.validation.SelectAndValidateModelCommand"
48
               icon="icons/etool16/validateSel.gif"
49
               id="org.eclipse.papyrus.validation.SelectAndValidateModel"
50
               label="Select constraints and Validate model">
51
         </command>
52
         <command
53
               commandId="org.eclipse.papyrus.validation.SelectAndValidateSubtreeCommand"
54
               icon="icons/etool16/validateSel.gif"
55
               id="org.eclipse.papyrus.validation.SelectAndValidateSubtree"
56
               label="Select constraints and Validate subtree">
57
         </command>
58
         <command
59
               commandId="org.eclipse.papyrus.validation.ValidateDelMarkersFromModelCommand"
60
               disabledIcon="IMG_TOOL_DELETE_DISABLED"
61
               icon="IMG_TOOL_DELETE"
62
               id="org.eclipse.papyrus.validation.DeleteMarkersFromModel"
63
               label="Remove markers from model">
64
         </command>
65
         <command
66
               commandId="org.eclipse.papyrus.validation.ValidateDelMarkersFromSubtreeCommand"
67
               disabledIcon="IMG_TOOL_DELETE_DISABLED"
68
               icon="IMG_TOOL_DELETE"
69
               id="org.eclipse.papyrus.validation.DelMarkersFromSubtree"
70
               label="Remove markers from subtree">
71
         </command>
72
      </menuContribution>
73
   </extension>
74
   <extension
75
         point="org.eclipse.ui.commands">
76
      <command
77
            categoryId="org.eclipse.papyrus.editor.category"
78
            defaultHandler="org.eclipse.papyrus.validation.handler.ValidateModelHandler"
79
            description="ValidateModel"
80
            id="org.eclipse.papyrus.validation.ValidateModelCommand"
81
            name="ValidateModel">
82
      </command>
83
      <command
84
            categoryId="org.eclipse.papyrus.editor.category"
85
            defaultHandler="org.eclipse.papyrus.validation.handler.ValidateSubtreeHandler"
86
            description="ValidateSubtree"
87
            id="org.eclipse.papyrus.validation.ValidateSubtreeCommand"
88
            name="ValidateSubtree">
89
      </command>
90
      <command
91
            categoryId="org.eclipse.papyrus.editor.category"
92
            defaultHandler="org.eclipse.papyrus.validation.handler.SelectAndValidateSubtreeHandler"
93
            description="SelectAndValidate"
94
            id="org.eclipse.papyrus.validation.SelectAndValidateSubtreeCommand"
95
            name="SelectAndValidate">
96
      </command>
97
      <command
98
            categoryId="org.eclipse.papyrus.editor.category"
99
            defaultHandler="org.eclipse.papyrus.validation.handler.SelectAndValidateModelHandler"
100
            description="SelectAndValidate"
101
            id="org.eclipse.papyrus.validation.SelectAndValidateModelCommand"
102
            name="SelectAndValidate">
103
      </command>
104
      <command
105
            categoryId="org.eclipse.papyrus.editor.category"
106
            defaultHandler="org.eclipse.papyrus.validation.handler.ValidateDelMarkersFromModelHandler"
107
            description="ValidateDelMarkersFromModel"
108
            id="org.eclipse.papyrus.validation.ValidateDelMarkersFromModelCommand"
109
            name="ValidateDelMarkersFromModel">
110
      </command>
111
      <command
112
            categoryId="org.eclipse.papyrus.editor.category"
113
            defaultHandler="org.eclipse.papyrus.validation.handler.ValidateDelMarkersFromSubtreeHandler"
114
            description="ValidateDelMarkersFromSubtree"
115
            id="org.eclipse.papyrus.validation.ValidateDelMarkersFromSubtreeCommand"
116
            name="ValidateDelMarkersFromSubtree">
117
      </command>
118
   </extension>
20
</plugin>
119
</plugin>
(-)src/org/eclipse/papyrus/validation/Activator.java (-4 / +43 lines)
Lines 1-45 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2011 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *	Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr 
12
 *****************************************************************************/
1
package org.eclipse.papyrus.validation;
13
package org.eclipse.papyrus.validation;
2
14
15
import org.eclipse.papyrus.log.LogHelper;
3
import org.eclipse.ui.plugin.AbstractUIPlugin;
16
import org.eclipse.ui.plugin.AbstractUIPlugin;
4
import org.osgi.framework.BundleContext;
17
import org.osgi.framework.BundleContext;
5
18
19
// TODO: Auto-generated Javadoc
6
/**
20
/**
7
 * The activator class controls the plug-in life cycle
21
 * The activator class controls the plug-in life cycle.
8
 */
22
 */
9
public class Activator extends AbstractUIPlugin {
23
public class Activator extends AbstractUIPlugin {
10
24
11
	// The plug-in ID
25
	// The plug-in ID
26
	/** The Constant PLUGIN_ID. */
12
	public static final String PLUGIN_ID = "org.eclipse.papyrus.validation"; //$NON-NLS-1$
27
	public static final String PLUGIN_ID = "org.eclipse.papyrus.validation"; //$NON-NLS-1$
13
28
14
	// The shared instance
29
	// The shared instance
30
	/** The plugin. */
15
	private static Activator plugin;
31
	private static Activator plugin;
16
	
32
33
	/** The log service. */
34
	public static LogHelper log;
35
17
	/**
36
	/**
18
	 * The constructor
37
	 * The constructor.
19
	 */
38
	 */
20
	public Activator() {
39
	public Activator() {
21
	}
40
	}
22
41
23
	/*
42
	/*
24
	 * (non-Javadoc)
43
	 * (non-Javadoc)
44
	 * 
25
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
45
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
26
	 */
46
	 */
47
	/**
48
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
49
	 *
50
	 * @param context
51
	 * @throws Exception
52
	 */
53
	
54
	@Override
27
	public void start(BundleContext context) throws Exception {
55
	public void start(BundleContext context) throws Exception {
28
		super.start(context);
56
		super.start(context);
29
		plugin = this;
57
		plugin = this;
58
		log = new LogHelper(plugin);
30
	}
59
	}
31
60
32
	/*
61
	/*
33
	 * (non-Javadoc)
62
	 * (non-Javadoc)
63
	 * 
34
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
64
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
35
	 */
65
	 */
66
	/**
67
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
68
	 *
69
	 * @param context
70
	 * @throws Exception
71
	 */
72
	
73
	@Override
36
	public void stop(BundleContext context) throws Exception {
74
	public void stop(BundleContext context) throws Exception {
37
		plugin = null;
75
		plugin = null;
76
		log = null;
38
		super.stop(context);
77
		super.stop(context);
39
	}
78
	}
40
79
41
	/**
80
	/**
42
	 * Returns the shared instance
81
	 * Returns the shared instance.
43
	 *
82
	 *
44
	 * @return the shared instance
83
	 * @return the shared instance
45
	 */
84
	 */
(-)src/org/eclipse/papyrus/validation/ValidationTool.java (-143 / +29 lines)
Lines 9-22 Link Here
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
12
 *	Amine EL KOUHEN (CEA LIST / LIFL) Updates
13
 *****************************************************************************/
13
 *****************************************************************************/
14
14
15
package org.eclipse.papyrus.validation;
15
package org.eclipse.papyrus.validation;
16
16
17
import java.util.List;
18
19
import org.apache.commons.lang.WordUtils;
20
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IMarker;
18
import org.eclipse.core.resources.IMarker;
22
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.resources.ResourcesPlugin;
Lines 28-43 Link Here
28
import org.eclipse.emf.ecore.EValidator;
25
import org.eclipse.emf.ecore.EValidator;
29
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
26
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
30
import org.eclipse.emf.edit.domain.EditingDomain;
27
import org.eclipse.emf.edit.domain.EditingDomain;
31
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem;
32
import org.eclipse.jface.preference.IPreferenceStore;
33
import org.eclipse.papyrus.validation.preferences.PreferencePage;
34
import org.eclipse.papyrus.validation.preferences.PreferencePage.MarkChildren;
35
28
36
public class ValidationTool {
29
public class ValidationTool {
37
30
38
	/** Current element */
39
	private Object element;
40
41
	/** current eobject */
31
	/** current eobject */
42
	private EObject eObject;
32
	private EObject eObject;
43
33
Lines 48-60 Link Here
48
	/**
38
	/**
49
	 * Constructor:
39
	 * Constructor:
50
	 * create a new instance of the validation tool for a specific model element
40
	 * create a new instance of the validation tool for a specific model element
51
	 *
41
	 * 
52
	 * @param element a model element
42
	 * @param element
43
	 *        a model element
53
	 */
44
	 */
54
	public ValidationTool (Object element) {
45
	public ValidationTool(Object element) {
55
		this.element = element;
56
		setEObject((EObject)Platform.getAdapterManager().getAdapter(element, EObject.class));
46
		setEObject((EObject)Platform.getAdapterManager().getAdapter(element, EObject.class));
57
	}	
47
	}
58
48
59
	/**
49
	/**
60
	 * Constructor:
50
	 * Constructor:
Lines 63-85 Link Here
63
	 * @param eObject
53
	 * @param eObject
64
	 *        a model element
54
	 *        a model element
65
	 */
55
	 */
66
	public ValidationTool (EObject eObject) {
56
	public ValidationTool(EObject eObject) {
67
		setEObject(eObject);
57
		setEObject(eObject);
68
	}	
69
70
71
	public void tryChildIfEmpty() {
72
		// element has no eObject. try parent
73
		if(getEObject() == null) {
74
			// TODO: is it possible to access the children in another way (without internal access?)
75
			if (element instanceof LinkItem) {
76
				List<?> items = ((LinkItem)element).getChildrenElements();
77
				if(items.size() > 0 && items.get(0) instanceof EObject) {
78
					// element = items[0];
79
					setEObject((EObject)items.get(0));
80
				}
81
			}
82
		}
83
	}
58
	}
84
59
85
	/**
60
	/**
Lines 90-97 Link Here
90
	public EObject getEObject() {
65
	public EObject getEObject() {
91
		return eObject;
66
		return eObject;
92
	}
67
	}
93
	
94
68
69
95
	/**
70
	/**
96
	 * sets the current EObject
71
	 * sets the current EObject
97
	 * 
72
	 * 
Lines 101-256 Link Here
101
		this.eObject = eObject;
76
		this.eObject = eObject;
102
	}
77
	}
103
78
104
	public IMarker [] getMarkers () {
79
	public IMarker[] getMarkers() {
105
		if(getEObject() != null) {
80
		if(getEObject() != null) {
106
			if(getEObject().eResource() != null) {
81
			if(getEObject().eResource() != null) {
107
				URI uri = getEObject().eResource().getURI();
82
				URI uri = getEObject().eResource().getURI();
108
				String platformResourceString = uri.toPlatformString(true);
83
				String platformResourceString = uri.toPlatformString(true);
109
				IFile file = (platformResourceString != null ?
84
				IFile file = (platformResourceString != null ? ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourceString)) : null);
110
				      ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourceString)) : null);
85
				if(file != null) {
111
				if (file != null) {
112
					try {
86
					try {
113
						// TODO: quite inefficient, since requested for each element (could cache markers, already done
87
						// TODO: quite inefficient, since requested for each element (could cache markers, already done
114
						// by findMarkers operation?)
88
						// by findMarkers operation?)
115
						return file.findMarkers(IMarker.PROBLEM, true, 0);
89
						return file.findMarkers(IMarker.PROBLEM, true, 0);
90
					} catch (CoreException e) {
116
					}
91
					}
117
					catch (CoreException e) {
118
					}
119
				}
92
				}
120
			}
93
			}
121
		}
94
		}
122
		return null;
95
		return null;
123
	}
96
	}
124
	
97
125
	/**
98
	/**
126
	 * 
99
	 * 
127
	 * @param marker
100
	 * @param marker
128
	 * @return
101
	 * @return
129
	 */
102
	 */
130
	public EObject eObjectOfMarker (IMarker marker) {
103
	public EObject eObjectOfMarker(IMarker marker) {
131
		if(getEObject() != null) {
104
		if(getEObject() != null) {
132
			domain = AdapterFactoryEditingDomain.getEditingDomainFor(getEObject());
105
			domain = AdapterFactoryEditingDomain.getEditingDomainFor(getEObject());
133
			try {
106
			try {
134
				if (marker.isSubtypeOf((EValidator.MARKER))) {
107
				if(marker.isSubtypeOf((EValidator.MARKER))) {
135
					return ValidationUtils.eObjectFromMarkerOrMap (marker, null, domain);
108
					return ValidationUtils.eObjectFromMarkerOrMap(marker, null, domain);
136
				}
109
				}
137
			}
110
			} catch (CoreException e) {
138
			catch (CoreException e) {
139
				// only reason: marker does not exist
111
				// only reason: marker does not exist
140
			}
112
			}
141
		}
113
		}
142
		return null;
114
		return null;
143
	}
115
	}
144
	
116
145
	/**
117
	/**
146
	 * Delete all markers that refer to eObjects owned by the passed parentEObj
118
	 * Delete all markers that refer to eObjects owned by the passed parentEObj
147
	 */
119
	 */
148
	public void deleteSubMarkers() {
120
	public void deleteSubMarkers() {
149
		for (IMarker marker : getMarkers ()) {
121
		for(IMarker marker : getMarkers()) {
150
			EObject eObjOfMarker = eObjectOfMarker (marker);
122
			EObject eObjOfMarker = eObjectOfMarker(marker);
151
			if(isContainedBy(eObjOfMarker, getEObject())) {
123
			if(isContainedBy(eObjOfMarker, getEObject())) {
152
				try {
124
				try {
153
					marker.delete ();
125
					marker.delete();
126
				} catch (CoreException e) {
154
				}
127
				}
155
				catch (CoreException e) {
156
				}
157
			}
128
			}
158
		}
129
		}
159
	}
130
	}
160
	
131
161
	/**
132
	private boolean isContainedBy(EObject subEObj, EObject eObj) {
162
	 * @return the maximum severity of markers associated with the model element
133
		if(eObj == subEObj)
163
	 * (constructor parameter of validation tool)
134
			return true;
164
	 */
135
		else if(subEObj != null) {
165
	public int getSeverity() {
136
			return isContainedBy(subEObj.eContainer(), eObj);
166
		IMarker markers[] = getMarkers();
167
		MarkChildren markChildren = PreferencePage.getHierarchicalMarkers();
168
		int severity = 0;
169
		if (markers != null) {
170
			for (IMarker marker : markers) {
171
				EObject eObjectOfMarker = eObjectOfMarker(marker);
172
				boolean first = true;
173
				while (eObjectOfMarker != null) {
174
					if (eObjectOfMarker == getEObject()) {
175
						try {
176
							Integer severityI = (Integer) marker.getAttribute(IMarker.SEVERITY);
177
							if (severityI.intValue () > severity) {
178
								severity = severityI.intValue();
179
							}
180
						}
181
						catch (CoreException e) {
182
						}
183
					}
184
					// navigate to parents, since parent folder is contaminated as well
185
					eObjectOfMarker = eObjectOfMarker.eContainer();
186
					if (markChildren != MarkChildren.ALL) {
187
						if ((!first) || (markChildren == MarkChildren.NO)) {
188
							break;
189
						}
190
					}
191
					first = false;
192
				}
193
			}
194
		}
137
		}
195
		return severity;
196
	}
197
	
198
	/**
199
	 * @return A set of messages associated with the markers for the model element
200
	 * (constructor parameter of validation tool)
201
	 */
202
	public String getMarkerMessages() {
203
		IMarker markers[] = getMarkers();
204
		MarkChildren markChildren = PreferencePage.getHierarchicalMarkers();
205
		if (markers != null) {
206
			boolean examineChilds = (markChildren != MarkChildren.NO);
207
			String message = "";
208
			for (IMarker marker : markers) {
209
				EObject eObjectOfMarker = eObjectOfMarker(marker);
210
				if (eObjectOfMarker == getEObject()) {
211
					if (message.length() > 0) {
212
						message += "\n";
213
					}
214
					// vt.getWrappedMessage (marker);
215
					try {
216
						message += "- " + WordUtils.wrap ((String) marker.getAttribute(IMarker.MESSAGE), 100, "\n  ", true);
217
					}
218
					catch (CoreException e) {
219
					}
220
				}
221
				if (examineChilds && (eObjectOfMarker != null)) {
222
					eObjectOfMarker = eObjectOfMarker.eContainer();
223
					boolean first = true;
224
					while (eObjectOfMarker != null) {
225
						if (eObjectOfMarker == getEObject ()) {
226
							if (message.length() > 0) {
227
								message += "\n";
228
							}
229
							message += "- Problem marker in (at least) one of the children";
230
							examineChilds = false;
231
							break;
232
						}
233
						// navigate to parents, since parent folder is contaminated as well
234
						eObjectOfMarker = eObjectOfMarker.eContainer();
235
						if ((!first) && (markChildren == MarkChildren.DIRECT)) {
236
							break;
237
						}
238
						first = false;
239
					}
240
				}
241
			}
242
			return (message.length() > 0) ? message : null; 
243
		}
244
		return null;
245
	}
246
	
247
	private boolean isContainedBy (EObject subEObj, EObject eObj) {
248
		if (eObj == subEObj) return true;
249
		else if (subEObj != null) {
250
			return isContainedBy (subEObj.eContainer(), eObj);
251
		}
252
		// reached, if subEObj == null
138
		// reached, if subEObj == null
253
		return false;
139
		return false;
254
	}
140
	}
255
	
141
256
}
142
}
(-)src/org/eclipse/papyrus/validation/commands/AbstractValidateCommand.java (+196 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
package org.eclipse.papyrus.validation.commands;
15
16
import java.lang.reflect.InvocationTargetException;
17
import java.util.Collections;
18
import java.util.Iterator;
19
import java.util.Map;
20
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.emf.common.EMFPlugin;
23
import org.eclipse.emf.common.notify.AdapterFactory;
24
import org.eclipse.emf.common.util.BasicDiagnostic;
25
import org.eclipse.emf.common.util.Diagnostic;
26
import org.eclipse.emf.common.util.DiagnosticChain;
27
import org.eclipse.emf.ecore.EClass;
28
import org.eclipse.emf.ecore.EObject;
29
import org.eclipse.emf.ecore.resource.Resource;
30
import org.eclipse.emf.ecore.util.Diagnostician;
31
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
32
import org.eclipse.emf.edit.provider.IItemLabelProvider;
33
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
34
import org.eclipse.emf.edit.ui.action.ValidateAction.EclipseResourcesUtil;
35
import org.eclipse.emf.transaction.TransactionalEditingDomain;
36
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
37
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
38
import org.eclipse.jface.operation.IRunnableWithProgress;
39
import org.eclipse.papyrus.validation.ValidationTool;
40
import org.eclipse.swt.widgets.Shell;
41
import org.eclipse.ui.PlatformUI;
42
43
/**
44
 * An abstract validation command that needs to be refined, in particular the doExecuteWithResult operation
45
 * (which will typically delegate to the runValidation operation).
46
 * 
47
 * Contains partly elements that are copied from @see emf.edit.ui.action.ValidateAction.
48
 * 
49
 * @author Ansgar Radermacher (CEA LIST)
50
 */
51
abstract public class AbstractValidateCommand extends AbstractTransactionalCommand {
52
53
	protected EclipseResourcesUtil eclipseResourcesUtil = EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE ? new EclipseResourcesUtil() : null;
54
55
	protected TransactionalEditingDomain domain;
56
57
	protected EObject selectedElement;
58
59
	/**
60
	 * Creates a new ImportLibraryFromRepositoryCommand
61
	 * 
62
	 * @param editingDomain
63
	 *        editing domain that manages the changed objects
64
	 * @param runnable
65
	 *        process that executes the modifications
66
	 * @param label
67
	 *        the label of the command
68
	 * @param description
69
	 *        description of the command
70
	 */
71
72
	public AbstractValidateCommand(String label, TransactionalEditingDomain domain, EObject selectedElement) {
73
		super(domain, label, Collections.EMPTY_LIST);
74
		this.domain = domain;
75
		this.selectedElement = selectedElement;
76
	}
77
78
	protected void handleDiagnostic(Diagnostic diagnostic) {
79
		// Do not show a dialog, as in the original version since the user sees the result directly
80
		// in the model explorer
81
		Resource resource = getResource();
82
		if(resource != null) {
83
			if(selectedElement != null) {
84
				ValidationTool vt = new ValidationTool(selectedElement);
85
				vt.deleteSubMarkers();
86
			}
87
88
			// IPath path = new Path(resource.getURI().toPlatformString (false));
89
			// IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
90
			// IFile file = wsRoot.getFile(path);
91
			// eclipseResourcesUtil.deleteMarkers (file);
92
93
			for(Diagnostic childDiagnostic : diagnostic.getChildren()) {
94
				eclipseResourcesUtil.createMarkers(resource, childDiagnostic);
95
				// createMarkersOnDi (file, childDiagnostic);
96
			}
97
		}
98
99
	}
100
101
	protected Resource getResource() {
102
		Resource resource = eclipseResourcesUtil != null ? domain.getResourceSet().getResources().get(0) : null;
103
		return resource;
104
	}
105
106
	protected void runValidation(final EObject validateElement) {
107
		final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
108
		IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
109
110
			public void run(final IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
111
				try {
112
					final Diagnostic diagnostic = validate(progressMonitor, validateElement);
113
					shell.getDisplay().asyncExec(new Runnable() {
114
115
						public void run() {
116
							if(progressMonitor.isCanceled()) {
117
								handleDiagnostic(Diagnostic.CANCEL_INSTANCE);
118
							} else {
119
								handleDiagnostic(diagnostic);
120
							}
121
						}
122
					});
123
				} finally {
124
					progressMonitor.done();
125
				}
126
			}
127
		};
128
129
		if(eclipseResourcesUtil != null) {
130
			runnableWithProgress = eclipseResourcesUtil.getWorkspaceModifyOperation(runnableWithProgress);
131
		}
132
133
		try {
134
			// This runs the operation, and shows progress.
135
			// (It appears to be a bad thing to fork this onto another thread, since we are
136
			// running a transaction in the UI thread and would prevent a validation rule
137
			// from opening a transaction))
138
			new ProgressMonitorDialog(shell).run(false, true, runnableWithProgress);
139
		} catch (Exception exception) {
140
			EMFEditUIPlugin.INSTANCE.log(exception);
141
		}
142
	}
143
144
	/**
145
	 * This simply executes the command.
146
	 */
147
	protected Diagnostic validate(IProgressMonitor progressMonitor, EObject validateElement) {
148
		int count = 0;
149
		for(Iterator<?> i = validateElement.eAllContents(); i.hasNext(); i.next()) {
150
			++count;
151
		}
152
153
		progressMonitor.beginTask("", count);
154
155
		AdapterFactory adapterFactory = domain instanceof AdapterFactoryEditingDomain ? ((AdapterFactoryEditingDomain)domain).getAdapterFactory() : null;
156
		Diagnostician diagnostician = createDiagnostician(adapterFactory, progressMonitor);
157
158
		BasicDiagnostic diagnostic = diagnostician.createDefaultDiagnostic(validateElement);
159
		Map<Object, Object> context = diagnostician.createDefaultContext();
160
161
		progressMonitor.setTaskName(EMFEditUIPlugin.INSTANCE.getString("_UI_Validating_message", new Object[]{ diagnostician.getObjectLabel(validateElement) }));
162
		diagnostician.validate(validateElement, diagnostic, context);
163
164
		return diagnostic;
165
	}
166
167
	protected Diagnostician createDiagnostician(final AdapterFactory adapterFactory, final IProgressMonitor progressMonitor) {
168
		return new Diagnostician() {
169
170
			@Override
171
			public String getObjectLabel(EObject eObject) {
172
				if(adapterFactory != null && !eObject.eIsProxy()) {
173
					IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(eObject, IItemLabelProvider.class);
174
					if(itemLabelProvider != null) {
175
						return itemLabelProvider.getText(eObject);
176
					}
177
				}
178
				return super.getObjectLabel(eObject);
179
			}
180
181
			@Override
182
			public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
183
				progressMonitor.worked(1);
184
				return super.validate(eClass, eObject, diagnostics, context);
185
			}
186
		};
187
	}
188
189
	/**
190
	 * {@inheritDoc}
191
	 */
192
	@Override
193
	public boolean canExecute() {
194
		return (selectedElement != null);
195
	}
196
}
(-)src/org/eclipse/papyrus/validation/commands/SelectAndValidateModelCommand.java (+56 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.commands;
16
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.transaction.util.TransactionUtil;
22
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
23
import org.eclipse.jface.dialogs.IDialogConstants;
24
import org.eclipse.jface.preference.PreferenceDialog;
25
import org.eclipse.ui.dialogs.PreferencesUtil;
26
27
28
public class SelectAndValidateModelCommand extends AbstractValidateCommand {
29
30
	public SelectAndValidateModelCommand(EObject selectedElement) {
31
		super("Validate subtree", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
32
	}
33
34
	/**
35
	 * {@inheritDoc}
36
	 */
37
	@Override
38
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
39
40
		String idRootPage = "org.eclipse.emf.validation.ui.rootPage";
41
		String idConstraints = "org.eclipse.emf.validation.constraintsPrefs";
42
		String filter[] = { idRootPage, idConstraints };
43
		PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, idConstraints, filter, null);
44
		int result = dialog.open();
45
46
		if(result == IDialogConstants.OK_ID) {
47
			EObject selectedObject = selectedElement;
48
			// replace selection by model instead of current selection
49
			while(selectedObject.eContainer() != null) {
50
				selectedObject = selectedObject.eContainer();
51
			}
52
			runValidation(selectedObject);
53
		}
54
		return null;
55
	}
56
}
(-)src/org/eclipse/papyrus/validation/commands/SelectAndValidateSubtreeCommand.java (+51 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.commands;
16
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.transaction.util.TransactionUtil;
22
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
23
import org.eclipse.jface.dialogs.IDialogConstants;
24
import org.eclipse.jface.preference.PreferenceDialog;
25
import org.eclipse.ui.dialogs.PreferencesUtil;
26
27
28
public class SelectAndValidateSubtreeCommand extends AbstractValidateCommand {
29
30
	public SelectAndValidateSubtreeCommand(EObject selectedElement) {
31
		super("Validate subtree", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
32
	}
33
34
	/**
35
	 * {@inheritDoc}
36
	 */
37
	@Override
38
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
39
40
		String idRootPage = "org.eclipse.emf.validation.ui.rootPage";
41
		String idConstraints = "org.eclipse.emf.validation.constraintsPrefs";
42
		String filter[] = { idRootPage, idConstraints };
43
		PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, idConstraints, filter, null);
44
		int result = dialog.open();
45
46
		if(result == IDialogConstants.OK_ID) {
47
			runValidation(selectedElement);
48
		}
49
		return null;
50
	}
51
}
(-)src/org/eclipse/papyrus/validation/commands/ValidateDelMarkersFromModelCommand.java (+43 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.commands;
16
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.ecore.resource.Resource;
22
import org.eclipse.emf.transaction.util.TransactionUtil;
23
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
24
25
26
public class ValidateDelMarkersFromModelCommand extends AbstractValidateCommand {
27
28
	public ValidateDelMarkersFromModelCommand(EObject selectedElement) {
29
		super("Delete markers from model", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
30
	}
31
32
	/**
33
	 * {@inheritDoc}
34
	 */
35
	@Override
36
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
37
		Resource resource = getResource();
38
		if((resource != null) && (eclipseResourcesUtil != null)) {
39
			eclipseResourcesUtil.deleteMarkers(getResource());
40
		}
41
		return null;
42
	}
43
}
(-)src/org/eclipse/papyrus/validation/commands/ValidateDelMarkersFromSubtreeCommand.java (+43 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.commands;
16
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.transaction.util.TransactionUtil;
22
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
23
import org.eclipse.papyrus.validation.ValidationTool;
24
25
26
public class ValidateDelMarkersFromSubtreeCommand extends AbstractValidateCommand {
27
28
	public ValidateDelMarkersFromSubtreeCommand(EObject selectedElement) {
29
		super("Delete markers from subtree", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
30
	}
31
32
	/**
33
	 * {@inheritDoc}
34
	 */
35
	@Override
36
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
37
38
		ValidationTool vt = new ValidationTool(selectedElement);
39
		vt.deleteSubMarkers();
40
41
		return null;
42
	}
43
}
(-)src/org/eclipse/papyrus/validation/commands/ValidateModelCommand.java (+45 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.commands;
16
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.transaction.util.TransactionUtil;
22
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
23
24
25
26
public class ValidateModelCommand extends AbstractValidateCommand {
27
28
	public ValidateModelCommand(EObject selectedElement) {
29
		super("Validate model", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
30
	}
31
32
	/**
33
	 * {@inheritDoc}
34
	 */
35
	@Override
36
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
37
		EObject selectedObject = selectedElement;
38
		// replace selection by model instead of current selection
39
		while(selectedObject.eContainer() != null) {
40
			selectedObject = selectedObject.eContainer();
41
		}
42
		runValidation(selectedObject);
43
		return null;
44
	}
45
}
(-)src/org/eclipse/papyrus/validation/commands/ValidateSubtreeCommand.java (+40 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.commands;
16
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.transaction.util.TransactionUtil;
22
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
23
24
25
public class ValidateSubtreeCommand extends AbstractValidateCommand {
26
27
	public ValidateSubtreeCommand(EObject selectedElement) {
28
		super("Validate subtree", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
29
	}
30
31
	/**
32
	 * {@inheritDoc}
33
	 */
34
	@Override
35
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
36
37
		runValidation(selectedElement);
38
		return null;
39
	}
40
}
(-)src/org/eclipse/papyrus/validation/handler/AbstractCommandHandler.java (+170 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 * 
12
 * 		Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
13
 *      Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
14
 *****************************************************************************/
15
package org.eclipse.papyrus.validation.handler;
16
17
import java.util.ArrayList;
18
import java.util.List;
19
20
import org.eclipse.core.commands.AbstractHandler;
21
import org.eclipse.core.commands.ExecutionEvent;
22
import org.eclipse.core.commands.ExecutionException;
23
import org.eclipse.core.runtime.IAdaptable;
24
import org.eclipse.emf.common.command.Command;
25
import org.eclipse.emf.ecore.EObject;
26
import org.eclipse.emf.transaction.TransactionalEditingDomain;
27
import org.eclipse.jface.viewers.ISelection;
28
import org.eclipse.jface.viewers.IStructuredSelection;
29
import org.eclipse.papyrus.core.services.ServiceException;
30
import org.eclipse.papyrus.core.utils.BusinessModelResolver;
31
import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers;
32
import org.eclipse.papyrus.validation.Activator;
33
import org.eclipse.ui.PlatformUI;
34
35
/**
36
 * <pre>
37
 * 
38
 * This abstract command handler manages:
39
 * - current selection in order to build a list of the selected {@link EObject}
40
 * - execute the command (returned by children) in Papyrus {@link TransactionalEditingDomain}
41
 * - calculate the command enablement and visibility regarding the command executability
42
 * (the command is now shown in menu if not executable).
43
 * 
44
 * </pre>
45
 */
46
public abstract class AbstractCommandHandler extends AbstractHandler {
47
48
	/**
49
	 * <pre>
50
	 * 
51
	 * Returns the command to execute (to be implemented 
52
	 * in children implementing this class)
53
	 * 
54
	 * @return the command to execute
55
	 * 
56
	 * </pre>
57
	 */
58
	protected abstract Command getCommand();
59
60
	/**
61
	 * <pre>
62
	 * Get the selected element, the first selected element if several are selected or null 
63
	 * if no selection or the selection is not an {@link EObject}. 
64
	 * 
65
	 * @return selected {@link EObject} or null
66
	 * </pre>
67
	 * 
68
	 */
69
	protected EObject getSelectedElement() {
70
		EObject eObject = null;
71
		Object selection = null;
72
73
		// Get current selection
74
		selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
75
76
		// Get first element if the selection is an IStructuredSelection
77
		if(selection instanceof IStructuredSelection) {
78
			IStructuredSelection structuredSelection = (IStructuredSelection)selection;
79
			selection = structuredSelection.getFirstElement();
80
		}
81
82
		// Treat non-null selected object (try to adapt and return EObject)
83
		if(selection != null) {
84
			if(selection instanceof IAdaptable) {
85
				selection = ((IAdaptable)selection).getAdapter(EObject.class);
86
			}
87
88
			Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection);
89
			if(businessObject instanceof EObject) {
90
				eObject = (EObject)businessObject;
91
			}
92
		}
93
		return eObject;
94
	}
95
96
	/**
97
	 * <pre>
98
	 * Parse current selection and extract the list of {@link EObject} from
99
	 * this selection.
100
	 * 
101
	 * This also tries to adapt selected element into {@link EObject}
102
	 * (for example to get the {@link EObject} from a selection in the ModelExplorer).
103
	 * 
104
	 * @return a list of currently selected {@link EObject}
105
	 * </pre>
106
	 * 
107
	 */
108
	protected List<EObject> getSelectedElements() {
109
110
		List<EObject> selectedEObjects = new ArrayList<EObject>();
111
112
		// Parse current selection
113
		ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
114
		if(selection instanceof IStructuredSelection) {
115
			IStructuredSelection structuredSelection = (IStructuredSelection)selection;
116
			for(Object current : structuredSelection.toArray()) {
117
				// Adapt current selection to EObject
118
				if(current instanceof IAdaptable) {
119
					selectedEObjects.add((EObject)((IAdaptable)current).getAdapter(EObject.class));
120
				}
121
			}
122
		} else { // Not a IStructuredSelection
123
			if(selection != null) {
124
				// Adapt current selection to EObject
125
				if(selection instanceof IAdaptable) {
126
					selectedEObjects.add((EObject)((IAdaptable)selection).getAdapter(EObject.class));
127
				}
128
			}
129
		}
130
131
		return selectedEObjects;
132
	}
133
134
	/**
135
	 * 
136
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
137
	 * 
138
	 * @param event
139
	 * @return null
140
	 * @throws ExecutionException
141
	 */
142
	public Object execute(ExecutionEvent event) throws ExecutionException {
143
		try {
144
			ServiceUtilsForActionHandlers util = new ServiceUtilsForActionHandlers();
145
			util.getTransactionalEditingDomain().getCommandStack().execute(getCommand());
146
		} catch (ServiceException e) {
147
			Activator.log.error("Unexpected error while executing command.", e); //$NON-NLS-1$
148
		}
149
150
		return null;
151
	}
152
153
	/**
154
	 * {@inheritDoc}
155
	 */
156
	@Override
157
	public boolean isEnabled() {
158
		return getCommand().canExecute();
159
	}
160
161
	/**
162
	 * 
163
	 * @return true (visible) when the command can be executed.
164
	 */
165
	public boolean isVisible() {
166
		return getCommand().canExecute();
167
	}
168
169
170
}
(-)src/org/eclipse/papyrus/validation/handler/SelectAndValidateModelHandler.java (+34 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.handler;
16
17
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
19
import org.eclipse.papyrus.validation.commands.SelectAndValidateModelCommand;
20
21
/**
22
 * Action used for pasting either a model element or a shape (i.e. the model element represented
23
 * by the shape). Delegates to PasteShapeOrElementCommand
24
 * 
25
 * @author Ansgar Radermacher (CEA LIST)
26
 */
27
public class SelectAndValidateModelHandler extends AbstractCommandHandler {
28
29
	@Override
30
	protected Command getCommand() {
31
		// not useful to cache command, since selected element may change
32
		return new GMFtoEMFCommandWrapper(new SelectAndValidateModelCommand(getSelectedElement()));
33
	}
34
}
(-)src/org/eclipse/papyrus/validation/handler/SelectAndValidateSubtreeHandler.java (+34 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.handler;
16
17
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
19
import org.eclipse.papyrus.validation.commands.SelectAndValidateSubtreeCommand;
20
21
/**
22
 * Action used for pasting either a model element or a shape (i.e. the model element represented
23
 * by the shape). Delegates to PasteShapeOrElementCommand
24
 * 
25
 * @author Ansgar Radermacher (CEA LIST)
26
 */
27
public class SelectAndValidateSubtreeHandler extends AbstractCommandHandler {
28
29
	@Override
30
	protected Command getCommand() {
31
		// not useful to cache command, since selected element may change
32
		return new GMFtoEMFCommandWrapper(new SelectAndValidateSubtreeCommand(getSelectedElement()));
33
	}
34
}
(-)src/org/eclipse/papyrus/validation/handler/ValidateDelMarkersFromModelHandler.java (+34 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.handler;
16
17
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
19
import org.eclipse.papyrus.validation.commands.ValidateDelMarkersFromModelCommand;
20
21
/**
22
 * Action used for pasting either a model element or a shape (i.e. the model element represented
23
 * by the shape). Delegates to PasteShapeOrElementCommand
24
 * 
25
 * @author Ansgar Radermacher (CEA LIST)
26
 */
27
public class ValidateDelMarkersFromModelHandler extends AbstractCommandHandler {
28
29
	@Override
30
	protected Command getCommand() {
31
		// not useful to cache command, since selected element may change
32
		return new GMFtoEMFCommandWrapper(new ValidateDelMarkersFromModelCommand(getSelectedElement()));
33
	}
34
}
(-)src/org/eclipse/papyrus/validation/handler/ValidateDelMarkersFromSubtreeHandler.java (+34 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.handler;
16
17
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
19
import org.eclipse.papyrus.validation.commands.ValidateDelMarkersFromSubtreeCommand;
20
21
/**
22
 * Action used for pasting either a model element or a shape (i.e. the model element represented
23
 * by the shape). Delegates to PasteShapeOrElementCommand
24
 * 
25
 * @author Ansgar Radermacher (CEA LIST)
26
 */
27
public class ValidateDelMarkersFromSubtreeHandler extends AbstractCommandHandler {
28
29
	@Override
30
	protected Command getCommand() {
31
		// not useful to cache command, since selected element may change
32
		return new GMFtoEMFCommandWrapper(new ValidateDelMarkersFromSubtreeCommand(getSelectedElement()));
33
	}
34
}
(-)src/org/eclipse/papyrus/validation/handler/ValidateModelHandler.java (+34 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.handler;
16
17
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
19
import org.eclipse.papyrus.validation.commands.ValidateModelCommand;
20
21
/**
22
 * Action used for pasting either a model element or a shape (i.e. the model element represented
23
 * by the shape). Delegates to PasteShapeOrElementCommand
24
 * 
25
 * @author Ansgar Radermacher (CEA LIST)
26
 */
27
public class ValidateModelHandler extends AbstractCommandHandler {
28
29
	@Override
30
	protected Command getCommand() {
31
		// not useful to cache command, since selected element may change
32
		return new GMFtoEMFCommandWrapper(new ValidateModelCommand(getSelectedElement()));
33
	}
34
}
(-)src/org/eclipse/papyrus/validation/handler/ValidateSubtreeHandler.java (+34 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2010 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.papyrus.validation.handler;
16
17
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
19
import org.eclipse.papyrus.validation.commands.ValidateSubtreeCommand;
20
21
/**
22
 * Action used for pasting either a model element or a shape (i.e. the model element represented
23
 * by the shape). Delegates to PasteShapeOrElementCommand
24
 * 
25
 * @author Ansgar Radermacher (CEA LIST)
26
 */
27
public class ValidateSubtreeHandler extends AbstractCommandHandler {
28
29
	@Override
30
	protected Command getCommand() {
31
		// not useful to cache command, since selected element may change
32
		return new GMFtoEMFCommandWrapper(new ValidateSubtreeCommand(getSelectedElement()));
33
	}
34
}

Return to bug 325610