--- /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.message.ui.test;\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.osgi.util.NLS;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.message.DetailStatus;\r
+import org.simantics.message.IDetailStatus;\r
+import org.simantics.message.ILogger;\r
+import org.simantics.message.MessageService;\r
+import org.simantics.message.ReferenceSerializationException;\r
+import org.simantics.message.ui.Activator;\r
+import org.simantics.message.util.MessageUtil;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class TestResourceStatusHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Resource[] rs = ResourceAdaptionUtils.toResources(HandlerUtil.getCurrentSelection(event));\r
+ ILogger log = MessageService.getDefault();\r
+ \r
+ Session s = SimanticsUI.peekSession();\r
+ if (s == null)\r
+ return null;\r
+\r
+ try {\r
+ int code = 0;\r
+ for (Resource r : rs) {\r
+ log.log(new DetailStatus(IDetailStatus.DEBUG, Activator.PLUGIN_ID, code++,\r
+ "Logged reference to selected resource",\r
+ NLS.bind(Messages.Test_message, MessageUtil.resource(s, r, "this link")),\r
+ null));\r
+ }\r
+ } catch (ReferenceSerializationException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ return null;\r
+ }\r
+\r
+}\r