Search in sources :

Example 1 with FormButton

use of org.openremote.app.client.widget.FormButton in project openremote by openremote.

the class AssetEditActivity method createAttributeActions.

@Override
protected List<FormButton> createAttributeActions(AssetAttribute attribute, AttributeViewImpl view) {
    FormButton deleteButton = new FormButton();
    deleteButton.setText(environment.getMessages().deleteAttribute());
    deleteButton.setIcon("remove");
    deleteButton.addClickHandler(clickEvent -> {
        removeAttribute(attribute);
        attribute.getName().ifPresent(name -> showInfo(environment.getMessages().attributeDeleted(name)));
    });
    return Collections.singletonList(deleteButton);
}
Also used : FormButton(org.openremote.app.client.widget.FormButton)

Example 2 with FormButton

use of org.openremote.app.client.widget.FormButton in project openremote by openremote.

the class AssetViewActivity method createAttributeActions.

protected List<FormButton> createAttributeActions(AssetAttribute attribute, AttributeViewImpl view) {
    List<FormButton> actionButtons = new ArrayList<>();
    if (attribute.isExecutable()) {
        // A command is executed by writing a special value
        FormButton startButton = new FormButton();
        startButton.setEnabled(!attribute.isReadOnly());
        startButton.setText(environment.getMessages().start());
        startButton.setPrimary(true);
        startButton.setIcon("play-circle");
        startButton.addClickHandler(clickEvent -> {
            attribute.setValue(AttributeExecuteStatus.REQUEST_START.asValue());
            writeAttributeValue(attribute);
        });
        actionButtons.add(startButton);
        FormButton repeatButton = new FormButton();
        repeatButton.setEnabled(!attribute.isReadOnly());
        repeatButton.setText(environment.getMessages().repeat());
        repeatButton.setPrimary(true);
        repeatButton.setIcon("repeat");
        repeatButton.addClickHandler(clickEvent -> {
            attribute.setValue(AttributeExecuteStatus.REQUEST_REPEATING.asValue());
            writeAttributeValue(attribute);
        });
        actionButtons.add(repeatButton);
        FormButton cancelButton = new FormButton();
        cancelButton.setEnabled(!attribute.isReadOnly());
        cancelButton.setText(environment.getMessages().cancel());
        cancelButton.setPrimary(true);
        cancelButton.setIcon("stop-circle");
        cancelButton.addClickHandler(clickEvent -> {
            attribute.setValue(AttributeExecuteStatus.REQUEST_CANCEL.asValue());
            writeAttributeValue(attribute);
        });
        actionButtons.add(cancelButton);
        FormButton readStatusButton = new FormButton();
        readStatusButton.setText(environment.getMessages().getStatus());
        readStatusButton.setIcon("cloud-download");
        readStatusButton.addStyleName(READ_BUTTON_CLASS);
        readStatusButton.setEnabled(!liveUpdates);
        readStatusButton.addClickHandler(clickEvent -> readAttributeValue(attribute));
        actionButtons.add(readStatusButton);
    } else {
        // Default read/write actions
        FormButton writeValueButton = new FormButton();
        writeValueButton.setEnabled(!attribute.isReadOnly());
        writeValueButton.setText(environment.getMessages().write());
        writeValueButton.setPrimary(true);
        writeValueButton.setIcon("cloud-upload");
        writeValueButton.addClickHandler(clickEvent -> writeAttributeValue(attribute));
        actionButtons.add(writeValueButton);
        FormButton readValueButton = new FormButton();
        readValueButton.addStyleName(READ_BUTTON_CLASS);
        readValueButton.setText(environment.getMessages().read());
        readValueButton.setIcon("cloud-download");
        readValueButton.setEnabled(!liveUpdates);
        readValueButton.addClickHandler(clickEvent -> readAttributeValue(attribute));
        actionButtons.add(readValueButton);
    }
    return actionButtons;
}
Also used : FormButton(org.openremote.app.client.widget.FormButton) ArrayList(java.util.ArrayList)

Aggregations

FormButton (org.openremote.app.client.widget.FormButton)2 ArrayList (java.util.ArrayList)1