Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 684c834cc04b94d8f2b0c929c97a0c56fc31bc21 (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
/*******************************************************************************
 * Copyright (c) 2009 Obeo.
 * 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:
 *     Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.papyrus.navigator.actions;

import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;

/**
 * Provider used to create actions applicable on diagrams
 * 
 * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
 */
public class DiagramActionProvider extends AbstractSubmenuActionProvider {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void fillContextMenu(IMenuManager menu) {
		Object selectedElement = getFirstSelectedElement();

		if(selectedElement instanceof Diagram) {
			Diagram diagram = (Diagram)selectedElement;
			// Get the Editor IPageMngr. It should be Transactional.
			IPageMngr pageMngr = EditorUtils.getIPageMngr();

			// Create Rename Diagram action
			RenameDiagramAction renameDiagramAction = new RenameDiagramAction(diagram);
			menu.add(renameDiagramAction);

			// Create Delete Diagram action
			OpenDiagramAction openDiagramAction = new OpenDiagramAction(pageMngr, diagram);
			menu.add(openDiagramAction);

			// Create Delete Diagram action
			CloseDiagramAction closeDiagramAction = new CloseDiagramAction(pageMngr, diagram);
			menu.add(closeDiagramAction);

			// Create Close all diagrams action
			// fjcano #287948 :: close all diagrams action
			CloseAllDiagramsAction closeAllDiagramsAction = new CloseAllDiagramsAction(pageMngr);
			menu.add(closeAllDiagramsAction);

			// Create Delete Diagram action
			DeleteDiagramAction deleteDiagramAction = new DeleteDiagramAction(pageMngr, diagram);
			menu.add(deleteDiagramAction);

			// Create Duplicate Diagram action
			DuplicateDiagramAction duplicateDiagramAction = new DuplicateDiagramAction(pageMngr, diagram);
			menu.add(duplicateDiagramAction);
		}
	}

}

Back to the top