1 11 package org.eclipse.pde.internal.ui.wizards.tools; 12 13 import org.eclipse.jface.dialogs.Dialog; 14 import org.eclipse.jface.dialogs.IDialogSettings; 15 import org.eclipse.jface.wizard.WizardPage; 16 import org.eclipse.pde.internal.ui.IHelpContextIds; 17 import org.eclipse.pde.internal.ui.IPreferenceConstants; 18 import org.eclipse.pde.internal.ui.PDEUIMessages; 19 import org.eclipse.swt.SWT; 20 import org.eclipse.swt.events.SelectionAdapter; 21 import org.eclipse.swt.events.SelectionEvent; 22 import org.eclipse.swt.layout.GridData; 23 import org.eclipse.swt.layout.GridLayout; 24 import org.eclipse.swt.widgets.Button; 25 import org.eclipse.swt.widgets.Composite; 26 import org.eclipse.swt.widgets.Group; 27 import org.eclipse.swt.widgets.Label; 28 import org.eclipse.swt.widgets.Text; 29 import org.eclipse.ui.PlatformUI; 30 31 public class OrganizeManifestsWizardPage extends WizardPage implements IPreferenceConstants, IOrganizeManifestsSettings { 32 33 private Button fRemoveUnresolved; 34 private Button fCalculateUses; 35 private Button fAddMissing; 36 private Button fMarkInternal; 37 private Text fPackageFilter; 38 private Label fPackageFilterLabel; 39 private Button fRemoveImport; 40 private Button fOptionalImport; 41 private Button fModifyDependencies; 42 private Button fUnusedDependencies; 43 private Button fAdditonalDependencies; 44 private Button fFixIconNLSPaths; 45 private Button fRemovedUnusedKeys; 46 private Button fRemoveLazy; 47 48 private Button[] fTopLevelButtons; private Button[] fParentButtons; 51 52 private static String title = PDEUIMessages.OrganizeManifestsWizardPage_title; 53 protected OrganizeManifestsWizardPage() { 54 super(title); 55 setTitle(title); 56 setDescription(PDEUIMessages.OrganizeManifestsWizardPage_description); 57 } 58 59 public void createControl(Composite parent) { 60 Composite container = new Composite(parent, SWT.NONE); 61 container.setLayout(new GridLayout()); 62 container.setLayoutData(new GridData(GridData.FILL_BOTH)); 63 64 createExportedPackagesGroup(container); 65 createRequireImportGroup(container); 66 createGeneralGroup(container); 67 createNLSGroup(container); 68 69 setButtonArrays(); 71 presetOptions(); 72 hookListeners(); 73 74 setControl(container); 75 PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.ORGANIZE_MANIFESTS); 76 Dialog.applyDialogFont(container); 77 } 78 79 private void createExportedPackagesGroup(Composite container) { 80 Group group = createGroup(container, PDEUIMessages.OrganizeManifestsWizardPage_exportedGroup, 1, true); 81 82 fAddMissing = new Button(group, SWT.CHECK); 83 fAddMissing.setText(PDEUIMessages.OrganizeManifestsWizardPage_addMissing); 84 85 fMarkInternal = new Button(group, SWT.CHECK); 86 fMarkInternal.setText(PDEUIMessages.OrganizeManifestsWizardPage_markInternal); 87 88 Composite comp = new Composite(group, SWT.NONE); 89 GridLayout layout = new GridLayout(2, false); 90 layout.marginHeight = layout.marginWidth = 0; 91 comp.setLayout(layout); 92 comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 93 fPackageFilterLabel = new Label(comp, SWT.NONE); 94 fPackageFilterLabel.setText(PDEUIMessages.OrganizeManifestsWizardPage_packageFilter); 95 GridData gd = new GridData(); 96 gd.horizontalIndent = 20; 97 fPackageFilterLabel.setLayoutData(gd); 98 fPackageFilter = new Text(comp, SWT.BORDER); 99 fPackageFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 100 101 fRemoveUnresolved = new Button(group, SWT.CHECK); 102 fRemoveUnresolved.setText(PDEUIMessages.OrganizeManifestsWizardPage_removeUnresolved); 103 gd = new GridData(); 104 gd.verticalIndent = 5; 105 fRemoveUnresolved.setLayoutData(gd); 106 107 fCalculateUses = new Button(group, SWT.CHECK); 108 fCalculateUses.setText(PDEUIMessages.OrganizeManifestsWizardPage_calculateUses); 109 gd = new GridData(); 110 gd.verticalIndent = 5; 111 fCalculateUses.setLayoutData(gd); 112 } 113 114 private void createRequireImportGroup(Composite container) { 115 Group group = createGroup(container, PDEUIMessages.OrganizeManifestsWizardPage_dependenciesGroup, 1, true); 116 117 Composite comp = new Composite(group, SWT.NONE); 118 GridLayout layout = new GridLayout(3, false); 119 layout.marginHeight = layout.marginWidth = 0; 120 comp.setLayout(layout); 121 comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 122 123 fModifyDependencies = new Button(comp, SWT.CHECK); 124 fModifyDependencies.setText(PDEUIMessages.OrganizeManifestsWizardPage_unresolvedDependencies); 125 126 fRemoveImport = new Button(comp, SWT.RADIO); 127 fRemoveImport.setText(PDEUIMessages.OrganizeManifestsWizardPage_remove); 128 129 fOptionalImport = new Button(comp, SWT.RADIO); 130 fOptionalImport.setText(PDEUIMessages.OrganizeManifestsWizardPage_markOptional); 131 132 fUnusedDependencies = new Button(group, SWT.CHECK); 133 fUnusedDependencies.setText(PDEUIMessages.OrganizeManifestsWizardPage_removeUnused); 134 135 fAdditonalDependencies = new Button(group, SWT.CHECK); 136 fAdditonalDependencies.setText(PDEUIMessages.OrganizeManifestsWizardPage_addDependencies); 137 } 138 139 private void createGeneralGroup(Composite container) { 140 Group group = createGroup(container, PDEUIMessages.OrganizeManifestsWizardPage_generalGroup, 1, true); 141 142 fRemoveLazy = new Button(group, SWT.CHECK); 143 fRemoveLazy.setText(PDEUIMessages.OrganizeManifestsWizardPage_lazyStart); 144 } 145 146 private void createNLSGroup(Composite container) { 147 Group group = createGroup(container, PDEUIMessages.OrganizeManifestsWizardPage_internationalizationGroup, 1, true); 148 149 fFixIconNLSPaths = new Button(group, SWT.CHECK); 150 fFixIconNLSPaths.setText(PDEUIMessages.OrganizeManifestsWizardPage_prefixNL); 151 152 fRemovedUnusedKeys = new Button(group, SWT.CHECK); 153 fRemovedUnusedKeys.setText(PDEUIMessages.OrganizeManifestsWizardPage_removeUnusedKeys); 154 } 155 156 private Group createGroup(Composite parent, String text, int span, boolean colsEqual) { 157 Group group = new Group(parent, SWT.NONE); 158 group.setText(text); 159 GridLayout layout = new GridLayout(span, colsEqual); 160 layout.marginHeight = layout.marginWidth = 10; 161 group.setLayout(layout); 162 GridData gd = new GridData(GridData.FILL_BOTH); 163 group.setLayoutData(gd); 164 return group; 165 } 166 167 private void presetOptions() { 168 IDialogSettings settings = getDialogSettings(); 169 170 fAddMissing.setSelection(!settings.getBoolean(PROP_ADD_MISSING)); 171 fMarkInternal.setSelection(!settings.getBoolean(PROP_MARK_INTERNAL)); 172 String filter = settings.get(PROP_INTERAL_PACKAGE_FILTER); 173 fPackageFilter.setText(filter != null ? filter : VALUE_DEFAULT_FILTER); 174 fRemoveUnresolved.setSelection(!settings.getBoolean(PROP_REMOVE_UNRESOLVED_EX)); 175 fCalculateUses.setSelection(settings.getBoolean(PROP_CALCULATE_USES)); 176 177 fModifyDependencies.setSelection(!settings.getBoolean(PROP_MODIFY_DEP)); 178 179 fRemoveImport.setSelection(!settings.getBoolean(PROP_RESOLVE_IMP_MARK_OPT)); 180 fOptionalImport.setSelection(settings.getBoolean(PROP_RESOLVE_IMP_MARK_OPT)); 181 182 fUnusedDependencies.setSelection(settings.getBoolean(PROP_UNUSED_DEPENDENCIES)); 183 fAdditonalDependencies.setSelection(settings.getBoolean(PROP_ADD_DEPENDENCIES)); 184 185 fRemoveLazy.setSelection(!settings.getBoolean(PROP_REMOVE_LAZY)); 186 187 fFixIconNLSPaths.setSelection(settings.getBoolean(PROP_NLS_PATH)); 188 fRemovedUnusedKeys.setSelection(settings.getBoolean(PROP_UNUSED_KEYS)); 189 190 setEnabledStates(); 191 setPageComplete(); 192 } 193 194 protected void preformOk() { 195 IDialogSettings settings = getDialogSettings(); 196 197 settings.put(PROP_ADD_MISSING, !fAddMissing.getSelection()); 198 settings.put(PROP_MARK_INTERNAL, !fMarkInternal.getSelection()); 199 settings.put(PROP_INTERAL_PACKAGE_FILTER, fPackageFilter.getText()); 200 settings.put(PROP_REMOVE_UNRESOLVED_EX, !fRemoveUnresolved.getSelection()); 201 settings.put(PROP_CALCULATE_USES, fCalculateUses.getSelection()); 202 203 204 settings.put(PROP_MODIFY_DEP, !fModifyDependencies.getSelection()); 205 settings.put(PROP_RESOLVE_IMP_MARK_OPT, fOptionalImport.getSelection()); 206 settings.put(PROP_UNUSED_DEPENDENCIES, fUnusedDependencies.getSelection()); 207 settings.put(PROP_ADD_DEPENDENCIES, fAdditonalDependencies.getSelection()); 208 209 settings.put(PROP_REMOVE_LAZY, !fRemoveLazy.getSelection()); 210 211 settings.put(PROP_NLS_PATH, fFixIconNLSPaths.getSelection()); 212 settings.put(PROP_UNUSED_KEYS, fRemovedUnusedKeys.getSelection()); 213 } 214 215 private void setEnabledStates() { 216 boolean markInternal = fMarkInternal.getSelection(); 217 fPackageFilter.setEnabled(markInternal); 218 fPackageFilter.setEditable(markInternal); 219 fPackageFilterLabel.setEnabled(markInternal); 220 221 boolean modifyDependencies = fModifyDependencies.getSelection(); 222 fRemoveImport.setEnabled(modifyDependencies); 223 fOptionalImport.setEnabled(modifyDependencies); 224 } 225 226 private void setButtonArrays() { 227 fTopLevelButtons = new Button[] { 228 fRemoveUnresolved, fAddMissing, fModifyDependencies, fMarkInternal, 229 fUnusedDependencies, fAdditonalDependencies, fFixIconNLSPaths, fRemovedUnusedKeys, fRemoveLazy, fCalculateUses 230 }; 231 fParentButtons = new Button[] { 232 fMarkInternal, fModifyDependencies 233 }; 234 } 235 236 private void setPageComplete() { 237 boolean pageComplete = false; 238 for (int i = 0; i < fTopLevelButtons.length; i++) { 239 if (fTopLevelButtons[i].getSelection()) { 240 pageComplete = true; 241 break; 242 } 243 } 244 setPageComplete(pageComplete); 245 } 246 247 private void hookListeners() { 248 hookListener(fParentButtons, new SelectionAdapter() { 249 public void widgetSelected(SelectionEvent e) { 250 setEnabledStates(); 251 } 252 }); 253 hookListener(fTopLevelButtons, new SelectionAdapter() { 254 public void widgetSelected(SelectionEvent e) { 255 setPageComplete(); 256 } 257 }); 258 } 259 260 private void hookListener(Button[] buttons, SelectionAdapter adapter) { 261 for (int i = 0; i < buttons.length; i++) { 262 buttons[i].addSelectionListener(adapter); 263 } 264 } 265 266 protected IDialogSettings getSettings() { 267 return getDialogSettings(); 268 } 269 } 270 | Popular Tags |