Author: rob.stryker(a)jboss.com
Date: 2008-11-25 21:45:14 -0500 (Tue, 25 Nov 2008)
New Revision: 12058
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java
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/internal/DeployableServer.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/editor/DeploySection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
Log:
JBIDE-2627 - allowing any value set in the editor to be automatically added to the
deployment scanner before each publish. Also, separated out into metadata the default
deploy location, giving each server its own folder.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2008-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2008-11-26
02:45:14 UTC (rev 12058)
@@ -25,20 +25,16 @@
import java.util.ArrayList;
import java.util.HashMap;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
-public class ServerLogger {
- private static final IPath LOG_LOCATION =
JBossServerCorePlugin.getDefault().getStateLocation().append("logs");
+public class ServerLogger implements IJBossServerConstants {
private static ServerLogger instance;
public static ServerLogger getDefault() {
if( instance == null ) {
instance = new ServerLogger();
- if( !LOG_LOCATION.toFile().exists())
- LOG_LOCATION.toFile().mkdirs();
}
return instance;
}
@@ -81,6 +77,10 @@
}
public File getServerLogFile(IServer server) {
- return server == null ? LOG_LOCATION.toFile() :
LOG_LOCATION.append(server.getId()).toFile();
+ File f = server == null ? PLUGIN_LOCATION.toFile() :
+ PLUGIN_LOCATION.append(server.getId()).append(LOG).toFile();
+ if( !f.getParentFile().exists() )
+ f.getParentFile().mkdirs();
+ return f;
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java 2008-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java 2008-11-26
02:45:14 UTC (rev 12058)
@@ -28,15 +28,23 @@
*
* @author rob.stryker(a)jboss.com
*/
-public interface IDeployableServer {
+public interface IDeployableServer extends IJBossServerConstants {
public static final String DEPLOY_DIRECTORY =
"org.jboss.ide.eclipse.as.core.server.deployDirectory";
public static final String TEMP_DEPLOY_DIRECTORY =
"org.jboss.ide.eclipse.as.core.server.tempDeployDirectory";
+ public static final String DEPLOY_DIRECTORY_TYPE =
"org.jboss.ide.eclipse.as.core.server.deployDirectoryType";
+
+ public static final String DEPLOY_METADATA = "metadata";
+ public static final String DEPLOY_CUSTOM = "custom";
+ public static final String DEPLOY_SERVER = "server";
public String getDeployFolder();
public void setDeployFolder(String folder);
public String getTempDeployFolder();
public void setTempDeployFolder(String folder);
-
+ public String getDeployLocationType();
+ public void setDeployLocationType(String type);
+
+
public String getConfigDirectory();
public ServerAttributeHelper getAttributeHelper();
public IServer getServer();
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-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java 2008-11-26
02:45:14 UTC (rev 12058)
@@ -21,7 +21,9 @@
*/
package org.jboss.ide.eclipse.as.core.server;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
/**
*
@@ -29,6 +31,11 @@
*
*/
public interface IJBossServerConstants {
+ public static final IPath PLUGIN_LOCATION =
JBossServerCorePlugin.getDefault().getStateLocation();
+ public static final String LOG = "log";
+ public static final String TEMP_DEPLOY = "tempDeploy";
+ public static final String JBOSSTOOLS_TMP = "jbosstoolsTemp";
+ public static final String TMP = "tmp";
// Launch configuration constants
public static final String JBOSS_SERVER_HOME_DIR = "jboss.server.home.dir";
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2008-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2008-11-26
02:45:14 UTC (rev 12058)
@@ -122,6 +122,14 @@
setAttribute(TEMP_DEPLOY_DIRECTORY, makeRelative(getRuntime(), new
Path(folder)).toString());
}
+ public void setDeployLocationType(String type) {
+ setAttribute(DEPLOY_DIRECTORY_TYPE, type);
+ }
+
+ public String getDeployLocationType() {
+ return getAttribute(DEPLOY_DIRECTORY_TYPE, DEPLOY_CUSTOM);
+ }
+
/*
* (non-Javadoc)
* @see
org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer#getAttributeHelper()
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-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2008-11-26
02:45:14 UTC (rev 12058)
@@ -201,8 +201,12 @@
/* Editor Strings */
+ public static String EditorUseWorkspaceMetadata;
+ public static String EditorUseServersDeployFolder;
+ public static String EditorUseCustomDeployFolder;
public static String EditorSetDeployLabel;
public static String EditorSetTempDeployLabel;
+ public static String EditorSetRadioClicked;
public static String EditorDeployDNE;
public static String EditorTempDeployDNE;
public static String EditorStartupPollerLabel;
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 2008-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2008-11-26
02:45:14 UTC (rev 12058)
@@ -179,8 +179,12 @@
DescriptorXPathMatch=Match
#Editor
+EditorUseWorkspaceMetadata=Use workspace metadata (does not modify JBoss deploy folder)
+EditorUseServersDeployFolder=Use the JBoss deploy folder
+EditorUseCustomDeployFolder=Use a custom deploy folder
EditorSetDeployLabel=Set Deploy Directory
EditorSetTempDeployLabel=Set Temporary Deploy Directory
+EditorSetRadioClicked=Set Deploy Location
EditorDeployDNE=The deploy directory "{0}" does not exist.
EditorTempDeployDNE=The temporary deploy directory "{0}" does not exist.
EditorStartupPollerLabel=Startup Poller
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2008-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2008-11-26
02:45:14 UTC (rev 12058)
@@ -39,6 +39,7 @@
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
@@ -47,6 +48,7 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
@@ -56,8 +58,10 @@
import org.eclipse.wst.server.ui.internal.command.ServerCommand;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+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.DeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -69,8 +73,13 @@
public class DeploySection extends ServerEditorSection {
private Text deployText, tempDeployText;
+ private Button metadataRadio, serverRadio, customRadio, currentSelection;
+ private Button deployButton, tempDeployButton;
private ModifyListener deployListener, tempDeployListener;
+ private SelectionListener radioListener;
private ServerAttributeHelper helper;
+
+ private String lastCustomDeploy, lastCustomTemp;
public DeploySection() {
}
@@ -94,18 +103,42 @@
Label descriptionLabel = toolkit.createLabel(composite,
Messages.swf_DeploymentDescription);
+ Composite inner = toolkit.createComposite(composite);
+ inner.setLayout(new GridLayout(1, false));
+ metadataRadio = toolkit.createButton(inner, Messages.EditorUseWorkspaceMetadata,
SWT.RADIO);
+ serverRadio = toolkit.createButton(inner, Messages.EditorUseServersDeployFolder,
SWT.RADIO);
+ customRadio = toolkit.createButton(inner, Messages.EditorUseCustomDeployFolder,
SWT.RADIO);
+
+ metadataRadio.setSelection(getDeployType().equals(IDeployableServer.DEPLOY_METADATA));
+ serverRadio.setSelection(getDeployType().equals(IDeployableServer.DEPLOY_SERVER));
+ customRadio.setSelection(getDeployType().equals(IDeployableServer.DEPLOY_CUSTOM));
+
+ radioListener = new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ if( e.getSource() == currentSelection )
+ return; // do nothing
+ execute(new RadioClickedCommand((Button)e.getSource(), currentSelection));
+ currentSelection = (Button)e.getSource();
+ } };
+ metadataRadio.addSelectionListener(radioListener);
+ serverRadio.addSelectionListener(radioListener);
+ customRadio.addSelectionListener(radioListener);
+
Label label = toolkit.createLabel(composite, Messages.swf_DeployDirectory);
+ label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
deployText = toolkit.createText(composite, getDeployDir(), SWT.BORDER);
deployListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
execute(new SetDeployDirCommand());
- getSaveStatus();
}
};
deployText.addModifyListener(deployListener);
- Button button = toolkit.createButton(composite, Messages.browse, SWT.PUSH);
- button.addSelectionListener(new SelectionListener() {
+ deployButton = toolkit.createButton(composite, Messages.browse, SWT.PUSH);
+ deployButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
@@ -119,16 +152,17 @@
});
Label tempDeployLabel = toolkit.createLabel(composite,
Messages.swf_TempDeployDirectory);
+ tempDeployLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+
tempDeployText = toolkit.createText(composite, getTempDeployDir(), SWT.BORDER);
tempDeployListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
execute(new SetTempDeployDirCommand());
- getSaveStatus();
}
};
tempDeployText.addModifyListener(tempDeployListener);
- Button tempDeployButton = toolkit.createButton(composite, Messages.browse, SWT.PUSH);
+ tempDeployButton = toolkit.createButton(composite, Messages.browse, SWT.PUSH);
tempDeployButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
@@ -141,30 +175,36 @@
}
});
-
FormData descriptionLabelData = new FormData();
descriptionLabelData.left = new FormAttachment(0,5);
descriptionLabelData.top = new FormAttachment(0,5);
descriptionLabel.setLayoutData(descriptionLabelData);
+ FormData radios = new FormData();
+ radios.top = new FormAttachment(descriptionLabel,5);
+ radios.left = new FormAttachment(0,5);
+ radios.right = new FormAttachment(100,-5);
+ inner.setLayoutData(radios);
+
+
// first row
FormData labelData = new FormData();
labelData.left = new FormAttachment(0,5);
labelData.right = new FormAttachment(deployText,-5);
- labelData.top = new FormAttachment(descriptionLabel,5);
+ labelData.top = new FormAttachment(inner,5);
label.setLayoutData(labelData);
FormData textData = new FormData();
- textData.left = new FormAttachment(button, -305);
- textData.top = new FormAttachment(descriptionLabel,5);
- textData.right = new FormAttachment(button, -5);
+ textData.left = new FormAttachment(deployButton, -305);
+ textData.top = new FormAttachment(inner,5);
+ textData.right = new FormAttachment(deployButton, -5);
deployText.setLayoutData(textData);
FormData buttonData = new FormData();
buttonData.right = new FormAttachment(100,-5);
buttonData.left = new FormAttachment(100, -100);
- buttonData.top = new FormAttachment(descriptionLabel,2);
- button.setLayoutData(buttonData);
+ buttonData.top = new FormAttachment(inner,2);
+ deployButton.setLayoutData(buttonData);
// second row
FormData tempLabelData = new FormData();
@@ -189,6 +229,10 @@
section.setClient(composite);
}
+ private String getDeployType() {
+ return helper.getAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
IDeployableServer.DEPLOY_CUSTOM);
+ }
+
private String getDeployDir() {
return helper.getAttribute(IDeployableServer.DEPLOY_DIRECTORY, "");
}
@@ -232,12 +276,15 @@
}
public void execute() {
helper.setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
+ lastCustomDeploy = newDir;
+ getSaveStatus();
}
public void undo() {
text.removeModifyListener(listener);
helper.setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
text.setText(oldDir);
text.addModifyListener(listener);
+ getSaveStatus();
}
}
@@ -255,15 +302,93 @@
}
public void execute() {
helper.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newDir);
+ lastCustomTemp = newDir;
+ getSaveStatus();
}
public void undo() {
text.removeModifyListener(listener);
helper.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldDir);
text.setText(oldDir);
text.addModifyListener(listener);
+ getSaveStatus();
}
}
+ public class RadioClickedCommand extends ServerCommand {
+ private Button newSelection, oldSelection;
+ private String oldDir, newDir;
+ private String oldTemp, newTemp;
+ private String name;
+ public RadioClickedCommand(Button clicked, Button previous) {
+ super(DeploySection.this.server, Messages.EditorSetRadioClicked);
+ newSelection = clicked;
+ oldSelection = previous;
+ name = DeploySection.this.server.getName();
+ }
+ public void execute() {
+ boolean custom = newSelection == customRadio;
+ deployText.setEnabled(custom);
+ tempDeployText.setEnabled(custom);
+ deployButton.setEnabled(custom);
+ tempDeployButton.setEnabled(custom);
+ oldDir = deployText.getText();
+ oldTemp = tempDeployText.getText();
+
+
+ if( newSelection == metadataRadio ) {
+ newDir = IJBossServerConstants.PLUGIN_LOCATION.append(name).
+ append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
+ newTemp = IJBossServerConstants.PLUGIN_LOCATION.append(name).
+ append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+ new File(newDir).mkdirs();
+ new File(newTemp).mkdirs();
+ } else if( newSelection == serverRadio ) {
+ IRuntime rt = DeploySection.this.server.getRuntime();
+ IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ String config = jbsrt.getJBossConfiguration();
+ newDir = new Path(IJBossServerConstants.SERVER)
+ .append(config)
+ .append(IJBossServerConstants.DEPLOY).makeRelative().toString();
+ newTemp = new Path(IJBossServerConstants.SERVER).append(config)
+ .append(IJBossServerConstants.TMP)
+ .append(IJBossServerConstants.JBOSSTOOLS_TMP).makeRelative().toString();
+ } else {
+ newDir = lastCustomDeploy;
+ newTemp = lastCustomTemp;
+ }
+
+ newDir = newDir == null ? oldDir : newDir;
+ newTemp = newTemp == null ? oldTemp : newTemp;
+
+ deployText.removeModifyListener(deployListener);
+ helper.setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
+ deployText.setText(newDir);
+ deployText.addModifyListener(deployListener);
+
+ tempDeployText.removeModifyListener(tempDeployListener);
+ helper.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newTemp);
+ tempDeployText.setText(newTemp);
+ tempDeployText.addModifyListener(tempDeployListener);
+ getSaveStatus();
+ }
+ public void undo() {
+ deployText.removeModifyListener(deployListener);
+ helper.setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
+ deployText.setText(oldDir);
+ deployText.addModifyListener(deployListener);
+
+ tempDeployText.removeModifyListener(tempDeployListener);
+ helper.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldTemp);
+ tempDeployText.setText(oldTemp);
+ tempDeployText.addModifyListener(tempDeployListener);
+
+ oldSelection.removeSelectionListener(radioListener);
+ oldSelection.setSelection(true);
+ oldSelection.addSelectionListener(radioListener);
+ getSaveStatus();
+ }
+ }
+
public void dispose() {
// ignore
}
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 2008-11-26
02:21:52 UTC (rev 12057)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2008-11-26
02:45:14 UTC (rev 12058)
@@ -24,29 +24,21 @@
import java.io.File;
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.jdt.launching.IVMInstall;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
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.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-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;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
@@ -55,8 +47,9 @@
import org.eclipse.wst.server.core.TaskModel;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+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.DeployableServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -68,17 +61,15 @@
*/
public class JBossServerWizardFragment extends WizardFragment {
private IWizardHandle handle;
- private String name, authUser, authPass, deployVal, deployTmpFolderVal;
+ private String name;
private Label nameLabel, serverExplanationLabel,
- runtimeExplanationLabel, authenticationExplanationLabel;
+ runtimeExplanationLabel;
private Label homeDirLabel, installedJRELabel, configLabel;
private Label homeValLabel, jreValLabel, configValLabel;
- private Label usernameLabel, passLabel, deployLabel;
private Composite nameComposite;
- private Group runtimeGroup, authenticationGroup, deployGroup;
- private Text nameText, userText, passText, deployText;
- private Button deployBrowseButton;
+ private Group runtimeGroup;
+ private Text nameText;
public Composite createComposite(Composite parent, IWizardHandle handle) {
this.handle = handle;
@@ -89,9 +80,7 @@
createExplanationLabel(main);
createNameComposite(main);
createRuntimeGroup(main);
- createAuthenticationGroup(main);
- createDeployGroup(main);
-
+
// make modifications to parent
handle.setTitle(Messages.swf_Title);
handle.setDescription(Messages.swf_Description);
@@ -225,100 +214,6 @@
configValLabel.setLayoutData(d);
}
- protected void createAuthenticationGroup(Composite main) {
- authenticationGroup = new Group(main, SWT.NONE);
- authenticationGroup.setText(Messages.swf_AuthenticationGroup);
- FormData groupData = new FormData();
- groupData.left = new FormAttachment(0,5);
- groupData.right = new FormAttachment(100, -5);
- groupData.top = new FormAttachment(runtimeGroup, 5);
- authenticationGroup.setLayoutData(groupData);
-
- authenticationGroup.setLayout(new GridLayout(2, false));
- GridData d;
-
- authenticationExplanationLabel = new Label(authenticationGroup, SWT.NONE);
- authenticationExplanationLabel.setText("JMX Console Access");
- d = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
- d.horizontalSpan = 2;
- authenticationExplanationLabel.setLayoutData(d);
-
- d = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
- d.minimumWidth = 200;
- usernameLabel = new Label(authenticationGroup, SWT.NONE);
- usernameLabel.setText(Messages.swf_Username);
- userText = new Text(authenticationGroup, SWT.BORDER);
- userText.setLayoutData(d);
-
- d = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
- d.minimumWidth = 200;
- passLabel = new Label(authenticationGroup, SWT.NONE);
- passLabel.setText(Messages.swf_Password);
- passText = new Text(authenticationGroup, SWT.BORDER);
- passText.setLayoutData(d);
-
- // listeners
- passText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- authPass = passText.getText();
- }
- });
- userText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- authUser = userText.getText();
- }
- });
- }
-
- protected void createDeployGroup(Composite main) {
- deployGroup = new Group(main, SWT.NONE);
- deployGroup.setText(Messages.swf_DeployGroup);
- FormData groupData = new FormData();
- groupData.left = new FormAttachment(0,5);
- groupData.right = new FormAttachment(100, -5);
- groupData.top = new FormAttachment(authenticationGroup, 5);
- deployGroup.setLayoutData(groupData);
-
- deployGroup.setLayout(new GridLayout(3, false));
- deployLabel = new Label(deployGroup, SWT.NONE);
- deployText = new Text(deployGroup, SWT.BORDER);
- deployLabel.setText(Messages.swf_DeployDirectory);
-
- deployBrowseButton = new Button(deployGroup, SWT.PUSH);
- deployBrowseButton.setText(Messages.browse);
-
- deployBrowseButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {}
- public void widgetSelected(SelectionEvent e) {
- String directory = getDirectory(deployText.getText(), deployGroup.getShell());
- if (directory != null) {
- deployText.setText(directory);
- deployVal = deployText.getText();
- }
- }
- });
-
- deployText.setEditable(false);
- }
-
- protected String getDirectory(String startingDirectory, Shell shell) {
- DirectoryDialog fileDialog = new DirectoryDialog(shell, SWT.OPEN);
-
- if( startingDirectory == null )
- startingDirectory = getRuntime().getRuntime().getLocation().toString();
- IPath sp = DeployableServer.makeGlobal(getRuntime(), new Path(startingDirectory));
- fileDialog.setFilterPath(sp.toString());
-
- String dir = fileDialog.open();
- if (dir != null) {
- dir = dir.trim();
- if (dir.length() > 0) {
- return DeployableServer.makeRelative(getRuntime(), new Path(dir)).toString();
- }
- }
- return null;
- }
-
private void updateErrorMessage() {
String error = getErrorString();
if( error == null ) {
@@ -331,15 +226,6 @@
private String getErrorString() {
if( findServer(name) != null )
return Messages.swf_NameInUse;
-
- if(deployVal==null || deployVal.trim().length()==0) {
- return "Deploy folder not specified";
- }
-
- if(deployTmpFolderVal==null || deployTmpFolderVal.trim().length()==0) {
- return "Temporary deploy folder not specified";
- }
-
return null;
}
@@ -353,14 +239,8 @@
nameText.setText(name);
homeValLabel.setText(srt.getRuntime().getLocation().toOSString());
configValLabel.setText(srt.getJBossConfiguration());
- IVMInstall install = srt.getVM();
- jreValLabel.setText(install.getInstallLocation().getAbsolutePath() + " (" +
install.getName() + ")");
- String deployFolder = new
Path("server").append(configValLabel.getText()).append("deploy").toString();
- deployTmpFolderVal = srt.getRuntime().getLocation().append(
"server").append(configValLabel.getText()).append("tmp").append("jbosstoolsTemp").toOSString();
- deployText.setText(deployFolder);
- deployVal = deployFolder;
+ jreValLabel.setText(srt.getVM().getInstallLocation().getAbsolutePath() + " ("
+ srt.getVM().getName() + ")");
runtimeGroup.layout();
- deployGroup.layout();
updateErrorMessage();
}
@@ -372,11 +252,23 @@
serverWC.setRuntime((IRuntime)getTaskModel().getObject(TaskModel.TASK_RUNTIME));
serverWC.setName(name);
serverWC.setServerConfiguration(null); // no inside jboss folder
- JBossServer jbs = (JBossServer)serverWC.loadAdapter(JBossServer.class, new
NullProgressMonitor());
- jbs.setUsername(authUser);
- jbs.setPassword(authPass);
+ handleDefaults(serverWC);
+ }
+
+ protected void handleDefaults(IServerWorkingCopy wc) {
+ String deployVal = IJBossServerConstants.PLUGIN_LOCATION.append(name).
+ append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
+ String deployTmpFolderVal = IJBossServerConstants.PLUGIN_LOCATION.append(name).
+ append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+
+
+ JBossServer jbs = (JBossServer)wc.loadAdapter(JBossServer.class, new
NullProgressMonitor());
+ jbs.setUsername("admin");
+ jbs.setPassword("admin");
+ jbs.setDeployLocationType(IDeployableServer.DEPLOY_METADATA);
jbs.setDeployFolder(deployVal);
jbs.setTempDeployFolder(deployTmpFolderVal);
+ new File(deployVal).mkdirs();
new File(deployTmpFolderVal).mkdirs();
}