Révision 6
projets/BCCCC/mydatabase.script (revision 6) | ||
---|---|---|
1 |
SET DATABASE UNIQUE NAME HSQLDB4E004EED72 |
|
2 |
SET DATABASE GC 0 |
|
3 |
SET DATABASE DEFAULT RESULT MEMORY ROWS 0 |
|
4 |
SET DATABASE EVENT LOG LEVEL 0 |
|
5 |
SET DATABASE TRANSACTION CONTROL LOCKS |
|
6 |
SET DATABASE DEFAULT ISOLATION LEVEL READ COMMITTED |
|
7 |
SET DATABASE TRANSACTION ROLLBACK ON CONFLICT TRUE |
|
8 |
SET DATABASE TEXT TABLE DEFAULTS '' |
|
9 |
SET DATABASE SQL NAMES FALSE |
|
10 |
SET DATABASE SQL REFERENCES FALSE |
|
11 |
SET DATABASE SQL SIZE TRUE |
|
12 |
SET DATABASE SQL TYPES FALSE |
|
13 |
SET DATABASE SQL TDC DELETE TRUE |
|
14 |
SET DATABASE SQL TDC UPDATE TRUE |
|
15 |
SET DATABASE SQL TRANSLATE TTI TYPES TRUE |
|
16 |
SET DATABASE SQL CONCAT NULLS TRUE |
|
17 |
SET DATABASE SQL UNIQUE NULLS TRUE |
|
18 |
SET DATABASE SQL CONVERT TRUNCATE TRUE |
|
19 |
SET DATABASE SQL AVG SCALE 0 |
|
20 |
SET DATABASE SQL DOUBLE NAN TRUE |
|
21 |
SET FILES WRITE DELAY 500 MILLIS |
|
22 |
SET FILES BACKUP INCREMENT TRUE |
|
23 |
SET FILES CACHE SIZE 10000 |
|
24 |
SET FILES CACHE ROWS 50000 |
|
25 |
SET FILES SCALE 32 |
|
26 |
SET FILES LOB SCALE 32 |
|
27 |
SET FILES DEFRAG 0 |
|
28 |
SET FILES NIO TRUE |
|
29 |
SET FILES NIO SIZE 256 |
|
30 |
SET FILES LOG TRUE |
|
31 |
SET FILES LOG SIZE 50 |
|
32 |
CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e' |
|
33 |
ALTER USER SA SET LOCAL TRUE |
|
34 |
CREATE SCHEMA PUBLIC AUTHORIZATION DBA |
|
35 |
ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1 |
|
36 |
SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC |
|
37 |
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC |
|
38 |
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.YES_OR_NO TO PUBLIC |
|
39 |
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.TIME_STAMP TO PUBLIC |
|
40 |
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CARDINAL_NUMBER TO PUBLIC |
|
41 |
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CHARACTER_DATA TO PUBLIC |
|
42 |
GRANT DBA TO SA |
projets/BCCCC/mydatabase.properties (revision 6) | ||
---|---|---|
1 |
#HSQL Database Engine 2.3.2 |
|
2 |
#Wed Jun 17 09:35:19 CEST 2015 |
|
3 |
version=2.3.2 |
|
4 |
modified=yes |
projets/BCCCC/src/org/ccc/bcccc/client/BrowsePanel.java (revision 6) | ||
---|---|---|
1 |
/* |
|
2 |
* Authors: Matthieu Decorde |
|
3 |
* |
|
4 |
* COPYRIGHT 2015 ICAR - CCC |
|
5 |
* |
|
6 |
* This software is free software: you can redistribute it |
|
7 |
* and/or modify it under the terms of the GNU General Public |
|
8 |
* License as published by the Free Software Foundation, |
|
9 |
* either version 2 of the License, or (at your option) any |
|
10 |
* later version. |
|
11 |
* |
|
12 |
* This software is distributed in the hope that it will be |
|
13 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
* PURPOSE. See the GNU General Public License for more |
|
16 |
* details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
package org.ccc.bcccc.client; |
|
20 |
|
|
21 |
import java.util.ArrayList; |
|
22 |
|
|
23 |
import org.ccc.bcccc.shared.K; |
|
24 |
import org.ccc.bcccc.shared.TerrainRecord; |
|
25 |
|
|
26 |
import com.google.gwt.user.client.History; |
|
27 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
28 |
import com.smartgwt.client.types.ListGridFieldType; |
|
29 |
import com.smartgwt.client.util.SC; |
|
30 |
import com.smartgwt.client.widgets.grid.ListGrid; |
|
31 |
import com.smartgwt.client.widgets.grid.ListGridField; |
|
32 |
import com.smartgwt.client.widgets.grid.ListGridRecord; |
|
33 |
import com.smartgwt.client.widgets.grid.events.ChangedEvent; |
|
34 |
import com.smartgwt.client.widgets.grid.events.ChangedHandler; |
|
35 |
import com.smartgwt.client.widgets.grid.events.RecordDoubleClickEvent; |
|
36 |
import com.smartgwt.client.widgets.grid.events.RecordDoubleClickHandler; |
|
37 |
import com.smartgwt.client.widgets.layout.VLayout; |
|
38 |
|
|
39 |
// TODO: Auto-generated Javadoc |
|
40 |
/** |
|
41 |
* The Class BrowsePanel. |
|
42 |
*/ |
|
43 |
public class BrowsePanel extends VLayout { |
|
44 |
|
|
45 |
/** |
|
46 |
* Instantiates a new browse panel. |
|
47 |
*/ |
|
48 |
public BrowsePanel() { |
|
49 |
this.setWidth100(); |
|
50 |
this.setHeight100(); |
|
51 |
} |
|
52 |
|
|
53 |
/** The init browse done. */ |
|
54 |
boolean initBrowseDone = false; |
|
55 |
|
|
56 |
/** The values grid. */ |
|
57 |
private ListGrid valuesGrid; |
|
58 |
|
|
59 |
/** The id field. */ |
|
60 |
private ListGridField idField; |
|
61 |
|
|
62 |
/** The year field. */ |
|
63 |
private ListGridField yearField; |
|
64 |
|
|
65 |
/** The validate field. */ |
|
66 |
//private ListGridField editField; |
|
67 |
private ListGridField validateField; |
|
68 |
|
|
69 |
/** The desc field. */ |
|
70 |
private ListGridField descField; |
|
71 |
|
|
72 |
/** The project field. */ |
|
73 |
private ListGridField projectField; |
|
74 |
|
|
75 |
/** |
|
76 |
* Inits the. |
|
77 |
*/ |
|
78 |
protected void init() { |
|
79 |
if (!initBrowseDone) { |
|
80 |
System.out.println("Initializing 'browse'..."); |
|
81 |
initBrowseDone = true; |
|
82 |
|
|
83 |
valuesGrid = new ListGrid(); |
|
84 |
valuesGrid.setWidth100(); |
|
85 |
valuesGrid.setWidth100(); |
|
86 |
valuesGrid.setShowResizeBar(false); |
|
87 |
valuesGrid.addRecordDoubleClickHandler(new RecordDoubleClickHandler() { |
|
88 |
@Override |
|
89 |
public void onRecordDoubleClick(RecordDoubleClickEvent event) { |
|
90 |
String UNIQID_str = event.getRecord().getAttribute(K.UNIQID); |
|
91 |
Long UNIQID = Long.parseLong(UNIQID_str); |
|
92 |
BCCCC.doubleClickedRecord = null; |
|
93 |
for (int i = 0 ; i < BCCCC.records.size() ; i++) { |
|
94 |
if (BCCCC.records.get(i).uniq_id == UNIQID) { |
|
95 |
BCCCC.doubleClickedRecord = BCCCC.records.get(i); |
|
96 |
continue; |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
if (BCCCC.doubleClickedRecord == null) { |
|
101 |
SC.warn("Current record not set: "+event.getRecord()); |
|
102 |
} else { |
|
103 |
History.newItem(K.VIEWEDITRECORD); |
|
104 |
} |
|
105 |
} |
|
106 |
}); |
|
107 |
|
|
108 |
System.out.println(" init fields..."); |
|
109 |
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(); |
|
110 |
|
|
111 |
idField = new ListGridField(K.ID, "Name"); |
|
112 |
idField.setPrompt("identifiant"); |
|
113 |
idField.setType(ListGridFieldType.INTEGER); |
|
114 |
fields.add(idField); |
|
115 |
|
|
116 |
yearField = new ListGridField(K.YEAR, "Year"); |
|
117 |
yearField.setPrompt("Year"); |
|
118 |
yearField.setWidth(150); |
|
119 |
yearField.setType(ListGridFieldType.INTEGER); |
|
120 |
fields.add(yearField); |
|
121 |
|
|
122 |
descField = new ListGridField(K.DESC, "Description"); |
|
123 |
descField.setPrompt("Short description"); |
|
124 |
descField.setWidth(150); |
|
125 |
descField.setType(ListGridFieldType.TEXT); |
|
126 |
descField.setWrap(true); |
|
127 |
fields.add(descField); |
|
128 |
|
|
129 |
projectField = new ListGridField(K.PROJECT, "Project"); |
|
130 |
projectField.setPrompt("Project name"); |
|
131 |
projectField.setWidth(150); |
|
132 |
projectField.setType(ListGridFieldType.TEXT); |
|
133 |
projectField.setWrap(true); |
|
134 |
fields.add(projectField); |
|
135 |
|
|
136 |
validateField = new ListGridField(K.VALIDATE, "Waiting for publication"); |
|
137 |
validateField.setPrompt("is visible or not to public users"); |
|
138 |
validateField.setType(ListGridFieldType.BOOLEAN); |
|
139 |
validateField.setWrap(true); |
|
140 |
validateField.setHidden(true); |
|
141 |
|
|
142 |
validateField.addChangedHandler(new ChangedHandler(){ |
|
143 |
@Override |
|
144 |
public void onChanged(ChangedEvent event) { |
|
145 |
Long ID = valuesGrid.getRecord(event.getRowNum()).getAttributeAsLong(K.UNIQID); |
|
146 |
Boolean newValue = (Boolean)event.getValue(); |
|
147 |
|
|
148 |
Services.getMain().setValidateRecordValue(ID, newValue, new AsyncCallback<Boolean>() { |
|
149 |
@Override |
|
150 |
public void onFailure(Throwable caught) { |
|
151 |
SC.warn("Error: "+caught); |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public void onSuccess(Boolean result) { |
|
156 |
if (result) { |
|
157 |
SC.say("Value changed."); |
|
158 |
} else { |
|
159 |
SC.warn("Error: value has not been changed"); |
|
160 |
} |
|
161 |
} |
|
162 |
}); |
|
163 |
} |
|
164 |
}); |
|
165 |
fields.add(validateField); |
|
166 |
|
|
167 |
valuesGrid.setFields(yearField, idField, projectField, validateField, descField); |
|
168 |
valuesGrid.setGroupByField(K.YEAR); |
|
169 |
valuesGrid.setGroupStartOpen("all"); |
|
170 |
|
|
171 |
this.addMember(valuesGrid); |
|
172 |
System.out.println("End of 'browse' init"); |
|
173 |
} |
|
174 |
|
|
175 |
valuesGrid.hideField("validate"); |
|
176 |
Services.getMain().isAdmin(new AsyncCallback<Boolean>() { // show validate field only if admin |
|
177 |
@Override |
|
178 |
public void onSuccess(Boolean result) { |
|
179 |
if (result != null && result) { |
|
180 |
validateField.setCanEdit(result); |
|
181 |
valuesGrid.showField("validate"); |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
185 |
@Override |
|
186 |
public void onFailure(Throwable caught) { |
|
187 |
SC.warn("Error: "+caught); |
|
188 |
} |
|
189 |
}); |
|
190 |
|
|
191 |
ListGridRecord[] listGridRecords = new ListGridRecord[BCCCC.records.size()]; |
|
192 |
|
|
193 |
int i = 0; |
|
194 |
System.out.println("Records: "+BCCCC.records.size()); |
|
195 |
for (TerrainRecord record : BCCCC.records) { |
|
196 |
//System.out.println(record); |
|
197 |
listGridRecords[i] = new ListGridRecord(); |
|
198 |
|
|
199 |
listGridRecords[i].setAttribute(K.UNIQID, record.uniq_id); |
|
200 |
listGridRecords[i].setAttribute(K.ID, record.name); |
|
201 |
listGridRecords[i].setAttribute(K.YEAR, record.year); |
|
202 |
listGridRecords[i].setAttribute(K.DESC, record.short_description); |
|
203 |
listGridRecords[i].setAttribute(K.PROJECT, record.project); |
|
204 |
listGridRecords[i].setAttribute(K.VALIDATE, record.mustBeValidated); |
|
205 |
i++; |
|
206 |
} |
|
207 |
|
|
208 |
valuesGrid.setRecords(listGridRecords); |
|
209 |
} |
|
210 |
} |
projets/BCCCC/src/org/ccc/bcccc/client/SearchPanel.java (revision 6) | ||
---|---|---|
1 |
/* |
|
2 |
* Authors: Matthieu Decorde |
|
3 |
* |
|
4 |
* COPYRIGHT 2015 ICAR - CCC |
|
5 |
* |
|
6 |
* This software is free software: you can redistribute it |
|
7 |
* and/or modify it under the terms of the GNU General Public |
|
8 |
* License as published by the Free Software Foundation, |
|
9 |
* either version 2 of the License, or (at your option) any |
|
10 |
* later version. |
|
11 |
* |
|
12 |
* This software is distributed in the hope that it will be |
|
13 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
* PURPOSE. See the GNU General Public License for more |
|
16 |
* details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
package org.ccc.bcccc.client; |
|
20 |
|
|
21 |
import java.util.ArrayList; |
|
22 |
import java.util.HashMap; |
|
23 |
|
|
24 |
import org.ccc.bcccc.shared.Dispositif; |
|
25 |
import org.ccc.bcccc.shared.DocumentUnit; |
|
26 |
import org.ccc.bcccc.shared.K; |
|
27 |
import org.ccc.bcccc.shared.TerrainRecord; |
|
28 |
|
|
29 |
import com.google.gwt.user.client.History; |
|
30 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
31 |
import com.smartgwt.client.types.MultipleAppearance; |
|
32 |
import com.smartgwt.client.util.SC; |
|
33 |
import com.smartgwt.client.widgets.form.DynamicForm; |
|
34 |
import com.smartgwt.client.widgets.form.fields.ButtonItem; |
|
35 |
import com.smartgwt.client.widgets.form.fields.SelectItem; |
|
36 |
import com.smartgwt.client.widgets.form.fields.SliderItem; |
|
37 |
import com.smartgwt.client.widgets.form.fields.TextItem; |
|
38 |
import com.smartgwt.client.widgets.layout.VLayout; |
|
39 |
|
|
40 |
// TODO: Auto-generated Javadoc |
|
41 |
/** |
|
42 |
* The Class SearchPanel. |
|
43 |
*/ |
|
44 |
public class SearchPanel extends VLayout { |
|
45 |
|
|
46 |
/** |
|
47 |
* Instantiates a new search panel. |
|
48 |
*/ |
|
49 |
public SearchPanel() { |
|
50 |
this.setWidth100(); |
|
51 |
this.setHeight100(); |
|
52 |
} |
|
53 |
|
|
54 |
/** The init search complex done. */ |
|
55 |
boolean initSearchComplexDone = false; |
|
56 |
|
|
57 |
/** |
|
58 |
* Inits the. |
|
59 |
*/ |
|
60 |
protected void init() { |
|
61 |
if (initSearchComplexDone) return; |
|
62 |
initSearchComplexDone = true; |
|
63 |
|
|
64 |
final DynamicForm form = new DynamicForm(); |
|
65 |
form.setWidth100(); |
|
66 |
form.setHeight100(); |
|
67 |
this.addMember(form); |
|
68 |
|
|
69 |
TextItem wordsField = new TextItem(K.WORDS, "Recherche par mot"); |
|
70 |
|
|
71 |
|
|
72 |
SelectItem types = new SelectItem(K.TYPES); |
|
73 |
types.setTitle("Terrain types"); |
|
74 |
types.setMultiple(true); |
|
75 |
types.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
76 |
types.setValueMap("commerce", "apprentissage", "privé", "médical", "etc."); |
|
77 |
|
|
78 |
SelectItem projets = new SelectItem("projets"); |
|
79 |
projets.setTitle("Projet"); |
|
80 |
projets.setMultiple(true); |
|
81 |
projets.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
82 |
projets.setValueMap("projet1", "projet2", "projetN"); |
|
83 |
|
|
84 |
SliderItem participants = new SliderItem(K.NUMBEROFPARTICIPANTS); |
|
85 |
participants.setTitle("More than N persons"); |
|
86 |
participants.setMinValue(1); |
|
87 |
participants.setMaxValue(100); |
|
88 |
// participants.setNumValues(5); |
|
89 |
participants.setDefaultValue(1); |
|
90 |
|
|
91 |
SelectItem dispositifs = new SelectItem(K.DISPOSITIFS); |
|
92 |
dispositifs.setTitle("Dispositifs"); |
|
93 |
dispositifs.setMultiple(true); |
|
94 |
dispositifs.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
95 |
dispositifs.setValueMap(Dispositif.types); |
|
96 |
|
|
97 |
|
|
98 |
SelectItem supports = new SelectItem(K.SUPPORTS); |
|
99 |
supports.setTitle("Supports"); |
|
100 |
supports.setMultiple(true); |
|
101 |
supports.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
102 |
supports.setValueMap(DocumentUnit.values); |
|
103 |
|
|
104 |
ButtonItem validate = new ButtonItem("validate"); |
|
105 |
validate.setTitle("Search"); |
|
106 |
validate.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
107 |
@Override |
|
108 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
109 |
|
|
110 |
String words_value = form.getValueAsString(K.WORDS); |
|
111 |
if (words_value == null) words_value = ""; |
|
112 |
else words_value = words_value.trim(); |
|
113 |
|
|
114 |
String types_value = form.getValueAsString(K.TYPES); |
|
115 |
if (types_value == null) types_value = ""; |
|
116 |
else types_value = types_value.trim(); |
|
117 |
|
|
118 |
String projects_value = form.getValueAsString(K.PROJECTS); |
|
119 |
if (projects_value == null) projects_value = ""; |
|
120 |
else projects_value = projects_value.trim(); |
|
121 |
|
|
122 |
String participants_value = form.getValueAsString(K.NUMBEROFPARTICIPANTS); |
|
123 |
if (participants_value == null) participants_value = ""; |
|
124 |
else participants_value = participants_value.trim(); |
|
125 |
|
|
126 |
String dispositifs_value = form.getValueAsString(K.DISPOSITIFS); |
|
127 |
if (dispositifs_value == null) dispositifs_value = ""; |
|
128 |
else dispositifs_value = dispositifs_value.trim(); |
|
129 |
|
|
130 |
String supports_value = form.getValueAsString(K.SUPPORTS); |
|
131 |
if (supports_value == null) supports_value = ""; |
|
132 |
else supports_value = supports_value.trim(); |
|
133 |
|
|
134 |
if (types_value.length() == 0 && |
|
135 |
projects_value.length() == 0 && |
|
136 |
participants_value.length() == 0 && |
|
137 |
dispositifs_value.length() == 0 && |
|
138 |
supports_value.length() == 0) return; |
|
139 |
|
|
140 |
System.out.println("Updating records..."); |
|
141 |
|
|
142 |
HashMap<String, String> critera = new HashMap<String, String>(); |
|
143 |
critera.put(K.WORDS, words_value); |
|
144 |
critera.put(K.TYPES, types_value); |
|
145 |
critera.put(K.PROJECTS, projects_value); |
|
146 |
critera.put(K.DISPOSITIFS, dispositifs_value); |
|
147 |
critera.put(K.SUPPORTS, supports_value); |
|
148 |
critera.put(K.NUMBEROFPARTICIPANTS, participants_value); |
|
149 |
|
|
150 |
Services.getMain().getRecordsWithComplexCritera(critera, new AsyncCallback<ArrayList<TerrainRecord>>() { |
|
151 |
@Override |
|
152 |
public void onFailure(Throwable caught) { |
|
153 |
SC.warn(caught.getMessage()); |
|
154 |
} |
|
155 |
|
|
156 |
@Override |
|
157 |
public void onSuccess(ArrayList<TerrainRecord> result) { |
|
158 |
BCCCC.searched_records = new ArrayList<TerrainRecord>(); |
|
159 |
if (result != null) { |
|
160 |
System.out.println("Found: "+result.size()); |
|
161 |
BCCCC.searched_records = result; |
|
162 |
} |
|
163 |
History.newItem("browse_searched"); |
|
164 |
} |
|
165 |
}); |
|
166 |
} |
|
167 |
}); |
|
168 |
|
|
169 |
form.setItems(wordsField, types, projets, participants, dispositifs, supports, validate); |
|
170 |
} |
|
171 |
} |
projets/BCCCC/src/org/ccc/bcccc/client/CreateTerrainRecordPanel.java (revision 6) | ||
---|---|---|
1 |
/* |
|
2 |
* Authors: Matthieu Decorde |
|
3 |
* |
|
4 |
* COPYRIGHT 2015 ICAR - CCC |
|
5 |
* |
|
6 |
* This software is free software: you can redistribute it |
|
7 |
* and/or modify it under the terms of the GNU General Public |
|
8 |
* License as published by the Free Software Foundation, |
|
9 |
* either version 2 of the License, or (at your option) any |
|
10 |
* later version. |
|
11 |
* |
|
12 |
* This software is distributed in the hope that it will be |
|
13 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
* PURPOSE. See the GNU General Public License for more |
|
16 |
* details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
package org.ccc.bcccc.client; |
|
20 |
|
|
21 |
import java.util.Date; |
|
22 |
|
|
23 |
import org.ccc.bcccc.shared.K; |
|
24 |
import org.ccc.bcccc.shared.TerrainRecord; |
|
25 |
import org.ccc.bcccc.shared.TerrainRecordAndRights; |
|
26 |
|
|
27 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
28 |
import com.smartgwt.client.util.SC; |
|
29 |
import com.smartgwt.client.widgets.form.DynamicForm; |
|
30 |
import com.smartgwt.client.widgets.form.fields.ButtonItem; |
|
31 |
import com.smartgwt.client.widgets.form.fields.DateItem; |
|
32 |
import com.smartgwt.client.widgets.form.fields.TextAreaItem; |
|
33 |
import com.smartgwt.client.widgets.form.fields.TextItem; |
|
34 |
import com.smartgwt.client.widgets.layout.VLayout; |
|
35 |
|
|
36 |
// TODO: Auto-generated Javadoc |
|
37 |
/** |
|
38 |
* The Class CreateTerrainRecordPanel. |
|
39 |
*/ |
|
40 |
public class CreateTerrainRecordPanel extends VLayout { |
|
41 |
|
|
42 |
/** |
|
43 |
* Instantiates a new creates the terrain record panel. |
|
44 |
*/ |
|
45 |
public CreateTerrainRecordPanel() { |
|
46 |
this.setWidth100(); |
|
47 |
this.setHeight100(); |
|
48 |
} |
|
49 |
|
|
50 |
/** The create form. */ |
|
51 |
private DynamicForm createForm; |
|
52 |
|
|
53 |
/** The id vae field. */ |
|
54 |
private TextItem idVAEField; |
|
55 |
|
|
56 |
/** The project vae field. */ |
|
57 |
private TextItem projectVAEField; |
|
58 |
|
|
59 |
/** The date vae field. */ |
|
60 |
private DateItem dateVAEField; |
|
61 |
|
|
62 |
/** The content vae field. */ |
|
63 |
private TextAreaItem contentVAEField; |
|
64 |
|
|
65 |
/** The save vae button. */ |
|
66 |
private ButtonItem saveVAEButton; |
|
67 |
|
|
68 |
/** The init view and edit done. */ |
|
69 |
boolean initViewAndEditDone; |
|
70 |
|
|
71 |
/** |
|
72 |
* Inits the. |
|
73 |
*/ |
|
74 |
protected void init() { |
|
75 |
|
|
76 |
if (!initViewAndEditDone) { |
|
77 |
|
|
78 |
initViewAndEditDone = true; |
|
79 |
|
|
80 |
createForm = new DynamicForm(); |
|
81 |
createForm.setWidth100(); |
|
82 |
createForm.setHeight100(); |
|
83 |
this.addMember(createForm); |
|
84 |
|
|
85 |
idVAEField = new TextItem(K.ID); |
|
86 |
idVAEField.setTitle("Record name"); |
|
87 |
idVAEField.setRequired(true); |
|
88 |
|
|
89 |
contentVAEField = new TextAreaItem(K.DESC); |
|
90 |
contentVAEField.setTitle("Short description"); |
|
91 |
contentVAEField.setRequired(true); |
|
92 |
|
|
93 |
dateVAEField = new DateItem(K.DATE); |
|
94 |
dateVAEField.setTitle("Date"); |
|
95 |
dateVAEField.setUseTextField(false); |
|
96 |
dateVAEField.setRequired(true); |
|
97 |
|
|
98 |
projectVAEField = new TextItem(K.PROJECT); |
|
99 |
projectVAEField.setTitle("Project name"); |
|
100 |
projectVAEField.setRequired(true); |
|
101 |
|
|
102 |
saveVAEButton = new ButtonItem("save_record"); |
|
103 |
saveVAEButton.setTitle("Save changes"); |
|
104 |
saveVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
105 |
@Override |
|
106 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
107 |
if (!createForm.validate()) return; |
|
108 |
|
|
109 |
TerrainRecordAndRights record = new TerrainRecordAndRights(); |
|
110 |
record.record = new TerrainRecord(); |
|
111 |
Date date = (Date)createForm.getValue(K.DATE); |
|
112 |
record.record.setInfoFields( |
|
113 |
createForm.getValueAsString(K.ID), |
|
114 |
createForm.getValueAsString(K.PROJECT), |
|
115 |
date, |
|
116 |
createForm.getValueAsString(K.DESC), |
|
117 |
"???"); |
|
118 |
|
|
119 |
Services.getMain().createRecord(record.record, new AsyncCallback<Boolean>() { |
|
120 |
|
|
121 |
@Override |
|
122 |
public void onFailure(Throwable caught) { |
|
123 |
SC.warn(caught.getMessage()); |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public void onSuccess(Boolean result) { |
|
128 |
if (result) { |
|
129 |
SC.warn("Record '"+createForm.getValueAsString(K.ID)+"' posted. Now wait for admin to validate the record."); |
|
130 |
} else { |
|
131 |
SC.warn("Record '"+createForm.getValueAsString(K.ID)+"' NOT created."); |
|
132 |
} |
|
133 |
} |
|
134 |
}); |
|
135 |
} |
|
136 |
}); |
|
137 |
|
|
138 |
createForm.setItems(idVAEField, contentVAEField, |
|
139 |
projectVAEField, dateVAEField, saveVAEButton); |
|
140 |
|
|
141 |
} |
|
142 |
} |
|
143 |
} |
projets/BCCCC/src/org/ccc/bcccc/client/ViewAndEditTerrainRecordPanel.java (revision 6) | ||
---|---|---|
1 |
/* |
|
2 |
* Authors: Matthieu Decorde |
|
3 |
* |
|
4 |
* COPYRIGHT 2015 ICAR - CCC |
|
5 |
* |
|
6 |
* This software is free software: you can redistribute it |
|
7 |
* and/or modify it under the terms of the GNU General Public |
|
8 |
* License as published by the Free Software Foundation, |
|
9 |
* either version 2 of the License, or (at your option) any |
|
10 |
* later version. |
|
11 |
* |
|
12 |
* This software is distributed in the hope that it will be |
|
13 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
* PURPOSE. See the GNU General Public License for more |
|
16 |
* details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
package org.ccc.bcccc.client; |
|
20 |
|
|
21 |
import java.util.ArrayList; |
|
22 |
import java.util.Arrays; |
|
23 |
import java.util.Date; |
|
24 |
|
|
25 |
import org.ccc.bcccc.client.areas.DataRecordArea; |
|
26 |
import org.ccc.bcccc.client.areas.DateRecordArea; |
|
27 |
import org.ccc.bcccc.client.areas.DispositifsRecordArea; |
|
28 |
import org.ccc.bcccc.client.areas.DocumentsRecordArea; |
|
29 |
import org.ccc.bcccc.client.areas.DoubleStringRecordArea; |
|
30 |
import org.ccc.bcccc.client.areas.LongStringRecordArea; |
|
31 |
import org.ccc.bcccc.client.areas.PublicationsRecordArea; |
|
32 |
import org.ccc.bcccc.client.areas.ReportsRecordArea; |
|
33 |
import org.ccc.bcccc.client.areas.StringRecordField; |
|
34 |
import org.ccc.bcccc.shared.Data; |
|
35 |
import org.ccc.bcccc.shared.Dispositif; |
|
36 |
import org.ccc.bcccc.shared.DocumentUnit; |
|
37 |
import org.ccc.bcccc.shared.K; |
|
38 |
import org.ccc.bcccc.shared.Publication; |
|
39 |
import org.ccc.bcccc.shared.Report; |
|
40 |
import org.ccc.bcccc.shared.TerrainRecordAndRights; |
|
41 |
|
|
42 |
import com.google.gwt.user.client.History; |
|
43 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
44 |
import com.smartgwt.client.types.TitleOrientation; |
|
45 |
import com.smartgwt.client.util.SC; |
|
46 |
import com.smartgwt.client.widgets.form.DynamicForm; |
|
47 |
import com.smartgwt.client.widgets.form.fields.ButtonItem; |
|
48 |
import com.smartgwt.client.widgets.layout.VLayout; |
|
49 |
|
|
50 |
// TODO: Auto-generated Javadoc |
|
51 |
/** |
|
52 |
* The Class ViewAndEditTerrainRecordPanel. |
|
53 |
*/ |
|
54 |
public class ViewAndEditTerrainRecordPanel extends VLayout { |
|
55 |
|
|
56 |
/** The record. */ |
|
57 |
public TerrainRecordAndRights record; |
|
58 |
|
|
59 |
/** |
|
60 |
* Instantiates a new view and edit terrain record panel. |
|
61 |
*/ |
|
62 |
public ViewAndEditTerrainRecordPanel() { |
|
63 |
this.setWidth100(); |
|
64 |
this.setHeight100(); |
|
65 |
} |
|
66 |
|
|
67 |
/** The init view and edit done. */ |
|
68 |
boolean initViewAndEditDone; |
|
69 |
|
|
70 |
/** The view and edit form. */ |
|
71 |
private DynamicForm viewAndEditForm; |
|
72 |
|
|
73 |
/** The save vae button. */ |
|
74 |
private ButtonItem saveVAEButton; |
|
75 |
|
|
76 |
/** The delete vae button. */ |
|
77 |
private ButtonItem deleteVAEButton; |
|
78 |
|
|
79 |
/** The validate vae button. */ |
|
80 |
private ButtonItem validateVAEButton; |
|
81 |
|
|
82 |
/** The name field. */ |
|
83 |
private StringRecordField nameField; |
|
84 |
|
|
85 |
/** The project field. */ |
|
86 |
private StringRecordField projectField; |
|
87 |
|
|
88 |
/** The description field. */ |
|
89 |
private LongStringRecordArea descriptionField; |
|
90 |
|
|
91 |
/** The date field. */ |
|
92 |
private DateRecordArea dateField; |
|
93 |
|
|
94 |
/** The participants field. */ |
|
95 |
private StringRecordField participantsField; |
|
96 |
|
|
97 |
/** The types field. */ |
|
98 |
private StringRecordField typesField; |
|
99 |
|
|
100 |
/** The dispositifs field. */ |
|
101 |
private DispositifsRecordArea dispositifsField; |
|
102 |
|
|
103 |
/** The data field. */ |
|
104 |
private DataRecordArea dataField; |
|
105 |
|
|
106 |
/** The documentation field. */ |
|
107 |
private DocumentsRecordArea documentationField; |
|
108 |
|
|
109 |
/** The report field. */ |
|
110 |
private ReportsRecordArea reportField; |
|
111 |
|
|
112 |
/** The publication field. */ |
|
113 |
private PublicationsRecordArea publicationField; |
|
114 |
|
|
115 |
/** |
|
116 |
* Inits the. |
|
117 |
*/ |
|
118 |
protected void init() { |
|
119 |
this.hide(); |
|
120 |
if (!initViewAndEditDone) { |
|
121 |
initViewAndEditDone = true; |
|
122 |
|
|
123 |
viewAndEditForm = new DynamicForm(); |
|
124 |
|
|
125 |
saveVAEButton = new ButtonItem("save_record"); |
|
126 |
saveVAEButton.setTitle("Save changes"); |
|
127 |
saveVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
128 |
@Override |
|
129 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
130 |
final String ID = viewAndEditForm.getValueAsString(K.ID); |
|
131 |
if (ID == null || ID.trim().length() == 0) return; |
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
// typesField |
|
136 |
// dispositifsField |
|
137 |
// dataField |
|
138 |
// documentationField |
|
139 |
// reportField |
|
140 |
// publicationField |
|
141 |
|
|
142 |
record.record.setInfoFields(nameField.getValue(), |
|
143 |
projectField.getValue(), |
|
144 |
dateField.getDate(), |
|
145 |
descriptionField.getValue(), |
|
146 |
"???"); |
|
147 |
|
|
148 |
record.record.setDetailFields(Integer.parseInt(participantsField.getValue()), |
|
149 |
viewAndEditForm.getValueAsString(K.PLACE), |
|
150 |
typesField.getValuesAsStringArray(), |
|
151 |
new ArrayList<String>(), |
|
152 |
dispositifsField.getValues(), |
|
153 |
documentationField.getValues(), |
|
154 |
dataField.getValues(), |
|
155 |
reportField.getValues(), |
|
156 |
publicationField.getValues()); |
|
157 |
|
|
158 |
Services.getMain().createRecord(record.record, new AsyncCallback<Boolean>() { |
|
159 |
@Override |
|
160 |
public void onFailure(Throwable caught) { |
|
161 |
SC.warn(caught.getMessage()); |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public void onSuccess(Boolean result) { |
|
166 |
if (result) { |
|
167 |
SC.warn("Record '"+ID+"' saved: "+record.record); |
|
168 |
} else { |
|
169 |
SC.warn("Record '"+ID+"' NOT created."); |
|
170 |
} |
|
171 |
} |
|
172 |
}); |
|
173 |
} |
|
174 |
}); |
|
175 |
|
|
176 |
deleteVAEButton = new ButtonItem("delete_record"); |
|
177 |
deleteVAEButton.setTitle("Delete record"); |
|
178 |
deleteVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
179 |
@Override |
|
180 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
181 |
Services.getMain().deleteRecord(record.record.uniq_id, new AsyncCallback<Boolean>() { |
|
182 |
@Override |
|
183 |
public void onFailure(Throwable caught) { |
|
184 |
SC.warn("Error: "+caught); |
|
185 |
} |
|
186 |
|
|
187 |
@Override |
|
188 |
public void onSuccess(Boolean result) { |
|
189 |
if (result) { |
|
190 |
SC.say("Deleted."); |
|
191 |
History.newItem(K.BROWSE+"_my"); |
|
192 |
} else { |
|
193 |
SC.say("NOT Deleted."); |
|
194 |
} |
|
195 |
} |
|
196 |
}); |
|
197 |
} |
|
198 |
}); |
|
199 |
|
|
200 |
validateVAEButton = new ButtonItem("validate_record"); |
|
201 |
validateVAEButton.setTitle("Validate record"); |
|
202 |
validateVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
203 |
@Override |
|
204 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
205 |
Services.getMain().setValidateRecordValue(record.record.uniq_id, false, new AsyncCallback<Boolean>() { |
|
206 |
@Override |
|
207 |
public void onFailure(Throwable caught) { |
|
208 |
SC.warn("Error: "+caught); |
|
209 |
} |
|
210 |
|
|
211 |
@Override |
|
212 |
public void onSuccess(Boolean result) { |
|
213 |
SC.say("Validated? "+result); |
|
214 |
} |
|
215 |
}); |
|
216 |
} |
|
217 |
}); |
|
218 |
|
|
219 |
viewAndEditForm.setNumCols(3); |
|
220 |
viewAndEditForm.setAutoWidth(); |
|
221 |
viewAndEditForm.setItems(deleteVAEButton, validateVAEButton, saveVAEButton); |
|
222 |
viewAndEditForm.setTitleOrientation(TitleOrientation.LEFT); |
|
223 |
|
|
224 |
nameField = new StringRecordField(this, "Name", false, true, null); |
|
225 |
projectField = new StringRecordField(this, "Project", false, true, null); |
|
226 |
dateField = new DateRecordArea(this, "Date", false, true, null); |
|
227 |
participantsField = new StringRecordField(this, "Participants", true, true, null); |
|
228 |
String[] typesValues = {"privé", "commerce", "école", "etc."}; |
|
229 |
typesField = new StringRecordField(this, "Types", true, false, typesValues); |
|
230 |
dispositifsField = new DispositifsRecordArea(this, "Dispositifs"); |
|
231 |
dataField = new DataRecordArea(this, "Données"); |
|
232 |
documentationField = new DocumentsRecordArea(this, "Documentation"); |
|
233 |
reportField = new ReportsRecordArea(this, "Rapports"); |
|
234 |
publicationField = new PublicationsRecordArea(this, "Publications"); |
|
235 |
} |
|
236 |
|
|
237 |
if (BCCCC.doubleClickedRecord != null) { // load record informations |
|
238 |
System.out.println("Reloading viewAndEdit record... "+BCCCC.doubleClickedRecord); |
|
239 |
Services.getMain().getRecord(BCCCC.doubleClickedRecord.uniq_id, new AsyncCallback<TerrainRecordAndRights>() { |
|
240 |
@Override |
|
241 |
public void onFailure(Throwable caught) { |
|
242 |
SC.warn("Error: "+caught); |
|
243 |
} |
|
244 |
|
|
245 |
@Override |
|
246 |
public void onSuccess(TerrainRecordAndRights result) { |
|
247 |
|
|
248 |
if (result == null) { |
|
249 |
SC.warn("Error: no record found for ID="+BCCCC.doubleClickedRecord); |
|
250 |
return; |
|
251 |
} |
|
252 |
record = result; |
|
253 |
|
|
254 |
viewAndEditForm.setCanEdit(result.editable); |
|
255 |
validateVAEButton.setDisabled(!result.validable); |
|
256 |
validateVAEButton.setStartRow(false); |
|
257 |
validateVAEButton.setEndRow(false); |
|
258 |
deleteVAEButton.setDisabled(!result.deletable); |
|
259 |
deleteVAEButton.setStartRow(false); |
|
260 |
deleteVAEButton.setEndRow(false); |
|
261 |
saveVAEButton.setDisabled(!result.editable); |
|
262 |
saveVAEButton.setStartRow(false); |
|
263 |
saveVAEButton.setEndRow(false); |
|
264 |
|
|
265 |
addMember(viewAndEditForm); |
|
266 |
viewAndEditForm.setVisible(result.editable); |
|
267 |
|
|
268 |
nameField.setCanEdit(record.editable); |
|
269 |
nameField.setValue(record.record.name); |
|
270 |
projectField.setCanEdit(record.editable); |
|
271 |
projectField.setValue(record.record.project); |
|
272 |
typesField.setCanEdit(record.editable); |
|
273 |
typesField.setValues(record.record.types); |
|
274 |
dateField.setCanEdit(record.editable); |
|
275 |
dateField.setValue(record.record.date); |
|
276 |
participantsField.setCanEdit(record.editable); |
|
277 |
dispositifsField.setCanEdit(record.editable); |
|
278 |
dispositifsField.setValues(record.record.dispositifs); |
|
279 |
dataField.setCanEdit(record.editable); |
|
280 |
dataField.setDataValues(record.record.supports); |
|
281 |
documentationField.setCanEdit(record.editable); |
|
282 |
documentationField.setDocumentationValues(record.record.documentations); |
|
283 |
reportField.setCanEdit(record.editable); |
|
284 |
reportField.setValues(record.record.reports); |
|
285 |
publicationField.setCanEdit(record.editable); |
|
286 |
publicationField.setPublicationValues(record.record.publications); |
|
287 |
|
|
288 |
addMember(viewAndEditForm); |
|
289 |
addMember(nameField); |
|
290 |
addMember(projectField); |
|
291 |
addMember(dateField); |
|
292 |
addMember(typesField); |
|
293 |
addMember(participantsField); |
|
294 |
addMember(dispositifsField); |
|
295 |
addMember(dataField); |
|
296 |
addMember(documentationField); |
|
297 |
addMember(reportField); |
|
298 |
addMember(publicationField); |
|
299 |
show(); |
|
300 |
} |
|
301 |
}); |
|
302 |
} else { |
|
303 |
this.show(); |
|
304 |
} |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* To string list. |
|
309 |
* |
|
310 |
* @param string the string |
|
311 |
* @return the string |
|
312 |
*/ |
|
313 |
protected static String toStringList(String string) { |
|
314 |
return string.replace("[", "").replace("]", ""); |
|
315 |
} |
|
316 |
|
|
317 |
/** |
|
318 |
* Checks if is record changed. |
|
319 |
* |
|
320 |
* @return true, if is record changed |
|
321 |
*/ |
|
322 |
public boolean isRecordChanged() { |
|
323 |
if (record != null) { |
|
324 |
return false; |
|
325 |
} else { |
|
326 |
return false; |
|
327 |
} |
|
328 |
} |
|
329 |
} |
projets/BCCCC/src/org/ccc/bcccc/client/HomePanel.java (revision 6) | ||
---|---|---|
1 |
/* |
|
2 |
* Authors: Matthieu Decorde |
|
3 |
* |
|
4 |
* COPYRIGHT 2015 ICAR - CCC |
|
5 |
* |
|
6 |
* This software is free software: you can redistribute it |
|
7 |
* and/or modify it under the terms of the GNU General Public |
|
8 |
* License as published by the Free Software Foundation, |
|
9 |
* either version 2 of the License, or (at your option) any |
|
10 |
* later version. |
|
11 |
* |
|
12 |
* This software is distributed in the hope that it will be |
|
13 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
* PURPOSE. See the GNU General Public License for more |
|
16 |
* details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
package org.ccc.bcccc.client; |
|
20 |
|
|
21 |
import com.smartgwt.client.widgets.HTMLPane; |
|
22 |
import com.smartgwt.client.widgets.layout.VLayout; |
|
23 |
|
|
24 |
// TODO: Auto-generated Javadoc |
|
25 |
/** |
|
26 |
* The Class HomePanel. |
|
27 |
*/ |
|
28 |
public class HomePanel extends VLayout { |
|
29 |
|
|
30 |
/** |
|
31 |
* Instantiates a new home panel. |
|
32 |
*/ |
|
33 |
public HomePanel() { |
|
34 |
this.setWidth100(); |
|
35 |
this.setHeight100(); |
|
36 |
} |
|
37 |
|
|
38 |
/** The init home done. */ |
|
39 |
boolean initHomeDone = false; |
|
40 |
|
|
41 |
/** |
|
42 |
* Inits the. |
|
43 |
*/ |
|
44 |
protected void init() { |
|
45 |
if (initHomeDone) return; |
|
46 |
initHomeDone = true; |
|
47 |
|
|
48 |
HTMLPane l = new HTMLPane(); |
|
49 |
l.setWidth100(); |
|
50 |
l.setHeight100(); |
|
51 |
l.setContentsURL("welcome.html"); |
|
52 |
this.addMember(l); |
|
53 |
this.setMargin(10); |
|
54 |
} |
|
55 |
} |
projets/BCCCC/src/org/ccc/bcccc/client/panels/EditPanel.java (revision 6) | ||
---|---|---|
1 |
/* |
|
2 |
* Authors: Matthieu Decorde |
|
3 |
* |
|
4 |
* COPYRIGHT 2015 ICAR - CCC |
|
5 |
* |
|
6 |
* This software is free software: you can redistribute it |
|
7 |
* and/or modify it under the terms of the GNU General Public |
|
8 |
* License as published by the Free Software Foundation, |
|
9 |
* either version 2 of the License, or (at your option) any |
|
10 |
* later version. |
|
11 |
* |
|
12 |
* This software is distributed in the hope that it will be |
|
13 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
* PURPOSE. See the GNU General Public License for more |
|
16 |
* details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
package org.ccc.bcccc.client.panels; |
|
20 |
|
|
21 |
import java.util.ArrayList; |
|
22 |
|
|
23 |
import org.ccc.bcccc.client.BCCCC; |
|
24 |
import org.ccc.bcccc.client.Services; |
|
25 |
import org.ccc.bcccc.client.areas.DataRecordArea; |
|
26 |
import org.ccc.bcccc.client.areas.DateRecordArea; |
|
27 |
import org.ccc.bcccc.client.areas.DispositifsRecordArea; |
|
28 |
import org.ccc.bcccc.client.areas.DocumentsRecordArea; |
|
29 |
import org.ccc.bcccc.client.areas.IntegerRecordArea; |
|
30 |
import org.ccc.bcccc.client.areas.LongStringRecordArea; |
|
31 |
import org.ccc.bcccc.client.areas.PublicationsRecordArea; |
|
32 |
import org.ccc.bcccc.client.areas.ReportsRecordArea; |
|
33 |
import org.ccc.bcccc.client.areas.StringRecordField; |
|
34 |
import org.ccc.bcccc.shared.K; |
|
35 |
import org.ccc.bcccc.shared.TerrainRecordAndRights; |
|
36 |
|
|
37 |
import com.google.gwt.user.client.History; |
|
38 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
39 |
import com.smartgwt.client.types.TitleOrientation; |
|
40 |
import com.smartgwt.client.util.SC; |
|
41 |
import com.smartgwt.client.widgets.form.DynamicForm; |
|
42 |
import com.smartgwt.client.widgets.form.fields.ButtonItem; |
|
43 |
import com.smartgwt.client.widgets.layout.VLayout; |
|
44 |
|
|
45 |
// TODO: Auto-generated Javadoc |
|
46 |
/** |
|
47 |
* The Class ViewAndEditTerrainRecordPanel. |
|
48 |
*/ |
|
49 |
public class EditPanel extends VLayout { |
|
50 |
|
|
51 |
/** The record. */ |
|
52 |
public TerrainRecordAndRights record; |
|
53 |
|
|
54 |
/** |
|
55 |
* Instantiates a new view and edit terrain record panel. |
|
56 |
*/ |
|
57 |
public EditPanel() { |
|
58 |
this.setWidth100(); |
|
59 |
this.setHeight100(); |
|
60 |
} |
|
61 |
|
|
62 |
/** The init view and edit done. */ |
|
63 |
boolean initViewAndEditDone; |
|
64 |
|
|
65 |
/** The view and edit form. */ |
|
66 |
private DynamicForm viewAndEditForm; |
|
67 |
|
|
68 |
/** The save vae button. */ |
|
69 |
private ButtonItem saveVAEButton; |
|
70 |
|
|
71 |
/** The delete vae button. */ |
|
72 |
private ButtonItem deleteVAEButton; |
|
73 |
|
|
74 |
/** The validate vae button. */ |
|
75 |
private ButtonItem validateVAEButton; |
|
76 |
|
|
77 |
/** The name field. */ |
|
78 |
private StringRecordField nameField; |
|
79 |
|
|
80 |
/** The project field. */ |
|
81 |
private StringRecordField projectField; |
|
82 |
|
|
83 |
/** The description field. */ |
|
84 |
private LongStringRecordArea descriptionField; |
|
85 |
|
|
86 |
/** The date field. */ |
|
87 |
private DateRecordArea dateField; |
|
88 |
|
|
89 |
/** The number of participants field. */ |
|
90 |
private IntegerRecordArea numberOfParticipantsField; |
|
91 |
|
|
92 |
/** The participants field. */ |
|
93 |
private StringRecordField personsField; |
|
94 |
|
|
95 |
/** The types field. */ |
|
96 |
private StringRecordField typesField; |
|
97 |
|
|
98 |
/** The dispositifs field. */ |
|
99 |
private DispositifsRecordArea dispositifsField; |
|
100 |
|
|
101 |
/** The data field. */ |
|
102 |
private DataRecordArea dataField; |
|
103 |
|
|
104 |
/** The documentation field. */ |
|
105 |
private DocumentsRecordArea documentationField; |
|
106 |
|
|
107 |
/** The report field. */ |
|
108 |
private ReportsRecordArea reportField; |
|
109 |
|
|
110 |
/** The publication field. */ |
|
111 |
private PublicationsRecordArea publicationField; |
|
112 |
|
|
113 |
/** |
|
114 |
* Inits the. |
|
115 |
*/ |
|
116 |
public void init() { |
|
117 |
this.hide(); |
|
118 |
if (!initViewAndEditDone) { |
|
119 |
initViewAndEditDone = true; |
|
120 |
|
|
121 |
viewAndEditForm = new DynamicForm(); |
|
122 |
|
|
123 |
saveVAEButton = new ButtonItem("save_record"); |
|
124 |
saveVAEButton.setTitle("Save changes"); |
|
125 |
saveVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
126 |
@Override |
|
127 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
128 |
// final String ID = viewAndEditForm.getValueAsString(K.ID); |
|
129 |
// if (ID == null || ID.trim().length() == 0) return; |
|
130 |
|
|
131 |
record.record.setInfoFields(nameField.getValue(), |
|
132 |
projectField.getValue(), |
|
133 |
dateField.getDate(), |
|
134 |
descriptionField.getValue(), |
|
135 |
"???"); |
|
136 |
|
|
137 |
record.record.setDetailFields(Integer.parseInt(numberOfParticipantsField.getValue()), |
|
138 |
viewAndEditForm.getValueAsString(K.PLACE), |
|
139 |
typesField.getValuesAsStringArray(), |
|
140 |
new ArrayList<String>(), |
|
141 |
personsField.getValuesAsStringArray(), |
|
142 |
dispositifsField.getValues(), |
|
143 |
documentationField.getValues(), |
|
144 |
dataField.getValues(), |
|
145 |
reportField.getValues(), |
|
146 |
publicationField.getValues()); |
|
147 |
|
|
148 |
System.out.println("Call updateRecord: "+record.record.uniq_id+", "+record.record); |
|
149 |
Services.getMain().updateRecord(record.record.uniq_id, null, new AsyncCallback<Boolean>() { |
|
150 |
|
|
151 |
@Override |
|
152 |
public void onFailure(Throwable caught) { |
|
153 |
SC.warn(caught.getMessage()); |
|
154 |
caught.printStackTrace(); |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public void onSuccess(Boolean result) { |
|
159 |
if (result) { |
|
160 |
SC.warn("Record '"+record.record.uniq_id+"' saved: "+record.record); |
|
161 |
} else { |
|
162 |
SC.warn("Record '"+record.record.uniq_id+"' NOT created."); |
|
163 |
} |
|
164 |
} |
|
165 |
}); |
|
166 |
} |
|
167 |
}); |
|
168 |
|
|
169 |
deleteVAEButton = new ButtonItem("delete_record"); |
|
170 |
deleteVAEButton.setTitle("Delete record"); |
|
171 |
deleteVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
172 |
@Override |
|
173 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
174 |
Services.getMain().deleteRecord(record.record.uniq_id, new AsyncCallback<Boolean>() { |
|
175 |
@Override |
|
176 |
public void onFailure(Throwable caught) { |
|
177 |
SC.warn("Error: "+caught); |
|
178 |
} |
|
179 |
|
|
180 |
@Override |
|
181 |
public void onSuccess(Boolean result) { |
|
182 |
if (result) { |
|
183 |
SC.say("Deleted."); |
|
184 |
History.newItem(K.BROWSE+"_my"); |
|
185 |
} else { |
|
186 |
SC.say("NOT Deleted."); |
|
187 |
} |
|
188 |
} |
|
189 |
}); |
|
190 |
} |
|
191 |
}); |
|
192 |
|
|
193 |
validateVAEButton = new ButtonItem("validate_record"); |
|
194 |
validateVAEButton.setTitle("Validate record"); |
|
195 |
validateVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
196 |
@Override |
|
197 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
198 |
Services.getMain().setValidateRecordValue(record.record.uniq_id, false, new AsyncCallback<Boolean>() { |
|
199 |
@Override |
|
200 |
public void onFailure(Throwable caught) { |
|
201 |
SC.warn("Error: "+caught); |
|
202 |
} |
|
203 |
|
|
204 |
@Override |
|
205 |
public void onSuccess(Boolean result) { |
|
206 |
SC.say("Validated? "+result); |
|
207 |
} |
|
208 |
}); |
|
209 |
} |
|
210 |
}); |
|
211 |
|
|
212 |
viewAndEditForm.setNumCols(3); |
|
213 |
viewAndEditForm.setAutoWidth(); |
|
214 |
viewAndEditForm.setItems(deleteVAEButton, validateVAEButton, saveVAEButton); |
|
215 |
viewAndEditForm.setTitleOrientation(TitleOrientation.LEFT); |
|
216 |
|
|
217 |
nameField = new StringRecordField(this, "Name", false, true, null); |
|
218 |
projectField = new StringRecordField(this, "Project", false, true, null); |
|
219 |
descriptionField = new LongStringRecordArea(this, "Description", false, true); |
|
220 |
dateField = new DateRecordArea(this, "Date", false, true, null); |
|
221 |
numberOfParticipantsField = new IntegerRecordArea(this, "Number of participants"); |
|
222 |
personsField = new StringRecordField(this, "Participants", true, true, null); |
|
223 |
String[] typesValues = {"privé", "commerce", "école", "etc."}; |
|
224 |
typesField = new StringRecordField(this, "Types", true, false, typesValues); |
|
225 |
dispositifsField = new DispositifsRecordArea(this, "Dispositifs"); |
|
226 |
dataField = new DataRecordArea(this, "Données"); |
|
227 |
documentationField = new DocumentsRecordArea(this, "Documentation"); |
|
228 |
reportField = new ReportsRecordArea(this, "Rapports"); |
|
229 |
publicationField = new PublicationsRecordArea(this, "Publications"); |
|
230 |
} |
|
231 |
|
|
232 |
if (BCCCC.doubleClickedRecord != null) { // load record informations |
|
233 |
System.out.println("Reloading viewAndEdit record... "+BCCCC.doubleClickedRecord); |
|
234 |
Services.getMain().getRecord(BCCCC.doubleClickedRecord.uniq_id, new AsyncCallback<TerrainRecordAndRights>() { |
|
235 |
@Override |
|
236 |
public void onFailure(Throwable caught) { |
|
237 |
SC.warn("Error: "+caught); |
|
238 |
} |
|
239 |
|
|
240 |
@Override |
|
241 |
public void onSuccess(TerrainRecordAndRights result) { |
|
242 |
|
|
243 |
if (result == null) { |
|
244 |
SC.warn("Error: no record found for ID="+BCCCC.doubleClickedRecord); |
|
245 |
return; |
|
246 |
} |
|
247 |
record = result; |
|
248 |
//record.record.uniq_id = BCCCC.doubleClickedRecord.uniq_id; |
|
249 |
|
|
250 |
viewAndEditForm.setCanEdit(result.editable); |
|
251 |
validateVAEButton.setDisabled(!result.validable); |
|
252 |
validateVAEButton.setStartRow(false); |
|
253 |
validateVAEButton.setEndRow(false); |
|
254 |
deleteVAEButton.setDisabled(!result.deletable); |
|
255 |
deleteVAEButton.setStartRow(false); |
|
256 |
deleteVAEButton.setEndRow(false); |
|
257 |
saveVAEButton.setDisabled(!result.editable); |
|
258 |
saveVAEButton.setStartRow(false); |
|
259 |
saveVAEButton.setEndRow(false); |
|
260 |
|
|
261 |
addMember(viewAndEditForm); |
|
262 |
viewAndEditForm.setVisible(result.editable); |
|
263 |
|
|
264 |
nameField.setCanEdit(record.editable); |
|
265 |
nameField.setValue(record.record.name); |
|
266 |
projectField.setCanEdit(record.editable); |
|
267 |
projectField.setValue(record.record.project); |
|
268 |
descriptionField.setCanEdit(record.editable); |
|
269 |
descriptionField.setValue(record.record.short_description); |
|
270 |
typesField.setCanEdit(record.editable); |
|
271 |
typesField.setValues(record.record.types); |
|
272 |
dateField.setCanEdit(record.editable); |
|
273 |
dateField.setValue(record.record.date); |
|
274 |
numberOfParticipantsField.setCanEdit(record.editable); |
|
275 |
numberOfParticipantsField.setValue(record.record.numberOfParticipants); |
|
276 |
personsField.setCanEdit(record.editable); |
|
277 |
dispositifsField.setCanEdit(record.editable); |
|
278 |
dispositifsField.setValues(record.record.dispositifs); |
|
279 |
dataField.setCanEdit(record.editable); |
|
280 |
dataField.setDataValues(record.record.supports); |
|
281 |
documentationField.setCanEdit(record.editable); |
|
282 |
documentationField.setValues(record.record.documentations); |
|
283 |
reportField.setCanEdit(record.editable); |
|
284 |
reportField.setValues(record.record.reports); |
|
285 |
publicationField.setCanEdit(record.editable); |
|
286 |
publicationField.setValues(record.record.publications); |
|
287 |
|
|
288 |
addMember(viewAndEditForm); |
|
289 |
addMember(nameField); |
|
290 |
addMember(projectField); |
|
291 |
addMember(descriptionField); |
|
292 |
addMember(dateField); |
|
293 |
addMember(numberOfParticipantsField); |
|
294 |
addMember(typesField); |
|
295 |
addMember(personsField); |
|
296 |
addMember(dispositifsField); |
|
297 |
addMember(dataField); |
|
298 |
addMember(documentationField); |
|
299 |
addMember(reportField); |
|
300 |
addMember(publicationField); |
|
301 |
show(); |
|
302 |
} |
|
303 |
}); |
|
304 |
} else { |
|
305 |
this.show(); |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* To string list. |
|
311 |
* |
|
312 |
* @param string the string |
|
313 |
* @return the string |
|
314 |
*/ |
|
315 |
protected static String toStringList(String string) { |
|
316 |
return string.replace("[", "").replace("]", ""); |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* Checks if is record changed. |
|
321 |
* |
|
322 |
* @return true, if is record changed |
|
323 |
*/ |
|
324 |
public boolean isRecordChanged() { |
|
325 |
if (record != null) { |
|
326 |
return false; |
|
327 |
} else { |
|
328 |
return false; |
|
329 |
} |
|
330 |
} |
|
331 |
} |
projets/BCCCC/src/org/ccc/bcccc/client/panels/SearchPanel.java (revision 6) | ||
---|---|---|
1 |
/* |
|
2 |
* Authors: Matthieu Decorde |
|
3 |
* |
|
4 |
* COPYRIGHT 2015 ICAR - CCC |
|
5 |
* |
|
6 |
* This software is free software: you can redistribute it |
|
7 |
* and/or modify it under the terms of the GNU General Public |
|
8 |
* License as published by the Free Software Foundation, |
|
9 |
* either version 2 of the License, or (at your option) any |
|
10 |
* later version. |
|
11 |
* |
|
12 |
* This software is distributed in the hope that it will be |
|
13 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
* PURPOSE. See the GNU General Public License for more |
|
16 |
* details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
package org.ccc.bcccc.client.panels; |
|
20 |
|
|
21 |
import java.util.ArrayList; |
|
22 |
import java.util.HashMap; |
|
23 |
|
|
24 |
import org.ccc.bcccc.client.BCCCC; |
|
25 |
import org.ccc.bcccc.client.Services; |
|
26 |
import org.ccc.bcccc.shared.Dispositif; |
|
27 |
import org.ccc.bcccc.shared.DocumentUnit; |
|
28 |
import org.ccc.bcccc.shared.K; |
|
29 |
import org.ccc.bcccc.shared.TerrainRecord; |
|
30 |
|
|
31 |
import com.google.gwt.user.client.History; |
|
32 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
33 |
import com.smartgwt.client.types.MultipleAppearance; |
|
34 |
import com.smartgwt.client.util.SC; |
|
35 |
import com.smartgwt.client.widgets.form.DynamicForm; |
|
36 |
import com.smartgwt.client.widgets.form.fields.ButtonItem; |
|
37 |
import com.smartgwt.client.widgets.form.fields.SelectItem; |
|
38 |
import com.smartgwt.client.widgets.form.fields.SliderItem; |
|
39 |
import com.smartgwt.client.widgets.form.fields.TextItem; |
|
40 |
import com.smartgwt.client.widgets.layout.VLayout; |
|
41 |
|
|
42 |
// TODO: Auto-generated Javadoc |
|
43 |
/** |
|
44 |
* The Class SearchPanel. |
|
45 |
*/ |
|
46 |
public class SearchPanel extends VLayout { |
|
47 |
|
|
48 |
/** |
|
49 |
* Instantiates a new search panel. |
|
50 |
*/ |
|
51 |
public SearchPanel() { |
|
52 |
this.setWidth100(); |
|
53 |
this.setHeight100(); |
|
54 |
} |
|
55 |
|
|
56 |
/** The init search complex done. */ |
|
57 |
boolean initSearchComplexDone = false; |
|
58 |
|
|
59 |
/** |
|
60 |
* Inits the. |
|
61 |
*/ |
|
62 |
public void init() { |
|
63 |
if (initSearchComplexDone) return; |
|
64 |
initSearchComplexDone = true; |
|
65 |
|
|
66 |
final DynamicForm form = new DynamicForm(); |
|
67 |
form.setWidth100(); |
|
68 |
form.setHeight100(); |
|
69 |
this.addMember(form); |
|
70 |
|
|
71 |
TextItem wordsField = new TextItem(K.WORDS, "Recherche par mot"); |
|
72 |
|
|
73 |
|
|
74 |
SelectItem types = new SelectItem(K.TYPES); |
|
75 |
types.setTitle("Terrain types"); |
|
76 |
types.setMultiple(true); |
|
77 |
types.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
78 |
types.setValueMap("commerce", "apprentissage", "privé", "médical", "etc."); |
|
79 |
|
|
80 |
SelectItem projets = new SelectItem("projets"); |
|
81 |
projets.setTitle("Projet"); |
|
82 |
projets.setMultiple(true); |
|
83 |
projets.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
84 |
projets.setValueMap("projet1", "projet2", "projetN"); |
|
85 |
|
|
86 |
SliderItem participants = new SliderItem(K.NUMBEROFPARTICIPANTS); |
|
87 |
participants.setTitle("More than N persons"); |
|
88 |
participants.setMinValue(1); |
|
89 |
participants.setMaxValue(100); |
|
90 |
// participants.setNumValues(5); |
|
91 |
participants.setDefaultValue(1); |
|
92 |
|
|
93 |
SelectItem dispositifs = new SelectItem(K.DISPOSITIFS); |
|
94 |
dispositifs.setTitle("Dispositifs"); |
|
95 |
dispositifs.setMultiple(true); |
|
96 |
dispositifs.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
97 |
dispositifs.setValueMap(Dispositif.types); |
|
98 |
|
|
99 |
|
|
100 |
SelectItem supports = new SelectItem(K.SUPPORTS); |
|
101 |
supports.setTitle("Supports"); |
|
102 |
supports.setMultiple(true); |
|
103 |
supports.setMultipleAppearance(MultipleAppearance.PICKLIST); |
|
104 |
supports.setValueMap(DocumentUnit.values); |
|
105 |
|
|
106 |
ButtonItem validate = new ButtonItem("validate"); |
|
107 |
validate.setTitle("Search"); |
|
108 |
validate.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { |
|
109 |
@Override |
|
110 |
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { |
|
111 |
|
|
112 |
String words_value = form.getValueAsString(K.WORDS); |
|
113 |
if (words_value == null) words_value = ""; |
|
114 |
else words_value = words_value.trim(); |
|
115 |
|
|
116 |
String types_value = form.getValueAsString(K.TYPES); |
|
117 |
if (types_value == null) types_value = ""; |
|
118 |
else types_value = types_value.trim(); |
|
119 |
|
|
120 |
String projects_value = form.getValueAsString(K.PROJECTS); |
|
121 |
if (projects_value == null) projects_value = ""; |
|
122 |
else projects_value = projects_value.trim(); |
|
123 |
|
|
124 |
String participants_value = form.getValueAsString(K.NUMBEROFPARTICIPANTS); |
|
125 |
if (participants_value == null) participants_value = ""; |
|
126 |
else participants_value = participants_value.trim(); |
|
127 |
|
|
128 |
String dispositifs_value = form.getValueAsString(K.DISPOSITIFS); |
|
129 |
if (dispositifs_value == null) dispositifs_value = ""; |
|
130 |
else dispositifs_value = dispositifs_value.trim(); |
|
131 |
|
|
132 |
String supports_value = form.getValueAsString(K.SUPPORTS); |
|
133 |
if (supports_value == null) supports_value = ""; |
|
134 |
else supports_value = supports_value.trim(); |
|
135 |
|
|
136 |
if (types_value.length() == 0 && |
|
137 |
projects_value.length() == 0 && |
|
138 |
participants_value.length() == 0 && |
|
139 |
dispositifs_value.length() == 0 && |
|
140 |
supports_value.length() == 0) return; |
|
141 |
|
|
142 |
System.out.println("Updating records..."); |
|
143 |
|
|
144 |
HashMap<String, String> critera = new HashMap<String, String>(); |
|
145 |
critera.put(K.WORDS, words_value); |
|
146 |
critera.put(K.TYPES, types_value); |
|
147 |
critera.put(K.PROJECTS, projects_value); |
|
148 |
critera.put(K.DISPOSITIFS, dispositifs_value); |
|
149 |
critera.put(K.SUPPORTS, supports_value); |
|
150 |
critera.put(K.NUMBEROFPARTICIPANTS, participants_value); |
|
151 |
|
|
152 |
Services.getMain().getRecordsWithComplexCritera(critera, new AsyncCallback<ArrayList<TerrainRecord>>() { |
|
153 |
@Override |
|
154 |
public void onFailure(Throwable caught) { |
|
155 |
SC.warn(caught.getMessage()); |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public void onSuccess(ArrayList<TerrainRecord> result) { |
|
160 |
BCCCC.searched_records = new ArrayList<TerrainRecord>(); |
|
161 |
if (result != null) { |
|
162 |
System.out.println("Found: "+result.size()); |
|
163 |
BCCCC.searched_records = result; |
|
164 |
} |
|
165 |
History.newItem("browse_searched"); |
|
166 |
} |
|
167 |
}); |
|
168 |
} |
|
169 |
}); |
|
170 |
|
|
171 |
form.setItems(wordsField, types, projets, participants, dispositifs, supports, validate); |
Formats disponibles : Unified diff