001: /**
002: *
003: */package newprocess.diagram.cust.annotations.actions;
004:
005: import newprocess.diagram.cust.annotations.utils.AnnotationTypes;
006: import newprocess.diagram.cust.annotations.wizards.AnnotationWizard;
007:
008: import org.eclipse.jface.action.Action;
009: import org.eclipse.jface.resource.ImageDescriptor;
010: import org.eclipse.jface.viewers.IStructuredSelection;
011: import org.eclipse.jface.wizard.WizardDialog;
012: import org.eclipse.swt.widgets.Event;
013: import org.eclipse.swt.widgets.Shell;
014: import org.eclipse.ui.PlatformUI;
015:
016: /**
017: * This class represents an action for
018: * each programm specified in the Annotation
019: * properties sheet page
020: * @author sh
021: */
022: public class ProgramAnnotationAction extends Action {
023: private IStructuredSelection structuredSelection = null;
024: private String projectName = null;
025:
026: /**
027: * Constructor
028: */
029: public ProgramAnnotationAction(String text,
030: ImageDescriptor imageDescriptor,
031: IStructuredSelection structuredSelection, String projectName) {
032: super (text, imageDescriptor);
033: this .structuredSelection = structuredSelection;
034: this .projectName = projectName;
035: }
036:
037: /**
038: * runs the action and opens a Wizard
039: * to create the annotation
040: */
041: @Override
042: public void runWithEvent(Event event) {
043: super .runWithEvent(event);
044:
045: //****************************************************************************
046: // FIXME "Preferences Sheet Page Workaround"
047: // if a MS Excel should be created
048: if (this .getText().contains(AnnotationTypes.MSEXCEL)) {
049: openMSExcelWizard();
050: }
051: // if a MS Word should be created
052: else if (this .getText().contains(AnnotationTypes.MSWORD)) {
053: openMSWordWizard();
054: }
055: //****************************************************************************
056: }
057:
058: /**
059: * open the MS Excel Wizard
060: */
061: private void openMSExcelWizard() {
062: // FIXME "Preferences Sheet Page Workaround"
063: // do the Annotation type settings
064: AnnotationWizard excelWizard = new AnnotationWizard(projectName);
065: excelWizard.setTitle(AnnotationTypes.MSEXCEL_TITLE);
066: excelWizard.setFileName(AnnotationTypes.MSEXCEL_FILENAME);
067: excelWizard
068: .setWindowTitle(AnnotationTypes.MSEXCEL_WINDOW_TITLE);
069: excelWizard.setPlugin(AnnotationTypes.PLUGIN);
070: excelWizard.setIcon(AnnotationTypes.MSEXCEL_ICON_PATH);
071: excelWizard.setAnnotationType(AnnotationTypes.MSEXCEL);
072:
073: // open the wizard
074: excelWizard
075: .init(PlatformUI.getWorkbench(), structuredSelection);
076: Shell shell = PlatformUI.getWorkbench()
077: .getActiveWorkbenchWindow().getShell();
078: WizardDialog dialog = new WizardDialog(shell, excelWizard);
079: dialog.open();
080: }
081:
082: /**
083: * open the MS Word Wizard
084: */
085: private void openMSWordWizard() {
086: // FIXME "Preferences Sheet Page Workaround"
087: // do the Annotation type settings
088: AnnotationWizard wordWizard = new AnnotationWizard(projectName);
089: wordWizard.setTitle(AnnotationTypes.MSWORD_TITLE);
090: wordWizard.setFileName(AnnotationTypes.MSWORD_FILENAME);
091: wordWizard.setWindowTitle(AnnotationTypes.MSWORD_WINDOW_TITLE);
092: wordWizard.setPlugin(AnnotationTypes.PLUGIN);
093: wordWizard.setIcon(AnnotationTypes.MSWORD_ICON_PATH);
094: wordWizard.setAnnotationType(AnnotationTypes.MSWORD);
095:
096: // open the wizard
097: wordWizard.init(PlatformUI.getWorkbench(), structuredSelection);
098: Shell shell = PlatformUI.getWorkbench()
099: .getActiveWorkbenchWindow().getShell();
100: WizardDialog dialog = new WizardDialog(shell, wordWizard);
101: dialog.open();
102: }
103: }
|