Example usage for com.vaadin.ui Window setClosable

List of usage examples for com.vaadin.ui Window setClosable

Introduction

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

Prototype

public void setClosable(boolean closable) 

Source Link

Document

Sets the closable status for the window.

Usage

From source file:org.opencms.ui.login.CmsLoginUI.java

License:Open Source License

/**
 * Shows the password reset dialog.<p>
 *///from ww  w .  ja  v a2  s  . co m
public void showPasswordResetDialog() {

    String caption = CmsVaadinUtils.getMessageText(Messages.GUI_PWCHANGE_FORGOT_PASSWORD_0);
    A_CmsUI r = A_CmsUI.get();
    r.setContent(new Label());
    Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
    CmsBasicDialog dialog = new CmsBasicDialog();
    VerticalLayout result = new VerticalLayout();
    dialog.setContent(result);
    window.setContent(dialog);
    window.setCaption(caption);
    window.setClosable(true);
    final CmsForgotPasswordDialog forgotPassword = new CmsForgotPasswordDialog();
    window.addCloseListener(new CloseListener() {

        /** Serial version id. */
        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {

            forgotPassword.cancel();
        }

    });
    for (Button button : forgotPassword.getButtons()) {
        dialog.addButton(button);
    }

    r.addWindow(window);
    window.center();
    VerticalLayout vl = result;
    vl.addComponent(forgotPassword);
}

From source file:org.opennms.features.topology.app.internal.TopologyUI.java

License:Open Source License

@Override
public void menuBarUpdated(CommandManager commandManager) {
    if (m_menuBar != null) {
        m_rootLayout.removeComponent(m_menuBar);
    }/*  w ww  .j  ava 2  s.  co  m*/

    if (m_contextMenu != null) {
        m_contextMenu.detach();
    }

    m_menuBar = commandManager.getMenuBar(m_graphContainer, this);
    m_menuBar.setWidth(100, Unit.PERCENTAGE);
    // Set expand ratio so that extra space is not allocated to this vertical component
    if (m_showHeader) {
        m_rootLayout.addComponent(m_menuBar, 1);
    } else {
        m_rootLayout.addComponent(m_menuBar, 0);
    }

    m_contextMenu = commandManager
            .getContextMenu(new DefaultOperationContext(this, m_graphContainer, DisplayLocation.CONTEXTMENU));
    m_contextMenu.setAsContextMenuOf(this);

    // Add Menu Item to share the View with others
    m_menuBar.addItem("Share", FontAwesome.SHARE, new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            // create the share link
            String fragment = getPage().getLocation().getFragment();
            String url = getPage().getLocation().toString().replace("#" + getPage().getLocation().getFragment(),
                    "");
            String shareLink = String.format("%s?%s=%s", url,
                    TopologyUIRequestHandler.PARAMETER_HISTORY_FRAGMENT, fragment);

            // Create the Window
            Window shareWindow = new Window();
            shareWindow.setCaption("Share Link");
            shareWindow.setModal(true);
            shareWindow.setClosable(true);
            shareWindow.setResizable(false);
            shareWindow.setWidth(400, Unit.PIXELS);

            TextArea shareLinkField = new TextArea();
            shareLinkField.setValue(shareLink);
            shareLinkField.setReadOnly(true);
            shareLinkField.setRows(3);
            shareLinkField.setWidth(100, Unit.PERCENTAGE);

            // Close Button
            Button close = new Button("Close");
            close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
            close.addClickListener(event -> shareWindow.close());

            // Layout for Buttons
            HorizontalLayout buttonLayout = new HorizontalLayout();
            buttonLayout.setMargin(true);
            buttonLayout.setSpacing(true);
            buttonLayout.setWidth("100%");
            buttonLayout.addComponent(close);
            buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);

            // Content Layout
            VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.setMargin(true);
            verticalLayout.setSpacing(true);
            verticalLayout.addComponent(
                    new Label("Please use the following link to share the current view with others."));
            verticalLayout.addComponent(shareLinkField);
            verticalLayout.addComponent(buttonLayout);

            shareWindow.setContent(verticalLayout);

            getUI().addWindow(shareWindow);
        }
    });

    updateMenuItems();
}

From source file:org.opennms.features.topology.app.internal.ui.ToolbarPanel.java

License:Open Source License

public ToolbarPanel(final ToolbarPanelController controller) {
    addStyleName(Styles.TOOLBAR);/*from   w  w  w .j a v a 2s. c o  m*/
    this.layoutManager = controller.getLayoutManager();

    final Property<Double> scale = controller.getScaleProperty();
    final Boolean[] eyeClosed = new Boolean[] { false };
    final Button showFocusVerticesBtn = new Button();
    showFocusVerticesBtn.setIcon(FontAwesome.EYE);
    showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes");
    showFocusVerticesBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (eyeClosed[0]) {
                showFocusVerticesBtn.setIcon(FontAwesome.EYE);
            } else {
                showFocusVerticesBtn.setIcon(FontAwesome.EYE_SLASH);
            }
            eyeClosed[0] = !eyeClosed[0]; // toggle
            controller.toggleHighlightFocus();
        }
    });

    final Button magnifyBtn = new Button();
    magnifyBtn.setIcon(FontAwesome.PLUS);
    magnifyBtn.setDescription("Magnify");
    magnifyBtn.addClickListener(
            (Button.ClickListener) event -> scale.setValue(Math.min(1, scale.getValue() + 0.25)));

    final Button demagnifyBtn = new Button();
    demagnifyBtn.setIcon(FontAwesome.MINUS);
    demagnifyBtn.setDescription("Demagnify");
    demagnifyBtn.addClickListener(
            (Button.ClickListener) event -> scale.setValue(Math.max(0, scale.getValue() - 0.25)));

    m_szlOutBtn = new Button();
    m_szlOutBtn.setId("szlOutBtn");
    m_szlOutBtn.setIcon(FontAwesome.ANGLE_DOWN);
    m_szlOutBtn.setDescription("Decrease Semantic Zoom Level");
    m_szlOutBtn.setEnabled(controller.getSemanticZoomLevel() > 0);
    m_szlOutBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            int szl = controller.getSemanticZoomLevel();
            if (szl > 0) {
                setSemanticZoomLevel(controller, szl - 1);
                controller.saveHistory();
            }
        }
    });

    final Button szlInBtn = new Button();
    szlInBtn.setId("szlInBtn");
    szlInBtn.setIcon(FontAwesome.ANGLE_UP);
    szlInBtn.setDescription("Increase Semantic Zoom Level");
    szlInBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setSemanticZoomLevel(controller, controller.getSemanticZoomLevel() + 1);
            controller.saveHistory();
        }
    });

    m_zoomLevelLabel.setId("szlInputLabel");

    m_panBtn = new Button();
    m_panBtn.setIcon(FontAwesome.ARROWS);
    m_panBtn.setDescription("Pan Tool");
    m_panBtn.addStyleName(Styles.SELECTED);

    m_selectBtn = new Button();
    m_selectBtn.setIcon(IonicIcons.ANDROID_EXPAND);
    m_selectBtn.setDescription("Selection Tool");
    m_selectBtn.setStyleName("toolbar-button");
    m_selectBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            m_selectBtn.addStyleName(Styles.SELECTED);
            m_panBtn.removeStyleName(Styles.SELECTED);
            controller.setActiveTool(ActiveTool.select);
        }
    });

    m_panBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            m_panBtn.addStyleName(Styles.SELECTED);
            m_selectBtn.removeStyleName(Styles.SELECTED);
            controller.setActiveTool(ActiveTool.pan);
        }
    });

    Button showAllMapBtn = new Button();
    showAllMapBtn.setId("showEntireMapBtn");
    showAllMapBtn.setIcon(FontAwesome.GLOBE);
    showAllMapBtn.setDescription("Show Entire Map");
    showAllMapBtn.addClickListener((Button.ClickListener) event -> controller.showAllMap());

    Button centerSelectionBtn = new Button();
    centerSelectionBtn.setIcon(FontAwesome.LOCATION_ARROW);
    centerSelectionBtn.setDescription("Center On Selection");
    centerSelectionBtn.addClickListener((Button.ClickListener) event -> controller.centerMapOnSelection());

    Button shareButton = new Button("", FontAwesome.SHARE_SQUARE_O);
    shareButton.setDescription("Share");
    shareButton.addClickListener((x) -> {
        // Create the share link
        String fragment = getUI().getPage().getLocation().getFragment();
        String url = getUI().getPage().getLocation().toString().replace("#" + fragment, "");
        String shareLink = String.format("%s?%s=%s", url, PARAMETER_HISTORY_FRAGMENT, fragment);

        // Create the Window
        Window shareWindow = new Window();
        shareWindow.setCaption("Share Link");
        shareWindow.setModal(true);
        shareWindow.setClosable(true);
        shareWindow.setResizable(false);
        shareWindow.setWidth(400, Sizeable.Unit.PIXELS);

        TextArea shareLinkField = new TextArea();
        shareLinkField.setValue(shareLink);
        shareLinkField.setReadOnly(true);
        shareLinkField.setRows(3);
        shareLinkField.setWidth(100, Sizeable.Unit.PERCENTAGE);

        // Close Button
        Button close = new Button("Close");
        close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
        close.addClickListener(event -> shareWindow.close());

        // Layout for Buttons
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setMargin(true);
        buttonLayout.setSpacing(true);
        buttonLayout.setWidth("100%");
        buttonLayout.addComponent(close);
        buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);

        // Content Layout
        VerticalLayout verticalLayout = new VerticalLayout();
        verticalLayout.setMargin(true);
        verticalLayout.setSpacing(true);
        verticalLayout.addComponent(
                new Label("Please use the following link to share the current view with others."));
        verticalLayout.addComponent(shareLinkField);
        verticalLayout.addComponent(buttonLayout);

        shareWindow.setContent(verticalLayout);

        getUI().addWindow(shareWindow);
    });

    // Refresh Button
    Button refreshButton = new Button();
    refreshButton.setId("refreshNow");
    refreshButton.setIcon(FontAwesome.REFRESH);
    refreshButton.setDescription("Refresh Now");
    refreshButton.addClickListener((event) -> controller.refreshUI());

    // Layer Layout
    layerLayout = new VerticalLayout();
    layerLayout.setId("layerComponent");
    layerLayout.setSpacing(true);
    layerLayout.setMargin(true);

    // Layer Button
    layerButton = new Button();
    layerButton.setId("layerToggleButton");
    layerButton.setIcon(FontAwesome.BARS);
    layerButton.setDescription("Layers");
    layerButton.addClickListener((event) -> {
        boolean isCollapsed = layerButton.getStyleName().contains(Styles.EXPANDED);
        setLayerLayoutVisible(!isCollapsed);
    });

    // Save button
    layerSaveButton = new Button();
    layerSaveButton.setId("saveLayerButton");
    layerSaveButton.setIcon(FontAwesome.FLOPPY_O);
    layerSaveButton.addClickListener((event) -> controller.saveLayout());

    // Actual Layout for the Toolbar
    CssLayout contentLayout = new CssLayout();
    contentLayout.addStyleName("toolbar-component");
    contentLayout.addComponent(createGroup(szlInBtn, m_zoomLevelLabel, m_szlOutBtn));
    contentLayout.addComponent(
            createGroup(refreshButton, centerSelectionBtn, showAllMapBtn, layerButton, showFocusVerticesBtn));
    contentLayout.addComponent(createGroup(m_panBtn, m_selectBtn));
    contentLayout.addComponent(createGroup(magnifyBtn, demagnifyBtn));
    contentLayout.addComponent(createGroup(shareButton));
    contentLayout.addComponent(createGroup(layerSaveButton));

    // Toolbar
    addComponent(contentLayout);
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.HelpClickListener.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent clickEvent) {
    final Window window = new Window("Help");

    window.setModal(true);/*from   www  .jav a  2s.c  o  m*/
    window.setClosable(false);
    window.setResizable(false);

    window.setWidth("55%");
    window.setHeight("80%");

    m_component.getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        {
            setMargin(true);
            setSpacing(true);
            setSizeFull();

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setSizeFull();
            horizontalLayout.setSpacing(true);

            Tree tree = new Tree();
            tree.setNullSelectionAllowed(false);
            tree.setMultiSelect(false);
            tree.setImmediate(true);

            tree.addItem("Overview");
            tree.setChildrenAllowed("Overview", false);

            tree.addItem("Installed Dashlets");
            tree.setChildrenAllowed("Installed Dashlets", true);

            final List<DashletFactory> factories = m_dashletSelector.getDashletFactoryList();

            for (DashletFactory dashletFactory : factories) {
                tree.addItem(dashletFactory.getName());
                tree.setParent(dashletFactory.getName(), "Installed Dashlets");
                tree.setChildrenAllowed(dashletFactory.getName(), false);
            }
            horizontalLayout.addComponent(tree);

            for (final Object id : tree.rootItemIds()) {
                tree.expandItemsRecursively(id);
            }

            final Panel panel = new Panel();
            panel.setSizeFull();

            horizontalLayout.addComponent(panel);
            horizontalLayout.setExpandRatio(panel, 1.0f);

            addComponent(horizontalLayout);
            setExpandRatio(horizontalLayout, 1.0f);

            tree.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                    String itemId = String.valueOf(valueChangeEvent.getProperty().getValue());

                    if ("Installed Dashlets".equals(itemId)) {
                        return;
                    }

                    if ("Overview".equals(itemId)) {
                        VerticalLayout verticalLayout = new VerticalLayout();
                        verticalLayout.setSpacing(true);
                        verticalLayout.setMargin(true);

                        verticalLayout.addComponent(new Label(getOverviewHelpHTML(), ContentMode.HTML));

                        panel.setContent(verticalLayout);
                    } else {
                        DashletFactory dashletFactory = m_dashletSelector.getDashletFactoryForName(itemId);

                        if (dashletFactory != null) {
                            if (dashletFactory.providesHelpComponent()) {
                                VerticalLayout verticalLayout = new VerticalLayout();
                                verticalLayout.setSpacing(true);
                                verticalLayout.setMargin(true);

                                Label helpTitle = new Label(
                                        "Help for Dashlet '" + dashletFactory.getName() + "'");
                                helpTitle.addStyleName("help-title");

                                verticalLayout.addComponent(helpTitle);
                                verticalLayout.addComponent(dashletFactory.getHelpComponent());

                                panel.setContent(verticalLayout);
                            }
                        }
                    }
                }
            });

            tree.select("Overview");

            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button closeButton = new Button("Close");

                    addComponent(closeButton);
                    setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT);
                    closeButton.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent clickEvent) {
                            window.close();
                        }
                    });
                }
            });
        }
    });
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.PreviewClickListener.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent clickEvent) {
    final Window window = new Window("Preview");

    window.setModal(true);// w ww  . j a v a  2  s. co m
    window.setClosable(false);
    window.setResizable(false);

    window.setWidth("80%");
    window.setHeight("90%");

    m_component.getUI().addWindow(window);

    final WallboardBody wallboardBody = new WallboardBody();

    window.setContent(new VerticalLayout() {
        {
            setMargin(true);
            setSpacing(true);
            setSizeFull();

            addComponent(wallboardBody);
            setExpandRatio(wallboardBody, 1.0f);
            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button closeButton = new Button("Close");

                    addComponent(closeButton);
                    setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT);
                    closeButton.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent clickEvent) {
                            window.close();
                        }
                    });
                }
            });
        }
    });
    wallboardBody.setDashletSpecs(m_wallboard.getDashletSpecs());
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.WallboardConfigView.java

License:Open Source License

/**
 * This method is used to add a new {@link TabSheet.Tab} component. It creates a new window querying the user for the name of the new {@link Wallboard}.
 *///from w  w  w  . j  a  va 2 s  .c o m
protected void addNewTabComponent() {
    final Window window = new Window("New Ops Board");

    window.setModal(true);
    window.setClosable(false);
    window.setResizable(false);
    window.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent e) {
            m_dashboardOverview.refreshTable();
        }
    });
    getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        TextField name = new TextField("Ops Board Name");

        {
            addComponent(new FormLayout() {
                {
                    setSizeUndefined();
                    setMargin(true);

                    String newName = "Untitled";
                    int i = 1;
                    if (WallboardProvider.getInstance().containsWallboard(newName)) {
                        do {
                            i++;
                            newName = "Untitled #" + i;
                        } while (WallboardProvider.getInstance().containsWallboard(newName));
                    }
                    name.setValue(newName);
                    addComponent(name);
                    name.focus();
                    name.selectAll();

                    name.addValidator(new AbstractStringValidator("Title must be unique") {
                        @Override
                        protected boolean isValidValue(String s) {
                            return (!WallboardProvider.getInstance().containsWallboard(s) && !"".equals(s));
                        }
                    });
                }
            });

            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button cancel = new Button("Cancel");
                    cancel.setDescription("Cancel editing");
                    cancel.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            // NMS-7560: Toggle the tab in order to allow us to click it again
                            m_tabSheet.togglePlusTab();
                            window.close();
                        }
                    });

                    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
                    addComponent(cancel);
                    setExpandRatio(cancel, 1);
                    setComponentAlignment(cancel, Alignment.TOP_RIGHT);

                    Button ok = new Button("Save");
                    ok.setDescription("Save configuration");
                    ok.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            if (name.isValid()) {
                                Wallboard wallboard = new Wallboard();
                                wallboard.setTitle(name.getValue());

                                WallboardProvider.getInstance().addWallboard(wallboard);
                                WallboardProvider.getInstance().save();

                                WallboardEditor wallboardEditor = new WallboardEditor(m_dashletSelector,
                                        wallboard);
                                TabSheet.Tab tab = m_tabSheet.addTab(wallboardEditor, wallboard.getTitle());

                                wallboardEditor.setTab(tab);

                                m_wallboardEditorMap.put(wallboard, tab);

                                tab.setClosable(true);

                                m_tabSheet.setSelectedTab(tab);

                                window.close();
                            }
                        }
                    });

                    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

                    addComponent(ok);
                }
            });
        }
    });
}

From source file:org.opennms.features.vaadin.surveillanceviews.ui.PreviewClickListener.java

License:Open Source License

/**
 * {@inheritDoc}/*  w  w w.j a  v  a2  s .com*/
 */
@Override
public void buttonClick(Button.ClickEvent clickEvent) {
    final Window window = new Window("Preview");

    window.setModal(true);
    window.setClosable(true);
    window.setResizable(false);

    window.setWidth("80%");
    window.setHeight("90%");

    m_component.getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        {
            addComponent(new VerticalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setSizeFull();

                    addComponent(new SurveillanceView(m_view, m_surveillanceViewService, false, false));
                }
            });
        }
    });
}

From source file:org.processbase.ui.servlet.MainWindow.java

License:Open Source License

void openLogoutWindow() {
    Window logout = new Window(((PbApplication) getApplication()).getPbMessages().getString("btnLogout"));
    logout.setModal(true);//from   w ww  .j av  a  2 s  .  com
    //        logout.setStyleName(Reindeer.WINDOW_BLACK);
    logout.setWidth("260px");
    logout.setResizable(false);
    logout.setClosable(false);
    logout.setDraggable(false);
    logout.setCloseShortcut(KeyCode.ESCAPE, null);

    Label helpText = new Label("Are you sure you want to log out?", Label.CONTENT_XHTML);
    logout.addComponent(helpText);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button yes = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnLogout"),
            new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    WebApplicationContext applicationContext = (WebApplicationContext) getApplication()
                            .getContext();
                    getApplication().close();
                    applicationContext.getHttpSession().invalidate();
                }
            });
    yes.setStyleName(Reindeer.BUTTON_DEFAULT);
    yes.focus();
    buttons.addComponent(yes);
    Button no = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnCancel"),
            new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    removeWindow(event.getButton().getWindow());
                }
            });
    buttons.addComponent(no);

    logout.addComponent(buttons);
    ((VerticalLayout) logout.getContent()).setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    ((VerticalLayout) logout.getContent()).setSpacing(true);

    addWindow(logout);
}

From source file:org.tltv.gantt.demo.DemoUI.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("Step Editor");
    win.setResizable(false);/*w w w.j  av  a  2s.  co  m*/
    win.center();

    final Collection<Component> hidden = new ArrayList<Component>();

    BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step);

    final FieldGroup group = new FieldGroup(item);
    group.setBuffered(true);

    TextField captionField = new TextField("Caption");
    captionField.setNullRepresentation("");
    group.bind(captionField, "caption");

    TextField descriptionField = new TextField("Description");
    descriptionField.setNullRepresentation("");
    group.bind(descriptionField, "description");
    descriptionField.setVisible(false);
    hidden.add(descriptionField);

    NativeSelect captionMode = new NativeSelect("Caption Mode");
    captionMode.addItem(Step.CaptionMode.TEXT);
    captionMode.addItem(Step.CaptionMode.HTML);
    group.bind(captionMode, "captionMode");
    captionMode.setVisible(false);
    hidden.add(captionMode);

    CheckBox showProgress = new CheckBox("Show progress");
    group.bind(showProgress, "showProgress");
    showProgress.setVisible(false);
    hidden.add(showProgress);

    Slider progress = new Slider("Progress");
    progress.setWidth(100, Unit.PERCENTAGE);
    group.bind(progress, "progress");
    progress.setVisible(false);
    hidden.add(progress);

    NativeSelect predecessorSelect = new NativeSelect("Predecessor Step");
    predecessorSelect.setWidth(100, Unit.PERCENTAGE);
    fillPredecessorCanditatesToSelect(step, predecessorSelect);
    predecessorSelect.setEnabled(step instanceof Step);
    if (step instanceof Step) {
        group.bind(predecessorSelect, "predecessor");
    }
    predecessorSelect.setVisible(false);
    hidden.add(predecessorSelect);

    final NativeSelect parentStepSelect = new NativeSelect("Parent Step");
    parentStepSelect.setWidth(100, Unit.PERCENTAGE);
    parentStepSelect.setEnabled(false);
    fillParentStepCanditatesToSelect(step, parentStepSelect);
    parentStepSelect.setVisible(false);
    hidden.add(parentStepSelect);

    HorizontalLayout colorLayout = new HorizontalLayout();
    colorLayout.setWidth(100, Unit.PERCENTAGE);
    colorLayout.setVisible(false);
    hidden.add(colorLayout);

    final TextField bgField = new TextField("Background color");
    bgField.setNullRepresentation("");
    group.bind(bgField, "backgroundColor");
    bgField.setEnabled(false);

    final ColorPicker bgColorPicker = new ColorPicker();
    bgColorPicker.setPosition(300, 100);
    bgColorPicker.setColor(new CssColorToColorPickerConverter().convertToModel(step.getBackgroundColor()));
    bgColorPicker.addColorChangeListener(new ColorChangeListener() {
        @Override
        public void colorChanged(ColorChangeEvent event) {
            bgField.setValue(event.getColor().getCSS());
        }
    });

    colorLayout.addComponent(bgField);
    colorLayout.addComponent(bgColorPicker);
    colorLayout.setExpandRatio(bgField, 1);
    colorLayout.setComponentAlignment(bgColorPicker, Alignment.BOTTOM_LEFT);

    DateField startDate = new DateField("Start date");
    startDate.setLocale(gantt.getLocale());
    startDate.setTimeZone(gantt.getTimeZone());
    startDate.setResolution(Resolution.SECOND);
    startDate.setConverter(new DateToLongConverter());
    group.bind(startDate, "startDate");

    DateField endDate = new DateField("End date");
    endDate.setLocale(gantt.getLocale());
    endDate.setTimeZone(gantt.getTimeZone());
    endDate.setResolution(Resolution.SECOND);
    endDate.setConverter(new DateToLongConverter());
    group.bind(endDate, "endDate");

    CheckBox showMore = new CheckBox("Show all settings");
    showMore.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            for (Component c : hidden) {
                c.setVisible((Boolean) event.getProperty().getValue());
            }
            win.center();
        }
    });

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    win.setContent(content);

    content.addComponent(captionField);
    content.addComponent(captionMode);
    content.addComponent(descriptionField);
    content.addComponent(showProgress);
    content.addComponent(progress);
    content.addComponent(predecessorSelect);
    content.addComponent(parentStepSelect);
    content.addComponent(colorLayout);
    content.addComponent(startDate);
    content.addComponent(endDate);
    content.addComponent(showMore);

    HorizontalLayout buttons = new HorizontalLayout();
    content.addComponent(buttons);

    Button ok = new Button("Ok", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            commit(win, group, parentStepSelect);
        }

    });
    Button cancel = new Button("Cancel", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            cancel(win, group);
        }
    });
    Button delete = new Button("Delete", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            delete(win, group);
        }

    });
    buttons.addComponent(ok);
    buttons.addComponent(cancel);
    buttons.addComponent(delete);
    win.setClosable(true);

    getUI().addWindow(win);
}

From source file:ro.zg.netcell.vaadin.action.user.LoginHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);/* www.jav a 2 s.  c om*/
    OpenGroupsApplication app = actionContext.getApp();
    if (app.getAppConfigManager().isInstancePrivate()) {
        w.setClosable(false);
    }

    OpenGroupsMainWindow mainWindow = actionContext.getWindow();

    UserAction ua = actionContext.getUserAction();
    w.setWidth("600px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    ComponentContainer loginView = getLoginView(actionContext);

    w.setContent(loginView);

}