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.Simantics;
20 import org.simantics.db.Resource;
21 import org.simantics.db.Session;
22 import org.simantics.message.DetailStatus;
23 import org.simantics.message.IDetailStatus;
24 import org.simantics.message.ILogger;
25 import org.simantics.message.MessageService;
26 import org.simantics.message.ReferenceSerializationException;
27 import org.simantics.message.ui.Activator;
28 import org.simantics.message.util.MessageUtil;
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 = Simantics.peekSession();
47 for (Resource r : rs) {
48 log.log(new DetailStatus(IDetailStatus.DEBUG, Activator.PLUGIN_ID, code++,
49 "Logged reference to selected resource", //$NON-NLS-1$
50 NLS.bind("<p>This is a detailed message that contains links to related information. Follow {0} to open your favorite editor for the database resource.</p>", MessageUtil.resource(s, r, "this link")), //$NON-NLS-1$
53 } catch (ReferenceSerializationException e) {