public void fetchTemplate(String name) { model.setTemplate(null); service.findTemplateByName(name, new AsyncCallback<RawSld>() { public void onSuccess(RawSld result) { model.setTemplate(result); TemplateLoadedEvent.fire(SldManagerImpl.this); } public void onFailure(Throwable caught) { log.log(Level.SEVERE, "findTemplateByName failed", caught); } }); }
/** * The editors model, get the xml data here. * * @return */ public SldModel getModel() { return manager.getModel(); }
public void convertToRawSld(StyledLayerDescriptorInfo sldi, AsyncCallback<RawSld> callback) { service.convertDescriptorToRaw(sldi, callback); } }
/** * Conveniencemethod to load data into the editor. * * @param rawXml */ public void loadSld(final String rawXml, final String name, final String title) { SldModel m = manager.getModel(); m.clear(); m.setTemplate(null); m.setDirty(false); m.setValid(false); // might be true, not checking... m.getRawSld().setName(name); m.getRawSld().setTitle(title); m.getRawSld().setXml(rawXml); SldLoadedEvent.fire(SldEditorExpertPresenter.this); }
public void onSuccess(Boolean result) { if (result != null && result) { model.setValid(true); if (saveAfterValidation) { service.convertRawToDescriptor(model.getRawSld(), new AsyncCallback<StyledLayerDescriptorInfo>() { public void onSuccess(StyledLayerDescriptorInfo result) { model.setSldDescriptor(result); SldSaveEvent.fire(SldManagerImpl.this); } public void onFailure(Throwable caught) { // should not happen as validation was OK. SldValidatedEvent.fireInValid(SldManagerImpl.this); model.setValid(false); } }); } else { SldValidatedEvent.fireValid(SldManagerImpl.this); } } else { onFailure(null); } } });
public void onTemplateSelect(final TemplateSelectEvent event) { String content = (manager.getModel().getRawSld() != null ? manager.getModel().getRawSld().getXml() : null); if (manager.getModel().isDirty() || (content != null && !"".equals(content))) { viewUtil.showYesNoMessage(EXP_MSG.confirmLoseDirtyData(), new YesNoCallback() { public void onYes() { manager.fetchTemplate(event.getTemplateName()); } public void onNo() { revert(); } public void onCancel() { revert(); } private void revert() { getView().selectTemplateCancelled(); } }); } else { manager.fetchTemplate(event.getTemplateName()); } } }));
public void fetchTemplateNames() { model.getTemplateNames().clear(); service.findTemplates(new AsyncCallback<List<SldInfo>>() { public void onSuccess(List<SldInfo> result) { for (SldInfo template : result) { model.getTemplateNames().add(template); } TemplateNamesLoadedEvent.fire(SldManagerImpl.this); } public void onFailure(Throwable caught) { log.log(Level.SEVERE, "fetchTemplateNames failed", caught); } }); }
public void onTemplateLoaded(TemplateLoadedEvent event) { // loading a template replaces the data, so throwing a new dataloaded event manager.getModel().setRawSld(manager.getModel().getTemplate()); SldLoadedEvent.fire(SldEditorExpertPresenter.this, new SldLoadedEvent(true)); } }));
public void onSuccess(List<SldInfo> result) { for (SldInfo template : result) { model.getTemplateNames().add(template); } TemplateNamesLoadedEvent.fire(SldManagerImpl.this); }
public void onSldValidate(SldValidateEvent event) { getView().viewToModel(manager.getModel()); manager.validateCurrent(event.isSaveAfterValidate()); } }));
public void modelToView(SldModel model, boolean keepDirty) { if (w == null) { asWidget(); } w.getEditor().setData(model.getRawSld().getXml()); w.getEditor().setDataDirty(keepDirty); // tricky ;-) }
/** * Conveniencemethod to load data into the editor. * <p> * Note that this is an async call, it will take some time before the data appears in the editor. * * @param sldi */ public void loadSld(final StyledLayerDescriptorInfo sldi) { manager.convertToRawSld(sldi, new AsyncCallback<RawSld>() { public void onSuccess(RawSld result) { loadSld(result.getXml(), result.getName(), result.getTitle()); } public void onFailure(Throwable caught) { loadSld(EXP_MSG.failedToParseSldObject(), sldi.getName(), sldi.getTitle()); } }); }
public void onFailure(Throwable caught) { SldValidatedEvent.fireInValid(SldManagerImpl.this); model.setValid(false); }
@Override protected void onReveal() { super.onReveal(); manager.fetchTemplateNames(); }
public void onSuccess(RawSld result) { model.setTemplate(result); TemplateLoadedEvent.fire(SldManagerImpl.this); }
public void setTemplates(SldModel model) { w.getEditor().setTemplates(model.getTemplateNames()); }
public void onTemplateNamesLoaded(TemplateNamesLoadedEvent event) { getView().setTemplates(manager.getModel()); } }));