blob: 639b7dcb2a4f638631af6b295524c050f2084dac (
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
|
/*****************************************************************************
* Copyright (c) 2015 Christian W. Damus 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:
* Christian W. Damus - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.uml.profile.types.generator.ui.internal.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.profile.types.generator.ui.internal.wizards.GeneratorWizard;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.uml2.uml.Profile;
/**
* @author damus
*
*/
public class GenerateElementTypesHandler extends AbstractHandler {
/**
* Constructor.
*
*/
public GenerateElementTypesHandler() {
super();
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
IStructuredSelection sselection = (IStructuredSelection) selection;
if (!sselection.isEmpty()) {
EObject eObject = EMFHelper.getEObject(sselection.getFirstElement());
if (eObject instanceof Profile) {
IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindowChecked(event).getActivePage();
GeneratorWizard wizard = new GeneratorWizard(page, (Profile) eObject);
WizardDialog dlg = new WizardDialog(HandlerUtil.getActiveShellChecked(event), wizard);
dlg.open();
}
}
}
return null;
}
}
|