public DeleteSourceManipulationChange(ISourceManipulation sm, boolean isExecuteChange) { Assert.isNotNull(sm); fHandle = getJavaElement(sm).getHandleIdentifier(); if (isExecuteChange) { if (sm instanceof ICompilationUnit) { // don't check anything in this case. We have a warning dialog // already presented to the user that the file is dirty. setValidationMethod(VALIDATE_DEFAULT); } else { setValidationMethod(VALIDATE_NOT_DIRTY); } } else { setValidationMethod(VALIDATE_NOT_DIRTY | VALIDATE_NOT_READ_ONLY); } }
public DeleteSourceManipulationChange(ISourceManipulation sm, boolean isExecuteChange) { Assert.isNotNull(sm); fHandle= getJavaElement(sm).getHandleIdentifier(); if (isExecuteChange) { if (sm instanceof ICompilationUnit) { // don't check anything in this case. We have a warning dialog // already presented to the user that the file is dirty. setValidationMethod(VALIDATE_DEFAULT); } else { setValidationMethod(VALIDATE_NOT_DIRTY); } } else { setValidationMethod(VALIDATE_NOT_DIRTY | VALIDATE_NOT_READ_ONLY); } }
private static void tryDeletingAllJavaChildren(IPackageFragment pack) throws CoreException { IJavaElement[] kids = pack.getChildren(); for (int i = 0; i < kids.length; i++) { if (kids[i] instanceof ISourceManipulation) { if (kids[i].exists() && !kids[i].isReadOnly()) JavaProjectHelper.delete(kids[i]); } } }
private static Change createSourceManipulationDeleteChange(ISourceManipulation element) { // XXX workaround for bug 31384, in case of linked ISourceManipulation delete the resource if (element instanceof ICompilationUnit || element instanceof IPackageFragment) { IResource resource; if (element instanceof ICompilationUnit) resource = ReorgUtils.getResource((ICompilationUnit) element); else resource = ((IPackageFragment) element).getResource(); if (resource != null && resource.isLinked()) return createDeleteChange(resource); } return new DeleteSourceManipulationChange(element, true); }
@Override protected Change doDelete(IProgressMonitor pm) throws CoreException { ISourceManipulation element = getSourceManipulation(); // we have to save dirty compilation units before deleting them. Otherwise // we will end up showing ghost compilation units in the package explorer // since the primary working copy still exists. if (element instanceof ICompilationUnit) { pm.beginTask("", 2); // $NON-NLS-1$ ICompilationUnit unit = (ICompilationUnit) element; saveCUnitIfNeeded(unit, new SubProgressMonitor(pm, 1)); IResource resource = unit.getResource(); ResourceDescription resourceDescription = ResourceDescription.fromResource(resource); element.delete(false, new SubProgressMonitor(pm, 1)); resourceDescription.recordStateFromHistory(resource, new SubProgressMonitor(pm, 1)); return new UndoDeleteResourceChange(resourceDescription); } else if (element instanceof IPackageFragment) { ICompilationUnit[] units = ((IPackageFragment) element).getCompilationUnits(); pm.beginTask("", units.length + 1); // $NON-NLS-1$ for (int i = 0; i < units.length; i++) { // fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=66835 saveCUnitIfNeeded(units[i], new SubProgressMonitor(pm, 1)); } element.delete(false, new SubProgressMonitor(pm, 1)); return new NullChange(); // caveat: real undo implemented by UndoablePackageDeleteChange } else { element.delete(false, pm); return null; // should not happen } }
private static Change createSourceManipulationDeleteChange(ISourceManipulation element) { //XXX workaround for bug 31384, in case of linked ISourceManipulation delete the resource if (element instanceof ICompilationUnit || element instanceof IPackageFragment){ IResource resource; if (element instanceof ICompilationUnit) resource= ReorgUtils.getResource((ICompilationUnit)element); else resource= ((IPackageFragment)element).getResource(); if (resource != null && resource.isLinked()) return createDeleteChange(resource); } return new DeleteSourceManipulationChange(element, true); }
@Override protected Change doDelete(IProgressMonitor pm) throws CoreException { ISourceManipulation element= getSourceManipulation(); // we have to save dirty compilation units before deleting them. Otherwise // we will end up showing ghost compilation units in the package explorer // since the primary working copy still exists. if (element instanceof ICompilationUnit) { pm.beginTask("", 2); //$NON-NLS-1$ ICompilationUnit unit= (ICompilationUnit)element; saveCUnitIfNeeded(unit, new SubProgressMonitor(pm, 1)); IResource resource= unit.getResource(); ResourceDescription resourceDescription = ResourceDescription.fromResource(resource); element.delete(false, new SubProgressMonitor(pm, 1)); resourceDescription.recordStateFromHistory(resource, new SubProgressMonitor(pm, 1)); return new UndoDeleteResourceChange(resourceDescription); } else if (element instanceof IPackageFragment) { ICompilationUnit[] units= ((IPackageFragment)element).getCompilationUnits(); pm.beginTask("", units.length + 1); //$NON-NLS-1$ for (int i = 0; i < units.length; i++) { // fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=66835 saveCUnitIfNeeded(units[i], new SubProgressMonitor(pm, 1)); } element.delete(false, new SubProgressMonitor(pm, 1)); return new NullChange(); // caveat: real undo implemented by UndoablePackageDeleteChange } else { element.delete(false, pm); return null; //should not happen } }
private ISourceManipulation getSourceManipulation() { return (ISourceManipulation) getModifiedElement(); }
private static IJavaElement getJavaElement(ISourceManipulation sm) { // all known ISourceManipulations are IJavaElements return (IJavaElement) sm; }
private static IJavaElement getJavaElement(ISourceManipulation sm) { //all known ISourceManipulations are IJavaElements return (IJavaElement)sm; }