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()]);
}
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);
}
}
}
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()]);
}
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());
}
}
}
}
Aggregations