Author: rob.stryker(a)jboss.com
Date: 2007-08-21 15:22:08 -0400 (Tue, 21 Aug 2007)
New Revision: 3260
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
Log:
JBIDE-679 fixed
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 2007-08-21
18:23:00 UTC (rev 3259)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2007-08-21
19:22:08 UTC (rev 3260)
@@ -71,21 +71,23 @@
* @author Stryker
*/
public class JBossRuntimeWizardFragment extends WizardFragment {
-
+
private final static int NAME_CHANGED = 1;
private final static int HOME_CHANGED = 2;
private final static int JRE_CHANGED = 3;
private final static int CONFIG_CHANGED = 4;
-
+
private final static int SEVERITY_ALL = 1;
private final static int SEVERITY_MAJOR = 2;
-
+
private IWizardHandle handle;
- private Label nameLabel, homeDirLabel, installedJRELabel, configLabel, explanationLabel;
+ private Label nameLabel, homeDirLabel, installedJRELabel, configLabel,
+ explanationLabel;
private Text nameText, homeDirText;
private Combo jreCombo;
private Button homeDirButton, jreButton;
- private Composite nameComposite, homeDirComposite, jreComposite, configComposite;
+ private Composite nameComposite, homeDirComposite, jreComposite,
+ configComposite;
private String name, homeDir, config;
// jre fields
@@ -95,18 +97,17 @@
private JBossConfigurationTableViewer configurations;
- private IVMInstall selectedVM;
+ private IVMInstall selectedVM;
private boolean pristine;
private String originalName;
-
- public Composite createComposite(Composite parent, IWizardHandle handle)
- {
+
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
this.handle = handle;
-
+
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new FormLayout());
-
+
updateJREs();
createExplanation(main);
createNameComposite(main);
@@ -116,209 +117,223 @@
// If it's an already filled runtime (ie not new) fill our widgets
pristine = isPristineRuntime();
- if( !pristine ) {
+ if (!pristine) {
fillWidgets();
} else {
setWidgetDefaults();
}
- //initTaskModel();
-
-
+ // initTaskModel();
+
// make modifications to parent
handle.setTitle(Messages.createRuntimeWizardTitle);
handle.setImageDescriptor(getImageDescriptor());
return main;
}
-
+
protected ImageDescriptor getImageDescriptor() {
- IRuntime rt = (IRuntime)getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+ IRuntime rt = (IRuntime) getTaskModel().getObject(
+ TaskModel.TASK_RUNTIME);
String id = rt.getRuntimeType().getId();
String imageKey = "";
- if( id.equals("org.jboss.ide.eclipse.as.runtime.32")) imageKey =
JBossServerUISharedImages.WIZBAN_JBOSS32_LOGO;
- else if( id.equals("org.jboss.ide.eclipse.as.runtime.40")) imageKey =
JBossServerUISharedImages.WIZBAN_JBOSS40_LOGO;
- else if( id.equals("org.jboss.ide.eclipse.as.runtime.42")) imageKey =
JBossServerUISharedImages.WIZBAN_JBOSS42_LOGO;
+ if (id.equals("org.jboss.ide.eclipse.as.runtime.32"))
+ imageKey = JBossServerUISharedImages.WIZBAN_JBOSS32_LOGO;
+ else if (id.equals("org.jboss.ide.eclipse.as.runtime.40"))
+ imageKey = JBossServerUISharedImages.WIZBAN_JBOSS40_LOGO;
+ else if (id.equals("org.jboss.ide.eclipse.as.runtime.42"))
+ imageKey = JBossServerUISharedImages.WIZBAN_JBOSS42_LOGO;
return JBossServerUISharedImages.getImageDescriptor(imageKey);
}
private void fillWidgets() {
RuntimeWorkingCopy rwc = getRuntimeWorkingCopy();
- if( rwc != null ) {
+ if (rwc != null) {
originalName = rwc.getName();
nameText.setText(rwc.getName());
homeDirText.setText(rwc.getLocation().toOSString());
- String configSelected =
rwc.getAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, "");
+ String configSelected = rwc.getAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, "");
configurations.setDefaultConfiguration(configSelected);
-
+
configurations.getTable().setVisible(false);
- configLabel.setText(Messages.wizardFragmentConfigLabel + ": " +
configSelected);
+ configLabel.setText(Messages.wizardFragmentConfigLabel + ": "
+ + configSelected);
homeDirText.setEditable(false);
homeDirButton.setEnabled(false);
-
+
try {
- Object o = rwc.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
- if( o != null ) {
- IJBossServerRuntime jbsr = (IJBossServerRuntime)o;
+ Object o = rwc.loadAdapter(IJBossServerRuntime.class,
+ new NullProgressMonitor());
+ if (o != null) {
+ IJBossServerRuntime jbsr = (IJBossServerRuntime) o;
IVMInstall install = jbsr.getVM();
String vmName = install.getName();
String[] jres = jreCombo.getItems();
- for( int i = 0; i < jres.length; i++ ) {
- if( vmName.equals(jres[i]))
+ for (int i = 0; i < jres.length; i++) {
+ if (vmName.equals(jres[i]))
jreCombo.select(i);
}
}
- } catch( Exception e ) {
-
+ } catch (Exception e) {
+
}
-
+
}
}
-
+
private void setWidgetDefaults() {
nameText.setText(generateNewRuntimeName());
- homeDirText.setText( Platform.getOS().equals( Platform.WS_WIN32 ) ?
- "c:/program files/jboss-" + getRuntimeVersionId() + ".x" :
- "/usr/bin/jboss-" + getRuntimeVersionId() + ".x");
+ homeDirText
+ .setText(Platform.getOS().equals(Platform.WS_WIN32) ? "c:/program
files/jboss-"
+ + getRuntimeVersionId() + ".x"
+ : "/usr/bin/jboss-" + getRuntimeVersionId() + ".x");
}
-
+
public String getVersion() {
- IRuntime rt = (IRuntime)getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+ IRuntime rt = (IRuntime) getTaskModel().getObject(
+ TaskModel.TASK_RUNTIME);
String id = rt.getRuntimeType().getId();
- if( id.equals("org.jboss.ide.eclipse.as.runtime.32")) return
"3.2";
- else if( id.equals("org.jboss.ide.eclipse.as.runtime.40")) return
"4.0";
- else if( id.equals("org.jboss.ide.eclipse.as.runtime.42")) return
"4.2";
+ if (id.equals("org.jboss.ide.eclipse.as.runtime.32"))
+ return "3.2";
+ else if (id.equals("org.jboss.ide.eclipse.as.runtime.40"))
+ return "4.0";
+ else if (id.equals("org.jboss.ide.eclipse.as.runtime.42"))
+ return "4.2";
return ""; // default
}
private String generateNewRuntimeName() {
String base = "JBoss " + getVersion() + " runtime";
IRuntime rt = ServerCore.findRuntime(base);
- if( rt == null ) return base;
-
+ if (rt == null)
+ return base;
+
int i = 0;
- while( rt != null ) {
+ while (rt != null) {
rt = ServerCore.findRuntime(base + " " + ++i);
}
return base + " " + i;
}
-
+
private RuntimeWorkingCopy getRuntimeWorkingCopy() {
- IRuntime r = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+ IRuntime r = (IRuntime) getTaskModel()
+ .getObject(TaskModel.TASK_RUNTIME);
IRuntimeWorkingCopy wc;
- if( !(r instanceof IRuntimeWorkingCopy )) {
+ if (!(r instanceof IRuntimeWorkingCopy)) {
wc = r.createWorkingCopy();
- } else { wc = (IRuntimeWorkingCopy)r; }
-
- if( wc instanceof RuntimeWorkingCopy ) {
- RuntimeWorkingCopy rwc = (RuntimeWorkingCopy)wc;
+ } else {
+ wc = (IRuntimeWorkingCopy) r;
+ }
+
+ if (wc instanceof RuntimeWorkingCopy) {
+ RuntimeWorkingCopy rwc = (RuntimeWorkingCopy) wc;
return rwc;
}
return null;
}
-
+
private String getRuntimeVersionId() {
RuntimeWorkingCopy rwc = getRuntimeWorkingCopy();
- try {
- Object o = rwc.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
- if( o != null ) {
- IJBossServerRuntime jbsr = (IJBossServerRuntime)o;
+ if( rwc != null ) {
+ Object o = rwc.loadAdapter(IJBossServerRuntime.class,
+ new NullProgressMonitor());
+ if (o != null) {
+ IJBossServerRuntime jbsr = (IJBossServerRuntime) o;
return jbsr.getId();
}
- } catch( Exception e ) {
}
return "4.0";
}
+
private boolean isPristineRuntime() {
RuntimeWorkingCopy rwc = getRuntimeWorkingCopy();
- if( rwc != null ) {
- if( rwc.getAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, (String)null) ==
null ) {
+ if (rwc != null) {
+ if (rwc.getAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
+ (String) null) == null) {
return true;
}
return false;
}
- // uncertain... its not internal... what is it? :: flails ::
return true;
}
-
+
private void createExplanation(Composite main) {
explanationLabel = new Label(main, SWT.WRAP);
FormData data = new FormData();
- data.top = new FormAttachment(0,5);
- data.left = new FormAttachment(0,5);
- data.right = new FormAttachment(100,-5);
+ data.top = new FormAttachment(0, 5);
+ data.left = new FormAttachment(0, 5);
+ data.right = new FormAttachment(100, -5);
explanationLabel.setLayoutData(data);
-
+
explanationLabel.setText(Messages.runtimeWizardFragmentExplanation);
}
-
+
private void createNameComposite(Composite main) {
// Create our name composite
nameComposite = new Composite(main, SWT.NONE);
-
+
FormData cData = new FormData();
- cData.left = new FormAttachment(0,5);
- cData.right = new FormAttachment(100,-5);
+ cData.left = new FormAttachment(0, 5);
+ cData.right = new FormAttachment(100, -5);
cData.top = new FormAttachment(explanationLabel, 10);
nameComposite.setLayoutData(cData);
-
+
nameComposite.setLayout(new FormLayout());
-
// create internal widgets
nameLabel = new Label(nameComposite, SWT.NONE);
nameLabel.setText(Messages.wizardFragmentNameLabel);
-
+
nameText = new Text(nameComposite, SWT.BORDER);
nameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updatePage(NAME_CHANGED);
- }
-
+ }
+
});
-
+
// organize widgets inside composite
FormData nameLabelData = new FormData();
- nameLabelData.left = new FormAttachment(0,0);
+ nameLabelData.left = new FormAttachment(0, 0);
nameLabel.setLayoutData(nameLabelData);
-
+
FormData nameTextData = new FormData();
nameTextData.left = new FormAttachment(0, 5);
nameTextData.right = new FormAttachment(100, -5);
nameTextData.top = new FormAttachment(nameLabel, 5);
nameText.setLayoutData(nameTextData);
}
-
+
private void createHomeComposite(Composite main) {
// Create our composite
homeDirComposite = new Composite(main, SWT.NONE);
-
+
FormData cData = new FormData();
- cData.left = new FormAttachment(0,5);
- cData.right = new FormAttachment(100,-5);
+ cData.left = new FormAttachment(0, 5);
+ cData.right = new FormAttachment(100, -5);
cData.top = new FormAttachment(nameComposite, 10);
homeDirComposite.setLayoutData(cData);
homeDirComposite.setLayout(new FormLayout());
-
-
+
// Create Internal Widgets
homeDirLabel = new Label(homeDirComposite, SWT.NONE);
homeDirLabel.setText(Messages.wizardFragmentHomeDirLabel);
-
+
homeDirText = new Text(homeDirComposite, SWT.BORDER);
-
+
homeDirButton = new Button(homeDirComposite, SWT.NONE);
homeDirButton.setText(Messages.browse);
-
// Add listeners
homeDirText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updatePage(HOME_CHANGED);
}
});
-
+
homeDirButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
browseHomeDirClicked();
@@ -326,24 +341,23 @@
public void widgetSelected(SelectionEvent e) {
browseHomeDirClicked();
- }
-
+ }
+
});
-
+
// Set Layout Data
FormData labelData = new FormData();
FormData textData = new FormData();
FormData buttonData = new FormData();
-
- labelData.left = new FormAttachment(0,0);
+
+ labelData.left = new FormAttachment(0, 0);
homeDirLabel.setLayoutData(labelData);
-
-
+
textData.left = new FormAttachment(0, 5);
textData.right = new FormAttachment(homeDirButton, -5);
textData.top = new FormAttachment(homeDirLabel, 5);
homeDirText.setLayoutData(textData);
-
+
buttonData.top = new FormAttachment(homeDirLabel, 5);
buttonData.right = new FormAttachment(100, 0);
homeDirButton.setLayoutData(buttonData);
@@ -352,27 +366,26 @@
private void createJREComposite(Composite main) {
// Create our composite
jreComposite = new Composite(main, SWT.NONE);
-
+
FormData cData = new FormData();
- cData.left = new FormAttachment(0,5);
- cData.right = new FormAttachment(100,-5);
+ cData.left = new FormAttachment(0, 5);
+ cData.right = new FormAttachment(100, -5);
cData.top = new FormAttachment(homeDirComposite, 10);
jreComposite.setLayoutData(cData);
jreComposite.setLayout(new FormLayout());
-
-
+
// Create Internal Widgets
installedJRELabel = new Label(jreComposite, SWT.NONE);
installedJRELabel.setText(Messages.wizardFragmentJRELabel);
-
+
jreCombo = new Combo(jreComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
jreCombo.setItems(jreNames);
jreCombo.select(defaultVMIndex);
-
+
jreButton = new Button(jreComposite, SWT.NONE);
jreButton.setText(Messages.installedJREs);
-
+
// Add action listeners
jreButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -394,115 +407,117 @@
public void widgetSelected(SelectionEvent e) {
updatePage(JRE_CHANGED);
- }
- } );
-
+ }
+ });
+
// Set Layout Data
FormData labelData = new FormData();
FormData comboData = new FormData();
FormData buttonData = new FormData();
-
- labelData.left = new FormAttachment(0,0);
+
+ labelData.left = new FormAttachment(0, 0);
installedJRELabel.setLayoutData(labelData);
-
-
+
comboData.left = new FormAttachment(0, 5);
comboData.right = new FormAttachment(jreButton, -5);
comboData.top = new FormAttachment(installedJRELabel, 5);
jreCombo.setLayoutData(comboData);
-
+
buttonData.top = new FormAttachment(installedJRELabel, 5);
buttonData.right = new FormAttachment(100, 0);
jreButton.setLayoutData(buttonData);
}
-
private void updatePage(int changed) {
- switch( changed ) {
- case NAME_CHANGED:
- updateErrorMessage(SEVERITY_MAJOR);
- break;
- case HOME_CHANGED:
- if (! new File(homeDirText.getText()).exists()) {
+ switch (changed) {
+ case NAME_CHANGED:
+ updateErrorMessage(SEVERITY_MAJOR);
+ break;
+ case HOME_CHANGED:
+ if (!isHomeValid()) {
configurations.getControl().setEnabled(false);
+ configurations.setJBossHome(homeDirText.getText());
} else {
- // No errors, clear the message and update the available configurations
+ // No errors, clear the message and update the available
+ // configurations
configurations.setJBossHome(homeDirText.getText());
configurations.setDefaultConfiguration("default");
// update config variable
int index = configurations.getTable().getSelectionIndex();
- if( index != -1 )
+ if (index != -1)
config = configurations.getTable().getItem(index).getText();
}
- updateErrorMessage(SEVERITY_MAJOR);
- break;
- case JRE_CHANGED:
- int sel = jreCombo.getSelectionIndex();
- if( sel != -1 )
- selectedVM = (IVMInstall) installedJREs.get(sel);
- break;
- default:
- break;
+ updateErrorMessage(SEVERITY_MAJOR);
+ break;
+ case JRE_CHANGED:
+ int sel = jreCombo.getSelectionIndex();
+ if (sel != -1)
+ selectedVM = (IVMInstall) installedJREs.get(sel);
+ break;
+ default:
+ break;
}
}
private void updateErrorMessage(int severity) {
String error = getErrorString(severity);
- if( error == null ) {
+ if (error == null) {
handle.setMessage(null, IMessageProvider.NONE);
return;
}
handle.setMessage(error, IMessageProvider.ERROR);
}
-
+
private String getErrorString(int severity) {
- if( getRuntime(nameText.getText()) != null ) {
+ if (getRuntime(nameText.getText()) != null) {
return Messages.runtimeNameInUse;
}
-
- if ( homeDirText.getText() != "" && !new
File(homeDirText.getText()).exists()) {
+
+ if (!isHomeValid())
return Messages.invalidDirectory;
- }
-
- if( severity == SEVERITY_MAJOR ) return null;
-
+
+ if (severity == SEVERITY_MAJOR)
+ return null;
+
// now give minor warnings
- if( nameText.getText().equals(""))
+ if (nameText.getText().equals(""))
return Messages.nameTextBlank;
- if( homeDirText.getText().equals(""))
+ if (homeDirText.getText().equals(""))
return Messages.homeDirBlank;
-
return null;
+ }
+ protected boolean isHomeValid() {
+ return new
Path(homeDirText.getText()).append("bin").append("run.jar")
+ .toFile().exists();
}
-
private void browseHomeDirClicked() {
File file = new File(homeDirText.getText());
- if (! file.exists()) {
+ if (!file.exists()) {
file = null;
}
-
+
File directory = getDirectory(file, homeDirComposite.getShell());
if (directory == null) {
return;
}
-
+
homeDirText.setText(directory.getAbsolutePath());
}
-
+
protected File getDirectory(File startingDirectory, Shell shell) {
DirectoryDialog fileDialog = new DirectoryDialog(shell, SWT.OPEN);
if (startingDirectory != null) {
fileDialog.setFilterPath(startingDirectory.getPath());
}
-
+
String dir = fileDialog.open();
if (dir != null) {
dir = dir.trim();
@@ -512,14 +527,19 @@
}
return null;
}
-
+
// Other
protected boolean showPreferencePage() {
- PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
- IPreferenceNode node =
manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage").findSubNode("org.eclipse.jdt.debug.ui.preferences.VMPreferencePage");
+ PreferenceManager manager = PlatformUI.getWorkbench()
+ .getPreferenceManager();
+ IPreferenceNode node = manager
+ .find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage")
+ .findSubNode(
+ "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage");
PreferenceManager manager2 = new PreferenceManager();
manager2.addToRoot(node);
- final PreferenceDialog dialog = new PreferenceDialog(jreButton.getShell(), manager2);
+ final PreferenceDialog dialog = new PreferenceDialog(jreButton
+ .getShell(), manager2);
final boolean[] result = new boolean[] { false };
BusyIndicator.showWhile(jreButton.getDisplay(), new Runnable() {
public void run() {
@@ -530,8 +550,7 @@
});
return result[0];
}
-
-
+
// JRE methods
protected void updateJREs() {
// get all installed JVMs
@@ -545,7 +564,7 @@
installedJREs.add(vmInstalls[j]);
}
}
-
+
// get names
size = installedJREs.size();
jreNames = new String[size];
@@ -553,13 +572,12 @@
IVMInstall vmInstall = (IVMInstall) installedJREs.get(i);
jreNames[i] = vmInstall.getName();
}
-
+
selectedVM = JavaRuntime.getDefaultVMInstall();
defaultVMIndex = installedJREs.indexOf(selectedVM);
-
}
-
+
// WST API methods
public void enter() {
}
@@ -567,54 +585,59 @@
public void exit() {
name = nameText.getText();
homeDir = homeDirText.getText();
- IRuntime r = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+ IRuntime r = (IRuntime) getTaskModel()
+ .getObject(TaskModel.TASK_RUNTIME);
IRuntimeWorkingCopy runtimeWC;
- if( r instanceof IRuntimeWorkingCopy ) {
- runtimeWC = (IRuntimeWorkingCopy)r;
+ if (r instanceof IRuntimeWorkingCopy) {
+ runtimeWC = (IRuntimeWorkingCopy) r;
} else {
runtimeWC = r.createWorkingCopy();
}
runtimeWC.setName(name);
runtimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy)runtimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_ID,
selectedVM.getId());
- ((RuntimeWorkingCopy)runtimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_TYPE_ID,
selectedVM.getVMInstallType().getId());
- ((RuntimeWorkingCopy)runtimeWC).setAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
configurations.getSelectedConfiguration());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_ID, selectedVM.getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_TYPE_ID, selectedVM
+ .getVMInstallType().getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, configurations
+ .getSelectedConfiguration());
getTaskModel().putObject(TaskModel.TASK_RUNTIME, runtimeWC);
}
-
+
private void createConfigurationComposite(Composite main) {
configComposite = new Composite(main, SWT.NONE);
-
+
FormData cData = new FormData();
- cData.left = new FormAttachment(0,5);
- cData.right = new FormAttachment(100,-5);
+ 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.setLayout(new FormLayout());
-
-
+
configLabel = new Label(configComposite, SWT.NONE);
configLabel.setText(Messages.wizardFragmentConfigLabel);
- configurations = new JBossConfigurationTableViewer(configComposite,
+ configurations = new JBossConfigurationTableViewer(configComposite,
SWT.BORDER | SWT.SINGLE);
-
+
FormData labelData = new FormData();
- labelData.left = new FormAttachment(0,5);
+ 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) {
@@ -623,22 +646,27 @@
public void widgetSelected(SelectionEvent e) {
updatePage(CONFIG_CHANGED);
- }
-
- } );
+ }
+ });
+
}
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
- public void performFinish(IProgressMonitor monitor) throws CoreException {
-
- IRuntime r = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+ IRuntime r = (IRuntime) getTaskModel()
+ .getObject(TaskModel.TASK_RUNTIME);
IRuntimeWorkingCopy runtimeWC = r.createWorkingCopy();
runtimeWC.setName(name);
runtimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy)runtimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_ID,
selectedVM.getId());
- ((RuntimeWorkingCopy)runtimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_TYPE_ID,
selectedVM.getVMInstallType().getId());
- ((RuntimeWorkingCopy)runtimeWC).setAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
configurations.getSelectedConfiguration());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_ID, selectedVM.getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_TYPE_ID, selectedVM
+ .getVMInstallType().getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, configurations
+ .getSelectedConfiguration());
IRuntime saved = runtimeWC.save(false, new NullProgressMonitor());
getTaskModel().putObject(TaskModel.TASK_RUNTIME, saved);
@@ -652,13 +680,15 @@
public boolean hasComposite() {
return true;
}
-
+
private IRuntime getRuntime(String runtimeName) {
- if( runtimeName.equals(originalName)) return null; // name is same as original. No
clash.
-
+ if (runtimeName.equals(originalName))
+ return null; // name is same as original. No clash.
+
IRuntime[] runtimes = ServerCore.getRuntimes();
- for( int i = 0; i < runtimes.length; i++ ) {
- if( runtimes[i].getName().equals(runtimeName)) return runtimes[i];
+ for (int i = 0; i < runtimes.length; i++) {
+ if (runtimes[i].getName().equals(runtimeName))
+ return runtimes[i];
}
return null;
}