Package org.jboss.dashboard.ui.components

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


            }
        }
    }

    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

        getWorkspaceHandler().setWorkspaceId(workspaceId);
        getWorkspaceHandler().deleteWorkspace();
    }

    public void actionCreateWorkspace(CommandRequest request) {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        final WorkspaceImpl newWorkspace = new WorkspaceImpl();
        try {
            buildI18nValues(request);
            if (validateBeforeCreation()) {
                newWorkspace.setId(UIServices.lookup().getWorkspacesManager().generateWorkspaceId());
                newWorkspace.setTitle(title);
                newWorkspace.setName(name);
                newWorkspace.setSkinId(skinId);
                newWorkspace.setEnvelopeId(envelopeId);

                // Register workspace (persistent operation)
                new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    UIServices.lookup().getWorkspacesManager().addNewWorkspace(newWorkspace);
                    getNavigationManager().setCurrentWorkspace(newWorkspace);
                }}.execute();

                // Add default access/admin permissions to the roles the creator user belongs to.
                RolesManager rolesManager = SecurityServices.lookup().getRolesManager();
                UIPolicy policy = (UIPolicy) SecurityServices.lookup().getSecurityPolicy();
                List<Permission> defaultPermissions = policy.createDefaultPermissions(newWorkspace);
                for (String roleId : UserStatus.lookup().getUserRoleIds()) {
                    Role role = rolesManager.getRoleById(roleId);
                    RolePrincipal prpal = new RolePrincipal(role);
                    for (Permission perm : defaultPermissions) {
                        policy.addPermission(prpal, perm);
                    }
                }
                policy.save();

                title = null;
                name = null;
                skinId = UIServices.lookup().getSkinsManager().getDefaultElement().getId();
                envelopeId = UIServices.lookup().getEnvelopesManager().getDefaultElement().getId();
                messagesHandler.addMessage("ui.alert.workspaceCreation.OK");
            }

        } catch (Exception e) {
            messagesHandler.clearAll();
            messagesHandler.addError("ui.alert.workspaceCreation.KO");
            log.error("Error: " + e.getMessage());
        }
    }
View Full Code Here

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

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

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

    public 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;
        }
        return valid;
    }
View Full Code Here

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

    public CommandResponse actionImportKPIs(CommandRequest request) {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        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();
                for (Message message : messages) {
                    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

        if ("false".equals(saveButtonPressed)) {
            readSectionValues();
            return;
        }

        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        setTitle(setLangTitle(request).get(LocaleManager.lookup().getDefaultLang()));
        if (validateBeforeEdition()) {
            try {
                final Section section = getSection();
                section.setTitle(setLangTitle(request));
                section.setVisible(Boolean.valueOf(visible));
                section.setSkinId(skin);
                section.setEnvelopeId(envelope);
                url = ("".equals(url)) ? null : url;
                section.setFriendlyUrl(url);
                section.setRegionsCellSpacing(new Integer(regionsCellSpacing));
                section.setPanelsCellSpacing(new Integer(panelsCellSpacing));
                section.setLayoutId(layout);


                HibernateTxFragment txFragment = new HibernateTxFragment() {
                    protected void txFragment(Session session) throws Exception {
                        UIServices.lookup().getSectionsManager().store(section);
                    }
                };

                txFragment.execute();
                messagesHandler.addMessage("ui.alert.sectionEdition.OK");
                setSection(section);
            } catch (Exception e) {
                log.error("Error: ", e);
                messagesHandler.clearAll();
                messagesHandler.addError("ui.alert.sectionEdition.KO");
            }
        }
    }
View Full Code Here

        }
        return m;
    }

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

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

    protected boolean validate() {
        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();

        if (title == null || "".equals(title)) {
            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();
    }
View Full Code Here

        clearFieldErrors();

        ResourceBundle i18n = localeManager.getBundle("org.jboss.dashboard.ui.components.panelManagement.messages", LocaleManager.currentLocale());
        title = i18n.getString("title.properties");

        MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
        messagesHandler.clearAll();

        return super.openDialog(panel, request, title, width, height);
    }
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.