View Javadoc

1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2008, Ontotext Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  /***
19   * <p>Title: WSMO Studio</p>
20   * <p>Description: Semantic Web Service Editor</p>
21   * <p>Copyright:  Copyright (c) 2004-2008</p>
22   * <p>Company: Ontotext Lab. / SIRMA </p>
23   */
24  
25  package org.wsmostudio.bpmo.ui.actions;
26  
27  import org.eclipse.jface.resource.ImageDescriptor;
28  import org.wsmostudio.bpmo.ui.editor.BpmoEditor;
29  
30  public class ActionExtensionDescriptor {
31  
32      
33      private BpmoActionProvider factory;
34      private String actionID, label, tooltip;
35      
36      private ImageDescriptor icon, disabledIcon;
37      
38      @SuppressWarnings("unused")
39      private ActionExtensionDescriptor() {
40      } // no descriptors without id and factory
41      
42      public ActionExtensionDescriptor(String id, BpmoActionProvider _factory) {
43          this.actionID = id;
44          this.factory = _factory;
45      }
46      
47      public void setLabel(String lab) {
48          this.label = lab;
49      }
50  
51      public String getTooltipText() {
52          return this.tooltip;
53      }
54      public void setTooltipText(String tooltip) {
55          this.tooltip = tooltip;
56      }
57  
58      public ImageDescriptor getIconDescriptor() {
59          return this.icon;
60      }
61      public void setIconDescriptor(ImageDescriptor imageDescr) {
62          this.icon = imageDescr;
63      }
64  
65      public ImageDescriptor getDisabledIconDescriptor() {
66          return this.disabledIcon;
67      }
68      public void setDisabledIconDescriptor(ImageDescriptor imageDescr) {
69          this.disabledIcon = imageDescr;
70      }
71      
72      public AbstractDiagramAction createAction(BpmoEditor editor) {
73          
74          AbstractDiagramAction actionHandler = factory.createAction(editor);
75          actionHandler.setId(actionID);
76          actionHandler.setText(
77                  (label != null && label.trim().length() >= 0) ? label : actionID);
78          if (tooltip != null 
79                  && tooltip.length() > 0) {
80              actionHandler.setToolTipText(tooltip);
81          }
82          if (icon != null) {
83              actionHandler.setImageDescriptor(icon);
84          }
85          if (disabledIcon != null) {
86              actionHandler.setDisabledImageDescriptor(disabledIcon);
87          }
88          return actionHandler;
89      }
90      
91  }