Example usage for com.vaadin.ui Button setEnabled

List of usage examples for com.vaadin.ui Button setEnabled

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

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

License:Open Source License

@HibernateSessionThreadLocalConstructor
@SuppressWarnings("serial")
public MapGameDesignPanel(GameDesignGlobals globs) {
    super(false, globs);
    Game g = Game.getTL();/*from  w  w  w .ja  v a 2s .c o  m*/
    TextArea titleTA;
    final Serializable uid = Mmowgli2UI.getGlobals().getUserID();

    titleTA = (TextArea) addEditLine("Map Title", "Game.mapTitle", g, g.getId(), "MapTitle").ta;
    titleTA.setValue(g.getMapTitle());
    titleTA.setRows(1);

    latTA = addEditLine("Map Initial Latitude", "Game.mmowgliMapLatitude");
    boolean lastRO = latTA.isReadOnly();
    latTA.setReadOnly(false);
    latTA.setValue("" + g.getMapLatitude());
    latTA.setRows(1);
    latTA.setReadOnly(lastRO);
    latTA.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void valueChange(ValueChangeEvent event) {
            HSess.init();
            try {
                String val = event.getProperty().getValue().toString();
                double lat = Double.parseDouble(val);
                Game g = Game.getTL();
                g.setMapLatitude(lat);
                Game.updateTL();
                GameEventLogger.logGameDesignChangeTL("Map latitude", val, uid);
            } catch (Exception ex) {
                new Notification("Parameter error",
                        "<html>Check for proper decimal format.</br>New value not committed.",
                        Notification.Type.WARNING_MESSAGE, true).show(Page.getCurrent());
            }
            HSess.close();
        }
    });

    lonTA = addEditLine("Map Initial Longitude", "Game.mmowgliMapLongitude");
    lastRO = lonTA.isReadOnly();
    lonTA.setReadOnly(false);
    lonTA.setValue("" + g.getMapLongitude());
    lonTA.setRows(1);
    lonTA.setReadOnly(lastRO);
    lonTA.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void valueChange(ValueChangeEvent event) {
            //System.out.println("lon valueChange");
            HSess.init();
            try {
                String val = event.getProperty().getValue().toString();
                double lon = Double.parseDouble(val);
                Game g = Game.getTL();
                g.setMapLongitude(lon);
                Game.updateTL();
                GameEventLogger.logGameDesignChangeTL("Map longitude", val, uid);
            } catch (Exception ex) {
                new Notification("Parameter error",
                        "<html>Check for proper decimal format.</br>New value not committed.",
                        Notification.Type.WARNING_MESSAGE, true).show(Page.getCurrent());
            }
            HSess.close();
        }
    });

    zoomTA = addEditLine("Map Initial Zoom", "Game.mmowgliMapZoom");
    lastRO = zoomTA.isReadOnly();
    zoomTA.setReadOnly(false);
    zoomTA.setValue("" + g.getMapZoom());
    zoomTA.setRows(1);
    zoomTA.setReadOnly(lastRO);
    zoomTA.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void valueChange(ValueChangeEvent event) {
            HSess.init();
            try {
                String val = event.getProperty().getValue().toString();
                int zoom = Integer.parseInt(val);
                Game g = Game.getTL();
                g.setMapZoom(zoom);
                Game.updateTL();
                GameEventLogger.logGameDesignChangeTL("Map zoom", val, uid);
            } catch (Exception ex) {
                new Notification("Parameter error",
                        "Check for proper integer format.</br>New value not committed.",
                        Notification.Type.WARNING_MESSAGE, true).show(Page.getCurrent());
            }
            HSess.close();
        }
    });
    Button b;
    this.addComponentLine(b = new Button("Set to generic Mmowgli Map Defaults", new MapDefaultSetter()));
    b.setEnabled(!globs.readOnlyCheck(false));
}

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

License:Open Source License

private Component renderFields(CardTypeFields fields, NativeSelect combo, String name) {
    VerticalLayout topPan = new VerticalLayout();
    topPan.setWidth("98%");
    topPan.addStyleName("m-greyborder3");
    Label lab;//from w  w w.  ja v  a  2 s. c o  m
    topPan.addComponent(lab = new Label());
    lab.setHeight("18px");

    HorizontalLayout topHL = new HorizontalLayout();
    topHL.setSpacing(true);
    ;
    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);
    topHL.addComponent(lab = new HtmlLabel("<b>" + name + "</b>"));
    lab.setSizeUndefined();

    topHL.addComponent(combo);

    Button newTypeButt;
    topHL.addComponent(newTypeButt = new NativeButton("Define new type"));
    newTypeButt.addStyleName(Runo.BUTTON_SMALL);

    newTypeButt.setReadOnly(globs.readOnlyCheck(false));
    newTypeButt.setEnabled(!newTypeButt.isReadOnly());
    if (!newTypeButt.isReadOnly())
        newTypeButt.addClickListener(new NewTypeListener(fields.typeOrdinal));

    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);

    topPan.addComponent(topHL);
    topHL.setWidth("100%");

    topPan.addComponent(fields);
    fields.setWidth("100%");
    return topPan;
}

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

License:Open Source License

private Component renderFields(CardTypeFields fields, NativeSelect combo, String name, Label editWarningLab) {
    VerticalLayout topPan = new VerticalLayout();
    topPan.setWidth("98%");
    topPan.addStyleName("m-greyborder3");
    Label lab;/*from   w  w w  .j av a2 s. co  m*/
    topPan.addComponent(lab = new Label());
    lab.setHeight("18px");

    HorizontalLayout topHL = new HorizontalLayout();
    topHL.setSpacing(true);
    ;
    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);
    topHL.addComponent(lab = new HtmlLabel("<b>" + name + "</b>"));
    lab.setSizeUndefined();

    topHL.addComponent(combo);

    Button newTypeButt;
    topHL.addComponent(newTypeButt = new NativeButton("Define new top-level type"));
    newTypeButt.addStyleName(Runo.BUTTON_SMALL);
    newTypeButt.setReadOnly(globals.readOnlyCheck(false));
    newTypeButt.setEnabled(!newTypeButt.isReadOnly());
    if (!newTypeButt.isReadOnly())
        newTypeButt.addClickListener(new NewCardClassListener(fields.cardClass));

    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);

    topPan.addComponent(topHL);
    topHL.setWidth("100%");

    addComponent(editWarningLab);

    topPan.addComponent(fields);
    fields.setWidth("100%");
    return topPan;
}

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

License:Open Source License

VideoChangerComponent(MovePhase mp, String setterMethodName, Media m, GameDesignGlobals globs) {
    this.mp = mp;
    this.currentMedia = m;
    try {//from ww  w .ja  v a2s .  c  om
        movePhaseSetter = MovePhase.class.getDeclaredMethod(setterMethodName, new Class<?>[] { Media.class });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    setSpacing(true);
    setMargin(false);
    setSizeUndefined();

    addComponent(roTF = new TextField());
    roTF.addStyleName("m-textarea-greyborder");
    //tf.setColumns(20);
    roTF.setValue(currentMedia == null ? "" : currentMedia.getUrl());
    roTF.setReadOnly(true);
    Button butt;
    addComponent(butt = new Button("change", this));
    setComponentAlignment(butt, Alignment.MIDDLE_CENTER);
    butt.addStyleName(Reindeer.BUTTON_SMALL);
    butt.setReadOnly(globs.readOnlyCheck(false));
    butt.setEnabled(!butt.isReadOnly());
}

From source file:edu.nps.moves.mmowgliMobile.ui.CardRenderer2.java

License:Open Source License

@SuppressWarnings("serial")
private Component makeChildGroupButton(final String title, CardListEntry card, CardType typ,
        final ListView2 currentMessageList) {
    final Button btn = new Button();
    btn.addStyleName("m-card-child-button");
    btn.addStyleName(CardStyler.getCardTextColorOverBaseStyle(typ));
    btn.addStyleName(CardStyler.getCardBaseStyle(typ));

    final Card parent = card.getCard();
    final Container container = new ChildCardsByTypeContainer<Card>(parent, typ);
    if (container.size() > 0) {
        btn.addClickListener(new ClickListener() {
            @Override//from  w  w w.j  a  v  a  2  s  .  c o m
            public void buttonClick(ClickEvent event) {
                NavigationManager nav = currentMessageList.getNavigationManager();
                if (nav == null)
                    nav = currentMessageList.getNavigationManager();
                String par = parent == null ? "?" : ("" + parent.getId());
                nav.navigateTo(new ListView2(new Folder(title + "s on card " + par, container, Card.class)));
            }
        });
        btn.setCaption(title + " " + container.size());
    } else {
        btn.setCaption(title);
        btn.setEnabled(false);
    }
    return btn;
}

From source file:edu.nps.moves.mmowgliMobile.ui.UserRenderer2.java

License:Open Source License

private Component makeButtons() {
    HorizontalLayout horl = new HorizontalLayout();
    horl.setWidth("100%");
    horl.setSpacing(true);/*from  w w  w.  ja  v  a2s  .co  m*/
    Label lab;
    horl.addComponent(lab = new Label(""));
    horl.setExpandRatio(lab, 0.5f);
    Button cardsButt = new Button("Cards");
    horl.addComponent(cardsButt);
    Button apButt = new Button("Action Plans");
    horl.addComponent(apButt);
    horl.addComponent(lab = new Label(""));
    horl.setExpandRatio(lab, 0.5f);
    cardsButt.addStyleName("m-author-button");
    apButt.addStyleName("m-author-button");

    cardsButt.addClickListener(cardListener);
    apButt.addClickListener(apListener);

    cardsButt.setEnabled(numCards > 0);
    apButt.setEnabled(numAps > 0);
    return horl;
}

From source file:eu.hurion.hello.vaadin.shiro.application.HelloScreen.java

License:Apache License

public HelloScreen(final HerokuShiroApplication app) {
    setSizeFull();/* www.  j  av  a 2  s . c  om*/
    final Subject currentUser = SecurityUtils.getSubject();

    final Panel welcomePanel = new Panel();
    final FormLayout content = new FormLayout();
    final Label label = new Label("Logged in as " + currentUser.getPrincipal().toString());
    logout = new Button("logout");
    logout.addClickListener(new HerokuShiroApplication.LogoutListener(app));

    content.addComponent(label);
    content.addComponent(logout);
    welcomePanel.setContent(content);
    welcomePanel.setWidth("400px");
    welcomePanel.setHeight("200px");
    addComponent(welcomePanel);
    setComponentAlignment(welcomePanel, Alignment.MIDDLE_CENTER);

    final HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    addComponent(footer);

    final Button adminButton = new Button("For admin only");
    adminButton.setEnabled(currentUser.hasRole("admin"));
    adminButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            Notification.show("you're an admin");
        }
    });
    content.addComponent(adminButton);

    final Button userButton = new Button("For users with permission 1");
    userButton.setEnabled(currentUser.isPermitted("permission_1"));
    userButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            Notification.show("you've got permission 1");
        }
    });
    content.addComponent(userButton);

}

From source file:eu.lod2.EURL.java

License:Apache License

public EURL(LOD2DemoState st) {

    // The internal state
    state = st;/*www. j  ava 2 s .c  om*/

    VerticalLayout panel = new VerticalLayout();
    Label description = new Label("Import the RDF available at a URL");
    panel.addComponent(description);

    exportGraph = new ExportSelector(state);
    exportGraph.setDebugId(this.getClass().getSimpleName() + "_exportGraph");
    panel.addComponent(exportGraph);

    uriSelector = new TextField("Enter URL to extract from: ");
    uriSelector.setDebugId(this.getClass().getSimpleName() + "_uriSelector");
    uriSelector.setDescription(
            "From this URL the RDF will be extracted and imported in the above selected graph.");
    panel.addComponent(uriSelector);

    Button importURL = new Button("Extract Links", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            doImportURL();
        }

        ;
    });
    importURL.setDebugId(this.getClass().getSimpleName() + "_importURL");
    importURL.setEnabled(true);
    importURL.setDescription("The operation is active only if the exported graph has been selected.");
    panel.addComponent(importURL);

    resultUser = new Label("");
    panel.addComponent(resultUser);

    /*
        // if an uri is given 
        if (!uriSelector.getValue().equals("")) {
            // activate button
            importURL.setEnabled(true);
        };
    */

    // The composition root MUST be set
    setCompositionRoot(panel);
}

From source file:eu.lod2.SameAsLinking.java

License:Apache License

public SameAsLinking(LOD2DemoState st) {

    // The internal state 
    state = st;//  w ww.  j  a  v  a 2s  . c  o m

    VerticalLayout panel = new VerticalLayout();
    Label description = new Label(
            "Import public links between individuals (URI's) from the current graph to external resources using "
                    + "the online service SameAs.org.");
    panel.addComponent(description);

    exportGraph = new ExportSelector(state);
    exportGraph.setDebugId(this.getClass().getSimpleName() + "_exportGraph");
    panel.addComponent(exportGraph);

    uriSelector = new ComboBox("Select URI to link: ");
    uriSelector.setDebugId(this.getClass().getSimpleName() + "_uriSelector");
    uriSelector.setDescription("The selector contains uri's only if a current graph has a value.");
    panel.addComponent(uriSelector);

    Button sameAsLinking = new Button("Extract Links", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            doSameAsLinking();
        };
    });
    sameAsLinking.setDebugId(this.getClass().getSimpleName() + "_sameAsLinking");
    sameAsLinking.setEnabled(false);
    sameAsLinking.setDescription("The operation is active only if a current graph has a value.");
    panel.addComponent(sameAsLinking);

    resultUser = new Label("");
    panel.addComponent(resultUser);

    // if the current graph is selected then
    if (state.getCurrentGraph() != null && !state.getCurrentGraph().equals("")) {
        // activate linking button
        sameAsLinking.setEnabled(true);
        // retrieve list of candidate uri's
        addCandidateURIs(uriSelector);
    }
    ;

    // The composition root MUST be set
    setCompositionRoot(panel);
}

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

License:Apache License

@Override
protected void init(VaadinRequest request) {

    getPage().setTitle(pageTitle);//from  w w  w  .  java  2s  . com

    final VerticalLayout margin = new VerticalLayout();
    setContent(margin);

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("658px");
    margin.addComponent(layout);
    margin.setComponentAlignment(layout, Alignment.TOP_CENTER);

    final Label header1 = new Label(pageTitle);
    header1.addStyleName("h1");
    header1.setSizeUndefined();
    layout.addComponent(header1);
    layout.setComponentAlignment(header1, Alignment.TOP_CENTER);

    final TabSheet tabSheet = new TabSheet();
    tabSheet.setWidth("100%");
    layout.addComponent(tabSheet);
    layout.setComponentAlignment(tabSheet, Alignment.TOP_CENTER);

    final Panel signaturePanel = new Panel();
    signaturePanel.addStyleName("signature-panel");
    signaturePanel.setWidth("100%");
    tabSheet.addTab(signaturePanel, "Demo");

    final VerticalLayout signatureLayout = new VerticalLayout();
    signatureLayout.setMargin(true);
    signatureLayout.setSpacing(true);
    signatureLayout.setSizeFull();
    signaturePanel.setContent(signatureLayout);

    final SignatureField signatureField = new SignatureField();
    signatureField.setWidth("100%");
    signatureField.setHeight("318px");
    signatureField.setPenColor(Color.ULTRAMARINE);
    signatureField.setBackgroundColor("white");
    signatureField.setConverter(new StringToDataUrlConverter());
    signatureField.setPropertyDataSource(dataUrlProperty);
    signatureField.setVelocityFilterWeight(0.7);
    signatureLayout.addComponent(signatureField);
    signatureLayout.setComponentAlignment(signatureField, Alignment.MIDDLE_CENTER);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");
    signatureLayout.addComponent(buttonLayout);

    final Button clearButton = new Button("Clear", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            signatureField.clear();
        }
    });
    buttonLayout.addComponent(clearButton);
    buttonLayout.setComponentAlignment(clearButton, Alignment.MIDDLE_LEFT);

    final Label message = new Label("Sign above");
    message.setSizeUndefined();
    buttonLayout.addComponent(message);
    buttonLayout.setComponentAlignment(message, Alignment.MIDDLE_CENTER);

    final ButtonLink saveButtonLink = new ButtonLink("Save", null);
    saveButtonLink.setTargetName("_blank");
    buttonLayout.addComponent(saveButtonLink);
    buttonLayout.setComponentAlignment(saveButtonLink, Alignment.MIDDLE_RIGHT);

    final Panel optionsPanel = new Panel();
    optionsPanel.setSizeFull();
    tabSheet.addTab(optionsPanel, "Options");

    final FormLayout optionsLayout = new FormLayout();
    optionsLayout.setMargin(true);
    optionsLayout.setSpacing(true);
    optionsPanel.setContent(optionsLayout);

    final ComboBox mimeTypeComboBox = new ComboBox(null, mimeTypeContainer);
    optionsLayout.addComponent(mimeTypeComboBox);
    mimeTypeComboBox.setItemCaptionPropertyId("mimeType");
    mimeTypeComboBox.setNullSelectionAllowed(false);
    mimeTypeComboBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            MimeType mimeType = (MimeType) event.getProperty().getValue();
            signatureField.setMimeType(mimeType);
        }
    });
    mimeTypeComboBox.setValue(MimeType.PNG);
    mimeTypeComboBox.setCaption("Result MIME-Type");

    final CheckBox immediateCheckBox = new CheckBox("immediate", false);
    optionsLayout.addComponent(immediateCheckBox);
    immediateCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean immediate = (Boolean) event.getProperty().getValue();
            signatureField.setImmediate(immediate);
        }
    });

    final CheckBox readOnlyCheckBox = new CheckBox("readOnly", false);
    optionsLayout.addComponent(readOnlyCheckBox);
    readOnlyCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean readOnly = (Boolean) event.getProperty().getValue();
            signatureField.setReadOnly(readOnly);
            mimeTypeComboBox.setReadOnly(readOnly);
            clearButton.setEnabled(!readOnly);
        }
    });

    final CheckBox requiredCheckBox = new CheckBox("required (causes bug that clears field)", false);
    optionsLayout.addComponent(requiredCheckBox);
    requiredCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean required = (Boolean) event.getProperty().getValue();
            signatureField.setRequired(required);
        }
    });

    final CheckBox clearButtonEnabledButton = new CheckBox("clearButtonEnabled", false);
    optionsLayout.addComponent(clearButtonEnabledButton);
    clearButtonEnabledButton.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean clearButtonEnabled = (Boolean) event.getProperty().getValue();
            signatureField.setClearButtonEnabled(clearButtonEnabled);
        }
    });

    final Panel resultPanel = new Panel("Results:");
    resultPanel.setWidth("100%");
    layout.addComponent(resultPanel);

    final VerticalLayout resultLayout = new VerticalLayout();
    resultLayout.setMargin(true);
    resultPanel.setContent(resultLayout);

    final Image stringPreviewImage = new Image("String preview image:");
    stringPreviewImage.setWidth("500px");
    resultLayout.addComponent(stringPreviewImage);

    final Image dataUrlPreviewImage = new Image("DataURL preview image:");
    dataUrlPreviewImage.setWidth("500px");
    resultLayout.addComponent(dataUrlPreviewImage);

    final TextArea textArea = new TextArea("DataURL:");
    textArea.setWidth("100%");
    textArea.setHeight("300px");
    resultLayout.addComponent(textArea);

    final Label emptyLabel = new Label();
    emptyLabel.setCaption("Is Empty:");
    emptyLabel.setValue(String.valueOf(signatureField.isEmpty()));
    resultLayout.addComponent(emptyLabel);

    signatureField.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            String signature = (String) event.getProperty().getValue();
            stringPreviewImage.setSource(signature != null ? new ExternalResource(signature) : null);
            textArea.setValue(signature);
            emptyLabel.setValue(String.valueOf(signatureField.isEmpty()));
        }
    });
    dataUrlProperty.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            try {
                final DataUrl signature = (DataUrl) event.getProperty().getValue();
                dataUrlPreviewImage.setSource(
                        signature != null ? new ExternalResource(serializer.serialize(signature)) : null);
                StreamResource streamResource = null;
                if (signature != null) {
                    StreamSource streamSource = new StreamSource() {

                        @Override
                        public InputStream getStream() {
                            return new ByteArrayInputStream(signature.getData());
                        }
                    };
                    MimeType mimeType = MimeType.valueOfMimeType(signature.getMimeType());
                    String extension = null;

                    switch (mimeType) {
                    case JPEG:
                        extension = "jpg";
                        break;
                    case PNG:
                        extension = "png";
                        break;
                    }

                    streamResource = new StreamResource(streamSource, "signature." + extension);
                    streamResource.setMIMEType(signature.getMimeType());
                    streamResource.setCacheTime(0);
                }
                saveButtonLink.setResource(streamResource);
            } catch (MalformedURLException e) {
                logger.error(e.getMessage(), e);
            }
        }
    });
}