Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-27 16:06:57 -0500
committerMilos Kleint2010-12-27 16:06:57 -0500
commite230373a239823a2ff0fbb2cc7e7b08221e7f442 (patch)
treec57673d4080a2849d860a91e1e9dbb49477aea70
parentae957d2dd92a312bdf6638654764a221f3f3c371 (diff)
downloadm2e-core-e230373a239823a2ff0fbb2cc7e7b08221e7f442.tar.gz
m2e-core-e230373a239823a2ff0fbb2cc7e7b08221e7f442.tar.xz
m2e-core-e230373a239823a2ff0fbb2cc7e7b08221e7f442.zip
use IAdaptable instead of special purpose interface
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectCache.java27
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java6
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java14
3 files changed, 13 insertions, 34 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectCache.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectCache.java
deleted file mode 100644
index 70731741..00000000
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectCache.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.m2e.core.project;
-
-import org.apache.maven.project.MavenProject;
-
-/**
- * interface implemented by maven pom's xml editor SourceViewer for storing and retrieving the latest valid
- * MavenProject cached for various xml editor related features.
- *
- *
- * Note: Added here in order not to introduce a dependency between editor and xml.editor projects. If that is not a problem,
- * probably move to editor.
- * @author mkleint
- */
-public interface IMavenProjectCache {
-
- MavenProject getMavenProject();
-}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
index d6887b2c..be154104 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
@@ -30,6 +30,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
@@ -44,7 +45,6 @@ import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.MavenLogger;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.internal.project.MavenMarkerManager;
-import org.eclipse.m2e.core.project.IMavenProjectCache;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
/**
*
@@ -114,8 +114,8 @@ public class XmlUtils {
public static MavenProject extractMavenProject(ITextViewer sourceViewer) {
//look in the sourceViewer's cache only
- if (sourceViewer instanceof IMavenProjectCache) {
- return ((IMavenProjectCache)sourceViewer).getMavenProject();
+ if (sourceViewer instanceof IAdaptable) {
+ return (MavenProject)((IAdaptable)sourceViewer).getAdapter(MavenProject.class);
}
return null;
}
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 d43a81c2..8cd206e4 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
@@ -39,6 +39,7 @@ import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -82,7 +83,6 @@ import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.core.MavenLogger;
import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.embedder.MavenModelManager;
-import org.eclipse.m2e.core.project.IMavenProjectCache;
import org.eclipse.m2e.core.project.IMavenProjectChangedListener;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
@@ -658,9 +658,8 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
job.schedule();
}
- protected class MavenStructuredTextViewer extends StructuredTextViewer implements IMavenProjectCache {
-
- private MavenProject project;
+ protected class MavenStructuredTextViewer extends StructuredTextViewer implements IAdaptable {
+
public MavenStructuredTextViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
boolean showAnnotationsOverview, int styles) {
super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
@@ -669,6 +668,13 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
public MavenProject getMavenProject() {
return MavenPomEditor.this.getMavenProject();
}
+
+ public Object getAdapter(Class adapter) {
+ if (MavenProject.class.equals(adapter)) {
+ return getMavenProject();
+ }
+ return null;
+ }
}

Back to the top