[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs ...
Robert Stryker
rawblem at gmail.com
Fri Jan 12 14:48:41 EST 2007
User: rawb
Date: 07/01/12 14:48:41
Modified: as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs
XPathDialogs.java ConvertNodeToXPathDialog.java
Log:
deployableserver can now use xpath stuff
Revision Changes Path
1.12 +51 -10 jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: XPathDialogs.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- XPathDialogs.java 11 Jan 2007 20:44:18 -0000 1.11
+++ XPathDialogs.java 12 Jan 2007 19:48:41 -0000 1.12
@@ -70,6 +70,7 @@
import org.jboss.ide.eclipse.as.core.model.DescriptorModel.ServerDescriptorModel.XPathTreeItem2;
import org.jboss.ide.eclipse.as.core.server.JBossServer;
import org.jboss.ide.eclipse.as.core.server.ServerAttributeHelper.XPathPreferenceTreeItem;
+import org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
import org.jboss.ide.eclipse.as.ui.Messages;
import org.jboss.ide.eclipse.as.ui.views.server.providers.DescriptorXPathViewProvider.XPathPropertyLabelProvider;
@@ -174,7 +175,7 @@
protected XPathProposalProvider proposalProvider;
protected SimpleTreeItem tree;
- protected JBossServer server;
+ protected IDeployableServer server;
protected String name, xpath, attribute, category;
protected String originalName = null;
protected XPathPreferenceTreeItem original = null;
@@ -188,15 +189,16 @@
public XPathDialog(Shell parentShell) {
this(parentShell, null);
}
- public XPathDialog(Shell parentShell, JBossServer server) {
+ public XPathDialog(Shell parentShell, IDeployableServer server) {
this(parentShell, server, null);
}
- public XPathDialog(Shell parentShell, JBossServer server, String categoryName) {
+ public XPathDialog(Shell parentShell, IDeployableServer server, String categoryName) {
this(parentShell, server, categoryName, null);
}
- public XPathDialog(Shell parentShell, JBossServer server, String categoryName, String originalName) {
+ public XPathDialog(Shell parentShell, IDeployableServer server, String categoryName, String originalName) {
super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
this.category = categoryName;
this.server = server;
this.originalName = this.name = originalName;
@@ -206,10 +208,13 @@
protected void configureShell(Shell shell) {
super.configureShell(shell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
shell.setText(Messages.XPathNewXpath);
shell.setBounds(shell.getLocation().x, shell.getLocation().y, 550, 400);
}
+ protected int getShellStyle() {
+ int ret = super.getShellStyle();
+ return ret | SWT.RESIZE;
+ }
protected void createButtonsForButtonBar(Composite parent) {
// create OK and Cancel buttons by default
@@ -241,6 +246,16 @@
proposalProvider, null, null);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+
+
+ XPathAttributeProposalProvider provider2 = new XPathAttributeProposalProvider(xpathText);
+ provider2.setServer(server);
+ ContentProposalAdapter adapter2 = new
+ ContentProposalAdapter(attributeText, new TextContentAdapter(),
+ provider2, null, null);
+ adapter2.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+
+
return main;
}
@@ -623,7 +638,7 @@
public String getCategory() {
return category;
}
- public JBossServer getServer() {
+ public IDeployableServer getServer() {
return server;
}
@@ -646,7 +661,33 @@
}
}
-
+ public static class XPathAttributeProposalProvider extends XPathProposalProvider {
+ private Text elementText;
+ public XPathAttributeProposalProvider(Text elementText) {
+ this.elementText = elementText;
+ }
+ public IContentProposal[] getProposals(String contents, int position) {
+ int type = getType(elementText.getText());
+ if( type == 4 ) {
+ String[] strings = getAttributeNameProposalStrings(elementText.getText(), contents);
+ return convertProposals(strings);
+ }
+ return null;
+ }
+ public String[] getAttributeNameProposalStrings(String parentPath, String remainder) {
+ ArrayList names = new ArrayList();
+ XPathTreeItem2[] items = getXPath(parentPath);
+ String[] attributes;
+ for( int i = 0; i < items.length; i++ ) {
+ attributes = items[0].getElementAttributeNames();
+ for( int j = 0; j < attributes.length; j++ ) {
+ if( attributes[j].startsWith(remainder) && !names.contains(attributes[j]))
+ names.add(attributes[j]);
+ }
+ }
+ return (String[]) names.toArray(new String[names.size()]);
+ }
+ }
public static class XPathProposalProvider implements IContentProposalProvider {
@@ -659,7 +700,7 @@
private static final int CLOSE_ATTRIBUTE = 7;
- private JBossServer server;
+ private IDeployableServer server;
private ServerDescriptorModel model;
private HashMap xpathCache;
@@ -667,10 +708,10 @@
public XPathProposalProvider() {
xpathCache = new HashMap();
}
- public void setServer(JBossServer server) {
+ public void setServer(IDeployableServer server) {
this.server = server;
if( server != null ) {
- String serverConfDir = server.getConfigDirectory(false);
+ String serverConfDir = server.getConfigDirectory();
model = DescriptorModel.getDefault().getServerModel(new Path(serverConfDir));
} else {
model = null;
1.3 +2 -2 jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ConvertNodeToXPathDialog.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConvertNodeToXPathDialog.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ConvertNodeToXPathDialog.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ConvertNodeToXPathDialog.java 14 Dec 2006 19:34:44 -0000 1.2
+++ ConvertNodeToXPathDialog.java 12 Jan 2007 19:48:41 -0000 1.3
@@ -58,6 +58,7 @@
import org.jboss.ide.eclipse.as.core.server.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.core.server.ServerAttributeHelper.SimpleXPathPreferenceTreeItem;
import org.jboss.ide.eclipse.as.core.server.ServerAttributeHelper.XPathPreferenceTreeItem;
+import org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
import org.jboss.ide.eclipse.as.ui.Messages;
import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathDialog;
@@ -337,7 +338,7 @@
ConvertNodeToXPathDialog d = new ConvertNodeToXPathDialog(new Shell(), node, attributeName);
int result = d.open();
if( result == Window.OK) {
- JBossServer s = d.getServer();
+ IDeployableServer s = d.getServer();
SimpleTreeItem tree = s.getAttributeHelper().getXPathPreferenceTree();
String category = d.getCategory();
SimpleTreeItem[] categories = tree.getChildren();
@@ -385,7 +386,6 @@
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);
- System.out.println(o);
}
}
}
More information about the jboss-cvs-commits
mailing list