org.eclipse.mylyn.java.tasks_3.7.1.v20120425-0100

16:46:44.914 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.java.tasks_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.java.tasks;

import org.eclipse.jdt.internal.junit.model.TestCaseElement;
import org.eclipse.jdt.internal.junit.model.TestElement;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.mylyn.tasks.core.TaskMapping;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

public class NewTaskFromJunitResultViewAction
  implements IViewActionDelegate, ISelectionChangedListener
{
  public static final String ID = "org.eclipse.mylyn.bugzilla.actions.newTaskFromJunitResultView";
  private String traceString;
  private TestCaseElement testCaseElement;
  
  public void run(IAction action)
  {
    run();
  }
  
  public void run()
  {
    if ((traceString == null) || (testCaseElement == null)) {
      return;
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("\n-- Error Log from JUnit --\nClass: ");
    sb.append(testCaseElement.getTestClassName());
    sb.append("\nMethod: ");
    sb.append(testCaseElement.getTestMethodName());
    sb.append("\nActual: ");
    sb.append(testCaseElement.getActual());
    sb.append("\nExpected: ");
    sb.append(testCaseElement.getExpected());
    sb.append("\nStack Trace:\n");
    sb.append(traceString);
    
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    TaskMapping taskMapping = new TaskMapping()
    {
      public String getDescription()
      {
        return sb.toString();
      }
    };
    TasksUiUtil.openNewTaskEditor(shell, taskMapping, null);
  }
  
  public void selectionChanged(SelectionChangedEvent event) {}
  
  public void init(IViewPart view) {}
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    traceString = null;
    testCaseElement = null;
    if ((selection instanceof TreeSelection))
    {
      TreeSelection t = (TreeSelection)selection;
      TestElement testElement = (TestElement)t.getFirstElement();
      if ((testElement instanceof TestCaseElement))
      {
        testCaseElement = ((TestCaseElement)testElement);
        traceString = testCaseElement.getTrace();
      }
    }
    action.setEnabled(traceString != null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.tasks.NewTaskFromJunitResultViewAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.tasks;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.internal.debug.ui.actions.OpenTypeAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.mylyn.tasks.ui.IHighlightingHyperlink;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;

public class JavaStackTraceFileHyperlink
  implements IHyperlink, IHighlightingHyperlink
{
  private final IRegion region;
  private final String traceLine;
  private final IRegion highlightingRegion;
  
  public JavaStackTraceFileHyperlink(IRegion region, String traceLine, IRegion highlightingRegion)
  {
    this.region = region;
    this.traceLine = traceLine;
    this.highlightingRegion = highlightingRegion;
  }
  
  public IRegion getHyperlinkRegion()
  {
    return region;
  }
  
  public String getHyperlinkText()
  {
    return null;
  }
  
  public String getTypeLabel()
  {
    return null;
  }
  
  public void open()
  {
    try
    {
      String typeName = getTypeName();
      int lineNumber = getLineNumber();
      if (lineNumber > 0) {
        lineNumber--;
      }
      startSourceSearch(typeName, lineNumber);
    }
    catch (CoreException localCoreException)
    {
      MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
        Messages.JavaStackTraceFileHyperlink_Open_Type, 
        Messages.JavaStackTraceFileHyperlink_Failed_to_open_type);
      return;
    }
  }
  
  protected void startSourceSearch(final String typeName, final int lineNumber)
  {
    Job search = new Job(Messages.JavaStackTraceFileHyperlink_Searching_)
    {
      protected IStatus run(IProgressMonitor monitor)
      {
        try
        {
          Object result = OpenTypeAction.findTypeInWorkspace(typeName);
          searchCompleted(result, typeName, lineNumber, null);
        }
        catch (CoreException e)
        {
          searchCompleted(null, typeName, lineNumber, e.getStatus());
        }
        return Status.OK_STATUS;
      }
    };
    search.schedule();
  }
  
  protected void searchCompleted(final Object source, final String typeName, final int lineNumber, IStatus status)
  {
    UIJob job = new UIJob(Messages.JavaStackTraceFileHyperlink_link_search_complete)
    {
      public IStatus runInUIThread(IProgressMonitor monitor)
      {
        if (source == null) {
          MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
            Messages.JavaStackTraceFileHyperlink_Open_Type, 
            Messages.JavaStackTraceFileHyperlink_Type_could_not_be_located);
        } else {
          processSearchResult(source, typeName, lineNumber);
        }
        return Status.OK_STATUS;
      }
    };
    job.setSystem(true);
    job.schedule();
  }
  
  protected void processSearchResult(Object source, String typeName, int lineNumber)
  {
    IDebugModelPresentation presentation = JDIDebugUIPlugin.getDefault().getModelPresentation();
    IEditorInput editorInput = presentation.getEditorInput(source);
    if (editorInput != null)
    {
      String editorId = presentation.getEditorId(editorInput, source);
      if (editorId != null) {
        try
        {
          IEditorPart editorPart = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow()
            .getActivePage()
            .openEditor(editorInput, editorId);
          if (((editorPart instanceof ITextEditor)) && (lineNumber >= 0))
          {
            ITextEditor textEditor = (ITextEditor)editorPart;
            IDocumentProvider provider = textEditor.getDocumentProvider();
            provider.connect(editorInput);
            IDocument document = provider.getDocument(editorInput);
            try
            {
              IRegion line = document.getLineInformation(lineNumber);
              textEditor.selectAndReveal(line.getOffset(), line.getLength());
            }
            catch (BadLocationException localBadLocationException)
            {
              MessageDialog.openInformation(
              
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.JavaStackTraceFileHyperlink_Open_Type, 
                Messages.JavaStackTraceFileHyperlink_Line_not_found_in_type);
            }
            provider.disconnect(editorInput);
          }
        }
        catch (CoreException localCoreException)
        {
          MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
            Messages.JavaStackTraceFileHyperlink_Open_Type, 
            Messages.JavaStackTraceFileHyperlink_Failed_to_open_type);
        }
      }
    }
  }
  
  private String getTypeName()
  {
    int start = traceLine.indexOf('(');
    int end = traceLine.indexOf(':');
    if ((start >= 0) && (end > start))
    {
      String typeName = traceLine.substring(start + 1, end);
      typeName = typeName.substring(0, typeName.indexOf("."));
      
      String qualifier = traceLine.substring(0, start);
      
      start = qualifier.lastIndexOf('.');
      if (start >= 0)
      {
        start = qualifier.subSequence(0, start).toString().lastIndexOf('.');
        if (start == -1) {
          start = 0;
        }
      }
      if (start >= 0) {
        qualifier = qualifier.substring(0, start);
      }
      if (qualifier.length() > 0) {
        typeName = qualifier + "." + typeName;
      }
      return typeName.trim();
    }
    return "error";
  }
  
  private int getLineNumber()
    throws CoreException
  {
    int index = traceLine.lastIndexOf(':');
    if (index >= 0)
    {
      String numText = traceLine.substring(index + 1);
      index = numText.indexOf(')');
      if (index >= 0) {
        numText = numText.substring(0, index);
      }
      try
      {
        return Integer.parseInt(numText);
      }
      catch (NumberFormatException localNumberFormatException)
      {
        throw new CoreException(null);
      }
    }
    throw new CoreException(null);
  }
  
  public IRegion getHighlightingRegion()
  {
    return highlightingRegion != null ? highlightingRegion : region;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.tasks.JavaStackTraceFileHyperlink
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.tasks;

import org.eclipse.mylyn.tasks.core.TaskMapping;

class NewTaskFromJunitResultViewAction$1
  extends TaskMapping
{
  NewTaskFromJunitResultViewAction$1(NewTaskFromJunitResultViewAction paramNewTaskFromJunitResultViewAction, StringBuilder paramStringBuilder) {}
  
  public String getDescription()
  {
    return val$sb.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.tasks.NewTaskFromJunitResultViewAction.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.tasks;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.mylyn.tasks.ui.AbstractTaskHyperlinkDetector;

public class JavaStackTraceHyperlinkDetector
  extends AbstractTaskHyperlinkDetector
{
  private static final Pattern stackTracePattern = Pattern.compile("\\S*\\(([\\w\\$]*\\.java:\\d*)\\)", 
    2);
  
  private static IRegion determineRegion(int textOffset, Matcher m, int group)
  {
    return new Region(textOffset + m.start(group), m.end(group) - m.start(group));
  }
  
  private static boolean isInRegion(int offsetInText, Matcher m)
  {
    return (offsetInText == -1) || ((offsetInText >= m.start()) && (offsetInText <= m.end()));
  }
  
  protected List<IHyperlink> detectHyperlinks(ITextViewer textViewer, String content, int offsetInContent, int contentOffset)
  {
    List<IHyperlink> links = null;
    Matcher m = stackTracePattern.matcher(content);
    while (m.find()) {
      if (isInRegion(offsetInContent, m))
      {
        if (links == null) {
          links = new ArrayList();
        }
        links.add(new JavaStackTraceFileHyperlink(determineRegion(contentOffset, m, 0), m.group(), 
          determineRegion(contentOffset, m, 1)));
      }
    }
    return links;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.tasks.JavaStackTraceHyperlinkDetector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.tasks;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.internal.debug.ui.actions.OpenTypeAction;

class JavaStackTraceFileHyperlink$1
  extends Job
{
  JavaStackTraceFileHyperlink$1(JavaStackTraceFileHyperlink paramJavaStackTraceFileHyperlink, String $anonymous0, String paramString1, int paramInt)
  {
    super($anonymous0);
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    try
    {
      Object result = OpenTypeAction.findTypeInWorkspace(val$typeName);
      this$0.searchCompleted(result, val$typeName, val$lineNumber, null);
    }
    catch (CoreException e)
    {
      this$0.searchCompleted(null, val$typeName, val$lineNumber, e.getStatus());
    }
    return Status.OK_STATUS;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.tasks.JavaStackTraceFileHyperlink.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.tasks;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;

class JavaStackTraceFileHyperlink$2
  extends UIJob
{
  JavaStackTraceFileHyperlink$2(JavaStackTraceFileHyperlink paramJavaStackTraceFileHyperlink, String $anonymous0, Object paramObject, String paramString1, int paramInt)
  {
    super($anonymous0);
  }
  
  public IStatus runInUIThread(IProgressMonitor monitor)
  {
    if (val$source == null) {
      MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
        Messages.JavaStackTraceFileHyperlink_Open_Type, 
        Messages.JavaStackTraceFileHyperlink_Type_could_not_be_located);
    } else {
      this$0.processSearchResult(val$source, val$typeName, val$lineNumber);
    }
    return Status.OK_STATUS;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.tasks.JavaStackTraceFileHyperlink.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.tasks;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.java.tasks.messages";
  public static String JavaStackTraceFileHyperlink_Failed_to_open_type;
  public static String JavaStackTraceFileHyperlink_Line_not_found_in_type;
  public static String JavaStackTraceFileHyperlink_link_search_complete;
  public static String JavaStackTraceFileHyperlink_Open_Type;
  public static String JavaStackTraceFileHyperlink_Searching_;
  public static String JavaStackTraceFileHyperlink_Type_could_not_be_located;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.java.tasks.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.tasks.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd