use of org.zkoss.zk.ui.SuspendNotAllowedException in project spatial-portal by AtlasOfLivingAustralia.
the class AddFacetController method resetWindow.
public void resetWindow(String selectedArea) {
try {
hasCustomArea = !(selectedArea == null || selectedArea.trim().isEmpty());
boolean ok = false;
if (hasCustomArea) {
MapLayer curTopArea;
List<MapLayer> layers = getMapComposer().getPolygonLayers();
if (layers != null && !layers.isEmpty()) {
curTopArea = layers.get(0);
} else {
curTopArea = null;
}
if (curTopArea != prevTopArea) {
if (isAreaHighlightTab()) {
loadAreaHighlightLayers(curTopArea.getDisplayName());
} else if (isAreaTab()) {
loadAreaLayers(curTopArea.getDisplayName());
}
ok = true;
}
}
this.setTop(winTop);
this.setLeft(winLeft);
this.doModal();
if (ok) {
onClick$btnOk(null);
hasCustomArea = false;
}
fixFocus();
} catch (SuspendNotAllowedException ex) {
LOGGER.error("Exception when resetting analysis window", ex);
}
}
use of org.zkoss.zk.ui.SuspendNotAllowedException in project spatial-portal by AtlasOfLivingAustralia.
the class AreaUploadShapefile method onUpload$btnFileUpload.
public void onUpload$btnFileUpload(Event event) {
UploadEvent ue = null;
if ("onUpload".equals(event.getName())) {
ue = (UploadEvent) event;
} else if ("onForward".equals(event.getName())) {
ue = (UploadEvent) ((ForwardEvent) event).getOrigin();
}
if (ue == null) {
LOGGER.debug("unable to upload file");
return;
} else {
LOGGER.debug("fileUploaded()");
}
try {
Media m = ue.getMedia();
LOGGER.debug("m.getName(): " + m.getName());
LOGGER.debug("getContentType: " + m.getContentType());
LOGGER.debug("getFormat: " + m.getFormat());
UserDataDTO ud = new UserDataDTO(txtLayerName.getValue());
ud.setFilename(m.getName());
byte[] kmldata = getKml(m);
if (kmldata.length > 0) {
loadUserLayerKML(m.getName(), kmldata, ud);
} else if (m.getName().toLowerCase().endsWith("zip")) {
Map args = new HashMap();
args.put(StringConstants.LAYERNAME, txtLayerName.getValue());
args.put(StringConstants.MEDIA, m);
String windowname = "areashapewizard";
if (getFellowIfAny(windowname) != null) {
getFellowIfAny(windowname).detach();
}
Window window = (Window) Executions.createComponents("WEB-INF/zul/add/area/AreaUploadShapefileWizard.zul", this.getParent(), args);
try {
window.setParent(this.getParent());
window.doModal();
} catch (SuspendNotAllowedException e) {
// we are really closing the window without opening/displaying to the user
}
} else if (m.getName().toLowerCase().endsWith("zip_removeme")) {
Map input = Zipper.unzipFile(m.getName(), m.getStreamData(), "/data/ala/runtime/output/layers/");
String type = "";
String file = "";
if (input.containsKey(StringConstants.TYPE)) {
type = (String) input.get(StringConstants.TYPE);
}
if (input.containsKey(StringConstants.FILE)) {
file = (String) input.get(StringConstants.FILE);
}
if ("shp".equalsIgnoreCase(type)) {
LOGGER.debug("Uploaded file is a shapefile. Loading...");
Map shape = ShapefileUtils.loadShapefile(new File(file));
if (shape != null) {
String wkt = (String) shape.get(StringConstants.WKT);
LOGGER.debug("Got shapefile wkt...validating");
String msg = "";
boolean invalid = false;
try {
WKTReader wktReader = new WKTReader();
com.vividsolutions.jts.geom.Geometry g = wktReader.read(wkt);
//NC 20130319: Ensure that the WKT is valid according to the WKT standards.
IsValidOp op = new IsValidOp(g);
if (!op.isValid()) {
//this will fix some issues
g = g.buffer(0);
op = new IsValidOp(g);
}
if (!op.isValid()) {
invalid = true;
LOGGER.warn(CommonData.lang(StringConstants.ERROR_WKT_INVALID) + " " + op.getValidationError().getMessage());
msg = op.getValidationError().getMessage();
//TODO Fix invalid WKT text using https://github.com/tudelft-gist/prepair maybe???
} else if (g.isRectangle()) {
//NC 20130319: When the shape is a rectangle ensure that the points a specified in the correct order.
//get the new WKT for the rectangle will possibly need to change the order.
com.vividsolutions.jts.geom.Envelope envelope = g.getEnvelopeInternal();
String wkt2 = "POLYGON((" + envelope.getMinX() + " " + envelope.getMinY() + "," + envelope.getMaxX() + " " + envelope.getMinY() + "," + envelope.getMaxX() + " " + envelope.getMaxY() + "," + envelope.getMinX() + " " + envelope.getMaxY() + "," + envelope.getMinX() + " " + envelope.getMinY() + "))";
if (!wkt.equals(wkt2)) {
LOGGER.debug("NEW WKT for Rectangle: " + wkt);
msg = CommonData.lang("error_wkt_anticlockwise");
invalid = true;
}
}
if (!invalid) {
invalid = !op.isValid();
}
} catch (ParseException parseException) {
LOGGER.error("error testing validity of uploaded shape file wkt", parseException);
}
if (invalid) {
ok = false;
getMapComposer().showMessage(CommonData.lang(StringConstants.ERROR_WKT_INVALID) + " " + msg);
} else {
layerName = getMapComposer().getNextAreaLayerName(txtLayerName.getValue());
MapLayer mapLayer = getMapComposer().addWKTLayer(wkt, layerName, txtLayerName.getValue());
ud.setUploadedTimeInMs(System.currentTimeMillis());
ud.setType("shapefile");
String metadata = "";
metadata += "User uploaded Shapefile \n";
metadata += "Name: " + ud.getName() + " <br />\n";
metadata += "Filename: " + ud.getFilename() + " <br />\n";
metadata += "Date: " + ud.getDisplayTime() + " <br />\n";
mapLayer.getMapLayerMetadata().setMoreInfo(metadata);
ok = true;
}
}
} else {
LOGGER.debug("Unknown file type. ");
getMapComposer().showMessage(CommonData.lang("error_unknown_file_type"));
}
} else {
LOGGER.debug("Unknown file type. ");
getMapComposer().showMessage(CommonData.lang("error_unknown_file_type"));
}
} catch (Exception ex) {
getMapComposer().showMessage(CommonData.lang("error_upload_failed"));
LOGGER.error("unable to load user area file: ", ex);
}
}
use of org.zkoss.zk.ui.SuspendNotAllowedException in project adempiere by adempiere.
the class WPaySelect method generatePaySelect.
// calculateSelection
/**
* Generate PaySelection
*/
private void generatePaySelect() {
if (miniTable.getRowCount() == 0)
return;
miniTable.setSelectedIndices(new int[] { 0 });
calculateSelection();
if (m_noSelected == 0)
return;
String msg = generatePaySelect(miniTable, (ValueNamePair) fieldPaymentRule.getSelectedItem().getValue(), new Timestamp(fieldPayDate.getComponent().getValue().getTime()), (BankInfo) fieldBankAccount.getSelectedItem().getValue());
if (msg != null && msg.length() > 0) {
FDialog.error(m_WindowNo, form, "SaveError", msg);
return;
}
// Ask to Post it
if (!FDialog.ask(m_WindowNo, form, "VPaySelectGenerate?", "(" + m_ps.getDocumentNo() + ")"))
return;
// Prepare Process
// C_PaySelection_CreatePayment
int AD_Proces_ID = 155;
// Execute Process
ProcessModalDialog dialog = new ProcessModalDialog(this, m_WindowNo, AD_Proces_ID, X_C_PaySelection.Table_ID, m_ps.getC_PaySelection_ID(), false);
if (dialog.isValid()) {
try {
dialog.setWidth("500px");
dialog.setVisible(true);
dialog.setPage(form.getPage());
dialog.doModal();
} catch (SuspendNotAllowedException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
}
Aggregations