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();
}
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"));
}
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"));
}
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;
}
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);
}
});
}
};
}
Aggregations