org.eclipse.mylyn.pde.ui_3.7.1.v20120425-0100

16:46:48.949 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.pde.ui_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.pde.ui.junit;

import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
import org.eclipse.mylyn.internal.java.ui.junit.TaskContextJUnitMainTab;
import org.eclipse.pde.ui.launcher.ConfigurationTab;
import org.eclipse.pde.ui.launcher.JUnitTabGroup;
import org.eclipse.pde.ui.launcher.PluginJUnitMainTab;
import org.eclipse.pde.ui.launcher.PluginsTab;
import org.eclipse.pde.ui.launcher.TracingTab;

public class TaskContextPdeJUnitTabGroup
  extends JUnitTabGroup
{
  public void createTabs(ILaunchConfigurationDialog dialog, String mode)
  {
    ILaunchConfigurationTab[] tabs = null;
    tabs = new ILaunchConfigurationTab[] { new TaskContextJUnitMainTab(true), 
    
      new PluginJUnitMainTab(), new JavaArgumentsTab(), new PluginsTab(false), new ConfigurationTab(true), 
      new TracingTab(), new EnvironmentTab(), new CommonTab() };
    setTabs(tabs);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.pde.ui.junit.TaskContextPdeJUnitTabGroup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.pde.ui.junit;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;

class TaskContextPdeJUnitLaunchConfiguration$1
  implements Runnable
{
  TaskContextPdeJUnitLaunchConfiguration$1(TaskContextPdeJUnitLaunchConfiguration paramTaskContextPdeJUnitLaunchConfiguration) {}
  
  public void run()
  {
    MessageDialog.openInformation(
      Display.getCurrent().getActiveShell(), 
      Messages.TaskContextPdeJUnitLaunchConfiguration_Context_Test_Suite, 
      Messages.TaskContextPdeJUnitLaunchConfiguration_No_test_types_found_in_the_active_task_context);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.pde.ui.junit.TaskContextPdeJUnitLaunchConfiguration.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.pde.ui.junit;

import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylyn.internal.java.ui.junit.InteractionContextTestUtil;
import org.eclipse.pde.ui.launcher.JUnitLaunchConfigurationDelegate;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public class TaskContextPdeJUnitLaunchConfiguration
  extends JUnitLaunchConfigurationDelegate
{
  protected IMember[] evaluateTests(ILaunchConfiguration configuration, IProgressMonitor monitor)
    throws CoreException
  {
    Set<IType> contextTestCases = InteractionContextTestUtil.getTestCasesInContext();
    InteractionContextTestUtil.setupTestConfiguration(contextTestCases, configuration, monitor);
    if (contextTestCases.isEmpty()) {
      PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          MessageDialog.openInformation(
            Display.getCurrent().getActiveShell(), 
            Messages.TaskContextPdeJUnitLaunchConfiguration_Context_Test_Suite, 
            Messages.TaskContextPdeJUnitLaunchConfiguration_No_test_types_found_in_the_active_task_context);
        }
      });
    }
    return (IMember[])contextTestCases.toArray(new IMember[contextTestCases.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.pde.ui.junit.TaskContextPdeJUnitLaunchConfiguration
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.pde.ui.junit;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.pde.ui.junit.messages";
  public static String TaskContextPdeJUnitLaunchConfiguration_Context_Test_Suite;
  public static String TaskContextPdeJUnitLaunchConfiguration_No_test_types_found_in_the_active_task_context;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.pde.ui.junit.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.pde.ui.junit.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.pde.ui;

import java.util.Collections;
import java.util.List;
import org.eclipse.core.internal.resources.File;
import org.eclipse.core.internal.resources.Marker;
import org.eclipse.core.internal.resources.Workspace;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.internal.ide.ui.XmlNodeHelper;
import org.eclipse.pde.core.plugin.ISharedPluginModel;
import org.eclipse.pde.internal.core.text.build.BuildEntry;
import org.eclipse.pde.internal.core.text.plugin.PluginNode;
import org.eclipse.pde.internal.core.text.plugin.PluginObjectNode;
import org.eclipse.pde.internal.ui.editor.PDEFormPage;
import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor;
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.views.markers.internal.ConcreteMarker;

public class PdeStructureBridge
  extends AbstractContextStructureBridge
{
  public static final String CONTENT_TYPE = "plugin.xml";
  
  public String getContentType()
  {
    return "plugin.xml";
  }
  
  public String getContentType(String elementHandle)
  {
    if (elementHandle.endsWith(".xml")) {
      return parentContentType;
    }
    return "plugin.xml";
  }
  
  public List<String> getChildHandles(String handle)
  {
    return Collections.emptyList();
  }
  
  public String getParentHandle(String handle)
  {
    Object object = getObjectForHandle(handle);
    if ((object instanceof PluginObjectNode))
    {
      PluginObjectNode parent = (PluginObjectNode)((PluginObjectNode)object).getParentNode();
      if (parent != null) {
        return getHandleIdentifier(parent);
      }
      int delimeterIndex = handle.indexOf(";");
      if (delimeterIndex != -1)
      {
        String parentHandle = handle.substring(0, delimeterIndex);
        return parentHandle;
      }
      return null;
    }
    if ((object instanceof PluginNode))
    {
      PluginNode parent = (PluginNode)((PluginNode)object).getParentNode();
      if (parent != null) {
        return getHandleIdentifier(parent);
      }
      int delimeterIndex = handle.indexOf(";");
      if (delimeterIndex != -1)
      {
        String parentHandle = handle.substring(0, delimeterIndex);
        return parentHandle;
      }
      return null;
    }
    if ((object instanceof IFile))
    {
      AbstractContextStructureBridge parentBridge = ContextCore.getStructureBridge(parentContentType);
      return parentBridge.getParentHandle(handle);
    }
    return null;
  }
  
  public Object getObjectForHandle(String handle)
  {
    if (handle == null) {
      return null;
    }
    int first = handle.indexOf(";");
    String filename = "";
    if (first == -1)
    {
      AbstractContextStructureBridge parentBridge = ContextCore.getStructureBridge(parentContentType);
      return parentBridge.getObjectForHandle(handle);
    }
    filename = handle.substring(0, first);
    try
    {
      IPath path = new Path(filename);
      IFile f = (IFile)((Workspace)ResourcesPlugin.getWorkspace()).newResource(path, 1);
      
      int start = Integer.parseInt(handle.substring(first + 1));
      
      IEditorPart editorPart = null;
      try
      {
        editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
      }
      catch (NullPointerException localNullPointerException) {}
      if ((editorPart != null) && ((editorPart instanceof ManifestEditor))) {
        return PdeEditingMonitor.getNode((ManifestEditor)editorPart, start, true);
      }
      String content = XmlNodeHelper.getContents(f.getContents());
      IDocument d = new Document(content);
      return PdeEditingMonitor.getNode(d, f, start, true);
    }
    catch (Exception localException) {}
    return null;
  }
  
  public String getHandleIdentifier(Object object)
  {
    if ((object instanceof XmlNodeHelper)) {
      return ((XmlNodeHelper)object).getHandle();
    }
    if ((object instanceof PluginObjectNode))
    {
      PluginObjectNode node = (PluginObjectNode)object;
      try
      {
        if ((node.getModel() == null) || (node.getModel().getUnderlyingResource() == null) || 
          (node.getModel().getUnderlyingResource().getFullPath() == null)) {
          return null;
        }
        IPath path = new Path(node.getModel().getUnderlyingResource().getFullPath().toString());
        IFile file = (IFile)((Workspace)ResourcesPlugin.getWorkspace()).newResource(path, 1);
        return new XmlNodeHelper(file.getFullPath().toString(), 
          PdeEditingMonitor.getStringOfNode(node).hashCode()).getHandle();
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.pde.ui", "Could not get handle", e));
      }
    }
    if ((object instanceof PluginNode))
    {
      PluginNode node = (PluginNode)object;
      try
      {
        if ((node.getModel() == null) || (node.getModel().getUnderlyingResource() == null) || 
          (node.getModel().getUnderlyingResource().getFullPath() == null)) {
          return null;
        }
        IPath path = new Path(node.getModel().getUnderlyingResource().getFullPath().toString());
        IFile file = (IFile)((Workspace)ResourcesPlugin.getWorkspace()).newResource(path, 1);
        return new XmlNodeHelper(file.getFullPath().toString(), 
          PdeEditingMonitor.getStringOfNode(node).hashCode()).getHandle();
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.pde.ui", "Could not get handle", e));
      }
    }
    if ((object instanceof File))
    {
      File file = (File)object;
      if (file.getFullPath().toString().endsWith("plugin.xml")) {
        return file.getFullPath().toString();
      }
    }
    return null;
  }
  
  public String getLabel(Object object)
  {
    if ((object instanceof PluginObjectNode))
    {
      PluginObjectNode node = (PluginObjectNode)object;
      String name = node.getXMLAttributeValue("name");
      if (name == null) {
        name = node.getXMLTagName();
      }
      name = node.getModel().getUnderlyingResource().getName() + ": " + name;
      return name;
    }
    if ((object instanceof File))
    {
      File file = (File)object;
      if (file.getFullPath().toString().endsWith("plugin.xml")) {
        return "plugin.xml";
      }
    }
    return "";
  }
  
  public boolean canBeLandmark(String handle)
  {
    if (handle == null) {
      return false;
    }
    return handle.indexOf(';') == -1;
  }
  
  public boolean acceptsObject(Object object)
  {
    if (((object instanceof PluginNode)) || ((object instanceof PluginObjectNode)) || ((object instanceof BuildEntry)) || 
      ((object instanceof PDEFormPage))) {
      return true;
    }
    if ((object instanceof XmlNodeHelper))
    {
      if (((XmlNodeHelper)object).getFilename().endsWith("plugin.xml")) {
        return true;
      }
    }
    else if ((object instanceof File))
    {
      File file = (File)object;
      if (file.getFullPath().toString().endsWith("plugin.xml")) {
        return true;
      }
    }
    return false;
  }
  
  public boolean canFilter(Object element)
  {
    return true;
  }
  
  public boolean isDocument(String handle)
  {
    return handle.indexOf(';') == -1;
  }
  
  public String getHandleForOffsetInObject(Object object, int offset)
  {
    if (object == null) {
      return null;
    }
    IResource markerResource = null;
    try
    {
      if ((object instanceof ConcreteMarker)) {
        markerResource = ((ConcreteMarker)object).getMarker().getResource();
      } else if ((object instanceof Marker)) {
        markerResource = ((Marker)object).getResource();
      }
    }
    catch (Exception localException1)
    {
      return null;
    }
    if (markerResource != null) {
      try
      {
        if ((markerResource instanceof IFile))
        {
          IFile file = (IFile)markerResource;
          if (file.getFullPath().toString().endsWith("plugin.xml")) {
            return file.getFullPath().toString();
          }
          return null;
        }
        return null;
      }
      catch (Throwable localThrowable)
      {
        StatusHandler.log(new Status(2, "org.eclipse.mylyn.pde.ui", 
          "Could not find element for: " + object));
        return null;
      }
    }
    if ((object instanceof IFile)) {
      try
      {
        IFile file = (IFile)object;
        if (file.getFullPath().toString().endsWith("plugin.xml"))
        {
          String content = XmlNodeHelper.getContents(file.getContents());
          IDocument d = new Document(content);
          PluginObjectNode node = PdeEditingMonitor.getNode(d, file, offset, false);
          return new XmlNodeHelper(file.getFullPath().toString(), PdeEditingMonitor.getStringOfNode(
            node).hashCode()).getHandle();
        }
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.pde.ui", 
          "Unable to get handle for offset in object", e));
      }
    }
    return null;
  }
  
  public boolean containsProblem(IInteractionElement node)
  {
    return false;
  }
}

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

import org.eclipse.mylyn.context.ui.IContextUiStartup;

public class PdeUiBridgePlugin$PdeUiBrideStartup
  implements IContextUiStartup
{
  public void lazyStartup()
  {
    PdeUiBridgePlugin.access$0(PdeUiBridgePlugin.getDefault());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.pde.ui.PdeUiBridgePlugin.PdeUiBrideStartup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.pde.ui;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.internal.resources.File;
import org.eclipse.core.internal.resources.Workspace;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.internal.context.core.AbstractRelationProvider;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.DegreeOfSeparation;
import org.eclipse.mylyn.internal.context.core.IActiveSearchListener;
import org.eclipse.mylyn.internal.context.core.IActiveSearchOperation;
import org.eclipse.mylyn.internal.context.core.IDegreeOfSeparation;
import org.eclipse.mylyn.internal.ide.ui.XmlNodeHelper;
import org.eclipse.mylyn.internal.java.ui.search.XmlActiveSearchUpdater;
import org.eclipse.mylyn.internal.resources.ui.ResourcesUiBridgePlugin;
import org.eclipse.search.core.text.TextSearchScope;
import org.eclipse.search.internal.ui.text.FileSearchQuery;
import org.eclipse.search.internal.ui.text.FileSearchResult;
import org.eclipse.search.ui.ISearchResult;
import org.eclipse.search.ui.text.FileTextSearchScope;
import org.eclipse.search.ui.text.Match;

public class XmlJavaRelationProvider
  extends AbstractRelationProvider
{
  public static final String SOURCE_ID = "org.eclipse.mylyn.xml.search.references";
  public static final String NAME = "referenced by";
  public static final int DEFAULT_DEGREE = 3;
  public static final List<Job> runningJobs = new ArrayList();
  public static final Map<Match, XmlNodeHelper> nodeMap = new HashMap();
  
  public XmlJavaRelationProvider()
  {
    super("plugin.xml", "org.eclipse.mylyn.xml.search.references");
  }
  
  public List<IDegreeOfSeparation> getDegreesOfSeparation()
  {
    List<IDegreeOfSeparation> separations = new ArrayList();
    separations.add(new DegreeOfSeparation("disabled", 0));
    separations.add(new DegreeOfSeparation("landmark resources", 1));
    separations.add(new DegreeOfSeparation("interesting resources", 2));
    separations.add(new DegreeOfSeparation("interesting projects", 3));
    separations.add(new DegreeOfSeparation("project dependencies", 4));
    separations.add(new DegreeOfSeparation("entire workspace (slow)", 5));
    return separations;
  }
  
  protected void findRelated(IInteractionElement node, int degreeOfSeparation)
  {
    if (!node.getContentType().equals("java")) {
      return;
    }
    IJavaElement javaElement = JavaCore.create(node.getHandleIdentifier());
    if ((javaElement == null) || ((javaElement instanceof ICompilationUnit)) || (!javaElement.exists())) {
      return;
    }
    if (!acceptElement(javaElement)) {
      return;
    }
    TextSearchScope scope = createTextSearchScope(degreeOfSeparation);
    if (scope != null) {
      runJob(node, javaElement, degreeOfSeparation, getId());
    }
  }
  
  protected TextSearchScope createTextSearchScope(int degreeOfSeparation)
  {
    Set<IInteractionElement> landmarks = ContextCore.getContextManager().getActiveLandmarks();
    int first;
    switch (degreeOfSeparation)
    {
    case 1: 
      Set<IResource> l = new HashSet();
      for (IInteractionElement landmark : landmarks) {
        if (landmark.getContentType().equals("plugin.xml"))
        {
          String handle = landmark.getHandleIdentifier();
          IResource element = null;
          first = handle.indexOf(";");
          String filename = handle;
          if (first != -1) {
            filename = handle.substring(0, first);
          }
          try
          {
            IPath path = new Path(filename);
            element = ((Workspace)ResourcesPlugin.getWorkspace()).newResource(path, 1);
          }
          catch (Exception e)
          {
            StatusHandler.log(new Status(2, "org.eclipse.mylyn.pde.ui", 
              "Scope creation failed", e));
          }
          l.add(element);
        }
      }
      IResource[] res = new IResource[l.size()];
      res = (IResource[])l.toArray(res);
      Object doiScope = FileTextSearchScope.newSearchScope(res, 
        new String[] { "plugin.xml" }, false);
      return l.isEmpty() ? null : doiScope;
    case 2: 
      Set<IProject> projectsToSearch = new HashSet();
      for (IInteractionElement landmark : landmarks)
      {
        AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(landmark.getContentType());
        IResource resource = ResourcesUiBridgePlugin.getDefault().getResourceForElement(landmark, true);
        IProject project = null;
        if (resource != null)
        {
          project = resource.getProject();
        }
        else
        {
          Object object = bridge.getObjectForHandle(landmark.getHandleIdentifier());
          if ((object instanceof IJavaElement)) {
            project = ((IJavaElement)object).getJavaProject().getProject();
          }
        }
        if (project != null) {
          projectsToSearch.add(project);
        }
      }
      IResource[] res = new IProject[projectsToSearch.size()];
      res = (IResource[])projectsToSearch.toArray(res);
      TextSearchScope projScope = FileTextSearchScope.newSearchScope(res, 
        new String[] { "plugin.xml" }, false);
      
      return projectsToSearch.isEmpty() ? null : projScope;
    case 3: 
      return FileTextSearchScope.newSearchScope(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, 
        new String[] { "plugin.xml" }, false);
    case 4: 
      return FileTextSearchScope.newSearchScope(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, 
        new String[] { "plugin.xml" }, false);
    }
    return null;
  }
  
  protected boolean acceptElement(IJavaElement javaElement)
  {
    return (javaElement != null) && (((javaElement instanceof IMember)) || ((javaElement instanceof IType)));
  }
  
  private void runJob(final IInteractionElement node, IJavaElement javaElement, final int degreeOfSeparation, String kind)
  {
    String fullyQualifiedName = getFullyQualifiedName(javaElement);
    if (fullyQualifiedName == null) {
      return;
    }
    XMLSearchOperation query = (XMLSearchOperation)getSearchOperation(node, 0, degreeOfSeparation);
    if (query != null)
    {
      XMLSearchJob job = new XMLSearchJob(query.getLabel(), query);
      query.addListener(new IActiveSearchListener()
      {
        private boolean gathered = false;
        
        public void searchCompleted(List<?> l)
        {
          if (l.isEmpty()) {
            return;
          }
          Map<String, String> nodes = new HashMap();
          Object[] far;
          if ((l.get(0) instanceof FileSearchResult))
          {
            FileSearchResult fsr = (FileSearchResult)l.get(0);
            
            far = fsr.getElements();
            Object[] arrayOfObject1;
            int j = (arrayOfObject1 = far).length;
            for (int i = 0; i < j; i++)
            {
              Object element = arrayOfObject1[i];
              Match[] mar = fsr.getMatches(element);
              if ((element instanceof File))
              {
                File f = (File)element;
                Match[] arrayOfMatch1;
                int m = (arrayOfMatch1 = mar).length;
                for (int k = 0; k < m; k++)
                {
                  Match m = arrayOfMatch1[k];
                  try
                  {
                    AbstractContextStructureBridge bridge = ContextCorePlugin.getDefault()
                      .getStructureBridge(f.getName());
                    String handle = bridge.getHandleForOffsetInObject(f, m.getOffset());
                    if (handle != null)
                    {
                      String second = handle.substring(handle.indexOf(";"));
                      
                      XmlNodeHelper xnode = new XmlNodeHelper(f.getFullPath().toString(), second);
                      XmlJavaRelationProvider.nodeMap.put(m, xnode);
                      Object o = bridge.getObjectForHandle(handle);
                      String name = bridge.getLabel(o);
                      if (o != null) {
                        nodes.put(handle, name);
                      }
                    }
                  }
                  catch (Exception e)
                  {
                    StatusHandler.log(new Status(4, "org.eclipse.mylyn.pde.ui", 
                      "Unable to create match", e));
                  }
                }
              }
            }
          }
          for (String handle : nodes.keySet()) {
            incrementInterest(node, "plugin.xml", handle, degreeOfSeparation);
          }
          gathered = true;
          searchCompleted(node);
        }
        
        public boolean resultsGathered()
        {
          return gathered;
        }
      });
      runningJobs.add(job);
      job.setPriority(40);
      job.schedule();
    }
  }
  
  public IActiveSearchOperation getSearchOperation(IInteractionElement node, int limitTo, int degreeOfSeparation)
  {
    IJavaElement javaElement = JavaCore.create(node.getHandleIdentifier());
    TextSearchScope scope = createTextSearchScope(degreeOfSeparation);
    if (scope == null) {
      return null;
    }
    String fullyQualifiedName = getFullyQualifiedName(javaElement);
    
    return new XMLSearchOperation(scope, fullyQualifiedName);
  }
  
  private String getFullyQualifiedName(IJavaElement je)
  {
    if (!(je instanceof IMember)) {
      return null;
    }
    IMember m = (IMember)je;
    if (m.getDeclaringType() == null) {
      return ((IType)m).getFullyQualifiedName();
    }
    return m.getDeclaringType().getFullyQualifiedName() + "." + m.getElementName();
  }
  
  public static class XMLSearchJob
    extends Job
  {
    private final XmlJavaRelationProvider.XMLSearchOperation op;
    
    public XMLSearchJob(String name, XmlJavaRelationProvider.XMLSearchOperation op)
    {
      super();
      this.op = op;
    }
    
    protected IStatus run(IProgressMonitor monitor)
    {
      return op.run(monitor);
    }
  }
  
  public static class XMLSearchOperation
    extends FileSearchQuery
    implements IActiveSearchOperation
  {
    public ISearchResult getSearchResult()
    {
      try
      {
        Class<?> clazz = FileSearchQuery.class;
        Field field = clazz.getDeclaredField("fResult");
        field.setAccessible(true);
        FileSearchResult fResult = (FileSearchResult)field.get(this);
        if (fResult == null)
        {
          fResult = new FileSearchResult(this);
          field.set(this, fResult);
          new XmlActiveSearchUpdater(fResult);
        }
        return fResult;
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(2, "org.eclipse.mylyn.pde.ui", 
          "Failed to get search result: " + e.getMessage()));
      }
      return super.getSearchResult();
    }
    
    public IStatus run(IProgressMonitor monitor)
    {
      try
      {
        super.run(monitor);
        ISearchResult result = getSearchResult();
        if ((result instanceof FileSearchResult))
        {
          List<Object> l = new ArrayList();
          if (((FileSearchResult)result).getElements().length != 0) {
            l.add(result);
          }
          notifySearchCompleted(l);
        }
        return Status.OK_STATUS;
      }
      catch (Throwable localThrowable) {}
      return new Status(2, "org.eclipse.mylyn.context.core", 0, 
        Messages.XmlJavaRelationProvider_Skipped_XML_search, null);
    }
    
    public XMLSearchOperation(TextSearchScope scope, String searchString)
    {
      super(false, true, (FileTextSearchScope)scope);
    }
    
    private final List<IActiveSearchListener> listeners = new ArrayList();
    
    public void addListener(IActiveSearchListener l)
    {
      listeners.add(l);
    }
    
    public void removeListener(IActiveSearchListener l)
    {
      listeners.remove(l);
    }
    
    public void notifySearchCompleted(List<Object> l)
    {
      for (IActiveSearchListener listener : listeners) {
        listener.searchCompleted(l);
      }
    }
  }
  
  public String getGenericId()
  {
    return "org.eclipse.mylyn.xml.search.references";
  }
  
  protected String getSourceId()
  {
    return "org.eclipse.mylyn.xml.search.references";
  }
  
  public String getName()
  {
    return "referenced by";
  }
  
  public void stopAllRunningJobs()
  {
    for (Job j : runningJobs) {
      j.cancel();
    }
    runningJobs.clear();
  }
  
  protected int getDefaultDegreeOfSeparation()
  {
    return 3;
  }
}

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

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.internal.resources.Workspace;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ITreeViewerListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.context.ui.AbstractContextUiBridge;
import org.eclipse.pde.internal.core.text.plugin.PluginObjectNode;
import org.eclipse.pde.internal.ui.editor.FormOutlinePage;
import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage;
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
import org.eclipse.pde.internal.ui.editor.PDESourcePage;
import org.eclipse.pde.internal.ui.editor.SourceOutlinePage;
import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.AbstractTextEditor;

public class PdeUiBridge
  extends AbstractContextUiBridge
{
  private final TreeViewerListener treeSelectionChangedListener;
  
  public PdeUiBridge()
  {
    treeSelectionChangedListener = new TreeViewerListener(null);
  }
  
  public void open(IInteractionElement node)
  {
    String handle = node.getHandleIdentifier();
    
    int first = handle.indexOf(";");
    String filename = "";
    if (first == -1) {
      filename = handle;
    } else {
      filename = handle.substring(0, first);
    }
    try
    {
      IPath path = new Path(filename);
      IFile f = (IFile)((Workspace)ResourcesPlugin.getWorkspace()).newResource(path, 1);
      
      IEditorPart editor = openInEditor(f, true);
      if (editor == null)
      {
        StatusHandler.log(new Status(2, "org.eclipse.mylyn.pde.ui", 
          "Unable to open editor for file: " + filename));
        return;
      }
    }
    catch (Exception localException) {}
  }
  
  private IEditorPart openInEditor(IFile file, boolean activate)
    throws PartInitException
  {
    if (file != null)
    {
      IWorkbenchPage p = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if ((p != null) && (file.exists()))
      {
        IEditorPart editorPart = IDE.openEditor(p, file, activate);
        
        return editorPart;
      }
    }
    return null;
  }
  
  public void close(IInteractionElement node)
  {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (page != null)
    {
      IEditorReference[] references = page.getEditorReferences();
      IEditorReference[] arrayOfIEditorReference1;
      int j = (arrayOfIEditorReference1 = references).length;
      for (int i = 0; i < j; i++)
      {
        IEditorReference reference = arrayOfIEditorReference1[i];
        IEditorPart part = reference.getEditor(false);
        if (part != null) {
          if (("/" + part.getTitleToolTip()).equals(node.getHandleIdentifier())) {
            if ((part instanceof FormEditor)) {
              ((FormEditor)part).close(true);
            } else if ((part instanceof AbstractTextEditor)) {
              ((AbstractTextEditor)part).close(true);
            }
          }
        }
      }
    }
  }
  
  public boolean acceptsEditor(IEditorPart editorPart)
  {
    return editorPart instanceof ManifestEditor;
  }
  
  public List<TreeViewer> getContentOutlineViewers(IEditorPart editor)
  {
    if ((editor instanceof PDEFormEditor))
    {
      PDESourcePage sp = null;
      List<TreeViewer> viewers = new ArrayList(2);
      if ((sp = (PDESourcePage)((PDEFormEditor)editor).findPage("plugin-context")) != null)
      {
        ISortableContentOutlinePage page = sp.getContentOutline();
        if ((page != null) && (page.getControl() != null)) {
          try
          {
            if ((page instanceof SourceOutlinePage))
            {
              Class<?> clazz2 = page.getClass();
              Field field2 = clazz2.getDeclaredField("viewer");
              field2.setAccessible(true);
              Object f2 = field2.get(page);
              if ((f2 != null) && ((f2 instanceof TreeViewer))) {
                viewers.add((TreeViewer)f2);
              }
            }
          }
          catch (Exception e)
          {
            StatusHandler.log(new Status(4, "org.eclipse.mylyn.pde.ui", 
              "Failed to get tree viewers", e));
            return null;
          }
        }
      }
      Field field;
      try
      {
        Class<?> clazz = PDEFormEditor.class;
        field = null;
        try
        {
          field = clazz.getDeclaredField("formOutline");
        }
        catch (NoSuchFieldException localNoSuchFieldException1)
        {
          field = clazz.getDeclaredField("fFormOutline");
        }
        field.setAccessible(true);
        Object f = field.get(editor);
        if ((f != null) && ((f instanceof FormOutlinePage)))
        {
          Class<?> clazz2 = FormOutlinePage.class;
          Field field2 = null;
          try
          {
            field2 = clazz2.getDeclaredField("treeViewer");
          }
          catch (NoSuchFieldException localNoSuchFieldException2)
          {
            field2 = clazz2.getDeclaredField("fTreeViewer");
          }
          field2.setAccessible(true);
          Object f2 = field2.get(f);
          if ((f2 != null) && ((f2 instanceof TreeViewer)))
          {
            TreeViewer treeViewer = (TreeViewer)f2;
            viewers.add(treeViewer);
          }
        }
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.pde.ui", "Could not get PDE outline", e));
        return Collections.emptyList();
      }
      for (TreeViewer viewer : viewers)
      {
        viewer.addSelectionChangedListener(treeSelectionChangedListener);
        viewer.addTreeListener(treeSelectionChangedListener);
      }
      return viewers;
    }
    return Collections.emptyList();
  }
  
  public void refreshOutline(Object element, boolean updateLabels, boolean setSelection)
  {
    IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    List<TreeViewer> treeViewers = getContentOutlineViewers(editorPart);
    for (TreeViewer treeViewer : treeViewers) {
      if (treeViewer != null) {
        if (element == null)
        {
          treeViewer.getControl().setRedraw(false);
          treeViewer.refresh(true);
          treeViewer.getControl().setRedraw(true);
          treeViewer.expandAll();
        }
        else if ((element instanceof PluginObjectNode))
        {
          treeViewer.getControl().setRedraw(false);
          treeViewer.refresh(element, true);
          treeViewer.getControl().setRedraw(true);
          treeViewer.expandAll();
        }
      }
    }
  }
  
  private class TreeViewerListener
    implements ISelectionChangedListener, ITreeViewerListener
  {
    private TreeViewerListener() {}
    
    public void selectionChanged(SelectionChangedEvent event)
    {
      Object o = event.getSource();
      if ((o instanceof TreeViewer))
      {
        ((TreeViewer)o).refresh();
        ((TreeViewer)o).expandAll();
      }
    }
    
    public void treeCollapsed(TreeExpansionEvent event)
    {
      Object o = event.getSource();
      if ((o instanceof TreeViewer)) {
        ((TreeViewer)o).refresh();
      }
    }
    
    public void treeExpanded(TreeExpansionEvent event)
    {
      Object o = event.getSource();
      if ((o instanceof TreeViewer)) {
        ((TreeViewer)o).refresh();
      }
    }
  }
  
  public Object getObjectForTextSelection(TextSelection selection, IEditorPart editor)
  {
    return null;
  }
  
  public IInteractionElement getElement(IEditorInput input)
  {
    return null;
  }
  
  public String getContentType()
  {
    return "plugin.xml";
  }
}

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

import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.context.core.IInteractionRelation;
import org.eclipse.mylyn.internal.context.ui.AbstractContextLabelProvider;
import org.eclipse.mylyn.internal.context.ui.ContextUiImages;
import org.eclipse.mylyn.internal.ide.ui.IdeUiBridgePlugin;
import org.eclipse.swt.graphics.Image;

public class PdeContextLabelProvider
  extends AbstractContextLabelProvider
{
  public static final String LABEL_RELATION = Messages.PdeContextLabelProvider_referenced_by;
  
  protected Image getImage(IInteractionElement node)
  {
    return CommonImages.getImage(ContextUiImages.FILE_XML);
  }
  
  protected Image getImage(IInteractionRelation edge)
  {
    return CommonImages.getImage(IdeUiBridgePlugin.EDGE_REF_XML);
  }
  
  protected String getText(IInteractionElement node)
  {
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge("plugin.xml");
    return bridge.getLabel(bridge.getObjectForHandle(node.getHandleIdentifier()));
  }
  
  protected String getText(IInteractionRelation edge)
  {
    return LABEL_RELATION;
  }
  
  protected Image getImageForObject(Object object)
  {
    return CommonImages.getImage(ContextUiImages.FILE_XML);
  }
  
  protected String getTextForObject(Object object)
  {
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge("plugin.xml");
    return bridge.getLabel(object);
  }
}

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

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ITreeViewerListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.jface.viewers.TreeViewer;

class PdeUiBridge$TreeViewerListener
  implements ISelectionChangedListener, ITreeViewerListener
{
  private PdeUiBridge$TreeViewerListener(PdeUiBridge paramPdeUiBridge) {}
  
  public void selectionChanged(SelectionChanged
1 2

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