1 /*******************************************************************************
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * VTT Technical Research Centre of Finland - initial API and implementation
10 *******************************************************************************/
11 package org.simantics.diagram.handler;
14 import org.eclipse.core.commands.AbstractHandler;
15 import org.eclipse.core.commands.ExecutionEvent;
16 import org.eclipse.core.commands.ExecutionException;
17 import org.eclipse.core.commands.IHandler;
18 import org.eclipse.ui.IWorkbenchPart;
19 import org.eclipse.ui.handlers.HandlerUtil;
20 import org.eclipse.ui.part.IPage;
21 import org.simantics.diagram.symbollibrary.ui.SymbolLibraryPage;
22 import org.simantics.diagram.symbollibrary.ui.SymbolPageView;
24 public class CollapseAll extends AbstractHandler implements IHandler {
27 public Object execute(ExecutionEvent event) throws ExecutionException {
29 IWorkbenchPart part = HandlerUtil.getActivePart(event);
30 if(part == null) return null;
31 if(part instanceof SymbolPageView) {
32 SymbolPageView view = (SymbolPageView)part;
33 IPage page = view.getCurrentPage();
34 if(page == null) return null;
35 if(page instanceof SymbolLibraryPage) {
36 SymbolLibraryPage libraryPage = (SymbolLibraryPage)page;
37 libraryPage.setAllExpandedStates(false);