Example usage for com.vaadin.ui Alignment TOP_LEFT

List of usage examples for com.vaadin.ui Alignment TOP_LEFT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment TOP_LEFT.

Prototype

Alignment TOP_LEFT

To view the source code for com.vaadin.ui Alignment TOP_LEFT.

Click Source Link

Usage

From source file:org.opennms.features.vaadin.pmatrix.ui.PmatrixApplication.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setWidth("-1px");
    layout.setHeight("-1px");
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    layout.setMargin(true);/*from w  w  w  .j  ava2s  .  c o m*/
    setContent(layout);

    //used to test that detach events are happening
    addDetachListener(new DetachListener() {
        @Override
        public void detach(DetachEvent event) {
            LOG.debug("Pmatrix UI instance detached:" + this);
        }
    });

    Component uiComponent = uiComponentFactory.getUiComponent(request);

    if (uiComponent == null) {

        StringBuilder sb = new StringBuilder(
                "Error: Cannot create the UI because the URL request parameters are not recognised<BR>\n"
                        + "you need to provide atleast '?" + UiComponentFactory.COMPONENT_REQUEST_PARAMETER
                        + "=" + UiComponentFactory.DEFAULT_COMPONENT_REQUEST_VALUE + "'<BR>\n"
                        + "Parameters passed in URL:<BR>\n");
        for (Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
            sb.append("parameter:'" + entry.getKey() + "' value:'");
            for (String s : entry.getValue()) {
                sb.append("{" + s + "}");
            }
            sb.append("'<BR>\n");
        }
        Label label = new Label();
        label.setWidth("600px");
        label.setContentMode(ContentMode.HTML);
        label.setValue(sb.toString());
        layout.addComponent(label);

    } else {
        layout.addComponent(uiComponent);

        // refresh interval to apply to the UI
        int pollInterval = uiComponentFactory.getRefreshRate();
        setPollInterval(pollInterval);

        // display poll interval in seconds
        DecimalFormat dformat = new DecimalFormat("##.##");
        Label label = new Label();
        label.setCaption("(refresh rate:" + dformat.format(pollInterval / 1000) + " seconds)");
        layout.addComponent(label);
    }

}

From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceMainLayout.java

License:Open Source License

public BusinessServiceMainLayout(BusinessServiceManager businessServiceManager) {
    m_businessServiceManager = Objects.requireNonNull(businessServiceManager);
    m_table = new BusinessServiceTreeTable(businessServiceManager);

    setSizeFull();/* ww  w.ja  v a  2 s.  c om*/

    // Create button
    final Button createButton = UIHelper.createButton("New Business Service", null, FontAwesome.PLUS_SQUARE,
            (Button.ClickListener) event -> {
                final BusinessService businessService = m_businessServiceManager.createBusinessService();
                final BusinessServiceEditWindow window = new BusinessServiceEditWindow(businessService,
                        m_businessServiceManager);
                window.addCloseListener(e -> m_table.refresh());
                getUI().addWindow(window);
            });
    createButton.setId("createButton");

    // Collapse all
    final Button collapseButton = UIHelper.createButton("Collapse All", null, FontAwesome.FOLDER,
            (Button.ClickListener) event -> {
                m_table.getContainerDataSource().getItemIds().forEach(id -> m_table.setCollapsed(id, true));
            });
    collapseButton.setId("collapseButton");

    // Expand all
    final Button expandButton = UIHelper.createButton("Expand All", null, FontAwesome.FOLDER_OPEN,
            (Button.ClickListener) event -> {
                m_table.getContainerDataSource().getItemIds().forEach(id -> m_table.setCollapsed(id, false));
            });
    expandButton.setId("expandButton");

    // Refresh
    final Button refreshButton = UIHelper.createButton("Refresh Table", null, FontAwesome.REFRESH,
            (Button.ClickListener) event -> {
                m_table.refresh();
            });
    refreshButton.setId("refreshButton");

    // Reload daemon
    final Button reloadButton = UIHelper.createButton("Reload Daemon",
            "Reloads the Business Service State Machine", FontAwesome.RETWEET, (Button.ClickListener) event -> {
                m_businessServiceManager.triggerDaemonReload();
            });
    reloadButton.setId("reloadButton");

    // Group the create and collapse buttons on the left
    HorizontalLayout leftButtonGroup = new HorizontalLayout();
    leftButtonGroup.setSpacing(true);
    leftButtonGroup.addComponent(createButton);
    leftButtonGroup.addComponent(collapseButton);
    leftButtonGroup.addComponent(expandButton);
    leftButtonGroup.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    // Group the refresh and reload buttons to the right
    HorizontalLayout rightButtonGroup = new HorizontalLayout();
    rightButtonGroup.setSpacing(true);
    rightButtonGroup.addComponent(refreshButton);
    rightButtonGroup.addComponent(reloadButton);
    rightButtonGroup.setDefaultComponentAlignment(Alignment.TOP_RIGHT);

    // Build the upper layout
    HorizontalLayout upperLayout = new HorizontalLayout();
    upperLayout.setSpacing(true);
    upperLayout.addComponent(leftButtonGroup);
    upperLayout.addComponent(rightButtonGroup);
    upperLayout.setComponentAlignment(leftButtonGroup, Alignment.TOP_LEFT);
    upperLayout.setComponentAlignment(rightButtonGroup, Alignment.TOP_RIGHT);
    upperLayout.setWidth(100, Unit.PERCENTAGE);
    addComponent(upperLayout);

    // Add some space between the upper layout and the table
    Label sz = new Label("");
    sz.setWidth(null);
    sz.setHeight(5, Unit.PIXELS);
    addComponent(sz);

    /**
     * add the table to the layout
     */
    addComponent(m_table);
    setExpandRatio(m_table, 1.0f);

    /**
     * initial refresh of table
     */
    m_table.refresh();
}

From source file:org.processbase.ui.core.template.TablePanel.java

License:Open Source License

@Override
public void initUI() {
    super.initUI();
    table.setSizeFull();//ww  w  .  ja v  a 2  s. c  om
    if (getPbWindow().getContent() instanceof PbPanel && ((PbPanel) getPbWindow().getContent()).isControl()) {
        table.setPageLength(20);
    } else {
        table.setPageLength(15);
    }
    table.addStyleName("striped");
    //        table.setSelectable(true);
    //        table.setMultiSelect(false);
    //        table.setImmediate(false);
    horizontalLayout.addComponent(table, 0);
    horizontalLayout.setComponentAlignment(table, Alignment.TOP_LEFT);
    horizontalLayout.setExpandRatio(table, 1);
}

From source file:org.processbase.ui.core.template.TreeTablePanel.java

License:Open Source License

@Override
public void initUI() {
    super.initUI();
    treeTable.setSizeFull();//from  ww w.j  av a2 s. c  o  m
    treeTable.setPageLength(15);
    treeTable.addStyleName("striped");
    //        table.setSelectable(true);
    //        table.setMultiSelect(false);
    //        table.setImmediate(false);
    horizontalLayout.addComponent(treeTable, 0);
    horizontalLayout.setComponentAlignment(treeTable, Alignment.TOP_LEFT);
    horizontalLayout.setExpandRatio(treeTable, 1);
}

From source file:org.rapidpm.jumpstart.vaadin.ui.basics.RapidTopPanel.java

License:Apache License

@PostConstruct
private void createIconsLayout() {
    iconsLayout.setWidth("100%");
    iconsLayout.setMargin(new MarginInfo(false, false, false, false));

    if (propertyService.hasKey("app.logo")) {
        final String resourceName = propertyService.resolve("app.logo");
        final Image iconLeft = new Image(null, new ClassResource(resourceName));
        final Image iconRight = new Image(null, new ClassResource(resourceName));

        iconsLayout.addComponent(iconLeft);
        iconsLayout.setComponentAlignment(iconLeft, Alignment.TOP_LEFT);

        if (propertyService.hasKey("app.version")) {
            final Label versionLabel = new Label(propertyService.resolve("app.version"));
            versionLabel.setSizeUndefined();
            iconsLayout.addComponent(versionLabel);
            iconsLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_CENTER);
            iconsLayout.setExpandRatio(versionLabel, 1.0f);
        }/*  ww  w  .  j a  v a  2s.c o m*/

        iconsLayout.addComponent(iconRight);
        iconsLayout.setComponentAlignment(iconRight, Alignment.TOP_RIGHT);
    }
}

From source file:org.ripla.web.util.FooterHelper.java

License:Open Source License

private void populateLayout(final HorizontalLayout inLayout, final String inFooterText) {
    final Label lFooterText = LabelHelper.createLabel(inFooterText, "ripla-footer-text"); //$NON-NLS-1$
    inLayout.addComponent(lFooterText);/*from  w  w  w. j a  v  a2 s  .  c o m*/
    inLayout.setComponentAlignment(lFooterText, Alignment.TOP_LEFT);
}

From source file:org.sensorhub.ui.SensorAdminPanel.java

License:Mozilla Public License

protected Panel newPanel(String title) {
    Panel panel = new Panel(title);
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from  w  ww .j a va  2  s .  com
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    panel.setContent(layout);
    return panel;
}

From source file:org.sensorhub.ui.StorageAdminPanel.java

License:Mozilla Public License

protected Panel newPanel(String title) {
    Panel panel = new Panel(title);
    GridLayout layout = new GridLayout(2, 2);
    layout.setWidth(100.0f, Unit.PERCENTAGE);
    layout.setMargin(true);/* w  w w . ja  v a  2s .  c  om*/
    layout.setSpacing(true);
    layout.setColumnExpandRatio(0, 0.2f);
    layout.setColumnExpandRatio(1, 0.8f);
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    panel.setContent(layout);
    return panel;
}

From source file:org.vaadin.overlay.sample.OverlaySampleApplication.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    VerticalLayout layout = new VerticalLayout();

    final Label label = new Label("Alignment.TOP_LEFT");
    layout.addComponent(label);//from   w  w  w .j  a v  a2s.  c  o m

    for (int i = 0; i < 20; i++) {

        Button button = new Button("Sample Button");
        layout.addComponent(button);

        final ImageOverlay io = new ImageOverlay(button);

        Resource res = new ClassResource(this.getClass(), "../icon-new.png");
        io.setImage(res);
        io.setComponentAnchor(Alignment.TOP_LEFT); // Top left of the button
        io.setOverlayAnchor(Alignment.MIDDLE_CENTER); // Center of the image
        io.setClickListener(new OverlayClickListener() {
            public void overlayClicked(CustomClickableOverlay overlay) {
                Notification.show("ImageOverlay Clicked!");
            }
        });
        layout.addComponent(io);
        io.setEnabled(true);

        final TextOverlay to = new TextOverlay(button, "New!");
        to.setComponentAnchor(Alignment.MIDDLE_RIGHT); // Top right of the button
        to.setOverlayAnchor(Alignment.MIDDLE_CENTER); // Center of the image
        to.setClickListener(new OverlayClickListener() {
            public void overlayClicked(CustomClickableOverlay overlay) {
                Notification.show("TextOverlay Clicked!");
            }
        });
        layout.addComponent(to);

        button.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                Alignment a = io.getComponentAnchor();
                String s = "";
                if (Alignment.TOP_LEFT.equals(a)) {
                    a = Alignment.TOP_CENTER;
                    s = "TOP_CENTER";
                } else if (Alignment.TOP_CENTER.equals(a)) {
                    a = Alignment.TOP_RIGHT;
                    s = "TOP_RIGHT";
                } else if (Alignment.TOP_RIGHT.equals(a)) {
                    a = Alignment.MIDDLE_RIGHT;
                    s = "MIDDLE_RIGHT";
                } else if (Alignment.MIDDLE_RIGHT.equals(a)) {
                    a = Alignment.BOTTOM_RIGHT;
                    s = "BOTTOM_RIGHT";
                } else if (Alignment.BOTTOM_RIGHT.equals(a)) {
                    a = Alignment.BOTTOM_CENTER;
                    s = "BOTTOM_CENTER";
                } else if (Alignment.BOTTOM_CENTER.equals(a)) {
                    a = Alignment.BOTTOM_LEFT;
                    s = "BOTTOM_LEFT";
                } else if (Alignment.BOTTOM_LEFT.equals(a)) {
                    a = Alignment.MIDDLE_LEFT;
                    s = "MIDDLE_LEFT";
                } else if (Alignment.MIDDLE_LEFT.equals(a)) {
                    a = Alignment.TOP_LEFT;
                    s = "TOP_LEFT";
                }
                io.setComponentAnchor(a);
                label.setValue("Alignment." + s);
            }
        });
    }

    setContent(layout);
}

From source file:org.vaadin.peholmst.samples.dddwebinar.ui.admin.ProcedureCategoryAdminView.java

@PostConstruct
void init() {//from w w  w.ja  v  a 2  s  . c  om
    setSpacing(true);
    setMargin(true);
    setSizeFull();
    Label label = new Label("Procedure Categories");
    label.addStyleName(ValoTheme.LABEL_H1);
    addComponent(label);

    procedureCategoryContainer = new BeanItemContainer<>(ProcedureCategory.class);
    procedureCategoryGrid = new Grid(procedureCategoryContainer);
    procedureCategoryGrid.setColumns("name", "licenseTypes");
    procedureCategoryGrid.getColumn("licenseTypes").setConverter(new LicenseTypeMapConverter());
    procedureCategoryGrid.setSizeFull();
    procedureCategoryGrid.addSelectionListener(this::select);

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

    formLayout = new HorizontalLayout();
    formLayout.setSpacing(true);
    formLayout.setVisible(false);
    addComponent(formLayout);

    name = new TextField("Category Name");
    formLayout.addComponent(name);
    formLayout.setComponentAlignment(name, Alignment.TOP_LEFT);

    licenseTypes = new LicenseTypeMapField("License Types");
    licenseTypes.setSelectable(licenseTypeRepository.findAll());
    formLayout.addComponent(licenseTypes);

    Button save = new Button("Save", this::save);
    formLayout.addComponent(save);
    formLayout.setComponentAlignment(save, Alignment.BOTTOM_LEFT);

    binder.bindMemberFields(this);
    refresh();
}