1 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 S_JNLP = "jnlp"; private static final String S_URL = "siteURL"; private static final String S_JRE = "jre"; 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"); } 44 45 protected String getDescriptionText() { 46 return PDEUIMessages.AdvancedFeatureExportPage_desc; } 48 49 protected void createJNLPSection(Composite parent) { 50 jnlpGroup = new Group(parent, SWT.NONE); 51 jnlpGroup.setText(PDEUIMessages.AdvancedFeatureExportPage_jnlp); jnlpGroup.setLayout(new GridLayout(2, false)); 53 jnlpGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 54 55 fButton = createbutton(jnlpGroup, PDEUIMessages.AdvancedFeatureExportPage_createJNLP); 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); fURLText = createText(jnlpGroup); 66 fURLText.setText(getString(S_URL)); 67 68 fVersionLabel = createLabel(jnlpGroup, PDEUIMessages.AdvancedFeatureExportPage_jreVersion); 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 error = null; 95 96 if (jnlpGroup.getVisible() && fButton.getSelection()) { 97 if (fURLText.getText().trim().length() == 0) { 98 error = PDEUIMessages.AdvancedFeatureExportPage_noSite; } else if (fVersionText.getText().trim().length() == 0) { 100 error = PDEUIMessages.AdvancedFeatureExportPage_noVersion; } 102 } 103 setErrorMessage(error); 104 setPageComplete(error == null); 105 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 [] getJNLPInfo() { 120 if (jnlpGroup.getVisible() && fButton.getSelection()) { 121 return new String [] { 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 |