Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-11-24 14:33:51 -0500
committerJean Michel-Lemieux2003-11-24 14:33:51 -0500
commit951b2573db62ddd77215f800cb37b154075ef772 (patch)
tree5775c561c70b873ed8ef134f52c8b7ab35de16e7
parent1d4c1fef9e9ffba1a98350961bbe0ec7c30179db (diff)
downloadeclipse.platform.team-951b2573db62ddd77215f800cb37b154075ef772.tar.gz
eclipse.platform.team-951b2573db62ddd77215f800cb37b154075ef772.tar.xz
eclipse.platform.team-951b2573db62ddd77215f800cb37b154075ef772.zip
Bug 47287 ClassCastException using CVS annotate
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java27
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java34
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/html/00024.html41
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/toc.xml2
4 files changed, 85 insertions, 19 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java
index f1e618318..0f45fbc90 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java
@@ -10,18 +10,13 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.client.listeners;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSAnnotateBlock;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
public class AnnotateListener extends CommandOutputListener {
@@ -34,13 +29,10 @@ public class AnnotateListener extends CommandOutputListener {
int lineNumber;
String error;
- /**
- * @return
- */
public String getError() {
return error;
}
-
+
public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
CVSAnnotateBlock aBlock = new CVSAnnotateBlock(line, lineNumber++);
@@ -89,11 +81,18 @@ public class AnnotateListener extends CommandOutputListener {
}
}
- /**
- * @return
- */
public boolean hasError() {
return (error != null);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#errorLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
+ if(line.startsWith("Skipping binary file")) {
+ error = "Cannot annotate a binary file.";
+ return new CVSStatus(CVSStatus.ERROR, CVSStatus.SERVER_ERROR, commandRoot, error);
+ }
+ return super.errorLine(line, location, commandRoot, monitor);
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java
index 10b284938..61dd02b9b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AnnotateView.java
@@ -17,6 +17,7 @@ import java.util.Collection;
import java.util.Iterator;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
@@ -26,6 +27,8 @@ import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.ui.*;
import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.registry.EditorDescriptor;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -267,9 +270,8 @@ public class AnnotateView extends ViewPart implements ISelectionChangedListener
private IEditorPart openEditor() throws InvocationTargetException {
// Open the editor
IEditorPart part;
-
- IEditorRegistry registry = CVSUIPlugin.getPlugin().getWorkbench().getEditorRegistry();
- ICVSRemoteFile file;
+ ICVSRemoteFile file;
+ IEditorRegistry registry;
try {
file = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(cvsResource);
@@ -277,12 +279,34 @@ public class AnnotateView extends ViewPart implements ISelectionChangedListener
throw new InvocationTargetException(e1);
}
+ registry = CVSUIPlugin.getPlugin().getWorkbench().getEditorRegistry();
IEditorDescriptor descriptor = registry.getDefaultEditor(file.getName());
+
+ // Determine if the registered editor is an ITextEditor.
+ // There is currently no support from UI to determine this information. This
+ // problem has been logged in: https://bugs.eclipse.org/bugs/show_bug.cgi?id=47362
+ // For now, use internal classes.
+ String id;
+
+ if (descriptor == null || !(descriptor instanceof EditorDescriptor) || !(((EditorDescriptor)descriptor).isInternal())) {
+ id = IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID; //$NON-NLS-1$
+ } else {
+ try {
+ Object obj = IDEWorkbenchPlugin.createExtension(((EditorDescriptor) descriptor).getConfigurationElement(), "class"); //$NON-NLS-1$
+ if (obj instanceof ITextEditor) {
+ id = descriptor.getId();
+ } else {
+ id = IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID;
+ }
+ } catch (CoreException e) {
+ id = IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID;
+ }
+ }
// Either reuse an existing editor or open a new editor of the correct type.
try {
try {
- if (editor != null && editor instanceof IReusableEditor && page.isPartVisible(editor) && editor.getSite().getId().equals(descriptor.getId())) {
+ if (editor != null && editor instanceof IReusableEditor && page.isPartVisible(editor) && editor.getSite().getId().equals(id)) {
// We can reuse the editor
((IReusableEditor) editor).setInput(new RemoteAnnotationEditorInput(file, contents));
part = editor;
@@ -292,7 +316,7 @@ public class AnnotateView extends ViewPart implements ISelectionChangedListener
page.closeEditor(editor, false);
editor = null;
}
- part = page.openEditor(new RemoteAnnotationEditorInput(file, contents), descriptor.getId());
+ part = page.openEditor(new RemoteAnnotationEditorInput(file, contents), id);
}
} catch (PartInitException e) {
throw e;
diff --git a/tests/org.eclipse.team.tests.cvs.core/html/00024.html b/tests/org.eclipse.team.tests.cvs.core/html/00024.html
new file mode 100644
index 000000000..2942db38a
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/html/00024.html
@@ -0,0 +1,41 @@
+<html><head><title>Annotate</title>
+<LINK REL=STYLESHEET HREF=../book.css CHARSET=ISO-8859-1 TYPE=text/css>
+<meta NAME="keywords" content="">
+<meta NAME="since" content="">
+</head><h2>Annotate</h2>
+<p>Since: 3.0 M6<br>
+Last Modified: $Date: 2003/11/20 22:20:45 $</p><body>
+
+<h4>Annotate action should be available from</h4>
+<ul>
+<li>history view, repo explorer, resource/packages view
+</ul>
+
+<h4>Annotate java files</h4>
+<ul>
+<li>should show the java editor
+<li>you should be able to step through changes in the annotate view and the java editor should
+stay in sync (e.g. highlight) the changes associated with the selected change in the annotate view.
+<li>you should also be able to select a line in the java file and the annotate view should
+select the change that is associated with that line.
+<li>the history view should show the history for the opened file and highlight the revision
+of the currently selected change in the annotate view.
+</ul>
+
+<h4>Annotate non-text editor files</h4>
+<ul>
+<li>annotate plugin.xml file
+<li>the default text editor should be shown
+<li>you should also be able to select a line in the text file and the annotate view should
+select the change that is associated with that line.
+<li>the history view should show the history for the opened file and highlight the revision
+of the currently selected change in the annotate view.
+</ul>
+
+<h4>Annotate binary files</h4>
+<ul>
+<li>annotate a file marked as binary
+<li>the server should report an error that annotations cannot be shown for binary files.
+</ul>
+
+</body></html> \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/toc.xml b/tests/org.eclipse.team.tests.cvs.core/toc.xml
index efc5e2d38..56c086c80 100644
--- a/tests/org.eclipse.team.tests.cvs.core/toc.xml
+++ b/tests/org.eclipse.team.tests.cvs.core/toc.xml
@@ -27,6 +27,8 @@
<topic label="Resource History" href="html/00014.html">
<topic label="Editor Linking" href="html/00018.html">
</topic>
+ <topic label="Annotate" href="html/00024.html">
+ </topic>
</topic>
<topic label="Crash Recovery" href="html/00019.html">
</topic>

Back to the top