|
From: <caw...@us...> - 2007-09-11 16:11:57
|
Revision: 3137
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3137&view=rev
Author: cawilliams
Date: 2007-09-11 09:11:51 -0700 (Tue, 11 Sep 2007)
Log Message:
-----------
show breakpoint marker annotations on external files
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalFileRubyAnnotationModel.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalFileRubyAnnotationModel.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalFileRubyAnnotationModel.java 2007-09-11 15:42:26 UTC (rev 3136)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalFileRubyAnnotationModel.java 2007-09-11 16:11:51 UTC (rev 3137)
@@ -1,29 +1,74 @@
package org.rubypeople.rdt.internal.ui.rubyeditor;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.core.ExternalRubyScript;
public class ExternalFileRubyAnnotationModel extends AbstractMarkerAnnotationModel {
- protected void deleteMarkers(IMarker[] markers) throws CoreException {
- // TODO Auto-generated method stub
+ private IWorkspace fWorkspace;
+ private IRubyScript fScript;
+ public ExternalFileRubyAnnotationModel(IRubyScript script) {
+ fScript = script;
+ fWorkspace= ResourcesPlugin.getWorkspace();
}
+
+ protected void deleteMarkers(final IMarker[] markers) throws CoreException {
+ fWorkspace.run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ for (int i= 0; i < markers.length; ++i) {
+ markers[i].delete();
+ }
+ }
+ }, null, IWorkspace.AVOID_UPDATE, null);
+ }
protected boolean isAcceptable(IMarker marker) {
- // TODO Auto-generated method stub
- return false;
+ return marker != null && marker.getResource().equals(getResource()) && getFileName(marker).equals(getFileName());
}
+ private String getFileName(IMarker marker) {
+ return marker.getAttribute("externalFileName", ""); // FIXME This is duplicated in RubyLineBreakpoint. Move this to an interface as a constant!
+ }
+
protected void listenToMarkerChanges(boolean listen) {
// TODO Auto-generated method stub
}
protected IMarker[] retrieveMarkers() throws CoreException {
- // TODO Auto-generated method stub
- return null;
+ IMarker[] markers = getResource().findMarkers(IMarker.MARKER, true, IResource.DEPTH_INFINITE);
+ List<IMarker> filtered = new ArrayList<IMarker>();
+ for (int i = 0; i < markers.length; i++) {
+ if (getFileName(markers[i]).equals(getFileName())) {
+ filtered.add(markers[i]);
+ }
+ }
+ return filtered.toArray(new IMarker[filtered.size()]);
}
+ private String getFileName() {
+ if (fScript == null) return null;
+ if (fScript instanceof ExternalRubyScript) {
+ ExternalRubyScript script = (ExternalRubyScript) fScript;
+ return script.getFile().getAbsolutePath();
+ }
+ return fScript.getPath().toPortableString();
+ }
+
+ private IResource getResource() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java 2007-09-11 15:42:26 UTC (rev 3136)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java 2007-09-11 16:11:51 UTC (rev 3137)
@@ -54,7 +54,7 @@
}
protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
- return new ExternalFileRubyAnnotationModel();
+ return new ExternalFileRubyAnnotationModel(null);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java 2007-09-11 15:42:26 UTC (rev 3136)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java 2007-09-11 16:11:51 UTC (rev 3137)
@@ -183,26 +183,14 @@
/**
* Creates an annotation model derived from the given class file editor input.
*
- * @param classFileEditorInput the editor input from which to query the annotations
+ * @param rubyScriptEditorInput the editor input from which to query the annotations
* @return the created annotation model
* @exception CoreException if the editor input could not be accessed
*/
- protected IAnnotationModel createRubyScriptAnnotationModel(IRubyScriptEditorInput classFileEditorInput) throws CoreException {
-// IResource resource= null;
-// IRubyScript classFile= classFileEditorInput.getRubyScript();
-//
-// IResourceLocator locator= (IResourceLocator) classFile.getAdapter(IResourceLocator.class);
-// if (locator != null)
-// resource= locator.getContainingResource(classFile);
-//
-// if (resource != null) {
-// RubyScriptMarkerAnnotationModel model= new RubyScriptMarkerAnnotationModel(resource);
-// model.setRubyScript(classFile);
-// return model;
-// }
-//
-// return null;
- return new ExternalFileRubyAnnotationModel();
+ protected IAnnotationModel createRubyScriptAnnotationModel(IRubyScriptEditorInput rubyScriptEditorInput) throws CoreException {
+ IRubyScript script = rubyScriptEditorInput.getRubyScript();
+ ExternalFileRubyAnnotationModel model = new ExternalFileRubyAnnotationModel(script);
+ return model;
}
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|