]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - cms/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
.argeo
.eclipse
.ui
.EclipseUiUtils
;
12 import org
.eclipse
.swt
.widgets
.Composite
;
13 import org
.eclipse
.swt
.widgets
.Control
;
14 import org
.eclipse
.swt
.widgets
.Label
;
15 import org
.eclipse
.swt
.widgets
.Text
;
17 /** Editable String in a CMS context */
18 public class EditablePropertyString
extends EditableText
implements
20 private static final long serialVersionUID
= 5055000749992803591L;
22 private String propertyName
;
23 private String message
;
25 public EditablePropertyString(Composite parent
, int style
, Node node
,
26 String propertyName
, String message
) throws RepositoryException
{
27 super(parent
, style
, node
, true);
29 this.propertyName
= propertyName
;
30 this.message
= message
;
32 if (node
.hasProperty(propertyName
)) {
33 this.setStyle(propertyText
.style());
34 this.setText(node
.getProperty(propertyName
).getString());
36 this.setStyle(propertyMessage
.style());
37 this.setText(message
+ " ");
41 public void setText(String text
) {
42 Control child
= getControl();
43 if (child
instanceof Label
) {
44 Label lbl
= (Label
) child
;
45 if (EclipseUiUtils
.isEmpty(text
))
46 lbl
.setText(message
+ " ");
49 } else if (child
instanceof Text
) {
50 Text txt
= (Text
) child
;
51 if (EclipseUiUtils
.isEmpty(text
)) {
53 txt
.setMessage(message
+ " ");
55 txt
.setText(text
.replaceAll("<br/>", "\n"));
59 public synchronized void startEditing() {
60 getControl().setData(STYLE
, propertyText
.style());
64 public synchronized void stopEditing() {
65 if (EclipseUiUtils
.isEmpty(((Text
) getControl()).getText()))
66 getControl().setData(STYLE
, propertyMessage
.style());
68 getControl().setData(STYLE
, propertyText
.style());
72 public String
getPropertyName() {