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