Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-27 05:10:40 -0500
committerMilos Kleint2010-12-27 05:10:40 -0500
commit9c946c3ebecfc372968ebc2e176b998916f47831 (patch)
treeac190a1341c0bef0730b68fad8c328638977f7e6
parent1b77821f02ba27fdbc07e5df83f0b56f17210a0f (diff)
downloadm2e-core-9c946c3ebecfc372968ebc2e176b998916f47831.tar.gz
m2e-core-9c946c3ebecfc372968ebc2e176b998916f47831.tar.xz
m2e-core-9c946c3ebecfc372968ebc2e176b998916f47831.zip
attempt to add a new method for getting the MavenProject instance that returns fast (and can return null when not loaded yet)
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
index 1be781cd..17d5429e 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
@@ -988,6 +988,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
IProgressMonitor monitor) throws CoreException {
if(force || !rootNodes.containsKey(classpath)) {
monitor.setTaskName(Messages.MavenPomEditor_task_reading);
+ //mkleint: I'm wondering if the force parameter on dependencyTree is also applicable to the pom project method.
MavenProject mavenProject = readMavenProject(force, monitor);
if(mavenProject == null){
MavenLogger.log("Unable to read maven project. Dependencies not updated.", null); //$NON-NLS-1$
@@ -1000,7 +1001,24 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
return rootNodes.get(classpath);
}
+
+ /**
+ * this method is safer than readMavenProject for instances that shall return fast and don't mind
+ * not having the MavenProject instance around.
+ * @return the cached MavenProject instance or null if not loaded.
+ */
+ public MavenProject getMavenProject() {
+ return mavenProject;
+ }
+ /**
+ * either returns the cached MavenProject instance or reads it, please note that if you want your method to always return fast
+ * getMavenProject() is preferable
+ * @param force
+ * @param monitor
+ * @return
+ * @throws CoreException
+ */
public MavenProject readMavenProject(boolean force, IProgressMonitor monitor) throws CoreException {
if(force || mavenProject == null) {
IEditorInput input = getEditorInput();

Back to the top