Example usage for com.vaadin.ui GridLayout GridLayout

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

Introduction

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

Prototype

public GridLayout(int columns, int rows) 

Source Link

Document

Constructor for a grid of given size (number of columns and rows).

Usage

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfile3Top.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
@HibernateUserRead//from w  w w.j a  va 2 s  .  c o m
public UserProfile3Top(Object uid) {
    this.uid = uid;

    User u = User.getTL(uid);
    User me = Mmowgli2UI.getGlobals().getUserTL();
    itsSomebodyElse = (u.getId() != me.getId());
    imGuestAccount = me.isViewOnly();
    imAdmin = me.isAdministrator();
    imAdminOrGameMaster = me.isAdministrator() || me.isGameMaster();

    Game game = Game.getTL();
    gameReadOnly = game.isReadonly();

    scoresLab = new Label();
    exploreScoreLab = new Label();
    innovateScoreLab = new Label();

    if (game.isActionPlansEnabled()) {
        scoresLab.addStyleName("m-userProfile3-scores-label");

        exploreScoreLab.addStyleName("m-userProfile3-explorescore-label");
        exploreScoreLab.setValue(formatFloat(u.getCombinedBasicScore())); // u.getBasicScore()));
        exploreScoreLab.setDescription("rounds combined");

        innovateScoreLab.addStyleName("m-userProfile3-explorescore-label");
        innovateScoreLab.setValue(formatFloat(u.getCombinedInnovScore())); // u.getInnovationScore()));
        innovateScoreLab.setDescription("rounds combined");
    } else {
        scoresLab.addStyleName("m-userProfile3-exploreonlyscore-label");

        exploreScoreLab.addStyleName("m-userProfile3-explorescorebig-label");
        exploreScoreLab.setValue(formatFloat(u.getCombinedBasicScore())); // u.getBasicScore()));
        exploreScoreLab.setDescription("rounds combined");
    }

    avatarButt = new NativeButton();

    locationLab = new Label();
    locationLab.setDescription("Where are you from?");

    expertiseLab = new Label();
    expertiseLab.setDescription("Enter a short description of your pertinent expertise.");

    affiliationLab = new Label("AFFILIATION");
    affiliationLab.setDescription("Your professional affliation");
    affiliationLab.addStyleName("m-userProfile3-learn-label");

    coverUpChangePW = new Label();

    nameLab = new Label();
    nameLab.setValue(u.getUserName());

    learnLab = new Label();

    GameQuestion q = u.getQuestion();

    String questSumm = null;
    if (q != null)
        questSumm = q.getSummary();
    questSumm = questSumm == null ? "" : questSumm;
    learnLab.setValue(questSumm);

    String questDesc = null;
    if (q != null)
        questDesc = q.getQuestion();
    questDesc = questDesc == null ? "" : questDesc;
    learnLab.setDescription(questDesc);

    levelLab = new Label();
    Level lev = u.getLevel();
    if (u.isGameMaster()) {
        Level l = Level.getLevelByOrdinalTL(Level.GAME_MASTER_ORDINAL);
        if (l != null)
            lev = l;
    }
    levelLab.setValue(lev.getDescription());

    changePWButt = new NativeButton();

    externMailCB = new CheckBox();
    externMailCB.setValue(u.isOkEmail());
    ingameMailCB = new CheckBox();
    ingameMailCB.setValue(u.isOkGameMessages());

    String s;
    locationTF = new TextField();
    s = u.getLocation();
    locationTF.setValue(s == null ? "" : s);
    expertiseTA = new TextArea();
    s = u.getExpertise();
    expertiseTA.setValue(s == null ? "" : s);

    affiliationTA = new TextArea();
    affiliationTA.setInputPrompt("optional additional affiliations");
    affiliationCombo = new BoundAffiliationCombo();
    affiliationCombo.setInputPrompt("required"); // override "optional"
    affiliationCombo.setNewItemsAllowed(false);
    s = u.getAffiliation();
    fillAffiliation(s);

    learnTA = new TextArea();
    s = u.getAnswer();
    learnTA.setValue(s == null ? "" : s);
    badgeButts = new NativeButton[8];
    badgeLayout = new GridLayout(4, 3); //col,row
    if (itsSomebodyElse) {
        followCB = new CheckBox();
        followCB.setValue(amIFollowing(me));
        followCB.addValueChangeListener(new FollowListener());
    }

    if (imAdmin) {
        manageAwardsButt = new NativeButton("manage awards");
        manageAwardsButt.setDescription("<p>accessible to game administrators</p>");
        manageAwardsButt.addClickListener(new ManageAwardsListener());
    }
}

From source file:eu.fp7.eagle.portal.ui.dashboard.design.impl.ActivitiesDesignImpl.java

License:Apache License

private GridLayout buildSubjectsLayout() {

    gridLayoutSubjects = new GridLayout(8, 1);
    gridLayoutSubjects.setImmediate(false);
    gridLayoutSubjects.setWidth("100%");
    gridLayoutSubjects.setHeight("-1px");
    gridLayoutSubjects.setSpacing(true);
    gridLayoutSubjects.setCaption("My Subjects");
    gridLayoutSubjects.addStyleName("gridLayoutSubjects");
    MarginInfo margin = new MarginInfo(true, false, true, false);
    gridLayoutSubjects.setMargin(margin);
    gridLayoutSubjects.setSpacing(false);
    gridLayoutSubjects.setColumnExpandRatio(7, 1.0f);

    PopupView popup = new PopupView(null, buildTableActivity("Migration", 3, 2));
    popup.addStyleName("popupviewActivities");
    Button migration = new Button("Migration" + " " + "(5)", click -> popup.setPopupVisible(true));
    migration.addStyleName("buttonSubjectsListAct");
    gridLayoutSubjects.addComponent(migration, 0, 0);
    //popup.setWidth("100px");
    gridLayoutSubjects.addComponent(popup, 1, 0);

    PopupView popup2 = new PopupView(null, buildTableActivity("Housing", 0, 0));
    popup2.addStyleName("popupviewActivities");
    Button housing = new Button("Housing", click -> popup.setPopupVisible(false));
    housing.addStyleName("buttonSubjectsEmptyAct");
    gridLayoutSubjects.addComponent(housing, 2, 0);
    //popup2.setWidth("100px");
    gridLayoutSubjects.addComponent(popup2, 3, 0);

    return gridLayoutSubjects;
}

From source file:eu.fp7.eagle.portal.ui.dashboard.design.impl.ActivitiesDesignImpl.java

License:Apache License

private GridLayout buildResourcesLayout() {

    gridLayoutResources = new GridLayout(8, 1);
    gridLayoutResources.setImmediate(false);
    gridLayoutResources.setWidth("100%");
    gridLayoutResources.setHeight("-1px");
    gridLayoutResources.setSpacing(true);
    gridLayoutResources.setCaption("My Resources");
    gridLayoutResources.addStyleName("gridLayoutResources");
    MarginInfo margin = new MarginInfo(true, false, true, false);
    gridLayoutResources.setMargin(margin);
    gridLayoutResources.setSpacing(false);
    gridLayoutResources.setColumnExpandRatio(7, 1.0f);

    PopupView popup = new PopupView(null, buildTableActivity("OER", 2, 2));
    popup.addStyleName("popupviewActivities");
    Button oer = new Button("OER" + " " + "(4)", click -> popup.setPopupVisible(true));
    oer.addStyleName("buttonResourcesListAct");
    gridLayoutResources.addComponent(oer, 0, 0);
    //popup.setWidth("100px");
    gridLayoutResources.addComponent(popup, 1, 0);

    PopupView popup2 = new PopupView(null, buildTableActivity("Wiki", 1, 2));
    popup2.addStyleName("popupviewActivities");
    Button wiki = new Button("Wiki" + " " + "(3)", click -> popup2.setPopupVisible(true));
    wiki.addStyleName("buttonResourcesListAct");
    gridLayoutResources.addComponent(wiki, 2, 0);
    popup2.setWidth("100px");
    gridLayoutResources.addComponent(popup2, 3, 0);

    PopupView popup3 = new PopupView(null, buildTableActivity("Blogs", 0, 0));
    popup3.addStyleName("popupviewActivities");
    Button blogs = new Button("Blogs", click -> popup3.setPopupVisible(false));
    blogs.addStyleName("buttonResourcesEmptyAct");
    gridLayoutResources.addComponent(blogs, 4, 0);
    //popup3.setWidth("100px");
    gridLayoutResources.addComponent(popup3, 5, 0);

    PopupView popup4 = new PopupView(null, buildTableActivity("Comments", 5, 5));
    popup4.addStyleName("popupviewActivities");
    Button comments = new Button("Comments" + " " + "(10)", click -> popup4.setPopupVisible(true));
    comments.addStyleName("buttonResourcesListAct");
    gridLayoutResources.addComponent(comments, 6, 0);
    //popup4.setWidth("100px");
    gridLayoutResources.addComponent(popup4, 7, 0);

    return gridLayoutResources;
}

From source file:facs.components.BookAdmin.java

License:Open Source License

private Component deletedBookingsGrid() {
    VerticalLayout devicesLayout = new VerticalLayout();
    devicesLayout.setCaption("Trash");
    // HorizontalLayout buttonLayout = new HorizontalLayout();

    // there will now be space around the test component
    // components added to the test component will now not stick together but have space between
    // them/*from w  ww . j  av  a 2 s . co m*/
    devicesLayout.setMargin(true);
    devicesLayout.setSpacing(true);
    // buttonLayout.setMargin(true);
    // buttonLayout.setSpacing(true);

    // buttonLayout.addComponent(add);

    BeanItemContainer<BookingBean> booking = getDeletedBookings();

    GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(booking);

    gpc.addGeneratedProperty("restore", new PropertyValueGenerator<String>() {
        /**
         * 
         */
        private static final long serialVersionUID = 4082425701384202280L;

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            // return FontAwesome.TRASH_O.getHtml(); // The caption
            return "Restore"; // The caption

        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() {
        /**
         * 
         */
        private static final long serialVersionUID = 1307493624895857513L;

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            // return FontAwesome.TRASH_O.getHtml(); // The caption
            return "Purge"; // The caption

        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    devicesGridTrash = new Grid(gpc);
    // Create a grid

    devicesGridTrash.setWidth("100%");
    devicesGridTrash.setSelectionMode(SelectionMode.SINGLE);
    devicesGridTrash.getColumn("delete").setRenderer(new HtmlRenderer());
    devicesGridTrash.getColumn("restore").setRenderer(new HtmlRenderer());
    setRenderers(devicesGridTrash);
    devicesGridTrash.setColumnOrder("ID", "deviceName", "service", "start", "end", "username", "phone",
            "price");

    // Render a button that deletes the data row (item)

    /*
     * devicesGrid.addColumn("delete", FontIcon.class).setWidth(35) .setRenderer(new
     * FontIconRenderer(new RendererClickListener() {
     * 
     * @Override public void click(RendererClickEvent e) { Notification.show("Deleted item " +
     * e.getItemId()); } }));
     */

    devicesGridTrash.getColumn("delete")
            .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {
                /**
                 * 
                 */
                private static final long serialVersionUID = 302628105070456680L;

                @Override
                public void click(RendererClickEvent event) {

                    try {

                        Window cd = new Window("Purge Booking");

                        cd.setHeight("200px");
                        cd.setWidth("400px");
                        cd.setResizable(false);

                        GridLayout dialogLayout = new GridLayout(3, 3);

                        Button okButton = new Button("Yes");
                        okButton.addStyleName(ValoTheme.BUTTON_DANGER);
                        Button cancelButton = new Button("No, I'm actually not sure!");
                        cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
                        Label information = new Label("Are you sure you want to purge this item?");
                        information.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                        okButton.addClickListener(new Button.ClickListener() {

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

                            @Override
                            public void buttonClick(ClickEvent okEvent) {
                                purgeBooking((BookingBean) event.getItemId());
                                cd.close();
                                Notification("The booking was purged!",
                                        "At the end, you are the admin, you have the power.", "");
                            }
                        });

                        cancelButton.addClickListener(new Button.ClickListener() {

                            /**
                             * 
                             */
                            private static final long serialVersionUID = -3931200823633220160L;

                            @Override
                            public void buttonClick(ClickEvent okEvent) {
                                cd.close();
                            }
                        });

                        dialogLayout.addComponent(information, 0, 0, 2, 0);
                        dialogLayout.addComponent(okButton, 0, 1);
                        dialogLayout.addComponent(cancelButton, 1, 1);
                        dialogLayout.setMargin(true);
                        dialogLayout.setSpacing(true);
                        cd.setContent(dialogLayout);
                        cd.center();
                        UI.getCurrent().addWindow(cd);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    FieldGroup fieldGroup = devicesGridTrash.getEditorFieldGroup();
                    fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() {
                        /**
                         * 
                         */
                        private static final long serialVersionUID = 3799806709907688919L;

                        @Override
                        public void preCommit(FieldGroup.CommitEvent commitEvent)
                                throws FieldGroup.CommitException {

                        }

                        @Override
                        public void postCommit(FieldGroup.CommitEvent commitEvent)
                                throws FieldGroup.CommitException {

                            Notification("Successfully Updated",
                                    "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                                    "success");

                            refreshGrid();
                        }

                        private void refreshGrid() {
                            getDeletedBookings();
                        }

                    });

                }
            }));

    devicesGridTrash.getColumn("restore")
            .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {
                /**
                 * 
                 */
                private static final long serialVersionUID = -9104571186503913834L;

                @Override
                public void click(RendererClickEvent event) {
                    restoreBooking((BookingBean) event.getItemId());
                }
            }));

    // devicesGrid.setEditorEnabled(true);

    // devicesLayout.addComponent(buttonLayout);
    devicesLayout.addComponent(devicesGridTrash);

    // TODO filtering
    // HeaderRow filterRow = devicesGrid.prependHeaderRow();

    return devicesLayout;
}

From source file:facs.components.Booking.java

License:Open Source License

private Component myUpcomingBookings() {
    VerticalLayout devicesLayout = new VerticalLayout();
    // devicesLayout.setCaption("My Bookings");
    // there will now be space around the test component
    // components added to the test component will now not stick together but have space between
    // them/*  ww  w  . j a  va  2  s.c  om*/
    devicesLayout.setMargin(true);
    devicesLayout.setSpacing(true);

    Date serverTime = new WebBrowser().getCurrentDate();
    Date nextDayTime = new Date(serverTime.getTime() + (1000 * 60 * 60 * 24));

    BeanItemContainer<BookingBean> users = getMyUpcomingBookings(bookingModel.getLDAP(), nextDayTime);
    // System.out.println(bookingModel.getLDAP());

    GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(users);
    gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() {
        /**
         * 
         */
        private static final long serialVersionUID = 1263377339178640406L;

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            // return FontAwesome.TRASH_O.getHtml(); // The caption
            return "Trash"; // The caption

        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    /*
     * 
     * try {
     * 
     * FreeformQuery query = new FreeformQuery(
     * "SELECT * FROM booking INNER JOIN user ON booking.user_ldap = user.user_ldap WHERE deleted IS NULL AND booking.user_ldap ='"
     * + bookingModel.getLDAP() + "';", DBManager.getDatabaseInstanceAlternative(), "booking_id");
     * SQLContainer container = new SQLContainer(query);
     * 
     * // System.out.println("Print Container: " + container.size());
     * container.setAutoCommit(isEnabled());
     * 
     * myBookings = new Grid(container);
     * 
     * } catch (Exception e) { e.printStackTrace(); }
     * 
     * myBookings.setColumnOrder("booking_id", "confirmation", "device_name", "service", "start",
     * "end", "kostenstelle", "price", "project");
     * 
     * myBookings.removeColumn("user_ldap"); myBookings.removeColumn("timestamp");
     * myBookings.removeColumn("deleted"); myBookings.removeColumn("user_name");
     * myBookings.removeColumn("group_id"); myBookings.removeColumn("workgroup_id");
     * myBookings.removeColumn("email"); myBookings.removeColumn("phone");
     * myBookings.removeColumn("admin_panel"); myBookings.removeColumn("user_id");
     * 
     * myBookings.getColumn("booking_id").setHeaderCaption("Booking ID");
     */

    upcomingBookings = new Grid(gpc);
    // Create a grid
    upcomingBookings.setStyleName("my-style");
    upcomingBookings.setWidth("100%");
    upcomingBookings.setSelectionMode(SelectionMode.SINGLE);
    upcomingBookings.setEditorEnabled(false);

    upcomingBookings.setColumnOrder("ID", "confirmation", "deviceName", "service", "start", "end", "username",
            "phone", "price");
    upcomingBookings.getColumn("price").setHeaderCaption("Approx. Price");

    // System.out.println(myBookings.getColumns());
    setRenderers(upcomingBookings);
    devicesLayout.addComponent(upcomingBookings);

    upcomingBookings.getColumn("delete")
            .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {
                /**
                 * 
                 */
                private static final long serialVersionUID = 302628105070456680L;

                @Override
                public void click(RendererClickEvent event) {

                    try {

                        Window cd = new Window("Delete Booking");

                        cd.setHeight("200px");
                        cd.setWidth("400px");
                        cd.setResizable(false);

                        GridLayout dialogLayout = new GridLayout(3, 3);

                        Button okButton = new Button("Yes");
                        okButton.addStyleName(ValoTheme.BUTTON_DANGER);
                        Button cancelButton = new Button("No, I'm actually not sure!");
                        cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
                        Label information = new Label("Are you sure you want to trash this item?");
                        information.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                        okButton.addClickListener(new Button.ClickListener() {
                            /**
                             * 
                             */
                            private static final long serialVersionUID = 1778157399909757369L;

                            @Override
                            public void buttonClick(ClickEvent okEvent) {

                                purgeBooking((BookingBean) event.getItemId());

                                booking.setSelectedTab(myUpcomingBookings());

                                cd.close();

                                showNotification("The booking was deleted!",
                                        "You wanted to delete an upcoming booking and it wasn't within the next 24 hours. All good, item purged.");
                            }
                        });

                        cancelButton.addClickListener(new Button.ClickListener() {
                            /**
                             * 
                             */
                            private static final long serialVersionUID = -8957620319158438769L;

                            @Override
                            public void buttonClick(ClickEvent okEvent) {
                                cd.close();
                            }
                        });

                        dialogLayout.addComponent(information, 0, 0, 2, 0);
                        dialogLayout.addComponent(okButton, 0, 1);
                        dialogLayout.addComponent(cancelButton, 1, 1);
                        dialogLayout.setMargin(true);
                        dialogLayout.setSpacing(true);
                        cd.setContent(dialogLayout);
                        cd.center();
                        UI.getCurrent().addWindow(cd);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }

            }));

    // TODO filtering
    // HeaderRow filterRow = devicesGrid.prependHeaderRow();

    return devicesLayout;
}

From source file:fi.csc.pathway.TutkaUI.java

License:Creative Commons License

/**
 * Pohjelma, joka luo kyttliittymn./*w  ww . jav a 2s .c o m*/
 */
@Override
protected void init(VaadinRequest request) {
    final String portletContextName = getPortletContextName(request);
    final VerticalLayout vasenpalkki = new VerticalLayout();
    final HorizontalLayout layout = new HorizontalLayout(); //main
    final HorizontalLayout karttapalkki = new HorizontalLayout();
    final HorizontalLayout lkmnext = new HorizontalLayout();
    final Label hr = new Label("  ____________________", ContentMode.HTML);
    final Label aika = new Label("Time", ContentMode.HTML);
    final Label lkm = new Label("0", ContentMode.HTML);
    final Button next = new Button("Next");
    final OptionGroup tyyppi = new OptionGroup("Type");
    final OptionGroup tutka = new OptionGroup("Radar");
    final OptionGroup kulma = new OptionGroup("Angle");
    final OptionGroup krjet = new OptionGroup("Min vertices");
    final Googlekartta gma = new Googlekartta(aika, tutka, kulma, tyyppi, krjet, portletContextName, lkm);
    final Tutkat tutkat = new Tutkat();
    final PopupDateField enddate = new PopupDateField("To:");
    final PopupDateField startdate = new PopupDateField("From:");
    final GoogleMap oldComponent = gma.getOrigMap();
    final GridLayout parametrit = new GridLayout(2, 2);
    tutkat.alusta(tutka, krjet, oldComponent);
    parametrit.addComponent(tutka);
    parametrit.addComponent(krjet);
    Ilmiot ilmio = new Ilmiot(tyyppi, tutka);
    kulma.addItem("1.5");
    kulma.addItem("0.7");
    kulma.addItem(Tutkat.LOW); //luostolla ei ole matalampaa kuin 0.7
    kulma.setValue("1.5");
    parametrit.addComponent(kulma);
    parametrit.addComponent(ilmio.getTyyppi());
    vasenpalkki.addComponent(parametrit);
    Tarkista tarkista = new Tarkista(enddate, startdate);
    vasenpalkki.addComponent(tarkista.getstartdate());
    vasenpalkki.addComponent(tarkista.getenddate());
    next.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -8146345475859196611L;

        public void buttonClick(ClickEvent event) {
            if (gma.updateMap()) {
                next.setEnabled(false);
            }
        }
    });
    final Button button = new Button("Query");
    button.addClickListener(new Button.ClickListener() {
        //Component oldC = oldComponent;
        private static final long serialVersionUID = -8146345475859196612L;

        public void buttonClick(ClickEvent event) {
            if (gma.getMap(startdate.getValue(), enddate.getValue(), tutka.getValue())) {
                // tm ei ole kaunista, mutta uudelleen lisminen ei haittaa
                vasenpalkki.addComponent(hr);
                vasenpalkki.addComponent(aika);
                lkmnext.addComponent(lkm);
                next.setEnabled(true);
                lkmnext.addComponent(next);
                vasenpalkki.addComponent(lkmnext);
            }
        }
    });
    vasenpalkki.addComponent(button);
    layout.addComponent(vasenpalkki);
    karttapalkki.setHeight(600, Sizeable.Unit.PIXELS);
    karttapalkki.addComponent(oldComponent);
    layout.addComponent(karttapalkki);
    layout.setMargin(true);
    setContent(layout);
}

From source file:fr.amapj.view.views.permanence.mespermanences.grille.InscriptionPopupRoleDifferent.java

License:Open Source License

/**
 * Permet de dessiner le tableau //from   w w w.j a v  a2 s .  com
 */
public void drawTab(Tab tab) {
    GridLayout gl = new GridLayout(4, 1 + tab.lines.size());
    gl.setWidth("800px");
    gl.setSpacing(false);

    contentLayout.addComponent(gl);

    // Construction du titre   
    Label l = new Label(tab.titre);
    l.addStyleName(tab.styleTitre);
    l.setWidth("100%");
    gl.addComponent(l, 0, 0, 3, 0);

    List<TabLine> lines = tab.lines;
    for (int i = 0; i < lines.size(); i++) {
        TabLine line = lines.get(i);

        int height = computeHeight(line);
        // La taille minimale est de 36 pixels, pour les boutons inscrire / desincrire
        height = Math.max(height, 36);

        Label l1 = new Label(line.col1);
        l1.addStyleName(line.styleCol1);
        l1.setWidth("100%");
        l1.setHeight(height + "px");
        gl.addComponent(l1, 0, i + 1);

        Label l2 = new Label(line.col2);
        l2.addStyleName(line.styleCol2);
        l2.setWidth("100%");
        l2.setHeight(height + "px");
        gl.addComponent(l2, 1, i + 1);

        Label l3 = new Label(line.col3);
        l3.addStyleName(line.styleCol3);
        l3.setWidth("100%");
        l3.setHeight(height + "px");
        gl.addComponent(l3, 2, i + 1);

        if (line.col4 != null) {
            Button b = new Button(line.col4);
            b.addStyleName(line.styleCol4);
            b.addClickListener(e -> handleButton(line.role));
            b.setWidth("100%");
            gl.addComponent(b, 3, i + 1);
            gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER);
        } else {
            Label l4 = new Label("");
            l4.addStyleName(line.styleCol4);
            l4.setWidth("100%");
            l4.setHeight(height + "px");
            gl.addComponent(l4, 3, i + 1);
        }
    }
}

From source file:fr.amapj.view.views.permanence.mespermanences.grille.InscriptionPopupToutAutorise.java

License:Open Source License

/**
 * Permet de dessiner le tableau // w  ww.  j av a  2 s  . co  m
 */
public void drawTab(Tab tab) {
    GridLayout gl = new GridLayout(3, 1 + tab.lines.size());
    gl.setWidth("600px");
    gl.setSpacing(false);

    contentLayout.addComponent(gl);

    // Construction du titre   
    Label l = new Label(tab.titre);
    l.addStyleName(tab.styleTitre);
    l.setWidth("100%");
    gl.addComponent(l, 0, 0, 2, 0);

    List<TabLine> lines = tab.lines;
    for (int i = 0; i < lines.size(); i++) {
        TabLine line = lines.get(i);

        int height = computeHeight(line);
        // La taille minimale est de 36 pixels, pour les boutons inscrire / desincrire
        height = Math.max(height, 36);

        Label l1 = new Label(line.col1);
        l1.addStyleName(line.styleCol1);
        l1.setWidth("100%");
        l1.setHeight(height + "px");
        gl.addComponent(l1, 0, i + 1);

        Label l2 = new Label(line.col2);
        l2.addStyleName(line.styleCol2);
        l2.setWidth("100%");
        l2.setHeight(height + "px");
        gl.addComponent(l2, 1, i + 1);

        if (line.col3 != null) {
            Button b = new Button(line.col3);
            b.addStyleName(line.styleCol3);
            b.addClickListener(e -> handleButton(line.cell));
            b.setWidth("100%");
            gl.addComponent(b, 2, i + 1);
            gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER);
        } else {
            Label l3 = new Label("");
            l3.addStyleName(line.styleCol3);
            l3.setWidth("100%");
            l3.setHeight(height + "px");
            gl.addComponent(l3, 2, i + 1);
        }
    }
}

From source file:fr.amapj.view.views.saisiecontrat.PopupSaisieJoker.java

License:Open Source License

@Override
protected void createContent(VerticalLayout contentLayout) {
    String msg = getTitre(abo.dateJokers.size());

    titre = new Label(msg, ContentMode.HTML);
    contentLayout.addComponent(titre);/*from w  ww .j  a v a2 s . c  o  m*/

    GridLayout gl = new GridLayout(3, contratDTO.jokerNbMax);
    gl.setMargin(true);
    gl.setSpacing(true);

    SimpleDateFormat df = FormatUtils.getFullDate();

    for (int i = 0; i < contratDTO.jokerNbMax; i++) {
        ContratLigDTO dateJoker = (i < abo.dateJokers.size()) ? abo.dateJokers.get(i) : null;
        boolean isModifiable = isModifiable(dateJoker);
        //
        Label l1 = new Label("Joker " + (i + 1));
        l1.setWidth("80px");
        gl.addComponent(l1, 0, i);

        //
        if (isModifiable && readOnly == false) {
            ComboBox box = createComboBox(dateJoker, df);
            box.setWidth("220px");
            gl.addComponent(box, 1, i);
            combos.add(box);
        } else {
            String caption = dateJoker == null ? "Non utilis" : df.format(dateJoker.date);
            gl.addComponent(new Label(caption), 1, i);
            if (dateJoker != null) {
                nonModifiableJokers.add(dateJoker);
            }
        }

        String l3msg = isModifiable ? "" : " (Non modifiable)";
        Label l3 = new Label(l3msg);
        gl.addComponent(l3, 2, i);

    }
    contentLayout.addComponent(gl);

}

From source file:fr.univlorraine.mondossierweb.views.windows.FiltreInscritsMobileWindow.java

License:Apache License

/**
 * Cre une fentre//from  w w  w  .  jav a 2  s.  co  m
 */
public FiltreInscritsMobileWindow() {
    setWidth("95%");
    setModal(true);
    setResizable(false);
    setClosable(true);

    setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale()));
    setStyleName("v-popover-blank");

    typeFavori = MdwTouchkitUI.getCurrent().getTypeObjListInscrits();

    GridLayout layout = new GridLayout(1, 2);
    layout.setWidth("100%");
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);

    //Si on affiche la liste des inscrits  un ELP
    //on doit affiche l'tape d'appartenance et ventuellement les groupes
    //Affichage d'une liste droulante contenant la liste des annes
    if (typeIsElp()) {

        //GESTION DES ETAPES
        List<VersionEtape> letapes = MdwTouchkitUI.getCurrent().getListeEtapesInscrits();
        if (letapes != null && letapes.size() > 0) {

            Label etapeLabel = new Label(applicationContext.getMessage(NAME + ".etape", null, getLocale()));
            layout.addComponent(etapeLabel);
            layout.setComponentAlignment(etapeLabel, Alignment.BOTTOM_LEFT);
            listeEtapes = new NativeSelect();
            listeEtapes.setNullSelectionAllowed(false);
            listeEtapes.setRequired(false);
            listeEtapes.setWidth("100%");
            listeEtapes.addItem(TOUTES_LES_ETAPES_LABEL);
            listeEtapes.setItemCaption(TOUTES_LES_ETAPES_LABEL, TOUTES_LES_ETAPES_LABEL);
            for (VersionEtape etape : letapes) {
                String idEtape = etape.getId().getCod_etp() + "/" + etape.getId().getCod_vrs_vet();
                listeEtapes.addItem(idEtape);
                listeEtapes.setItemCaption(idEtape, "[" + idEtape + "] " + etape.getLib_web_vet());
            }

            if (MdwTouchkitUI.getCurrent().getEtapeInscrits() != null) {
                listeEtapes.setValue(MdwTouchkitUI.getCurrent().getEtapeInscrits());
            } else {

                listeEtapes.setValue(TOUTES_LES_ETAPES_LABEL);
            }
            //Gestion de l'vnement sur le changement d'tape
            listeEtapes.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(ValueChangeEvent event) {
                    vetSelectionnee = (String) event.getProperty().getValue();
                    if (vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) {
                        vetSelectionnee = null;
                    }
                    MdwTouchkitUI.getCurrent().setEtapeInscrits(vetSelectionnee);
                    //faire le changement
                    groupeSelectionne = ((listeGroupes != null && listeGroupes.getValue() != null)
                            ? (String) listeGroupes.getValue()
                            : null);
                    if (groupeSelectionne != null && groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) {
                        groupeSelectionne = null;
                    }

                    //update de l'affichage
                    //initListe();

                }
            });
            layout.addComponent(listeEtapes);

        }

        //GESTION DES GROUPES
        List<ElpDeCollection> lgroupes = MdwTouchkitUI.getCurrent().getListeGroupesInscrits();
        if (lgroupes != null && lgroupes.size() > 0) {

            // Label "GROUPE"
            HorizontalLayout gLayout = new HorizontalLayout();
            gLayout.setSizeFull();
            Label groupeLabel = new Label(applicationContext.getMessage(NAME + ".groupe", null, getLocale()));
            gLayout.addComponent(groupeLabel);
            gLayout.setComponentAlignment(groupeLabel, Alignment.MIDDLE_LEFT);
            layout.addComponent(gLayout);

            //Liste droulante pour choisir le groupe
            listeGroupes = new NativeSelect();
            listeGroupes.setNullSelectionAllowed(false);
            listeGroupes.setRequired(false);
            listeGroupes.setWidth("100%");
            listeGroupes.addItem(TOUS_LES_GROUPES_LABEL);
            listeGroupes.setItemCaption(TOUS_LES_GROUPES_LABEL, TOUS_LES_GROUPES_LABEL);
            for (ElpDeCollection edc : lgroupes) {
                for (CollectionDeGroupes cdg : edc.getListeCollection()) {
                    for (Groupe groupe : cdg.getListeGroupes()) {
                        listeGroupes.addItem(groupe.getCleGroupe());
                        listeGroupes.setItemCaption(groupe.getCleGroupe(), groupe.getLibGroupe());

                    }
                }
            }
            //On pr-remplie le groupe choisi si on en a dj choisi un
            if (MdwTouchkitUI.getCurrent().getGroupeInscrits() != null) {
                listeGroupes.setValue(MdwTouchkitUI.getCurrent().getGroupeInscrits());
            } else {
                listeGroupes.setValue(TOUS_LES_GROUPES_LABEL);
            }

            //Gestion de l'vnement sur le changement de groupe
            listeGroupes.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(ValueChangeEvent event) {
                    groupeSelectionne = (String) event.getProperty().getValue();
                    if (groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) {
                        groupeSelectionne = null;
                    }
                    MdwTouchkitUI.getCurrent().setGroupeInscrits(groupeSelectionne);
                    //faire le changement
                    vetSelectionnee = ((listeEtapes != null && listeEtapes.getValue() != null)
                            ? (String) listeEtapes.getValue()
                            : null);
                    if (vetSelectionnee != null && vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) {
                        vetSelectionnee = null;
                    }

                }
            });

            layout.addComponent(listeGroupes);

        }
    }

    // Bouton "Filtrer"
    HorizontalLayout bLayout = new HorizontalLayout();
    bLayout.setSizeFull();
    Button closeButton = new Button(applicationContext.getMessage(NAME + ".filtrerBtn", null, getLocale()));
    closeButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    closeButton.addStyleName("v-popover-button");
    demandeFiltrage = false;
    closeButton.addClickListener(e -> {
        //retourner vetSelectionnee et groupeSelectionne;
        demandeFiltrage = true;
        close();
    });
    bLayout.addComponent(closeButton);
    bLayout.setComponentAlignment(closeButton, Alignment.MIDDLE_CENTER);
    layout.addComponent(bLayout);

}