Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java81
1 files changed, 0 insertions, 81 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java
deleted file mode 100644
index d7eb8a7177..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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.refactor.structure;
-
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDSchema;
-
-
-public final class MakeLocalElementGlobalCommand extends AbstractCommand
-{
- public MakeLocalElementGlobalCommand(XSDConcreteComponent element)
- {
- super(element.getContainer());
- setModelObject(element);
- }
-
- public void run()
- {
- if (getModelObject() instanceof XSDElementDeclaration)
- {
-
- XSDElementDeclaration localElementDeclaration = (XSDElementDeclaration)getModelObject();
- XSDConcreteComponent parent = getParent();
- XSDConcreteComponent container = parent.getContainer();
-
- // Clone the local element with its content and set it global
-
- XSDElementDeclaration globalElementDeclaration = (XSDElementDeclaration)localElementDeclaration.cloneConcreteComponent(true, false);
-
- // The schema may already have a global element declaration with this name. In that case, ensure the name of the newly created
- // element does not collide with an existing one.
-
- XSDSchema schema = container.getSchema();
- String localElementName = localElementDeclaration.getName();
- XSDElementDeclaration existingGlobalElement = schema.resolveElementDeclaration(localElementName);
- boolean elementExists = existingGlobalElement != null && existingGlobalElement.getSchema() != null;
- if (elementExists)
- {
- String newElementName = XSDCommonUIUtils.createUniqueElementName(localElementName, schema.getElementDeclarations());
- globalElementDeclaration.setName(newElementName);
- }
-
- EList schemaContents = schema.getContents();
- schemaContents.add(globalElementDeclaration);
-
- // Modify the local element to become a reference to the global element.
-
- localElementDeclaration.setName(null);
- localElementDeclaration.setTypeDefinition(null);
- localElementDeclaration.setAnonymousTypeDefinition(null);
- localElementDeclaration.setResolvedElementDeclaration(globalElementDeclaration);
- XSDModelGroup modelGroup = (XSDModelGroup)container;
-
- // Format the markup.
-
- formatChild(modelGroup.getElement());
- formatChild(globalElementDeclaration.getElement());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
- */
- protected boolean adopt(XSDConcreteComponent model)
- {
- return true;
- }
-} \ No newline at end of file

Back to the top