use of org.openremote.app.client.event.ShowSuccessEvent in project openremote by openremote.
the class AssetEditActivity method delete.
@Override
public void delete() {
view.showConfirmation(environment.getMessages().confirmation(), environment.getMessages().confirmationDelete(asset.getName()), () -> {
view.setFormBusy(true);
clearViewMessages();
environment.getApp().getRequests().send(requestParams -> assetResource.delete(requestParams, this.assetId), 204, () -> {
view.setFormBusy(false);
environment.getEventBus().dispatch(new ShowSuccessEvent(environment.getMessages().assetDeleted(asset.getName())));
environment.getPlaceController().goTo(new AssetsDashboardPlace());
});
});
}
use of org.openremote.app.client.event.ShowSuccessEvent in project openremote by openremote.
the class AssetEditActivity method update.
@Override
public void update() {
view.setFormBusy(true);
clearViewMessages();
validateAttributes(false, results -> {
if (results.stream().anyMatch(result -> !result.isValid())) {
view.setFormBusy(false);
processValidationResults(results);
} else {
readFromView();
environment.getApp().getRequests().sendWith(assetMapper, requestParams -> assetResource.update(requestParams, assetId, asset), 204, () -> {
view.setFormBusy(false);
environment.getEventBus().dispatch(new ShowSuccessEvent(environment.getMessages().assetUpdated(asset.getName())));
environment.getPlaceController().goTo(new AssetViewPlace(assetId));
}, validationErrorHandler);
}
});
}
use of org.openremote.app.client.event.ShowSuccessEvent in project openremote by openremote.
the class AssetsTenantActivity method onCreateAssetLink.
@Override
public void onCreateAssetLink() {
if (selectedUserId == null || selectedAssetId == null)
return;
UserAsset userAsset = new UserAsset(realmId, selectedUserId, selectedAssetId);
view.setFormBusy(true);
environment.getApp().getRequests().sendWith(userAssetMapper, requestParams -> assetResource.createUserAsset(requestParams, userAsset), 204, () -> {
environment.getEventBus().dispatch(new ShowSuccessEvent(environment.getMessages().userAssetLinkCreated()));
view.setFormBusy(false);
loadUserAssets();
});
}
use of org.openremote.app.client.event.ShowSuccessEvent in project openremote by openremote.
the class Simulator method writeView.
protected void writeView() {
clear();
addLabel(environment.getMessages().simulator());
formGroups.clear();
List<SimulatorElement> sortedElements = Arrays.asList(simulatorState.getElements());
sortedElements.sort(Comparator.comparing(o -> simulatorState.getElementName(o)));
for (SimulatorElement element : sortedElements) {
FormGroup formGroup = new FormGroup();
String elementName = simulatorState.getElementName(element);
FormLabel formLabel = new FormLabel(elementName);
formLabel.addStyleName("largest");
formGroup.setFormLabel(formLabel);
FormField formField = new FormField();
formGroup.setFormField(formField);
// Don't push simulator value validation up to the presenter as it is a special case that should
// just be evaluated in-situ and shouldn't invalidate the parent attribute
Consumer<Value> onModified = value -> {
element.setValue(value);
List<ValidationFailure> failures = element.getValidationFailures();
formGroup.setError(failures != null && !failures.isEmpty());
};
ValueType valueType = element.getExpectedType().getValueType();
IsWidget editor = valueEditorSupplier.createValueEditor(element, valueType, style, parentView, onModified);
formField.add(editor);
formGroups.put(element.getAttributeRef(), formGroup);
add(formGroup);
}
if (sortedElements.size() > 0) {
FormGroup submitGroup = new FormGroup();
submitGroup.getElement().getStyle().setWidth(80, com.google.gwt.dom.client.Style.Unit.PCT);
FormField submitField = new FormField();
submitGroup.setFormField(submitField);
FormButton writeButton = new FormButton(environment.getMessages().writeSimulatorState());
writeButton.setPrimary(true);
writeButton.addClickHandler(event -> {
if (isValid()) {
environment.getEventService().dispatch(simulatorState);
environment.getEventBus().dispatch(new ShowSuccessEvent(environment.getMessages().simulatorStateSubmitted()));
}
});
submitField.add(writeButton);
add(submitGroup);
} else {
add(new FormInlineLabel(environment.getMessages().noAttributesLinkedToSimulator()));
}
// "Blink" the editor so users know there might be a new value
for (FormGroup formGroup : formGroups.values()) {
formGroup.addStyleName(environment.getWidgetStyle().HighlightBackground());
}
Browser.getWindow().setTimeout(() -> {
for (FormGroup formGroup : formGroups.values()) formGroup.removeStyleName(environment.getWidgetStyle().HighlightBackground());
}, 250);
}
use of org.openremote.app.client.event.ShowSuccessEvent in project openremote by openremote.
the class AdminTenantActivity method update.
@Override
public void update() {
adminContent.setFormBusy(true);
adminContent.clearFormMessages();
clearViewFieldErrors();
readFromView();
environment.getApp().getRequests().sendWith(tenantMapper, requestParams -> tenantResource.update(requestParams, realm, tenant), 204, () -> {
adminContent.setFormBusy(false);
environment.getEventBus().dispatch(new ShowSuccessEvent(environment.getMessages().tenantUpdated(tenant.getDisplayName())));
this.realm = tenant.getRealm();
}, validationErrorHandler);
}
Aggregations