blob: 34dad50c1f96dac5b5f7cf165038d071710f6d14 [file] [log] [blame]
vbaciufb8b10d2009-03-11 18:27:42 +00001/*******************************************************************************
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 *******************************************************************************/
11package org.eclipse.wst.xsd.ui.internal.common.commands;
12
13
14import org.eclipse.xsd.XSDComplexTypeDefinition;
15import org.eclipse.xsd.XSDDerivationMethod;
16import org.eclipse.xsd.XSDFactory;
17import org.eclipse.xsd.XSDRedefinableComponent;
18import 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 */
24public 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}