Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > subclipse commit: rev 91 - trunk/subclipse/ui/src/org/tigris/subversion/subclipse/ui/console

subclipse
Discussion topic

Back to topic list

subclipse commit: rev 91 - trunk/subclipse/ui/src/org/tigris/subversion/subclipse/ui/console

Author cchab
Full name chabanois cédric
Date 2003-07-26 08:23:11 PDT
Message Author: cchab
Date: Sat Jul 26 10:22:45 2003
New Revision: 91

Added:
   trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/co​nsole/ConsoleListene​r.java
Modified:
   trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/co​nsole/ConsoleView.ja​va
Log:
ConsoleListener not an inner class of ConsoleView anymore.
The console view is shown if something goes wrong during a subversion operation


Added: trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/co​nsole/ConsoleListene​r.java
====================​====================​====================​==================
--- (empty file)
+++ trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/co​nsole/ConsoleListene​r.java Sat Jul 26 10:22:45 2003
@@ -0,0 +1,108 @@
+/******************​********************​********************​********************​*
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.o​rg/legal/cpl-v10.htm​l
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Cédric Chabanois (cchabanois at ifrance dot com) - modified for Subversion
+ ********************​********************​********************​*******************/​
+package org.tigris.subversio​n.subclipse.ui.conso​le;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.eclipse.core.run​time.IStatus;
+import org.eclipse.core.run​time.OperationCancel​edException;
+import org.eclipse.core.run​time.Status;
+import org.eclipse.team.int​ernal.ui.TeamUIPlugi​n;
+import org.eclipse.ui.PartI​nitException;
+import org.tigris.subversio​n.subclipse.core.SVN​Status;
+import org.tigris.subversio​n.subclipse.core.cli​ent.IConsoleListener​;
+import org.tigris.subversio​n.subclipse.ui.Polic​y;
+import org.tigris.subversio​n.subclipse.ui.SVNUI​Plugin;
+
+/**
+ * The console listener
+ */
+class ConsoleListener implements IConsoleListener {
+ private long commandStarted = 0;
+ private static final DateFormat TIME_FORMAT = new SimpleDateFormat(Pol​icy.bind("Console.re​sultTimeFormat")); //$NON-NLS-1$
+
+ public void commandInvoked(String line) {
+ commandStarted = System.currentTimeMillis();
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.DELIMITER, Policy.bind("Console​.preExecutionDelimit​er")); //$NON-NLS-1$
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.COMMAND, line);
+ }
+
+ public void messageLineReceived(String line) {
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.MESSAGE, " " + line); //$NON-NLS-1$
+ }
+
+ public void errorLineReceived(String line) {
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.ERROR, " " + line); //$NON-NLS-1$
+
+ // we show the console view if something goes wrong
+ ConsoleView.findInAc​tivePerspective();
+ }
+
+ public void commandCompleted(IStatus status, Exception exception) {
+ long commandRuntime = System.currentTimeMillis() - commandStarted;
+ String time;
+ try {
+ time = TIME_FORMAT.format(new Date(commandRuntime));
+ } catch (RuntimeException e) {
+ SVNUIPlugin.log(new Status(IStatus.ERROR, SVNUIPlugin.ID, 0, Policy.bind("Console​.couldNotFormatTime"​), e)); //$NON-NLS-1$
+ time = ""; //$NON-NLS-1$
+ }
+ String statusText;
+ if (status != null) {
+ if (status.getCode() == SVNStatus.SERVER_ERROR) {
+ statusText = Policy.bind("Console​.resultServerError",​ status.getMessage(), time); //$NON-NLS-1$
+ } else {
+ statusText = Policy.bind("Console.resultOk", time); //$NON-NLS-1$
+ }
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.STATUS, statusText);
+ IStatus[] children = status.getChildren();
+ if (children.length == 0) {
+ if (!status.isOK())
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.STATUS, messageLineForStatus(status));
+ } else {
+ for (int i = 0; i < children.length; i++) {
+ if (!children[i].isOK())
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.STATUS, messageLineForStatus​(children[i]));
+ }
+ }
+ } else if (exception != null) {
+ if (exception instanceof OperationCanceledException) {
+ statusText = Policy.bind("Console​.resultAborted", time); //$NON-NLS-1$
+ } else {
+ statusText = Policy.bind("Console​.resultException", time); //$NON-NLS-1$
+ }
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.STATUS, statusText);
+ } else {
+ statusText = Policy.bind("Console.resultOk", time); //$NON-NLS-1$
+ }
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.DELIMITER, Policy.bind("Console​.postExecutionDelimi​ter")); //$NON-NLS-1$
+ ConsoleView.appendCo​nsoleLines(ConsoleDo​cument.DELIMITER, ""); //$NON-NLS-1$
+ ConsoleView.flushCon​soleBuffer();
+ }
+
+ /**
+ * Method messageLineForStatus.
+ * @param status
+ */
+ private String messageLineForStatus(IStatus status) {
+ if (status.getSeverity() == IStatus.ERROR) {
+ return Policy.bind("Console.error", status.getMessage()); //$NON-NLS-1$
+ } else if (status.getSeverity() == IStatus.WARNING) {
+ return Policy.bind("Console.warning", status.getMessage()); //$NON-NLS-1$
+ } else if (status.getSeverity() == IStatus.INFO) {
+ return Policy.bind("Console.info", status.getMessage()); //$NON-NLS-1$
+ }
+ return status.getMessage();
+ }
+}

Modified: trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/co​nsole/ConsoleView.ja​va
====================​====================​====================​==================
--- trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/co​nsole/ConsoleView.ja​va (original)
+++ trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/co​nsole/ConsoleView.ja​va Sat Jul 26 10:22:45 2003
@@ -71,8 +71,7 @@
  * Console is a view that displays the communication with the Subversion server
  */
 public class ConsoleView extends ViewPart {
- public static final String CONSOLE_ID = "org.tigris.subversi​on.subclipse.ui.cons​ole"; //$NON-NLS-1$
- private static final DateFormat TIME_FORMAT = new SimpleDateFormat(Pol​icy.bind("Console.re​sultTimeFormat")); //$NON-NLS-1$
+ public static final String CONSOLE_ID = "org.tigris.subversi​on.subclipse.ui.cons​ole.ConsoleView"; //$NON-NLS-1$
     private static ConsoleDocument document;
     private static List /* of Console */ instances;
     
@@ -355,7 +354,7 @@
     /**
      * Appends lines to the console if any views are open.
      */
- private static void appendConsoleLines(int type, String lines) {
+ public static void appendConsoleLines(int type, String lines) {
         StringTokenizer st = new StringTokenizer(lines,"\n");
         while (st.hasMoreTokens())
             appendConsoleLine(ty​pe,st.nextToken());
@@ -392,7 +391,7 @@
      * Flush the buffered console data to the console.
      * Safe to call even if console isn't open (does nothing).
      */
- private static void flushConsoleBuffer() {
+ public static void flushConsoleBuffer() {
         if(document == null) return;
     
         Display display = Display.getCurrent();
@@ -432,7 +431,7 @@
      *
      * Must be called from the UI thread.
      */
- private static ConsoleView findInActivePerspective() {
+ public static ConsoleView findInActivePerspective() {
         try {
             IWorkbenchPage page = SVNUIPlugin.getActivePage();
             IViewPart consolePart = page.findView(CONSOLE_ID);
@@ -457,74 +456,5 @@
         return SVNUIPlugin.getPlugi​n().getPreferenceSto​re();
     }
 
- private static class ConsoleListener implements IConsoleListener {
- private long commandStarted = 0;
-
- public void commandInvoked(String line) {
- commandStarted = System.currentTimeMillis();
- appendConsoleLines(C​onsoleDocument.DELIM​ITER, Policy.bind("Console​.preExecutionDelimit​er")); //$NON-NLS-1$
- appendConsoleLines(C​onsoleDocument.COMMA​ND, line);
- }
- public void messageLineReceived(String line) {
- appendConsoleLines(C​onsoleDocument.MESSA​GE, " " + line); //$NON-NLS-1$
- }
- public void errorLineReceived(String line) {
- appendConsoleLines(C​onsoleDocument.ERROR​, " " + line); //$NON-NLS-1$
- }
- public void commandCompleted(IStatus status, Exception exception) {
- long commandRuntime = System.currentTimeMillis() - commandStarted;
- String time;
- try {
- time = TIME_FORMAT.format(new Date(commandRuntime));
- } catch (RuntimeException e) {
- SVNUIPlugin.log(new Status(IStatus.ERROR, SVNUIPlugin.ID, 0, Policy.bind("Console​.couldNotFormatTime"​), e)); //$NON-NLS-1$
- time = ""; //$NON-NLS-1$
- }
- String statusText;
- if (status != null) {
- if (status.getCode() == SVNStatus.SERVER_ERROR) {
- statusText = Policy.bind("Console​.resultServerError",​ status.getMessage(), time); //$NON-NLS-1$
- } else {
- statusText = Policy.bind("Console.resultOk", time); //$NON-NLS-1$
- }
- appendConsoleLines(C​onsoleDocument.STATU​S, statusText);
- IStatus[] children = status.getChildren();
- if (children.length == 0) {
- if (!status.isOK())
- appendConsoleLine(Co​nsoleDocument.STATUS​, messageLineForStatus(status));
- } else {
- for (int i = 0; i < children.length; i++) {
- if (!children[i].isOK())
- appendConsoleLine(Co​nsoleDocument.STATUS​, messageLineForStatus​(children[i]));
- }
- }
- } else if (exception != null) {
- if (exception instanceof OperationCanceledException) {
- statusText = Policy.bind("Console​.resultAborted", time); //$NON-NLS-1$
- } else {
- statusText = Policy.bind("Console​.resultException", time); //$NON-NLS-1$
- }
- appendConsoleLine(Co​nsoleDocument.STATUS​, statusText);
- } else {
- statusText = Policy.bind("Console.resultOk", time); //$NON-NLS-1$
- }
- appendConsoleLine(Co​nsoleDocument.DELIMI​TER, Policy.bind("Console​.postExecutionDelimi​ter")); //$NON-NLS-1$
- appendConsoleLine(Co​nsoleDocument.DELIMI​TER, ""); //$NON-NLS-1$
- flushConsoleBuffer();
- }
- /**
- * Method messageLineForStatus.
- * @param status
- */
- private String messageLineForStatus(IStatus status) {
- if (status.getSeverity() == IStatus.ERROR) {
- return Policy.bind("Console.error", status.getMessage()); //$NON-NLS-1$
- } else if (status.getSeverity() == IStatus.WARNING) {
- return Policy.bind("Console.warning", status.getMessage()); //$NON-NLS-1$
- } else if (status.getSeverity() == IStatus.INFO) {
- return Policy.bind("Console.info", status.getMessage()); //$NON-NLS-1$
- }
- return status.getMessage();
- }
- }
+
 }

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@subc​lipse.tigris.org
For additional commands, e-mail: cvs-help at subclipse dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

subclipse commit: rev 91 - trunk/subclipse/ui/src/org/tigris/subversion/subclipse/ui/console cchab chabanois cédric 2003-07-26 08:23:11 PDT
Messages per page: