Repository navigation
Expand file tree
/
Copy pathGenerateAction.java
More file actions
52 lines (36 loc) · 1.51 KB
/
Copy pathGenerateAction.java
File metadata and controls
52 lines (36 loc) · 1.51 KB
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
package code2code.popupmenu;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.wizards.IWizardDescriptor;
import org.eclipse.ui.wizards.IWizardRegistry;
import code2code.utils.EclipseGuiUtils;
public class GenerateAction implements IObjectActionDelegate{
private ISelection selection;
private IWorkbenchPart targetPart;
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
this.targetPart = targetPart;
}
public void run(IAction action) {
IWizardRegistry newWizardRegistry = PlatformUI.getWorkbench().getNewWizardRegistry();
IWizardDescriptor descriptor = newWizardRegistry.findWizard("code2code.newWizard");
try {
IWorkbenchWizard wizard = descriptor.createWizard();
wizard.init(targetPart.getSite().getWorkbenchWindow().getWorkbench(), (IStructuredSelection) selection);
WizardDialog dialog = new WizardDialog(targetPart.getSite().getShell(), wizard);
dialog.open();
} catch (CoreException e) {
EclipseGuiUtils.showErrorDialog(targetPart.getSite().getShell(), e);
throw new RuntimeException(e);
}
}
public void selectionChanged(IAction action, ISelection selection) {
this.selection = selection;
}
}