List of usage examples for com.vaadin.ui GridLayout GridLayout
public GridLayout(int columns, int rows)
From source file:com.scsb.vaadin.composite.MessageBox.java
License:Apache License
/** * Similar to {@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. * //from www .j a va2 s . c om * @param messageComponent a Vaadin component */ public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon, Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) { super(); setResizable(false); setClosable(false); setSizeUndefined(); setWidth(dialogWidth); //setHeight(dialogHeight); setCaption(dialogCaption); GridLayout mainLayout = new GridLayout(2, 2); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setSizeUndefined(); mainLayout.setWidth(GRID_DEFAULT_WIDTH1); // Add Content messageComponent.setSizeUndefined(); messageComponent.setWidth(GRID_DEFAULT_WIDTH2); 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); Embedded icon = null; switch (dialogIcon) { case QUESTION: icon = new Embedded(null, new ThemeResource("./images/question.png")); break; case INFO: icon = new Embedded(null, new ThemeResource("./images/info.png")); break; case WARN: icon = new Embedded(null, new ThemeResource("./images/warn.png")); break; case ERROR: icon = new Embedded(null, new ThemeResource("./images/error.png")); break; } mainLayout.addComponent(icon, 0, 0); icon.setWidth(ICON_DEFAULT_SIZE); icon.setHeight(ICON_DEFAULT_SIZE); } // Add Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); mainLayout.addComponent(buttonLayout, 0, 1, 1, 1); mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment); for (ButtonConfig buttonConfig : buttonConfigs) { Button button = new Button(buttonConfig.getCaption(), new ButtonClickListener(buttonConfig.getButtonType())); if (buttonConfig.getWidth() != null) { button.setWidth(buttonConfig.getWidth()); } if (buttonConfig.getOptionalResource() != null) { button.setIcon(buttonConfig.getOptionalResource()); } else { Resource icon = null; switch (buttonConfig.getButtonType()) { case ABORT: icon = new ThemeResource("images/famfamfam/cross.png"); break; case CANCEL: icon = new ThemeResource("images/famfamfam/cross.png"); break; case CLOSE: icon = new ThemeResource("images/famfamfam/door.png"); break; case HELP: icon = new ThemeResource("images/famfamfam/lightbulb.png"); break; case OK: icon = new ThemeResource("images/famfamfam/tick.png"); break; case YES: icon = new ThemeResource("images/famfamfam/tick.png"); break; case NO: icon = new ThemeResource("images/famfamfam/cross.png"); break; case SAVE: icon = new ThemeResource("images/famfamfam/disk.png"); break; case RETRY: icon = new ThemeResource("images/famfamfam/arrow_refresh.png"); break; case IGNORE: icon = new ThemeResource("images/famfamfam/lightning_go.png"); break; } button.setIcon(icon); } buttonLayout.addComponent(button); } setContent(mainLayout); }
From source file:com.skysql.manager.ui.components.ParametersLayout.java
License:Open Source License
/** * Display backup info.//from w w w . j a va 2 s. co m * * @param layout the layout * @param record the record */ final public void displayBackupInfo(VerticalLayout layout, BackupRecord record) { String value; String values[] = { (value = record.getNode()) != null ? value : NOT_AVAILABLE, (value = record.getLevelAsString()) != null ? value : NOT_AVAILABLE, ((record.getLevel() != null) && (record.getLevel().equals(BackupRecord.BACKUP_TYPE_INCREMENTAL)) && ((value = record.getParent()) != null)) ? value : "-", ((value = record.getState()) != null) && (value = BackupStates.getDescriptions().get(value)) != null ? value : "Invalid", (value = record.getSize()) != null ? value : NOT_AVAILABLE }; GridLayout newBackupInfoGrid = new GridLayout(2, backupLabels.length); newBackupInfoGrid.setSpacing(true); for (int i = 0; i < backupLabels.length; i++) { newBackupInfoGrid.addComponent(new Label(backupLabels[i]), 0, i); newBackupInfoGrid.addComponent(new Label(values[i]), 1, i); } if (backupInfoGrid == null) { layout.addComponent(newBackupInfoGrid); backupInfoGrid = newBackupInfoGrid; } else { layout.replaceComponent(backupInfoGrid, newBackupInfoGrid); backupInfoGrid = newBackupInfoGrid; } // SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); // LinkedHashMap<String, String> sysProperties = systemInfo.getCurrentSystem().getProperties(); // String EIP = sysProperties.get(SystemInfo.PROPERTY_EIP); // if (EIP != null) { // String url = "http://" + EIP + "/consoleAPI/" + record.getLog(); // Link newBackupLogLink = new Link("Backup Log", new ExternalResource(url)); // newBackupLogLink.setTargetName("_blank"); // newBackupLogLink.setDescription("Open backup log in a new window"); // newBackupLogLink.setIcon(new ThemeResource("img/externalLink.png")); // newBackupLogLink.addStyleName("icon-after-caption"); // if (backupLogLink == null) { // layout.addComponent(newBackupLogLink); // backupLogLink = newBackupLogLink; // } else { // layout.replaceComponent(backupLogLink, newBackupLogLink); // backupLogLink = newBackupLogLink; // } // } }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the current info.//w ww.ja v a 2 s . c o m * * @param labels the labels * @param values the values * @return the component */ private Component createCurrentInfo(Label[] labels, String[] values) { GridLayout currentGrid = new GridLayout(2, labels.length); currentGrid.addStyleName("currentInfo"); currentGrid.setSpacing(true); currentGrid.setMargin(new MarginInfo(false, false, false, true)); currentGrid.setSizeUndefined(); for (int i = 0; i < labels.length; i++) { Label label = new Label(values[i]); label.setSizeUndefined(); currentGrid.addComponent(label, 0, i); labels[i] = new Label(""); labels[i].setSizeUndefined(); currentGrid.addComponent(labels[i], 1, i); } return (currentGrid); }
From source file:com.tapas.evidence.fe.child.ChildDetailForm.java
License:Apache License
public ChildDetailForm() { layout = new GridLayout(2, 4); vLayout = new VerticalLayout(); vLayout.setSpacing(true);//w w w.j a v a 2 s . c o m //layout.setMargin(false, false, false, false); layout.setSpacing(true); layout.addComponent(vLayout, 1, 0); setLayout(layout); }
From source file:com.tapas.evidence.fe.responsible.ResponsiblePersonDetailForm.java
License:Apache License
public ResponsiblePersonDetailForm() { layout = new GridLayout(2, 6); vLayout = new VerticalLayout(); vLayout.setSizeUndefined();//from w w w .j a va 2s. c o m vLayout.setSpacing(true); //layout.setMargin(false, false, false, false); layout.setSpacing(true); layout.addComponent(vLayout, 1, 0); setLayout(layout); }
From source file:com.tapas.evidence.fe.teacher.TeacherDetailForm.java
License:Apache License
public TeacherDetailForm() { layout = new GridLayout(2, 6); vLayout = new VerticalLayout(); vLayout.setSizeUndefined();/* w w w . ja va 2s .com*/ vLayout.setSpacing(true); //layout.setMargin(false, false, false, false); layout.setSpacing(true); layout.addComponent(vLayout, 1, 0); setLayout(layout); }
From source file:com.terralcode.gestion.frontend.view.widgets.desplegable.ComponenteDesplegableView.java
private Component buildCustomerDetail() { GridLayout miGrid = new GridLayout(3, 2); ComboBox combo = new ComboBox(); combo.addValueChangeListener(new Property.ValueChangeListener() { @Override//from w w w. jav a 2 s . c om public void valueChange(Property.ValueChangeEvent event) { seleccion = (String) event.getProperty().getValue(); } }); combo.addItems("Pocino Ibrico", "Pocino Blanco", "Ovino", "Vacuno", "Avicultura", "Otros"); // combo.addItem(especies); Label informacion = new Label("datos"); Button botonMas = new Button("+"); botonMas.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Integer clave; if (valores.containsValue(seleccion)) { clave = 1; if (!valores.isEmpty()) { clave = valores.size() + 1; } valores.put(clave, seleccion); } informacion.setValue(mostrarValores()); Notification.show(seleccion + " aadido"); } }); Button botonMenos = new Button("-"); miGrid.addComponent(informacion, 0, 0); miGrid.addComponent(combo, 0, 1); miGrid.addComponent(botonMas, 1, 1); miGrid.addComponent(botonMenos, 2, 1); return miGrid; }
From source file:com.tripoin.util.ui.calendar.CalendarActionsUI.java
License:Apache License
@SuppressWarnings("deprecation") @Override//from w ww . j a v a2 s . co 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() { /** * */ private static final long serialVersionUID = -9176166330213062162L; public final Action NEW_EVENT = new Action("Add event"); @SuppressWarnings("unused") 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() { /** * */ private static final long serialVersionUID = -9193155583440680362L; @Override public void buttonClick(ClickEvent event) { calendar.setEndDate(new Date(100, 1, 7)); } })); content.setRowExpandRatio(0, 1); }
From source file:com.tripoin.util.ui.calendar.HiddenFwdBackButtons.java
License:Apache License
@SuppressWarnings("deprecation") @Override//from ww w . j a v a2s .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, 1, 7)); content.addComponent(calendar); Button button = new Button("Hide forward and back buttons"); button.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 7195717021662140155L; @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.tripoin.util.ui.calendar.NotificationTestUI.java
License:Apache License
@Override protected void init(com.vaadin.server.VaadinRequest request) { GridLayout content = new GridLayout(1, 2); content.setSizeFull();// w ww . j ava 2 s . c om content.setRowExpandRatio(1, 1.0f); setContent(content); final Button btn = new Button("Show working notification", new Button.ClickListener() { /** * */ private static final long serialVersionUID = -165570248584063787L; @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() { /** * */ private static final long serialVersionUID = 1903111449161995776L; @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); }