--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 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
+ *******************************************************************************/
+package org.eclipse.jdt.internal.ui.actions;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.jface.text.ITextSelection;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+
+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
+
+import org.eclipse.jdt.ui.actions.OrganizeImportsAction;
+import org.eclipse.jdt.ui.cleanup.CleanUpOptions;
+import org.eclipse.jdt.ui.cleanup.ICleanUp;
+
+import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
+import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+
+public class MultiOrganizeImportAction extends CleanUpAction {
+
+ public MultiOrganizeImportAction(IWorkbenchSite site) {
+ super(site);
+
+ setText(ActionMessages.OrganizeImportsAction_label);
+ setToolTipText(ActionMessages.OrganizeImportsAction_tooltip);
+ setDescription(ActionMessages.OrganizeImportsAction_description);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION);
+ }
+
+ public MultiOrganizeImportAction(JavaEditor editor) {
+ super(editor);
+
+ setText(ActionMessages.OrganizeImportsAction_label);
+ setToolTipText(ActionMessages.OrganizeImportsAction_tooltip);
+ setDescription(ActionMessages.OrganizeImportsAction_description);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION);
+ }
+
+ @Override
+ protected ICleanUp[] getCleanUps(ICompilationUnit[] units) {
+ Map<String, String> settings= new Hashtable<String, String>();
+ settings.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpOptions.TRUE);
+ ImportsCleanUp importsCleanUp= new ImportsCleanUp(settings);
+
+ return new ICleanUp[] {
+ importsCleanUp
+ };
+ }
+
+ @Override
+ protected String getActionName() {
+ return ActionMessages.OrganizeImportsAction_error_title;
+ }
+
+ public void generated_7866736237107717235(OrganizeImportsAction organizeimportsaction, ITextSelection selection) {
+ selectionChanged(selection);
+ organizeimportsaction.setEnabled(isEnabled());
+ }
+
+ public void generated_4114549769882915287(OrganizeImportsAction organizeimportsaction, IStructuredSelection selection) {
+ selectionChanged(selection);
+ organizeimportsaction.setEnabled(isEnabled());
+ }
+
+ public void generated_7198141821551489748(OrganizeImportsAction organizeimportsaction, IStructuredSelection selection) {
+ ICompilationUnit[] cus= getCompilationUnits(selection);
+ if (cus.length == 0) {
+ MessageDialog.openInformation(organizeimportsaction.getShell(), ActionMessages.OrganizeImportsAction_EmptySelection_title, ActionMessages.OrganizeImportsAction_EmptySelection_description);
+ } else if (cus.length == 1) {
+ organizeimportsaction.run(cus[0]);
+ } else {
+ run(selection);
+ }
+ }
+}