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.ui.workbench;
14 import java.util.function.Consumer;
15 import java.util.function.Supplier;
17 import org.eclipse.core.runtime.IStatus;
18 import org.eclipse.core.runtime.Status;
19 import org.eclipse.swt.widgets.Display;
20 import org.simantics.db.procedure.Listener;
21 import org.simantics.ui.internal.Activator;
24 * @author Tuukka Lehtonen
26 public class TitleUpdater implements Listener<String> {
28 private final Display display;
29 private final Consumer<String> callback;
30 private final Supplier<Boolean> disposed;
32 public TitleUpdater(Display display, Consumer<String> titleChangedCallback, Supplier<Boolean> disposed) {
33 this.display = display;
34 this.callback = titleChangedCallback;
35 this.disposed = disposed;
39 public void execute(final String result) {
40 display.asyncExec(new Runnable() {
44 callback.accept(result);
50 public boolean isDisposed() {
51 return disposed.get();
55 public void exception(Throwable t) {
56 Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Title update failed.", t));