01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.designstudio.editors.reportwizard.actions;
14:
15: import org.eclipse.jface.action.IAction;
16: import org.eclipse.jface.viewers.ISelection;
17: import org.eclipse.jface.viewers.IStructuredSelection;
18: import org.eclipse.jface.wizard.WizardDialog;
19: import org.eclipse.swt.widgets.Shell;
20: import org.eclipse.ui.IWorkbenchWindow;
21: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
22: import org.eclipse.ui.PlatformUI;
23: import org.pentaho.designstudio.editors.reportwizard.wizards.ReportSpecNewWizard;
24:
25: /**
26: * Our sample action implements workbench action delegate.
27: * The action proxy will be created by the workbench and
28: * shown in the UI. When the user tries to use the action,
29: * this delegate will be created and execution will be
30: * delegated to it.
31: * @see IWorkbenchWindowActionDelegate
32: */
33: public class NewJFreeWizardSpecAction implements
34: IWorkbenchWindowActionDelegate {
35: private ISelection selection = null;
36:
37: /**
38: * The constructor.
39: */
40: public NewJFreeWizardSpecAction() {
41: }
42:
43: /**
44: * The action has been activated. The argument of the
45: * method represents the 'real' action sitting
46: * in the workbench UI.
47: * @see IWorkbenchWindowActionDelegate#run
48: */
49: public void run(IAction action) {
50: ReportSpecNewWizard wiz = new ReportSpecNewWizard();
51: wiz
52: .init(
53: PlatformUI.getWorkbench(),
54: (selection instanceof IStructuredSelection) ? (IStructuredSelection) selection
55: : null);//selection );
56: WizardDialog dialog = new WizardDialog(new Shell(), wiz);
57: dialog.open();
58: }
59:
60: /**
61: * Selection in the workbench has been changed. We
62: * can change the state of the 'real' action here
63: * if we want, but this can only happen after
64: * the delegate has been created.
65: * @see IWorkbenchWindowActionDelegate#selectionChanged
66: */
67: public void selectionChanged(IAction action, ISelection selection) {
68: this .selection = selection;
69: }
70:
71: /**
72: * We can use this method to dispose of any system
73: * resources we previously allocated.
74: * @see IWorkbenchWindowActionDelegate#dispose
75: */
76: public void dispose() {
77: }
78:
79: /**
80: * We will cache window object in order to
81: * be able to provide parent shell for the message dialog.
82: * @see IWorkbenchWindowActionDelegate#init
83: */
84: public void init(IWorkbenchWindow window) {
85: //this.window = window;
86: }
87: }
|