]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - forms/EditablePropertyString.java
1 package org
.argeo
.cms
.forms
;
3 import static org
.argeo
.cms
.forms
.FormStyle
.propertyMessage
;
4 import static org
.argeo
.cms
.forms
.FormStyle
.propertyText
;
7 import javax
.jcr
.RepositoryException
;
9 import org
.argeo
.cms
.viewers
.EditablePart
;
10 import org
.argeo
.cms
.widgets
.EditableText
;
11 import org
.eclipse
.swt
.widgets
.Composite
;
12 import org
.eclipse
.swt
.widgets
.Control
;
13 import org
.eclipse
.swt
.widgets
.Label
;
14 import org
.eclipse
.swt
.widgets
.Text
;
16 /** Editable String in a CMS context */
17 public class EditablePropertyString
extends EditableText
implements
19 private static final long serialVersionUID
= 5055000749992803591L;
21 private String propertyName
;
22 private String message
;
24 public EditablePropertyString(Composite parent
, int style
, Node node
,
25 String propertyName
, String message
) throws RepositoryException
{
26 super(parent
, style
, node
, true);
28 this.propertyName
= propertyName
;
29 this.message
= message
;
31 if (node
.hasProperty(propertyName
)) {
32 this.setStyle(propertyText
.style());
33 this.setText(node
.getProperty(propertyName
).getString());
35 this.setStyle(propertyMessage
.style());
36 this.setText(message
+ " ");
40 public void setText(String text
) {
41 Control child
= getControl();
42 if (child
instanceof Label
) {
43 Label lbl
= (Label
) child
;
44 if (FormUtils
.notEmpty(text
))
45 lbl
.setText(message
+ " ");
48 } else if (child
instanceof Text
) {
49 Text txt
= (Text
) child
;
50 if (FormUtils
.notEmpty(text
)) {
52 txt
.setMessage(message
+ " ");
54 txt
.setText(text
.replaceAll("<br/>", "\n"));
58 public synchronized void startEditing() {
59 getControl().setData(STYLE
, propertyText
.style());
63 public synchronized void stopEditing() {
64 if (FormUtils
.notEmpty(((Text
) getControl()).getText()))
65 getControl().setData(STYLE
, propertyMessage
.style());
67 getControl().setData(STYLE
, propertyText
.style());
71 public String
getPropertyName() {