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.viewers.*;
28  import org.omwg.ontology.*;
29  import org.wsmo.service.choreography.Choreography;
30  import org.wsmo.service.signature.*;
31  import org.wsmostudio.runtime.*;
32  import org.wsmostudio.ui.editors.common.WSMOChooser;
33  import org.wsmostudio.ui.editors.model.*;
34  import org.wsmostudio.ui.views.navigator.actions.AbstractAction;
35  
36  public abstract class AddModeAction extends AbstractAction {
37  
38      public void run() {
39          StateSignature selected = (StateSignature)
40              ((IStructuredSelection)navigator.getTree().getSelection()).getFirstElement();
41          Choreography chor = (Choreography)
42              navigator.getTree().getTree().getSelection()[0].getParentItem().getData();
43          
44          ObservableModel uiModel = 
45              (ObservableModel)navigator.getWsmoInput().getAdapter(ObservableModel.class);
46          
47          WSMOChooser chooser = WSMOChooser.createConceptChooser(
48                  navigator.getTree().getTree().getShell(), 
49                  WSMORuntime.getRuntime());
50  
51          Concept newConcept = (Concept)chooser.open();
52          if (newConcept == null) {
53              return;
54          }
55          Mode newMode = createMode(newConcept);
56          selected.addMode(newMode);
57          uiModel.setChanged();
58          navigator.fireEntityChanged(chor);
59          navigator.fireEntityChanged(selected);
60          navigator.getTree().refresh(selected);
61          navigator.getTree().setExpandedState(selected, true);
62      }
63      
64      protected abstract Mode createMode(Concept target);
65  }
66  
67  /*
68   * $Log$
69   * Revision 1.3  2006/11/22 14:11:08  alex_simov
70   * Code refactoring: the plug-in is synchronized with the latest wsmo4j changes
71   *
72   * Revision 1.2  2006/01/09 12:51:11  alex_simov
73   * Copyright message in header updated
74   *
75   * Revision 1.1  2005/11/16 16:23:31  alex_simov
76   * new WSMO navigator actions for StateSignature objects
77   *
78   *
79   */