Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.simantics.h2d;bundle-version="1.0.0",
- org.simantics.db;bundle-version="0.6.2",
- org.simantics.db.management;bundle-version="0.6.2",
org.simantics.layer0.utils;bundle-version="0.6.2",
org.simantics.scenegraph;bundle-version="0.9.0",
org.junit4;bundle-version="4.5.0",
org.simantics.project;bundle-version="1.0.0",
org.eclipse.jface.text;bundle-version="3.5.0",
org.eclipse.ui.editors;bundle-version="3.5.0",
- org.jfree.jchart;bundle-version="1.0.13",
org.jfree.jcommon;bundle-version="1.0.16",
+ org.jfree.jchart;bundle-version="1.0.13",
org.simantics.modelica;bundle-version="1.0.0",
- org.simantics.browsing.ui;bundle-version="0.9.0",
- org.simantics.browsing.ui.common;bundle-version="0.9.0",
org.apache.log4j;bundle-version="1.2.15",
org.eclipse.ui.console;bundle-version="3.4.0",
org.simantics.browsing.ui.graph;bundle-version="0.9.0",
class="org.simantics.ui.contribution.OpenWithMenuContribution"\r
id="org.simantics.sysdyn.ui.browser.openWithMenu">\r
</dynamic>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.deleteItem"\r
+ label="Delete"\r
+ style="push"\r
+ tooltip="Remove from database">\r
+ <visibleWhen checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
</menuContribution>\r
<menuContribution\r
locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
id="org.simantics.sysdyn.ui.rename"\r
name="Rename">\r
</command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.deleteItem"\r
+ name="Delete Item">\r
+ </command>\r
<command\r
defaultHandler="org.simantics.sysdyn.ui.actions.ToggleSimulation"\r
id="org.simantics.sysdyn.ui.simulate"\r
class="org.simantics.sysdyn.ui.trend.PinTrend"\r
commandId="org.simantics.sysdyn.ui.trend.view.pin">\r
</handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.UnlinkItemHandler"\r
+ commandId="org.simantics.sysdyn.ui.deleteItem">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="http://www.simantics.org/Sysdyn-1.0/Configuration"\r
+ property="org.simantics.graph.resourceType">\r
+ </test>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
</extension>
</plugin>\r
--- /dev/null
+/*******************************************************************************\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.sysdyn.ui.handlers;\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.dialogs.MessageDialog;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class DeleteItemHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+ if (resources.length == 0)\r
+ return null;\r
+\r
+ MessageDialog dialog = new MessageDialog(shell, "Delete Item", null, "Are you sure?", 0,\r
+ new String[] { "OK", "Cancel" }, 0);\r
+ dialog.create();\r
+ if (dialog.open() == 0)\r
+ deleteItem(resources);\r
+\r
+ return null;\r
+ }\r
+\r
+ private void deleteItem(final Resource[] resources) {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ for (Resource r : resources)\r
+ GraphUtils.remove(graph, r);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\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.sysdyn.ui.handlers;\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.dialogs.MessageDialog;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class UnlinkItemHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+ if (resources.length == 0)\r
+ return null;\r
+\r
+ MessageDialog dialog = new MessageDialog(shell, "Delete Item", null, "Are you sure?", 0,\r
+ new String[] { "OK", "Cancel" }, 0);\r
+ dialog.create();\r
+ if (dialog.open() == 0)\r
+ deleteItem(resources);\r
+\r
+ return null;\r
+ }\r
+\r
+ private void deleteItem(final Resource[] resources) {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ Builtins b = graph.getBuiltins();\r
+ for (Resource r : resources)\r
+ graph.deny(r, b.PartOf);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+ }\r
+\r
+}
\ No newline at end of file