Example usage for com.vaadin.ui Window center

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

Introduction

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

Prototype

public void center() 

Source Link

Document

Sets this window to be centered relative to its parent window.

Usage

From source file:com.openhris.payroll.AdjustmentWindow.java

private Table adjustmentTable() {
    adjustmentTbl.removeAllItems();//from  w  ww .j a v a  2  s . c o m
    adjustmentTbl.setWidth("100%");
    adjustmentTbl.setImmediate(true);
    adjustmentTbl.setSelectable(true);

    adjustmentTbl.addContainerProperty("id", Integer.class, null);
    adjustmentTbl.addContainerProperty("amount", Double.class, null);
    adjustmentTbl.addContainerProperty("remarks", String.class, null);
    adjustmentTbl.addContainerProperty("date posted", String.class, null);

    int i = 0;
    List<Adjustment> adjustmentList = payrollService.getListOfAdjustmentFromPayrollId(getPayrollId());
    for (Adjustment adj : adjustmentList) {
        adjustmentTbl.addItem(new Object[] { adj.getAdjustmentId(), adj.getAmount(), adj.getRemarks(),
                utilities.convertDateFormat(adj.getDatePosted().toString()) }, i);
        i++;
    }

    adjustmentTbl.setPageLength(adjustmentTbl.size());

    for (Object listener : adjustmentTbl.getListeners(ItemClickEvent.class)) {
        adjustmentTbl.removeListener(ItemClickEvent.class, listener);
    }

    adjustmentTbl.addListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            Object itemId = event.getItemId();
            final Item item = adjustmentTbl.getItem(itemId);

            double adjustments = utilities
                    .convertStringToDouble(item.getItemProperty("amount").getValue().toString());
            String remarks = item.getItemProperty("remarks").getValue().toString();

            if (remarks.equals("edit timekeeping table")) {
                getWindow().showNotification("You cannot delete adjustment from previous Payroll!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            if (event.getPropertyId().equals("id")) {
                Window subWindow = removeAdjustment(
                        utilities.convertStringToInteger(item.getItemProperty("id").getValue().toString()),
                        getAmountToBeReceive(), getAmountReceived(), adjustments, getPayrollId());
                if (subWindow.getParent() == null) {
                    getApplication().getMainWindow().addWindow(subWindow);
                }
                subWindow.setModal(true);
                subWindow.center();
            }

        }
    });

    return adjustmentTbl;
}

From source file:com.openhris.payroll.PayrollSubModules.java

public Window perDiemWindow(Item item) {
    this.item = item;

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);//from w ww.  j  av  a 2 s .c o m
    vlayout.setMargin(true);

    final Window sub = new Window("PER DIEM", vlayout);
    sub.setWidth("220px");
    sub.setModal(true);
    sub.center();

    final TextField perDiemAmount = new TextField("Amount: ");
    perDiemAmount.setWidth("100%");
    perDiemAmount
            .setValue(util.convertStringToDouble(getPayrollTableItem().getItemProperty("per diem").toString()));
    perDiemAmount.setNullSettingAllowed(false);
    sub.addComponent(perDiemAmount);

    Button save = new Button("SAVE");
    save.setWidth("100%");
    save.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            int payrollId = util
                    .convertStringToInteger(getPayrollTableItem().getItemProperty("id").getValue().toString());
            double amountToBeReceive = util.convertStringToDouble(
                    getPayrollTableItem().getItemProperty("amount to be receive").toString());
            double amountReceived = util
                    .convertStringToDouble(getPayrollTableItem().getItemProperty("amount received").toString());
            double amount = util.convertStringToDouble(perDiemAmount.getValue().toString())
                    - util.convertStringToDouble(
                            getPayrollTableItem().getItemProperty("per diem").getValue().toString());

            boolean result = ps.addPerDiem(payrollId,
                    util.convertStringToDouble(perDiemAmount.getValue().toString()),
                    util.convertStringToDouble(
                            getPayrollTableItem().getItemProperty("per diem").getValue().toString()),
                    amountToBeReceive, amountReceived);
            if (result) {
                getPayrollTableItem().getItemProperty("amount to be receive")
                        .setValue(amountToBeReceive + amount);
                getPayrollTableItem().getItemProperty("amount received").setValue(amountReceived + amount);
                getPayrollTableItem().getItemProperty("per diem").setValue(perDiemAmount.getValue());
                (sub.getParent()).removeWindow(sub);
            }
        }
    });
    sub.addComponent(save);

    return sub;
}

From source file:com.peergreen.webconsole.scope.home.extensions.PeergreenNewsFeedFrame.java

License:Open Source License

/**
 * News popup//from  ww w. j  a v  a2s . c om
 *
 * @param feedMessage
 * @return
 */
private Window getNewsDescription(FeedMessage feedMessage) {
    FormLayout fields = new FormLayout();
    fields.setWidth("35em");
    fields.setSpacing(true);
    fields.setMargin(true);

    Label label = new Label("<a href=\"" + feedMessage.getLink() + "\">"
            + feedMessage.getLink().substring(0, 50) + "..." + "</a>");
    label.setContentMode(ContentMode.HTML);
    label.setSizeUndefined();
    label.setCaption("URL");
    fields.addComponent(label);

    String description = feedMessage.getDescription();
    if (description.length() > 1000) {
        description = description.substring(0, 999) + "...";
    }

    Label desc = new Label(description);
    desc.setContentMode(ContentMode.HTML);
    desc.setCaption("Description");
    fields.addComponent(desc);

    Button ok = new Button("Close");
    ok.addStyleName("wide");
    ok.addStyleName("default");

    final Window w = new DefaultWindow(feedMessage.getTitle(), fields, ok);
    w.center();
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            w.close();
        }
    });
    return w;
}

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 ww  .  j a v  a2 s  . c  o 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);

    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);/*  w w  w. j  av  a  2s  .  com*/
    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);//w w w .j av  a 2 s .com
    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.ribas.andrei.vaadin.OpenWindowApplication.java

License:Open Source License

private void createSubWindow(String subWindowMessage, boolean modal, Embedded iframe) {

    final Window tempSubWindow = new Window(subWindowMessage);
    tempSubWindow.setWidth("80%");
    tempSubWindow.setHeight("80%");
    tempSubWindow.center();
    tempSubWindow.setModal(modal);/*from   www  .ja v  a  2s . c  o m*/

    tempSubWindow.addListener(new Window.CloseListener() {
        public void windowClose(CloseEvent e) {
            closeWindow();
        }
    });

    tempSubWindow.addComponent(iframe);

    OpenWindowApplication.this.subWindow = tempSubWindow;

    OpenWindowApplication.this.mainWindow.addWindow(OpenWindowApplication.this.subWindow);

}

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 w w w .  j  a v a2  s. c  o  m*/
    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();
    sub.setResizable(false);/*from   www  . ja  v  a 2  s.  com*/
    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.request.RequestFormWindow.java

Window deleteRequestForm() {
    Window sub = new Window("DELETE REQUEST");
    sub.setWidth("280px");
    sub.setModal(true);//from  w ww  . j  a v a  2  s.  c  o  m
    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;
}