use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateXSDWhiteSpaceFacetCommand in project webtools.sourceediting by eclipse.
the class XSDFacetSection method widgetSelected.
public void widgetSelected(SelectionEvent e) {
if (e.widget == collapseWhitespaceButton) {
CompoundCommand compoundCommand = new CompoundCommand();
XSDSimpleTypeDefinition anonymousSimpleType = null;
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(xsdSimpleTypeDefinition.getTargetNamespace())) {
if (input instanceof XSDFeature) {
anonymousSimpleType = XSDCommonUIUtils.getAnonymousSimpleType((XSDFeature) input, xsdSimpleTypeDefinition);
if (anonymousSimpleType == null) {
anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
anonymousSimpleType.setBaseTypeDefinition(xsdSimpleTypeDefinition);
ChangeToLocalSimpleTypeCommand changeToAnonymousCommand = new ChangeToLocalSimpleTypeCommand(Messages._UI_ACTION_CONSTRAIN_LENGTH, (XSDFeature) input);
changeToAnonymousCommand.setAnonymousSimpleType(anonymousSimpleType);
compoundCommand.add(changeToAnonymousCommand);
}
UpdateXSDWhiteSpaceFacetCommand whiteSpaceCommand = new UpdateXSDWhiteSpaceFacetCommand(Messages._UI_ACTION_COLLAPSE_WHITESPACE, anonymousSimpleType, collapseWhitespaceButton.getSelection());
compoundCommand.add(whiteSpaceCommand);
getCommandStack().execute(compoundCommand);
}
setInput(getPart(), getSelection());
} else {
UpdateXSDWhiteSpaceFacetCommand whiteSpaceCommand = new UpdateXSDWhiteSpaceFacetCommand(Messages._UI_ACTION_COLLAPSE_WHITESPACE, xsdSimpleTypeDefinition, collapseWhitespaceButton.getSelection());
getCommandStack().execute(whiteSpaceCommand);
}
} else if (e.widget == minimumInclusiveCheckbox) {
String minValue = minLengthText.getText().trim();
if (minValue.length() == 0)
minValue = null;
UpdateNumericBoundsFacetCommand updateCommand = new UpdateNumericBoundsFacetCommand(Messages._UI_ACTION_UPDATE_BOUNDS, xsdSimpleTypeDefinition, minimumInclusiveCheckbox.getSelection(), maximumInclusiveCheckbox.getSelection());
updateCommand.setMin(minValue);
if (minValue != null)
getCommandStack().execute(updateCommand);
} else if (e.widget == maximumInclusiveCheckbox) {
String maxValue = maxLengthText.getText().trim();
if (maxValue.length() == 0)
maxValue = null;
UpdateNumericBoundsFacetCommand updateCommand = new UpdateNumericBoundsFacetCommand(Messages._UI_ACTION_UPDATE_BOUNDS, xsdSimpleTypeDefinition, minimumInclusiveCheckbox.getSelection(), maximumInclusiveCheckbox.getSelection());
updateCommand.setMax(maxValue);
if (maxValue != null)
getCommandStack().execute(updateCommand);
} else if (e.widget == useEnumerationsButton) {
constraintsWidget.addButton.setEnabled(true);
if (isListenerEnabled()) {
constraintsWidget.setConstraintKind(SpecificConstraintsWidget.ENUMERATION);
constraintKind = constraintsWidget.getConstraintKind();
}
} else if (e.widget == usePatternsButton) {
constraintsWidget.addButton.setEnabled(false);
if (isListenerEnabled()) {
constraintsWidget.setConstraintKind(SpecificConstraintsWidget.PATTERN);
constraintKind = constraintsWidget.getConstraintKind();
}
}
}
Aggregations