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);
}
}
}
Aggregations