Author: rob.stryker(a)jboss.com
Date: 2009-05-12 05:32:44 -0400 (Tue, 12 May 2009)
New Revision: 15221
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.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/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossConfigurationTableViewer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
Log:
JBIDE-3896 - implemented as shown
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.launching.JavaRuntime;
@@ -56,28 +57,26 @@
}
IPath loc = runtime.getLocation();
- String config = jbsrt.getJBossConfiguration();
+ IPath configPath = jbsrt.getConfigurationFullPath();
String rtID = runtime.getRuntimeType().getId();
- if(AS_32.equals(rtID)) return get32(loc, config);
- if(AS_40.equals(rtID)) return get40(loc,config);
- if(AS_42.equals(rtID)) return get42(loc,config);
- if(AS_50.equals(rtID)) return get50(loc,config);
- if(EAP_43.equals(rtID)) return getEAP43(loc,config);
+ if(AS_32.equals(rtID)) return get32(loc, configPath);
+ if(AS_40.equals(rtID)) return get40(loc,configPath);
+ if(AS_42.equals(rtID)) return get42(loc,configPath);
+ if(AS_50.equals(rtID)) return get50(loc,configPath);
+ if(EAP_43.equals(rtID)) return getEAP43(loc,configPath);
return null;
}
- protected IClasspathEntry[] get32(IPath location, String config) {
+ protected IClasspathEntry[] get32(IPath location, IPath configPath) {
ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- IPath configPath = location.append(SERVER).append(config);
addEntries(location.append(CLIENT), list);
addEntries(location.append(LIB), list);
addEntries(configPath.append(LIB), list);
return list.toArray(new IClasspathEntry[list.size()]);
}
- protected IClasspathEntry[] get40(IPath location, String config) {
+ protected IClasspathEntry[] get40(IPath location, IPath configPath) {
ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- IPath configPath = location.append(SERVER).append(config);
IPath deployPath = configPath.append(DEPLOY);
addEntries(location.append(CLIENT), list);
addEntries(location.append(LIB), list);
@@ -88,17 +87,16 @@
return list.toArray(new IClasspathEntry[list.size()]);
}
- protected IClasspathEntry[] get42(IPath location, String config) {
- return get40(location, config);
+ protected IClasspathEntry[] get42(IPath location, IPath configPath) {
+ return get40(location, configPath);
}
- protected IClasspathEntry[] getEAP43(IPath location, String config) {
- return get40(location, config);
+ protected IClasspathEntry[] getEAP43(IPath location, IPath configPath) {
+ return get40(location, configPath);
}
- protected IClasspathEntry[] get50(IPath location, String config) {
+ protected IClasspathEntry[] get50(IPath location, IPath configPath) {
ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- IPath configPath = location.append(SERVER).append(config);
IPath deployerPath = configPath.append(DEPLOYERS);
IPath deployPath = configPath.append(DEPLOY);
addEntries(location.append(CLIENT), list);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -81,8 +81,7 @@
LocalJBossServerRuntime ajbsr = (LocalJBossServerRuntime)
server2.getRuntime().loadAdapter(LocalJBossServerRuntime.class, null);
if(ajbsr != null ) {
- IPath loc = server2.getRuntime().getLocation();
- IPath configFolder =
loc.append(IJBossServerConstants.SERVER).append(ajbsr.getJBossConfiguration());
+ IPath configFolder = ajbsr.getConfigurationFullPath();
ArrayList<XPathCategory> defaults = loadDefaults(server2,
configFolder.toOSString());
serverToCategories.put(server2.getId(), defaults);
save(server2);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -12,6 +12,7 @@
import java.util.HashMap;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.wst.server.core.IRuntime;
@@ -32,9 +33,34 @@
public String getJBossConfiguration();
public void setJBossConfiguration(String config);
+
+ /**
+ * The folder this config is located in, for example:
+ * /home/rob/tmp/default_copy1 would return /home/rob/tmp/
+ * whereas /home/rob/apps/jboss/server/default_copy3 would return server
+ * @return
+ */
public String getConfigLocation();
+
+ /**
+ * The full path of the folder this config is located in, for example:
+ * /home/rob/tmp/default_copy1 would return
+ * /home/rob/tmp/
+ * whereas
+ * /home/rob/apps/jboss/server/default_copy3 would return
+ * /home/rob/apps/jboss/server
+ * @return
+ */
+ public IPath getConfigLocationFullPath();
+
public void setConfigLocation(String configLocation);
+ /**
+ * The full path of the configuration, ex:
+ * /home/rob/tmp/default_copy3 would return /home/rob/tmp/default_copy3
+ * @return
+ */
+ public IPath getConfigurationFullPath();
// for startup
public String getDefaultRunArgs();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -12,6 +12,7 @@
import java.util.HashMap;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
@@ -33,11 +34,6 @@
public class LocalJBossServerRuntime extends RuntimeDelegate implements
IJBossServerRuntime {
public void setDefaults(IProgressMonitor monitor) {
- String location = Platform.getOS().equals(Platform.WS_WIN32)
- ? "c:/program files/jboss-" : "/usr/bin/jboss-"; //$NON-NLS-1$
//$NON-NLS-2$
- String version = getRuntime().getRuntimeType().getVersion();
- location += version + ".x"; //$NON-NLS-1$
- getRuntimeWorkingCopy().setLocation(new Path(location));
getRuntimeWorkingCopy().setName(getNextRuntimeName());
setAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
IJBossServerConstants.DEFAULT_CONFIGURATION);
setVM(null);
@@ -150,10 +146,21 @@
}
public String getConfigLocation() {
- return getAttribute(PROPERTY_CONFIG_LOCATION, (String)null);
+ return getAttribute(PROPERTY_CONFIG_LOCATION, IConstants.SERVER);
}
public void setConfigLocation(String configLocation) {
setAttribute(PROPERTY_CONFIG_LOCATION, configLocation);
}
+
+ public IPath getConfigurationFullPath() {
+ return getConfigLocationFullPath().append(getJBossConfiguration());
+ }
+
+ public IPath getConfigLocationFullPath() {
+ String cl = getConfigLocation();
+ if( new Path(cl).isAbsolute())
+ return new Path(cl);
+ return getRuntime().getLocation().append(cl);
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -46,6 +46,7 @@
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
+import org.jboss.ide.eclipse.as.core.util.IConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
@@ -127,6 +128,15 @@
IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG, config);
+ try {
+ if( !runtime.getConfigLocation().equals(IConstants.SERVER)) {
+ args = ArgsUtil.setArg(args, null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JBOSS_SERVER_HOME_URL,
+ runtime.getConfigLocationFullPath().toFile().toURL().toString());
+ }
+ } catch( MalformedURLException murle) {}
+
+
vmArgs= ArgsUtil.setArg(vmArgs, null,
IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
runtime.getRuntime().getLocation().append(
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 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -27,15 +27,21 @@
/* Standard and re-usable */
public static String browse;
public static String serverName;
-
+ public static String copy;
+ public static String delete;
+ public static String directory;
+
/* Server and Runtime Wizard Fragments */
public static String wf_BaseNameVersionReplacement;
public static String wf_NameLabel;
public static String wf_HomeDirLabel;
public static String wf_JRELabel;
public static String wf_ConfigLabel;
+
public static String JBAS_version;
public static String JBEAP_version;
+ public static String rwf_CopyConfigLabel;
+ public static String rwf_DestinationLabel;
public static String rwf_TitleCreate;
public static String rwf_TitleEdit;
public static String rwf_Explanation;
@@ -50,6 +56,7 @@
public static String swf_AuthorizationDescription;
public static String swf_Explanation;
public static String swf_Explanation2;
+ public static String swf_ConfigurationLocation;
public static String swf_AuthenticationGroup;
public static String swf_Username;
public static String swf_Password;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2009-05-12
09:32:44 UTC (rev 15221)
@@ -1,11 +1,15 @@
browse=Browse...
serverName=Server Name
-
+copy=Copy...
+delete=Delete...
+directory=Directory:
wf_BaseNameVersionReplacement=_VERSION_
wf_NameLabel=Name
wf_HomeDirLabel=Home Directory
wf_JRELabel=JRE
wf_ConfigLabel=Configuration
+rwf_CopyConfigLabel=Copy configuration "{0}" to a new destination from
"{1}".
+rwf_DestinationLabel=Destination
rwf_TitleCreate=Create a new JBoss Runtime
rwf_TitleEdit=Edit a JBoss Runtime
rwf_Explanation=A JBoss Server runtime references a JBoss installation directory.\nIt can
be used to set up classpaths for projects which depend on this runtime,\nas well as by a
"server" which will be able to start and stop instances of JBoss.
@@ -21,6 +25,7 @@
swf_RuntimeInformation=Runtime Information
swf_Explanation=A JBoss Server manages starting and stopping instances of JBoss. \nIt
manages command line arguments and keeps track of which modules have been deployed.
swf_Explanation2=If the runtime information below is incorrect, please press back,
Installed Runtimes..., \nand then Add to create a new runtime from a different location.
+swf_ConfigurationLocation=Configuration Location
swf_AuthorizationDescription=Set the login and password for your server.\nThis will
ensure it starts and stops properly.
swf_AuthenticationGroup=Login Credentials
swf_Username=User Name
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -0,0 +1,39 @@
+package org.jboss.ide.eclipse.as.ui;
+
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Control;
+
+public class UIUtil {
+
+ public static FormData createFormData2(Object topStart, int topOffset, Object
bottomStart, int bottomOffset,
+ Object leftStart, int leftOffset, Object rightStart, int rightOffset) {
+ FormData data = new FormData();
+
+ if( topStart != null ) {
+ data.top = topStart instanceof Control ? new FormAttachment((Control)topStart,
topOffset) :
+ new FormAttachment(((Integer)topStart).intValue(), topOffset);
+ }
+
+ if( bottomStart != null ) {
+ data.bottom = bottomStart instanceof Control ? new
FormAttachment((Control)bottomStart, bottomOffset) :
+ new FormAttachment(((Integer)bottomStart).intValue(), bottomOffset);
+ }
+
+ if( leftStart != null ) {
+ data.left = leftStart instanceof Control ? new FormAttachment((Control)leftStart,
leftOffset) :
+ new FormAttachment(((Integer)leftStart).intValue(), leftOffset);
+ }
+
+ if( rightStart != null ) {
+ data.right = rightStart instanceof Control ? new FormAttachment((Control)rightStart,
rightOffset) :
+ new FormAttachment(((Integer)rightStart).intValue(), rightOffset);
+ }
+ return data;
+ }
+
+ public FormData createFormData(Object topStart, int topOffset, Object bottomStart, int
bottomOffset,
+ Object leftStart, int leftOffset, Object rightStart, int rightOffset) {
+ return createFormData2(topStart, topOffset, bottomStart, bottomOffset, leftStart,
leftOffset, rightStart, rightOffset);
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossConfigurationTableViewer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossConfigurationTableViewer.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossConfigurationTableViewer.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -30,6 +30,7 @@
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
@@ -37,7 +38,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
/**
@@ -46,8 +46,6 @@
public class JBossConfigurationTableViewer extends TableViewer {
// private String jbossHome;
private String selectedConfiguration;
- private WizardFragment fragment;
-
public JBossConfigurationTableViewer(Composite parent) {
super(parent);
init();
@@ -63,9 +61,8 @@
init();
}
- public void setJBossHome(String jbossHome) {
- // this.jbossHome = jbossHome;
- setInput(jbossHome);
+ public void setFolder(String folder) {
+ setInput(folder);
}
public String getSelectedConfiguration() {
@@ -73,20 +70,7 @@
}
public void setConfiguration(String defaultConfiguration) {
- int item = -1;
- TableItem items[] = getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null && items[i].getText() != null
- && items[i].getText().equals(defaultConfiguration)) {
- item = i;
- break;
- }
- }
-
- if (item != -1) {
- getTable().setSelection(item);
- }
-
+ setSelection(new StructuredSelection(defaultConfiguration));
selectedConfiguration = defaultConfiguration;
}
@@ -114,10 +98,6 @@
protected void configurationSelected() {
selectedConfiguration = getCurrentlySelectedConfiguration();
-
- if (fragment != null) {
- fragment.updateChildFragments();
- }
}
protected class ConfigurationProvider implements
@@ -132,8 +112,7 @@
public Object[] getElements(Object inputElement) {
ArrayList<String> configList = new ArrayList<String>();
- File serverDirectory = new File(inputElement.toString()
- + File.separator + "server");
+ File serverDirectory = new File(inputElement.toString());
if (serverDirectory.exists()) {
@@ -181,8 +160,4 @@
return (String) element;
}
}
-
- public void setWizardFragment(WizardFragment fragment) {
- this.fragment = fragment;
- }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -25,18 +25,27 @@
import java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -46,13 +55,18 @@
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
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.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
@@ -66,6 +80,8 @@
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.IConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.JBossServerType;
import org.jboss.ide.eclipse.as.core.util.ServerBeanLoader;
@@ -73,6 +89,7 @@
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.UIUtil;
/**
* @author Stryker
@@ -83,22 +100,29 @@
private boolean beenEntered = false;
- private Label nameLabel, homeDirLabel, installedJRELabel, configLabel,
- explanationLabel;
+ private Label nameLabel, homeDirLabel,
+ installedJRELabel, explanationLabel;
private Text nameText, homeDirText;
private Combo jreCombo;
private int jreComboIndex;
private Button homeDirButton, jreButton;
- private Composite nameComposite, homeDirComposite, jreComposite,
- configComposite, cloneComposite;
- private String name, homeDir, config;
+ private Composite nameComposite, homeDirComposite, jreComposite;
+ private String name, homeDir;
+ // Configuration stuff
+ private Composite configComposite;
+ private Group configGroup;
+ private Label configDirLabel;
+ private Text configDirText;
+ private JBossConfigurationTableViewer configurations;
+ private Button configCopy, configBrowse, configDelete;
+ private String configDirTextVal;
+
// jre fields
protected ArrayList<IVMInstall> installedJREs;
protected String[] jreNames;
protected int defaultVMIndex;
private IVMInstall selectedVM;
- private JBossConfigurationTableViewer configurations;
private String originalName;
public Composite createComposite(Composite parent, IWizardHandle handle) {
@@ -113,7 +137,6 @@
createHomeComposite(main);
createJREComposite(main);
createConfigurationComposite(main);
- createCloneComposite(main);
fillWidgets();
// make modifications to parent
@@ -163,14 +186,29 @@
originalName = rt.getRuntime().getName();
nameText.setText(originalName);
name = originalName;
- Preferences prefs = JBossServerUIPlugin.getDefault().getPluginPreferences();
- String value = prefs.getString(IPreferenceKeys.RUNTIME_HOME_PREF_KEY_PREFIX +
rt.getRuntime().getRuntimeType().getId());
- homeDir = (value != null && value.length() != 0) ? value :
rt.getRuntime().getLocation().toOSString();
+
+ if( rt.getRuntime().getLocation() == null ) {
+ // new runtime creation
+ Preferences prefs = JBossServerUIPlugin.getDefault().getPluginPreferences();
+ String value = prefs.getString(IPreferenceKeys.RUNTIME_HOME_PREF_KEY_PREFIX +
rt.getRuntime().getRuntimeType().getId());
+
+ String locationDefault = Platform.getOS().equals(Platform.WS_WIN32)
+ ? "c:/program files/jboss-" : "/usr/bin/jboss-"; //$NON-NLS-1$
//$NON-NLS-2$
+ String version = rt.getRuntime().getRuntimeType().getVersion();
+ locationDefault += version + ".x"; //$NON-NLS-1$
+
+ homeDir = (value != null && value.length() != 0) ? value : locationDefault;
+ } else {
+ // old runtime, load from it
+ homeDir = rt.getRuntime().getLocation().toOSString();
+ }
homeDirText.setText(homeDir);
+
((IRuntimeWorkingCopy)rt.getRuntime()).setLocation(new Path(homeDir));
- config = rt.getJBossConfiguration();
- configurations.setConfiguration(config);
- configLabel.setText(Messages.wf_ConfigLabel);
+ String dirText = rt.getConfigLocation();
+ configDirText.setText(dirText == null ? IConstants.SERVER : dirText);
+ configurations.setConfiguration(rt.getJBossConfiguration() == null
+ ? IConstants.DEFAULT_CONFIGURATION : rt.getJBossConfiguration());
if (rt.isUsingDefaultJRE()) {
jreCombo.select(0);
@@ -382,107 +420,167 @@
}
private void createConfigurationComposite(Composite main) {
+ UIUtil u = new UIUtil(); // top bottom left right
configComposite = new Composite(main, SWT.NONE);
-
- FormData cData = new FormData();
- cData.left = new FormAttachment(0, 5);
- cData.right = new FormAttachment(100, -5);
- cData.top = new FormAttachment(jreComposite, 10);
- cData.bottom = new FormAttachment(100, -5);
- configComposite.setLayoutData(cData);
-
+ configComposite.setLayoutData(u.createFormData(
+ jreComposite, 10, 100, -5, 0, 5, 100, -5));
configComposite.setLayout(new FormLayout());
+
+ configGroup = new Group(configComposite, SWT.DEFAULT);
+ configGroup.setText(Messages.wf_ConfigLabel);
+ configGroup.setLayoutData(u.createFormData(
+ 0, 0, 100, 0, 0, 0, 100, 0));
+ configGroup.setLayout(new FormLayout());
+
+ configDirLabel = new Label(configGroup, SWT.NONE);
+ configDirLabel.setText(Messages.directory);
+ configDirText = new Text(configGroup, SWT.BORDER);
- configLabel = new Label(configComposite, SWT.NONE);
- configLabel.setText(Messages.wf_ConfigLabel);
-
- configurations = new JBossConfigurationTableViewer(configComposite,
- SWT.BORDER | SWT.SINGLE);
-
- FormData labelData = new FormData();
- labelData.left = new FormAttachment(0, 5);
- configLabel.setLayoutData(labelData);
-
- FormData viewerData = new FormData();
- viewerData.left = new FormAttachment(0, 5);
- viewerData.right = new FormAttachment(100, -5);
- viewerData.top = new FormAttachment(configLabel, 5);
- viewerData.bottom = new FormAttachment(100, -5);
-
- configurations.getTable().setLayoutData(viewerData);
-
- configurations.getTable().addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
+ configurations = new JBossConfigurationTableViewer(configGroup,
+ SWT.BORDER | SWT.SINGLE);
+
+ configBrowse = new Button(configGroup, SWT.DEFAULT);
+ configCopy = new Button(configGroup, SWT.DEFAULT);
+ configDelete = new Button(configGroup, SWT.DEFAULT);
+ configBrowse.setText(Messages.browse);
+ configCopy.setText(Messages.copy);
+ configDelete.setText(Messages.delete);
+
+ // Organize them
+ configDirLabel.setLayoutData(u.createFormData(
+ 2, 5, null, 0, 0, 5, null, 0));
+ configDirText.setLayoutData(u.createFormData(
+ 0, 5, null, 0, configDirLabel, 5, configBrowse, -5));
+ configBrowse.setLayoutData(u.createFormData(
+ 0, 5, null, 0, configurations.getTable(), 5, 100, -5));
+ configurations.getTable().setLayoutData(u.createFormData(
+ configDirText, 5, 100,-5, 0,5, 80, 0));
+ configCopy.setLayoutData(u.createFormData(
+ configBrowse, 5, null, 0, configurations.getTable(), 5, 100, -5));
+ configDelete.setLayoutData(u.createFormData(
+ configCopy, 5, null, 0, configurations.getTable(), 5, 100, -5));
+
+ configDirText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
updatePage();
+ }
+ });
+
+ configBrowse.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ configBrowsePressed();
}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ configCopy.addSelectionListener(new SelectionListener(){
public void widgetSelected(SelectionEvent e) {
- updatePage();
+ configCopyPressed();
}
-
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
});
-
+ configDelete.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ configDeletePressed();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ configurations.addSelectionChangedListener(new ISelectionChangedListener(){
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateErrorMessage();
+ configDelete.setEnabled(!((IStructuredSelection)configurations.getSelection()).isEmpty());
+ configCopy.setEnabled(!((IStructuredSelection)configurations.getSelection()).isEmpty());
+ }
+ });
}
- private void createCloneComposite(Composite main) {
- IJBossServerRuntime rt = getRuntime();
- if (rt != null) {
+ protected void configBrowsePressed() {
+ String folder = new Path(configDirText.getText()).isAbsolute() ?
+ configDirText.getText() : new
Path(homeDir).append(configDirText.getText()).toString();
+ File file = new File(folder);
+ if (!file.exists()) {
+ file = null;
+ }
- cloneComposite = new Composite(main, SWT.NONE);
- FormData cData = new FormData();
- cData.left = new FormAttachment(0, 5);
- cData.right = new FormAttachment(100, -5);
- cData.top = new FormAttachment(configComposite, 5);
- cData.bottom = new FormAttachment(100, -5);
- cloneComposite.setLayoutData(cData);
-
- cloneComposite.setLayout(new FormLayout());
- Button cloneButton = new Button(cloneComposite, SWT.CHECK);
- cloneButton.setSelection(false);
- cloneButton.setText("Clone this configuration");
- cData = new FormData();
- cData.left = new FormAttachment(0, 5);
- cData.right = new FormAttachment(100, -5);
- cData.top = new FormAttachment(0, 5);
- cData.bottom = new FormAttachment(100, -5);
- cloneButton.setLayoutData(cData);
+ File directory = getDirectory(file, homeDirComposite.getShell());
+ if (directory != null) {
+ if(directory.getAbsolutePath().startsWith(new Path(homeDir).toString())) {
+ String result = directory.getAbsolutePath().substring(homeDir.length());
+ configDirText.setText(new Path(result).makeRelative().toString());
+ } else {
+ configDirText.setText(directory.getAbsolutePath());
+ }
+ }
+ }
+ protected void configCopyPressed() {
+ CopyConfigurationDialog d = new CopyConfigurationDialog(configCopy.getShell(), homeDir,
configDirText.getText(), configurations.getCurrentlySelectedConfiguration());
+ if(d.open() == 0 ) {
+ IPath source = new Path(configDirText.getText());
+ if( !source.isAbsolute())
+ source = new Path(homeDir).append(source);
+ source = source.append(configurations.getCurrentlySelectedConfiguration());
- Button intoConfigButton = new Button(cloneComposite, SWT.RADIO);
- Button intoLocationButton = new Button(cloneComposite, SWT.RADIO);
- Text newConfigName = new Text(cloneComposite, SWT.DEFAULT);
- Text newLocation = new Text(cloneComposite, SWT.DEFAULT);
-
-
- intoConfigButton.setText("new configuration name");
- intoLocationButton.setText("arbitrary location");
-
-
-
-
- } else {
- // TODO Display something useful in edit-runtime wizard
+ IPath dest = new Path(d.getNewDest());
+ if( !dest.isAbsolute())
+ dest = new Path(homeDir).append(dest);
+ dest = dest.append(d.getNewConfig());
+ dest.toFile().mkdirs();
+ org.jboss.tools.jmx.core.util.FileUtil.copyDir(source.toFile(), dest.toFile());
+ configDirText.setText(d.getNewDest());
+ configurations.setSelection(new StructuredSelection(d.getNewConfig()));
}
+
}
+ protected void configDeletePressed() {
+ MessageDialog dialog = new MessageDialog(configBrowse.getShell(),
+ "Delete Configuration?", null,
+ "Are you sure you want to delete this folder? This cannot be
undone.",
+ MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL }, 0); // yes is the default
+ if(dialog.open() == 0) {
+ String config = configurations.getCurrentlySelectedConfiguration();
+ String configDir = configDirText.getText();
+ File folder;
+ if( !new Path(configDir).isAbsolute())
+ folder = new Path(homeDir).append(configDir).append(config).toFile();
+ else
+ folder = new Path(configDir).append(config).toFile();
+
+ FileUtil.completeDelete(folder);
+ configurations.refresh();
+ updatePage();
+ }
+ }
+ // Launchable only from UI thread
private void updatePage() {
- updateErrorMessage();
+ String folder;
if (!isHomeValid()) {
configurations.getControl().setEnabled(false);
- configurations.setJBossHome(homeDirText.getText());
+ folder = homeDirText.getText();
} else {
- configurations.getControl().setEnabled(true);
- if( !homeDirText.getText().equals(configurations.getInput())) {
- configurations.setJBossHome(homeDirText.getText());
- configurations.setConfiguration(IJBossServerConstants.DEFAULT_CONFIGURATION);
- }
+ IPath p = new Path(configDirText.getText());
+ if( p.isAbsolute())
+ folder = p.toString();
+ else
+ folder = new Path(homeDirText.getText()).append(p).toString();
}
+ configurations.setFolder(folder);
+ File f = new File(folder);
+ configurations.getControl().setEnabled(f.exists() && f.isDirectory());
+ configurations.setConfiguration(IJBossServerConstants.DEFAULT_CONFIGURATION);
int sel = jreCombo.getSelectionIndex();
if (sel > 0)
selectedVM = installedJREs.get(sel-1);
else
selectedVM = null;
+ configDirTextVal = configDirText.getText();
+ updateErrorMessage();
}
private void updateErrorMessage() {
@@ -518,6 +616,9 @@
if (jreComboIndex < 0)
return Messages.rwf_NoVMSelected;
+
+ if( configurations.getSelection().isEmpty())
+ return "User must select a valid configuration";
return null;
}
@@ -554,7 +655,7 @@
}
}
- protected File getDirectory(File startingDirectory, Shell shell) {
+ protected static File getDirectory(File startingDirectory, Shell shell) {
DirectoryDialog fileDialog = new DirectoryDialog(shell, SWT.OPEN);
if (startingDirectory != null) {
fileDialog.setFilterPath(startingDirectory.getPath());
@@ -638,6 +739,7 @@
IJBossServerRuntime.class, new NullProgressMonitor());
srt.setVM(selectedVM);
srt.setJBossConfiguration(configurations.getSelectedConfiguration());
+ srt.setConfigLocation(configDirTextVal);
getTaskModel().putObject(TaskModel.TASK_RUNTIME, runtimeWC);
}
@@ -671,4 +773,156 @@
}
return null;
}
+
+
+ public static class CopyConfigurationDialog extends TitleAreaDialog {
+ private String origHome, origDest, origConfig;
+ private String newDest, newConfig;
+ private Text destText;
+ protected CopyConfigurationDialog(Shell parentShell, String home,
+ String dir, String config) {
+ super(new Shell(parentShell));
+ origHome = home;
+ origDest = dir;
+ origConfig = config;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite c = (Composite) super.createDialogArea(parent);
+ Composite main = new Composite(c, SWT.NONE);
+ main.setLayoutData(new GridData(GridData.FILL_BOTH));
+ main.setLayout(new FormLayout());
+
+ setCleanMessage();
+
+ Label nameLabel = new Label(main, SWT.NONE);
+ nameLabel.setText(Messages.wf_NameLabel);
+
+ final Text nameText = new Text(main, SWT.BORDER);
+
+ Label destLabel = new Label(main, SWT.NONE);
+ destLabel.setText(Messages.rwf_DestinationLabel);
+
+ destText = new Text(main, SWT.BORDER);
+
+ Button browse = new Button(main, SWT.PUSH);
+ browse.setText(Messages.browse);
+
+ Point nameSize = new GC(nameLabel).textExtent(nameLabel.getText());
+ Point destSize = new GC(destLabel).textExtent(destLabel.getText());
+ Control wider = nameSize.x > destSize.x ? nameLabel : destLabel;
+
+ nameText.setLayoutData(UIUtil.createFormData2(
+ 0,13,null,0,wider,5,100,-5));
+ nameLabel.setLayoutData(UIUtil.createFormData2(
+ 0,15,null,0,0,5,null,0));
+ destText.setLayoutData(UIUtil.createFormData2(
+ nameText,5,null,0,wider,5,browse,-5));
+ destLabel.setLayoutData(UIUtil.createFormData2(
+ nameText,7,null,0,0,5,null,0));
+ browse.setLayoutData(UIUtil.createFormData2(
+ nameText,5,null,0,null,0,100,-5));
+
+ nameText.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e) {
+ newConfig = nameText.getText();
+ validate();
+ }
+ });
+ destText.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e) {
+ newDest = destText.getText();
+ validate();
+ }
+ });
+ browse.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ IPath p = new Path(newDest);
+ if( !p.isAbsolute())
+ p = new Path(origHome).append(newDest);
+ File file = p.toFile();
+ if (!file.exists()) {
+ file = null;
+ }
+
+ File directory = getDirectory(file, getShell());
+ if (directory != null) {
+ IPath newP = new Path(directory.getAbsolutePath());
+ IPath result;
+ if( newP.toOSString().startsWith(new Path(origHome).toOSString()))
+ result = newP.removeFirstSegments(new Path(origHome).segmentCount());
+ else
+ result = newP;
+ destText.setText(result.toString());
+ }
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+
+
+ destText.setText(origDest);
+ nameText.setText(findNewest(origConfig + "_copy")); // TODO increment
+ return c;
+ }
+
+ public void validate() {
+ boolean valid = false;
+ IPath p = null;
+ if( newDest != null && newConfig != null ) {
+ p = new Path(newDest);
+ if( !p.isAbsolute())
+ p = new Path(origHome).append(newDest);
+ if( !p.append(newConfig).toFile().exists())
+ valid = true;
+
+ }
+ if( !valid ) {
+ if( newDest == null || newConfig == null ) {
+ setMessage("All fields must be completed.", IMessageProvider.ERROR);
+ } else {
+ setMessage("The output folder already exists: " +
p.append(newConfig).toString(), IMessageProvider.ERROR);
+ }
+ } else {
+ setCleanMessage();
+ }
+ if( getOKButton() != null )
+ getOKButton().setEnabled(valid);
+ }
+
+ protected void setCleanMessage() {
+ setMessage(NLS.bind(Messages.rwf_CopyConfigLabel, origConfig, origDest));
+ }
+ // Only to be used in initializing dialog
+ protected String findNewest(String suggested) {
+ IPath p = new Path(origDest);
+ if( !p.isAbsolute())
+ p = new Path(origHome).append(origDest);
+ if( p.append(suggested).toFile().exists()) {
+ int i = 1;
+ while(p.append(suggested + i).toFile().exists())
+ i++;
+ return suggested + i;
+ }
+ return suggested;
+ }
+
+ protected Point getInitialSize() {
+ return new Point(500, super.getInitialSize().y);
+ }
+
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Copy a Configuration");
+ }
+
+ public String getNewDest() {
+ return newDest;
+ }
+
+ public String getNewConfig() {
+ return newConfig;
+ }
+ }
}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-05-12
09:15:47 UTC (rev 15220)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-05-12
09:32:44 UTC (rev 15221)
@@ -63,7 +63,7 @@
private Label serverExplanationLabel,
runtimeExplanationLabel;
private Label homeDirLabel, installedJRELabel, configLabel;
- private Label homeValLabel, jreValLabel, configValLabel;
+ private Label homeValLabel, jreValLabel, configValLabel, configLocValLabel;
private Group runtimeGroup;
public Composite createComposite(Composite parent, IWizardHandle handle) {
@@ -151,6 +151,10 @@
d = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
jreValLabel.setLayoutData(d);
+ Label configLocationLabel = new Label(runtimeGroup, SWT.NONE);
+ configLocationLabel.setText(Messages.swf_ConfigurationLocation);
+ configLocValLabel = new Label(runtimeGroup, SWT.NONE);
+
configLabel = new Label(runtimeGroup, SWT.NONE);
configLabel.setText(Messages.wf_ConfigLabel);
configValLabel = new Label(runtimeGroup, SWT.NONE);
@@ -178,6 +182,7 @@
homeValLabel.setText(srt.getRuntime().getLocation().toOSString());
configValLabel.setText(srt.getJBossConfiguration());
jreValLabel.setText(srt.getVM().getInstallLocation().getAbsolutePath() + "
(" + srt.getVM().getName() + ")");
+ configLocValLabel.setText(srt.getConfigLocation());
runtimeGroup.layout();
updateErrorMessage();
}