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

16:46:49.431 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.resources.ui_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.resources.ui;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.navigator.CommonNavigator;

class FocusCommonNavigatorAction$1
  implements Runnable
{
  FocusCommonNavigatorAction$1(FocusCommonNavigatorAction paramFocusCommonNavigatorAction, ISelection paramISelection) {}
  
  public void run()
  {
    if (FocusCommonNavigatorAction.access$0(this$0) == null) {
      FocusCommonNavigatorAction.access$2(this$0, (CommonNavigator)FocusCommonNavigatorAction.access$1(this$0));
    }
    if (FocusCommonNavigatorAction.access$0(this$0) != null) {
      FocusCommonNavigatorAction.access$0(this$0).selectReveal(val$toSelect);
    }
  }
}

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

import java.util.Set;
import org.eclipse.core.resources.IResource;
import org.eclipse.mylyn.internal.resources.ui.ResourceInterestUpdater;
import org.eclipse.mylyn.internal.resources.ui.ResourcesUiBridgePlugin;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;

public final class ResourcesUi
{
  public static void addResourceToContext(Set<IResource> resources, InteractionEvent.Kind interactionKind)
  {
    ResourcesUiBridgePlugin.getInterestUpdater().addResourceToContext(resources, interactionKind);
  }
}

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

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.ui.AbstractAutoFocusViewAction;
import org.eclipse.mylyn.context.ui.InterestFilter;
import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.internal.navigator.NavigatorContentService;
import org.eclipse.ui.internal.navigator.actions.LinkEditorAction;
import org.eclipse.ui.internal.navigator.filters.CommonFilterDescriptor;
import org.eclipse.ui.internal.navigator.filters.CommonFilterDescriptorManager;
import org.eclipse.ui.internal.navigator.filters.CoreExpressionFilter;
import org.eclipse.ui.internal.navigator.filters.SelectFiltersAction;
import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ILinkHelper;

public abstract class FocusCommonNavigatorAction
  extends AbstractAutoFocusViewAction
{
  private Object linkService;
  private Method linkServiceMethod;
  private boolean resolveFailed;
  private CommonNavigator commonNavigator;
  private CommonFilterDescriptor[] filterDescriptors;
  private Field filterExpressionField1;
  private Field filterExpressionField2;
  
  public FocusCommonNavigatorAction(InterestFilter interestFilter, boolean manageViewer, boolean manageFilters, boolean manageLinking)
  {
    super(interestFilter, manageViewer, manageFilters, manageLinking);
  }
  
  protected boolean installInterestFilter(StructuredViewer viewer)
  {
    if (commonNavigator == null) {
      commonNavigator = ((CommonNavigator)super.getPartForAction());
    }
    try
    {
      Class<?> clazz2 = CoreExpressionFilter.class;
      filterExpressionField1 = clazz2.getDeclaredField("filterExpression");
      filterExpressionField1.setAccessible(true);
      
      Class<?> clazz1 = CommonFilterDescriptor.class;
      filterExpressionField2 = clazz1.getDeclaredField("filterExpression");
      filterExpressionField2.setAccessible(true);
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
        "Could not determine filter", e));
    }
    filterDescriptors = CommonFilterDescriptorManager.getInstance().findVisibleFilters(
      commonNavigator.getNavigatorContentService());
    
    return super.installInterestFilter(viewer);
  }
  
  protected ISelection resolveSelection(IEditorPart editor, ITextSelection changedSelection, StructuredViewer viewer)
    throws CoreException
  {
    if (resolveFailed) {
      return null;
    }
    if (linkServiceMethod == null) {
      try
      {
        try
        {
          Method method = CommonNavigator.class.getDeclaredMethod("getLinkHelperService", new Class[0]);
          method.setAccessible(true);
          linkService = method.invoke(commonNavigator, new Object[0]);
        }
        catch (NoSuchMethodException localNoSuchMethodException)
        {
          Class<?> clazz = Class.forName("org.eclipse.ui.internal.navigator.extensions.LinkHelperService");
          Constructor<?> constructor = clazz.getConstructor(new Class[] { NavigatorContentService.class });
          linkService = constructor.newInstance(new Object[] {
            (NavigatorContentService)commonNavigator.getCommonViewer().getNavigatorContentService() });
        }
        linkServiceMethod = linkService.getClass().getDeclaredMethod("getLinkHelpersFor", new Class[] { IEditorInput.class });
      }
      catch (Throwable e)
      {
        resolveFailed = true;
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
          "Initialization of LinkHelperService failed", e));
      }
    }
    IEditorInput input = editor.getEditorInput();
    try
    {
      helpers = (ILinkHelper[])linkServiceMethod.invoke(linkService, new Object[] { editor.getEditorInput() });
    }
    catch (Exception localException)
    {
      ILinkHelper[] helpers;
      return null;
    }
    ILinkHelper[] helpers;
    IStructuredSelection selection = StructuredSelection.EMPTY;
    IStructuredSelection newSelection = StructuredSelection.EMPTY;
    ILinkHelper[] arrayOfILinkHelper1;
    int j = (arrayOfILinkHelper1 = helpers).length;
    for (int i = 0; i < j; i++)
    {
      ILinkHelper helper = arrayOfILinkHelper1[i];
      selection = helper.findSelection(input);
      if ((selection != null) && (!selection.isEmpty())) {
        newSelection = mergeSelection(newSelection, selection);
      }
    }
    if (!newSelection.isEmpty()) {
      return newSelection;
    }
    return null;
  }
  
  protected void select(StructuredViewer viewer, final ISelection toSelect)
  {
    Display.getDefault().asyncExec(new Runnable()
    {
      public void run()
      {
        if (commonNavigator == null) {
          commonNavigator = ((CommonNavigator)FocusCommonNavigatorAction.this.getPartForAction());
        }
        if (commonNavigator != null) {
          commonNavigator.selectReveal(toSelect);
        }
      }
    });
  }
  
  protected void setManualFilteringAndLinkingEnabled(boolean on)
  {
    IViewPart part = super.getPartForAction();
    if ((part instanceof CommonNavigator))
    {
      IContributionItem[] arrayOfIContributionItem;
      int j = (arrayOfIContributionItem = ((CommonNavigator)part).getViewSite().getActionBars().getToolBarManager().getItems()).length;
      for (int i = 0; i < j; i++)
      {
        IContributionItem item = arrayOfIContributionItem[i];
        if ((item instanceof ActionContributionItem))
        {
          ActionContributionItem actionItem = (ActionContributionItem)item;
          if ((actionItem.getAction() instanceof LinkEditorAction)) {
            actionItem.getAction().setEnabled(on);
          }
        }
      }
      j = (arrayOfIContributionItem = ((CommonNavigator)part).getViewSite().getActionBars().getMenuManager().getItems()).length;
      for (i = 0; i < j; i++)
      {
        IContributionItem item = arrayOfIContributionItem[i];
        if ((item instanceof ActionContributionItem))
        {
          ActionContributionItem actionItem = (ActionContributionItem)item;
          if ((actionItem.getAction() instanceof SelectFiltersAction)) {
            actionItem.getAction().setEnabled(on);
          }
        }
      }
    }
  }
  
  protected void setDefaultLinkingEnabled(boolean on)
  {
    IViewPart part = super.getPartForAction();
    if ((part instanceof CommonNavigator)) {
      ((CommonNavigator)part).setLinkingEnabled(on);
    }
  }
  
  protected boolean isDefaultLinkingEnabled()
  {
    IViewPart part = super.getPartForAction();
    if ((part instanceof CommonNavigator)) {
      return ((CommonNavigator)part).isLinkingEnabled();
    }
    return false;
  }
  
  protected boolean isPreservedFilter(ViewerFilter filter)
  {
    if ((filter instanceof CoreExpressionFilter))
    {
      CoreExpressionFilter expressionFilter = (CoreExpressionFilter)filter;
      
      Set<String> preservedIds = ContextUiPlugin.getDefault().getPreservedFilterIds(viewPart.getSite().getId());
      if (!preservedIds.isEmpty()) {
        try
        {
          Expression expression2 = (Expression)filterExpressionField1.get(expressionFilter);
          CommonFilterDescriptor[] arrayOfCommonFilterDescriptor;
          int j = (arrayOfCommonFilterDescriptor = filterDescriptors).length;
          for (int i = 0; i < j; i++)
          {
            CommonFilterDescriptor commonFilterDescriptor = arrayOfCommonFilterDescriptor[i];
            if (preservedIds.contains(commonFilterDescriptor.getId()))
            {
              Expression expression1 = (Expression)filterExpressionField2.get(commonFilterDescriptor);
              if ((expression1 != null) && (expression1.equals(expression2))) {
                return true;
              }
            }
          }
        }
        catch (IllegalArgumentException e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
            "Could not determine filter", e));
        }
        catch (IllegalAccessException e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
            "Could not determine filter", e));
        }
      }
    }
    return false;
  }
  
  private IStructuredSelection mergeSelection(IStructuredSelection aBase, IStructuredSelection aSelectionToAppend)
  {
    if ((aBase == null) || (aBase.isEmpty())) {
      return aSelectionToAppend != null ? aSelectionToAppend : StructuredSelection.EMPTY;
    }
    if ((aSelectionToAppend == null) || (aSelectionToAppend.isEmpty())) {
      return aBase;
    }
    List<Object> newItems = new ArrayList(aBase.toList());
    newItems.addAll(aSelectionToAppend.toList());
    return new StructuredSelection(newItems);
  }
}

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

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
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.swt.graphics.Image;

public class ResourceContextLabelProvider
  extends AbstractContextLabelProvider
{
  public Image getImage(IInteractionElement node)
  {
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge("resource");
    Object object = bridge.getObjectForHandle(node.getHandleIdentifier());
    return getImageForObject(object);
  }
  
  protected Image getImageForObject(Object object)
  {
    if ((object instanceof IFile)) {
      return CommonImages.getImage(ContextUiImages.FILE_GENERIC);
    }
    if ((object instanceof IContainer)) {
      return CommonImages.getImage(ContextUiImages.FOLDER_GENERIC);
    }
    return null;
  }
  
  protected String getTextForObject(Object object)
  {
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(object);
    return bridge.getLabel(object);
  }
  
  public String getText(IInteractionElement node)
  {
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge("resource");
    return bridge.getLabel(bridge.getObjectForHandle(node.getHandleIdentifier()));
  }
  
  protected Image getImage(IInteractionRelation edge)
  {
    return null;
  }
  
  protected String getText(IInteractionRelation edge)
  {
    return null;
  }
}

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

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.eclipse.core.internal.resources.Marker;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
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.IInteractionContext;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.ui.views.markers.internal.ConcreteMarker;

public class ResourceStructureBridge
  extends AbstractContextStructureBridge
{
  public static final String CONTENT_TYPE = "resource";
  
  public String getContentType()
  {
    return "resource";
  }
  
  public String getParentHandle(String handle, boolean allowChildBridgeHandles)
  {
    if (allowChildBridgeHandles) {
      return getParentHandle(handle);
    }
    IResource resource = (IResource)getObjectForHandle(handle);
    if (resource != null)
    {
      IContainer parent = resource.getParent();
      return getHandleIdentifier(parent);
    }
    return null;
  }
  
  public String getParentHandle(String handle)
  {
    IResource resource = (IResource)getObjectForHandle(handle);
    if (resource != null)
    {
      IContainer parent = resource.getParent();
      if ((resource instanceof IFile)) {
        for (String contentType : ContextCore.getChildContentTypes("resource"))
        {
          AbstractContextStructureBridge parentBridge = ContextCore.getStructureBridge(contentType);
          Object adaptedParent = parentBridge.getAdaptedParent(resource);
          if (adaptedParent != null) {
            return parentBridge.getHandleIdentifier(adaptedParent);
          }
        }
      }
      return getHandleIdentifier(parent);
    }
    return null;
  }
  
  public List<String> getChildHandles(String handle)
  {
    Object object = getObjectForHandle(handle);
    if ((object instanceof IResource))
    {
      IResource resource = (IResource)object;
      if ((resource instanceof IContainer))
      {
        IContainer container = (IContainer)resource;
        try
        {
          if (!container.isAccessible()) {
            break label143;
          }
          IResource[] children = container.members();
          List<String> childHandles = new ArrayList();
          IResource[] arrayOfIResource1;
          int j = (arrayOfIResource1 = children).length;
          for (int i = 0; i < j; i++)
          {
            IResource element = arrayOfIResource1[i];
            String childHandle = getHandleIdentifier(element);
            if (childHandle != null) {
              childHandles.add(childHandle);
            }
          }
          return childHandles;
        }
        catch (Exception e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", "Could not get child", 
            e));
        }
      }
      else
      {
        (resource instanceof IFile);
      }
    }
    label143:
    return Collections.emptyList();
  }
  
  public String getHandleIdentifier(Object object)
  {
    if ((object instanceof IProject))
    {
      String path = ((IResource)object).getFullPath().toPortableString();
      String javaCoreStylePath = "=" + path.substring(1);
      return javaCoreStylePath;
    }
    if ((object instanceof IResource)) {
      return ((IResource)object).getFullPath().toPortableString();
    }
    if ((object instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)object;
      Object adapter = adaptable.getAdapter(IResource.class);
      if ((adapter instanceof IResource)) {
        return ((IResource)adapter).getFullPath().toPortableString();
      }
    }
    return null;
  }
  
  public Object getObjectForHandle(String handle)
  {
    if (handle == null) {
      return null;
    }
    IPath path = new Path(handle);
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    if (path.segmentCount() == 1)
    {
      String projectName = handle.substring(1);
      try
      {
        return workspace.getRoot().getProject(projectName);
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        return null;
      }
    }
    if (path.segmentCount() > 1) {
      return workspace.getRoot().findMember(path);
    }
    return null;
  }
  
  public String getLabel(Object object)
  {
    if ((object instanceof IResource)) {
      return ((IResource)object).getName();
    }
    return "";
  }
  
  public boolean canBeLandmark(String handle)
  {
    Object element = getObjectForHandle(handle);
    return element instanceof IFile;
  }
  
  public boolean acceptsObject(Object object)
  {
    if ((object instanceof IResource)) {
      return true;
    }
    if ((object instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)object;
      Object adapter = adaptable.getAdapter(IResource.class);
      if ((adapter instanceof IResource)) {
        return true;
      }
    }
    return false;
  }
  
  public boolean canFilter(Object element)
  {
    return true;
  }
  
  public boolean isDocument(String handle)
  {
    return getObjectForHandle(handle) instanceof IFile;
  }
  
  public String getHandleForOffsetInObject(Object object, int offset)
  {
    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 localException)
    {
      return null;
    }
    try
    {
      if ((markerResource instanceof IFile))
      {
        IFile file = (IFile)markerResource;
        return getHandleIdentifier(file);
      }
      return null;
    }
    catch (Throwable t)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
        "Could not find element for: \"" + object + "\"", t));
    }
    return null;
  }
  
  public String getContentType(String elementHandle)
  {
    return getContentType();
  }
  
  public Set<IProject> getProjectsInActiveContext()
  {
    IInteractionContext activeContext = ContextCore.getContextManager().getActiveContext();
    List<IInteractionElement> allElements = activeContext.getAllElements();
    Set<IProject> projectsInContext = new HashSet();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    List<IProject> projectsInWorkspace = new LinkedList();
    IProject[] arrayOfIProject;
    int j = (arrayOfIProject = workspace.getRoot().getProjects()).length;
    for (int i = 0; i < j; i++)
    {
      IProject p = arrayOfIProject[i];
      if (p.exists()) {
        projectsInWorkspace.add(p);
      }
    }
    for (IInteractionElement element : allElements)
    {
      String handle = element.getHandleIdentifier();
      Object path = new Path(handle);
      if ((((IPath)path).segmentCount() == 1) && (((IPath)path).isValidPath(handle)))
      {
        String projectName = handle.substring(1);
        IProject project = workspace.getRoot().getProject(projectName);
        if (projectsInWorkspace.contains(project)) {
          projectsInContext.add(project);
        }
      }
    }
    return projectsInContext;
  }
}

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

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

public class ResourcesUiBridgePlugin$ResourcesUiBridgeStartup
  implements IContextUiStartup
{
  public void lazyStartup()
  {
    ResourcesUiBridgePlugin.getDefault().lazyStart();
  }
}

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

import java.util.Set;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;

class ResourceInterestUpdater$1
  implements Runnable
{
  ResourceInterestUpdater$1(ResourceInterestUpdater paramResourceInterestUpdater, Set paramSet, InteractionEvent.Kind paramKind) {}
  
  public void run()
  {
    ResourceInterestUpdater.access$0(this$0, val$resources, val$interactionKind);
  }
}

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

import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.monitor.ui.AbstractUserInteractionMonitor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.part.EditorPart;

public class ResourceInteractionMonitor
  extends AbstractUserInteractionMonitor
{
  private static final String ID_SYNCHRONIZE_VIEW = "org.eclipse.team.sync.views.SynchronizeView";
  
  protected void handleWorkbenchPartSelection(IWorkbenchPart part, ISelection selection, boolean contributeToContext)
  {
    if ("org.eclipse.team.sync.views.SynchronizeView".equals(part.getSite().getId())) {
      return;
    }
    if ((selection instanceof StructuredSelection))
    {
      StructuredSelection structuredSelection = (StructuredSelection)selection;
      for (Iterator<?> iterator = structuredSelection.iterator(); iterator.hasNext();)
      {
        Object selectedObject = iterator.next();
        if ((selectedObject instanceof IResource))
        {
          IResource resource = (IResource)selectedObject;
          super.handleElementSelection(part, resource, contributeToContext);
        }
      }
    }
    else if (((selection instanceof TextSelection)) && 
      ((part instanceof EditorPart)))
    {
      try
      {
        Object object = ((EditorPart)part).getEditorInput().getAdapter(IResource.class);
        if ((object instanceof IFile))
        {
          IFile file = (IFile)object;
          if ((file.getFileExtension() != null) && 
            (!ContextCore.getContentTypes().contains(file.getFileExtension()))) {
            super.handleElementEdit(part, object, contributeToContext);
          }
        }
      }
      catch (Throwable t)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
          "Failed to resolve resource edit", t));
      }
    }
  }
}

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

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
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.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.context.ui.AbstractContextUiBridge;
import org.eclipse.ui.IEditorDescriptor;
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.ide.IDE;

public class ResourceUiBridge
  extends AbstractContextUiBridge
{
  public void open(IInteractionElement element)
  {
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(element.getContentType());
    if (bridge == null) {
      return;
    }
    IResource resource = (IResource)bridge.getObjectForHandle(element.getHandleIdentifier());
    if (((resource instanceof IFile)) && (resource.exists())) {
      internalOpenEditor((IFile)resource, true);
    }
  }
  
  private void internalOpenEditor(IFile file, boolean activate)
  {
    try
    {
      IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      IEditorDescriptor editorDescriptor = IDE.getDefaultEditor(file);
      if ((editorDescriptor != null) && (editorDescriptor.isInternal()) && (!editorDescriptor.isOpenInPlace()) && 
        (!isContextIgnoring(editorDescriptor))) {
        IDE.openEditor(activePage, file, activate);
      }
    }
    catch (PartInitException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
        "Failed to open editor for: \"" + file + "\"", e));
    }
  }
  
  private boolean isContextIgnoring(IEditorDescriptor editorDescriptor)
  {
    if ((editorDescriptor.getId() != null) && (editorDescriptor.getId().endsWith(".contextIgnoring"))) {
      return true;
    }
    return false;
  }
  
  public void close(IInteractionElement element)
  {
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(element.getContentType());
    Object object = bridge.getObjectForHandle(element.getHandleIdentifier());
    if ((object instanceof IFile))
    {
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if (page != null)
      {
        List<IEditorReference> toClose = new ArrayList(0);
        IEditorReference[] arrayOfIEditorReference;
        int j = (arrayOfIEditorReference = page.getEditorReferences()).length;
        for (int i = 0; i < j; i++)
        {
          IEditorReference reference = arrayOfIEditorReference[i];
          try
          {
            IResource input = (IResource)reference.getEditorInput().getAdapter(IResource.class);
            if (((input instanceof IFile)) && (((IFile)input).equals(object))) {
              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 false;
  }
  
  public List<TreeViewer> getContentOutlineViewers(IEditorPart editor)
  {
    return Collections.emptyList();
  }
  
  public Object getObjectForTextSelection(TextSelection selection, IEditorPart editor)
  {
    return null;
  }
  
  public IInteractionElement getElement(IEditorInput input)
  {
    Object adapter = input.getAdapter(IResource.class);
    if ((adapter instanceof IFile))
    {
      IFile javaElement = (IFile)adapter;
      String handle = ContextCore.getStructureBridge(javaElement).getHandleIdentifier(javaElement);
      return ContextCore.getContextManager().getElement(handle);
    }
    return null;
  }
  
  public String getContentType()
  {
    return "resource";
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContext;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.context.ui.IContextUiStartup;
import org.eclipse.mylyn.monitor.ui.MonitorUi;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class ResourcesUiBridgePlugin
  extends AbstractUIPlugin
{
  public static final String ID_PLUGIN = "org.eclipse.mylyn.resources.ui";
  private static ResourcesUiBridgePlugin INSTANCE;
  private ResourceChangeMonitor resourceChangeMonitor;
  private ResourceInteractionMonitor resourceInteractionMonitor;
  private EditorInteractionMonitor interestEditorTracker;
  private ResourceInterestUpdater interestUpdater;
  
  public static class ResourcesUiBridgeStartup
    implements IContextUiStartup
  {
    public void lazyStartup()
    {
      ResourcesUiBridgePlugin.getDefault().lazyStart();
    }
  }
  
  private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener()
  {
    public void propertyChange(PropertyChangeEvent event)
    {
      ResourcesUiBridgePlugin.this.updateResourceMonitorEnablement();
    }
  };
  private boolean started;
  
  public ResourcesUiBridgePlugin()
  {
    INSTANCE = this;
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    interestUpdater = new ResourceInterestUpdater();
  }
  
  protected void lazyStart()
  {
    resourceChangeMonitor = new ResourceChangeMonitor();
    updateResourceMonitorEnablement();
    getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
    
    resourceInteractionMonitor = new ResourceInteractionMonitor();
    interestEditorTracker = new EditorInteractionMonitor();
    
    MonitorUi.getSelectionMonitors().add(resourceInteractionMonitor);
    
    ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeMonitor, 
      1);
    
    interestEditorTracker.install(PlatformUI.getWorkbench());
    
    started = true;
  }
  
  protected void lazyStop()
  {
    getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
    if (resourceChangeMonitor != null) {
      ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeMonitor);
    }
    if (resourceInteractionMonitor != null)
    {
      MonitorUi.getSelectionMonitors().remove(resourceInteractionMonitor);
      resourceChangeMonitor.dispose();
    }
    if (interestEditorTracker != null) {
      interestEditorTracker.dispose(PlatformUI.getWorkbench());
    }
    started = false;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    lazyStop();
    
    super.stop(context);
    INSTANCE = null;
  }
  
  public List<IResource> getInterestingResources(IInteractionContext context)
  {
    List<IResource> interestingResources = new ArrayList();
    Collection<IInteractionElement> resourceElements = ContextCore.getContextManager().getActiveDocuments(context);
    for (IInteractionElement element : resourceElements)
    {
      IResource resource = getResourceForElement(element, false);
      if (resource != null) {
        interestingResources.add(resource);
      }
    }
    return interestingResources;
  }
  
  public static ResourceInterestUpdater getInterestUpdater()
  {
    return INSTANCEinterestUpdater;
  }
  
  public IResource getResourceForElement(IInteractionElement element, boolean findContainingResource)
  {
    if (element == null) {
      return null;
    }
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(element.getContentType());
    Object object = bridge.getObjectForHandle(element.getHandleIdentifier());
    if ((object instanceof IResource)) {
      return (IResource)object;
    }
    if ((object instanceof IAdaptable))
    {
      Object adapted = ((IAdaptable)object).getAdapter(IResource.class);
      if ((adapted instanceof IResource)) {
        return (IResource)adapted;
      }
    }
    if (findContainingResource)
    {
      String parentHandle = bridge.getParentHandle(element.getHandleIdentifier());
      if (element.getHandleIdentifier().equals(parentHandle)) {
        return null;
      }
      return getResourceForElement(ContextCore.getContextManager().getElement(parentHandle), true);
    }
    return null;
  }
  
  public void setResourceMonitoringEnabled(boolean enabled)
  {
    resourceChangeMonitor.setEnabled(enabled);
  }
  
  public static ResourcesUiBridgePlugin getDefault()
  {
    return INSTANCE;
  }
  
  @Deprecated
  public ResourceBundle getResourceBundle()
  {
    return null;
  }
  
  private void updateResourceMonitorEnablement()
  {
    resourceChangeMonitor.setEnabled(getPreferenceStore().getBoolean(
      "org.eclipse.mylyn.ide.resources.resource.monitor.enabled"));
  }
  
  public boolean isStarted()
  {
    return started;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.compare.internal.CompareEditor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IDegreeOfInterest;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.context.ui.AbstractContextUiBridge;
import org.eclipse.mylyn.context.ui.ContextUi;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;
import org.eclipse.mylyn.monitor.ui.AbstractEditorTracker;
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.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

public class EditorInteractionMonitor
  extends AbstractEditorTracker
{
  public static final String SOURCE_ID = "org.eclipse.mylyn.resources.ui.editor.tracker.interest";
  
  protected void editorBroughtToTop(IEditorPart part)
  {
    Object object = part.getEditorInput().getAdapter(IResource.class);
    if ((object instanceof IResource))
    {
      IResource resource = (IResource)object;
      AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(resource);
      InteractionEvent selectionEvent = new InteractionEvent(InteractionEvent.Kind.SELECTION, 
        bridge.getContentType(), bridge.getHandleIdentifier(resource), part.getSite().getId());
      ContextCore.getContextManager().processInteractionEvent(selectionEvent);
    }
  }
  
  public void editorOpened(IEditorPart editorPartOpened)
  {
    if ((!ContextUi.isEditorAutoManageEnabled()) || (ContextCore.getContextManager().isContextCapturePaused())) {
      return;
    }
    IWorkbenchPage page = editorPartOpened.getSite().getPage();
    List<IEditorReference> toClose = new ArrayList();
    IEditorReference[] arrayOfIEditorReference;
    int j = (arrayOfIEditorReference = page.getEditorReferences()).length;
    for (int i = 0; i < j; i++)
    {
      IEditorReference editorReference = arrayOfIEditorReference[i];
      try
      {
        IInteractionElement element = null;
        
        Object adapter = editorReference.getEditorInput().getAdapter(IResource.class);
        if ((adapter instanceof IFile))
        {
          String handle = ContextCore.getStructureBridge(adapter).getHandleIdentifier(adapter);
          element = ContextCore.getContextManager().getElement(handle);
        }
        if ((element != null) && (!element.getInterest().isInteresting()) && 
          (!isSameEditor(editorPartOpened, editorReference))) {
          toClose.add(editorReference);
        }
      }
      catch (PartInitException localPartInitException) {}
    }
    if (toClose.size() > 0) {
      page.closeEditors((IEditorReference[])toClose.toArray(new IEditorReference[toClose.size()]), true);
    }
  }
  
  private boolean isSameEditor(IEditorPart editorPart1, IEditorReference editorReference2)
    throws PartInitException
  {
    if ((editorPart1 == null) || (editorReference2 == null)) {
      return false;
    }
    return editorPart1.getEditorInput().equals(editorReference2.getEditorInput());
  }
  
  public void editorClosed(IEditorPart editorPart)
  {
    if (PlatformUI.getWorkbench().isClosing()) {
      return;
    }
    if ((ContextUi.isEditorAutoCloseEnabled()) && (!otherEditorsOpenForResource(editorPart)) && 
      (!(editorPart instanceof CompareEditor)))
    {
      IInteractionElement element = null;
      AbstractContextUiBridge uiBridge = ContextUi.getUiBridgeForEditor(editorPart);
      Object object = uiBridge.getObjectForTextSelection(null, editorPart);
      if (objec
1 2 3

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