1 package org.simantics.document.swt.core.widget;
\r
3 import org.eclipse.swt.SWT;
\r
4 import org.eclipse.swt.widgets.Composite;
\r
5 import org.eclipse.swt.widgets.Label;
\r
6 import org.simantics.datatypes.literal.Font;
\r
7 import org.simantics.datatypes.literal.RGB;
\r
8 import org.simantics.document.server.JSONObject;
\r
9 import org.simantics.document.swt.core.SWTDocument;
\r
10 import org.simantics.document.swt.core.SWTDocumentUtils;
\r
11 import org.simantics.document.swt.core.base.LeafWidgetManager;
\r
13 public class LabelWidget extends LeafWidgetManager<Label> {
\r
16 protected void doUpdateProperties(SWTDocument document, Label control, JSONObject object) {
\r
18 if(control.isDisposed()) return;
\r
20 String text = object.getJSONField("text");
\r
22 RGB.Integer background = object.getBeanJSONFieldDefault("background", RGB.Integer.BINDING, new RGB.Integer(255,255,255));
\r
23 RGB.Integer foreground = object.getBeanJSONFieldDefault("foreground", RGB.Integer.BINDING, new RGB.Integer(0,0,0));
\r
24 Font font = object.getBeanJSONFieldDefault("font", Font.BINDING, new Font("Arial",10,"Normal"));
\r
25 String alignment = object.getValue("alignment");
\r
26 if(alignment == null) alignment = "left";
\r
28 control.setText(text);
\r
29 control.setBackground(document.getColor(background));
\r
30 control.setForeground(document.getColor(foreground));
\r
31 control.setFont(document.getFont(font));
\r
33 control.setAlignment(SWTDocumentUtils.getAlignment(alignment));
\r
38 protected Label doCreateControl(SWTDocument document, Composite parent, JSONObject object) {
\r
39 Label label = new Label(parent, SWT.NONE);
\r