Bug 273275 - "CollapseAll" for ant view
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/CollapseAllHandler.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/CollapseAllHandler.java
new file mode 100644
index 0000000..8eab1a1
--- /dev/null
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/CollapseAllHandler.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.ant.internal.ui.views.actions;
+
+import org.eclipse.ant.internal.ui.views.AntView;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Default handler for Collapse All in the Ant view
+ * 
+ * @since 3.5.500
+ */
+public class CollapseAllHandler extends AbstractHandler {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+	 */
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		IWorkbenchPart part = HandlerUtil.getActivePart(event);
+		if (part instanceof AntView) {
+			AntView view = (AntView) part;
+			TreeViewer viewer = view.getViewer();
+			try {
+				viewer.getTree().setRedraw(false);
+				viewer.collapseAll();
+			}
+			finally {
+				viewer.getTree().setRedraw(true);
+			}
+		}
+		return null;
+	}
+}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/plugin.xml b/ant/org.eclipse.ant.ui/plugin.xml
index 948559d..0be2aa2 100644
--- a/ant/org.eclipse.ant.ui/plugin.xml
+++ b/ant/org.eclipse.ant.ui/plugin.xml
@@ -858,6 +858,14 @@
                  style="push">
            </command>
         </menuContribution>
+        <menuContribution
+              allPopups="false"
+              locationURI="toolbar:org.eclipse.ant.ui.views.AntView?endof=additions">
+           <command
+                 commandId="org.eclipse.ui.navigate.collapseAll"
+                 style="push">
+           </command>
+        </menuContribution>
      </extension>
      <extension
            point="org.eclipse.core.expressions.definitions">
@@ -870,5 +878,21 @@
               </equals>
            </with>
         </definition>
+     </extension>
+     <extension
+           point="org.eclipse.ui.handlers">
+        <handler
+              class="org.eclipse.ant.internal.ui.views.actions.CollapseAllHandler"
+              commandId="org.eclipse.ui.navigate.collapseAll"
+              helpContextId="ant_collapse_all_handler">
+           <activeWhen>
+              <with
+                    variable="activePartId">
+                 <equals
+                       value="org.eclipse.ant.ui.views.AntView">
+                 </equals>
+              </with>
+           </activeWhen>
+        </handler>
      </extension>	
 </plugin>