|
From: <caw...@us...> - 2007-01-18 21:44:50
|
Revision: 1803
http://svn.sourceforge.net/rubyeclipse/?rev=1803&view=rev
Author: cawilliams
Date: 2007-01-18 13:44:46 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
Lots of changes! More work towards modifying our interpreter setup/usage (so we can eventually support many types of VMs - JRuby, C Ruby, Rubinius, YARV)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.build/cruiseControl/plugin/cruiseControl.launch
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/LoadPathEntryLabelProvider.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
trunk/org.rubypeople.rdt.launching/plugin.xml
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.properties
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingPlugin.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyApplicationLaunchConfigurationDelegate.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VMDefinitionsContainer.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMInstallType.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMsUpdater.java
trunk/org.rubypeople.rdt.launching/schema/
trunk/org.rubypeople.rdt.launching/schema/vmInstallTypes.exsd
trunk/org.rubypeople.rdt.launching/schema/vmInstalls.exsd
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LibraryInfo.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMInstall.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMInstallType.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VMStandin.java
Modified: trunk/org.rubypeople.rdt.build/cruiseControl/plugin/cruiseControl.launch
===================================================================
--- trunk/org.rubypeople.rdt.build/cruiseControl/plugin/cruiseControl.launch 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.build/cruiseControl/plugin/cruiseControl.launch 2007-01-18 21:44:46 UTC (rev 1803)
@@ -1,7 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="CruiseControl"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="cruise-control-plugin"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/cruise-control-plugin"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:cruise-control-plugin/config}"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -16,48 +16,60 @@
import org.eclipse.debug.core.model.IProcess;
import org.rubypeople.eclipse.testutils.ResourceTools;
import org.rubypeople.rdt.internal.debug.core.RubyLineBreakpoint;
-import org.rubypeople.rdt.internal.launching.RubyInterpreter;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
-import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
+import org.rubypeople.rdt.launching.VMStandin;
/*
*
*/
public class FTC_DebuggerLaunch extends TestCase {
+ private static final String RUBY_INTERPRETER_ID = "RubyInterpreter";
+ private static final String VM_TYPE_ID = "org.rubypeople.rdt.launching.StandardVMType";
+ private static final boolean VERBOSE = false;
+ private IVMInstallType vmType;
+
public void setUp() {
- this.createInterpreter() ;
- }
-
- protected void createInterpreter() {
+ vmType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
// We rely on the RUBY_INTERPRETER to be a full path to a valid ruby executable, therefore the property rdt.rubyInterpreter has
// to be set accordingly
- String rubyInterpreterPath = FTC_ClassicDebuggerCommunicationTest.RUBY_INTERPRETER ;
- System.out.println("Using interpreter: " + rubyInterpreterPath) ;
- IVMInstall rubyInterpreter = new RubyInterpreter("RubyInterpreter", new File(rubyInterpreterPath));
- RubyRuntime.getDefault().addInstalledInterpreter(rubyInterpreter) ;
+ String rubyInterpreterPath = FTC_ClassicDebuggerCommunicationTest.RUBY_INTERPRETER;
+ log("Using interpreter: " + rubyInterpreterPath);
+ VMStandin standin = new VMStandin(vmType, RUBY_INTERPRETER_ID);
+ standin.setInstallLocation(new File(rubyInterpreterPath));
+ standin.convertToRealVM();
+ }
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ vmType.disposeVMInstall(RUBY_INTERPRETER_ID);
}
protected void log(String label, ILaunch launch) throws Exception {
- System.out.println("Infos about " + label + ":");
+ log("Infos about " + label + ":");
IProcess process = launch.getProcesses()[0];
if (process.isTerminated()) {
- System.out.println("Process has finished with exit-value: " + process.getExitValue());
+ log("Process has finished with exit-value: " + process.getExitValue());
} else {
- System.out.println("Process still running.");
+ log("Process still running.");
}
String error = process.getStreamsProxy().getErrorStreamMonitor().getContents();
if (error != null && error.length() > 0) {
- System.out.println("Process stderr: " + error);
+ log("Process stderr: " + error);
}
String stdout = process.getStreamsProxy().getOutputStreamMonitor().getContents();
if (stdout != null && stdout.length() > 0) {
- System.out.println("Process stdout: " + stdout);
+ log("Process stdout: " + stdout);
}
}
+
+ private void log(String message) {
+ if (VERBOSE) System.out.println(message);
+ }
public void testTwoSessions() throws Exception {
@@ -71,7 +83,7 @@
wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, rubyFile.getProject().getName());
wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, rubyFile.getProjectRelativePath().toString());
//wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, RubyApplicationShortcut.getDefaultWorkingDirectory(rubyFile.getProject()));
- wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, "RubyInterpreter");
+ wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RUBY_INTERPRETER_ID);
ILaunchConfiguration lc = wc.doSave() ;
DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(new RubyLineBreakpoint(rubyFile, 1)) ;
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/LoadPathEntryLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/LoadPathEntryLabelProvider.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/LoadPathEntryLabelProvider.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -7,12 +7,6 @@
import org.rubypeople.rdt.internal.core.LoadpathEntry;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
-/**
- * @author xp4
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- */
public class LoadPathEntryLabelProvider implements ILabelProvider {
/**
@@ -27,7 +21,7 @@
*/
public String getText(Object element) {
if (element != null && element.getClass() == LoadpathEntry.class) {
- IProject project = ((LoadpathEntry) element).getProject() ;
+ IProject project = ((LoadpathEntry) element).getProject();
if (project.isAccessible()) {
return project.getLocation().toOSString() ;
}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -119,7 +119,7 @@
}
protected ILaunchConfiguration createConfiguration(IFile rubyFile) {
- if (RubyRuntime.getDefault().getSelectedInterpreter() == null) {
+ if (RubyRuntime.getDefaultVMInstall() == null) {
this.showNoInterpreterDialog();
return null;
}
@@ -130,7 +130,8 @@
wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, rubyFile.getProject().getName());
wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, rubyFile.getProjectRelativePath().toString());
wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, RubyApplicationShortcut.getDefaultWorkingDirectory(rubyFile.getProject()));
- wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getDefault().getSelectedInterpreter().getName());
+ wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getCompositeIdFromVM(RubyRuntime.getDefaultVMInstall()));
+ // FIXME generate a composite id for the interpreter, not name!
wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator");
config = wc.doSave();
} catch (CoreException ce) {
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -33,13 +33,15 @@
import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiMessages;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
-import org.rubypeople.rdt.internal.debug.ui.preferences.EditInterpreterDialog;
+import org.rubypeople.rdt.internal.debug.ui.preferences.AddVMDialog;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.IAddVMDialogRequestor;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.RubyVMMessages;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
import org.rubypeople.rdt.internal.ui.RubyPluginImages;
import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
+import org.rubypeople.rdt.launching.VMStandin;
public class RubyEnvironmentTab extends AbstractLaunchConfigurationTab {
protected ListViewer loadPathListViewer;
@@ -156,7 +158,7 @@
}
public void widgetSelected(SelectionEvent evt) {
- EditInterpreterDialog dialog = new EditInterpreterDialog(this,
+ AddVMDialog dialog = new AddVMDialog(this,
fShell, RubyRuntime.getVMInstallTypes(),
null);
dialog.setTitle(RubyVMMessages.InstalledJREsBlock_7);
@@ -166,12 +168,15 @@
}
public boolean isDuplicateName(String name) {
- // TODO Auto-generated method stub
return false;
}
public void vmAdded(IVMInstall vm) {
- RubyRuntime.getDefault().addInstalledInterpreter(vm);
+ // FIXME Use something like JREsUpdater?
+ if (vm instanceof VMStandin) {
+ VMStandin standin = (VMStandin) vm;
+ standin.convertToRealVM();
+ }
fCombo.add(vm.getName());
fCombo.select(fCombo.indexOf(vm.getName()));
}
@@ -195,7 +200,7 @@
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
IVMInstall defaultInterpreter = RubyRuntime.getDefault()
- .getSelectedInterpreter();
+ .getDefaultVMInstall();
if (defaultInterpreter != null) {
configuration.setAttribute(
RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER,
@@ -254,9 +259,18 @@
protected void initializeInterpreterCombo(Combo interpreterCombo) {
installedInterpretersWorkingCopy = new ArrayList();
- installedInterpretersWorkingCopy.addAll(RubyRuntime.getDefault()
- .getInstalledInterpreters());
-
+ List standins = new ArrayList();
+ IVMInstallType[] types = RubyRuntime.getVMInstallTypes();
+ for (int i = 0; i < types.length; i++) {
+ IVMInstallType type = types[i];
+ IVMInstall[] installs = type.getVMInstalls();
+ for (int j = 0; j < installs.length; j++) {
+ IVMInstall install = installs[j];
+ standins.add(new VMStandin(install));
+ }
+ }
+ installedInterpretersWorkingCopy.addAll(standins);
+
String[] interpreterNames = new String[installedInterpretersWorkingCopy
.size()];
for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy
@@ -267,8 +281,7 @@
}
interpreterCombo.setItems(interpreterNames);
- IVMInstall selectedInterpreter = RubyRuntime.getDefault()
- .getSelectedInterpreter();
+ IVMInstall selectedInterpreter = RubyRuntime.getDefaultVMInstall();
if (selectedInterpreter != null)
interpreterCombo.select(interpreterCombo
.indexOf(selectedInterpreter.getName()));
Deleted: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -1,345 +0,0 @@
-package org.rubypeople.rdt.internal.debug.ui.preferences;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiMessages;
-import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
-import org.rubypeople.rdt.internal.debug.ui.rubyvms.IAddVMDialogRequestor;
-import org.rubypeople.rdt.internal.debug.ui.rubyvms.RubyVMMessages;
-import org.rubypeople.rdt.internal.launching.VMStandin;
-import org.rubypeople.rdt.internal.ui.dialogs.StatusDialog;
-import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
-import org.rubypeople.rdt.internal.ui.wizards.dialogfields.ComboDialogField;
-import org.rubypeople.rdt.internal.ui.wizards.dialogfields.DialogField;
-import org.rubypeople.rdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.rubypeople.rdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.rubypeople.rdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.rubypeople.rdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.rubypeople.rdt.launching.IVMInstall;
-import org.rubypeople.rdt.launching.IVMInstall2;
-import org.rubypeople.rdt.launching.IVMInstallType;
-
-public class EditInterpreterDialog extends StatusDialog {
-
- protected IStatus[] allStatus = new IStatus[2];
-
- protected IVMInstall fEditedVM;
- private StringButtonDialogField fJRERoot;
- private StringDialogField fVMName;
-
- private StringDialogField fVMArgs;
-
- private IVMInstallType fSelectedVMType;
- private IVMInstallType[] fVMTypes;
- private ComboDialogField fVMTypeCombo;
-
- private IStatus[] fStati;
-
- private int fPrevIndex = -1;
-
- private IAddVMDialogRequestor fRequestor;
-
- public EditInterpreterDialog(IAddVMDialogRequestor requestor, Shell shell, IVMInstallType[] vmInstallTypes, IVMInstall editedVM) {
- super(shell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- fRequestor= requestor;
- fStati= new IStatus[5];
- for (int i= 0; i < fStati.length; i++) {
- fStati[i]= new StatusInfo();
- }
-
- fVMTypes= vmInstallTypes;
- fSelectedVMType= editedVM != null ? editedVM.getVMInstallType() : vmInstallTypes[0];
-
- fEditedVM= editedVM;
- }
-
- protected IStatus validateInterpreterLocationText() {
- String locationName = fJRERoot.getText();
- if (locationName.length() == 0) {
- return new StatusInfo(IStatus.INFO, RubyVMMessages.addVMDialog_enterLocation);
- }
- File file = new File(locationName);
- if (!file.exists()) {
- return new StatusInfo(IStatus.ERROR, RubyVMMessages.addVMDialog_locationNotExists);
- }
- // FIXME We want the user to select a directory as the home of the ruby install!
- if(file.isFile()){
- return new Status(IStatus.OK, RdtDebugUiPlugin.PLUGIN_ID, 0, "", null);
- }
- return new Status(IStatus.ERROR, RdtDebugUiPlugin.PLUGIN_ID, 1, RdtDebugUiMessages.getString("EditInterpreterDialog.rubyInterpreter.path.error"), null);
- }
-
- protected void browseForInstallLocation() {
- FileDialog dialog = new FileDialog(getShell());
- dialog.setFilterPath(fJRERoot.getText());
- dialog.setText(RdtDebugUiMessages.getString("EditInterpreterDialog.rubyInterpreter.path.browse.message")); //$NON-NLS-1$
- String newPath = dialog.open();
- if (newPath != null)
- fJRERoot.setText(newPath);
- }
-
- protected void okPressed() {
- doOkPressed();
- super.okPressed();
- }
-
- private void doOkPressed() {
- if (fEditedVM == null) {
- IVMInstall vm= new VMStandin(fSelectedVMType, createUniqueId(fSelectedVMType));
- setFieldValuesToVM(vm);
- fRequestor.vmAdded(vm);
- } else {
- setFieldValuesToVM(fEditedVM);
- }
- }
-
- public void create() {
- super.create();
- fVMName.setFocus();
- selectVMType();
- }
-
- private String createUniqueId(IVMInstallType vmType) {
- String id= null;
- do {
- id= String.valueOf(System.currentTimeMillis());
- } while (vmType.findVMInstall(id) != null);
- return id;
- }
-
- private void selectVMType() {
- for (int i= 0; i < fVMTypes.length; i++) {
- if (fSelectedVMType == fVMTypes[i]) {
- fVMTypeCombo.selectItem(i);
- return;
- }
- }
- }
-
- private void updateVMType() {
- int selIndex= fVMTypeCombo.getSelectionIndex();
- if (selIndex == fPrevIndex) {
- return;
- }
- fPrevIndex = selIndex;
- if (selIndex >= 0 && selIndex < fVMTypes.length) {
- fSelectedVMType= fVMTypes[selIndex];
- }
- setJRELocationStatus(validateInterpreterLocationText());
-// fLibraryBlock.initializeFrom(fEditedVM, fSelectedVMType);
- updateStatusLine();
- }
-
- private void setJRELocationStatus(IStatus status) {
- fStati[1]= status;
- }
-
- protected void updateStatusLine() {
- IStatus max= null;
- for (int i= 0; i < fStati.length; i++) {
- IStatus curr= fStati[i];
- if (curr.matches(IStatus.ERROR)) {
- updateStatus(curr);
- return;
- }
- if (max == null || curr.getSeverity() > max.getSeverity()) {
- max= curr;
- }
- }
- updateStatus(max);
- }
-
- protected Control createDialogArea(Composite ancestor) {
- createDialogFields();
- Composite parent = (Composite)super.createDialogArea(ancestor);
- ((GridLayout)parent.getLayout()).numColumns= 3;
-
- fVMTypeCombo.doFillIntoGrid(parent, 3);
- ((GridData)fVMTypeCombo.getComboControl(null).getLayoutData()).widthHint= convertWidthInCharsToPixels(50);
-
- fVMName.doFillIntoGrid(parent, 3);
-
- fJRERoot.doFillIntoGrid(parent, 3);
-
- fVMArgs.doFillIntoGrid(parent, 3);
- ((GridData)fVMArgs.getTextControl(null).getLayoutData()).widthHint= convertWidthInCharsToPixels(50);
-
- Label l = new Label(parent, SWT.NONE);
- l.setText(RubyVMMessages.AddVMDialog_JRE_system_libraries__1);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- l.setLayoutData(gd);
-
-// fLibraryBlock = new VMLibraryBlock(this);
-// Control block = fLibraryBlock.createControl(parent);
-// gd = new GridData(GridData.FILL_BOTH);
-// gd.horizontalSpan = 3;
-// block.setLayoutData(gd);
-
- Text t= fJRERoot.getTextControl(parent);
- gd= (GridData)t.getLayoutData();
- gd.grabExcessHorizontalSpace=true;
- gd.widthHint= convertWidthInCharsToPixels(50);
-
- initializeFields();
- createFieldListeners();
- applyDialogFont(parent);
- return parent;
- }
-
- private void initializeFields() {
- fVMTypeCombo.setItems(getVMTypeNames());
- if (fEditedVM == null) {
- fVMName.setText(""); //$NON-NLS-1$
- fJRERoot.setText(""); //$NON-NLS-1$
-// fLibraryBlock.initializeFrom(null, fSelectedVMType);
- fVMArgs.setText(""); //$NON-NLS-1$
- } else {
- fVMTypeCombo.setEnabled(false);
- fVMName.setText(fEditedVM.getName());
- fJRERoot.setText(fEditedVM.getInstallLocation().getAbsolutePath());
-// fLibraryBlock.initializeFrom(fEditedVM, fSelectedVMType);
- if (fEditedVM instanceof IVMInstall2) {
- IVMInstall2 vm2 = (IVMInstall2) fEditedVM;
- String vmArgs = vm2.getVMArgs();
- if (vmArgs != null) {
- fVMArgs.setText(vmArgs);
- }
- } else {
- String[] vmArgs = fEditedVM.getVMArguments();
- if (vmArgs != null) {
- StringBuffer buffer = new StringBuffer();
- int length= vmArgs.length;
- if (length > 0) {
- buffer.append(vmArgs[0]);
- for (int i = 1; i < length; i++) {
- buffer.append(' ').append(vmArgs[i]);
- }
- }
- fVMArgs.setText(buffer.toString());
- }
- }
- }
- setVMNameStatus(validateVMName());
- updateStatusLine();
- }
-
- private void setVMNameStatus(IStatus status) {
- fStati[0]= status;
- }
-
- protected void createFieldListeners() {
- fVMTypeCombo.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- updateVMType();
- }
- });
-
- fVMName.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- setVMNameStatus(validateVMName());
- updateStatusLine();
- }
- });
-
- fJRERoot.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- setJRELocationStatus(validateInterpreterLocationText());
- updateStatusLine();
- }
- });
- }
-
- private IStatus validateVMName() {
- StatusInfo status= new StatusInfo();
- String name= fVMName.getText();
- if (name == null || name.trim().length() == 0) {
- status.setInfo(RubyVMMessages.addVMDialog_enterName);
- } else {
- if (fRequestor.isDuplicateName(name) && (fEditedVM == null || !name.equals(fEditedVM.getName()))) {
- status.setError(RubyVMMessages.addVMDialog_duplicateName);
- } else {
- IStatus s = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
- if (!s.isOK()) {
- status.setError(MessageFormat.format(RubyVMMessages.AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1, new String[]{s.getMessage()}));
- }
- }
- }
- return status;
- }
-
- protected void createDialogFields() {
- fVMTypeCombo= new ComboDialogField(SWT.READ_ONLY);
- fVMTypeCombo.setLabelText(RubyVMMessages.addVMDialog_jreType);
- fVMTypeCombo.setItems(getVMTypeNames());
-
- fVMName= new StringDialogField();
- fVMName.setLabelText(RubyVMMessages.addVMDialog_jreName);
-
- fJRERoot= new StringButtonDialogField(new IStringButtonAdapter() {
- public void changeControlPressed(DialogField field) {
- browseForInstallLocation();
- }
- });
- fJRERoot.setLabelText(RubyVMMessages.addVMDialog_jreHome);
- fJRERoot.setButtonLabel(RubyVMMessages.addVMDialog_browse1);
-
- fVMArgs= new StringDialogField();
- fVMArgs.setLabelText(RubyVMMessages.AddVMDialog_23);
- }
-
- private String[] getVMTypeNames() {
- String[] names= new String[fVMTypes.length];
- for (int i= 0; i < fVMTypes.length; i++) {
- names[i]= fVMTypes[i].getName();
- }
- return names;
- }
-
- protected void setFieldValuesToVM(IVMInstall vm) {
- File dir = new File(fJRERoot.getText());
- try {
- vm.setInstallLocation(dir.getCanonicalFile());
- } catch (IOException e) {
- vm.setInstallLocation(dir.getAbsoluteFile());
- }
- vm.setName(fVMName.getText());
-
- String argString = fVMArgs.getText().trim();
- if (vm instanceof IVMInstall2) {
- IVMInstall2 vm2 = (IVMInstall2) vm;
- if (argString != null && argString.length() >0) {
- vm2.setVMArgs(argString);
- } else {
- vm2.setVMArgs(null);
- }
- } else {
- if (argString != null && argString.length() >0) {
- vm.setVMArguments(DebugPlugin.parseArguments(argString));
- } else {
- vm.setVMArguments(null);
- }
- }
-
-
-// fLibraryBlock.performApply(vm);
- }
-
-}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -14,6 +14,7 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -23,14 +24,16 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiMessages;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.IAddVMDialogRequestor;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.RubyVMMessages;
+import org.rubypeople.rdt.internal.debug.ui.rubyvms.RubyVMsUpdater;
import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
+import org.rubypeople.rdt.launching.VMStandin;
public class RubyInterpreterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IAddVMDialogRequestor {
@@ -54,10 +57,11 @@
Composite composite = createPageRoot(parent);
Table table = createInstalledInterpretersTable(composite);
createInstalledInterpretersTableViewer(table);
- createButtonGroup(composite);
+ createButtonGroup(composite);
- fVMList.setInput(RubyRuntime.getDefault().getInstalledInterpreters());
- IVMInstall selectedInterpreter = RubyRuntime.getDefault().getSelectedInterpreter();
+ fillWithWorkspaceRubyVMs();
+
+ IVMInstall selectedInterpreter = RubyRuntime.getDefaultVMInstall();
if (selectedInterpreter != null)
fVMList.setChecked(selectedInterpreter, true);
@@ -65,7 +69,36 @@
return composite;
}
+
+ private void fillWithWorkspaceRubyVMs() {
+// fill with Ruby VMs
+ List standins = new ArrayList();
+ IVMInstallType[] types = RubyRuntime.getVMInstallTypes();
+ for (int i = 0; i < types.length; i++) {
+ IVMInstallType type = types[i];
+ IVMInstall[] installs = type.getVMInstalls();
+ for (int j = 0; j < installs.length; j++) {
+ IVMInstall install = installs[j];
+ standins.add(new VMStandin(install));
+ }
+ }
+ setJREs((IVMInstall[])standins.toArray(new IVMInstall[standins.size()]));
+ }
+ /**
+ * Sets the JREs to be displayed in this block
+ *
+ * @param vms JREs to be displayed
+ */
+ protected void setJREs(IVMInstall[] vms) {
+ fVMs.clear();
+ for (int i = 0; i < vms.length; i++) {
+ fVMs.add(vms[i]);
+ }
+ fVMList.setInput(fVMs);
+ fVMList.refresh();
+ }
+
protected void createButtonGroup(Composite composite) {
Composite buttons = new Composite(composite, SWT.NULL);
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
@@ -155,7 +188,7 @@
}
protected void addInterpreter() {
- EditInterpreterDialog dialog = new EditInterpreterDialog(this, getShell(), RubyRuntime.getVMInstallTypes(), null);
+ AddVMDialog dialog = new AddVMDialog(this, getShell(), RubyRuntime.getVMInstallTypes(), null);
dialog.setTitle(RubyVMMessages.InstalledJREsBlock_7);
if (dialog.open() != Window.OK) {
return;
@@ -195,7 +228,7 @@
// VMDetailsDialog dialog= new VMDetailsDialog(getShell(), vm);
// dialog.open();
// } else {
- EditInterpreterDialog dialog= new EditInterpreterDialog(this, getShell(), RubyRuntime.getVMInstallTypes(), vm);
+ AddVMDialog dialog= new AddVMDialog(this, getShell(), RubyRuntime.getVMInstallTypes(), vm);
dialog.setTitle(RubyVMMessages.InstalledJREsBlock_8);
if (dialog.open() != Window.OK) {
return;
@@ -209,19 +242,47 @@
return (IVMInstall) selection.getFirstElement();
}
- public boolean performOk() {
- TableItem[] tableItems = fVMList.getTable().getItems();
- List installedInterpreters = new ArrayList(tableItems.length);
- for (int i = 0; i < tableItems.length; i++)
- installedInterpreters.add(tableItems[i].getData());
- RubyRuntime.getDefault().setInstalledInterpreters(installedInterpreters);
-
- Object[] checkedElements = fVMList.getCheckedElements();
- if (checkedElements.length > 0)
- RubyRuntime.getDefault().setSelectedInterpreter((IVMInstall) checkedElements[0]);
-
- return super.performOk();
+ public boolean performOk() {
+ final boolean[] canceled = new boolean[] {false};
+ BusyIndicator.showWhile(null, new Runnable() {
+ public void run() {
+ IVMInstall defaultVM = getCheckedRubyVM();
+ IVMInstall[] vms = getRubyVMs();
+ RubyVMsUpdater updater = new RubyVMsUpdater();
+ if (!updater.updateJRESettings(vms, defaultVM)) {
+ canceled[0] = true;
+ }
+ }
+ });
+
+ if(canceled[0]) {
+ return false;
+ }
+
+ return super.performOk();
}
+
+ /**
+ * Returns the checked RubyVM or <code>null</code> if none.
+ *
+ * @return the checked RubyVM or <code>null</code> if none
+ */
+ public IVMInstall getCheckedRubyVM() {
+ Object[] objects = fVMList.getCheckedElements();
+ if (objects.length == 0) {
+ return null;
+ }
+ return (IVMInstall)objects[0];
+ }
+
+ /**
+ * Returns the RubyVMs currently being displayed in this block
+ *
+ * @return RubyVMs currently being displayed in this block
+ */
+ public IVMInstall[] getRubyVMs() {
+ return (IVMInstall[])fVMs.toArray(new IVMInstall[fVMs.size()]);
+ }
public boolean isDuplicateName(String name) {
for (int i= 0; i < fVMs.size(); i++) {
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -7,7 +7,6 @@
public static String addVMDialog_enterLocation;
public static String addVMDialog_locationNotExists;
-
public static String AddVMDialog_JRE_system_libraries__1;
public static String addVMDialog_jreType;
public static String addVMDialog_jreName;
@@ -19,6 +18,8 @@
public static String AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1;
public static String InstalledJREsBlock_7;
public static String InstalledJREsBlock_8;
+ public static String JREsUpdater_0;
+ public static String addVMDialog_pickJRERootDialog_message;
static {
// load message values from bundle file
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties 2007-01-18 21:44:46 UTC (rev 1803)
@@ -1,2 +1,19 @@
+addVMDialog_pickJRERootDialog_message=Select the root directory of the Ruby installation:
addVMDialog_enterLocation=Enter the location of the Ruby VM.
-addVMDialog_locationNotExists=The location does not exist.
\ No newline at end of file
+addVMDialog_locationNotExists=The location does not exist.
+
+AddVMDialog_JRE_system_libraries__1=RubyVM system libraries:
+
+AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1=RubyVM name must be a valid file name: {0}
+addVMDialog_browse1=&Browse...
+addVMDialog_duplicateName=The name is already used.
+addVMDialog_enterName=Enter a name for the RubyVM.
+addVMDialog_jreHome=&RubyVM home directory:
+addVMDialog_jreName=RubyVM &name:
+addVMDialog_jreType=RubyVM &type:
+AddVMDialog_23=Default &VM Arguments:
+
+InstalledJREsBlock_7=Add RubyVM
+InstalledJREsBlock_8=Edit RubyVM
+
+JREsUpdater_0=Save VM Definitions
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMsUpdater.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMsUpdater.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMsUpdater.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.rubyvms;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
+import org.rubypeople.rdt.internal.launching.VMDefinitionsContainer;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallType;
+import org.rubypeople.rdt.launching.RubyRuntime;
+
+/**
+ * Processes add/removed/changed VMs.
+ */
+public class RubyVMsUpdater {
+
+ // the VMs defined when this updated is instantiated
+ private VMDefinitionsContainer fOriginalVMs;
+
+ /**
+ * Contstructs a new VM updater to update VM install settings.
+ */
+ public RubyVMsUpdater() {
+ fOriginalVMs = new VMDefinitionsContainer();
+ IVMInstall def = RubyRuntime.getDefaultVMInstall();
+ if (def != null) {
+ fOriginalVMs.setDefaultVMInstallCompositeID(RubyRuntime.getCompositeIdFromVM(def));
+ }
+
+ IVMInstallType[] types = RubyRuntime.getVMInstallTypes();
+ for (int i = 0; i < types.length; i++) {
+ IVMInstall[] vms = types[i].getVMInstalls();
+ for (int j = 0; j < vms.length; j++) {
+ fOriginalVMs.addVM(vms[j]);
+ }
+ }
+ }
+
+ /**
+ * Updates VM settings and returns whether the update was successful.
+ *
+ * @param jres new installed JREs
+ * @param defaultJRE new default VM
+ * @return whether the update was successful
+ */
+ public boolean updateJRESettings(IVMInstall[] jres, IVMInstall defaultJRE) {
+
+ // Create a VM definition container
+ VMDefinitionsContainer vmContainer = new VMDefinitionsContainer();
+
+ // Set the default VM Id on the container
+ String defaultVMId = RubyRuntime.getCompositeIdFromVM(defaultJRE);
+ vmContainer.setDefaultVMInstallCompositeID(defaultVMId);
+
+ // Set the VMs on the container
+ for (int i = 0; i < jres.length; i++) {
+ vmContainer.addVM(jres[i]);
+ }
+
+
+ // Generate XML for the VM defs and save it as the new value of the VM preference
+ saveVMDefinitions(vmContainer);
+
+ return true;
+ }
+
+ private void saveVMDefinitions(final VMDefinitionsContainer container) {
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ monitor.beginTask(RubyVMMessages.JREsUpdater_0, 100);
+ String vmDefXML = container.getAsXML();
+ monitor.worked(40);
+ RubyRuntime.getPreferences().setValue(RubyRuntime.PREF_VM_XML, vmDefXML);
+ monitor.worked(30);
+ RubyRuntime.savePreferences();
+ monitor.worked(30);
+ } catch (IOException ioe) {
+ RdtDebugUiPlugin.log(ioe);
+ } catch (ParserConfigurationException e) {
+ RdtDebugUiPlugin.log(e);
+ } catch (TransformerException e) {
+ RdtDebugUiPlugin.log(e);
+ } finally {
+ monitor.done();
+ }
+
+ }
+ };
+ try {
+ RdtDebugUiPlugin.getDefault().getWorkbench().getProgressService().busyCursorWhile(runnable);
+ } catch (InvocationTargetException e) {
+ RdtDebugUiPlugin.log(e);
+ } catch (InterruptedException e) {
+ RdtDebugUiPlugin.log(e);
+ }
+ }
+}
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -1,7 +1,6 @@
package org.rubypeople.rdt.internal.debug.ui.launcher;
import java.io.File;
-import java.util.Arrays;
import junit.framework.Assert;
@@ -22,14 +21,18 @@
import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
import org.rubypeople.rdt.internal.debug.ui.RubySourceLocator;
-import org.rubypeople.rdt.internal.launching.RubyInterpreter;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
-import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
+import org.rubypeople.rdt.launching.VMStandin;
import org.rubypeople.rdt.ui.IRubyConstants;
public class TC_RubyApplicationShortcut extends ModifyingResourceTest {
+ private static final String VM_ID = "vm_id";
+
+ private static final String VM_TYPE_ID = "org.rubypeople.rdt.launching.StandardVMType";
+
protected ShamRubyApplicationShortcut shortcut;
protected IFile rubyFile, nonRubyFile;
private static String SHAM_LAUNCH_CONFIG_TYPE = "org.rubypeople.rdt.debug.ui.tests.launching.LaunchConfigurationTypeSham";
@@ -46,7 +49,7 @@
wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, pFile.getProject().getName());
wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, pFile.getProjectRelativePath().toString());
wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
- wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getDefault().getSelectedInterpreter().getName());
+ wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getCompositeIdFromVM(RubyRuntime.getDefaultVMInstall()));
wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator");
config = wc.doSave();
} catch (CoreException ce) {
@@ -59,6 +62,8 @@
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
return launchManager.getLaunchConfigurations(launchManager.getLaunchConfigurationType(SHAM_LAUNCH_CONFIG_TYPE));
}
+
+ private IVMInstallType vmType;
protected void setUp() throws Exception {
shortcut = new ShamRubyApplicationShortcut();
@@ -76,9 +81,12 @@
Assert.assertEquals("All configurations deleted.", 0, this.getLaunchConfigurations().length);
ShamApplicationLaunchConfigurationDelegate.resetLaunches();
- IVMInstall interpreterOne = new RubyInterpreter("InterpreterOne", new File("C:/RubyInstallRootOne"));
- RubyRuntime.getDefault().setInstalledInterpreters(Arrays.asList(new IVMInstall[] { interpreterOne}));
-
+
+ vmType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
+ VMStandin standin = new VMStandin(vmType, VM_ID);
+ standin.setInstallLocation(new File("C:/RubyInstallRootOne"));
+ standin.setName("InterpreterOne");
+ standin.convertToRealVM();
super.setUp();
}
@@ -90,7 +98,8 @@
public void testNoInterpreterInstalled() throws Exception {
- RubyRuntime.getDefault().setInstalledInterpreters(Arrays.asList(new IVMInstall[] { }));
+ vmType.disposeVMInstall(VM_ID);
+
ISelection selection = new StructuredSelection(rubyFile);
shortcut.launch(selection, ILaunchManager.RUN_MODE);
@@ -102,7 +111,7 @@
shortcut.launch(selection, ILaunchManager.RUN_MODE);
- assertEquals("A configuration has been created", 1, this.getLaunchConfigurations().length);
+ assertEquals("A configuration has been created", 1, getLaunchConfigurations().length);
assertEquals("A launch took place.", 1, shortcut.launchCount());
assertTrue("The shortcut should not log a message when asked to launch the correct file type.", !shortcut.didLog());
}
@@ -118,8 +127,8 @@
}
public void testLaunchWithSelectionMultipleConfigurationsExist() throws Exception {
- this.createConfiguration(rubyFile);
- this.createConfiguration(rubyFile);
+ createConfiguration(rubyFile);
+ createConfiguration(rubyFile);
ISelection selection = new StructuredSelection(rubyFile);
shortcut.launch(selection, ILaunchManager.RUN_MODE);
Modified: trunk/org.rubypeople.rdt.launching/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-18 21:44:46 UTC (rev 1803)
@@ -21,8 +21,19 @@
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.variables"/>
</requires>
-
+
+ <!-- Extension point definitions -->
+ <extension-point id="vmInstallTypes" name="%vmInstallTypes" schema="schema/vmInstallTypes.exsd"/>
+ <extension-point id="vmInstalls" name="%vmInstalls" schema="schema/vmInstalls.exsd"/>
+
<extension
+ point="org.rubypeople.rdt.launching.vmInstallTypes">
+ <vmInstallType
+ class="org.rubypeople.rdt.internal.launching.StandardVMType"
+ id="org.rubypeople.rdt.launching.StandardVMType">
+ </vmInstallType>
+ </extension>
+ <extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
name="%LaunchConfigurationTypeRubyApplication.name"
Added: trunk/org.rubypeople.rdt.launching/schema/vmInstallTypes.exsd
===================================================================
--- trunk/org.rubypeople.rdt.launching/schema/vmInstallTypes.exsd (rev 0)
+++ trunk/org.rubypeople.rdt.launching/schema/vmInstallTypes.exsd 2007-01-18 21:44:46 UTC (rev 1803)
@@ -0,0 +1,111 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.launching">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.launching" id="vmInstallTypes" name="Ruby VM Install Types"/>
+ </appInfo>
+ <documentation>
+ This extension point represents different kinds of Java runtime environments and development kits.
+Each extension must implement <code>org.eclipse.jdt.launching.IVMInstallType</code>.
+An <code>IVMInstallType</code> is responsible for creating and managing a set of instances of its corresponding <code>IVMInstall</code> class.
+Through creating different <code>IVMInstall</code> objects, an <code>IVMInstallType</code> allows for specific behaviour for various Java VMs.
+A UI for managing <code>IVMInstall</code>s is provided by the Java Debug UI plug-in.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="vmInstallType" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="vmInstallType">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique identifier that can be used to reference this IVMInstallType.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the class that implements this VM install type. The class must implement IVMInstallType.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.rubypeople.rdt.launching.AbstractVMInstallType"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is an example of an IVMInstallType for the J9 VM:
+
+<p>
+<pre>
+ <extension point="org.eclipse.jdt.launching.vmInstallTypes">
+ <vmInstallType
+ class="org.eclipse.jdt.internal.launching.j9.J9VMInstallType"
+ id="org.eclipse.jdt.internal.launching.j9.J9Type">
+ </vmInstallType>
+ </extension>
+</pre>
+</p>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ Abstract implementations of IVMInstall and IVMInstallType are provided. The Java Development Tools Launching Support plug-in defines a VM
+install type for the standard 1.1.* and 1.2/1.3/1.4 level <b>JRE</b>.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2000, 2005 IBM Corporation and others.<br>
+All rights reserved. This program and the accompanying materials are made
+available under the terms of the Eclipse Public License v1.0 which
+accompanies this distribution, and is available at
+<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
Added: trunk/org.rubypeople.rdt.launching/schema/vmInstalls.exsd
===================================================================
--- trunk/org.rubypeople.rdt.launching/schema/vmInstalls.exsd (rev 0)
+++ trunk/org.rubypeople.rdt.launching/schema/vmInstalls.exsd 2007-01-18 21:44:46 UTC (rev 1803)
@@ -0,0 +1,147 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.launching">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.launching" id="vmInstalls" name="Ruby VM Installs"/>
+ </appInfo>
+ <documentation>
+ Allows specific configurations of Ruby runtime environments and development kits to be contributed to the Java development tooling.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="vmInstall" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="vmInstall">
+ <complexType>
+ <sequence>
+ <element ref="library" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ Unique identifier for this VM install
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="vmInstallType" type="string" use="required">
+ <annotation>
+ <documentation>
+ References a registered VM install type via the corresponding vmInstallType's id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ Human readable name for this VM install
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="home" type="string" use="required">
+ <annotation>
+ <documentation>
+ Path to the home installation directory for this VM install. Paths must be absolute and may use string substitution variables such as ${eclipse_home}.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="vmArgs" type="string">
+ <annotation>
+ <documentation>
+ Default VM arguments used when launching this VM install as they should appear on the command line.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="library">
+ <complexType>
+ <attribute name="path" type="string" use="required">
+ <annotation>
+ <documentation>
+ File system path to a system library, relative to the VM install's home directory.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.2
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Following is an example vm install definition.
+<p>
+<pre>
+<extension point="org.eclipse.jdt.launching.vmInstalls">
+ <vmInstall
+ home="${eclipse_home}/jre"
+ id="com.example.vm.id"
+ name="JRE-1.4"
+ vmInstallType="com.example.vm.type"/>
+</extension>
+</pre>
+</p>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ JDT does not provide any specific VM installs.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -99,7 +99,7 @@
selectedInterpreter = configuration.getAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
} catch(CoreException e) {}
- return RubyRuntime.getDefault().getInterpreter(selectedInterpreter);
+ return RubyRuntime.getVMFromCompositeId(selectedInterpreter);
}
protected void addToLoadPath(List<String> loadPath, IProject project) {
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.java 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.java 2007-01-18 21:44:46 UTC (rev 1803)
@@ -23,6 +23,13 @@
public static String AbstractInterpreterInstall_4;
public static String LaunchingPlugin_33;
public static String LaunchingPlugin_34;
+ public static String RubyRuntime_exceptionsOccurred;
+ public static String vmInstallType_duplicateVM;
+ public static String StandardVMType_Standard_VM_3;
+ public static String StandardVMType_Standard_VM_not_supported_on_MacOS__1;
+ public static String StandardVMType_Not_a_JDK_Root__Java_executable_was_not_found_1;
+ public static String StandardVMType_ok_2;
+ public static String StandardVMType_Not_a_JDK_root__System_library_was_not_found__1;
private LaunchingMessages() {}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.properties 2007-01-18 16:35:31 UTC (rev 1802)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingMessages.properties 2007-01-18 21:44:46 UTC (rev 1803)
@@ -11,4 +11,25 @@
RdtLaunchingPlugin_processTerminatedBecauseNoDebuggerConnection=Ruby process terminated because no connection to the debugger could me made
RdtLaunchingPlugin_interpreterNotFound=Please check the location of the following interpreter: {0}
RdtLaunchingPlugin_noInterpreterSelectedTitle=No interpreter selected
-RdtLaunchingPlugin_noInterpreterSelected=There is currently no ruby interpreter defined. Use preferences to define and select the active interpreter.
\ No newline at end of file
+RdtLaunchingPlugin_noInterpreterSelected=There is currently no ruby interpreter defined. Use preferences to define and select the active interpreter.
+
+RubyRuntime_badFormat=Invalid format
+RubyRuntime_VM_type_element_with_unknown_id_1=VM type element with unknown id
+RubyRuntime_VM_element_specified_with_no_id_attribute_2=id attribute missing from VM element specification
+RubyRuntime_exceptionOccurred=Exceptions occurred
+RubyRuntime_exceptionsOccurred=Exceptions occurred while saving VMs
+
+vmInstall_assert_idNotNull=id cannot be null
+vmInstall_assert_typeNotNull=VM type cannot be null
+AbstractInterpreterInstall_0=Unable to retrieve system properties
+AbstractInterpreterInstall_1=Evaluating system properties
+AbstractInterpreterInstall_3=Reading system properties
+AbstractInterpreterInstall_4=Exception retrieving system properties
+LaunchingPlugin_33=Unable to create XML parser.
+LaunchingPlugin_34=Unable to create XML parser.
+vmInstallType_duplicateVM=Duplicate VM: {0}
+StandardVMType_Standard_VM_3=Standard VM
+StandardVMType_Standard_VM_not_supported_on_MacOS__1=Standard VM not supported on MacOS.
+StandardVMType_Not_a_JDK_Root__Java_executable_was_not_found_1=Target is not a Ruby installation root. Ruby executable was not found
+StandardVMType_ok_2=ok
+StandardVMType_Not_a_JDK_root__System_library_was_not_found__1=Target is not a Ruby installation root. System library was not found.
\ No newlin...
[truncated message content] |