Example usage for com.vaadin.ui CheckBox CheckBox

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

Introduction

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

Prototype

public CheckBox(String caption) 

Source Link

Document

Creates a new checkbox with a set caption.

Usage

From source file:edu.kit.dama.ui.admin.wizard.AdministratorAccountCreation.java

License:Apache License

@Override
public void buildMainLayout() {
    Label information = new Label(
            "In order to be able to perform administrative tasks and for basic configuration, a privileged user must be created. This user is allowed to "
                    + "modify settings and internal workflows of the repository system. Therefor, the administrator should have at least valid contact information assigned and must be "
                    + "able to log in into the web interface.<br/>Optionally, OAuth creadentials can be added directly to allow RESTful access to the administrator. However, this can "
                    + "also be done later inside the web user interface.",
            ContentMode.HTML);//from w w  w  . j  a  va  2  s.  c om

    adminFirstName = UIUtils7.factoryTextField("First Name", "The first name of the admin user.", 3, 255);
    adminFirstName.setRequired(true);
    adminFirstName.setWidth("400px");
    adminLastName = UIUtils7.factoryTextField("Last Name", "The last name of the admin user.", 3, 255);
    adminLastName.setRequired(true);
    adminLastName.setWidth("400px");
    adminEMail = UIUtils7.factoryTextField("Contact EMail", "The admin contact email.", 6, 255);
    adminEMail.setRequired(true);
    adminEMail.setWidth("400px");
    adminPassword = new PasswordField("Password");
    adminPassword.setWidth("400px");
    adminPassword.setRequired(true);
    adminPasswordCheck = new PasswordField("Confirm Password");
    adminPasswordCheck.setWidth("400px");
    adminPasswordCheck.setRequired(true);
    addOAuthCredentials = new CheckBox("Create OAuth Credentials for Administrator (optional)");
    addOAuthCredentials.setDescription(
            "Create (random) OAuth credentials for the admin user. These credentials can be used to access the RESTful endpoints of the repository. "
                    + "You can also create/modify OAuth credentials later inside the user interface.");
    addOAuthCredentials.setWidth("400px");
    getMainLayout().addComponent(information);
    getMainLayout().addComponent(adminFirstName);
    getMainLayout().addComponent(adminLastName);
    getMainLayout().addComponent(adminEMail);
    getMainLayout().addComponent(adminPassword);
    getMainLayout().addComponent(adminPasswordCheck);
    getMainLayout().addComponent(addOAuthCredentials);
    getMainLayout().setComponentAlignment(information, Alignment.TOP_LEFT);
    getMainLayout().setComponentAlignment(adminFirstName, Alignment.TOP_LEFT);
    getMainLayout().setComponentAlignment(adminLastName, Alignment.TOP_LEFT);
    getMainLayout().setComponentAlignment(adminEMail, Alignment.TOP_LEFT);
    getMainLayout().setComponentAlignment(adminPassword, Alignment.TOP_LEFT);
    getMainLayout().setComponentAlignment(adminPasswordCheck, Alignment.TOP_LEFT);
    getMainLayout().setComponentAlignment(addOAuthCredentials, Alignment.TOP_LEFT);
    addOAuthCredentials.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (addOAuthCredentials.getValue()) {
            oAuthSecret = RandomStringUtils.randomAlphabetic(16);
        } else {
            oAuthSecret = null;
        }
    });
}

From source file:edu.kit.dama.ui.admin.wizard.BaseMetadataExtractionAndIndexingCreation.java

License:Apache License

public void buildMainLayout() {
    extractorProperties = new HashMap<>();
    Label information = new Label(
            "In order to query for digital objects by metadata, relevant metadata must be extracted, processed and indexed at ingest time. "
                    + "Typically, this process highly depends on the community ingesting data as metadata might be located next to the data, within the data or externally. "
                    + "In order to be able to query at least for base metadata available for all digital objects, basic METS metadata extraction marked below should remain enabled. "
                    + "It is highly recommended to keep the default settings and to modify them later according to special needs.<br/>"
                    + "If you already have a custom metadata extractor in place, feel free to disable the checkbox.",
            ContentMode.HTML);//from   w ww.  j av a  2  s .c o m

    createMetsExtractor = new CheckBox("Select to Enable basic METS metadata extraction for each ingest.");
    createMetsExtractor.setValue(true);

    createMetsExtractor.addValueChangeListener((event) -> {
        Set<Entry<String, TextField>> entries = extractorProperties.entrySet();
        entries.forEach((entry) -> {
            entry.getValue().setEnabled(createMetsExtractor.getValue());
        });
    });

    getMainLayout().addComponent(information);
    getMainLayout().addComponent(createMetsExtractor);
    getMainLayout().setComponentAlignment(information, Alignment.TOP_LEFT);
    getMainLayout().setComponentAlignment(createMetsExtractor, Alignment.TOP_LEFT);

    BasicMetsExtractor ext = new BasicMetsExtractor("");
    String[] internalKeys = ext.getInternalPropertyKeys();

    for (String internalKey : internalKeys) {
        TextField field = UIUtils7.factoryTextField(internalKey, null);
        field.setRequired(true);
        field.setDescription(ext.getInternalPropertyDescription(internalKey));
        if (MetsMetadataExtractor.COMMUNITY_DMD_SECTION_ID.equals(internalKey)) {
            field.setValue("cmd0");
        } else if (MetsMetadataExtractor.COMMUNITY_MD_TYPE_ID.equals(internalKey)) {
            field.setValue("DC");
        } else if (MetsMetadataExtractor.COMMUNITY_METADATA_SCHEMA_ID.equals(internalKey)) {
            field.setValue("oai_dc");
        } else {
            field.setValue("TRUE");
        }
        extractorProperties.put(internalKey, field);
        getMainLayout().addComponent(field);
        getMainLayout().setComponentAlignment(field, Alignment.TOP_LEFT);
    }
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliController.java

License:Open Source License

@SuppressWarnings("serial")
private void handleAdminMessage(Game g) {
    final Window dialog = new Window("Important!");
    VerticalLayout vl = new VerticalLayout();
    dialog.setContent(vl);/*  w  w w .j  av a2s .  c  o m*/
    vl.setSizeUndefined();
    vl.setMargin(true);
    vl.setSpacing(true);

    vl.addComponent(new HtmlLabel(g.getAdminLoginMessage()));

    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);
    final CheckBox cb;
    buttHL.addComponent(cb = new CheckBox("Show this message again on the next administrator login"));
    cb.setValue(true);
    Button closeButt;
    buttHL.addComponent(closeButt = new Button("Close"));
    closeButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            if (Boolean.parseBoolean(cb.getValue().toString()))
                ; // do nothing
            else {
                HSess.init();
                Game.getTL().setAdminLoginMessage(null);
                Game.updateTL();
                HSess.close();
            }
            UI.getCurrent().removeWindow(dialog);
        }
    });

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

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

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

License:Open Source License

public SendMessageWindow(User user, boolean ccSelf, MailManager.Channel channel, boolean showCcTroubleList) {
    super("A message to " + user.getUserName());

    this.usr = user;
    this.ccSelf = ccSelf;
    this.channel = channel;

    setModal(true);/*w ww.  ja  v  a 2 s .c  o  m*/
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

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

    User me = Mmowgli2UI.getGlobals().getUserTL();
    Game game = Game.getTL();
    String acronym = game.getAcronym();
    acronym = acronym == null ? "" : acronym + " ";
    subjTf.setValue(acronym + "Mmowgli message to " + usr.getUserName() + " from " + me.getUserName());
    layout.addComponent(subjTf);
    if (showCcTroubleList) {
        layout.addComponent(ccTroubleListCB = new CheckBox("CC mmowgli trouble list"));
        ccTroubleListCB.setValue(false);
    }
    ta = new TextArea();
    ta.setCaption("Content");
    ta.setRows(10);
    ta.setColumns(50);
    ta.setInputPrompt("Type message here");
    layout.addComponent(ta);

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

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

    sendButt = new Button("Send", closeListener);//new IDButton("Send", SENDPRIVATEMESSAGECLICK, user);
    sendButt.addClickListener(closeListener);
    buttHL.addComponent(sendButt);

    layout.addComponent(buttHL);
    layout.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);
    layout.setSizeUndefined(); // does a "pack"

    UI.getCurrent().addWindow(this);
    ta.focus();
}

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

License:Open Source License

private static void addFilterCheckBoxes(VerticalLayout vl) {
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);/*from   w ww. j a va2s.c  om*/
    hl.addComponent(new HtmlLabel("Filters:&nbsp;&nbsp;"));
    hl.addComponent(confirmedCB = new CheckBox("confirmed"));
    hl.addComponent(ingameCB = new CheckBox("in-game"));
    hl.addComponent(eligibleCB = new CheckBox("eligible"));
    confirmedCB.setDescription("email address has been confirmed");
    ingameCB.setDescription("a player with this email address has established a game account");
    eligibleCB.setDescription("email address meets elibibility rules (*.mil, *.navy.mil, etc.");
}

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

License:Open Source License

@SuppressWarnings("serial")
private void maybeAddHiddenCheckBoxTL(HorizontalLayout hl, ActionPlan ap) {
    User me = Mmowgli2UI.getGlobals().getUserTL();

    if (me.isAdministrator() || me.isGameMaster()) {
        Label sp;/*from   w  w  w .j a  v a 2  s  . com*/
        hl.addComponent(sp = new Label());
        sp.setWidth("80px");

        final CheckBox hidCb = new CheckBox("hidden");
        hidCb.setValue(ap.isHidden());
        hidCb.setDescription("Only game masters see this");
        hidCb.setImmediate(true);
        hl.addComponent(hidCb);
        hl.setComponentAlignment(hidCb, Alignment.BOTTOM_RIGHT);

        hidCb.addValueChangeListener(new ValueChangeListener() {
            @Override
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            public void valueChange(ValueChangeEvent event) {
                HSess.init();
                ActionPlan acntp = ActionPlan.getTL(getApId());
                boolean nowHidden = acntp.isHidden();
                boolean tobeHidden = hidCb.getValue();
                if (nowHidden != tobeHidden) {
                    acntp.setHidden(tobeHidden);
                    ActionPlan.updateTL(acntp);
                }
                HSess.close();
            }
        });

        final CheckBox supIntCb = new CheckBox("super interesting");
        supIntCb.setValue(ap.isSuperInteresting());
        supIntCb.setDescription("Mark plan super-interesting (only game masters see this)");
        supIntCb.setImmediate(true);
        hl.addComponent(supIntCb);
        hl.setComponentAlignment(supIntCb, Alignment.BOTTOM_RIGHT);
        supIntCb.addValueChangeListener(new ValueChangeListener() {

            @Override
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            public void valueChange(ValueChangeEvent event) {
                HSess.init();
                ActionPlan acntp = ActionPlan.getTL(getApId());
                boolean nowSupInt = acntp.isSuperInteresting();
                boolean tobeSupInt = supIntCb.getValue();
                if (nowSupInt != tobeSupInt) {
                    acntp.setSuperInteresting(tobeSupInt);
                    ActionPlan.updateTL(acntp);
                }
                HSess.close();
            }
        });
    }
}

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

License:Open Source License

@SuppressWarnings("serial")
@HibernateSessionThreadLocalConstructor/*from w  w  w  .  j av a2 s .  c  o  m*/
public PhasesEditPanel(Move move, GameDesignGlobals globs) {
    this.moveBeingEdited = move;
    setWidth("100%");
    setSpacing(true);
    phaseBeingEdited = moveBeingEdited.getCurrentMovePhase();
    tabSh = new TabSheet();

    tabPanels.add(titlePan = new PhaseTitlesGameDesignPanel(phaseBeingEdited, auxListener, globs));
    tabPanels.add(signupPan = new SignupHTMLGameDesignPanel(phaseBeingEdited, auxListener, globs));
    tabPanels.add(loginPan = new LoginSignupGameDesignPanel(phaseBeingEdited, auxListener, globs));
    tabPanels.add(welcomePan = new WelcomeScreenGameDesignPanel(phaseBeingEdited, auxListener, globs));
    tabPanels.add(call2ActionPan = new CallToActionGameDesignPanel(phaseBeingEdited, auxListener, globs));

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

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

    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);
    topHL.addComponent(topLevelLabel = new Label());
    setTopLabelText(moveBeingEdited);
    topLevelLabel.setSizeUndefined();
    topHL.addComponent(phaseSelector = new PhaseSelector(null, Move.getCurrentMoveTL()));
    phaseSelector.addValueChangeListener(new PhaseComboListener());

    topHL.addComponent(
            runningPhaseWarningLabel = new HtmlLabel("<font color='red'><i>Active game phase!</i></font>"));
    runningPhaseWarningLabel.setSizeUndefined();
    runningPhaseWarningLabel.setVisible(AbstractGameBuilderPanel.isRunningPhaseTL(phaseBeingEdited));

    topHL.addComponent(newPhaseButt = new NativeButton("Add new phase to round"));
    newPhaseButt.setEnabled(false);
    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);
    topHL.setWidth("100%");
    addComponent(topHL);

    propagateCB = new CheckBox("Propagate new phase-dependent edits to all other phases in this round");
    addComponent(propagateCB);
    setComponentAlignment(propagateCB, Alignment.MIDDLE_CENTER);
    propagateCB.setVisible(phaseBeingEdited.isPreparePhase());

    addComponent(lab = new HtmlLabel(
            "<b>The currently running phase is set through the Game Administrator menu</b>"));
    lab.setSizeUndefined();
    setComponentAlignment(lab, Alignment.TOP_CENTER);

    newPhaseButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            NewMovePhaseDialog dial = new NewMovePhaseDialog(moveBeingEdited);
            dial.addCloseListener(new CloseListener() {
                @Override
                public void windowClose(CloseEvent e) {
                    Object key = HSess.checkInit();
                    phaseSelector.fillCombo(moveBeingEdited);
                    HSess.checkClose(key);
                }
            });
            dial.showDialog();
            HSess.close();
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.gamemaster.SetBlogHeadlineWindow.java

License:Open Source License

public SetBlogHeadlineWindow() {
    super("Edit Blog Headline");
    cancelButt = new Button("Cancel");
    okButt = new Button("Update");
    nullCheckBox = new CheckBox("Do not show blog headline");
    nullCheckBox.setImmediate(true);/*from   ww  w.j  a  v  a 2 s  . co  m*/
    setModal(true);
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RoleSelectionPage.java

License:Open Source License

public RoleSelectionPage(ClickListener listener, Long uId) {
    super(listener);
    super.initGui();
    this.localUserId = uId;

    setTitleString("Last Step: tell others of your interests"); //"Role Selection");

    contentVLayout.setSpacing(true);//from  www .  j  av  a2 s.c  o  m
    contentVLayout.setMargin(true);
    contentVLayout.addStyleName("m-role-page");

    Label lab;
    contentVLayout.addComponent(lab = new HtmlLabel(
            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This optional information is revealed to other players."));
    lab.addStyleName(labelStyle);
    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("10px");

    expertiseTf = new TextField();
    expertiseTf.addStyleName("m-noleftmargin");
    expertiseTf.setCaption("Enter a short description of your pertinent expertise.");
    expertiseTf.setColumns(38);
    expertiseTf.setInputPrompt("optional");
    contentVLayout.addComponent(expertiseTf);

    Game game = Game.getTL();
    ques = game.getQuestion();

    ansTf = new TextArea(ques.getQuestion());
    ansTf.setWidth("98%");
    ansTf.setRows(10);
    ansTf.setInputPrompt("(optional, but worth 10 points if you answer)");
    contentVLayout.addComponent(ansTf);

    emailCb = new CheckBox("I agree to receive private email during game play.");
    contentVLayout.addComponent(emailCb);
    emailCb.addStyleName(labelStyle);
    emailCb.addStyleName("m-nopaddingormargin");
    emailCb.setValue(true);

    messagesCb = new CheckBox("I agree to receive private in-game messages during game play.");
    contentVLayout.addComponent(messagesCb);
    messagesCb.addStyleName(labelStyle);
    messagesCb.addStyleName("m-nopaddingormargin");
    messagesCb.setValue(true);

    HorizontalLayout buttPan = new HorizontalLayout();
    buttPan.setWidth("100%");
    buttPan.setSpacing(true);

    buttPan.addComponent(lab = new Label("OK great, thanks for registering!  Let's play."));
    lab.addStyleName(labelStyle);
    lab.addStyleName("m-nopaddingormargin");
    lab.setSizeUndefined();

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

    buttPan.addComponent(continueButt = new NativeButton(null));
    Mmowgli2UI.getGlobals().mediaLocator().decorateGetABriefingButton(continueButt);

    Label sp;
    buttPan.addComponent(sp = new Label());
    sp.setWidth("10px");

    contentVLayout.addComponent(buttPan);

    continueButt.addClickListener(new ContinueListener());
    continueButt.setClickShortcut(KeyCode.ENTER);
    expertiseTf.focus();
}

From source file:eu.maxschuster.vaadin.buttonlink.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout wrapper = new VerticalLayout();
    wrapper.setSizeFull();//www  .  java  2 s  .c o  m
    setContent(wrapper);

    // Show it in the middle of the screen
    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeUndefined();
    wrapper.addComponent(layout);
    wrapper.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

    final Label themeName = new Label();
    themeName.setCaption("Current Theme:");
    themeName.addStyleName("h1");
    layout.addComponent(themeName);

    Label waring = new Label("<strong>Attention:</strong><br />\nChanging the theme may take a few seconds!");
    waring.setContentMode(ContentMode.HTML);
    layout.addComponent(waring);

    getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {

        @Override
        public void uriFragmentChanged(UriFragmentChangedEvent event) {
            String fragment = event.getUriFragment().replace("!", "");
            if (fragment.isEmpty()) {
                fragment = defaultTheme;
            }
            loadTheme(fragment);
        }
    });

    themeSelect.setSizeFull();
    themeSelect.setNullSelectionAllowed(false);
    themeSelect.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            String fragment = "!" + themeSelect.getValue();
            getPage().setUriFragment(fragment);
        }
    });
    layout.addComponent(themeSelect);
    layout.setComponentAlignment(themeSelect, Alignment.BOTTOM_CENTER);

    final CheckBox useIcon = new CheckBox("Use icons");
    useIcon.setValue(false);
    layout.addComponent(useIcon);

    final HorizontalLayout comparsionLayout = new HorizontalLayout();
    comparsionLayout.setSpacing(true);
    layout.addComponent(comparsionLayout);
    layout.setComponentAlignment(comparsionLayout, Alignment.TOP_CENTER);

    final Button button = new Button("This is a \"normal\" Button", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("Hello World!");
        }
    });
    comparsionLayout.addComponent(button);
    comparsionLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

    // Initialize our new UI component
    final ButtonLink buttonLink = new ButtonLink("This is a ButtonLink",
            new ExternalResource("https://vaadin.com"));
    buttonLink.setTargetName("_blank");
    buttonLink.setDescription("Visit vaadin.com in a new tab or window.");
    buttonLink.addStyleName("test-stylename");
    comparsionLayout.addComponent(buttonLink);
    comparsionLayout.setComponentAlignment(buttonLink, Alignment.MIDDLE_LEFT);

    themeName.setPropertyDataSource(themeSelect);

    useIcon.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean b = (Boolean) event.getProperty().getValue();
            if (b) {
                button.setIcon(vaadinIcon, "Vaadin Logo");
                buttonLink.setIcon(vaadinIcon, "Vaadin Logo");
            } else {
                button.setIcon(null);
                buttonLink.setIcon(null);
            }
        }
    });

    String fragment = getPage().getUriFragment();

    loadTheme(
            fragment == null || fragment.replace("!", "").isEmpty() ? defaultTheme : fragment.replace("!", ""));
}