001: /**
002: *
003: */package newprocess.diagram.cust.annotations.utils;
004:
005: import java.util.Vector;
006:
007: import newprocess.diagram.cust.annotations.actions.ProgramAnnotationAction;
008:
009: import org.eclipse.jface.resource.ImageDescriptor;
010: import org.eclipse.jface.viewers.IStructuredSelection;
011: import org.eclipse.ui.PlatformUI;
012:
013: /**
014: * This class is intended to fetch the programms
015: * specified for an editor from the Annotations
016: * property sheet page.
017: * @author sh
018: */
019: public class PropertiesPageUtil {
020: Vector<ProgramAnnotationAction> actions = new Vector<ProgramAnnotationAction>();
021: private String projectName = null;
022:
023: /**
024: * Constructor
025: */
026: public PropertiesPageUtil(String projectName) {
027: super ();
028: this .projectName = projectName;
029: }
030:
031: /**
032: * fetch the mappings of the Annotations
033: * property sheet page.
034: * This is just a dummy method
035: * @return
036: */
037: public Object[] getAnnotationProperties() {
038: return null;
039: // FIXME "Preferences Sheet Page Workaround"
040: }
041:
042: /**
043: * get the program actions
044: */
045: public Vector<ProgramAnnotationAction> getProgramActions() {
046: return actions;
047: }
048:
049: /**
050: * create actions for each program
051: */
052: public Vector<ProgramAnnotationAction> createProgramActions(
053: IStructuredSelection structuredSelection) {
054: // get the editormappings of the property sheet page
055: //Object[] mappings = getAnnotationProperties();
056:
057: //***************************************************************
058: // in the first release "MS Word", "MS Excel" are set as default
059: if (structuredSelection == null)
060: return null;
061: // create a MS Word Action
062: ProgramAnnotationAction wordAction = createMSWordAction(structuredSelection);
063: actions.add(wordAction);
064:
065: // create a MS Excel Action
066: ProgramAnnotationAction excelAction = createMSExcelAction(structuredSelection);
067: actions.add(excelAction);
068: //***************************************************************
069: return actions;
070: // FIXME "Preferences Sheet Page Workaround"
071: }
072:
073: /**
074: * Create a MS Word Action
075: * This method is a workaound
076: */
077: private ProgramAnnotationAction createMSWordAction(
078: IStructuredSelection structuredSelection) {
079: String text = "New " + AnnotationTypes.MSWORD + "...";
080: ImageDescriptor wordImage = PlatformUI.getWorkbench()
081: .getSharedImages().getImageDescriptor(
082: AnnotationTypes.MSWORD_ICON_PATH);
083: ProgramAnnotationAction wordAction = new ProgramAnnotationAction(
084: text, wordImage, structuredSelection, projectName);
085: return wordAction;
086: // FIXME "Preferences Sheet Page Workaround"
087: }
088:
089: /**
090: * Create a MS Excel Action
091: * This method is a workaound
092: */
093: private ProgramAnnotationAction createMSExcelAction(
094: IStructuredSelection structuredSelection) {
095: String text = "New " + AnnotationTypes.MSEXCEL + "...";
096: ImageDescriptor excelImage = PlatformUI.getWorkbench()
097: .getSharedImages().getImageDescriptor(
098: AnnotationTypes.MSEXCEL_ICON_PATH);
099: ProgramAnnotationAction excelAction = new ProgramAnnotationAction(
100: text, excelImage, structuredSelection, projectName);
101: return excelAction;
102: // FIXME "Preferences Sheet Page Workaround"
103: }
104: }
|