diff --git a/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/actions/CreateActionViewDelegate.java b/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/actions/CreateActionViewDelegate.java index 098e82b..f413336 100644 --- a/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/actions/CreateActionViewDelegate.java +++ b/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/actions/CreateActionViewDelegate.java @@ -14,11 +14,11 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; -import com.anjlab.eclipse.tapestry5.Activator; import com.anjlab.eclipse.tapestry5.EclipseUtils; import com.anjlab.eclipse.tapestry5.TapestryContext; import com.anjlab.eclipse.tapestry5.TapestryModule; import com.anjlab.eclipse.tapestry5.TapestryUtils; +import com.anjlab.eclipse.tapestry5.views.context.TapestryContextView; public class CreateActionViewDelegate implements IViewActionDelegate, IMenuCreator { @@ -91,8 +91,8 @@ public Menu getMenu(Control parent) { Menu menu = new Menu(parent); - TapestryContext tapestryContext = fromView - ? Activator.getDefault().getTapestryContext(window) + TapestryContext tapestryContext = view instanceof TapestryContextView + ? ((TapestryContextView) view).getTapestryContext() : TapestryUtils.createTapestryContext(window); // From Main ToolBar TapestryModule module; @@ -195,20 +195,19 @@ public Menu getMenu(Menu parent) return null; } - private boolean fromView; private IWorkbenchWindow window; + private IViewPart view; @Override public void init(IViewPart view) { + this.view = view; this.window = view.getSite().getWorkbenchWindow(); - this.fromView = true; } public void init(IWorkbenchWindow window) { this.window = window; - this.fromView = false; } } diff --git a/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/views/context/TapestryContextView.java b/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/views/context/TapestryContextView.java index a536d58..d1a3c6b 100644 --- a/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/views/context/TapestryContextView.java +++ b/com.anjlab.eclipse.tapestry5/src/com/anjlab/eclipse/tapestry5/views/context/TapestryContextView.java @@ -113,6 +113,11 @@ public void projectChanged(IWorkbenchWindow window, TapestryProject newTapestryP Activator.getDefault().addTapestryContextListener(getViewSite().getWorkbenchWindow(), tapestryContextListener); } + public TapestryContext getTapestryContext() + { + return ((TapestryContextContentProvider) viewer.getContentProvider()).getContext(); + } + @Override public void dispose() {