|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 package com.symbian.smt.gui.properties; |
|
19 |
|
20 import org.eclipse.core.resources.IProject; |
|
21 import org.eclipse.core.resources.ProjectScope; |
|
22 import org.eclipse.core.runtime.preferences.DefaultScope; |
|
23 import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
|
24 import org.eclipse.core.runtime.preferences.IScopeContext; |
|
25 import org.eclipse.core.runtime.preferences.InstanceScope; |
|
26 import org.eclipse.swt.SWT; |
|
27 import org.eclipse.swt.layout.FillLayout; |
|
28 import org.eclipse.swt.widgets.Composite; |
|
29 import org.eclipse.swt.widgets.Control; |
|
30 import org.eclipse.ui.IWorkbenchPropertyPage; |
|
31 import org.eclipse.ui.dialogs.PropertyPage; |
|
32 |
|
33 import com.symbian.smt.gui.Activator; |
|
34 import com.symbian.smt.gui.NodeListener; |
|
35 import com.symbian.smt.gui.PersistentDataStore; |
|
36 import com.symbian.smt.gui.smtwidgets.AdvancedOptionsWidget; |
|
37 |
|
38 /** |
|
39 * This is the PropertyPage that handles the advanced command line options. It |
|
40 * creates and presents the AdvancedOptionsWidget. |
|
41 * |
|
42 * @author barbararosi-schwartz |
|
43 */ |
|
44 public class AdvancedOptionsProperties extends PropertyPage implements |
|
45 IWorkbenchPropertyPage { |
|
46 |
|
47 private AdvancedOptionsWidget advancedOptionsWidget; |
|
48 private PersistentDataStore projectStore; |
|
49 private PersistentDataStore instanceStore; |
|
50 |
|
51 @Override |
|
52 protected Control createContents(Composite parent) { |
|
53 new NodeListener(getProject()); |
|
54 |
|
55 // Create the project scope data store |
|
56 IScopeContext projectScope = new ProjectScope(this.getProject()); |
|
57 projectStore = new PersistentDataStore(projectScope |
|
58 .getNode(Activator.PLUGIN_ID)); |
|
59 |
|
60 // Create the default scope data store |
|
61 IScopeContext defaultScope = new DefaultScope(); |
|
62 IEclipsePreferences defaultNode = defaultScope |
|
63 .getNode(Activator.PLUGIN_ID); |
|
64 |
|
65 IScopeContext instanceScope = new InstanceScope(); |
|
66 IEclipsePreferences instanceNode = instanceScope |
|
67 .getNode(Activator.PLUGIN_ID); |
|
68 |
|
69 instanceStore = new PersistentDataStore(instanceNode, defaultNode); |
|
70 |
|
71 // Create the widget |
|
72 Composite composite = new Composite(parent, SWT.NONE); |
|
73 composite.setLayout(new FillLayout(SWT.VERTICAL)); |
|
74 advancedOptionsWidget = new AdvancedOptionsWidget(composite, SWT.NONE); |
|
75 |
|
76 // Set required values |
|
77 populate(projectStore); |
|
78 |
|
79 return composite; |
|
80 } |
|
81 |
|
82 private IProject getProject() { |
|
83 return (IProject) getElement(); |
|
84 } |
|
85 |
|
86 @Override |
|
87 protected void performApply() { |
|
88 saveChanges(); |
|
89 } |
|
90 |
|
91 @Override |
|
92 protected void performDefaults() { |
|
93 populate(instanceStore); |
|
94 } |
|
95 |
|
96 @Override |
|
97 public boolean performOk() { |
|
98 saveChanges(); |
|
99 return super.performOk(); |
|
100 } |
|
101 |
|
102 private void populate(PersistentDataStore dataStore) { |
|
103 advancedOptionsWidget |
|
104 .setAdvancedOptions(dataStore.getAdvancedOptions()); |
|
105 } |
|
106 |
|
107 private void saveChanges() { |
|
108 projectStore.setAdvancedOptions(advancedOptionsWidget |
|
109 .getAdvancedOptions()); |
|
110 } |
|
111 |
|
112 } |