[154922] Change derivation method should be placed in a command
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComplexTypeDerivationBy.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComplexTypeDerivationBy.java
new file mode 100644
index 0000000..6c0bbab
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComplexTypeDerivationBy.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.common.commands;
+
+import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
+import org.eclipse.xsd.XSDComplexTypeDefinition;
+import org.eclipse.xsd.XSDDerivationMethod;
+import org.eclipse.xsd.util.XSDConstants;
+
+public class UpdateComplexTypeDerivationBy extends BaseCommand
+{
+  private XSDComplexTypeDefinition complexType;
+  private String derivation;
+
+  public UpdateComplexTypeDerivationBy(XSDComplexTypeDefinition complexType, String derivation)
+  {
+    this.complexType = complexType;
+    this.derivation = derivation;
+    // TODO: use new Message bundle mechanism
+    setLabel(XSDEditorPlugin.getXSDString("_UI_DERIVEDBY_CHANGE"));
+  }
+
+  public void execute()
+  {
+    super.execute();
+    try
+    {
+      beginRecording(complexType.getElement());
+      if (derivation.equals(XSDConstants.EXTENSION_ELEMENT_TAG))
+      {
+        complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
+      }
+      else if (derivation.equals(XSDConstants.RESTRICTION_ELEMENT_TAG))
+      {
+        complexType.setDerivationMethod(XSDDerivationMethod.RESTRICTION_LITERAL);
+      }
+    }
+    finally
+    {
+      endRecording();
+    }
+  }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java
index c501420..a19c760 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java
@@ -28,6 +28,7 @@
 import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification;
 import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager;
 import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog;
+import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateComplexTypeDerivationBy;
 import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand;
 import org.eclipse.wst.xsd.ui.internal.editor.Messages;
 import org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager;
@@ -244,16 +245,12 @@
     else if (e.widget == derivedByCombo)
     {
       XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input;
-      
-      // TODO: put this in an action
       String value = derivedByCombo.getText();
-      if (value.equals(XSDConstants.EXTENSION_ELEMENT_TAG))
+      Command command = new UpdateComplexTypeDerivationBy(complexType, value);
+      
+      if (getCommandStack() != null)
       {
-        complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
-      }
-      else if (value.equals(XSDConstants.RESTRICTION_ELEMENT_TAG))
-      {
-        complexType.setDerivationMethod(XSDDerivationMethod.RESTRICTION_LITERAL);
+        getCommandStack().execute(command);
       }
     }
     super.doWidgetSelected(e);