Example usage for com.vaadin.ui GridLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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();/*from   www .j  av a  2s  .  co m*/

    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.MappingConfigurationPanel.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///from  ww w  . j  a  va  2  s  .c o m
@SuppressWarnings("serial")
protected void init() {
    layout = new GridLayout(5, 6);
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setWidth("100%");

    this.addStyleName(ValoTheme.PANEL_BORDERLESS);

    paramQueriesLayout = new VerticalLayout();

    toolBarLayout = new HorizontalLayout();
    toolBarLayout.setWidth("100%");

    Button linkButton = new Button();

    linkButton.setIcon(VaadinIcons.REPLY_ALL);
    linkButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    linkButton.setDescription("Return to search results");
    linkButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    linkButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer());

            for (IkasanUIView view : topLevelNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }

            saveRequiredMonitor.manageSaveRequired("mappingView");

            navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer());

            for (IkasanUIView view : mappingNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }
        }
    });

    toolBarLayout.addComponent(linkButton);
    toolBarLayout.setExpandRatio(linkButton, 0.865f);

    this.editButton.setIcon(VaadinIcons.EDIT);
    this.editButton.setDescription("Edit the mapping configuration");
    this.editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.editButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.editButton.setVisible(false);
    this.editButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            setEditable(true);
            mappingConfigurationFunctionalGroup.editButtonPressed();
        }
    });

    toolBarLayout.addComponent(this.editButton);
    toolBarLayout.setExpandRatio(this.editButton, 0.045f);

    this.saveButton.setIcon(VaadinIcons.HARDDRIVE);
    this.saveButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.saveButton.setDescription("Save the mapping configuration");
    this.saveButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.saveButton.setVisible(false);
    this.saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                logger.info("Save button clicked!!");
                save();
                setEditable(false);
                Notification.show("Changes Saved!", "", Notification.Type.HUMANIZED_MESSAGE);
                mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed();
            } catch (InvalidValueException e) {
                // We can ignore this one as we have already dealt with the
                // validation messages using the validation framework.
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

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

    toolBarLayout.addComponent(this.saveButton);
    toolBarLayout.setExpandRatio(this.saveButton, 0.045f);

    this.cancelButton.setIcon(VaadinIcons.CLOSE_CIRCLE);
    this.cancelButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.cancelButton.setDescription("Cancel the current edit");
    this.cancelButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.cancelButton.setVisible(false);
    this.cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            setEditable(false);
            mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed();

            Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer());

            for (IkasanUIView view : topLevelNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }

            saveRequiredMonitor.manageSaveRequired("mappingView");

            navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer());

            for (IkasanUIView view : mappingNavigator.getIkasanViews()) {
                navigator.addView(view.getPath(), view.getView());
            }
        }
    });

    toolBarLayout.addComponent(this.cancelButton);
    toolBarLayout.setExpandRatio(this.cancelButton, 0.045f);

    FileDownloader fd = new FileDownloader(this.getMappingConfigurationExportStream());
    fd.extend(exportMappingConfigurationButton);

    this.exportMappingConfigurationButton.setIcon(VaadinIcons.DOWNLOAD_ALT);
    this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.exportMappingConfigurationButton.setDescription("Export the current mapping configuration");
    this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    toolBarLayout.addComponent(this.exportMappingConfigurationButton);
    toolBarLayout.setExpandRatio(this.exportMappingConfigurationButton, 0.045f);

    final GridLayout contentLayout = new GridLayout(1, 2);
    contentLayout.setWidth("100%");

    contentLayout.addComponent(toolBarLayout);
    contentLayout.addComponent(createMappingConfigurationForm());

    VerticalSplitPanel vpanel = new VerticalSplitPanel(contentLayout, createTableLayout(false));
    vpanel.setStyleName(ValoTheme.SPLITPANEL_LARGE);

    paramQueriesLayout.setSpacing(true);

    Label configValueLabels = new Label("Source Configuration Value Queries:");
    layout.addComponent(configValueLabels, 2, 2, 3, 2);
    Panel queryParamsPanel = new Panel();
    queryParamsPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    queryParamsPanel.setHeight(100, Unit.PIXELS);
    queryParamsPanel.setWidth(100, Unit.PERCENTAGE);
    queryParamsPanel.setContent(paramQueriesLayout);
    this.layout.addComponent(queryParamsPanel, 2, 3, 3, 5);

    vpanel.setSplitPosition(325, Unit.PIXELS);
    this.setContent(vpanel);
    this.setSizeFull();
}

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

License:BSD License

/**
 * Helper method to initialise this object.
 *///from w w  w  . j ava  2 s .  co  m
@SuppressWarnings("serial")
protected void init() {
    this.addStyleName(ValoTheme.PANEL_BORDERLESS);

    final Label typeLabel = new Label("Type:");
    final Label sourceContextLabel = new Label("Source Context:");
    final Label targetContextLabel = new Label("Target Context:");

    final GridLayout contentLayout = new GridLayout(4, 6);
    contentLayout.setColumnExpandRatio(0, .15f);
    contentLayout.setColumnExpandRatio(1, .35f);
    contentLayout.setColumnExpandRatio(2, .05f);
    contentLayout.setColumnExpandRatio(3, .45f);
    contentLayout.setWidth("100%");
    contentLayout.setSpacing(true);

    Label errorOccurrenceDetailsLabel = new Label("Mapping Configuration Search");
    errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    contentLayout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 1, 0);

    Label clientLabel = new Label("Client:");
    clientLabel.setSizeUndefined();
    contentLayout.addComponent(clientLabel, 0, 1);
    contentLayout.setComponentAlignment(clientLabel, Alignment.MIDDLE_RIGHT);

    this.clientComboBox.setWidth(80, Unit.PERCENTAGE);
    this.clientComboBox.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                typeComboBox.refresh(((ConfigurationServiceClient) event.getProperty().getValue()).getName());
                sourceContextComboBox
                        .refresh(((ConfigurationServiceClient) event.getProperty().getValue()).getName(), null);
                targetContextComboBox.refresh(
                        ((ConfigurationServiceClient) event.getProperty().getValue()).getName(), null, null);

                typeLabel.setVisible(true);
                typeComboBox.setVisible(true);
            }
        }
    });
    contentLayout.addComponent(clientComboBox, 1, 1);

    typeLabel.setSizeUndefined();
    contentLayout.addComponent(typeLabel, 0, 2);
    contentLayout.setComponentAlignment(typeLabel, Alignment.MIDDLE_RIGHT);
    typeLabel.setVisible(false);

    this.typeComboBox.setWidth(80, Unit.PERCENTAGE);
    this.typeComboBox.setVisible(false);
    this.typeComboBox.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            String client = null;

            if (clientComboBox.getValue() != null) {
                client = ((ConfigurationServiceClient) clientComboBox.getValue()).getName();
            }

            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                sourceContextComboBox.refresh(client,
                        ((ConfigurationType) event.getProperty().getValue()).getName());
                targetContextComboBox.refresh(client,
                        ((ConfigurationType) event.getProperty().getValue()).getName(), null);

                sourceContextLabel.setVisible(true);
                sourceContextComboBox.setVisible(true);
            }
        }
    });
    contentLayout.addComponent(this.typeComboBox, 1, 2);

    sourceContextLabel.setSizeUndefined();
    contentLayout.addComponent(sourceContextLabel, 0, 3);
    contentLayout.setComponentAlignment(sourceContextLabel, Alignment.MIDDLE_RIGHT);
    sourceContextLabel.setVisible(false);

    this.sourceContextComboBox.setWidth(80, Unit.PERCENTAGE);
    this.sourceContextComboBox.setVisible(false);
    this.sourceContextComboBox.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            String type = null;
            String client = null;

            if (typeComboBox.getValue() != null) {
                type = ((ConfigurationType) typeComboBox.getValue()).getName();
            }

            if (clientComboBox.getValue() != null) {
                client = ((ConfigurationServiceClient) clientComboBox.getValue()).getName();
            }

            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                targetContextComboBox.refresh(client, type,
                        ((ConfigurationContext) event.getProperty().getValue()).getName());

                targetContextLabel.setVisible(true);
                targetContextComboBox.setVisible(true);
            }
        }
    });
    contentLayout.addComponent(this.sourceContextComboBox, 1, 3);

    targetContextLabel.setSizeUndefined();
    contentLayout.addComponent(targetContextLabel, 0, 4);
    contentLayout.setComponentAlignment(targetContextLabel, Alignment.MIDDLE_RIGHT);
    targetContextLabel.setVisible(false);

    this.targetContextComboBox.setWidth(80, Unit.PERCENTAGE);
    this.targetContextComboBox.setVisible(false);
    contentLayout.addComponent(this.targetContextComboBox, 1, 4);

    Label actionsLabel = newActions.getActionsLabel();
    actionsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    contentLayout.addComponent(actionsLabel, 2, 0, 3, 0);

    Label createNewClientLabel = newActions.getNewClientLabel();
    createNewClientLabel.setSizeUndefined();
    contentLayout.addComponent(createNewClientLabel, 2, 1);
    contentLayout.setComponentAlignment(createNewClientLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewClientButton(), 3, 1);
    contentLayout.setComponentAlignment(newActions.getNewClientButton(), Alignment.MIDDLE_LEFT);

    Label createNewTypeLabel = newActions.getNewTypeLabel();
    createNewTypeLabel.setSizeUndefined();
    contentLayout.addComponent(createNewTypeLabel, 2, 2);
    contentLayout.setComponentAlignment(createNewTypeLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewTypeButton(), 3, 2);
    contentLayout.setComponentAlignment(newActions.getNewTypeButton(), Alignment.MIDDLE_LEFT);

    Label createContextTypeLabel = newActions.getNewContextLabel();
    createContextTypeLabel.setSizeUndefined();
    contentLayout.addComponent(createContextTypeLabel, 2, 3);
    contentLayout.setComponentAlignment(createContextTypeLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewContextButton(), 3, 3);
    contentLayout.setComponentAlignment(newActions.getNewContextButton(), Alignment.MIDDLE_LEFT);

    Label createMappingConfigurationLabel = newActions.getNewMappingConfigurationLabel();
    createMappingConfigurationLabel.setSizeUndefined();
    contentLayout.addComponent(createMappingConfigurationLabel, 2, 4);
    contentLayout.setComponentAlignment(createMappingConfigurationLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewMappingConfigurationButton(), 3, 4);
    contentLayout.setComponentAlignment(newActions.getNewMappingConfigurationButton(), Alignment.MIDDLE_LEFT);

    Label importMappingConfigurationLabel = newActions.getImportMappingConfigurationLabel();
    importMappingConfigurationLabel.setSizeUndefined();
    contentLayout.addComponent(importMappingConfigurationLabel, 2, 5);
    contentLayout.setComponentAlignment(importMappingConfigurationLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getImportMappingConfigurationButton(), 3, 5);
    contentLayout.setComponentAlignment(newActions.getImportMappingConfigurationButton(),
            Alignment.MIDDLE_LEFT);

    Button button = new Button("Search");
    button.setStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener(searchButtonClickListener);

    contentLayout.addComponent(button, 1, 5);

    this.setContent(contentLayout);
}

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  www .j  av  a 2s .  c o m
        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.panel.TopologyViewPanel.java

License:BSD License

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

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

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

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

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

            return "";
        }
    });

    GridLayout layout = new GridLayout(1, 4);

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

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

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

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

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

                moduleTree.removeAllItems();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    this.topologyTreePanel.setContent(layout);
}

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

License:BSD License

protected Layout createSystemEventPanel() {
    this.systemEventTable = new Table();
    this.systemEventTable.setSizeFull();
    this.systemEventTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    this.systemEventTable.addContainerProperty("Subject", String.class, null);
    this.systemEventTable.setColumnExpandRatio("Subject", .3f);
    this.systemEventTable.addContainerProperty("Action", String.class, null);
    this.systemEventTable.setColumnExpandRatio("Action", .4f);
    this.systemEventTable.addContainerProperty("Actioned By", String.class, null);
    this.systemEventTable.setColumnExpandRatio("Actioned By", .15f);
    this.systemEventTable.addContainerProperty("Timestamp", String.class, null);
    this.systemEventTable.setColumnExpandRatio("Timestamp", .15f);

    this.systemEventTable.setStyleName("wordwrap-table");

    this.systemEventTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override//from w  w  w.j a v  a  2 s . 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) {
            systemEventTable.removeAllItems();

            PagedSearchResult<SystemEvent> systemEvents = systemEventService.listSystemEvents(0, 10000,
                    "timestamp", true, null, null, systemEventFromDate.getValue(), systemEventToDate.getValue(),
                    null);

            for (SystemEvent systemEvent : systemEvents.getPagedResults()) {
                SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
                String timestamp = format.format(systemEvent.getTimestamp());

                systemEventTable.addItem(new Object[] { systemEvent.getSubject(), systemEvent.getAction(),
                        systemEvent.getActor(), timestamp }, systemEvent);
            }
        }
    });

    GridLayout layout = new GridLayout(1, 2);

    GridLayout dateSelectLayout = new GridLayout(2, 2);
    dateSelectLayout.setColumnExpandRatio(0, 0.25f);
    dateSelectLayout.setSpacing(true);
    dateSelectLayout.setWidth("50%");
    this.systemEventFromDate = new PopupDateField("From date");
    this.systemEventFromDate.setResolution(Resolution.MINUTE);
    this.systemEventFromDate.setValue(this.getMidnightToday());
    dateSelectLayout.addComponent(this.systemEventFromDate, 0, 0);
    this.systemEventToDate = new PopupDateField("To date");
    this.systemEventToDate.setResolution(Resolution.MINUTE);
    this.systemEventToDate.setValue(this.getTwentyThreeFixtyNineToday());
    dateSelectLayout.addComponent(this.systemEventToDate, 1, 0);

    dateSelectLayout.addComponent(searchButton, 0, 1, 1, 1);

    HorizontalLayout hSearchLayout = new HorizontalLayout();
    hSearchLayout.setHeight(75, Unit.PIXELS);
    hSearchLayout.setWidth("100%");
    hSearchLayout.addComponent(dateSelectLayout);
    layout.addComponent(hSearchLayout);
    HorizontalLayout hErrorTable = new HorizontalLayout();
    hErrorTable.setWidth("100%");
    hErrorTable.setHeight(600, Unit.PIXELS);
    hErrorTable.addComponent(this.systemEventTable);
    layout.addComponent(hErrorTable);
    layout.setSizeFull();

    return layout;
}

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

License:BSD License

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

    GridLayout layout = new GridLayout(4, 7);
    layout.setSpacing(true);/*from  w  w  w  .  j a  va2s. c o m*/
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

    layout.setWidth("100%");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    exclusionEventDetailsPanel.setContent(wrapperLayout);
    return exclusionEventDetailsPanel;
}

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

License:BSD License

public void init() {
    this.setModal(true);
    this.setResizable(false);
    this.setHeight("90%");
    this.setWidth("90%");

    GridLayout layout = new GridLayout(1, 1);
    layout.setWidth("100%");

    layout.addComponent(createErrorOccurrenceDetailsPanel(), 0, 0);

    this.setContent(layout);
}

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

License:BSD License

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

    GridLayout layout = new GridLayout(4, 7);
    layout.setWidth("100%");
    layout.setSpacing(true);//w  ww  .  j  ava 2s  .  co m
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    wrapperLayout.addComponent(tabsheet, 0, 1);

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

    errorOccurrenceDetailsPanel.setContent(wrapperLayout);
    return errorOccurrenceDetailsPanel;
}

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

License:BSD License

protected Panel createListPanel(final ConfigurationParameterListImpl parameter) {
    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);/*from w  w w . ja va2s.  co m*/
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    final List<String> valueList = parameter.getValue();

    final GridLayout listLayout = new GridLayout(3, (valueList.size() != 0 ? valueList.size() : 1) + 1);
    listLayout.setWidth("450px");
    listLayout.setMargin(true);
    listLayout.setSpacing(true);

    listLayout.setColumnExpandRatio(0, 0.25f);
    listLayout.setColumnExpandRatio(1, 0.5f);
    listLayout.setColumnExpandRatio(2, 0.25f);

    int i = 0;

    for (final String value : valueList) {
        final Label valueLabel = new Label("Value");

        final TextField valueField = new TextField();
        valueField.setValue(value);
        valueField.setWidth("90%");

        listLayout.addComponent(valueLabel, 0, i);
        listLayout.addComponent(valueField, 1, i);

        final String mapKey = parameter.getName() + i;

        this.valueTextFields.put(mapKey, valueField);

        final Button removeButton = new Button("remove");
        removeButton.setStyleName(ValoTheme.BUTTON_LINK);
        removeButton.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                valueList.remove(value);
                listLayout.removeComponent(valueLabel);
                listLayout.removeComponent(valueField);
                listLayout.removeComponent(removeButton);

                valueTextFields.remove(mapKey);
            }
        });

        listLayout.addComponent(removeButton, 2, i);

        i++;
    }

    final Button addButton = new Button("add");
    addButton.setStyleName(ValoTheme.BUTTON_LINK);
    addButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final Label valueLabel = new Label("Value");

            final TextField valueField = new TextField();
            valueField.setWidth("90%");

            listLayout.insertRow(listLayout.getRows());

            listLayout.removeComponent(addButton);
            listLayout.addComponent(valueLabel, 0, listLayout.getRows() - 2);
            listLayout.addComponent(valueField, 1, listLayout.getRows() - 2);

            final String mapKey = parameter.getName() + valueTextFields.size();

            valueTextFields.put(mapKey, valueField);

            final Button removeButton = new Button("remove");
            removeButton.setStyleName(ValoTheme.BUTTON_LINK);
            removeButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    listLayout.removeComponent(valueLabel);
                    listLayout.removeComponent(valueField);

                    listLayout.removeComponent(removeButton);

                    valueTextFields.remove(mapKey);
                }
            });

            listLayout.addComponent(removeButton, 2, listLayout.getRows() - 2);

            listLayout.addComponent(addButton, 0, listLayout.getRows() - 1);
        }
    });

    listLayout.addComponent(addButton, 0, listLayout.getRows() - 1);

    Panel mapPanel = new Panel();
    mapPanel.setStyleName("dashboard");
    mapPanel.setContent(listLayout);

    paramLayout.addComponent(mapPanel, 0, 1, 1, 1);
    paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER);
    paramPanel.setContent(paramLayout);

    Label paramDescriptionLabel = new Label("Description:");
    paramDescriptionLabel.setSizeUndefined();
    TextArea descriptionTextField = new TextArea();
    descriptionTextField.setRows(4);
    descriptionTextField.setWidth("80%");
    descriptionTextField.setId(parameter.getName());

    paramLayout.addComponent(paramDescriptionLabel, 0, 2);
    paramLayout.addComponent(descriptionTextField, 1, 2);
    paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT);

    descriptionTextFields.put(parameter.getName(), descriptionTextField);

    if (parameter.getDescription() != null) {
        descriptionTextField.setValue(parameter.getDescription());
    }

    return paramPanel;
}