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.message.ui.test;
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.osgi.util.NLS;
18 import org.eclipse.ui.handlers.HandlerUtil;
19 import org.simantics.db.Resource;
20 import org.simantics.db.Session;
21 import org.simantics.message.DetailStatus;
22 import org.simantics.message.IDetailStatus;
23 import org.simantics.message.ILogger;
24 import org.simantics.message.MessageService;
25 import org.simantics.message.ReferenceSerializationException;
26 import org.simantics.message.ui.Activator;
27 import org.simantics.message.util.MessageUtil;
28 import org.simantics.ui.SimanticsUI;
29 import org.simantics.ui.utils.ResourceAdaptionUtils;
32 * @author Tuukka Lehtonen
34 public class TestResourceStatusHandler extends AbstractHandler {
37 public Object execute(ExecutionEvent event) throws ExecutionException {
38 Resource[] rs = ResourceAdaptionUtils.toResources(HandlerUtil.getCurrentSelection(event));
39 ILogger log = MessageService.getDefault();
41 Session s = SimanticsUI.peekSession();
47 for (Resource r : rs) {
48 log.log(new DetailStatus(IDetailStatus.DEBUG, Activator.PLUGIN_ID, code++,
49 "Logged reference to selected resource",
50 NLS.bind(Messages.Test_message, MessageUtil.resource(s, r, "this link")),
53 } catch (ReferenceSerializationException e) {