Skip to main content
summaryrefslogtreecommitdiffstats
blob: 3639ea8225bc4ccd4bf146e5f3a30b34fc95432d (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
/*****************************************************************************
 * Copyright (c) 2009 Atos Origin.
 *
 *    
 * 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:
 *   Atos Origin - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.command;

import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.notation.View;

/**
 * ZOrder command with a custom index
 */
public class CustomZOrderCommand extends AbstractTransactionalCommand {

	protected View view;

	protected View containerView;

	private int index;

	/**
	 * @param editingDomain
	 *        the editing domain through which model changes are made
	 * @param label
	 * @param view
	 */
	public CustomZOrderCommand(TransactionalEditingDomain editingDomain, View view, int index) {
		super(editingDomain, "change ZOrder", getWorkspaceFiles(view));

		this.view = view;
		this.index = index;
		containerView = ViewUtil.getContainerView(view);

	}

	@Override
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
		ViewUtil.repositionChildAt(containerView, view, index);
		return CommandResult.newOKCommandResult();
	}

}

Back to the top