1 package org.simantics.spreadsheet.ui;
3 import java.awt.Graphics2D;
4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
6 import java.awt.event.FocusListener;
7 import java.awt.geom.Rectangle2D;
9 import javax.swing.JComponent;
11 import org.simantics.scenegraph.swing.ComponentNode;
12 import org.simantics.spreadsheet.Adaptable;
13 import org.simantics.spreadsheet.ClientModel;
15 public class SheetNode extends ComponentNode<JComponent> implements ActionListener, FocusListener {
17 private static final long serialVersionUID = -8212264868316567181L;
19 private SpreadsheetModel sm;
21 public void init(Adaptable serverInterface) {
24 sm = new SpreadsheetModel(serverInterface, null);
25 component = sm.createComponent(this);
26 component.addFocusListener(this);
32 public ClientModel getModifier() {
33 return sm.getClientInterface();
36 protected ActionListener actionListener = null;
38 public void setActionListener(ActionListener actionListener) {
39 this.actionListener = actionListener;
44 public void actionPerformed(ActionEvent e) {
45 if(actionListener != null)
46 actionListener.actionPerformed(e);
47 if(container.getParent() != null)
48 container.getParent().requestFocusInWindow(); // Loose focus
53 public void setBounds(Rectangle2D bounds) {
55 container.setBounds(0, 0, (int)bounds.getWidth(), (int)bounds.getHeight());
56 container.setSize((int)bounds.getWidth(), (int)bounds.getHeight());
61 public void render(Graphics2D g2d) {
63 if(sm == null) return;
64 if(sm.getTable() == null) return;