use of org.zkoss.zk.ui.event.ForwardEvent in project spatial-portal by AtlasOfLivingAustralia.
the class SandboxEmbeddedController method gotDrUid.
public void gotDrUid(Event event) {
dataResourceUid = ((String) event.getData());
sandboxReady.setVisible(true);
sandboxFrame.setVisible(false);
List<Facet> facetList = new ArrayList<Facet>();
facetList.add(new Facet("data_resource_uid", dataResourceUid, true));
query = new BiocacheQuery(null, null, null, facetList, true, null, CommonData.getSettings().getProperty("sandbox.biocache.url"), CommonData.getSettings().getProperty("sandbox.biocache.ws.url"), true);
if (addtoMap) {
getMapComposer().mapSpecies(query, query.getSolrName(), StringConstants.SPECIES, query.getOccurrenceCount(), LayerUtilitiesImpl.SPECIES, null, 0, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
}
//call reset window on caller to perform refresh'
if (callback != null) {
try {
callback.onEvent(new ForwardEvent("", null, null, new String[] { dataResourceUid, "normal" }));
} catch (Exception e) {
LOGGER.error("failed to cancel species points upload", e);
}
}
onClick$btnOk(null);
}
use of org.zkoss.zk.ui.event.ForwardEvent in project spatial-portal by AtlasOfLivingAustralia.
the class SandboxPasteController method gotDrUid.
public void gotDrUid(Event event) {
dataResourceUid = ((String) event.getData());
sandboxReady.setVisible(true);
sandboxFrame.setVisible(false);
List<Facet> facetList = new ArrayList<Facet>();
facetList.add(new Facet("data_resource_uid", dataResourceUid, true));
query = new BiocacheQuery(null, null, null, facetList, true, null, CommonData.getSettings().getProperty("sandbox.biocache.url"), CommonData.getSettings().getProperty("sandbox.biocache.ws.url"), true);
if (addtoMap) {
getMapComposer().mapSpecies(query, query.getSolrName(), StringConstants.SPECIES, query.getOccurrenceCount(), LayerUtilitiesImpl.SPECIES, null, 0, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
}
//call reset window on caller to perform refresh'
if (callback != null) {
try {
callback.onEvent(new ForwardEvent("", null, null, new String[] { dataResourceUid, "normal" }));
} catch (Exception e) {
LOGGER.error("failed to cancel species points upload", e);
}
}
onClick$btnOk(null);
}
use of org.zkoss.zk.ui.event.ForwardEvent in project spatial-portal by AtlasOfLivingAustralia.
the class SandboxPasteController method doFileUpload.
public void doFileUpload(Event event) {
UploadEvent ue = null;
if (event instanceof UploadEvent) {
ue = (UploadEvent) event;
} else if (event instanceof ForwardEvent) {
ue = (UploadEvent) ((ForwardEvent) event).getOrigin();
}
if (ue == null) {
LOGGER.debug("unable to upload file");
return;
} else {
LOGGER.debug("fileUploaded()");
}
try {
Media m = ue.getMedia();
String filename = m.getName();
String contentType = m.getContentType();
String format = m.getFormat();
boolean loaded = false;
if (!loaded) {
try {
loaded = upload(m.getByteData(), filename, contentType);
LOGGER.debug(m.getContentType() + " with getByteData");
} catch (Exception e) {
//failed to read, will try another method
}
}
if (!loaded) {
try {
loaded = upload(IOUtils.toByteArray(m.getStreamData()), filename, contentType);
LOGGER.debug(m.getContentType() + " with getStreamData");
} catch (Exception e) {
//failed to read, will try another method
}
}
try {
Reader r = m.getReaderData();
InputStream is = new ReaderInputStream(r, "UTF-8");
loaded = upload(IOUtils.toByteArray(is), filename, contentType);
LOGGER.debug(m.getContentType() + " with getReaderData");
} catch (Exception e) {
//failed to read, will try another method
}
if (!loaded) {
try {
loaded = upload(m.getStringData().getBytes(), filename, contentType);
LOGGER.debug(m.getContentType() + " with getStringData");
} catch (Exception e) {
//last one, report error
getMapComposer().showMessage(CommonData.lang("error_uploading_file"));
LOGGER.error("unable to load user layer list: ", e);
}
}
//process if successful upload
if (loaded) {
((Iframe) getFellow("sandboxFrame")).setSrc("sandboxPreview.html?uploadId=" + uploadId + "&uploadFn=" + uploadFn);
//display frame and trigger javascript setup function
getMapComposer().getOpenLayersJavascript().execute("$('#sandboxContainer')[0].style.display = \"inline\";setTimeout(\"setUrls()\",500)");
getFellow("fileUpload").setVisible(false);
getFellow("fileUpload").detach();
getFellow("divSandbox").setVisible(false);
setTop("10px");
}
} catch (Exception ex) {
LOGGER.error("error reading uploaded file", ex);
}
}
use of org.zkoss.zk.ui.event.ForwardEvent in project spatial-portal by AtlasOfLivingAustralia.
the class UploadLayerListController method loadLayerList.
private void loadLayerList(Reader r) throws IOException {
CSVReader reader = new CSVReader(r);
//one line, read it
StringBuilder sb = new StringBuilder();
for (String s : reader.readNext()) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(s);
}
reader.close();
if (callback != null) {
try {
callback.onEvent(new ForwardEvent("", this, null, sb.toString()));
} catch (Exception e) {
LOGGER.error("failed when calling ToolComposer callback", e);
}
}
}
use of org.zkoss.zk.ui.event.ForwardEvent in project spatial-portal by AtlasOfLivingAustralia.
the class UploadToSpeciesListController method onClick$btnOk.
public void onClick$btnOk(Event event) {
if (tbName.getValue().length() > 0) {
String name = tbName.getValue();
String description = tbDesc.getValue();
dataResourceUid = SpeciesListUtil.createNewList(name, species, description, null, Util.getUserEmail(), chkPrivate.isChecked());
LOGGER.debug("The data resource uid: " + dataResourceUid);
if (callback != null) {
try {
callback.onEvent(new ForwardEvent("", null, null, dataResourceUid));
} catch (Exception e) {
LOGGER.error("failed to trigger callback from species list upload", e);
}
}
this.detach();
} else {
tbInstructions.setValue("WARNING: Must supply a list name");
}
}
Aggregations