Author: rob.stryker(a)jboss.com
Date: 2008-06-04 13:00:19 -0400 (Wed, 04 Jun 2008)
New Revision: 8551
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PortSection.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerPollingAttributes.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PollerSection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-2129 - ports section in editor
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java 2008-06-04
15:21:22 UTC (rev 8550)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -21,18 +21,46 @@
*/
package org.jboss.ide.eclipse.as.core.server;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
/**
*
* @author Rob Stryker
*
*/
public interface IJBossServerConstants {
+
+ // Launch configuration constants
public static final String JBOSS_SERVER_HOME_DIR = "jboss.server.home.dir";
public static final String JBOSS_SERVER_BASE_DIR = "jboss.server.base.dir";
public static final String JBOSS_SERVER_NAME = "jboss.server.name";
public static final String JBOSS_HOME_DIR = "jboss.home.dir";
+ // Folder constants
public static final String DEFAULT_SERVER_NAME = "default";
public static final String DEPLOY = "deploy";
public static final String SERVER = "server";
+
+ // Property keys stored in the server object
+ public static final String SERVER_USERNAME =
"org.jboss.ide.eclipse.as.core.server.userName";
+ public static final String SERVER_PASSWORD =
"org.jboss.ide.eclipse.as.core.server.password";
+ public static final String JNDI_PORT =
"org.jboss.ide.eclipse.as.core.server.jndiPort";
+ public static final String WEB_PORT =
"org.jboss.ide.eclipse.as.core.server.webPort";
+ public static final String JNDI_PORT_DETECT =
"org.jboss.ide.eclipse.as.core.server.jndiPortAutoDetect";
+ public static final String WEB_PORT_DETECT=
"org.jboss.ide.eclipse.as.core.server.webPortAutoDetect";
+ public static final String JNDI_PORT_DETECT_XPATH =
"org.jboss.ide.eclipse.as.core.server.jndiPortAutoDetect.XPath";
+ public static final String WEB_PORT_DETECT_XPATH =
"org.jboss.ide.eclipse.as.core.server.webPortAutoDetect.XPath";
+ public static final String JNDI_PORT_DEFAULT_XPATH = "Ports" + Path.SEPARATOR
+ "JNDI";
+ public static final String WEB_PORT_DEFAULT_XPATH = "Ports" + Path.SEPARATOR +
"JBoss Web";
+ public static final int JNDI_DEFAULT_PORT = 1099;
+ public static final int JBOSS_WEB_DEFAULT_PORT = 8080;
+
+
+ // Poller constants
+ public static final String STARTUP_POLLER_KEY =
"org.jboss.ide.eclipse.as.core.server.attributes.startupPollerKey";
+ public static final String SHUTDOWN_POLLER_KEY =
"org.jboss.ide.eclipse.as.core.server.attributes.shutdownPollerKey";
+ public static final String DEFAULT_STARTUP_POLLER =
"org.jboss.ide.eclipse.as.core.runtime.server.JMXPoller";
+ public static final String DEFAULT_SHUTDOWN_POLLER =
"org.jboss.ide.eclipse.as.core.runtime.server.processTerminatedPoller";
+
}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerPollingAttributes.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerPollingAttributes.java 2008-06-04
15:21:22 UTC (rev 8550)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerPollingAttributes.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -1,33 +0,0 @@
-/**
- * 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.core.server;
-
-/**
- *
- * @author Rob Stryker
- */
-public interface IServerPollingAttributes {
- public static final String STARTUP_POLLER_KEY =
"org.jboss.ide.eclipse.as.core.server.attributes.startupPollerKey";
- public static final String SHUTDOWN_POLLER_KEY =
"org.jboss.ide.eclipse.as.core.server.attributes.shutdownPollerKey";
- public static final String DEFAULT_STARTUP_POLLER =
"org.jboss.ide.eclipse.as.core.runtime.server.JMXPoller";
- public static final String DEFAULT_SHUTDOWN_POLLER =
"org.jboss.ide.eclipse.as.core.runtime.server.processTerminatedPoller";
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-06-04
15:21:22 UTC (rev 8550)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -33,7 +33,7 @@
* @author Rob Stryker
*
*/
-public interface IServerStatePoller extends IServerPollingAttributes {
+public interface IServerStatePoller {
public static final boolean SERVER_UP = true;
public static final boolean SERVER_DOWN = false;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2008-06-04
15:21:22 UTC (rev 8550)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -27,7 +27,6 @@
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -56,9 +55,6 @@
public class JBossServer extends DeployableServer
implements IJBossServerConstants, IDeployableServer, IURLProvider {
- public static final String SERVER_USERNAME =
"org.jboss.ide.eclipse.as.core.server.userName";
- public static final String SERVER_PASSWORD =
"org.jboss.ide.eclipse.as.core.server.password";
-
public JBossServer() {
}
@@ -164,39 +160,42 @@
protected String getRuntimeConfigDirectory() {
IJBossServerRuntime runtime = (IJBossServerRuntime)
getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
- String p = getServer().getRuntime().getLocation().toOSString() + Path.SEPARATOR +
"server" +
+ String p = getServer().getRuntime().getLocation().toOSString() + Path.SEPARATOR +
SERVER +
Path.SEPARATOR + runtime.getJBossConfiguration();
return new Path(p).toOSString();
}
- private static final IPath JNDI_KEY = new
Path("Ports").append("JNDI");
- private static final int JNDI_DEFAULT_PORT = 1099;
public int getJNDIPort() {
- int port = findPort(JNDI_KEY);
- return port == -1 ? JNDI_DEFAULT_PORT : port;
+ return findPort(JNDI_PORT, JNDI_PORT_DETECT, JNDI_PORT_DETECT_XPATH,
+ JNDI_PORT_DEFAULT_XPATH, JNDI_DEFAULT_PORT);
}
- private static final IPath JBOSS_WEB_KEY = new
Path("Ports").append("JBoss Web");
- public static final int JBOSS_WEB_DEFAULT_PORT = 8080;
public int getJBossWebPort() {
- int port = findPort(JBOSS_WEB_KEY);
- return port == -1 ? JBOSS_WEB_DEFAULT_PORT : port;
+ return findPort(WEB_PORT, WEB_PORT_DETECT, WEB_PORT_DETECT_XPATH,
+ WEB_PORT_DEFAULT_XPATH, JBOSS_WEB_DEFAULT_PORT);
}
- protected int findPort(IPath path) {
-
- XPathQuery query = XPathModel.getDefault().getQuery(getServer(), path);
+ protected int findPort(String attributeKey, String detectKey, String xpathKey, String
defaultXPath, int defaultValue) {
+ boolean detect = getAttribute(detectKey, true);
+ String result = null;
+ if( !detect ) {
+ result = getAttribute(attributeKey, (String)null);
+ } else {
+ String xpath = getAttribute(xpathKey, defaultXPath);
+ XPathQuery query = XPathModel.getDefault().getQuery(getServer(), new Path(xpath));
if(query!=null) {
- String result = query.getFirstResult();
- if( result != null ) {
- try {
- return Integer.parseInt(result);
- } catch(NumberFormatException nfe) {
- return -1;
- }
- }
- }
- return -1;
+ result = query.getFirstResult();
+ }
+ }
+
+ if( result != null ) {
+ try {
+ return Integer.parseInt(result);
+ } catch(NumberFormatException nfe) {
+ return defaultValue;
+ }
+ }
+ return defaultValue;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-06-04
15:21:22 UTC (rev 8550)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -24,13 +24,12 @@
import java.util.Date;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.internal.ServerType;
import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogRoot;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
-import org.jboss.ide.eclipse.as.core.server.IServerPollingAttributes;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.PollingException;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.RequiresInfoException;
@@ -80,11 +79,11 @@
JBossServer s = ServerConverter.getJBossServer(behavior.getServer());
ServerAttributeHelper helper = s.getAttributeHelper();
String key = expectedState == IServerStatePoller.SERVER_UP ?
- IServerPollingAttributes.STARTUP_POLLER_KEY :
- IServerPollingAttributes.SHUTDOWN_POLLER_KEY;
+ IJBossServerConstants.STARTUP_POLLER_KEY :
+ IJBossServerConstants.SHUTDOWN_POLLER_KEY;
String defaultPoller = expectedState == IServerStatePoller.SERVER_UP ?
- IServerPollingAttributes.DEFAULT_STARTUP_POLLER :
- IServerPollingAttributes.DEFAULT_SHUTDOWN_POLLER;
+ IJBossServerConstants.DEFAULT_STARTUP_POLLER :
+ IJBossServerConstants.DEFAULT_SHUTDOWN_POLLER;
String pollerId = helper.getAttribute(key, defaultPoller);
ServerStatePollerType type = ExtensionManager.getDefault().getPollerType(pollerId);
if( type != null ) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2008-06-04
15:21:22 UTC (rev 8550)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -206,6 +206,10 @@
public static String FilesetsNewExcludes;
public static String FilesetsNewPreview;
+
+ /* Editor Strings */
+
+
static {
NLS.initializeMessages(JBossServerUIPlugin.PLUGIN_ID + ".Messages",
Messages.class);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PollerSection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PollerSection.java 2008-06-04
15:21:22 UTC (rev 8550)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PollerSection.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -18,7 +18,7 @@
import org.eclipse.wst.server.ui.editor.ServerEditorSection;
import org.eclipse.wst.server.ui.internal.command.ServerCommand;
import org.jboss.ide.eclipse.as.core.ExtensionManager;
-import org.jboss.ide.eclipse.as.core.server.IServerPollingAttributes;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
@@ -77,8 +77,8 @@
startPollerCombo.setEnabled(true);
stopPollerCombo.setEnabled(true);
- String currentStartId =
helper.getAttribute(IServerPollingAttributes.STARTUP_POLLER_KEY,
IServerPollingAttributes.DEFAULT_STARTUP_POLLER);
- String currentStopId =
helper.getAttribute(IServerPollingAttributes.SHUTDOWN_POLLER_KEY,
IServerPollingAttributes.DEFAULT_SHUTDOWN_POLLER);
+ String currentStartId = helper.getAttribute(IJBossServerConstants.STARTUP_POLLER_KEY,
IJBossServerConstants.DEFAULT_STARTUP_POLLER);
+ String currentStopId = helper.getAttribute(IJBossServerConstants.SHUTDOWN_POLLER_KEY,
IJBossServerConstants.DEFAULT_SHUTDOWN_POLLER);
startPollerCombo.select(startPollerCombo.indexOf(ExtensionManager.getDefault().getPollerType(currentStartId).getName()));
stopPollerCombo.select(stopPollerCombo.indexOf(ExtensionManager.getDefault().getPollerType(currentStopId).getName()));
@@ -118,16 +118,16 @@
public class SetStartupPollerCommand extends SetPollerCommand {
public SetStartupPollerCommand(IServerWorkingCopy server) {
- super(server, "Change Start Poller",
IServerPollingAttributes.STARTUP_POLLER_KEY,
- IServerPollingAttributes.DEFAULT_STARTUP_POLLER,
+ super(server, "Change Start Poller",
IJBossServerConstants.STARTUP_POLLER_KEY,
+ IJBossServerConstants.DEFAULT_STARTUP_POLLER,
startupTypes, startPollerCombo, startPollerListener);
}
}
public class SetStopPollerCommand extends SetPollerCommand {
public SetStopPollerCommand(IServerWorkingCopy server) {
- super(server, "Change Stop Poller",
IServerPollingAttributes.SHUTDOWN_POLLER_KEY,
- IServerPollingAttributes.DEFAULT_SHUTDOWN_POLLER,
+ super(server, "Change Stop Poller",
IJBossServerConstants.SHUTDOWN_POLLER_KEY,
+ IJBossServerConstants.DEFAULT_SHUTDOWN_POLLER,
shutdownTypes, stopPollerCombo, stopPollerListener);
}
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PortSection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PortSection.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/PortSection.java 2008-06-04
17:00:19 UTC (rev 8551)
@@ -0,0 +1,325 @@
+package org.jboss.ide.eclipse.as.ui.editor;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.editor.ServerEditorSection;
+import org.eclipse.wst.server.ui.internal.command.ServerCommand;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+
+/**
+ *
+ * @author rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class PortSection extends ServerEditorSection {
+ protected ServerAttributeHelper helper;
+ protected Label jndiLabel, webLabel;
+ protected Text jndiText, webText;
+ protected Button jndiDetect, webDetect;
+ protected Combo jndiDetectCombo, webDetectCombo;
+
+ public void init(IEditorSite site, IEditorInput input) {
+ super.init(site, input);
+ helper = new ServerAttributeHelper(server.getOriginal(), server);
+ }
+
+ public void createSection(Composite parent) {
+ super.createSection(parent);
+ createUI(parent);
+ initializeState();
+ addListeners();
+ }
+
+ protected void initializeState() {
+ boolean detectJNDI = helper.getAttribute(IJBossServerConstants.JNDI_PORT_DETECT,
true);
+ jndiDetect.setSelection(detectJNDI);
+ jndiDetectCombo.setEnabled(detectJNDI);
+ jndiText.setEnabled(!detectJNDI);
+ jndiText.setEditable(!detectJNDI);
+ String jndiXPath = helper.getAttribute(IJBossServerConstants.JNDI_PORT_DETECT_XPATH,
IJBossServerConstants.JNDI_PORT_DEFAULT_XPATH.toString());
+ int index = jndiDetectCombo.indexOf(jndiXPath);
+ if( index != -1 ) {
+ jndiDetectCombo.select(index);
+ if( detectJNDI )
+ jndiText.setText(findPort(new Path(jndiXPath)));
+ else
+ jndiText.setText(helper.getAttribute(IJBossServerConstants.JNDI_PORT,
""));
+ }
+
+ boolean detectWeb = helper.getAttribute(IJBossServerConstants.WEB_PORT_DETECT, true);
+ webDetect.setSelection(detectWeb);
+ webDetectCombo.setEnabled(detectWeb);
+ webText.setEnabled(!detectWeb);
+ webText.setEditable(!detectWeb);
+ String webXPath = helper.getAttribute(IJBossServerConstants.WEB_PORT_DETECT_XPATH,
IJBossServerConstants.WEB_PORT_DEFAULT_XPATH.toString());
+ int index2 = webDetectCombo.indexOf(webXPath);
+ if( index2 != -1 ) {
+ webDetectCombo.select(index2);
+ if( detectWeb )
+ webText.setText(findPort(new Path(webXPath)));
+ else
+ webText.setText(helper.getAttribute(IJBossServerConstants.WEB_PORT, ""));
+ }
+ }
+
+ protected String findPort(IPath path) {
+ XPathQuery query = XPathModel.getDefault().getQuery(server.getOriginal(), path);
+ if(query!=null) {
+ String result = query.getFirstResult();
+ if( result != null ) {
+ return result;
+ }
+ }
+ return "-1";
+}
+
+
+ protected void createUI(Composite parent) {
+
+ FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+ Section section = toolkit.createSection(parent,
ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);
+ section.setText("Server Ports");
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
GridData.VERTICAL_ALIGN_FILL));
+
+ Composite composite = toolkit.createComposite(section);
+ composite.setLayout(new FormLayout());
+ Label description = new Label(composite, SWT.NONE);
+ description.setText("The ports entered here are which ports the tools\nwill poll
the server on. Changing these fields\nwill not change the ports the server itself listens
on.");
+
+ Composite jndiChild = createJNDIUI(composite);
+ Composite webChild = createWebUI(composite);
+
+ FormData data = new FormData();
+ data.top = new FormAttachment(0,5);
+ description.setLayoutData(data);
+
+ data = new FormData();
+ data.top = new FormAttachment(description, 5);
+ jndiChild.setLayoutData(data);
+
+ data = new FormData();
+ data.top = new FormAttachment(jndiChild, 5);
+ webChild.setLayoutData(data);
+
+ toolkit.paintBordersFor(composite);
+ section.setClient(composite);
+ }
+
+ protected Composite createJNDIUI(Composite composite) {
+ Composite child = new Composite(composite, SWT.NONE);
+ child.setLayout(new FormLayout());
+ jndiLabel = new Label(child, SWT.NONE);
+ jndiText = new Text(child, SWT.DEFAULT);
+ jndiDetect = new Button(child, SWT.CHECK);
+ jndiDetectCombo = new Combo(child, SWT.DEFAULT);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0,5);
+ data.top = new FormAttachment(0,5);
+ jndiLabel.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(jndiLabel,5);
+ data.right = new FormAttachment(jndiLabel, 150);
+ data.top = new FormAttachment(0,5);
+ jndiText.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(jndiText,5);
+ data.top = new FormAttachment(0,5);
+ jndiDetect.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(jndiDetect,5);
+ data.top = new FormAttachment(0,5);
+ jndiDetectCombo.setLayoutData(data);
+
+ jndiLabel.setText("JNDI Port: ");
+ jndiDetect.setText("Automatically detect");
+ jndiDetectCombo.setItems(getXPathStrings());
+ return child;
+ }
+
+ protected Composite createWebUI(Composite composite) {
+ Composite child = new Composite(composite, SWT.NONE);
+ child.setLayout(new FormLayout());
+ webLabel = new Label(child, SWT.NONE);
+ webText = new Text(child, SWT.DEFAULT);
+ webDetect = new Button(child, SWT.CHECK);
+ webDetectCombo = new Combo(child, SWT.DEFAULT);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0,5);
+ data.top = new FormAttachment(0,5);
+ webLabel.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(webLabel,5);
+ data.right = new FormAttachment(webLabel, 150);
+ data.top = new FormAttachment(0,5);
+ webText.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(webText,5);
+ data.top = new FormAttachment(0,5);
+ webDetect.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(webDetect,5);
+ data.top = new FormAttachment(0,5);
+ webDetectCombo.setLayoutData(data);
+
+ webLabel.setText("web Port: ");
+ webDetect.setText("Automatically detect");
+ webDetectCombo.setItems(getXPathStrings());
+ return child;
+ }
+
+ protected String[] getXPathStrings() {
+ ArrayList<String> list = new ArrayList<String>();
+ XPathCategory[] categories =
XPathModel.getDefault().getCategories(server.getOriginal());
+ for( int i = 0; i < categories.length; i++ ) {
+ XPathQuery[] queries = categories[i].getQueries();
+ for( int j = 0; j < queries.length; j++ ) {
+ list.add(categories[i].getName() + IPath.SEPARATOR + queries[j].getName());
+ }
+ }
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+
+ protected Listener jndiListener, webListener;
+
+ protected void addListeners() {
+ jndiListener = new Listener() {
+ public void handleEvent(Event event) {
+ execute(new ChangeJNDICommand(server));
+ }
+ };
+ jndiText.addListener(SWT.Modify, jndiListener);
+ jndiDetect.addListener(SWT.Selection, jndiListener);
+ jndiDetectCombo.addListener(SWT.Modify, jndiListener);
+
+ webListener = new Listener() {
+ public void handleEvent(Event event) {
+ execute(new ChangeWebCommand(server));
+ }
+ };
+ webText.addListener(SWT.Modify, webListener);
+ webDetect.addListener(SWT.Selection, webListener);
+ webDetectCombo.addListener(SWT.Modify, webListener);
+
+ }
+
+ public class ChangeJNDICommand extends SetPortCommand {
+ public ChangeJNDICommand(IServerWorkingCopy server) {
+ super(server, "Change JNDI Details",
+ IJBossServerConstants.JNDI_PORT, IJBossServerConstants.JNDI_PORT_DETECT,
+ IJBossServerConstants.JNDI_PORT_DETECT_XPATH,
IJBossServerConstants.JNDI_PORT_DEFAULT_XPATH,
+ jndiText, jndiDetect, jndiDetectCombo, jndiListener);
+ }
+ }
+
+ public class ChangeWebCommand extends SetPortCommand {
+ public ChangeWebCommand(IServerWorkingCopy server) {
+ super(server, "Change Web Port Details",
+ IJBossServerConstants.WEB_PORT, IJBossServerConstants.WEB_PORT_DETECT,
+ IJBossServerConstants.WEB_PORT_DETECT_XPATH,
IJBossServerConstants.WEB_PORT_DEFAULT_XPATH,
+ webText, webDetect, webDetectCombo, webListener);
+ }
+ }
+
+
+ public class SetPortCommand extends ServerCommand {
+ String textAttribute, overrideAttribute, overridePathAttribute;
+ String preText, prePath, defaultPath;
+ boolean preOverride;
+ Text text;
+ Button button;
+ Combo combo;
+ Listener listener;
+ public SetPortCommand(IServerWorkingCopy server, String name,
+ String textAttribute, String overrideAttribute, String overridePathAttribute,
+ String pathDefault, Text text, Button button, Combo xpath, Listener listener) {
+ super(server, name);
+ this.textAttribute = textAttribute;
+ this.overrideAttribute = overrideAttribute;
+ this.overridePathAttribute = overridePathAttribute;
+ this.defaultPath = pathDefault;
+ this.text = text;
+ this.button = button;
+ this.combo = xpath;
+ this.listener = listener;
+ }
+
+ public void execute() {
+ preText = helper.getAttribute(textAttribute, (String)null);
+ prePath = helper.getAttribute(overridePathAttribute, (String)defaultPath);
+ preOverride = helper.getAttribute(overrideAttribute, false);
+ helper.setAttribute(textAttribute, text.getText());
+ helper.setAttribute(overrideAttribute, button.getSelection());
+ helper.setAttribute(overridePathAttribute, combo.getText());
+
+ text.setEnabled(!button.getSelection());
+ text.setEditable(!button.getSelection());
+ combo.setEnabled(button.getSelection());
+ if( button.getSelection() ) {
+ text.removeListener(SWT.Modify, listener);
+ text.setText(findPort(new Path(combo.getText())));
+ text.addListener(SWT.Modify, listener);
+ }
+ }
+
+ public void undo() {
+ // set new values
+ helper.setAttribute(textAttribute, preText);
+ helper.setAttribute(overrideAttribute, preOverride);
+ helper.setAttribute(overridePathAttribute, prePath);
+
+ // update ui
+ combo.removeListener(SWT.Modify, listener);
+ text.removeListener(SWT.Modify, listener);
+ button.removeListener(SWT.Selection, listener);
+
+ button.setSelection(preOverride);
+ text.setText(preText == null ? "" : preText);
+ int ind = combo.indexOf(prePath);
+ if( ind == -1 )
+ combo.clearSelection();
+ else
+ combo.select(ind);
+
+ text.setEnabled(!preOverride);
+ text.setEditable(!preOverride);
+ combo.setEnabled(preOverride);
+
+ combo.addListener(SWT.Modify, listener);
+ button.addListener(SWT.Selection, listener);
+ text.addListener(SWT.Modify, listener);
+ }
+ }
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-06-04 15:21:22 UTC (rev
8550)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-06-04 17:00:19 UTC (rev
8551)
@@ -237,8 +237,14 @@
id="org.jboss.ide.eclipse.as.ui.editor.pollerSection"
insertionId="org.eclipse.wst.server.editor.overview.right"
order="10"
- typeIds="org.jboss.ide.eclipse.as.systemCopyServer,
org.jboss.ide.eclipse.as.32, org.jboss.ide.eclipse.as.40, org.jboss.ide.eclipse.as.42,
org.jboss.ide.eclipse.as.50"/>
+ typeIds="org.jboss.ide.eclipse.as.32, org.jboss.ide.eclipse.as.40,
org.jboss.ide.eclipse.as.42, org.jboss.ide.eclipse.as.50"/>
<section
+ class="org.jboss.ide.eclipse.as.ui.editor.PortSection"
+ id="org.jboss.ide.eclipse.as.ui.editor.portSection"
+ insertionId="org.eclipse.wst.server.editor.overview.right"
+ order="11"
+ typeIds="org.jboss.ide.eclipse.as.32, org.jboss.ide.eclipse.as.40,
org.jboss.ide.eclipse.as.42, org.jboss.ide.eclipse.as.50"/>
+ <section
class="org.jboss.ide.eclipse.as.ui.editor.ServerPasswordSection"
id="org.jboss.ide.eclipse.as.ui.editor.passwordSection"
insertionId="org.eclipse.wst.server.editor.overview.left"