Search in sources :

Example 1 with CopyArguments

use of org.eclipse.ltk.core.refactoring.participants.CopyArguments in project che by eclipse.

the class ResourceModifications method getParticipants.

public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) {
    List<RefactoringParticipant> result = new ArrayList<RefactoringParticipant>(5);
    if (fDelete != null) {
        DeleteArguments arguments = new DeleteArguments();
        for (Iterator<IResource> iter = fDelete.iterator(); iter.hasNext(); ) {
            DeleteParticipant[] deletes = ParticipantManager.loadDeleteParticipants(status, processor, iter.next(), arguments, natures, shared);
            result.addAll(Arrays.asList(deletes));
        }
    }
    if (fCreate != null) {
        CreateArguments arguments = new CreateArguments();
        for (Iterator<IResource> iter = fCreate.iterator(); iter.hasNext(); ) {
            CreateParticipant[] creates = ParticipantManager.loadCreateParticipants(status, processor, iter.next(), arguments, natures, shared);
            result.addAll(Arrays.asList(creates));
        }
    }
    if (fMove != null) {
        for (int i = 0; i < fMove.size(); i++) {
            Object element = fMove.get(i);
            MoveArguments arguments = fMoveArguments.get(i);
            MoveParticipant[] moves = ParticipantManager.loadMoveParticipants(status, processor, element, arguments, natures, shared);
            result.addAll(Arrays.asList(moves));
        }
    }
    if (fCopy != null) {
        for (int i = 0; i < fCopy.size(); i++) {
            Object element = fCopy.get(i);
            CopyArguments arguments = fCopyArguments.get(i);
            CopyParticipant[] copies = ParticipantManager.loadCopyParticipants(status, processor, element, arguments, natures, shared);
            result.addAll(Arrays.asList(copies));
        }
    }
    if (fRename != null) {
        for (int i = 0; i < fRename.size(); i++) {
            Object resource = fRename.get(i);
            RenameArguments arguments = fRenameArguments.get(i);
            RenameParticipant[] renames = ParticipantManager.loadRenameParticipants(status, processor, resource, arguments, natures, shared);
            result.addAll(Arrays.asList(renames));
        }
    }
    return result.toArray(new RefactoringParticipant[result.size()]);
}
Also used : RefactoringParticipant(org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant) RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments) ArrayList(java.util.ArrayList) MoveParticipant(org.eclipse.ltk.core.refactoring.participants.MoveParticipant) DeleteParticipant(org.eclipse.ltk.core.refactoring.participants.DeleteParticipant) CreateArguments(org.eclipse.ltk.core.refactoring.participants.CreateArguments) DeleteArguments(org.eclipse.ltk.core.refactoring.participants.DeleteArguments) CopyArguments(org.eclipse.ltk.core.refactoring.participants.CopyArguments) CreateParticipant(org.eclipse.ltk.core.refactoring.participants.CreateParticipant) CopyParticipant(org.eclipse.ltk.core.refactoring.participants.CopyParticipant) MoveArguments(org.eclipse.ltk.core.refactoring.participants.MoveArguments) RenameParticipant(org.eclipse.ltk.core.refactoring.participants.RenameParticipant) IResource(org.eclipse.core.resources.IResource)

Example 2 with CopyArguments

use of org.eclipse.ltk.core.refactoring.participants.CopyArguments in project che by eclipse.

the class CopyModifications method copy.

public void copy(IPackageFragment pack, CopyArguments javaArgs, CopyArguments resourceArgs) throws CoreException {
    add(pack, javaArgs, null);
    ResourceMapping mapping = JavaElementResourceMapping.create(pack);
    if (mapping != null) {
        add(mapping, resourceArgs, null);
    }
    IPackageFragmentRoot javaDestination = (IPackageFragmentRoot) javaArgs.getDestination();
    if (javaDestination.getResource() == null)
        return;
    IPackageFragment newPack = javaDestination.getPackageFragment(pack.getElementName());
    // the new name yet, so we use the current package name.
    if (!pack.hasSubpackages() && (!newPack.exists() || pack.equals(newPack))) {
        // we can do a simple move
        IContainer resourceDestination = newPack.getResource().getParent();
        createIncludingParents(resourceDestination);
        getResourceModifications().addCopyDelta(pack.getResource(), resourceArgs);
    } else {
        IContainer resourceDestination = (IContainer) newPack.getResource();
        createIncludingParents(resourceDestination);
        CopyArguments arguments = new CopyArguments(resourceDestination, resourceArgs.getExecutionLog());
        IResource[] resourcesToCopy = collectResourcesOfInterest(pack);
        for (int i = 0; i < resourcesToCopy.length; i++) {
            IResource toCopy = resourcesToCopy[i];
            getResourceModifications().addCopyDelta(toCopy, arguments);
        }
    }
}
Also used : IPackageFragment(org.eclipse.jdt.core.IPackageFragment) CopyArguments(org.eclipse.ltk.core.refactoring.participants.CopyArguments) JavaElementResourceMapping(org.eclipse.jdt.internal.corext.util.JavaElementResourceMapping) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Example 3 with CopyArguments

use of org.eclipse.ltk.core.refactoring.participants.CopyArguments in project che by eclipse.

the class ResourceModifications method getParticipants.

public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) {
    List result = new ArrayList(5);
    if (fDelete != null) {
        DeleteArguments arguments = new DeleteArguments();
        for (Iterator iter = fDelete.iterator(); iter.hasNext(); ) {
            DeleteParticipant[] deletes = ParticipantManager.loadDeleteParticipants(status, processor, iter.next(), arguments, natures, shared);
            result.addAll(Arrays.asList(deletes));
        }
    }
    if (fCreate != null) {
        CreateArguments arguments = new CreateArguments();
        for (Iterator iter = fCreate.iterator(); iter.hasNext(); ) {
            CreateParticipant[] creates = ParticipantManager.loadCreateParticipants(status, processor, iter.next(), arguments, natures, shared);
            result.addAll(Arrays.asList(creates));
        }
    }
    if (fMove != null) {
        for (int i = 0; i < fMove.size(); i++) {
            Object element = fMove.get(i);
            MoveArguments arguments = (MoveArguments) fMoveArguments.get(i);
            MoveParticipant[] moves = ParticipantManager.loadMoveParticipants(status, processor, element, arguments, natures, shared);
            result.addAll(Arrays.asList(moves));
        }
    }
    if (fCopy != null) {
        for (int i = 0; i < fCopy.size(); i++) {
            Object element = fCopy.get(i);
            CopyArguments arguments = (CopyArguments) fCopyArguments.get(i);
            CopyParticipant[] copies = ParticipantManager.loadCopyParticipants(status, processor, element, arguments, natures, shared);
            result.addAll(Arrays.asList(copies));
        }
    }
    if (fRename != null) {
        for (int i = 0; i < fRename.size(); i++) {
            Object resource = fRename.get(i);
            RenameArguments arguments = (RenameArguments) fRenameArguments.get(i);
            RenameParticipant[] renames = ParticipantManager.loadRenameParticipants(status, processor, resource, arguments, natures, shared);
            result.addAll(Arrays.asList(renames));
        }
    }
    return (RefactoringParticipant[]) result.toArray(new RefactoringParticipant[result.size()]);
}
Also used : RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments) RefactoringParticipant(org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant) ArrayList(java.util.ArrayList) MoveParticipant(org.eclipse.ltk.core.refactoring.participants.MoveParticipant) DeleteParticipant(org.eclipse.ltk.core.refactoring.participants.DeleteParticipant) CreateArguments(org.eclipse.ltk.core.refactoring.participants.CreateArguments) DeleteArguments(org.eclipse.ltk.core.refactoring.participants.DeleteArguments) CopyArguments(org.eclipse.ltk.core.refactoring.participants.CopyArguments) CreateParticipant(org.eclipse.ltk.core.refactoring.participants.CreateParticipant) CopyParticipant(org.eclipse.ltk.core.refactoring.participants.CopyParticipant) MoveArguments(org.eclipse.ltk.core.refactoring.participants.MoveArguments) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) RenameParticipant(org.eclipse.ltk.core.refactoring.participants.RenameParticipant)

Example 4 with CopyArguments

use of org.eclipse.ltk.core.refactoring.participants.CopyArguments in project xtext-eclipse by eclipse.

the class XtextCopyResourceParticipant method addElement.

@Override
public void addElement(final Object element, final RefactoringArguments arguments) {
    if ((arguments instanceof CopyArguments)) {
        if ((element instanceof IResource)) {
            final Object destination = ((CopyArguments) arguments).getDestination();
            if (((destination instanceof IFolder) || (destination instanceof IProject))) {
                IFile _switchResult = null;
                boolean _matched = false;
                if (destination instanceof IFolder) {
                    _matched = true;
                    _switchResult = ((IFolder) destination).getFile(((IResource) element).getName());
                }
                if (!_matched) {
                    if (destination instanceof IProject) {
                        _matched = true;
                        _switchResult = ((IProject) destination).getFile(((IResource) element).getName());
                    }
                }
                final IFile destinationFile = _switchResult;
                this.processor.addChangedResource(((IResource) element), ((IResource) element).getFullPath(), destinationFile.getFullPath());
            }
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) CopyArguments(org.eclipse.ltk.core.refactoring.participants.CopyArguments) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

CopyArguments (org.eclipse.ltk.core.refactoring.participants.CopyArguments)4 IResource (org.eclipse.core.resources.IResource)3 ArrayList (java.util.ArrayList)2 CopyParticipant (org.eclipse.ltk.core.refactoring.participants.CopyParticipant)2 CreateArguments (org.eclipse.ltk.core.refactoring.participants.CreateArguments)2 CreateParticipant (org.eclipse.ltk.core.refactoring.participants.CreateParticipant)2 DeleteArguments (org.eclipse.ltk.core.refactoring.participants.DeleteArguments)2 DeleteParticipant (org.eclipse.ltk.core.refactoring.participants.DeleteParticipant)2 MoveArguments (org.eclipse.ltk.core.refactoring.participants.MoveArguments)2 MoveParticipant (org.eclipse.ltk.core.refactoring.participants.MoveParticipant)2 RefactoringParticipant (org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant)2 RenameArguments (org.eclipse.ltk.core.refactoring.participants.RenameArguments)2 RenameParticipant (org.eclipse.ltk.core.refactoring.participants.RenameParticipant)2 Iterator (java.util.Iterator)1 List (java.util.List)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)1