Example usage for com.vaadin.shared Position BOTTOM_RIGHT

List of usage examples for com.vaadin.shared Position BOTTOM_RIGHT

Introduction

In this page you can find the example usage for com.vaadin.shared Position BOTTOM_RIGHT.

Prototype

Position BOTTOM_RIGHT

To view the source code for com.vaadin.shared Position BOTTOM_RIGHT.

Click Source Link

Usage

From source file:com.anphat.list.controller.ListDeptAndStaffController.java

public void deptActionListener() {

    ShortcutUtils.setShortcutKey(listDepartmentsAndStaffUI.getBtnSearchDept());
    ShortcutUtils.doTextChangeUppercase(searchFormDeptController.getSearchDepartmentForm().getTxtDeptCode());
    listDepartmentsAndStaffUI.getBtnSearchDept().addClickListener(new Button.ClickListener() {

        @Override//w  ww.j a v  a 2  s. com
        public void buttonClick(Button.ClickEvent event) {
            doSearchDepartments();
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnResetDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            doResetInputDept();
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnAddDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            DialogCreateDepartment dialogCreateDepartment = new DialogCreateDepartment(
                    BundleUtils.getString("department.management.panel.addDepartment"), new DepartmentDTO());
            dialogCreateDepartmentController = new DialogCreateDepartmentController(dialogCreateDepartment,
                    Constants.ADD, tblDepartment, tblStaff, staffForm.getF9Departments());
            dialogCreateDepartmentController.init(new DepartmentDTO());
            UI.getCurrent().addWindow(dialogCreateDepartment);
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnEditDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<DepartmentDTO> selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
            if (selectedValues != null) {
                List<DepartmentDTO> lstDepartment = Lists.newArrayList();
                for (DepartmentDTO departmentDTO : selectedValues) {
                    lstDepartment.add(departmentDTO);
                }
                if (selectedValues.size() == 1) {
                    DepartmentDTO departmentDTO;
                    departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                    DialogCreateDepartment dialogCreateContract = new DialogCreateDepartment(
                            BundleUtils.getString("department.management.panel.updateDepartment"),
                            departmentDTO);
                    dialogCreateDepartmentController = new DialogCreateDepartmentController(
                            dialogCreateContract, Constants.EDIT, tblDepartment, tblStaff,
                            staffForm.getF9Departments());
                    dialogCreateDepartmentController.init(departmentDTO);
                    UI.getCurrent().addWindow(dialogCreateContract);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnCopyDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //                DepartmentDTO selectedValues = (DepartmentDTO) tblDepartment.getValue();
            Set<DepartmentDTO> selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
            if (selectedValues != null) {
                List<DepartmentDTO> lstDepartment = Lists.newArrayList();
                for (DepartmentDTO departmentDTO : selectedValues) {
                    lstDepartment.add(departmentDTO);
                }
                if (selectedValues.size() == 1) {
                    DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                    DialogCreateDepartment dialogCreateContract = new DialogCreateDepartment(
                            BundleUtils.getString("department.management.panel.copyDepartment"), departmentDTO);
                    dialogCreateDepartmentController = new DialogCreateDepartmentController(
                            dialogCreateContract, Constants.COPY, tblDepartment, tblStaff,
                            staffForm.getF9Departments());
                    dialogCreateDepartmentController.init(departmentDTO);
                    UI.getCurrent().addWindow(dialogCreateContract);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    listDepartmentController.getBtnDel().addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();

            if (selectedValues.isEmpty()) {
                CommonUtils.showChoseOne();
            } else {
                final DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                ConfirmDialog.show(UI.getCurrent(), BundleUtils.getString("titleMessage") + "",
                        BundleUtils.getString("bodyMessage"), BundleUtils.getString("yes"),
                        BundleUtils.getString("no"), new ConfirmDialog.Listener() {
                            @Override
                            public void onClose(ConfirmDialog dialog) {
                                // tiepnv6 edit 16h 15/07/15
                                // check neu phong ban la cha thi khong xoa
                                if (deptIsParent(departmentDTO)) {
                                    Notification.show(
                                            BundleUtils.getString("dept.staff.required.delete.staff.1"),
                                            Notification.Type.HUMANIZED_MESSAGE);
                                    return;
                                }
                                //check neu bang phong ban co nhan vien thi xoa phong ban fai xoa het nv
                                if (!checkHasValue(departmentDTO)) {
                                    if (dialog.isConfirmed()) {
                                        List<DepartmentDTO> lstDeptDel = Lists.newArrayList();
                                        lstDeptDel.addAll(selectedValues);
                                        if (selectedValues.size() > 1) {
                                            //neu dept khong co dept cap con thi xoa
                                            List<DepartmentDTO> listChildOfDept = Lists.newArrayList();
                                            DepartmentDTO deptDTODel = new DepartmentDTO();
                                            deptDTODel = lstDeptDel.get(0);
                                            listChildOfDept = getChildDepartment(deptDTODel);
                                            if (listChildOfDept != null) {
                                                // Notification with default settings for a warning
                                                String showDepartmentChild = "";
                                                for (DepartmentDTO listChildOfDept1 : listChildOfDept) {
                                                    listChildOfDept1.getName();
                                                    showDepartmentChild += listChildOfDept1.getName() + ", ";
                                                }
                                                Notification notif = new Notification(
                                                        BundleUtils.getString("Warning"),
                                                        BundleUtils
                                                                .getString("message.required.deleteDepartment")
                                                                + "<br/>" + showDepartmentChild,
                                                        Notification.Type.TRAY_NOTIFICATION);
                                                notif.setDelayMsec(20000);
                                                notif.setPosition(Position.BOTTOM_RIGHT);
                                                notif.setStyleName("mystyle");
                                                notif.show(Page.getCurrent());
                                                //
                                            } else {
                                                message = doDeleteLstDept(lstDeptDel);
                                            }
                                            if (message.contains(Constants.SUCCESS)) {
                                                for (DepartmentDTO deptDTO : lstDeptDel) {
                                                    tblDepartment.removeItem(deptDTO);
                                                }
                                                tblDepartment.refreshRowCache();
                                                tblDepartment.resetPage();
                                                CommonUtils
                                                        .showDeleteSuccess(BundleUtils.getString("department"));
                                            } else {
                                                CommonUtils.showDeleteFail(BundleUtils.getString("department"));
                                            }
                                        } else {
                                            //                                                tblDepartment = listDepartmentsAndStaffUI.getTblListDepartmentUI().getMainTable();
                                            List<DepartmentDTO> listDepartment = Lists.newArrayList();
                                            selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
                                            DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues
                                                    .toArray()[0];
                                            //                                                departmentDTO.setUserNameLogging("Username");
                                            listDepartment.add(departmentDTO);
                                            message = doDeleteLstDept(listDepartment);
                                            if (message.contains(Constants.SUCCESS)) {

                                                tblDepartment.removeItem(departmentDTO);
                                                tblDepartment.resetPage();
                                                CommonUtils
                                                        .showDeleteSuccess(BundleUtils.getString("department"));
                                            } else {
                                                CommonUtils.showDeleteFail(BundleUtils.getString("department"));
                                            }
                                        }
                                    }
                                } else {
                                    Notification.show(BundleUtils.getString("dept.staff.required.delete.staff"),
                                            Notification.Type.HUMANIZED_MESSAGE);
                                }
                            }
                        });
            }
            CommonFunction.enableButtonAfterClick(event);
        }

    });
    btnAddMapStaffCusts.setDisableOnClick(true);
    btnAddMapStaffCusts.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<StaffDTO> selectedValues = (Set<StaffDTO>) tblStaff.getValue();
            if (!DataUtil.isListNullOrEmpty(Lists.newArrayList(selectedValues))) {
                MapStaffCustomerDialog dialogAddMapStaffGoods = new MapStaffCustomerDialog();
                MapStaffCustomerController mapStaffCustomerController = new MapStaffCustomerController(
                        dialogAddMapStaffGoods, Lists.newArrayList(selectedValues), lstAllAppParams);
                DataUtil.reloadWindow(dialogAddMapStaffGoods);
                UI.getCurrent().addWindow(dialogAddMapStaffGoods);
            } else {
                CommonMessages.showWarningMessage(BundleUtils.getString("notification.staff.customer.choice"));
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });
}

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel notifications() {
    Panel p = new Panel("Notifications");
    VerticalLayout content = new VerticalLayout() {
        Notification notification = new Notification("");
        TextField title = new TextField("Title");
        TextArea description = new TextArea("Description");
        MenuBar style = new MenuBar();
        MenuBar type = new MenuBar();
        String typeString = "";
        String styleString = "";
        TextField delay = new TextField();
        {//from   w  w  w .  ja va  2 s.c  o  m
            setSpacing(true);
            setMargin(true);

            title.setInputPrompt("Title for the notification");
            title.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (title.getValue() == null || title.getValue().length() == 0) {
                        notification.setCaption(null);
                    } else {
                        notification.setCaption(title.getValue());
                    }
                }
            });
            title.setValue("Notification Title");
            title.setWidth("100%");
            addComponent(title);

            description.setInputPrompt("Description for the notification");
            description.addStyleName("small");
            description.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (description.getValue() == null || description.getValue().length() == 0) {
                        notification.setDescription(null);
                    } else {
                        notification.setDescription(description.getValue());
                    }
                }
            });
            description.setValue(
                    "A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
            description.setWidth("100%");
            addComponent(description);

            Command typeCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Humanized")) {
                        typeString = "";
                        notification.setStyleName(styleString.trim());
                    } else {
                        typeString = selectedItem.getText().toLowerCase();
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    }
                    for (MenuItem item : type.getItems()) {
                        item.setChecked(false);
                    }
                    selectedItem.setChecked(true);
                }
            };

            type.setCaption("Type");
            MenuItem humanized = type.addItem("Humanized", typeCommand);
            humanized.setCheckable(true);
            humanized.setChecked(true);
            type.addItem("Tray", typeCommand).setCheckable(true);
            type.addItem("Warning", typeCommand).setCheckable(true);
            type.addItem("Error", typeCommand).setCheckable(true);
            type.addItem("System", typeCommand).setCheckable(true);
            addComponent(type);
            type.addStyleName("small");

            Command styleCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    styleString = "";
                    for (MenuItem item : style.getItems()) {
                        if (item.isChecked()) {
                            styleString += " " + item.getText().toLowerCase();
                        }
                    }
                    if (styleString.trim().length() > 0) {
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    } else if (typeString.length() > 0) {
                        notification.setStyleName(typeString.trim());
                    } else {
                        notification.setStyleName(null);
                    }
                }
            };

            style.setCaption("Additional style");
            style.addItem("Dark", styleCommand).setCheckable(true);
            style.addItem("Success", styleCommand).setCheckable(true);
            style.addItem("Failure", styleCommand).setCheckable(true);
            style.addItem("Bar", styleCommand).setCheckable(true);
            style.addItem("Small", styleCommand).setCheckable(true);
            style.addItem("Closable", styleCommand).setCheckable(true);
            addComponent(style);
            style.addStyleName("small");

            CssLayout group = new CssLayout();
            group.setCaption("Fade delay");
            group.addStyleName("v-component-group");
            addComponent(group);

            delay.setInputPrompt("Infinite");
            delay.addStyleName("align-right");
            delay.addStyleName("small");
            delay.setWidth("7em");
            delay.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    try {
                        notification.setDelayMsec(Integer.parseInt(delay.getValue()));
                    } catch (Exception e) {
                        notification.setDelayMsec(-1);
                        delay.setValue("");
                    }

                }
            });
            delay.setValue("1000");
            group.addComponent(delay);

            Button clear = new Button(null, new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    delay.setValue("");
                }
            });
            clear.setIcon(FontAwesome.TIMES_CIRCLE);
            clear.addStyleName("last");
            clear.addStyleName("small");
            clear.addStyleName("icon-only");
            group.addComponent(clear);
            group.addComponent(new Label("&nbsp; msec", ContentMode.HTML));

            GridLayout grid = new GridLayout(3, 3);
            grid.setCaption("Show in position");
            addComponent(grid);
            grid.setSpacing(true);

            Button pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

        }
    };
    p.setContent(content);

    return p;
}

From source file:com.github.tempora.view.TemporaUI.java

License:Apache License

/**
 * Helper method to display a notification to the end user.
 *
 * @param message the notification description.
 *///from   w  w w .  ja v a2  s  .  c  om
private void notifyEndUser(String message) {
    Notification notification = new Notification("INFO", message, Notification.Type.TRAY_NOTIFICATION, true);
    notification.setPosition(Position.BOTTOM_RIGHT);
    notification.show(getPage());
}

From source file:org.eclipse.hawkbit.ui.components.HawkbitErrorNotificationMessage.java

License:Open Source License

/**
 * Constructor of HawkbitErrorNotificationMessage
 * /*from w w w  . j  av  a2  s.c  om*/
 * @param style
 *            style of the notification message
 * @param caption
 *            caption of the notification message
 * @param description
 *            text which is displayed in the notification
 * @param autoClose
 *            boolean if notification is closed after random click (true) or
 *            closed by clicking on the notification (false)
 */
public HawkbitErrorNotificationMessage(final String style, final String caption, final String description,
        final boolean autoClose) {
    super(caption);
    setStyleName(style);
    if (autoClose) {
        setDelayMsec(SPUILabelDefinitions.SP_DELAY);
    } else {
        setDelayMsec(-1);
    }
    setHtmlContentAllowed(true);
    setPosition(Position.BOTTOM_RIGHT);
    setDescription(description);
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewClientCriterion.java

License:Open Source License

/**
 * Displays a message box telling that the action is not allowed.
 *
 * @param drag/*  w ww . ja  va  2s.c o  m*/
 *            the current drag event holding the context.
 */
private void showErrorNotification(final VDragEvent drag) {
    final VNotification n = VNotification.createNotification(SPUILabelDefinitions.SP_DELAY,
            drag.getTransferable().getDragSource().getWidget());
    n.show(getDraggableTemplate().notificationMsg(errorMessage).asString(), Position.BOTTOM_RIGHT,
            SPUIStyleDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE);
}

From source file:org.eclipse.hawkbit.ui.ErrorView.java

License:Open Source License

@Override
public void enter(final ViewChangeListener.ViewChangeEvent event) {
    final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName());
    if (view == null) {
        message.setValue(i18n.getMessage("message.error.view", event.getViewName()));
        return;//from  w  w w  .  ja v  a2 s  .  com
    }
    if (dashboardMenu.isAccessDenied(event.getViewName())) {
        final Notification nt = new Notification("Access denied",
                i18n.getMessage("message.accessdenied.view", event.getViewName()), Type.ERROR_MESSAGE, false);
        nt.setStyleName(SPUIStyleDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE);
        nt.setPosition(Position.BOTTOM_RIGHT);
        nt.show(UI.getCurrent().getPage());
        message.setValue(i18n.getMessage("message.accessdenied.view", event.getViewName()));
    }
}

From source file:org.eclipse.hawkbit.ui.utils.NotificationMessage.java

License:Open Source License

/**
 * Decorate.//ww w .  j  a  v  a  2  s.co  m
 * 
 * @param styleName
 *            style name of message
 * @param caption
 *            message caption
 * @param description
 *            message description
 * @param autoClose
 *            flag to indicate enable close option
 */
private void decorate(final String styleName, final String caption, final String description,
        final Boolean autoClose) {
    setCaption(caption);
    setDescription(description);
    setStyleName(styleName);
    setHtmlContentAllowed(true);
    setPosition(Position.BOTTOM_RIGHT);
    if (autoClose) {
        setDelayMsec(SPUILabelDefinitions.SP_DELAY);
    } else {
        setDelayMsec(-1);
    }
}

From source file:org.groom.shell.Shell.java

License:Apache License

/**
 * Executes requested shell command./*from ww w . j a  v  a2s.  co  m*/
 *
 * @param cmd the shell command to execute
 */
public static String execute(final String cmd, final String path) {
    LOGGER.debug("Executing shell command: " + cmd);
    try {

        if (UI.getCurrent() != null) {
            Notification.show(cmd, Notification.Type.TRAY_NOTIFICATION);
        }

        List<String> commands = new ArrayList<String>();
        if (PropertiesUtil.getProperty("groom", "os").equals("windows")) {
            commands.add("cmd");
            commands.add("/c");
            commands.add(cmd);
        } else {
            commands.add("/bin/sh");
            commands.add("-c");
            commands.add(cmd);
        }

        SystemCommandExecutor commandExecutor = new SystemCommandExecutor(path, commands);
        commandExecutor.executeCommand();

        StringBuilder errorOutput = commandExecutor.getErrorOutput();
        if (errorOutput.length() > 0) {
            LOGGER.error(errorOutput);
            {
                if (UI.getCurrent() != null) {
                    final Notification notification = new Notification("Shell", errorOutput.toString(),
                            Notification.Type.WARNING_MESSAGE);
                    notification.setDelayMsec(5000);
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            }
        }
        StringBuilder standardOutput = commandExecutor.getStandardOutput();
        if (standardOutput == null) {
            return "";
        }

        return standardOutput.toString();
    } catch (final Throwable t) {
        LOGGER.error("Error executing shell command: " + cmd, t);
        return "";
    }
}