|
Lines 35-45
Link Here
|
| 35 |
import org.eclipse.swt.graphics.Image; |
35 |
import org.eclipse.swt.graphics.Image; |
| 36 |
import org.eclipse.swt.layout.GridData; |
36 |
import org.eclipse.swt.layout.GridData; |
| 37 |
import org.eclipse.swt.layout.GridLayout; |
37 |
import org.eclipse.swt.layout.GridLayout; |
|
|
38 |
import org.eclipse.swt.widgets.Button; |
| 38 |
import org.eclipse.swt.widgets.Composite; |
39 |
import org.eclipse.swt.widgets.Composite; |
|
|
40 |
import org.eclipse.swt.widgets.Control; |
| 39 |
import org.eclipse.swt.widgets.Link; |
41 |
import org.eclipse.swt.widgets.Link; |
| 40 |
import org.eclipse.swt.widgets.Shell; |
42 |
import org.eclipse.swt.widgets.Shell; |
| 41 |
import org.eclipse.swt.widgets.TabFolder; |
43 |
import org.eclipse.swt.widgets.Table; |
| 42 |
import org.eclipse.swt.widgets.TabItem; |
|
|
| 43 |
|
44 |
|
| 44 |
import org.eclipse.jface.dialogs.ControlEnableState; |
45 |
import org.eclipse.jface.dialogs.ControlEnableState; |
| 45 |
import org.eclipse.jface.viewers.ColumnLayoutData; |
46 |
import org.eclipse.jface.viewers.ColumnLayoutData; |
|
Lines 67-85
Link Here
|
| 67 |
|
68 |
|
| 68 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
69 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
| 69 |
import org.eclipse.jdt.internal.ui.JavaPluginImages; |
70 |
import org.eclipse.jdt.internal.ui.JavaPluginImages; |
|
|
71 |
import org.eclipse.jdt.internal.ui.preferences.BulletListBlock; |
| 70 |
import org.eclipse.jdt.internal.ui.preferences.CleanUpPreferencePage; |
72 |
import org.eclipse.jdt.internal.ui.preferences.CleanUpPreferencePage; |
| 71 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.CleanUpProfileVersioner; |
73 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.CleanUpProfileVersioner; |
|
|
74 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.CleanUpTabPage; |
| 72 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.CodeFormatingTabPage; |
75 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.CodeFormatingTabPage; |
| 73 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.CodeStyleTabPage; |
76 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.CodeStyleTabPage; |
| 74 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.MemberAccessesTabPage; |
77 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.MemberAccessesTabPage; |
| 75 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.MissingCodeTabPage; |
78 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.MissingCodeTabPage; |
| 76 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.UnnecessaryCodeTabPage; |
79 |
import org.eclipse.jdt.internal.ui.preferences.cleanup.UnnecessaryCodeTabPage; |
| 77 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage; |
|
|
| 78 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager; |
80 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager; |
| 79 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore; |
81 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore; |
| 80 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage.IModificationListener; |
82 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage.IModificationListener; |
| 81 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile; |
83 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile; |
| 82 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile; |
84 |
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile; |
|
|
85 |
import org.eclipse.jdt.internal.ui.util.SWTUtil; |
| 83 |
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; |
86 |
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; |
| 84 |
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; |
87 |
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; |
| 85 |
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter; |
88 |
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter; |
|
Lines 92-98
Link Here
|
| 92 |
|
95 |
|
| 93 |
private static final String USE_CUSTOM_PROFILE_KEY= "org.eclipse.jdt.ui.cleanup.use_dialog_profile"; //$NON-NLS-1$ |
96 |
private static final String USE_CUSTOM_PROFILE_KEY= "org.eclipse.jdt.ui.cleanup.use_dialog_profile"; //$NON-NLS-1$ |
| 94 |
private static final String CUSTOM_PROFILE_KEY= "org.eclipse.jdt.ui.cleanup.custom_profile"; //$NON-NLS-1$ |
97 |
private static final String CUSTOM_PROFILE_KEY= "org.eclipse.jdt.ui.cleanup.custom_profile"; //$NON-NLS-1$ |
| 95 |
private static final String LAST_SELECTED_TAB_PAGE_INDEX= "org.eclipse.jdt.ui.cleanup.selected_tab_page"; //$NON-NLS-1$ |
|
|
| 96 |
|
98 |
|
| 97 |
private static class ProjectProfileLableProvider extends LabelProvider implements ITableLabelProvider { |
99 |
private static class ProjectProfileLableProvider extends LabelProvider implements ITableLabelProvider { |
| 98 |
|
100 |
|
|
Lines 211-217
Link Here
|
| 211 |
private final CleanUpRefactoring fCleanUpRefactoring; |
213 |
private final CleanUpRefactoring fCleanUpRefactoring; |
| 212 |
private Map fCustomSettings; |
214 |
private Map fCustomSettings; |
| 213 |
private SelectionButtonDialogField fUseCustomField; |
215 |
private SelectionButtonDialogField fUseCustomField; |
| 214 |
|
216 |
|
| 215 |
private ControlEnableState fEnableState; |
217 |
private ControlEnableState fEnableState; |
| 216 |
|
218 |
|
| 217 |
public CleanUpConfigurationPage(CleanUpRefactoring refactoring) { |
219 |
public CleanUpConfigurationPage(CleanUpRefactoring refactoring) { |
|
Lines 263-272
Link Here
|
| 263 |
settingsField.setViewerComparator(new ViewerComparator()); |
265 |
settingsField.setViewerComparator(new ViewerComparator()); |
| 264 |
|
266 |
|
| 265 |
settingsField.doFillIntoGrid(composite, 3); |
267 |
settingsField.doFillIntoGrid(composite, 3); |
|
|
268 |
|
| 269 |
Table table= settingsField.getTableViewer().getTable(); |
| 266 |
GridData data= (GridData)settingsField.getListControl(null).getLayoutData(); |
270 |
GridData data= (GridData)settingsField.getListControl(null).getLayoutData(); |
| 267 |
data.horizontalIndent= 15; |
271 |
data.horizontalIndent= 15; |
|
|
272 |
data.grabExcessVerticalSpace= false; |
| 273 |
data.heightHint= SWTUtil.getTableHeightHint(table, Math.min(5, fCleanUpRefactoring.getProjects().length + 1)); |
| 268 |
data.grabExcessHorizontalSpace= true; |
274 |
data.grabExcessHorizontalSpace= true; |
|
|
275 |
data.verticalAlignment= GridData.BEGINNING; |
| 269 |
|
276 |
|
|
|
277 |
data= (GridData)settingsField.getButtonBox(null).getLayoutData(); |
| 278 |
data.grabExcessVerticalSpace= false; |
| 279 |
data.verticalAlignment= GridData.BEGINNING; |
| 280 |
|
| 270 |
data= (GridData)settingsField.getLabelControl(null).getLayoutData(); |
281 |
data= (GridData)settingsField.getLabelControl(null).getLayoutData(); |
| 271 |
data.exclude= true; |
282 |
data.exclude= true; |
| 272 |
|
283 |
|
|
Lines 290-319
Link Here
|
| 290 |
} |
301 |
} |
| 291 |
} |
302 |
} |
| 292 |
|
303 |
|
| 293 |
final TabFolder tabFolder= createTabFolder(composite, fCustomSettings); |
304 |
final BulletListBlock bulletListBlock= new BulletListBlock(); |
| 294 |
tabFolder.addSelectionListener(new SelectionAdapter() { |
305 |
Control bulletList= bulletListBlock.createControl(composite); |
|
|
306 |
GridData layoutData= (GridData)bulletList.getLayoutData(); |
| 307 |
(layoutData).horizontalIndent= 15; |
| 308 |
layoutData.grabExcessVerticalSpace= true; |
| 309 |
|
| 310 |
final Button configure= new Button(composite, SWT.NONE); |
| 311 |
configure.setText(MultiFixMessages.CleanUpRefactoringWizard_ConfigureCustomProfile_button); |
| 312 |
|
| 313 |
data= new GridData(SWT.TOP, SWT.LEAD, false, false); |
| 314 |
data.widthHint= SWTUtil.getButtonWidthHint(configure); |
| 315 |
configure.setLayoutData(data); |
| 316 |
|
| 317 |
showCustomSettings(bulletListBlock); |
| 318 |
configure.addSelectionListener(new SelectionAdapter() { |
| 319 |
/** |
| 320 |
* {@inheritDoc} |
| 321 |
*/ |
| 295 |
public void widgetSelected(SelectionEvent e) { |
322 |
public void widgetSelected(SelectionEvent e) { |
| 296 |
getDialogSettings().put(LAST_SELECTED_TAB_PAGE_INDEX, tabFolder.getSelectionIndex()); |
323 |
CleanUpSaveParticipantConfigurationModifyDialog dialog= new CleanUpSaveParticipantConfigurationModifyDialog(getShell(), fCustomSettings, MultiFixMessages.CleanUpRefactoringWizard_CustomCleanUpsDialog_title) { |
|
|
324 |
protected CleanUpTabPage[] createTabPages(Map workingValues) { |
| 325 |
CleanUpTabPage[] result= new CleanUpTabPage[5]; |
| 326 |
result[0]= new CodeStyleTabPage(this, workingValues, false); |
| 327 |
result[1]= new MemberAccessesTabPage(this, workingValues, false); |
| 328 |
result[2]= new UnnecessaryCodeTabPage(this, workingValues, false); |
| 329 |
result[3]= new MissingCodeTabPage(this, workingValues, false); |
| 330 |
result[4]= new CodeFormatingTabPage(this, workingValues, false); |
| 331 |
|
| 332 |
addTabPage(MultiFixMessages.CleanUpRefactoringWizard_code_style_tab, result[0]); |
| 333 |
addTabPage(MultiFixMessages.CleanUpRefactoringWizard_member_accesses_tab, result[1]); |
| 334 |
addTabPage(MultiFixMessages.CleanUpRefactoringWizard_unnecessary_code_tab, result[2]); |
| 335 |
addTabPage(MultiFixMessages.CleanUpRefactoringWizard_missing_code_tab, result[3]); |
| 336 |
addTabPage(MultiFixMessages.CleanUpRefactoringWizard_code_organizing_tab, result[4]); |
| 337 |
|
| 338 |
return result; |
| 339 |
} |
| 340 |
}; |
| 341 |
dialog.open(); |
| 342 |
showCustomSettings(bulletListBlock); |
| 297 |
} |
343 |
} |
| 298 |
}); |
344 |
}); |
| 299 |
|
345 |
|
| 300 |
settingsField.getListControl(null).setEnabled(!isCustom); |
346 |
updateEnableState(isCustom, settingsField, configure, bulletListBlock); |
| 301 |
if (isCustom) { |
|
|
| 302 |
fEnableState= ControlEnableState.disable(settingsField.getButtonBox(null)); |
| 303 |
} else { |
| 304 |
fEnableState= ControlEnableState.disable(tabFolder); |
| 305 |
} |
| 306 |
|
347 |
|
| 307 |
fUseCustomField.setDialogFieldListener(new IDialogFieldListener() { |
348 |
fUseCustomField.setDialogFieldListener(new IDialogFieldListener() { |
| 308 |
public void dialogFieldChanged(DialogField field) { |
349 |
public void dialogFieldChanged(DialogField field) { |
| 309 |
fEnableState.restore(); |
350 |
updateEnableState(fUseCustomField.isSelected(), settingsField, configure, bulletListBlock); |
| 310 |
boolean isCustomSelected= fUseCustomField.isSelected(); |
|
|
| 311 |
settingsField.getListControl(null).setEnabled(!isCustomSelected); |
| 312 |
if (isCustomSelected) { |
| 313 |
fEnableState= ControlEnableState.disable(settingsField.getButtonBox(null)); |
| 314 |
} else { |
| 315 |
fEnableState= ControlEnableState.disable(tabFolder); |
| 316 |
} |
| 317 |
} |
351 |
} |
| 318 |
}); |
352 |
}); |
| 319 |
|
353 |
|
|
Lines 336-370
Link Here
|
| 336 |
setControl(composite); |
370 |
setControl(composite); |
| 337 |
} |
371 |
} |
| 338 |
|
372 |
|
| 339 |
private TabFolder createTabFolder(Composite composite, Map settings) { |
373 |
private void updateEnableState(boolean isCustom, final ListDialogField settingsField, Button configureCustom, BulletListBlock bulletListBlock) { |
| 340 |
final TabFolder tabFolder = new TabFolder(composite, SWT.NONE); |
374 |
settingsField.getListControl(null).setEnabled(!isCustom); |
| 341 |
tabFolder.setFont(composite.getFont()); |
375 |
if (isCustom) { |
| 342 |
GridData gridData= new GridData(SWT.FILL, SWT.TOP, true, false); |
376 |
fEnableState= ControlEnableState.disable(settingsField.getButtonBox(null)); |
| 343 |
gridData.horizontalIndent= 15; |
377 |
} else if (fEnableState != null) { |
| 344 |
gridData.horizontalSpan= 2; |
378 |
fEnableState.restore(); |
| 345 |
tabFolder.setLayoutData(gridData); |
379 |
fEnableState= null; |
| 346 |
|
380 |
} |
| 347 |
addTabPage(tabFolder, MultiFixMessages.CleanUpRefactoringWizard_code_style_tab, new CodeStyleTabPage(this, settings, false)); |
381 |
bulletListBlock.setEnabled(isCustom); |
| 348 |
addTabPage(tabFolder, MultiFixMessages.CleanUpRefactoringWizard_member_accesses_tab, new MemberAccessesTabPage(this, settings, false)); |
382 |
configureCustom.setEnabled(isCustom); |
| 349 |
addTabPage(tabFolder, MultiFixMessages.CleanUpRefactoringWizard_unnecessary_code_tab, new UnnecessaryCodeTabPage(this, settings, false)); |
383 |
} |
| 350 |
addTabPage(tabFolder, MultiFixMessages.CleanUpRefactoringWizard_missing_code_tab, new MissingCodeTabPage(this, settings, false)); |
384 |
|
| 351 |
addTabPage(tabFolder, MultiFixMessages.CleanUpRefactoringWizard_code_organizing_tab, new CodeFormatingTabPage(this, settings, false)); |
385 |
private void showCustomSettings(BulletListBlock bulletListBlock) { |
| 352 |
|
386 |
StringBuffer buf= new StringBuffer(); |
| 353 |
try { |
387 |
|
| 354 |
int lastTabIndex= getDialogSettings().getInt(LAST_SELECTED_TAB_PAGE_INDEX); |
388 |
final ICleanUp[] cleanUps= CleanUpRefactoring.createCleanUps(fCustomSettings); |
| 355 |
tabFolder.setSelection(lastTabIndex); |
389 |
for (int i= 0; i < cleanUps.length; i++) { |
| 356 |
} catch (NumberFormatException e1) { |
390 |
String[] descriptions= cleanUps[i].getDescriptions(); |
| 357 |
} |
391 |
if (descriptions != null) { |
| 358 |
|
392 |
for (int j= 0; j < descriptions.length; j++) { |
| 359 |
return tabFolder; |
393 |
if (buf.length() > 0) { |
|
|
394 |
buf.append('\n'); |
| 395 |
} |
| 396 |
buf.append(descriptions[j]); |
| 397 |
} |
| 398 |
} |
| 399 |
} |
| 400 |
bulletListBlock.setText(buf.toString()); |
| 360 |
} |
401 |
} |
| 361 |
|
|
|
| 362 |
protected final void addTabPage(TabFolder tabFolder, String title, ModifyDialogTabPage tabPage) { |
| 363 |
final TabItem tabItem= new TabItem(tabFolder, SWT.NONE); |
| 364 |
tabItem.setText(title); |
| 365 |
tabItem.setData(tabPage); |
| 366 |
tabItem.setControl(tabPage.createContents(tabFolder)); |
| 367 |
} |
| 368 |
|
402 |
|
| 369 |
protected boolean performFinish() { |
403 |
protected boolean performFinish() { |
| 370 |
initializeRefactoring(); |
404 |
initializeRefactoring(); |