Example usage for com.vaadin.ui HorizontalLayout setHeight

List of usage examples for com.vaadin.ui HorizontalLayout setHeight

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setHeight.

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

From source file:org.ikasan.dashboard.ui.topology.window.ExclusionEventViewWindow.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);/*ww w  . j a v a  2  s .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("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.exclusionEvent.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.exclusionEvent.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.exclusionEvent.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(exclusionEvent.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);

    final Button resubmitButton = new Button("Re-submit");
    final Button ignoreButton = new Button("Ignore");

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

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

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

            Client client = ClientBuilder.newClient(clientConfig);

            Module module = topologyService.getModuleByName(exclusionEvent.getModuleName());

            if (module == null) {
                Notification
                        .show("Unable to find server information for module we are attempting to re-submit to: "
                                + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE);

                return;
            }

            Server server = module.getServer();

            String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot()
                    + "/rest/resubmission/resubmit/" + exclusionEvent.getModuleName() + "/"
                    + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri();

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

            WebTarget webTarget = client.target(url);
            Response response = webTarget.request()
                    .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM));

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

                String responseMessage = response.readEntity(String.class);
                Notification.show("An error was received trying to resubmit event: " + responseMessage,
                        Type.ERROR_MESSAGE);
            } else {
                Notification.show("Event resumitted successfully.");
                resubmitButton.setVisible(false);
                ignoreButton.setVisible(false);

                ExclusionEventAction action = hospitalManagementService
                        .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri());
                tf6.setReadOnly(false);
                tf7.setReadOnly(false);
                tf8.setReadOnly(false);
                tf6.setValue(action.getAction());
                tf7.setValue(action.getActionedBy());
                tf8.setValue(new Date(action.getTimestamp()).toString());
                tf6.setReadOnly(true);
                tf7.setReadOnly(true);
                tf8.setReadOnly(true);
            }
        }
    });

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

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

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

            Client client = ClientBuilder.newClient(clientConfig);

            Module module = topologyService.getModuleByName(exclusionEvent.getModuleName());

            if (module == null) {
                Notification
                        .show("Unable to find server information for module we are submitting the ignore to: "
                                + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE);

                return;
            }

            Server server = module.getServer();

            String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot()
                    + "/rest/resubmission/ignore/" + exclusionEvent.getModuleName() + "/"
                    + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri();

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

            WebTarget webTarget = client.target(url);
            Response response = webTarget.request()
                    .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM));

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

                String responseMessage = response.readEntity(String.class);
                Notification.show("An error was received trying to resubmit event: " + responseMessage,
                        Type.ERROR_MESSAGE);
            } else {
                Notification.show("Event ignored successfully.");
                resubmitButton.setVisible(false);
                ignoreButton.setVisible(false);

                ExclusionEventAction action = hospitalManagementService
                        .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri());
                tf6.setReadOnly(false);
                tf7.setReadOnly(false);
                tf8.setReadOnly(false);
                tf6.setValue(action.getAction());
                tf7.setValue(action.getActionedBy());
                tf8.setValue(new Date(action.getTimestamp()).toString());
                tf6.setReadOnly(true);
                tf7.setReadOnly(true);
                tf8.setReadOnly(true);
            }
        }
    });

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight("100%");
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(200, Unit.PIXELS);
    buttonLayout.setMargin(true);
    buttonLayout.addComponent(resubmitButton);
    buttonLayout.addComponent(ignoreButton);

    if (this.action == null) {
        layout.addComponent(buttonLayout, 0, 6, 3, 6);
        layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);
    }

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

    if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            && !authentication.hasGrantedAuthority(SecurityConstants.ACTION_EXCLUSIONS_AUTHORITY))) {
        resubmitButton.setVisible(false);
        ignoreButton.setVisible(false);
    }

    AceEditor eventEditor = new AceEditor();
    eventEditor.setCaption("Event Payload");
    logger.info("Setting exclusion event to: " + new String(this.exclusionEvent.getEvent()));
    Object event = this.serialiserFactory.getDefaultSerialiser().deserialise(this.exclusionEvent.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);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setSizeFull();
    h1.setMargin(true);
    h1.addComponent(eventEditorLayout);
    splitPanel.setFirstComponent(eventEditorLayout);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setSizeFull();
    h2.setMargin(true);
    h2.addComponent(errorEditorLayout);
    splitPanel.setSecondComponent(errorEditorLayout);

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(240, 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.investovator.ui.agentgaming.user.DashboardPlayingView.java

License:Open Source License

private void createUI() {

    //Setup Layout
    content = new VerticalLayout();
    content.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    content.setSpacing(true);/* ww  w .  j av a 2 s.c  om*/

    HorizontalLayout row1 = new HorizontalLayout();
    HorizontalLayout row2 = new HorizontalLayout();

    row1.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    row2.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    row1.setWidth("100%");
    row2.setWidth("100%");

    row1.setHeight("60%");
    row1.setHeight("35%");

    content.addComponent(row1);
    content.addComponent(row2);

    content.setExpandRatio(row1, 55);
    content.setExpandRatio(row2, 45);

    //Portfolio Summary
    portfolioSummary = new PortfolioSummary();

    //QuoteUI
    quoteUI = new QuoteUI(companyData);

    watchListTable = getTable();
    currentPriceChart = new MultiStockChart();

    //Adding to main layout
    row1.addComponent(watchListTable);
    row1.addComponent(currentPriceChart);
    row2.addComponent(quoteUI);
    row2.addComponent(portfolioSummary);
    row2.setComponentAlignment(portfolioSummary, Alignment.TOP_CENTER);

    watchListTable.addStyleName("center-caption");
    quoteUI.addStyleName("center-caption");
    currentPriceChart.addStyleName("center-caption");

    content.setSizeFull();

    this.setSizeFull();

    this.setContent(content);

}

From source file:org.jpos.qi.RevisionsPanel.java

License:Open Source License

private void addRevision(Revision r) {
    Label author = new Label("<strong>" + r.getAuthor().getName() + "</strong>", ContentMode.HTML);
    Label date = new Label(r.getDate().toString());
    Label info = new Label(r.getInfo(), ContentMode.HTML);
    author.setWidth("60%");

    HorizontalLayout hl = new HorizontalLayout();
    hl.setHeight("30px");
    hl.setWidth("100%");
    hl.addComponent(author);/*from  w  w w  .j  a v a 2  s  . c  o  m*/
    hl.addComponent(date);

    Layout content = (Layout) getContent();
    content.addComponent(hl);
    content.addComponent(info);
    content.addComponent(new Label("<hr/>", ContentMode.HTML));
}

From source file:org.lunifera.examples.kwiee.erp.module.core.presentation.web.vaadin.ui.KwieeUINavigator.java

License:Open Source License

@SuppressWarnings("serial")
protected void createTasksTable() {

    // create layout
    VerticalLayout tableArea = new VerticalLayout();
    tableArea.setSizeFull();//ww w.  j  av a2  s  .  com
    tabSheet.addTab(tableArea, "Tasks");

    // create table -> expand 1.0
    taskTable = new Table();
    tableArea.addComponent(taskTable);
    tableArea.setExpandRatio(taskTable, 1.0f);
    taskTable.setSizeFull();
    taskTable.setImmediate(true);
    taskTable.setBuffered(false);
    taskTable.setSelectable(true);
    taskTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            showTask((Task) event.getProperty().getValue());
        }
    });

    refreshTasks();

    // create button -> 28px
    HorizontalLayout buttonBar = new HorizontalLayout();
    buttonBar.setSizeFull();
    buttonBar.setMargin(true);
    buttonBar.setSpacing(true);
    buttonBar.setHeight("48px");
    tableArea.addComponent(buttonBar);

    refreshTasksButton = new Button("Refresh");
    buttonBar.addComponent(refreshTasksButton);
    buttonBar.setComponentAlignment(refreshTasksButton, Alignment.MIDDLE_LEFT);
    refreshTasksButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            refreshTasks();
        }
    });
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorOptions.java

License:Open Source License

/**
 * Initializes the lower right component {@link #m_lowerRightComponent}, with all its components, i.e.,
 * the "Add key" input field {@link #m_addKeyInput} and the "Add key" button.
 *//*from   w  ww .j a  va 2 s. co  m*/
private void initLowerRightComponent() {

    initAddKeyInput();

    Component addKeyButton = createAddKeyButton();
    HorizontalLayout addKeyWrapper = new HorizontalLayout(addKeyButton);
    addKeyWrapper.setComponentAlignment(addKeyButton, Alignment.MIDDLE_CENTER);
    addKeyWrapper.setHeight("100%");
    addKeyWrapper.setWidth(CmsMessageBundleEditorTypes.OPTION_COLUMN_WIDTH_PX);

    FormLayout inputForm = new FormLayout(m_addKeyInput);
    inputForm.setWidth("100%");
    HorizontalLayout lowerRight = new HorizontalLayout();
    lowerRight.setWidth("100%");
    lowerRight.addComponent(inputForm);
    lowerRight.addComponent(addKeyWrapper);
    lowerRight.setExpandRatio(inputForm, 1f);
    m_lowerRightComponent = lowerRight;

}

From source file:org.opennms.features.vaadin.dashboard.dashlets.KscDashlet.java

License:Open Source License

@Override
public DashletComponent getWallboardComponent() {
    if (m_wallboardComponent == null) {
        m_wallboardComponent = new AbstractDashletComponent() {
            private GridLayout m_gridLayout = new GridLayout();

            {/* w w w.j  a  va 2s . com*/
                m_gridLayout.setCaption(getName());
                m_gridLayout.setSizeFull();
                m_gridLayout.setColumns(1);
                m_gridLayout.setRows(1);
            }

            @Override
            public void refresh() {
                m_gridLayout.removeAllComponents();

                /**
                 * initializing the parameters
                 */
                int columns = 0;
                int rows = 0;

                String kscReportName = getDashletSpec().getParameters().get("kscReport");

                if (kscReportName == null || "".equals(kscReportName)) {
                    return;
                }

                KSC_PerformanceReportFactory kscPerformanceReportFactory = KSC_PerformanceReportFactory
                        .getInstance();

                Map<Integer, String> reportsMap = kscPerformanceReportFactory.getReportList();

                int kscReportId = -1;

                for (Map.Entry<Integer, String> entry : reportsMap.entrySet()) {

                    if (kscReportName.equals(entry.getValue())) {
                        kscReportId = entry.getKey();
                        break;
                    }
                }

                if (kscReportId == -1) {
                    return;
                }

                Report kscReport = kscPerformanceReportFactory.getReportByIndex(kscReportId);

                columns = kscReport.getGraphs_per_line();

                if (columns == 0) {
                    columns = 1;
                }

                rows = kscReport.getGraphCount() / columns;

                if (rows == 0) {
                    rows = 1;
                }

                if (kscReport.getGraphCount() % columns > 0) {
                    rows++;
                }

                /**
                 * setting new columns/rows
                 */
                m_gridLayout.setColumns(columns);
                m_gridLayout.setRows(rows);

                int i = 0;

                /**
                 * adding the components
                 */

                Page.getCurrent().getStyles().add(
                        ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }");
                Page.getCurrent().getStyles().add(
                        ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }");
                Page.getCurrent().getStyles().add(".margin { margin:5px; }");

                for (int y = 0; y < m_gridLayout.getRows(); y++) {
                    for (int x = 0; x < m_gridLayout.getColumns(); x++) {

                        if (i < kscReport.getGraphCount()) {
                            Graph graph = kscReport.getGraph(i);

                            Map<String, String> data = getDataForResourceId(graph.getNodeId(),
                                    graph.getResourceId());

                            Calendar beginTime = Calendar.getInstance();
                            Calendar endTime = Calendar.getInstance();

                            KSC_PerformanceReportFactory.getBeginEndTime(graph.getTimespan(), beginTime,
                                    endTime);

                            GraphContainer graphContainer = getGraphContainer(graph, beginTime.getTime(),
                                    endTime.getTime());

                            VerticalLayout verticalLayout = new VerticalLayout();

                            HorizontalLayout horizontalLayout = new HorizontalLayout();
                            horizontalLayout.addStyleName("box");
                            horizontalLayout.setWidth("100%");
                            horizontalLayout.setHeight("42px");

                            VerticalLayout leftLayout = new VerticalLayout();
                            leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                            leftLayout.addStyleName("margin");

                            Label labelTitle;

                            if (graph.getTitle() == null || "".equals(graph.getTitle())) {
                                labelTitle = new Label("&nbsp;");
                                labelTitle.setContentMode(ContentMode.HTML);
                            } else {
                                labelTitle = new Label(graph.getTitle());
                            }

                            labelTitle.addStyleName("text");

                            Label labelFrom = new Label("From: " + beginTime.getTime().toString());
                            labelFrom.addStyleName("text");

                            Label labelTo = new Label("To: " + endTime.getTime().toString());
                            labelTo.addStyleName("text");

                            Label labelNodeLabel = new Label(data.get("nodeLabel"));
                            labelNodeLabel.addStyleName("text");

                            Label labelResourceLabel = new Label(
                                    data.get("resourceTypeLabel") + ": " + data.get("resourceLabel"));
                            labelResourceLabel.addStyleName("text");

                            leftLayout.addComponent(labelTitle);
                            leftLayout.addComponent(labelFrom);
                            leftLayout.addComponent(labelTo);

                            VerticalLayout rightLayout = new VerticalLayout();
                            rightLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                            rightLayout.addStyleName("margin");

                            rightLayout.addComponent(labelNodeLabel);
                            rightLayout.addComponent(labelResourceLabel);

                            horizontalLayout.addComponent(leftLayout);
                            horizontalLayout.addComponent(rightLayout);

                            horizontalLayout.setExpandRatio(leftLayout, 1.0f);
                            horizontalLayout.setExpandRatio(rightLayout, 1.0f);

                            verticalLayout.addComponent(horizontalLayout);
                            verticalLayout.addComponent(graphContainer);
                            verticalLayout.setWidth(DEFAULT_GRAPH_WIDTH_PX, Unit.PIXELS);

                            m_gridLayout.addComponent(verticalLayout, x, y);

                            verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
                            verticalLayout.setComponentAlignment(graphContainer, Alignment.MIDDLE_CENTER);
                            m_gridLayout.setComponentAlignment(verticalLayout, Alignment.MIDDLE_CENTER);
                        }
                        i++;
                    }
                }
            }

            @Override
            public Component getComponent() {
                return m_gridLayout;
            }
        };
    }

    return m_wallboardComponent;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.KscDashlet.java

License:Open Source License

@Override
public DashletComponent getDashboardComponent() {
    if (m_dashboardComponent == null) {
        m_dashboardComponent = new AbstractDashletComponent() {
            private VerticalLayout m_verticalLayout = new VerticalLayout();

            {/*from ww  w  .  ja va2  s.co  m*/
                m_verticalLayout.setCaption(getName());
                m_verticalLayout.setSizeFull();
            }

            @Override
            public void refresh() {
                m_verticalLayout.removeAllComponents();

                String kscReportName = getDashletSpec().getParameters().get("kscReport");

                if (kscReportName == null || "".equals(kscReportName)) {
                    return;
                }

                KSC_PerformanceReportFactory kscPerformanceReportFactory = KSC_PerformanceReportFactory
                        .getInstance();

                Map<Integer, String> reportsMap = kscPerformanceReportFactory.getReportList();

                int kscReportId = -1;

                for (Map.Entry<Integer, String> entry : reportsMap.entrySet()) {

                    if (kscReportName.equals(entry.getValue())) {
                        kscReportId = entry.getKey();
                        break;
                    }
                }

                if (kscReportId == -1) {
                    return;
                }

                Report kscReport = kscPerformanceReportFactory.getReportByIndex(kscReportId);

                Page.getCurrent().getStyles().add(
                        ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }");
                Page.getCurrent().getStyles().add(
                        ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }");
                Page.getCurrent().getStyles().add(".margin { margin:5px; }");

                Accordion accordion = new Accordion();
                accordion.setSizeFull();
                m_verticalLayout.addComponent(accordion);

                for (Graph graph : kscReport.getGraph()) {
                    Map<String, String> data = getDataForResourceId(graph.getNodeId(), graph.getResourceId());

                    Calendar beginTime = Calendar.getInstance();
                    Calendar endTime = Calendar.getInstance();

                    KSC_PerformanceReportFactory.getBeginEndTime(graph.getTimespan(), beginTime, endTime);

                    GraphContainer graphContainer = getGraphContainer(graph, beginTime.getTime(),
                            endTime.getTime());

                    VerticalLayout verticalLayout = new VerticalLayout();

                    HorizontalLayout horizontalLayout = new HorizontalLayout();
                    horizontalLayout.addStyleName("box");
                    horizontalLayout.setWidth("100%");
                    horizontalLayout.setHeight("42px");

                    VerticalLayout leftLayout = new VerticalLayout();
                    leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                    leftLayout.addStyleName("margin");

                    Label labelTitle;

                    if (graph.getTitle() == null || "".equals(graph.getTitle())) {
                        labelTitle = new Label("&nbsp;");
                        labelTitle.setContentMode(ContentMode.HTML);
                    } else {
                        labelTitle = new Label(graph.getTitle());
                    }

                    labelTitle.addStyleName("text");

                    Label labelFrom = new Label("From: " + beginTime.getTime().toString());
                    labelFrom.addStyleName("text");

                    Label labelTo = new Label("To: " + endTime.getTime().toString());
                    labelTo.addStyleName("text");

                    Label labelNodeLabel = new Label(data.get("nodeLabel"));
                    labelNodeLabel.addStyleName("text");

                    Label labelResourceLabel = new Label(
                            data.get("resourceTypeLabel") + ": " + data.get("resourceLabel"));
                    labelResourceLabel.addStyleName("text");

                    leftLayout.addComponent(labelTitle);
                    leftLayout.addComponent(labelFrom);
                    leftLayout.addComponent(labelTo);

                    VerticalLayout rightLayout = new VerticalLayout();
                    rightLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                    rightLayout.addStyleName("margin");

                    rightLayout.addComponent(labelNodeLabel);
                    rightLayout.addComponent(labelResourceLabel);

                    horizontalLayout.addComponent(leftLayout);
                    horizontalLayout.addComponent(rightLayout);

                    horizontalLayout.setExpandRatio(leftLayout, 1.0f);
                    horizontalLayout.setExpandRatio(rightLayout, 1.0f);

                    verticalLayout.addComponent(horizontalLayout);
                    verticalLayout.addComponent(graphContainer);
                    verticalLayout.setWidth(DEFAULT_GRAPH_WIDTH_PX, Unit.PIXELS);

                    accordion.addTab(verticalLayout, data.get("nodeLabel") + "/" + data.get("resourceTypeLabel")
                            + ": " + data.get("resourceLabel"));

                    verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
                    verticalLayout.setComponentAlignment(graphContainer, Alignment.MIDDLE_CENTER);
                    verticalLayout.setMargin(true);
                }
            }

            @Override
            public Component getComponent() {
                return m_verticalLayout;
            }
        };
    }

    return m_dashboardComponent;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.RrdDashlet.java

License:Open Source License

/**
 * Returns the graph component for a given graph of the {@link DashletSpec}.
 *
 * @param i              the entry id/*  w w w  . j a va  2 s .com*/
 * @param width          the width
 * @param height         the height
 * @param timeFrameType  the timeframe type
 * @param timeFrameValue the timeframe value
 * @return the component
 */
private Component getGraphComponent(int i, int width, int height, int timeFrameType, int timeFrameValue) {
    String graphTitle = getDashletSpec().getParameters().get("graphLabel" + i);
    String graphName = RrdGraphHelper
            .getGraphNameFromQuery(getDashletSpec().getParameters().get("graphUrl" + i));
    String resourceId = getDashletSpec().getParameters().get("resourceId" + i);

    GraphContainer graph = new GraphContainer(graphName, resourceId);
    graph.setTitle(graphTitle);
    // Setup the time span
    Calendar cal = new GregorianCalendar();
    graph.setEnd(cal.getTime());
    cal.add(timeFrameType, -timeFrameValue);
    graph.setStart(cal.getTime());
    // Use all of the available width
    graph.setWidthRatio(1.0d);

    VerticalLayout verticalLayout = new VerticalLayout();

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.addStyleName("box");
    horizontalLayout.setWidth("100%");
    horizontalLayout.setHeight("42px");

    VerticalLayout leftLayout = new VerticalLayout();
    leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    leftLayout.addStyleName("margin");

    Label labelFrom = new Label(getDashletSpec().getParameters().get("nodeLabel" + i));
    labelFrom.addStyleName("text");

    Label labelTo = new Label(getDashletSpec().getParameters().get("resourceTypeLabel" + i) + ": "
            + getDashletSpec().getParameters().get("resourceLabel" + i));
    labelTo.addStyleName("text");

    leftLayout.addComponent(labelFrom);
    leftLayout.addComponent(labelTo);

    horizontalLayout.addComponent(leftLayout);
    horizontalLayout.setExpandRatio(leftLayout, 1.0f);

    verticalLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(graph);
    verticalLayout.setWidth(width, Unit.PIXELS);

    verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
    verticalLayout.setComponentAlignment(graph, Alignment.MIDDLE_CENTER);
    verticalLayout.setMargin(true);

    return verticalLayout;
}

From source file:org.ow2.sirocco.cloudmanager.AddressView.java

License:Open Source License

public AddressView() {
    this.setSizeFull();

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);// w  ww  . j ava2  s.c  o m
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Allocate Address...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            if (AddressView.this.addressAllocationWizard.init(AddressView.this)) {
                UI.getCurrent().addWindow(AddressView.this.addressAllocationWizard);
            }
        }
    });
    actionButtonHeader.addComponent(button);

    this.associateAddressButton = new Button("Associate");
    this.associateAddressButton.setEnabled(false);
    this.associateAddressButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedAddressIds = (Set<?>) AddressView.this.addressTable.getValue();
            final String addressId = (String) Iterables.getOnlyElement(selectedAddressIds);
            List<AddressAssociateDialog.MachineChoice> choices = new ArrayList<>();
            Address address = null;
            try {
                address = AddressView.this.networkManager.getAddressByUuid(addressId);
                List<Machine> machines = AddressView.this.machineManager.getMachines(
                        new QueryParams.Builder().filterByProvider(address.getCloudProviderAccount().getUuid())
                                .filterByLocation(address.getLocation().getUuid()).build())
                        .getItems();
                for (Machine machine : machines) {
                    MachineChoice machineChoice = new MachineChoice();
                    machineChoice.id = machine.getUuid();
                    machineChoice.name = machine.getName();
                    choices.add(machineChoice);
                }

            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Internal error", e);
            }

            final String ipAddress = address.getIp();
            AddressAssociateDialog addressAssociateDialog = new AddressAssociateDialog(choices,
                    new AddressAssociateDialog.DialogCallback() {

                        @Override
                        public void response(final String machineId) {
                            try {
                                AddressView.this.networkManager.addAddressToMachine(machineId, ipAddress);
                            } catch (CloudProviderException e) {
                                Util.diplayErrorMessageBox("Address association failure", e);
                            }
                        }
                    });
            UI.getCurrent().addWindow(addressAssociateDialog);
        }
    });
    actionButtonHeader.addComponent(this.associateAddressButton);

    this.disassociateAddressButton = new Button("Disassociate");
    this.disassociateAddressButton.setEnabled(false);
    this.disassociateAddressButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedAddressIds = (Set<?>) AddressView.this.addressTable.getValue();
            String addressId = (String) selectedAddressIds.iterator().next();
            try {
                Address address = AddressView.this.networkManager.getAddressByUuid(addressId);
                AddressView.this.networkManager.removeAddressFromMachine(address.getResource().getUuid(),
                        address.getIp());
            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Address disassociation failure", e);
            }
        }
    });
    actionButtonHeader.addComponent(this.disassociateAddressButton);

    this.releaseAddressButton = new Button("Release");
    this.releaseAddressButton.setIcon(new ThemeResource("img/delete.png"));
    this.releaseAddressButton.setEnabled(false);
    this.releaseAddressButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedAddressIds = (Set<?>) AddressView.this.addressTable.getValue();
            String ip = AddressView.this.addresses.getItem(selectedAddressIds.iterator().next()).getBean()
                    .getIp();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Release Address",
                    "Are you sure you want to release address " + ip + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedAddressIds) {
                                    try {
                                        AddressView.this.networkManager.deleteAddress(id.toString());
                                    } catch (CloudProviderException e) {
                                        Util.diplayErrorMessageBox("Address delete failure", e);
                                    }
                                }
                                AddressView.this.refresh();
                            }
                        }
                    });
            AddressView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.releaseAddressButton);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            AddressView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    this.addComponent(actionButtonHeader);
    this.addComponent(this.addressTable = this.createAddressTable());
    this.setExpandRatio(this.addressTable, 1.0f);
}

From source file:org.ow2.sirocco.cloudmanager.CloudProviderView.java

License:Open Source License

public CloudProviderView() {
    this.setSizeFull();

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();//from w  w  w . j av  a2 s. c  om

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Add Provider Account...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            CloudProviderView.this.providerAccountCreationWizard.init(CloudProviderView.this);
            UI.getCurrent().addWindow(CloudProviderView.this.providerAccountCreationWizard);
        }
    });
    actionButtonHeader.addComponent(button);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            CloudProviderView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    verticalLayout.addComponent(actionButtonHeader);
    verticalLayout.addComponent(this.providerAccountTable = this.createCloudProviderAccountTable());
    verticalLayout.setExpandRatio(this.providerAccountTable, 1.0f);

    this.setFirstComponent(verticalLayout);
    this.setSecondComponent(this.detailView = new ProviderAccountDetailView(this));
    this.setSplitPosition(60.0f);
}