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.modeling.ui.actions;
16 import org.eclipse.core.commands.AbstractHandler;
17 import org.eclipse.core.commands.ExecutionEvent;
18 import org.eclipse.core.commands.ExecutionException;
19 import org.eclipse.ui.IWorkbenchPart;
20 import org.eclipse.ui.IWorkbenchPartSite;
21 import org.eclipse.ui.commands.IElementUpdater;
22 import org.eclipse.ui.handlers.HandlerUtil;
23 import org.eclipse.ui.menus.UIElement;
24 import org.eclipse.ui.services.IServiceScopes;
25 import org.simantics.browsing.ui.platform.PropertyPageView;
27 public class PinSelectionHandler extends AbstractHandler implements IElementUpdater {
30 public Object execute(ExecutionEvent event) throws ExecutionException {
31 IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
32 if (!(part instanceof PropertyPageView))
35 PropertyPageView ppv = (PropertyPageView) part;
36 ppv.pinWorkbenchSelection(!ppv.isWorkbenchSelectionPinned());
41 @SuppressWarnings("rawtypes")
43 public void updateElement(UIElement element, Map parameters) {
44 IWorkbenchPartSite site = (IWorkbenchPartSite) parameters.get(IServiceScopes.PARTSITE_SCOPE);
46 IWorkbenchPart part = site.getPart();
47 if (part instanceof PropertyPageView) {
48 PropertyPageView ppv = (PropertyPageView) part;
49 element.setChecked(ppv.isWorkbenchSelectionPinned());