Example usage for com.vaadin.ui VerticalLayout setSpacing

List of usage examples for com.vaadin.ui VerticalLayout setSpacing

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.modules.administration.AddCardTypeDialog.java

License:Open Source License

public AddCardTypeDialog(int descType, String title) {
    super(title);
    this.typ = descType;

    VerticalLayout vl = new VerticalLayout();
    setContent(vl);//w ww. j  av a2 s.c  om
    vl.setSizeUndefined();
    vl.setMargin(true);
    vl.setSpacing(true);
    vl.addComponent(titleTF = new TextField("Title"));
    titleTF.setValue("title goes here");
    titleTF.setColumns(35);

    vl.addComponent(summTF = new TextField("Summary"));
    summTF.setValue("summary goes here");
    summTF.setColumns(35);

    vl.addComponent(promptTF = new TextField("Prompt"));
    promptTF.setValue("prompt goes here");
    promptTF.setColumns(35);

    vl.addComponent(colorCombo = new NativeSelect("Color"));
    fillCombo();

    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);
    buttHL.addComponent(cancelButt = new Button("Cancel"));
    cancelButt.addClickListener(new CancelListener());
    buttHL.addComponent(saveButt = new Button("Save"));
    saveButt.addClickListener(new SaveListener());
    vl.addComponent(buttHL);
    vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);
}

From source file:edu.nps.moves.mmowgli.modules.administration.NewMovePhaseDialog.java

License:Open Source License

@SuppressWarnings("serial")
public NewMovePhaseDialog(Move move) {
    super("Make a new Phase for " + move.getName());
    this.moveBeingEdited = Move.getTL(move.getId());
    setSizeUndefined();/*  w  w  w  .j a  va 2 s  .  c  o m*/
    setWidth("390px");
    VerticalLayout vLay;
    setContent(vLay = new VerticalLayout());
    vLay.setSpacing(true);
    vLay.setMargin(true);
    vLay.addComponent(new Label("Choose a descriptive name for this phase.  Suggested names are shown in the "
            + "drop down list, but any text is permitted."));

    descriptionCB = new ComboBox("Phase description");
    vLay.addComponent(descriptionCB);
    fillCombo(descriptionCB);

    descriptionCB.setInputPrompt("Choose suggested description, or enter text");
    descriptionCB.setWidth("350px");

    descriptionCB.setImmediate(true);
    descriptionCB.setNullSelectionAllowed(false);
    descriptionCB.setTextInputAllowed(true);
    descriptionCB.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(final ValueChangeEvent event) {
            // final String valueString = String.valueOf(event.getProperty().getValue());
            // Notification.show("Value changed:", valueString,
            // Type.TRAY_NOTIFICATION);
        }
    });
    vLay.addComponent(existingPhasesGLay = new GridLayout());
    existingPhasesGLay.setColumns(3);
    existingPhasesGLay.setRows(1); // to start
    existingPhasesGLay.setSpacing(true);
    existingPhasesGLay.addStyleName("m-greyborder");
    existingPhasesGLay.setCaption("Existing Phases");
    fillExistingPhases();

    HorizontalLayout buttHLay;
    vLay.addComponent(buttHLay = new HorizontalLayout());
    buttHLay.setWidth("100%");
    buttHLay.setSpacing(true);
    Label lab;
    buttHLay.addComponent(lab = new Label());
    lab.setWidth("1px");
    buttHLay.setExpandRatio(lab, 1.0f);
    buttHLay.addComponent(cancelButt = new Button("Cancel", saveCancelListener));
    buttHLay.addComponent(saveButt = new Button("Save", saveCancelListener));
}

From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java

License:Open Source License

private void showAddDialogOrCancel(final DoneListener lis) {
    dialog = new Window("Add to VIP list");
    dialog.setModal(true);//w  ww . j a  v  a 2s  .c  om
    dialog.setWidth("400px");
    dialog.setHeight("350px");

    VerticalLayout layout = new VerticalLayout();
    dialog.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    List<String> rtypes = Arrays.asList(new String[] { EMAILTYPE, DOMAINTYPE });
    radios = new OptionGroup("Select type", rtypes);

    radios.setNullSelectionAllowed(false); // user can not 'unselect'
    radios.select("Emails"); // select this by default
    radios.setImmediate(false); // don't send the change to the server at once
    layout.addComponent(radios);

    final TextArea ta = new TextArea();
    //ta.setColumns(40);
    ta.setSizeFull();
    ta.setInputPrompt(
            "Type or paste a tab-, comma- or space-separated list of emails or domains.  For domains, "
                    + "use forms such as \"army.mil\", \"nmci.navy.mil\", \"ucla.edu\", \"gov\", etc.");
    layout.addComponent(ta);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    @SuppressWarnings("serial")
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
            lis.continueOrCancel(null);
        }
    });

    @SuppressWarnings("serial")
    Button addButt = new Button("Add", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            String[] returnArr = null;
            String result = ta.getValue().toString();
            if (result == null || result.length() <= 0)
                returnArr = null;
            else if ((returnArr = parseIt(result)) == null)
                return;

            dialog.close();
            lis.continueOrCancel(returnArr);
        }
    });

    hl.addComponent(cancelButt);
    hl.addComponent(addButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);

    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

    UI.getCurrent().addWindow(dialog);
    dialog.center();
}

From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java

License:Open Source License

@SuppressWarnings({ "unchecked", "serial" })
private void showViewOrDelete(final DeleteListener lis) {
    dialog = new Window("View / Delete VIPs");
    dialog.setModal(true);// ww  w.  ja va 2 s  . c o  m

    VerticalLayout layout = new VerticalLayout();
    dialog.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    List<VipPii> vLis = VHibPii.getAllVips();

    vipListSelect = new ListSelect("Select items to delete");
    StringBuffer sb = new StringBuffer(); // for popup
    vipListSelect.addStyleName("m-greyborder");
    String lf = System.getProperty("line.separator");
    for (int i = 0; i < vLis.size(); i++) {
        VipPii v;
        vipListSelect.addItem(v = vLis.get(i));
        sb.append(v.getEntry());
        sb.append(lf);
    }
    if (sb.length() > 0)
        sb.setLength(sb.length() - 1); // last space

    vipListSelect.setNullSelectionAllowed(true);
    vipListSelect.setMultiSelect(true);
    vipListSelect.setImmediate(true);
    vipListSelect.addValueChangeListener(new VipSelectListener());

    layout.addComponent(vipListSelect);

    Label copyPopupList = new HtmlLabel("<pre>" + sb.toString() + "</pre>");
    Panel p = new Panel();
    VerticalLayout lay = new VerticalLayout();
    p.setContent(lay);
    lay.addComponent(copyPopupList);
    p.setWidth("400px");
    p.setHeight("300px");
    PopupView popup = new PopupView("Display list as copyable text", p);
    popup.setHideOnMouseOut(false);
    if (sb.length() <= 0)
        popup.setEnabled(false);

    layout.addComponent(popup);
    layout.setComponentAlignment(popup, Alignment.MIDDLE_CENTER);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
            lis.continueOrCancel(null);
        }
    });

    deleteButt = new Button("Delete & Close", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Set<VipPii> set = (Set<VipPii>) vipListSelect.getValue();
            if (set.size() <= 0)
                set = null;
            dialog.close();
            lis.continueOrCancel(set);
        }
    });
    deleteButt.setEnabled(false);
    hl.addComponent(cancelButt);
    hl.addComponent(deleteButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);
    dialog.setWidth("300px");
    dialog.setHeight("350px");
    hl.setWidth("100%");
    vipListSelect.setWidth("99%");
    vipListSelect.setHeight("99%");
    layout.setExpandRatio(vipListSelect, 1.0f);

    UI.getCurrent().addWindow(dialog);
    dialog.center();
}

From source file:edu.nps.moves.mmowgli.modules.cards.CallToActionPage.java

License:Open Source License

public void initGui() {
    Object sessKey = HSess.checkInit();
    Label spacer = new Label();
    spacer.setWidth(CALLTOACTION_HOR_OFFSET_STR);
    addComponent(spacer);//from  w ww.  ja v  a 2s  .c  o m
    VerticalLayout mainVl = new VerticalLayout();
    addComponent(mainVl);
    mainVl.setSpacing(true);
    mainVl.setWidth("100%");

    MovePhase phase = MovePhase.getCurrentMovePhaseTL();
    String sum = phase.getCallToActionBriefingSummary();
    String tx = phase.getCallToActionBriefingText();
    Media v = phase.getCallToActionBriefingVideo();

    Embedded headerImg = new Embedded(null, Mmowgli2UI.getGlobals().mediaLocator().getCallToActionBang());
    headerImg.setDescription("Review motivation and purpose of this game");

    NativeButton needButt = new NativeButton();
    needButt.setStyleName("m-weNeedYourHelpButton");

    vidPan = new VideoWithRightTextPanel(v, headerImg, sum, tx, needButt); // needImg);
    vidPan.initGui();
    mainVl.addComponent(vidPan);

    String playCardString = Game.getTL().getCurrentMove().getCurrentMovePhase().getPlayACardTitle();
    NativeButton butt;
    if (!mockupOnly)
        butt = new IDNativeButton(playCardString, MmowgliEvent.PLAYIDEACLICK);
    else
        butt = new NativeButton(playCardString); // no listener
    butt.addStyleName("borderless");
    butt.addStyleName("m-calltoaction-playprompt");
    butt.setDescription("View existing cards and play new ones");
    mainVl.addComponent(butt);
    mainVl.setComponentAlignment(butt, Alignment.MIDDLE_CENTER);
    HSess.checkClose(sessKey);
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java

License:Open Source License

@SuppressWarnings("serial")

@HibernateOpened/*from  w  w  w  .j ava  2 s  .  co m*/
@HibernateRead
@HibernateClosed
public void initGuiTL() {
    VerticalLayout outerVl = this;
    outerVl.setWidth("100%");
    outerVl.setSpacing(true);

    cardMarkingPanel = makeCardMarkingPanelTL();
    Card c = Card.getTL(cardId);
    MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals();
    User me = globs.getUserTL();

    if (c.isHidden() && !me.isAdministrator() && !me.isGameMaster()) {
        // This case should only come into play when a non-gm user is showing this page
        // by explicitly using the url.  Not too frequent an occurance.
        Label lab = new Label("This card is not active");
        lab.addStyleName("m-cardlarge-hidden-label");
        outerVl.setHeight("300px");
        outerVl.addComponent(lab);
        outerVl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);
        return;
    }
    loadMarkingPanel_oobTL(c);
    // won't have Roles lazily update w/out above loadMarkingPanel_oob(DBGet.getCard(cardId));

    markingRadioGroup.addValueChangeListener(markingListener = new MarkingChangeListener());

    // Top part
    topHL = new HorizontalLayout();
    addComponent(topHL);
    topHL.setWidth("95%");
    setComponentAlignment(topHL, Alignment.TOP_CENTER);

    // Card columns
    listsHL = new HorizontalLayout();
    addComponent(listsHL);
    listsHL.setSpacing(true);
    setComponentAlignment(listsHL, Alignment.TOP_CENTER);

    addChildListsTL();

    chainButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            AppEvent evt = new AppEvent(CARDCHAINPOPUPCLICK, CardChainPage.this, cardId);
            Mmowgli2UI.getGlobals().getController().miscEventTL(evt);
            HSess.close();
            return;
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java

License:Open Source License

@HibernateRead
private GhostVerticalLayoutWrapper makeCardMarkingPanelTL() {
    GhostVerticalLayoutWrapper wrapper = new GhostVerticalLayoutWrapper();
    VerticalLayout vl = new VerticalLayout();
    vl.setSpacing(true);
    wrapper.ghost_setContent(vl);//from w w  w .j  a  va 2 s. co m

    Label lab = new HtmlLabel("<b><i>Game Master Actions</i></b>");
    vl.addComponent(lab);
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    NativeButton editCardButt = new NativeButton("Edit Card");
    editCardButt.addStyleName(BaseTheme.BUTTON_LINK);
    editCardButt.addClickListener(new EditCardTextListener());
    vl.addComponent(editCardButt);

    markingRadioGroup = new OptionGroup(null);
    markingRadioGroup.setMultiSelect(false);
    markingRadioGroup.setImmediate(true);
    markingRadioGroup.setDescription("Only game masters may change.");
    vl.addComponent(markingRadioGroup);

    NativeButton clearButt = new NativeButton("clear card marking");
    clearButt.addStyleName(BaseTheme.BUTTON_LINK);
    vl.addComponent(clearButt);
    clearButt.addClickListener(new MarkingClearListener());

    Collection<?> markings = CardMarking.getContainer().getItemIds();
    CardMarking hiddencm = null;
    for (Object o : markings) {
        CardMarking cm = CardMarking.getTL(o);
        if (cm == CardMarkingManager.getHiddenMarking())
            hiddencm = cm;
        else if (cm == CardMarkingManager.getNoChildrenMarking())
            ; // todo enable with game switch
        else
            markingRadioGroup.addItem(cm);
    }

    if (hiddencm != null)
        markingRadioGroup.addItem(hiddencm);

    Card card = Card.getTL(cardId); // feb refactor DBGet.getCardTL(cardId);
    vl.addComponent(lab = new Label());
    lab.setHeight("5px");

    NativeButton newActionPlanButt = new IDNativeButton("create action plan from this card",
            CARDCREATEACTIONPLANCLICK, cardId);
    newActionPlanButt.addStyleName(BaseTheme.BUTTON_LINK);
    vl.addComponent(newActionPlanButt);

    if (Mmowgli2UI.getGlobals().getUserTL().isTweeter()) {
        String tweet = TWEETBUTTONEMBEDDED_0 + buildTweet(card) + TWEETBUTTONEMBEDDED_1;
        Label tweeter = new HtmlLabel(tweet);
        tweeter.setHeight(TWEETBUTTON_HEIGHT);
        tweeter.setWidth(TWEETBUTTON_WIDTH);
        vl.addComponent(tweeter);
    }
    return wrapper;
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java

License:Open Source License

private void addChildListsTL() {
    MovePhase phase = MovePhase.getCurrentMovePhaseTL();
    Set<CardType> allowedTypes = phase.getAllowedCards();
    followOnTypes = new ArrayList<CardType>();
    for (CardType ct : allowedTypes)
        if (!ct.isIdeaCard()) // "idea/initiating" is the opposite of followon
            followOnTypes.add(ct);/*from ww  w .ja  va 2  s  .c om*/

    Collections.sort(followOnTypes, new Comparator<CardType>() {
        @Override
        public int compare(CardType arg0, CardType arg1) {
            return (int) (arg0.getDescendantOrdinal() - arg1.getDescendantOrdinal());
        }
    });

    columnVLs = new ArrayList<VerticalLayout>(followOnTypes.size());

    for (int i = 0; i < followOnTypes.size(); i++) {
        VerticalLayout vl = new VerticalLayout();
        vl.setSpacing(true);
        columnVLs.add(vl);
        listsHL.addComponent(vl);
    }
    Card card = Card.getTL(cardId);
    Card parent = card.getParentCard();
    VerticalLayout spacerVL = new VerticalLayout();

    if (parent != null) {
        topHL.addComponent(spacerVL);
        topHL.setExpandRatio(spacerVL, 1.0f);
        spacerVL.setWidth("100%");

        parentSumm = CardSummary.newCardSummarySmallTL(parent.getId());
        spacerVL.addComponent(parentSumm);
        parentSumm.initGui();
        spacerVL.setComponentAlignment(parentSumm, Alignment.MIDDLE_CENTER);
        parentSumm.setCaption("Parent Card");
        parentSumm.addStyleName("m-parent-card-summary");
    } else {
        topHL.addComponent(spacerVL);
        topHL.setExpandRatio(spacerVL, 1.0f);
        spacerVL.setWidth("100%");

        gotoTopLevelButt.setStyleName("m-gotoTopLevelButton");
        gotoTopLevelButt.setDescription(idea_dash_tt);
        gotoTopLevelButt.setId(PLAY_AN_IDEA_BLUE_BUTTON);
        gotoTopLevelButt.setDescription("Show two top-level card rows");
        spacerVL.addComponent(gotoTopLevelButt);
        spacerVL.setComponentAlignment(gotoTopLevelButt, Alignment.MIDDLE_CENTER);

    }
    if (isGameMaster) {
        spacerVL.addComponent(cardMarkingPanel);
        spacerVL.setComponentAlignment(cardMarkingPanel, Alignment.BOTTOM_LEFT);
    }

    cardLg = CardLarge.newCardLargeTL(card.getId());
    topHL.addComponent(cardLg);
    cardLg.initGuiTL();

    VerticalLayout buttVL = new VerticalLayout();
    buttVL.setHeight("100%");
    topHL.addComponent(buttVL);
    topHL.setComponentAlignment(buttVL, Alignment.MIDDLE_CENTER);
    topHL.setExpandRatio(buttVL, 1.0f);

    Label spacer = new Label();
    buttVL.addComponent(spacer);
    buttVL.setExpandRatio(spacer, 1.0f);

    buttVL.addComponent(gotoIdeaDashButt);
    gotoIdeaDashButt.setStyleName("m-gotoIdeaDashboardButton");
    gotoIdeaDashButt.setDescription(idea_dash_tt);
    gotoIdeaDashButt.setId(GO_TO_IDEA_DASHBOARD_BUTTON);
    buttVL.setComponentAlignment(gotoIdeaDashButt, Alignment.MIDDLE_CENTER);

    buttVL.addComponent(chainButt);
    chainButt.setStyleName("m-viewCardChainButton");
    chainButt.setDescription(view_chain_tt);
    buttVL.setComponentAlignment(chainButt, Alignment.MIDDLE_CENTER);

    spacer = new Label();
    buttVL.addComponent(spacer);
    buttVL.setExpandRatio(spacer, 1.0f);

    int col = -1;
    for (CardType ct : followOnTypes) {
        col++;
        VerticalLayout columnV = columnVLs.get(col);

        CardSummaryListHeader lstHdr = CardSummaryListHeader.newCardSummaryListHeader(ct, card);
        lstHdr.addNewCardListener(this);
        columnV.addComponent(lstHdr);
        lstHdr.initGui();
    }

    listFollowers_oobTL(card.getId()); // gets current vaadin transaction session
}

From source file:edu.nps.moves.mmowgli.modules.cards.EditCardTextWindow.java

License:Open Source License

public EditCardTextWindow(String text, Integer charLim) {
    super("Edit card text");

    if (charLim != null)
        characterLimit = charLim;//from w  ww.  j  a  va 2  s.  co m

    setModal(true);
    VerticalLayout layout = new VerticalLayout();
    setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    ta = new TextArea();
    ta.setRows(10);
    ta.setColumns(50);
    if (text != null) {
        ta.setValue(text);
        ta.selectAll();
    } else
        ta.setInputPrompt("Type card text here");
    layout.addComponent(ta);

    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);

    WindowCloser closeListener = new WindowCloser(this);
    cancelButt = new Button("Cancel", closeListener);
    buttHL.addComponent(cancelButt);

    saveButt = new Button("Save", closeListener);
    saveButt.addClickListener(closeListener);
    buttHL.addComponent(saveButt);

    layout.addComponent(buttHL);

    layout.setSizeUndefined(); // does a "pack"
    UI.getCurrent().addWindow(this);
    ta.focus();
}