package com offshorestar gwt client ui import java util Collection imp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
*
*/
package com.offshorestar.gwt.client.ui;
import java.util.Collection;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.google.gwt.core.client.GWT;
import com.offshorestar.gwt.client.i18n.OffstarMessages;
import com.offshorestar.gwt.client.service.ServiceHelper;
import com.offshorestar.gwt.client.util.AsyncCallbackAdapter;
import com.offshorestar.gwt.domain.Currency;
/**
* @author Ilja S.
*
*/
public class CommonUI {
private static OffstarMessages messages = null;
private static Collection<Currency> currencies = null;
public static OffstarMessages getMessages() {
if (messages == null) {
messages = GWT.create(OffstarMessages.class);
}
return messages;
}
public static void alert(String msg) {
MessageBox.alert("Warning", msg, null);
}
public static void alert(Throwable t) {
String s = t.toString() + "<br/>";
for (int i = 0; i < t.getStackTrace().length; i++) {
s += t.getStackTrace()[i] + "<br/>";
}
MessageBox box = MessageBox.alert("Error", s, null);
box.getDialog().setWidth(600);
box.getDialog().setShadow(false);
box.getDialog().layout();
}
public static ComboBox<ModelData> getCurrencyComboBox() {
ComboBox<ModelData> currency = new CommonComboBox() {
@Override
public void loadDataImpl(final DataLoadCallback callback) {
ServiceHelper.getRemoteGwtService().getCurrencies(new AsyncCallbackAdapter<Collection<Currency>>() {
public void onSuccess(Collection<Currency> result) {
currencies = result;
callback.dataReady(currencies);
}
});
}
};
currency.setFieldLabel(getMessages().currency());
currency.setDisplayField("name");
currency.setValueField("id");
return currency;
}
}