diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure')
5 files changed, 0 insertions, 624 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/AbstractCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/AbstractCommand.java deleted file mode 100644 index a39ebafae5..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/AbstractCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.refactor.structure; - -import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; -import org.eclipse.xsd.XSDConcreteComponent; -import org.w3c.dom.Element; - -public abstract class AbstractCommand -{ - private XSDConcreteComponent parent; - private XSDConcreteComponent model; - - protected AbstractCommand(XSDConcreteComponent parent) - { - this.parent = parent; - } - - public abstract void run(); - - protected XSDConcreteComponent getParent() - { - return parent; - } - - public XSDConcreteComponent getModelObject() - { - return model; - } - - protected void setModelObject(XSDConcreteComponent model) - { - this.model = model; - } - - // Establish part-whole relationship - protected abstract boolean adopt(XSDConcreteComponent model); - - protected void formatChild(Element child) - { - if (child instanceof IDOMNode) - { - IDOMModel model = ((IDOMNode)child).getModel(); - try - { - // tell the model that we are about to make a big model change - model.aboutToChangeModel(); - - IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); - formatProcessor.formatNode(child); - } - finally - { - // tell the model that we are done with the big model change - model.changedModel(); - } - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeAnonymousTypeGlobalCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeAnonymousTypeGlobalCommand.java deleted file mode 100644 index d9fc1b022c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeAnonymousTypeGlobalCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * 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.refactor.structure; - -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; - -public final class MakeAnonymousTypeGlobalCommand extends AbstractCommand { - - String fNewName; - - public MakeAnonymousTypeGlobalCommand(XSDConcreteComponent element, - String newName) { - super(element.getContainer()); - setModelObject(element); - fNewName = newName; - } - - public void run() { - XSDConcreteComponent model = getModelObject(); - XSDConcreteComponent parent = model.getContainer(); - XSDTypeDefinition globalTypeDef = null; - if (model instanceof XSDComplexTypeDefinition) { - if (parent instanceof XSDElementDeclaration) { - // clone typedef with it's content and set it global - globalTypeDef = (XSDComplexTypeDefinition) model - .cloneConcreteComponent(true, false); - globalTypeDef.setName(fNewName); - parent.getSchema().getContents().add(globalTypeDef); - ((XSDElementDeclaration) parent) - .setTypeDefinition(globalTypeDef); - } - } else if (model instanceof XSDSimpleTypeDefinition) { - - XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) model; - if (parent instanceof XSDElementDeclaration) { - // clone typedef with it's content and set it global - globalTypeDef = (XSDSimpleTypeDefinition) typeDef - .cloneConcreteComponent(true, false); - globalTypeDef.setName(fNewName); - parent.getSchema().getContents().add(globalTypeDef); - ((XSDElementDeclaration) parent) - .setTypeDefinition(globalTypeDef); - formatChild(globalTypeDef.getElement()); - - } else if (parent instanceof XSDAttributeDeclaration) { - // clone typedef with it's content and set it global - globalTypeDef = (XSDSimpleTypeDefinition) typeDef - .cloneConcreteComponent(true, false); - globalTypeDef.setName(fNewName); - parent.getSchema().getContents().add(globalTypeDef); - ((XSDAttributeDeclaration) parent) - .setTypeDefinition((XSDSimpleTypeDefinition) globalTypeDef); - - } - - } - - formatChild(globalTypeDef.getElement()); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent) - */ - protected boolean adopt(XSDConcreteComponent model) { - // TODO Auto-generated method stub - return true; - } -} 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 diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java deleted file mode 100644 index 23b1d23b88..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.refactor.structure; - -import java.util.Map; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.text.Assert; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.TextChange; -import org.eclipse.ltk.core.refactoring.TextFileChange; -import org.eclipse.wst.xml.core.internal.document.DocumentImpl; -import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages; -import org.eclipse.xsd.XSDTypeDefinition; - -/** - * @author ebelisar - * - */ -public class MakeTypeGlobalChange extends Change { - - private Map fChanges; - - private String fNewName; - - private XSDTypeDefinition fTypeComponent; - - public MakeTypeGlobalChange(XSDTypeDefinition component, - String newName) { - Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ - - fTypeComponent = component; - fNewName = newName; - } - - // public static Change[] createChangesFor(XSDNamedComponent component, - // String newName) { - // // TODO: P1 implement search of XSD files - // XSDSearchSupport support = XSDSearchSupport.getInstance(); - // RefactorSearchRequestor requestor = new - // RefactorSearchRequestor(component, newName); - // support.searchRunnable(component, IXSDSearchConstants.WORKSPACE_SCOPE, - // requestor); - // - // return requestor.getChanges(); - // - // } - - protected Change createUndoChange() { - return new MakeTypeGlobalChange(fTypeComponent, getNewName()); - } - - protected void doRename(IProgressMonitor pm) throws CoreException { - // TODO P1 change temporary rename of XSD model components - performModify(getNewName()); - } - - public void performModify(final String value) { -// DelayedRenameRunnable runnable = new DelayedRenameRunnable( -// fTypeComponent, value); - // TODO: remove Display - //Display.getCurrent().asyncExec(runnable); - } - - protected static class DelayedRenameRunnable implements Runnable { - protected XSDTypeDefinition component; - - protected String name; - - public DelayedRenameRunnable(XSDTypeDefinition component, String name) { - this.component = component; - this.name = name; - } - - public void run() { - DocumentImpl doc = (DocumentImpl) component.getElement().getOwnerDocument(); - doc.getModel().beginRecording( - this, - RefactoringMessages - .getString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL")); - MakeAnonymousTypeGlobalCommand command = new MakeAnonymousTypeGlobalCommand( - component, name); - command.run(); - doc.getModel().endRecording(this); - } - } - - public TextChange getChange(IFile file) { - TextChange result = (TextChange) fChanges.get(file); - if (result == null) { - result = new TextFileChange(file.getName(), file); - fChanges.put(file, result); - } - return result; - } - - public String getName() { - return RefactoringMessages - .getFormattedString( - "MakeTypeGlobalChange.name", new String[] {getNewName() }); //$NON-NLS-1$ - } - - public final Change perform(IProgressMonitor pm) throws CoreException { - try { - pm.beginTask(RefactoringMessages - .getString("XSDComponentRenameChange.Renaming"), 1); //$NON-NLS-1$ - Change result = createUndoChange(); - doRename(new SubProgressMonitor(pm, 1)); - return result; - } finally { - pm.done(); - } - } - - /** - * Gets the newName. - * - * @return Returns a String - */ - protected String getNewName() { - return fNewName; - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement() - */ - public Object getModifiedElement() { - // TODO Auto-generated method stub - return fTypeComponent; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor) - */ - public void initializeValidationData(IProgressMonitor pm) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor) - */ - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, - OperationCanceledException { - // TODO implement change validation - return new RefactoringStatus(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java deleted file mode 100644 index 0b793f3716..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.refactor.structure; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.ParticipantManager; -import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant; -import org.eclipse.ltk.core.refactoring.participants.RenameArguments; -import org.eclipse.ltk.core.refactoring.participants.RenameProcessor; -import org.eclipse.ltk.core.refactoring.participants.SharableParticipants; -import org.eclipse.wst.xsd.ui.internal.refactor.INameUpdating; -import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages; -import org.eclipse.xsd.XSDTypeDefinition; - -public class MakeTypeGlobalProcessor extends RenameProcessor implements INameUpdating{ - - private XSDTypeDefinition fTypeComponent; - private String fNewElementName; - - public static final String IDENTIFIER= "org.eclipse.wst.ui.xsd.makeTypeGlobalProcessor"; //$NON-NLS-1$ - - //private QualifiedNameSearchResult fNameSearchResult; - - public MakeTypeGlobalProcessor(XSDTypeDefinition element, String newName) { - fTypeComponent= element; - fNewElementName = newName; - - } - - public XSDTypeDefinition getTypeComponent() { - return fTypeComponent; - } - - - - /* (non-Javadoc) - * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#canEnableTextUpdating() - */ - public boolean canEnableTextUpdating() { - return true; - } - - protected String[] getAffectedProjectNatures() throws CoreException { - //TODO: find project natures of the files that are going to be refactored - return new String[0]; - } - - protected void loadDerivedParticipants(RefactoringStatus status, - List result, String[] natures, SharableParticipants shared) - throws CoreException { - // TODO: provide a way to load rename participants - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - public RefactoringStatus checkFinalConditions(IProgressMonitor pm, - CheckConditionsContext context) throws CoreException, - OperationCanceledException { - // TODO add code to check final conditions for component rename - return new RefactoringStatus(); - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor) - */ - public RefactoringStatus checkInitialConditions(IProgressMonitor pm) - throws CoreException, OperationCanceledException { -// TODO add code to check initial conditions for component rename - return new RefactoringStatus(); - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change createChange(IProgressMonitor pm) throws CoreException, - OperationCanceledException { - // TODO P1 add change creation -// Change[] changes = XSDComponentRenameChange.createChangesFor(this.fNamedComponent, getNewElementName()); -// CompositeChange multiChange = null; -// if(changes.length > 0) -// multiChange = new CompositeChange("XSD component rename participant changes", changes); //$NON-NLS-1$ TODO: externalize string -// return multiChange; - -// computeNameMatches(pm); -// Change[] changes = fNameSearchResult.getAllChanges(); -// return new CompositeChange("XSD file rename participant changes", changes); //TODO: externalize string - pm.beginTask("", 1); //$NON-NLS-1$ - try{ - return new MakeTypeGlobalChange(fTypeComponent, getNewElementName()); - } finally{ - pm.done(); - } - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements() - */ - public Object[] getElements() { - - return new Object[] {fTypeComponent}; - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier() - */ - public String getIdentifier() { - return IDENTIFIER; - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName() - */ - public String getProcessorName() { - return RefactoringMessages.getFormattedString( - "MakeLocalTypeGlobalRefactoring.name", //$NON-NLS-1$ - new String[]{getNewElementName()}); - - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable() - */ - public boolean isApplicable() throws CoreException { - if (fTypeComponent == null) - return false; - // TODO implement isApplicable logic for the named component, - // verify how it is different from other condition checks -// if (fNamedComponent.isAnonymous()) -// return false; -// if (! Checks.isAvailable(fType)) -// return false; -// if (isSpecialCase(fType)) -// return false; - return true; - } - /* (non-Javadoc) - * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#checkNewElementName(java.lang.String) - */ - public RefactoringStatus checkNewElementName(String newName){ - Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ - // TODO: implement new name checking -// RefactoringStatus result = Checks.checkTypeName(newName); -// if (Checks.isAlreadyNamed(fType, newName)) -// result.addFatalError(RefactoringCoreMessages.getString("RenameTypeRefactoring.choose_another_name")); //$NON-NLS-1$ - return new RefactoringStatus(); - } - /* (non-Javadoc) - * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#getNewElement() - */ - public Object getNewElement() throws CoreException { - // TODO implement this method, it's used for updating selection on new element - return null; - } - -// private void computeNameMatches(IProgressMonitor pm) throws CoreException { -// -// IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); -// try { -// URL fileURL = Platform.resolve(new URL(fNamedComponent.getSchema().getSchemaLocation())); -// IFile file = workspaceRoot.getFileForLocation(new Path(fileURL.getPath())); -// if (fNameSearchResult == null) -// fNameSearchResult= new QualifiedNameSearchResult(); -// QualifiedNameFinder.process(fNameSearchResult, getNamedComponent().getName(), -// getNewElementName(), -// "*.xsd", file.getProject(), pm); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } - - public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException { - RenameArguments arguments= new RenameArguments(getNewElementName(), true); - String[] natures= getAffectedProjectNatures(); - List result= new ArrayList(); - loadElementParticipants(status, result, arguments, natures, sharedParticipants); - loadDerivedParticipants(status, result, natures, sharedParticipants); - return (RefactoringParticipant[])result.toArray(new RefactoringParticipant[result.size()]); - } - - protected void loadElementParticipants(RefactoringStatus status, List result, RenameArguments arguments, String[] natures, SharableParticipants shared) throws CoreException { - Object[] elements= getElements(); - for (int i= 0; i < elements.length; i++) { - result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status, - this, elements[i], - arguments, natures, shared))); - } - } - - - public void setNewElementName(String newName) { - - fNewElementName= newName; - } - - public String getNewElementName() { - return fNewElementName; - } - - public String getCurrentElementName() { - // TODO Auto-generated method stub - return fNewElementName; - } - - -} |