Bug 109244 - [Misc] CVS Console is subclassing MessageConsole which is not intended for subclassing
Summary: [Misc] CVS Console is subclassing MessageConsole which is not intended for s...
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: CVS (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: platform-cvs-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 183414
Blocks:
  Show dependency tree
 
Reported: 2005-09-10 21:21 EDT by Brock Janiczak CLA
Modified: 2019-09-06 15:36 EDT (History)
0 users

See Also:


Attachments
Patch (3.95 KB, patch)
2007-04-20 11:20 EDT, Krzysztof Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brock Janiczak CLA 2005-09-10 21:21:46 EDT
Since 3.1 the preferred way to implement console is to extend IOConsole
directly.  The javadoc of MessageConsole states: "Clients may instantiate this
class; not intended to be subclassed.".  Attached is a patch to update
CVSOutputConsole to extend IOConsole instead of MessageConsole.  No
functionality is lost.

Index: CVSOutputConsole.java
===================================================================
RCS file:
/home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java,v
retrieving revision 1.21
diff -u -r1.21 CVSOutputConsole.java
--- CVSOutputConsole.java	4 Aug 2005 20:24:51 -0000	1.21
+++ CVSOutputConsole.java	11 Sep 2005 01:07:23 -0000
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.team.internal.ccvs.ui.console;
 
+import java.io.IOException;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -41,7 +42,7 @@
  * 
  * @since 3.0 
  */
-public class CVSOutputConsole extends MessageConsole implements
IConsoleListener, IPropertyChangeListener {
+public class CVSOutputConsole extends IOConsole implements IConsoleListener,
IPropertyChangeListener {
 	
 	// created colors for each line type - must be disposed at shutdown
 	private Color commandColor;
@@ -52,9 +53,9 @@
 	private long commandStarted = 0;
 	
 	// streams for each command type - each stream has its own color
-	private MessageConsoleStream commandStream;
-	private MessageConsoleStream messageStream;
-	private MessageConsoleStream errorStream;
+	private IOConsoleOutputStream commandStream;
+	private IOConsoleOutputStream messageStream;
+	private IOConsoleOutputStream errorStream;
 	
 	// preferences for showing the cvs console when cvs output is provided 
 	private boolean showOnMessage;
@@ -169,9 +170,9 @@
 	private void initializeStreams() {
 		synchronized(document) {
 			if (!initialized) {
-				commandStream = newMessageStream();
-				errorStream = newMessageStream();
-				messageStream = newMessageStream();
+				commandStream = newOutputStream();
+				errorStream = newOutputStream();
+				messageStream = newOutputStream();
 				// install colors
 				commandColor = createColor(CVSUIPlugin.getStandardDisplay(),
ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR);
 				commandStream.setColor(commandColor);
@@ -203,16 +204,20 @@
 		showConsole();
 		synchronized(document) {
 			if(visible) {
-				switch(type) {
-					case ConsoleDocument.COMMAND:
-						commandStream.println(line);
-						break;
-					case ConsoleDocument.MESSAGE:
-						messageStream.println("  " + line); //$NON-NLS-1$
-						break;
-					case ConsoleDocument.ERROR:
-						errorStream.println("  " + line); //$NON-NLS-1$
-						break;
+				try {
+					switch(type) {
+						case ConsoleDocument.COMMAND:
+							commandStream.write(line + '\n');
+							break;
+						case ConsoleDocument.MESSAGE:
+							messageStream.write("  " + line + '\n'); //$NON-NLS-1$
+							break;
+						case ConsoleDocument.ERROR:
+							errorStream.write("  " + line + '\n'); //$NON-NLS-1$
+							break;
+					}
+				} catch (IOException e) {
+					CVSUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
 				}
 			} else {
 				document.appendConsoleLine(type, line);
Comment 1 Michael Valenta CLA 2007-04-17 10:22:46 EDT
Chris, can you test the given patch to verify that everything works as expected when the patch is applied? I seem to recall trying it in 3.2 and encountering problems. Let me know what you find.
Comment 2 Krzysztof Daniel CLA 2007-04-20 11:20:50 EDT
Created attachment 64452 [details]
Patch

Michael,

the patch worked pretty well, except that the console was writtable.

I have made it read-only, but it is not clean solution - I used internal ui.console IOConsolePage - it is the only way I see to disable input.
Comment 3 Michael Valenta CLA 2007-04-20 12:45:05 EDT
I've logged bug 183414 to request the required API. This bug will have to wait until the required API is provided.
Comment 4 Eclipse Webmaster CLA 2019-09-06 15:36:04 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.