KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > exports > ProductExportWizardPage


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.wizards.exports;
12
13 import org.eclipse.core.resources.IFile;
14 import org.eclipse.jface.dialogs.Dialog;
15 import org.eclipse.jface.dialogs.IDialogSettings;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.jface.wizard.IWizardPage;
18 import org.eclipse.pde.internal.ui.IHelpContextIds;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.events.SelectionAdapter;
22 import org.eclipse.swt.events.SelectionEvent;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.widgets.Button;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.swt.widgets.Control;
28 import org.eclipse.swt.widgets.Group;
29 import org.eclipse.swt.widgets.Label;
30 import org.eclipse.ui.PlatformUI;
31
32 public class ProductExportWizardPage extends AbstractExportWizardPage {
33     
34     private static final String JavaDoc S_SYNC_PRODUCT = "syncProduct"; //$NON-NLS-1$
35
private static final String JavaDoc S_EXPORT_SOURCE = "exportSource"; //$NON-NLS-1$
36
private static final String JavaDoc S_MULTI_PLATFORM = "multiplatform"; //$NON-NLS-1$
37

38     private Button fSyncButton;
39     private IStructuredSelection fSelection;
40     private ProductDestinationGroup fExportGroup;
41     private ProductConfigurationSection fConfigurationGroup;
42     private Button fExportSource;
43     private Button fMultiPlatform;
44
45     public ProductExportWizardPage(IStructuredSelection selection) {
46         super("productExport"); //$NON-NLS-1$
47
fSelection = selection;
48         setTitle(PDEUIMessages.ProductExportWizardPage_title);
49         setDescription(PDEUIMessages.ProductExportWizardPage_desc);
50     }
51
52     public void createControl(Composite parent) {
53         Composite container = new Composite(parent, SWT.NONE);
54         GridLayout layout = new GridLayout();
55         layout.verticalSpacing = 10;
56         container.setLayout(layout);
57         
58         createConfigurationSection(container);
59         createSynchronizationSection(container);
60         createDestinationSection(container);
61         createOptionsSection(container);
62         
63         initialize();
64         pageChanged();
65         if (getErrorMessage() != null) {
66             setMessage(getErrorMessage());
67             setErrorMessage(null);
68         }
69         setControl(container);
70         hookHelpContext(container);
71         Dialog.applyDialogFont(container);
72         
73         PlatformUI.getWorkbench().getHelpSystem()
74         .setHelp(container, IHelpContextIds.PRODUCT_EXPORT_WIZARD);
75     }
76     
77     private void createConfigurationSection(Composite parent) {
78         fConfigurationGroup = new ProductConfigurationSection(this);
79         fConfigurationGroup.createControl(parent);
80     }
81     
82     private void createSynchronizationSection(Composite parent) {
83         Group group = new Group(parent, SWT.NONE);
84         GridLayout layout = new GridLayout();
85         layout.verticalSpacing = 7;
86         group.setLayout(layout);
87         group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
88         group.setText(PDEUIMessages.ProductExportWizardPage_sync);
89         
90         Label label = new Label(group, SWT.WRAP);
91         label.setText(PDEUIMessages.ProductExportWizardPage_syncText);
92         GridData gd = new GridData(GridData.FILL_HORIZONTAL);
93         gd.widthHint = 400;
94         label.setLayoutData(gd);
95         
96         fSyncButton = new Button(group, SWT.CHECK);
97         fSyncButton.setText(PDEUIMessages.ProductExportWizardPage_syncButton);
98         gd = new GridData();
99         gd.horizontalIndent = 20;
100         fSyncButton.setLayoutData(gd);
101     }
102     
103     private void createDestinationSection(Composite container) {
104         fExportGroup = new ProductDestinationGroup(this);
105         fExportGroup.createControl(container);
106     }
107
108     private void createOptionsSection(Composite container) {
109         Group group = new Group(container, SWT.NONE);
110         group.setText(PDEUIMessages.ProductExportWizardPage_exportOptionsGroup);
111         group.setLayout(new GridLayout());
112         group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
113         
114         fExportSource = new Button(group, SWT.CHECK);
115         fExportSource.setText(PDEUIMessages.ExportWizard_includeSource);
116         
117         if (getWizard().getPages().length > 1) {
118             fMultiPlatform = new Button(group, SWT.CHECK);
119             fMultiPlatform.setText(PDEUIMessages.ExportWizard_multi_platform);
120             fMultiPlatform.addSelectionListener(new SelectionAdapter() {
121                 public void widgetSelected(SelectionEvent e) {
122                     getContainer().updateButtons();
123                 }
124             });
125         }
126     }
127
128     protected void initialize() {
129         IDialogSettings settings = getDialogSettings();
130         fConfigurationGroup.initialize(fSelection, settings);
131         
132         String JavaDoc value = settings.get(S_SYNC_PRODUCT);
133         fSyncButton.setSelection(value == null ? true : settings.getBoolean(S_SYNC_PRODUCT));
134         
135         fExportGroup.initialize(settings, fConfigurationGroup.getProductFile());
136         
137         fExportSource.setSelection(settings.getBoolean(S_EXPORT_SOURCE));
138         if (fMultiPlatform != null)
139             fMultiPlatform.setSelection(settings.getBoolean(S_MULTI_PLATFORM));
140     }
141     
142     protected void updateProductFields() {
143         fExportGroup.updateDestination(fConfigurationGroup.getProductFile());
144     }
145
146     protected void pageChanged() {
147         String JavaDoc error = fConfigurationGroup.validate();
148         if (error == null)
149             error = fExportGroup.validate();
150         setErrorMessage(error);
151         setPageComplete(error == null);
152     }
153     
154     public IWizardPage getNextPage() {
155         return doMultiPlatform() ? getWizard().getNextPage(this) : null;
156     }
157     
158     protected void hookHelpContext(Control control) {
159         PlatformUI.getWorkbench().getHelpSystem().setHelp(control, IHelpContextIds.PRODUCT_EXPORT_WIZARD);
160     }
161     
162     protected void saveSettings(IDialogSettings settings) {
163         fConfigurationGroup.saveSettings(settings);
164         settings.put(S_SYNC_PRODUCT, fSyncButton.getSelection());
165         fExportGroup.saveSettings(settings);
166         settings.put(S_EXPORT_SOURCE, doExportSource());
167         
168         if (fMultiPlatform != null)
169             settings.put(S_MULTI_PLATFORM, fMultiPlatform.getSelection());
170     }
171
172     protected boolean doSync() {
173         return fSyncButton.getSelection();
174     }
175     
176     protected boolean doMultiPlatform() {
177         return fMultiPlatform != null && fMultiPlatform.getSelection();
178     }
179     
180     protected boolean doExportSource() {
181         return fExportSource.getSelection();
182     }
183
184     protected boolean doExportToDirectory() {
185         return fExportGroup.doExportToDirectory();
186     }
187
188     protected String JavaDoc getFileName() {
189         return fExportGroup.getFileName();
190     }
191
192     protected String JavaDoc getDestination() {
193         return fExportGroup.getDestination();
194     }
195
196     protected String JavaDoc getRootDirectory() {
197         return fConfigurationGroup.getRootDirectory();
198     }
199
200     protected IFile getProductFile() {
201         return fConfigurationGroup.getProductFile();
202     }
203
204 }
205
Popular Tags