Search in sources :

Example 51 with IInputValidator

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);
    }
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) FacetsListInputDialog(com.amalto.workbench.dialogs.FacetsListInputDialog) XSDTotalDigitsFacet(org.eclipse.xsd.XSDTotalDigitsFacet) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 52 with IInputValidator

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);
    }
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) FacetsListInputDialog(com.amalto.workbench.dialogs.FacetsListInputDialog) XSDMaxLengthFacet(org.eclipse.xsd.XSDMaxLengthFacet) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 53 with IInputValidator

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);
        }
    }
}
Also used : XSDMinInclusiveFacet(org.eclipse.xsd.XSDMinInclusiveFacet) InputDialog(org.eclipse.jface.dialogs.InputDialog) FacetsListInputDialog(com.amalto.workbench.dialogs.FacetsListInputDialog) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 54 with IInputValidator

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);
        }
    }
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) FacetsListInputDialog(com.amalto.workbench.dialogs.FacetsListInputDialog) XSDMaxExclusiveFacet(org.eclipse.xsd.XSDMaxExclusiveFacet) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 55 with IInputValidator

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);
        }
    }
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) FacetsListInputDialog(com.amalto.workbench.dialogs.FacetsListInputDialog) XSDFractionDigitsFacet(org.eclipse.xsd.XSDFractionDigitsFacet) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Aggregations

IInputValidator (org.eclipse.jface.dialogs.IInputValidator)60 InputDialog (org.eclipse.jface.dialogs.InputDialog)51 Composite (org.eclipse.swt.widgets.Composite)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 FacetsListInputDialog (com.amalto.workbench.dialogs.FacetsListInputDialog)9 Button (org.eclipse.swt.widgets.Button)9 ArrayList (java.util.ArrayList)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 IStatus (org.eclipse.core.runtime.IStatus)7 GridData (org.eclipse.swt.layout.GridData)7 Label (org.eclipse.swt.widgets.Label)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 SelectionListener (org.eclipse.swt.events.SelectionListener)6 Event (org.eclipse.swt.widgets.Event)6 FillLayout (org.eclipse.swt.layout.FillLayout)5 Control (org.eclipse.swt.widgets.Control)5 Group (org.eclipse.swt.widgets.Group)5 MessageBox (org.eclipse.swt.widgets.MessageBox)5 ISelection (org.eclipse.jface.viewers.ISelection)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4