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