From: Antti Villberg Date: Mon, 23 Jul 2018 18:50:47 +0000 (+0300) Subject: Functions for manipulating column beans X-Git-Tag: v1.43.0~136^2~424 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ca33d642807f24adfe6a34147700058923dcdd92;p=simantics%2Fplatform.git Functions for manipulating column beans gitlab #51 Change-Id: I27a62a07324fa3dc48f5d80efa660881f85940a1 --- diff --git a/bundles/org.simantics.document.swt.core/scl/SWT/All.scl b/bundles/org.simantics.document.swt.core/scl/SWT/All.scl index 0ef41f97c..f87f939ec 100644 --- a/bundles/org.simantics.document.swt.core/scl/SWT/All.scl +++ b/bundles/org.simantics.document.swt.core/scl/SWT/All.scl @@ -28,5 +28,9 @@ importJava "org.simantics.document.swt.core.scl.SCL" where propertyDisplayValue :: Variable -> String -> String propertyValueSetter :: Variable -> String -> AbstractEventHandler - - \ No newline at end of file + + columnsBean :: Resource -> ColumnsBean + columnBeans :: ColumnsBean -> [ColumnBean] + + columnBeanKey :: ColumnBean -> String + columnBeanLabel :: ColumnBean -> String diff --git a/bundles/org.simantics.document.swt.core/scl/SWT/Types.scl b/bundles/org.simantics.document.swt.core/scl/SWT/Types.scl index 03fd4d9a0..28a942b78 100644 --- a/bundles/org.simantics.document.swt.core/scl/SWT/Types.scl +++ b/bundles/org.simantics.document.swt.core/scl/SWT/Types.scl @@ -2,6 +2,9 @@ importJava "org.simantics.document.swt.core.bean.ColumnBean" where data ColumnBean +importJava "org.simantics.document.swt.core.bean.ColumnsBean" where + data ColumnsBean + importJava "org.simantics.browsing.ui.StatePersistor" where data StatePersistor diff --git a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/scl/SCL.java b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/scl/SCL.java index ad5cf7091..0c3529bfa 100644 --- a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/scl/SCL.java +++ b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/scl/SCL.java @@ -1,5 +1,6 @@ package org.simantics.document.swt.core.scl; +import java.util.ArrayList; import java.util.List; import org.simantics.databoard.Bindings; @@ -17,6 +18,8 @@ import org.simantics.document.server.io.CommandContext; import org.simantics.document.server.io.CommandResult; import org.simantics.document.server.serverResponse.ServerResponse; import org.simantics.document.swt.core.SWTViews; +import org.simantics.document.swt.core.bean.ColumnBean; +import org.simantics.document.swt.core.bean.ColumnsBean; import org.simantics.scl.runtime.SCLContext; import org.simantics.scl.runtime.function.Function1; import org.simantics.scl.runtime.reporting.SCLReportingHandler; @@ -108,4 +111,22 @@ public class SCL { return WorkbenchSelectionUtils.getPossibleResource(wse); } + public static ColumnsBean columnsBean(ReadGraph graph, Resource value) throws DatabaseException { + return graph.getValue(value, ColumnsBean.BINDING); + } + + public static List columnBeans(ColumnsBean bean) { + ArrayList result = new ArrayList<>(); + for(ColumnBean b : bean.columns) result.add(b); + return result; + } + + public static String columnBeanKey(ColumnBean bean) { + return bean.key; + } + + public static String columnBeanLabel(ColumnBean bean) { + return bean.label; + } + }