Java Code Examples for org.eclipse.jdt.core.IPackageFragmentRoot#OTHER_REFERRING_PROJECTS_CLASSPATH
The following examples show how to use
org.eclipse.jdt.core.IPackageFragmentRoot#OTHER_REFERRING_PROJECTS_CLASSPATH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackageFragmentRootReorgChange.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
protected int getUpdateModelFlags(boolean isCopy) throws JavaModelException{ final int destination= IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH; final int replace= IPackageFragmentRoot.REPLACE; final int originating; final int otherProjects; if (isCopy){ originating= 0; //ORIGINATING_PROJECT_CLASSPATH does not apply to copy otherProjects= 0;//OTHER_REFERRING_PROJECTS_CLASSPATH does not apply to copy } else{ originating= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH; otherProjects= IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH; } IJavaElement javaElement= JavaCore.create(getDestination()); if (javaElement == null || !javaElement.exists()) { return replace | originating; } if (fUpdateClasspathQuery == null) { return replace | originating | destination; } IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(getRoot()); if (referencingProjects.length <= 1) { return replace | originating | destination; } boolean updateOtherProjectsToo= fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects); if (updateOtherProjectsToo) { return replace | originating | destination | otherProjects; } else { return replace | originating | destination; } }
Example 2
Source File: DeletePackageFragmentRootChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected Change doDelete(IProgressMonitor pm) throws CoreException { if (! confirmDeleteIfReferenced()) return new NullChange(); int resourceUpdateFlags= IResource.KEEP_HISTORY; int jCoreUpdateFlags= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH; pm.beginTask("", 2); //$NON-NLS-1$ IPackageFragmentRoot root= getRoot(); IResource rootResource= root.getResource(); CompositeChange result= new CompositeChange(getName()); ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource); IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(root); HashMap<IFile, String> classpathFilesContents= new HashMap<IFile, String>(); for (int i= 0; i < referencingProjects.length; i++) { IJavaProject javaProject= referencingProjects[i]; IFile classpathFile= javaProject.getProject().getFile(".classpath"); //$NON-NLS-1$ if (classpathFile.exists()) { classpathFilesContents.put(classpathFile, getFileContents(classpathFile)); } } root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1)); rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1)); for (Iterator<Entry<IFile, String>> iterator= classpathFilesContents.entrySet().iterator(); iterator.hasNext();) { Entry<IFile, String> entry= iterator.next(); IFile file= entry.getKey(); String contents= entry.getValue(); //Restore time stamps? This should probably be some sort of UndoTextFileChange. TextFileChange classpathUndo= new TextFileChange(Messages.format(RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file, BasicElementLabels.getPathLabel(file.getFullPath(), true)), file); classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents)); result.add(classpathUndo); } result.add(new UndoDeleteResourceChange(rootDescription)); pm.done(); return result; }
Example 3
Source File: PackageFragmentRootReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected int getUpdateModelFlags(boolean isCopy) throws JavaModelException{ final int destination= IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH; final int replace= IPackageFragmentRoot.REPLACE; final int originating; final int otherProjects; if (isCopy){ originating= 0; //ORIGINATING_PROJECT_CLASSPATH does not apply to copy otherProjects= 0;//OTHER_REFERRING_PROJECTS_CLASSPATH does not apply to copy } else{ originating= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH; otherProjects= IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH; } IJavaElement javaElement= JavaCore.create(getDestination()); if (javaElement == null || !javaElement.exists()) return replace | originating; if (fUpdateClasspathQuery == null) return replace | originating | destination; IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(getRoot()); if (referencingProjects.length <= 1) return replace | originating | destination; boolean updateOtherProjectsToo= fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects); if (updateOtherProjectsToo) return replace | originating | destination | otherProjects; else return replace | originating | destination; }
Example 4
Source File: DeletePackageFragmentRootChange.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override protected Change doDelete(IProgressMonitor pm) throws CoreException { if (! confirmDeleteIfReferenced()) { return new NullChange(); } int resourceUpdateFlags= IResource.KEEP_HISTORY; int jCoreUpdateFlags= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH; pm.beginTask("", 2); //$NON-NLS-1$ IPackageFragmentRoot root= getRoot(); IResource rootResource= root.getResource(); CompositeChange result= new CompositeChange(getName()); IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(root); HashMap<IFile, String> classpathFilesContents= new HashMap<>(); for (int i= 0; i < referencingProjects.length; i++) { IJavaProject javaProject= referencingProjects[i]; IFile classpathFile= javaProject.getProject().getFile(".classpath"); //$NON-NLS-1$ if (classpathFile.exists()) { classpathFilesContents.put(classpathFile, getFileContents(classpathFile)); } } root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1)); // TODO can't port org.eclipse.ui.ide.undo.ResourceDescription.class // ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource); // rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1)); for (Iterator<Entry<IFile, String>> iterator= classpathFilesContents.entrySet().iterator(); iterator.hasNext();) { Entry<IFile, String> entry= iterator.next(); IFile file= entry.getKey(); String contents= entry.getValue(); //Restore time stamps? This should probably be some sort of UndoTextFileChange. TextFileChange classpathUndo= new TextFileChange(Messages.format(RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file, BasicElementLabels.getPathLabel(file.getFullPath(), true)), file); classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents)); result.add(classpathUndo); } // result.add(new UndoDeleteResourceChange(rootDescription)); pm.done(); return result; }
Example 5
Source File: RenameSourceFolderChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private int getJavaModelUpdateFlags() { return IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH | IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH | IPackageFragmentRoot.REPLACE; }