vbaciu | fb8b10d | 2009-03-11 18:27:42 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2009 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.wst.xsd.ui.internal.common.commands; |
| 12 | |
| 13 | |
| 14 | import org.eclipse.xsd.XSDComplexTypeDefinition; |
| 15 | import org.eclipse.xsd.XSDDerivationMethod; |
| 16 | import org.eclipse.xsd.XSDFactory; |
| 17 | import org.eclipse.xsd.XSDRedefinableComponent; |
| 18 | import org.eclipse.xsd.XSDRedefine; |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * Creates a redefined complex type based on the input complex type and adds it to the parent redefine. |
| 23 | */ |
| 24 | public class RedefineComplexTypeCommand extends AddRedefinedComponentCommand |
| 25 | { |
| 26 | public RedefineComplexTypeCommand(String label, XSDRedefine redefine, XSDRedefinableComponent redefinableComponent) |
| 27 | { |
| 28 | super(label, redefine, redefinableComponent); |
| 29 | } |
| 30 | |
| 31 | protected void doExecute() |
| 32 | { |
| 33 | XSDComplexTypeDefinition redefinedComplexTypeDefinition = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); |
| 34 | redefinedComplexTypeDefinition.setName(redefinableComponent.getName()); |
| 35 | redefinedComplexTypeDefinition.setContent(XSDFactory.eINSTANCE.createXSDComplexTypeDefinition().getContent()); |
| 36 | redefinedComplexTypeDefinition.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); |
| 37 | redefinedComplexTypeDefinition.setBaseTypeDefinition((XSDComplexTypeDefinition)redefinableComponent); |
| 38 | addedXSDConcreteComponent = redefinedComplexTypeDefinition; |
| 39 | } |
| 40 | } |