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.preferences;
26  
27  import org.eclipse.jface.preference.*;
28  import org.eclipse.swt.SWT;
29  import org.eclipse.swt.events.*;
30  import org.eclipse.swt.layout.*;
31  import org.eclipse.swt.widgets.*;
32  import org.eclipse.ui.*;
33  import org.wsmostudio.runtime.*;
34  import org.wsmostudio.runtime.io.WorkspaceIOManager;
35  
36  /***
37   * The main preference page for the WSMO Studio.
38   *
39   * @author not attributable
40   * @version $Revision: 1420 $ $Date: 2008-01-29 19:46:27 +0200 $
41   */
42  
43  public class WSMOMainPage extends PreferencePage implements IWorkbenchPreferencePage {
44  
45      public static final String PREF_USE_IRI_FULL_NAME = "useIRIFullName";
46      public static final String PREF_USE_SLASH_SEP = "useSlashSep";
47      public static final String PREF_USE_IRI_LOCAL_NAME_IN_NAVI = "useIRILocNameInNavi";
48  
49      public static final String PREF_LOAD_IMPORTS = "loadImportsMode";
50  
51      private Button enableValidatorCheck, validateImportsCheck;
52      
53      private boolean useFullIRI = true;
54      private boolean useSlashSep = false;
55      private boolean useLocalInNavi = true;
56      
57      private byte importsLoadingMode = 0;
58      
59      protected Control createContents(Composite parent) {
60          Label headerLab = new Label(parent, SWT.NONE);
61          headerLab.setText("WSMO Studio Preferences");
62          
63          createIRIOptionsPanel(parent);
64  
65          Group validatorGroup = new Group(parent, SWT.NONE);
66          validatorGroup.setText("WSML Validator");
67          validatorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
68          validatorGroup.setLayout(new GridLayout(2, false));
69          
70          enableValidatorCheck = new Button(validatorGroup, SWT.CHECK);
71          enableValidatorCheck.setText("Enable WSML Validator on Save/Load");
72          
73          enableValidatorCheck.setSelection(
74                  false == RuntimePlugin.getDefault().getPreferenceStore().getBoolean(
75                          WorkspaceIOManager.DISABLE_VALIDATOR_PROPERTY));
76          enableValidatorCheck.addSelectionListener(new SelectionAdapter() {
77              public void widgetSelected(SelectionEvent event) {
78                  validateImportsCheck.setEnabled(enableValidatorCheck.getSelection());
79              }
80          });
81          GridData gd = new GridData(GridData.FILL_HORIZONTAL);
82          gd.horizontalSpan = 2;
83          enableValidatorCheck.setLayoutData(gd);
84          
85          new Label(validatorGroup, SWT.NONE).setText("             ");
86          validateImportsCheck = new Button(validatorGroup, SWT.CHECK);
87          validateImportsCheck.setText("Validate Imports");
88          validateImportsCheck.setSelection(
89                          RuntimePlugin.getDefault().getPreferenceStore().getBoolean(
90                          WorkspaceIOManager.VALIDATE_IMPORTS_PROPERTY));
91          validateImportsCheck.setEnabled(enableValidatorCheck.getSelection());
92          
93          createImportsOptionsPanel(parent);
94          
95          new Label(parent, SWT.NONE).setLayoutData(new GridData(GridData.FILL_BOTH));
96          return headerLab;
97      }
98      
99      public void init(IWorkbench workbench) {
100     }
101     
102     public boolean performOk() {
103         IPreferenceStore store = RuntimePlugin.getDefault().getPreferenceStore();
104         
105         store.setValue(WorkspaceIOManager.DISABLE_VALIDATOR_PROPERTY, 
106                        false == enableValidatorCheck.getSelection());
107         boolean needsValidatorReinit = 
108             RuntimePlugin.getDefault().getPreferenceStore().getBoolean(
109                 WorkspaceIOManager.VALIDATE_IMPORTS_PROPERTY) 
110             != validateImportsCheck.getSelection();
111         
112         if (needsValidatorReinit) {
113             store.setValue(WorkspaceIOManager.VALIDATE_IMPORTS_PROPERTY, 
114                            validateImportsCheck.getSelection());
115             WSMORuntime.getRuntime().reinitWsmlValidator();
116         }
117         store.setValue(PREF_USE_IRI_FULL_NAME, useFullIRI);
118         store.setValue(PREF_USE_SLASH_SEP, useSlashSep);
119         store.setValue(PREF_USE_IRI_LOCAL_NAME_IN_NAVI, useLocalInNavi);
120         
121         store.setValue(PREF_LOAD_IMPORTS, this.importsLoadingMode);
122         return super.performOk();
123     }
124 
125     public void dispose() {
126         enableValidatorCheck.dispose();
127         super.dispose();
128     }
129     
130     private Group createIRIOptionsPanel(Composite comp) {
131 
132         useFullIRI = RuntimePlugin.getDefault().getPreferenceStore().getBoolean(PREF_USE_IRI_FULL_NAME);
133         useSlashSep = RuntimePlugin.getDefault().getPreferenceStore().getBoolean(PREF_USE_SLASH_SEP);
134         useLocalInNavi = RuntimePlugin.getDefault().getPreferenceStore().getBoolean(PREF_USE_IRI_LOCAL_NAME_IN_NAVI);
135         
136         
137         Group iriGroup = new Group(comp, SWT.NONE);
138         iriGroup.setText("IRI Visualization");
139         iriGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
140         iriGroup.setLayout(new GridLayout(3, false));
141         
142         final Button useLocalB = new Button(iriGroup, SWT.RADIO);
143         useLocalB.setText("Show local names using delimiter : ");
144         useLocalB.setSelection(false == useFullIRI);
145         
146         Button sepHashB = new Button(iriGroup, SWT.CHECK);
147         sepHashB.setText(" # (hash)");
148         sepHashB.setSelection(true);
149         sepHashB.setEnabled(false);
150 
151         final Button sepSlashB = new Button(iriGroup, SWT.CHECK);
152         sepSlashB.setText(" / (slash)");
153         sepSlashB.setSelection(useSlashSep);
154         sepSlashB.setEnabled(false == useFullIRI);
155         sepSlashB.addSelectionListener(new SelectionAdapter() {
156             public void widgetSelected(SelectionEvent e) {
157                 useSlashSep = sepSlashB.getSelection();
158             }
159         });
160         
161         Button useFullB = new Button(iriGroup, SWT.RADIO);
162         useFullB.setText("Show Full Identifiers");
163         useFullB.setSelection(useFullIRI);
164 
165         final Button disableInNavB = new Button(iriGroup, SWT.CHECK);
166         disableInNavB.setText("Disable in WSMO Navigator");
167         disableInNavB.setSelection(useLocalInNavi);
168         disableInNavB.setEnabled(useFullIRI);
169         disableInNavB.addSelectionListener(new SelectionAdapter() {
170             public void widgetSelected(SelectionEvent e) {
171                 useLocalInNavi = disableInNavB.getSelection();
172             }
173         });
174         GridData gData = new GridData();
175         gData.horizontalSpan = 2;
176         disableInNavB.setLayoutData(gData);
177         
178         useLocalB.addSelectionListener(new SelectionAdapter() {
179             public void widgetSelected(SelectionEvent e) {
180                 useFullIRI = false == useLocalB.getSelection();
181                 disableInNavB.setEnabled(useFullIRI);
182                 sepSlashB.setEnabled(useFullIRI == false);
183             }
184         });
185 
186         return iriGroup;
187     }
188 
189     private Group createImportsOptionsPanel(Composite comp) {
190 
191         importsLoadingMode = (byte)
192             RuntimePlugin.getDefault().getPreferenceStore().getInt(PREF_LOAD_IMPORTS);
193         
194         Group importsGroup = new Group(comp, SWT.NONE);
195         importsGroup.setText("Imported Ontologies Policy");
196         importsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
197         importsGroup.setLayout(new GridLayout(1, false));
198         
199         Button alwaysLoadB = new Button(importsGroup, SWT.RADIO);
200         alwaysLoadB.setText("Always load imported ontologies automatically");
201         alwaysLoadB.setSelection(importsLoadingMode == WorkspaceLocator.ALWAYS_LOAD_IMPORTS);
202         alwaysLoadB.addSelectionListener(new SelectionAdapter() {
203             public void widgetSelected(SelectionEvent event) {
204                 importsLoadingMode = WorkspaceLocator.ALWAYS_LOAD_IMPORTS;
205             }
206         });
207         
208         Button promptBeforeLoadB = new Button(importsGroup, SWT.RADIO);
209         promptBeforeLoadB.setText("Prompt before loading imported ontologies");
210         promptBeforeLoadB.setSelection(importsLoadingMode == WorkspaceLocator.PROMPT_FOR_LOADING_IMPORTS);
211         promptBeforeLoadB.addSelectionListener(new SelectionAdapter() {
212             public void widgetSelected(SelectionEvent event) {
213                 importsLoadingMode = WorkspaceLocator.PROMPT_FOR_LOADING_IMPORTS;
214             }
215         });
216 
217         Button neverLoadB = new Button(importsGroup, SWT.RADIO);
218         neverLoadB.setText("Ignore imported ontologies part");
219         neverLoadB.setSelection(importsLoadingMode == WorkspaceLocator.NEVER_LOAD_IMPORTS);
220         neverLoadB.addSelectionListener(new SelectionAdapter() {
221             public void widgetSelected(SelectionEvent event) {
222                 importsLoadingMode = WorkspaceLocator.NEVER_LOAD_IMPORTS;
223             }
224         });
225         return importsGroup;
226     }
227 
228     
229 }
230 
231 /*
232  * $Log$
233  * Revision 1.4  2006/05/25 09:21:27  alex_simov
234  * New preferences options added allowing IRI vizualization customization
235  *  related to showing full/local names in the UI components
236  *
237  * Revision 1.3  2006/01/09 12:51:12  alex_simov
238  * Copyright message in header updated
239  *
240  * Revision 1.2  2005/12/07 15:36:40  alex_simov
241  * wsml validator enabled to mark invalid resources
242  *
243  * Revision 1.1  2005/08/11 07:59:35  alex_simov
244  * wsmo-api implementation extension point
245  *
246  * Revision 1.2  2005/07/22 14:07:21  alex_simov
247  * added javadoc: class description, footer
248  *
249  */