1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.renderer.impl;
17
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.widgets.Text;
20 import org.seasar.uruma.component.jface.TextComponent;
21
22
23
24
25
26
27 public class TextRenderer extends AbstractControlRenderer<TextComponent, Text> {
28
29
30
31
32
33 @Override
34 protected void doRenderControl(final TextComponent controlComponent,
35 final Text control) {
36 setSelection(controlComponent, control);
37 }
38
39 private void setSelection(final TextComponent controlComponent,
40 final Text control) {
41 if (controlComponent.selectionStart == null
42 && controlComponent.selectionEnd == null) {
43 return;
44 }
45
46 int start = 0;
47 if (controlComponent.selectionStart != null) {
48 start = Integer.parseInt(controlComponent.selectionStart);
49 }
50
51 if (controlComponent.selectionEnd == null) {
52 control.setSelection(start);
53 } else {
54 int end = Integer.parseInt(controlComponent.selectionEnd);
55 control.setSelection(start, end);
56 }
57 }
58
59
60
61
62 @Override
63 protected Class<Text> getWidgetType() {
64 return Text.class;
65 }
66
67
68
69
70 @Override
71 protected int getDefaultStyle() {
72 return SWT.SINGLE | SWT.BORDER;
73 }
74
75 }