Example usage for org.eclipse.jface.dialogs MessageDialog ERROR

List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog ERROR.

Prototype

int ERROR

To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.

Click Source Link

Document

Constant for the error image, or a simple dialog with the error image and a single OK button (value 1).

Usage

From source file:org.celllife.idart.gui.patient.PatientIdentifierDialog.java

License:Open Source License

private boolean fieldsOk() {
    boolean allEmpty = true;
    for (PatientIdentifier newId : identiers) {
        if (newId.getValueEdit() == null || newId.getValueEdit().isEmpty())
            continue;

        allEmpty = false;//  w w  w  . ja  v a 2s.  com

        String illegalText = iDARTUtil.checkPatientId(newId.getValueEdit());
        if (illegalText != null) {
            showMessage(MessageDialog.ERROR,
                    MessageFormat.format(Messages.getString("patient.error.badCharacterInPatientId.title"), //$NON-NLS-1$
                            illegalText),
                    MessageFormat.format(Messages.getString("patient.error.badCharacterInPatientId"), //$NON-NLS-1$
                            iDartProperties.illegalPatientIdChars));
            return false;
        }

        if (PatientManager.checkPatientIdentifier(getHSession(), newId.getPatient(), newId.getType(),
                newId.getValueEdit())) {
            showMessage(MessageDialog.ERROR, Messages.getString("PatientIdDialog.error.exists.title"), //$NON-NLS-1$
                    MessageFormat.format(Messages.getString("PatientIdDialog.error.exists.message"), //$NON-NLS-1$
                            newId.getType().getName(), newId.getValueEdit()));
            return false;
        }

        List<Patient> altPatients = PatientManager.getPatientsByAltId(getHSession(), newId.getType(),
                newId.getValueEdit());
        if (!altPatients.isEmpty()) {
            String patientsWithThisOldId = EMPTY;
            for (Patient p : altPatients) {
                patientsWithThisOldId += (p.getPatientId() + ", "); //$NON-NLS-1$
            }
            patientsWithThisOldId = patientsWithThisOldId.substring(0, patientsWithThisOldId.length() - 2);

            MessageBox mSave = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);
            mSave.setText(Messages.getString("patient.warning.saveDuplicateId.title")); //$NON-NLS-1$
            mSave.setMessage(MessageFormat.format(Messages.getString("patient.warning.saveDuplicateId"), //$NON-NLS-1$
                    patientsWithThisOldId));
            if (mSave.open() != SWT.YES) {
                return false;
            }
        }
    }

    if (allEmpty) {
        showMessage(MessageDialog.ERROR, Messages.getString("PatientIdDialog.error.empty.title"), //$NON-NLS-1$
                Messages.getString("PatientIdDialog.error.empyt.message")); //$NON-NLS-1$
        return false;
    }

    return true;
}

From source file:org.celllife.idart.gui.patient.PatientIdentifierDialogOpenMrs.java

License:Open Source License

private boolean fieldsOk() {
    boolean allEmpty = true;
    for (PatientIdentifier newId : identiers) {
        if (newId.getValueEdit() == null || newId.getValueEdit().isEmpty())
            continue;

        allEmpty = false;//ww w  .  j  a  v a  2  s .com

        String illegalText = iDARTUtil.checkPatientId(newId.getValueEdit());
        if (illegalText != null) {
            showMessage(MessageDialog.ERROR,
                    MessageFormat.format(Messages.getString("patient.error.badCharacterInPatientId.title"), //$NON-NLS-1$
                            illegalText),
                    MessageFormat.format(Messages.getString("patient.error.badCharacterInPatientId"), //$NON-NLS-1$
                            iDartProperties.illegalPatientIdChars));
            return false;
        }

        if (PatientManager.checkPatientIdentifier(getHSession(), newId.getPatient(), newId.getType(),
                newId.getValueEdit())) {
            showMessage(MessageDialog.ERROR, Messages.getString("PatientIdDialog.error.exists.title"), //$NON-NLS-1$
                    MessageFormat.format(Messages.getString("PatientIdDialog.error.exists.message"), //$NON-NLS-1$
                            newId.getType().getName(), newId.getValueEdit()));
            return false;
        }

        //Validate NID format against OpenMRS
        if (!(newId.getValueEdit().matches("[0-9]{8}/[0-9]{2}/[0-9]{4,5}"))) {
            showMessage(MessageDialog.ERROR, "Formato de NID incorrecto",
                    "O valor introduzido no obedece a estrutura de um NID");
            return false;
        }

        restClient = new RestClient();

        //Verificar se o NID existe no OpenMRS
        String openMrsResource = restClient.getOpenMRSResource(
                iDartProperties.REST_GET_PATIENT + StringUtils.replace(newId.getValueEdit(), " ", "%20"));

        if (openMrsResource.length() > 14) {
            showMessage(MessageDialog.ERROR, "Informao no encontrada",
                    "NID inserido j existe no OpenMRS");
            return false;
        }

        List<Patient> altPatients = PatientManager.getPatientsByAltId(getHSession(), newId.getType(),
                newId.getValueEdit());
        if (!altPatients.isEmpty()) {
            String patientsWithThisOldId = EMPTY;
            for (Patient p : altPatients) {
                patientsWithThisOldId += (p.getPatientId() + ", "); //$NON-NLS-1$
            }
            patientsWithThisOldId = patientsWithThisOldId.substring(0, patientsWithThisOldId.length() - 2);

            MessageBox mSave = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);
            mSave.setText(Messages.getString("patient.warning.saveDuplicateId.title")); //$NON-NLS-1$
            mSave.setMessage(MessageFormat.format(Messages.getString("patient.warning.saveDuplicateId"), //$NON-NLS-1$
                    patientsWithThisOldId));
            if (mSave.open() != SWT.YES) {
                return false;
            }
        }
    }

    if (allEmpty) {
        showMessage(MessageDialog.ERROR, Messages.getString("PatientIdDialog.error.empty.title"), //$NON-NLS-1$
                Messages.getString("PatientIdDialog.error.empyt.message")); //$NON-NLS-1$
        return false;
    }

    return true;
}

From source file:org.celllife.idart.gui.reportParameters.CohortDrugCollections.java

License:Open Source License

@Override
protected void cmdViewReportWidgetSelected() {

    if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;/*from   w  w w. j  av a2s .  c o  m*/
    }

    SafeSaveDialog dialog = new SafeSaveDialog(getShell(), FileType.EXCEL);
    String path = "";
    dialog.setFileName("Cohort_Drug_Collections_report");
    path = dialog.open();

    if (path != null) {
        ExcelReportObject reportObject = getColumnsFromTables(path);
        EntitySet patients = getPatientSet(reportObject);
        if (patients.size() <= 0) {
            showMessage(MessageDialog.INFORMATION, "No patients", "No patients have a '"
                    + Episode.REASON_NEW_PATIENT + "' episode starting between the selected dates");
            return;
        }
        viewReport(new ExcelReportJob(reportObject, new RowPerPatientExcelExporter(patients)));
        showMessage(MessageDialog.INFORMATION, "Report complete",
                "Report generation complete.\n\n" + reportObject.getPath());
    }
}

From source file:org.celllife.idart.gui.reportParameters.CotrimoxazolReport.java

License:Open Source License

@SuppressWarnings("unused")
@Override/*from ww  w .j av a2s.c  o  m*/
protected void cmdViewReportWidgetSelected() {

    if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;
    }

    else {
        try {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");

            Date theStartDate = calendarStart.getCalendar().getTime();

            Date theEndDate = calendarEnd.getCalendar().getTime();

            //theStartDate = sdf.parse(strTheDate);

            CCotrimoxazolReport report = new CCotrimoxazolReport(getShell(), theStartDate, theEndDate);
            viewReport(report);
        } catch (Exception e) {
            getLog().error("Exception while running Cotrimoxazol report", e);
        }
    }

}

From source file:org.celllife.idart.gui.reportParameters.DispensaTrimestralReport.java

License:Open Source License

@SuppressWarnings("unused")
@Override//  w  ww. j  a  v a 2  s . co  m
protected void cmdViewReportWidgetSelected() {

    StockCenter pharm = AdministrationManager.getStockCenter(getHSession(), cmbStockCenter.getText());

    if (cmbStockCenter.getText().equals("")) {

        MessageBox missing = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        missing.setText("No Pharmacy Was Selected");
        missing.setMessage(
                "No pharmacy was selected. Please select a pharmacy by looking through the list of available pharmacies.");
        missing.open();

    } else if (pharm == null) {

        MessageBox missing = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        missing.setText("Pharmacy not found");
        missing.setMessage("There is no pharmacy called '" + cmbStockCenter.getText()
                + "' in the database. Please select a pharmacy by looking through the list of available pharmacies.");
        missing.open();

    } else if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;
    } else {
        try {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");

            //            String strTheDate = "" + cmbYear.getText() + "-"
            //            + cmbMonth.getText() + "-01";
            Date theStartDate = calendarStart.getCalendar().getTime();

            Date theEndDate = calendarEnd.getCalendar().getTime();

            //theStartDate = sdf.parse(strTheDate);
            DispensaTrimestral report = new DispensaTrimestral(getShell(), theStartDate, theEndDate);
            viewReport(report);
        } catch (Exception e) {
            getLog().error("Exception while running Monthly Receipts and Issues report", e);

        }
    }

}

From source file:org.celllife.idart.gui.reportParameters.DrugsDispensed.java

License:Open Source License

@Override
protected void cmdViewReportWidgetSelected() {

    if (cmbPharmacy.getText().equals("")) {
        showMessage(MessageDialog.ERROR, "No Pharmacy Was Selected",
                "No pharmacy was selected. Please select a pharmacy by looking through the list of available pharmacies.");
        return;//from   w  w w.j a v a  2 s  .co  m
    }

    StockCenter pharm = AdministrationManager.getStockCenter(getHSession(), cmbPharmacy.getText());

    if (pharm == null) {
        showMessage(MessageDialog.ERROR, "Pharmacy not found", "There is no pharmacy called '"
                + cmbPharmacy.getText()
                + "' in the database. Please select a pharmacy by looking through the list of available pharmacies.");
        return;
    }

    if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;
    }

    SafeSaveDialog dialog = new SafeSaveDialog(getShell(), FileType.EXCEL);
    String path = "";
    dialog.setFileName("Drugs_Dispensed_Report");
    path = dialog.open();

    if (path != null) {
        ExcelReportObject reportObject = getColumnsFromTables(path);
        viewReport(new ExcelReportJob(reportObject, new RowPerPackageExcelExporter()));
        showMessage(MessageDialog.INFORMATION, "Report complete",
                "Report generation complete.\n\n" + reportObject.getPath());
    }
}

From source file:org.celllife.idart.gui.reportParameters.FilaGeralReport.java

License:Open Source License

@SuppressWarnings("unused")
@Override/*from   w w w. j a v  a2  s .  c  o  m*/
protected void cmdViewReportWidgetSelected() {

    if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;
    }

    else {
        try {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");

            Date theStartDate = calendarStart.getCalendar().getTime();

            Date theEndDate = calendarEnd.getCalendar().getTime();
            //theStartDate = sdf.parse(strTheDate);
            FilaGeralReporter report = new FilaGeralReporter(getShell(), theStartDate, theEndDate);
            viewReport(report);
        } catch (Exception e) {
            getLog().error("Exception while running FILA GERAL report", e);
        }
    }

}

From source file:org.celllife.idart.gui.reportParameters.HistoricoLevantamentos.java

License:Open Source License

@SuppressWarnings("unused")
@Override/*  www .j  av a  2  s.c  o m*/
protected void cmdViewReportWidgetSelected() {

    if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;
    }

    if (chkBtnInicio.getSelection() == false && chkBtnManutencao.getSelection() == false
            && chkBtnAlteraccao.getSelection() == false) {

        showMessage(MessageDialog.ERROR, "Seleccionar Tipo Tarv", "Seleccione pelo menos um tipo TARV.");
        return;

    }

    else {
        try {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");

            Date theStartDate = calendarStart.getCalendar().getTime();

            Date theEndDate = calendarEnd.getCalendar().getTime();

            //theStartDate = sdf.parse(strTheDate);

            HHistoricoLevantamentos report = new HHistoricoLevantamentos(getShell(), theStartDate, theEndDate,
                    chkBtnInicio.getSelection(), chkBtnManutencao.getSelection(),
                    chkBtnAlteraccao.getSelection());
            viewReport(report);
        } catch (Exception e) {
            getLog().error("Exception while running Historico levantamento report", e);
        }
    }

}

From source file:org.celllife.idart.gui.reportParameters.IsoniazidaReport.java

License:Open Source License

@SuppressWarnings("unused")
@Override//from w  ww .  ja  va2 s. c o  m
protected void cmdViewReportWidgetSelected() {

    if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;
    }

    else {
        try {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");

            Date theStartDate = calendarStart.getCalendar().getTime();

            Date theEndDate = calendarEnd.getCalendar().getTime();

            //theStartDate = sdf.parse(strTheDate);

            IIsoniazidaReport report = new IIsoniazidaReport(getShell(), theStartDate, theEndDate);
            viewReport(report);
        } catch (Exception e) {
            getLog().error("Exception while running Isoniazida report", e);
        }
    }

}

From source file:org.celllife.idart.gui.reportParameters.LivroEletronicoDispensaARV.java

@SuppressWarnings("unused")
@Override/*from ww  w.  ja  v a  2  s.  c o m*/
protected void cmdViewReportWidgetSelected() {

    StockCenter pharm = AdministrationManager.getStockCenter(getHSession(), cmbStockCenter.getText());

    if (cmbStockCenter.getText().equals("")) {

        MessageBox missing = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        missing.setText("No Pharmacy Was Selected");
        missing.setMessage(
                "No pharmacy was selected. Please select a pharmacy by looking through the list of available pharmacies.");
        missing.open();

    } else if (pharm == null) {

        MessageBox missing = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        missing.setText("Pharmacy not found");
        missing.setMessage("There is no pharmacy called '" + cmbStockCenter.getText()
                + "' in the database. Please select a pharmacy by looking through the list of available pharmacies.");
        missing.open();

    }

    else

    if (iDARTUtil.before(calendarEnd.getCalendar().getTime(), calendarStart.getCalendar().getTime())) {
        showMessage(MessageDialog.ERROR, "End date before start date",
                "You have selected an end date that is before the start date.\nPlease select an end date after the start date.");
        return;
    }

    else {
        try {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");

            Date theStartDate = calendarStart.getCalendar().getTime();

            Date theEndDate = calendarEnd.getCalendar().getTime();

            LivroEletronicoDispensaARVReport report = new LivroEletronicoDispensaARVReport(getShell(), pharm,
                    theStartDate, theEndDate);
            viewReport(report);
        } catch (Exception e) {
            getLog().error("Exception while running Monthly Receipts and Issues report", e);
        }
    }

}