Search in sources :

Example 1 with UpdateXSDWhiteSpaceFacetCommand

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();
        }
    }
}
Also used : UpdateXSDWhiteSpaceFacetCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateXSDWhiteSpaceFacetCommand) XSDFeature(org.eclipse.xsd.XSDFeature) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ChangeToLocalSimpleTypeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ChangeToLocalSimpleTypeCommand) UpdateNumericBoundsFacetCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNumericBoundsFacetCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 ChangeToLocalSimpleTypeCommand (org.eclipse.wst.xsd.ui.internal.common.commands.ChangeToLocalSimpleTypeCommand)1 UpdateNumericBoundsFacetCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNumericBoundsFacetCommand)1 UpdateXSDWhiteSpaceFacetCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateXSDWhiteSpaceFacetCommand)1 XSDFeature (org.eclipse.xsd.XSDFeature)1 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)1