扩展Editor的Configuration
<extension
point="org.eclipse.wst.sse.ui.editorConfiguration">
<!-- associating an outline configuration to an input's content type -->
<contentOutlineConfiguration
class="com.test.outline.OutlineConfiguration"
target="org.eclipse.core.runtime.xml,org.eclipse.wst.html.core.htmlsource"/>
</extension>
OutlineConfiguration.java
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.ui.internal.IReleasable;
import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
import org.eclipse.wst.xml.ui.views.contentoutline.XMLContentOutlineConfiguration;
public class OutlineConfiguration extends XMLContentOutlineConfiguration {
private class ActionManagerMenuListener implements IMenuListener, IReleasable {
public void menuAboutToShow(IMenuManager imenumanager) {
TestAction action = new TestAction();
imenumanager.add(action);
}
public void release() {
fTreeViewer = null;
if (fActionManager != null)
fActionManager.setModel(null);
}
private XMLNodeActionManager fActionManager;
private TreeViewer fTreeViewer;
public ActionManagerMenuListener(TreeViewer treeviewer) {
super();
fTreeViewer = treeviewer;
}
}
private ActionManagerMenuListener fContextMenuFiller;
public OutlineConfiguration() {
super();
}
@Override
public IMenuListener getMenuListener(TreeViewer treeviewer) {
if (fContextMenuFiller == null)
fContextMenuFiller = new ActionManagerMenuListener(treeviewer);
return fContextMenuFiller;
}
}
import org.eclipse.jface.action.Action;
public class TestAction extends Action {
public TestAction(){
super("Test");
}
}
这样Outline的Menu就是你自己定义的了.
参考资料:
http://www.eclipse.org/webtools/wst/components/sse/designs/EditorConfiguration.html