Skip to main content
summaryrefslogtreecommitdiffstats
blob: a0da2f95bf8ed95518ac489e6047e099030b7a4b (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*******************************************************************************
 * Copyright (c) 2003, 2004 IBM Corporation and others.
 * 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:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.provider;


import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.CopyToClipboardCommand;
import org.eclipse.emf.edit.command.CreateCopyCommand;
import org.eclipse.emf.edit.command.DragAndDropCommand;
import org.eclipse.emf.edit.command.InitializeCopyCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.command.OverrideableCommand;
import org.eclipse.emf.edit.command.PasteFromClipboardCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.ReplaceCommand;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;

/**
 * Custom editing domain which provides hooks for creating override commands; should not be used
 * directly but can be subclassed to override commands as necessary. All the override methods by
 * default return null, so a subclass may override only a subset of the commands.
 */
public class J2EEEditingDomain extends AdapterFactoryEditingDomain {
	/**
	 * J2EEEditingDomain constructor comment.
	 * 
	 * @param adapterFactory
	 *            org.eclipse.emf.common.notify.AdapterFactory
	 * @param commandStack
	 *            CommandStack
	 */
	public J2EEEditingDomain(org.eclipse.emf.common.notify.AdapterFactory adapterFactory, CommandStack commandStack) {
		super(adapterFactory, commandStack);
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createAddOverrideCommand(AddCommand addCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createCopyToClipboardOverrideCommand(CopyToClipboardCommand copyToClipboardCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createCreateCopyOverrideCommand(CreateCopyCommand createCopyCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createDragAndDropOverrideCommand(DragAndDropCommand dragAndDropCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createInitializeCopyOverrideCommand(InitializeCopyCommand initializeCopyCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createMoveOverrideCommand(MoveCommand moveCommand) {
		return null;
	}

	@Override
	public Command createOverrideCommand(OverrideableCommand command) {
		if (command instanceof AddCommand) {
			AddCommand addCommand = (AddCommand) command;
			return createAddOverrideCommand(addCommand);
		} else if (command instanceof RemoveCommand) {
			RemoveCommand removeCommand = (RemoveCommand) command;
			return createRemoveOverrideCommand(removeCommand);
		} else if (command instanceof SetCommand) {
			SetCommand setCommand = (SetCommand) command;
			return createSetOverrideCommand(setCommand);
		} else if (command instanceof ReplaceCommand) {
			ReplaceCommand replaceCommand = (ReplaceCommand) command;
			return createReplaceOverrideCommand(replaceCommand);
		} else if (command instanceof MoveCommand) {
			MoveCommand moveCommand = (MoveCommand) command;
			return createMoveOverrideCommand(moveCommand);
		} else if (command instanceof CreateCopyCommand) {
			CreateCopyCommand createCopyCommand = (CreateCopyCommand) command;
			return createCreateCopyOverrideCommand(createCopyCommand);
		} else if (command instanceof InitializeCopyCommand) {
			InitializeCopyCommand initializeCopyCommand = (InitializeCopyCommand) command;
			return createInitializeCopyOverrideCommand(initializeCopyCommand);
		} else if (command instanceof CopyToClipboardCommand) {
			CopyToClipboardCommand copyToClipboardCommand = (CopyToClipboardCommand) command;
			return createCopyToClipboardOverrideCommand(copyToClipboardCommand);
		} else if (command instanceof PasteFromClipboardCommand) {
			PasteFromClipboardCommand pasteFromClipboardCommand = (PasteFromClipboardCommand) command;
			return createPasteFromClipboardOverrideCommand(pasteFromClipboardCommand);
		} else if (command instanceof DragAndDropCommand) {
			DragAndDropCommand dragAndDropCommand = (DragAndDropCommand) command;
			return createDragAndDropOverrideCommand(dragAndDropCommand);
		} else {
			return null;
		}
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createPasteFromClipboardOverrideCommand(PasteFromClipboardCommand pasteFromClipboardCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createRemoveOverrideCommand(RemoveCommand removeCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createReplaceOverrideCommand(ReplaceCommand replaceCommand) {
		return null;
	}

	/**
	 * The default is not to override this command; subclasses can override if necessary
	 */
	protected Command createSetOverrideCommand(SetCommand setCommand) {
		return null;
	}
}

Back to the top