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.grounding.sawsdl.preferences;
26  
27  import org.eclipse.jface.preference.PreferencePage;
28  import org.eclipse.swt.SWT;
29  import org.eclipse.swt.layout.GridData;
30  import org.eclipse.swt.layout.GridLayout;
31  import org.eclipse.swt.widgets.Button;
32  import org.eclipse.swt.widgets.Composite;
33  import org.eclipse.swt.widgets.Control;
34  import org.eclipse.swt.widgets.Group;
35  import org.eclipse.ui.*;
36  import org.wsmostudio.grounding.sawsdl.ui.UiPlugin;
37  import org.wsmostudio.grounding.sawsdl.ui.editor.WSDLSEditor;
38  
39  
40  public class SAWSDLPrefsPage extends PreferencePage 
41  implements IWorkbenchPreferencePage {
42  
43      
44      private Button enableWSDL11SupportButton;
45      private Button showLocalIRIsButton;
46      
47      protected Control createContents(Composite parent) {
48          final Group mainPanel = new Group(parent, SWT.NONE);
49          mainPanel.setText("WSDL Annotation");
50          mainPanel.setLayout(new GridLayout(1, false));
51          
52          enableWSDL11SupportButton = new Button(mainPanel, SWT.CHECK);
53          enableWSDL11SupportButton.setSelection(UiPlugin.hasWSDL11Support());
54          enableWSDL11SupportButton.setText("Enable WSDL 1.1 Support");
55          enableWSDL11SupportButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
56  
57          showLocalIRIsButton = new Button(mainPanel, SWT.CHECK);
58          showLocalIRIsButton.setSelection(UiPlugin.isShowingLocalNames());
59          showLocalIRIsButton.setText("Show local reference names in tree");
60          showLocalIRIsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61  
62          return mainPanel;
63      }
64      
65      public void init(IWorkbench workbench) {
66      }
67      
68      protected void performDefaults() {
69      	enableWSDL11SupportButton.setSelection(false);
70          showLocalIRIsButton.setSelection(false);
71      }
72      
73      public boolean performOk() {
74      	UiPlugin.setWSDL11Support(enableWSDL11SupportButton.getSelection());
75          UiPlugin.setIsShowingLocalNames(showLocalIRIsButton.getSelection());
76          doUpdateOpenedEditors();
77          return super.performOk();
78      }
79      
80      private void doUpdateOpenedEditors() {
81  
82          IWorkbenchPage page = PlatformUI.getWorkbench()
83                                          .getActiveWorkbenchWindow()
84                                          .getActivePage();
85          if (page == null) {
86              return;
87          }
88          IEditorReference[] editors = page.getEditorReferences();
89          if (editors == null) {
90              return;
91          }
92          for(int i = 0; i < editors.length; i++) {
93              IEditorPart editor = editors[i].getEditor(true);
94              if (editor != null 
95                      && editor instanceof WSDLSEditor) {
96                  ((WSDLSEditor)editor).getUITree().refresh(true);
97              }
98          }
99      }
100 
101 }
102 
103 /*
104  * $Log$
105  * Revision 1.3  2007/04/21 13:48:01  alex_simov
106  * The changes on the preference page are reflected on all opened editors
107  *
108  * Revision 1.2  2006/10/12 16:23:36  alex_simov
109  * showing full/local model references made optional making SAWSDL
110  * editor content cleaner
111  *
112  * Revision 1.1  2006/07/19 11:27:40  alex_simov
113  * WSDL 1.1 annotation support added (this option is controlled by preference
114  *  pages)
115  *
116  */