-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.actions;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import java.util.UUID;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.ui.IWorkbenchPart;\r
-import org.eclipse.ui.commands.ICommandService;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.eclipse.ui.services.IServiceScopes;\r
-import org.simantics.browsing.ui.platform.PropertyPageView;\r
-import org.simantics.utils.ui.ExceptionUtils;\r
-import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class DuplicatePinnedViewHandler extends AbstractHandler {\r
-\r
- private static final String PIN_SELECTION_COMMAND = "org.simantics.modeling.ui.pinSelection";\r
-\r
- @Override\r
- public Object execute(ExecutionEvent event) throws ExecutionException {\r
- IWorkbenchPart originalPart = HandlerUtil.getActivePartChecked(event);\r
- if (!(originalPart instanceof PropertyPageView))\r
- return null;\r
- PropertyPageView originalPropertyView = (PropertyPageView) originalPart;\r
-\r
- try {\r
- // Activate a new unique instance of the same property page view.\r
- // Its initialization procedures and IContributedContentsView\r
- // implementation should take care that the view will be initialized\r
- // with a property page just like the original.\r
- ISelection originalSelection = originalPropertyView.getLastSelection();\r
-\r
- final String id = originalPart.getSite().getId() + "Pinned:" + UUID.randomUUID().toString();\r
- PropertyPageView newPart = (PropertyPageView) WorkbenchUtils.activateView(id);\r
-\r
- newPart.partActivated(originalPart);\r
- newPart.selectionChanged(originalPart, originalSelection);\r
-\r
- // Make sure that the view is pinned and that its pinned button is in the right state.\r
- newPart.pinWorkbenchSelection(true);\r
-\r
- ICommandService commandService = (ICommandService) newPart.getViewSite().getService(ICommandService.class);\r
- Map<Object, Object> filter = new HashMap<Object, Object>();\r
- filter.put(IServiceScopes.PARTSITE_SCOPE, newPart.getSite());\r
- commandService.refreshElements(PIN_SELECTION_COMMAND, filter);\r
-\r
- } catch (Exception e) {\r
- ExceptionUtils.logAndShowError(e);\r
- }\r
-\r
- return null;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.ui.actions;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.services.IServiceScopes;
+import org.simantics.browsing.ui.platform.PropertyPageView;
+import org.simantics.utils.ui.ExceptionUtils;
+import org.simantics.utils.ui.workbench.WorkbenchUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class DuplicatePinnedViewHandler extends AbstractHandler {
+
+ private static final String PIN_SELECTION_COMMAND = "org.simantics.modeling.ui.pinSelection";
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchPart originalPart = HandlerUtil.getActivePartChecked(event);
+ if (!(originalPart instanceof PropertyPageView))
+ return null;
+ PropertyPageView originalPropertyView = (PropertyPageView) originalPart;
+
+ try {
+ // Activate a new unique instance of the same property page view.
+ // Its initialization procedures and IContributedContentsView
+ // implementation should take care that the view will be initialized
+ // with a property page just like the original.
+ ISelection originalSelection = originalPropertyView.getLastSelection();
+
+ final String id = originalPart.getSite().getId() + "Pinned:" + UUID.randomUUID().toString();
+ PropertyPageView newPart = (PropertyPageView) WorkbenchUtils.activateView(id);
+
+ newPart.partActivated(originalPart);
+ newPart.selectionChanged(originalPart, originalSelection);
+
+ // Make sure that the view is pinned and that its pinned button is in the right state.
+ newPart.pinWorkbenchSelection(true);
+
+ ICommandService commandService = (ICommandService) newPart.getViewSite().getService(ICommandService.class);
+ Map<Object, Object> filter = new HashMap<Object, Object>();
+ filter.put(IServiceScopes.PARTSITE_SCOPE, newPart.getSite());
+ commandService.refreshElements(PIN_SELECTION_COMMAND, filter);
+
+ } catch (Exception e) {
+ ExceptionUtils.logAndShowError(e);
+ }
+
+ return null;
+ }
+
+}