]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/handler/CollapseAll.java
Sync git svn branch with SVN repository r33176.
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / handler / CollapseAll.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.diagram.handler;\r
12 \r
13 \r
14 import org.eclipse.core.commands.AbstractHandler;\r
15 import org.eclipse.core.commands.ExecutionEvent;\r
16 import org.eclipse.core.commands.ExecutionException;\r
17 import org.eclipse.core.commands.IHandler;\r
18 import org.eclipse.ui.IWorkbenchPart;\r
19 import org.eclipse.ui.handlers.HandlerUtil;\r
20 import org.eclipse.ui.part.IPage;\r
21 import org.simantics.diagram.symbollibrary.ui.SymbolLibraryPage;\r
22 import org.simantics.diagram.symbollibrary.ui.SymbolPageView;\r
23 \r
24 public class CollapseAll extends AbstractHandler implements IHandler {\r
25 \r
26     @Override\r
27     public Object execute(ExecutionEvent event) throws ExecutionException {\r
28         \r
29         IWorkbenchPart part = HandlerUtil.getActivePart(event);\r
30         if(part == null) return null;\r
31         if(part instanceof SymbolPageView) {\r
32                 SymbolPageView view = (SymbolPageView)part;\r
33                 IPage page = view.getCurrentPage();\r
34                 if(page == null) return null;\r
35                 if(page instanceof SymbolLibraryPage) {\r
36                         SymbolLibraryPage libraryPage = (SymbolLibraryPage)page;\r
37                         libraryPage.setAllExpandedStates(false);\r
38                 }\r
39         }\r
40         \r
41         return null;\r
42         \r
43     }\r
44 \r
45 }\r