1 11 package org.eclipse.pde.internal.ui.editor.site; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.pde.internal.core.isite.*; 15 import org.eclipse.pde.internal.ui.*; 16 import org.eclipse.swt.*; 17 import org.eclipse.swt.events.*; 18 import org.eclipse.swt.layout.*; 19 import org.eclipse.swt.widgets.*; 20 21 25 public class FeaturePropertiesDialog extends BaseNewDialog { 26 27 private Text fURLText; 28 private Text fIdText; 29 private Text fVersionText; 30 private Text fLabelText; 31 private Text fTypeText; 32 private Text fOSText; 33 private Text fWSText; 34 private Text fNLText; 35 private Text fArchText; 36 private Button fIsPatch; 37 38 43 public FeaturePropertiesDialog(Shell shell, ISiteModel siteModel, 44 ISiteFeature siteObject) { 45 super(shell, siteModel, siteObject); 46 } 47 50 protected String getDialogTitle() { 51 return PDEPlugin.getResourceString("FeaturePropertiesDialog.title"); } 53 56 protected String getHelpId() { 57 return null; 58 } 59 62 protected void createEntries(Composite container) { 63 ISiteFeature feature = (ISiteFeature)getSiteObject(); 64 65 Label label = new Label(container, SWT.NONE); 66 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.url")); fURLText = new Text(container, SWT.SINGLE | SWT.BORDER); 68 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 69 gd.widthHint = 250; 70 fURLText.setLayoutData(gd); 71 setIfDefined(fURLText, feature.getURL()); 72 73 label = new Label(container, SWT.NONE); 74 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.id")); fIdText = new Text(container, SWT.SINGLE | SWT.BORDER); 76 fIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 77 fIdText.setEnabled(false); 78 setIfDefined(fIdText, feature.getId()); 79 80 label = new Label(container, SWT.NONE); 81 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.version")); fVersionText = new Text(container, SWT.SINGLE | SWT.BORDER); 83 fVersionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 84 fVersionText.setEnabled(false); 85 setIfDefined(fVersionText, feature.getVersion()); 86 87 label = new Label(container, SWT.NONE); 88 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.label")); fLabelText = new Text(container, SWT.SINGLE | SWT.BORDER); 90 fLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 91 setIfDefined(fLabelText, feature.getLabel()); 92 93 label = new Label(container, SWT.NONE); 94 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.type")); fTypeText = new Text(container, SWT.SINGLE | SWT.BORDER); 96 fTypeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 97 setIfDefined(fTypeText, feature.getType()); 98 99 label = new Label(container, SWT.NONE); 100 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.os")); fOSText = new Text(container, SWT.SINGLE | SWT.BORDER); 102 fOSText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 103 setIfDefined(fOSText, feature.getOS()); 104 105 label = new Label(container, SWT.NONE); 106 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.ws")); fWSText = new Text(container, SWT.SINGLE | SWT.BORDER); 108 fWSText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 109 setIfDefined(fWSText, feature.getWS()); 110 111 label = new Label(container, SWT.NONE); 112 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.nl")); fNLText = new Text(container, SWT.SINGLE | SWT.BORDER); 114 fNLText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 115 setIfDefined(fNLText, feature.getNL()); 116 117 label = new Label(container, SWT.NONE); 118 label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.arch")); fArchText = new Text(container, SWT.SINGLE | SWT.BORDER); 120 fArchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 121 setIfDefined(fArchText, feature.getArch()); 122 123 fIsPatch = new Button(container, SWT.CHECK); 124 fIsPatch.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.patch")); gd = new GridData(); 126 gd.horizontalSpan = 2; 127 fIsPatch.setLayoutData(gd); 128 fIsPatch.setSelection(feature.isPatch()); 129 130 } 131 134 protected void hookListeners(ModifyListener listener) { 135 fURLText.addModifyListener(listener); 136 } 137 140 protected void dialogChanged() { 141 IStatus status = (fURLText.getText().trim().length() == 0) ? createErrorStatus(getEmptyErrorMessage()) : getOKStatus(); 142 updateStatus(status); 143 } 144 147 protected String getEmptyErrorMessage() { 148 return PDEPlugin.getResourceString("FeaturePropertiesDialog.requiredURL"); } 150 153 protected void execute() { 154 try { 155 ISiteFeature feature = (ISiteFeature)getSiteObject(); 156 feature.setIsPatch(fIsPatch.getSelection()); 157 feature.setURL(fURLText.getText().trim()); 158 159 String text = fLabelText.getText().trim(); 160 feature.setLabel(text.length() == 0 ? null : text); 161 162 text = fTypeText.getText().trim(); 163 feature.setType(text.length() == 0 ? null : text); 164 165 text = fOSText.getText().trim(); 166 feature.setOS(text.length() == 0 ? null : text); 167 168 text = fWSText.getText().trim(); 169 feature.setWS(text.length() == 0 ? null : text); 170 171 text = fNLText.getText().trim(); 172 feature.setNL(text.length() == 0 ? null : text); 173 174 text = fArchText.getText().trim(); 175 feature.setArch(text.length() == 0 ? null : text); 176 } catch (CoreException e) { 177 } 178 } 179 } 180 | Popular Tags |