[259275] [outline] Attributes can be added to scriptlets through the outline view
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/actions/JSPNodeActionManager.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/actions/JSPNodeActionManager.java
new file mode 100644
index 0000000..ba58b98
--- /dev/null
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/actions/JSPNodeActionManager.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.ui.internal.actions;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.jsp.core.internal.provisional.JSP11Namespace;
+import org.eclipse.wst.html.ui.internal.contentoutline.HTMLNodeActionManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.w3c.dom.Node;
+
+public class JSPNodeActionManager extends HTMLNodeActionManager {
+
+ public JSPNodeActionManager(IStructuredModel model, Viewer viewer) {
+ super(model, viewer);
+ }
+
+ protected boolean canContributeChildActions(Node node){
+ String nodeName = node.getNodeName().toLowerCase();
+ return !(nodeName.equals(JSP11Namespace.ElementName.SCRIPTLET) || nodeName.equals(JSP11Namespace.ElementName.DECLARATION) || nodeName.equals(JSP11Namespace.ElementName.EXPRESSION));
+ }
+
+}
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/views/contentoutline/JSPContentOutlineConfiguration.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/views/contentoutline/JSPContentOutlineConfiguration.java
index f9a1570..aaee92b 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/views/contentoutline/JSPContentOutlineConfiguration.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/views/contentoutline/JSPContentOutlineConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* 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
@@ -11,8 +11,12 @@
package org.eclipse.jst.jsp.ui.views.contentoutline;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
+import org.eclipse.jst.jsp.ui.internal.actions.JSPNodeActionManager;
import org.eclipse.wst.html.ui.views.contentoutline.HTMLContentOutlineConfiguration;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
/**
* Configuration for outline view page which shows JSP content.
@@ -48,4 +52,8 @@
protected IPreferenceStore getPreferenceStore() {
return JSPUIPlugin.getDefault().getPreferenceStore();
}
+
+ protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) {
+ return new JSPNodeActionManager((IStructuredModel) treeViewer.getInput(), treeViewer);
+ }
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java
index 4629a23..4465152 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2010 IBM Corporation and others.
* 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
@@ -151,11 +151,14 @@
}
}
+ protected boolean canContributeChildActions(Node node){
+ return true;
+ }
protected void contributeAddChildActions(IMenuManager menu, Node node, int ic, int vc) {
int nodeType = node.getNodeType();
- if (nodeType == Node.ELEMENT_NODE) {
+ if (nodeType == Node.ELEMENT_NODE && canContributeChildActions(node)) {
// 'Add Child...' and 'Add Attribute...' actions
//
Element element = (Element) node;
@@ -164,7 +167,7 @@
IMenuManager addChildMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_CHILD);
menu.add(addAttributeMenu);
menu.add(addChildMenu);
-
+
CMElementDeclaration ed = modelQuery.getCMElementDeclaration(element);
if (ed != null) {
// add insert attribute actions
@@ -172,7 +175,6 @@
List modelQueryActionList = new ArrayList();
modelQuery.getInsertActions(element, ed, -1, ModelQuery.INCLUDE_ATTRIBUTES, vc, modelQueryActionList);
addActionHelper(addAttributeMenu, modelQueryActionList);
-
// add insert child node actions
//
modelQueryActionList = new ArrayList();