KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005 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.jface.dialogs.IDialogSettings;
14 import org.eclipse.pde.internal.ui.PDEUIMessages;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.events.SelectionAdapter;
17 import org.eclipse.swt.events.SelectionEvent;
18 import org.eclipse.swt.layout.GridData;
19 import org.eclipse.swt.layout.GridLayout;
20 import org.eclipse.swt.widgets.Button;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Group;
23 import org.eclipse.swt.widgets.Label;
24 import org.eclipse.swt.widgets.Text;
25
26 public class AdvancedFeatureExportPage extends AdvancedPluginExportPage {
27     
28     private static final String JavaDoc S_JNLP = "jnlp"; //$NON-NLS-1$
29
private static final String JavaDoc S_URL = "siteURL"; //$NON-NLS-1$
30
private static final String JavaDoc S_JRE = "jre"; //$NON-NLS-1$
31

32
33     private Label fURLLabel;
34     private Text fURLText;
35     private Label fVersionLabel;
36     private Text fVersionText;
37     private Button fButton;
38     private Group jnlpGroup;
39     
40     
41     public AdvancedFeatureExportPage() {
42         super("feature-sign"); //$NON-NLS-1$
43
}
44     
45     protected String JavaDoc getDescriptionText() {
46         return PDEUIMessages.AdvancedFeatureExportPage_desc; //$NON-NLS-1$
47
}
48     
49     protected void createJNLPSection(Composite parent) {
50         jnlpGroup = new Group(parent, SWT.NONE);
51         jnlpGroup.setText(PDEUIMessages.AdvancedFeatureExportPage_jnlp); //$NON-NLS-1$
52
jnlpGroup.setLayout(new GridLayout(2, false));
53         jnlpGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
54         
55         fButton = createbutton(jnlpGroup, PDEUIMessages.AdvancedFeatureExportPage_createJNLP); //$NON-NLS-1$
56
fButton.addSelectionListener(new SelectionAdapter() {
57             public void widgetSelected(SelectionEvent e) {
58                 boolean selected = fButton.getSelection();
59                 updateGroup(selected);
60                 validatePage();
61             }
62         });
63
64         fURLLabel = createLabel(jnlpGroup, PDEUIMessages.AdvancedFeatureExportPage_siteURL); //$NON-NLS-1$
65
fURLText = createText(jnlpGroup);
66         fURLText.setText(getString(S_URL));
67         
68         fVersionLabel = createLabel(jnlpGroup, PDEUIMessages.AdvancedFeatureExportPage_jreVersion); //$NON-NLS-1$
69
fVersionText = createText(jnlpGroup);
70         fVersionText.setText(getString(S_JRE));
71         
72         fButton.setSelection(getDialogSettings().getBoolean(S_JNLP));
73         updateGroup(fButton.getSelection());
74     }
75     
76     private void updateGroup(boolean enabled) {
77         fURLLabel.setEnabled(enabled);
78         fURLText.setEnabled(enabled);
79         fVersionLabel.setEnabled(enabled);
80         fVersionText.setEnabled(enabled);
81     }
82     
83     protected void validatePage() {
84         if (!isCurrentPage())
85             return;
86         forceValidatePage(false);
87     }
88     
89     protected void forceValidatePage(boolean forceSuper) {
90         if (forceSuper) super.forceValidatePage();
91         else super.validatePage();
92             
93         if (isPageComplete()) {
94             String JavaDoc error = null;
95             
96             if (jnlpGroup.getVisible() && fButton.getSelection()) {
97                 if (fURLText.getText().trim().length() == 0) {
98                     error = PDEUIMessages.AdvancedFeatureExportPage_noSite; //$NON-NLS-1$
99
} else if (fVersionText.getText().trim().length() == 0) {
100                     error = PDEUIMessages.AdvancedFeatureExportPage_noVersion; //$NON-NLS-1$
101
}
102             }
103             setErrorMessage(error);
104             setPageComplete(error == null);
105             // setPageComplete does not update buttons since we are checking a different page
106
// and so we must updateButtons explicitly.
107
if (forceSuper) getContainer().updateButtons();
108         }
109     }
110     
111     public void saveSettings() {
112         IDialogSettings settings = getDialogSettings();
113         settings.put(S_JNLP, fButton.getSelection());
114         settings.put(S_URL, fURLText.getText());
115         settings.put(S_JRE, fVersionText.getText());
116         super.saveSettings();
117     }
118     
119     public String JavaDoc[] getJNLPInfo() {
120         if (jnlpGroup.getVisible() && fButton.getSelection()) {
121             return new String JavaDoc[] { fURLText.getText().trim(),
122                     fVersionText.getText().trim() };
123         }
124         return null;
125     }
126
127     public void hideJNLP(boolean hide) {
128         jnlpGroup.setVisible(!hide);
129         fButton.setEnabled(!hide);
130     }
131 }
132
Popular Tags