Package org.jboss.dashboard.ui.components

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


        resetFormStatus();

        PanelInstance instance = getPanelInstance();

        if (instance != null) {
            MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
            messagesHandler.clearAll();
            boolean propertiesOk = setSystemParameters(request, instance) && setCustomParameters(request, instance);
            if (propertiesOk) {
                resetFormStatus();
                if (!closeDialog(request)) {
                    messagesHandler.addMessage(PROPERTIES_STORED);
                } else {
                    reset();
                }
            } else {
                messagesHandler.addError(PROPERTIES_NOT_STORED);
            }
        }
    }
View Full Code Here


        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

    /**
     * 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

            }
        }
    }

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

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

    protected boolean validate() {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        try {
            if (titleMap == null || titleMap.isEmpty()) {
                addFieldError(new FactoryURL(getBeanName(), "title"), null, title);
                messagesHandler.addError("ui.alert.sectionErrors.title");
            }

            if (!isValidURL(url)) {
                addFieldError(new FactoryURL(getBeanName(), "url"), null, url);
                messagesHandler.addError("ui.alert.sectionErrors.url");
            }

            return getFieldErrors().isEmpty();
        } catch (Exception e) {
            log.error("Error: ", e);
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.