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;
return font;
else {
FontDescriptor desc = (FontDescriptor)font;
+ if(desc == null) desc = FontDescriptor.createFrom(JFaceResources.getDialogFont().getFontData());
return (Font)desc.withStyle(style);
}
}
public interface ITreeTableCell extends ITableCell {
int getParent();
+
+ Object getData();
+
+ boolean isEditable();
+
}
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;
else
return Collections.<IListItem>emptyList();
}
+
+ @SuppressWarnings("unchecked")
+ public static Collection<ITreeTableCell> 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<ITreeTableCell>) 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 <code>true</code> 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);
+
+ }
+
+
}
importJava "org.simantics.document.server.io.IFont" where
data IFont
+
+ @JavaName getFamily
+ fontFamily :: IFont -> <Proc> Maybe String
+ @JavaName getStyle
+ fontStyle :: IFont -> <Proc> Maybe String
+ @JavaName getHeight
+ fontHeight :: IFont -> <Proc> Integer
importJava "org.simantics.document.server.io.IColor" where
data IColor
@private
decorateLabelStub :: LabelDecorator -> String -> String -> <Proc> ()
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
decorateLabel :: LabelDecorator -> String -> String -> Integer -> <Proc> String
decorateForeground :: LabelDecorator -> a -> String -> Integer -> <Proc> a
decorateBackground :: LabelDecorator -> a -> String -> Integer -> <Proc> a
- decorateFont :: LabelDecorator -> a -> String -> Integer -> <Proc> a
+ decorateFont :: LabelDecorator -> Maybe a -> String -> Integer -> <Proc> Maybe a
importJava "org.simantics.browsing.ui.CheckedState" where
data CheckedState
data Modifier
getValue :: Modifier -> <Proc> String
- isValid :: Modifier -> String -> <Proc> String
+ isValid :: Modifier -> String -> <Proc> Maybe String
+ modify :: Modifier -> String -> <Proc> ()
importJava "org.simantics.browsing.ui.model.browsecontexts.BrowseContexts" where
toBrowseContextG :: Vector String -> <ReadGraph> BrowseContext
createBrowseContext resource = do
create resource
+importJava "org.simantics.browsing.ui.common.NodeContextBuilder" where
+ buildWithInput :: a -> <Proc> NodeContext
+
SEL.StandardPropertyInfo.CategorySortingName ""
SEL.StandardPropertyInfo.IsHidden true
-SEL.getSpecialCategory ==> "Resource -> <ReadGraph> Resource" <R L0.HasProperty : L0.FunctionalRelation
+SEL.getSpecialCategory ==> "Resource -> <ReadGraph> Maybe Resource" <R L0.HasProperty : L0.FunctionalRelation
SEL.ColorParameterType <T SEL.GenericParameterType
@L0.assert SEL.HasDisplayValue
@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"
VP.ChildContribution.HasChildNodeType SEL.CategoryNode
VP.ChildContribution.HasRule
SEL.StandardProperties.BrowseContextStandardChildren.Cat : SEL.VariablePropertyCategoryRule
+ @MOD.scl SEL_BASE.getSpecialCategory "layer0Categories" "Resource -> <ReadGraph> 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 -> <ReadGraph> Maybe Resource"
+ @L0.assert VP.BrowseContext.HasVisualsContribution
+ _ : VP.VisualsContribution
+ VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable
+ VP.VisualsContribution.HasRule VP.DescriptionTooltipRule
SEL.StandardProperties.BrowseContextWithoutChildren <T VP.BrowseContext
@L0.assert VP.BrowseContext.HasVisualsContribution
--- /dev/null
+include "Simantics/All"
+
+layer0Categories :: Resource -> <ReadGraph> Maybe Resource
+layer0Categories predicate = match predicate with
+ L0.HasName -> Just MOD.SystemPropertyInfo
+ _ -> Nothing
+
\ No newline at end of file
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;
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";
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);
*******************************************************************************/
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;
}
return parent;
}
+ @Override
+ public Object getData() {
+ return data;
+ }
+
+ @Override
+ public boolean isEditable() {
+ return editable;
+ }
+
}
importJava "org.simantics.spreadsheet.common.TreeTableCell" where
data TreeTableCell
+ @JavaName getData
+ getTreeTableCellData :: TreeTableCell -> <Proc> a
+
+ createTreeTableCell :: String -> a -> Maybe b -> Integer -> Integer -> Integer -> Boolean -> <Proc> TreeTableCell
+
+ @JavaName getText
+ treeTableCellText :: TreeTableCell -> <Proc> String
+ @JavaName getFont
+ treeTableCellFont :: TreeTableCell -> <Proc> Maybe IFont
+ @JavaName getRow
+ treeTableCellRow :: TreeTableCell -> <Proc> Integer
+ @JavaName getColumn
+ treeTableCellColumn :: TreeTableCell -> <Proc> Integer
+
importJava "org.simantics.spreadsheet.common.SpreadsheetCell" where
data SpreadsheetCell