Example usage for com.vaadin.ui GridLayout GridLayout

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

Introduction

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

Prototype

public GridLayout(int columns, int rows) 

Source Link

Document

Constructor for a grid of given size (number of columns and rows).

Usage

From source file:org.processbase.ui.bpm.generator.GeneratedWindow.java

License:Open Source License

protected void generateWindow() throws Exception {
    prepareAttachmentDefinitions();/* ww  w  . j  ava2 s .  c om*/
    prepareGroovyScripts();
    for (Page page : pageFlow.getPages().getPages()) {
        TableStyle ts = barResource.getTableStyle(page);
        GridLayout gridLayout = new GridLayout(ts.getColumns(), ts.getRows());
        gridLayout.setMargin(false, true, true, true);
        gridLayout.setSpacing(true);
        for (Object wg : page.getWidgets().getWidgetsAndGroups()) {
            Component component = null;
            if (wg instanceof Widget) {
                Widget widget = (Widget) wg;
                component = getComponent(widget);
                components.put(component, widget);
                fields.put("field_" + widget.getId(), component);
                ComponentStyle componentStyle = ts.getElements().get(widget.getId());
                int fColumn = componentStyle.getPosition().getFColumn();
                int fRow = componentStyle.getPosition().getFRow();
                int tColumn = componentStyle.getPosition().getTColumn();
                int tRow = componentStyle.getPosition().getTRow();
                //                    System.out.println(widget.getId() + " " + fColumn + " " + tColumn + " " + fRow + " " + tRow);
                CSSProperty cssProperty = componentStyle.getCss();
                if (cssProperty != null) {
                    //                        System.out.print(widget.getId() + " H:" + cssProperty.getHeigth());
                    //                        System.out.print(" W:" + cssProperty.getWidth());
                    //                        System.out.println(" A:" + cssProperty.getAlign());
                } else {
                    if (!(component instanceof Table) && !(component instanceof Button)
                            && (fColumn == tColumn)) {
                        component.setWidth("200px");
                    }
                }
                gridLayout.addComponent(component, fColumn, fRow, tColumn, tRow);
            } else if (wg instanceof WidgetGroup) {
            }
        }
        pages.add(gridLayout);
    }
    taskPanel.setContent(pages.get(currentPage));
    taskPanel.setCaption(pageFlow.getPages().getPages().get(currentPage).getPageLabel());
}

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

License:Apache License

@Override
public void init() {
    setMainWindow(main);/*  w  ww . ja v  a 2 s .  com*/
    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.ripla.web.util.LabelValueTable.java

License:Open Source License

/**
 * Constructor setting the table's style class.
 * /*from  w ww .j a v  a 2s.  c  o  m*/
 * @param inStyleName
 *            String the name of the table's style class attribute
 */
public LabelValueTable(final String inStyleName) {
    super();

    layout = new GridLayout(2, 1);
    setCompositionRoot(layout);
    layout.setStyleName(inStyleName);
    layout.setWidth("100%"); //$NON-NLS-1$
    layout.setColumnExpandRatio(1, 1);
}

From source file:org.semanticsoft.vaaclipse.presentation.widgets.TopbarComponent.java

License:Open Source License

public TopbarComponent() {
    addStyleName("trimbar");
    rootLayout = new GridLayout(3, 3);
    rootLayout.setSizeFull();/*  w  w w .  j a v  a  2  s.co  m*/

    setSizeUndefined();
    setWidth("100%");
    setHeight("42px");

    // create the elements
    //
    rootLayout.addComponent(edge_top_left, 0, 0);
    rootLayout.addComponent(edge_top_middle, 1, 0);
    rootLayout.addComponent(edge_top_right, 2, 0);
    rootLayout.addComponent(edge_center_left, 0, 1);
    setContent(new CssLayout());
    rootLayout.addComponent(edge_center_right, 2, 1);
    rootLayout.addComponent(edge_bottom_left, 0, 2);
    rootLayout.addComponent(edge_bottom_middle, 1, 2);
    rootLayout.addComponent(edge_bottom_right, 2, 2);

    // style the elements
    //
    edge_top_left.addStyleName("edge_top_left");
    // edge_top_left.setWidth("8px");
    // edge_top_left.setHeight("8px");

    edge_top_middle.addStyleName("edge_top_middle");
    // edge_top_middle.setWidth("100%");
    // edge_top_middle.setHeight("8px");

    edge_top_right.addStyleName("edge_top_right");
    // edge_top_right.setWidth("6px");
    // edge_top_right.setHeight("8px");

    edge_center_left.addStyleName("edge_center_left");
    // edge_center_left.setHeight("100%");
    // edge_center_left.setWidth("8px");

    edge_center_right.addStyleName("edge_center_right");
    // edge_center_right.setHeight("100%");
    // edge_center_right.setWidth("8px");
    edge_bottom_left.addStyleName("edge_bottom_left");
    edge_bottom_middle.addStyleName("edge_bottom_middle");
    edge_bottom_right.addStyleName("edge_bottom_right");

    // set the width of at least one side element for proper layouting
    edge_bottom_left.setWidth("8px");
    edge_bottom_right.setWidth("6px");

    // expand the center column to its maximum
    // left and right column will gain their set size
    rootLayout.setColumnExpandRatio(1, 1.0f);

    setCompositionRoot(rootLayout);

}

From source file:org.semanticsoft.vaaclipse.presentation.widgets.TrimmedWindowContent.java

License:Open Source License

public TrimmedWindowContent() {
    leftBarContainer.setWidth(-1, Unit.PIXELS);
    leftBarContainer.setHeight("100%");

    rightBarContainer.setWidth(-1, Unit.PIXELS);
    rightBarContainer.setHeight("100%");

    topBarContainer.setHeight(-1, Unit.PIXELS);
    topBarContainer.setWidth("100%");
    topBarContainer.setMargin(false);/*from ww  w  . jav a 2 s.  co m*/

    //bottomBarContainer.setSizeFull();
    bottomBarContainer.setHeight(-1, Unit.PIXELS);
    bottomBarContainer.setWidth("100%");
    bottomBarContainer.setMargin(false);

    this.setSizeFull();

    windowBody = new VerticalLayout();
    windowBody.setSizeFull();
    this.addComponent(windowBody);
    this.setExpandRatio(windowBody, 100);

    windowCenterArea = new ExtendedVerticalLayout();
    windowCenterArea.setVariableValue(Constants.E4_ELEMENT_TYPE, Constants.TRIMMED_WINDOW_CLIENT_AREA);
    windowCenterArea.setSizeFull();

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

    //Top panel - it contains the top trimbar and the perspective stack panel
    topContainerPanel = new GridLayout(2, 1);
    topContainerPanel.setColumnExpandRatio(0, 100);
    topContainerPanel.setColumnExpandRatio(1, 0);
    topContainerPanel.setSizeUndefined();
    topContainerPanel.setWidth("100%");

    windowBody.addComponent(topContainerPanel);
    //------------------------
    helperLayout.addComponent(leftBarContainer);
    helperLayout.addComponent(windowCenterArea);
    helperLayout.addComponent(rightBarContainer);
    helperLayout.setExpandRatio(windowCenterArea, 100);

    windowBody.addComponent(topBarContainer);
    windowBody.addComponent(helperLayout);
    windowBody.setExpandRatio(helperLayout, 100);
    windowBody.addComponent(bottomBarContainer);
    //-------------------------------------------------------------------
}

From source file:org.semanticsoft.vaaclipse.widgets.WorkbenchWindow.java

License:Open Source License

public WorkbenchWindow() {
    //      leftBarContainer.setVisible(false);
    //      rightBarContainer.setVisible(false);
    //      topBarContainer.setVisible(false);
    //      bottomBarContainer.setVisible(false);

    //leftBarContainer.setSizeFull();
    leftBarContainer.setWidth(-1);// w  w w .  ja va 2s. c  o m
    leftBarContainer.setHeight("100%");

    rightBarContainer.setWidth(-1);
    rightBarContainer.setHeight("100%");

    topBarContainer.setHeight(-1);
    topBarContainer.setWidth("100%");
    topBarContainer.setMargin(false);

    //bottomBarContainer.setSizeFull();
    bottomBarContainer.setHeight(-1);
    bottomBarContainer.setWidth("100%");
    bottomBarContainer.setMargin(false);

    windowContent = new VerticalLayout();
    windowContent.setSizeFull();
    this.setContent(windowContent);

    windowBody = new VerticalLayout();
    windowBody.setSizeFull();
    windowContent.addComponent(windowBody);
    windowContent.setExpandRatio(windowBody, 100);

    windowCenterArea = new BoundsinfoVerticalLayout();
    windowCenterArea.setEnableBoundsUpdate(true); //enable bounds update
    windowCenterArea.setSizeFull();
    windowCenterArea.addBoundsUpdateListener(new BoundsUpdateListener() {

        public void processEvent(BoundsinfoVerticalLayout layout) {
            invalidateBounds();
        }
    });

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

    //Top panel - it contains the top trimbar and the perspective stack panel
    topContainerPanel = new GridLayout(2, 1);
    topContainerPanel.setColumnExpandRatio(0, 100);
    topContainerPanel.setColumnExpandRatio(1, 0);
    topContainerPanel.setSizeUndefined();
    topContainerPanel.setWidth("100%");

    windowBody.addComponent(topContainerPanel);
    //------------------------
    helperLayout.addComponent(leftBarContainer);
    helperLayout.addComponent(windowCenterArea);
    helperLayout.addComponent(rightBarContainer);
    helperLayout.setExpandRatio(windowCenterArea, 100);

    windowBody.addComponent(topBarContainer);
    windowBody.addComponent(helperLayout);
    windowBody.setExpandRatio(helperLayout, 100);
    windowBody.addComponent(bottomBarContainer);
    //-------------------------------------------------------------------
}

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);//from   www.  ja  va  2  s .c o  m
    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.addons.forms.GridForm.java

License:Apache License

public GridForm(int cols, int rows) {
    super(new GridLayout(cols, rows));
    getLayout().setSpacing(true);/*from  w w  w . j  ava 2 s.  c  om*/
    getLayout().setMargin(false, false, true, false);
}

From source file:org.vaadin.addons.sitekit.flow.AbstractFlowlet.java

License:Apache License

@Override
public final void attach() {
    super.attach();
    this.setSizeFull();

    rootLayout = new GridLayout(1, 2);
    rootLayout.setMargin(true);/*w  w w  .jav a  2  s . c om*/
    rootLayout.setSpacing(true);
    rootLayout.setSizeFull();
    rootLayout.setRowExpandRatio(0, 0f);
    rootLayout.setRowExpandRatio(1, 1f);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, true, false));
    titleLayout.setSpacing(true);

    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-" + getFlowletKey()));
    titleIcon.setWidth(32, UNITS_PIXELS);
    titleIcon.setHeight(32, UNITS_PIXELS);
    titleLayout.addComponent(titleIcon);

    final Label titleLabel = new Label("<h1>" + getSite().localize("view-" + getFlowletKey()) + "</h1>",
            Label.CONTENT_XHTML);
    titleLayout.addComponent(titleLabel);
    rootLayout.addComponent(titleLayout, 0, 0);

    setCompositionRoot(rootLayout);

    initialize();
}

From source file:org.vaadin.addons.sitekit.flow.AbstractFlowViewlet.java

License:Apache License

@Override
public final void attach() {
    super.attach();

    final GridLayout layout = new GridLayout(1, 3);
    layout.setSizeFull();/*  w ww .j a v a  2s . c o m*/
    this.setCompositionRoot(layout);
    layout.setRowExpandRatio(1, 1.0f);
    layout.setMargin(false);
    layout.setSpacing(true);

    topLayout = new HorizontalLayout();
    layout.addComponent(topLayout, 0, 0);

    topBackButton = new Button(getSite().localize("button-back"));
    topBackButton.setEnabled(false);
    topBackButton.addListener(this);
    topLayout.addComponent(topBackButton);
    topLayout.setExpandRatio(topBackButton, 0.0f);

    topPathLabel = new Label("", Label.CONTENT_XHTML);

    topLayout.addComponent(topPathLabel);
    topLayout.setComponentAlignment(topPathLabel, Alignment.MIDDLE_LEFT);
    topLayout.setExpandRatio(topPathLabel, 1f);

    topRightLayout = new HorizontalLayout();
    topLayout.addComponent(topRightLayout);
    topLayout.setComponentAlignment(topRightLayout, Alignment.MIDDLE_RIGHT);
    topLayout.setExpandRatio(topRightLayout, 0.0f);
    topLayout.setWidth(100, Unit.PERCENTAGE);

    bottomLayout = new HorizontalLayout();
    layout.addComponent(bottomLayout, 0, 2);

    bottomBackButton = new Button(getSite().localize("button-back"));
    bottomBackButton.setEnabled(false);
    bottomBackButton.addListener(this);
    bottomLayout.addComponent(bottomBackButton);
    bottomLayout.setExpandRatio(bottomBackButton, 0f);

    bottomPathLabel = new Label("", Label.CONTENT_XHTML);

    bottomLayout.addComponent(bottomPathLabel);
    bottomLayout.setExpandRatio(bottomPathLabel, 1f);
    bottomLayout.setComponentAlignment(bottomPathLabel, Alignment.MIDDLE_LEFT);

    bottomRightLayout = new HorizontalLayout();
    bottomLayout.addComponent(bottomRightLayout);
    bottomLayout.setComponentAlignment(bottomRightLayout, Alignment.MIDDLE_RIGHT);
    bottomLayout.setExpandRatio(bottomRightLayout, 0f);
    bottomLayout.setWidth(100, Unit.PERCENTAGE);

    tabSheet = new TabSheet();
    tabSheet.setStyleName("flow-sheet");
    tabSheet.hideTabs(true);
    tabSheet.setSizeFull();
    layout.addComponent(tabSheet, 0, 1);

    addFlowlets();

    tabSheet.setSelectedTab((Component) getRootFlowlet());
}