Search in sources :

Example 1 with ConfirmationDialog

use of org.opennms.netmgt.vaadin.core.ConfirmationDialog in project opennms by OpenNMS.

the class MBeansController method selectItemInTree.

/**
	 * Updates the view when the selected MBean changes. At first each
	 * SelectionChangedListener are told, that there is a new Mbean to take care of
	 * (in detail: change the view to list mbean details of new mbean). And of
	 * course set a new ViewState (e.g. a non Mbean was selected and now a Mbean
	 * is selected)
	 *
	 * @param itemId the ItemId (Object Id) to select in the tree.
	 */
protected void selectItemInTree(final String itemId) {
    if (currentSelection.getItemId() != itemId) {
        if (mbeansContentPanel.isDirty()) {
            new ConfirmationDialog().withOkAction(new ConfirmationDialog.Action() {

                @Override
                public void execute(ConfirmationDialog window) {
                    mbeansContentPanel.discard();
                    currentSelection.update(itemId, mbeansContainer.getItem(itemId), mbeansContainer.getDataFor(itemId));
                    fireTreeSelectionChanged(currentSelection);
                }
            }).withCancelAction(new ConfirmationDialog.Action() {

                @Override
                public void execute(ConfirmationDialog window) {
                    // abort, do not continue -> revert selection
                    // (the change is already visible to the client)
                    mbeansTree.select(currentSelection.getItemId());
                }
            }).withOkLabel("yes").withCancelLabel("no").withCaption("Validation errors").withDescription("The current view contains validation errors.<br/>The values cannot be saved.<br/>If you continue, they are lost.<br/><br/>Do you want to switch selection?").open();
        } else {
            currentSelection.update(itemId, mbeansContainer.getItem(itemId), mbeansContainer.getDataFor(itemId));
            fireTreeSelectionChanged(currentSelection);
        }
    }
}
Also used : ConfirmationDialog(org.opennms.netmgt.vaadin.core.ConfirmationDialog)

Aggregations

ConfirmationDialog (org.opennms.netmgt.vaadin.core.ConfirmationDialog)1