[logback-dev] svn commit: r1352 - logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views

noreply.seb at qos.ch noreply.seb at qos.ch
Mon Feb 26 19:25:44 CET 2007


Author: seb
Date: Mon Feb 26 19:25:44 2007
New Revision: 1352

Modified:
   logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java
   logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java

Log:
Added scroll lock function to the console 

Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java	Mon Feb 26 19:25:44 2007
@@ -32,8 +32,10 @@
   private MessageConsole myConsole;
   private LoggingEventContentProvider provider;
   private LoggingEventLabelProvider labelProvider;
+  
   private Action clearConsoleAction;
-
+  private Action autoScrollAction;
+  
   private SimpleSocketServer server;
   private Thread serverThread;
   private LogbackPreferencesAction preferencesAction;
@@ -44,16 +46,21 @@
 
   public void createPartControl(Composite parent) {
 
-    myConsole = new MessageConsole("My Console", null);
+    myConsole = new MessageConsole("Logback Console", null);
     myConsole.setWaterMarks(LOW_WATERMARK, DEFAULT_HIGH_WATERMARK);
 
     viewer = new TextConsoleViewer(parent, myConsole);
     viewer.setEditable(false);
+//    Display disp = Display.getCurrent();
+//    Color blue = new Color(disp, new RGB(0,0,255) );
+//    DefaultHyperlinkPresenter presenter = new DefaultHyperlinkPresenter(blue);
+//    HyperlinkManager manager = new HyperlinkManager(HyperlinkManager.FIRST);
+//    manager.install(viewer, presenter, new IHyperlinkDetector[]{new URLHyperlinkDetector()}, 0);
 
     provider = new LoggingEventContentProvider(myConsole, viewer);
     labelProvider = new LoggingEventLabelProvider();
     provider.setLabelProvider(labelProvider);
-
+    
     LoggingEventManager.getManager().addLoggingEventManagerListener(provider);
 
     makeActions();
@@ -64,6 +71,7 @@
     IActionBars bars = getViewSite().getActionBars();
     IToolBarManager manager = bars.getToolBarManager();
     manager.add(clearConsoleAction);
+    manager.add(autoScrollAction);
   }
 
   private void makeActions() {
@@ -73,7 +81,6 @@
     menu.add(preferencesAction);
 
     clearConsoleAction = new Action() {
-
       @Override
       public void run() {
         super.run();
@@ -83,6 +90,29 @@
     clearConsoleAction.setText("Clear console");
     clearConsoleAction.setToolTipText("Clear the console");
     clearConsoleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+        .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+    
+    autoScrollAction = new Action() {
+      @Override
+      public void run() {
+        super.run();
+        provider.toggleAutoScroll();
+        updateText();
+      }
+      
+      private void updateText() {
+        if (provider.isAutoScroll()) {
+          this.setText("Turn off auto scroll");
+          this.setToolTipText("Turn off auto scroll");
+        } else {
+          this.setText("Turn on auto scroll");
+          this.setToolTipText("Turn on auto scroll");
+        }
+      }
+    };
+    autoScrollAction.setText("Turn off auto scroll");
+    autoScrollAction.setToolTipText("Turn off auto scroll");
+    autoScrollAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
         .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
 
   }

Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java	Mon Feb 26 19:25:44 2007
@@ -32,6 +32,8 @@
   private Color cachedRed;
   private Color cachedBlack;
   private LabelProvider labelProvider;
+  
+  private boolean autoScroll;
 
   public LoggingEventContentProvider(MessageConsole console, TextConsoleViewer viewer) {
     Display display = Display.getCurrent();
@@ -83,7 +85,9 @@
     } catch (Exception e) {
       PluginLogger.logError(e);
     }
-    revealJob.schedule(50);
+    if (autoScroll) {
+      revealJob.schedule(50);
+    }
   }
 
   private void flushStreams() {
@@ -98,4 +102,16 @@
   public void setLabelProvider(LabelProvider provider) {
     this.labelProvider = provider;
   }
+  
+  public void setAutoScroll(boolean autoScroll) {
+    this.autoScroll = autoScroll;
+  }
+  
+  public boolean isAutoScroll() {
+    return autoScroll;
+  }
+  
+  public void toggleAutoScroll() {
+    autoScroll = !autoScroll;
+  }
 }



More information about the logback-dev mailing list