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.Interface;
32  import org.wsmo.service.choreography.Choreography;
33  import org.wsmo.service.choreography.rule.ChoreographyRules;
34  import org.wsmostudio.choreography.ChoreographyPlugin;
35  import org.wsmostudio.runtime.WSMORuntime;
36  import org.wsmostudio.ui.*;
37  import org.wsmostudio.ui.editors.model.ObservableModel;
38  import org.wsmostudio.ui.views.navigator.actions.AbstractAction;
39  
40  public class CreateChoreography extends AbstractAction {
41  
42      public void run() {
43          
44          Interface iface = (Interface)
45              ((IStructuredSelection)navigator.getTree().getSelection())
46                  .getFirstElement();
47          
48          if (iface.getChoreography() != null) {
49              MessageDialog.openWarning(navigator.getSite().getShell(),
50                      "Incorrect Usage",
51                      "The selected interface already has a choreography set!");
52              return;
53          }
54          
55          ObservableModel uiModel = 
56              (ObservableModel)navigator.getWsmoInput().getAdapter(ObservableModel.class);
57          
58          IdentifierInputDialog iriInputDialog = new IdentifierInputDialog(
59                  navigator.getSite().getShell(),
60                  "New Choreography",
61                  "New Choreography Identifier (leave blank for anonymous):",
62                  Utils.findTopContainer(uiModel),
63                  WSMORuntime.getRuntime().getWsmoFactory(),
64                  true);
65          if (iriInputDialog.open() != Dialog.OK) {
66              return;
67          }
68          Identifier chorID = (Identifier)iriInputDialog.getIdentifier();
69          ChoreographyFactory fact = ChoreographyPlugin.getFactory();
70          Choreography chor = fact.containers.createChoreography(chorID);
71          ChoreographyRules rules = fact.containers.createRules(
72                  WSMORuntime.getRuntime().getWsmoFactory().createAnonymousID());
73          chor.setRules(rules);
74          iface.setChoreography(chor);
75          
76          uiModel.setChanged();
77          navigator.fireEntityChanged(iface);
78          navigator.getTree().refresh(iface);
79          navigator.getTree().setExpandedState(iface, true);
80      }
81  }
82  
83  /*
84   * $Log$
85   * Revision 1.8  2006/11/22 14:11:08  alex_simov
86   * Code refactoring: the plug-in is synchronized with the latest wsmo4j changes
87   *
88   * Revision 1.7  2006/04/18 07:35:38  alex_simov
89   * new choreographies are now created by specifying only one IRI (instead of
90   * requiring additional identifiers for StateSignature and RulesContainer)
91   *
92   * Revision 1.6  2006/01/20 16:29:32  alex_simov
93   * a new spacialized IRI input dialog introduced
94   *
95   * Revision 1.5  2006/01/09 12:51:11  alex_simov
96   * Copyright message in header updated
97   *
98   * Revision 1.4  2005/12/21 15:25:35  alex_simov
99   * choreography managment implementation completed
100  *
101  * Revision 1.3  2005/12/21 09:50:18  alex_simov
102  * unused imports removed
103  *
104  * Revision 1.2  2005/12/16 12:47:32  alex_simov
105  * Plugin activator contains a shared ChoreographyFactory instance
106  *
107  * Revision 1.1  2005/11/17 16:09:58  alex_simov
108  * new navigator actions
109  *
110  */