|
From: <caw...@us...> - 2007-01-25 15:40:46
|
Revision: 1881
http://svn.sourceforge.net/rubyeclipse/?rev=1881&view=rev
Author: cawilliams
Date: 2007-01-25 07:40:44 -0800 (Thu, 25 Jan 2007)
Log Message:
-----------
fix how we deal with source folder roots inside our wizards (now that we have external ones)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewElementWizardPage.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-25 14:22:26 UTC (rev 1880)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-25 15:40:44 UTC (rev 1881)
@@ -98,6 +98,17 @@
* @see RubyCore#getDefaultOptions()
*/
Map getOptions(boolean inheritRubyCoreOptions);
+
+ /**
+ * Returns all of the existing source folder roots that exist
+ * on the loadpath, in the order they are defined by the loadpath.
+ *
+ * @return all of the existing source folder roots that exist
+ * on the loadpath
+ * @exception RubyModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+ ISourceFolderRoot[] getAllSourceFolderRoots() throws RubyModelException;
public abstract Object[] getNonRubyResources() throws RubyModelException;
@@ -131,4 +142,6 @@
throws RubyModelException;
public abstract ISourceFolderRoot getSourceFolderRoot(String rootPath);
+
+ public abstract ISourceFolderRoot findSourceFolderRoot(IPath path) throws RubyModelException;
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-25 14:22:26 UTC (rev 1880)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-25 15:40:44 UTC (rev 1881)
@@ -2316,4 +2316,36 @@
public ILoadpathEntry[] decodeLoadpath(String xmlClasspath, boolean createMarker, boolean logProblems) {
return decodeLoadpath(xmlClasspath, createMarker, logProblems, null/*not interested in unknown elements*/);
}
+
+ public ISourceFolderRoot findSourceFolderRoot(IPath path) throws RubyModelException {
+ return findSourceFolderRoot0(RubyProject.canonicalizedPath(path));
+ }
+
+ /*
+ * no path canonicalization
+ */
+ public ISourceFolderRoot findSourceFolderRoot0(IPath path)
+ throws RubyModelException {
+
+ ISourceFolderRoot[] allRoots = this.getAllSourceFolderRoots();
+ if (!path.isAbsolute()) {
+ throw new IllegalArgumentException(Messages.path_mustBeAbsolute);
+ }
+ for (int i= 0; i < allRoots.length; i++) {
+ ISourceFolderRoot classpathRoot= allRoots[i];
+ if (classpathRoot.getPath().equals(path)) {
+ return classpathRoot;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see IRubyProject
+ */
+ public ISourceFolderRoot[] getAllSourceFolderRoots()
+ throws RubyModelException {
+
+ return getAllSourceFolderRoots(null /*no reverse map*/);
+ }
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java 2007-01-25 14:22:26 UTC (rev 1880)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java 2007-01-25 15:40:44 UTC (rev 1881)
@@ -14,6 +14,7 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Composite;
@@ -252,8 +253,8 @@
status.setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_ProjectClosed, proj.getFullPath().toString()));
return status;
}
- IRubyProject jproject= RubyCore.create(proj);
- fCurrRoot= jproject.getSourceFolderRoot(res);
+ IRubyProject rproject= RubyCore.create(proj);
+ fCurrRoot= rproject.getSourceFolderRoot(res);
if (res.exists()) {
try {
if (!proj.hasNature(RubyCore.NATURE_ID)) {
@@ -264,7 +265,7 @@
}
return status;
}
- if (!jproject.isOnLoadpath(fCurrRoot)) {
+ if (!rproject.isOnLoadpath(fCurrRoot)) {
status.setWarning(Messages.format(NewWizardMessages.NewContainerWizardPage_warning_NotOnLoadPath, str));
}
} catch (CoreException e) {
@@ -308,21 +309,21 @@
if (elem != null) {
initRoot= RubyModelUtil.getSourceFolderRoot(elem);
try {
- if (initRoot == null) {
- IRubyProject jproject= elem.getRubyProject();
- if (jproject != null) {
+ if (initRoot == null || initRoot.isExternal()) {
+ IRubyProject rproject= elem.getRubyProject();
+ if (rproject != null) {
initRoot= null;
- if (jproject.exists()) {
- ISourceFolderRoot[] roots= jproject.getSourceFolderRoots();
+ if (rproject.exists()) {
+ ISourceFolderRoot[] roots= rproject.getSourceFolderRoots();
for (int i= 0; i < roots.length; i++) {
-
+ if (!roots[i].isExternal()) {
initRoot= roots[i];
break;
-
+ }
}
}
if (initRoot == null) {
- initRoot= jproject.getSourceFolderRoot(jproject.getResource());
+ initRoot= rproject.getSourceFolderRoot(rproject.getResource());
}
}
}
@@ -385,10 +386,33 @@
protected ISourceFolderRoot chooseContainer() {
IRubyElement initElement= getSourceFolderRoot();
Class[] acceptedClasses= new Class[] { IRubyProject.class, ISourceFolderRoot.class };
- TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
+ TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false) {
+ public boolean isSelectedValid(Object element) {
+ try {
+ if (element instanceof IRubyProject) {
+ IRubyProject jproject= (IRubyProject)element;
+ IPath path= jproject.getProject().getFullPath();
+ return (jproject.findSourceFolderRoot(path) != null);
+ } else if (element instanceof ISourceFolderRoot) {
+ return (!((ISourceFolderRoot)element).isExternal());
+ }
+ return true;
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e.getStatus()); // just log, no UI in validation
+ }
+ return false;
+ }
+ };
- acceptedClasses= new Class[] { IRubyModel.class, IRubyProject.class, ISourceFolderRoot.class };
- ViewerFilter filter= new TypedViewerFilter(acceptedClasses);
+ acceptedClasses= new Class[] { IRubyModel.class, ISourceFolderRoot.class, IRubyProject.class };
+ ViewerFilter filter= new TypedViewerFilter(acceptedClasses) {
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ if (element instanceof ISourceFolderRoot) {
+ return (!((ISourceFolderRoot)element).isExternal());
+ }
+ return super.select(viewer, parent, element);
+ }
+ };
StandardRubyElementContentProvider provider= new StandardRubyElementContentProvider();
ILabelProvider labelProvider= new RubyElementLabelProvider(RubyElementLabelProvider.SHOW_DEFAULT);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewElementWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewElementWizardPage.java 2007-01-25 14:22:26 UTC (rev 1880)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewElementWizardPage.java 2007-01-25 15:40:44 UTC (rev 1881)
@@ -25,7 +25,7 @@
* Clients may subclass.
* </p>
*
- * @since 2.0
+ * @since 0.9.0
*/
public abstract class NewElementWizardPage extends WizardPage {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|