1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.symbollibrary.ui;
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.swt.widgets.Control;
18 import org.eclipse.ui.IWorkbenchPart;
19 import org.eclipse.ui.handlers.HandlerUtil;
20 import org.eclipse.ui.part.IPage;
21 import org.eclipse.ui.part.PageBookView;
24 * @author Tuukka Lehtonen
26 public class ActivateFilterHandler extends AbstractHandler {
28 FilterArea getFilterArea(IWorkbenchPart part) {
29 if (part instanceof SymbolLibraryView) {
30 SymbolLibraryView slv = (SymbolLibraryView) part;
31 return slv.getFilterArea();
33 if (part instanceof SymbolPageView) {
34 PageBookView pv = (PageBookView) part;
35 IPage page = pv.getCurrentPage();
36 Control ctrl = page.getControl();
37 if (ctrl instanceof SymbolLibraryComposite) {
38 return ((SymbolLibraryComposite) ctrl).getFilterArea();
45 public Object execute(ExecutionEvent event) throws ExecutionException {
46 IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
47 FilterArea filter = getFilterArea(part);
48 if (filter != null && !filter.isDisposed())