View Javadoc

1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2006, 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-2006</p>
22   * <p>Company: OntoText Lab. / SIRMA </p>
23   */
24  
25  package org.wsmostudio.choreography.navigator.actions;
26  
27  import org.eclipse.jface.dialogs.*;
28  import org.eclipse.jface.viewers.IStructuredSelection;
29  import org.wsmo.common.Identifier;
30  import org.wsmo.factory.ChoreographyFactory;
31  import org.wsmo.service.choreography.Choreography;
32  import org.wsmo.service.signature.StateSignature;
33  import org.wsmostudio.choreography.ChoreographyPlugin;
34  import org.wsmostudio.runtime.WSMORuntime;
35  import org.wsmostudio.ui.*;
36  import org.wsmostudio.ui.editors.model.ObservableModel;
37  import org.wsmostudio.ui.views.navigator.actions.AbstractAction;
38  
39  public class CreateStateSignatureAction extends AbstractAction {
40  
41      public void run() {
42          
43          Choreography chor = (Choreography)
44              ((IStructuredSelection)navigator.getTree().getSelection())
45                  .getFirstElement();
46          
47          if (chor.getStateSignature() != null) {
48              MessageDialog.openWarning(navigator.getSite().getShell(),
49                      "Incorrect Usage",
50                      "The selected choreography already has a state signature set!");
51              return;
52          }
53          
54          ObservableModel uiModel = 
55              (ObservableModel)navigator.getWsmoInput().getAdapter(ObservableModel.class);
56          
57          IdentifierInputDialog iriInputDialog = new IdentifierInputDialog(
58                  navigator.getSite().getShell(),
59                  "New State Signature",
60                  "New State Signature Identifier (leave blank for anonymous): ",
61                  Utils.findTopContainer(uiModel),
62                  WSMORuntime.getRuntime().getWsmoFactory(),
63                  true);
64          if (iriInputDialog.open() != Dialog.OK) {
65              return;
66          }
67          Identifier sSigID = iriInputDialog.getIdentifier();
68          ChoreographyFactory fact = ChoreographyPlugin.getFactory();
69          StateSignature sSig = fact.containers.createStateSignature(sSigID);
70  
71          chor.setStateSignature(sSig);
72          
73          uiModel.setChanged();
74          navigator.fireEntityChanged(chor);
75          navigator.getTree().refresh(chor);
76          navigator.getTree().setExpandedState(chor, true);
77      }
78  }
79  
80  /*
81   * $Log$
82   * Revision 1.2  2006/11/22 14:11:08  alex_simov
83   * Code refactoring: the plug-in is synchronized with the latest wsmo4j changes
84   *
85   * Revision 1.1  2006/04/18 07:28:24  alex_simov
86   * new context menu actions added in WSMO Navigator for choreographies:
87   * - Create / Remove State Siganture
88   * - Create / Remove Rules Container
89   *
90   */