Lines 7-12
Link Here
|
7 |
* |
7 |
* |
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
|
|
10 |
* Alex Blewitt - Bug 133277 Allow Sort Members to be performed on package and project levels |
10 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.internal.ui.actions; |
12 |
package org.eclipse.jdt.internal.ui.actions; |
12 |
|
13 |
|
Lines 19-29
Link Here
|
19 |
import org.eclipse.core.runtime.IStatus; |
20 |
import org.eclipse.core.runtime.IStatus; |
20 |
import org.eclipse.core.runtime.MultiStatus; |
21 |
import org.eclipse.core.runtime.MultiStatus; |
21 |
import org.eclipse.core.runtime.Status; |
22 |
import org.eclipse.core.runtime.Status; |
22 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
|
|
23 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
24 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
25 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; |
26 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; |
27 |
|
23 |
|
28 |
import org.eclipse.jface.dialogs.ErrorDialog; |
24 |
import org.eclipse.jface.dialogs.ErrorDialog; |
29 |
import org.eclipse.jface.dialogs.MessageDialog; |
25 |
import org.eclipse.jface.dialogs.MessageDialog; |
Lines 40-137
Link Here
|
40 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
36 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
41 |
import org.eclipse.jdt.core.JavaModelException; |
37 |
import org.eclipse.jdt.core.JavaModelException; |
42 |
|
38 |
|
43 |
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; |
|
|
44 |
import org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter; |
45 |
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; |
39 |
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; |
46 |
import org.eclipse.jdt.internal.corext.util.Messages; |
40 |
import org.eclipse.jdt.internal.corext.util.Messages; |
47 |
|
41 |
|
48 |
import org.eclipse.jdt.ui.IWorkingCopyManager; |
|
|
49 |
import org.eclipse.jdt.ui.JavaUI; |
42 |
import org.eclipse.jdt.ui.JavaUI; |
50 |
import org.eclipse.jdt.ui.actions.SelectionDispatchAction; |
43 |
import org.eclipse.jdt.ui.actions.SelectionDispatchAction; |
51 |
|
44 |
|
52 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
45 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
53 |
import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; |
46 |
import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; |
|
|
47 |
import org.eclipse.jdt.internal.ui.fix.ICleanUp; |
54 |
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; |
48 |
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; |
55 |
import org.eclipse.jdt.internal.ui.util.ElementValidator; |
49 |
import org.eclipse.jdt.internal.ui.util.ElementValidator; |
56 |
|
50 |
|
57 |
public class CleanUpAction extends SelectionDispatchAction { |
51 |
public abstract class CleanUpAction extends SelectionDispatchAction { |
58 |
|
52 |
|
59 |
private JavaEditor fEditor; |
53 |
private JavaEditor fEditor; |
60 |
private IPreferenceChangeListener fPreferenceChangeListener; |
|
|
61 |
|
54 |
|
62 |
public CleanUpAction(IWorkbenchSite site) { |
55 |
public CleanUpAction(IWorkbenchSite site) { |
63 |
super(site); |
56 |
super(site); |
64 |
setToolTipText(ActionMessages.CleanUpAction_tooltip); |
|
|
65 |
setDescription(ActionMessages.CleanUpAction_description); |
66 |
|
67 |
fPreferenceChangeListener= new IPreferenceChangeListener() { |
68 |
public void preferenceChange(PreferenceChangeEvent event) { |
69 |
if (event.getKey().equals(CleanUpConstants.SHOW_CLEAN_UP_WIZARD)) { |
70 |
updateActionLabel(); |
71 |
} |
72 |
} |
73 |
}; |
74 |
new InstanceScope().getNode(JavaUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceChangeListener); |
75 |
|
76 |
updateActionLabel(); |
77 |
|
78 |
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION); |
79 |
} |
57 |
} |
80 |
|
58 |
|
81 |
/** |
59 |
/** |
82 |
* Note: This constructor is for internal use only. Clients should not call this constructor. |
60 |
* Note: This constructor is for internal use only. Clients should not call |
83 |
* @param editor the Java editor |
61 |
* this constructor. |
|
|
62 |
* |
63 |
* @param editor |
64 |
* the Java editor |
84 |
*/ |
65 |
*/ |
85 |
public CleanUpAction(JavaEditor editor) { |
66 |
public CleanUpAction(JavaEditor editor) { |
86 |
this(editor.getEditorSite()); |
67 |
this(editor.getEditorSite()); |
87 |
fEditor= editor; |
68 |
fEditor= editor; |
88 |
setEnabled(getCompilationUnit(fEditor) != null); |
69 |
setEnabled(getCompilationUnit(fEditor) != null); |
89 |
} |
70 |
} |
90 |
|
71 |
|
91 |
/* (non-Javadoc) |
72 |
/** |
92 |
* Method declared on SelectionDispatchAction. |
73 |
* @return the name of this action, not <b>null</b> |
93 |
*/ |
74 |
*/ |
|
|
75 |
protected abstract String getActionName(); |
76 |
|
77 |
/** |
78 |
* @param units |
79 |
* the units to clean up |
80 |
* @return the clean ups to be performed or <b>null</b> if none to be |
81 |
* performed |
82 |
*/ |
83 |
protected abstract ICleanUp[] createCleanUps(ICompilationUnit[] units); |
84 |
|
85 |
/** |
86 |
* @param units |
87 |
* to clean up |
88 |
* @param cleanUps |
89 |
* clean ups to execute on units |
90 |
* |
91 |
* @throws JavaModelException |
92 |
* @throws InvocationTargetException |
93 |
*/ |
94 |
protected abstract void performRefactoring(ICompilationUnit[] units, ICleanUp[] cleanUps) throws JavaModelException, InvocationTargetException; |
95 |
|
94 |
public void run(ITextSelection selection) { |
96 |
public void run(ITextSelection selection) { |
95 |
ICompilationUnit cu= getCompilationUnit(fEditor); |
97 |
ICompilationUnit cu= getCompilationUnit(fEditor); |
96 |
if (cu != null) { |
98 |
if (cu != null) { |
97 |
run(cu); |
99 |
run(cu); |
98 |
} |
100 |
} |
99 |
} |
101 |
} |
100 |
|
102 |
|
101 |
/* (non-Javadoc) |
|
|
102 |
* Method declared on SelectionDispatchAction. |
103 |
*/ |
104 |
public void run(IStructuredSelection selection) { |
103 |
public void run(IStructuredSelection selection) { |
105 |
ICompilationUnit[] cus= getCompilationUnits(selection); |
104 |
ICompilationUnit[] cus= getCompilationUnits(selection); |
106 |
if (cus.length == 0) { |
105 |
if (cus.length == 0) { |
107 |
MessageDialog.openInformation(getShell(), ActionMessages.CleanUpAction_EmptySelection_title, ActionMessages.CleanUpAction_EmptySelection_description); |
106 |
MessageDialog.openInformation(getShell(), getActionName(), ActionMessages.CleanUpAction_EmptySelection_description); |
108 |
} else if (cus.length == 1) { |
107 |
} else if (cus.length == 1) { |
109 |
run(cus[0]); |
108 |
run(cus[0]); |
110 |
} else { |
109 |
} else { |
111 |
runOnMultiple(cus); |
110 |
runOnMultiple(cus); |
112 |
} |
111 |
} |
113 |
} |
112 |
} |
114 |
|
113 |
|
115 |
/* (non-Javadoc) |
|
|
116 |
* Method declared on SelectionDispatchAction. |
117 |
*/ |
118 |
public void selectionChanged(ITextSelection selection) { |
114 |
public void selectionChanged(ITextSelection selection) { |
119 |
setEnabled(getCompilationUnit(fEditor) != null); |
115 |
setEnabled(getCompilationUnit(fEditor) != null); |
120 |
} |
116 |
} |
121 |
|
117 |
|
122 |
/* (non-Javadoc) |
|
|
123 |
* Method declared on SelectionDispatchAction. |
124 |
*/ |
125 |
public void selectionChanged(IStructuredSelection selection) { |
118 |
public void selectionChanged(IStructuredSelection selection) { |
126 |
setEnabled(isEnabled(selection)); |
119 |
setEnabled(isEnabled(selection)); |
127 |
} |
120 |
} |
128 |
|
121 |
|
129 |
private boolean isEnabled(IStructuredSelection selection) { |
122 |
private boolean isEnabled(IStructuredSelection selection) { |
130 |
Object[] selected= selection.toArray(); |
123 |
Object[] selected= selection.toArray(); |
131 |
for (int i= 0; i < selected.length; i++) { |
124 |
for (int i= 0; i < selected.length; i++) { |
132 |
try { |
125 |
try { |
133 |
if (selected[i] instanceof IJavaElement) { |
126 |
if (selected[i] instanceof IJavaElement) { |
134 |
IJavaElement elem= (IJavaElement) selected[i]; |
127 |
IJavaElement elem= (IJavaElement)selected[i]; |
135 |
if (elem.exists()) { |
128 |
if (elem.exists()) { |
136 |
switch (elem.getElementType()) { |
129 |
switch (elem.getElementType()) { |
137 |
case IJavaElement.TYPE: |
130 |
case IJavaElement.TYPE: |
Lines 142-148
Link Here
|
142 |
return true; |
135 |
return true; |
143 |
case IJavaElement.PACKAGE_FRAGMENT: |
136 |
case IJavaElement.PACKAGE_FRAGMENT: |
144 |
case IJavaElement.PACKAGE_FRAGMENT_ROOT: |
137 |
case IJavaElement.PACKAGE_FRAGMENT_ROOT: |
145 |
IPackageFragmentRoot root= (IPackageFragmentRoot) elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); |
138 |
IPackageFragmentRoot root= (IPackageFragmentRoot)elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); |
146 |
return (root.getKind() == IPackageFragmentRoot.K_SOURCE); |
139 |
return (root.getKind() == IPackageFragmentRoot.K_SOURCE); |
147 |
case IJavaElement.JAVA_PROJECT: |
140 |
case IJavaElement.JAVA_PROJECT: |
148 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=65638 |
141 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=65638 |
Lines 160-208
Link Here
|
160 |
} |
153 |
} |
161 |
return false; |
154 |
return false; |
162 |
} |
155 |
} |
163 |
|
156 |
|
164 |
/** |
157 |
private void run(ICompilationUnit cu) { |
165 |
* Note: This method is for internal use only. Clients should not call this method. |
|
|
166 |
* @param cu The compilation unit to process |
167 |
*/ |
168 |
public void run(ICompilationUnit cu) { |
169 |
if (!ElementValidator.check(cu, getShell(), ActionMessages.CleanUpAction_ErrorDialogTitle, fEditor != null)) |
170 |
return; |
171 |
if (!ActionUtil.isEditable(fEditor, getShell(), cu)) |
158 |
if (!ActionUtil.isEditable(fEditor, getShell(), cu)) |
172 |
return; |
159 |
return; |
173 |
|
160 |
|
|
|
161 |
ICleanUp[] cleanUps= createCleanUps(new ICompilationUnit[] { |
162 |
cu |
163 |
}); |
164 |
if (cleanUps == null) |
165 |
return; |
166 |
|
167 |
if (!ElementValidator.check(cu, getShell(), getActionName(), fEditor != null)) |
168 |
return; |
169 |
|
174 |
try { |
170 |
try { |
175 |
RefactoringExecutionStarter.startCleanupRefactoring(new ICompilationUnit[] {cu}, showWizard(), getShell()); |
171 |
performRefactoring(new ICompilationUnit[] { |
|
|
172 |
cu |
173 |
}, cleanUps); |
176 |
} catch (InvocationTargetException e) { |
174 |
} catch (InvocationTargetException e) { |
177 |
JavaPlugin.log(e); |
175 |
JavaPlugin.log(e); |
178 |
if (e.getCause() instanceof CoreException) |
176 |
if (e.getCause() instanceof CoreException) |
179 |
showUnexpectedError((CoreException)e.getCause()); |
177 |
showUnexpectedError((CoreException)e.getCause()); |
180 |
} catch (JavaModelException e) { |
178 |
} catch (JavaModelException e) { |
181 |
showUnexpectedError(e); |
179 |
showUnexpectedError(e); |
182 |
} |
180 |
} |
183 |
return; |
|
|
184 |
} |
181 |
} |
185 |
|
182 |
|
186 |
/** |
183 |
private void runOnMultiple(final ICompilationUnit[] cus) { |
187 |
* Perform on multiple compilation units. No editors are opened. |
184 |
ICleanUp[] cleanUps= createCleanUps(cus); |
188 |
* @param cus The compilation units to run on |
185 |
if (cleanUps == null) |
189 |
*/ |
186 |
return; |
190 |
public void runOnMultiple(final ICompilationUnit[] cus) { |
187 |
|
191 |
String message= ActionMessages.CleanUpAction_MultiStateErrorTitle; |
188 |
MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null); |
192 |
final MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, message, null); |
|
|
193 |
|
194 |
for (int i= 0; i < cus.length; i++) { |
189 |
for (int i= 0; i < cus.length; i++) { |
195 |
testOnBuildPath(cus[i], status); |
190 |
ICompilationUnit cu= cus[i]; |
|
|
191 |
|
192 |
if (!ActionUtil.isOnBuildPath(cu)) { |
193 |
String cuLocation= cu.getPath().makeRelative().toString(); |
194 |
String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation); |
195 |
status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); |
196 |
} |
196 |
} |
197 |
} |
197 |
|
|
|
198 |
if (!status.isOK()) { |
198 |
if (!status.isOK()) { |
199 |
String title= ActionMessages.CleanUpAction_ErrorDialogTitle; |
199 |
ErrorDialog.openError(getShell(), getActionName(), null, status); |
200 |
ErrorDialog.openError(getShell(), title, null, status); |
|
|
201 |
return; |
200 |
return; |
202 |
} |
201 |
} |
203 |
|
202 |
|
204 |
try { |
203 |
try { |
205 |
RefactoringExecutionStarter.startCleanupRefactoring(cus, showWizard(), getShell()); |
204 |
performRefactoring(cus, cleanUps); |
206 |
} catch (InvocationTargetException e) { |
205 |
} catch (InvocationTargetException e) { |
207 |
JavaPlugin.log(e); |
206 |
JavaPlugin.log(e); |
208 |
if (e.getCause() instanceof CoreException) |
207 |
if (e.getCause() instanceof CoreException) |
Lines 210-269
Link Here
|
210 |
} catch (JavaModelException e) { |
209 |
} catch (JavaModelException e) { |
211 |
showUnexpectedError(e); |
210 |
showUnexpectedError(e); |
212 |
} |
211 |
} |
213 |
return; |
|
|
214 |
} |
212 |
} |
215 |
|
213 |
|
216 |
private void showUnexpectedError(CoreException e) { |
214 |
private void showUnexpectedError(CoreException e) { |
217 |
String message2= Messages.format(ActionMessages.CleanUpAction_UnexpectedErrorMessage, e.getStatus().getMessage()); |
215 |
String message2= Messages.format(ActionMessages.CleanUpAction_UnexpectedErrorMessage, e.getStatus().getMessage()); |
218 |
IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, message2, null); |
216 |
IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, message2, null); |
219 |
String title= ActionMessages.CleanUpAction_ErrorDialogTitle; |
217 |
ErrorDialog.openError(getShell(), getActionName(), null, status); |
220 |
ErrorDialog.openError(getShell(), title, null, status); |
|
|
221 |
} |
222 |
|
223 |
private boolean testOnBuildPath(ICompilationUnit cu, MultiStatus status) { |
224 |
IJavaProject project= cu.getJavaProject(); |
225 |
if (!project.isOnClasspath(cu)) { |
226 |
String cuLocation= cu.getPath().makeRelative().toString(); |
227 |
String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation); |
228 |
status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); |
229 |
return false; |
230 |
} |
231 |
return true; |
232 |
} |
218 |
} |
233 |
|
219 |
|
234 |
private ICompilationUnit[] getCompilationUnits(IStructuredSelection selection) { |
220 |
private ICompilationUnit[] getCompilationUnits(IStructuredSelection selection) { |
235 |
HashSet result= new HashSet(); |
221 |
HashSet result= new HashSet(); |
236 |
Object[] selected= selection.toArray(); |
222 |
Object[] selected= selection.toArray(); |
237 |
for (int i= 0; i < selected.length; i++) { |
223 |
for (int i= 0; i < selected.length; i++) { |
238 |
try { |
224 |
try { |
239 |
if (selected[i] instanceof IJavaElement) { |
225 |
if (selected[i] instanceof IJavaElement) { |
240 |
IJavaElement elem= (IJavaElement) selected[i]; |
226 |
IJavaElement elem= (IJavaElement)selected[i]; |
241 |
if (elem.exists()) { |
227 |
if (elem.exists()) { |
242 |
|
|
|
243 |
switch (elem.getElementType()) { |
228 |
switch (elem.getElementType()) { |
244 |
case IJavaElement.TYPE: |
229 |
case IJavaElement.TYPE: |
245 |
if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) { |
230 |
if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) { |
246 |
result.add(elem.getParent()); |
231 |
result.add(elem.getParent()); |
247 |
} |
232 |
} |
248 |
break; |
233 |
break; |
249 |
case IJavaElement.COMPILATION_UNIT: |
234 |
case IJavaElement.COMPILATION_UNIT: |
250 |
result.add(elem); |
235 |
result.add(elem); |
251 |
break; |
236 |
break; |
252 |
case IJavaElement.IMPORT_CONTAINER: |
237 |
case IJavaElement.IMPORT_CONTAINER: |
253 |
result.add(elem.getParent()); |
238 |
result.add(elem.getParent()); |
254 |
break; |
239 |
break; |
255 |
case IJavaElement.PACKAGE_FRAGMENT: |
240 |
case IJavaElement.PACKAGE_FRAGMENT: |
256 |
collectCompilationUnits((IPackageFragment) elem, result); |
241 |
collectCompilationUnits((IPackageFragment)elem, result); |
257 |
break; |
242 |
break; |
258 |
case IJavaElement.PACKAGE_FRAGMENT_ROOT: |
243 |
case IJavaElement.PACKAGE_FRAGMENT_ROOT: |
259 |
collectCompilationUnits((IPackageFragmentRoot) elem, result); |
244 |
collectCompilationUnits((IPackageFragmentRoot)elem, result); |
260 |
break; |
245 |
break; |
261 |
case IJavaElement.JAVA_PROJECT: |
246 |
case IJavaElement.JAVA_PROJECT: |
262 |
IPackageFragmentRoot[] roots= ((IJavaProject) elem).getPackageFragmentRoots(); |
247 |
IPackageFragmentRoot[] roots= ((IJavaProject)elem).getPackageFragmentRoots(); |
263 |
for (int k= 0; k < roots.length; k++) { |
248 |
for (int k= 0; k < roots.length; k++) { |
264 |
collectCompilationUnits(roots[k], result); |
249 |
collectCompilationUnits(roots[k], result); |
265 |
} |
250 |
} |
266 |
break; |
251 |
break; |
267 |
} |
252 |
} |
268 |
} |
253 |
} |
269 |
} else if (selected[i] instanceof LogicalPackage) { |
254 |
} else if (selected[i] instanceof LogicalPackage) { |
Lines 280-330
Link Here
|
280 |
JavaPlugin.log(e); |
265 |
JavaPlugin.log(e); |
281 |
} |
266 |
} |
282 |
} |
267 |
} |
283 |
return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]); |
268 |
return (ICompilationUnit[])result.toArray(new ICompilationUnit[result.size()]); |
284 |
} |
269 |
} |
285 |
|
270 |
|
286 |
private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaModelException { |
271 |
private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaModelException { |
287 |
result.addAll(Arrays.asList(pack.getCompilationUnits())); |
272 |
result.addAll(Arrays.asList(pack.getCompilationUnits())); |
288 |
} |
273 |
} |
289 |
|
274 |
|
290 |
private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaModelException { |
275 |
private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaModelException { |
291 |
if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { |
276 |
if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { |
292 |
IJavaElement[] children= root.getChildren(); |
277 |
IJavaElement[] children= root.getChildren(); |
293 |
for (int i= 0; i < children.length; i++) { |
278 |
for (int i= 0; i < children.length; i++) { |
294 |
collectCompilationUnits((IPackageFragment) children[i], result); |
279 |
collectCompilationUnits((IPackageFragment)children[i], result); |
295 |
} |
280 |
} |
296 |
} |
281 |
} |
297 |
} |
282 |
} |
298 |
|
283 |
|
299 |
private static ICompilationUnit getCompilationUnit(JavaEditor editor) { |
284 |
private static ICompilationUnit getCompilationUnit(JavaEditor editor) { |
300 |
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); |
285 |
IJavaElement element= JavaUI.getEditorInputJavaElement(editor.getEditorInput()); |
301 |
ICompilationUnit cu= manager.getWorkingCopy(editor.getEditorInput()); |
286 |
if (!(element instanceof ICompilationUnit)) |
302 |
return cu; |
287 |
return null; |
303 |
} |
|
|
304 |
|
305 |
private boolean showWizard() { |
306 |
InstanceScope instanceScope= new InstanceScope(); |
307 |
IEclipsePreferences instanceNode= instanceScope.getNode(JavaUI.ID_PLUGIN); |
308 |
if (instanceNode.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null) |
309 |
return instanceNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); |
310 |
|
311 |
DefaultScope defaultScope= new DefaultScope(); |
312 |
IEclipsePreferences defaultNode= defaultScope.getNode(JavaUI.ID_PLUGIN); |
313 |
return defaultNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); |
314 |
} |
315 |
|
316 |
private void updateActionLabel() { |
317 |
if (showWizard()) { |
318 |
setText(ActionMessages.CleanUpAction_labelWizard); |
319 |
} else { |
320 |
setText(ActionMessages.CleanUpAction_label); |
321 |
} |
322 |
} |
323 |
|
288 |
|
324 |
public void dispose() { |
289 |
return (ICompilationUnit)element; |
325 |
if (fPreferenceChangeListener != null) { |
290 |
} |
326 |
new InstanceScope().getNode(JavaUI.ID_PLUGIN).removePreferenceChangeListener(fPreferenceChangeListener); |
291 |
|
327 |
fPreferenceChangeListener= null; |
292 |
} |
328 |
} |
|
|
329 |
} |
330 |
} |