Example usage for com.vaadin.ui HorizontalLayout setSizeFull

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

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java

License:Apache License

private Component createTaskSummary(UserTask task) {

    //      TextField name = new TextField("Name");
    //      name.setValue(task.getName());
    //      name.setReadOnly(true);
    //      name.setWidth("100%");

    TextField priority = new TextField("Priority");
    priority.setValue(Integer.toString(task.getPriority()));
    priority.setReadOnly(true);//from   w ww  .  j  av  a 2s.c  o  m

    TextField status = new TextField("Status");
    status.setValue(task.getStatus().getDescription());
    status.setReadOnly(true);

    TextArea description = new TextArea("Description");
    description.setSizeFull();
    description.setValue(task.getDescription());
    description.setReadOnly(true);
    description.setRows(3);

    ComponentContainer buttons = createSummaryButtons(task);

    VerticalLayout secondColumnFields = new VerticalLayout();
    secondColumnFields.setMargin(false);
    secondColumnFields.setSizeFull();

    secondColumnFields.addComponent(priority);
    secondColumnFields.addComponent(status);

    HorizontalLayout fieldsLayout = new HorizontalLayout();
    fieldsLayout.setSizeFull();
    fieldsLayout.setMargin(false);
    fieldsLayout.setSpacing(false);
    fieldsLayout.addComponent(description);
    fieldsLayout.addComponent(secondColumnFields);
    fieldsLayout.setExpandRatio(description, 4.0f);
    fieldsLayout.setExpandRatio(secondColumnFields, 1.0f);

    HorizontalLayout mainLayout = new HorizontalLayout();
    mainLayout.setMargin(true);
    mainLayout.setSpacing(false);
    mainLayout.setSizeFull();
    mainLayout.addComponent(fieldsLayout);
    mainLayout.addComponent(buttons);
    mainLayout.setComponentAlignment(buttons, Alignment.TOP_LEFT);
    mainLayout.setExpandRatio(fieldsLayout, 1.0f);

    Panel panel = new Panel("Summary");
    panel.setStyleName("background-transparent");
    panel.setContent(mainLayout);

    return panel;
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.HelpClickListener.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent clickEvent) {
    final Window window = new Window("Help");

    window.setModal(true);//from  w w w.j  a  v a  2  s . co m
    window.setClosable(false);
    window.setResizable(false);

    window.setWidth("55%");
    window.setHeight("80%");

    m_component.getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        {
            setMargin(true);
            setSpacing(true);
            setSizeFull();

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setSizeFull();
            horizontalLayout.setSpacing(true);

            Tree tree = new Tree();
            tree.setNullSelectionAllowed(false);
            tree.setMultiSelect(false);
            tree.setImmediate(true);

            tree.addItem("Overview");
            tree.setChildrenAllowed("Overview", false);

            tree.addItem("Installed Dashlets");
            tree.setChildrenAllowed("Installed Dashlets", true);

            final List<DashletFactory> factories = m_dashletSelector.getDashletFactoryList();

            for (DashletFactory dashletFactory : factories) {
                tree.addItem(dashletFactory.getName());
                tree.setParent(dashletFactory.getName(), "Installed Dashlets");
                tree.setChildrenAllowed(dashletFactory.getName(), false);
            }
            horizontalLayout.addComponent(tree);

            for (final Object id : tree.rootItemIds()) {
                tree.expandItemsRecursively(id);
            }

            final Panel panel = new Panel();
            panel.setSizeFull();

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

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

            tree.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                    String itemId = String.valueOf(valueChangeEvent.getProperty().getValue());

                    if ("Installed Dashlets".equals(itemId)) {
                        return;
                    }

                    if ("Overview".equals(itemId)) {
                        VerticalLayout verticalLayout = new VerticalLayout();
                        verticalLayout.setSpacing(true);
                        verticalLayout.setMargin(true);

                        verticalLayout.addComponent(new Label(getOverviewHelpHTML(), ContentMode.HTML));

                        panel.setContent(verticalLayout);
                    } else {
                        DashletFactory dashletFactory = m_dashletSelector.getDashletFactoryForName(itemId);

                        if (dashletFactory != null) {
                            if (dashletFactory.providesHelpComponent()) {
                                VerticalLayout verticalLayout = new VerticalLayout();
                                verticalLayout.setSpacing(true);
                                verticalLayout.setMargin(true);

                                Label helpTitle = new Label(
                                        "Help for Dashlet '" + dashletFactory.getName() + "'");
                                helpTitle.addStyleName("help-title");

                                verticalLayout.addComponent(helpTitle);
                                verticalLayout.addComponent(dashletFactory.getHelpComponent());

                                panel.setContent(verticalLayout);
                            }
                        }
                    }
                }
            });

            tree.select("Overview");

            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button closeButton = new Button("Close");

                    addComponent(closeButton);
                    setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT);
                    closeButton.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent clickEvent) {
                            window.close();
                        }
                    });
                }
            });
        }
    });
}

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

License:Open Source License

/**
 * Returns the component for visualising the alarms data.
 *
 * @param onmsAlarm an {@link OnmsAlarm} instance
 * @param onmsNode  an {@link OnmsNode} instance
 * @return component for this alarm/*  w  w  w.j a v  a2  s  .  c o  m*/
 */
@Deprecated
public Component createAlarmComponent(OnmsAlarm onmsAlarm, OnmsNode onmsNode) {
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    horizontalLayout.addStyleName("alert-details");
    horizontalLayout.addStyleName("alert-details-font");
    horizontalLayout.addStyleName(onmsAlarm.getSeverity().name().toLowerCase());

    VerticalLayout verticalLayout1 = new VerticalLayout();
    VerticalLayout verticalLayout2 = new VerticalLayout();

    horizontalLayout.addComponent(verticalLayout1);
    horizontalLayout.addComponent(verticalLayout2);

    Label lastEvent = new Label();
    lastEvent.setSizeUndefined();
    lastEvent.addStyleName("alert-details-font");
    lastEvent.setCaption("Last event");
    lastEvent.setValue(onmsAlarm.getLastEventTime().toString());

    Label firstEvent = new Label();
    firstEvent.setSizeUndefined();
    firstEvent.addStyleName("alert-details-font");
    firstEvent.setCaption("First event");
    firstEvent.setValue(onmsAlarm.getFirstEventTime().toString());

    verticalLayout1.addComponent(firstEvent);
    verticalLayout1.addComponent(lastEvent);

    Label nodeId = new Label();
    nodeId.setSizeUndefined();
    nodeId.addStyleName("alert-details-font");
    nodeId.setCaption("Node Id");

    if (onmsNode != null) {
        nodeId.setValue(onmsNode.getNodeId());
    } else {
        nodeId.setValue("-");
    }

    Label nodeLabel = new Label();
    nodeLabel.setSizeUndefined();
    nodeLabel.addStyleName("alert-details-font");
    nodeLabel.setCaption("Node Label");

    if (onmsNode != null) {
        nodeLabel.setValue(onmsNode.getLabel());
    } else {
        nodeLabel.setValue("-");
    }

    Label logMessage = new Label();
    logMessage.addStyleName("alert-details-font");
    logMessage.setSizeFull();
    logMessage.setCaption("Log message");
    logMessage.setValue(onmsAlarm.getLogMsg().replaceAll("<[^>]*>", ""));

    HorizontalLayout horizontalLayout2 = new HorizontalLayout();
    horizontalLayout2.setSizeFull();
    horizontalLayout2.setSpacing(true);
    horizontalLayout2.addComponent(nodeId);
    horizontalLayout2.addComponent(nodeLabel);

    verticalLayout2.addComponent(horizontalLayout2);
    verticalLayout2.addComponent(logMessage);

    horizontalLayout.setExpandRatio(verticalLayout1, 1.0f);
    horizontalLayout.setExpandRatio(verticalLayout2, 4.0f);

    return horizontalLayout;
}

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

License:Open Source License

/**
 * Constructor for instantiating new objects of this class.
 *
 * @param dashletSpec the {@link DashletSpec} to be edited
 *//*from   ww  w.  j  av a  2  s.c  o  m*/
public BSMConfigurationWindow(DashletSpec dashletSpec) {
    /**
     * Setting the members
     */
    m_dashletSpec = dashletSpec;

    /**
     * Setting up the base layouts
     */

    setHeight(91, Unit.PERCENTAGE);
    setWidth(60, Unit.PERCENTAGE);

    /**
     * Retrieve the config...
     */

    boolean filterByName = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(), "filterByName");
    String nameValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "nameValue", "");
    boolean filterByAttribute = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(),
            "filterByAttribute");
    String attributeKey = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "attributeKey", "");
    String attributeValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "attributeValue",
            "");
    boolean filterBySeverity = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(),
            "filterBySeverity");
    String severityValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "severityValue",
            Status.WARNING.name());
    String severityCompareOperator = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(),
            "severityCompareOperator",
            BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name());
    String orderBy = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "orderBy",
            BusinessServiceSearchCriteriaBuilder.Order.Name.name());
    String orderSequence = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "orderSequence",
            BusinessServiceSearchCriteriaBuilder.Sequence.Ascending.name());
    int resultsLimit = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "resultsLimit", 10);
    int columnCountBoard = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "columnCountBoard",
            10);
    int columnCountPanel = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "columnCountPanel",
            5);

    /**
     * Adding the "Filter By Name" panel
     */

    m_filterByNameCheckBox = new CheckBox();
    m_filterByNameCheckBox.setCaption("Enable");
    m_filterByNameCheckBox.setDescription("Filter by Business Service name");

    VerticalLayout nameLayout = new VerticalLayout();
    nameLayout.setSpacing(true);
    nameLayout.setMargin(true);
    nameLayout.setSizeFull();

    m_nameTextField = new TextField("Name (REGEXP)");
    m_nameTextField.setEnabled(false);

    addToComponent(nameLayout, m_filterByNameCheckBox);
    addToComponent(nameLayout, m_nameTextField);

    Panel namePanel = new Panel();
    namePanel.setCaption("Filter by Name");
    namePanel.setContent(nameLayout);

    m_filterByNameCheckBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            m_nameTextField.setEnabled(m_filterByNameCheckBox.getValue());
        }
    });

    m_nameTextField.setValue(nameValue);
    m_filterByNameCheckBox.setValue(filterByName);

    /**
     * Adding the "Filter By Attribute" panel
     */

    m_filterByAttributeCheckBox = new CheckBox();
    m_filterByAttributeCheckBox.setCaption("Enable");
    m_filterByAttributeCheckBox.setDescription("Filter by Business Service attribute");

    VerticalLayout attributeLayout = new VerticalLayout();
    attributeLayout.setSpacing(true);
    attributeLayout.setMargin(true);
    attributeLayout.setSizeFull();

    m_attributeKeyTextField = new TextField("Key");
    m_attributeKeyTextField.setEnabled(false);
    m_attributeValueTextField = new TextField("Value (REGEXP)");
    m_attributeValueTextField.setEnabled(false);
    addToComponent(attributeLayout, m_filterByAttributeCheckBox);
    addToComponent(attributeLayout, m_attributeKeyTextField);
    addToComponent(attributeLayout, m_attributeValueTextField);

    Panel attributePanel = new Panel();
    attributePanel.setCaption("Filter by Attribute");
    attributePanel.setContent(attributeLayout);

    m_filterByAttributeCheckBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            m_attributeKeyTextField.setEnabled(m_filterByAttributeCheckBox.getValue());
            m_attributeValueTextField.setEnabled(m_filterByAttributeCheckBox.getValue());
        }
    });

    m_attributeKeyTextField.setValue(attributeKey);
    m_attributeValueTextField.setValue(attributeValue);
    m_filterByAttributeCheckBox.setValue(filterByAttribute);

    /**
     * Adding the "Filter By Severity" panel
     */

    m_filterBySeverityCheckBox = new CheckBox();
    m_filterBySeverityCheckBox.setCaption("Enable");
    m_filterBySeverityCheckBox.setDescription("Filter by Business Service severity");

    VerticalLayout severityLayout = new VerticalLayout();
    severityLayout.setSpacing(true);
    severityLayout.setMargin(true);
    severityLayout.setSizeFull();

    m_severitySelect = new NativeSelect("Severity");
    m_severitySelect.setEnabled(false);
    m_severitySelect.setNullSelectionAllowed(false);
    m_severitySelect.setMultiSelect(false);

    for (Status eachStatus : Status.values()) {
        m_severitySelect.addItem(eachStatus.name());
    }

    m_compareOperatorSelect = new NativeSelect("Comparator");
    m_compareOperatorSelect.setEnabled(false);
    m_compareOperatorSelect.setNullSelectionAllowed(false);
    m_compareOperatorSelect.setMultiSelect(false);

    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Lower.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.LowerOrEqual.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Equal.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Greater.name());

    addToComponent(severityLayout, m_filterBySeverityCheckBox);
    addToComponent(severityLayout, m_severitySelect);
    addToComponent(severityLayout, m_compareOperatorSelect);

    Panel severityPanel = new Panel();
    severityPanel.setCaption("Filter by Severity");
    severityPanel.setContent(severityLayout);

    m_filterBySeverityCheckBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            m_severitySelect.setEnabled(m_filterBySeverityCheckBox.getValue());
            m_compareOperatorSelect.setEnabled(m_filterBySeverityCheckBox.getValue());
        }
    });

    m_severitySelect.setValue(severityValue);
    m_compareOperatorSelect.setValue(severityCompareOperator);
    m_filterBySeverityCheckBox.setValue(filterBySeverity);

    /**
     * Adding the "Results" panel
     */

    VerticalLayout limitLayout = new VerticalLayout();
    limitLayout.setSpacing(true);
    limitLayout.setMargin(true);
    limitLayout.setSizeFull();

    m_limitTextField = new TextField("Limit");

    m_orderBy = new NativeSelect("Order by");
    m_orderBy.setNullSelectionAllowed(false);
    m_orderBy.setMultiSelect(false);

    m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Name.name());
    m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Severity.name());
    m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Level.name());

    m_orderSequence = new NativeSelect("Asc/Desc ");
    m_orderSequence.setNullSelectionAllowed(false);
    m_orderSequence.setMultiSelect(false);

    m_orderSequence.addItem("Ascending");
    m_orderSequence.addItem("Descending");

    m_columnCountBoardTextField = new TextField("Ops Board Column Count");
    m_columnCountBoardTextField.addValidator(new AbstractStringValidator("Number greater zero expected") {
        @Override
        protected boolean isValidValue(String value) {
            try {
                int i = Integer.parseInt(value);
                return i > 0;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    m_columnCountPanelTextField = new TextField("Ops Panel Column Count");
    m_columnCountPanelTextField.addValidator(new AbstractStringValidator("Number greater zero expected") {
        @Override
        protected boolean isValidValue(String value) {
            try {
                int i = Integer.parseInt(value);
                return i > 0;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    addToComponent(limitLayout, m_limitTextField);
    addToComponent(limitLayout, m_orderBy);
    addToComponent(limitLayout, m_orderSequence);
    addToComponent(limitLayout, m_columnCountBoardTextField);
    addToComponent(limitLayout, m_columnCountPanelTextField);

    Panel limitPanel = new Panel();
    limitPanel.setSizeFull();
    limitPanel.setCaption("Results");
    limitPanel.setContent(limitLayout);

    m_limitTextField.setValue(String.valueOf(resultsLimit));
    m_orderBy.setValue(orderBy);
    m_orderSequence.setValue(orderSequence);
    m_columnCountBoardTextField.setValue(String.valueOf(columnCountBoard));
    m_columnCountPanelTextField.setValue(String.valueOf(columnCountPanel));

    m_limitTextField.addValidator(new AbstractStringValidator("Number greater or equal zero expected") {
        @Override
        protected boolean isValidValue(String value) {
            try {
                int i = Integer.parseInt(value);
                return i >= 0;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    /**
     * Create the main layout...
     */

    VerticalLayout verticalLayout = new VerticalLayout();

    verticalLayout.setWidth(100, Unit.PERCENTAGE);
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    verticalLayout.addComponent(namePanel);
    verticalLayout.addComponent(attributePanel);

    HorizontalLayout bottomLayout = new HorizontalLayout(severityPanel, limitPanel);
    bottomLayout.setSpacing(true);
    bottomLayout.setSizeFull();
    bottomLayout.setWidth(100, Unit.PERCENTAGE);

    verticalLayout.addComponent(bottomLayout);

    /**
     * Using an additional {@link HorizontalLayout} for layouting the buttons
     */
    HorizontalLayout buttonLayout = new HorizontalLayout();

    buttonLayout.setMargin(true);
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");

    Label label = new Label("Note: Multiple enabled filter constraints will be combined by a logical AND.");
    buttonLayout.addComponent(label);
    buttonLayout.setExpandRatio(label, 1.0f);

    /**
     * Adding the cancel button...
     */
    Button cancel = new Button("Cancel");
    cancel.setDescription("Cancel editing");
    cancel.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });

    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    buttonLayout.addComponent(cancel);
    buttonLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT);

    /**
     * ...and the OK button
     */
    Button ok = new Button("Save");
    ok.setDescription("Save properties and close");
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!m_limitTextField.isValid() || !m_columnCountPanelTextField.isValid()
                    || !m_columnCountBoardTextField.isValid()) {
                return;
            }

            m_dashletSpec.getParameters().put("filterByName",
                    (m_filterByNameCheckBox.getValue() ? "true" : "false"));

            if (m_filterByNameCheckBox.getValue()) {
                m_dashletSpec.getParameters().put("nameValue", m_nameTextField.getValue());
            } else {
                m_dashletSpec.getParameters().put("nameValue", "");
            }

            m_dashletSpec.getParameters().put("filterByAttribute",
                    (m_filterByAttributeCheckBox.getValue() ? "true" : "false"));

            if (m_filterByAttributeCheckBox.getValue()) {
                m_dashletSpec.getParameters().put("attributeKey", m_attributeKeyTextField.getValue());
                m_dashletSpec.getParameters().put("attributeValue", m_attributeValueTextField.getValue());
            } else {
                m_dashletSpec.getParameters().put("attributeKey", "");
                m_dashletSpec.getParameters().put("attributeValue", "");
            }

            m_dashletSpec.getParameters().put("filterBySeverity",
                    (m_filterBySeverityCheckBox.getValue() ? "true" : "false"));

            if (m_filterBySeverityCheckBox.getValue() && m_severitySelect.getValue() != null) {
                m_dashletSpec.getParameters().put("severityValue", m_severitySelect.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("severityValue", Status.WARNING.getLabel());
            }

            if (m_filterBySeverityCheckBox.getValue() && m_compareOperatorSelect.getValue() != null) {
                m_dashletSpec.getParameters().put("severityCompareOperator",
                        m_compareOperatorSelect.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("severityCompareOperator",
                        BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name());
            }

            if (m_orderBy.getValue() != null) {
                m_dashletSpec.getParameters().put("orderBy", m_orderBy.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("orderBy",
                        BusinessServiceSearchCriteriaBuilder.Order.Name.name());
            }

            if (m_orderSequence.getValue() != null) {
                m_dashletSpec.getParameters().put("orderSequence", m_orderSequence.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("orderSequence", "Ascending");
            }

            m_dashletSpec.getParameters().put("resultsLimit", m_limitTextField.getValue().toString());
            m_dashletSpec.getParameters().put("columnCountBoard",
                    m_columnCountBoardTextField.getValue().toString());
            m_dashletSpec.getParameters().put("columnCountPanel",
                    m_columnCountPanelTextField.getValue().toString());

            WallboardProvider.getInstance().save();
            ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties");

            close();
        }
    });

    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttonLayout.addComponent(ok);

    /**
     * Adding the layout and setting the content
     */
    verticalLayout.addComponent(buttonLayout);

    setContent(verticalLayout);
}

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

License:Open Source License

private HorizontalLayout createRow(BusinessService service) {
    HorizontalLayout rowLayout = new HorizontalLayout();
    rowLayout.setSizeFull();
    rowLayout.setSpacing(true);/*  w w w .  ja va  2  s  .  c  om*/

    final Status severity = m_businessServiceManager.getOperationalStatus(service);
    Label nameLabel = new Label(service.getName());
    nameLabel.setSizeFull();
    nameLabel.setStyleName("h3");
    nameLabel.addStyleName("bright");
    nameLabel.addStyleName("severity");
    nameLabel.addStyleName(severity.getLabel());

    rowLayout.addComponent(nameLabel);
    return rowLayout;
}

From source file:org.opennms.features.vaadin.surveillanceviews.ui.dashboard.SurveillanceViewGraphComponent.java

License:Open Source License

/**
 * Constructor for instantiating this component.
 *
 * @param surveillanceViewService the surveillance view service to be used
 * @param enabled                 the flag should links be enabled?
 *///from   w  w  w . j av  a2 s  .c  om
public SurveillanceViewGraphComponent(SurveillanceViewService surveillanceViewService, boolean enabled) {
    /**
     * set the fields
     */
    m_surveillanceViewService = surveillanceViewService;
    m_enabled = enabled;

    /**
     * create layout for caption
     */
    HorizontalLayout horizontalLayout = new HorizontalLayout();

    horizontalLayout.setWidth(100, Unit.PERCENTAGE);
    horizontalLayout.setSpacing(false);
    horizontalLayout.setPrimaryStyleName("v-caption-surveillance-view");
    horizontalLayout.addComponent(new Label("Resource Graphs"));
    addComponent(horizontalLayout);

    /**
     * create node selection box
     */
    m_nodeSelect = new NativeSelect();
    m_nodeSelect.setNullSelectionAllowed(false);

    m_nodeSelect.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            Integer onmsNodeId = (Integer) m_nodeSelect.getValue();

            m_resourceSelect.removeAllItems();

            if (onmsNodeId != null) {
                Map<OnmsResourceType, List<OnmsResource>> map = getSurveillanceViewService()
                        .getResourceTypeMapForNodeId(onmsNodeId);

                for (OnmsResourceType onmsResourceType : map.keySet()) {
                    for (OnmsResource onmsResource : map.get(onmsResourceType)) {
                        m_resourceSelect.addItem(onmsResource.getId());
                        m_resourceSelect.setItemCaption(onmsResource.getId(),
                                onmsResourceType.getLabel() + ": " + onmsResource.getLabel());
                    }
                }

                Iterator<?> i = m_resourceSelect.getItemIds().iterator();

                if (i.hasNext()) {
                    m_resourceSelect.select(i.next());
                }
            }
        }
    });

    /**
     * create resource selection box
     */
    m_resourceSelect = new NativeSelect();
    m_resourceSelect.setNullSelectionAllowed(false);

    m_resourceSelect.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            String onmsResourceId = (String) m_resourceSelect.getValue();

            m_graphSelect.removeAllItems();

            if (onmsResourceId != null) {
                Map<String, String> map = getSurveillanceViewService()
                        .getGraphResultsForResourceId(onmsResourceId);

                for (String string : map.keySet()) {
                    m_graphSelect.addItem(map.get(string));
                    m_graphSelect.setItemCaption(map.get(string), string);
                }

                Iterator<?> i = m_graphSelect.getItemIds().iterator();

                if (i.hasNext()) {
                    m_graphSelect.select(i.next());
                }
            }
        }
    });

    /**
     * create graph selection box
     */
    m_graphSelect = new NativeSelect();
    m_graphSelect.setNullSelectionAllowed(false);

    m_graphSelect.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            String graphName = (String) m_graphSelect.getValue();
            String resourceId = (String) m_resourceSelect.getValue();
            replaceGraph(graphName, resourceId);
        }
    });

    /**
     * set box sizes to full
     */
    m_nodeSelect.setSizeFull();
    m_resourceSelect.setSizeFull();
    m_graphSelect.setSizeFull();

    /**
     * add box styles
     */
    m_nodeSelect.addStyleName("surveillance-view");
    m_resourceSelect.addStyleName("surveillance-view");
    m_graphSelect.addStyleName("surveillance-view");

    /**
     * create layout for storing the graph
     */
    m_graphLayout = new VerticalLayout();
    m_graphLayout.setSizeUndefined();
    m_graphLayout.setWidth(100, Unit.PERCENTAGE);

    /**
     * create layout for selection boxes
     */
    HorizontalLayout selectionBoxesLayout = new HorizontalLayout();
    selectionBoxesLayout.setSizeFull();
    selectionBoxesLayout.addComponent(m_nodeSelect);
    selectionBoxesLayout.addComponent(m_resourceSelect);
    selectionBoxesLayout.addComponent(m_graphSelect);

    m_graphLayout.setId("graphLayout");

    /**
     * ...and call it when page is constructed. Also add a resize listener...
     */
    addAttachListener(new AttachListener() {
        @Override
        public void attach(AttachEvent attachEvent) {
            getUI().getPage().addBrowserWindowResizeListener(SurveillanceViewGraphComponent.this);
        }
    });

    /**
     * ... and remove the resize listener on detach event
     */
    addDetachListener(new DetachListener() {
        @Override
        public void detach(DetachEvent detachEvent) {
            getUI().getPage().removeBrowserWindowResizeListener(SurveillanceViewGraphComponent.this);
        }
    });

    /**
     * add layout for selection boxes and image
     */
    addComponent(selectionBoxesLayout);
    addComponent(m_graphLayout);
}

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

License:Open Source License

public SecurityGroupRuleCreationDialog(final List<SecGroupChoice> choices, final DialogCallback callback) {
    super("Add Rule");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    FormLayout content = new FormLayout();
    content.setMargin(true);/*  www. j  a  va  2  s  . c o m*/
    content.setWidth("500px");
    content.setHeight("350px");

    this.protocolBox = new ComboBox("IP Protocol");
    this.protocolBox.setRequired(true);
    this.protocolBox.setTextInputAllowed(false);
    this.protocolBox.setNullSelectionAllowed(false);
    this.protocolBox.setImmediate(true);
    this.protocolBox.addItem("TCP");
    this.protocolBox.addItem("UDP");
    this.protocolBox.addItem("ICMP");
    this.protocolBox.setValue("TCP");
    content.addComponent(this.protocolBox);

    this.portField = new TextField("Port range");
    this.portField.setRequired(true);
    this.portField.setWidth("80%");
    this.portField.setRequired(true);
    this.portField.setRequiredError("Please provide a port range");
    this.portField.setImmediate(true);
    content.addComponent(this.portField);

    this.sourceChoice = new OptionGroup("Source");
    this.sourceChoice.addItem("CIDR");
    this.sourceChoice.addItem("Security Group");
    this.sourceChoice.setValue("CIDR");
    this.sourceChoice.setImmediate(true);
    this.sourceChoice.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(final ValueChangeEvent event) {
            boolean sourceIsCidr = SecurityGroupRuleCreationDialog.this.sourceChoice.getValue().equals("CIDR");
            SecurityGroupRuleCreationDialog.this.sourceIpRangeField.setEnabled(sourceIsCidr);
            SecurityGroupRuleCreationDialog.this.sourceSecGroupBox.setEnabled(!sourceIsCidr);
        }
    });
    content.addComponent(this.sourceChoice);

    this.sourceIpRangeField = new TextField("CIDR");
    this.sourceIpRangeField.setRequired(true);
    this.sourceIpRangeField.setWidth("80%");
    this.sourceIpRangeField.setRequired(true);
    this.sourceIpRangeField.setRequiredError("Please provide a CIDR");
    this.sourceIpRangeField.setImmediate(true);
    this.sourceIpRangeField.setValue("0.0.0.0/0");
    content.addComponent(this.sourceIpRangeField);

    this.sourceSecGroupBox = new ComboBox("Security Group");
    this.sourceSecGroupBox.setRequired(true);
    this.sourceSecGroupBox.setTextInputAllowed(false);
    this.sourceSecGroupBox.setNullSelectionAllowed(false);
    this.sourceSecGroupBox.setInputPrompt("select machine");
    this.sourceSecGroupBox.setImmediate(true);
    for (SecGroupChoice choice : choices) {
        this.sourceSecGroupBox.addItem(choice.id);
        this.sourceSecGroupBox.setItemCaption(choice.id, choice.name);
    }
    this.sourceSecGroupBox.setValue(choices.get(0).id);
    this.sourceSecGroupBox.setEnabled(false);
    content.addComponent(this.sourceSecGroupBox);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);

    this.errorLabel = new Label("                                       ");
    this.errorLabel.setStyleName("errorMsg");
    this.errorLabel.setWidth("100%");
    buttonLayout.addComponent(this.errorLabel);
    buttonLayout.setExpandRatio(this.errorLabel, 1.0f);

    this.okButton = new Button("Ok", this);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    // content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

}

From source file:org.rdflivenews.annotator.gui.AnnotatorGuiApplication.java

License:Apache License

@Override
public void init() {
    setMainWindow(main);//from w ww  . ja va  2  s  .  c om
    setTheme("mytheme");

    if (!patterns.isEmpty()) {

        mainLayout.removeAllComponents();
        main.removeAllComponents();

        this.pattern = patterns.remove(0);
        this.writeTodoPatterns();

        GridLayout grid = new GridLayout(4, 6);
        grid.setSpacing(true);

        HorizontalLayout labels = new HorizontalLayout();
        labels.setSizeFull();

        subject = new Label("<span style=\"font-size:130%\">" + this.pattern.entityOne + "</span>");
        subject.setContentMode(Label.CONTENT_XHTML);
        subject.setSizeFull();
        patternLabel = new Label("<span style=\"font-size:130%;color:red;\">" + this.pattern.nlr + "</span>");
        patternLabel.setContentMode(Label.CONTENT_XHTML);
        patternLabel.setSizeFull();
        patternLabel.setStyleName("center");
        object = new Label(
                "<span style=\"font-size:130%;text-align:right;\">" + this.pattern.entityTwo + "</span>");
        object.setContentMode(Label.CONTENT_XHTML);
        object.setSizeFull();
        object.setStyleName("right");

        String sentenceLabel = "<a href=\"" + this.pattern.url + "\">" + "<span style=\"font-size:130%\">"
                + this.pattern.sentence
                        .replace(this.pattern.entityOne,
                                "<span style=\"font-weight:bold\">" + this.pattern.entityOne + "</span>")
                        .replace(this.pattern.entityTwo,
                                "<span style=\"font-weight:bold\">" + this.pattern.entityTwo + "</span>")
                        .replace(this.pattern.nlr, "<span style=\"color:red\">" + this.pattern.nlr + "</span>")
                + "</span></a>";

        sentence = new Label(sentenceLabel);
        sentence.setContentMode(Label.CONTENT_XHTML);

        grid.addComponent(sentence, 0, 0, 3, 0);
        labels.addComponent(subject);
        labels.addComponent(patternLabel);
        labels.addComponent(object);
        //            grid.addComponent(subject, 0, 1);
        //            grid.addComponent(patternLabel, 1, 1, 2, 1);
        //            grid.addComponent(object, 3, 1);
        labels.setComponentAlignment(subject, Alignment.MIDDLE_LEFT);
        labels.setComponentAlignment(patternLabel, Alignment.MIDDLE_CENTER);
        labels.setComponentAlignment(object, Alignment.MIDDLE_RIGHT);
        grid.addComponent(labels, 0, 1, 3, 1);

        AutocompleteWidget subject = new AutocompleteWidget(index);
        subject.addSelectionListener(new SelectionListener() {

            @Override
            public void itemSelected(SolrItem item) {
                subjectUri.setValue(item.getUri());
            }
        });
        grid.addComponent(subject, 0, 2, 1, 2);
        AutocompleteWidget object = new AutocompleteWidget(index);
        object.addSelectionListener(new SelectionListener() {

            @Override
            public void itemSelected(SolrItem item) {
                objectUri.setValue(item.getUri());
            }
        });
        grid.addComponent(object, 2, 2, 3, 2);

        saidObject = new TextArea("Say Cluster Object Value");
        saidObject.setWidth("100%");
        grid.addComponent(saidObject, 0, 5, 1, 5);

        comment = new TextArea("Comments");
        comment.setWidth("100%");
        grid.addComponent(comment, 2, 5, 3, 5);

        HorizontalLayout urisAndCluster = new HorizontalLayout();
        subjectUri = new TextField("Subject URI");
        objectUri = new TextField("Object URI");
        subjectUri.setSizeFull();
        objectUri.setSizeFull();

        //cluster category combobox
        clusterCategoriesBox = new ComboBox();
        clusterCategoriesBox.setWidth("40%");
        clusterCategoriesBox.setCaption("Cluster Category");
        clusterCategoriesBox.addContainerProperty("name", String.class, null);
        clusterCategoriesBox.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
        for (ClusterCategory cat : ClusterCategory.values()) {
            clusterCategoriesBox.addItem(cat).getItemProperty("name").setValue(cat.getName());
        }
        clusterCategoriesBox.setImmediate(true);
        clusterCategoriesBox.setValue(ClusterCategory.UNKNOWN);
        clusterCategoriesBox.setNullSelectionAllowed(false);

        urisAndCluster.setSizeFull();
        urisAndCluster.addComponent(subjectUri);
        urisAndCluster.addComponent(clusterCategoriesBox);
        urisAndCluster.addComponent(objectUri);
        urisAndCluster.setComponentAlignment(subjectUri, Alignment.MIDDLE_LEFT);
        urisAndCluster.setComponentAlignment(clusterCategoriesBox, Alignment.MIDDLE_CENTER);
        urisAndCluster.setComponentAlignment(objectUri, Alignment.MIDDLE_RIGHT);

        grid.addComponent(urisAndCluster, 0, 3, 3, 3);

        //            grid.addComponent(clusterCategoriesBox, 1, 3, 2, 3);
        //            grid.setComponentAlignment(clusterCategoriesBox, Alignment.BOTTOM_CENTER);

        mainLayout.addComponent(grid);

        HorizontalLayout submitButtonslayout = new HorizontalLayout();

        nextButton = new NativeButton("Next");
        trashButton = new NativeButton("Trash");
        stopButton = new NativeButton("Stop");
        nextButton.addListener(this);
        trashButton.addListener(this);
        stopButton.addListener(this);
        submitButtonslayout.setSpacing(true);
        submitButtonslayout.setWidth("100%");
        submitButtonslayout.addComponent(trashButton);
        submitButtonslayout.addComponent(stopButton);
        submitButtonslayout.addComponent(nextButton);
        submitButtonslayout.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);
        submitButtonslayout.setComponentAlignment(stopButton, Alignment.MIDDLE_RIGHT);

        mainLayout.addComponent(submitButtonslayout);
        mainLayout.setSpacing(true);
        mainLayout.setWidth(null);
        mainLayout.setHeight("100%");
        Panel panel = new Panel();
        panel.setWidth(null);
        panel.addComponent(mainLayout);

        main.addComponent(panel);
        ((VerticalLayout) main.getContent()).setHeight("100%");
        ((VerticalLayout) main.getContent()).setComponentAlignment(panel, Alignment.MIDDLE_CENTER);

        //force URI search with given labels
        subject.setSearchTerm(this.pattern.entityOne);
        object.setSearchTerm(this.pattern.entityTwo);
    } else
        getMainWindow().showNotification("No patterns anymore...");

}

From source file:org.tylproject.vaadin.addon.fields.collectiontables.CollectionTabularView.java

License:Apache License

/**
 * @return adds a default button bar to the bottom right of this component
 *///w ww.  java2s  .  c  o m
public CollectionTabularView<T, U> withDefaultEditorBar() {
    CrudButtonBar buttonBar = buildDefaultEditorBar();
    compositionRoot.setSizeFull();

    HorizontalLayout inner = new HorizontalLayout(buttonBar);
    inner.setSizeFull();
    inner.setComponentAlignment(buttonBar, Alignment.BOTTOM_RIGHT);

    compositionRoot.addComponent(inner);
    return this;
}

From source file:org.vaadin.spring.samples.security.shared.MainUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo");
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(new DefaultErrorHandler() {
        @Override/*from  w w  w .j a v  a 2 s  .  c  om*/
        public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                Notification.show("Sorry, you don't have access to do that.");
            } else {
                super.error(event);
            }
        }
    });
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    // By adding a security item filter, only views that are accessible to the user will show up in the side bar.
    sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
    layout.addComponent(sideBar);

    CssLayout viewContainer = new CssLayout();
    viewContainer.setSizeFull();
    layout.addComponent(viewContainer);
    layout.setExpandRatio(viewContainer, 1f);

    Navigator navigator = new Navigator(this, viewContainer);
    // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all.
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(ErrorView.class);
    navigator.navigateTo(navigator.getState());

    setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI.
}