|
From: <caw...@us...> - 2007-01-18 14:36:57
|
Revision: 1790
http://svn.sourceforge.net/rubyeclipse/?rev=1790&view=rev
Author: cawilliams
Date: 2007-01-18 06:36:55 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/LoadPathEntryLabelProvider.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
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 14:26:54 UTC (rev 1789)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/LoadPathEntryLabelProvider.java 2007-01-18 14:36:55 UTC (rev 1790)
@@ -60,7 +60,7 @@
}
/**
- * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
+ * @see IBaseLabelProvider#removeInterpreterInstallChangedListener(ILabelProviderListener)
*/
public void removeListener(ILabelProviderListener listener) {
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-01-18 14:26:54 UTC (rev 1789)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-01-18 14:36:55 UTC (rev 1790)
@@ -35,6 +35,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.VariablesPlugin;
import org.rubypeople.rdt.internal.launching.CompositeId;
+import org.rubypeople.rdt.internal.launching.ListenerList;
import org.rubypeople.rdt.internal.launching.RdtLaunchingMessages;
import org.rubypeople.rdt.internal.launching.RdtLaunchingPlugin;
import org.rubypeople.rdt.internal.launching.RubyInterpreter;
@@ -104,12 +105,8 @@
protected List<IInterpreter> installedInterpreters;
protected IInterpreter selectedInterpreter;
- private List<Listener> listeners = new ArrayList<Listener>();
+ private static ListenerList fgVMListeners = new ListenerList(5);
- public static interface Listener {
- void selectedInterpreterChanged();
- }
-
protected RubyRuntime() {
super();
}
@@ -120,14 +117,10 @@
}
return runtime;
}
-
- public void addListener(Listener listener) {
- listeners.add(listener);
+
+ public static void removeInterpreterInstallChangedListener(IInterpreterInstallChangedListener listener) {
+ fgVMListeners.remove(listener);
}
-
- public void removeListener(Listener listener) {
- listeners.remove(listener);
- }
public IInterpreter getSelectedInterpreter() {
if (selectedInterpreter == null) {
@@ -142,19 +135,20 @@
IInterpreter each = (IInterpreter) interpreters.next();
if (each.getName().equals(name))
return each;
- }
-
+ }
return getSelectedInterpreter();
}
public void setSelectedInterpreter(IInterpreter anInterpreter) {
if (selectedInterpreter == anInterpreter) return;
- selectedInterpreter = anInterpreter;
- saveRuntimeConfiguration();
- for (Iterator<Listener> iter = listeners.iterator(); iter.hasNext();) {
- Listener listener = iter.next();
- listener.selectedInterpreterChanged();
- }
+ IInterpreter oldInterpreter = selectedInterpreter;
+ selectedInterpreter = anInterpreter;
+ saveRuntimeConfiguration();
+ Object[] listeners = fgVMListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ IInterpreterInstallChangedListener listener = (IInterpreterInstallChangedListener)listeners[i];
+ listener.defaultInterpreterInstallChanged(oldInterpreter, anInterpreter);
+ }
}
public void addInstalledInterpreter(IInterpreter anInterpreter) {
@@ -198,31 +192,16 @@
try {
XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
reader.setContentHandler(getRuntimeConfigurationContentHandler());
- Reader fileReader = this.getRuntimeConfigurationReader() ;
+ Reader fileReader = this.getRuntimeConfigurationReader();
if (fileReader == null) {
- // FIXME If we get a better algorithm for auto detection we should use it, but apparently this didn't make people happy
-// autoDetectRubyInterpreter();
return ;
}
- reader.parse(new InputSource(fileReader)) ;
+ reader.parse(new InputSource(fileReader));
} catch(Exception e) {
RdtLaunchingPlugin.log(e);
}
}
- private void autoDetectRubyInterpreter() {
- File path = null;
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- path = new File("/ruby/bin/ruby.exe");
- } else {
- //FIXME Why not use `which ruby` or something?
- path = new File("/usr/local/bin/ruby");
- }
- IInterpreter interpreter = new RubyInterpreter("Default Ruby Interpreter", path);
- installedInterpreters.add(interpreter);
- selectedInterpreter = interpreter;
- }
-
protected Reader getRuntimeConfigurationReader() {
try {
return new FileReader(getRuntimeConfigurationFile());
@@ -296,9 +275,9 @@
}
public static void addInterpreterInstallChangedListener(IInterpreterInstallChangedListener listener) {
- // TODO Implement and add to listeners, and replace the addListener(Listener) stuff
-
+ fgVMListeners.add(listener);
}
+
/**
* Returns the VM install type with the given unique id.
* @param id the VM install type unique id
Modified: 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/infoviews/RIView.java 2007-01-18 14:26:54 UTC (rev 1789)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-01-18 14:36:55 UTC (rev 1790)
@@ -45,6 +45,8 @@
import org.rubypeople.rdt.internal.ui.rdocexport.RDocUtility;
import org.rubypeople.rdt.internal.ui.rdocexport.RdocListener;
import org.rubypeople.rdt.launching.IInterpreter;
+import org.rubypeople.rdt.launching.IInterpreterInstallChangedListener;
+import org.rubypeople.rdt.launching.PropertyChangeEvent;
import org.rubypeople.rdt.launching.RubyRuntime;
import org.rubypeople.rdt.ui.PreferenceConstants;
@@ -60,7 +62,7 @@
private List possibleMatches = new ArrayList();
private SearchValue itemToSearch = new SearchValue();
private DescriptionUpdater descriptionUpdater = new DescriptionUpdater();
- private RubyRuntime.Listener runtimeListener;
+ private IInterpreterInstallChangedListener runtimeListener;
private ListContentProvider contentProvider = new ListContentProvider();
/**
@@ -135,12 +137,22 @@
form.setWeights(new int[]{1, 3});
- runtimeListener = new RubyRuntime.Listener() {
- public void selectedInterpreterChanged() {
- updatePage();
+ runtimeListener = new IInterpreterInstallChangedListener() {
+ public void defaultInterpreterInstallChanged(IInterpreter previous,
+ IInterpreter current) {
+ updatePage();
}
+
+ public void interpreterAdded(IInterpreter newVm) {
+ }
+
+ public void interpreterChanged(PropertyChangeEvent event) {
+ }
+
+ public void interpreterRemoved(IInterpreter removedVm) {
+ }
};
- RubyRuntime.getDefault().addListener(runtimeListener);
+ RubyRuntime.addInterpreterInstallChangedListener(runtimeListener);
RubyPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
@@ -190,7 +202,7 @@
public void dispose() {
descriptionUpdater.requestStop();
- RubyRuntime.getDefault().removeListener(runtimeListener);
+ RubyRuntime.removeInterpreterInstallChangedListener(runtimeListener);
super.dispose();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|