use of org.zkoss.zul.Listitem 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.Listitem in project spatial-portal by AtlasOfLivingAustralia.
the class ActiveLayersRemoveEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
MapComposer mapComposer = getMapComposer(event);
if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
// get reference to the label/image the user clicked on
Component target = event.getTarget();
Listitem listItem = (Listitem) target.getParent().getParent();
MapLayer activeLayer = listItem.getValue();
if (activeLayer != null) {
mapComposer.deactiveLayer(activeLayer, true, false);
}
} else {
LOGGER.debug("MapController reports unsafe to perform action");
}
}
use of org.zkoss.zul.Listitem in project spatial-portal by AtlasOfLivingAustralia.
the class ActiveLayersZoomExtentEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
MapComposer mapComposer = getMapComposer(event);
if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
// get reference to the label/image the user clicked on
Component target = event.getTarget();
Listitem listItem = (Listitem) target.getParent().getParent();
MapLayer activeLayer = listItem.getValue();
if (activeLayer != null) {
mapComposer.zoomToExtent(activeLayer);
}
} else {
LOGGER.debug("MapController reports unsafe to perform action");
}
}
use of org.zkoss.zul.Listitem in project adempiere by adempiere.
the class WAssignmentDialog method setDisplay.
// jbInit
/**
* Initialize component & values from m_mAssignment
*/
private void setDisplay() {
m_setting = true;
// Set Resource
int S_Resource_ID = m_mAssignment.getS_Resource_ID();
for (Listitem item : fResource.getItems()) {
if ((Integer) item.getValue() == S_Resource_ID) {
fResource.setSelectedItem(item);
break;
}
}
ListItem listItem = fResource.getSelectedItem();
KeyNamePair check = new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel());
if (check == null || check.getKey() != S_Resource_ID) {
if (// new record select first
m_mAssignment.getS_ResourceAssignment_ID() == 0)
// initiates UOM display
fResource.setSelectedItem(fResource.getSelectedItem());
else
log.log(Level.SEVERE, "Resource not found ID=" + S_Resource_ID);
}
// Set Date, Qty
fDateFrom.setValue(m_mAssignment.getAssignDateFrom());
fTimeFrom.setValue(m_mAssignment.getAssignDateFrom());
fQty.setValue(m_mAssignment.getQty());
// Name, Description
fName.setValue(m_mAssignment.getName());
fDescription.setValue(m_mAssignment.getDescription());
// Set Editor to R/O if confirmed
boolean readWrite = true;
if (m_mAssignment.isConfirmed())
readWrite = false;
confirmPanel.getButton("Cancel").setVisible(readWrite);
fResource.setEnabled(readWrite);
fDateFrom.setReadonly(!readWrite);
fQty.setEnabled(readWrite);
m_setting = false;
}
use of org.zkoss.zul.Listitem in project adempiere by adempiere.
the class ZkJRViewer method renderReport.
/***
*
* This method is used for generate report in PDF or XLS based on previewType selection.
*
* @throws Exception
*/
private void renderReport() throws Exception {
Listitem selected = previewType.getSelectedItem();
//
// Place Common code outside the If else block
//
String path = System.getProperty("java.io.tmpdir");
String prefix = makePrefix(jasperPrint.getName());
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
}
if (selected == null || "PDF".equals(selected.getValue())) {
file = File.createTempFile(prefix, ".pdf", new File(path));
JasperExportManager.exportReportToPdfFile(jasperPrint, file.getAbsolutePath());
media = new AMedia(this.title, "pdf", "application/pdf", file, true);
} else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
file = File.createTempFile(prefix, ".xls", new File(path));
FileOutputStream fos = new FileOutputStream(file);
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, fos);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_FILE, file.getAbsolutePath());
exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.FALSE);
exporterXLS.exportReport();
media = new AMedia(this.title, "xls", "application/vnd.ms-excel", file, true);
} else if ("RTF".equals(previewType.getSelectedItem().getValue())) {
FileOutputStream fos = new FileOutputStream(file);
JRRtfExporter rtfExporter = new JRRtfExporter();
rtfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
rtfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, fos);
rtfExporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
rtfExporter.exportReport();
media = new AMedia(this.title, "doc", "application/vnd.ms-word", file, true);
}
iframe.setContent(media);
}
Aggregations