Example usage for com.vaadin.ui VerticalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:edu.nps.moves.mmowgli.components.AvatarChooser.java

License:Open Source License

@SuppressWarnings("serial")
@Override/* w  w  w .ja v a  2s.c  o  m*/
public void initGui() {
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setMargin(true); //test
    mainLayout.setSpacing(true);
    MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    Label sp;
    setContent(mainLayout);

    Panel p = new Panel(imgLay = new HorizontalLayout());
    imgLay.setSpacing(true);

    p.setWidth("100%");
    mainLayout.addComponent(p);

    Collection<?> lis = Avatar.getContainer().getItemIds();
    avIdArr = new Object[lis.size()];

    int idx = 0;

    for (Object id : lis) {
        avIdArr[idx++] = id;
        if (initSelectedID == null)
            initSelectedID = id; // sets first one
        Avatar a = Avatar.getTL(id);
        Image em = new Image(null, medLoc.locate(a.getMedia()));
        em.setWidth("95px");
        em.setHeight("95px");
        em.addClickListener(new ImageClicked());

        if (id.equals(initSelectedID)) {
            em.addStyleName("m-orangeborder5");
            lastSel = em;
        } else
            em.addStyleName("m-greyborder5");
        imgLay.addComponent(em);
    }

    butts = new HorizontalLayout();
    butts.setWidth("100%");
    butts.setSpacing(true);
    mainLayout.addComponent(butts);

    butts.addComponent(sp = new Label());
    sp.setWidth("1px");
    butts.setExpandRatio(sp, 1.0f);

    NativeButton cancelButt = new NativeButton();
    medLoc.decorateCancelButton(cancelButt);
    butts.addComponent(cancelButt);

    NativeButton selectButt = new NativeButton();
    medLoc.decorateSelectButton(selectButt);
    butts.addComponent(selectButt);

    butts.addComponent(sp = new Label(""));
    sp.setWidth("20px");

    mainLayout.addComponent(sp = new Label(""));
    sp.setHeight("1px");
    mainLayout.setExpandRatio(sp, 1.0f);
    ;

    cancelButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        public void buttonClick(ClickEvent event) {
            cancelClick();
        }
    });
    selectButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        public void buttonClick(ClickEvent event) {
            selectClick();
        }
    });
}

From source file:edu.nps.moves.mmowgli.components.SendMessageWindow.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public SendMessageWindow(List<String> emails) {
    super("A message to mmowgli followers");

    this.emails = emails;

    setModal(true);// w  ww  .ja  v  a2  s  .c om
    VerticalLayout layout = new VerticalLayout();
    setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setHeight("100%");

    Label lab = new Label(makeString(emails));
    lab.setCaption("To: (other addresses hidden from each recipient)");
    lab.setDescription(lab.getValue().toString());
    lab.addStyleName("m-nowrap");
    //   lab.setHeight("100%"); // makes label clip
    lab.addStyleName("m-greyborder");
    layout.addComponent(lab);

    subjTf = new TextField();
    subjTf.setCaption("Subject:");
    subjTf.setWidth("100%");

    Game game = Game.getTL();
    String acronym = game.getAcronym();
    acronym = acronym == null ? "" : acronym + " ";
    subjTf.setValue("Message from " + acronym + "Mmowgli");
    layout.addComponent(subjTf);

    ta = new TextArea();
    ta.setCaption("Content: (may include HTML tags)");
    ta.setRows(10);
    ta.setColumns(50);
    ta.setWidth("100%");
    ta.setHeight("100%");
    ta.setInputPrompt("Type message here");
    layout.addComponent(ta);
    layout.setExpandRatio(ta, 1.0f);
    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);

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

    sendButt = new Button("Send", closeListener);
    sendButt.addClickListener(closeListener);
    buttHL.addComponent(sendButt);

    layout.addComponent(buttHL);
    layout.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);
    setWidth("650px");
    setHeight("500px");
    UI.getCurrent().addWindow(this);
    ta.focus();
}

From source file:edu.nps.moves.mmowgli.components.SignupsTable.java

License:Open Source License

@SuppressWarnings("serial")
public static void showDialog(String title) {
    final Button bulkMailButt = new Button("Initiate bulk mail job sending to filtered list");

    final Button emailButt = new Button("Compose email");
    emailButt.setDescription("Opens editing dialog to compose an email message to the selected individuals");
    final Button displayButt = new Button("Display as plain text");
    Button closeButt;/*ww  w .  j  a v  a  2s. co  m*/

    final SignupsTable tab = new SignupsTable(null, null, new ValueChangeListener() // selected
    {
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            emailButt.setEnabled(true);
        }
    });

    final Window dialog = new Window(title);
    dialog.setWidth("950px");
    dialog.setHeight("650px");

    VerticalLayout vl = new VerticalLayout();
    dialog.setContent(vl);
    vl.setSizeFull();
    vl.setMargin(true);
    vl.setSpacing(true);
    addFilterCheckBoxes(vl);
    vl.addComponent(new Label("Individuals who have established game accounts are shown faintly"));

    tab.setSizeFull();
    vl.addComponent(tab);
    vl.setExpandRatio(tab, 1.0f);

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

    buttHL.addComponent(bulkMailButt);
    bulkMailButt.setImmediate(true);
    ;
    Label lab = new Label("");
    buttHL.addComponent(lab);
    buttHL.setExpandRatio(lab, 1.0f);

    buttHL.addComponent(emailButt);
    emailButt.setImmediate(true);
    buttHL.addComponent(displayButt);
    displayButt.setImmediate(true);
    buttHL.addComponent(closeButt = new Button("Close"));
    closeButt.setImmediate(true);

    emailButt.setEnabled(false);

    closeButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            dialog.close();
        }
    });

    emailButt.addClickListener(new ClickListener() {
        @SuppressWarnings("rawtypes")
        @Override
        public void buttonClick(ClickEvent event) {
            HSess.init();
            Set set = (Set) tab.getValue();
            ArrayList<String> emails = new ArrayList<String>(set.size());
            Iterator itr = set.iterator();
            while (itr.hasNext()) {
                QueryWrapper wrap = (QueryWrapper) itr.next();
                emails.add(wrap.getEmail());
            }
            new SendMessageWindow(emails);
            HSess.close();
        }
    });

    displayButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            dumpSignupsTL();
            HSess.close();
        }
    });

    bulkMailButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            BulkMailHandler.showDialog((QueryContainer) tab.getContainerDataSource());
        }
    });

    vl.addComponent(buttHL);
    vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);

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

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) {
    final Window dialog = new Window(title);
    final TextField[] parameterFields;

    dialog.setModal(true);//from ww  w  .j  a  v a 2s.  c  o m

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

    final TextArea ta = new TextArea();
    ta.setWidth("100%");
    ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)");

    ta.setImmediate(true);
    layout.addComponent(ta);

    Set<String> keySet = params.keySet();
    parameterFields = new TextField[keySet.size()];
    int i = 0;
    GridLayout pGL = new GridLayout();
    pGL.addStyleName("m-greyborder");
    pGL.setColumns(2);
    Label hdr = new HtmlLabel("<b>Parameters</b>");
    hdr.addStyleName("m-textaligncenter");
    pGL.addComponent(hdr, 0, 0, 1, 0); // top row
    pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER);
    pGL.setSpacing(false);
    for (String key : keySet) {
        pGL.addComponent(new HtmlLabel("&nbsp;" + key + "&nbsp;&nbsp;"));
        pGL.addComponent(parameterFields[i] = new TextField());
        parameterFields[i++].setValue(params.get(key));
    }
    if (i > 0) {
        layout.addComponent(pGL);
        layout.setComponentAlignment(pGL, Alignment.TOP_CENTER);
    }

    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 exportButt = new Button("Export", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();

            Set<String> keySet = params.keySet();
            int i = 0;
            for (String key : keySet)
                params.put(key, parameterFields[i++].getValue().toString());

            lis.continueOrCancel(ta.getValue().toString());
        }
    });
    hl.addComponent(cancelButt);
    hl.addComponent(exportButt);
    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("385px");
    dialog.setHeight("310px");
    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

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

From source file:edu.nps.moves.mmowgli.hibernate.SearchPopup.java

License:Open Source License

@SuppressWarnings("serial")
public SearchPopup(String startingText) {
    super("Search for Players, Action Plans, Idea Cards");
    //setModal(true);   better not to be model

    this.initialText = startingText;
    setWidth("635px");
    setHeight("600px");
    center();/*from   w  w w .ja v a2 s.  c o m*/

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

    WordCloudPanel wcPan = new WordCloudPanel(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WordButton wb = (WordButton) event.getButton();
            tf.setValue(wb.word.text);
            searchButt.fireClick();
        }
    });
    wcPan.setImmediate(true);

    TermInfo[] tinfo = SearchManager.getHighFrequencyTerms();
    List<Word> wdLis = new ArrayList<Word>(tinfo.length);

    for (TermInfo inf : tinfo) {
        String txt = inf.term.text();
        Word wd = new Word(txt, inf.docFreq);
        wdLis.add(wd);
    }

    // V7
    /*
    TermStats[] tstats = SearchManager.getHighFrequencyTerms();
    List<Word> wdLis = new ArrayList<Word>(tstats.length);
    for(TermStats ts : tstats) {
      String txt = new String(ts.termtext.utf8ToString());
      Word wd = new Word(txt,ts.docFreq);
      wdLis.add(wd);
    }
    */

    wdLis = finalFilter(wdLis);
    // dumpList(wLis);
    wcPan.setWordData(wdLis, WordOrder.ALPHA);
    wcPan.setWidth("590px"); // won't work in ie"100%");
    vLay.addComponent(wcPan);

    HorizontalLayout topHL = new HorizontalLayout();
    vLay.addComponent(topHL);
    topHL.setWidth("100%");
    topHL.setMargin(true);
    topHL.setSpacing(true);

    topHL.addComponent(tf = new TextField());
    tf.addValueChangeListener(new TextFieldChangeListener());
    tf.setWidth("100%");
    //tf.setInputPrompt("Enter search terms");
    tf.setImmediate(true);
    tf.setTextChangeTimeout(5000);
    topHL.setExpandRatio(tf, 1.0f);
    if (startingText != null)
        tf.setValue(startingText);

    searchButt = new FireableButton("Search", this);
    topHL.addComponent(searchButt);
    searchButt.setClickShortcut(KeyCode.ENTER);

    vLay.addComponent(statusLabel = new HtmlLabel("&nbsp;"));
    statusLabel.setImmediate(true);

    resultsTable = new Table();
    resultsTable.addStyleName("m-actiondashboard-table");
    resultsTable.setImmediate(true);
    vLay.addComponent(resultsTable);
    resultsTable.setHeight("100%");
    resultsTable.setWidth("99%");
    vLay.setExpandRatio(resultsTable, 1.0f);

    BeanItemContainer<SearchResult> bCont = new BeanItemContainer<SearchResult>(SearchResult.class);
    bCont.addBean(new SearchResult("", "", "")); // fix for 6.7.0 bug
    resultsTable.addGeneratedColumn("text", new ToolTipAdder());
    resetTable(bCont);

    resultsTable.setNewItemsAllowed(false);
    resultsTable.setSelectable(true);

    resultsTable.addItemClickListener(new ItemClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void itemClick(ItemClickEvent event) {
            HSess.init();
            @SuppressWarnings("unchecked")
            BeanItem<SearchResult> bi = (BeanItem<SearchResult>) event.getItem();
            SearchResult sr = bi.getBean();
            MmowgliController controller = Mmowgli2UI.getGlobals().getController();
            if (sr.getType().equals(USERTYPEKEY))
                controller.miscEventTL(new AppEvent(SHOWUSERPROFILECLICK, SearchPopup.this, sr.getHibId()));
            else if (sr.getType().equals(ACTIONPLANTYPEKEY))
                controller.miscEventTL(new AppEvent(ACTIONPLANSHOWCLICK, SearchPopup.this, sr.getHibId()));
            else
                controller.miscEventTL(new AppEvent(CARDCLICK, SearchPopup.this, sr.getHibId()));
            HSess.close();

            closeListener.buttonClick(null);
        }
    });

    vLay.addComponent(closeButt = new Button("Close"));
    vLay.setComponentAlignment(closeButt, Alignment.TOP_RIGHT);
    closeButt.addClickListener(closeListener = new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (searchThread != null)
                searcherObj.killed = true;
            //V7 SearchPopup.this.getParent().removeWindow(SearchPopup.this);
            SearchPopup.this.close();
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabMap.java

License:Open Source License

@Override
public void initGui() {
    setSizeUndefined();/*from   w ww .ja va 2  s .co m*/

    ActionPlan ap = ActionPlan.getTL(apId);
    mmowgliMap = ap.getMap();
    if (mmowgliMap == null) {
        mmowgliMap = new edu.nps.moves.mmowgli.db.GoogleMap();
        GoogleMap.saveTL(mmowgliMap);

        ap.setMap(mmowgliMap);
        ActionPlan.updateTL(ap);
    }

    VerticalLayout leftLay = getLeftLayout();
    leftLay.setSpacing(false);
    leftLay.setMargin(false);

    Label missionLab = new Label("Authors, put your plan on the map!");
    leftLay.addComponent(missionLab);
    leftLay.setComponentAlignment(missionLab, Alignment.TOP_LEFT);
    missionLab.addStyleName("m-actionplan-mission-title-text");

    Label missionContentLab;
    if (!isMockup)
        missionContentLab = new HtmlLabel(ap.getMapInstructions());
    else {
        Game g = Game.getTL();
        missionContentLab = new HtmlLabel(g.getDefaultActionPlanMapText());
    }

    leftLay.addComponent(missionContentLab);
    leftLay.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT);
    leftLay.addStyleName("m-actionplan-mission-content-text");
    /*
    Component c;
    c=buildMapFlags(leftLay);  // does the addComponent
    leftLay.setComponentAlignment(c, Alignment.TOP_CENTER);
    */
    toggleFlags(editingOK);

    Label sp;
    leftLay.addComponent(sp = new Label());
    sp.setHeight("1px");
    leftLay.setExpandRatio(sp, 1.0f);

    map.setAttributionPrefix("Powered by Leaflet with v-leaflet");
    map.addStyleName("m-greyborder");
    map.removeAllComponents();
    try {
        LeafletLayers.installAllProviders(map);
    } catch (Exception ex) {
        System.err.println("ActionPlanPageTabMap error loading layers: " + ex.getClass().getSimpleName() + " "
                + ex.getLocalizedMessage());
    }
    double lat = mmowgliMap.getLatCenter();
    double lon = mmowgliMap.getLonCenter();
    map.setCenter(lat, lon);
    map.setZoomLevel(mmowgliMap.getZoom());
    map.setWidth(MAPWIDTH);
    map.setHeight(editingOK ? MAPHEIGHT_WITH_BUTTONS : MAPHEIGHT);

    // Build a mmowgliMap widget from our content
    /*
    googleMapWidget = new MmowgliMapWidget(app, mmowgliMap.getLatLonCenter(), mmowgliMap.getZoom(), GOOGLEMAPS_KEY);
            
    googleMapWidget.setWidth(MAPWIDTH);
    googleMapWidget.setHeight(editingOK ? MAPHEIGHT_WITH_BUTTONS : MAPHEIGHT);
    googleMapWidget.addControl(MapControl.MenuMapTypeControl);
    googleMapWidget.addControl(MapControl.SmallMapControl);
    //googleMapWidget.addListener(new MyMapClickListener());
    googleMapWidget.addListener(new MyMapMoveListener());
    //googleMapWidget.addListener(new MyMarkerClickListener());
    googleMapWidget.addListener(new MyMarkerMovedListener());
    googleMapWidget.reportMapBounds();
    */
    loadMarkers(ap);

    VerticalLayout rightLay = getRightLayout();
    rightLay.setSpacing(false);
    rightLay.setMargin(false);

    rightLay.addComponent(sp = new Label());
    sp.setHeight("15px");

    savePanel = new MapSaveButtPan();
    rightLay.addComponent(savePanel);
    rightLay.setComponentAlignment(savePanel, Alignment.TOP_CENTER);
    savePanel.setVisible(editingOK);
    // MapSaveListener msLis = new MapSaveListener();
    //  savePanel.setClickHearers(msLis.mapLocListener,msLis.mapMarkerListener,msLis.cancelListener);

    /*  DragAndDropWrapper ddw = new DragAndDropWrapper(googleMapWidget);
      ddw.setDropHandler(new MapDropHandler());
      ddw.setSizeFull();
              
      rightLay.addComponent(ddw);
      rightLay.setExpandRatio(ddw, 1.0f);
      */
    rightLay.addComponent(map);
    rightLay.setExpandRatio(map, 1);
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabPanel.java

License:Open Source License

public ActionPlanPageTabPanel(Object apId, boolean isMockup, boolean isReadOnly) {
    this.apId = apId;
    this.isMockup = isMockup;
    this.isReadOnly = isReadOnly;

    setSpacing(true);/*from ww  w .  ja va  2  s  .co  m*/
    setMargin(false);

    setWidth("970px");
    setHeight("750px");

    VerticalLayout leftWrapper = new VerticalLayout();
    addComponent(leftWrapper);
    leftWrapper.setSpacing(false);
    leftWrapper.setMargin(false);
    leftWrapper.setWidth("261px");

    Label sp;
    leftWrapper.addComponent(sp = new Label());
    sp.setHeight("15px");

    GhostVerticalLayoutWrapper gWrap = new GhostVerticalLayoutWrapper();
    leftWrapper.addComponent(gWrap);
    leftVertLay = new VerticalLayout();
    gWrap.ghost_setContent(leftVertLay);

    leftWrapper.addComponent(sp = new Label());
    sp.setHeight("1px");
    leftWrapper.setExpandRatio(sp, 1.0f);

    VerticalLayout rightWrapper = new VerticalLayout();
    addComponent(rightWrapper);
    rightWrapper.setSpacing(false);
    rightWrapper.setMargin(false);
    rightWrapper.setWidth("100%");
    rightWrapper.setHeight("690px");

    rightVertLay = new VerticalLayout();
    rightWrapper.addComponent(rightVertLay);
    rightVertLay.setWidth("690px");
    rightVertLay.setHeight("695px");
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabTalk.java

License:Open Source License

@Override
public void initGui() {
    setSizeUndefined();//from   w ww.  jav a  2  s. co m
    VerticalLayout leftVL = this.getLeftLayout();

    leftVL.setSpacing(true);

    Label missionLab = new Label("Authors, this is your team space.");
    leftVL.addComponent(missionLab);
    leftVL.setComponentAlignment(missionLab, Alignment.TOP_LEFT);
    missionLab.addStyleName("m-actionplan-mission-title-text");

    ActionPlan ap = ActionPlan.getTL(apId);

    Label missionContentLab;
    Game g = Game.getTL();
    if (!isMockup)
        missionContentLab = new HtmlLabel(ap.getTalkItOverInstructions());
    else {
        missionContentLab = new HtmlLabel(g.getDefaultActionPlanTalkText());
    }

    leftVL.addComponent(missionContentLab);
    leftVL.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT);
    leftVL.addStyleName("m-actionplan-mission-content-text");

    Label sp;
    leftVL.addComponent(sp = new Label());
    sp.setHeight("1px");
    leftVL.setExpandRatio(sp, 1.0f);

    VerticalLayout rightVL = getRightLayout();
    rightVL.setSpacing(true);

    Label lab;
    rightVL.addComponent(lab = new Label());
    lab.setHeight("15px");

    rightVL.addComponent(nonAuthorLabel = new Label("This is a space for plan authors to communicate."));
    nonAuthorLabel.setVisible(false);

    rightVL.addComponent(chatEntryComponent);
    chatEntryComponent.setWidth("100%");

    if (isGameMasterOrAdmin) {
        HorizontalLayout hl = new HorizontalLayout();
        rightVL.addComponent(hl);
        hl.setWidth("100%");

        hl.addComponent(sp = new Label());
        sp.setWidth("1px");
        hl.setExpandRatio(sp, 1.0f);

        viewAllButt = new ToggleLinkButton("View all", "View unhidden only", "m-actionplan-comment-text");
        viewAllButt.setToolTips("Temporarily show all messages, including those marked \"hidden\" (gm)",
                "Temporarily hide messages marked \"hidden\" (gm)");
        viewAllButt.addStyleName("m-actionplan-comments-button");
        viewAllButt.addOnListener(new ViewAllListener());
        viewAllButt.addOffListener(new ViewUnhiddenOnlyListener());
        hl.addComponent(viewAllButt);

        hl.addComponent(sp = new Label());
        sp.setWidth("8px");
    }
    Component comp = createChatScroller(rightVL);
    comp.setWidth("99%");
    rightVL.setExpandRatio(comp, 1.0f);
    comp.setHeight("99%");
    fillChatScrollerTL();
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.AddAuthorDialog.java

License:Open Source License

@SuppressWarnings("serial")
public AddAuthorDialog(Collection<User> currentlySelectedNames, boolean removeExisting) {
    setCaption("Invite Players to be Authors");
    setClosable(false); // no x in corner
    setWidth("300px");
    setHeight("400px");
    VerticalLayout mainVL = new VerticalLayout();
    mainVL.setSpacing(true);/*from w  w  w .  j  a  v  a 2 s  . c  o m*/
    mainVL.setMargin(true);
    mainVL.setSizeFull();
    setContent(mainVL);

    mainVL.addComponent(infoLabel);
    userList = new ListSelect();
    userList.addStyleName("m-greyborder");

    List<QuickUser> qlis = AppMaster.instance().getMcache().getUsersQuickList();
    BeanItemContainer<QuickUser> beanContainerQ = new BeanItemContainer<QuickUser>(QuickUser.class, qlis);

    userList.setContainerDataSource(beanContainerQ);
    userList.setItemCaptionMode(ListSelect.ItemCaptionMode.PROPERTY); // works!
    userList.setItemCaptionPropertyId("uname");
    userList.setNewItemsAllowed(false);

    mainVL.addComponent(userList);
    userList.setSizeFull();
    mainVL.setExpandRatio(userList, 1.0f);
    userList.setRows(15);
    userList.setImmediate(true);
    setMultiSelect(true); //userList.setMultiSelect(true);
    userList.setNullSelectionAllowed(false);

    if (currentlySelectedNames != null)
        for (User selU : currentlySelectedNames) {
            Collection<?> all = userList.getItemIds();
            for (Object o : all) {
                QuickUser qu = (QuickUser) o;
                if (selU.getId() == qu.getId()) {
                    if (removeExisting)
                        userList.removeItem(o);
                    else
                        userList.select(o);
                    break;
                }
            }
        }

    buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);
    mainVL.addComponent(buttHL);
    buttHL.setWidth("100%");
    Label spacer;
    buttHL.addComponent(spacer = new Label());
    spacer.setWidth("1px");
    buttHL.setExpandRatio(spacer, 1.0f);

    buttHL.addComponent(addButt = new Button("Select"));
    buttHL.addComponent(cancelButt = new Button("Cancel"));

    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            selected = null;
            addClicked = false;
            UI.getCurrent().removeWindow(AddAuthorDialog.this);//getParent().removeWindow(AddAuthorDialog.this);
            if (closer != null)
                closer.windowClose(null);
        }
    });
    addButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            selected = userList.getValue();

            addClicked = true;
            UI.getCurrent().removeWindow(AddAuthorDialog.this);//getParent().removeWindow(AddAuthorDialog.this);        
            if (closer != null)
                closer.windowClose(null);
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.HelpWantedDialog.java

License:Open Source License

@SuppressWarnings("serial")
@HibernateSessionThreadLocalConstructor//w  w  w .j  a  va  2  s .com
public HelpWantedDialog(final Object aplnId, boolean interested) {
    setCaption(interested ? "Express Interest in Action Plan" : "Offer Assistance with Action Plan");
    setModal(true);
    setSizeUndefined();
    setWidth("500px");
    setHeight("550px");

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

    StringBuilder sb = new StringBuilder();

    ActionPlan ap = ActionPlan.getTL(aplnId);
    String s = ap.getHelpWanted();

    if (s != null) {
        vLay.addComponent(new Label(msg1));
        Label helpWantedLab = new Label(s);
        helpWantedLab.addStyleName("m-helpWantedLabel");
        helpWantedLab.setWidth("100%");
        vLay.addComponent(helpWantedLab);
    }

    vLay.addComponent(new Label(msg2));
    final TextArea toTA = new TextArea("To");
    toTA.addStyleName("m-textareaboldcaption");
    toTA.setWidth("100%");
    toTA.setRows(1);
    toTA.setNullRepresentation("");
    toTA.setValue(getAuthors(sb, ap));
    vLay.addComponent(toTA);

    final TextArea ccTA = new TextArea("CC");
    ccTA.addStyleName("m-textareaboldcaption");
    ccTA.setWidth("100%");
    ccTA.setRows(1);
    ccTA.setNullRepresentation("");

    PagesData pd = new PagesData();
    ccTA.setValue(pd.gettroubleMailto());

    vLay.addComponent(ccTA);

    final TextArea subjTA = new TextArea("Subject");
    subjTA.addStyleName("m-textareaboldcaption");
    subjTA.setWidth("100%");
    subjTA.setRows(2);
    subjTA.setNullRepresentation("");
    sb.setLength(0);
    sb.append("My interest in Action Plan ");
    sb.append(ap.getId());
    sb.append(", \"");
    sb.append(ap.getTitle());
    sb.append('"');
    subjTA.setValue(sb.toString());
    vLay.addComponent(subjTA);

    final TextArea msgTA = new TextArea("Message");
    msgTA.addStyleName("m-textareaboldcaption");
    msgTA.setWidth("100%");
    msgTA.setHeight("100%");
    msgTA.setNullRepresentation("");
    vLay.addComponent(msgTA);
    vLay.setExpandRatio(msgTA, 1.0f);

    HorizontalLayout buttLay = new HorizontalLayout();
    vLay.addComponent(buttLay);
    buttLay.setSpacing(true);
    buttLay.setWidth("100%");
    Label sp;
    buttLay.addComponent(sp = new Label());
    sp.setHeight("1px");
    buttLay.setExpandRatio(sp, 1.0f);

    Button canButt = new Button("Cancel");
    buttLay.addComponent(canButt);

    Button sendButt = new Button("Send to authors");
    buttLay.addComponent(sendButt);

    canButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(HelpWantedDialog.this);
        }
    });

    sendButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            Object tos = toTA.getValue();
            if (tos == null || tos.toString().length() <= 0) {
                Notification.show("No recipients", Notification.Type.ERROR_MESSAGE);
                return;
            }
            Object cc = ccTA.getValue();
            if (cc == null || cc.toString().length() <= 0)
                cc = null;

            Object msg = msgTA.getValue();
            if (msg == null || msg.toString().length() <= 0) {
                Notification.show("No Message", Notification.Type.ERROR_MESSAGE);
                return;
            }
            Object subj = subjTA.getValue();
            if (subj == null)
                subj = "";

            HSess.init();

            List<User> authors = parseAuthorsTL(tos.toString().trim());
            MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals();
            MailManager mmgr = AppMaster.instance().getMailManager();
            User me = globs.getUserTL();
            for (User u : authors) {
                mmgr.mailToUserTL(me.getId(), u.getId(), subj.toString(), msg.toString());
            }

            if (cc == null)
                mmgr.mailToUserTL(me.getId(), me.getId(), "(CC:)" + subj.toString(), msg.toString());
            else
                mmgr.mailToUserTL(me.getId(), me.getId(), subj.toString(), msg.toString(), cc.toString(),
                        MailManager.Channel.BOTH); // the cc is an email, not a user name

            UI.getCurrent().removeWindow(HelpWantedDialog.this);
            Notification.show("Message(s) sent", Notification.Type.HUMANIZED_MESSAGE); // fixed 21 Jan 2015

            HSess.close();
        }
    });
}