Author: rob.stryker(a)jboss.com
Date: 2011-01-13 17:49:09 -0500 (Thu, 13 Jan 2011)
New Revision: 28209
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java
Log:
JBIDE-8105 and error logging
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java 2011-01-13
22:26:29 UTC (rev 28208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java 2011-01-13
22:49:09 UTC (rev 28209)
@@ -52,7 +52,9 @@
method.getFileService().upload(file, remotePath.removeLastSegments(1).toString(),
remotePath.lastSegment(), true, null, null, monitor);
} catch( SystemMessageException sme ) {
- System.err.println("failed to copy to " + remotePath.toString());
//$NON-NLS-1$
+ IStatus s = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID,
+ "failed to copy to " + remotePath.toString(), sme);
+ return new IStatus[]{s};
}
return new IStatus[]{};
}
@@ -63,7 +65,9 @@
try {
method.getFileService().delete(remotePath.removeLastSegments(1).toString(),
remotePath.lastSegment(), monitor);
} catch( SystemMessageException sme ) {
- System.err.println("failed to delete " + remotePath.toString());
//$NON-NLS-1$
+ IStatus s = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID,
+ "failed to delete " + remotePath.toString(), sme);
+ return new IStatus[]{s};
}
return new IStatus[]{};
}
@@ -82,7 +86,9 @@
toMake.lastSegment(), ProgressMonitorUtil.submon(monitor, 30));
}
} catch( SystemMessageException sme ) {
- System.err.println("failed to make folder " + toMake.toString());
//$NON-NLS-1$
+ IStatus s = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID,
+ "failed to create folder " + toMake.toString(), sme);
+ return new IStatus[]{s};
}
createdFolders.add(toMake);
monitor.done();
@@ -98,6 +104,9 @@
}
method.getFileServiceSubSystem().setLastModified(rf, new Date().getTime(), null);
} catch(SystemMessageException sme) {
+ IStatus s = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID,
+ "failed to touch remote resource " + file.toString(), sme);
+ return new IStatus[]{s};
}
return new IStatus[]{};
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2011-01-13
22:26:29 UTC (rev 28208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2011-01-13
22:49:09 UTC (rev 28209)
@@ -69,11 +69,11 @@
// if no value is set, default to metadata
type = JBossServer.DEPLOY_SERVER;
}
- // TODO error here, or sensible default?
+ // This should *NOT* happen, so if it does, we will default to server location
if( type.equals(JBossServer.DEPLOY_METADATA)) {
- return JBossServerCorePlugin.getServerStateLocation(server).
- append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
- } else if( type.equals(JBossServer.DEPLOY_SERVER)) {
+ type = JBossServer.DEPLOY_SERVER;
+ }
+ if( type.equals(JBossServer.DEPLOY_SERVER)) {
String loc = IConstants.SERVER;
String config = getRSEConfigName(server);
IPath p = new Path(loc).append(config)
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java 2011-01-13
22:26:29 UTC (rev 28208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java 2011-01-13
22:49:09 UTC (rev 28209)
@@ -55,12 +55,15 @@
import org.eclipse.ui.progress.IProgressService;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.internal.command.ServerCommand;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.util.IConstants;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod;
import org.jboss.ide.eclipse.as.rse.core.RSEUtils;
+import org.jboss.ide.eclipse.as.ui.Messages;
import org.jboss.ide.eclipse.as.ui.UIUtil;
import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI;
import org.jboss.ide.eclipse.as.ui.editor.ServerModeSection;
@@ -109,56 +112,148 @@
ServerConverter.getJBossServer(cServer) :
ServerConverter.getJBossServer(cServer.getOriginal());
if( jbs != null ) {
-
- Label serverHomeLabel = new Label(this, SWT.NONE);
- serverHomeLabel.setText("Remote Server Home: ");
- rseBrowse = new Button(this, SWT.DEFAULT);
- rseBrowse.setText("Browse...");
- rseBrowse.setLayoutData(UIUtil.createFormData2(child, 5, null, 0, null, 0, 100,
-5));
- rseBrowse.addSelectionListener(new SelectionListener(){
- public void widgetSelected(SelectionEvent e) {
- browseClicked();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- browseClicked();
- }
- });
- rseServerHome = new Text(this, SWT.SINGLE | SWT.BORDER);
- serverHomeLabel.setLayoutData(UIUtil.createFormData2(child, 7, null, 0, 0, 10, null,
0));
- rseServerHome.setLayoutData(UIUtil.createFormData2(child, 5, null, 0,
serverHomeLabel, 5, rseBrowse, -5));
- rseServerHome.setText(callback.getServer().getAttribute(RSEUtils.RSE_SERVER_HOME_DIR,
- getRuntime() == null ? "" :
getRuntime().getRuntime().getLocation().toString()));
- rseServerHome.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- serverHomeChanged();
- }});
-
- Label serverConfigLabel = new Label(this, SWT.NONE);
- serverConfigLabel.setText("Remote Server Configuration: ");
- rseServerConfig= new Text(this, SWT.SINGLE | SWT.BORDER);
- serverConfigLabel.setLayoutData(UIUtil.createFormData2(rseServerHome, 7, null, 0, 0,
10, null, 0));
- rseServerConfig.setText(callback.getServer().getAttribute(RSEUtils.RSE_SERVER_CONFIG,
- getRuntime() == null ? "" : getRuntime().getJBossConfiguration()));
- rseServerConfig.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- serverConfigChanged();
- }});
- callback.getServer().addPropertyChangeListener(this);
-
- rseTest = new Button(this, SWT.NONE);
- rseTest.setText("Test...");
- rseTest.setLayoutData(UIUtil.createFormData2(rseServerHome, 5, null, 0, null, 0, 100,
-5));
- rseServerConfig.setLayoutData(UIUtil.createFormData2(rseServerHome, 5, null, 0,
serverConfigLabel, 5, rseTest, -5));
- rseTest.addSelectionListener(new SelectionListener(){
- public void widgetSelected(SelectionEvent e) {
- testPressed();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
+ handleJBossServer(child);
+ } else {
+ handleDeployOnlyServer(child);
}
}
+ private IDeployableServer getServer() {
+ return (IDeployableServer) callback.getServer().loadAdapter(
+ IDeployableServer.class, new NullProgressMonitor());
+ }
+
+ private Text deployText, tempDeployText;
+ private Button deployButton, tempDeployButton;
+ private ModifyListener deployListener, tempDeployListener;
+
+ private void handleJBossServer(Composite composite) {
+ Label serverHomeLabel = new Label(this, SWT.NONE);
+ serverHomeLabel.setText("Remote Server Home: ");
+ rseBrowse = new Button(this, SWT.DEFAULT);
+ rseBrowse.setText("Browse...");
+ rseBrowse.setLayoutData(UIUtil.createFormData2(composite, 5, null,
+ 0, null, 0, 100, -5));
+ rseBrowse.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ browseClicked2();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ browseClicked2();
+ }
+ });
+ rseServerHome = new Text(this, SWT.SINGLE | SWT.BORDER);
+ serverHomeLabel.setLayoutData(UIUtil.createFormData2(composite, 7,
+ null, 0, 0, 10, null, 0));
+ rseServerHome.setLayoutData(UIUtil.createFormData2(composite, 5,
+ null, 0, serverHomeLabel, 5, rseBrowse, -5));
+ rseServerHome.setText(callback.getServer().getAttribute(
+ RSEUtils.RSE_SERVER_HOME_DIR,
+ getRuntime() == null ? "" : getRuntime().getRuntime()
+ .getLocation().toString()));
+ rseServerHome.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ serverHomeChanged();
+ }
+ });
+
+ Label serverConfigLabel = new Label(this, SWT.NONE);
+ serverConfigLabel.setText("Remote Server Configuration: ");
+ rseServerConfig = new Text(this, SWT.SINGLE | SWT.BORDER);
+ serverConfigLabel.setLayoutData(UIUtil.createFormData2(
+ rseServerHome, 7, null, 0, 0, 10, null, 0));
+ rseServerConfig.setText(callback.getServer().getAttribute(
+ RSEUtils.RSE_SERVER_CONFIG,
+ getRuntime() == null ? "" : getRuntime()
+ .getJBossConfiguration()));
+ rseServerConfig.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ serverConfigChanged();
+ }
+ });
+ callback.getServer().addPropertyChangeListener(this);
+
+ rseTest = new Button(this, SWT.NONE);
+ rseTest.setText("Test...");
+ rseTest.setLayoutData(UIUtil.createFormData2(rseServerHome, 5,
+ null, 0, null, 0, 100, -5));
+ rseServerConfig.setLayoutData(UIUtil.createFormData2(rseServerHome,
+ 5, null, 0, serverConfigLabel, 5, rseTest, -5));
+ rseTest.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ testPressed();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ }
+
+
+
+ private void handleDeployOnlyServer(Composite composite) {
+ Label label = new Label(this, SWT.NONE);
+ label.setText(Messages.swf_DeployDirectory);
+ deployText = new Text(this, SWT.BORDER);
+ deployText.setText(getServer().getDeployFolder());
+ deployListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ callback.execute(new SetDeployDirCommand());
+ }
+ };
+ deployText.addModifyListener(deployListener);
+
+ deployButton = new Button(this, SWT.PUSH);
+ deployButton.setText(Messages.browse);
+ label.setLayoutData(UIUtil.createFormData2(composite, 7, null, 0, 0, 10, null, 0));
+ deployButton.setLayoutData(UIUtil.createFormData2(composite, 5, null, 0, null, 0, 100,
-5));
+ deployText.setLayoutData(UIUtil.createFormData2(composite, 5, null, 0, label, 5,
deployButton, -5));
+
+ deployButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ }
+ });
+
+ Label tempDeployLabel = new Label(this, SWT.NONE);
+ tempDeployLabel.setText(Messages.swf_TempDeployDirectory);
+ tempDeployText = new Text(this, SWT.BORDER);
+ tempDeployText.setText(getServer().getTempDeployFolder());
+ tempDeployListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ callback.execute(new SetTempDeployDirCommand());
+ }
+ };
+ tempDeployText.addModifyListener(tempDeployListener);
+
+ tempDeployButton = new Button(this, SWT.PUSH);
+ tempDeployButton.setText(Messages.browse);
+
+ tempDeployLabel.setLayoutData(UIUtil.createFormData2(deployText, 7, null, 0, 0, 10,
null, 0));
+ tempDeployButton.setLayoutData(UIUtil.createFormData2(deployText, 5, null, 0, null, 0,
100, -5));
+ tempDeployText.setLayoutData(UIUtil.createFormData2(deployText, 5, null, 0,
tempDeployLabel, 5, deployButton, -5));
+
+ tempDeployButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ }
+ });
+ }
+ private void updateDeployOnlyWidgets() {
+ String newDir = callback.getServer().getAttribute(IDeployableServer.DEPLOY_DIRECTORY,
"");
+ String newTemp =
callback.getServer().getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, "");
+ deployText.removeModifyListener(deployListener);
+ deployText.setText(newDir);
+ deployText.addModifyListener(deployListener);
+ tempDeployText.removeModifyListener(tempDeployListener);
+ tempDeployText.setText(newTemp);
+ tempDeployText.addModifyListener(tempDeployListener);
+ }
+
private void testPressed(){
rseTest.setEnabled(false);
IWorkbench wb = PlatformUI.getWorkbench();
@@ -298,17 +393,25 @@
}
}
- protected void browseClicked() {
+ protected void browseClicked2() {
+ String browseVal = browseClicked3();
+ if (browseVal != null) {
+ rseServerHome.setText(browseVal);
+ serverHomeChanged();
+ }
+ }
+
+ protected String browseClicked3() {
SystemRemoteFileDialog d = new SystemRemoteFileDialog(
rseBrowse.getShell(), "Browse remote system", combo.getHost());
if( d.open() == Dialog.OK) {
Object o = d.getOutputObject();
if( o instanceof IRemoteFile ) {
String path = ((IRemoteFile)o).getAbsolutePath();
- rseServerHome.setText(path);
- serverHomeChanged();
+ return path;
}
}
+ return null;
}
protected IJBossServerRuntime getRuntime() {
@@ -492,6 +595,59 @@
RSECorePlugin.getTheSystemRegistry().removeSystemModelChangeListener(this);
}
}
+
+ public class SetDeployDirCommand extends ServerCommand {
+ private String oldDir;
+ private String newDir;
+ private Text text;
+ private ModifyListener listener;
+
+ public SetDeployDirCommand() {
+ super(callback.getServer(), Messages.EditorSetDeployLabel);
+ this.text = deployText;
+ this.newDir = deployText.getText();
+ this.listener = deployListener;
+ this.oldDir = callback.getServer().getAttribute(
+ IDeployableServer.DEPLOY_DIRECTORY, ""); //$NON-NLS-1$
+ }
+
+ public void execute() {
+ callback.getServer().setAttribute(
+ IDeployableServer.DEPLOY_DIRECTORY, newDir);
+ updateDeployOnlyWidgets();
+ }
+
+ public void undo() {
+ callback.getServer().setAttribute(
+ IDeployableServer.DEPLOY_DIRECTORY, oldDir);
+ updateDeployOnlyWidgets();
+ }
+ }
+
+ public class SetTempDeployDirCommand extends ServerCommand {
+ private String oldDir;
+ private String newDir;
+ private Text text;
+ private ModifyListener listener;
+
+ public SetTempDeployDirCommand() {
+ super(callback.getServer(), Messages.EditorSetTempDeployLabel);
+ text = tempDeployText;
+ newDir = tempDeployText.getText();
+ listener = tempDeployListener;
+ oldDir = callback.getServer().getAttribute(
+ IDeployableServer.TEMP_DEPLOY_DIRECTORY, ""); //$NON-NLS-1$
+ }
+
+ public void execute() {
+ callback.getServer().setAttribute(
+ IDeployableServer.TEMP_DEPLOY_DIRECTORY, newDir);
+ }
+
+ public void undo() {
+ callback.getServer().setAttribute(
+ IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldDir);
+ }
+ }
}
-
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java 2011-01-13
22:26:29 UTC (rev 28208)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java 2011-01-13
22:49:09 UTC (rev 28209)
@@ -141,6 +141,15 @@
callback.execute(new ChangeServerPropertyCommand(
callback.getServer(), IDeployableServer.SERVER_MODE,
ui.getPublishType().getId(), "Change server mode"));
+ String deployType = null;
+ if( ui.getPublishType().getId().equals(LocalPublishMethod.LOCAL_PUBLISH_METHOD)) {
+ deployType = IDeployableServer.DEPLOY_METADATA;
+ } else {
+ deployType = IDeployableServer.DEPLOY_SERVER;
+ }
+ callback.execute(new ChangeServerPropertyCommand(
+ callback.getServer(), IDeployableServer.DEPLOY_DIRECTORY_TYPE,
+ deployType, "Change server's deploy location"));
}
} else {
// null selection