Example usage for com.vaadin.ui GridLayout setColumnExpandRatio

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

Introduction

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

Prototype

public void setColumnExpandRatio(int columnIndex, float ratio) 

Source Link

Document

Sets the expand ratio of given column.

Usage

From source file:annis.gui.controlpanel.CorpusListPanel.java

License:Apache License

public void initCorpusBrowser(String topLevelCorpusName, final Button l) {

    AnnisCorpus c = ui.getQueryState().getAvailableCorpora().getItem(topLevelCorpusName).getBean();
    MetaDataPanel meta = new MetaDataPanel(c.getName());

    CorpusBrowserPanel browse = new CorpusBrowserPanel(c, ui.getQueryController());
    GridLayout infoLayout = new GridLayout(2, 2);
    infoLayout.setSizeFull();/* w w w.j ava 2s.c  o m*/

    String corpusURL = Helper.generateCorpusLink(Sets.newHashSet(topLevelCorpusName));
    Label lblLink = new Label("Link to corpus: <a href=\"" + corpusURL + "\">" + corpusURL + "</a>",
            ContentMode.HTML);
    lblLink.setHeight("-1px");
    lblLink.setWidth("-1px");

    infoLayout.addComponent(meta, 0, 0);
    infoLayout.addComponent(browse, 1, 0);
    infoLayout.addComponent(lblLink, 0, 1, 1, 1);

    infoLayout.setRowExpandRatio(0, 1.0f);
    infoLayout.setColumnExpandRatio(0, 0.5f);
    infoLayout.setColumnExpandRatio(1, 0.5f);
    infoLayout.setComponentAlignment(lblLink, Alignment.MIDDLE_CENTER);

    Window window = new Window("Corpus information for " + c.getName() + " (ID: " + c.getId() + ")",
            infoLayout);
    window.setWidth(70, UNITS_EM);
    window.setHeight(45, UNITS_EM);
    window.setResizable(true);
    window.setModal(false);
    window.setResizeLazy(true);

    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            l.setEnabled(true);
        }
    });

    UI.getCurrent().addWindow(window);
    window.center();
}

From source file:at.peppol.webgui.app.components.TabInvoiceHeader.java

License:Mozilla Public License

private void initElements() {
    additionalDocRefList = parent.getInvoice().getAdditionalDocumentReference();
    setWidth("100%");
    setHeight("100%");
    //final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    //outerLayout.setMargin(true);
    //outerLayout.setSpacing(true);

    //grid that contains "Details", "Contract", "Order"
    final GridLayout topGridLayout = new GridLayout(2, 2);
    //topGridLayout.setSizeFull();
    topGridLayout.setMargin(true);/*from  w  w  w. j a va  2s  .c o  m*/
    topGridLayout.setSpacing(true);

    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);
    hiddenContent.setMargin(true);

    final Panel outerPanel = new Panel("Invoice Header");
    //outerPanel.addComponent(grid);
    outerPanel.setScrollable(true);
    outerPanel.setContent(outerLayout);
    //outerLayout.addComponent(outerPanel);

    VerticalLayout tabLayout = new VerticalLayout();
    tabLayout.addComponent(outerPanel);

    outerLayout.addComponent(topGridLayout);

    final Panel invoiceDetailsPanel = new Panel("Invoice Header Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setWidth("50%");
    //invoiceDetailsPanel.setSizeFull();
    invoiceDetailsPanel.addComponent(createInvoiceTopForm());
    topGridLayout.addComponent(invoiceDetailsPanel, 0, 0);

    final Panel orderReferencePanel = new Panel("Referencing Order");
    orderReferencePanel.setStyleName("light");
    orderReferencePanel.setWidth("50%");
    //orderReferencePanel.setSizeFull();
    orderReferencePanel.addComponent(createInvoiceOrderReferenceForm());
    topGridLayout.addComponent(orderReferencePanel, 0, 1);

    final VerticalLayout tableVerticalLayout = new VerticalLayout();
    //tableVerticalLayout.setSpacing (true);
    tableVerticalLayout.setMargin(true);
    outerLayout.addComponent(tableVerticalLayout);

    table = new InvoiceAdditionalDocRefTable(parent.getInvoice().getAdditionalDocumentReference());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setSizeFull();
    //table.setWidth("300px");
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    Panel tablePanel = new Panel("Relevant Documents");
    tablePanel.setStyleName("light");
    tablePanel.setWidth("60%");
    tableVerticalLayout.addComponent(tablePanel);

    GridLayout h = new GridLayout(2, 2);
    h.setMargin(true);
    h.setSpacing(true);
    tablePanel.setContent(h);
    h.addComponent(table, 0, 0);
    h.setColumnExpandRatio(0, 3);
    h.setColumnExpandRatio(1, 1);
    h.setSizeFull();

    Button addButton = new Button("Add new");
    Button editButton = new Button("Edit selected");
    Button deleteButton = new Button("Delete selected");

    VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addButton);
    buttonsContainer.addComponent(editButton);
    buttonsContainer.addComponent(deleteButton);

    InvoiceAdditionalDocRefTableEditor editor = new InvoiceAdditionalDocRefTableEditor(editMode);
    Label label = new Label("<h3>Adding new relevant document</h3>", Label.CONTENT_XHTML);
    addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table,
            additionalDocRefList, label));
    label = new Label("<h3>Edit relevant document</h3>", Label.CONTENT_XHTML);
    editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table,
            additionalDocRefList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    final Button addContractReferenceBtn = new Button("Add Contract Reference");
    final Button removeContractReferenceBtn = new Button("Remove Contract Reference");
    removeContractReferenceBtn.setVisible(false);
    addContractReferenceBtn.setStyleName("marginLeft");
    removeContractReferenceBtn.setStyleName("marginLeft");

    addContractReferenceBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Panel panel = createInvoiceContractReference(removeContractReferenceBtn);
            topGridLayout.removeComponent(1, 0);
            topGridLayout.addComponent(panel, 1, 0);
            removeContractReferenceBtn.setVisible(true);
        }
    });

    removeContractReferenceBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            //remove the legal entity component panel
            Component c = removeContractReferenceBtn.getParent().getParent();
            topGridLayout.removeComponent(c);
            if (parent.getInvoice().getContractDocumentReference().size() > 0) {
                //parent.getInvoice().getContractDocumentReference().remove(0);
                parent.getInvoice().getContractDocumentReference().clear();
                ValidatorsList.removeListeners(Utils.getFieldListeners(contractReferenceForm));
            }

            topGridLayout.addComponent(addContractReferenceBtn, 1, 0);
        }
    });

    h.addComponent(buttonsContainer, 1, 0);
    topGridLayout.addComponent(addContractReferenceBtn, 1, 0);
    if (parent.getInvoice().getContractDocumentReference().size() > 0)
        addContractReferenceBtn.click();

    // ---- HIDDEN FORM BEGINS -----
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);

    h.addComponent(formLayout, 0, 1);
    // ---- HIDDEN FORM ENDS -----

    setLayout(tabLayout);
}

From source file:com.esofthead.mycollab.module.crm.ui.components.PeopleInfoComp.java

License:Open Source License

public void displayEntryPeople(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(new MarginInfo(true, false, true, true));

    Label peopleInfoHeader = new Label(
            FontAwesome.USER.getHtml() + " " + AppContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE),
            ContentMode.HTML);/*from   w w  w  .j ava2s .  co m*/
    peopleInfoHeader.setStyleName("info-hdr");
    this.addComponent(peopleInfoHeader);

    GridLayout layout = new GridLayout(2, 2);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setMargin(new MarginInfo(false, false, false, true));
    try {
        Label createdLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_PEOPLE));
        createdLbl.setSizeUndefined();
        layout.addComponent(createdLbl, 0, 0);

        String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser");
        String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId");
        String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName");

        UserLink createdUserLink = new UserLink(createdUserName, createdUserAvatarId, createdUserDisplayName);
        layout.addComponent(createdUserLink, 1, 0);
        layout.setColumnExpandRatio(1, 1.0f);

        Label assigneeLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_ASSIGN_PEOPLE));
        assigneeLbl.setSizeUndefined();
        layout.addComponent(assigneeLbl, 0, 1);
        String assignUserName = (String) PropertyUtils.getProperty(bean, "assignuser");
        String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "assignUserAvatarId");
        String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "assignUserFullName");

        UserLink assignUserLink = new UserLink(assignUserName, assignUserAvatarId, assignUserDisplayName);
        layout.addComponent(assignUserLink, 1, 1);
    } catch (Exception e) {
        LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean));
    }

    this.addComponent(layout);

}

From source file:com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl.AbstractMenuItemFactoryImpl.java

License:Apache License

protected final void createButtonLink(final GridLayout panelContent, final String linkText, final Resource icon,
        final ClickListener command, final String description) {
    final GridLayout grid = new GridLayout(2, 1);
    grid.setWidth(100, Unit.PERCENTAGE);
    grid.setHeight(100, Unit.PERCENTAGE);
    grid.setColumnExpandRatio(0, 1);
    grid.setColumnExpandRatio(1, 2);//ww w  . j  ava 2s . c o m

    final Button b = new Button(linkText);
    b.setStyleName("link");
    b.addClickListener(command);
    b.setWidth(100, Unit.PERCENTAGE);

    b.setIcon(icon);
    b.setWidth(100, Unit.PERCENTAGE);

    grid.addComponent(b, 0, 0);
    grid.setComponentAlignment(b, Alignment.MIDDLE_LEFT);

    final Label descriptionLabel = new Label(description);
    descriptionLabel.setWidth(100, Unit.PERCENTAGE);
    grid.addComponent(descriptionLabel, 1, 0);
    grid.setComponentAlignment(descriptionLabel, Alignment.MIDDLE_LEFT);

    panelContent.addComponent(grid);
    panelContent.setComponentAlignment(grid, Alignment.MIDDLE_LEFT);
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl.AbstractMenuItemFactoryImpl.java

License:Apache License

protected final GridLayout createGridLayout(final VerticalLayout panelContent) {
    final GridLayout grid = new GridLayout(2, 1);
    grid.setWidth(100, Unit.PERCENTAGE);
    grid.setHeight(100, Unit.PERCENTAGE);
    grid.setColumnExpandRatio(0, 1);
    grid.setColumnExpandRatio(1, 1);// w w  w .  j a  va 2  s .  co m
    grid.setSpacing(true);
    panelContent.addComponent(grid);
    panelContent.setExpandRatio(grid, ContentRatio.LARGE);
    return grid;
}

From source file:com.javalego.ui.vaadin.component.util.MessageBox.java

License:Apache License

/**
 * Similar to/* w  w  w  . j av a2s.c om*/
 * {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)}
 * , but the message component is defined explicitly. The component can be
 * even a composite of a layout manager and manager further Vaadin
 * components.
 * 
 * @param messageComponent
 *            a Vaadin component
 */
public MessageBox(String dialogCaption, Icon dialogIcon, Component messageComponent, Alignment buttonsAlignment,
        ButtonConfig... buttonConfigs) {

    super();

    setResizable(false);
    setClosable(false);

    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    mainLayout.setSizeUndefined();
    messageComponent.setSizeUndefined();

    // Add Content
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {

        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);

        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        //         Label icon = new Label();
        //         switch (dialogIcon) {
        //         case QUESTION:
        //            icon.setIcon(FontAwesome.QUESTION);
        //            break;
        //         case INFO:
        //            icon.setIcon(FontAwesome.INFO);
        //            break;
        //         case WARN:
        //            icon.setIcon(FontAwesome.WARNING);
        //            break;
        //         case ERROR:
        //            icon.setIcon(FontAwesome.STOP);
        //            break;
        //         default:
        //            break;
        //         }
        //         mainLayout.addComponent(icon, 0, 0);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);

    for (ButtonConfig buttonConfig : buttonConfigs) {

        ButtonExt button = new ButtonExt(buttonConfig.getCaption());

        //         if (buttonConfig.buttonType == ButtonType.YES || buttonConfig.buttonType == ButtonType.OK) {
        //            button.blue();
        //         }

        button.addClickListener(new ButtonClickListener(buttonConfig.getButtonType()));
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java

License:Apache License

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(5, 2);
    taskDetails.setWidth(100, UNITS_PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);/*w w w  .j a  va2 s .c om*/
    taskDetails.setMargin(new MarginInfo(false, false, true, false));

    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(historicTask.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0, 4, 0);

    // Add due date
    PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT),
            historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false);
    dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE);
    taskDetails.addComponent(dueDateLabel, 1, 1);

    // Add priority
    Integer lowMedHighPriority = convertPriority(historicTask.getPriority());
    Label priorityLabel = new Label();
    switch (lowMedHighPriority) {
    case 1:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW);
        break;
    case 2:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM);
        break;
    case 3:
    default:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH);
    }
    taskDetails.addComponent(priorityLabel, 2, 1);

    // Add create date
    PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT),
            historicTask.getStartTime(), "", true);
    createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME);
    taskDetails.addComponent(createLabel, 3, 1);

    // Add label to fill excess space
    Label spacer = new Label();
    spacer.setContentMode(Label.CONTENT_XHTML);
    spacer.setValue("&nbsp;");
    spacer.setSizeUndefined();
    taskDetails.addComponent(spacer);

    taskDetails.setColumnExpandRatio(1, 1.0f);
    taskDetails.setColumnExpandRatio(2, 1.0f);
    taskDetails.setColumnExpandRatio(3, 1.0f);
    taskDetails.setColumnExpandRatio(4, 1.0f);
    centralLayout.addComponent(taskDetails);
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(2, 2);
    taskDetails.setWidth(100, Unit.PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);/*from  w w w.j ava  2s  .c o  m*/
    taskDetails.setMargin(new MarginInfo(false, false, true, false));
    taskDetails.setColumnExpandRatio(1, 1.0f);
    centralLayout.addComponent(taskDetails);

    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    //??
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(task.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0);
    taskDetails.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT);

    // Properties
    HorizontalLayout propertiesLayout = new HorizontalLayout();//
    propertiesLayout.setSpacing(true);
    taskDetails.addComponent(propertiesLayout);

    propertiesLayout.addComponent(new DueDateComponent(task, i18nManager, taskService));
    propertiesLayout.addComponent(new PriorityComponent(task, i18nManager, taskService));
    //?
    initCreateTime(propertiesLayout);
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.DayWidget.java

public DayWidget() {

    //Creating Panel
    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setWidth("876px");
    iPanel.setHeight("41px");

    ProgressBar iDayProgressBar = new ProgressBar();
    iDayProgressBar.setCaption("Period 3, 10th October");
    iDayProgressBar.setWidth("875px");
    iDayProgressBar.setValue(0.3f);/*ww  w.  j a v a2 s  . c  om*/
    addComponent(iDayProgressBar);

    //Adding Panel to Vertical Layout
    addComponent(iPanel);
    VerticalLayout iVerticalLayout = new VerticalLayout();

    GridLayout iGridLayout = new GridLayout(9, 1);
    iGridLayout.setWidth("1000px");
    iGridLayout.setHeight("40px");

    for (int i = 1; i <= 8; i++) {

        HourWidget iHourAtAGlanceWidget = new HourWidget(i, 8);
        iHourAtAGlanceWidget.setSizeFull();
        iGridLayout.addComponent(iHourAtAGlanceWidget);
        iGridLayout.setColumnExpandRatio(i, 1);
    }

    iVerticalLayout.addComponent(iGridLayout);
    iPanel.setContent(iVerticalLayout);

}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoDetails.java

License:Open Source License

private Component createProcessInfo(LspsUI ui) {
    ModelInstanceInfo instance = processService.getModelInstanceInfo(todo.getModelInstanceId());

    GridLayout grid = new GridLayout(2, 10);
    grid.setMargin(true);/*ww w. ja v a 2s .  c o  m*/
    grid.setSpacing(true);
    grid.setWidth("100%");
    grid.setColumnExpandRatio(0, 1);
    grid.setColumnExpandRatio(1, 2);

    grid.addComponent(new Label(ui.getMessage("process.id")));
    grid.addComponent(new Label(String.valueOf(instance.getId())));

    grid.addComponent(new Label(ui.getMessage("process.model")));
    grid.addComponent(new Label(instance.getModelName() + " - " + instance.getModelVersion()));

    grid.addComponent(new Label(ui.getMessage("process.started")));
    grid.addComponent(new Label(
            new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(instance.getStartedDate())));

    grid.addComponent(new Label(ui.getMessage("process.finished")));
    grid.addComponent(new Label(instance.getFinishedDate() == null ? ""
            : new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(instance.getFinishedDate())));

    String status = "???";
    switch (instance.getState()) {
    case CREATED:
        status = ui.getMessage("process.statusCreated");
        break;
    case FINISHED:
        status = ui.getMessage("process.statusFinished");
        break;
    case RUNNING:
        status = ui.getMessage("process.statusRunning");
        break;
    case SUSPENDED:
        status = ui.getMessage("process.statusSuspended");
        break;
    case MODEL_UPDATE_PREPROCESSING:
        status = ui.getMessage("process.statusPreprocessing");
        break;
    case MODEL_UPDATE_PREPROCESSED:
        status = ui.getMessage("process.statusPreprocessed");
        break;
    case MODEL_UPDATE_TRANSFORMED:
        status = ui.getMessage("process.statusTransformed");
        break;
    case MODEL_UPDATE_POSTPROCESSING:
        status = ui.getMessage("process.statusPostprocessing");
        break;
    case MODEL_UPDATE_UPDATED:
        status = ui.getMessage("process.statusUpdated");
        break;
    case MODEL_UPDATE_ABORTED:
        status = ui.getMessage("process.statusUpdateAborted");
        break;
    }
    grid.addComponent(new Label(ui.getMessage("process.status")));
    grid.addComponent(new Label(status));

    return grid;
}