use of org.eclipse.jface.dialogs.IInputValidator in project tmdm-studio-se by Talend.
the class XSDEditFacetAction method editTotalDigits.
// EditMaxLength
private void editTotalDigits() {
XSDTotalDigitsFacet currentValue = std.getTotalDigitsFacet();
// $NON-NLS-1$
String stringValue = "0";
if (currentValue != null) {
stringValue = currentValue.getLexicalValue();
}
dialog = new InputDialog(page.getSite().getShell(), Messages.XSDEditFacetAction_DialogTitle6, Messages.XSDEditFacetAction_DialogTitle6Tip, stringValue == null ? "" : stringValue, new // $NON-NLS-1$
IInputValidator() {
public String isValid(String newText) {
int val;
try {
val = Integer.parseInt(newText);
} catch (Exception e) {
return Messages.XSDEditFacetAction_ValueMustBeXX;
}
if (val < 0) {
return Messages.XSDEditFacetAction_ValueMustBeXX;
}
return null;
}
});
dialog.setBlockOnOpen(true);
int ret = dialog.open();
if (ret == Dialog.CANCEL) {
return;
}
if (currentValue != null) {
std.getFacetContents().remove(currentValue);
}
int intValue = Integer.parseInt(((InputDialog) dialog).getValue());
if (intValue > 0) {
XSDTotalDigitsFacet f = (XSDSchemaBuildingTools.getXSDFactory()).createXSDTotalDigitsFacet();
// $NON-NLS-1$
f.setLexicalValue("" + intValue);
std.getFacetContents().add(f);
}
}
use of org.eclipse.jface.dialogs.IInputValidator in project tmdm-studio-se by Talend.
the class XSDEditFacetAction method editMaxLength.
// EditMinLength
private void editMaxLength() {
XSDMaxLengthFacet currentValue = std.getMaxLengthFacet();
// $NON-NLS-1$
String stringValue = "0";
if (currentValue != null) {
stringValue = currentValue.getLexicalValue();
}
dialog = new InputDialog(page.getSite().getShell(), Messages.XSDEditFacetAction_DialogTitle5, Messages.XSDEditFacetAction_DialogTitle4Tip, stringValue == null ? "" : stringValue, new // $NON-NLS-1$
IInputValidator() {
public String isValid(String newText) {
int val;
try {
val = Integer.parseInt(newText);
} catch (Exception e) {
return Messages.XSDEditFacetAction_ValueMustBeXX;
}
if (val < 0) {
return Messages.XSDEditFacetAction_ValueMustBeXX;
}
return null;
}
});
dialog.setBlockOnOpen(true);
int ret = dialog.open();
if (ret == Dialog.CANCEL) {
return;
}
if (currentValue != null) {
std.getFacetContents().remove(currentValue);
}
int intValue = Integer.parseInt(((InputDialog) dialog).getValue());
if (intValue > 0) {
XSDMaxLengthFacet f = (XSDSchemaBuildingTools.getXSDFactory()).createXSDMaxLengthFacet();
// $NON-NLS-1$
f.setLexicalValue("" + intValue);
std.getFacetContents().add(f);
}
}
use of org.eclipse.jface.dialogs.IInputValidator in project tmdm-studio-se by Talend.
the class XSDEditFacetAction method editMinInclusive.
private void editMinInclusive() {
XSDMinInclusiveFacet currentValue = std.getMinInclusiveFacet();
String stringValue = null;
if (currentValue != null) {
stringValue = currentValue.getLexicalValue();
}
boolean isDateType = true;
dialog = getInputDialog4Date(Messages.XSDEditFacetAction_DialogTitle10, Messages.XSDEditFacetAction_DialogTitle10Tip, stringValue);
if (dialog == null) {
isDateType = false;
dialog = new InputDialog(page.getSite().getShell(), Messages.XSDEditFacetAction_DialogTitle10, Messages.XSDEditFacetAction_DialogTitle10Tip, stringValue == null ? "" : stringValue, new // $NON-NLS-1$
IInputValidator() {
public String isValid(String newText) {
if (newText.trim().isEmpty()) {
return null;
}
return isValidBoundaryNumber(std, newText);
}
});
}
dialog.setBlockOnOpen(true);
int ret = dialog.open();
if (ret == Dialog.CANCEL) {
return;
}
if (currentValue != null) {
std.getFacetContents().remove(currentValue);
}
String input = ((InputDialog) dialog).getValue();
if (!input.trim().isEmpty()) {
XSDMinInclusiveFacet f = (XSDSchemaBuildingTools.getXSDFactory()).createXSDMinInclusiveFacet();
if (isDateType) {
f.setLexicalValue(input.trim());
std.getFacetContents().add(f);
} else if (Double.parseDouble(input) >= 0) {
// $NON-NLS-1$
f.setLexicalValue("" + getValidBoundaryNumber(std, input));
std.getFacetContents().add(f);
}
}
}
use of org.eclipse.jface.dialogs.IInputValidator in project tmdm-studio-se by Talend.
the class XSDEditFacetAction method editMaxExclusive.
private void editMaxExclusive() {
XSDMaxExclusiveFacet currentValue = std.getMaxExclusiveFacet();
String stringValue = null;
if (currentValue != null) {
stringValue = currentValue.getLexicalValue();
}
boolean isDateType = true;
dialog = getInputDialog4Date(Messages.XSDEditFacetAction_DialogTitle9, Messages.XSDEditFacetAction_DialogTitle9Tip, stringValue);
if (dialog == null) {
isDateType = false;
dialog = new InputDialog(page.getSite().getShell(), Messages.XSDEditFacetAction_DialogTitle9, Messages.XSDEditFacetAction_DialogTitle9Tip, stringValue == null ? "" : stringValue, new // $NON-NLS-1$
IInputValidator() {
public String isValid(String newText) {
if (newText.trim().isEmpty()) {
return null;
}
return isValidBoundaryNumber(std, newText);
}
});
}
dialog.setBlockOnOpen(true);
int ret = dialog.open();
if (ret == Dialog.CANCEL) {
return;
}
if (currentValue != null) {
std.getFacetContents().remove(currentValue);
}
String input = ((InputDialog) dialog).getValue();
if (!input.trim().isEmpty()) {
XSDMaxExclusiveFacet f = (XSDSchemaBuildingTools.getXSDFactory()).createXSDMaxExclusiveFacet();
if (isDateType) {
f.setLexicalValue(input.trim());
std.getFacetContents().add(f);
} else if (Double.parseDouble(input) >= 0) {
// $NON-NLS-1$
f.setLexicalValue("" + getValidBoundaryNumber(std, input));
std.getFacetContents().add(f);
}
}
}
use of org.eclipse.jface.dialogs.IInputValidator in project tmdm-studio-se by Talend.
the class XSDEditFacetAction method editFractionDigits.
private void editFractionDigits() {
XSDFractionDigitsFacet currentValue = std.getFractionDigitsFacet();
String stringValue = null;
if (currentValue != null) {
stringValue = currentValue.getLexicalValue();
}
dialog = new InputDialog(page.getSite().getShell(), Messages.XSDEditFacetAction_DialogTitle7, Messages.XSDEditFacetAction_DialogTitle7Tip, stringValue == null ? "" : stringValue, new // $NON-NLS-1$
IInputValidator() {
public String isValid(String newText) {
if (newText.trim().isEmpty()) {
return null;
}
int val;
try {
val = Integer.parseInt(newText);
} catch (Exception e) {
return Messages.XSDEditFacetAction_ValueMustBeXX;
}
if (val < 0) {
return Messages.XSDEditFacetAction_ValueMustBeXX;
}
return null;
}
});
dialog.setBlockOnOpen(true);
int ret = dialog.open();
if (ret == Dialog.CANCEL) {
return;
}
if (currentValue != null) {
std.getFacetContents().remove(currentValue);
}
String input = ((InputDialog) dialog).getValue();
if (!input.trim().isEmpty()) {
int intValue = Integer.parseInt(input);
if (intValue >= 0) {
XSDFractionDigitsFacet f = (XSDSchemaBuildingTools.getXSDFactory()).createXSDFractionDigitsFacet();
// $NON-NLS-1$
f.setLexicalValue("" + intValue);
std.getFacetContents().add(f);
}
}
}
Aggregations