Example usage for com.vaadin.ui Window setContent

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

Introduction

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

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:com.oodrive.nuage.webui.component.window.VvrAttributesWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override/*from w  w  w  .j a  va  2s  .c om*/
public final Window init(final AbstractItemModel model) {

    // Cast model in vvrModel
    final VvrModel vvrModel = (VvrModel) model;
    // Add new window
    final Window vvrAttributesWindow = new Window("VVR Attributes");
    vvrAttributesWindow.center();
    vvrAttributesWindow.setWidth("400px");
    vvrAttributesWindow.setResizable(false);

    final VerticalLayout layout = new VerticalLayout();
    vvrAttributesWindow.setContent(layout);
    layout.setMargin(true);

    final FormLayout vvrAttributesLayout = new FormLayout();
    layout.addComponent(vvrAttributesLayout);
    vvrAttributesLayout.setMargin(true);

    // Enter NAME
    String value = vvrModel.getVvrName();
    if (value == null) {
        value = "";
    }
    final TextField name = new TextField("Name", value);
    name.setSizeFull();
    vvrAttributesLayout.addComponent(name);

    // Enter description
    value = vvrModel.getVvrDescription();
    if (value == null) {
        value = "";
    }
    final TextField desc = new TextField("Description", value);
    desc.setSizeFull();
    vvrAttributesLayout.addComponent(desc);

    // Enter name
    final TextField vvrUUID = new TextField("UUID");
    vvrUUID.setValue(vvrUuid.toString());
    vvrUUID.setReadOnly(true);
    vvrUUID.setSizeFull();
    vvrAttributesLayout.addComponent(vvrUUID);

    // OK button
    final HorizontalLayout hzlayout = new HorizontalLayout();
    layout.addComponent(hzlayout);
    hzlayout.setSizeFull();

    final Button okButton = new Button("OK");
    hzlayout.addComponent(okButton);
    hzlayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);

    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            WaitingComponent.executeBackground(vvrModel, new Background() {
                @Override
                public void processing() {
                    vvrModel.setVvrName(name.getValue());
                    vvrModel.setVvrDescription(desc.getValue());
                }

                @Override
                public void postProcessing() {
                }
            });
            vvrAttributesWindow.close();
        }
    });

    // Cancel button
    final Button cancelButton = new Button("Cancel");
    hzlayout.addComponent(cancelButton);
    hzlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrAttributesWindow.close();
        }
    });
    return vvrAttributesWindow;
}

From source file:com.peergreen.webconsole.core.notifier.NotifierService.java

License:Open Source License

/**
 * {@inheritDoc}//from  ww w  .  j av a2 s .c  o  m
 */
@Override
public void addNotificationsButton(Button button, final Window window, final UI ui) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    window.setContent(layout);

    notificationButtons.put(ui, new NotificationButton(button, 0));

    button.addClickListener(new NotificationClickListener(layout));
}

From source file:com.piccritic.website.Home.java

/**
 * Sets up menu based on auth//from   ww w  . j av  a2  s  . c om
 */
private void setupMenu() {
    Button home = new Button("Home", e -> {
        navigator.navigateTo(DefaultView.NAME);
    });
    menu.addComponent(home);
    LoginStatus loginStatus = getLoginStatus();
    if (loginStatus == LoginStatus.LOGGED_IN) {
        Button logout = new Button("Log out");
        logout.addClickListener(e -> {
            logoutUser();
            Page.getCurrent().reload();
        });
        menu.addComponent(logout);

        Button button = new Button("Create Post");
        button.addClickListener(e -> {
            Window createPost = new CreatePost(getHandle());
            UI.getCurrent().addWindow(createPost);
        });

        menu.addComponent(button);
    } else {
        Button loginUser = new Button("Login");
        loginUser.addClickListener(e -> {
            Window login = new LoginWindow();
            addWindow(login);
        });
        menu.addComponent(loginUser);
    }

    Button createUser = new Button(((loginStatus == LoginStatus.LOGGED_IN) ? "Update" : "Create") + "User");
    createUser.addClickListener(e -> {
        Window userForm = new Window();
        userForm.setModal(true);
        userForm.setContent(new VerticalLayout(new UserForm(getHandle())));
        addWindow(userForm);
    });

    menu.addComponent(createUser);
    menu.setMargin(true);
    menu.setSpacing(true);

}

From source file:com.pms.component.ganttchart.DemoUI.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("Step Editor");
    win.setResizable(false);/*  w  w w  .  ja va2 s  .c om*/
    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);

    final NativeSelect parentStepSelect = new NativeSelect("Parent Step");
    parentStepSelect.setEnabled(false);
    if (!gantt.getSteps().contains(step)) {
        // new step
        parentStepSelect.setEnabled(true);
        for (Step parentStepCanditate : gantt.getSteps()) {
            parentStepSelect.addItem(parentStepCanditate);
            parentStepSelect.setItemCaption(parentStepCanditate, parentStepCanditate.getCaption());
            if (step instanceof SubStep) {
                if (parentStepCanditate.getSubSteps().contains(step)) {
                    parentStepSelect.setValue(parentStepCanditate);
                    parentStepSelect.setEnabled(false);
                    break;
                }
            }
        }
    }
    parentStepSelect.setVisible(false);
    hidden.add(parentStepSelect);

    TextField bgField = new TextField("Background color");
    bgField.setNullRepresentation("");
    group.bind(bgField, "backgroundColor");
    bgField.setVisible(false);
    hidden.add(bgField);

    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(parentStepSelect);
    content.addComponent(bgField);
    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) {
            try {
                group.commit();
                AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean();
                gantt.markStepDirty(step);
                if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) {
                    SubStep subStep = addSubStep(parentStepSelect, step);
                    step = subStep;
                }
                if (step instanceof Step && !gantt.getSteps().contains(step)) {
                    gantt.addStep((Step) step);
                }
                if (ganttListener != null && step instanceof Step) {
                    ganttListener.stepModified((Step) step);
                }
                win.close();
            } catch (CommitException e) {
                Notification.show("Commit failed", e.getMessage(), Type.ERROR_MESSAGE);
                e.printStackTrace();
            }
        }

        private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) {
            SubStep subStep = new SubStep();
            subStep.setCaption(dataSource.getCaption());
            subStep.setCaptionMode(dataSource.getCaptionMode());
            subStep.setStartDate(dataSource.getStartDate());
            subStep.setEndDate(dataSource.getEndDate());
            subStep.setBackgroundColor(dataSource.getBackgroundColor());
            subStep.setDescription(dataSource.getDescription());
            subStep.setStyleName(dataSource.getStyleName());
            ((Step) parentStepSelect.getValue()).addSubStep(subStep);
            return subStep;
        }
    });
    Button cancel = new Button("Cancel", new ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {
            AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean();
            if (step instanceof SubStep) {
                SubStep substep = (SubStep) step;
                substep.getOwner().removeSubStep(substep);
            } else {
                gantt.removeStep((Step) step);
                if (ganttListener != null) {
                    ganttListener.stepDeleted((Step) step);
                }
            }
            win.close();
        }
    });
    buttons.addComponent(ok);
    buttons.addComponent(cancel);
    buttons.addComponent(delete);
    win.setClosable(true);

    DashboardUI.getCurrent().getUI().addWindow(win);
}

From source file:com.pms.component.ganttchart.scheduletask.TaskGanntChart.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("More Info");
    win.setResizable(false);//  ww w . ja  v  a2  s. co m
    win.center();

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

    String taskName = step.getCaption();
    UserStoryDAO userStoryDAO = (UserStoryDAO) DashboardUI.context.getBean("UserStory");
    UserStory userStory = userStoryDAO.getCurrentWorkingUserStory(project);

    TaskDAO taskDAO = (TaskDAO) DashboardUI.context.getBean("Task");
    Task task1 = taskDAO.getTaskFromUserStroyNameAndTaskName(userStory.getName(), taskName);

    TextField userStoryNameField = new TextField("Task Name");
    userStoryNameField.setValue(task1.getName());

    TextField userStoryPriority = new TextField("Priority");
    userStoryPriority.setValue(String.valueOf(task1.getPriority()));

    TextField userStoryState = new TextField("State");
    userStoryState.setValue(task1.getState());

    TextField projectName = new TextField("Project Name");
    projectName.setValue(project.getName());

    TextField userStoryName = new TextField("UserStoryName Name");
    userStoryName.setValue(userStory.getName());

    content.addComponent(userStoryNameField);
    content.addComponent(userStoryPriority);
    content.addComponent(userStoryState);
    content.addComponent(projectName);
    content.addComponent(userStoryName);

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

        @Override
        public void buttonClick(ClickEvent event) {

            win.close();
        }

    });

    content.addComponent(ok);
    win.setClosable(true);

    DashboardUI.getCurrent().getUI().addWindow(win);
}

From source file:com.pms.component.ganttchart.scheduletask.UserStoryGanntChart.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("More Info");
    win.setResizable(false);/*from w  w w .ja  v  a  2s.co  m*/
    win.center();

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

    String userStoryName = step.getCaption();
    UserStoryDAO userStoryDAO = (UserStoryDAO) DashboardUI.context.getBean("UserStory");
    UserStory userStory = userStoryDAO.getUserStoryFormProjectNameAndUserStoryName(project.getName(),
            userStoryName);

    TextField userStoryNameField = new TextField("User Story Name");
    userStoryNameField.setValue(userStory.getName());

    TextField userStoryPriority = new TextField("Priority");
    userStoryPriority.setValue(String.valueOf(userStory.getPriority()));

    TextField userStoryState = new TextField("State");
    userStoryState.setValue(userStory.getState());

    TextField projectName = new TextField("Project Name");
    projectName.setValue(project.getName());

    content.addComponent(userStoryNameField);
    content.addComponent(userStoryPriority);
    content.addComponent(userStoryState);
    content.addComponent(projectName);

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

        @Override
        public void buttonClick(ClickEvent event) {

            win.close();
        }

    });

    content.addComponent(ok);
    win.setClosable(true);

    DashboardUI.getCurrent().getUI().addWindow(win);
}

From source file:com.save.client.promodeals.PDDataGridProperties.java

Window delete(Object itemId, int promoId) {
    Window sub = new Window("REMOVE PROMO DEAL");
    sub.setWidth("250px");
    sub.setModal(true);/*from   www .  j  a  v a  2s. c om*/
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button delBtn = new Button("CONFIRM DELETE?", (Button.ClickEvent event) -> {
        boolean result = pds.delete(promoId, "removed");
        getContainerDataSource().removeItem(itemId);
        sub.close();
    });
    delBtn.setWidth("100%");
    delBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    v.addComponent(delBtn);

    sub.setContent(v);
    return sub;
}

From source file:com.save.client.RemoveAccountWindow.java

void getConfirmationWindow(final String str) {
    final Window sub = new Window("Conifrm?");
    sub.setWidth("180px");
    sub.setHeight("150px");
    sub.center();/*ww  w.j a  v  a2  s .  c o  m*/
    sub.setResizable(false);
    UI.getCurrent().addWindow(sub);

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setMargin(true);
    vlayout.setSpacing(true);

    vlayout.addComponent(new Label("Client is a Distributor!"));

    Button removeBtn = new Button("REMOVE");
    removeBtn.setWidth("100%");
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        boolean result = clientService.removeAccount(getClientId(), str);
        if (result) {
            sub.close();
            close();
        }
    });
    vlayout.addComponent(removeBtn);

    sub.setContent(vlayout);
    sub.addCloseListener((CloseEvent e) -> {
        close();
    });
}

From source file:com.save.employee.maintenance.MRDataGridProperties.java

Window deletConfirmationWindow(int mrId, Object itemId) {
    Window sub = new Window();
    sub.setCaption("CONFIRM DELETE");
    sub.setWidth("250px");
    sub.setModal(true);//from  www  .java2s.c  o  m

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button deleteBtn = new Button("DELETE?");
    deleteBtn.setWidth("100%");
    deleteBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    deleteBtn.addClickListener((Button.ClickEvent event) -> {
        boolean result = mrs.removeMaintenanceReimbursement(mrId);
        if (result) {
            getContainerDataSource().removeItem(itemId);
            sub.close();
        }
    });
    v.addComponent(deleteBtn);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();
    return sub;
}

From source file:com.save.employee.request.RequestFormWindow.java

Window deleteRequestForm() {
    Window sub = new Window("DELETE REQUEST");
    sub.setWidth("280px");
    sub.setModal(true);// ww  w  .  ja v a 2 s. c  om
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button delete = new Button();
    delete.setCaption("CONFIRM DELETE REQUEST?");
    delete.setWidth("100%");
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener((Button.ClickEvent event) -> {
        boolean result = rls.deleteRequestById(getRequestId());
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(delete);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}