Search in sources :

Example 1 with UpdateMaxOccursCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateMaxOccursCommand in project webtools.sourceediting by eclipse.

the class MultiplicitySection method updateMaxAttribute.

protected void updateMaxAttribute() {
    setErrorMessage(null);
    XSDParticle particle = null;
    if (input instanceof XSDParticleContent) {
        particle = getAssociatedParticle((XSDParticleContent) input);
    }
    if (particle != null) {
        String newValue = maxCombo.getText().trim();
        if (newValue.length() == 0) {
            particle.unsetMaxOccurs();
            return;
        }
        try {
            int newMax = 1;
            if (// $NON-NLS-1$ //$NON-NLS-2$
            newValue.equals("unbounded") || newValue.equals("*")) {
                newMax = XSDParticle.UNBOUNDED;
            } else {
                if (newValue.length() > 0) {
                    newMax = Integer.parseInt(newValue);
                }
            }
            setListenerEnabled(false);
            UpdateMaxOccursCommand command = new UpdateMaxOccursCommand(Messages._UI_ACTION_CHANGE_MAXIMUM_OCCURRENCE, particle, newMax);
            getCommandStack().execute(command);
            setListenerEnabled(true);
        } catch (NumberFormatException e) {
            setErrorMessage(Messages._UI_ERROR_INVALID_VALUE_FOR_MAXIMUM_OCCURRENCE);
        }
    }
}
Also used : XSDParticleContent(org.eclipse.xsd.XSDParticleContent) UpdateMaxOccursCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateMaxOccursCommand) XSDParticle(org.eclipse.xsd.XSDParticle)

Aggregations

UpdateMaxOccursCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateMaxOccursCommand)1 XSDParticle (org.eclipse.xsd.XSDParticle)1 XSDParticleContent (org.eclipse.xsd.XSDParticleContent)1