| /******************************************************************************* |
| * Copyright (c) 2013 IBM Corporation and others. |
| * |
| * This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * 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; |
| } |
| } |