Example usage for com.vaadin.ui Label setWidth

List of usage examples for com.vaadin.ui Label setWidth

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

License:Open Source License

private void addOneImage(Media m) {
    MPanelWrapper wrap = new MPanelWrapper();
    wrap.setMargin(false);/*from w w  w .j  av a  2 s . co  m*/
    wrap.setSpacing(false);
    wrap.ip = new MediaPanel(m, apId, 0, replaceLis);
    wrap.addComponent(wrap.ip);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth(MediaPanel.WIDTH);
    Label lab;
    hl.addComponent(lab = new Label());
    lab.setWidth("3px");
    hl.addComponent(lab = new Label(getDisplayedName(m)));
    lab.addStyleName("m-font-size-11");
    hl.setExpandRatio(lab, 1.0f);
    hl.addComponent(wrap.killButt = new NativeButton(null));
    hl.addComponent(lab = new Label());
    lab.setWidth("3px");

    wrap.addComponent(hl);
    wrap.killButt.setCaption("delete");
    wrap.killButt.setStyleName(BaseTheme.BUTTON_LINK);
    wrap.killButt.addStyleName("borderless");
    wrap.killButt.addStyleName("m-actionplan-nothumbs-button");
    wrap.killButt.addClickListener(new ImageRemover(m));
    ((AbstractLayout) imageScroller.getContent()).addComponent(wrap);
    wrap.ip.initGui();
}

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

License:Open Source License

@Override
public void initGui() {
    setSizeUndefined();// w  w w.j a v  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.ActionPlanPageTabVideos.java

License:Open Source License

private void addOneVideo(Media m) {
    VMPanelWrapper vl = new VMPanelWrapper();
    vl.setMargin(false);//from w  w w  .ja  v a 2  s  . c o m
    vl.setSpacing(false);
    vl.ip = new MediaPanel(m, apId, 0, replaceLis);
    vl.addComponent(vl.ip);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth(MediaPanel.WIDTH);
    Label lab;
    hl.addComponent(lab = new Label());
    lab.setWidth("3px");

    if (m.getType() != MediaType.YOUTUBE) {
        hl.addComponent(lab = new Label(getDisplayedName(m))); // label
        lab.addStyleName("m-font-size-11");
        hl.setExpandRatio(lab, 1.0f);
    } else {
        NativeButton linkButt;
        hl.addComponent(linkButt = new NativeButton(null)); // link
        linkButt.setCaption(getDisplayedName(m));
        linkButt.setStyleName(BaseTheme.BUTTON_LINK);
        linkButt.addStyleName("borderless");
        linkButt.addStyleName("m-actionplan-nothumbs-button");
        linkButt.addClickListener(new LinkVisitor(m));

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

    hl.addComponent(vl.killButt = new NativeButton(null));
    vl.killButt.setCaption("delete");
    vl.killButt.setStyleName(BaseTheme.BUTTON_LINK);
    vl.killButt.addStyleName("borderless");
    vl.killButt.addStyleName("m-actionplan-nothumbs-button");
    vl.killButt.addClickListener(new VideoRemover(m));

    hl.addComponent(lab = new Label());
    lab.setWidth("3px");

    vl.addComponent(hl);

    ((AbstractLayout) rightScroller.getContent()).addComponent(vl);
    vl.ip.initGui();
}

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. ja v  a 2s  . c  om
    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.AddImageDialog.java

License:Open Source License

@SuppressWarnings("serial")
@HibernateSessionThreadLocalConstructor/*from   w ww  .  jav  a  2  s  .c  om*/
public AddImageDialog(Object apId) {
    super("Add an Image");

    addStyleName("m-greybackground");

    setClosable(false); // no x in corner

    VerticalLayout mainVL = new VerticalLayout();
    mainVL.setSpacing(true);
    mainVL.setMargin(true);
    mainVL.setSizeUndefined(); // auto size
    setContent(mainVL);

    mainHL = new HorizontalLayout();
    mainVL.addComponent(mainHL);

    mainHL.setSpacing(true);

    holder = new AbsoluteLayout();
    mainHL.addComponent(holder);
    holder.setWidth("150px");
    holder.setHeight("150px");
    holder.addStyleName("m-darkgreyborder");

    VerticalLayout rightVL = new VerticalLayout();
    mainHL.addComponent(rightVL);

    fromWebCheck = new CheckBox();
    fromWebCheck.addStyleName("v-radiobutton");
    fromWebCheck.setValue(true);
    fromWebCheck.setImmediate(true);
    fromWebCheck.addValueChangeListener(new RadioListener(fromWebCheck));

    HorizontalLayout frWebHL = new HorizontalLayout();
    rightVL.addComponent(frWebHL);
    frWebHL.addComponent(fromWebCheck);
    VerticalLayout frWebVL = new VerticalLayout();
    frWebVL.setMargin(true);
    frWebVL.addStyleName("m-greyborder");
    frWebHL.addComponent(frWebVL);
    frWebVL.setWidth("370px");

    frWebVL.addComponent(new Label("From the web:"));
    HorizontalLayout webHL = new HorizontalLayout();
    webHL.setSpacing(true);
    frWebVL.addComponent(webHL);
    webHL.addComponent(webUrl = new TextField());
    webUrl.setColumns(21);
    webHL.addComponent(testButt = new Button("Test"));
    Label sp;
    webHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    webHL.setExpandRatio(sp, 1.0f);

    fromDeskCheck = new CheckBox();
    fromDeskCheck.addStyleName("v-radiobutton");
    fromDeskCheck.setValue(false);
    fromDeskCheck.addValueChangeListener(new RadioListener(fromDeskCheck));
    fromDeskCheck.setImmediate(true);
    HorizontalLayout dtHL = new HorizontalLayout();
    rightVL.addComponent(dtHL);
    dtHL.addComponent(fromDeskCheck);

    VerticalLayout dtopVL = new VerticalLayout();
    dtopVL.setMargin(true);
    dtopVL.addStyleName("m-greyborder");
    dtHL.addComponent(dtopVL);
    dtopVL.setWidth("370px");
    dtopVL.addComponent(new Label("From your desktop:"));
    HorizontalLayout localHL = new HorizontalLayout();
    localHL.setSpacing(true);
    dtopVL.addComponent(localHL);
    localHL.addComponent(localTF = new TextField());
    localTF.setColumns(21);
    localHL.addComponent(uploadWidget = new Upload());
    panel = new UploadStatus(uploadWidget);
    uploadWidget.setButtonCaption("Browse");

    File tempDir = Files.createTempDir();
    tempDir.deleteOnExit();
    handler = new UploadHandler(uploadWidget, panel, tempDir.getAbsolutePath());
    uploadWidget.setReceiver(handler);
    uploadWidget.setImmediate(true);
    panel.setWidth("100%");
    dtopVL.addComponent(panel);
    dtopVL.setComponentAlignment(panel, Alignment.TOP_CENTER);

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

    bottomHL.addComponent(cancelButt = new Button("Cancel"));
    bottomHL.addComponent(submitButt = new Button("Add"));
    setDisabledFields();

    uploadWidget.addFinishedListener(new FinishedListener() {
        @Override
        public void uploadFinished(FinishedEvent event) {
            Object key = HSess.checkInit();
            System.out.println("AddImageDialog.uploadFinished()");
            String fpath = handler.getFullUploadedPath();
            if (fpath != null) { // error of some kind if null 
                if (!MalwareChecker.isFileVirusFree(fpath)) {
                    panel.state.setValue("<span style='color:red;'>Failed malware check</span>");
                    fpath = null;
                    localTF.setValue("");
                    HSess.checkClose(key);
                    return;
                }

                File f = new File(fpath);
                f.deleteOnExit();

                try {
                    MediaImage mediaImage = InstallImageDialog.putFileImageIntoDbTL(f, f.getName(),
                            event.getMIMEType());
                    f.delete();
                    media = mediaImage.media;
                    image = mediaImage.image;
                    media.setCaption(null);
                    Resource res = Mmowgli2UI.getGlobals().getMediaLocator().locate(media);
                    setupEmbeddedImageThumbnail(res, media);
                    localTF.setValue(event.getFilename());
                } catch (IOException ex) {
                    Notification.show("Error loading image", Notification.Type.ERROR_MESSAGE);
                    MSysOut.println(ERROR_LOGS, "Error in AddImageDialog loading image: "
                            + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
                }
            }
            HSess.checkClose(key);
        }
    });

    testButt.addClickListener(new testWebImageHandler());

    submitButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (fromWebCheck.getValue()) {
                if (checkBadUrl(webUrl.getValue(), event.getButton()))
                    return;
            }
            UI.getCurrent().removeWindow(AddImageDialog.this);
            if (closer != null)
                closer.windowClose(null);
        }
    });
    cancelButt.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            Object key = HSess.checkInit();
            if (media != null) {
                Media.deleteTL(media);
                media = null;
            }
            if (image != null) {
                Image.deleteTL(image);
                image = null;
            }
            uploadWidget.interruptUpload();
            UI.getCurrent().removeWindow(AddImageDialog.this);
            if (closer != null)
                closer.windowClose(null);

            HSess.checkClose(key);
        }
    });

    webUrl.focus();
}

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

License:Open Source License

@SuppressWarnings("serial")
public AddVideoDialog() {
    super("Add a Video");
    addStyleName("m-greybackground");

    setClosable(false); // no x in corner
    setWidth("530px");
    setHeight("400px");

    VerticalLayout mainVL = new VerticalLayout();
    mainVL.setSpacing(true);/*from  w w  w  .ja  va  2s.  c  om*/
    mainVL.setMargin(true);
    mainVL.setSizeUndefined(); // auto size
    mainVL.setWidth("100%");
    setContent(mainVL);

    Label helpLab = new HtmlLabel("Add YouTube videos to your Action Plan this way:"
            + "<OL><LI>Find the video you want at <a href=\"https://www.youtube.com\" target=\""
            + PORTALTARGETWINDOWNAME + "\">www.youtube.com</a>.</LI>"
            + "<LI>Click the \"share\" button below the video screen.</LI>"
            + "<LI>Copy the URL under \"Link to this video:\"</LI>"
            + "<LI>Paste the URL into the field below.</LI>" + "</OL>" + "If you have media that "
            + "has not been uploaded to YouTube, see <a href=\"https://www.youtube.com\" target=\""
            + PORTALTARGETWINDOWNAME + "\">www.youtube.com</a> "
            + "for help with establishing a free account.<br/>");
    helpLab.setWidth("100%");
    mainVL.addComponent(helpLab);

    HorizontalLayout mainHL = new HorizontalLayout();
    mainHL.setMargin(false);
    mainHL.setSpacing(true);
    mainVL.addComponent(mainHL);

    holder = new AbsoluteLayout();
    mainHL.addComponent(holder);
    holder.addStyleName("m-darkgreyborder");
    holder.setWidth("150px");
    holder.setHeight("150px");
    holder.addComponent(new Label("Test video display"), "top:0px;left:0px;");
    VerticalLayout rightVL = new VerticalLayout();
    mainHL.addComponent(rightVL);
    rightVL.setMargin(false);
    rightVL.setSpacing(true);
    rightVL.addComponent(new Label("YouTube video address"));

    HorizontalLayout tfHL = new HorizontalLayout();
    tfHL.setSpacing(true);
    rightVL.addComponent(tfHL);
    addrTf = new TextField();
    tfHL.addComponent(addrTf);
    addrTf.setColumns(21);
    tfHL.addComponent(testButt = new Button("Test"));

    rightVL.addComponent(new Label("Using the test button will set the"));
    rightVL.addComponent(new Label("default title and description."));

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

    HorizontalLayout bottomHL = new HorizontalLayout();
    rightVL.addComponent(bottomHL);
    rightVL.setComponentAlignment(bottomHL, Alignment.TOP_RIGHT);
    bottomHL.setSpacing(true);
    bottomHL.setWidth("100%");
    Label spacer;
    bottomHL.addComponent(spacer = new Label());
    spacer.setWidth("100%");
    bottomHL.setExpandRatio(spacer, 1.0f);

    bottomHL.addComponent(cancelButt = new Button("Cancel"));
    bottomHL.addComponent(submitButt = new Button("Add"));
    testButt.addClickListener(new TestVidHandler());

    submitButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(AddVideoDialog.this);
            if (closer != null)
                closer.windowClose(null);
        }
    });

    cancelButt.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            media = null;
            UI.getCurrent().removeWindow(AddVideoDialog.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/*from  w  w  w . j  a  v a  2s .  c om*/
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();
        }
    });
}

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

License:Open Source License

MediaPanel(Media m, Object apId, int idx, ClickListener replaceListener) {
    this.idx = idx;
    this.m = m;//from   ww w.j a va  2 s.c  o  m

    zoom = new NativeButton();
    caption = new TextArea();
    caption.setInputPrompt("Description");
    title = new TextField();
    title.setInputPrompt("Title");
    titleHL = new HorizontalLayout();
    indexLab = new HtmlLabel("");

    FocusHandler fHandler = new FocusHandler();
    caption.addFocusListener((FocusListener) fHandler);
    title.addFocusListener((FocusListener) fHandler);

    captionSavePan = new HorizontalLayout();
    captionSavePan.setSpacing(true);
    captionSavePan.setMargin(false);
    Label lab;
    captionSavePan.addComponent(lab = new Label());
    lab.setWidth("1px");
    captionSavePan.setExpandRatio(lab, 1.0f);
    canButt = new Button("Cancel");
    captionSavePan.addComponent(canButt);
    canButt.setStyleName(Reindeer.BUTTON_SMALL);
    canButt.addClickListener((ClickListener) fHandler);
    saveButt = new Button("Save");
    captionSavePan.addComponent(saveButt);
    saveButt.setStyleName(Reindeer.BUTTON_SMALL);
    saveButt.addStyleName("m-redbutton");
    saveButt.addClickListener((ClickListener) fHandler);
    captionSavePan.addComponent(lab = new Label());
    lab.setWidth("5px");
}

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

License:Open Source License

@Override
public void initGui() {
    setStyleName("m-actionplan-image-panel");
    setSizeUndefined();/*from  www. ja va2s. co m*/
    setWidth(WIDTH);

    setSpacing(false);
    titleHL.setMargin(false);
    titleHL.setSpacing(true);
    titleHL.setSizeUndefined();
    titleHL.setWidth("307px"); //WIDTH);
    Label sp;
    titleHL.addComponent(sp = new Label());
    sp.setWidth("3px");
    titleHL.addComponent(indexLab);
    titleHL.setComponentAlignment(indexLab, Alignment.MIDDLE_CENTER);
    titleHL.addComponent(title);
    titleHL.setExpandRatio(title, 1.0f);
    addComponent(titleHL);
    title.addStyleName("m-actionplan-image-title");
    title.setWidth("100%");

    setMedia(m);

    caption.setHeight("65px");// this: setRows(4); doesn't size the same on chrome and ff
    caption.setWidth("100%");
    addComponent(caption);
    caption.addStyleName("m-actionplan-images-caption");

    addComponent(captionSavePan);
    captionSavePan.setWidth("99%");
    captionSavePan.setVisible(false);
}

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

License:Open Source License

@HibernateSessionThreadLocalConstructor
@SuppressWarnings("serial")
public RfeDialog(Object aplnId) {
    this.apId = aplnId;

    setCaption("Request for Expertise");
    setModal(true);//w w w. j av  a2s . c  o m
    setSizeUndefined();
    setWidth("500px");
    setHeight("400px");

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

    IDButton searchButt = new IDButton("Option 1: Search for players with needed expertise", SEARCHCLICK, null);
    searchButt.enableAction(false); // do manually
    searchButt.addClickListener(new SearchListener());
    vLay.addComponent(searchButt);

    VerticalLayout nuts = new VerticalLayout();
    vLay.addComponent(nuts);
    nuts.setSizeFull();
    vLay.setExpandRatio(nuts, 1.0f);
    Label lab;
    /*vLay*/nuts.addComponent(lab = new Label("Option 2: Post help-wanted notice to action plan"));
    lab.addStyleName("m-font-bold11");

    final VerticalLayout helpWantedPan = new VerticalLayout();
    /*vLay*/nuts.addComponent(helpWantedPan);
    helpWantedPan.addStyleName("m-greyborder");
    helpWantedPan.setWidth("99%");
    helpWantedPan.setHeight("99%");
    helpWantedPan.setSpacing(true);
    helpWantedPan.setMargin(true);
    /*vLay*/nuts.setExpandRatio(helpWantedPan, 1.0f);

    helpWantedTA = new TextArea("Current posting");
    helpWantedTA.setWidth("100%");
    helpWantedTA.setHeight("100%");
    helpWantedTA.setNullRepresentation("");
    helpWantedPan.addComponent(helpWantedTA);
    helpWantedPan.setExpandRatio(helpWantedTA, 1.0f);

    HorizontalLayout buttLay = new HorizontalLayout();
    helpWantedPan.addComponent(buttLay);
    buttLay.setSpacing(true);
    buttLay.setWidth("100%");

    buttLay.addComponent(lab = new Label());
    lab.setWidth("10px");

    clearButt = new Button("Clear");
    buttLay.addComponent(clearButt);
    clearButt.addClickListener(clearButtLis = new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            ActionPlan ap = ActionPlan.getTL(apId);
            helpWantedTA.setValue(null);
            if (null != ap.getHelpWanted()) {
                ap.setHelpWanted(null);
                ActionPlan.updateTL(ap);
                Notification notif = new Notification("Cleared");
                notif.setDelayMsec(3000);
                notif.show(Page.getCurrent());
                GameEventLogger.logHelpWantedTL(ap);
                notifyAuthorsOfChangeTL(ap);
            }
            HSess.close();
        }
    });

    buttLay.addComponent(lab = new Label());
    buttLay.setExpandRatio(lab, 1.0f);

    postButt = new Button("Post");
    buttLay.addComponent(postButt);
    postButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            Object val = helpWantedTA.getValue();
            if (val == null || val.toString().length() <= 0) {
                clearButtLis.buttonClick(event);
                return;
            }

            HSess.init();
            String s = val.toString();
            ActionPlan ap = ActionPlan.getTL(apId);
            if (s == null ? ap.getHelpWanted() != null : !s.equals(ap.getHelpWanted())) {
                ap.setHelpWanted(s);
                ActionPlan.updateTL(ap);
                Notification notif = new Notification("Posted");
                notif.setDelayMsec(3000);
                notif.show(Page.getCurrent());
                GameEventLogger.logHelpWantedTL(ap);
                notifyAuthorsOfChangeTL(ap);
            }
            HSess.close();
        }
    });
    buttLay.addComponent(lab = new Label());
    lab.setWidth("10px");

    helpWantedPan.addComponent(lab = new Label());
    lab.setHeight("10px");

    IDButton troubleButt = new IDButton("Option 3: Post Trouble Report", POSTTROUBLECLICK, null);
    troubleButt.enableAction(false); // managed manually
    troubleButt.addClickListener(new TroubleListener());
    vLay.addComponent(troubleButt);

    Button closeButt = new Button("Close");
    vLay.addComponent(closeButt);
    closeButt.addClickListener(new CloseListener());

    vLay.setComponentAlignment(closeButt, Alignment.MIDDLE_RIGHT);

    ActionPlan ap = ActionPlan.getTL(apId);
    String s = ap.getHelpWanted();
    helpWantedTA.setValue(s);
}