Search in sources :

Example 6 with ShowSuccessEvent

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());
        });
    });
}
Also used : ShowSuccessEvent(org.openremote.app.client.event.ShowSuccessEvent)

Example 7 with ShowSuccessEvent

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);
        }
    });
}
Also used : ShowSuccessEvent(org.openremote.app.client.event.ShowSuccessEvent)

Example 8 with ShowSuccessEvent

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();
    });
}
Also used : UserAsset(org.openremote.model.asset.UserAsset) ShowSuccessEvent(org.openremote.app.client.event.ShowSuccessEvent)

Example 9 with ShowSuccessEvent

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);
}
Also used : Browser(elemental.client.Browser) EventRegistration(org.openremote.model.event.bus.EventRegistration) Consumer(org.openremote.model.interop.Consumer) SimulatorState(org.openremote.model.simulator.SimulatorState) java.util(java.util) ValueType(org.openremote.model.value.ValueType) Environment(org.openremote.app.client.Environment) AttributeRef(org.openremote.model.attribute.AttributeRef) ValidationFailure(org.openremote.model.ValidationFailure) org.openremote.app.client.widget(org.openremote.app.client.widget) AttributeViewImpl(org.openremote.app.client.assets.attributes.AttributeViewImpl) RequestSimulatorState(org.openremote.model.simulator.RequestSimulatorState) ShowSuccessEvent(org.openremote.app.client.event.ShowSuccessEvent) AttributeValidationResult(org.openremote.model.attribute.AttributeValidationResult) Value(org.openremote.model.value.Value) SimulatorElement(org.openremote.model.simulator.SimulatorElement) AbstractAttributeViewExtension(org.openremote.app.client.assets.attributes.AbstractAttributeViewExtension) IsWidget(com.google.gwt.user.client.ui.IsWidget) AssetAttribute(org.openremote.model.asset.AssetAttribute) AttributeView(org.openremote.app.client.assets.attributes.AttributeView) IsWidget(com.google.gwt.user.client.ui.IsWidget) ValueType(org.openremote.model.value.ValueType) SimulatorElement(org.openremote.model.simulator.SimulatorElement) ShowSuccessEvent(org.openremote.app.client.event.ShowSuccessEvent) Value(org.openremote.model.value.Value)

Example 10 with ShowSuccessEvent

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);
}
Also used : ShowSuccessEvent(org.openremote.app.client.event.ShowSuccessEvent)

Aggregations

ShowSuccessEvent (org.openremote.app.client.event.ShowSuccessEvent)17 AdminUsersPlace (org.openremote.app.client.admin.users.AdminUsersPlace)2 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 Browser (elemental.client.Browser)1 java.util (java.util)1 Environment (org.openremote.app.client.Environment)1 AbstractAttributeViewExtension (org.openremote.app.client.assets.attributes.AbstractAttributeViewExtension)1 AttributeView (org.openremote.app.client.assets.attributes.AttributeView)1 AttributeViewImpl (org.openremote.app.client.assets.attributes.AttributeViewImpl)1 org.openremote.app.client.widget (org.openremote.app.client.widget)1 ValidationFailure (org.openremote.model.ValidationFailure)1 AssetAttribute (org.openremote.model.asset.AssetAttribute)1 UserAsset (org.openremote.model.asset.UserAsset)1 AttributeRef (org.openremote.model.attribute.AttributeRef)1 AttributeValidationResult (org.openremote.model.attribute.AttributeValidationResult)1 EventRegistration (org.openremote.model.event.bus.EventRegistration)1 Consumer (org.openremote.model.interop.Consumer)1 RequestSimulatorState (org.openremote.model.simulator.RequestSimulatorState)1 SimulatorElement (org.openremote.model.simulator.SimulatorElement)1 SimulatorState (org.openremote.model.simulator.SimulatorState)1