Skip to content

Commit

Permalink
2nd update for locale specific inputs in GoTo dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
chhh committed Mar 22, 2017
1 parent 5ff7a4a commit ed960af
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 45 deletions.
2 changes: 1 addition & 1 deletion GUI/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ AutoUpdate-Show-In-Client: true
OpenIDE-Module: umich.ms.batmass.gui
OpenIDE-Module-Layer: umich/ms/batmass/gui/layer.xml
OpenIDE-Module-Localizing-Bundle: umich/ms/batmass/gui/Bundle.properties
OpenIDE-Module-Specification-Version: 1.1.8.3
OpenIDE-Module-Specification-Version: 1.1.8.5

4 changes: 2 additions & 2 deletions GUI/nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=ce7b1e4d
build.xml.data.CRC32=5b69ce85
build.xml.script.CRC32=561f1472
build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=ce7b1e4d
nbproject/build-impl.xml.data.CRC32=5b69ce85
nbproject/build-impl.xml.script.CRC32=c12ad135
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
2 changes: 1 addition & 1 deletion GUI/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.1</specification-version>
<specification-version>1.1.1</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package umich.ms.batmass.gui.viewers.chromatogram.actions;

import java.util.Locale;
import javax.swing.JTextField;
import umich.ms.batmass.gui.core.components.util.textinput.DocumentFilters;
import umich.ms.batmass.gui.viewers.chromatogram.components.ChromatogramComponent;
Expand Down Expand Up @@ -90,7 +91,8 @@ public Double getRtHi () {

private Double getValidatedDouble(JTextField field) {
String text = field.getText();
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
text = text.replaceAll("[,\\.]+", ".");
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text, Locale.ROOT);
}

public void initFields(ChromatogramComponent.Viewport view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package umich.ms.batmass.gui.viewers.map2d.actions;

import java.util.Locale;
import javax.swing.JTextField;
import umich.ms.batmass.gui.core.components.util.textinput.DocumentFilters;

Expand Down Expand Up @@ -88,23 +89,25 @@ private String formatFloatToDecimalPoints(Double mz, int decimalDigits) {
}

public Double getMzStart() {
String text = getFieldMzStart().getText();
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
return getValidatedDouble(getFieldMzStart());
}

public Double getMzEnd() {
String text = getFieldMzEnd().getText();
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
return getValidatedDouble(getFieldMzEnd());
}

public Double getRtStart() {
String text = getFieldRtStart().getText();
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
return getValidatedDouble(getFieldRtStart());
}

public Double getRtEnd() {
String text = getFieldRtEnd().getText();
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
return getValidatedDouble(getFieldRtEnd());
}

private Double getValidatedDouble(JTextField field) {
String text = field.getText();
text = text.replaceAll("[,\\.]+", ".");
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text, Locale.ROOT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package umich.ms.batmass.gui.viewers.spectrum.actions;

import java.util.Locale;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
Expand Down Expand Up @@ -68,10 +69,11 @@ private void setAvailableRanges() {

public Double getRtInMinutes() {
String text = getFieldRt().getText();
text = text.replaceAll("[,\\.]+", ".");
if ( ((String)comboBoxTimeUnits.getModel().getSelectedItem()).equals("min") ) {
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text, Locale.ROOT);
} else {
Double validate = org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
Double validate = org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text, Locale.ROOT);
if (validate == null)
return null;
return validate/60d;
Expand All @@ -80,17 +82,21 @@ public Double getRtInMinutes() {

public Integer getScanNum() {
String text = getFieldScanNum().getText();
return org.apache.commons.validator.routines.IntegerValidator.getInstance().validate(text);
return org.apache.commons.validator.routines.IntegerValidator.getInstance().validate(text, Locale.ROOT);
}

public Double getMzStart() {
String text = getFieldMzStart().getText();
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
return getValidatedDouble(getFieldMzStart());
}

public Double getMzEnd() {
String text = getFieldMzEnd().getText();
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text);
return getValidatedDouble(getFieldMzEnd());
}

private Double getValidatedDouble(JTextField field) {
String text = field.getText();
text = text.replaceAll("[,\\.]+", ".");
return org.apache.commons.validator.routines.DoubleValidator.getInstance().validate(text, Locale.ROOT);
}

public JTextField getFieldMzEnd() {
Expand Down
2 changes: 1 addition & 1 deletion GUICore/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: umich.ms.batmass.gui.core
OpenIDE-Module-Localizing-Bundle: umich/ms/batmass/gui/core/Bundle.properties
OpenIDE-Module-Specification-Version: 1.1
OpenIDE-Module-Specification-Version: 1.1.2

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.regex.Pattern;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.DocumentFilter;
import javax.swing.text.PlainDocument;

Expand Down Expand Up @@ -99,24 +100,23 @@ public static PlainDocument getDigitsAndDotCommaFilter() {
@Override
public void insertString(DocumentFilter.FilterBypass fb, int off, String str, AttributeSet attr)
throws BadLocationException {
fb.insertString(off, str.replaceAll("[^0-9\\.,]", ""), attr); // remove non-digits and dots
fb.insertString(off, str.replaceAll("[^0-9\\.,]", ""), attr); // remove non-digits and dots/commas
}

@Override
public void replace(DocumentFilter.FilterBypass fb, int off, int len, String str, AttributeSet attr)
throws BadLocationException {
String text = fb.getDocument().getText(0, fb.getDocument().getLength());
Pattern dot = Pattern.compile("\\.");
Matcher m = dot.matcher(text);
StringBuffer sb = new StringBuffer();
int cnt = 0;
while(m.find()) {
cnt++;
if (cnt > 1)
m.appendReplacement(sb, "");
}
m.appendTail(sb);
fb.replace(off, len, str.replaceAll("[^0-9\\.,]", ""), attr); // remove non-digits and dots
// String text = fb.getDocument().getText(0, fb.getDocument().getLength());
// Matcher m = Pattern.compile("[\\.,]").matcher(text);
// StringBuffer sb = new StringBuffer();
// int cnt = 0;
// while(m.find()) {
// cnt++;
// if (cnt > 1)
// m.appendReplacement(sb, "");
// }
// m.appendTail(sb);
fb.replace(off, len, str.replaceAll("[^0-9\\.,]", ""), attr); // remove non-digits and dots/commas
}
});
return doc;
Expand Down
Binary file modified updates/umich-ms-batmass-autoupdate.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-data-core.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-db.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-diaumpire.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-filesupport-core.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-filesupport.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-gui-core.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-gui.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-nbpcustomizer.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-nbputils.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-projects-core.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-projects.nbm
Binary file not shown.
Binary file modified updates/umich-ms-batmass-resources-core.nbm
Binary file not shown.
Loading

0 comments on commit ed960af

Please sign in to comment.