Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 62938 Details for
Bug 133277
[actions] Allow Sort Members to be performed on package and project levels
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
fix
fix_133277.txt (text/plain), 40.25 KB, created by
Benno Baumgartner
on 2007-04-04 11:09:08 EDT
(
hide
)
Description:
fix
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2007-04-04 11:09:08 EDT
Size:
40.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui.tests >Index: ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java,v >retrieving revision 1.1 >diff -u -r1.1 CleanUpTestCase.java >--- ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java 27 Feb 2007 17:16:08 -0000 1.1 >+++ ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java 4 Apr 2007 15:06:50 -0000 >@@ -189,7 +189,7 @@ > } > > protected void assertRefactoringResultAsExpectedIgnoreHashValue(ICompilationUnit[] cus, String[] expected) throws InvocationTargetException, JavaModelException { >- RefactoringExecutionStarter.startCleanupRefactoring(cus, false, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); >+ RefactoringExecutionStarter.startCleanupRefactoring(cus, CleanUpRefactoring.createCleanUps(), PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), false, "Clean Up"); > > Pattern regex= Pattern.compile("long serialVersionUID = .*L;"); > >Index: ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java,v >retrieving revision 1.17 >diff -u -r1.17 CleanUpStressTest.java >--- ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 27 Feb 2007 17:16:08 -0000 1.17 >+++ ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 4 Apr 2007 15:06:50 -0000 >@@ -35,6 +35,7 @@ > import org.eclipse.jdt.core.JavaModelException; > > import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; >+import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring; > import org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter; > > import org.eclipse.jdt.ui.JavaElementLabels; >@@ -5280,7 +5281,7 @@ > > ICompilationUnit[] units= (ICompilationUnit[])cus.toArray(new ICompilationUnit[cus.size()]); > Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); >- RefactoringExecutionStarter.startCleanupRefactoring(units, false, shell); >+ RefactoringExecutionStarter.startCleanupRefactoring(units, CleanUpRefactoring.createCleanUps(), shell, false, "Clean Up"); > > // generateTable(units); > >#P org.eclipse.jdt.ui >Index: ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringMessages.java,v >retrieving revision 1.45 >diff -u -r1.45 RefactoringMessages.java >--- ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringMessages.java 2 Apr 2007 14:00:26 -0000 1.45 >+++ ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringMessages.java 4 Apr 2007 15:06:56 -0000 >@@ -98,8 +98,6 @@ > > public static String ChangeTypeWizard_with_itself; > >- public static String CleanUpAction_dialog_title; >- > public static String ConvertAnonymousToNestedAction_Convert_Anonymous; > > public static String ConvertAnonymousToNestedAction_dialog_title; >Index: ui refactoring/org/eclipse/jdt/internal/ui/refactoring/refactoringui.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/refactoringui.properties,v >retrieving revision 1.248 >diff -u -r1.248 refactoringui.properties >--- ui refactoring/org/eclipse/jdt/internal/ui/refactoring/refactoringui.properties 2 Apr 2007 14:00:26 -0000 1.248 >+++ ui refactoring/org/eclipse/jdt/internal/ui/refactoring/refactoringui.properties 4 Apr 2007 15:06:58 -0000 >@@ -592,4 +592,3 @@ > ReplaceInvocationsInputPage_replaceInvocationsBy=&Replace Invocations by: > ReplaceInvocationsInputPage_replaceAll=Replace &all invocations > ReplaceInvocationsAction_unavailable=An unexpected exception occurred. See the error log for more details >-CleanUpAction_dialog_title=Clean Up >Index: ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java,v >retrieving revision 1.44 >diff -u -r1.44 ActionMessages.java >--- ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java 22 Jan 2007 18:22:06 -0000 1.44 >+++ ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java 4 Apr 2007 15:06:58 -0000 >@@ -109,12 +109,11 @@ > public static String CleanUpAction_labelWizard; > public static String CleanUpAction_tooltip; > public static String CleanUpAction_description; >- public static String CleanUpAction_ErrorDialogTitle; > public static String CleanUpAction_MultiStateErrorTitle; > public static String CleanUpAction_UnexpectedErrorMessage; > public static String CleanUpAction_CUNotOnBuildpathMessage; > public static String CleanUpAction_EmptySelection_description; >- public static String CleanUpAction_EmptySelection_title; >+ public static String CleanUpAction_actionName; > > public static String AddGetterSetterAction_no_primary_type_title; > public static String AddGetterSetterAction_no_primary_type_message; >Index: ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java,v >retrieving revision 1.18 >diff -u -r1.18 CleanUpAction.java >--- ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java 14 Nov 2006 08:00:09 -0000 1.18 >+++ ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java 4 Apr 2007 15:07:00 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Alex Blewitt - Bug 133277 Allow Sort Members to be performed on package and project levels > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.actions; > >@@ -19,11 +20,6 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.MultiStatus; > import org.eclipse.core.runtime.Status; >-import org.eclipse.core.runtime.preferences.DefaultScope; >-import org.eclipse.core.runtime.preferences.IEclipsePreferences; >-import org.eclipse.core.runtime.preferences.InstanceScope; >-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; >-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; > > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.MessageDialog; >@@ -40,98 +36,95 @@ > import org.eclipse.jdt.core.IPackageFragmentRoot; > import org.eclipse.jdt.core.JavaModelException; > >-import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; >-import org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter; > import org.eclipse.jdt.internal.corext.util.JavaModelUtil; > import org.eclipse.jdt.internal.corext.util.Messages; > >-import org.eclipse.jdt.ui.IWorkingCopyManager; > import org.eclipse.jdt.ui.JavaUI; > import org.eclipse.jdt.ui.actions.SelectionDispatchAction; > > import org.eclipse.jdt.internal.ui.JavaPlugin; > import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; >+import org.eclipse.jdt.internal.ui.fix.ICleanUp; > import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; > import org.eclipse.jdt.internal.ui.util.ElementValidator; > >-public class CleanUpAction extends SelectionDispatchAction { >+public abstract class CleanUpAction extends SelectionDispatchAction { > > private JavaEditor fEditor; >- private IPreferenceChangeListener fPreferenceChangeListener; > > public CleanUpAction(IWorkbenchSite site) { >- super(site); >- setToolTipText(ActionMessages.CleanUpAction_tooltip); >- setDescription(ActionMessages.CleanUpAction_description); >- >- fPreferenceChangeListener= new IPreferenceChangeListener() { >- public void preferenceChange(PreferenceChangeEvent event) { >- if (event.getKey().equals(CleanUpConstants.SHOW_CLEAN_UP_WIZARD)) { >- updateActionLabel(); >- } >- } >- }; >- new InstanceScope().getNode(JavaUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceChangeListener); >- >- updateActionLabel(); >- >-// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION); >+ super(site); > } >- >+ > /** >- * Note: This constructor is for internal use only. Clients should not call this constructor. >- * @param editor the Java editor >+ * Note: This constructor is for internal use only. Clients should not call >+ * this constructor. >+ * >+ * @param editor >+ * the Java editor > */ > public CleanUpAction(JavaEditor editor) { > this(editor.getEditorSite()); > fEditor= editor; > setEnabled(getCompilationUnit(fEditor) != null); > } >- >- /* (non-Javadoc) >- * Method declared on SelectionDispatchAction. >+ >+ /** >+ * @return the name of this action, not <b>null</b> > */ >+ protected abstract String getActionName(); >+ >+ /** >+ * @param units >+ * the units to clean up >+ * @return the clean ups to be performed or <b>null</b> if none to be >+ * performed >+ */ >+ protected abstract ICleanUp[] createCleanUps(ICompilationUnit[] units); >+ >+ /** >+ * @param units >+ * to clean up >+ * @param cleanUps >+ * clean ups to execute on units >+ * >+ * @throws JavaModelException >+ * @throws InvocationTargetException >+ */ >+ protected abstract void performRefactoring(ICompilationUnit[] units, ICleanUp[] cleanUps) throws JavaModelException, InvocationTargetException; >+ > public void run(ITextSelection selection) { > ICompilationUnit cu= getCompilationUnit(fEditor); > if (cu != null) { > run(cu); > } > } >- >- /* (non-Javadoc) >- * Method declared on SelectionDispatchAction. >- */ >+ > public void run(IStructuredSelection selection) { > ICompilationUnit[] cus= getCompilationUnits(selection); > if (cus.length == 0) { >- MessageDialog.openInformation(getShell(), ActionMessages.CleanUpAction_EmptySelection_title, ActionMessages.CleanUpAction_EmptySelection_description); >+ MessageDialog.openInformation(getShell(), getActionName(), ActionMessages.CleanUpAction_EmptySelection_description); > } else if (cus.length == 1) { > run(cus[0]); > } else { > runOnMultiple(cus); > } > } >- >- /* (non-Javadoc) >- * Method declared on SelectionDispatchAction. >- */ >+ > public void selectionChanged(ITextSelection selection) { > setEnabled(getCompilationUnit(fEditor) != null); > } >- >- /* (non-Javadoc) >- * Method declared on SelectionDispatchAction. >- */ >+ > public void selectionChanged(IStructuredSelection selection) { > setEnabled(isEnabled(selection)); > } >- >+ > private boolean isEnabled(IStructuredSelection selection) { > Object[] selected= selection.toArray(); > for (int i= 0; i < selected.length; i++) { > try { > if (selected[i] instanceof IJavaElement) { >- IJavaElement elem= (IJavaElement) selected[i]; >+ IJavaElement elem= (IJavaElement)selected[i]; > if (elem.exists()) { > switch (elem.getElementType()) { > case IJavaElement.TYPE: >@@ -142,7 +135,7 @@ > return true; > case IJavaElement.PACKAGE_FRAGMENT: > case IJavaElement.PACKAGE_FRAGMENT_ROOT: >- IPackageFragmentRoot root= (IPackageFragmentRoot) elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); >+ IPackageFragmentRoot root= (IPackageFragmentRoot)elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); > return (root.getKind() == IPackageFragmentRoot.K_SOURCE); > case IJavaElement.JAVA_PROJECT: > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=65638 >@@ -160,49 +153,55 @@ > } > return false; > } >- >- /** >- * Note: This method is for internal use only. Clients should not call this method. >- * @param cu The compilation unit to process >- */ >- public void run(ICompilationUnit cu) { >- if (!ElementValidator.check(cu, getShell(), ActionMessages.CleanUpAction_ErrorDialogTitle, fEditor != null)) >- return; >+ >+ private void run(ICompilationUnit cu) { > if (!ActionUtil.isEditable(fEditor, getShell(), cu)) > return; >- >+ >+ ICleanUp[] cleanUps= createCleanUps(new ICompilationUnit[] { >+ cu >+ }); >+ if (cleanUps == null) >+ return; >+ >+ if (!ElementValidator.check(cu, getShell(), getActionName(), fEditor != null)) >+ return; >+ > try { >- RefactoringExecutionStarter.startCleanupRefactoring(new ICompilationUnit[] {cu}, showWizard(), getShell()); >+ performRefactoring(new ICompilationUnit[] { >+ cu >+ }, cleanUps); > } catch (InvocationTargetException e) { > JavaPlugin.log(e); > if (e.getCause() instanceof CoreException) > showUnexpectedError((CoreException)e.getCause()); > } catch (JavaModelException e) { > showUnexpectedError(e); >- } >- return; >+ } > } > >- /** >- * Perform on multiple compilation units. No editors are opened. >- * @param cus The compilation units to run on >- */ >- public void runOnMultiple(final ICompilationUnit[] cus) { >- String message= ActionMessages.CleanUpAction_MultiStateErrorTitle; >- final MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, message, null); >- >+ private void runOnMultiple(final ICompilationUnit[] cus) { >+ ICleanUp[] cleanUps= createCleanUps(cus); >+ if (cleanUps == null) >+ return; >+ >+ MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null); > for (int i= 0; i < cus.length; i++) { >- testOnBuildPath(cus[i], status); >+ ICompilationUnit cu= cus[i]; >+ >+ if (!ActionUtil.isOnBuildPath(cu)) { >+ String cuLocation= cu.getPath().makeRelative().toString(); >+ String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation); >+ status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); >+ } > } >- > if (!status.isOK()) { >- String title= ActionMessages.CleanUpAction_ErrorDialogTitle; >- ErrorDialog.openError(getShell(), title, null, status); >+ ErrorDialog.openError(getShell(), getActionName(), null, status); > return; > } >- >+ > try { >- RefactoringExecutionStarter.startCleanupRefactoring(cus, showWizard(), getShell()); >+ performRefactoring(cus, cleanUps); > } catch (InvocationTargetException e) { > JavaPlugin.log(e); > if (e.getCause() instanceof CoreException) >@@ -210,60 +209,46 @@ > } catch (JavaModelException e) { > showUnexpectedError(e); > } >- return; > } > > private void showUnexpectedError(CoreException e) { >- String message2= Messages.format(ActionMessages.CleanUpAction_UnexpectedErrorMessage, e.getStatus().getMessage()); >+ String message2= Messages.format(ActionMessages.CleanUpAction_UnexpectedErrorMessage, e.getStatus().getMessage()); > IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, message2, null); >- String title= ActionMessages.CleanUpAction_ErrorDialogTitle; >- ErrorDialog.openError(getShell(), title, null, status); >- } >- >- private boolean testOnBuildPath(ICompilationUnit cu, MultiStatus status) { >- IJavaProject project= cu.getJavaProject(); >- if (!project.isOnClasspath(cu)) { >- String cuLocation= cu.getPath().makeRelative().toString(); >- String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation); >- status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); >- return false; >- } >- return true; >+ ErrorDialog.openError(getShell(), getActionName(), null, status); > } >- >+ > private ICompilationUnit[] getCompilationUnits(IStructuredSelection selection) { > HashSet result= new HashSet(); > Object[] selected= selection.toArray(); > for (int i= 0; i < selected.length; i++) { > try { > if (selected[i] instanceof IJavaElement) { >- IJavaElement elem= (IJavaElement) selected[i]; >+ IJavaElement elem= (IJavaElement)selected[i]; > if (elem.exists()) { >- > switch (elem.getElementType()) { > case IJavaElement.TYPE: > if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) { > result.add(elem.getParent()); > } >- break; >+ break; > case IJavaElement.COMPILATION_UNIT: > result.add(elem); > break; > case IJavaElement.IMPORT_CONTAINER: > result.add(elem.getParent()); >- break; >+ break; > case IJavaElement.PACKAGE_FRAGMENT: >- collectCompilationUnits((IPackageFragment) elem, result); >+ collectCompilationUnits((IPackageFragment)elem, result); > break; > case IJavaElement.PACKAGE_FRAGMENT_ROOT: >- collectCompilationUnits((IPackageFragmentRoot) elem, result); >+ collectCompilationUnits((IPackageFragmentRoot)elem, result); > break; > case IJavaElement.JAVA_PROJECT: >- IPackageFragmentRoot[] roots= ((IJavaProject) elem).getPackageFragmentRoots(); >+ IPackageFragmentRoot[] roots= ((IJavaProject)elem).getPackageFragmentRoots(); > for (int k= 0; k < roots.length; k++) { > collectCompilationUnits(roots[k], result); > } >- break; >+ break; > } > } > } else if (selected[i] instanceof LogicalPackage) { >@@ -280,51 +265,28 @@ > JavaPlugin.log(e); > } > } >- return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]); >+ return (ICompilationUnit[])result.toArray(new ICompilationUnit[result.size()]); > } >- >+ > private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaModelException { > result.addAll(Arrays.asList(pack.getCompilationUnits())); > } >- >+ > private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaModelException { > if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { > IJavaElement[] children= root.getChildren(); > for (int i= 0; i < children.length; i++) { >- collectCompilationUnits((IPackageFragment) children[i], result); >+ collectCompilationUnits((IPackageFragment)children[i], result); > } > } >- } >- >+ } >+ > private static ICompilationUnit getCompilationUnit(JavaEditor editor) { >- IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); >- ICompilationUnit cu= manager.getWorkingCopy(editor.getEditorInput()); >- return cu; >- } >- >- private boolean showWizard() { >- InstanceScope instanceScope= new InstanceScope(); >- IEclipsePreferences instanceNode= instanceScope.getNode(JavaUI.ID_PLUGIN); >- if (instanceNode.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null) >- return instanceNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); >- >- DefaultScope defaultScope= new DefaultScope(); >- IEclipsePreferences defaultNode= defaultScope.getNode(JavaUI.ID_PLUGIN); >- return defaultNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); >- } >- >- private void updateActionLabel() { >- if (showWizard()) { >- setText(ActionMessages.CleanUpAction_labelWizard); >- } else { >- setText(ActionMessages.CleanUpAction_label); >- } >- } >+ IJavaElement element= JavaUI.getEditorInputJavaElement(editor.getEditorInput()); >+ if (!(element instanceof ICompilationUnit)) >+ return null; > >- public void dispose() { >- if (fPreferenceChangeListener != null) { >- new InstanceScope().getNode(JavaUI.ID_PLUGIN).removePreferenceChangeListener(fPreferenceChangeListener); >- fPreferenceChangeListener= null; >- } >- } >-} >+ return (ICompilationUnit)element; >+ } >+ >+} >\ No newline at end of file >Index: ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties,v >retrieving revision 1.195 >diff -u -r1.195 ActionMessages.properties >--- ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties 13 Feb 2007 14:17:04 -0000 1.195 >+++ ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties 4 Apr 2007 15:06:59 -0000 >@@ -220,9 +220,8 @@ > CleanUpAction_labelWizard=Clean &Up... > CleanUpAction_tooltip=Solve Problems and Improve Code Style on Selected Resources > CleanUpAction_description=Solve problems and improve code style on selected resources >-CleanUpAction_ErrorDialogTitle=Clean Up >-CleanUpAction_MultiStateErrorTitle=Problems while cleaning up some compilation units. See 'Details' for more information. >-CleanUpAction_EmptySelection_title=Clean Up... >+CleanUpAction_MultiStateErrorTitle=Problems while processing some compilation units. See 'Details' for more information. >+CleanUpAction_actionName=Clean Up > CleanUpAction_UnexpectedErrorMessage={0}: Unexpected error. See log for details. > CleanUpAction_CUNotOnBuildpathMessage={0}: Compilation unit not on build path. No changes applied. > CleanUpAction_EmptySelection_description=The selection contains no compilation units. >Index: ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties,v >retrieving revision 1.64 >diff -u -r1.64 MultiFixMessages.properties >--- ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties 27 Feb 2007 17:16:09 -0000 1.64 >+++ ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties 4 Apr 2007 15:07:00 -0000 >@@ -83,4 +83,4 @@ > CleanUpSaveParticipantPreferenceConfiguration_edit_button_label=&Edit... > SortMembersCleanUp_AllMembers_description=Sort all members > SortMembersCleanUp_Excluding_description=Sort members excluding fields, enum constants, and initializers >-SortMembersCleanUp_RemoveMarkersWarning0=The file ''{0}'' in project ''{1}'' contains markers which may be removed by the Sort Members Clean Up >+SortMembersCleanUp_RemoveMarkersWarning0=The file ''{0}'' in project ''{1}'' contains markers which may be removed by Sort Members >Index: ui/org/eclipse/jdt/ui/actions/GenerateActionGroup.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/GenerateActionGroup.java,v >retrieving revision 1.95 >diff -u -r1.95 GenerateActionGroup.java >--- ui/org/eclipse/jdt/ui/actions/GenerateActionGroup.java 13 Oct 2006 13:40:55 -0000 1.95 >+++ ui/org/eclipse/jdt/ui/actions/GenerateActionGroup.java 4 Apr 2007 15:07:00 -0000 >@@ -44,10 +44,11 @@ > > import org.eclipse.jdt.internal.ui.actions.ActionMessages; > import org.eclipse.jdt.internal.ui.actions.AddTaskAction; >-import org.eclipse.jdt.internal.ui.actions.CleanUpAction; >+import org.eclipse.jdt.internal.ui.actions.AllCleanUpsAction; > import org.eclipse.jdt.internal.ui.actions.CopyQualifiedNameAction; > import org.eclipse.jdt.internal.ui.actions.FindBrokenNLSKeysAction; > import org.eclipse.jdt.internal.ui.actions.JDTQuickMenuAction; >+import org.eclipse.jdt.internal.ui.actions.MultiSortMembersAction; > import org.eclipse.jdt.internal.ui.javaeditor.AddImportOnSelectionAction; > import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; > >@@ -134,11 +135,11 @@ > private AddBookmarkAction fAddBookmark; > private AddTaskAction fAddTaskAction; > private ExternalizeStringsAction fExternalizeStrings; >- private CleanUpAction fCleanUp; >+ private AllCleanUpsAction fCleanUp; > private FindBrokenNLSKeysAction fFindNLSProblems; > > private OrganizeImportsAction fOrganizeImports; >- private SortMembersAction fSortMembers; >+ private MultiSortMembersAction fSortMembers; > private FormatAllAction fFormatAll; > private CopyQualifiedNameAction fCopyQualifiedNameAction; > >@@ -176,7 +177,7 @@ > fOrganizeImports.setActionDefinitionId(IJavaEditorActionDefinitionIds.ORGANIZE_IMPORTS); > editor.setAction("OrganizeImports", fOrganizeImports); //$NON-NLS-1$ > >- fSortMembers= new SortMembersAction(editor); >+ fSortMembers= new MultiSortMembersAction(editor); > fSortMembers.setActionDefinitionId(IJavaEditorActionDefinitionIds.SORT_MEMBERS); > editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$ > >@@ -213,7 +214,7 @@ > fAddJavaDocStub.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_JAVADOC_COMMENT); > editor.setAction("AddJavadocComment", fAddJavaDocStub); //$NON-NLS-1$ > >- fCleanUp= new CleanUpAction(editor); >+ fCleanUp= new AllCleanUpsAction(editor); > fCleanUp.setActionDefinitionId(IJavaEditorActionDefinitionIds.CLEAN_UP); > editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$ > >@@ -289,13 +290,13 @@ > fOrganizeImports= new OrganizeImportsAction(site); > fOrganizeImports.setActionDefinitionId(IJavaEditorActionDefinitionIds.ORGANIZE_IMPORTS); > >- fSortMembers= new SortMembersAction(site); >+ fSortMembers= new MultiSortMembersAction(site); > fSortMembers.setActionDefinitionId(IJavaEditorActionDefinitionIds.SORT_MEMBERS); > > fFormatAll= new FormatAllAction(site); > fFormatAll.setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT); > >- fCleanUp= new CleanUpAction(site); >+ fCleanUp= new AllCleanUpsAction(site); > fCleanUp.setActionDefinitionId(IJavaEditorActionDefinitionIds.CLEAN_UP); > > >Index: core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties,v >retrieving revision 1.37 >diff -u -r1.37 FixMessages.properties >--- core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties 27 Mar 2007 12:35:30 -0000 1.37 >+++ core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties 4 Apr 2007 15:06:53 -0000 >@@ -9,8 +9,8 @@ > # IBM Corporation - initial API and implementation > ############################################################################### > CleanUpRefactoring_Refactoring_name=Clean Up >-CleanUpRefactoring_Initialize_message=Checking Clean Up preconditions for project ''{0}'' >-CleanUpRefactoring_Parser_Startup_message=Cleaning up project {0} >+CleanUpRefactoring_Initialize_message=Checking preconditions for project ''{0}'' >+CleanUpRefactoring_Parser_Startup_message=Processing project {0} > CleanUpRefactoring_clean_up_multi_chang_name=Clean Up > CleanUpRefactoring_could_not_retrive_profile=Could not retrieve profile for project ''{0}'' > CleanUpRefactoring_ProcessingCompilationUnit_message=Processing compilation unit {0} of {1} ({2}) >Index: core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java,v >retrieving revision 1.44 >diff -u -r1.44 CleanUpRefactoring.java >--- core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java 24 Jan 2007 08:49:54 -0000 1.44 >+++ core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java 4 Apr 2007 15:06:53 -0000 >@@ -481,12 +481,16 @@ > > private final List/*<ICleanUp>*/fCleanUps; > private final Hashtable/*<IJavaProject, List<ICompilationUnit>*/fProjects; >- > private Change fChange; >- > private boolean fLeaveFilesDirty; >+ private final String fName; > > public CleanUpRefactoring() { >+ this(FixMessages.CleanUpRefactoring_Refactoring_name); >+ } >+ >+ public CleanUpRefactoring(String name) { >+ fName= name; > fCleanUps= new ArrayList(); > fProjects= new Hashtable(); > } >@@ -545,7 +549,7 @@ > * @see org.eclipse.ltk.core.refactoring.Refactoring#getName() > */ > public String getName() { >- return FixMessages.CleanUpRefactoring_Refactoring_name; >+ return fName; > } > > /* (non-Javadoc) >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java,v >retrieving revision 1.38 >diff -u -r1.38 RefactoringExecutionStarter.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java 4 Jan 2007 17:23:54 -0000 1.38 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java 4 Apr 2007 15:06:55 -0000 >@@ -25,6 +25,7 @@ > > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.dialogs.ProgressMonitorDialog; >+import org.eclipse.jface.operation.IRunnableContext; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; > >@@ -227,27 +228,33 @@ > new RefactoringStarter().activate(refactoring, new ChangeTypeWizard(refactoring), shell, RefactoringMessages.ChangeTypeAction_dialog_title, RefactoringSaveHelper.SAVE_JAVA_ONLY_UPDATES); > } > >- public static void startCleanupRefactoring(ICompilationUnit[] cus, boolean showWizard, Shell shell) throws InvocationTargetException, JavaModelException { >- final CleanUpRefactoring refactoring= new CleanUpRefactoring(); >+ public static void startCleanupRefactoring(ICompilationUnit[] cus, ICleanUp[] cleanUps, Shell shell, boolean showWizard, String actionName) throws InvocationTargetException, JavaModelException { >+ final CleanUpRefactoring refactoring= new CleanUpRefactoring(actionName); > for (int i= 0; i < cus.length; i++) { > refactoring.addCompilationUnit(cus[i]); > } > > if (!showWizard) { >- ICleanUp[] cleanUps= CleanUpRefactoring.createCleanUps(); > for (int i= 0; i < cleanUps.length; i++) { >- refactoring.addCleanUp(cleanUps[i]); >- } >+ refactoring.addCleanUp(cleanUps[i]); >+ } >+ >+ IRunnableContext context; >+ if (refactoring.getCompilationUnits().length > 1) { >+ context= new ProgressMonitorDialog(shell); >+ } else { >+ context= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); >+ } > >- RefactoringExecutionHelper helper= new RefactoringExecutionHelper(refactoring, IStatus.ERROR, RefactoringSaveHelper.SAVE_JAVA_ONLY_UPDATES, shell, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); >- try { >- helper.perform(true, true); >- } catch (InterruptedException e) { >- } >+ RefactoringExecutionHelper helper= new RefactoringExecutionHelper(refactoring, IStatus.WARNING, RefactoringSaveHelper.SAVE_JAVA_ONLY_UPDATES, shell, context); >+ try { >+ helper.perform(true, true); >+ } catch (InterruptedException e) { >+ } > } else { > CleanUpRefactoringWizard refactoringWizard= new CleanUpRefactoringWizard(refactoring, RefactoringWizard.WIZARD_BASED_USER_INTERFACE); > RefactoringStarter starter= new RefactoringStarter(); >- starter.activate(refactoring, refactoringWizard, shell, RefactoringMessages.CleanUpAction_dialog_title, RefactoringSaveHelper.SAVE_JAVA_ONLY_UPDATES); >+ starter.activate(refactoring, refactoringWizard, shell, actionName, RefactoringSaveHelper.SAVE_JAVA_ONLY_UPDATES); > } > } > >Index: ui/org/eclipse/jdt/internal/ui/actions/AllCleanUpsAction.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/actions/AllCleanUpsAction.java >diff -N ui/org/eclipse/jdt/internal/ui/actions/AllCleanUpsAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/actions/AllCleanUpsAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,115 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Alex Blewitt - Bug 133277 Allow Sort Members to be performed on package and project levels >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.actions; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.runtime.preferences.DefaultScope; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences; >+import org.eclipse.core.runtime.preferences.InstanceScope; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; >+ >+import org.eclipse.ui.IWorkbenchSite; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.JavaModelException; >+ >+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; >+import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring; >+import org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter; >+ >+import org.eclipse.jdt.ui.JavaUI; >+ >+import org.eclipse.jdt.internal.ui.fix.ICleanUp; >+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; >+ >+public class AllCleanUpsAction extends CleanUpAction { >+ >+ private IPreferenceChangeListener fPreferenceChangeListener; >+ >+ public AllCleanUpsAction(IWorkbenchSite site) { >+ super(site); >+ setToolTipText(ActionMessages.CleanUpAction_tooltip); >+ setDescription(ActionMessages.CleanUpAction_description); >+ installPreferenceListener(); >+ updateActionLabel(); >+ >+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION); >+ } >+ >+ public AllCleanUpsAction(JavaEditor editor) { >+ super(editor); >+ setToolTipText(ActionMessages.CleanUpAction_tooltip); >+ setDescription(ActionMessages.CleanUpAction_description); >+ installPreferenceListener(); >+ updateActionLabel(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected ICleanUp[] createCleanUps(ICompilationUnit[] units) { >+ return CleanUpRefactoring.createCleanUps(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected String getActionName() { >+ return ActionMessages.CleanUpAction_actionName; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected void performRefactoring(ICompilationUnit[] cus, ICleanUp[] cleanUps) throws JavaModelException, InvocationTargetException { >+ RefactoringExecutionStarter.startCleanupRefactoring(cus, cleanUps, getShell(), showWizard(), getActionName()); >+ } >+ >+ private boolean showWizard() { >+ InstanceScope instanceScope= new InstanceScope(); >+ IEclipsePreferences instanceNode= instanceScope.getNode(JavaUI.ID_PLUGIN); >+ if (instanceNode.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null) >+ return instanceNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); >+ >+ DefaultScope defaultScope= new DefaultScope(); >+ IEclipsePreferences defaultNode= defaultScope.getNode(JavaUI.ID_PLUGIN); >+ return defaultNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); >+ } >+ >+ private void updateActionLabel() { >+ if (showWizard()) { >+ setText(ActionMessages.CleanUpAction_labelWizard); >+ } else { >+ setText(ActionMessages.CleanUpAction_label); >+ } >+ } >+ >+ private void installPreferenceListener() { >+ fPreferenceChangeListener= new IPreferenceChangeListener() { >+ public void preferenceChange(PreferenceChangeEvent event) { >+ if (event.getKey().equals(CleanUpConstants.SHOW_CLEAN_UP_WIZARD)) { >+ updateActionLabel(); >+ } >+ } >+ }; >+ new InstanceScope().getNode(JavaUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceChangeListener); >+ } >+ >+ public void dispose() { >+ if (fPreferenceChangeListener != null) { >+ new InstanceScope().getNode(JavaUI.ID_PLUGIN).removePreferenceChangeListener(fPreferenceChangeListener); >+ fPreferenceChangeListener= null; >+ } >+ } >+} >Index: ui/org/eclipse/jdt/internal/ui/actions/MultiSortMembersAction.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/actions/MultiSortMembersAction.java >diff -N ui/org/eclipse/jdt/internal/ui/actions/MultiSortMembersAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/actions/MultiSortMembersAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,120 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Alex Blewitt - Bug 133277 Allow Sort Members to be performed on package and project levels >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.actions; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.Hashtable; >+ >+import org.eclipse.jface.window.Window; >+ >+import org.eclipse.ui.IWorkbenchSite; >+import org.eclipse.ui.PlatformUI; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IParent; >+import org.eclipse.jdt.core.JavaModelException; >+ >+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; >+import org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter; >+ >+import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; >+import org.eclipse.jdt.internal.ui.JavaPlugin; >+import org.eclipse.jdt.internal.ui.dialogs.SortMembersMessageDialog; >+import org.eclipse.jdt.internal.ui.fix.ICleanUp; >+import org.eclipse.jdt.internal.ui.fix.SortMembersCleanUp; >+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; >+ >+public class MultiSortMembersAction extends CleanUpAction { >+ >+ public MultiSortMembersAction(IWorkbenchSite site) { >+ super(site); >+ >+ setText(ActionMessages.SortMembersAction_label); >+ setDescription(ActionMessages.SortMembersAction_description); >+ setToolTipText(ActionMessages.SortMembersAction_tooltip); >+ >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.SORT_MEMBERS_ACTION); >+ } >+ >+ public MultiSortMembersAction(JavaEditor editor) { >+ super(editor); >+ >+ setText(ActionMessages.SortMembersAction_label); >+ setDescription(ActionMessages.SortMembersAction_description); >+ setToolTipText(ActionMessages.SortMembersAction_tooltip); >+ >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.SORT_MEMBERS_ACTION); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected ICleanUp[] createCleanUps(ICompilationUnit[] units) { >+ try { >+ if (!hasMembersToSort(units)) >+ return null; >+ } catch (JavaModelException e) { >+ JavaPlugin.log(e); >+ return null; >+ } >+ >+ SortMembersMessageDialog dialog= new SortMembersMessageDialog(getShell()); >+ if (dialog.open() != Window.OK) >+ return null; >+ >+ Hashtable settings= new Hashtable(); >+ settings.put(CleanUpConstants.SORT_MEMBERS, CleanUpConstants.TRUE); >+ settings.put(CleanUpConstants.SORT_MEMBERS_ALL, !dialog.isNotSortingFieldsEnabled() ? CleanUpConstants.TRUE : CleanUpConstants.FALSE); >+ >+ return new ICleanUp[] { >+ new SortMembersCleanUp(settings) >+ }; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected String getActionName() { >+ return ActionMessages.SortMembersAction_dialog_title; >+ } >+ >+ private boolean hasMembersToSort(ICompilationUnit[] units) throws JavaModelException { >+ for (int i= 0; i < units.length; i++) { >+ if (hasMembersToSort(units[i].getTypes())) >+ return true; >+ } >+ >+ return false; >+ } >+ >+ private boolean hasMembersToSort(IJavaElement[] members) throws JavaModelException { >+ if (members.length > 1) >+ return true; >+ >+ if (members.length == 0) >+ return false; >+ >+ IJavaElement elem= members[0]; >+ if (!(elem instanceof IParent)) >+ return false; >+ >+ return hasMembersToSort(((IParent)elem).getChildren()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected void performRefactoring(ICompilationUnit[] units, ICleanUp[] cleanUps) throws JavaModelException, InvocationTargetException { >+ RefactoringExecutionStarter.startCleanupRefactoring(units, cleanUps, getShell(), false, getActionName()); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 133277
:
57663
|
57664
|
58624
|
62936
| 62938