1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Association for Decentralized
3 * Information Management in Industry THTH ry.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the THTH Simantics
6 * Division Member Component License which accompanies this
7 * distribution, and is available at
8 * http://www.simantics.org/legal/sdmcl-v10.html
11 * Semantum Oy - initial API and implementation
12 *******************************************************************************/
13 package org.simantics.spreadsheet.common;
15 import org.eclipse.jface.resource.FontDescriptor;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.graphics.FontData;
18 import org.simantics.document.server.io.IFont;
19 import org.simantics.document.server.io.ITreeTableCell;
20 import org.simantics.document.server.io.SimpleFont;
22 public class TreeTableCell extends TableCell implements ITreeTableCell {
24 private int parent = -1;
26 private boolean editable = true;
29 public TreeTableCell() {
32 public TreeTableCell(String text, Object data, Object font, int parent, int row, int column, boolean editable) {
33 super(column, row, 0, 0, text, (IFont)font, null, null, false, 1, 1);
34 this.editable = editable;
39 public static TreeTableCell createTreeTableCell(String text, Object data, Object font, int parent, int row, int column, boolean editable) {
40 return new TreeTableCell(text, data, extractIFont(font), parent, row, column, editable);
43 private static IFont extractIFont(Object font) {
44 if(font instanceof FontDescriptor) {
45 FontDescriptor descriptor = (FontDescriptor)font;
49 for(FontData d : descriptor.getFontData()) {
50 System.err.println("data: " + d);
52 if((d.getStyle() & SWT.ITALIC) != 0) style += "Italic";
53 if((d.getStyle() & SWT.BOLD) != 0) style += "Bold";
56 return new SimpleFont(family, style, size);
61 public void setParent(int parent) {
66 public int getParent() {
71 public Object getData() {
76 public boolean isEditable() {