use of org.zkoss.zul.Checkbox in project spatial-portal by AtlasOfLivingAustralia.
the class InOutComposer method getSelectedAreas.
public List<SelectedArea> getSelectedAreas() {
List<SelectedArea> selectedAreas = new ArrayList<SelectedArea>();
Vbox vboxArea = (Vbox) getFellowIfAny("vboxArea");
for (Component c : vboxArea.getChildren()) {
if ((c instanceof Checkbox) && ((Checkbox) c).isChecked()) {
SelectedArea sa = null;
String area = ((Checkbox) c).getValue();
try {
if (StringConstants.CURRENT.equals(area)) {
sa = new SelectedArea(null, getMapComposer().getViewArea());
} else if (StringConstants.AUSTRALIA.equals(area)) {
sa = new SelectedArea(null, CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT));
} else if (StringConstants.WORLD.equals(area)) {
sa = new SelectedArea(null, CommonData.WORLD_WKT);
} else {
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (MapLayer ml : layers) {
if (area.equals(ml.getName())) {
sa = new SelectedArea(ml, null);
break;
}
}
}
} catch (Exception e) {
LOGGER.warn("Unable to retrieve selected area", e);
}
if (sa != null) {
selectedAreas.add(sa);
}
}
}
return selectedAreas;
}
use of org.zkoss.zul.Checkbox in project adempiere by adempiere.
the class WDelete method zkInit.
private void zkInit() throws Exception {
//Form Init()
form.appendChild(mainLayout);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
clientLabel.setText(Msg.translate(Env.getCtx(), "AD_Client_ID"));
tableLabel.setText(Msg.translate(Env.getCtx(), "AD_Table_ID"));
dryRun = new Checkbox("Dry Run");
dryRun.setChecked(true);
parameterPanel.appendChild(parameterLayout);
North north = new North();
north.setStyle("border: none");
mainLayout.appendChild(north);
north.appendChild(parameterPanel);
Rows rows = null;
Row row = null;
parameterLayout.setWidth("100%");
rows = parameterLayout.newRows();
row = rows.newRow();
row.appendChild(clientLabel.rightAlign());
row.appendChild(clientPick);
row.appendChild(tableLabel.rightAlign());
row.appendChild(tablePick.getComponent());
row.appendChild(dryRun);
centerPanel.appendChild(centerLayout);
centerLayout.setWidth("100%");
Center center = new Center();
mainLayout.appendChild(center);
center.setStyle("border: none");
center.appendChild(centerPanel);
tree = new Tree();
treeCols = new Treecols();
treeCol = new Treecol("");
treeCol2 = new Treecol();
centerPanel.appendChild(tree);
treeCols.appendChild(treeCol);
treeCols.appendChild(treeCol2);
tree.appendChild(treeCols);
center.setFlex(true);
center.setAutoscroll(true);
South south = new South();
south.appendChild(southPanel);
southPanel.appendChild(southLayout);
southPanel.setWidth("100%");
mainLayout.appendChild(south);
Rows rows2 = southLayout.newRows();
Row south_row = rows2.newRow();
south_row.appendChild(confirmPanel);
confirmPanel.addActionListener(this);
clientPick.addEventListener(Events.ON_SELECT, this);
}
use of org.zkoss.zul.Checkbox in project spatial-portal by AtlasOfLivingAustralia.
the class LayerLegendGeneralComposer method setupForClassificationLayers.
private void setupForClassificationLayers() {
if (mapLayer.isPolygonLayer())
return;
String activeLayerName = StringConstants.NONE;
JSONObject field = null;
JSONObject layer = null;
if (mapLayer != null && mapLayer.getUri() != null) {
if (mapLayer.getBaseUri() != null) {
activeLayerName = mapLayer.getBaseUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
} else {
activeLayerName = mapLayer.getUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
}
field = CommonData.getLayer(activeLayerName);
if (field == null)
return;
layer = (JSONObject) field.get("layer");
}
LOGGER.debug("ACTIVE LAYER: " + activeLayerName);
if (mapLayer != null && mapLayer.getSubType() == LayerUtilitiesImpl.ALOC) {
divClassificationPicker.setVisible(true);
// reset content
Integer groupCount = mapLayer.getClassificationGroupCount();
if (groupCount == null) {
mapLayer.setClassificationGroupCount(getClassificationGroupCount(mapLayer.getName().replace("aloc_", "")));
groupCount = 0;
}
for (int i = cbClassificationGroup.getItemCount() - 1; i >= 0; i--) {
cbClassificationGroup.removeItemAt(i);
}
Comboitem ci = new Comboitem(StringConstants.NONE);
ci.setParent(cbClassificationGroup);
for (int i = 1; i <= groupCount; i++) {
new Comboitem("Group " + i).setParent(cbClassificationGroup);
}
// is there a current selection?
Integer groupSelection = mapLayer.getClassificationSelection();
if (groupSelection == null) {
groupSelection = 0;
mapLayer.setClassificationSelection(groupSelection);
}
cbClassificationGroup.setSelectedIndex(groupSelection);
getFellow("btnCreateArea").setVisible(false);
cbClassificationGroup.setVisible(true);
lbClassificationGroup.setVisible(false);
hboxClassificationGroup.setVisible(false);
} else if (layer != null && layer.containsKey("type") && layer.get("type").toString().equalsIgnoreCase("contextual")) {
divClassificationPicker.setVisible(true);
if (mapLayer.getClassificationGroupCount() == null || mapLayer.getClassificationGroupCount() == 0) {
// build
String fieldId = field.get(StringConstants.ID).toString();
JSONParser jp = new JSONParser();
JSONObject objJson = null;
try {
objJson = (JSONObject) jp.parse(Util.readUrl(CommonData.getLayersServer() + "/field/" + fieldId));
} catch (ParseException e) {
LOGGER.error("failed to parse for: " + fieldId);
}
JSONArray objects = (JSONArray) objJson.get("objects");
// sort
List<JSONObject> list = objects.subList(0, objects.size());
Collections.sort(list, new Comparator<JSONObject>() {
@Override
public int compare(JSONObject o1, JSONObject o2) {
String s1 = (o1 == null || !o1.containsKey("name")) ? "" : o1.get("name").toString();
String s2 = (o2 == null || !o2.containsKey("name")) ? "" : o2.get("name").toString();
return s1.compareTo(s2);
}
});
JSONArray obj = new JSONArray();
obj.addAll(list);
mapLayer.setClassificationGroupCount(obj.size());
mapLayer.setClassificationObjects(obj);
}
// reset content
Integer groupCount = mapLayer.getClassificationGroupCount();
JSONArray groupObjects = mapLayer.getClassificationObjects();
lbClassificationGroup.setItemRenderer(new ListitemRenderer<JSONObject>() {
@Override
public void render(Listitem item, JSONObject data, int index) throws Exception {
Checkbox cb = new Checkbox();
final int idx = index;
cb.addEventListener("onCheck", new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (mapLayer != null) {
lbClassificationGroup.setMultiple(true);
String v = ((Listcell) event.getTarget().getParent().getParent().getChildren().get(1)).getLabel();
if (((CheckEvent) event).isChecked()) {
selectedList.add(v);
} else {
selectedList.remove(v);
}
lblSelectedCount.setValue(selectedList.size() + " checked");
getFellow("clearSelection").setVisible(selectedList.size() > 0);
getFellow("createInGroup").setVisible(selectedList.size() > 0);
if (getFellowIfAny("createOutGroup") != null)
getFellow("createOutGroup").setVisible(selectedList.size() > 0);
highlightSelect(idx);
}
}
});
determineCheckboxState(cb, data.get("name").toString());
Listcell lc;
lc = new Listcell();
cb.setParent(lc);
lc.setParent(item);
lc = new Listcell(data.get("name").toString());
lc.setParent(item);
lc = new Listcell();
Image img = new Image();
img.setTooltip("Create as an area layer");
img.setClass("icon-plus-sign");
img.setParent(lc);
lc.setParent(item);
final JSONObject j = data;
img.addEventListener("onClick", new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
createAreaEcho(j.get("pid").toString());
}
});
lc = new Listcell();
img = new Image();
img.setTooltip("Zoom to area");
img.setClass("icon-zoom-in");
img.setParent(lc);
lc.setParent(item);
img.addEventListener("onClick", new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
List<Double> b = Util.getBoundingBox(j.get("bbox").toString());
BoundingBox bbox = new BoundingBox();
bbox.setMinLongitude(b.get(0).floatValue());
bbox.setMinLatitude(b.get(1).floatValue());
bbox.setMaxLongitude(b.get(2).floatValue());
bbox.setMaxLatitude(b.get(3).floatValue());
getMapComposer().getOpenLayersJavascript().execute(getMapComposer().getOpenLayersJavascript().zoomToBoundingBox(bbox, false));
}
});
}
});
lbClassificationGroup.addEventListener("onSelect", new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (mapLayer != null) {
highlightSelect(lbClassificationGroup.getSelectedIndex());
}
}
});
List<JSONObject> model = new ArrayList<JSONObject>();
for (int i = 0; i < groupCount; i++) {
model.add((JSONObject) groupObjects.get(i));
}
lbClassificationGroup.setModel(new SimpleListModel(model));
// is there a current selection?
Integer groupSelection = mapLayer.getClassificationSelection();
if (groupSelection == null) {
groupSelection = 0;
mapLayer.setClassificationSelection(groupSelection);
}
getFellow("btnCreateArea").setVisible(true);
getFellow("btnCreateArea").setVisible(false);
cbClassificationGroup.setVisible(false);
lbClassificationGroup.setVisible(true);
hboxClassificationGroup.setVisible(true);
} else {
getFellow("btnCreateArea").setVisible(false);
divClassificationPicker.setVisible(false);
}
}
use of org.zkoss.zul.Checkbox in project spatial-portal by AtlasOfLivingAustralia.
the class VisibilityToggleEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
LOGGER.debug("VisibilityToggleEventListener.onEvent() fired ");
Checkbox checkbox = (Checkbox) event.getTarget();
try {
MapComposer mapComposer = (MapComposer) event.getPage().getFellow(StringConstants.MAPPORTALPAGE);
if (mapComposer.safeToPerformMapAction()) {
Listitem listitem = (Listitem) checkbox.getParent().getParent();
MapLayer layer = listitem.getValue();
boolean checked = checkbox.isChecked();
/* checkbox state will be saved automatically in MapLayer instances
* with calls to activate/remove in OpenLayersJavascript
*/
if (checked) {
PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer(layer, false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
checkbox.setTooltiptext("Hide");
mapComposer.refreshContextualMenu();
} else {
openLayersJavascript.removeMapLayerNow(layer);
checkbox.setTooltiptext("Show");
mapComposer.refreshContextualMenu();
}
} else {
/* there was a problem performing the action - 'undo'
* the user's click on the checkbox
*/
checkbox.setChecked(!checkbox.isChecked());
}
} catch (Exception e) {
// toogle won't work if page not completely loaded.
}
}
use of org.zkoss.zul.Checkbox in project adempiere by adempiere.
the class LoginPanel method initComponents.
private void initComponents() {
lblUserId = new Label();
lblUserId.setId("lblUserId");
lblUserId.setValue("User ID");
lblPassword = new Label();
lblPassword.setId("lblPassword");
lblPassword.setValue("Password");
lblLanguage = new Label();
lblLanguage.setId("lblLanguage");
lblLanguage.setValue("Language");
txtUserId = new Textbox();
txtUserId.setId("txtUserId");
//txtUserId.setCols(25);
txtUserId.setMaxlength(40);
//txtUserId.setWidth("220px");
// Elaine 2009/02/06
txtUserId.addEventListener(Events.ON_CHANGE, this);
txtPassword = new Textbox();
txtPassword.setId("txtPassword");
txtPassword.setType("password");
//txtPassword.setCols(25);
//txtPassword.setWidth("220px");
lstLanguage = new Combobox();
lstLanguage.setAutocomplete(true);
lstLanguage.setAutodrop(true);
lstLanguage.setId("lstLanguage");
lstLanguage.addEventListener(Events.ON_SELECT, this);
//lstLanguage.setWidth("220px");
// Update Language List
lstLanguage.getItems().clear();
ArrayList<String> supported = Env.getSupportedLanguages();
String[] availableLanguages = Language.getNames();
for (String langName : availableLanguages) {
Language language = Language.getLanguage(langName);
if (!language.isBaseLanguage()) {
if (!supported.contains(language.getAD_Language()))
continue;
}
lstLanguage.appendItem(langName, language.getAD_Language());
}
chkRememberMe = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "RememberMe"));
chkRememberMe.setId("chkRememberMe");
// Make the default language the language of client System
String defaultLanguage = MClient.get(ctx, 0).getAD_Language();
for (int i = 0; i < lstLanguage.getItemCount(); i++) {
Comboitem li = lstLanguage.getItemAtIndex(i);
if (li.getValue().equals(defaultLanguage)) {
lstLanguage.setSelectedIndex(i);
languageChanged(li.getLabel());
break;
}
}
}
Aggregations