org.eclipse.mylyn.ide.ant_3.7.1.v20120425-0100

16:46:44.073 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.ide.ant_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.ide.ant;

import org.eclipse.ant.internal.ui.editor.AntEditor;
import org.eclipse.ant.internal.ui.model.AntElementNode;
import org.eclipse.ant.internal.ui.model.AntModel;
import org.eclipse.ant.internal.ui.model.AntProjectNode;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.ide.ui.XmlNodeHelper;
import org.eclipse.mylyn.monitor.ui.AbstractUserInteractionMonitor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.FileEditorInput;

public class AntEditingMonitor
  extends AbstractUserInteractionMonitor
{
  protected void handleWorkbenchPartSelection(IWorkbenchPart part, ISelection selection, boolean contributeToContext)
  {
    if ((part instanceof AntEditor))
    {
      TextSelection textSelection = null;
      IEditorInput in = null;
      
      AntEditor editor = (AntEditor)part;
      if (!(editor.getSelectionProvider().getSelection() instanceof TextSelection)) {
        return;
      }
      textSelection = (TextSelection)editor.getSelectionProvider().getSelection();
      in = editor.getEditorInput();
      if ((textSelection != null) && (editor.getAntModel() != null)) {
        try
        {
          AntElementNode node = editor.getAntModel().getNode(textSelection.getOffset(), false);
          if (node == null) {
            return;
          }
          FileEditorInput fei = (FileEditorInput)in;
          
          String path = node.getElementPath();
          if (path == null) {
            return;
          }
          XmlNodeHelper xnode = new XmlNodeHelper(fei.getFile().getFullPath().toString(), path);
          super.handleElementSelection(part, xnode, contributeToContext);
        }
        catch (Exception e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.ide.ant", 
            "Resolving selection failed", e));
        }
      }
    }
  }
  
  public static AntElementNode getNode(AntModel antModel, String elementPath)
    throws SecurityException, NoSuchMethodException
  {
    try
    {
      AntProjectNode topNode = antModel.getProjectNode();
      return getNode(topNode, elementPath);
    }
    catch (Exception localException) {}
    return null;
  }
  
  private static AntElementNode getNode(AntElementNode topNode, String elementPath)
    throws NoSuchMethodException, IllegalAccessException
  {
    if (topNode == null) {
      return null;
    }
    String path = topNode.getElementPath();
    if (path.compareTo(elementPath) == 0) {
      return topNode;
    }
    if (topNode.getChildNodes() == null) {
      return null;
    }
    for (Object obj : topNode.getChildNodes()) {
      if ((obj instanceof AntElementNode))
      {
        AntElementNode node = (AntElementNode)obj;
        
        path = node.getElementPath();
        if (path.compareTo(elementPath) == 0) {
          return node;
        }
        AntElementNode node2 = getNode(node, elementPath);
        if (node2 != null) {
          return node2;
        }
      }
    }
    return null;
  }
}

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

import java.util.Collections;
import java.util.List;
import org.eclipse.ant.internal.ui.editor.AntEditor;
import org.eclipse.ant.internal.ui.editor.text.AntAnnotationModel;
import org.eclipse.ant.internal.ui.model.AntElementNode;
import org.eclipse.ant.internal.ui.model.AntModel;
import org.eclipse.ant.internal.ui.model.IProblemRequestor;
import org.eclipse.ant.internal.ui.model.LocationProvider;
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.internal.ide.ui.XmlNodeHelper;
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.part.FileEditorInput;
import org.eclipse.ui.views.markers.internal.ConcreteMarker;

public class AntStructureBridge
  extends AbstractContextStructureBridge
{
  public static final String CONTENT_TYPE = "build.xml";
  private static final char HANDLE_PATH_SEPARATOR = ';';
  
  public String getContentType()
  {
    return "build.xml";
  }
  
  public String getContentType(String elementHandle)
  {
    if (elementHandle.endsWith(".xml")) {
      return parentContentType;
    }
    return "build.xml";
  }
  
  public List<String> getChildHandles(String handle)
  {
    return Collections.emptyList();
  }
  
  public String getParentHandle(String handle)
  {
    Object o = getObjectForHandle(handle);
    if ((o instanceof AntElementNode))
    {
      AntElementNode parent = ((AntElementNode)o).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 ((o instanceof IFile))
    {
      AbstractContextStructureBridge parentBridge = ContextCore.getStructureBridge(parentContentType);
      return parentBridge.getParentHandle(handle);
    }
    return null;
  }
  
  public Object getObjectForHandle(String handle)
  {
    try
    {
      if (handle == null) {
        return null;
      }
      int first = handle.indexOf(';');
      String filename = "";
      if (first == -1)
      {
        filename = handle;
        IPath path = new Path(filename);
        return (IFile)((Workspace)ResourcesPlugin.getWorkspace()).newResource(path, 1);
      }
      filename = handle.substring(0, first);
      
      IPath path = new Path(filename);
      IFile file = (IFile)((Workspace)ResourcesPlugin.getWorkspace()).newResource(path, 1);
      FileEditorInput fei = new FileEditorInput(file);
      
      String elementPath = handle.substring(first + 1);
      if (elementPath.equals("")) {
        return file;
      }
      IEditorPart editorPart = PlatformUI.getWorkbench()
        .getActiveWorkbenchWindow()
        .getActivePage()
        .getActiveEditor();
      if ((editorPart instanceof AntEditor))
      {
        AntModel antModel = ((AntEditor)editorPart).getAntModel();
        if (antModel != null) {
          return AntEditingMonitor.getNode(antModel, elementPath);
        }
      }
      else
      {
        String content = XmlNodeHelper.getContents(file.getContents());
        IDocument d = new Document(content);
        
        IProblemRequestor p = new AntAnnotationModel(file);
        AntModel am = new AntModel(d, p, new LocationProvider(fei));
        am.reconcile();
        return AntEditingMonitor.getNode(am, elementPath);
      }
    }
    catch (Throwable localThrowable) {}
    return null;
  }
  
  public String getHandleIdentifier(Object object)
  {
    if ((object instanceof XmlNodeHelper)) {
      return ((XmlNodeHelper)object).getHandle();
    }
    if ((object instanceof AntElementNode))
    {
      AntElementNode node = (AntElementNode)object;
      String path = node.getElementPath();
      if ((path == null) || (node.getIFile() == null)) {
        return null;
      }
      XmlNodeHelper helper = new XmlNodeHelper(node.getIFile().getFullPath().toString(), path);
      return helper.getHandle();
    }
    if ((object instanceof File))
    {
      File file = (File)object;
      if (file.getFullPath().toString().endsWith("build.xml")) {
        return file.getFullPath().toString();
      }
    }
    return null;
  }
  
  public String getLabel(Object object)
  {
    if ((object instanceof AntElementNode))
    {
      AntElementNode n = (AntElementNode)object;
      String name = n.getIFile().getName() + ": " + n.getName();
      return name;
    }
    if ((object instanceof File))
    {
      File file = (File)object;
      if (file.getFullPath().toString().endsWith("build.xml")) {
        return "build.xml";
      }
    }
    return "";
  }
  
  public boolean canBeLandmark(String handle)
  {
    if (handle != null) {
      return handle.indexOf(';') == -1;
    }
    return false;
  }
  
  public boolean acceptsObject(Object object)
  {
    if ((object instanceof AntElementNode)) {
      return true;
    }
    if ((object instanceof XmlNodeHelper))
    {
      if (((XmlNodeHelper)object).getFilename().endsWith("build.xml")) {
        return true;
      }
    }
    else if ((object instanceof File))
    {
      File file = (File)object;
      if (file.getFullPath().toString().endsWith("build.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();
      } else {
        return null;
      }
    }
    catch (Exception localException1)
    {
      return null;
    }
    if (markerResource != null) {
      try
      {
        if ((markerResource instanceof IFile))
        {
          IFile file = (IFile)markerResource;
          if (file.getFullPath().toString().endsWith("build.xml")) {
            return file.getFullPath().toString();
          }
          return null;
        }
        return null;
      }
      catch (Throwable t)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.ide.ant", "Could not find element for: " + 
          object, t));
        return null;
      }
    }
    if ((object instanceof IFile)) {
      try
      {
        IFile file = (IFile)object;
        if (file.getFullPath().toString().endsWith("build.xml"))
        {
          FileEditorInput fei = new FileEditorInput(file);
          String content = XmlNodeHelper.getContents(file.getContents());
          IDocument d = new Document(content);
          
          IProblemRequestor p = new AntAnnotationModel(file);
          AntModel am = new AntModel(d, p, new LocationProvider(fei));
          am.reconcile();
          
          AntElementNode node = am.getNode(offset, false);
          
          String path = node.getElementPath();
          if (path == null) {
            return null;
          }
          return new XmlNodeHelper(file.getFullPath().toString(), path).getHandle();
        }
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(2, "org.eclipse.mylyn.ide.ant", 
          "Unable to get handle for offset in object", e));
      }
    }
    return null;
  }
}

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

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.ant.internal.ui.editor.AntEditor;
import org.eclipse.ant.internal.ui.editor.outline.AntEditorContentOutlinePage;
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.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.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IFileEditorInput;
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.ide.IDE;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;

public class AntUiBridge
  extends AbstractContextUiBridge
{
  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(4, "org.eclipse.mylyn.ide.ant", 
          "Unable to open editor for file: " + filename));
        return;
      }
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.ide.ant", "Could not open XML editor", e));
    }
  }
  
  private IEditorPart openInEditor(IFile file, boolean activate)
    throws PartInitException
  {
    if (file != null)
    {
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if ((page != null) && (file.exists())) {
        try
        {
          return IDE.openEditor(page, file, activate);
        }
        catch (Exception localException) {}
      }
    }
    return null;
  }
  
  public void close(IInteractionElement node)
  {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (page != null)
    {
      List<IEditorReference> toClose = new ArrayList();
      IEditorReference[] arrayOfIEditorReference;
      int j = (arrayOfIEditorReference = page.getEditorReferences()).length;
      for (int i = 0; i < j; i++)
      {
        IEditorReference reference = arrayOfIEditorReference[i];
        try
        {
          if ((reference.getEditorInput() instanceof IFileEditorInput))
          {
            IFileEditorInput input = (IFileEditorInput)reference.getEditorInput();
            if (input.getFile().getFullPath().toString().equals(node.getHandleIdentifier())) {
              toClose.add(reference);
            }
          }
        }
        catch (PartInitException localPartInitException) {}
      }
      if (toClose.size() > 0) {
        page.closeEditors((IEditorReference[])toClose.toArray(new IEditorReference[toClose.size()]), true);
      }
    }
  }
  
  public boolean acceptsEditor(IEditorPart editorPart)
  {
    return editorPart instanceof AntEditor;
  }
  
  public List<TreeViewer> getContentOutlineViewers(IEditorPart editor)
  {
    List<TreeViewer> viewers = new ArrayList();
    if ((editor instanceof AntEditor)) {
      try
      {
        AntEditor ae = (AntEditor)editor;
        AntEditorContentOutlinePage outline = (AntEditorContentOutlinePage)ae.getAdapter(IContentOutlinePage.class);
        Class<?> clazz = ContentOutlinePage.class;
        Method method = clazz.getDeclaredMethod("getTreeViewer", new Class[0]);
        method.setAccessible(true);
        viewers.add((TreeViewer)method.invoke(outline, new Object[0]));
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(2, "org.eclipse.mylyn.ide.ant", "Unable to get outline", e));
      }
    }
    return viewers;
  }
  
  public Object getObjectForTextSelection(TextSelection selection, IEditorPart editor)
  {
    return null;
  }
  
  public IInteractionElement getElement(IEditorInput input)
  {
    return null;
  }
  
  public String getContentType()
  {
    return "build.xml";
  }
}

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

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

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

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.ide.ant.AntUiBridgePlugin.AntUiBridgePluginStartup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.ide.ant;

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 AntContextLabelProvider
  extends AbstractContextLabelProvider
{
  public static final String LABEL_RELATION = Messages.AntContextLabelProvider_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("build.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("build.xml");
    return bridge.getLabel(object);
  }
}

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

import java.util.List;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.mylyn.context.ui.IContextUiStartup;
import org.eclipse.mylyn.monitor.ui.MonitorUi;
import org.osgi.framework.BundleContext;

public class AntUiBridgePlugin
  extends Plugin
{
  public static final String ID_PLUGIN = "org.eclipse.mylyn.ide.ant";
  private static AntUiBridgePlugin INSTANCE;
  private AntEditingMonitor antEditingMonitor;
  
  public static class AntUiBridgePluginStartup
    implements IContextUiStartup
  {
    public void lazyStartup()
    {
      AntUiBridgePlugin.getDefault().lazyStart();
    }
  }
  
  public static AntUiBridgePlugin getDefault()
  {
    return INSTANCE;
  }
  
  public AntUiBridgePlugin()
  {
    INSTANCE = this;
  }
  
  private void lazyStart()
  {
    antEditingMonitor = new AntEditingMonitor();
    MonitorUi.getSelectionMonitors().add(antEditingMonitor);
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    if (antEditingMonitor != null) {
      MonitorUi.getSelectionMonitors().remove(antEditingMonitor);
    }
    super.stop(context);
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.ide.ant.messages";
  public static String AntContextLabelProvider_referenced_by;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.ide.ant.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.ide.ant.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