]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/handler/CollapseAll.java
(refs #7595) Started SCL/Reflection module
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / handler / CollapseAll.java
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
7  *
8  * Contributors:
9  *     VTT Technical Research Centre of Finland - initial API and implementation
10  *******************************************************************************/
11 package org.simantics.diagram.handler;
12
13
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;
23
24 public class CollapseAll extends AbstractHandler implements IHandler {
25
26     @Override
27     public Object execute(ExecutionEvent event) throws ExecutionException {
28         
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);
38                 }
39         }
40         
41         return null;
42         
43     }
44
45 }