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.g2d.participant;
14 import org.eclipse.jface.action.IStatusLineManager;
15 import org.eclipse.swt.widgets.Display;
16 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
17 import org.simantics.utils.threads.SWTThread;
18 import org.simantics.utils.threads.ThreadUtils;
21 * A utility participant for accessing the workbench status line.
23 * @author Tuukka Lehtonen
25 * TODO: add scheduled task to remove messages from status bar
27 public class WorkbenchStatusLine extends AbstractCanvasParticipant {
29 private final IStatusLineManager statusLine;
31 public WorkbenchStatusLine(IStatusLineManager statusLine) {
32 this.statusLine = statusLine;
35 public IStatusLineManager getStatusLine() {
39 public void message(final String message) {
40 if (statusLine == null)
43 swtExec(new Runnable() {
46 statusLine.setMessage(message);
47 statusLine.setErrorMessage(null);
52 public void error(final String message) {
53 if (statusLine == null)
56 swtExec(new Runnable() {
59 statusLine.setErrorMessage(message);
64 protected void swtExec(Runnable r) {
65 ThreadUtils.asyncExec(SWTThread.getThreadAccess(Display.getDefault()), r);