use of com.extjs.gxt.ui.client.fx.Draggable in project geo-platform by geosdi.
the class GPScaleWidget method onShowInfo.
protected void onShowInfo() {
Draggable d = new Draggable(this, this.getHeader());
d.setContainer(LayoutManager.getInstance().getCenter());
d.setUseProxy(false);
RootPanel.get().add(this);
el().makePositionable(true);
setTitle();
setText();
List<GPScaleBean> scales = Lists.<GPScaleBean>newArrayList();
scales.add(new GPScaleBean("1:1000"));
scales.add(new GPScaleBean("1:10000"));
scales.add(new GPScaleBean("1:100000"));
scales.add(new GPScaleBean("1:1000000"));
scales.add(new GPScaleBean("1:10000000"));
scales.add(new GPScaleBean("1:100000000"));
scales.add(new GPScaleBean("1:1000000000"));
ListStore<GPScaleBean> scaleStore = new ListStore<GPScaleBean>();
scaleStore.add(scales);
ComboBox<GPScaleBean> comboScale = new ComboBox<GPScaleBean>();
comboScale.setEmptyText(MapModuleConstants.INSTANCE.GPScaleWidget_comboScaleEmptyText());
comboScale.setDisplayField("scale");
comboScale.setWidth(150);
comboScale.setStore(scaleStore);
comboScale.setTypeAhead(true);
comboScale.setTriggerAction(TriggerAction.ALL);
comboScale.setEditable(true);
comboScale.setForceSelection(false);
comboScale.setValidator(new Validator() {
@Override
public String validate(Field<?> field, String value) {
String result = null;
try {
Long.parseLong(value.substring(2));
} catch (NumberFormatException nfe) {
result = "The scale value: " + value.substring(2) + " is not a number";
}
if (!value.startsWith("1:")) {
String error = "The scale value must start with string 1:";
result = (result == null) ? error : (result += '\n' + error);
}
return result;
}
});
add(comboScale);
Point p = position(XDOM.getViewportSize());
el().setLeftTop(p.x, p.y);
setSize(config.width, config.height);
comboScale.addListener(Events.Select, new Listener<FieldEvent>() {
@Override
public void handleEvent(FieldEvent fe) {
ComboBox cb = (ComboBox) fe.getComponent();
GPScaleBean s = (GPScaleBean) cb.getValue();
scaleSelectedElement(s);
}
});
comboScale.addListener(Events.OnKeyPress, new Listener<FieldEvent>() {
@Override
public void handleEvent(FieldEvent fe) {
ComboBox cb = (ComboBox) fe.getComponent();
if (fe.getKeyCode() == KeyCodes.KEY_ENTER && cb.validate()) {
GPScaleBean scaleBean = new GPScaleBean(cb.getRawValue());
scaleSelectedElement(scaleBean);
}
}
});
el().slideIn(Direction.DOWN, FxConfig.NONE);
}
Aggregations