Package org.rhq.coregui.client.util.message

Examples of org.rhq.coregui.client.util.message.Message


     *
     * @param isReadOnly whether or not the record editor should be in read-only mode
     */
    protected void init(boolean isReadOnly) {
        if (this.recordId == ID_NEW && isReadOnly) {
            Message message = new Message(MSG.widget_recordEditor_error_permissionCreate(this.dataTypeName),
                Message.Severity.Error);
            CoreGUI.goToView(getListViewPath(), message);
        } else {
            this.isReadOnly = isReadOnly;

View Full Code Here


        this.form.resetValues();
    }

    protected void save(final DSRequest requestProperties) {
        if (!this.form.validate()) {
            Message message = new Message(MSG.widget_recordEditor_warn_validation(this.dataTypeName),
                Message.Severity.Warning, EnumSet.of(Message.Option.Transient));
            CoreGUI.getMessageCenter().notify(message);
            return;
        }

        this.form.saveData(new DSCallback() {
            public void execute(DSResponse response, Object rawData, DSRequest request) {
                if (response.getStatus() == RPCResponse.STATUS_SUCCESS) {
                    Record[] data = response.getData();
                    Record record = data[0];

                    String id = record.getAttribute(FIELD_ID);
                    String name = record.getAttribute(getTitleFieldName());

                    Message message;
                    String conciseMessage;
                    String detailedMessage;
                    DSOperationType operationType = request.getOperationType();
                    if (Log.isDebugEnabled()) {
                        Object dataObject = dataSource.copyValues(record);
                        if (operationType == DSOperationType.ADD) {
                            Log.debug("Created: " + dataObject);
                        } else {
                            Log.debug("Updated: " + dataObject);
                        }
                    }
                    switch (operationType) {
                    case ADD:
                        conciseMessage = MSG.widget_recordEditor_info_recordCreatedConcise(dataTypeName);
                        detailedMessage = MSG.widget_recordEditor_info_recordCreatedDetailed(dataTypeName, name);
                        if (CoreGUI.isDebugMode()) {
                            conciseMessage += " (" + FIELD_ID + "=" + id + ")";
                            detailedMessage += " (" + FIELD_ID + "=" + id + ")";
                        }
                        break;
                    case UPDATE:
                        conciseMessage = MSG.widget_recordEditor_info_recordUpdatedConcise(dataTypeName);
                        detailedMessage = MSG.widget_recordEditor_info_recordUpdatedDetailed(dataTypeName, name);
                        break;
                    default:
                        throw new IllegalStateException(MSG
                            .widget_recordEditor_error_unsupportedOperationType(operationType.name()));
                    }

                    message = new Message(conciseMessage, detailedMessage);
                    // only refresh if no-refresh attribute is missing
                    boolean refresh = requestProperties.getAttribute(FIELD_NO_REFRESH) == null;
                    CoreGUI.goToView(getListViewPath(), message, refresh);

                } else if (response.getStatus() == RPCResponse.STATUS_VALIDATION_ERROR) {
                    String causes = null;
                    if (response.getErrors() != null && !response.getErrors().isEmpty()) {
                        // prepare detailed error message
                        StringBuffer sb = new StringBuffer();
                        for (Object cause : response.getErrors().values()) {
                            sb.append(cause);
                            sb.append('\n');
                        }
                        causes = sb.toString();
                    }
                    Message message = new Message(MSG.widget_recordEditor_error_operationInvalidValues(), causes,
                        Message.Severity.Error);
                    CoreGUI.getMessageCenter().notify(message);
                } else {
                    // assume failure                   
                    Message message = new Message(MSG.widget_recordEditor_error_operation(), Message.Severity.Error);
                    CoreGUI.getMessageCenter().notify(message);
                }
            }
        }, requestProperties);
    }
View Full Code Here

    public void executeFetch(final DSRequest request, final DSResponse response, final ResourceCriteria criteria) {
        resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
            public void onFailure(Throwable caught) {
                if (caught.getMessage().contains("SearchExpressionException")) {
                    Message message = new Message("Invalid search expression.", Message.Severity.Error);
                    CoreGUI.getMessageCenter().notify(message);
                } else if (caught.getMessage().contains("PageList was passed an empty collection")) {
                    // Because of bug 773626
                    Log.warn(caught.getMessage());
                    criteria.setPageControl(new PageControl(0, getDataPageSize()));
View Full Code Here

                    caught);
            }

            public void onSuccess(Dashboard result) {
                String msg = MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName());
                CoreGUI.getMessageCenter().notify(new Message(msg, Message.Severity.Info));
            }
        });
    }
View Full Code Here

                int[] selectedIds = getSelectedIds(selections);
                GWTServiceLookup.getPluginService().enableAgentPlugins(selectedIds,
                    new AsyncCallback<ArrayList<String>>() {
                        @Override
                        public void onSuccess(ArrayList<String> result) {
                            Message msg = new Message(MSG.view_admin_plugins_enabledAgentPlugins(result.toString()),
                                Severity.Info);
                            CoreGUI.getMessageCenter().notify(msg);
                            refresh();
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            CoreGUI.getErrorHandler()
                                .handleError(
                                    MSG.view_admin_plugins_enabledAgentPluginsFailure() + " " + caught.getMessage(),
                                    caught);
                            refreshTableInfo();
                        }
                    });
            }
        });

        addTableAction(MSG.common_button_disable(), new AuthorizedTableAction(this, TableActionEnablement.ANY,
            Permission.MANAGE_SETTINGS) {
            public void executeAction(final ListGridRecord[] selections, Object actionValue) {
                ArrayList<String> selectedNames = getSelectedNames(selections);
                String message = MSG.view_admin_plugins_agentDisableConfirm(selectedNames.toString());
                SC.ask(message, new BooleanCallback() {
                    public void execute(Boolean confirmed) {
                        if (confirmed) {
                            int[] selectedIds = getSelectedIds(selections);
                            GWTServiceLookup.getPluginService().disableAgentPlugins(selectedIds,
                                new AsyncCallback<ArrayList<String>>() {
                                    @Override
                                    public void onSuccess(ArrayList<String> result) {
                                        Message msg = new Message(MSG.view_admin_plugins_disabledAgentPlugins(result
                                            .toString()), Severity.Info);
                                        CoreGUI.getMessageCenter().notify(msg);
                                        refresh();
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        CoreGUI.getErrorHandler().handleError(
                                            MSG.view_admin_plugins_disabledAgentPluginsFailure() + " "
                                                + caught.getMessage(), caught);
                                        refreshTableInfo();
                                    }
                                });
                        } else {
                            refreshTableInfo();
                        }
                    }
                });
            }
        });

        addTableAction(MSG.common_button_delete(), ButtonColor.RED, new AuthorizedTableAction(this, TableActionEnablement.ANY,
            Permission.MANAGE_SETTINGS) {
            public void executeAction(final ListGridRecord[] selections, Object actionValue) {
                ArrayList<String> selectedNames = getSelectedNames(selections);
                String message = MSG.view_admin_plugins_agentDeleteConfirm(selectedNames.toString());
                SC.ask(message, new BooleanCallback() {
                    public void execute(Boolean confirmed) {
                        if (confirmed) {
                            int[] selectedIds = getSelectedIds(selections);
                            GWTServiceLookup.getPluginService().deleteAgentPlugins(selectedIds,
                                new AsyncCallback<ArrayList<String>>() {
                                    @Override
                                    public void onSuccess(ArrayList<String> result) {
                                        Message msg = new Message(MSG.view_admin_plugins_deletedAgentPlugins(result
                                            .toString()), Severity.Info);
                                        CoreGUI.getMessageCenter().notify(msg);
                                        refresh();
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        CoreGUI.getErrorHandler().handleError(
                                            MSG.view_admin_plugins_deletedAgentPluginsFailure() + " "
                                                + caught.getMessage(), caught);
                                        refreshTableInfo();
                                    }
                                });
                        } else {
                            refreshTableInfo();
                        }
                    }
                });
            }
        });

        IButton updateOnAgentsButton = new EnhancedIButton(MSG.view_admin_plugins_update_on_agents(), ButtonColor.BLUE);
        updateOnAgentsButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent clickEvent) {
                VLayout layout = new VLayout();
                final PopupWindow w = new PopupWindow(null);

                Canvas nowCanvas = new Canvas();
                nowCanvas.setWidth(1);
                nowCanvas.setHeight(1);


                DynamicForm delayForm = new DynamicForm();
                delayForm.setTitleOrientation(TitleOrientation.TOP);
                TreeSet<TimeUnit> timeUnits = new TreeSet<TimeUnit>();
                timeUnits.add(TimeUnit.SECONDS);
                timeUnits.add(TimeUnit.MINUTES);
                timeUnits.add(TimeUnit.HOURS);
                timeUnits.add(TimeUnit.DAYS);
                final DurationItem startDelay = new DurationItem("duration", "", timeUnits, false, false);

                delayForm.setFields(startDelay);

                DynamicForm scheduleForm = new DynamicForm();

                final DateTimeItem schedule = new DateTimeItem("schedule");
                schedule.setEnforceDate(true);
                schedule.setCenturyThreshold(99);
                schedule.setShowTitle(false);
                schedule.setStartDate(new Date());
                schedule.setUseMask(true);
                schedule.setShowHint(true);

                scheduleForm.setFields(schedule);


                LinkedHashMap<String, Canvas> items = new LinkedHashMap<String, Canvas>();
                items.put(MSG.view_admin_plugins_update_on_agents_now(), nowCanvas);
                items.put(MSG.view_admin_plugins_update_on_agents_delayed(), delayForm);
                items.put(MSG.view_admin_plugins_update_on_agents_scheduled(), scheduleForm);

                DynamicForm form = new DynamicForm();
                form.setWidth(300);
                final RadioGroupWithComponentsItem scheduling = new RadioGroupWithComponentsItem("scheduling", "", items, form);

                form.setFields(scheduling);

                layout.addMember(form);

                ButtonItem ok = new ButtonItem("ok", MSG.common_button_ok());
                ok.setEndRow(false);
                ok.setAlign(Alignment.RIGHT);
                ButtonItem cancel = new ButtonItem("cancel", MSG.common_button_cancel());
                cancel.setStartRow(false);
                cancel.setAlign(Alignment.LEFT);

                DynamicForm buttons = new DynamicForm();
                buttons.setNumCols(2);
                buttons.setFields(ok, cancel);

                layout.addMember(buttons);

                ok.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
                    @Override
                    public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) {
                        long delay;
                        if (MSG.view_admin_plugins_update_on_agents_now().equals(scheduling.getSelected())) {
                            delay = 0;
                        } else if (MSG.view_admin_plugins_update_on_agents_delayed().equals(scheduling.getSelected())) {
                            Integer value = (Integer) startDelay.getValue();
                            TimeUnit u = startDelay.getValueUnit();

                            if (value == null) {
                                CoreGUI.getErrorHandler()
                                    .handleError(MSG.view_admin_plugins_update_on_agents_no_time_specified());
                                w.hide();
                                return;
                            }

                            delay = value;
                            switch (u) {
                            case SECONDS:
                                delay *= 1000;
                                break;
                            case MINUTES:
                                delay *= 60 * 1000;
                                break;
                            case HOURS:
                                delay *= 60 * 60 * 1000;
                                break;
                            case DAYS:
                                delay *= 24 * 60 * 60 * 1000;
                                break;
                            }
                        } else {
                            Date scheduledDate = schedule.getValueAsDate();
                            delay = scheduledDate.getTime() - new Date().getTime();
                        }

                        GWT.log("About to schedule update of the plugins on the agent in " + delay + " milliseconds.");

                        GWTServiceLookup.getPluginService().updatePluginsOnAgents(delay, new AsyncCallback<Void>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                CoreGUI.getErrorHandler().handleError(
                                    MSG.view_admin_plugins_update_on_agents_failure() + " " +
                                        caught.getMessage(), caught);
                                w.hide();
                            }

                            @Override
                            public void onSuccess(Void result) {
                                w.hide();
                            }
                        });
                    }
                });

                scheduling.setValue(MSG.view_admin_plugins_update_on_agents_now());

                cancel.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
                    @Override
                    public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) {
                        w.hide();
                    }
                });

                w.addItem(layout);

                w.setTitle(MSG.view_admin_plugins_update_on_agents());
                w.setHeight(200);
                w.setWidth(340);
                w.show();
            }

        });

        IButton scanForUpdatesButton = new EnhancedIButton(MSG.view_admin_plugins_scan());
        scanForUpdatesButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                GWTServiceLookup.getPluginService().scanAndRegister(new AsyncCallback<Void>() {
                    @Override
                    public void onSuccess(Void result) {
                        Message msg = new Message(MSG.view_admin_plugins_scanComplete(), Severity.Info);
                        CoreGUI.getMessageCenter().notify(msg);
                        refresh();
                    }

                    @Override
View Full Code Here

        GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
            new AsyncCallback<PageList<ResourceGroupComposite>>() {
                @Override
                public void onFailure(Throwable caught) {
                    Message message = new Message(MSG.view_group_detail_failLoadComp(String.valueOf(groupId)),
                        Message.Severity.Warning);
                    CoreGUI.goToView(InventoryView.VIEW_ID.getName(), message);
                }

                @Override
View Full Code Here

                    if (condition.getMeasurementDefinition() != null) {
                        Integer id = Integer.valueOf(condition.getMeasurementDefinition().getId());
                        if (metricIdsUsed.containsKey(id)) {
                            String msg = MSG.view_alert_definition_condition_editor_metricswarning(metricIdsUsed
                                .get(id));
                            Message warning = new Message(msg, Severity.Warning, EnumSet.of(Message.Option.Transient));
                            CoreGUI.getMessageCenter().notify(warning);
                            return false; // multiple conditions used the same metric with ALL conjunction, this doesn't work - abort (BZ 737565)
                        }
                        metricIdsUsed.put(id, condition.getMeasurementDefinition().getDisplayName());
                    }
View Full Code Here

                int[] selectedIds = getSelectedIds(selections);
                GWTServiceLookup.getPluginService().enableServerPlugins(selectedIds,
                    new AsyncCallback<ArrayList<String>>() {
                        @Override
                        public void onSuccess(ArrayList<String> result) {
                            Message msg = new Message(MSG.view_admin_plugins_enabledServerPlugins(result.toString()),
                                Severity.Info);
                            CoreGUI.getMessageCenter().notify(msg);
                            refresh();
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            CoreGUI.getErrorHandler().handleError(
                                MSG.view_admin_plugins_enabledServerPluginsFailure() + " " + caught.getMessage(),
                                caught);
                            refreshTableInfo();
                        }
                    }
                );
            }
        });

        addTableAction(MSG.common_button_disable(), new AuthorizedTableAction(this, TableActionEnablement.ANY,
            Permission.MANAGE_SETTINGS) {
            public void executeAction(final ListGridRecord[] selections, Object actionValue) {
                ArrayList<String> selectedNames = getSelectedNames(selections);
                String message = MSG.view_admin_plugins_serverDisableConfirm(selectedNames.toString());
                SC.ask(message, new BooleanCallback() {
                    public void execute(Boolean confirmed) {
                        if (confirmed) {
                            int[] selectedIds = getSelectedIds(selections);
                            GWTServiceLookup.getPluginService().disableServerPlugins(selectedIds,
                                new AsyncCallback<ArrayList<String>>() {
                                    @Override
                                    public void onSuccess(ArrayList<String> result) {
                                        Message msg = new Message(MSG.view_admin_plugins_disabledServerPlugins(result
                                            .toString()), Severity.Info);
                                        CoreGUI.getMessageCenter().notify(msg);
                                        refresh();
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        CoreGUI.getErrorHandler().handleError(
                                            MSG.view_admin_plugins_disabledServerPluginsFailure() + " "
                                                + caught.getMessage(), caught
                                        );
                                        refreshTableInfo();
                                    }
                                }
                            );
                        } else {
                            refreshTableInfo();
                        }
                    }
                });
            }
        });

        addTableAction(MSG.common_button_delete(), ButtonColor.RED, new AuthorizedTableAction(this, TableActionEnablement.ANY,
            Permission.MANAGE_SETTINGS) {
            public void executeAction(final ListGridRecord[] selections, Object actionValue) {
                ArrayList<String> selectedNames = getSelectedNames(selections);
                String message = MSG.view_admin_plugins_serverUndeployConfirm(selectedNames.toString());
                SC.ask(message, new BooleanCallback() {
                    public void execute(Boolean confirmed) {
                        if (confirmed) {
                            int[] selectedIds = getSelectedIds(selections);
                            GWTServiceLookup.getPluginService().deleteServerPlugins(selectedIds,
                                new AsyncCallback<ArrayList<String>>() {
                                    @Override
                                    public void onSuccess(ArrayList<String> result) {
                                        Message msg = new Message(MSG.view_admin_plugins_undeployedServerPlugins(result
                                            .toString()), Severity.Info);
                                        CoreGUI.getMessageCenter().notify(msg);
                                        refresh();
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        CoreGUI.getErrorHandler().handleError(
                                            MSG.view_admin_plugins_undeployedServerPluginsFailure() + " "
                                                + caught.getMessage(), caught
                                        );
                                        refreshTableInfo();
                                    }
                                }
                            );
                        } else {
                            refreshTableInfo();
                        }
                    }
                });
            }
        });

        IButton scanForUpdatesButton = new EnhancedIButton(MSG.view_admin_plugins_scan(), ButtonColor.BLUE);
        scanForUpdatesButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                GWTServiceLookup.getPluginService().scanAndRegister(new AsyncCallback<Void>() {
                    @Override
                    public void onSuccess(Void result) {
                        Message msg = new Message(MSG.view_admin_plugins_scanComplete(), Severity.Info);
                        CoreGUI.getMessageCenter().notify(msg);
                        refresh();
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(
                            MSG.view_admin_plugins_scanFailure() + " " + caught.getMessage(), caught);
                        refreshTableInfo();
                    }
                });
            }
        });

        IButton restartMasterPCButton = new EnhancedIButton(MSG.view_admin_plugins_restartMasterPC(), ButtonColor.RED);
        restartMasterPCButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Message msg = new Message(MSG.view_admin_plugins_restartMasterPCStarted(), Severity.Info);
                CoreGUI.getMessageCenter().notify(msg);

                GWTServiceLookup.getPluginService().restartMasterPluginContainer(new AsyncCallback<Void>() {
                    @Override
                    public void onSuccess(Void result) {
                        Message msg = new Message(MSG.view_admin_plugins_restartMasterPCComplete(), Severity.Info);
                        CoreGUI.getMessageCenter().notify(msg);
                        refresh();
                    }

                    @Override
View Full Code Here

                // TODO (ips): Make the below message sticky, but add a new ClearSticky Message option that the
                //             below callback methods can use to clear it once the importResources() call has
                //             completed.
                CoreGUI.getMessageCenter().notify(
                    new Message(MSG.view_autoDiscoveryQ_importInProgress(), Message.Severity.Info, EnumSet
                        .of(Message.Option.Transient)));

                importResources(getSelectedPlatforms());

            }
        });

        ignoreButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                disableButtons(selectAllButton, deselectAllButton, importButton, ignoreButton, unignoreButton);
                CoreGUI.getMessageCenter().notify(
                    new Message(MSG.view_autoDiscoveryQ_ignoreInProgress(), Message.Severity.Info, EnumSet
                        .of(Message.Option.Transient)));

                // assuming here that the ignore list will not be massive and that we can do it all in one go,
                // otherwise re-impl this like import.
                resourceService.ignoreResources(getAllSelectedIds(), new AsyncCallback<Void>() {
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.view_autoDiscoveryQ_ignoreFailure(), caught);
                    }

                    public void onSuccess(Void result) {
                        CoreGUI.getMessageCenter().notify(
                            new Message(MSG.view_autoDiscoveryQ_ignoreSuccessful(), Message.Severity.Info));
                        refresh();
                    }
                });
            }
        });

        unignoreButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                disableButtons(selectAllButton, deselectAllButton, importButton, ignoreButton, unignoreButton);
                CoreGUI.getMessageCenter().notify(
                    new Message(MSG.view_autoDiscoveryQ_unignoreInProgress(), Message.Severity.Info, EnumSet
                        .of(Message.Option.Transient)));

                // assuming here that the unignore list will not be massive and that we can do it all in one go,
                // otherwise re-impl this like import.
                resourceService.unignoreResources(getAllSelectedIds(), new AsyncCallback<Void>() {
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.view_autoDiscoveryQ_unignoreFailure(), caught);
                    }

                    public void onSuccess(Void result) {
                        CoreGUI.getMessageCenter().notify(
                            new Message(MSG.view_autoDiscoveryQ_unignoreSuccessful(), Message.Severity.Info));
                        refresh();
                    }
                });
            }
        });
View Full Code Here

                        }

                        public void onSuccess(Void result) {
                            titleBar.displayResourceName(newName);
                            CoreGUI.getMessageCenter().notify(
                                new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(
                                    String.valueOf(resource.getId()), oldName, newName), Message.Severity.Info));
                        }
                    });
                }
            });
        }
        formItems.add(nameItem);

        // Description
        final FormItem descriptionItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
        descriptionItem.setName("description");
        descriptionItem.setTitle(MSG.common_title_description());
        descriptionItem.setValue(resource.getDescription());
        descriptionItem.setAttribute(OUTPUT_AS_HTML_ATTRIBUTE, true);
        if (descriptionItem instanceof EditableFormItem) {
            EditableFormItem togglableDescriptionItem = (EditableFormItem) descriptionItem;
            togglableDescriptionItem.setValueEditedHandler(new ValueEditedHandler() {
                public void editedValue(Object newValue) {
                    final String newDescription = newValue != null ? newValue.toString() : "";
                    final String oldDescription = resource.getDescription();
                    if (newDescription.equals(oldDescription)) {
                        return;
                    }
                    resource.setDescription(newDescription);
                    OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
                        public void onFailure(Throwable caught) {
                            CoreGUI.getErrorHandler().handleError(
                                MSG.view_summaryOverviewForm_error_descriptionChangeFailure(
                                    String.valueOf(resource.getId()), oldDescription, newDescription), caught);
                            // We failed to update it on the Server, so change back the Resource and the form item to
                            // the original value.
                            resource.setDescription(oldDescription);
                            descriptionItem.setValue(oldDescription);
                        }

                        public void onSuccess(Void result) {
                            CoreGUI.getMessageCenter().notify(
                                new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(
                                    String.valueOf(resource.getId()), oldDescription, newDescription),
                                    Message.Severity.Info));
                        }
                    });
                }
            });
        }
        formItems.add(descriptionItem);

        // Location
        final FormItem locationItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
        locationItem.setName("location");
        locationItem.setTitle(MSG.view_summaryOverviewForm_field_location());
        locationItem.setValue(resource.getLocation());
        locationItem.setAttribute(OUTPUT_AS_HTML_ATTRIBUTE, true);
        if (locationItem instanceof EditableFormItem) {
            EditableFormItem togglableLocationItem = (EditableFormItem) locationItem;
            togglableLocationItem.setValueEditedHandler(new ValueEditedHandler() {
                public void editedValue(Object newValue) {
                    final String newLocation = newValue != null ? newValue.toString() : "";
                    final String oldLocation = resource.getLocation();
                    if (newLocation.equals(oldLocation)) {
                        return;
                    }
                    resource.setLocation(newLocation);
                    OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
                        public void onFailure(Throwable caught) {
                            CoreGUI.getErrorHandler().handleError(
                                MSG.view_summaryOverviewForm_error_locationChangeFailure(
                                    String.valueOf(resource.getId()), oldLocation, newLocation), caught);
                            // We failed to update it on the Server, so change back the Resource and the form item to
                            // the original value.
                            resource.setLocation(oldLocation);
                            locationItem.setValue(oldLocation);
                        }

                        public void onSuccess(Void result) {
                            CoreGUI.getMessageCenter()
                                .notify(
                                    new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(
                                        String.valueOf(resource.getId()), oldLocation, newLocation),
                                        Message.Severity.Info));
                        }
                    });
                }
View Full Code Here

TOP

Related Classes of org.rhq.coregui.client.util.message.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.