Example usage for com.vaadin.ui Component setEnabled

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

Introduction

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

Prototype

public void setEnabled(boolean enabled);

Source Link

Document

Enables or disables the component.

Usage

From source file:org.hip.vif.forum.groups.ui.ContributionsListView.java

License:Open Source License

private void disableOtherButtons(final Button inButton) {
    final Iterator<Component> lIterator = buttons.iterator();
    while (lIterator.hasNext()) {
        final Component lComponent = lIterator.next();
        if (lComponent instanceof Button) {
            if (!inButton.equals(lComponent)) {
                lComponent.setEnabled(false);
            }/*from   w  w w  .  java2 s.  c  om*/
        }
    }
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditor.java

License:Open Source License

/** Adds Editor specific UI components to the toolbar.
 * @param context The context that provides access to the toolbar.
 *//* www. ja  v  a 2  s.c o  m*/
private void fillToolBar(final I_CmsAppUIContext context) {

    context.setAppTitle(m_messages.key(Messages.GUI_APP_TITLE_0));

    // create components
    Component publishBtn = createPublishButton();
    m_saveBtn = createSaveButton();
    m_saveExitBtn = createSaveExitButton();
    Component closeBtn = createCloseButton();

    context.enableDefaultToolbarButtons(false);
    context.addToolbarButtonRight(closeBtn);
    context.addToolbarButton(publishBtn);
    context.addToolbarButton(m_saveExitBtn);
    context.addToolbarButton(m_saveBtn);

    Component addDescriptorBtn = createAddDescriptorButton();
    if (m_model.hasDescriptor() || m_model.getBundleType().equals(BundleType.DESCRIPTOR)) {
        addDescriptorBtn.setEnabled(false);
    }
    context.addToolbarButton(addDescriptorBtn);
    if (m_model.getBundleType().equals(BundleType.XML)) {
        Component convertToPropertyBundleBtn = createConvertToPropertyBundleButton();
        context.addToolbarButton(convertToPropertyBundleBtn);
    }
}

From source file:org.vaadin.alump.fancylayouts.demo.ImageDemo.java

License:Apache License

public ImageDemo() {
    setMargin(true);//w w w .j  a v a 2 s  .  c om
    setSpacing(true);
    setWidth("100%");

    Label desc = new Label(
            "FancyImage can be used when you want to present multiple images in one place. This component allows you to select which image to show when or just enabled the automatic slide show mode.");
    addComponent(desc);

    final FancyImage image = new FancyImage();
    image.setWidth("500px");
    image.setHeight("281px");

    // Setting images used
    final List<Resource> resources = getImageResources();
    for (Resource resource : resources) {
        image.addResource(resource);
    }

    // Setting slideshow timeout to 3 seconds (3000 millisecs)
    image.setSlideShowTimeout(3000);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    addComponent(buttonLayout);
    addComponent(image);
    setComponentAlignment(image, Alignment.TOP_CENTER);

    for (int i = 0; i < resources.size(); ++i) {
        final Button button = new Button("Pic " + (i + 1));
        buttonLayout.addComponent(button);
        final Resource res = resources.get(i);
        button.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                image.showResource(res);

            }
        });
        disableWhenAutoPlay.add(button);
    }

    CheckBox auto = new CheckBox("Slide show");
    auto.setImmediate(true);
    buttonLayout.addComponent(auto);

    CheckBox fade = new CheckBox("Fade");
    fade.setDescription("Fade image when changing");
    fade.setImmediate(true);
    fade.setValue(image.isFadeTransition());
    buttonLayout.addComponent(fade);

    CheckBox rotate = new CheckBox("Rotate");
    rotate.setDescription("Rotate image when changing");
    rotate.setImmediate(true);
    rotate.setValue(image.isRotateTransition());
    buttonLayout.addComponent(rotate);

    horizontal = new CheckBox("Horizontal");
    horizontal.setDescription("Should rotate happen horizontally or vertically.");
    horizontal.setValue(true);
    buttonLayout.addComponent(horizontal);

    TextField timeout = new TextField();
    timeout.setCaption("Slide show millisecs");
    timeout.setValue(String.valueOf(image.getSlideShowTimeout()));
    timeout.setDescription("How many millisec the slideshow shows one image");
    buttonLayout.addComponent(timeout);
    timeout.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            try {
                int value = Integer.parseInt(event.getText());
                // Change slide show value
                image.setSlideShowTimeout(value);
            } catch (NumberFormatException e) {
            }
        }

    });

    auto.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            // Enable/disable slideshow mode
            image.setSlideShowEnabled(value);
            for (Component component : disableWhenAutoPlay) {
                component.setEnabled(!value);
            }
        }
    });

    fade.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            image.setFadeTransition(value.booleanValue());
        }
    });

    rotate.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            image.setRotateTransition(value.booleanValue(), horizontal.getValue());
        }
    });

    horizontal.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (image.isRotateTransition()) {
                image.setRotateTransition(true, (Boolean) event.getProperty().getValue());
            }
        }
    });
}

From source file:org.vaadin.tori.view.listing.thread.ThreadMoveComponent.java

License:Apache License

public ThreadMoveComponent(final long threadId, final Long currentCategoryId,
        final List<Category> allCategories, final ThreadMoveComponentListener listener) {
    addStyleName("threadmove");
    setClosable(false);/*from   w  ww.  j av  a 2s  .c  o m*/
    setResizable(false);
    setModal(true);

    setContent(layout);
    layout.setSizeFull();
    layout.setMargin(true);

    setCaption("Move Thread to Category...");
    setWidth("300px");
    setHeight("300px");

    categoriesTree = createCategories(allCategories, threadId, currentCategoryId);
    final Panel panel = new Panel(categoriesTree);
    panel.setStyleName(Reindeer.PANEL_LIGHT);
    panel.setSizeFull();
    layout.addComponent(panel);
    layout.setExpandRatio(panel, 1.0f);

    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSpacing(true);
    layout.addComponent(horizontalLayout);

    final Component moveButton = new Button("Move Thread", new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            final Long newCategoryId = (Long) categoriesTree.getValue();
            listener.commit(threadId, newCategoryId);
            close();
        }
    });
    moveButton.setEnabled(false);
    horizontalLayout.addComponent(moveButton);
    categoriesTree.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(final ValueChangeEvent event) {
            moveButton.setEnabled(event.getProperty().getValue() == null
                    || !event.getProperty().getValue().equals(currentCategoryId));
        }
    });

    horizontalLayout.addComponent(ComponentUtil.getSecondaryButton("Cancel", new NativeButton.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            close();
        }
    }));
}