Author: adietish
Date: 2011-05-05 05:54:52 -0400 (Thu, 05 May 2011)
New Revision: 31093
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java
Log:
corrected warnings about ServerWorkingCopy type (which is internal) and replaced by
IServerWorkingCopy
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java 2011-05-05
09:49:57 UTC (rev 31092)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java 2011-05-05
09:54:52 UTC (rev 31093)
@@ -4,7 +4,7 @@
* 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
+ * 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.
@@ -45,8 +45,6 @@
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.TaskModel;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
@@ -59,12 +57,12 @@
/**
*
* @author Rob Stryker <rob.stryker(a)redhat.com>
- *
+ *
*/
public class StrippedServerWizardFragment extends WizardFragment {
private IWizardHandle handle;
-
+
private Label deployLabel, nameLabel;
private Text deployText, nameText;
private Button browse;
@@ -72,7 +70,7 @@
public StrippedServerWizardFragment() {
}
-
+
public Composite createComposite(Composite parent, IWizardHandle handle) {
this.handle = handle;
Composite main = new Composite(parent, SWT.NONE);
@@ -81,7 +79,7 @@
nameLabel = new Label(main, SWT.NONE);
nameText = new Text(main, SWT.BORDER);
nameLabel.setText(Messages.serverName);
-
+
deployLabel = new Label(main, SWT.NONE);
deployText = new Text(main, SWT.BORDER);
browse = new Button(main, SWT.PUSH);
@@ -89,61 +87,62 @@
browse.setText(Messages.browse);
FormData namelData = new FormData();
- namelData.top = new FormAttachment(0,5);
- namelData.left = new FormAttachment(0,5);
+ namelData.top = new FormAttachment(0, 5);
+ namelData.left = new FormAttachment(0, 5);
nameLabel.setLayoutData(namelData);
-
+
FormData nametData = new FormData();
- nametData.top = new FormAttachment(0,5);
- nametData.left = new FormAttachment(deployLabel,5);
- nametData.right = new FormAttachment(100,-5);
+ nametData.top = new FormAttachment(0, 5);
+ nametData.left = new FormAttachment(deployLabel, 5);
+ nametData.right = new FormAttachment(100, -5);
nameText.setLayoutData(nametData);
-
+
FormData lData = new FormData();
- lData.top = new FormAttachment(nameText,5);
- lData.left = new FormAttachment(0,5);
+ lData.top = new FormAttachment(nameText, 5);
+ lData.left = new FormAttachment(0, 5);
deployLabel.setLayoutData(lData);
-
+
FormData tData = new FormData();
- tData.top = new FormAttachment(nameText,5);
- tData.left = new FormAttachment(deployLabel,5);
+ tData.top = new FormAttachment(nameText, 5);
+ tData.left = new FormAttachment(deployLabel, 5);
tData.right = new FormAttachment(browse, -5);
deployText.setLayoutData(tData);
FormData bData = new FormData();
- bData.right = new FormAttachment(100,-5);
- bData.top = new FormAttachment(nameText,5);
+ bData.right = new FormAttachment(100, -5);
+ bData.top = new FormAttachment(nameText, 5);
browse.setLayoutData(bData);
-
+
ModifyListener ml = new ModifyListener() {
public void modifyText(ModifyEvent e) {
textChanged();
}
};
-
+
browse.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
+
public void widgetSelected(SelectionEvent e) {
DirectoryDialog d = new DirectoryDialog(new Shell());
d.setFilterPath(deployText.getText());
String x = d.open();
- if( x != null )
+ if (x != null)
deployText.setText(x);
- }
+ }
});
-
deployText.addModifyListener(ml);
nameText.addModifyListener(ml);
nameText.setText(getDefaultNameText());
- handle.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.WIZBAN_JBOSS_LOGO));
+ handle.setImageDescriptor(JBossServerUISharedImages
+ .getImageDescriptor(JBossServerUISharedImages.WIZBAN_JBOSS_LOGO));
return main;
}
protected void textChanged() {
IStatus status = checkErrors();
- if( status.isOK() ) {
+ if (status.isOK()) {
deployLoc = deployText.getText();
name = nameText.getText();
handle.setMessage("", IStatus.OK); //$NON-NLS-1$
@@ -152,63 +151,58 @@
handle.setMessage(status.getMessage(), IStatus.WARNING);
}
}
-
+
protected IStatus checkErrors() {
- if( findServer(nameText.getText()) != null ) {
- return new Status(IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID, IStatus.OK,
Messages.StrippedServerWizardFragment_NameInUseStatusMessage, null);
+ if (findServer(nameText.getText()) != null) {
+ return new Status(IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID, IStatus.OK,
+ Messages.StrippedServerWizardFragment_NameInUseStatusMessage, null);
}
File f = new File(deployText.getText());
- if( !f.exists() || !f.isDirectory() ) {
- return new Status(IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID, IStatus.OK,
Messages.StrippedServerWizardFragment_DeployFolderDoesNotExistStatusMessage, null);
+ if (!f.exists() || !f.isDirectory()) {
+ return new Status(IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID, IStatus.OK,
+ Messages.StrippedServerWizardFragment_DeployFolderDoesNotExistStatusMessage, null);
}
return new Status(IStatus.OK, JBossServerUIPlugin.PLUGIN_ID, IStatus.OK, "",
null); //$NON-NLS-1$
}
-
+
public void enter() {
handle.setTitle(Messages.sswf_Title);
IServer s = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
IServerWorkingCopy swc;
- if( s instanceof IServerWorkingCopy)
- swc = (IServerWorkingCopy)s;
+ if (s instanceof IServerWorkingCopy)
+ swc = (IServerWorkingCopy) s;
else
swc = s.createWorkingCopy();
-
- ServerWorkingCopy swcInternal;
- if( swc instanceof ServerWorkingCopy ) {
- swcInternal = (ServerWorkingCopy)swc;
- deployText.setText(swcInternal.getAttribute(DeployableServer.DEPLOY_DIRECTORY,
"")); //$NON-NLS-1$
- }
+
+ deployText.setText(swc.getAttribute(DeployableServer.DEPLOY_DIRECTORY, ""));
//$NON-NLS-1$
}
+
public void exit() {
textChanged();
IServer s = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
IServerWorkingCopy swc;
- if( s instanceof IServerWorkingCopy)
- swc = (IServerWorkingCopy)s;
+ if (s instanceof IServerWorkingCopy)
+ swc = (IServerWorkingCopy) s;
else
swc = s.createWorkingCopy();
-
- ServerWorkingCopy swcInternal;
- if( swc instanceof ServerWorkingCopy ) {
- swcInternal = (ServerWorkingCopy)swc;
- swcInternal.setName(name);
- swcInternal.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLoc);
- String tempFolder =
JBossServerCorePlugin.getServerStateLocation(s).append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
- swcInternal.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempFolder);
- getTaskModel().putObject(TaskModel.TASK_SERVER, swcInternal);
- }
+
+ swc.setName(name);
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLoc);
+ String tempFolder = JBossServerCorePlugin.getServerStateLocation(s)
+ .append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempFolder);
+ getTaskModel().putObject(TaskModel.TASK_SERVER, swc);
}
-
+
public void performFinish(IProgressMonitor monitor) throws CoreException {
IServerWorkingCopy serverWC = (IServerWorkingCopy)
getTaskModel().getObject(TaskModel.TASK_SERVER);
- ServerWorkingCopy serverwc2 = (serverWC instanceof ServerWorkingCopy ?
((ServerWorkingCopy)serverWC) : null);
-
+
try {
- serverwc2.setServerConfiguration(null);
- serverwc2.setName(name);
- serverwc2.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLoc);
- getTaskModel().putObject(TaskModel.TASK_SERVER, serverwc2);
- } catch( Exception ce ) {
+ serverWC.setServerConfiguration(null);
+ serverWC.setName(name);
+ serverWC.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLoc);
+ getTaskModel().putObject(TaskModel.TASK_SERVER, serverWC);
+ } catch (Exception ce) {
}
}
@@ -219,21 +213,20 @@
public boolean hasComposite() {
return true;
}
-
+
private String getDefaultNameText() {
Object o = getTaskModel().getObject(TaskModel.TASK_SERVER);
- return ((ServerWorkingCopy)o).getName();
+ return ((IServerWorkingCopy) o).getName();
}
-
+
private IServer findServer(String name) {
IServer[] servers = ServerCore.getServers();
- for( int i = 0; i < servers.length; i++ ) {
- Server server = (Server) servers[i];
+ for (int i = 0; i < servers.length; i++) {
+ IServer server = servers[i];
if (name.equals(server.getName()))
return server;
}
return null;
}
-
}