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:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre una vista. La colocar en el lado derecho
 *
 * @param ui//from ww w . ja  v a 2  s.com
 * @param view
 */
public static void addView(MyUI ui, AbstractView view) {

    if (view == null) {
        System.out.println("abriendo vista null");
        ui.getViewDisplay().removeAllComponents();
    } else {

        System.out.println("abriendo vista " + view.getClass().getName() + "::" + view.getViewId());

        ViewLayout v = new ViewLayout(view);
        if (view instanceof AbstractDialog) {

            AbstractDialog d = (AbstractDialog) view;

            // Create a sub-window and set the content
            Window subWindow = new Window(((AbstractDialog) view).getTitle());

            HorizontalLayout footer = new HorizontalLayout();
            footer.setWidth("100%");
            footer.setSpacing(true);
            footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

            Label footerText = new Label("");
            footerText.setSizeUndefined();

            Button ok;
            if (d instanceof AbstractAddRecordDialog) {
                ok = new Button("Add record", e -> {
                    List<String> errors = v.getView().getForm().validate();
                    if (errors.size() > 0) {
                        io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors);
                    } else {
                        //if (d.isCloseOnOk()) subWindow.close();
                        ((AbstractAddRecordDialog) view).addAndClean(v.getView().getForm().getData());
                    }
                });
            } else {
                ok = new Button(d.getOkText(), e -> {
                    List<String> errors = v.getView().getForm().validate();
                    if (errors.size() > 0) {
                        io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors);
                    } else {
                        if (d.isCloseOnOk())
                            subWindow.close();
                        ((AbstractDialog) view).onOk(v.getView().getForm().getData());
                    }
                });
            }
            ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
            ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

            footer.addComponents(footerText);

            for (AbstractAction a : d.getActions()) {
                Button b = new Button(a.getName(), e -> {
                    a.run();
                });
                //b.addStyleName(ValoTheme.BUTTON_);
                //b.setClickShortcut(ShortcutAction.KeyCode.ENTER);
                if ("previous".equalsIgnoreCase(a.getName())) {
                    b.setIcon(VaadinIcons.ANGLE_LEFT);
                } else if ("next".equalsIgnoreCase(a.getName())) {
                    b.setIcon(VaadinIcons.ANGLE_RIGHT);
                }
                footer.addComponent(b);
            }

            if (d instanceof AbstractListEditorDialog) {
                AbstractListEditorDialog lv = (AbstractListEditorDialog) d;

                Property<Integer> pos = new SimpleObjectProperty<>();

                pos.setValue(lv.getInitialPos());

                Button prev = new Button("Previous", e -> {
                    List<String> errors = v.getView().getForm().validate();
                    if (errors.size() > 0) {
                        io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors);
                    } else {

                        if (pos.getValue() > 0) {
                            lv.setData(pos.getValue(), view.getForm().getData());
                            pos.setValue(pos.getValue() - 1);
                            view.getForm().setData(lv.getData(pos.getValue()));
                        }

                    }
                });
                prev.setIcon(VaadinIcons.ANGLE_LEFT);
                footer.addComponent(prev);

                Button next = new Button("Next", e -> {
                    List<String> errors = v.getView().getForm().validate();
                    if (errors.size() > 0) {
                        io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors);
                    } else {

                        if (pos.getValue() < lv.getListSize() - 1) {
                            lv.setData(pos.getValue(), view.getForm().getData());
                            pos.setValue(pos.getValue() + 1);
                            view.getForm().setData(lv.getData(pos.getValue()));
                        }

                    }
                });
                next.setIcon(VaadinIcons.ANGLE_RIGHT);
                footer.addComponent(next);

                pos.addListener(new ChangeListener<Integer>() {
                    @Override
                    public void changed(ObservableValue<? extends Integer> observable, Integer oldValue,
                            Integer newValue) {
                        if (newValue <= 0) {
                            prev.setEnabled(false);
                        } else {
                            prev.setEnabled(true);
                        }
                        if (newValue < lv.getListSize() - 1) {
                            next.setEnabled(true);
                        } else {
                            next.setEnabled(false);
                        }
                    }
                });

            }

            footer.addComponents(ok); //, cancel);
            footer.setExpandRatio(footerText, 1);

            v.addComponent(footer);

            subWindow.setContent(v);

            // Center it in the browser window
            subWindow.center();

            subWindow.setModal(true);

            // Open it in the UI
            ui.addWindow(subWindow);

        } else {

            System.out.println("aadiendo vista al contenedor de vistas");

            ui.getViewDisplay().removeAllComponents();
            ui.getViewDisplay().addComponent(v);

            ui.refreshMenu(v.getArea(), v.getMenu());

        }

    }

}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * are el dilogo para autenticarse/* ww  w.ja  v  a 2 s .  c  o m*/
 */
private void openLoginDialog(boolean gohome) {

    // Create a sub-window and set the content
    Window subWindow = new Window("Login");

    subWindow.setWidth("375px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    TextField l;
    f.addComponent(l = new TextField("Username"));
    PasswordField p;
    f.addComponent(p = new PasswordField("Password"));
    Label e;
    f.addComponent(e = new Label());

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    Label footerText = new Label("");
    footerText.setSizeUndefined();

    Button forgot = new Button("Forgot password", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Asking for email...");
            io.mateu.ui.core.client.app.MateuUI.getBaseService().forgotPassword(l.getValue(),
                    new AsyncCallback<Void>() {

                        @Override
                        public void onFailure(Throwable caught) {
                            e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            e.setValue("Email sent. Please check your inbox");
                        }
                    });
        }
    });
    //forgot.addStyleName(ValoTheme.BUTTON_);

    Button ok = new Button("Login", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Authenticating...");
            io.mateu.ui.core.client.app.MateuUI.getBaseService().authenticate(l.getValue(), p.getValue(),
                    new AsyncCallback<UserData>() {

                        @Override
                        public void onFailure(Throwable caught) {
                            e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(UserData result) {
                            e.setValue("OK!");
                            getApp().setUserData(result);
                            VaadinSession.getCurrent().setAttribute("usuario", "admin");
                            subWindow.close();

                            if (MateuUI.getApp().isFavouritesAvailable())
                                linkFavoritos.setVisible(true);
                            if (MateuUI.getApp().isLastEditedAvailable())
                                linkUltimosRegistros.setVisible(true);
                            if (MateuUI.getApp().isFavouritesAvailable())
                                linkNuevoFavorito.setVisible(true);

                            refreshSettings();
                            refreshMenu(null, null);
                            System.out.println("STATE:" + navigator.getState());
                            System.out.println("URIFRAGMENT:" + Page.getCurrent().getUriFragment());
                            navigator.navigateTo((gohome) ? "" : navigator.getState());
                        }
                    });
        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

    footer.addComponents(footerText, forgot, ok); //, cancel);
    footer.setExpandRatio(footerText, 1);

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    l.focus();
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre el dilogo para cambiar el password
 *
 *///from w  w w.j a  v a  2s .  co m
private void changePassword() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Change password");

    subWindow.setWidth("375px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    PasswordField l;
    f.addComponent(l = new PasswordField("Current password"));
    PasswordField p;
    f.addComponent(p = new PasswordField("New password"));
    PasswordField p2;
    f.addComponent(p2 = new PasswordField("Repeat password"));
    Label e;
    f.addComponent(e = new Label());

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    Label footerText = new Label("");
    footerText.setSizeUndefined();

    Button ok = new Button("Change it!", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            if (l.getValue() == null || "".equals(l.getValue().trim()))
                e.setValue("Old password is required");
            else if (p.getValue() == null || "".equals(p.getValue().trim()))
                e.setValue("New password is required");
            else if (p2.getValue() == null || "".equals(p2.getValue().trim()))
                e.setValue("New password repeated is required");
            else if (!p.getValue().equals(p2.getValue()))
                e.setValue("New password and new password repeated must be equal");
            else {
                e.setValue("Changing password...");

                io.mateu.ui.core.client.app.MateuUI.getBaseService().changePassword(
                        getApp().getUserData().getLogin(), l.getValue(), p.getValue(),
                        new AsyncCallback<Void>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                            }

                            @Override
                            public void onSuccess(Void result) {
                                e.setValue("OK!");
                                subWindow.close();
                            }
                        });

            }
        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

    footer.addComponents(footerText, ok); //, cancel);
    footer.setExpandRatio(footerText, 1);

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    l.focus();
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre el dilogo para editar el perfil/*from  w  ww.ja va2  s.com*/
 *
 */
private void editProfile() {
    // Create a sub-window and set the content
    Window subWindow = new Window("My profile");

    subWindow.setWidth("375px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    TextField l;
    f.addComponent(l = new TextField("Name"));
    l.setValue(getApp().getUserData().getName());
    TextField p;
    f.addComponent(p = new TextField("Email"));
    p.setValue(getApp().getUserData().getEmail());
    Label e;
    f.addComponent(e = new Label());

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    Label footerText = new Label("");
    footerText.setSizeUndefined();

    Button ok = new Button("Update it!", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Authenticating...");
            io.mateu.ui.core.client.app.MateuUI.getBaseService().updateProfile(
                    getApp().getUserData().getLogin(), l.getValue(), p.getValue(), null,
                    new AsyncCallback<Void>() {

                        @Override
                        public void onFailure(Throwable caught) {
                            e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            e.setValue("OK!");
                            getApp().getUserData().setName(l.getValue());
                            getApp().getUserData().setEmail(p.getValue());
                            subWindow.close();
                            refreshSettings();
                        }
                    });
        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

    footer.addComponents(footerText, ok); //, cancel);
    footer.setExpandRatio(footerText, 1);

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    l.focus();
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre el dilogo para cambiar la foto//w w  w  .  j a  v  a  2  s .  co  m
 *
 *
 */
private void uploadFoto() {
    // Create a sub-window and set the content
    Window subWindow = new Window("My photo");

    subWindow.setWidth("475px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    Label e = new Label();

    Image image = new Image();

    class MyUploader implements Upload.Receiver, Upload.SucceededListener {

        File file;

        public File getFile() {
            return file;
        }

        public OutputStream receiveUpload(String fileName, String mimeType) {
            // Create and return a file output stream

            System.out.println("receiveUpload(" + fileName + "," + mimeType + ")");

            FileOutputStream os = null;
            if (fileName != null && !"".equals(fileName)) {

                long id = fileId++;
                String extension = ".tmp";
                if (fileName == null || "".equals(fileName.trim()))
                    fileName = "" + id + extension;
                if (fileName.lastIndexOf(".") < fileName.length() - 1) {
                    extension = fileName.substring(fileName.lastIndexOf("."));
                    fileName = fileName.substring(0, fileName.lastIndexOf("."));
                }
                File temp = null;
                try {
                    temp = File.createTempFile(fileName, extension);
                    os = new FileOutputStream(file = temp);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            return os;
        }

        public void uploadSucceeded(Upload.SucceededEvent event) {
            // Show the uploaded file in the image viewer
            image.setSource(new FileResource(file));
            System.out.println("uploadSucceeded(" + file.getAbsolutePath() + ")");

        }

        public FileLocator getFileLocator() throws IOException {

            String extension = ".tmp";
            String fileName = file.getName();

            if (file.getName() == null || "".equals(file.getName().trim()))
                fileName = "" + getId();
            if (fileName.lastIndexOf(".") < fileName.length() - 1) {
                extension = fileName.substring(fileName.lastIndexOf("."));
                fileName = fileName.substring(0, fileName.lastIndexOf(".")).replaceAll(" ", "_");
            }

            java.io.File temp = (System.getProperty("tmpdir") == null)
                    ? java.io.File.createTempFile(fileName, extension)
                    : new java.io.File(new java.io.File(System.getProperty("tmpdir")), fileName + extension);

            System.out.println("java.io.tmpdir=" + System.getProperty("java.io.tmpdir"));
            System.out.println("Temp file : " + temp.getAbsolutePath());

            if (System.getProperty("tmpdir") == null || !temp.exists()) {
                System.out.println("writing temp file to " + temp.getAbsolutePath());
                Files.copy(file, temp);
            } else {
                System.out.println("temp file already exists");
            }

            String baseUrl = System.getProperty("tmpurl");
            URL url = null;
            try {
                if (baseUrl == null) {
                    url = file.toURI().toURL();
                } else
                    url = new URL(baseUrl + "/" + file.getName());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            return new FileLocator(0, file.getName(), url.toString(), file.getAbsolutePath());
        }
    }
    ;
    MyUploader receiver = new MyUploader();

    Upload upload = new Upload(null, receiver);
    //upload.setImmediateMode(false);
    upload.addSucceededListener(receiver);

    f.addComponent(image);

    f.addComponent(upload);

    f.addComponent(e);

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    Label footerText = new Label("");
    footerText.setSizeUndefined();

    Button ok = new Button("Change it!", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Changing photo...");
            try {
                FileLocator loc = receiver.getFileLocator();

                io.mateu.ui.core.client.app.MateuUI.getBaseService()
                        .updateFoto(getApp().getUserData().getLogin(), loc, new AsyncCallback<Void>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                            }

                            @Override
                            public void onSuccess(Void result) {
                                e.setValue("OK!");
                                getApp().getUserData().setPhoto(loc.getUrl());
                                foto = (getApp().getUserData().getPhoto() != null)
                                        ? new ExternalResource(getApp().getUserData().getPhoto())
                                        : new ClassResource("profile-pic-300px.jpg");
                                subWindow.close();

                                refreshSettings();

                            }
                        });

            } catch (IOException e1) {
                e1.printStackTrace();
                io.mateu.ui.core.client.app.MateuUI.alert("" + e1.getClass().getName() + ":" + e1.getMessage());
            }

        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

    footer.addComponents(footerText, ok); //, cancel);
    footer.setExpandRatio(footerText, 1);

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    upload.focus();
}

From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.KmlDocumentViewer.java

License:Apache License

public KmlDocumentViewer(String focusedFeature, Coordinate coordinate) {
    super();//from w  w  w  . ja va 2 s  . c  o m
    setImmediate(true);
    loadDocument();
    setWidth(100, UNITS_PERCENTAGE);
    addComponent(ufu);
    addLayer(osm);
    addLayer(vectorLayer);

    extractStyles(doc);

    displayFeatures(focusedFeature);

    vectorLayer.setSelectionMode(SIMPLE);
    vectorLayer.setImmediate(true);
    vectorLayer.addListener(new VectorSelectedListener() {
        public void vectorSelected(VectorSelectedEvent event) {
            final Area component = (Area) event.getVector();
            final String data = (String) component.getData();

            final Window window = new Window("Details");
            window.getContent().setSizeFull();
            window.setHeight("50%");
            window.setWidth("50%");

            Button button = new Button("Focus this feature");
            button.addListener(new ClickListener() {
                private static final long serialVersionUID = 3286851301965195290L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ufu.setFragment(data);
                    displayFeatures(data);
                    window.getParent().removeWindow(window);
                }
            });
            window.addComponent(button);
            window.setClosable(true);
            window.center();
            getWindow().addWindow(window);
            vectorLayer.setSelectedVector(null);
        }
    });

    if (coordinate != null) {
        // Definig a Marker Layer
        MarkerLayer markerLayer = new MarkerLayer();

        // Defining a new Marker

        final Marker marker = new Marker(coordinate.getLongitude(), coordinate.getLatitude());
        // URL of marker Icon
        marker.setIcon(new ThemeResource("img/marker.png"), 60, 60);
        markerLayer.addComponent(marker);
        addLayer(markerLayer);
        setCenter(coordinate.getLongitude(), coordinate.getLatitude());
    }

}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.CoordMobileAuthView.java

License:Open Source License

public CoordMobileAuthView(String CoordID) {

    CtCoordinator ctCoordinator = (CtCoordinator) sys
            .getCtCoordinator(new DtCoordinatorID(new PtString(CoordID)));
    ActCoordinator actCoordinator = sys.getActCoordinator(ctCoordinator);

    actCoordinator.setActorUI(UI.getCurrent());
    env.setActCoordinator(actCoordinator.getName(), actCoordinator);

    IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
    IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);

    thisCoordID = CoordID;/*from  w w w.  j  a  v  a  2  s .c o m*/

    setResponsive(true);
    setWidth("100%");

    NavigationBar alertsBar = new NavigationBar();
    VerticalComponentGroup alertsContent = new VerticalComponentGroup();
    alertsContent.setWidth("100%");
    alertsContent.setResponsive(true);

    HorizontalLayout alertButtons1 = new HorizontalLayout();
    HorizontalLayout alertButtons2 = new HorizontalLayout();
    //alertButtons.setMargin(true);
    //alertButtons.setSpacing(true);

    alertsBar.setCaption("Coordinator " + ctCoordinator.login.toString());
    // NavigationButton logoutBtn1 = new NavigationButton("Logout");
    Button logoutBtn1 = new Button("Logout");
    alertsBar.setRightComponent(logoutBtn1);

    alertsTable = new Grid();
    alertsTable.setContainerDataSource(actCoordinator.getAlertsContainer());
    alertsTable.setColumnOrder("ID", "date", "time", "longitude", "latitude", "comment", "status");
    alertsTable.setSelectionMode(SelectionMode.SINGLE);

    alertsTable.setWidth("100%");
    alertsTable.setResponsive(true);
    //alertsTable.setSizeUndefined();

    alertsTable.setImmediate(true);

    Grid inputEventsTable1 = new Grid();
    inputEventsTable1.setContainerDataSource(actCoordinator.getMessagesDataSource());
    inputEventsTable1.setWidth("100%");
    inputEventsTable1.setResponsive(true);

    alertsContent.addComponents(alertsBar, alertButtons1, alertButtons2, alertsTable, inputEventsTable1);

    Tab alertsTab = this.addTab(alertsContent);
    alertsTab.setCaption("Alerts");

    alertStatus = new NativeSelect();
    alertStatus.setNullSelectionAllowed(false);
    alertStatus.addItems("Pending", "Valid", "Invalid");
    alertStatus.setImmediate(true);

    alertStatus.select("Pending");

    Button validateAlertBtn = new Button("Validate");
    Button invalidateAlertBtn = new Button("Invalidate");
    Button getAlertsSetBtn = new Button("Get alerts set");

    validateAlertBtn.setImmediate(true);
    invalidateAlertBtn.setImmediate(true);

    validateAlertBtn.addClickListener(event -> {
        AlertBean selectedAlertBean = (AlertBean) alertsTable.getSelectedRow();

        Integer thisAlertID = new Integer(selectedAlertBean.getID());
        PtBoolean res;
        res = sys.oeValidateAlert(new DtAlertID(new PtString(thisAlertID.toString())));
    });

    invalidateAlertBtn.addClickListener(event -> {
        AlertBean selectedAlertBean = (AlertBean) alertsTable.getSelectedRow();
        Integer thisAlertID = new Integer(selectedAlertBean.getID());
        PtBoolean res;
        res = sys.oeInvalidateAlert(new DtAlertID(new PtString(thisAlertID.toString())));
    });

    getAlertsSetBtn.addClickListener(event -> {
        if (alertStatus.getValue().toString().equals("Pending"))
            actCoordinator.oeGetAlertsSet(EtAlertStatus.pending);
        else if (alertStatus.getValue().toString().equals("Valid"))
            actCoordinator.oeGetAlertsSet(EtAlertStatus.valid);
        else if (alertStatus.getValue().toString().equals("Invalid"))
            actCoordinator.oeGetAlertsSet(EtAlertStatus.invalid);
    });

    alertButtons1.addComponents(validateAlertBtn, invalidateAlertBtn);
    alertButtons2.addComponents(getAlertsSetBtn, alertStatus);

    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    NavigationBar crisesBar = new NavigationBar();
    VerticalComponentGroup crisesContent = new VerticalComponentGroup();
    crisesContent.setWidth("100%");
    crisesContent.setResponsive(true);

    HorizontalLayout crisesButtons1 = new HorizontalLayout();
    HorizontalLayout crisesButtons2 = new HorizontalLayout();
    crisesBar.setCaption("Coordinator " + ctCoordinator.login.toString());
    //NavigationButton logoutBtn2 = new NavigationButton("Logout");
    Button logoutBtn2 = new Button("Logout");
    crisesBar.setRightComponent(logoutBtn2);

    crisesTable = new Grid();
    crisesTable.setContainerDataSource(actCoordinator.getCrisesContainer());
    crisesTable.setColumnOrder("ID", "date", "time", "type", "longitude", "latitude", "comment", "status");
    crisesTable.setSelectionMode(SelectionMode.SINGLE);

    crisesTable.setWidth("100%");
    //crisesTable.setSizeUndefined();

    crisesTable.setImmediate(true);
    crisesTable.setResponsive(true);

    Grid inputEventsTable2 = new Grid();
    inputEventsTable2.setContainerDataSource(actCoordinator.getMessagesDataSource());
    inputEventsTable2.setWidth("100%");
    inputEventsTable2.setResponsive(true);

    crisesContent.addComponents(crisesBar, crisesButtons1, crisesButtons2, crisesTable, inputEventsTable2);

    Tab crisesTab = this.addTab(crisesContent);
    crisesTab.setCaption("Crises");

    Button handleCrisesBtn = new Button("Handle");
    Button reportOnCrisisBtn = new Button("Report");
    Button changeCrisisStatusBtn = new Button("Status");
    Button closeCrisisBtn = new Button("Close");
    Button getCrisesSetBtn = new Button("Get crises set");
    crisesStatus = new NativeSelect();

    handleCrisesBtn.setImmediate(true);
    reportOnCrisisBtn.setImmediate(true);
    changeCrisisStatusBtn.setImmediate(true);
    closeCrisisBtn.setImmediate(true);
    getCrisesSetBtn.setImmediate(true);
    crisesStatus.setImmediate(true);

    crisesStatus.addItems("Pending", "Handled", "Solved", "Closed");
    crisesStatus.setNullSelectionAllowed(false);
    crisesStatus.select("Pending");

    crisesButtons1.addComponents(handleCrisesBtn, reportOnCrisisBtn, changeCrisisStatusBtn);
    crisesButtons2.addComponents(closeCrisisBtn, getCrisesSetBtn, crisesStatus);

    ////////////////////////////////////////

    Window reportCrisisSubWindow = new Window();
    reportCrisisSubWindow.setClosable(false);
    reportCrisisSubWindow.setResizable(false);
    reportCrisisSubWindow.setResponsive(true);
    VerticalLayout reportLayout = new VerticalLayout();
    reportLayout.setMargin(true);
    reportLayout.setSpacing(true);
    reportCrisisSubWindow.setContent(reportLayout);
    TextField crisisID = new TextField();
    TextField reportText = new TextField();
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    Button reportCrisisBtn = new Button("Report");
    reportCrisisBtn.setClickShortcut(KeyCode.ENTER);
    reportCrisisBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    Button cancelBtn = new Button("Cancel");
    buttonsLayout.addComponents(reportCrisisBtn, cancelBtn);
    buttonsLayout.setSpacing(true);
    reportLayout.addComponents(crisisID, reportText, buttonsLayout);

    cancelBtn.addClickListener(event -> {
        reportCrisisSubWindow.close();
        reportText.clear();
    });

    reportCrisisBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        actCoordinator.oeReportOnCrisis(new DtCrisisID(new PtString(thisCrisisID.toString())),
                new DtComment(new PtString(reportText.getValue())));

        reportCrisisSubWindow.close();
        reportText.clear();
    });

    ////////////////////////////////////////

    Window changeCrisisStatusSubWindow = new Window();
    changeCrisisStatusSubWindow.setClosable(false);
    changeCrisisStatusSubWindow.setResizable(false);
    changeCrisisStatusSubWindow.setResponsive(true);
    VerticalLayout statusLayout = new VerticalLayout();
    statusLayout.setMargin(true);
    statusLayout.setSpacing(true);
    changeCrisisStatusSubWindow.setContent(statusLayout);
    TextField crisisID1 = new TextField();

    NativeSelect crisisStatus = new NativeSelect("crisis status");
    crisisStatus.addItems("Pending", "Handled", "Solved", "Closed");
    crisisStatus.setNullSelectionAllowed(false);
    crisisStatus.select("Pending");

    HorizontalLayout buttonsLayout1 = new HorizontalLayout();
    Button changeCrisisStatusBtn1 = new Button("Change status");
    changeCrisisStatusBtn1.setClickShortcut(KeyCode.ENTER);
    changeCrisisStatusBtn1.addStyleName(ValoTheme.BUTTON_PRIMARY);
    Button cancelBtn1 = new Button("Cancel");
    buttonsLayout1.addComponents(changeCrisisStatusBtn1, cancelBtn1);
    buttonsLayout1.setSpacing(true);
    statusLayout.addComponents(crisisID1, crisisStatus, buttonsLayout1);

    cancelBtn1.addClickListener(event -> changeCrisisStatusSubWindow.close());

    changeCrisisStatusBtn1.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());

        EtCrisisStatus statusToPut = null;

        if (crisisStatus.getValue().toString().equals("Pending"))
            statusToPut = EtCrisisStatus.pending;
        if (crisisStatus.getValue().toString().equals("Handled"))
            statusToPut = EtCrisisStatus.handled;
        if (crisisStatus.getValue().toString().equals("Solved"))
            statusToPut = EtCrisisStatus.solved;
        if (crisisStatus.getValue().toString().equals("Closed"))
            statusToPut = EtCrisisStatus.closed;

        PtBoolean res = actCoordinator.oeSetCrisisStatus(new DtCrisisID(new PtString(thisCrisisID.toString())),
                statusToPut);

        changeCrisisStatusSubWindow.close();
    });

    ////////////////////////////////////////

    handleCrisesBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        PtBoolean res = actCoordinator
                .oeSetCrisisHandler(new DtCrisisID(new PtString(thisCrisisID.toString())));
    });

    reportOnCrisisBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        reportCrisisSubWindow.center();
        crisisID.setValue(thisCrisisID.toString());
        crisisID.setEnabled(false);
        reportText.focus();
        UI.getCurrent().addWindow(reportCrisisSubWindow);
    });

    changeCrisisStatusBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        changeCrisisStatusSubWindow.center();
        crisisID1.setValue(thisCrisisID.toString());
        crisisID1.setEnabled(false);
        crisisStatus.focus();
        UI.getCurrent().addWindow(changeCrisisStatusSubWindow);
    });

    closeCrisisBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        PtBoolean res = actCoordinator.oeCloseCrisis(new DtCrisisID(new PtString(thisCrisisID.toString())));
    });

    getCrisesSetBtn.addClickListener(event -> {
        if (crisesStatus.getValue().toString().equals("Closed"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.closed);
        if (crisesStatus.getValue().toString().equals("Handled"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.handled);
        if (crisesStatus.getValue().toString().equals("Solved"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.solved);
        if (crisesStatus.getValue().toString().equals("Pending"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.pending);
    });

    ClickListener logoutAction = event -> {
        PtBoolean res;
        try {
            res = actCoordinator.oeLogout();
            if (res.getValue()) {
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Page.getCurrent().reload();
    };

    logoutBtn1.addClickListener(logoutAction);
    logoutBtn2.addClickListener(logoutAction);
}

From source file:org.esn.esobase.view.MainView.java

private void openSearchInCatalogs() {
    if (searchInCatalogsTabContent == null) {
        searchInCatalogsTabContent = new SearchInCatalogsTab(service, dictionaryService);
    }/*from   www.ja  v a2 s  . c  om*/
    Window subWindow = new Window(searchInCatalogsMenuItem.getText());
    subWindow.setModal(true);

    subWindow.center();
    this.getUI().addWindow(subWindow);
    subWindow.setResizable(false);
    subWindow.setSizeFull();
    subWindow.setContent(searchInCatalogsTabContent);
    searchInCatalogsTabContent.setWidth();
}

From source file:org.esn.esobase.view.MainView.java

private void openSearchInRaw() {
    if (searchInRawStringsTabContent == null) {
        searchInRawStringsTabContent = new SearchInRawStringsTab(service);
    }/*from   www .jav  a  2 s  .  com*/
    Window subWindow = new Window(searchInRawStringsMenuItem.getText());
    subWindow.setModal(true);

    subWindow.center();
    this.getUI().addWindow(subWindow);
    subWindow.setResizable(false);
    subWindow.setSizeFull();
    subWindow.setContent(searchInRawStringsTabContent);
    searchInRawStringsTabContent.setWidth();
}

From source file:org.geant.sat.ui.EntityListViewer.java

License:BSD License

/**
 * Add entity click handler - creates a sub window for user to enter the
 * data.//from   w w w  . ja v  a 2  s. c  o m
 * 
 * @param event
 *            button click event.
 */
private void addEntity(ClickEvent event) {

    // We create a simple window for user to enter entity information
    // no declarative design used, we form it locally
    Window subWindowNewEntity = new Window(getString("lang.window.newentity.title"));
    subWindowNewEntity.setModal(true);
    subWindowNewEntity.setWidth("50%");
    VerticalLayout subContent = new VerticalLayout();
    TextField field = new TextField(getString("lang.window.newentity.textFieldName"));
    field.setWidth("80%");
    subContent.addComponent(field, 0);
    field = new TextField(getString("lang.window.newentity.textFieldDescription"));
    field.setWidth("80%");
    subContent.addComponent(field, 1);
    Button okButton = new Button(getString("lang.window.newentity.buttonCreate"));
    subContent.addComponent(okButton, 2);
    okButton.addClickListener(this::addedEntity);
    Button cancelButton = new Button(getString("lang.window.newentity.buttonCancel"));
    subContent.addComponent(cancelButton, 3);
    cancelButton.addClickListener(this::canceledEntityAdd);
    subWindowNewEntity.setContent(subContent);
    subWindowNewEntity.center();
    getMainUI().addWindow(subWindowNewEntity);

}