From 8360fe5756f40b0f43f673394f1fef098d31627e Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Tue, 25 Jul 2017 16:13:25 +0300 Subject: [PATCH] TreeGridWidget improvements refs #7381 Change-Id: I79a2650fef07142cc95c6bd31e901e062baeba75 --- .../document/server/io/ITreeTableCell.java | 8 +++----- .../document/server/io/JSONObjectUtils.java | 20 +++++++++++++++++++ .../spreadsheet/common/TreeTableCell.java | 10 ++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java index 9bf10fb3a..1849273d1 100644 --- a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java +++ b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java @@ -1,11 +1,9 @@ package org.simantics.document.server.io; public interface ITreeTableCell extends ITableCell { - - int getParent(); - - Object getData(); - boolean isEditable(); + int getParent(); + Object getData(); + boolean isEditable(); } diff --git a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/JSONObjectUtils.java b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/JSONObjectUtils.java index 558ee3204..004166dc0 100644 --- a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/JSONObjectUtils.java +++ b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/JSONObjectUtils.java @@ -314,6 +314,26 @@ public class JSONObjectUtils { return Collections.emptyList(); } + @SuppressWarnings("unchecked") + public static Collection getTreeTableCells(IJSONObject object) { + try { + Object tableCells = object.getValue("tableCells"); + if (tableCells instanceof String) { + String tableCellsS = (String) tableCells; + if (tableCellsS.length() == 0) + return Collections.emptyList(); + } + if (tableCells != null) { + return (List) tableCells; + } else { + return Collections.emptyList(); + } + } catch (ClassCastException e) { + e.printStackTrace(); + } + return Collections.emptyList(); + } + public static Collection getFiles(IJSONObject object) { try { @SuppressWarnings("unchecked") diff --git a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java index baf3b83de..299c7c796 100644 --- a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java +++ b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java @@ -36,6 +36,16 @@ public class TreeTableCell extends TableCell implements ITreeTableCell { this.data = data; } + @Override + public int getRowSpan() { + throw new IllegalStateException("Row span is not supported in TreeTableCell"); + } + + @Override + public int getColumnSpan() { + throw new IllegalStateException("Column span is not supported in TreeTableCell"); + } + public static TreeTableCell createTreeTableCell(String text, Object data, Object font, int parent, int row, int column, boolean editable) { return new TreeTableCell(text, data, extractIFont(font), parent, row, column, editable); } -- 2.47.1