[logback-dev] svn commit: r1434 - in logbackPDE/trunk/plugins/ConsolePlugin: . META-INF src/main/java/ch/qos/logback/eclipse/views

noreply.seb at qos.ch noreply.seb at qos.ch
Thu Mar 15 15:51:07 CET 2007


Author: seb
Date: Thu Mar 15 15:51:07 2007
New Revision: 1434

Removed:
   logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/MyHyperlinkPresenter.java
Modified:
   logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF
   logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/JavaFileHyperLink.java
   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/LogbackViewerConfiguration.java
   logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java
   logbackPDE/trunk/plugins/ConsolePlugin/todo.txt

Log:
The plugin detects links and can now open an editor to display the clicked java class.
It is not able to display a specific line yet.

Modified: logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF	Thu Mar 15 15:51:07 2007
@@ -15,11 +15,9 @@
  org.eclipse.core.runtime,
  org.eclipse.jface.text,
  org.eclipse.ui.console,
- org.eclipse.jdt,
  org.eclipse.jdt.core,
- org.eclipse.jdt.core.manipulation,
- org.eclipse.jdt.source,
  org.eclipse.jdt.ui,
- org.eclipse.core.resources
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide
 Eclipse-LazyStart: true
 Export-Package: ch.qos.logback.eclipse.views

Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/JavaFileHyperLink.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/JavaFileHyperLink.java	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/JavaFileHyperLink.java	Thu Mar 15 15:51:07 2007
@@ -1,7 +1,18 @@
 package ch.qos.logback.eclipse.views;
 
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.Workbench;
 
 class JavaFileHyperLink implements IHyperlink {
 
@@ -9,7 +20,7 @@
   private String method;
   private int lineNumber;
   private IRegion region;
-  
+
   public JavaFileHyperLink(String className, String method, int lineNumber, IRegion region) {
     this.lineNumber = lineNumber;
     this.region = region;
@@ -31,5 +42,38 @@
 
   public void open() {
     System.out.println("Link to: " + className + "/" + method + " line: " + lineNumber);
+
+    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+
+    IType type;
+    IProject project;
+    for (int i = 0; i < projects.length; i++) {
+      project = projects[i];
+      if (project.isOpen()) {
+        try {
+          JavaProject javaProject = new JavaProject(project, null);
+          type = JavaModelUtil.findType(javaProject, className);
+          if (type != null) {
+            String path = type.getPath().toString();
+            if (path.startsWith("/" + project.getName())) {
+              path = path.substring(project.getName().length() + 1);
+            }
+            System.out.println(path);
+            openInEditor(project.getFile(path));
+          }
+        } catch (JavaModelException e) {
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+
+  private void openInEditor(IFile file) {
+    IWorkbenchPage page = Workbench.getInstance().getActiveWorkbenchWindow().getActivePage();
+    try {
+      IDE.openEditor(page, file);
+    } catch (PartInitException e) {
+      e.printStackTrace();
+    }
   }
 }

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	Thu Mar 15 15:51:07 2007
@@ -55,15 +55,13 @@
 
   public void createPartControl(Composite parent) {
 
-    myConsole = new MessageConsole("Logback Console", null);
+    myConsole = new MessageConsole("Logback console", null);
     myConsole.setWaterMarks(LOW_WATERMARK, DEFAULT_HIGH_WATERMARK);
 
     viewer = new TextConsoleViewer(parent, myConsole);
     viewer.setEditable(false);
 
     viewer.configure(new LogbackViewerConfiguration());
-    viewer.setDocument(viewer.getDocument());
-    
     
     provider = new LoggingEventContentProvider(myConsole, viewer);
     

Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackViewerConfiguration.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackViewerConfiguration.java	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackViewerConfiguration.java	Thu Mar 15 15:51:07 2007
@@ -1,39 +1,20 @@
 package ch.qos.logback.eclipse.views;
 
-import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter;
 import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
-import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter;
 import org.eclipse.jface.text.hyperlink.URLHyperlinkDetector;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.RGB;
 
 public class LogbackViewerConfiguration extends SourceViewerConfiguration {
 
-  PresentationReconciler recon = new PresentationReconciler();
-  DefaultHyperlinkPresenter pres = new DefaultHyperlinkPresenter(new RGB(0, 0, 255));
-  
   @Override
   public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
     return new IHyperlinkDetector[] { new URLHyperlinkDetector(), new JavaLinkDetector() };
   }
 
   @Override
-  public IHyperlinkPresenter getHyperlinkPresenter(ISourceViewer sourceViewer) {
-    return pres;
-  }
-
-  @Override
   public int getHyperlinkStateMask(ISourceViewer sourceViewer) {
     return SWT.NONE;
   }
-
-  @Override
-  public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
-    return recon;
-  }
-
 }

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	Thu Mar 15 15:51:07 2007
@@ -29,19 +29,16 @@
   private MessageConsoleStream redStream;
   private MessageConsoleStream blackStream;
   private TextConsoleViewer viewer;
-  //private MessageConsole console;
 
   private Color cachedRed;
   private Color cachedBlack;
   private LabelProvider labelProvider;
 
-
   public LoggingEventContentProvider(MessageConsole console, TextConsoleViewer viewer) {
     Display display = Display.getCurrent();
     cachedRed = new Color(display, 255, 0, 0);
     cachedBlack = new Color(display, 0, 0, 0);
     this.viewer = viewer;
-    //this.console = console;
 
     redStream = console.newMessageStream();
     redStream.setColor(cachedRed);
@@ -80,7 +77,7 @@
     if (le == null) {
       return;
     }
-    
+
     try {
       flushStreams();
 
@@ -89,7 +86,7 @@
     } catch (Exception e) {
       PluginLogger.logError(e);
     }
-    
+
     revealJob.schedule(50);
   }
 

Modified: logbackPDE/trunk/plugins/ConsolePlugin/todo.txt
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/todo.txt	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/todo.txt	Thu Mar 15 15:51:07 2007
@@ -8,6 +8,8 @@
 
 Color certains lines. Based on keywords and colors?
 
+Click on a log line and display the java class that requested the log
+
 DONE:
 Allow the user to change the socket's port
 Make the viewer always display the latest lines added



More information about the logback-dev mailing list