Search in sources :

Example 31 with GridLayout

use of com.vaadin.ui.GridLayout in project ANNIS by korpling.

the class CorpusListPanel method initCorpusBrowser.

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();
    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, Unit.EM);
    window.setHeight(45, Unit.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();
}
Also used : Window(com.vaadin.ui.Window) GridLayout(com.vaadin.ui.GridLayout) CorpusBrowserPanel(annis.gui.CorpusBrowserPanel) MetaDataPanel(annis.gui.MetaDataPanel) AnnisCorpus(annis.service.objects.AnnisCorpus) Label(com.vaadin.ui.Label)

Example 32 with GridLayout

use of com.vaadin.ui.GridLayout in project linkki by linkki-framework.

the class UiCustomFieldTest method testAvailableValues_NotApplicable.

@Test
public void testAvailableValues_NotApplicable() {
    GridLayout section = TestUiUtil.createSectionWith(pmo);
    TextField textField = TestUiUtil.getComponentAt(section, 1);
    // the real test is that this text field could be created, just check the value to check anything
    assertThat(textField.getValue(), is("test"));
}
Also used : GridLayout(com.vaadin.ui.GridLayout) TextField(com.vaadin.ui.TextField) Test(org.junit.Test)

Example 33 with GridLayout

use of com.vaadin.ui.GridLayout in project linkki by linkki-framework.

the class SectionCreationContextTest method testSetComponentId.

@Test
public void testSetComponentId() {
    BaseSection section = createContext(new SCCPmoWithID()).createSection();
    assertThat(section.getComponentCount(), is(2));
    Component textField = ((GridLayout) ((Panel) section.getComponent(1)).getContent()).getComponent(1, 0);
    assertThat(textField.getId(), is("testProperty"));
}
Also used : GridLayout(com.vaadin.ui.GridLayout) Component(com.vaadin.ui.Component) Test(org.junit.Test)

Example 34 with GridLayout

use of com.vaadin.ui.GridLayout in project linkki by linkki-framework.

the class FormSection method createContent.

protected GridLayout createContent() {
    int columns = getNumberOfColumns();
    int gridColumns = columns * 3;
    GridLayout gridLayout = new GridLayout(gridColumns, 1);
    gridLayout.setWidth("100%");
    gridLayout.setMargin(new MarginInfo(true, true, true, true));
    gridLayout.setSpacing(true);
    for (int i = 0; i < columns; i++) {
        gridLayout.setColumnExpandRatio(i * 3, 0);
        gridLayout.setColumnExpandRatio(i * 3 + 1, 0);
        gridLayout.setColumnExpandRatio(i * 3 + 2, 1);
    }
    return gridLayout;
}
Also used : GridLayout(com.vaadin.ui.GridLayout) MarginInfo(com.vaadin.shared.ui.MarginInfo)

Example 35 with GridLayout

use of com.vaadin.ui.GridLayout in project VaadinUtils by rlsutton1.

the class DateTimePickerInline method getChangeYearClickListener.

private ClickListener getChangeYearClickListener() {
    return new ClickListener() {

        /**
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            final Window window = new Window();
            GridLayout yearGrid = new GridLayout(5, 20);
            int currentYear = DateTime.now().getYear();
            int endYear = DateTime.now().getYear() + 10;
            int startYear = (endYear - 135);
            for (int year = endYear; year > startYear; year--) {
                final int buttonYear = year;
                Button yearButton = new Button("" + year);
                yearButton.setStyleName(ValoTheme.BUTTON_TINY);
                if (year == currentYear) {
                    yearButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);
                }
                yearButton.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        setValue(new DateTime(getValue().getTime()).withYear(buttonYear).toDate());
                        window.close();
                    }
                });
                yearGrid.addComponent(yearButton);
            }
            Panel scrollPanel = new Panel();
            VerticalLayout container = new VerticalLayout();
            container.addComponent(new Label("Select a year"));
            container.setMargin(true);
            container.addComponent(scrollPanel);
            scrollPanel.setContent(yearGrid);
            scrollPanel.setHeight("200");
            window.setResizable(false);
            window.setContent(container);
            // position window over year button
            int x = event.getClientX();
            int y = event.getClientY();
            int wh = UI.getCurrent().getPage().getBrowserWindowHeight();
            y = Math.max(0, y);
            int heightOfDatePicker = 300;
            y = Math.min(y, wh - heightOfDatePicker);
            int ww = UI.getCurrent().getPage().getBrowserWindowWidth();
            x = Math.max(0, x - 50);
            int widthOfDatePicker = 290;
            x = Math.min(x, ww - widthOfDatePicker);
            // window.setModal(true);
            window.setPosition(x, y);
            window.setClosable(true);
            UI.getCurrent().addWindow(window);
            // add mouse click listener to close window when the user
            // clicks outside of the window
            final MouseEvents.ClickListener listener = new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void click(MouseEvents.ClickEvent event) {
                    window.close();
                }
            };
            UI.getCurrent().addClickListener(listener);
            // tidy up: remove mouse click listener
            window.addCloseListener(new CloseListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void windowClose(CloseEvent e) {
                    UI.getCurrent().removeClickListener(listener);
                }
            });
        }
    };
}
Also used : Window(com.vaadin.ui.Window) CloseEvent(com.vaadin.ui.Window.CloseEvent) ClickEvent(com.vaadin.ui.Button.ClickEvent) Label(com.vaadin.ui.Label) DateTime(org.joda.time.DateTime) MouseEvents(com.vaadin.event.MouseEvents) Panel(com.vaadin.ui.Panel) GridLayout(com.vaadin.ui.GridLayout) Button(com.vaadin.ui.Button) CloseListener(com.vaadin.ui.Window.CloseListener) VerticalLayout(com.vaadin.ui.VerticalLayout) ClickListener(com.vaadin.ui.Button.ClickListener)

Aggregations

GridLayout (com.vaadin.ui.GridLayout)36 Label (com.vaadin.ui.Label)21 Embedded (com.vaadin.ui.Embedded)9 HorizontalLayout (com.vaadin.ui.HorizontalLayout)9 TextField (com.vaadin.ui.TextField)7 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)6 Panel (com.vaadin.ui.Panel)4 Button (com.vaadin.ui.Button)3 PasswordField (com.vaadin.ui.PasswordField)3 VerticalLayout (com.vaadin.ui.VerticalLayout)3 ComboBox (com.vaadin.ui.ComboBox)2 Component (com.vaadin.ui.Component)2 DateField (com.vaadin.ui.DateField)2 Link (com.vaadin.ui.Link)2 TextArea (com.vaadin.ui.TextArea)2 Window (com.vaadin.ui.Window)2 Test (org.junit.Test)2 DefaultPmoBasedSectionFactory (org.linkki.core.ui.section.DefaultPmoBasedSectionFactory)2 CorpusBrowserPanel (annis.gui.CorpusBrowserPanel)1 MetaDataPanel (annis.gui.MetaDataPanel)1