summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-03-10 15:35:52 (EST)
committer pelder2006-03-10 15:35:52 (EST)
commit141027d9b9750b3d423c8647db779e3f15815293 (patch)
tree830e4acd3915a1e59be99bca29b3b3e47742de89
parent8de01f8f1313a34b3d0ed72c8239b4a514a23d02 (diff)
downloadorg.eclipse.jet-141027d9b9750b3d423c8647db779e3f15815293.zip
org.eclipse.jet-141027d9b9750b3d423c8647db779e3f15815293.tar.gz
org.eclipse.jet-141027d9b9750b3d423c8647db779e3f15815293.tar.bz2
[131381] Add public function to expose the ImportManager created by the java:importsLocation tag.
-rw-r--r--plugins/org.eclipse.jet/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportTag.java4
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportsLocationTag.java27
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaImportsUtil.java73
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/package.html13
5 files changed, 98 insertions, 20 deletions
diff --git a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
index 32ce08c..ffa9257 100644
--- a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
@@ -39,6 +39,7 @@ Export-Package: org.eclipse.jet,
org.eclipse.jet.internal.xpath.parser;x-friends:="org.eclipse.jet.tests",
org.eclipse.jet.runtime.model,
org.eclipse.jet.taglib,
+ org.eclipse.jet.taglib.java,
org.eclipse.jet.taglib.workspace,
org.eclipse.jet.transform,
org.eclipse.jet.xpath,
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportTag.java
index 43555dd..c5f18c4 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportTag.java
@@ -23,6 +23,7 @@ import org.eclipse.jet.JET2Context;
import org.eclipse.jet.taglib.AbstractFunctionTag;
import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.TagInfo;
+import org.eclipse.jet.taglib.java.JavaImportsUtil;
/**
@@ -38,7 +39,6 @@ public class ImportTag extends AbstractFunctionTag
public ImportTag()
{
super();
- // TODO Auto-generated constructor stub
}
/* (non-Javadoc)
@@ -46,7 +46,7 @@ public class ImportTag extends AbstractFunctionTag
*/
public String doFunction(TagInfo tc, JET2Context context, String bodyContent) throws JET2TagException
{
- ImportManager importManager = ImportsLocationTag.getImportManager(getOut());
+ ImportManager importManager = JavaImportsUtil.getImportManager(getOut());
importManager.addImport(bodyContent);
return importManager.getImportedName(bodyContent);
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportsLocationTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportsLocationTag.java
index 4ee4496..884b217 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportsLocationTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/ImportsLocationTag.java
@@ -26,6 +26,7 @@ import org.eclipse.jet.internal.l10n.JET2Messages;
import org.eclipse.jet.taglib.AbstractEmptyTag;
import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.TagInfo;
+import org.eclipse.jet.taglib.java.JavaImportsUtil;
import org.eclipse.jface.text.Position;
@@ -139,26 +140,16 @@ public class ImportsLocationTag extends AbstractEmptyTag
}
}
+ /**
+ *
+ * @param writer
+ * @return
+ * @throws JET2TagException
+ * @deprecated Use {@link JavaImportsUtil#getImportManager(JET2Writer)} instead.
+ */
public static ImportManager getImportManager(JET2Writer writer) throws JET2TagException
{
-
- // defenseive add of the category...
- writer.addPositionCategory(IMPORTS_POSITION_CATEGORY);
-
- Position[] positions = writer.getPositions(IMPORTS_POSITION_CATEGORY);
- if (positions.length > 0)
- {
- ImportsPosition position = (ImportsPosition)positions[0];
- return position.getImportManager();
- }
- else if (writer.getParentWriter() != null)
- {
- return getImportManager(writer.getParentWriter());
- }
- else
- {
- throw new JET2TagException(JET2Messages.ImportsLocationTag_MissingImportsLocation);
- }
+ return JavaImportsUtil.getImportManager(writer);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaImportsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaImportsUtil.java
new file mode 100644
index 0000000..19de48e
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaImportsUtil.java
@@ -0,0 +1,73 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.jet.taglib.java;
+
+import org.eclipse.emf.codegen.util.ImportManager;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.internal.l10n.JET2Messages;
+import org.eclipse.jet.internal.taglib.java.ImportsLocationTag;
+import org.eclipse.jet.internal.taglib.java.ImportsLocationTag.ImportsPosition;
+import org.eclipse.jet.taglib.JET2TagException;
+import org.eclipse.jface.text.Position;
+
+/**
+ * Utility function for sharing access to {@link ImportManager} created by the &lt;java:importsManager;&gt; tags.
+ * <p>
+ * This class is not intended to be instantiated or extended by clients.
+ * </p>
+ */
+public final class JavaImportsUtil
+{
+
+ /**
+ *
+ */
+ private JavaImportsUtil()
+ {
+ super();
+ }
+
+ /**
+ * Return the imports manager installed in the current writer.
+ * @param writer the current writer. Cannot be <code>null</code>.
+ * @return the imports manager installed on the writer.
+ * @throws JET2TagException if no &lt;java:importsLocation&gt; tag has executed on the writer.
+ * @throws NullPointerException if <code>writer</code> is <code>null</code>.
+ */
+ public static ImportManager getImportManager(JET2Writer writer) throws JET2TagException
+ {
+
+ // defensive add of the category...
+ writer.addPositionCategory(ImportsLocationTag.IMPORTS_POSITION_CATEGORY);
+
+ Position[] positions = writer.getPositions(ImportsLocationTag.IMPORTS_POSITION_CATEGORY);
+ if (positions.length > 0)
+ {
+ ImportsPosition position = (ImportsPosition)positions[0];
+ return position.getImportManager();
+ }
+ else if (writer.getParentWriter() != null)
+ {
+ return getImportManager(writer.getParentWriter());
+ }
+ else
+ {
+ throw new JET2TagException(JET2Messages.ImportsLocationTag_MissingImportsLocation);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/package.html b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/package.html
new file mode 100644
index 0000000..b7f5278
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/package.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About org.eclipse.jet.taglib.workspace</title>
+</head>
+<body lang="EN-US">
+<p>
+Define utility functions for interacting with the Standard JET Java tags.
+</p>
+</body>
+</html>