source: rtems-eclipse-plug-in/org.rtems.cdt/src/org/rtems/cdt/wizards/BasicSetup.java @ e7c1ecb

Last change on this file since e7c1ecb was e7c1ecb, checked in by Sebastian Huber <sebastian.huber@…>, on 12/08/09 at 12:52:32

2009-12-08 Sebastian Huber <sebastian.huber@…>

  • src/org/rtems/cdt/Activator.java, src/org/rtems/cdt/Constants.java, src/org/rtems/cdt/Storage.java, src/org/rtems/cdt/VolatilePreferenceStore.java, src/org/rtems/cdt/build/CommandLineGenerator.java, src/org/rtems/cdt/build/CygwinScannerInfoCollector.java, src/org/rtems/cdt/build/EnvironmentSupplier.java, src/org/rtems/cdt/build/RunScannerInfoProvider.java, src/org/rtems/cdt/preferences/PreferenceInitializer.java, src/org/rtems/cdt/preferences/PreferencePage.java, src/org/rtems/cdt/properties/PropertyPage.java, src/org/rtems/cdt/wizards/BasicSetup.java, src/org/rtems/cdt/wizards/FinishSetup.java: Replaced '( ' with '('.
  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*
2 * Copyright (c) 2008 Embedded Brains GmbH and others.
3 *
4 *   Embedded Brains GmbH
5 *   Obere Lagerstr. 30
6 *   D-82178 Puchheim
7 *   Germany
8 *   rtems@embedded-brains.de
9 *
10 * All rights reserved.  This program and the accompanying materials are made
11 * available under the terms of the Eclipse Public License Version 1.0 ("EPL")
12 * which accompanies this distribution and is available at
13 *
14 *   http://www.eclipse.org/legal/epl-v10.html
15 *
16 * For purposes of the EPL, "Program" will mean the Content.
17 *
18 * Contributors:
19 *
20 *   Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation.
21 */
22
23package org.rtems.cdt.wizards;
24
25import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage;
26import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
27import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
28import org.eclipse.core.resources.IProject;
29import org.eclipse.jface.resource.ImageDescriptor;
30import org.eclipse.swt.events.ModifyEvent;
31import org.eclipse.swt.events.ModifyListener;
32import org.eclipse.swt.events.SelectionAdapter;
33import org.eclipse.swt.events.SelectionEvent;
34import org.eclipse.swt.graphics.Image;
35import org.eclipse.swt.layout.GridData;
36import org.eclipse.swt.layout.GridLayout;
37import org.eclipse.swt.widgets.Button;
38import org.eclipse.swt.widgets.Composite;
39import org.eclipse.swt.widgets.Control;
40import org.eclipse.swt.widgets.DirectoryDialog;
41import org.eclipse.swt.widgets.Label;
42import org.eclipse.swt.widgets.Text;
43import org.eclipse.swt.SWT;
44import org.rtems.cdt.Constants;
45import org.rtems.cdt.Storage;
46
47public class BasicSetup extends MBSCustomPage {
48        public static final String PAGE_ID = "org.rtems.cdt.wizards.BasicSetup";
49
50        public static final String BROWSE = " &Browse... ";
51
52        private Composite mComposite;
53
54        private Text mBasePath;
55
56        private Text mBSPPath;
57
58        public BasicSetup() {
59                pageID = PAGE_ID;
60        }
61
62        public boolean canFlipToNextPage() {
63                return MBSCustomPageManager.getNextPage(pageID) != null;
64        }
65
66        public String getName() {
67                return "Basic Setup Page";
68        }
69
70        public void createControl(Composite parent) {
71                // Create base widget
72                mComposite = new Composite(parent, SWT.NONE);
73
74                GridData gd = new GridData(GridData.FILL_BOTH);
75                mComposite.setLayoutData(gd);
76
77                GridLayout layout = new GridLayout();
78                layout.numColumns = 3;
79                mComposite.setLayout(layout);
80
81                // Base path
82                Label label = new Label(mComposite, SWT.LEFT);
83                label.setText("Base path:");
84
85                mBasePath = new Text(mComposite, SWT.LEFT | SWT.BORDER);
86                gd = new GridData(GridData.FILL_HORIZONTAL);
87                mBasePath.setLayoutData(gd);
88
89                Button button = new Button(mComposite, SWT.PUSH);
90                button.setText(BROWSE);
91                button.addSelectionListener(
92                        new SelectionAdapter() {
93                                public void widgetSelected(SelectionEvent e) {
94                                        browseForPath(mBasePath);
95                                }
96                        }
97                );
98
99                // BSP path
100                label = new Label(mComposite, SWT.LEFT);
101                label.setText("BSP path:");
102
103                mBSPPath = new Text(mComposite, SWT.LEFT | SWT.BORDER);
104                gd = new GridData(GridData.FILL_HORIZONTAL);
105                mBSPPath.setLayoutData(gd);
106
107                button = new Button(mComposite, SWT.PUSH);
108                button.setText(BROWSE);
109                button.addSelectionListener(
110                        new SelectionAdapter() {
111                                public void widgetSelected(SelectionEvent e) {
112                                        browseForPath(mBSPPath);
113                                }
114                        }
115                );
116
117                // Connect user input
118                mBasePath.addModifyListener(
119                        new ModifyListener() {
120                                public void modifyText(ModifyEvent e) {
121                                        basePathChanged();
122                                }
123                        }
124                );
125                mBSPPath.addModifyListener(
126                        new ModifyListener() {
127                                public void modifyText(ModifyEvent e) {
128                                        bspPathChanged();
129                                }
130                        }
131                );
132
133                // Trigger initial setup
134                basePathChanged();
135                bspPathChanged();
136        }
137
138        public void dispose() {
139                mComposite.dispose();
140        }
141
142        public Control getControl() {
143                return mComposite;
144        }
145
146        public String getDescription() {
147                return "Select the RTEMS base installation path and the board support package (BSP) installation path.";
148        }
149
150        public String getErrorMessage() {
151                return null;
152        }
153
154        public Image getImage() {
155                return wizard.getDefaultPageImage();
156        }
157
158        public String getMessage() {
159                return null;
160        }
161
162        public String getTitle() {
163                return "RTEMS Setup";
164        }
165
166        public void performHelp() {
167                // Do nothing
168        }
169
170        public void setDescription(String description) {
171                // Do nothing
172        }
173
174        public void setImageDescriptor(ImageDescriptor image) {
175                // Do nothing
176        }
177
178        public void setTitle(String title) {
179                // Do nothing
180        }
181
182        public void setVisible(boolean visible) {
183                // Get current project
184                CDTCommonProjectWizard wizard = (CDTCommonProjectWizard) getWizard();
185                IProject project = wizard.getLastProject();
186
187                /*
188                 *  Here we have to take care about the synchronization between the wizard
189                 *  and the properties of the new project (advanced settings dialog).
190                 */
191                if (visible) {
192                        if (project != null) {
193                                // For already created projects use the properties
194                                mBasePath.setText(Storage.getProperty(project, Constants.BASE_PATH_KEY));
195                                mBSPPath.setText(Storage.getProperty(project, Constants.BSP_PATH_KEY));
196                        } else {
197                                // For not yet created projects use the preferences
198                                mBasePath.setText(Storage.getPreference(Constants.BASE_PATH_KEY));
199                                mBSPPath.setText(Storage.getPreference(Constants.BSP_PATH_KEY));
200                        }
201                } else {
202                        if (project != null) {
203                                // Store the wizard values in the properties if the project exists already
204                                Storage.setProperty(project, Constants.BASE_PATH_KEY, mBasePath.getText());
205                                Storage.setProperty(project, Constants.BSP_PATH_KEY, mBSPPath.getText());
206                        }
207                }
208
209                mComposite.setVisible(visible);
210        }
211
212        protected boolean isCustomPageComplete() {
213                return true;
214        }
215
216        private void browseForPath(Text text) {
217                DirectoryDialog dialog = new DirectoryDialog(mComposite.getShell(), SWT.NONE);
218                dialog.setFilterPath(text.getText());
219                String path = dialog.open();
220                if (path != null) {
221                        text.setText(path);
222                }
223        }
224
225        private void basePathChanged() {
226                MBSCustomPageManager.addPageProperty(pageID, Constants.BASE_PATH_KEY, mBasePath.getText());
227        }
228
229        private void bspPathChanged() {
230                MBSCustomPageManager.addPageProperty(pageID, Constants.BSP_PATH_KEY, mBSPPath.getText());
231        }
232}
Note: See TracBrowser for help on using the repository browser.