Package org.jboss.dashboard.ui.components

Examples of org.jboss.dashboard.ui.components.MessagesComponentHandler


        if (id < 0) id = id*-1;
        return new SendStreamResponse(new ByteArrayInputStream(xml.getBytes()), "inline;filename=kpiExport_" + id + ".xml");
    }

    public CommandResponse actionImportKPIs(CommandRequest request) {
        MessagesComponentHandler messagesHandler = (MessagesComponentHandler) Factory.lookup("org.jboss.dashboard.ui.components.MessagesComponentHandler");
        messagesHandler.clearAll();
        if (request.getUploadedFilesCount() > 0) {
            File file = (File) request.getFilesByParamName().get("importFile");
            try {

                // Parse the file.
                ImportManager importMgr = DataDisplayerServices.lookup().getImportManager();
                ImportResults importResults = importMgr.parse(new FileInputStream(file));

                // Save the imported results.
                importMgr.update(importResults);

                // Show import messages.
                MessageList messages = importResults.getMessages();
                Locale locale = LocaleManager.currentLocale();
                Iterator it = messages.iterator();
                while (it.hasNext()) {
                    Message message = (Message) it.next();
                    switch (message.getMessageType()) {
                        case Message.ERROR: messagesHandler.addError(message.getMessage(locale)); break;
                        case Message.WARNING: messagesHandler.addWarning(message.getMessage(locale)); break;
                        case Message.INFO: messagesHandler.addMessage(message.getMessage(locale)); break;
                    }
                }
            } catch (Exception e) {
                log.error("Error importing KPIs from file (" + file + ")", e);
                messagesHandler.addError(new ExportHandlerMessage("import.kpis.importAbortedError", new Object[] {}).getMessage(LocaleManager.currentLocale()));
            }
            setComponentIncludeJSP(getKpiImportResultJSP());
        }
        return new ShowCurrentScreenResponse();
    }
View Full Code Here


        try {
            getWorkspacesPropertiesHandler().clearFieldErrors();
            getWorkspacesPropertiesHandler().setName(null);
            getWorkspacesPropertiesHandler().setTitle(null);

            MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
            messagesHandler.clearAll();
        } catch (Exception e) {
            log.error("Error: ", e);
            return false;
        }
        return true;
View Full Code Here

    public void setErrorsImg(String errorsImg) {
        this.errorsImg = errorsImg;
    }

    public void service(HttpServletRequest request, HttpServletResponse response) throws FormatterException {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        if (messagesHandler.getErrorsToDisplay() != null && messagesHandler.getErrorsToDisplay().size() > 0) {
            renderMessages(messagesHandler.getErrorsToDisplay(), messagesHandler.getErrorsParameters(), errorsImg, classForErrors);
        } else if (messagesHandler.getWarningsToDisplay() != null && messagesHandler.getWarningsToDisplay().size() > 0) {
            renderMessages(messagesHandler.getWarningsToDisplay(), messagesHandler.getWarningsParameters(), warningsImg, classForWarnings);
        } else if (messagesHandler.getMessagesToDisplay() != null && messagesHandler.getMessagesToDisplay().size() > 0) {
            renderMessages(messagesHandler.getMessagesToDisplay(), messagesHandler.getMessagesParameters(), messagesImg, classForMessages);
        }
    }
View Full Code Here

    protected void renderMessages(List<String> messages, List<String[]> params, String img, String className) {
        while (messages.size() > params.size()) {
            params.add(null);
        }
        MessagesComponentHandler messagesComponentHandler = MessagesComponentHandler.lookup();
        long id = System.currentTimeMillis();
        boolean maxRised = false;

        setAttribute("image", img);
        setAttribute("bundle", messagesComponentHandler.getI18nBundle());
        renderFragment("outputStart");

        renderFragment("outputVisibleMessagesStart");

        for (int i = 0; i < messages.size(); i++) {
            if (i == maxVisibleErrors) {
                renderFragment("outputMessagesEnd");
                renderFragment("outputNewLine");
                setAttribute("id", id);
                renderFragment("outputHiddenMessagesStart");
                maxRised = true;
            }
            setAttribute("bundle", messagesComponentHandler.getI18nBundle());
            setAttribute("msg", messages.get(i));
            setAttribute("params", params.get(i));
            setAttribute("className", className);
            renderFragment("outputMessage");
        }
        renderFragment("outputMessagesEnd");
        if (maxRised) {
            renderFragment("outputNewLine");
            setAttribute("id", id);
            renderFragment("outputDisplayLinks");
        }
        renderFragment("outputEnd");
        if (messagesComponentHandler.isClearAfterRender()) messagesComponentHandler.clearAll();
    }
View Full Code Here

        renderFragment("outputEnd");
        if (messagesComponentHandler.isClearAfterRender()) messagesComponentHandler.clearAll();
    }

    protected String localizeMessage(String message) {
        MessagesComponentHandler messagesComponentHandler = MessagesComponentHandler.lookup();
        try {
            if (messagesComponentHandler.getI18nBundle() != null) {
                ResourceBundle bundle = localeManager.getBundle(messagesComponentHandler.getI18nBundle(), LocaleManager.currentLocale());
                message = bundle.getString(message);
            }
        } catch (Exception e) {
            if (log.isDebugEnabled())
                log.debug("Error trying to get message '" + message + "' from bundle '" + messagesComponentHandler.getI18nBundle());
        }
        return message;
    }
View Full Code Here

            }
        }
    }

    protected boolean validateBeforeEdition() {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        messagesHandler.clearAll();
        boolean valid = validate();
        if (!valid) messagesHandler.getErrorsToDisplay().add(0, "ui.alert.workspaceEdition.KO");
        return valid;
    }
View Full Code Here

        if (!valid) messagesHandler.getErrorsToDisplay().add(0, "ui.alert.workspaceEdition.KO");
        return valid;
    }

    protected boolean validate() {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        boolean valid = true;
        if (name == null || name.isEmpty()) {
            addFieldError(new FactoryURL(getBeanName(), "name"), null, name);
            messagesHandler.addError("ui.alert.workspaceErrors.name");
            valid = false;
        }
        if (title == null || title.isEmpty()) {
            addFieldError(new FactoryURL(getBeanName(), "title"), null, title);
            messagesHandler.addError("ui.alert.workspaceErrors.title");
            valid = false;
        }
        if (!isValidURL(url)) {
            addFieldError(new FactoryURL(getBeanName(), "url"), null, url);
            messagesHandler.addError("ui.alert.workspaceErrors.url");
            valid = false;
        }
        return valid;
    }
View Full Code Here

                    elements = contentProvider.getSublist(getPaginationComponentHandler().getElementToStart(), getPaginationComponentHandler().getElementToEnd());
                } catch (Exception e) {
                    log.warn("Error getting elements to paginate: ", e);
                    paginationError = true;

                    MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
                    messagesHandler.addError("pagination.error");
                    renderFragment("outputError");
                }
                if (elements != null && !paginationError) {
                    if (paginationComponentHandler.isShowHeader())
                        renderPaginationHeader(contentProvider, providerLength);
View Full Code Here

    /**
     * Duplicates Section in workspace
     */
    public void actionDuplicateSection(final CommandRequest request) {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        try {
            if (action != null && action.equals(ACTION_SAVE)) {
                final Long selectedSectionId = Long.decode(getSelectedSectionId());
                if (selectedSectionId != null && selectedSectionId.longValue() != 0L) {
                    HibernateTxFragment txFragment = new HibernateTxFragment() {
                        protected void txFragment(Session session) throws Exception {
                            log.debug("Duplicating section " + selectedSectionId.toString());
                            WorkspaceImpl workspace = (WorkspaceImpl) getWorkspace();
                            Section section = null;
                            section = workspace.getSection(selectedSectionId);
                            if (section != null) {
                                // Security check.
                                WorkspacePermission sectionPerm = WorkspacePermission.newInstance(workspace, WorkspacePermission.ACTION_CREATE_PAGE);
                                getUserStatus().checkPermission(sectionPerm);

                                // Duplicate
                                SectionCopyOption sco = getCopyOptions(request);
                                Section sectionCopy = getCopyManager().copy(section, workspace, sco);
                                Map<String, String> title = section.getTitle();
                                for (String lang : title.keySet()) {
                                    String desc = title.get(lang);
                                    String prefix = "Copia de ";
                                    prefix = lang.equals("en") ? "Copy of " : prefix;
                                    sectionCopy.setTitle(prefix + desc, lang);
                                }
                                UIServices.lookup().getSectionsManager().store(sectionCopy);
                            }
                        }
                    };

                    txFragment.execute();
                    messagesHandler.addMessage("ui.alert.sectionCopy.OK");
                }
            }
            this.setDuplicateSection(Boolean.FALSE);
            this.setCreateSection(Boolean.FALSE);
            this.setSelectedSectionId(null);
            defaultValues();
        } catch (Exception e) {
            log.error("Error: " + e.getMessage());
            messagesHandler.clearAll();
            messagesHandler.addError("ui.alert.sectionCopy.KO");
        }
    }
View Full Code Here

            log.error("Error: " + e.getMessage());
        }
    }

    public synchronized void actionCreateSection(CommandRequest request) throws Exception {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();

        if (action != null && (action.equals(ACTION_SAVE) || action.equals(ACTION_PREVIEW))) {

            setLangTitle(request);

            if (action.equals(ACTION_PREVIEW)) return;

            if (validateBeforeEdition()) {
                try {
                    // Create a new section instance.
                    final Section newSection = new Section();
                    WorkspaceImpl workspace = (WorkspaceImpl) getWorkspace();
                    newSection.setTitle(titleMap);
                    if ((parent != null && !"".equals(parent))) {
                        newSection.setParent(workspace.getSection(new Long(parent)));
                    }
                    newSection.setVisible(Boolean.TRUE);
                    newSection.setSkinId(skin);
                    newSection.setEnvelopeId(envelope);
                    newSection.setRegionsCellSpacing(new Integer(2));
                    newSection.setPanelsCellSpacing(new Integer(2));
                    newSection.setLayoutId(layout);

                    // Make changes persistent
                    new HibernateTxFragment() {
                    protected void txFragment(Session session) throws Exception {
                        ((WorkspaceImpl) getWorkspace()).addSection(newSection);
                        UIServices.lookup().getSectionsManager().store(newSection);
                        UIServices.lookup().getWorkspacesManager().store(getWorkspace());
                    }}.execute();

                    // Finish creation action
                    this.setDuplicateSection(Boolean.FALSE);
                    this.setCreateSection(Boolean.FALSE);
                    this.setSelectedSectionId(null);
                    defaultValues();

                    // Print an ok message and move the user into the new page
                    messagesHandler.addMessage("ui.alert.sectionCreation.OK");
                    NavigationManager.lookup().setCurrentSection(newSection);
                } catch (Exception e) {
                    log.error("Error creating section: ", e);
                    messagesHandler.clearAll();
                    messagesHandler.addError("ui.alert.sectionCreation.KO");
                }
            }
        } else {
            this.setDuplicateSection(Boolean.FALSE);
            this.setCreateSection(Boolean.FALSE);
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.ui.components.MessagesComponentHandler

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.