Example usage for com.vaadin.ui.themes ValoTheme TABLE_NO_STRIPES

List of usage examples for com.vaadin.ui.themes ValoTheme TABLE_NO_STRIPES

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme TABLE_NO_STRIPES.

Prototype

String TABLE_NO_STRIPES

To view the source code for com.vaadin.ui.themes ValoTheme TABLE_NO_STRIPES.

Click Source Link

Document

Remove the alternating row colors.

Usage

From source file:org.ikasan.dashboard.ui.topology.component.CategorisedErrorTab.java

License:BSD License

public Layout createCategorisedErrorLayout() {
    this.categorizedErrorOccurenceTable = new FilterTable();
    this.categorizedErrorOccurenceTable.setSizeFull();
    this.categorizedErrorOccurenceTable.addContainerProperty("", Label.class, null);
    this.categorizedErrorOccurenceTable.setColumnExpandRatio("", .03f);
    this.categorizedErrorOccurenceTable.addContainerProperty("Module Name", String.class, null);
    this.categorizedErrorOccurenceTable.setColumnExpandRatio("Module Name", .15f);
    this.categorizedErrorOccurenceTable.addContainerProperty("Flow Name", String.class, null);
    this.categorizedErrorOccurenceTable.setColumnExpandRatio("Flow Name", .18f);
    this.categorizedErrorOccurenceTable.addContainerProperty("Component Name", String.class, null);
    this.categorizedErrorOccurenceTable.setColumnExpandRatio("Component Name", .2f);
    this.categorizedErrorOccurenceTable.addContainerProperty("Error Message", String.class, null);
    this.categorizedErrorOccurenceTable.setColumnExpandRatio("Error Message", .33f);
    this.categorizedErrorOccurenceTable.addContainerProperty("Timestamp", String.class, null);
    this.categorizedErrorOccurenceTable.setColumnExpandRatio("Timestamp", .1f);

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

    //      this.categorizedErrorOccurenceTable.setFilterBarVisible(true);

    this.categorizedErrorOccurenceTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override/*from  ww  w.java  2s.  c o  m*/
        public void itemClick(ItemClickEvent itemClickEvent) {
            CategorisedErrorOccurrence errorOccurrence = (CategorisedErrorOccurrence) itemClickEvent
                    .getItemId();
            CategorisedErrorOccurrenceViewWindow errorOccurrenceViewWindow = new CategorisedErrorOccurrenceViewWindow(
                    errorOccurrence, serialiserFactory);

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

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

            CategorisedErrorOccurrence categorisedErrorOccurrence = (CategorisedErrorOccurrence) itemId;

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

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

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

            return "ikasan-small";
        }
    });

    Button searchButton = new Button("Search");
    searchButton.setStyleName(ValoTheme.BUTTON_SMALL);
    searchButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            categorizedErrorOccurenceTable.removeAllItems();

            ArrayList<String> modulesNames = null;

            if (errorOccurenceModules.getItemIds().size() > 0) {
                modulesNames = new ArrayList<String>();
                for (Object module : errorOccurenceModules.getItemIds()) {
                    modulesNames.add(((Module) module).getName());
                }
            }

            ArrayList<String> flowNames = null;

            if (errorOccurenceFlows.getItemIds().size() > 0) {
                flowNames = new ArrayList<String>();
                for (Object flow : errorOccurenceFlows.getItemIds()) {
                    flowNames.add(((Flow) flow).getName());
                }
            }

            ArrayList<String> componentNames = null;

            if (errorOccurenceComponents.getItemIds().size() > 0) {
                componentNames = new ArrayList<String>();
                for (Object component : errorOccurenceComponents.getItemIds()) {
                    componentNames.add(((Component) component).getName());
                }
            }

            if (modulesNames == null && flowNames == null && componentNames == null
                    && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) {
                BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue());

                modulesNames = new ArrayList<String>();

                for (BusinessStreamFlow flow : businessStream.getFlows()) {
                    modulesNames.add(flow.getFlow().getModule().getName());
                }
            }

            String errorCategory = null;

            if (errorCategoryCombo != null && errorCategoryCombo.getValue() != null) {
                errorCategory = (String) errorCategoryCombo.getValue();
            }

            List<CategorisedErrorOccurrence> categorisedErrorOccurences = errorCategorisationService
                    .findCategorisedErrorOccurences(modulesNames, flowNames, componentNames, "", "",
                            errorCategory, errorFromDate.getValue(), errorToDate.getValue());

            for (CategorisedErrorOccurrence categorisedErrorOccurrence : categorisedErrorOccurences) {
                ErrorOccurrence errorOccurrence = categorisedErrorOccurrence.getErrorOccurrence();

                Date date = new Date(errorOccurrence.getTimestamp());
                SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
                String timestamp = format.format(date);

                Label categoryLabel = new Label();

                if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.BLOCKER)) {
                    categoryLabel = new Label(VaadinIcons.BAN.getHtml(), ContentMode.HTML);
                } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.CRITICAL)) {
                    categoryLabel = new Label(VaadinIcons.EXCLAMATION.getHtml(), ContentMode.HTML);
                } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.MAJOR)) {
                    categoryLabel = new Label(VaadinIcons.ARROW_UP.getHtml(), ContentMode.HTML);
                } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.TRIVIAL)) {
                    categoryLabel = new Label(VaadinIcons.ARROW_DOWN.getHtml(), ContentMode.HTML);
                }

                categorizedErrorOccurenceTable
                        .addItem(
                                new Object[] { categoryLabel, errorOccurrence.getModuleName(),
                                        errorOccurrence.getFlowName(), errorOccurrence.getFlowElementName(),
                                        categorisedErrorOccurrence.getErrorCategorisation()
                                                .getErrorDescription(),
                                        timestamp },
                                categorisedErrorOccurrence);
            }
        }
    });

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

    GridLayout layout = new GridLayout(1, 6);
    layout.setMargin(false);
    layout.setHeight(270, Unit.PIXELS);

    GridLayout listSelectLayout = new GridLayout(3, 1);
    listSelectLayout.setSpacing(true);
    listSelectLayout.setSizeFull();

    errorOccurenceModules.setIcon(VaadinIcons.ARCHIVE);
    errorOccurenceModules.addContainerProperty("Module Name", String.class, null);
    errorOccurenceModules.addContainerProperty("", Button.class, null);
    errorOccurenceModules.setSizeFull();
    errorOccurenceModules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    errorOccurenceModules.setDragMode(TableDragMode.ROW);
    errorOccurenceModules.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();

            if (t.getItemId() instanceof Module) {
                final Module module = (Module) t.getItemId();
                logger.info("sourceContainer.getText(): " + module.getName());

                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                // Add the delete functionality to each role that is added
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        errorOccurenceModules.removeItem(module);
                    }
                });

                errorOccurenceModules.addItem(new Object[] { module.getName(), deleteButton }, module);

                for (final Flow flow : module.getFlows()) {
                    deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            errorOccurenceFlows.removeItem(flow);
                        }
                    });

                    errorOccurenceFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow);

                    for (final Component component : flow.getComponents()) {
                        deleteButton = new Button();
                        deleteButton.setIcon(VaadinIcons.TRASH);
                        deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                        deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                        // Add the delete functionality to each role that is added
                        deleteButton.addClickListener(new Button.ClickListener() {
                            public void buttonClick(ClickEvent event) {
                                errorOccurenceComponents.removeItem(component);
                            }
                        });

                        errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton },
                                component);
                    }
                }
            }

        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    listSelectLayout.addComponent(errorOccurenceModules, 0, 0);

    errorOccurenceFlows.setIcon(VaadinIcons.AUTOMATION);
    errorOccurenceFlows.addContainerProperty("Flow Name", String.class, null);
    errorOccurenceFlows.addContainerProperty("", Button.class, null);
    errorOccurenceFlows.setSizeFull();
    errorOccurenceFlows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    errorOccurenceFlows.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();

            if (t.getItemId() instanceof Flow) {
                final Flow flow = (Flow) t.getItemId();
                logger.info("sourceContainer.getText(): " + flow.getName());

                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                // Add the delete functionality to each role that is added
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        errorOccurenceFlows.removeItem(flow);
                    }
                });

                errorOccurenceFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow);

                for (final Component component : flow.getComponents()) {
                    deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            errorOccurenceComponents.removeItem(component);
                        }
                    });

                    errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton },
                            component);
                }
            }

        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    listSelectLayout.addComponent(errorOccurenceFlows, 1, 0);

    errorOccurenceComponents.setIcon(VaadinIcons.COG);
    errorOccurenceComponents.setSizeFull();
    errorOccurenceComponents.addContainerProperty("Component Name", String.class, null);
    errorOccurenceComponents.addContainerProperty("", Button.class, null);
    errorOccurenceComponents.setCellStyleGenerator(new IkasanCellStyleGenerator());
    errorOccurenceComponents.setSizeFull();
    errorOccurenceComponents.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    errorOccurenceComponents.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();

            if (t.getItemId() instanceof Component) {
                final Component component = (Component) t.getItemId();
                logger.info("sourceContainer.getText(): " + component.getName());

                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                // Add the delete functionality to each role that is added
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        errorOccurenceComponents.removeItem(component);
                    }
                });

                errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton }, component);

            }

        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });
    listSelectLayout.addComponent(this.errorOccurenceComponents, 2, 0);

    errorCategoryCombo = new ComboBox("Error Category");
    errorCategoryCombo.setNullSelectionAllowed(true);
    errorCategoryCombo.addItem(ErrorCategorisation.TRIVIAL);
    errorCategoryCombo.setItemIcon(ErrorCategorisation.TRIVIAL, VaadinIcons.ARROW_DOWN);
    errorCategoryCombo.addItem(ErrorCategorisation.MAJOR);
    errorCategoryCombo.setItemIcon(ErrorCategorisation.MAJOR, VaadinIcons.ARROW_UP);
    errorCategoryCombo.addItem(ErrorCategorisation.CRITICAL);
    errorCategoryCombo.setItemIcon(ErrorCategorisation.CRITICAL, VaadinIcons.EXCLAMATION_CIRCLE_O);
    errorCategoryCombo.addItem(ErrorCategorisation.BLOCKER);
    errorCategoryCombo.setItemIcon(ErrorCategorisation.BLOCKER, VaadinIcons.BAN);

    GridLayout dateSelectLayout = new GridLayout(3, 1);
    dateSelectLayout.addComponent(errorCategoryCombo, 2, 0);
    dateSelectLayout.setSizeFull();
    errorFromDate = new PopupDateField("From date");
    errorFromDate.setResolution(Resolution.MINUTE);
    errorFromDate.setValue(this.getMidnightToday());
    dateSelectLayout.addComponent(errorFromDate, 0, 0);
    errorToDate = new PopupDateField("To date");
    errorToDate.setResolution(Resolution.MINUTE);
    errorToDate.setValue(this.getTwentyThreeFixtyNineToday());
    dateSelectLayout.addComponent(errorToDate, 1, 0);

    final VerticalSplitPanel vSplitPanel = new VerticalSplitPanel();
    vSplitPanel.setHeight("95%");

    GridLayout searchLayout = new GridLayout(2, 1);
    searchLayout.setSpacing(true);
    searchLayout.addComponent(searchButton, 0, 0);
    searchLayout.addComponent(clearButton, 1, 0);

    final Button hideFilterButton = new Button();
    hideFilterButton.setIcon(VaadinIcons.MINUS);
    hideFilterButton.setCaption("Hide Filter");
    hideFilterButton.setStyleName(ValoTheme.BUTTON_LINK);
    hideFilterButton.addStyleName(ValoTheme.BUTTON_SMALL);

    final Button showFilterButton = new Button();
    showFilterButton.setIcon(VaadinIcons.PLUS);
    showFilterButton.setCaption("Show Filter");
    showFilterButton.addStyleName(ValoTheme.BUTTON_LINK);
    showFilterButton.addStyleName(ValoTheme.BUTTON_SMALL);
    showFilterButton.setVisible(false);

    final HorizontalLayout hListSelectLayout = new HorizontalLayout();
    hListSelectLayout.setHeight(150, Unit.PIXELS);
    hListSelectLayout.setWidth("100%");
    hListSelectLayout.addComponent(listSelectLayout);

    final HorizontalLayout hDateSelectLayout = new HorizontalLayout();
    hDateSelectLayout.setHeight(40, Unit.PIXELS);
    hDateSelectLayout.setWidth("100%");
    hDateSelectLayout.addComponent(dateSelectLayout);

    final HorizontalLayout hSearchLayout = new HorizontalLayout();
    hSearchLayout.setHeight(30, Unit.PIXELS);
    hSearchLayout.setWidth("100%");
    hSearchLayout.addComponent(searchLayout);
    hSearchLayout.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER);

    hideFilterButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            hideFilterButton.setVisible(false);
            showFilterButton.setVisible(true);
            splitPosition = vSplitPanel.getSplitPosition();
            splitUnit = vSplitPanel.getSplitPositionUnit();
            vSplitPanel.setSplitPosition(0, Unit.PIXELS);
        }
    });

    showFilterButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            hideFilterButton.setVisible(true);
            showFilterButton.setVisible(false);
            vSplitPanel.setSplitPosition(splitPosition, splitUnit);
        }
    });

    GridLayout filterButtonLayout = new GridLayout(2, 1);
    filterButtonLayout.setHeight(25, Unit.PIXELS);
    filterButtonLayout.addComponent(hideFilterButton, 0, 0);
    filterButtonLayout.addComponent(showFilterButton, 1, 0);

    Label filterHintLabel = new Label();
    filterHintLabel.setCaptionAsHtml(true);
    filterHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drag items from the topology tree to the tables below in order to narrow your search.");
    filterHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    filterHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);

    layout.addComponent(filterHintLabel);
    layout.addComponent(hListSelectLayout);
    layout.addComponent(hDateSelectLayout);
    layout.addComponent(hSearchLayout);
    layout.setSizeFull();

    Panel filterPanel = new Panel();
    filterPanel.setHeight(300, Unit.PIXELS);
    filterPanel.setWidth("100%");
    filterPanel.setContent(layout);
    filterPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);

    vSplitPanel.setFirstComponent(filterPanel);

    CssLayout hErrorTable = new CssLayout();
    hErrorTable.setSizeFull();
    hErrorTable.addComponent(this.categorizedErrorOccurenceTable);

    vSplitPanel.setSecondComponent(hErrorTable);
    vSplitPanel.setSplitPosition(310, Unit.PIXELS);

    GridLayout wrapper = new GridLayout(1, 2);
    wrapper.setRowExpandRatio(0, .01f);
    wrapper.setRowExpandRatio(1, .99f);
    wrapper.setSizeFull();
    wrapper.addComponent(filterButtonLayout);
    wrapper.setComponentAlignment(filterButtonLayout, Alignment.MIDDLE_RIGHT);
    wrapper.addComponent(vSplitPanel);

    return wrapper;
}

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

License:BSD License

/**
  * Helper method to initialise this object.
  * /*w  ww.  j av  a2  s .  c o  m*/
  * @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.opencms.ui.components.fileselect.CmsResourceTreeTable.java

License:Open Source License

/**
 * Creates a new instance.<p>//from w  w w .  j  a v  a2  s.c o  m
 *
 * @param cms the CMS context
 * @param root the root resource
 * @param container the data container for the tree
 */
public CmsResourceTreeTable(CmsObject cms, CmsResource root, CmsResourceTreeContainer container) {
    m_cms = cms;
    m_root = root;
    FileSorter sorter = new FileSorter();
    sorter.setSortProperties(container,
            new Object[] { CAPTION_FOLDERS, CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT },
            new boolean[] { true, true });
    container.setItemSorter(sorter);
    setContainerDataSource(container);
    ColumnGenerator captionGenerator = new ColumnGenerator() {

        private static final long serialVersionUID = 1L;

        public Object generateCell(Table source, Object itemId, Object columnId) {

            if (CAPTION_FOLDERS.equals(columnId)) {
                String html = (String) source.getContainerDataSource().getItem(itemId)
                        .getItemProperty(CmsResourceTableProperty.PROPERTY_TREE_CAPTION).getValue();
                Label label = new Label(html, ContentMode.HTML);
                label.setStyleName("o-tree-table-caption");
                return label;
            } else {
                return null;
            }
        }
    };
    addGeneratedColumn(CAPTION_FOLDERS, captionGenerator);
    setVisibleColumns(CAPTION_FOLDERS, CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT);
    setItemCaptionPropertyId(CAPTION_FOLDERS);
    setColumnHeader(CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT,
            CmsVaadinUtils.getMessageText(CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT.getHeaderKey()));
    setColumnHeader(CAPTION_FOLDERS,
            CmsVaadinUtils.getMessageText(CmsResourceTableProperty.PROPERTY_RESOURCE_NAME.getHeaderKey()));

    // hide vertical and horizontal lines and disable alternating row background
    addStyleName(ValoTheme.TABLE_NO_STRIPES);
    addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);

    addExpandListener(new ExpandListener() {

        private static final long serialVersionUID = 1L;

        public void nodeExpand(ExpandEvent event) {

            getTreeContainer().readTreeLevel(m_cms, (CmsUUID) event.getItemId());
            getTreeContainer().updateSort();
            markAsDirtyRecursive(); // required so open / close arrows on folders without contents are rendered correctly
        }

    });

    addCollapseListener(new CollapseListener() {

        private static final long serialVersionUID = 1L;

        public void nodeCollapse(CollapseEvent event) {

            getTreeContainer().removeChildren((CmsUUID) event.getItemId());
        }
    });

    addItemClickListener(new ItemClickListener() {

        private static final long serialVersionUID = 1L;

        public void itemClick(ItemClickEvent event) {

            if (isSelectable(event.getItem())) {
                CmsResource resource = (CmsResource) (event.getItem()
                        .getItemProperty(CmsResourceTreeContainer.PROPERTY_RESOURCE).getValue());
                handleSelection(resource);
            }
        }
    });
    setCellStyleGenerator(new StyleGenerator());

    getTreeContainer().addTreeItem(cms, m_root, null);
    try {
        setCollapsed(m_root.getStructureId(), false);
        markAsDirtyRecursive();

    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage(), e);
    }
}