Example usage for com.vaadin.ui Label setStyleName

List of usage examples for com.vaadin.ui Label setStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Label setStyleName.

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.NewClientWindow.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///from   w  w w . j ava 2s  . c  o  m
protected void init() {
    this.setStyleName("dashboard");
    this.setModal(true);
    this.setWidth(800, Unit.PIXELS);
    this.setHeight(180, Unit.PIXELS);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty(NewClientFieldGroup.NAME, new ObjectProperty<String>(""));
    item.addItemProperty(NewClientFieldGroup.KEY_LOCATION_QUERY_PROCESSOR_TYPE, new ObjectProperty<String>(
            "org.ikasan.mapping.keyQueryProcessor.impl.XPathKeyLocationQueryProcessor"));

    GridLayout form = new GridLayout(2, 4);
    form.setWidth(100, Unit.PERCENTAGE);
    form.setMargin(true);
    form.setSpacing(true);

    Label newClientLabel = new Label("New Mapping Configuration Client");
    newClientLabel.setStyleName(ValoTheme.LABEL_HUGE);
    form.addComponent(newClientLabel, 0, 0, 1, 0);

    Label nameLabel = new Label("Name:");
    nameLabel.setSizeUndefined();
    form.addComponent(nameLabel, 0, 1);
    form.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);

    nameField.addValidator(new StringLengthValidator("The name must not be blank!", 1, 256, true));
    nameField.setValidationVisible(false);
    nameField.setStyleName("ikasan");
    form.addComponent(nameField, 1, 1);

    Label keyLocationLabel = new Label("Key Location Query Processor Type:");
    keyLocationLabel.setSizeUndefined();
    form.addComponent(keyLocationLabel, 0, 2);
    form.setComponentAlignment(keyLocationLabel, Alignment.MIDDLE_RIGHT);

    TextField keyLocationQueryProcessorTypeField = new TextField();
    keyLocationQueryProcessorTypeField.setStyleName("ikasan");
    keyLocationQueryProcessorTypeField.setWidth(500, Unit.PIXELS);
    form.addComponent(keyLocationQueryProcessorTypeField, 1, 2);

    final NewClientFieldGroup binder = new NewClientFieldGroup(item, this.refreshGroup,
            this.mappingConfigurationService, this.systemEventService);
    binder.bind(nameField, "name");
    binder.bind(keyLocationQueryProcessorTypeField, "keyLocationQueryProcessorType");

    keyLocationQueryProcessorTypeField.setReadOnly(true);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                nameField.validate();
            } catch (InvalidValueException e) {
                nameField.setValidationVisible(true);
                return;
            }

            try {
                binder.commit();
                UI.getCurrent().getNavigator().navigateTo("emptyPanel");

                nameField.setValue("");

                Notification.show("New Mapping Configuration Client Successfully Created!");
                saveRequiredMonitor.setSaveRequired(false);

                close();
            } catch (CommitException e) {
                Notification.show("An error has occurred saving a new client: " + e.getMessage());
            }
        }
    });
    buttons.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo("emptyPanel");
            binder.discard();
            saveRequiredMonitor.setSaveRequired(false);

            close();
        }
    });
    buttons.addComponent(cancelButton);

    form.addComponent(buttons, 0, 3, 1, 3);
    form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    this.setContent(form);
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.NewMappingConfigurationContextWindow.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///from   w  w w.  j a  v a  2 s  .c om
protected void init() {
    this.setStyleName("dashboard");
    this.setModal(true);
    this.setWidth(500, Unit.PIXELS);
    this.setHeight(250, Unit.PIXELS);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty(NewContextFieldGroup.NAME, new ObjectProperty<String>(""));
    item.addItemProperty(NewContextFieldGroup.DESCRIPTION, new ObjectProperty<String>(""));

    GridLayout form = new GridLayout(2, 4);
    form.setColumnExpandRatio(0, .15f);
    form.setColumnExpandRatio(1, .85f);
    form.setWidth(100, Unit.PERCENTAGE);
    form.setMargin(true);
    form.setSpacing(true);

    Label newTypeLabel = new Label("New Mapping Configuration Context");
    newTypeLabel.setStyleName(ValoTheme.LABEL_HUGE);
    form.addComponent(newTypeLabel, 0, 0, 1, 0);

    Label nameLabel = new Label("Name:");
    nameLabel.setSizeUndefined();
    form.addComponent(nameLabel, 0, 1);
    form.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);

    nameField.setStyleName("ikasan");
    nameField.addValidator(new StringLengthValidator("The name must not be blank!", 1, 256, true));
    nameField.setValidationVisible(false);
    nameField.setWidth(70, Unit.PERCENTAGE);
    form.addComponent(nameField, 1, 1);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();
    form.addComponent(descriptionLabel, 0, 2);
    form.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);

    descriptionField.setStyleName("ikasan");
    descriptionField
            .addValidator(new StringLengthValidator("The description must not be blank!", 1, 256, true));
    descriptionField.setValidationVisible(false);
    descriptionField.setWidth(90, Unit.PERCENTAGE);
    descriptionField.setRows(5);

    form.addComponent(descriptionField, 1, 2);

    final NewContextFieldGroup binder = new NewContextFieldGroup(item, this.refreshGroup,
            this.mappingConfigurationService, this.systemEventService);
    binder.bind(nameField, NewContextFieldGroup.NAME);
    binder.bind(descriptionField, NewContextFieldGroup.DESCRIPTION);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                nameField.validate();
                descriptionField.validate();
            } catch (InvalidValueException e) {
                nameField.setValidationVisible(true);
                descriptionField.setValidationVisible(true);
                return;
            }

            try {
                binder.commit();
                UI.getCurrent().getNavigator().navigateTo("emptyPanel");
                nameField.setValue("");
                descriptionField.setValue("");
                Notification.show("New Mapping Configuration Context Successfully Created!");
                saveRequiredMonitor.setSaveRequired(false);

                close();
            } catch (CommitException e) {
                Notification.show("An error occurred saving a new context! " + e.getMessage(),
                        Type.ERROR_MESSAGE);
            }
        }
    });
    buttons.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo("emptyPanel");
            binder.discard();
            saveRequiredMonitor.setSaveRequired(false);

            close();
        }
    });
    buttons.addComponent(cancelButton);

    form.addComponent(buttons, 0, 3, 1, 3);
    form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);

    this.setContent(form);
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.NewMappingConfigurationTypeWindow.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///from  w  w w  .jav  a  2s. c o  m
protected void init() {
    this.setStyleName("dashboard");
    this.setModal(true);
    this.setWidth(500, Unit.PIXELS);
    this.setHeight(180, Unit.PIXELS);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty(NewContextFieldGroup.NAME, new ObjectProperty<String>(""));

    GridLayout form = new GridLayout(2, 3);
    form.setColumnExpandRatio(0, .15f);
    form.setColumnExpandRatio(1, .85f);
    form.setWidth(100, Unit.PERCENTAGE);
    form.setMargin(true);
    form.setSpacing(true);

    Label newTypeLabel = new Label("New Mapping Configuration Type");
    newTypeLabel.setStyleName(ValoTheme.LABEL_HUGE);
    form.addComponent(newTypeLabel, 0, 0, 1, 0);

    Label nameLabel = new Label("Name:");
    nameLabel.setSizeUndefined();
    form.addComponent(nameLabel, 0, 1);
    form.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);

    nameField.setStyleName("ikasan");
    nameField.addValidator(new StringLengthValidator("The name must not be blank!", 1, 256, true));
    nameField.setValidationVisible(false);
    nameField.setWidth(70, Unit.PERCENTAGE);
    form.addComponent(nameField, 1, 1);

    final NewConfigurationTypeFieldGroup binder = new NewConfigurationTypeFieldGroup(item, this.refreshGroup,
            this.mappingConfigurationService, systemEventService);
    binder.bind(nameField, NewContextFieldGroup.NAME);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                nameField.validate();
            } catch (InvalidValueException e) {
                nameField.setValidationVisible(true);
                return;
            }

            try {
                binder.commit();
                UI.getCurrent().getNavigator().navigateTo("emptyPanel");
                nameField.setValue("");
                Notification.show("New Mapping Configuration Type Successfully Created!");
                saveRequiredMonitor.setSaveRequired(false);

                close();
            } catch (CommitException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Cauget exception trying to save a new Mapping Configuration Type!",
                        sw.toString(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    buttons.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo("emptyPanel");
            binder.discard();
            saveRequiredMonitor.setSaveRequired(false);

            close();
        }
    });
    buttons.addComponent(cancelButton);

    form.addComponent(buttons, 0, 2, 1, 2);
    form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    this.setContent(form);
}

From source file:org.ikasan.dashboard.ui.monitor.component.MonitorPanel.java

License:BSD License

public Component buildServerComponent() {
    Panel component = new Panel();
    component.setSizeFull();//from   w  w  w. j  a v a  2s. c  o  m
    component.addStyleName(ValoTheme.PANEL_BORDERLESS);

    GridLayout layout = new GridLayout(2, 4);
    layout.setSizeFull();
    layout.setMargin(true);

    Label serverNameLabel = new Label(server.getName());
    serverNameLabel.setStyleName(ValoTheme.LABEL_LARGE);
    serverNameLabel.setWidth("100%");
    Label serverDescriptionLabel = new Label(server.getDescription());
    serverDescriptionLabel.setWidth("100%");
    serverDescriptionLabel.setStyleName(ValoTheme.LABEL_LARGE);
    Label serverUrlLabel = new Label(server.getUrl() + ":" + server.getPort());
    serverUrlLabel.setStyleName(ValoTheme.LABEL_LARGE);
    serverUrlLabel.setWidth("100%");

    layout.addComponent(serverNameLabel, 0, 0);
    layout.addComponent(serverDescriptionLabel, 0, 1);
    layout.addComponent(serverUrlLabel, 0, 2);

    statusLabel.setCaptionAsHtml(true);

    MonitorIcons icon = MonitorIcons.SERVER;
    icon.setSizePixels(64);

    Label serverLabel = new Label();
    serverLabel.setCaption(icon.getHtml());
    serverLabel.setCaptionAsHtml(true);

    layout.addComponent(serverLabel, 1, 0, 1, 2);
    layout.setComponentAlignment(serverLabel, Alignment.MIDDLE_CENTER);

    layout.addComponent(statusLabel, 0, 3, 1, 3);
    layout.setComponentAlignment(statusLabel, Alignment.MIDDLE_CENTER);

    buildFilterTable();

    component.setContent(layout);

    Component contentWrapper = createContentWrapper(component, buildFilterTable());

    contentWrapper.addStyleName("top10-revenue");
    return contentWrapper;
}

From source file:org.ikasan.dashboard.ui.topology.panel.TopologyViewPanel.java

License:BSD License

protected void createModuleTreePanel() {
    this.topologyTreePanel = new Panel();
    this.topologyTreePanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    this.topologyTreePanel.setSizeFull();

    this.moduleTree = new Tree();
    this.moduleTree.setImmediate(true);
    this.moduleTree.setSizeFull();
    this.moduleTree.addActionHandler(this);
    this.moduleTree.setDragMode(TreeDragMode.NODE);
    this.moduleTree.setItemStyleGenerator(new ItemStyleGenerator() {
        @Override/*from   w ww .  j  a va2 s .  c  o  m*/
        public String getStyle(Tree source, Object itemId) {
            if (itemId instanceof Flow) {
                Flow flow = (Flow) itemId;

                String state = flowStates.get(flow.getModule().getName() + "-" + flow.getName());

                logger.info("State = " + state);

                if (state != null && state.equals(RUNNING)) {
                    return "greenicon";
                } else if (state != null && state.equals(RECOVERING)) {
                    return "orangeicon";
                } else if (state != null && state.equals(STOPPED)) {
                    return "redicon";
                } else if (state != null && state.equals(STOPPED_IN_ERROR)) {
                    return "redicon";
                } else if (state != null && state.equals(PAUSED)) {
                    return "indigoicon";
                }
            }

            return "";
        }
    });

    GridLayout layout = new GridLayout(1, 4);

    Label roleManagementLabel = new Label("Topology");
    roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(roleManagementLabel, 0, 0);

    layout.setSpacing(true);
    layout.setWidth("100%");

    this.treeViewBusinessStreamCombo = new ComboBox("Business Stream");

    this.treeViewBusinessStreamCombo.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                businessStream = (BusinessStream) event.getProperty().getValue();

                logger.info("Value changed to business stream: " + businessStream.getName());

                moduleTree.removeAllItems();

                final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService
                        .getCurrentRequest().getWrappedSession()
                        .getAttribute(DashboardSessionValueConstants.USER);

                if (authentication != null
                        && authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
                        && businessStream.getName().equals("All")) {
                    List<Server> servers = TopologyViewPanel.this.topologyService.getAllServers();

                    for (Server server : servers) {
                        Set<Module> modules = server.getModules();

                        TopologyViewPanel.this.moduleTree.addItem(server);
                        TopologyViewPanel.this.moduleTree.setItemCaption(server, server.getName());
                        TopologyViewPanel.this.moduleTree.setChildrenAllowed(server, true);
                        TopologyViewPanel.this.moduleTree.setItemIcon(server, VaadinIcons.SERVER);

                        for (Module module : modules) {
                            TopologyViewPanel.this.moduleTree.addItem(module);
                            TopologyViewPanel.this.moduleTree.setItemCaption(module, module.getName());
                            TopologyViewPanel.this.moduleTree.setParent(module, server);
                            TopologyViewPanel.this.moduleTree.setChildrenAllowed(module, true);
                            TopologyViewPanel.this.moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE);

                            Set<Flow> flows = module.getFlows();

                            for (Flow flow : flows) {
                                TopologyViewPanel.this.moduleTree.addItem(flow);
                                TopologyViewPanel.this.moduleTree.setItemCaption(flow, flow.getName());
                                TopologyViewPanel.this.moduleTree.setParent(flow, module);
                                TopologyViewPanel.this.moduleTree.setChildrenAllowed(flow, true);

                                TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION);

                                Set<Component> components = flow.getComponents();

                                for (Component component : components) {
                                    TopologyViewPanel.this.moduleTree.addItem(component);
                                    TopologyViewPanel.this.moduleTree.setParent(component, flow);
                                    TopologyViewPanel.this.moduleTree.setItemCaption(component,
                                            component.getName());
                                    TopologyViewPanel.this.moduleTree.setChildrenAllowed(component, false);

                                    if (component.isConfigurable()) {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG);
                                    } else {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG_O);
                                    }
                                }
                            }
                        }
                    }
                } else if (authentication != null
                        && !authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
                        && businessStream.getName().equals("All")) {
                    List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams();

                    for (BusinessStream businessStream : businessStreams) {
                        if (authentication.canAccessLinkedItem(
                                PolicyLinkTypeConstants.BUSINESS_STREAM_LINK_TYPE, businessStream.getId())) {
                            for (BusinessStreamFlow bsFlow : businessStream.getFlows()) {
                                Server server = bsFlow.getFlow().getModule().getServer();
                                Module module = bsFlow.getFlow().getModule();
                                Flow flow = bsFlow.getFlow();

                                if (!moduleTree.containsId(server)) {
                                    moduleTree.addItem(server);
                                    moduleTree.setItemCaption(server, server.getName());
                                    moduleTree.setChildrenAllowed(server, true);
                                    moduleTree.setItemIcon(server, VaadinIcons.SERVER);
                                }

                                moduleTree.addItem(module);
                                moduleTree.setItemCaption(module, module.getName());
                                moduleTree.setParent(module, server);
                                moduleTree.setChildrenAllowed(module, true);
                                moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE);

                                moduleTree.addItem(flow);
                                moduleTree.setItemCaption(flow, flow.getName());
                                moduleTree.setParent(flow, module);
                                moduleTree.setChildrenAllowed(flow, true);

                                TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION);

                                Set<Component> components = flow.getComponents();

                                for (Component component : components) {
                                    moduleTree.addItem(component);
                                    moduleTree.setParent(component, flow);
                                    moduleTree.setItemCaption(component, component.getName());
                                    moduleTree.setChildrenAllowed(component, false);

                                    if (component.isConfigurable()) {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG);
                                    } else {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG_O);
                                    }
                                }
                            }
                        }
                    }
                } else {
                    for (BusinessStreamFlow bsFlow : businessStream.getFlows()) {
                        Server server = bsFlow.getFlow().getModule().getServer();
                        Module module = bsFlow.getFlow().getModule();
                        Flow flow = bsFlow.getFlow();

                        if (!moduleTree.containsId(server)) {
                            moduleTree.addItem(server);
                            moduleTree.setItemCaption(server, server.getName());
                            moduleTree.setChildrenAllowed(server, true);
                            moduleTree.setItemIcon(server, VaadinIcons.SERVER);
                        }

                        moduleTree.addItem(module);
                        moduleTree.setItemCaption(module, module.getName());
                        moduleTree.setParent(module, server);
                        moduleTree.setChildrenAllowed(module, true);
                        moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE);

                        moduleTree.addItem(flow);
                        moduleTree.setItemCaption(flow, flow.getName());
                        moduleTree.setParent(flow, module);
                        moduleTree.setChildrenAllowed(flow, true);

                        TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION);

                        Set<Component> components = flow.getComponents();

                        for (Component component : components) {
                            moduleTree.addItem(component);
                            moduleTree.setParent(component, flow);
                            moduleTree.setItemCaption(component, component.getName());
                            moduleTree.setChildrenAllowed(component, false);

                            if (component.isConfigurable()) {
                                TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG);
                            } else {
                                TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O);
                            }
                        }
                    }
                }
            }
        }
    });

    this.treeViewBusinessStreamCombo.setWidth("250px");
    layout.addComponent(this.treeViewBusinessStreamCombo);

    Button discoverButton = new Button("Discover");
    discoverButton.setStyleName(ValoTheme.BUTTON_SMALL);

    discoverButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            try {
                topologyService.discover(authentication);
            } catch (DiscoveryException e) {
                Notification.show("An error occurred trying to auto discover modules: " + e.getMessage(),
                        Type.ERROR_MESSAGE);
            }

            Notification.show("Auto discovery complete!");
        }
    });

    Button refreshButton = new Button("Refresh");
    refreshButton.setStyleName(ValoTheme.BUTTON_SMALL);
    refreshButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            refreshTree();
        }
    });

    Button newServerButton = new Button("New Server");
    newServerButton.setStyleName(ValoTheme.BUTTON_SMALL);
    newServerButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().addWindow(new NewServerWindow(topologyService));
        }
    });

    GridLayout buttonLayout = new GridLayout(3, 1);
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(discoverButton);
    buttonLayout.addComponent(refreshButton);
    buttonLayout.addComponent(newServerButton);

    layout.addComponent(buttonLayout);
    layout.addComponent(this.moduleTree);

    this.topologyTreePanel.setContent(layout);
}

From source file:org.ikasan.dashboard.ui.topology.window.ActionedExclusionEventViewWindow.java

License:BSD License

protected Panel createExclusionEventDetailsPanel() {
    Panel exclusionEventDetailsPanel = new Panel();
    exclusionEventDetailsPanel.setSizeFull();
    exclusionEventDetailsPanel.setStyleName("dashboard");

    GridLayout layout = new GridLayout(4, 7);
    layout.setSpacing(true);//from  w ww .  j  ava  2  s. c  om
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

    layout.setWidth("100%");

    Label exclusionEvenDetailsLabel = new Label("Actioned Exclusion Event Details");
    exclusionEvenDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(exclusionEvenDetailsLabel, 0, 0, 3, 0);

    Label label = new Label("Module Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf1 = new TextField();
    tf1.setValue(this.action.getModuleName());
    tf1.setReadOnly(true);
    tf1.setWidth("80%");
    layout.addComponent(tf1, 1, 1);

    label = new Label("Flow Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf2 = new TextField();
    tf2.setValue(this.action.getFlowName());
    tf2.setReadOnly(true);
    tf2.setWidth("80%");
    layout.addComponent(tf2, 1, 2);

    label = new Label("Event Id:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf3 = new TextField();
    tf3.setValue(this.errorOccurrence.getEventLifeIdentifier());
    tf3.setReadOnly(true);
    tf3.setWidth("80%");
    layout.addComponent(tf3, 1, 3);

    label = new Label("Date/Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf4 = new TextField();
    tf4.setValue(new Date(this.action.getTimestamp()).toString());
    tf4.setReadOnly(true);
    tf4.setWidth("80%");
    layout.addComponent(tf4, 1, 4);

    label = new Label("Error URI:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 5);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf5 = new TextField();
    tf5.setValue(this.action.getErrorUri());
    tf5.setReadOnly(true);
    tf5.setWidth("80%");
    layout.addComponent(tf5, 1, 5);

    label = new Label("Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf6 = new TextField();
    if (this.action != null) {
        tf6.setValue(action.getAction());
    }
    tf6.setReadOnly(true);
    tf6.setWidth("80%");
    layout.addComponent(tf6, 3, 1);

    label = new Label("Actioned By:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf7 = new TextField();
    if (this.action != null) {
        tf7.setValue(action.getActionedBy());
    }
    tf7.setReadOnly(true);
    tf7.setWidth("80%");
    layout.addComponent(tf7, 3, 2);

    label = new Label("Actioned Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf8 = new TextField();
    if (this.action != null) {
        tf8.setValue(new Date(action.getTimestamp()).toString());
    }
    tf8.setReadOnly(true);
    tf8.setWidth("80%");
    layout.addComponent(tf8, 3, 3);

    AceEditor eventEditor = new AceEditor();
    eventEditor.setCaption("Event Payload");

    Object event = this.serialiserFactory.getDefaultSerialiser().deserialise(this.action.getEvent());
    eventEditor.setValue(event.toString());
    eventEditor.setReadOnly(true);
    eventEditor.setMode(AceMode.java);
    eventEditor.setTheme(AceTheme.eclipse);
    eventEditor.setWidth("100%");
    eventEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout eventEditorLayout = new HorizontalLayout();
    eventEditorLayout.setSizeFull();
    eventEditorLayout.setMargin(true);
    eventEditorLayout.addComponent(eventEditor);

    AceEditor errorEditor = new AceEditor();
    errorEditor.setCaption("Error Details");
    errorEditor.setValue(this.errorOccurrence.getErrorDetail());
    errorEditor.setReadOnly(true);
    errorEditor.setMode(AceMode.xml);
    errorEditor.setTheme(AceTheme.eclipse);
    errorEditor.setWidth("100%");
    errorEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout errorEditorLayout = new HorizontalLayout();
    errorEditorLayout.setSizeFull();
    errorEditorLayout.setMargin(true);
    errorEditorLayout.addComponent(errorEditor);

    VerticalSplitPanel splitPanel = new VerticalSplitPanel();
    splitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);
    splitPanel.setWidth("100%");
    splitPanel.setHeight(800, Unit.PIXELS);
    splitPanel.setFirstComponent(eventEditorLayout);
    splitPanel.setSecondComponent(errorEditorLayout);

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(220, Unit.PIXELS);
    formLayout.addComponent(layout);

    GridLayout wrapperLayout = new GridLayout(1, 4);
    wrapperLayout.setMargin(true);
    wrapperLayout.setWidth("100%");
    wrapperLayout.addComponent(formLayout);
    wrapperLayout.addComponent(splitPanel);

    exclusionEventDetailsPanel.setContent(wrapperLayout);
    return exclusionEventDetailsPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.CategorisedErrorOccurrenceViewWindow.java

License:BSD License

protected Panel createErrorOccurrenceDetailsPanel() {
    Panel errorOccurrenceDetailsPanel = new Panel();

    GridLayout layout = new GridLayout(4, 7);
    layout.setWidth("100%");
    layout.setSpacing(true);/*w w  w .java2 s  . c  om*/
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

    Label errorOccurrenceDetailsLabel = new Label(" Categorised Error Occurence Details", ContentMode.HTML);
    Label errorCategoryLabel = new Label();

    if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.BLOCKER)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.BAN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.BAN.getHtml() + " Blocker", ContentMode.HTML);
    } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.CRITICAL)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.EXCLAMATION.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.EXCLAMATION.getHtml() + " Critical", ContentMode.HTML);
    } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.MAJOR)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.ARROW_UP.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.ARROW_UP.getHtml() + " Major", ContentMode.HTML);
    } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.TRIVIAL)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.ARROW_DOWN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.ARROW_DOWN.getHtml() + " Trivial", ContentMode.HTML);
    }

    errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 3, 0);

    Label label = new Label("Module Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf1 = new TextField();
    tf1.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getModuleName());
    tf1.setReadOnly(true);
    tf1.setWidth("80%");
    layout.addComponent(tf1, 1, 1);

    label = new Label("Flow Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf2 = new TextField();
    tf2.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowName());
    tf2.setReadOnly(true);
    tf2.setWidth("80%");
    layout.addComponent(tf2, 1, 2);

    label = new Label("Component Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf3 = new TextField();
    tf3.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowElementName());
    tf3.setReadOnly(true);
    tf3.setWidth("80%");
    layout.addComponent(tf3, 1, 3);

    label = new Label("Date/Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf4 = new TextField();
    tf4.setValue(new Date(this.categorisedErrorOccurrence.getErrorOccurrence().getTimestamp()).toString());
    tf4.setReadOnly(true);
    tf4.setWidth("80%");
    layout.addComponent(tf4, 1, 4);

    GridLayout wrapperLayout = new GridLayout(1, 4);
    wrapperLayout.setMargin(true);
    wrapperLayout.setWidth("100%");

    Label errorMessageLabel = new Label("Error Message:");
    errorMessageLabel.setSizeUndefined();
    layout.addComponent(errorMessageLabel, 0, 5);
    layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT);

    final TextArea errorMessageTextArea = new TextArea();
    errorMessageTextArea.setWidth("650px");
    errorMessageTextArea.setRows(6);
    errorMessageTextArea
            .setValue(this.categorisedErrorOccurrence.getErrorCategorisation().getErrorDescription());

    layout.addComponent(errorMessageTextArea, 1, 5, 3, 5);

    AceEditor editor = new AceEditor();
    editor.setCaption("Error Details");
    editor.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getErrorDetail());
    editor.setReadOnly(true);
    editor.setMode(AceMode.xml);
    editor.setTheme(AceTheme.eclipse);
    editor.setHeight(470, Unit.PIXELS);
    editor.setWidth("100%");

    label = new Label("Error Category:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    layout.addComponent(errorCategoryLabel, 3, 1);
    layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_LEFT);

    label = new Label("System Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField systemAction = new TextField();
    systemAction.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getAction());
    systemAction.setReadOnly(true);
    systemAction.setWidth("80%");
    layout.addComponent(systemAction, 3, 2);

    label = new Label("User Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField userAction = new TextField();
    userAction.setValue("");
    userAction.setReadOnly(true);
    userAction.setWidth("80%");
    layout.addComponent(userAction, 3, 3);

    label = new Label("User Action By:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    Label userActionBy = new Label();
    userActionBy.setValue("");
    userActionBy.setReadOnly(true);
    userActionBy.setWidth("80%");
    layout.addComponent(userActionBy, 3, 4);

    AceEditor eventEditor = new AceEditor();
    eventEditor.setCaption("Event Payload");

    if (this.categorisedErrorOccurrence.getErrorOccurrence().getEvent() != null) {
        eventEditor
                .setValue(new String((byte[]) this.categorisedErrorOccurrence.getErrorOccurrence().getEvent()));
    }

    eventEditor.setReadOnly(true);
    eventEditor.setMode(AceMode.java);
    eventEditor.setTheme(AceTheme.eclipse);
    eventEditor.setHeight(470, Unit.PIXELS);
    eventEditor.setWidth("100%");

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(300, Unit.PIXELS);
    formLayout.addComponent(layout);
    wrapperLayout.addComponent(formLayout, 0, 0);

    //      VerticalSplitPanel vSplitPanel = new VerticalSplitPanel();
    //      vSplitPanel.setWidth("100%");
    //      vSplitPanel.setHeight(800, Unit.PIXELS);
    //      vSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);

    TabSheet tabsheet = new TabSheet();
    tabsheet.setSizeFull();

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setSizeFull();
    h1.setMargin(true);
    h1.addComponent(eventEditor);
    //      vSplitPanel.setFirstComponent(h1);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setSizeFull();
    h2.setMargin(true);
    h2.addComponent(editor);
    //      vSplitPanel.setSecondComponent(h2);

    tabsheet.addTab(h2, "Error Details");
    tabsheet.addTab(h1, "Event Payload");

    wrapperLayout.addComponent(tabsheet, 0, 1);

    //      wrapperLayout.addComponent(vSplitPanel, 0, 1);

    errorOccurrenceDetailsPanel.setContent(wrapperLayout);
    return errorOccurrenceDetailsPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java

License:BSD License

@SuppressWarnings("unchecked")
public void populate(Component component) {
    configuration = this.configurationManagement.getConfiguration(component.getConfigurationId());

    if (configuration == null) {
        Server server = component.getFlow().getModule().getServer();

        String url = "http://" + server.getUrl() + ":" + server.getPort()
                + component.getFlow().getModule().getContextRoot() + "/rest/configuration/createConfiguration/"
                + component.getFlow().getModule().getName() + "/" + component.getFlow().getName() + "/"
                + component.getName();//w  w  w .j  a v a2s  .  c  om

        logger.info("Configuration Url: " + url);

        IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
                (String) authentication.getCredentials());

        ClientConfig clientConfig = new ClientConfig();
        clientConfig.register(feature);

        Client client = ClientBuilder.newClient(clientConfig);

        ObjectMapper mapper = new ObjectMapper();

        WebTarget webTarget = client.target(url);

        Response response = webTarget.request().get();

        if (response.getStatus() != 200) {
            response.bufferEntity();

            String responseMessage = response.readEntity(String.class);
            Notification.show("An error was received trying to create configured resource '"
                    + component.getConfigurationId() + "': " + responseMessage, Type.ERROR_MESSAGE);
        }

        configuration = this.configurationManagement.getConfiguration(component.getConfigurationId());
    }

    final List<ConfigurationParameter> parameters = (List<ConfigurationParameter>) configuration
            .getParameters();

    this.layout = new GridLayout(2, parameters.size() + 6);
    this.layout.setSpacing(true);
    this.layout.setColumnExpandRatio(0, .25f);
    this.layout.setColumnExpandRatio(1, .75f);

    this.layout.setWidth("95%");
    this.layout.setMargin(true);

    Label configurationParametersLabel = new Label("Configuration Parameters");
    configurationParametersLabel.setStyleName(ValoTheme.LABEL_HUGE);
    this.layout.addComponent(configurationParametersLabel, 0, 0);

    GridLayout paramLayout = new GridLayout(2, 2);
    paramLayout.setSpacing(true);
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label configuredResourceIdLabel = new Label("Configured Resource Id");
    configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_LARGE);
    configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_BOLD);
    Label configuredResourceIdValueLabel = new Label(configuration.getConfigurationId());
    configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_LARGE);
    configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_BOLD);

    paramLayout.addComponent(configuredResourceIdLabel, 0, 0);
    paramLayout.setComponentAlignment(configuredResourceIdLabel, Alignment.TOP_RIGHT);
    paramLayout.addComponent(configuredResourceIdValueLabel, 1, 0);

    Label configurationDescriptionLabel = new Label("Description:");
    configurationDescriptionLabel.setSizeUndefined();
    paramLayout.addComponent(configurationDescriptionLabel, 0, 1);
    paramLayout.setComponentAlignment(configurationDescriptionLabel, Alignment.TOP_RIGHT);

    TextArea conmfigurationDescriptionTextField = new TextArea();
    conmfigurationDescriptionTextField.setRows(4);
    conmfigurationDescriptionTextField.setWidth("80%");
    paramLayout.addComponent(conmfigurationDescriptionTextField, 1, 1);

    this.layout.addComponent(paramLayout, 0, 1, 1, 1);

    int i = 2;

    for (ConfigurationParameter parameter : parameters) {
        if (parameter instanceof ConfigurationParameterIntegerImpl) {
            this.layout.addComponent(
                    this.createTextAreaPanel(parameter, new IntegerValidator("Must be a valid number")), 0, i,
                    1, i);
        } else if (parameter instanceof ConfigurationParameterStringImpl) {
            this.layout.addComponent(this.createTextAreaPanel(parameter, new StringValidator()), 0, i, 1, i);
        } else if (parameter instanceof ConfigurationParameterBooleanImpl) {
            this.layout.addComponent(this.createTextAreaPanel(parameter, new BooleanValidator()), 0, i, 1, i);
        } else if (parameter instanceof ConfigurationParameterLongImpl) {
            this.layout.addComponent(this.createTextAreaPanel(parameter, new LongValidator()), 0, i, 1, i);
        } else if (parameter instanceof ConfigurationParameterMapImpl) {
            this.layout.addComponent(this.createMapPanel((ConfigurationParameterMapImpl) parameter), 0, i, 1,
                    i);
        } else if (parameter instanceof ConfigurationParameterListImpl) {
            this.layout.addComponent(this.createListPanel((ConfigurationParameterListImpl) parameter), 0, i, 1,
                    i);
        }

        i++;
    }

    Button saveButton = new Button("Save");
    saveButton.addStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                for (TextArea textField : textFields.values()) {
                    textField.validate();
                }
            } catch (InvalidValueException e) {
                e.printStackTrace();
                for (TextArea textField : textFields.values()) {
                    textField.setValidationVisible(true);
                }

                Notification.show("There are errors on the form above", Type.ERROR_MESSAGE);

                return;
            }

            for (ConfigurationParameter parameter : parameters) {
                TextArea textField = ComponentConfigurationWindow.this.textFields.get(parameter.getName());
                TextArea descriptionTextField = ComponentConfigurationWindow.this.descriptionTextFields
                        .get(parameter.getName());

                if (parameter != null && descriptionTextField != null) {
                    parameter.setDescription(descriptionTextField.getValue());
                }

                if (parameter instanceof ConfigurationParameterIntegerImpl) {
                    logger.info("Setting Integer value: " + textField.getValue());

                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(new Integer(textField.getValue()));
                } else if (parameter instanceof ConfigurationParameterStringImpl) {
                    logger.info("Setting String value: " + textField.getValue());
                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(textField.getValue());
                } else if (parameter instanceof ConfigurationParameterBooleanImpl) {
                    logger.info("Setting Boolean value: " + textField.getValue());
                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(new Boolean(textField.getValue()));
                } else if (parameter instanceof ConfigurationParameterLongImpl) {
                    logger.info("Setting Boolean value: " + textField.getValue());
                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(new Long(textField.getValue()));
                } else if (parameter instanceof ConfigurationParameterMapImpl) {
                    ConfigurationParameterMapImpl mapParameter = (ConfigurationParameterMapImpl) parameter;

                    HashMap<String, String> map = new HashMap<String, String>();

                    logger.info("Saving map: " + mapTextFields.size());

                    for (String key : mapTextFields.keySet()) {
                        if (key.startsWith(parameter.getName())) {
                            TextFieldKeyValuePair pair = mapTextFields.get(key);

                            logger.info("Saving for key: " + key);

                            if (pair.key.getValue() != "") {
                                map.put(pair.key.getValue(), pair.value.getValue());
                            }
                        }
                    }

                    parameter.setValue(map);
                } else if (parameter instanceof ConfigurationParameterListImpl) {
                    ConfigurationParameterListImpl mapParameter = (ConfigurationParameterListImpl) parameter;

                    ArrayList<String> map = new ArrayList<String>();

                    for (String key : valueTextFields.keySet()) {
                        if (key.startsWith(parameter.getName())) {
                            map.add(valueTextFields.get(key).getValue());
                        }
                    }

                    parameter.setValue(map);
                }

            }

            ComponentConfigurationWindow.this.configurationManagement.saveConfiguration(configuration);

            Notification notification = new Notification("Saved",
                    "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE);
            notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE);
            notification.show(Page.getCurrent());
        }
    });

    Button deleteButton = new Button("Delete");
    deleteButton.addStyleName(ValoTheme.BUTTON_SMALL);
    deleteButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            DeleteConfigurationAction action = new DeleteConfigurationAction(configuration,
                    configurationManagement, ComponentConfigurationWindow.this);

            IkasanMessageDialog dialog = new IkasanMessageDialog("Delete configuration",
                    "Are you sure you would like to delete this configuration?", action);

            UI.getCurrent().addWindow(dialog);
        }
    });

    GridLayout buttonLayout = new GridLayout(2, 1);
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(saveButton, 0, 0);
    buttonLayout.addComponent(deleteButton, 1, 0);

    this.layout.addComponent(buttonLayout, 0, i, 1, i);
    this.layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    Panel configurationPanel = new Panel();
    configurationPanel.setContent(this.layout);

    this.setContent(configurationPanel);
}

From source file:org.ikasan.dashboard.ui.topology.window.ErrorCategorisationWindow.java

License:BSD License

/**
  * Helper method to initialise this object.
  * /*from w  ww  .  j  av a  2s .  com*/
  * @param message
  */
protected void init() {
    setModal(true);
    setHeight("90%");
    setWidth("90%");

    this.existingCategorisedErrorsTable = new Table();
    this.existingCategorisedErrorsTable.setWidth("100%");
    this.existingCategorisedErrorsTable.setHeight(200, Unit.PIXELS);
    this.existingCategorisedErrorsTable.addContainerProperty("Module Name", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Module Name", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Flow Name", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Flow Name", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Component Name", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Component Name", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Action", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Action", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Error Category", Label.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Error Category", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Error Message", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Error Message", .5f);

    this.existingCategorisedErrorsTable.addStyleName("wordwrap-table");
    this.existingCategorisedErrorsTable.addStyleName(ValoTheme.TABLE_NO_STRIPES);

    this.existingCategorisedErrorsTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
        @Override
        public String getStyle(Table source, Object itemId, Object propertyId) {

            ErrorCategorisationLink errorCategorisationLink = (ErrorCategorisationLink) itemId;

            if (propertyId == null) {
                // Styling for row         

                if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.TRIVIAL)) {
                    return "ikasan-green-small";
                } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.MAJOR)) {
                    return "ikasan-green-small";
                } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.CRITICAL)) {
                    return "ikasan-orange-small";
                } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.BLOCKER)) {
                    return "ikasan-red-small";
                }
            }

            if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.TRIVIAL)) {
                return "ikasan-green-small";
            } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.MAJOR)) {
                return "ikasan-green-small";
            } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.CRITICAL)) {
                return "ikasan-orange-small";
            } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.BLOCKER)) {
                return "ikasan-red-small";
            }

            return "ikasan-small";
        }
    });

    this.existingCategorisedErrorsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent itemClickEvent) {
            logger.info("table item slected: " + (ErrorCategorisationLink) itemClickEvent.getItemId());

            errorCategorisationLink = (ErrorCategorisationLink) itemClickEvent.getItemId();
            errorCategorisation = errorCategorisationLink.getErrorCategorisation();

            errorCategorisationItem = new BeanItem<ErrorCategorisation>(errorCategorisation);
            errorCategorisationLinkItem = new BeanItem<ErrorCategorisationLink>(errorCategorisationLink);

            moduleNameTextField
                    .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("moduleName"));
            flowNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowName"));
            componentNameTextField
                    .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowElementName"));
            errorCategoryCombo.setPropertyDataSource(errorCategorisationItem.getItemProperty("errorCategory"));
            errorMessageTextArea
                    .setPropertyDataSource(errorCategorisationItem.getItemProperty("errorDescription"));
            actionCombo.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("action"));
            exceptionClassTextField
                    .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("exceptionClass"));

            errorMessageTextArea.markAsDirty();
            actionCombo.markAsDirty();
            errorCategoryCombo.markAsDirty();
            componentNameTextField.markAsDirty();
            flowNameTextField.markAsDirty();
            moduleNameTextField.markAsDirty();
        }
    });

    refreshExistingCategorisedErrorsTable();

    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setColumnExpandRatio(0, .25f);
    layout.setColumnExpandRatio(1, .75f);

    if (this.errorCategorisationLink == null) {
        clear();
    }

    Label configuredResourceIdLabel = new Label("Error Categorisation");
    configuredResourceIdLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(configuredResourceIdLabel, 0, 0, 1, 0);

    if (this.module == null && this.flow == null && this.component == null) {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation for server wide errors. This categorisation will be applied"
                + " against errors that occur server wide, that do not have a more focused error categorisation.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    } else if (this.flow == null && this.component == null) {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation for module wide errors. This categorisation will be applied"
                + " against errors that occur within this module, that do not have a more focused error categorisation.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    } else if (this.component == null) {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation for flow wide errors. This categorisation will be applied"
                + " against errors that occur within this flow, that do not have a more focused error categorisation.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    } else {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation against a component. This is the most focused error categorisation"
                + " that can be applied. This categorisation will be applied against errors that occur on this component.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    }

    if (this.module != null) {
        Label moduleNameLabel = new Label();
        moduleNameLabel.setContentMode(ContentMode.HTML);
        moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:");
        moduleNameLabel.setSizeUndefined();
        layout.addComponent(moduleNameLabel, 0, 2);
        layout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT);

        moduleNameTextField.setRequired(true);
        moduleNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("moduleName"));
        moduleNameTextField.setReadOnly(true);
        moduleNameTextField.setWidth("80%");
        layout.addComponent(moduleNameTextField, 1, 2);
    }

    if (this.flow != null) {
        Label flowNameLabel = new Label();
        flowNameLabel.setContentMode(ContentMode.HTML);
        flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:");
        flowNameLabel.setSizeUndefined();
        layout.addComponent(flowNameLabel, 0, 3);
        layout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT);

        flowNameTextField.setRequired(true);
        flowNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowName"));
        flowNameTextField.setReadOnly(true);
        flowNameTextField.setWidth("80%");
        layout.addComponent(flowNameTextField, 1, 3);
    }

    if (this.component != null) {
        Label componentNameLabel = new Label();
        componentNameLabel.setContentMode(ContentMode.HTML);
        componentNameLabel.setValue(VaadinIcons.COG.getHtml() + " Component Name:");
        componentNameLabel.setSizeUndefined();
        layout.addComponent(componentNameLabel, 0, 4);
        layout.setComponentAlignment(componentNameLabel, Alignment.MIDDLE_RIGHT);

        componentNameTextField.setRequired(true);
        componentNameTextField
                .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowElementName"));
        componentNameTextField.setReadOnly(true);
        componentNameTextField.setWidth("80%");
        layout.addComponent(componentNameTextField, 1, 4);
    }

    Label exceptionClassLabel = new Label();
    exceptionClassLabel.setContentMode(ContentMode.HTML);
    exceptionClassLabel.setValue("Exception Class:");
    exceptionClassLabel.setSizeUndefined();
    layout.addComponent(exceptionClassLabel, 0, 5);
    layout.setComponentAlignment(exceptionClassLabel, Alignment.MIDDLE_RIGHT);

    this.exceptionClassTextField.setWidth("80%");
    exceptionClassTextField
            .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("exceptionClass"));
    layout.addComponent(exceptionClassTextField, 1, 5);

    Label actionLabel = new Label();
    actionLabel.setContentMode(ContentMode.HTML);
    actionLabel.setValue("Action:");
    actionLabel.setSizeUndefined();
    layout.addComponent(actionLabel, 0, 6);
    layout.setComponentAlignment(actionLabel, Alignment.MIDDLE_RIGHT);

    Label errorCategoryLabel = new Label("Error Category:");
    errorCategoryLabel.setSizeUndefined();
    layout.addComponent(errorCategoryLabel, 0, 7);
    layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_RIGHT);

    this.setupComboBoxesAndItems();

    Label errorMessageLabel = new Label("Error Message:");
    errorMessageLabel.setSizeUndefined();
    layout.addComponent(errorMessageLabel, 0, 8);
    layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT);

    errorMessageTextArea.addValidator(new StringLengthValidator(
            "You must define an error message between 1 and 2048 characters in length!", 1, 2048, false));
    errorMessageTextArea.setValidationVisible(false);
    errorMessageTextArea.setPropertyDataSource(errorCategorisationItem.getItemProperty("errorDescription"));
    errorMessageTextArea.setRequired(true);
    errorMessageTextArea.setWidth("650px");
    errorMessageTextArea.setRows(8);
    errorMessageTextArea.setRequiredError("An error message is required!");
    layout.addComponent(errorMessageTextArea, 1, 8);

    GridLayout buttonLayouts = new GridLayout(4, 1);
    buttonLayouts.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                errorCategoryCombo.validate();
                errorMessageTextArea.validate();
                actionCombo.validate();
            } catch (InvalidValueException e) {
                errorCategoryCombo.setValidationVisible(true);
                errorMessageTextArea.setValidationVisible(true);
                actionCombo.setValidationVisible(true);

                errorCategoryCombo.markAsDirty();
                errorMessageTextArea.markAsDirty();
                actionCombo.markAsDirty();
                return;
            }

            try {
                errorCategorisationService.save(errorCategorisationItem.getBean());

                errorCategorisationLink.setErrorCategorisation(errorCategorisationItem.getBean());

                errorCategorisationService.save(errorCategorisationLink);
            } catch (Exception e) {
                if (e.getCause() instanceof ConstraintViolationException) {
                    Notification.show(
                            "An error occurred trying to save an error categorisation: Action type must be unique for a given node!",
                            Type.ERROR_MESSAGE);
                } else {
                    Notification.show(
                            "An error occurred trying to save an error categorisation: " + e.getMessage(),
                            Type.ERROR_MESSAGE);
                }
            }

            refreshExistingCategorisedErrorsTable();

            Notification.show("Saved!");
        }
    });

    Button clearButton = new Button("Clear");
    clearButton.setStyleName(ValoTheme.BUTTON_SMALL);
    clearButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            clear();
        }
    });

    Button deleteButton = new Button("Delete");
    deleteButton.setStyleName(ValoTheme.BUTTON_SMALL);
    deleteButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            ErrorCategorisation ec = errorCategorisationLink.getErrorCategorisation();

            errorCategorisationService.delete(errorCategorisationLink);
            errorCategorisationService.delete(ec);
            existingCategorisedErrorsTable.removeItem(errorCategorisationLink);

            clear();
        }
    });

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    buttonLayouts.addComponent(saveButton);
    buttonLayouts.addComponent(clearButton);
    buttonLayouts.addComponent(deleteButton);
    buttonLayouts.addComponent(cancelButton);

    layout.addComponent(buttonLayouts, 0, 9, 1, 9);
    layout.setComponentAlignment(buttonLayouts, Alignment.MIDDLE_CENTER);

    Label existingCategorisationLabel = new Label("Existing Error Categorisations");
    existingCategorisationLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(existingCategorisationLabel, 0, 10, 1, 10);

    Label uniquenessHintLabel = new Label();
    uniquenessHintLabel.setCaptionAsHtml(true);
    uniquenessHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " You can only create one error categorisation per Action type for a give node. If you attempt to create more you will receive an error when"
            + " trying to save.");
    uniquenessHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    uniquenessHintLabel.addStyleName(ValoTheme.LABEL_SMALL);
    layout.addComponent(uniquenessHintLabel, 0, 11, 1, 11);

    Label editHintLabel = new Label();
    editHintLabel.setCaptionAsHtml(true);
    editHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " You can can click on a row in the table below to edit an error categorisation.");
    editHintLabel.addStyleName(ValoTheme.LABEL_BOLD);
    editHintLabel.addStyleName(ValoTheme.LABEL_SMALL);
    layout.addComponent(editHintLabel, 0, 12, 1, 12);

    layout.addComponent(this.existingCategorisedErrorsTable, 0, 13, 1, 13);
    layout.setComponentAlignment(this.existingCategorisedErrorsTable, Alignment.MIDDLE_CENTER);

    Panel paramPanel = new Panel();
    paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    paramPanel.setWidth("100%");
    paramPanel.setContent(layout);

    GridLayout wrapper = new GridLayout();
    //      wrapper.setMargin(true);
    wrapper.setSizeFull();
    wrapper.addComponent(paramPanel);

    this.setContent(wrapper);
}

From source file:org.ikasan.dashboard.ui.topology.window.ErrorOccurrenceViewWindow.java

License:BSD License

protected Panel createErrorOccurrenceDetailsPanel() {
    Panel errorOccurrenceDetailsPanel = new Panel();

    GridLayout layout = new GridLayout(2, 6);
    layout.setSizeFull();/*from   www  . jav a 2s. c  o  m*/
    layout.setSpacing(true);
    layout.setColumnExpandRatio(0, 0.25f);
    layout.setColumnExpandRatio(1, 0.75f);

    Label errorOccurrenceDetailsLabel = new Label("Error Occurence Details");
    errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(errorOccurrenceDetailsLabel);

    Label label = new Label("Module Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf1 = new TextField();
    tf1.setValue(this.errorOccurrence.getModuleName());
    tf1.setReadOnly(true);
    tf1.setWidth("80%");
    layout.addComponent(tf1, 1, 1);

    label = new Label("Flow Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf2 = new TextField();
    tf2.setValue(this.errorOccurrence.getFlowName());
    tf2.setReadOnly(true);
    tf2.setWidth("80%");
    layout.addComponent(tf2, 1, 2);

    label = new Label("Component Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf3 = new TextField();
    tf3.setValue(this.errorOccurrence.getFlowElementName());
    tf3.setReadOnly(true);
    tf3.setWidth("80%");
    layout.addComponent(tf3, 1, 3);

    label = new Label("Date/Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf4 = new TextField();
    tf4.setValue(new Date(this.errorOccurrence.getTimestamp()).toString());
    tf4.setReadOnly(true);
    tf4.setWidth("80%");
    layout.addComponent(tf4, 1, 4);

    label = new Label("Error Message:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 5);
    layout.setComponentAlignment(label, Alignment.TOP_RIGHT);

    TextArea tf5 = new TextArea();
    tf5.setValue(this.errorOccurrence.getErrorMessage());
    tf5.setReadOnly(true);
    tf5.setWidth("80%");
    tf5.setRows(3);
    layout.addComponent(tf5, 1, 5);

    GridLayout wrapperLayout = new GridLayout(1, 4);
    wrapperLayout.setMargin(true);
    wrapperLayout.setWidth("100%");

    TabSheet tabsheet = new TabSheet();
    tabsheet.setSizeFull();

    AceEditor editor = new AceEditor();
    //      editor.setCaption("Error Details");
    editor.setValue(this.errorOccurrence.getErrorDetail());
    editor.setReadOnly(true);
    editor.setMode(AceMode.xml);
    editor.setTheme(AceTheme.eclipse);
    editor.setHeight(470, Unit.PIXELS);
    editor.setWidth("100%");

    AceEditor eventEditor = new AceEditor();
    //      eventEditor.setCaption("Event Payload");

    if (this.errorOccurrence.getEvent() != null) {
        eventEditor.setValue(new String((byte[]) this.errorOccurrence.getEvent()));
    }

    eventEditor.setReadOnly(true);
    eventEditor.setMode(AceMode.java);
    eventEditor.setTheme(AceTheme.eclipse);
    eventEditor.setHeight(470, Unit.PIXELS);
    eventEditor.setWidth("100%");

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(230, Unit.PIXELS);
    formLayout.addComponent(layout);
    wrapperLayout.addComponent(formLayout, 0, 0);

    //      VerticalSplitPanel vSplitPanel = new VerticalSplitPanel();
    //      vSplitPanel.setWidth("100%");
    //      vSplitPanel.setHeight(800, Unit.PIXELS);
    //      vSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setSizeFull();
    h1.setMargin(true);
    h1.addComponent(eventEditor);
    //      vSplitPanel.setFirstComponent(h1);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setSizeFull();
    h2.setMargin(true);
    h2.addComponent(editor);
    //      vSplitPanel.setSecondComponent(h2);

    tabsheet.addTab(h2, "Error Details");
    tabsheet.addTab(h1, "Event Payload");

    wrapperLayout.addComponent(tabsheet, 0, 1);

    errorOccurrenceDetailsPanel.setContent(wrapperLayout);
    return errorOccurrenceDetailsPanel;
}