Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/StyleEditorWindow.java @ 1290:f4deeafa60b3
Build up the editor window from CollectionItemAttribute response.
flys-client/trunk@2887 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 04 Oct 2011 16:04:16 +0000 |
parents | 95ecb98c6015 |
children | 1d04f35b2cc0 |
comparison
equal
deleted
inserted
replaced
1289:d59dcaf52796 | 1290:f4deeafa60b3 |
---|---|
4 | 4 |
5 import com.smartgwt.client.widgets.Window; | 5 import com.smartgwt.client.widgets.Window; |
6 import com.smartgwt.client.widgets.layout.VLayout; | 6 import com.smartgwt.client.widgets.layout.VLayout; |
7 import com.smartgwt.client.widgets.layout.HLayout; | 7 import com.smartgwt.client.widgets.layout.HLayout; |
8 import com.smartgwt.client.widgets.Button; | 8 import com.smartgwt.client.widgets.Button; |
9 import com.smartgwt.client.widgets.form.DynamicForm; | |
10 import com.smartgwt.client.widgets.form.fields.FormItem; | |
11 import com.smartgwt.client.widgets.form.fields.CheckboxItem; | |
12 import com.smartgwt.client.widgets.form.fields.SpinnerItem; | |
13 import com.smartgwt.client.widgets.form.fields.ColorPickerItem; | |
14 import com.smartgwt.client.widgets.form.fields.ComboBoxItem; | |
9 | 15 |
10 import com.smartgwt.client.widgets.events.ClickEvent; | 16 import com.smartgwt.client.widgets.events.ClickEvent; |
11 import com.smartgwt.client.widgets.events.ClickHandler; | 17 import com.smartgwt.client.widgets.events.ClickHandler; |
18 import com.smartgwt.client.types.Alignment; | |
12 | 19 |
13 import de.intevation.flys.client.shared.model.Collection; | 20 import de.intevation.flys.client.shared.model.Collection; |
14 import de.intevation.flys.client.shared.model.CollectionItemAttribute; | 21 import de.intevation.flys.client.shared.model.CollectionItemAttribute; |
22 import de.intevation.flys.client.shared.model.Style; | |
23 import de.intevation.flys.client.shared.model.StyleSetting; | |
15 import de.intevation.flys.client.client.ui.CollectionView; | 24 import de.intevation.flys.client.client.ui.CollectionView; |
16 | 25 |
17 import de.intevation.flys.client.client.FLYSConstants; | 26 import de.intevation.flys.client.client.FLYSConstants; |
18 | 27 |
19 /** | 28 /** |
52 } | 61 } |
53 | 62 |
54 | 63 |
55 protected void init() { | 64 protected void init() { |
56 setTitle(MSG.properties()); | 65 setTitle(MSG.properties()); |
57 setWidth(250); | 66 setWidth(270); |
58 | 67 setHeight(200); |
59 setCanDragReposition(true); | 68 setCanDragReposition(true); |
60 setCanDragResize(true); | 69 setCanDragResize(true); |
61 setKeepInParentRect(true); | 70 setKeepInParentRect(true); |
62 | 71 |
63 layout.setWidth100(); | 72 layout.setWidth100(); |
69 protected void initPanels() { | 78 protected void initPanels() { |
70 HLayout buttons = new HLayout(); | 79 HLayout buttons = new HLayout(); |
71 Button accept = new Button(MSG.label_ok()); | 80 Button accept = new Button(MSG.label_ok()); |
72 Button cancel = new Button(MSG.label_cancel()); | 81 Button cancel = new Button(MSG.label_cancel()); |
73 cancel.addClickHandler(this); | 82 cancel.addClickHandler(this); |
83 accept.addClickHandler(new ClickHandler() { | |
84 public void onClick(ClickEvent e) { | |
74 | 85 |
86 } | |
87 }); | |
75 | 88 |
76 buttons.addMember(accept); | 89 buttons.addMember(accept); |
77 buttons.addMember(cancel); | 90 buttons.addMember(cancel); |
91 buttons.setAlign(Alignment.RIGHT); | |
92 | |
93 layout.addMember(createPropertyGrid("LongitudinalSectionW"));; | |
78 layout.addMember(buttons); | 94 layout.addMember(buttons); |
79 | |
80 addItem(layout); | 95 addItem(layout); |
81 } | 96 } |
82 | 97 |
83 | 98 |
84 public void setCollectionView (CollectionView view) { | 99 public void setCollectionView (CollectionView view) { |
88 | 103 |
89 | 104 |
90 public void onClick(ClickEvent event) { | 105 public void onClick(ClickEvent event) { |
91 this.hide(); | 106 this.hide(); |
92 } | 107 } |
108 | |
109 | |
110 protected VLayout createPropertyGrid(String stylename) { | |
111 //TODO use the style-(theme-)name from response to get the correct | |
112 //attribute set. | |
113 | |
114 VLayout properties = new VLayout(); | |
115 | |
116 // get the correct style using the name. | |
117 Style s = attributes.getStyle(0); | |
118 | |
119 for (int i = 0; i < s.getNumSettings(); i ++) { | |
120 final StyleSetting set = s.getSetting(i); | |
121 DynamicForm property = createPropertyUI( | |
122 set.getDisplayName(), | |
123 set.getName(), | |
124 set.getType(), | |
125 set.getDefaultValue()); | |
126 properties.addMember(property); | |
127 } | |
128 return properties; | |
129 } | |
130 | |
131 protected DynamicForm createPropertyUI( | |
132 String dname, | |
133 String name, | |
134 String type, | |
135 String value) | |
136 { | |
137 DynamicForm df = new DynamicForm(); | |
138 | |
139 FormItem f; | |
140 if(type.equals("int")) { | |
141 SpinnerItem s = new SpinnerItem(name, dname); | |
142 s.setMin(1); | |
143 s.setMax(10); | |
144 f = s; | |
145 } | |
146 else if (type.equals("boolean")) { | |
147 CheckboxItem c = new CheckboxItem(name, dname); | |
148 if(value.equals("true")) { | |
149 c.setValue(true); | |
150 } | |
151 else { | |
152 c.setValue(false); | |
153 } | |
154 c.setLabelAsTitle(true); | |
155 f = c; | |
156 } | |
157 else if (type.equals("Color")) { | |
158 f = new ColorPickerItem(name, dname); | |
159 } | |
160 else if (type.equals("Dash")) { | |
161 f = new ComboBoxItem(name, dname); | |
162 } | |
163 else { | |
164 f = new FormItem(); | |
165 } | |
166 f.setValue(value); | |
167 f.setTitleStyle("color:#000; width:120px"); | |
168 f.setTitleAlign(Alignment.LEFT); | |
169 df.setFields(f); | |
170 | |
171 return df; | |
172 } | |
93 } | 173 } |
174 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |