Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e2609af6ff5760f0d1aae62d5de2a5bbdbeaab43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Copyright (c) 2007 Borland Software Corporation
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 */

«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»

«DEFINE CreateShortcutDecorationsCommand FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR editorGen-»
package «editCommandsPackageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «createShortcutDecorationsCommandClassName»
		extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand {

	«EXPAND xpt::Common::generatedMemberComment»
	private java.util.List myDescriptors;

	«EXPAND xpt::Common::generatedMemberComment»
	public «createShortcutDecorationsCommandClassName»(
			org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
			org.eclipse.gmf.runtime.notation.View parentView,
			java.util.List viewDescriptors) {
		super(editingDomain, "Create Shortcuts", getWorkspaceFiles(parentView)); //$NON-NLS-1$
		myDescriptors = viewDescriptors;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public «createShortcutDecorationsCommandClassName»(
			org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
			org.eclipse.gmf.runtime.notation.View parentView,
			org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor viewDescriptor) {
		this(editingDomain, parentView, java.util.Collections.singletonList(viewDescriptor));
	}

	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(
			org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
			throws org.eclipse.core.commands.ExecutionException {
		for (java.util.Iterator it = myDescriptors.iterator(); it.hasNext();) {
			org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor nextDescriptor =
					(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor) it.next();
			org.eclipse.gmf.runtime.notation.View view =
					(org.eclipse.gmf.runtime.notation.View) nextDescriptor.getAdapter(
							org.eclipse.gmf.runtime.notation.View.class);
			if (view != null && view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
				«EXPAND xpt::Common::addShortcutAnnotation('view')-»
			}
		}
		return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
	}
}
«ENDDEFINE»

Back to the top