[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/proposals/internal ...
Robert Stryker
rawblem at gmail.com
Thu Jan 25 15:08:10 EST 2007
User: rawb
Date: 07/01/25 15:08:10
Added: as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/proposals/internal
ConvertNodeToXPathDialogProvider.java
ConvertNodeToXPathDialogOutlineMenuItemProvider.java
Log:
Swapped dependency direction. MBeans now depends on ui, instead of the other way around.
Also fixed (temp) a bug in new mbean wizard due to upstream eclipse code (smite them, lord, please)
Revision Changes Path
1.1 date: 2007/01/25 20:08:10; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/proposals/internal/ConvertNodeToXPathDialogProvider.java
Index: ConvertNodeToXPathDialogProvider.java
===================================================================
/**
* JBoss, a Division of Red Hat
* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.ide.eclipse.as.ui.mbeans.editors.proposals.internal;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.wst.xml.core.internal.document.AttrImpl;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor;
import org.jboss.ide.eclipse.as.ui.dialogs.ConvertNodeToXPathDialog.OpenXPathDialogProposal;
import org.jboss.ide.eclipse.as.ui.mbeans.editors.proposals.IServiceXMLQuickFixProposalProvider;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
*
* @author rob.stryker at jboss.com
*/
public class ConvertNodeToXPathDialogProvider extends XMLContentAssistProcessor
implements IServiceXMLQuickFixProposalProvider {
public ICompletionProposal[] getProposals(ITextViewer viewer, int offset) {
return computeCompletionProposals(viewer, offset);
}
protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
Node n = contentAssistRequest.getNode();
String name = n.getNodeName();
String attName = ((AttrImpl)n.getAttributes().getNamedItem(contentAssistRequest.getText())).getName();
contentAssistRequest.addProposal(createProposal(n, attName));
}
protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
String elementName = contentAssistRequest.getNode().getNodeName();
String match = contentAssistRequest.getMatchString();
String text = contentAssistRequest.getText();
int beginPos = contentAssistRequest.getReplacementBeginPosition();
// find the attribute we're inside of, because the contentAssistRequester only returns the element (BOO!)
NamedNodeMap map = contentAssistRequest.getNode().getAttributes();
boolean found = false;
AttrImpl attribute = null;
for( int i = 0; i < map.getLength() && !found; i++ ) {
Node tmp = map.item(i);
if( tmp instanceof AttrImpl ) {
int start = ((AttrImpl)tmp).getStartOffset();
int end = ((AttrImpl)tmp).getEndOffset();
if( beginPos > start && beginPos < end ) {
found = true;
attribute = (AttrImpl)tmp;
}
}
}
if( found ) {
contentAssistRequest.addProposal(createProposal(contentAssistRequest.getNode(), attribute.getName()));
}
}
protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
}
protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
contentAssistRequest.addProposal(createProposal(contentAssistRequest.getNode(), null));
}
protected ICompletionProposal createProposal(Node node, String attributeName) {
return new OpenXPathDialogProposal(node, attributeName);
}
}
1.1 date: 2007/01/25 20:08:10; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/proposals/internal/ConvertNodeToXPathDialogOutlineMenuItemProvider.java
Index: ConvertNodeToXPathDialogOutlineMenuItemProvider.java
===================================================================
/**
* JBoss, a Division of Red Hat
* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.ide.eclipse.as.ui.mbeans.editors.proposals.internal;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.wst.xml.core.internal.document.AttrImpl;
import org.jboss.ide.eclipse.as.ui.dialogs.ConvertNodeToXPathDialog.ConvertNodeRunnable;
import org.jboss.ide.eclipse.as.ui.mbeans.editors.proposals.IServiceXMLOutlineActionProvider;
import org.w3c.dom.Node;
/**
*
* @author rob.stryker at jboss.com
*/
public class ConvertNodeToXPathDialogOutlineMenuItemProvider implements
IServiceXMLOutlineActionProvider {
public void release() {
}
public void menuAboutToShow(IMenuManager manager, ISelection selection) {
Object o = ((IStructuredSelection)selection).getFirstElement();
Node n;
String attName = null;
if( o instanceof Node ) {
n = (Node)o;
if( n instanceof AttrImpl) {
attName = ((AttrImpl)n).getName();
n = ((AttrImpl)n).getOwnerElement();
}
final Node n2 = n;
final String attName2 = attName;
Action temp = new Action() {
public void run() {
new ConvertNodeRunnable(n2, attName2).run();
}
};
temp.setText("Add to XPaths");
temp.setDescription("Add this element to the list of xpaths you can edit from the properties view.");
manager.add(temp);
}
}
}
More information about the jboss-cvs-commits
mailing list