Example usage for com.google.gwt.user.client Window confirm

List of usage examples for com.google.gwt.user.client Window confirm

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window confirm.

Prototype

public static boolean confirm(String msg) 

Source Link

Usage

From source file:org.eobjects.datacleaner.monitor.scheduling.widgets.CustomizeJobClickHandler.java

License:Open Source License

@Override
public void onClick(ClickEvent event) {
    final JobIdentifier job = _schedulePanel.getSchedule().getJob();
    final MenuBar menuBar = new MenuBar(true);
    menuBar.addItem("Rename job", new Command() {
        @Override//from   w w w  .  j  a v  a2 s .  c  o  m
        public void execute() {
            final String newName = Window.prompt("Enter job name", job.getName());
            if (newName == null || newName.trim().length() == 0 || newName.equals(job.getName())) {
                return;
            }

            final DCPopupPanel popup = new DCPopupPanel("Renaming...");
            popup.setWidget(new LoadingIndicator());
            popup.center();
            popup.show();

            final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".modify");

            final JSONObject payload = new JSONObject();
            payload.put("name", new JSONString(newName));

            final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url);
            requestBuilder.setHeader("Content-Type", "application/json");
            requestBuilder.send(payload.toString(), new DCRequestCallback() {
                @Override
                protected void onSuccess(Request request, Response response) {
                    Window.Location.reload();
                }

                @Override
                public void onNonSuccesfullStatusCode(Request request, Response response, int statusCode,
                        String statusText) {
                    popup.hide();
                    ErrorHandler.showErrorDialog(response.getText());
                }
            });
        }
    });
    menuBar.addItem("Copy job", new Command() {
        @Override
        public void execute() {
            final String newJobName = Window.prompt("Enter new job name", job.getName() + " (Copy)");

            if (newJobName == null || newJobName.trim().length() == 0 || newJobName.equals(job.getName())) {
                return;
            }

            final DCPopupPanel popup = new DCPopupPanel("Copying...");
            popup.setWidget(new LoadingIndicator());
            popup.center();
            popup.show();

            final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".copy");

            final JSONObject payload = new JSONObject();
            payload.put("name", new JSONString(newJobName));

            final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url);
            requestBuilder.setHeader("Content-Type", "application/json");
            requestBuilder.send(payload.toString(), new DCRequestCallback() {
                @Override
                protected void onSuccess(Request request, Response response) {
                    Window.Location.reload();
                }
            });
        }
    });

    menuBar.addItem("Delete job", new Command() {
        @Override
        public void execute() {
            boolean delete = Window.confirm("Are you sure you want to delete the job '" + job.getName()
                    + "' and related schedule, results and timelines.");
            if (delete) {
                final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".delete");
                final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url);
                requestBuilder.setHeader("Content-Type", "application/json");
                requestBuilder.send("", new DCRequestCallback() {
                    @Override
                    protected void onSuccess(Request request, Response response) {
                        Window.Location.reload();
                    }
                });
            }
        }
    });

    final boolean analysisJob = JobIdentifier.JOB_TYPE_ANALYSIS_JOB.equals(job.getType());

    if (analysisJob) {
        menuBar.addSeparator();

        menuBar.addItem("Job definition (xml)", new Command() {
            @Override
            public void execute() {
                String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".analysis.xml");
                Window.open(url, "datacleaner_job_details", null);
                _popup.hide();
            }
        });
        menuBar.addItem("Show latest result", new Command() {
            @Override
            public void execute() {
                String url = Urls.createRepositoryUrl(_tenant,
                        "results/" + job.getName() + "-latest.analysis.result.dat");
                Window.open(url, "datacleaner_job_details", null);
                _popup.hide();
            }
        });
    }

    _popup.setWidget(menuBar);
    _popup.showRelativeTo((UIObject) event.getSource());
}

From source file:org.eurekastreams.web.client.jsni.WidgetJSNIFacadeImpl.java

License:Apache License

/**
 * Prompt for confirmation.//from  w w  w. j av a  2  s .c om
 *
 * @param prompt
 *            the question to ask.
 * @return the user's response as a boolean.
 */
public boolean confirm(final String prompt) {
    return Window.confirm(prompt);
}

From source file:org.fourthline.konto.client.currency.view.CurrencyViewImpl.java

License:Open Source License

@UiHandler("removeAllButton")
void onClickRemoveAll(ClickEvent e) {
    if (presenter != null && Window.confirm("Are you are you want to remove all exchange rates?")) {
        presenter.removeAll();/*  w  w w  .j  a va 2 s  . c om*/
    }
}

From source file:org.fourthline.konto.client.currency.view.MonetaryUnitViewImpl.java

License:Open Source License

@UiHandler("deleteButton")
void onClickDelete(ClickEvent e) {
    if (presenter != null && Window.confirm("Are you are you want to delete this currency?")) {
        presenter.delete();/*w w w  . j ava  2 s  .c  o  m*/
    }
}

From source file:org.fourthline.konto.client.ledger.account.view.AccountViewImpl.java

License:Open Source License

@UiHandler("deleteButton")
void onClickDelete(ClickEvent e) {
    if (presenter != null && Window
            .confirm("Are you are you want to delete this account? " + "All entries will be deleted!")) {
        presenter.delete();/*from ww w.  j a  va  2 s.c  o m*/
    }
}

From source file:org.fourthline.konto.client.ledger.entry.view.EntryViewImpl.java

License:Open Source License

@UiHandler("deleteButton")
void onClickDeleteEntry(ClickEvent e) {
    if (presenter != null && Window.confirm("Are you are you want to delete the entry?")) {
        presenter.deleteEntry();/*from ww w  . jav  a  2 s . c om*/
    }
}

From source file:org.freemedsoftware.gwt.client.screen.CallInScreen.java

License:Open Source License

public CallInScreen() {
    super(ModuleName);
    final boolean canBook = CurrentState.isActionAllowed(SchedulerWidget.moduleName, AppConstants.WRITE);

    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    initWidget(horizontalPanel);/*from   www  .  j  a v a2s  .  com*/
    horizontalPanel.setSize("100%", "100%");

    final VerticalPanel verticalPanel = new VerticalPanel();
    horizontalPanel.add(verticalPanel);
    verticalPanel.setSize("100%", "100%");

    tabPanel = new TabPanel();
    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            // TODO Auto-generated method stub
            if (event.getSelectedItem() == 1 && formSelection.getWidgetValue().equals("Basic"))
                ((TextBox) basicFormFields.get("cifname")).setFocus(true);
        }
    });
    verticalPanel.add(tabPanel);

    /*
     * final Label callInLabel = new Label("Call-in Patient Management.");
     * verticalPanelMenu.add(callInLabel);
     * callInLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
     */

    final HorizontalPanel headerHPanel = new HorizontalPanel();
    headerHPanel.setWidth("100%");
    verticalPanelMenu.add(headerHPanel);

    final HorizontalPanel menuButtonsPanel = new HorizontalPanel();
    menuButtonsPanel.setSpacing(1);
    headerHPanel.add(menuButtonsPanel);
    if (canDelete || canWrite || canBook) {
        final CustomButton selectAllButton = new CustomButton(_("Select All"), AppConstants.ICON_SELECT_ALL);
        menuButtonsPanel.add(selectAllButton);
        selectAllButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent wvt) {
                Iterator<CheckBox> iter = checkboxStack.keySet().iterator();
                while (iter.hasNext()) {
                    CheckBox t = iter.next();
                    t.setValue(true);
                    callInTable.selectionAdd(checkboxStack.get(t).toString());
                    // }
                }
            }
        });
    }
    if (canDelete || canWrite || canBook) {
        final CustomButton selectNoneButton = new CustomButton(_("Select None"), AppConstants.ICON_SELECT_NONE);
        menuButtonsPanel.add(selectNoneButton);
        selectNoneButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                clearSelection();
            }
        });
    }

    if (canDelete) {
        final CustomButton deleteButton = new CustomButton(_("Delete"), AppConstants.ICON_DELETE);
        menuButtonsPanel.add(deleteButton);
        deleteButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (callInTable.getSelectedCount() < 1)
                    Window.alert(_("Please select at least one entry!"));
                else if (Window.confirm(_("Are you sure you want to delete these item(s)?"))) {
                    List<String> slectedItems = callInTable.getSelected();
                    Iterator<String> itr = slectedItems.iterator();// Get all
                    // selected
                    // items
                    // from
                    // custom
                    // table
                    int totalItems = slectedItems.size();
                    int curItem = 1;
                    while (itr.hasNext())
                        deleteEntry(Integer.parseInt(itr.next()), curItem++, totalItems);// delete
                    // messages
                    // one by
                    // one
                }
            }
        });
    }
    if (canWrite) {
        final CustomButton enterButton = new CustomButton(_("Create Patient"), AppConstants.ICON_ADD_PERSON);
        menuButtonsPanel.add(enterButton);
        enterButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (callInTable.getSelectedCount() < 1)
                    Window.alert(_("Please select at least one entry!"));
                else if (callInTable.getSelectedCount() > 1)
                    Window.alert(_("You can create only a single patient at a time!"));
                else {
                    List<String> slectedItems = callInTable.getSelected();
                    Integer id = Integer.parseInt(slectedItems.get(0));
                    final HashMap<String, String> data = callInTable.getDataById(id);
                    if (data.get("archive") == null || data.get("archive").compareTo("0") == 0) {
                        //                     openPatientForm(id,getCallInScreen());
                        callinConvertFromPatient(id, new CustomCommand() {
                            @Override
                            public void execute(Object id) {
                                populate(null);
                                Util.spawnPatientScreen((Integer) id, data.get("name"));
                            }

                        });
                    } else {
                        Window.alert(_("You can't create patient of archived enteries!"));
                    }
                }
            }
        });
    }

    if (canBook) {
        final CustomButton bookButton = new CustomButton(_("Book"), AppConstants.ICON_BOOK_APP);
        menuButtonsPanel.add(bookButton);
        bookButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (callInTable.getSelectedCount() < 1)
                    Window.alert(_("Please select at least one entry!"));
                else if (callInTable.getSelectedCount() > 1)
                    Window.alert(_("You can book only a single appointment at a time!"));
                else {
                    List<String> slectedItems = callInTable.getSelected();
                    Integer id = Integer.parseInt(slectedItems.get(0));
                    HashMap<String, String> data = callInTable.getDataById(id);
                    if (data.get("archive") == null || data.get("archive").compareTo("0") == 0) {
                        SchedulerScreen schedulerScreen = SchedulerScreen.getInstance();
                        EventData eventData = schedulerScreen.getSchedulerWidget().getNewExternalDataEvent();
                        eventData.setPatientId(id);
                        if (data.get("provider") != null)
                            eventData.setProviderId(Integer.parseInt(data.get("provider")));
                        eventData.setResourceType(AppConstants.APPOINTMENT_TYPE_CALLIN_PATIENT);
                        schedulerScreen.getSchedulerWidget().setExternalDataEvent(eventData);
                        Util.spawnTab(AppConstants.SCHEDULER, schedulerScreen);
                    } else {
                        Window.alert(_("You can't book archived enteries!"));
                    }

                }
            }
        });

        if (canModify) {
            final CustomButton modifyButton = new CustomButton(_("Modify"), AppConstants.ICON_MODIFY);
            menuButtonsPanel.add(modifyButton);
            modifyButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent evt) {
                    if (callInTable.getSelectedCount() < 1)
                        Window.alert(_("Please select an entry!"));
                    else if (callInTable.getSelectedCount() > 1)
                        Window.alert(_("You can modify only a single entry at a time!"));
                    else {
                        List<String> slectedItems = callInTable.getSelected();
                        Integer id = Integer.parseInt(slectedItems.get(0));
                        selectedEntryId = id;
                        HashMap<String, String> data = callInTable.getDataById(id);
                        if (data.get("archive") == null || data.get("archive").compareTo("0") == 0) {
                            tabPanel.selectTab(1);
                            selectedEntryId = id;
                            modifyEntry(selectedEntryId);
                        } else {
                            Util.confirm(_(
                                    "You can not modify an archived record. Do you want to un-archive this record?"),
                                    new Command() {

                                        @Override
                                        public void execute() {
                                            // TODO Auto-generated method stub
                                            unarchiveEntry(selectedEntryId);
                                        }
                                    }, null);
                        }
                    }
                }
            });
        }

    }

    if (canWrite) {
        final CustomButton addEventButton = new CustomButton(_("Add Event"), AppConstants.ICON_ADD);
        menuButtonsPanel.add(addEventButton);
        addEventButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (callInTable.getSelectedCount() < 1)
                    Window.alert(_("Please select an entry!"));
                else if (callInTable.getSelectedCount() > 1)
                    Window.alert(_("You can modify only a single entry at a time!"));
                else {
                    List<String> slectedItems = callInTable.getSelected();
                    Integer id = Integer.parseInt(slectedItems.get(0));
                    HashMap<String, String> data = callInTable.getDataById(id);
                    String name = null;
                    if (data != null && data.get("name") != null) {
                        name = data.get("name");
                    }
                    openAddEventForm(id, name);
                }
            }
        });
    }

    if (canRead) {
        final CustomButton searchButton = new CustomButton(_("Search"), AppConstants.ICON_SEARCH);
        menuButtonsPanel.add(searchButton);
        searchButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                initSearchPopup();
            }
        });
    }

    callInTable = new CustomTable();
    verticalPanelMenu.add(callInTable);
    callInTable.setAllowSelection(false);
    callInTable.setSize("100%", "100%");
    // //what for is this used???To work on this
    callInTable.setIndexName("id");
    // ///
    if (canDelete || canWrite || canBook)
        callInTable.addColumn("", "selected");
    callInTable.addColumn(_("Date"), "call_date_mdy");
    callInTable.addColumn(_("Name"), "name");
    callInTable.addColumn(_("Contact Phone"), "contact_phone");
    callInTable.addColumn(_("Coverage"), "coverage");
    callInTable.addColumn(_("Complaint"), "complaint");

    callInTable.setTableRowClickHandler(new TableRowClickHandler() {
        @Override
        public void handleRowClick(HashMap<String, String> data, int col) {
            try {
                if (col != 0 || !(canBook || canWrite || canDelete)) {
                    final Integer callinId = Integer.parseInt(data.get("id"));
                    showCallinInfo(callinId);

                }
            } catch (Exception e) {
                GWT.log("Caught exception: ", e);
            }
        }
    });

    callInTable.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() {
        public Widget setColumn(String columnName, HashMap<String, String> data) {
            Integer id = Integer.parseInt(data.get("id"));
            if (columnName.compareTo("selected") == 0) {
                CheckBox c = new CheckBox();
                c.addClickHandler(getCallInScreen());
                checkboxStack.put(c, id);
                return c;
            } else if (data.get("archive") != null && data.get("archive").compareTo("1") == 0) {
                Label label = new Label(data.get(columnName));
                label.setStyleName(AppConstants.STYLE_LABEL_ALERT);
                return label;
            }
            return (Widget) null;
        }
    });

    tabPanel.add(verticalPanelMenu, _("Menu"));
    if (canWrite) {
        //         tabPanel.add(createEntryTabBar(), "Entry");
        entryVPanel = new VerticalPanel();
        tabPanel.add(entryVPanel, _("Entry"));
        final HorizontalPanel selectionHPanel = new HorizontalPanel();
        selectionHPanel.setStyleName(AppConstants.STYLE_LABEL_HEADER_SMALL);
        entryVPanel.add(selectionHPanel);
        selectionHPanel.setSpacing(5);
        final Label selectionLabel = new Label(_("Select Form Type") + ":");
        selectionHPanel.add(selectionLabel);
        formSelection = new CustomListBox();
        selectionHPanel.add(formSelection);
        formSelection.addItem("", "");
        formSelection.addItem(_("Basic Entry Form"), "Basic");
        formSelection.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent arg0) {
                handleFormSelection();
            }
        });
    }
    // tabPanel.add(new VerticalPanel(),"Entry");
    tabPanel.selectTab(0);
    // createEntryTabBar();

    // callInTable.formatTable(5);
    // callInTable.getFlexTable().setWidth("100%");

    // //////
    populate(null);
}

From source file:org.freemedsoftware.gwt.client.screen.MessagingScreen.java

License:Open Source License

private MessagingScreen() {
    super(moduleName);
    final VerticalPanel verticalPanel = new VerticalPanel();
    initWidget(verticalPanel);/*from  w  w  w  . j ava 2 s. co m*/
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    verticalPanel.add(horizontalPanel);

    if (canRead) {
        horizontalPanel.add(messageTagSelect);
        messageTagSelect.addChangeHandler(new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                try {
                    String effective = messageTagSelect.getWidgetValue();
                    wMessages.clearAllSelections();
                    populate(effective);
                } catch (Exception ex) {
                    Window.alert(ex.toString());
                }
            }
        });
    }

    if (canWrite) {
        final CustomButton composeButton = new CustomButton(_("Compose"), AppConstants.ICON_COMPOSE_MAIL);
        horizontalPanel.add(composeButton);
        composeButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                final MessagingComposeScreen p = new MessagingComposeScreen();
                p.setParentScreen(getMessagingScreen());
                CurrentState.getTabPanel().add(p, new ClosableTab(_("Compose Message"), p));
                CurrentState.getTabPanel().selectTab(CurrentState.getTabPanel().getWidgetCount() - 1);
            }
        });
    }

    if (canModify) {
        final CustomButton selectButton = new CustomButton(_("Change"), AppConstants.ICON_CHANGE);
        horizontalPanel.add(selectButton);
        selectButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                populate(((CustomListBox) evt.getSource()).getWidgetValue());
            }
        });
    }
    if (canModify) {
        final CustomButton moveButton = new CustomButton(_("Move"), AppConstants.ICON_MOVE_MAIL);
        horizontalPanel.add(moveButton);
        moveButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                Window.alert("STUB: move message(s)");
            }
        });
    }

    if (canRead) {
        final CustomButton selectAllButton = new CustomButton(_("Select All"), AppConstants.ICON_SELECT_ALL);
        horizontalPanel.add(selectAllButton);
        selectAllButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent wvt) {
                Iterator<CheckBox> iter = checkboxStack.keySet().iterator();
                while (iter.hasNext()) {
                    CheckBox t = iter.next();
                    t.setValue(true);
                    if (!selectedItems.contains(checkboxStack.get(t))) {
                        selectedItems.add(checkboxStack.get(t));
                    }
                }
            }
        });
    }
    if (canRead) {
        final CustomButton selectNoneButton = new CustomButton(_("Select None"), AppConstants.ICON_SELECT_NONE);
        horizontalPanel.add(selectNoneButton);
        selectNoneButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                Iterator<CheckBox> iter = checkboxStack.keySet().iterator();
                while (iter.hasNext()) {
                    CheckBox t = iter.next();
                    t.setValue(false);
                    if (selectedItems.contains(checkboxStack.get(t))) {
                        selectedItems.remove(checkboxStack.get(t));
                    }
                }
            }
        });
    }
    if (canDelete) {
        final CustomButton deleteButton = new CustomButton(_("Delete"), AppConstants.ICON_DELETE);
        horizontalPanel.add(deleteButton);
        deleteButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (Window.confirm(_("Are you sure you want to delete these item(s)?"))) {
                    List<String> slectedItems = wMessages.getSelected();
                    // Get all selected items from custom table
                    Iterator<String> itr = slectedItems.iterator();
                    while (itr.hasNext()) {
                        deleteMessage(Integer.parseInt(itr.next()));
                    }
                    populate(messageTagSelect.getWidgetValue());
                }
            }
        });
    }
    final VerticalPanel verticalSplitPanel = new VerticalPanel();
    verticalPanel.add(verticalSplitPanel);
    verticalSplitPanel.setSize("100%", "100%");
    // verticalSplitPanel.setSplitPosition("50%");

    if (canRead) {

        wMessages = new CustomTable();
        // wMessages.setAllowSelection(true);
        // wMessages.setMultipleSelection(true);
        verticalSplitPanel.add(wMessages);
        wMessages.setSize("100%", "100%");
        wMessages.addColumn(_("Selected"), "selected");
        wMessages.addColumn(_("Received"), "stamp"); // col 1
        wMessages.addColumn(_("From"), "from_user"); // col 2
        wMessages.addColumn(_("Subject"), "subject"); // col 3
        // wMessages.addColumn(_("Delete"), "delete"); // col 4
        wMessages.setIndexName("id");
        wMessages.setTableRowClickHandler(new TableRowClickHandler() {
            @Override
            public void handleRowClick(HashMap<String, String> data, int col) {
                try {
                    final Integer messageId = Integer.parseInt(data.get("id"));
                    if (col == 4) {
                        deleteMessage(messageId);
                    } else if (col != 0) {
                        showMessage(messageId);
                        msgView = new MessageView();
                        msgView.setMessageId(messageId);
                        msgView.setMsgFrom(data.get("from_user"));
                        msgView.setMsgDate(data.get("stamp"));
                        msgView.setText(msgView.createMessageHtml(data.get("from_user"), data.get("stamp"),
                                data.get("subject"), data.get("content")));
                        // showMessage(messageId);
                        msgView.setMessagingScreen(getMessagingScreen());
                        popupMessageView = new Popup();
                        popupMessageView.setNewWidget(msgView);
                        msgView.setOnClose(new Command() {
                            public void execute() {
                                popupMessageView.hide();
                            }
                        });
                        popupMessageView.initialize();

                    }
                } catch (Exception e) {
                    GWT.log("Caught exception: ", e);
                }
            }
        });
        wMessages.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() {
            public Widget setColumn(String columnName, HashMap<String, String> data) {
                Integer id = Integer.parseInt(data.get("id"));
                if (columnName.compareTo("selected") == 0) {
                    CheckBox c = new CheckBox();
                    c.addClickHandler(getMessagingScreen());
                    checkboxStack.put(c, id);
                    return c;
                } else {
                    return (Widget) null;
                }
            }
        });
    }
    // verticalSplitPanel.setSize("100%", "100%");

    // Start population routine
    populate("");
    populateTagWidget();

    // Register on the event bus
    CurrentState.getEventBus().addHandler(SystemEvent.TYPE, this);
}

From source file:org.freemedsoftware.gwt.client.screen.PatientsGroupScreen.java

License:Open Source License

public PatientsGroupScreen() {
    super(ModuleName);
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    initWidget(horizontalPanel);/*from  www.j a v  a2 s.  c om*/
    horizontalPanel.setSize("100%", "100%");

    final VerticalPanel verticalPanel = new VerticalPanel();
    horizontalPanel.add(verticalPanel);
    verticalPanel.setSize("100%", "100%");
    tabPanel = new TabPanel();
    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            // TODO Auto-generated method stub
            if (event.getSelectedItem() == 1)
                groupName.setFocus(true);
        }
    });

    verticalPanel.add(tabPanel);

    /*
     * final Label callInLabel = new Label("Call-in Patient Management.");
     * verticalPanelMenu.add(callInLabel);
     * callInLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
     */

    final HorizontalPanel menuButtonsPanel = new HorizontalPanel();
    menuButtonsPanel.setSpacing(1);
    if (canDelete || canWrite || canBook) {
        final CustomButton selectAllButton = new CustomButton(_("Select All"), AppConstants.ICON_SELECT_ALL);
        menuButtonsPanel.add(selectAllButton);
        selectAllButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent wvt) {
                Iterator<CheckBox> iter = checkboxStack.keySet().iterator();
                while (iter.hasNext()) {
                    CheckBox t = iter.next();
                    t.setValue(true);
                    patientGroupTable.selectionAdd(checkboxStack.get(t).toString());
                    // }
                }
            }
        });
    }

    if (canDelete || canWrite || canBook) {
        final CustomButton selectNoneButton = new CustomButton(_("Select None"), AppConstants.ICON_SELECT_NONE);
        menuButtonsPanel.add(selectNoneButton);
        selectNoneButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                Iterator<CheckBox> iter = checkboxStack.keySet().iterator();
                while (iter.hasNext()) {
                    CheckBox t = iter.next();
                    t.setValue(false);
                    patientGroupTable.selectionRemove(checkboxStack.get(t).toString());
                }
            }
        });
    }

    if (canBook) {
        final CustomButton bookButton = new CustomButton(_("Book"), AppConstants.ICON_BOOK_APP);
        menuButtonsPanel.add(bookButton);
        bookButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (patientGroupTable.getSelectedCount() < 1)
                    Window.alert(_("Please select at least one entry."));
                else {
                    List<String> slectedItems = patientGroupTable.getSelected();
                    SchedulerScreen schedulerScreen = SchedulerScreen.getInstance();
                    EventData eventData = schedulerScreen.getSchedulerWidget().getNewExternalDataEvent();
                    eventData.setPatientId(Integer.parseInt(slectedItems.get(0)));
                    eventData.setResourceType(AppConstants.APPOINTMENT_TYPE_GROUP);
                    schedulerScreen.getSchedulerWidget().setExternalDataEvent(eventData);
                    Util.spawnTab(AppConstants.SCHEDULER, schedulerScreen);
                }
            }
        });
    }

    if (canModify) {
        final CustomButton modifyButton = new CustomButton("Modify", AppConstants.ICON_MODIFY);
        menuButtonsPanel.add(modifyButton);
        modifyButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (patientGroupTable.getSelectedCount() < 1)
                    Window.alert(_("Please select an entry."));
                else if (patientGroupTable.getSelectedCount() > 1)
                    Window.alert(_("You can modify only a single entry at a time."));
                else {
                    List<String> slectedItems = patientGroupTable.getSelected();
                    Iterator<String> itr = slectedItems.iterator();// Get all
                    // selected
                    // items
                    // from
                    // custom
                    // table
                    tabPanel.selectTab(1);
                    groupName.setFocus(true);
                    btnAdd.setText(_("Modify"));
                    selectedEntryId = Integer.parseInt(itr.next());
                    modifyEntry(selectedEntryId);
                }
            }
        });
    }

    if (canDelete) {
        final CustomButton deleteButton = new CustomButton(_("Delete"), AppConstants.ICON_DELETE);
        menuButtonsPanel.add(deleteButton);
        deleteButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (patientGroupTable.getSelectedCount() < 1)
                    Window.alert(_("Please select at least one entry."));
                else if (Window.confirm(_("Are you sure you want to delete these item(s)?"))) {
                    List<String> slectedItems = patientGroupTable.getSelected();
                    Iterator<String> itr = slectedItems.iterator();// Get all
                    // selected
                    // items
                    // from
                    // custom
                    // table
                    while (itr.hasNext())
                        deleteEntry(Integer.parseInt(itr.next()));// delete
                    // messages
                    // one by
                    // one
                    populate();
                }
            }
        });
    }

    verticalPanelMenu.add(menuButtonsPanel);
    patientGroupTable = new CustomTable();
    verticalPanelMenu.add(patientGroupTable);
    patientGroupTable.setAllowSelection(false);
    patientGroupTable.setSize("100%", "100%");
    // //what for is this used???To work on this
    patientGroupTable.setIndexName("id");
    // ///
    if (canBook || canDelete)
        patientGroupTable.addColumn(_("Selected"), "selected");

    patientGroupTable.addColumn(_("Group Name"), "groupname");
    patientGroupTable.addColumn(_("Group Facility"), "groupfacility");
    patientGroupTable.addColumn(_("Group Frequency (in days)"), "groupfrequency");
    patientGroupTable.addColumn(_("Group Length (min)"), "grouplength");

    patientGroupTable.setTableRowClickHandler(new TableRowClickHandler() {
        @Override
        public void handleRowClick(HashMap<String, String> data, int col) {
            try {
                if (col != 0)
                    showGroupInfo(Integer.parseInt(data.get("id")));
            } catch (Exception e) {
                GWT.log("Caught exception: ", e);
            }
        }
    });

    patientGroupTable.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() {
        public Widget setColumn(String columnName, HashMap<String, String> data) {
            Integer id = Integer.parseInt(data.get("id"));
            if (columnName.compareTo("selected") == 0) {
                CheckBox c = new CheckBox();
                c.addClickHandler(getPatientGroupScreen());
                checkboxStack.put(c, id);
                return c;
            } else {
                return (Widget) null;
            }
        }
    });

    tabPanel.add(verticalPanelMenu, _("Menu"));
    if (canWrite)
        tabPanel.add(createEntryTabBar(), _("Entry"));

    // tabPanel.add(new VerticalPanel(),"Entry");
    tabPanel.selectTab(0);
    // createEntryTabBar();

    // patientGroupTable.formatTable(5);
    // patientGroupTable.getFlexTable().setWidth("100%");

    // //////
    populate();
}

From source file:org.freemedsoftware.gwt.client.Util.java

License:Open Source License

/**
 * Generates Report To Printer/*www .j  ava  2s .co m*/
 * 
 * @param reportName
 *            - Report name (stored in reporting table)
 * 
 * @param format
 *            - format (pdf,html etc)
 * 
 * @param reportParams
 *            - list of parameters of any type or multi-type
 * 
 * @param saveFailed
 *            - if true then saves failed reports into printing log
 * 
 */

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void generateReportToPrinter(final String reportName, final String format,
        final List<String> reportParams, final boolean saveFailed) {

    List paramsList = new ArrayList();
    paramsList.add(reportName);
    callModuleMethod("Reporting", "GetReport", paramsList, new CustomRequestCallback() {

        @Override
        public void onError() {

        }

        @Override
        public void jsonifiedData(Object data) {
            if (data != null) {
                List paramsList = new ArrayList();
                paramsList.add(data.toString());
                paramsList.add(format);
                paramsList.add(reportParams.toArray(new String[0]));
                paramsList.add("true");

                callModuleMethod("Reporting", "GenerateReport", paramsList, new CustomRequestCallback() {

                    @Override
                    public void onError() {

                    }

                    @Override
                    public void jsonifiedData(Object data) {
                        if (data != null) {
                            if (!data.toString().equals("PRINTED") && saveFailed)
                                saveFailedReports(reportName, format, reportParams);
                            if (data.toString().equals("DPNS")) {
                                if (Window.confirm(_("Default printer not found,") + "\n"
                                        + _("Press Ok to set default printer.")))
                                    Util.spawnTab("Preferences", PreferencesScreen.getInstance());
                            } else if (data.toString().equals("PNA")) {
                                showErrorMsg("Reporting", _("Printer not available."));
                            }
                        }
                    }

                }, "String");
            } else {
                showErrorMsg("reporting", _("Report not found."));
            }
        }

    }, "String");

}