Example usage for com.vaadin.ui GridLayout setSizeFull

List of usage examples for com.vaadin.ui GridLayout setSizeFull

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setSizeFull.

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:org.ikasan.dashboard.ui.administration.panel.UserManagementPanel.java

License:BSD License

@SuppressWarnings("deprecation")
protected void init() {
    this.setWidth("100%");
    this.setHeight("100%");

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from  ww  w.  ja v  a2 s.  c  om

    Panel securityAdministrationPanel = new Panel();
    securityAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    securityAdministrationPanel.setHeight("100%");
    securityAdministrationPanel.setWidth("100%");

    GridLayout gridLayout = new GridLayout(2, 6);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    gridLayout.setSizeFull();

    Label mappingConfigurationLabel = new Label("User Management");
    mappingConfigurationLabel.setStyleName(ValoTheme.LABEL_HUGE);
    gridLayout.addComponent(mappingConfigurationLabel, 0, 0, 1, 0);

    Label userSearchHintLabel = new Label();
    userSearchHintLabel.setCaptionAsHtml(true);
    userSearchHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Type into the Username, Firstname or Surname fields to find a user.");
    userSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    userSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(userSearchHintLabel, 0, 1, 1, 1);

    Label usernameLabel = new Label("Username:");

    usernameField.setWidth("40%");

    final DragAndDropWrapper usernameFieldWrap = new DragAndDropWrapper(usernameField);
    usernameFieldWrap.setDragStartMode(DragStartMode.COMPONENT);

    firstName = new AutocompleteField<User>();
    firstName.setWidth("40%");
    surname = new AutocompleteField<User>();
    surname.setWidth("40%");
    final TextField department = new TextField();
    department.setWidth("40%");
    final TextField email = new TextField();
    email.setWidth("40%");

    final Table roleTable = new Table();
    roleTable.addContainerProperty("Role", String.class, null);
    roleTable.addContainerProperty("", Button.class, null);
    roleTable.setHeight("520px");
    roleTable.setWidth("250px");

    usernameField.setQueryListener(new AutocompleteQueryListener<User>() {
        @Override
        public void handleUserQuery(AutocompleteField<User> field, String query) {
            for (User user : userService.getUserByUsernameLike(query)) {
                field.addSuggestion(user, user.getUsername());
            }
        }
    });

    usernameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() {
        @Override
        public void onSuggestionPicked(User user) {
            UserManagementPanel.this.user = user;
            firstName.setText(user.getFirstName());
            surname.setText(user.getSurname());
            department.setValue(user.getDepartment());
            email.setValue(user.getEmail());

            final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername());

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

                        userDropTable.removeItem(principal.getName());
                    }
                });

                roleTable.addItem(new Object[] { role.getName(), deleteButton }, role);
            }

            associatedPrincipalsTable.removeAllItems();

            for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) {
                if (!ikasanPrincipal.getType().equals("user")) {
                    associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() },
                            ikasanPrincipal);
                }
            }
        }
    });

    firstName.setQueryListener(new AutocompleteQueryListener<User>() {
        @Override
        public void handleUserQuery(AutocompleteField<User> field, String query) {
            for (User user : userService.getUserByFirstnameLike(query)) {
                field.addSuggestion(user, user.getFirstName() + " " + user.getSurname());
            }
        }
    });

    firstName.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() {
        @Override
        public void onSuggestionPicked(User user) {
            UserManagementPanel.this.user = user;
            usernameField.setText(user.getUsername());
            firstName.setText(user.getFirstName());
            surname.setText(user.getSurname());
            department.setValue(user.getDepartment());
            email.setValue(user.getEmail());

            final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername());

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

                        userDropTable.removeItem(principal.getName());
                    }
                });

                roleTable.addItem(new Object[] { role.getName(), deleteButton }, role);
            }

            associatedPrincipalsTable.removeAllItems();

            for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) {
                if (!ikasanPrincipal.getType().equals("user")) {
                    associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() },
                            ikasanPrincipal);
                }
            }
        }
    });

    surname.setQueryListener(new AutocompleteQueryListener<User>() {
        @Override
        public void handleUserQuery(AutocompleteField<User> field, String query) {
            for (User user : userService.getUserBySurnameLike(query)) {
                field.addSuggestion(user, user.getFirstName() + " " + user.getSurname());
            }
        }
    });

    surname.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() {
        @Override
        public void onSuggestionPicked(User user) {
            UserManagementPanel.this.user = user;
            usernameField.setText(user.getUsername());
            firstName.setText(user.getFirstName());
            surname.setText(user.getSurname());
            department.setValue(user.getDepartment());
            email.setValue(user.getEmail());

            final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername());

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

                        userDropTable.removeItem(principal.getName());
                    }
                });

                roleTable.addItem(new Object[] { role.getName(), deleteButton }, role);

                associatedPrincipalsTable.removeAllItems();

                for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) {
                    if (!ikasanPrincipal.getType().equals("user")) {
                        associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() },
                                ikasanPrincipal);
                    }
                }
            }
        }
    });

    GridLayout formLayout = new GridLayout(2, 5);
    formLayout.setSpacing(true);
    formLayout.setWidth("100%");

    formLayout.setColumnExpandRatio(0, .1f);
    formLayout.setColumnExpandRatio(1, .8f);

    usernameLabel.setSizeUndefined();
    formLayout.addComponent(usernameLabel, 0, 0);
    formLayout.setComponentAlignment(usernameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(usernameFieldWrap, 1, 0);

    Label firstNameLabel = new Label("First name:");
    firstNameLabel.setSizeUndefined();
    formLayout.addComponent(firstNameLabel, 0, 1);
    formLayout.setComponentAlignment(firstNameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(firstName, 1, 1);

    Label surnameLabel = new Label("Surname:");
    surnameLabel.setSizeUndefined();
    formLayout.addComponent(surnameLabel, 0, 2);
    formLayout.setComponentAlignment(surnameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(surname, 1, 2);

    Label departmentLabel = new Label("Department:");
    departmentLabel.setSizeUndefined();
    formLayout.addComponent(departmentLabel, 0, 3);
    formLayout.setComponentAlignment(departmentLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(department, 1, 3);

    Label emailLabel = new Label("Email address:");
    emailLabel.setSizeUndefined();
    formLayout.addComponent(emailLabel, 0, 4);
    formLayout.setComponentAlignment(emailLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(email, 1, 4);

    gridLayout.addComponent(formLayout, 0, 2, 1, 2);

    Label rolesAndGroupsHintLabel1 = new Label();
    rolesAndGroupsHintLabel1.setCaptionAsHtml(true);
    rolesAndGroupsHintLabel1.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Roles table below displays the roles that the user has. Roles can be deleted from this table.");
    rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_TINY);
    rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_LIGHT);
    rolesAndGroupsHintLabel1.setWidth(300, Unit.PIXELS);
    gridLayout.addComponent(rolesAndGroupsHintLabel1, 0, 3, 1, 3);

    Label rolesAndGroupsHintLabel2 = new Label();
    rolesAndGroupsHintLabel2.setCaptionAsHtml(true);
    rolesAndGroupsHintLabel2.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Groups table below displays all the LDAP groups that the user is a member of. You cannot manage these "
            + "from this application.");
    rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_TINY);
    rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_LIGHT);
    rolesAndGroupsHintLabel2.setWidth(300, Unit.PIXELS);
    gridLayout.addComponent(rolesAndGroupsHintLabel2, 0, 4, 1, 4);

    final ClientSideCriterion acceptCriterion = new SourceIs(usernameField);

    userDropTable.addContainerProperty("Members", String.class, null);
    userDropTable.addContainerProperty("", Button.class, null);
    userDropTable.setHeight("715px");
    userDropTable.setWidth("300px");

    userDropTable.setDragMode(TableDragMode.ROW);
    userDropTable.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            if (rolesCombo.getValue() == null) {
                // Do nothing if there is no role selected
                logger.info("Ignoring drop: " + dropEvent);
                return;
            }

            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

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

            final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent();
            logger.info("sourceContainer.getText(): " + sourceContainer.getText());

            Button deleteButton = new Button();

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

            final IkasanPrincipal principal = securityService.findPrincipalByName(sourceContainer.getText());
            final Role roleToRemove = (Role) rolesCombo.getValue();

            deleteButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    userDropTable.removeItem(principal.getName());

                    principal.getRoles().remove(roleToRemove);

                    securityService.savePrincipal(principal);

                    if (UserManagementPanel.this.usernameField.getText().equals(principal.getName())) {
                        roleTable.removeItem(roleToRemove);
                    }
                }
            });

            userDropTable.addItem(new Object[] { sourceContainer.getText(), deleteButton },
                    sourceContainer.getText());

            principal.getRoles().add((Role) rolesCombo.getValue());

            securityService.savePrincipal(principal);

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                Button roleDeleteButton = new Button();
                roleDeleteButton.setIcon(VaadinIcons.TRASH);
                roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                roleDeleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

                roleDeleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

                        userDropTable.removeItem(principal.getName());
                    }
                });

                roleTable.addItem(new Object[] { role.getName(), roleDeleteButton }, role);
            }
        }

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

    gridLayout.addComponent(roleTable, 0, 5);

    this.associatedPrincipalsTable.addContainerProperty("Groups", String.class, null);
    this.associatedPrincipalsTable.addItemClickListener(this.associatedPrincipalItemClickListener);
    associatedPrincipalsTable.setHeight("520px");
    associatedPrincipalsTable.setWidth("400px");

    gridLayout.addComponent(this.associatedPrincipalsTable, 1, 5);

    this.rolesCombo = new ComboBox("Roles");
    this.rolesCombo.setWidth("90%");
    this.rolesCombo.addValueChangeListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            final Role role = (Role) event.getProperty().getValue();

            if (role != null) {
                logger.info("Value changed got Role: " + role);

                List<IkasanPrincipal> principals = securityService.getAllPrincipalsWithRole(role.getName());

                userDropTable.removeAllItems();

                for (final IkasanPrincipal principal : principals) {
                    Button deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            userDropTable.removeItem(principal.getName());

                            principal.getRoles().remove(role);

                            securityService.savePrincipal(principal);

                            if (UserManagementPanel.this.usernameField.getText().equals(principal.getName())) {
                                roleTable.removeItem(role);
                            }
                        }
                    });

                    userDropTable.addItem(new Object[] { principal.getName(), deleteButton },
                            principal.getName());
                }
            }
        }
    });

    Panel roleMemberPanel = new Panel();

    roleMemberPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    roleMemberPanel.setHeight("100%");
    roleMemberPanel.setWidth("100%");

    GridLayout roleMemberLayout = new GridLayout();
    roleMemberLayout.setSpacing(true);
    roleMemberLayout.setWidth("100%");

    Label roleMemberAssociationsLabel = new Label("Role/Member Associations");
    roleMemberAssociationsLabel.setStyleName(ValoTheme.LABEL_HUGE);

    Label userDragHintLabel = new Label();
    userDragHintLabel.setCaptionAsHtml(true);
    userDragHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drop users into the table below to assign them the role.");

    roleMemberLayout.addComponent(roleMemberAssociationsLabel);
    roleMemberLayout.addComponent(userDragHintLabel);
    roleMemberLayout.addComponent(this.rolesCombo);
    roleMemberLayout.addComponent(this.userDropTable);

    roleMemberPanel.setContent(roleMemberLayout);

    securityAdministrationPanel.setContent(gridLayout);
    layout.addComponent(securityAdministrationPanel);

    VerticalLayout roleMemberPanelLayout = new VerticalLayout();
    roleMemberPanelLayout.setWidth("100%");
    roleMemberPanelLayout.setHeight("100%");
    roleMemberPanelLayout.setMargin(true);
    roleMemberPanelLayout.addComponent(roleMemberPanel);
    roleMemberPanelLayout.setSizeFull();

    HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
    hsplit.setFirstComponent(layout);
    hsplit.setSecondComponent(roleMemberPanelLayout);

    // Set the position of the splitter as percentage
    hsplit.setSplitPosition(65, Unit.PERCENTAGE);
    hsplit.setLocked(true);

    this.setContent(hsplit);
}

From source file:org.ikasan.dashboard.ui.framework.panel.ProfilePanel.java

License:BSD License

@SuppressWarnings("deprecation")
protected void init() {
    this.setWidth("100%");
    this.setHeight("100%");

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();/*  w w w.j a v a2 s  .c om*/

    Panel securityAdministrationPanel = new Panel();
    securityAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    securityAdministrationPanel.setHeight("100%");
    securityAdministrationPanel.setWidth("100%");

    GridLayout gridLayout = new GridLayout(2, 6);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    gridLayout.setSizeFull();

    Label mappingConfigurationLabel = new Label("User Profile");
    mappingConfigurationLabel.setStyleName(ValoTheme.LABEL_HUGE);
    gridLayout.addComponent(mappingConfigurationLabel, 0, 0, 1, 0);

    Label usernameLabel = new Label("Username:");

    usernameField.setWidth("65%");

    firstName = new TextField();
    firstName.setWidth("65%");
    firstName.setNullRepresentation("");
    surname = new TextField();
    surname.setWidth("65%");
    surname.setNullRepresentation("");
    department.setWidth("65%");
    department.setNullRepresentation("");
    email.setWidth("65%");
    email.setNullRepresentation("");

    roleTable.addContainerProperty("Role", String.class, null);
    roleTable.addStyleName("ikasan");
    roleTable.addStyleName(ValoTheme.TABLE_SMALL);
    roleTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    roleTable.setHeight("520px");
    roleTable.setWidth("250px");

    GridLayout formLayout = new GridLayout(2, 5);
    formLayout.setSpacing(true);
    formLayout.setWidth("100%");

    formLayout.setColumnExpandRatio(0, .1f);
    formLayout.setColumnExpandRatio(1, .8f);

    usernameLabel.setSizeUndefined();
    formLayout.addComponent(usernameLabel, 0, 0);
    formLayout.setComponentAlignment(usernameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(usernameField, 1, 0);

    Label firstNameLabel = new Label("First name:");
    firstNameLabel.setSizeUndefined();
    formLayout.addComponent(firstNameLabel, 0, 1);
    formLayout.setComponentAlignment(firstNameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(firstName, 1, 1);

    Label surnameLabel = new Label("Surname:");
    surnameLabel.setSizeUndefined();
    formLayout.addComponent(surnameLabel, 0, 2);
    formLayout.setComponentAlignment(surnameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(surname, 1, 2);

    Label departmentLabel = new Label("Department:");
    departmentLabel.setSizeUndefined();
    formLayout.addComponent(departmentLabel, 0, 3);
    formLayout.setComponentAlignment(departmentLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(department, 1, 3);

    Label emailLabel = new Label("Email address:");
    emailLabel.setSizeUndefined();
    formLayout.addComponent(emailLabel, 0, 4);
    formLayout.setComponentAlignment(emailLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(email, 1, 4);

    gridLayout.addComponent(formLayout, 0, 2, 1, 2);

    Label rolesAndGroupsHintLabel1 = new Label();
    rolesAndGroupsHintLabel1.setCaptionAsHtml(true);
    rolesAndGroupsHintLabel1.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Roles table below displays the Ikasan roles that the user has.");
    rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_TINY);
    rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_LIGHT);
    rolesAndGroupsHintLabel1.setWidth(300, Unit.PIXELS);
    gridLayout.addComponent(rolesAndGroupsHintLabel1, 0, 3, 1, 3);

    Label rolesAndGroupsHintLabel2 = new Label();
    rolesAndGroupsHintLabel2.setCaptionAsHtml(true);
    rolesAndGroupsHintLabel2.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Groups table below displays all the LDAP groups that the user is a member of.");

    rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_TINY);
    rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_LIGHT);
    rolesAndGroupsHintLabel2.setWidth(300, Unit.PIXELS);
    gridLayout.addComponent(rolesAndGroupsHintLabel2, 0, 4, 1, 4);

    dashboadActivityTable.addContainerProperty("Action", String.class, null);
    dashboadActivityTable.addContainerProperty("Date/Time", String.class, null);
    dashboadActivityTable.addStyleName("ikasan");
    dashboadActivityTable.addStyleName(ValoTheme.TABLE_SMALL);
    dashboadActivityTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    dashboadActivityTable.setHeight("350px");
    dashboadActivityTable.setWidth("300px");

    this.permissionChangeTable.addContainerProperty("Action", String.class, null);
    this.permissionChangeTable.addContainerProperty("Date/Time", String.class, null);
    this.permissionChangeTable.addStyleName("ikasan");
    this.permissionChangeTable.addStyleName(ValoTheme.TABLE_SMALL);
    this.permissionChangeTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    this.permissionChangeTable.setHeight("350px");
    this.permissionChangeTable.setWidth("300px");

    gridLayout.addComponent(roleTable, 0, 5);

    this.associatedPrincipalsTable.addContainerProperty("Groups", String.class, null);
    this.associatedPrincipalsTable.addItemClickListener(this.associatedPrincipalItemClickListener);
    this.associatedPrincipalsTable.addStyleName("ikasan");
    this.associatedPrincipalsTable.addStyleName(ValoTheme.TABLE_SMALL);
    this.associatedPrincipalsTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    associatedPrincipalsTable.setHeight("520px");
    associatedPrincipalsTable.setWidth("400px");

    gridLayout.addComponent(this.associatedPrincipalsTable, 1, 5);

    Panel roleMemberPanel = new Panel();

    roleMemberPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    roleMemberPanel.setHeight("100%");
    roleMemberPanel.setWidth("100%");

    GridLayout roleMemberLayout = new GridLayout();
    roleMemberLayout.setSpacing(true);
    roleMemberLayout.setWidth("100%");

    Label dashboardActivityLabel = new Label("Dashboard Activity");
    dashboardActivityLabel.setStyleName(ValoTheme.LABEL_HUGE);

    roleMemberLayout.addComponent(dashboardActivityLabel);
    roleMemberLayout.addComponent(this.dashboadActivityTable);

    Label permissionChangeLabel = new Label("User Security Changes");
    permissionChangeLabel.setStyleName(ValoTheme.LABEL_HUGE);

    roleMemberLayout.addComponent(permissionChangeLabel);
    roleMemberLayout.addComponent(this.permissionChangeTable);

    roleMemberPanel.setContent(roleMemberLayout);

    securityAdministrationPanel.setContent(gridLayout);
    layout.addComponent(securityAdministrationPanel);

    VerticalLayout roleMemberPanelLayout = new VerticalLayout();
    roleMemberPanelLayout.setWidth("100%");
    roleMemberPanelLayout.setHeight("100%");
    roleMemberPanelLayout.setMargin(true);
    roleMemberPanelLayout.addComponent(roleMemberPanel);
    roleMemberPanelLayout.setSizeFull();

    HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
    hsplit.setFirstComponent(layout);
    hsplit.setSecondComponent(roleMemberPanelLayout);

    // Set the position of the splitter as percentage
    hsplit.setSplitPosition(65, Unit.PERCENTAGE);
    hsplit.setLocked(true);

    this.setContent(hsplit);
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationView.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///w w  w.  j  av a 2  s  . com
protected void init() {
    this.setSizeFull();

    HorizontalLayout topContainer = new HorizontalLayout();
    topContainer.setSizeFull();
    topContainer.setMargin(true);
    topContainer.addComponent(this.searchPanel);
    HorizontalLayout bottomContainer = new HorizontalLayout();
    bottomContainer.setMargin(true);
    bottomContainer.setSizeFull();
    bottomContainer.addComponent(this.viewComponentContainer);

    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);

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

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

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

    this.verticalSplitPanel = new VerticalSplitPanel(topContainer, bottomContainer);
    this.verticalSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);
    this.verticalSplitPanel.setSizeFull();
    this.verticalSplitPanel.setSplitPosition(260, 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(verticalSplitPanel);

    this.setContent(wrapper);
}

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

License:BSD License

public Component buildServerComponent() {
    Panel component = new Panel();
    component.setSizeFull();/*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.component.ActionedExclusionTab.java

License:BSD License

public Layout createLayout() {
    this.actionedExclusionsTable = new Table();
    this.actionedExclusionsTable.setSizeFull();
    this.actionedExclusionsTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    this.actionedExclusionsTable.addContainerProperty("Module Name", String.class, null);
    this.actionedExclusionsTable.addContainerProperty("Flow Name", String.class, null);
    this.actionedExclusionsTable.addContainerProperty("Action", String.class, null);
    this.actionedExclusionsTable.addContainerProperty("Actioned By", String.class, null);
    this.actionedExclusionsTable.addContainerProperty("Timestamp", String.class, null);

    this.actionedExclusionsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override/*from   w  w  w  .  ja v a 2 s  .c o  m*/
        public void itemClick(ItemClickEvent itemClickEvent) {
            ExclusionEventAction exclusionEventAction = (ExclusionEventAction) itemClickEvent.getItemId();

            ErrorOccurrence errorOccurrence = (ErrorOccurrence) errorReportingService
                    .find(exclusionEventAction.getErrorUri());
            ExclusionEventAction action = hospitalManagementService
                    .getExclusionEventActionByErrorUri(exclusionEventAction.getErrorUri());
            ActionedExclusionEventViewWindow actionExclusionEventViewWindow = new ActionedExclusionEventViewWindow(
                    errorOccurrence, serialiserFactory, action, hospitalManagementService, topologyService);

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

    Button searchButton = new Button("Search");
    searchButton.setStyleName(ValoTheme.BUTTON_SMALL);
    searchButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            actionedExclusionsTable.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());
                }
            }

            List<ExclusionEventAction> exclusionEventActions = hospitalManagementService
                    .getActionedExclusions(modulesNames, flowNames, fromDate.getValue(), toDate.getValue());

            for (ExclusionEventAction exclusionEventAction : exclusionEventActions) {
                Date date = new Date(exclusionEventAction.getTimestamp());
                SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
                String timestamp = format.format(date);

                actionedExclusionsTable
                        .addItem(
                                new Object[] { exclusionEventAction.getModuleName(),
                                        exclusionEventAction.getFlowName(), exclusionEventAction.getAction(),
                                        exclusionEventAction.getActionedBy(), timestamp },
                                exclusionEventAction);
            }
        }
    });

    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);

    GridLayout dateSelectLayout = new GridLayout(2, 1);

    dateSelectLayout.setSizeFull();
    fromDate = new PopupDateField("From date");
    fromDate.setResolution(Resolution.MINUTE);
    fromDate.setValue(this.getMidnightToday());
    dateSelectLayout.addComponent(fromDate, 0, 0);
    toDate = new PopupDateField("To date");
    toDate.setResolution(Resolution.MINUTE);
    toDate.setValue(this.getTwentyThreeFixtyNineToday());
    dateSelectLayout.addComponent(toDate, 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.actionedExclusionsTable);

    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.component.BusinessStreamTab.java

License:BSD License

public Layout createBusinessStreamLayout() {
    this.businessStreamTable = new Table();
    this.businessStreamTable.addContainerProperty("Server Name", String.class, null);
    this.businessStreamTable.addContainerProperty("Module Name", String.class, null);
    this.businessStreamTable.addContainerProperty("Flow Name", String.class, null);
    this.businessStreamTable.addContainerProperty("", Button.class, null);
    this.businessStreamTable.setWidth("100%");
    this.businessStreamTable.setHeight(600, Unit.PIXELS);
    this.businessStreamTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    this.businessStreamTable.setDragMode(TableDragMode.ROW);
    this.businessStreamTable.setDropHandler(new DropHandler() {
        @Override//from w w  w  .ja va2  s  .c om
        public void drop(final DragAndDropEvent dropEvent) {
            final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            if (authentication != null
                    && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication
                            .hasGrantedAuthority(SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) {
                Notification.show("You do not have the privilege to modify a business stream.");
                return;
            }

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

            if (t.getItemId() instanceof Flow) {
                final Flow flow = (Flow) t.getItemId();

                final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue();
                BusinessStreamFlowKey key = new BusinessStreamFlowKey();
                key.setBusinessStreamId(businessStream.getId());
                key.setFlowId(flow.getId());
                final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key);
                businessStreamFlow.setFlow(flow);
                businessStreamFlow.setOrder(businessStreamTable.getItemIds().size());

                if (!businessStream.getFlows().contains(businessStreamFlow)) {
                    businessStream.getFlows().add(businessStreamFlow);

                    topologyService.saveBusinessStream(businessStream);

                    Button deleteButton = new Button();
                    Resource deleteIcon = VaadinIcons.TRASH;
                    deleteButton.setIcon(deleteIcon);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.setDescription("Delete the flow from the business stream.");

                    deleteButton.setData(businessStreamFlow);

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            businessStream.getFlows().remove(businessStreamFlow);

                            topologyService.deleteBusinessStreamFlow(businessStreamFlow);
                            topologyService.saveBusinessStream(businessStream);

                            businessStreamTable.removeItem(businessStreamFlow.getFlow());
                        }
                    });

                    businessStreamTable
                            .addItem(
                                    new Object[] { flow.getModule().getServer().getName(),
                                            flow.getModule().getName(), flow.getName(), deleteButton },
                                    businessStreamFlow);
                }
            } else if (t.getItemId() instanceof Module) {
                final Module sourceContainer = (Module) t.getItemId();

                for (Flow flow : sourceContainer.getFlows()) {

                    final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue();
                    BusinessStreamFlowKey key = new BusinessStreamFlowKey();
                    key.setBusinessStreamId(businessStream.getId());
                    key.setFlowId(flow.getId());
                    final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key);
                    businessStreamFlow.setFlow(flow);
                    businessStreamFlow.setOrder(businessStreamTable.getItemIds().size());

                    if (!businessStream.getFlows().contains(businessStreamFlow)) {
                        businessStream.getFlows().add(businessStreamFlow);

                        topologyService.saveBusinessStream(businessStream);

                        Button deleteButton = new Button();
                        Resource deleteIcon = VaadinIcons.TRASH;

                        deleteButton.setIcon(deleteIcon);
                        deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                        deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                        deleteButton.setDescription("Delete the flow from the business stream.");
                        deleteButton.setData(businessStreamFlow);

                        // Add the delete functionality to each role that is added
                        deleteButton.addClickListener(new Button.ClickListener() {
                            public void buttonClick(ClickEvent event) {
                                businessStream.getFlows().remove(businessStreamFlow);

                                topologyService.deleteBusinessStreamFlow(businessStreamFlow);
                                topologyService.saveBusinessStream(businessStream);

                                businessStreamTable.removeItem(businessStreamFlow.getFlow());
                            }
                        });

                        businessStreamTable.addItem(
                                new Object[] { flow.getModule().getServer().getName(),
                                        flow.getModule().getName(), flow.getName(), deleteButton },
                                businessStreamFlow);
                    }
                }
            } else {
                Notification.show("Only modules or flows can be dragged to this table.");
            }
        }

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

    GridLayout layout = new GridLayout(1, 6);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    Label tableDropHintLabel = new Label();
    tableDropHintLabel.setCaptionAsHtml(true);
    tableDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drag modules or flows from the topology tree to the table below to build a business stream.");
    tableDropHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    tableDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);

    layout.addComponent(tableDropHintLabel);

    GridLayout controlsLayout = new GridLayout(3, 3);
    controlsLayout.setColumnExpandRatio(0, .05f);
    controlsLayout.setColumnExpandRatio(1, .65f);
    controlsLayout.setColumnExpandRatio(2, .3f);

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

    Label newBusinessStreamLabel = new Label("New Business Stream:");
    newBusinessStreamLabel.setSizeUndefined();
    controlsLayout.addComponent(newBusinessStreamLabel, 0, 0);
    controlsLayout.setComponentAlignment(newBusinessStreamLabel, Alignment.MIDDLE_RIGHT);

    Button newButton = new Button();
    newButton.setIcon(VaadinIcons.PLUS);
    newButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    newButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    newButton.setDescription("Create a new business stream.");
    newButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final NewBusinessStreamWindow newBusinessStreamWindow = new NewBusinessStreamWindow();
            UI.getCurrent().addWindow(newBusinessStreamWindow);

            newBusinessStreamWindow.addCloseListener(new Window.CloseListener() {
                // inline close-listener
                public void windowClose(CloseEvent e) {
                    topologyService.saveBusinessStream(newBusinessStreamWindow.getBusinessStream());

                    businessStreamCombo.addItem(newBusinessStreamWindow.getBusinessStream());
                    businessStreamCombo.setItemCaption(newBusinessStreamWindow.getBusinessStream(),
                            newBusinessStreamWindow.getBusinessStream().getName());

                    businessStreamCombo.select(newBusinessStreamWindow.getBusinessStream());

                    businessStreamTable.removeAllItems();
                }
            });
        }
    });

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

    if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            && !authentication.hasGrantedAuthority(SecurityConstants.CREATE_BUSINESS_STREAM_AUTHORITY))) {
        newButton.setVisible(false);
    }

    controlsLayout.addComponent(newButton, 1, 0);

    Label businessStreamLabel = new Label("Business Stream:");
    businessStreamLabel.setSizeUndefined();

    final TextArea descriptionTextArea = new TextArea();
    descriptionTextArea.setReadOnly(true);

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

                descriptionTextArea.setReadOnly(false);
                descriptionTextArea.setValue(businessStream.getDescription());
                descriptionTextArea.setReadOnly(true);

                businessStreamTable.removeAllItems();

                for (final BusinessStreamFlow businessStreamFlow : businessStream.getFlows()) {
                    logger.info("Adding flow: " + businessStreamFlow);
                    Button deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.setDescription("Delete the flow from the business stream.");

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            businessStream.getFlows().remove(businessStreamFlow);

                            topologyService.deleteBusinessStreamFlow(businessStreamFlow);
                            topologyService.saveBusinessStream(businessStream);

                            businessStreamTable.removeItem(businessStreamFlow.getFlow());
                        }
                    });

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

                    if (authentication != null
                            && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
                                    && !authentication.hasGrantedAuthority(
                                            SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) {
                        deleteButton.setVisible(false);
                    }

                    businessStreamTable.addItem(
                            new Object[] { businessStreamFlow.getFlow().getModule().getServer().getName(),
                                    businessStreamFlow.getFlow().getName(),
                                    businessStreamFlow.getFlow().getName(), deleteButton },
                            businessStreamFlow);
                }
            }
        }
    });
    businessStreamCombo.setWidth("100%");

    controlsLayout.addComponent(businessStreamLabel, 0, 1);
    controlsLayout.setComponentAlignment(businessStreamLabel, Alignment.MIDDLE_RIGHT);
    controlsLayout.addComponent(businessStreamCombo, 1, 1);

    Button deleteButton = new Button();
    deleteButton.setIcon(VaadinIcons.TRASH);
    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    deleteButton.setDescription("Delete the selected business stream.");
    deleteButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Collection<BusinessStreamFlow> businessStreamFlows = (Collection<BusinessStreamFlow>) businessStreamTable
                    .getItemIds();

            for (BusinessStreamFlow businessStreamFlow : businessStreamFlows) {
                topologyService.deleteBusinessStreamFlow(businessStreamFlow);
            }

            BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue();

            topologyService.deleteBusinessStream(businessStream);

            businessStreamTable.removeAllItems();

            List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams();

            businessStreamCombo.removeItem(businessStream);

            descriptionTextArea.setValue("");
        }
    });

    if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            && !authentication.hasGrantedAuthority(SecurityConstants.DELETE_BUSINESS_STREAM_AUTHORITY))) {
        deleteButton.setVisible(false);
    }

    controlsLayout.addComponent(deleteButton, 2, 1);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();

    descriptionTextArea.setRows(4);
    descriptionTextArea.setWidth("100%");
    controlsLayout.addComponent(descriptionLabel, 0, 2);
    controlsLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);
    controlsLayout.addComponent(descriptionTextArea, 1, 2);

    layout.addComponent(controlsLayout);
    layout.addComponent(this.businessStreamTable);

    return layout;
}

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// w  ww .  j a  v  a 2  s . 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.component.ErrorOccurrenceTab.java

License:BSD License

public Layout createCategorisedErrorLayout() {
    this.errorOccurenceTable = new Table();
    this.errorOccurenceTable.setSizeFull();
    this.errorOccurenceTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    this.errorOccurenceTable.addStyleName(ValoTheme.TABLE_SMALL);
    this.errorOccurenceTable.addStyleName("ikasan");
    this.errorOccurenceTable.addContainerProperty("Module Name", String.class, null);
    this.errorOccurenceTable.setColumnExpandRatio("Module Name", .14f);
    this.errorOccurenceTable.addContainerProperty("Flow Name", String.class, null);
    this.errorOccurenceTable.setColumnExpandRatio("Flow Name", .18f);
    this.errorOccurenceTable.addContainerProperty("Component Name", String.class, null);
    this.errorOccurenceTable.setColumnExpandRatio("Component Name", .2f);
    this.errorOccurenceTable.addContainerProperty("Error Message", String.class, null);
    this.errorOccurenceTable.setColumnExpandRatio("Error Message", .33f);
    this.errorOccurenceTable.addContainerProperty("Timestamp", String.class, null);
    this.errorOccurenceTable.setColumnExpandRatio("Timestamp", .1f);

    this.errorOccurenceTable.addStyleName("wordwrap-table");

    this.errorOccurenceTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override/*w  ww . ja va  2 s  .  c  o  m*/
        public void itemClick(ItemClickEvent itemClickEvent) {
            ErrorOccurrence errorOccurrence = (ErrorOccurrence) itemClickEvent.getItemId();
            ErrorOccurrenceViewWindow errorOccurrenceViewWindow = new ErrorOccurrenceViewWindow(
                    errorOccurrence);

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

    Button searchButton = new Button("Search");
    searchButton.setStyleName(ValoTheme.BUTTON_SMALL);
    searchButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            errorOccurenceTable.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());
                }
            }

            List<ErrorOccurrence> errorOccurences = errorReportingService.find(modulesNames, flowNames,
                    componentNames, errorFromDate.getValue(), errorToDate.getValue());

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

                errorOccurenceTable.addItem(new Object[] { errorOccurrence.getModuleName(),
                        errorOccurrence.getFlowName(), errorOccurrence.getFlowElementName(),
                        errorOccurrence.getErrorMessage(), timestamp }, errorOccurrence);
            }
        }
    });

    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);

    GridLayout dateSelectLayout = new GridLayout(2, 1);

    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.errorOccurenceTable);

    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.component.ExclusionsTab.java

License:BSD License

public Layout createLayout() {
    this.exclusionsTable = new Table();
    this.exclusionsTable.setSizeFull();
    this.exclusionsTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    this.exclusionsTable.addContainerProperty("Module Name", String.class, null);
    this.exclusionsTable.addContainerProperty("Flow Name", String.class, null);
    this.exclusionsTable.addContainerProperty("Timestamp", String.class, null);

    this.exclusionsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override//from w  w w . j ava2s  .  c om
        public void itemClick(ItemClickEvent itemClickEvent) {
            ExclusionEvent exclusionEvent = (ExclusionEvent) itemClickEvent.getItemId();
            ErrorOccurrence errorOccurrence = (ErrorOccurrence) errorReportingService
                    .find(exclusionEvent.getErrorUri());
            ExclusionEventAction action = hospitalManagementService
                    .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri());
            ExclusionEventViewWindow exclusionEventViewWindow = new ExclusionEventViewWindow(exclusionEvent,
                    errorOccurrence, serialiserFactory, action, hospitalManagementService, topologyService);

            exclusionEventViewWindow.addCloseListener(new Window.CloseListener() {
                // inline close-listener
                public void windowClose(CloseEvent e) {
                    refreshExcludedEventsTable();
                }
            });

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

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

            ArrayList<String> modulesNames = null;

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

            ArrayList<String> flowNames = null;

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

            if (modulesNames == null && flowNames == 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());
                }
            }

            List<ExclusionEvent> exclusionEvents = exclusionManagementService.find(modulesNames, flowNames,
                    fromDate.getValue(), toDate.getValue(), null);

            for (ExclusionEvent exclusionEvent : exclusionEvents) {
                Date date = new Date(exclusionEvent.getTimestamp());
                SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
                String timestamp = format.format(date);

                exclusionsTable.addItem(new Object[] { exclusionEvent.getModuleName(),
                        exclusionEvent.getFlowName(), timestamp }, exclusionEvent);
            }
        }
    });

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

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

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

    exclusionModules.setIcon(VaadinIcons.ARCHIVE);
    exclusionModules.addContainerProperty("Module Name", String.class, null);
    exclusionModules.addContainerProperty("", Button.class, null);
    exclusionModules.setSizeFull();
    exclusionModules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    exclusionModules.setDragMode(TableDragMode.ROW);
    exclusionModules.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) {
                        exclusionModules.removeItem(module);
                    }
                });

                exclusionModules.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) {
                            exclusionFlows.removeItem(flow);
                        }
                    });

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

        }

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

    listSelectLayout.addComponent(exclusionModules, 0, 0);

    exclusionFlows.setIcon(VaadinIcons.AUTOMATION);
    exclusionFlows.addContainerProperty("Flow Name", String.class, null);
    exclusionFlows.addContainerProperty("", Button.class, null);
    exclusionFlows.setSizeFull();
    exclusionFlows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    exclusionFlows.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) {
                        exclusionFlows.removeItem(flow);
                    }
                });

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

        }

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

    listSelectLayout.addComponent(exclusionFlows, 1, 0);

    GridLayout dateSelectLayout = new GridLayout(2, 1);

    dateSelectLayout.setSizeFull();
    fromDate = new PopupDateField("From date");
    fromDate.setResolution(Resolution.MINUTE);
    fromDate.setValue(this.getMidnightToday());
    dateSelectLayout.addComponent(fromDate, 0, 0);
    toDate = new PopupDateField("To date");
    toDate.setResolution(Resolution.MINUTE);
    toDate.setValue(this.getTwentyThreeFixtyNineToday());
    dateSelectLayout.addComponent(toDate, 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.exclusionsTable);

    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.component.WiretapTab.java

License:BSD License

public Layout createWiretapLayout() {
    this.wiretapTable = new Table();
    this.wiretapTable.setSizeFull();
    this.wiretapTable.addStyleName(ValoTheme.TABLE_SMALL);
    this.wiretapTable.addStyleName("ikasan");

    this.wiretapTable.addContainerProperty("Module Name", String.class, null);
    this.wiretapTable.addContainerProperty("Flow Name", String.class, null);
    this.wiretapTable.addContainerProperty("Component Name", String.class, null);
    this.wiretapTable.addContainerProperty("Event Id / Payload Id", String.class, null);
    this.wiretapTable.addContainerProperty("Timestamp", String.class, null);
    this.wiretapTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());

    this.wiretapTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override/*  www  .j a  va2s  . co m*/
        public void itemClick(ItemClickEvent itemClickEvent) {
            WiretapEvent<String> wiretapEvent = (WiretapEvent<String>) itemClickEvent.getItemId();
            WiretapPayloadViewWindow wiretapPayloadViewWindow = new WiretapPayloadViewWindow(wiretapEvent);

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

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

            UI.getCurrent().addWindow(pbWindow);

            wiretapTable.removeAllItems();

            HashSet<String> modulesNames = null;

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

            HashSet<String> flowNames = null;

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

            HashSet<String> componentNames = null;

            if (components.getItemIds().size() > 0) {
                componentNames = new HashSet<String>();
                for (Object component : components.getItemIds()) {

                    componentNames.add("before " + ((Component) component).getName());
                    componentNames.add("after " + ((Component) component).getName());
                }
            }

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

                modulesNames = new HashSet<String>();

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

            String errorCategory = null;

            // TODO Need to take a proper look at the wiretap search interface. We do not need to worry about paging search
            // results with Vaadin.
            PagedSearchResult<WiretapEvent> events = wiretapDao.findWiretapEvents(0, 10000, "timestamp", false,
                    modulesNames, flowNames, componentNames, eventId.getValue(), null, fromDate.getValue(),
                    toDate.getValue(), payloadContent.getValue());

            for (WiretapEvent<String> wiretapEvent : events.getPagedResults()) {
                Date date = new Date(wiretapEvent.getTimestamp());
                SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
                String timestamp = format.format(date);

                wiretapTable
                        .addItem(
                                new Object[] { wiretapEvent.getModuleName(), wiretapEvent.getFlowName(),
                                        wiretapEvent.getComponentName(),
                                        ((WiretapFlowEvent) wiretapEvent).getEventId(), timestamp },
                                wiretapEvent);
            }

            pbWindow.close();
        }
    });

    Button clearButton = new Button("Clear");
    clearButton.setStyleName(ValoTheme.BUTTON_SMALL);
    clearButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            modules.removeAllItems();
            flows.removeAllItems();
            components.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();

    modules.setIcon(VaadinIcons.ARCHIVE);
    modules.addContainerProperty("Module Name", String.class, null);
    modules.addContainerProperty("", Button.class, null);
    modules.setSizeFull();
    modules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    modules.setDragMode(TableDragMode.ROW);
    modules.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) {
                        modules.removeItem(module);
                    }
                });

                modules.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) {
                            flows.removeItem(flow);
                        }
                    });

                    flows.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) {
                                components.removeItem(component);
                            }
                        });

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

        }

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

    listSelectLayout.addComponent(modules, 0, 0);

    flows.setIcon(VaadinIcons.AUTOMATION);
    flows.addContainerProperty("Flow Name", String.class, null);
    flows.addContainerProperty("", Button.class, null);
    flows.setSizeFull();
    flows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    flows.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) {
                        flows.removeItem(flow);
                    }
                });

                flows.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) {
                            components.removeItem(component);
                        }
                    });

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

        }

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

    listSelectLayout.addComponent(flows, 1, 0);

    components.setIcon(VaadinIcons.COG);
    components.setSizeFull();
    components.addContainerProperty("Component Name", String.class, null);
    components.addContainerProperty("", Button.class, null);
    components.setCellStyleGenerator(new IkasanCellStyleGenerator());
    components.setSizeFull();
    components.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    components.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) {
                        components.removeItem(component);
                    }
                });

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

            }

        }

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

    GridLayout dateSelectLayout = new GridLayout(2, 2);
    dateSelectLayout.setColumnExpandRatio(0, 0.25f);
    dateSelectLayout.setColumnExpandRatio(1, 0.75f);
    dateSelectLayout.setSizeFull();
    this.fromDate = new PopupDateField("From date");
    this.fromDate.setResolution(Resolution.MINUTE);
    this.fromDate.setValue(this.getMidnightToday());
    dateSelectLayout.addComponent(this.fromDate, 0, 0);
    this.toDate = new PopupDateField("To date");
    this.toDate.setResolution(Resolution.MINUTE);
    this.toDate.setValue(this.getTwentyThreeFixtyNineToday());
    dateSelectLayout.addComponent(this.toDate, 0, 1);

    this.eventId = new TextField("Event Id");
    this.eventId.setWidth("80%");
    this.payloadContent = new TextField("Payload Content");
    this.payloadContent.setWidth("80%");

    this.eventId.setNullSettingAllowed(true);
    this.payloadContent.setNullSettingAllowed(true);

    dateSelectLayout.addComponent(this.eventId, 1, 0);
    dateSelectLayout.addComponent(this.payloadContent, 1, 1);

    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(80, 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(340, 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.wiretapTable);

    vSplitPanel.setSecondComponent(hErrorTable);
    vSplitPanel.setSplitPosition(350, 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;
}