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.workbench.internal.contributions;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.ui.IWorkbenchWindow;
17 import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
18 import org.simantics.db.management.ISessionContext;
19 import org.simantics.db.management.ISessionContextChangedListener;
20 import org.simantics.db.management.ISessionContextProvider;
21 import org.simantics.db.management.SessionContextChangedEvent;
22 import org.simantics.ui.SimanticsUI;
23 import org.simantics.workbench.internal.Activator;
27 * @author Tuukka Lehtonen
29 public class GraphRequestStatusContribution extends WorkbenchWindowControlContribution implements ISessionContextChangedListener {
31 GraphRequestStatusTrim trim;
32 ISessionContextProvider contextProvider;
35 public String getId() {
36 return "org.simantics.workbench.db.monitor";
40 protected Control createControl(Composite parent) {
41 IWorkbenchWindow window = getWorkbenchWindow();
42 contextProvider = SimanticsUI.getSessionContextProvider(window);
43 contextProvider.addContextChangedListener(this);
45 trim = new GraphRequestStatusTrim(parent, Activator.getDefault().getPreferenceStore());
46 ISessionContext ctx = SimanticsUI.getSessionContext();
48 trim.attachToSession(ctx.getSession());
54 public void dispose() {
55 contextProvider.removeContextChangedListener(this);
61 public void sessionContextChanged(SessionContextChangedEvent event) {
62 // System.out.println("session changed for '" + event.getHandle() + "' from '" + event.getOldValue() + "' to '" + event.getNewValue() + "'");
63 GraphRequestStatusTrim trim = this.trim;
65 ISessionContext ctx = event.getNewValue();
66 trim.attachToSession((ctx != null) ? ctx.getSession() : null);