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.spreadsheet.ui;
14 import javax.swing.JComponent;
15 import javax.swing.JTable;
16 import javax.swing.UIManager;
17 import javax.swing.UnsupportedLookAndFeelException;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.events.DisposeEvent;
21 import org.eclipse.swt.events.DisposeListener;
22 import org.eclipse.swt.layout.FillLayout;
23 import org.eclipse.swt.widgets.Composite;
24 import org.simantics.g2d.chassis.SWTChassis;
25 import org.simantics.spreadsheet.Adaptable;
26 import org.simantics.spreadsheet.ClientModel;
27 import org.simantics.utils.ui.jface.ActiveSelectionProvider;
29 public class Spreadsheet extends Composite {
31 public static boolean DEBUG = false;
33 final private SpreadsheetModel sm;
35 public SpreadsheetModel getModel() {
39 public Spreadsheet(Composite parent, int style, Adaptable serverInterface, ActiveSelectionProvider selectionProvider) {
43 sm = new SpreadsheetModel(serverInterface, selectionProvider);
45 addDisposeListener(new DisposeListener() {
47 public void widgetDisposed(DisposeEvent e) {
53 public ClientModel getClientModel() {
55 return sm.getClientModel();
59 public ClientModel getClientInterface() {
61 return sm.getClientInterface();
65 public void defaultInitializeUI() {
69 UIManager.setLookAndFeel(
70 UIManager.getSystemLookAndFeelClassName());
72 catch (UnsupportedLookAndFeelException e) {
75 catch (ClassNotFoundException e) {
78 catch (InstantiationException e) {
81 catch (IllegalAccessException e) {
85 setLayout(new FillLayout(SWT.NONE));
89 // Makes sure that the UI is up-to-date now that
90 // ClientTableModel is in play.
91 sm.getClientInterface().flush();
95 public JTable createTable(Composite parent) {
97 SWTChassis c = new SWTChassis(parent, 0){
100 protected JComponent createSwingComponent() {
101 return sm.createComponent(null);