1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.participant;
\r
14 import org.eclipse.jface.action.IStatusLineManager;
\r
15 import org.eclipse.swt.widgets.Display;
\r
16 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
\r
17 import org.simantics.utils.threads.SWTThread;
\r
18 import org.simantics.utils.threads.ThreadUtils;
\r
21 * A utility participant for accessing the workbench status line.
\r
23 * @author Tuukka Lehtonen
\r
25 * TODO: add scheduled task to remove messages from status bar
\r
27 public class WorkbenchStatusLine extends AbstractCanvasParticipant {
\r
29 private final IStatusLineManager statusLine;
\r
31 public WorkbenchStatusLine(IStatusLineManager statusLine) {
\r
32 this.statusLine = statusLine;
\r
35 public IStatusLineManager getStatusLine() {
\r
39 public void message(final String message) {
\r
40 if (statusLine == null)
\r
43 swtExec(new Runnable() {
\r
46 statusLine.setMessage(message);
\r
47 statusLine.setErrorMessage(null);
\r
52 public void error(final String message) {
\r
53 if (statusLine == null)
\r
56 swtExec(new Runnable() {
\r
59 statusLine.setErrorMessage(message);
\r
64 protected void swtExec(Runnable r) {
\r
65 ThreadUtils.asyncExec(SWTThread.getThreadAccess(Display.getDefault()), r);
\r