From 7be4bee75769c628c944b42d4c5b8563c72bc6d8 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Fri, 24 Feb 2017 14:47:17 +0200 Subject: [PATCH] Misc. changes to support Selection View in modelled documents refs #7050 Change-Id: Ia088db3d75c8d9963d0e513d1e6042a63b13e6c8 --- .../ConstantLabelDecorationRule.java | 3 + .../document/server/io/ITreeTableCell.java | 5 ++ .../document/server/io/JSONObjectUtils.java | 69 ++++++++++++++++++ .../scl/Document/All.scl | 7 ++ .../Simantics/Testing/ActionBrowseContext.scl | 4 +- .../scl/Simantics/Testing/BrowseContext.scl | 8 +- .../graph.tg | Bin 11557 -> 11563 bytes .../graph/Selectionview.pgraph | 2 +- .../graph.tg | Bin 7756 -> 8786 bytes .../graph/SelectionViewUi.pgraph | 10 +++ .../graph/scl/SCLMain.scl | 7 ++ .../ui/ontology/SelectionViewUIResources.java | 3 + .../spreadsheet/common/TreeTableCell.java | 47 ++++++++++++ .../scl/Spreadsheet/All.scl | 14 ++++ 14 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 bundles/org.simantics.selectionview.ui.ontology/graph/scl/SCLMain.scl diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java index 3bb2db942..494c0a819 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java @@ -13,7 +13,9 @@ package org.simantics.browsing.ui.model.labeldecorators; import org.eclipse.jface.resource.ColorDescriptor; import org.eclipse.jface.resource.FontDescriptor; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.RGB; import org.simantics.browsing.ui.content.LabelDecorator; import org.simantics.databoard.Bindings; @@ -133,6 +135,7 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen return font; else { FontDescriptor desc = (FontDescriptor)font; + if(desc == null) desc = FontDescriptor.createFrom(JFaceResources.getDialogFont().getFontData()); return (Font)desc.withStyle(style); } } 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 7a59a1461..9bf10fb3a 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 @@ -3,4 +3,9 @@ package org.simantics.document.server.io; public interface ITreeTableCell extends ITableCell { 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 8913645a9..558ee3204 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 @@ -13,6 +13,7 @@ package org.simantics.document.server.io; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -343,4 +344,72 @@ public class JSONObjectUtils { else return Collections.emptyList(); } + + @SuppressWarnings("unchecked") + public static Collection getTreeTableCell(IJSONObject object) { + try { + Object treeTableCells = object.getValue("tableCells"); + if (treeTableCells instanceof String) { + String tableCellsS = (String) treeTableCells; + if (tableCellsS.length() == 0) + return Collections.emptyList(); + } + if (treeTableCells != null) { + return (List) treeTableCells; + } else { + return Collections.emptyList(); + } + } catch (ClassCastException e) { + e.printStackTrace(); + } + return Collections.emptyList(); + } + + public static final boolean equalObjects(Object oldValue, Object newValue) { + if (newValue != null) { + if (newValue.getClass().isArray()) { + return arrayEquals(newValue, oldValue); + } else { + return newValue.equals(oldValue); + } + } else + return oldValue == null; + } + + + /** + * @param av1 an array (guaranteed) + * @param av2 any object + * @return true if the two arrays are equal + */ + private static final boolean arrayEquals(Object av1, Object av2) { + if (av2 == null) + return false; + Class c1 = av1.getClass().getComponentType(); + Class c2 = av2.getClass().getComponentType(); + if (c2 == null || !c1.equals(c2)) + return false; + boolean p1 = c1.isPrimitive(); + boolean p2 = c2.isPrimitive(); + if (p1 != p2) + return false; + if (!p1) + return Arrays.equals((Object[]) av1, (Object[]) av2); + if (boolean.class.equals(c1)) + return Arrays.equals((boolean[]) av1, (boolean[]) av2); + else if (byte.class.equals(c1)) + return Arrays.equals((byte[]) av1, (byte[]) av2); + else if (int.class.equals(c1)) + return Arrays.equals((int[]) av1, (int[]) av2); + else if (long.class.equals(c1)) + return Arrays.equals((long[]) av1, (long[]) av2); + else if (float.class.equals(c1)) + return Arrays.equals((float[]) av1, (float[]) av2); + else if (double.class.equals(c1)) + return Arrays.equals((double[]) av1, (double[]) av2); + throw new RuntimeException("Unsupported objects for equality testing ." + av1 + " vs. " + av2); + + } + + } diff --git a/bundles/org.simantics.document.server/scl/Document/All.scl b/bundles/org.simantics.document.server/scl/Document/All.scl index 238968142..fa83a224a 100644 --- a/bundles/org.simantics.document.server/scl/Document/All.scl +++ b/bundles/org.simantics.document.server/scl/Document/All.scl @@ -21,6 +21,13 @@ importJava "org.simantics.document.server.io.ITreeTableCell" where importJava "org.simantics.document.server.io.IFont" where data IFont + + @JavaName getFamily + fontFamily :: IFont -> Maybe String + @JavaName getStyle + fontStyle :: IFont -> Maybe String + @JavaName getHeight + fontHeight :: IFont -> Integer importJava "org.simantics.document.server.io.IColor" where data IColor diff --git a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl index ecacf0090..b821fcc03 100644 --- a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl @@ -123,7 +123,9 @@ printActionDetails action = do @private decorateLabelStub :: LabelDecorator -> String -> String -> () decorateLabelStub decorator key value = do - fontti = decorateFont decorator getDefaultFontDescriptor key 0 + fontti = match decorateFont decorator (Just getDefaultFontDescriptor) key 0 with + Nothing -> "" + Just font -> "" fontti = decorateBackground decorator Nothing key 0 fontti = decorateForeground decorator Nothing key 0 laabeli = decorateLabel decorator value key 0 diff --git a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl index a4b06495a..d3890192e 100644 --- a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl @@ -96,7 +96,7 @@ importJava "org.simantics.browsing.ui.content.LabelDecorator" where decorateLabel :: LabelDecorator -> String -> String -> Integer -> String decorateForeground :: LabelDecorator -> a -> String -> Integer -> a decorateBackground :: LabelDecorator -> a -> String -> Integer -> a - decorateFont :: LabelDecorator -> a -> String -> Integer -> a + decorateFont :: LabelDecorator -> Maybe a -> String -> Integer -> Maybe a importJava "org.simantics.browsing.ui.CheckedState" where data CheckedState @@ -105,7 +105,8 @@ importJava "org.simantics.browsing.ui.content.Labeler$Modifier" where data Modifier getValue :: Modifier -> String - isValid :: Modifier -> String -> String + isValid :: Modifier -> String -> Maybe String + modify :: Modifier -> String -> () importJava "org.simantics.browsing.ui.model.browsecontexts.BrowseContexts" where toBrowseContextG :: Vector String -> BrowseContext @@ -118,3 +119,6 @@ createBrowseContext :: [Resource] -> BrowseContext createBrowseContext resource = do create resource +importJava "org.simantics.browsing.ui.common.NodeContextBuilder" where + buildWithInput :: a -> NodeContext + diff --git a/bundles/org.simantics.selectionview.ontology/graph.tg b/bundles/org.simantics.selectionview.ontology/graph.tg index 62f5bc7921cb706b62d10cbb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m$Is%OkH$0uujeQ1vvrhe3L$+3^mA7Rv92h;x7IM(xk zXC2QR8z*c0S+sdZXne@=Fh1Xe?QY;b;HzM&=X&pGV4fj6VQ;~xC2xnl4WpK<{kNgb zITvBP9_wIay&gQ9EI-k}&o?md1y=t;1Hah7FE#MX4g88@y?$KpEikSB4YW5K=6Y;0 z%>CADnED>WjBjk<4Gnx5_)*vgFyK7uh9`4H@57;7OPgna_r03$yH z`xM67$p>Jc!B`tv=huz)rG{DmuMBg(ml)=JE;da4MTQx_uz@dV;Pb&cU*;m~d|3-w z=gVAVoiA%4>wKA;tn+2(lFxjJDQXTE~rHphCN zurK4vtj#iOx6HM$%(b)3wYAK(x6Es0nb+1b_kv~a70djtSms$_xvzoCjyv%A1B`3a z3e)xBdNjdw{>;Ta(bqnf>7rnEl%%gRUML_lwz3eyLc)`xJ-BPWCzu@w3FUV0w5HJ4Iqe{js?iqB1h3Od#VEvFvv+&l z$g)zDbBb$tX>S!+ij?{aNOSgwV-W<$iJ++m&4toj@iQ9=qWL0P`!k|${Z*U4PohT% b%a*HBZ`~+aPM(=%!o5A>wslt#@4fy9mhQ^S diff --git a/bundles/org.simantics.selectionview.ui.ontology/graph/SelectionViewUi.pgraph b/bundles/org.simantics.selectionview.ui.ontology/graph/SelectionViewUi.pgraph index 0fb82a9af..704e7430c 100644 --- a/bundles/org.simantics.selectionview.ui.ontology/graph/SelectionViewUi.pgraph +++ b/bundles/org.simantics.selectionview.ui.ontology/graph/SelectionViewUi.pgraph @@ -10,6 +10,10 @@ SEL = : L0.Ontology @L0.new L0.HasResourceClass "org.simantics.selectionview.ui.ontology.SelectionViewUIResources" +SEL.SCLMain : L0.SCLModule + L0.SCLModule.definition _ : L0.String + @L0.loadString "scl/SCLMain.scl" + SEL.CategoryNode : VP.NodeType VP.HasContentType "org.simantics.selectionview.CategoryNode" VP.HasBundle "org.simantics.selectionview" @@ -83,11 +87,17 @@ SEL.StandardProperties.BrowseContextStandardChildren Maybe Resource" @L0.assert VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable VP.VisualsContribution.HasRule SEL.StandardProperties.BrowseContextStandardChildren.Sorter : SEL.StandardPropertySorterRuleType + @MOD.scl SEL_BASE.getSpecialCategory "layer0Categories" "Resource -> Maybe Resource" + @L0.assert VP.BrowseContext.HasVisualsContribution + _ : VP.VisualsContribution + VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable + VP.VisualsContribution.HasRule VP.DescriptionTooltipRule SEL.StandardProperties.BrowseContextWithoutChildren Maybe Resource +layer0Categories predicate = match predicate with + L0.HasName -> Just MOD.SystemPropertyInfo + _ -> Nothing + \ No newline at end of file diff --git a/bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java b/bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java index cdf0fa26f..b3b474592 100644 --- a/bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java +++ b/bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java @@ -14,6 +14,7 @@ public class SelectionViewUIResources { public final Resource CategoryNode; public final Resource CategoryNodeLabelRule; public final Resource PropertyColumn; + public final Resource SCLMain; public final Resource StandardProperties; public final Resource StandardPropertiesBase; public final Resource StandardPropertiesBase_BrowseContext; @@ -37,6 +38,7 @@ public class SelectionViewUIResources { public static final String CategoryNode = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNode"; public static final String CategoryNodeLabelRule = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNodeLabelRule"; public static final String PropertyColumn = "http://www.simantics.org/SelectionViewUI-1.1/PropertyColumn"; + public static final String SCLMain = "http://www.simantics.org/SelectionViewUI-1.1/SCLMain"; public static final String StandardProperties = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties"; public static final String StandardPropertiesBase = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase"; public static final String StandardPropertiesBase_BrowseContext = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase/BrowseContext"; @@ -70,6 +72,7 @@ public class SelectionViewUIResources { CategoryNode = getResourceOrNull(graph, URIs.CategoryNode); CategoryNodeLabelRule = getResourceOrNull(graph, URIs.CategoryNodeLabelRule); PropertyColumn = getResourceOrNull(graph, URIs.PropertyColumn); + SCLMain = getResourceOrNull(graph, URIs.SCLMain); StandardProperties = getResourceOrNull(graph, URIs.StandardProperties); StandardPropertiesBase = getResourceOrNull(graph, URIs.StandardPropertiesBase); StandardPropertiesBase_BrowseContext = getResourceOrNull(graph, URIs.StandardPropertiesBase_BrowseContext); 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 2face448f..fb80d0760 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 @@ -12,15 +12,52 @@ *******************************************************************************/ package org.simantics.spreadsheet.common; +import org.eclipse.jface.resource.FontDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.FontData; +import org.simantics.document.server.io.IFont; import org.simantics.document.server.io.ITreeTableCell; +import org.simantics.document.server.io.SimpleFont; public class TreeTableCell extends TableCell implements ITreeTableCell { private int parent = -1; + + private boolean editable = true; + private Object data; public TreeTableCell() { } + public TreeTableCell(String text, Object data, Object font, int parent, int row, int column, boolean editable) { + super(column, row, 0, 0, text, (IFont)font, null, null, false, 1, 1); + this.editable = editable; + this.parent = parent; + this.data = data; + } + + 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); + } + + private static IFont extractIFont(Object font) { + if(font instanceof FontDescriptor) { + FontDescriptor descriptor = (FontDescriptor)font; + String family = ""; + String style = ""; + int size = 12; + for(FontData d : descriptor.getFontData()) { + System.err.println("data: " + d); + family = d.getName(); + if((d.getStyle() & SWT.ITALIC) != 0) style += "Italic"; + if((d.getStyle() & SWT.BOLD) != 0) style += "Bold"; + size = d.getHeight(); + } + return new SimpleFont(family, style, size); + } + return null; + } + public void setParent(int parent) { this.parent = parent; } @@ -30,4 +67,14 @@ public class TreeTableCell extends TableCell implements ITreeTableCell { return parent; } + @Override + public Object getData() { + return data; + } + + @Override + public boolean isEditable() { + return editable; + } + } diff --git a/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl b/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl index ddfd3bef0..532331e55 100644 --- a/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl +++ b/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl @@ -10,6 +10,20 @@ importJava "org.simantics.spreadsheet.common.TableCell" where importJava "org.simantics.spreadsheet.common.TreeTableCell" where data TreeTableCell + @JavaName getData + getTreeTableCellData :: TreeTableCell -> a + + createTreeTableCell :: String -> a -> Maybe b -> Integer -> Integer -> Integer -> Boolean -> TreeTableCell + + @JavaName getText + treeTableCellText :: TreeTableCell -> String + @JavaName getFont + treeTableCellFont :: TreeTableCell -> Maybe IFont + @JavaName getRow + treeTableCellRow :: TreeTableCell -> Integer + @JavaName getColumn + treeTableCellColumn :: TreeTableCell -> Integer + importJava "org.simantics.spreadsheet.common.SpreadsheetCell" where data SpreadsheetCell -- 2.47.1