|
From: <caw...@us...> - 2007-04-30 14:08:49
|
Revision: 2396
http://svn.sourceforge.net/rubyeclipse/?rev=2396&view=rev
Author: cawilliams
Date: 2007-04-30 07:08:47 -0700 (Mon, 30 Apr 2007)
Log Message:
-----------
detect RI and Rdoc locations from our default VM install location. Now we don't need to force user to input this information, and we can detect whether we nee dto point at the .bat file by checking which platform we're on.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
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
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RdocRiPreferencePage.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-04-30 12:41:26 UTC (rev 2395)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-04-30 14:08:47 UTC (rev 2396)
@@ -28,7 +28,6 @@
PreferencePage.RubyLibrary.name=Library
PreferencePage.rdtTemplatePreferences=Templates
PreferencePage.rdtTaskPreferences=Task Tags
-PreferencePage.rdtRiPreferences=Ri/rdoc
PreferencePage.rdtDebuggerPreferences=Debugger
viewCategoryName=Ruby
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-04-30 12:41:26 UTC (rev 2395)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-04-30 14:08:47 UTC (rev 2396)
@@ -47,14 +47,8 @@
category="org.rubypeople.rdt.ui.preferences.PreferencePageRubyEditor"
class="org.rubypeople.rdt.internal.ui.preferences.RubyTemplatePreferencePage"
id="org.rubypeople.rdt.ui.TemplatesPreferencePage">
- </page>
+ </page>
<page
- name="%PreferencePage.rdtRiPreferences"
- category="org.rubypeople.rdt.ui.preferences.PreferencePageRubyBase"
- class="org.rubypeople.rdt.internal.ui.preferences.RdocRiPreferencePage"
- id="org.rubypeople.rdt.ui.RdocRiPreferencePage">
- </page>
- <page
name="%memberSortPrefName"
category="org.rubypeople.rdt.ui.preferences.AppearancePreferencePage"
class="org.rubypeople.rdt.internal.ui.preferences.MembersOrderPreferencePage"
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-04-30 12:41:26 UTC (rev 2395)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-04-30 14:08:47 UTC (rev 2396)
@@ -8,16 +8,13 @@
import java.util.Collection;
import java.util.List;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
@@ -45,9 +42,12 @@
import org.rubypeople.rdt.internal.ui.RubyPluginImages;
import org.rubypeople.rdt.internal.ui.rdocexport.RDocUtility;
import org.rubypeople.rdt.internal.ui.rdocexport.RdocListener;
-import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallChangedListener;
+import org.rubypeople.rdt.launching.PropertyChangeEvent;
+import org.rubypeople.rdt.launching.RubyRuntime;
-public class RIView extends ViewPart implements RdocListener {
+public class RIView extends ViewPart implements RdocListener, IVMInstallChangedListener {
private boolean riFound = false;
private PageBook pageBook;
@@ -63,7 +63,9 @@
/**
* The constructor.
*/
- public RIView() {}
+ public RIView() {
+ RubyRuntime.addVMInstallChangedListener(this);
+ }
/**
* This is a callback that will allow us to create the viewer and initialize
@@ -129,16 +131,8 @@
// search result
searchResult = new Browser(form, SWT.BORDER);
- form.setWeights(new int[]{1, 3});
+ form.setWeights(new int[]{1, 3});
- RubyPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.RI_PATH)) {
- updatePage();
- }
- }
- });
-
pageBook.showPage(inProgressLabel);
updatePage();
RDocUtility.addRdocListener(this);
@@ -177,6 +171,7 @@
public void dispose() {
RDocUtility.removeRdocListener(this);
+ RubyRuntime.removeVMInstallChangedListener(this);
super.dispose();
}
@@ -244,16 +239,13 @@
protected abstract void handleOutput(Process process);
protected void beforeInvoke(){}
- public final void invoke() {
-
- IPath riPath = new Path( RubyPlugin.getDefault().getPreferenceStore().getString( PreferenceConstants.RI_PATH ) );
-
+ public final void invoke() {
// check the ri path for existence. It might have been unconfigured
// and set to the default value or the file could have been removed
- File file = new File(riPath.toOSString());
+ File file = RubyRuntime.getRI();
// If we can't find it ourselves then display an error to the user
- if (!file.exists() || !file.isFile()) {
+ if (file == null || !file.exists() || !file.isFile()) {
riFound = false;
pageBook.showPage(riNotFoundLabel);
return;
@@ -261,7 +253,7 @@
try {
List<String> args = getArgList();
- args.add(0, riPath.toString());
+ args.add(0, file.getAbsolutePath());
ProcessBuilder builder = new ProcessBuilder();
builder.command(args);
builder.redirectErrorStream(true);
@@ -389,4 +381,20 @@
riFound = false;
pageBook.showPage( riNotFoundLabel );
}
+
+ public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) {
+ updatePage();
+ }
+
+ public void vmAdded(IVMInstall newVm) {
+ // ignore
+ }
+
+ public void vmChanged(PropertyChangeEvent event) {
+ // ignore
+ }
+
+ public void vmRemoved(IVMInstall removedVm) {
+ // ignore
+ }
}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RdocRiPreferencePage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RdocRiPreferencePage.java 2007-04-30 12:41:26 UTC (rev 2395)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RdocRiPreferencePage.java 2007-04-30 14:08:47 UTC (rev 2396)
@@ -1,53 +0,0 @@
-package org.rubypeople.rdt.internal.ui.preferences;
-
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.FileFieldEditor;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.rubypeople.rdt.internal.ui.RubyPlugin;
-import org.rubypeople.rdt.ui.PreferenceConstants;
-
-/**
- * This class represents a preference page that
- * is contributed to the Preferences dialog. By
- * subclassing <samp>FieldEditorPreferencePage</samp>, we
- * can use the field support built into JFace that allows
- * us to create a page that is small and knows how to
- * save, restore and apply itself.
- * <p>
- * This page is used to modify preferences only. They
- * are stored in the preference store that belongs to
- * the main plug-in class. That way, preferences can
- * be accessed directly via the preference store.
- */
-
-public class RdocRiPreferencePage
- extends FieldEditorPreferencePage
- implements IWorkbenchPreferencePage {
-
- public RdocRiPreferencePage() {
- super(GRID);
- setPreferenceStore(RubyPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.RiPreferencePage_description_label);
- }
-
- /**
- * Creates the field editors. Field editors are abstractions of
- * the common GUI blocks needed to manipulate various types
- * of preferences. Each field editor knows how to save and
- * restore itself.
- */
- public void createFieldEditors() {
- addField( new FileFieldEditor( PreferenceConstants.RDOC_PATH,
- PreferencesMessages.RiPreferencePage_rdocpath_label, getFieldEditorParent() ) );
-
- addField( new FileFieldEditor( PreferenceConstants.RI_PATH,
- PreferencesMessages.RiPreferencePage_ripath_label, getFieldEditorParent() ) );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {}
-
-}
\ No newline at end of file
Modified: 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/rdocexport/RDocUtility.java 2007-04-30 12:41:26 UTC (rev 2395)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java 2007-04-30 14:08:47 UTC (rev 2396)
@@ -12,14 +12,12 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyUIMessages;
import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
-import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.launching.RubyRuntime;
/**
* A utility class which will generate RDoc for a resource. If teh resource is
@@ -82,21 +80,18 @@
public final void invoke() {
log("Generating RDoc for " + resource.getName());
- IPath rdocPath = new Path(RubyPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.RDOC_PATH));
-
+ File file = RubyRuntime.getRDoc();
// check the rdoc path for existence. It might have been
// unconfigured
// and set to the default value or the file could have been removed
- File file = new File(rdocPath.toOSString());
-
// If we can't find it ourselves then display an error to the user
- if (!file.exists() || !file.isFile()) {
+ if (file == null || !file.exists() || !file.isFile()) {
MessageDialog.openError(RubyPlugin.getActiveWorkbenchShell(), RubyUIMessages.RDocPathErrorTitle, RubyUIMessages.RDocPathError);
return;
}
List<String> args = new ArrayList<String>();
- args.add(rdocPath.toString());
+ args.add(file.getAbsolutePath());
args.add("-r");
args.add(resource.getLocation().toOSString());
String[] argArray= (String[]) args.toArray(new String[args.size()]);
Modified: 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/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-04-30 12:41:26 UTC (rev 2395)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-04-30 14:08:47 UTC (rev 2396)
@@ -7,25 +7,23 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.ui.IEditorInput;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
-import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.RubyRuntime;
import org.rubypeople.rdt.ui.extensions.ITextHoverProvider;
public class RiDocHoverProvider implements ITextHoverProvider {
public String getHoverInfo(IEditorInput input, ITextViewer textViewer, IRegion hoverRegion){
- IPath riPath = new Path( RubyPlugin.getDefault().getPreferenceStore().getString( PreferenceConstants.RI_PATH ) );
- File ri = riPath.toFile();
- if (!ri.exists() || !ri.isFile()) return null;
+ File ri = RubyRuntime.getRI();
+ if (ri == null || !ri.exists() || !ri.isFile()) return null;
List<String> args = new ArrayList<String>();
- args.add(0, riPath.toString());
+ args.add(0, ri.getAbsolutePath());
// these will get rid of some of the overhead formatting
args.add("-f");
args.add("simple");
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-04-30 12:41:26 UTC (rev 2395)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-04-30 14:08:47 UTC (rev 2396)
@@ -30,14 +30,9 @@
private static String fgDefaultEncoding= System.getProperty("file.encoding"); //$NON-NLS-1$
- public static final String RI_PATH = "riDirectoryPath";
- public static final String RDOC_PATH = "rdocDirectoryPath";
public static final String DEBUGGER_USE_RUBY_DEBUG = "useRubyDebug";
public static final String TEMPLATES_USE_CODEFORMATTER = "templatesUseCodeFormatter"; //$NON-NLS-1$
-
- private final static String DEFAULT_RDOC_CMD = ""; //$NON-NLS-1$
- private final static String DEFAULT_RI_CMD = ""; //$NON-NLS-1$
private static final String LOADPATH_RUBYVMLIBRARY_INDEX= PreferenceConstants.NEWPROJECT_JRELIBRARY_INDEX;
private static final String LOADPATH_RUBYVMLIBRARY_LIST= PreferenceConstants.NEWPROJECT_JRELIBRARY_LIST;
@@ -782,9 +777,6 @@
store.setDefault(PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
- store.setDefault(PreferenceConstants.RDOC_PATH, PreferenceConstants.getDefaultPath(PreferenceConstants.DEFAULT_RDOC_CMD));
- store.setDefault(PreferenceConstants.RI_PATH, PreferenceConstants.getDefaultPath(PreferenceConstants.DEFAULT_RI_CMD));
-
store.setDefault(PreferenceConstants.DEBUGGER_USE_RUBY_DEBUG, false);
store.setDefault(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|