Example usage for java.lang Character equals

List of usage examples for java.lang Character equals

Introduction

In this page you can find the example usage for java.lang Character equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object against the specified object.

Usage

From source file:ffx.potential.utils.PotentialsFileOpener.java

/**
 * At present, parses the PDB, XYZ, INT, or ARC file from the constructor
 * and creates MolecularAssembly and properties objects.
 *///from   w  w  w. j a  va  2 s. c om
@Override
public void run() {
    int numFiles = allFiles.length;
    for (int i = 0; i < numFiles; i++) {
        File fileI = allFiles[i];
        Path pathI = allPaths[i];
        MolecularAssembly assembly = new MolecularAssembly(pathI.toString());
        assembly.setFile(fileI);
        CompositeConfiguration properties = Keyword.loadProperties(fileI);
        ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties);
        ForceField forceField = forceFieldFilter.parse();
        String patches[] = properties.getStringArray("patch");
        for (String patch : patches) {
            logger.info(" Attempting to read force field patch from " + patch + ".");
            CompositeConfiguration patchConfiguration = new CompositeConfiguration();
            try {
                patchConfiguration.addProperty("propertyFile", fileI.getCanonicalPath());
            } catch (IOException e) {
                logger.log(Level.INFO, " Error loading {0}.", patch);
            }
            patchConfiguration.addProperty("parameters", patch);
            forceFieldFilter = new ForceFieldFilter(patchConfiguration);
            ForceField patchForceField = forceFieldFilter.parse();
            forceField.append(patchForceField);
            if (RotamerLibrary.addRotPatch(patch)) {
                logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
            }
        }
        assembly.setForceField(forceField);
        if (new PDBFileFilter().acceptDeep(fileI)) {
            filter = new PDBFilter(fileI, assembly, forceField, properties);
        } else if (new XYZFileFilter().acceptDeep(fileI)) {
            filter = new XYZFilter(fileI, assembly, forceField, properties);
        } else if (new INTFileFilter().acceptDeep(fileI) || new ARCFileFilter().accept(fileI)) {
            filter = new INTFilter(fileI, assembly, forceField, properties);
        } else {
            throw new IllegalArgumentException(
                    String.format(" File %s could not be recognized as a valid PDB, XYZ, INT, or ARC file.",
                            pathI.toString()));
        }
        if (filter.readFile()) {
            if (!(filter instanceof PDBFilter)) {
                Utilities.biochemistry(assembly, filter.getAtomList());
            }
            filter.applyAtomProperties();
            assembly.finalize(true, forceField);
            //ForceFieldEnergy energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints());
            ForceFieldEnergy energy;
            if (nThreads > 0) {
                energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints(), nThreads);
            } else {
                energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints());
            }
            assembly.setPotential(energy);
            assemblies.add(assembly);
            propertyList.add(properties);

            if (filter instanceof PDBFilter) {
                PDBFilter pdbFilter = (PDBFilter) filter;
                List<Character> altLocs = pdbFilter.getAltLocs();
                if (altLocs.size() > 1 || altLocs.get(0) != ' ') {
                    StringBuilder altLocString = new StringBuilder("\n Alternate locations found [ ");
                    for (Character c : altLocs) {
                        // Do not report the root conformer.
                        if (c == ' ') {
                            continue;
                        }
                        altLocString.append(format("(%s) ", c));
                    }
                    altLocString.append("]\n");
                    logger.info(altLocString.toString());
                }

                /**
                 * Alternate conformers may have different chemistry, so
                 * they each need to be their own MolecularAssembly.
                 */
                for (Character c : altLocs) {
                    if (c.equals(' ') || c.equals('A')) {
                        continue;
                    }
                    MolecularAssembly newAssembly = new MolecularAssembly(pathI.toString());
                    newAssembly.setForceField(assembly.getForceField());
                    pdbFilter.setAltID(newAssembly, c);
                    pdbFilter.clearSegIDs();
                    if (pdbFilter.readFile()) {
                        String fileName = assembly.getFile().getAbsolutePath();
                        newAssembly.setName(FilenameUtils.getBaseName(fileName) + " " + c);
                        filter.applyAtomProperties();
                        newAssembly.finalize(true, assembly.getForceField());
                        //energy = new ForceFieldEnergy(newAssembly, filter.getCoordRestraints());
                        if (nThreads > 0) {
                            energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints(), nThreads);
                        } else {
                            energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints());
                        }
                        newAssembly.setPotential(energy);
                        assemblies.add(newAssembly);
                    }
                }
            }
        } else {
            logger.warning(String.format(" Failed to read file %s", fileI.toString()));
        }
    }
    activeAssembly = assemblies.get(0);
    activeProperties = propertyList.get(0);
}

From source file:uk.ac.ebi.embl.api.translation.Translator.java

private byte[] validateTranslationExceptions(byte[] sequence) throws ValidationException {
    int bases = sequence.length;
    Iterator<Integer> itr = translationExceptionMap.keySet().iterator();
    while (itr.hasNext()) {
        TranslationException translationException = translationExceptionMap.get(itr.next());
        int beginPos = translationException.beginPosition;
        int endPos;
        if (translationException.endPosition == null) {
            endPos = beginPos;/*w  ww  .j  a va2s . c  o m*/
        } else {
            endPos = translationException.endPosition;
        }

        Character aminoAcid = translationException.aminoAcid;
        if (beginPos < codonStart) {
            // Translation exception outside frame on the 5' end.
            ValidationException.throwError("Translator-4");
        }
        if (beginPos > bases) {
            // Translation exception outside frame on the 3' end.
            ValidationException.throwError("Translator-6");
        }
        if (endPos < beginPos) {
            // Invalid translation exception range.
            ValidationException.throwError("Translator-7");
        }
        if (!(endPos == beginPos + 2) && !(endPos == beginPos + 1 && endPos == bases && aminoAcid.equals('*'))
                && !(endPos == beginPos && endPos == bases && aminoAcid.equals('*'))) {
            // Translation exception must span 3 bases or be a partial stop codon at 3' end.
            ValidationException.throwError("Translator-8");
        }
        if (endPos > bases) {
            // Translation exception outside frame on the 3' end.
            ValidationException.throwError("Translator-6");
        }
        int translationExceptionCodonStart = beginPos % 3;
        if (translationExceptionCodonStart == 0) {
            translationExceptionCodonStart = 3;
        }
        if (translationExceptionCodonStart != codonStart) {
            // Translation exception is in different frame.
            ValidationException.throwError("Translator-9", beginPos, translationExceptionCodonStart,
                    codonStart);
        }
        // Extend 3' partial stop codon.
        if (endPos == beginPos + 1 && aminoAcid.equals('*')) {
            sequence = Arrays.copyOf(sequence, bases + 1);
            sequence[bases] = 'n';
        } else if (endPos == beginPos && aminoAcid.equals('*')) {
            sequence = Arrays.copyOf(sequence, bases + 2);
            sequence[bases] = 'n';
            sequence[bases + 1] = 'n';
        }
    }
    return sequence;
}

From source file:com.marand.thinkmed.medications.business.impl.TherapyDisplayProvider.java

public String getFormattedDecimalValue(final String decimalValue, final Locale locale, final boolean bold) {
    if (decimalValue == null || locale == null) {
        return "";
    }/*from   w  w w .  j  av a2  s  . c  o m*/
    final DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
    final Character decimalSeparator = dfs.getDecimalSeparator();
    final String splitDelimiter = decimalSeparator.equals(new Character('.')) ? "\\." : ",";

    String formattedValue = decimalValue;
    final Pattern p = Pattern.compile("\\d+" + splitDelimiter + "\\d+"); // or ("[0-9]+" + splitDelimiter + "[0-9]+") ?
    final Matcher m = p.matcher(formattedValue);
    while (m.find()) {
        final String[] decimalNumbers = m.group().split(splitDelimiter);
        if (decimalNumbers.length == 2) {
            formattedValue = formattedValue.replaceAll(m.group(),
                    decimalNumbers[0] + splitDelimiter + createSpannedValue(decimalNumbers[1],
                            "TextDataSmallerDecimal" + (bold ? " bold" : ""), false));
        }
    }
    return formattedValue;
}

From source file:org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.java

@SuppressWarnings("nls")
public static String unescapeSQLString(String b) {
    Character enclosure = null;

    // Some of the strings can be passed in as unicode. For example, the
    // delimiter can be passed in as \002 - So, we first check if the
    // string is a unicode number, else go back to the old behavior
    StringBuilder sb = new StringBuilder(b.length());
    for (int i = 0; i < b.length(); i++) {

        char currentChar = b.charAt(i);
        if (enclosure == null) {
            if (currentChar == '\'' || b.charAt(i) == '\"') {
                enclosure = currentChar;
            }//from  ww w  .ja  v  a 2 s  .  c om
            // ignore all other chars outside the enclosure
            continue;
        }

        if (enclosure.equals(currentChar)) {
            enclosure = null;
            continue;
        }

        if (currentChar == '\\' && (i + 6 < b.length()) && b.charAt(i + 1) == 'u') {
            int code = 0;
            int base = i + 2;
            for (int j = 0; j < 4; j++) {
                int digit = Character.digit(b.charAt(j + base), 16);
                code = (code << 4) + digit;
            }
            sb.append((char) code);
            i += 5;
            continue;
        }

        if (currentChar == '\\' && (i + 4 < b.length())) {
            char i1 = b.charAt(i + 1);
            char i2 = b.charAt(i + 2);
            char i3 = b.charAt(i + 3);
            if ((i1 >= '0' && i1 <= '1') && (i2 >= '0' && i2 <= '7') && (i3 >= '0' && i3 <= '7')) {
                byte bVal = (byte) ((i3 - '0') + ((i2 - '0') * 8) + ((i1 - '0') * 8 * 8));
                byte[] bValArr = new byte[1];
                bValArr[0] = bVal;
                String tmp = new String(bValArr);
                sb.append(tmp);
                i += 3;
                continue;
            }
        }

        if (currentChar == '\\' && (i + 2 < b.length())) {
            char n = b.charAt(i + 1);
            switch (n) {
            case '0':
                sb.append("\0");
                break;
            case '\'':
                sb.append("'");
                break;
            case '"':
                sb.append("\"");
                break;
            case 'b':
                sb.append("\b");
                break;
            case 'n':
                sb.append("\n");
                break;
            case 'r':
                sb.append("\r");
                break;
            case 't':
                sb.append("\t");
                break;
            case 'Z':
                sb.append("\u001A");
                break;
            case '\\':
                sb.append("\\");
                break;
            // The following 2 lines are exactly what MySQL does TODO: why do we do this?
            case '%':
                sb.append("\\%");
                break;
            case '_':
                sb.append("\\_");
                break;
            default:
                sb.append(n);
            }
            i++;
        } else {
            sb.append(currentChar);
        }
    }
    return sb.toString();
}

From source file:org.lockss.servlet.ServletUtil.java

/**
 * Creates the spans required by jQuery to build the desired tabs.
 * /*ww  w . j  a v  a 2s  . c  o m*/
 * @param tabLetters
 *          A Map<Character, Character> with the tabs start and end letters.
 * @return an org.mortbay.html.List with the spans required by jQuery to build
 *         the desired tabs.
 */
private static org.mortbay.html.List createTabList(Map<Character, Character> tabLetters) {
    final String DEBUG_HEADER = "createTabList(): ";
    if (log.isDebug2())
        log.debug2(DEBUG_HEADER + "Starting...");

    org.mortbay.html.List tabList = new org.mortbay.html.List(org.mortbay.html.List.Unordered);

    // The start and end letters of a tab letter group.
    Map.Entry<Character, Character> letterPair;
    Character startLetter;
    Character endLetter;
    Block tabSpan;
    Link tabLink;
    Composite tabListItem;

    Iterator<Map.Entry<Character, Character>> iterator = tabLetters.entrySet().iterator();

    // Loop through all the tab letter groups.
    while (iterator.hasNext()) {
        // Get the start and end letters of the tab letter group.
        letterPair = iterator.next();
        startLetter = (Character) letterPair.getKey();
        if (log.isDebug3())
            log.debug3(DEBUG_HEADER + "startLetter = " + startLetter);

        endLetter = (Character) letterPair.getValue();
        if (log.isDebug3())
            log.debug3(DEBUG_HEADER + "endLetter = " + endLetter);

        // Initialize the tab.
        tabSpan = new Block(Block.Span);

        // Add the label.
        if (!startLetter.equals(endLetter)) {
            tabSpan.add(startLetter + " - " + endLetter);
        } else {
            tabSpan.add(startLetter);
        }

        // Set up the tab link.
        tabLink = new Link("#" + startLetter);
        tabLink.add(tabSpan);

        // Add the tab to the list.
        tabListItem = tabList.newItem();
        tabListItem.add(tabLink);
    }

    if (log.isDebug2())
        log.debug2(DEBUG_HEADER + "Done.");
    return tabList;
}

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

/**
 * This method initializes grpParticulars
 * //  w  w w  .j  a v  a2  s .  co m
 */
private void createGrpParticulars() {

    int col2x = 105;

    // grpParticulars
    grpParticulars = new Group(compPatientInfo, SWT.NONE);
    grpParticulars.setBounds(new Rectangle(30, 40, 400, 255));
    grpParticulars.setText(Messages.getString("patient.group.particulars")); //$NON-NLS-1$
    grpParticulars.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    // Patient ID
    Label lblPatientId = new Label(grpParticulars, SWT.NONE);
    lblPatientId.setBounds(new Rectangle(7, 25, 84, 20));
    lblPatientId.setText(
            Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.patientid")); //$NON-NLS-1$ //$NON-NLS-2$
    lblPatientId.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    /*if(iDartProperties.country.equalsIgnoreCase("Nigeria")){
       txtPatientId = new CustomIdField(grpParticulars, SWT.BORDER);
        txtPatientId.setBounds(new Rectangle(col2x, 25, 270, 20));
    } else {
       txtPatientId = new TextAdapter(grpParticulars, SWT.BORDER);
       txtPatientId.setBounds(new Rectangle(col2x, 25, 150, 20));
    }*/
    txtPatientId = new TextAdapter(grpParticulars, SWT.BORDER);
    txtPatientId.setBounds(new Rectangle(col2x, 25, 150, 20));
    txtPatientId.setData(iDartProperties.SWTBOT_KEY, "txtPatientId"); //$NON-NLS-1$
    txtPatientId.setFocus();
    txtPatientId.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtPatientId.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if ((btnSearch != null) && (btnSearch.getEnabled())) {
                if ((e.character == SWT.CR)
                        || (e.character == (char) iDartProperties.intValueOfAlternativeBarcodeEndChar)) {
                    cmdSearchWidgetSelected();
                }
            }
        }
    });

    if (isAddnotUpdate) {
        txtPatientId.setEnabled(false);
    }

    btnSearch = new Button(grpParticulars, SWT.NONE);
    btnSearch.setBounds(new Rectangle(270, 20, 119, 28));
    /*if(iDartProperties.country.equalsIgnoreCase("Nigeria")){
       btnSearch.setBounds(new Rectangle(270, 47, 110, 28));
    } else {
       btnSearch.setBounds(new Rectangle(270, 20, 110, 28));
    }*/

    btnSearchByName = new Button(grpParticulars, SWT.NONE);
    btnSearchByName.setBounds(new Rectangle(270, 50, 119, 28));

    if (!isAddnotUpdate) {
        btnSearchByName.setVisible(false);
    }

    if (isAddnotUpdate) {
        btnSearch.setText(Messages.getString("patient.button.editid")); //$NON-NLS-1$
        btnSearch.setToolTipText(Messages.getString("patient.button.editid.tooltip")); //$NON-NLS-1$

        btnSearchByName.setText(Messages.getString("patient.button.editid.nome")); //$NON-NLS-1$
        btnSearchByName.setToolTipText(Messages.getString("patient.button.editid.tooltip.nome")); //$NON-NLS-1$
    } else {
        btnSearch.setText(Messages.getString("patient.button.search")); //$NON-NLS-1$
        btnSearch.setToolTipText(Messages.getString("patient.button.search.tooltip")); //$NON-NLS-1$
    }

    btnSearch.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnSearch.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            cmdSearchWidgetSelected();
        }
    });

    btnSearchByName.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnSearchByName.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            cmdSearchWidgetSelectedSearchByName();
        }
    });

    btnEkapaSearch = new Button(grpParticulars, SWT.NONE);
    btnEkapaSearch.setBounds(new Rectangle(270, 47, 110, 28));
    btnEkapaSearch.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnEkapaSearch.setText(Messages.getString("patient.button.ekapasearch")); //$NON-NLS-1$
    if (!iDartProperties.isEkapaVersion || isAddnotUpdate) {
        btnEkapaSearch.setVisible(false);
    }

    btnEkapaSearch.setToolTipText(Messages.getString("patient.button.ekapasearch.tooltip")); //$NON-NLS-1$
    btnEkapaSearch.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            cmdEkapaSearchWidgetSelected();
        }
    });

    // FirstNames
    Label lblFirstNames = new Label(grpParticulars, SWT.NONE);
    lblFirstNames.setBounds(new Rectangle(7, 55, 84, 20));
    lblFirstNames.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lblFirstNames.setText(
            Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.firstname")); //$NON-NLS-1$ //$NON-NLS-2$
    txtFirstNames = new Text(grpParticulars, SWT.BORDER);
    txtFirstNames.setBounds(new Rectangle(col2x, 55, 150, 20));
    txtFirstNames.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    // Surname
    Label lblSurname = new Label(grpParticulars, SWT.NONE);
    lblSurname.setBounds(new Rectangle(7, 85, 84, 20));
    lblSurname.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lblSurname.setText(
            Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.surname")); //$NON-NLS-1$ //$NON-NLS-2$
    txtSurname = new Text(grpParticulars, SWT.BORDER);
    txtSurname.setBounds(new Rectangle(col2x, 85, 150, 20));
    txtSurname.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    lblOtherPatientsWithThisID = new Label(grpParticulars, SWT.NONE);
    lblOtherPatientsWithThisID.setBounds(new Rectangle(355, 140, 40, 40));
    lblOtherPatientsWithThisID.setImage(ResourceUtils.getImage(iDartImage.PATIENTDUPLICATES_30X26));
    lblOtherPatientsWithThisID.setVisible(false);

    // Date of Birth
    Label lbldob = new Label(grpParticulars, SWT.NONE);
    lbldob.setBounds(new Rectangle(7, 115, 84, 20));
    lbldob.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lbldob.setText(Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.dob")); //$NON-NLS-1$ //$NON-NLS-2$

    cmbDOBDay = new Combo(grpParticulars, SWT.BORDER);
    cmbDOBDay.setBounds(new Rectangle(col2x, 112, 50, 18));
    cmbDOBDay.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbDOBDay.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    cmbDOBDay.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            String theText = cmbDOBDay.getText();
            if (cmbDOBDay.indexOf(theText) == -1) {
                cmbDOBDay.setText(cmbDOBDay.getItem(0));
            }
        }
    });

    cmbDOBMonth = new Combo(grpParticulars, SWT.BORDER);
    cmbDOBMonth.setBounds(new Rectangle(col2x + 50, 112, 97, 18));
    cmbDOBMonth.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbDOBMonth.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    cmbDOBMonth.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            String theText = cmbDOBMonth.getText();
            if (theText.length() > 2) {
                String s = theText.substring(0, 1);
                String t = theText.substring(1, theText.length());
                theText = s.toUpperCase() + t;
                String[] items = cmbDOBMonth.getItems();
                for (int i = 0; i < items.length; i++) {
                    if (items[i].substring(0, 3).equalsIgnoreCase(theText)) {
                        cmbDOBMonth.setText(items[i]);
                        cmbDOBYear.setFocus();
                    }
                }
            }
        }
    });

    cmbDOBYear = new Combo(grpParticulars, SWT.BORDER);
    cmbDOBYear.setBounds(new Rectangle(col2x + 148, 112, 60, 18));
    cmbDOBYear.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbDOBYear.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    cmbDOBYear.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            String theText = cmbDOBYear.getText();
            if ((cmbDOBYear.indexOf(theText) == -1) && (theText.length() >= 4)) {
                cmbDOBYear.setText(EMPTY);
            }
        }
    });

    cmbDOBDay.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            cmdUpdateAge();
        }
    });
    cmbDOBMonth.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            cmdUpdateAge();
        }
    });
    cmbDOBYear.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            cmdUpdateAge();
        }
    });

    // populate the comboboxes
    ComboUtils.populateDateCombos(cmbDOBDay, cmbDOBMonth, cmbDOBYear, false, false);
    cmbDOBDay.setVisibleItemCount(cmbDOBDay.getItemCount());
    cmbDOBMonth.setVisibleItemCount(cmbDOBMonth.getItemCount());
    cmbDOBYear.setVisibleItemCount(31);

    // Sex
    Label lblSex = new Label(grpParticulars, SWT.NONE);
    lblSex.setBounds(new Rectangle(7, 152, 84, 20));
    lblSex.setText(Messages.getString("patient.label.sex")); //$NON-NLS-1$
    lblSex.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    cmbSex = new Combo(grpParticulars, SWT.BORDER);
    cmbSex.setBounds(new Rectangle(col2x, 145, 150, 18));
    cmbSex.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbSex.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    // cmbSex.setEditable(false);
    //cmbSex.add(Messages.getString("common.unknown")); //$NON-NLS-1$
    cmbSex.add(Messages.getString("patient.sex.female")); //$NON-NLS-1$
    cmbSex.add(Messages.getString("patient.sex.male")); //$NON-NLS-1$
    //cmbSex.setText(Messages.getString("common.unknown")); //$NON-NLS-1$
    cmbSex.select(0);
    cmbSex.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            e.doit = false;
            Character keyPressed = new Character(Character.toLowerCase(e.character));
            getLog().debug("The char pressed in cmbSex: " + keyPressed); //$NON-NLS-1$
            if (Character.isLetter(keyPressed)) {
                if (keyPressed.equals('f')) {
                    cmbSex.select(1);
                } else if (keyPressed.equals('m')) {
                    cmbSex.select(2);
                } else {
                    cmbSex.select(0);
                }
                updateClinicInfoTab();
            }
        }
    });

    /*
     * add TraverseListener to allow traversal out of combo see JavaDoc for
     * org.eclipse.swt.events.KeyEvent
     */
    cmbSex.addTraverseListener(new TraverseListener() {
        @Override
        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.doit = true;
            } else {
                e.doit = false;
            }
        }

    });
    cmbSex.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent se) {
            updateClinicInfoTab();
        }
    });

    // Age
    Label lblAge = new Label(grpParticulars, SWT.NONE);
    lblAge.setBounds(new Rectangle(col2x + 212, 117, 33, 20));
    lblAge.setText(Messages.getString("patient.label.age")); //$NON-NLS-1$
    lblAge.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtAge = new Text(grpParticulars, SWT.BORDER);
    txtAge.setBounds(new Rectangle(col2x + 249, 114, 35, 20));
    txtAge.setEditable(false);
    txtAge.setEnabled(false);
    txtAge.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    // Child Icon
    lblPicChild = new Label(grpParticulars, SWT.NONE);
    lblPicChild.setBounds(new Rectangle(255, 140, 50, 43));
    lblPicChild.setImage(ResourceUtils.getImage(iDartImage.CHILD_50X43));
    lblPicChild.setVisible(false);

    transito = new Button(grpParticulars, SWT.CHECK);
    transito.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 1, 1));
    transito.setBounds(new Rectangle(col2x, 150, 150, 18));
    transito.setText("Paciente Em Transito");
    transito.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    transito.setSelection(false);

    // Phone Cell
    Label lblPhoneCell = new Label(grpParticulars, SWT.NONE);
    lblPhoneCell.setBounds(new Rectangle(7, 207, 85, 20));
    lblPhoneCell.setText(Messages.getString("patient.label.cellphone")); //$NON-NLS-1$
    lblPhoneCell.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtCellphone = new Text(grpParticulars, SWT.BORDER);
    txtCellphone.setBounds(new Rectangle(col2x, 205, 150, 20));
    txtCellphone.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtCellphone.setEnabled(false);

    Label lblARVStartDate = new Label(grpParticulars, SWT.NONE);
    lblARVStartDate.setBounds(new Rectangle(7, 233, 90, 20));
    lblARVStartDate.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lblARVStartDate.setText(Messages.getString("patient.label.arvstartdate")); //$NON-NLS-1$

    btnARVStart = new DateButton(grpParticulars, DateButton.ZERO_TIMESTAMP,
            new DateInputValidator(DateRuleFactory.beforeNowInclusive(true)));
    btnARVStart.setBounds(new Rectangle(col2x, 230, 150, 20));
    btnARVStart.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnARVStart.setText(Messages.getString("common.unknown")); //$NON-NLS-1$

    btnPatientHistoryReport = new Button(grpParticulars, SWT.NONE);
    btnPatientHistoryReport.setBounds(new Rectangle(310, 140, 40, 40));
    btnPatientHistoryReport.setToolTipText(Messages.getString("patient.button.report.tooltip")); //$NON-NLS-1$
    btnPatientHistoryReport.setImage(ResourceUtils.getImage(iDartImage.REPORT_PATIENTHISTORY_30X26));

    btnPatientHistoryReport.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent mu) {
            cmdPatientHistoryWidgetSelected();
        }
    });

}

From source file:org.gatein.wcm.services.impl.WcmServiceImpl.java

private Map<Long, Long> updateSecurity(List<Acl> acls, Character strategy) throws Exception {
    Map<Long, Long> mAcls = new HashMap<Long, Long>();

    for (Acl newA : acls) {
        Acl oldA = em.find(Acl.class, newA.getId());
        if (oldA == null) {
            Long importId, newId;

            importId = newA.getId();//from w  w  w. j  ava 2 s . co  m
            newA = em.merge(newA);
            newId = newA.getId();

            mAcls.put(importId, newId);
        } else {
            if (!strategy.equals(Wcm.IMPORT.STRATEGY.UPDATE)) {
                oldA.setPrincipal(newA.getPrincipal());
                oldA.setPermission(newA.getPermission());

                em.merge(oldA);
                mAcls.put(oldA.getId(), oldA.getId());
            }
        }
    }
    return mAcls;
}

From source file:org.gatein.wcm.services.impl.WcmServiceImpl.java

private Map<Long, Long> updatePosts(List<Post> posts, Character strategy) throws Exception {
    Map<Long, Long> mPosts = new HashMap<Long, Long>();

    for (Post newP : posts) {
        Post oldP = em.find(Post.class, newP.getId());
        if (oldP == null) {
            Long importId, newId;

            importId = newP.getId();//from   w w w  .  ja v a  2 s .  c o  m
            newP = em.merge(newP);
            newId = newP.getId();

            mPosts.put(importId, newId);
        } else {
            if (!strategy.equals(Wcm.IMPORT.STRATEGY.UPDATE)) {
                oldP.setAuthor(newP.getAuthor());
                oldP.setContent(newP.getContent());
                oldP.setCreated(newP.getCreated());
                oldP.setCommentsStatus(newP.getCommentsStatus());
                oldP.setExcerpt(newP.getExcerpt());
                oldP.setLocale(newP.getLocale());
                oldP.setModified(newP.getModified());
                oldP.setPostStatus(newP.getPostStatus());
                oldP.setTitle(newP.getTitle());
                oldP.setVersion(newP.getVersion());

                em.merge(oldP);
                mPosts.put(oldP.getId(), oldP.getId());
            }
        }
    }

    return mPosts;
}

From source file:org.gatein.wcm.services.impl.WcmServiceImpl.java

private Map<Long, Long> updateComments(List<Comment> comments, Character strategy) throws Exception {
    Map<Long, Long> mComments = new HashMap<Long, Long>();

    for (Comment newC : comments) {
        Comment oldC = em.find(Comment.class, newC.getId());
        if (oldC == null) {
            Long importId, newId;

            importId = newC.getId();//  www.  j a  v  a 2  s .  com
            newC = em.merge(newC);
            newId = newC.getId();

            mComments.put(importId, newId);
        } else {
            if (!strategy.equals(Wcm.IMPORT.STRATEGY.UPDATE)) {
                oldC.setAuthor(newC.getAuthor());
                oldC.setAuthorEmail(newC.getAuthorEmail());
                oldC.setAuthorUrl(newC.getAuthorUrl());
                oldC.setContent(newC.getContent());
                oldC.setCreated(newC.getCreated());
                oldC.setStatus(newC.getStatus());

                em.merge(oldC);
                mComments.put(oldC.getId(), oldC.getId());
            }
        }
    }

    return mComments;
}

From source file:org.gatein.wcm.services.impl.WcmServiceImpl.java

private Map<Long, Long> updateTemplates(List<Template> templates, Character strategy) throws Exception {
    Map<Long, Long> mTemplates = new HashMap<Long, Long>();

    for (Template newT : templates) {
        Template oldT = em.find(Template.class, newT.getId());
        if (oldT == null) {
            Long importId, newId;

            importId = newT.getId();/*from  w w w. jav  a 2  s.co m*/
            newT = em.merge(newT);
            newId = newT.getId();

            mTemplates.put(importId, newId);
        } else {
            if (!strategy.equals(Wcm.IMPORT.STRATEGY.UPDATE)) {
                oldT.setCreated(newT.getCreated());
                oldT.setContent(newT.getContent());
                oldT.setLocale(newT.getLocale());
                oldT.setModified(newT.getModified());
                oldT.setName(newT.getName());
                oldT.setUser(newT.getUser());
                oldT.setVersion(newT.getVersion());

                em.merge(oldT);
                mTemplates.put(oldT.getId(), oldT.getId());
            }
        }
    }

    return mTemplates;
}