summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-05-16 16:05:35 (EDT)
committer pelder2006-05-16 16:05:35 (EDT)
commit54f23223500a53356a81f1317f66cd72f5c094be (patch)
tree3b65f75fb908dc9d803865e6abf3c1981a1d9db9
parent7b467bf59f06c0e4269e7ff6c049be365b466898 (diff)
downloadorg.eclipse.jet-54f23223500a53356a81f1317f66cd72f5c094be.zip
org.eclipse.jet-54f23223500a53356a81f1317f66cd72f5c094be.tar.gz
org.eclipse.jet-54f23223500a53356a81f1317f66cd72f5c094be.tar.bz2
[141537] Pass current shell to validateEdit calls if we can determine the current shell.
-rw-r--r--plugins/org.eclipse.jet/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java46
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java4
3 files changed, 51 insertions, 2 deletions
diff --git a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
index 2ced348..2573ada 100644
--- a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ant.core;bundle-version="[3.1.100,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
- org.apache.ant;bundle-version="[1.6.5,2.0.0)"
+ org.apache.ant;bundle-version="[1.6.5,2.0.0)",
+ org.eclipse.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional
Eclipse-AutoStart: true
Export-Package: org.eclipse.jet,
org.eclipse.jet.compiler,
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java
index 2089807..f0020c3 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java
@@ -63,6 +63,10 @@ import org.eclipse.jet.xpath.XPathFunctionMetaData;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
/**
@@ -87,6 +91,39 @@ public class JET2Platform
public static final String JET2_NATURE_ID = JET2Platform.PLUGIN_ID + "." + "jet2Nature"; //$NON-NLS-1$ //$NON-NLS-2$
/**
+ * Return the value of the shell context, suitable for passing to
+ * {@link TransformContextExtender#setShellContext(Object)}.
+ * This method will work, even in the abscences of a shell or even SWT.
+ * @return the shell context or <code>null</code> if none is set
+ */
+ public static final Object getShellContext()
+ {
+ try
+ {
+ Display display = Display.getDefault();
+ final Shell[] shell = new Shell []{ null };
+ display.syncExec(new Runnable()
+ {
+
+ public void run()
+ {
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ shell[0] = activeWorkbenchWindow != null ? activeWorkbenchWindow.getShell() : null;
+ }
+ });
+ return shell[0];
+ }
+ catch (NoClassDefFoundError e)
+ {
+ return null;
+ }
+ catch (IllegalStateException e)
+ {
+ return null;
+ }
+ }
+
+ /**
* @param project
* @param result
* @throws CoreException
@@ -316,6 +353,7 @@ public class JET2Platform
{
IStatus result;
monitor.beginTask(JET2Messages.JET2Platform_Executing + id, 100);
+
try
{
final IJETBundleManager bundleManager = getJETBundleManager();
@@ -353,6 +391,14 @@ public class JET2Platform
{
monitor.beginTask(JET2Messages.JET2Platform_Executing, 100);
final TransformContextExtender tce = TransformContextExtender.getInstance(context);
+ if(tce.getShellContext() == null )
+ {
+ Object shell = getShellContext();
+ if(shell != null)
+ {
+ tce.setShellContext(shell);
+ }
+ }
try
{
XPathContextExtender xpe = XPathContextExtender.getInstance(context);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java
index 682d635..d3cc010 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java
@@ -205,7 +205,9 @@ public class WorkspaceContextExtender extends AbstractContextExtender
if (!validateOk.isOK())
{
- throw new CoreException(validateOk);
+ // it would be nice to co-relate this message to a particular action, but
+ // the validateEdit API doesn't give us much
+ throw new JET2TagException(validateOk.getMessage());
}
monitor.worked(1);