blob: 34eb2f5a1d8c741f0cb4adbd9984cbe5e0f5991f (
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
|
/******************************************************************************
* Copyright (c) 2005, 2020 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
* Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : Obsolete plugins (graphdef /bridge, etc.) /external 'x-friends' removed
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.codegen.popup.actions;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
/**
* Runs generation of diagram editor project
*
* @author artem
*/
public abstract class ExecuteTemplatesAction implements IObjectActionDelegate {
private IFile gmFile;
private IWorkbenchPart myPart;
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
myPart = targetPart;
}
public void selectionChanged(IAction action, ISelection selection) {
gmFile = (IFile) ((IStructuredSelection) selection).getFirstElement();
}
public void run(IAction action) {
ExecuteTemplatesOperation op = createOperation();
op.setName(action.getText());
op.setShell(getShell());
op.setGenModelURI(URI.createPlatformResourceURI(gmFile.getFullPath().toString(), true));
op.run();
}
protected abstract ExecuteTemplatesOperation createOperation();
private Shell getShell() {
return myPart.getSite().getShell();
}
}
|