[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards ...
Robert Stryker
rawblem at gmail.com
Wed Sep 6 15:32:12 EDT 2006
User: rawb
Date: 06/09/06 15:32:12
Modified: as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards
AbstractJBossRuntimeWizardFragment.java
AbstractJBossServerWizardFragment.java
Removed: as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards
ProjectRuntimeWizardFragment.java
Log:
Moved more data from 'server' object to 'runtime' object to more closely follow the WTP assumptions.
Revision Changes Path
1.2 +89 -8 jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/AbstractJBossRuntimeWizardFragment.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractJBossRuntimeWizardFragment.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/AbstractJBossRuntimeWizardFragment.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AbstractJBossRuntimeWizardFragment.java 26 Aug 2006 02:33:14 -0000 1.1
+++ AbstractJBossRuntimeWizardFragment.java 6 Sep 2006 19:32:12 -0000 1.2
@@ -63,7 +63,9 @@
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
import org.jboss.ide.eclipse.as.core.server.runtime.JBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.util.ASDebug;
import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.util.JBossConfigurationTableViewer;
/**
* @author Stryker
@@ -79,18 +81,20 @@
private final static int SEVERITY_MAJOR = 2;
private IWizardHandle handle;
- private Label nameLabel, homeDirLabel, installedJRELabel;
+ private Label nameLabel, homeDirLabel, installedJRELabel, configLabel;
private Text nameText, homeDirText;
private Combo jreCombo;
private Button homeDirButton, jreButton;
- private Composite nameComposite, homeDirComposite, jreComposite;
- private String name, homeDir;
+ private Composite nameComposite, homeDirComposite, jreComposite, configComposite;
+ private String name, homeDir, config;
// jre fields
protected ArrayList installedJREs;
protected String[] jreNames;
protected int defaultVMIndex;
+ private JBossConfigurationTableViewer configurations;
+
private IVMInstall selectedVM;
public Composite createComposite(Composite parent, IWizardHandle handle)
@@ -104,6 +108,10 @@
createNameComposite(main);
createHomeComposite(main);
createJREComposite(main);
+ createConfigurationComposite(main);
+
+ initTaskModel();
+
// make modifications to parent
handle.setTitle(Messages.createWizardTitle);
@@ -250,11 +258,11 @@
jreCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
- updatePage(CONFIG_CHANGED);
+ updatePage(JRE_CHANGED);
}
public void widgetSelected(SelectionEvent e) {
- updatePage(CONFIG_CHANGED);
+ updatePage(JRE_CHANGED);
}
} );
@@ -278,12 +286,39 @@
}
+ private void initTaskModel() {
+ IRuntime r = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+ IRuntimeWorkingCopy wc;
+ if( !(r instanceof IRuntimeWorkingCopy )) {
+ wc = r.createWorkingCopy();
+ } else { wc = (IRuntimeWorkingCopy)r; }
+
+ if( wc instanceof RuntimeWorkingCopy ) {
+ RuntimeWorkingCopy rwc = (RuntimeWorkingCopy)wc;
+ rwc.setAttribute(JBossServerRuntime.PROPERTY_CONFIGURATION_NAME, configurations.getSelectedConfiguration());
+ rwc.setAttribute(JBossServerRuntime.PROPERTY_VM_ID, selectedVM.getId());
+ rwc.setAttribute(JBossServerRuntime.PROPERTY_VM_TYPE_ID, selectedVM.getVMInstallType().getId());
+ }
+ }
+
private void updatePage(int changed) {
switch( changed ) {
case NAME_CHANGED:
updateErrorMessage(SEVERITY_MAJOR);
break;
case HOME_CHANGED:
+ if (! new File(homeDirText.getText()).exists()) {
+ configurations.getControl().setEnabled(false);
+ } else {
+ // 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();
+ config = configurations.getTable().getItem(index).getText();
+ }
+
updateErrorMessage(SEVERITY_MAJOR);
break;
case JRE_CHANGED:
@@ -425,6 +460,7 @@
((RuntimeWorkingCopy)runtimeWC).setAttribute(JBossServerRuntime.PROPERTY_VM_ID, selectedVM.getId());
((RuntimeWorkingCopy)runtimeWC).setAttribute(JBossServerRuntime.PROPERTY_VM_TYPE_ID, selectedVM.getVMInstallType().getId());
+ ((RuntimeWorkingCopy)runtimeWC).setAttribute(JBossServerRuntime.PROPERTY_CONFIGURATION_NAME, configurations.getSelectedConfiguration());
getTaskModel().putObject(TaskModel.TASK_RUNTIME, runtimeWC);
// JBossServerRuntime runtime = (JBossServerRuntime)runtimeWC.loadAdapter(JBossServerRuntime.class, new NullProgressMonitor());
@@ -432,17 +468,62 @@
}
+ 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.top = new FormAttachment(jreComposite, 10);
+ configComposite.setLayoutData(cData);
+
+ configComposite.setLayout(new FormLayout());
+
+
+ configLabel = new Label(configComposite, SWT.NONE);
+ configLabel.setText(Messages.wizardFragmentConfigLabel);
+
+ 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);
+ configurations.getTable().setLayoutData(viewerData);
+
+ configurations.getTable().addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updatePage(CONFIG_CHANGED);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ ASDebug.p("selected is " + configurations.getSelectedConfiguration(), this);
+ updatePage(CONFIG_CHANGED);
+ }
+
+ } );
+
+ }
+
+
public void performFinish(IProgressMonitor monitor) throws CoreException {
IRuntime r = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
IRuntimeWorkingCopy runtimeWC = r.createWorkingCopy();
runtimeWC.setName(name);
runtimeWC.setLocation(new Path(homeDir));
+ ((RuntimeWorkingCopy)runtimeWC).setAttribute(JBossServerRuntime.PROPERTY_VM_ID, selectedVM.getId());
+ ((RuntimeWorkingCopy)runtimeWC).setAttribute(JBossServerRuntime.PROPERTY_VM_TYPE_ID, selectedVM.getVMInstallType().getId());
+ ((RuntimeWorkingCopy)runtimeWC).setAttribute(JBossServerRuntime.PROPERTY_CONFIGURATION_NAME, configurations.getSelectedConfiguration());
+
IRuntime saved = runtimeWC.save(false, new NullProgressMonitor());
getTaskModel().putObject(TaskModel.TASK_RUNTIME, saved);
- JBossServerRuntime runtime = (JBossServerRuntime)saved.loadAdapter(JBossServerRuntime.class, new NullProgressMonitor());
- runtime.setVMInstall(selectedVM);
-
}
public boolean isComplete() {
1.2 +96 -156 jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/AbstractJBossServerWizardFragment.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractJBossServerWizardFragment.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/AbstractJBossServerWizardFragment.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AbstractJBossServerWizardFragment.java 26 Aug 2006 02:33:14 -0000 1.1
+++ AbstractJBossServerWizardFragment.java 6 Sep 2006 19:32:12 -0000 1.2
@@ -59,6 +59,7 @@
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
import org.eclipse.wst.server.core.internal.ServerType;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
@@ -80,19 +81,18 @@
private final static int SEVERITY_MAJOR = 2;
private IWizardHandle handle;
- private Label nameLabel, homeDirLabel, installedJRELabel, configLabel;
- private Text nameText, homeDirText;
+ private Label nameLabel, homeDirLabel, installedJRELabel, configLabel;// configLabel;
+ private Text nameText, homeDirText, configText;
private Combo jreCombo;
- private Button homeDirButton, jreButton;
private Composite nameComposite, homeDirComposite, jreComposite, configComposite;
private Group g;
- private String name, homeDir, jre, config;
+ private String name, config;
// jre fields
protected ArrayList installedJREs;
protected String[] jreNames;
protected int defaultVMIndex;
- private JBossConfigurationTableViewer configurations;
+// private JBossConfigurationTableViewer configurations;
private IVMInstall selectedVM;
@@ -129,7 +129,7 @@
createHomeComposite(g);
createJREComposite(g);
- createConfigurationComposite(main);
+ createConfigurationComposite(g);
@@ -155,7 +155,7 @@
// create internal widgets
nameLabel = new Label(nameComposite, SWT.None);
- nameLabel.setText(Messages.wizardFragmentNameLabel);
+ nameLabel.setText("Server " + Messages.wizardFragmentNameLabel);
nameText = new Text(nameComposite, SWT.BORDER);
nameText.addModifyListener(new ModifyListener() {
@@ -198,29 +198,6 @@
homeDirText = new Text(homeDirComposite, SWT.BORDER);
homeDirText.setEditable(false);
-
-// 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();
-// }
-//
-// public void widgetSelected(SelectionEvent e) {
-// browseHomeDirClicked();
-// }
-//
-// });
-
// Set Layout Data
FormData labelData = new FormData();
FormData textData = new FormData();
@@ -234,13 +211,8 @@
textData.right = new FormAttachment(100, -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);
-
-
}
+
private void createJREComposite(Composite main) {
// Create our composite
jreComposite = new Composite(main, SWT.NONE);
@@ -263,32 +235,6 @@
jreCombo.select(defaultVMIndex);
jreCombo.setEnabled(false);
-// jreButton = new Button(jreComposite, SWT.NONE);
-// jreButton.setText(Messages.installedJREs);
-
- // Add action listeners
-// jreButton.addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent e) {
-// String currentVM = jreCombo.getText();
-// if (showPreferencePage()) {
-// updateJREs();
-// jreCombo.setItems(jreNames);
-// jreCombo.setText(currentVM);
-// if (jreCombo.getSelectionIndex() == -1)
-// jreCombo.select(defaultVMIndex);
-// }
-// }
-// });
-//
-// jreCombo.addSelectionListener(new SelectionListener() {
-// public void widgetDefaultSelected(SelectionEvent e) {
-// updatePage(CONFIG_CHANGED);
-// }
-//
-// public void widgetSelected(SelectionEvent e) {
-// updatePage(CONFIG_CHANGED);
-// }
-// } );
// Set Layout Data
FormData labelData = new FormData();
@@ -303,52 +249,80 @@
comboData.right = new FormAttachment(60, -5);
comboData.top = new FormAttachment(homeDirComposite, 5);
jreCombo.setLayoutData(comboData);
-
-// buttonData.top = new FormAttachment(installedJRELabel, 5);
-// buttonData.right = new FormAttachment(100, 0);
-// jreButton.setLayoutData(buttonData);
-
}
+
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.top = new FormAttachment(g, 10);
+ cData.top = new FormAttachment(jreComposite, 5);
configComposite.setLayoutData(cData);
configComposite.setLayout(new FormLayout());
+ // Create Internal Widgets
configLabel = new Label(configComposite, SWT.NONE);
- configLabel.setText(Messages.wizardFragmentConfigLabel);
+ configLabel.setText("Configuration");
- configurations = new JBossConfigurationTableViewer(configComposite,
- SWT.BORDER | SWT.SINGLE);
+ configText = new Text(configComposite, SWT.BORDER);
+ configText.setEditable(false);
+ // Set Layout Data
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);
- configurations.getTable().setLayoutData(viewerData);
-
- configurations.getTable().addSelectionListener(new SelectionListener() {
+ FormData textData = new FormData();
+ //FormData buttonData = new FormData();
- public void widgetDefaultSelected(SelectionEvent e) {
- updatePage(CONFIG_CHANGED);
- }
+ labelData.left = new FormAttachment(0,0);
+ configLabel.setLayoutData(labelData);
- public void widgetSelected(SelectionEvent e) {
- updatePage(CONFIG_CHANGED);
- }
- } );
+ textData.left = new FormAttachment(0, 5);
+ textData.right = new FormAttachment(100, -5);
+ textData.top = new FormAttachment(configLabel, 5);
+ configText.setLayoutData(textData);
+// 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(g, 10);
+// configComposite.setLayoutData(cData);
+//
+// configComposite.setLayout(new FormLayout());
+//
+//
+// configLabel = new Label(configComposite, SWT.NONE);
+// configLabel.setText(Messages.wizardFragmentConfigLabel);
+//
+// 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);
+// configurations.getTable().setLayoutData(viewerData);
+//
+// configurations.getTable().addSelectionListener(new SelectionListener() {
+//
+// public void widgetDefaultSelected(SelectionEvent e) {
+// updatePage(CONFIG_CHANGED);
+// }
+//
+// public void widgetSelected(SelectionEvent e) {
+// updatePage(CONFIG_CHANGED);
+// }
+//
+// } );
+//
}
private void updatePage(int changed) {
@@ -357,17 +331,6 @@
updateErrorMessage(SEVERITY_MAJOR);
break;
case HOME_CHANGED:
- if (! new File(homeDirText.getText()).exists()) {
- configurations.getControl().setEnabled(false);
- } else {
- // 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();
- config = configurations.getTable().getItem(index).getText();
- }
updateErrorMessage(SEVERITY_MAJOR);
break;
@@ -376,8 +339,6 @@
selectedVM = (IVMInstall) installedJREs.get(sel);
break;
case CONFIG_CHANGED:
- int index = configurations.getTable().getSelectionIndex();
- config = configurations.getTable().getItem(index).getText();
break;
default:
break;
@@ -418,21 +379,6 @@
}
-
-// private void browseHomeDirClicked() {
-// File file = new File(homeDirText.getText());
-// 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) {
@@ -449,25 +395,6 @@
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 manager2 = new PreferenceManager();
- manager2.addToRoot(node);
- final PreferenceDialog dialog = new PreferenceDialog(jreButton.getShell(), manager2);
- final boolean[] result = new boolean[] { false };
- BusyIndicator.showWhile(jreButton.getDisplay(), new Runnable() {
- public void run() {
- dialog.create();
- if (dialog.open() == Window.OK)
- result[0] = true;
- }
- });
- return result[0];
- }
-
-
// JRE methods
protected void updateJREs() {
// get all installed JVMs
@@ -492,31 +419,53 @@
selectedVM = JavaRuntime.getDefaultVMInstall();
defaultVMIndex = installedJREs.indexOf(selectedVM);
-
-
}
// WST API methods
public void enter() {
IRuntime r = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
- IRuntimeWorkingCopy runtimeWC = r.createWorkingCopy();
- runtime = (JBossServerRuntime) runtimeWC.loadAdapter(JBossServerRuntime.class, null);
+ IRuntimeWorkingCopy wc;
+ if( r instanceof IRuntimeWorkingCopy )
+ wc = (IRuntimeWorkingCopy)r;
+ else
+ wc = r.createWorkingCopy();
+
+ if( wc instanceof RuntimeWorkingCopy ) {
+ RuntimeWorkingCopy rwc = (RuntimeWorkingCopy)wc;
+ homeDirText.setText(rwc.getLocation().toOSString());
+ configText.setText(rwc.getAttribute(JBossServerRuntime.PROPERTY_CONFIGURATION_NAME, ""));
+
+
+ String[] vmNames = jreCombo.getItems();
+ IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(rwc.getAttribute(JBossServerRuntime.PROPERTY_VM_TYPE_ID, ""));
+ String vmId = rwc.getAttribute(JBossServerRuntime.PROPERTY_VM_ID, "");
+
+ IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
+
+ int comboIndex = -1;
+ for (int i = 0; i < vmNames.length && comboIndex == -1; i++) {
+ for( int j = 0; j < vmInstalls.length && comboIndex == -1; j++ ) {
+ ASDebug.p("comparing " + vmNames[i] + " with " + vmInstalls[j].getName(), this);
+ if (vmNames[i].equals(vmInstalls[j].getName()) && vmInstalls[j].getId().equals(vmId))
+ comboIndex = i;
+ }
+ }
+
+ jreCombo.select(comboIndex);
- try {
- homeDirText.setText(r.getLocation().toOSString());
- } catch( Exception e ) {
- e.printStackTrace();
}
}
public void exit() {
name = nameText.getText();
- homeDir = homeDirText.getText();
- jre = jreCombo.getText();
}
public void performFinish(IProgressMonitor monitor) throws CoreException {
IServerWorkingCopy serverWC = (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
+ IRuntime r = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
+ runtime = (JBossServerRuntime) r.loadAdapter(JBossServerRuntime.class, null);
+
+
IFolder folder = getJbossServerFolder(name);
if( !folder.exists()) {
@@ -531,16 +480,9 @@
server = (JBossServer) serverWC.loadAdapter(JBossServer.class, new NullProgressMonitor());
}
- ServerAttributeHelper helper = new ServerAttributeHelper(server, serverWC);
- //helper.setServerHome(homeDir);
- helper.setJbossConfiguration(config);
-
try {
server.setRuntime(runtime);
- //runtime.setVMInstall(selectedVM);
} catch( Exception e ) {
-// System.out.println("DYING HERE");
- e.printStackTrace();
}
}
@@ -550,8 +492,6 @@
return s == null ? true : false;
}
- //protected abstract ImageDescriptor getImageDescriptor();
-
public boolean hasComposite() {
return true;
}
More information about the jboss-cvs-commits
mailing list