Example usage for com.vaadin.ui GridLayout setRowExpandRatio

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

Introduction

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

Prototype

public void setRowExpandRatio(int rowIndex, float ratio) 

Source Link

Document

Sets the expand ratio of given row.

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();//from   w  w w .  j  a  v a  2  s.  co  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:biz.eelis.translation.EntriesFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    filterDefinitions.add(new FilterDescriptor("basename", "basename", "Basename", new TextField(), 200, "like",
            String.class, ""));

    filterDefinitions.add(new FilterDescriptor("language", "language", "Language", new TextField(), 30, "=",
            String.class, ""));

    filterDefinitions.add(//w  w w.  j a  va2s  .co m
            new FilterDescriptor("country", "country", "Country", new TextField(), 30, "=", String.class, ""));

    filterDefinitions
            .add(new FilterDescriptor("key", "key", "Key", new TextField(), 200, "like", String.class, ""));

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000,
            new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true },
            "entryId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("entryId", true);
    table.setColumnCollapsed("path", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Entry entry = new Entry();
            entry.setCreated(new Date());
            entry.setModified(entry.getCreated());
            entry.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class);
            entryView.edit(entry, true);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Entry entity = container.getEntity(grid.getSelectedItemId());
            final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class);
            entryView.edit(entity, false);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

From source file:biz.eelis.translation.EntryFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 3);
    gridLayout.setSizeFull();//  w  w  w.jav a2 s .c  om
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(2, 1f);
    setViewContent(gridLayout);

    entryEditor = new ValidatingEditor(TranslationSiteFields.getFieldDescriptors(Entry.class));
    entryEditor.setCaption("Entry");
    entryEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(entryEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    buttonLayout.addComponent(saveButton);
    saveButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            entryEditor.commit();
            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entity.setAuthor(getSite().getSecurityProvider().getUser());
                entity.setModified(new Date());
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                entityManager.detach(entity);
                entryEditor.discard();
                container.refresh();
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    buttonLayout.addComponent(discardButton);
    discardButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            entryEditor.discard();
        }
    });

    final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000,
            new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true },
            "entryId");
    container.getQueryView().getQueryDefinition().setMaxQuerySize(1);

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final Table table = new FormattingTable();
    final Grid grid = new Grid(table, container);
    grid.setCaption("All Translations");
    grid.setSizeFull();
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("entryId", true);
    table.setColumnCollapsed("path", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 0, 2);

}

From source file:com.cavisson.gui.dashboard.components.calender.CalendarActionsUI.java

License:Apache License

@SuppressWarnings("deprecation")
@Override// w ww  .  java2s.  c o  m
protected void init(VaadinRequest request) {
    GridLayout content = new GridLayout(1, 2);
    content.setSizeFull();
    setContent(content);

    final Calendar calendar = new Calendar();
    calendar.setLocale(new Locale("fi", "FI"));

    calendar.setSizeFull();
    calendar.setStartDate(new Date(100, 1, 1));
    calendar.setEndDate(new Date(100, 2, 1));

    calendar.addActionHandler(new Action.Handler() {

        public final Action NEW_EVENT = new Action("Add event");
        public final Action EDIT_EVENT = new Action("Edit event");
        public final Action REMOVE_EVENT = new Action("Remove event");

        /*
         * (non-Javadoc)
         * 
         * @see
         * com.vaadin.event.Action.Handler#handleAction(com.vaadin.event
         * .Action, java.lang.Object, java.lang.Object)
         */
        @Override
        public void handleAction(Action action, Object sender, Object target) {
            Date date = (Date) target;
            if (action == NEW_EVENT) {
                BasicEvent event = new BasicEvent("New event", "Hello world", date, date);
                calendar.addEvent(event);
            }
        }

        /*
         * (non-Javadoc)
         * 
         * @see com.vaadin.event.Action.Handler#getActions(java.lang.Object,
         * java.lang.Object)
         */
        @Override
        public Action[] getActions(Object target, Object sender) {
            CalendarDateRange date = (CalendarDateRange) target;

            java.util.Calendar cal = java.util.Calendar.getInstance();
            cal.set(2000, 1, 1, 12, 0, 0);

            if (date.inRange(cal.getTime())) {
                return new Action[] { NEW_EVENT, };
            }

            cal.add(java.util.Calendar.DAY_OF_WEEK, 1);

            if (date.inRange(cal.getTime())) {
                return new Action[] { REMOVE_EVENT };
            }

            return null;
        }
    });

    content.addComponent(calendar);

    content.addComponent(new Button("Set week view", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            calendar.setEndDate(new Date(100, 1, 7));
        }
    }));

    content.setRowExpandRatio(0, 1);

}

From source file:com.cavisson.gui.dashboard.components.calender.HiddenFwdBackButtons.java

License:Apache License

@SuppressWarnings("deprecation")
@Override//  w w  w.ja  v  a2s . com
protected void init(VaadinRequest request) {
    GridLayout content = new GridLayout(1, 2);
    content.setSizeFull();
    setContent(content);

    final Calendar calendar = new Calendar();
    calendar.setLocale(new Locale("fi", "FI"));

    calendar.setSizeFull();
    calendar.setStartDate(new Date(100, 1, 1));
    calendar.setEndDate(new Date(100, 1, 7));
    content.addComponent(calendar);
    Button button = new Button("Hide forward and back buttons");
    button.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // This should hide the forward and back navigation buttons
            calendar.setHandler((BackwardHandler) null);
            calendar.setHandler((ForwardHandler) null);
        }
    });
    content.addComponent(button);

    content.setRowExpandRatio(0, 1);

}

From source file:com.cavisson.gui.dashboard.components.calender.NotificationTestUI.java

License:Apache License

@Override
protected void init(com.vaadin.server.VaadinRequest request) {
    GridLayout content = new GridLayout(1, 2);
    content.setSizeFull();//from ww w . j  a v a2s.co m
    content.setRowExpandRatio(1, 1.0f);
    setContent(content);
    final Button btn = new Button("Show working notification", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("This will disappear when you move your mouse!");
        }
    });
    content.addComponent(btn);

    provider = new DummyEventProvider();
    final Calendar cal = new Calendar(provider);
    cal.setLocale(Locale.US);
    cal.setSizeFull();
    cal.setHandler(new DateClickHandler() {
        @Override
        public void dateClick(DateClickEvent event) {
            provider.addEvent(event.getDate());
            Notification.show("This should disappear, but if wont unless clicked.");

            // this requestRepaint call interferes with the notification
            cal.markAsDirty();
        }
    });
    content.addComponent(cal);

    java.util.Calendar javaCal = java.util.Calendar.getInstance();
    javaCal.set(java.util.Calendar.YEAR, 2000);
    javaCal.set(java.util.Calendar.MONTH, 0);
    javaCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
    Date start = javaCal.getTime();
    javaCal.set(java.util.Calendar.DAY_OF_MONTH, 31);
    Date end = javaCal.getTime();

    cal.setStartDate(start);
    cal.setEndDate(end);
}

From source file:com.esspl.datagen.ui.SettingsView.java

License:Open Source License

public SettingsView(DataGenApplication application) {
    setModal(true);/*  ww  w . j a  v  a 2s  .c o  m*/
    setResizable(false);
    setCaption("Settings");
    setWidth("620px");
    setHeight("440px");
    dataGenApplication = application;

    GridLayout layout = createMainLayout();
    setContent(layout);

    Component bottom = createBottomBar(dataGenApplication);
    layout.addComponent(bottom, 0, 1);
    layout.setComponentAlignment(bottom, Alignment.MIDDLE_RIGHT);
    layout.setRowExpandRatio(0, 1);

    //Context Help added
    contextHelp = new ContextHelp();
    layout.addComponent(contextHelp);

    refreshDetails();
}

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

License:Apache License

/**
 * Similar to/*w w w  .  j  ava2  s.  com*/
 * {@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.project.MyCalendarView.java

License:Apache License

private void initLayoutContent() {
    initNavigationButtons();/*from  w  ww.  jav  a2 s. c om*/
    initHideWeekEndButton();
    initReadOnlyButton();
    initDisabledButton();
    initAddNewEventButton();

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    hl.setSpacing(true);
    hl.setMargin(new MarginInfo(false, false, true, false));
    hl.addComponent(prevButton);
    hl.addComponent(captionLabel);
    hl.addComponent(monthButton);
    hl.addComponent(weekButton);
    hl.addComponent(nextButton);
    hl.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT);
    hl.setComponentAlignment(captionLabel, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);

    monthButton.setVisible(viewMode == Mode.WEEK);
    weekButton.setVisible(viewMode == Mode.DAY);

    HorizontalLayout controlPanel = new HorizontalLayout();
    controlPanel.setSpacing(true);
    controlPanel.setMargin(new MarginInfo(false, false, true, false));
    controlPanel.setWidth("100%");
    //controlPanel.addComponent(localeSelect);
    //controlPanel.addComponent(timeZoneSelect);
    controlPanel.addComponent(formatSelect);
    controlPanel.addComponent(hideWeekendsButton);
    //controlPanel.addComponent(readOnlyButton);
    //controlPanel.addComponent(disabledButton);
    controlPanel.addComponent(addNewEvent);

    /*controlPanel.setComponentAlignment(timeZoneSelect,
        Alignment.MIDDLE_LEFT);*/
    controlPanel.setComponentAlignment(formatSelect, Alignment.MIDDLE_LEFT);
    /*controlPanel.setComponentAlignment(localeSelect, Alignment.MIDDLE_LEFT);*/
    controlPanel.setComponentAlignment(hideWeekendsButton, Alignment.MIDDLE_LEFT);
    /* controlPanel.setComponentAlignment(readOnlyButton,
        Alignment.MIDDLE_LEFT);
     controlPanel.setComponentAlignment(disabledButton,
        Alignment.MIDDLE_LEFT);*/
    controlPanel.setComponentAlignment(addNewEvent, Alignment.MIDDLE_LEFT);

    GridLayout layout = (GridLayout) getContent();
    layout.addComponent(controlPanel);
    layout.addComponent(hl);
    layout.addComponent(calendarComponent);
    layout.setRowExpandRatio(layout.getRows() - 1, 1.0f);
}

From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java

License:Apache License

private void setupAddFilterWindow(Window window) {
    // General variables

    // Layouts//w w w.j  a  v a 2s.co m
    GridLayout mainLayout = new GridLayout(1, 3);
    HorizontalLayout axisLayout = new HorizontalLayout();
    HorizontalLayout criteriaLayout = new HorizontalLayout();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    hznCriteria = criteriaLayout;

    // Buttons
    ExpressZipButton btnAdd = new ExpressZipButton("Add", Style.ACTION);
    btnAdd.setClickShortcut(KeyCode.ENTER);
    btnAdd.addStyleName("primary");
    ExpressZipButton btnCancel = new ExpressZipButton("Cancel", Style.ACTION);

    // Fields
    ComboBox cmbAxis = new ComboBox();
    cmbAxis.setTextInputAllowed(false);
    cmbAxis.setNullSelectionAllowed(false);

    // Labels
    Label lblAxis = new Label("Axis");

    btnAdd.addListener(filterButtonListener);
    btnCancel.addListener(filterButtonListener);

    for (Filter.AxisFilters f : Filter.axisArray) {
        cmbAxis.addItem(filter.getNameOfFilter(f));
    }
    cmbAxis.setImmediate(true);
    cmbAxis.addListener(axisSelectedListener);
    cmbAxis.setValue(filter.getNameOfFilter(Filter.axisArray[0]));

    mainLayout.addComponent(axisLayout, 0, 0);
    mainLayout.addComponent(criteriaLayout, 0, 1);
    mainLayout.addComponent(buttonLayout, 0, 2);
    mainLayout.setSpacing(true);

    axisLayout.setSpacing(true);

    axisLayout.addComponent(lblAxis);
    axisLayout.addComponent(cmbAxis);
    axisLayout.setExpandRatio(lblAxis, .2f);
    axisLayout.setExpandRatio(cmbAxis, .8f);
    axisLayout.setComponentAlignment(lblAxis, Alignment.MIDDLE_LEFT);
    axisLayout.setComponentAlignment(cmbAxis, Alignment.MIDDLE_LEFT);
    axisLayout.setSizeFull();

    criteriaLayout.setSizeFull();

    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(btnAdd);
    buttonLayout.addComponent(btnCancel);
    buttonLayout.setComponentAlignment(btnAdd, Alignment.BOTTOM_RIGHT);
    buttonLayout.setComponentAlignment(btnCancel, Alignment.BOTTOM_RIGHT);
    buttonLayout.setExpandRatio(btnAdd, 1f);
    buttonLayout.setExpandRatio(btnCancel, 0f);
    buttonLayout.setSizeFull();

    mainLayout.setRowExpandRatio(0, 1f);
    mainLayout.setRowExpandRatio(1, 1f);
    mainLayout.setRowExpandRatio(2, 1f);
    mainLayout.setSizeFull();

    window.addComponent(mainLayout);
    window.getContent().setSizeFull();
}