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

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

import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;

class AbstractAutoFocusViewAction$2
  implements Runnable
{
  AbstractAutoFocusViewAction$2(AbstractAutoFocusViewAction paramAbstractAutoFocusViewAction) {}
  
  public void run()
  {
    try
    {
      if (ContextCore.getContextManager().isContextActive()) {
        if (ContextUiPlugin.getDefault().getPreferenceStore().getBoolean("org.eclipse.mylyn.context.ui.navigators.filter.auto.enable"))
        {
          this$0.internalSuppressExpandAll = true;
          this$0.update(true);
        }
      }
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
        "Could not toggle focus action on view: " + this$0.getPartForAction(), e));
    }
  }
}

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

import java.util.List;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.AbstractContextListener;
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.internal.context.ui.ContextUiPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public abstract class AbstractAutoFocusViewAction
  extends AbstractFocusViewAction
{
  private boolean initialized = false;
  private final AbstractContextListener CONTEXT_LISTENER = new AbstractContextListener()
  {
    public void contextActivated(IInteractionContext context)
    {
      if ((ContextUiPlugin.getDefault().getPreferenceStore().getBoolean("org.eclipse.mylyn.context.ui.navigators.filter.auto.enable")) && 
        (context.getAllElements().size() > 0))
      {
        AbstractAutoFocusViewAction.access$0(AbstractAutoFocusViewAction.this, true);
        AbstractAutoFocusViewAction.this.update(true);
      }
      else
      {
        AbstractAutoFocusViewAction.access$0(AbstractAutoFocusViewAction.this, true);
        AbstractAutoFocusViewAction.this.update(false);
      }
    }
  };
  
  public AbstractAutoFocusViewAction(InterestFilter interestFilter, boolean manageViewer, boolean manageFilters, boolean manageLinking)
  {
    super(interestFilter, manageViewer, manageFilters, manageLinking);
    showEmptyViewMessage = true;
    ContextCore.getContextManager().addListener(CONTEXT_LISTENER);
  }
  
  public void dispose()
  {
    super.dispose();
    ContextCore.getContextManager().removeListener(CONTEXT_LISTENER);
  }
  
  public void init(IViewPart view)
  {
    super.init(view);
    configureAction();
  }
  
  public void init(IAction action)
  {
    super.init(action);
    configureAction();
  }
  
  private void configureAction()
  {
    if (initialized) {
      return;
    }
    initialized = true;
    
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
    {
      public void run()
      {
        try
        {
          if (ContextCore.getContextManager().isContextActive()) {
            if (ContextUiPlugin.getDefault().getPreferenceStore().getBoolean("org.eclipse.mylyn.context.ui.navigators.filter.auto.enable"))
            {
              internalSuppressExpandAll = true;
              update(true);
            }
          }
        }
        catch (Exception e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
            "Could not toggle focus action on view: " + getPartForAction(), e));
        }
      }
    });
  }
}

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

public abstract class ContextAwareEditorInput
{
  public abstract boolean forceClose(String paramString);
}

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

public abstract interface IContextAwareEditor
{
  public abstract boolean canClose();
}

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

import org.eclipse.mylyn.context.core.AbstractContextListener;
import org.eclipse.mylyn.context.core.ContextChangeEvent;

class AbstractFocusViewAction$1
  extends AbstractContextListener
{
  AbstractFocusViewAction$1(AbstractFocusViewAction paramAbstractFocusViewAction) {}
  
  public void contextChanged(ContextChangeEvent event)
  {
    switch (event.getEventKind())
    {
    case CLEARED: 
      if (this$0.updateEnablementWithContextActivation()) {
        this$0.updateEnablement(this$0.initAction);
      }
      break;
    case DEACTIVATED: 
      if (this$0.updateEnablementWithContextActivation())
      {
        this$0.updateEnablement(this$0.initAction);
        this$0.update(false);
      }
      break;
    }
  }
}

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

public abstract interface IContextUiStartup
{
  public abstract void lazyStartup();
}

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

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.context.core.AbstractContextListener;
import org.eclipse.mylyn.context.core.ContextChangeEvent;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.context.ui.ContextUiImages;
import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
import org.eclipse.mylyn.internal.context.ui.FocusedViewerManager;
import org.eclipse.mylyn.internal.context.ui.Messages;
import org.eclipse.mylyn.monitor.ui.MonitorUi;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IActionDelegate2;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;

public abstract class AbstractFocusViewAction
  extends Action
  implements IViewActionDelegate, IActionDelegate2, ISelectionListener
{
  public static final String PREF_ID_PREFIX = "org.eclipse.mylyn.ui.interest.filter.";
  private static Map<IViewPart, AbstractFocusViewAction> partMap = new WeakHashMap();
  protected String globalPrefId;
  protected IAction initAction = null;
  protected final InterestFilter interestFilter;
  protected IViewPart viewPart;
  protected Map<StructuredViewer, List<ViewerFilter>> previousFilters = new WeakHashMap();
  private final boolean manageViewer;
  private final boolean manageFilters;
  private final boolean manageLinking;
  private boolean wasLinkingEnabled = false;
  private boolean wasRun = false;
  private Set<String> cachedPreservedFilters;
  @Deprecated
  protected boolean internalSuppressExpandAll = false;
  protected boolean showEmptyViewMessage = false;
  private final Map<StructuredViewer, EmptyContextDrawer> viewerToDrawerMap = new HashMap();
  
  private class EmptyContextDrawer
    implements Listener
  {
    private final String LABEL = getEmptyViewMessage();
    private final Image IMAGE = CommonImages.getImage(ContextUiImages.CONTEXT_FOCUS);
    private final Tree tree;
    
    EmptyContextDrawer(Tree tree)
    {
      this.tree = tree;
    }
    
    public void handleEvent(Event event)
    {
      if ((tree != null) && (tree.getItemCount() == 0)) {
        switch (type)
        {
        case 9: 
          int offset = 7;
          gc.drawImage(IMAGE, offset, offset);
          gc.drawText(LABEL, offset + IMAGE.getBounds().width + 5, offset);
        }
      }
    }
  }
  
  private final AbstractContextListener CONTEXT_LISTENER = new AbstractContextListener()
  {
    public void contextChanged(ContextChangeEvent event)
    {
      switch (event.getEventKind())
      {
      case CLEARED: 
        if (updateEnablementWithContextActivation()) {
          updateEnablement(initAction);
        }
        break;
      case DEACTIVATED: 
        if (updateEnablementWithContextActivation())
        {
          updateEnablement(initAction);
          update(false);
        }
        break;
      }
    }
  };
  private final IWorkbenchListener WORKBENCH_LISTENER = new IWorkbenchListener()
  {
    public boolean preShutdown(IWorkbench workbench, boolean forced)
    {
      if ((wasRun) && (manageLinking)) {
        setDefaultLinkingEnabled(wasLinkingEnabled);
      }
      List<StructuredViewer> viewers = getViewers();
      Set<String> excludedFilters = AbstractFocusViewAction.this.getPreservedFilterClasses(false);
      for (StructuredViewer viewer : viewers) {
        if (previousFilters.containsKey(viewer))
        {
          for (ViewerFilter filter : (List)previousFilters.get(viewer)) {
            if (!excludedFilters.contains(filter.getClass().getName())) {
              try
              {
                viewer.addFilter(filter);
              }
              catch (Throwable t)
              {
                StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
                  "Failed to restore filter: " + filter, t));
              }
            }
          }
          previousFilters.remove(viewer);
        }
      }
      return true;
    }
    
    public void postShutdown(IWorkbench workbench) {}
  };
  
  public static AbstractFocusViewAction getActionForPart(IViewPart part)
  {
    return (AbstractFocusViewAction)partMap.get(part);
  }
  
  public IViewPart getPartForAction()
  {
    if (viewPart == null) {
      if ((this instanceof IWorkbenchWindowActionDelegate)) {
        PlatformUI.getWorkbench().isClosing();
      } else {
        throw new RuntimeException("error: viewPart is null");
      }
    }
    return viewPart;
  }
  
  public AbstractFocusViewAction(InterestFilter interestFilter, boolean manageViewer, boolean manageFilters, boolean manageLinking)
  {
    this.interestFilter = interestFilter;
    this.manageViewer = manageViewer;
    this.manageFilters = manageFilters;
    this.manageLinking = manageLinking;
    setText(Messages.AbstractFocusViewAction_Apply_Mylyn);
    setToolTipText(Messages.AbstractFocusViewAction_Apply_Mylyn);
    setImageDescriptor(ContextUiImages.CONTEXT_FOCUS);
    PlatformUI.getWorkbench().addWorkbenchListener(WORKBENCH_LISTENER);
    ContextCore.getContextManager().addListener(CONTEXT_LISTENER);
  }
  
  public void dispose()
  {
    partMap.remove(getPartForAction());
    if ((viewPart != null) && (!PlatformUI.getWorkbench().isClosing())) {
      for (StructuredViewer viewer : getViewers()) {
        ContextUiPlugin.getViewerManager().removeManagedViewer(viewer, viewPart);
      }
    }
    MonitorUi.removeWindowPostSelectionListener(this);
    ContextCore.getContextManager().removeListener(CONTEXT_LISTENER);
    PlatformUI.getWorkbench().removeWorkbenchListener(WORKBENCH_LISTENER);
  }
  
  public void init(IAction action)
  {
    initAction = action;
    initAction.setChecked(action.isChecked());
  }
  
  public void init(IViewPart view)
  {
    String id = view.getSite().getId();
    globalPrefId = ("org.eclipse.mylyn.ui.interest.filter." + id);
    viewPart = view;
    partMap.put(view, this);
    wasLinkingEnabled = isDefaultLinkingEnabled();
  }
  
  protected boolean updateEnablementWithContextActivation()
  {
    return true;
  }
  
  public void run(IAction action)
  {
    setChecked(action.isChecked());
    valueChanged(action, action.isChecked(), true);
    wasRun = true;
  }
  
  public void runWithEvent(IAction action, Event event)
  {
    run(action);
  }
  
  public void update()
  {
    if (globalPrefId != null) {
      update(ContextUiPlugin.getDefault().getPreferenceStore().getBoolean(globalPrefId));
    }
  }
  
  public void update(boolean on)
  {
    valueChanged(initAction, on, false);
    updateEnablement(initAction);
  }
  
  /* Error */
  protected void valueChanged(IAction action, boolean on, boolean store)
  {
    // Byte code:
    //   0: invokestatic 569	org/eclipse/ui/PlatformUI:getWorkbench	()Lorg/eclipse/ui/IWorkbench;
    //   3: invokeinterface 597 1 0
    //   8: ifeq +4 -> 12
    //   11: return
    //   12: invokestatic 525	org/eclipse/mylyn/context/core/ContextCore:getContextManager	()Lorg/eclipse/mylyn/context/core/IInteractionContextManager;
    //   15: invokeinterface 592 1 0
    //   20: istore 4
    //   22: iload 4
    //   24: ifne +12 -> 36
    //   27: invokestatic 525	org/eclipse/mylyn/context/core/ContextCore:getContextManager	()Lorg/eclipse/mylyn/context/core/IInteractionContextManager;
    //   30: iconst_1
    //   31: invokeinterface 593 2 0
    //   36: aload_0
    //   37: iload_2
    //   38: invokevirtual 528	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:setChecked	(Z)V
    //   41: aload_1
    //   42: ifnull +10 -> 52
    //   45: aload_1
    //   46: iload_2
    //   47: invokeinterface 587 2 0
    //   52: iload_3
    //   53: ifeq +25 -> 78
    //   56: invokestatic 554	org/eclipse/mylyn/internal/context/core/ContextCorePlugin:getDefault	()Lorg/eclipse/mylyn/internal/context/core/ContextCorePlugin;
    //   59: ifnull +19 -> 78
    //   62: invokestatic 556	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getDefault	()Lorg/eclipse/mylyn/internal/context/ui/ContextUiPlugin;
    //   65: invokevirtual 555	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getPreferenceStore	()Lorg/eclipse/jface/preference/IPreferenceStore;
    //   68: aload_0
    //   69: getfield 486	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:globalPrefId	Ljava/lang/String;
    //   72: iload_2
    //   73: invokeinterface 590 3 0
    //   78: aload_0
    //   79: invokevirtual 535	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:getViewers	()Ljava/util/List;
    //   82: astore 5
    //   84: aload 5
    //   86: invokeinterface 575 1 0
    //   91: astore 7
    //   93: goto +59 -> 152
    //   96: aload 7
    //   98: invokeinterface 572 1 0
    //   103: checkcast 239	org/eclipse/jface/viewers/StructuredViewer
    //   106: astore 6
    //   108: aload_0
    //   109: getfield 494	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:viewPart	Lorg/eclipse/ui/IViewPart;
    //   112: ifnull +33 -> 145
    //   115: aload 6
    //   117: invokevirtual 521	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   120: invokevirtual 565	org/eclipse/swt/widgets/Control:isDisposed	()Z
    //   123: ifne +22 -> 145
    //   126: aload_0
    //   127: getfield 482	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:manageViewer	Z
    //   130: ifeq +15 -> 145
    //   133: invokestatic 557	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getViewerManager	()Lorg/eclipse/mylyn/internal/context/ui/FocusedViewerManager;
    //   136: aload 6
    //   138: aload_0
    //   139: getfield 494	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:viewPart	Lorg/eclipse/ui/IViewPart;
    //   142: invokevirtual 561	org/eclipse/mylyn/internal/context/ui/FocusedViewerManager:addManagedViewer	(Lorg/eclipse/jface/viewers/StructuredViewer;Lorg/eclipse/ui/IWorkbenchPart;)V
    //   145: aload_0
    //   146: iload_2
    //   147: aload 6
    //   149: invokevirtual 544	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:updateInterestFilter	(ZLorg/eclipse/jface/viewers/StructuredViewer;)V
    //   152: aload 7
    //   154: invokeinterface 571 1 0
    //   159: ifne -63 -> 96
    //   162: aload_0
    //   163: iload_2
    //   164: ifeq +7 -> 171
    //   167: iconst_0
    //   168: goto +4 -> 172
    //   171: iconst_1
    //   172: invokevirtual 530	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:setManualFilteringAndLinkingEnabled	(Z)V
    //   175: aload_0
    //   176: getfield 481	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:manageLinking	Z
    //   179: ifeq +85 -> 264
    //   182: aload_0
    //   183: iload_2
    //   184: invokespecial 532	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:updateLinking	(Z)V
    //   187: goto +77 -> 264
    //   190: astore 5
    //   192: new 234	org/eclipse/core/runtime/Status
    //   195: dup
    //   196: iconst_4
    //   197: ldc_w 216
    //   200: new 222	java/lang/StringBuilder
    //   203: dup
    //   204: ldc_w 212
    //   207: invokespecial 505	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   210: aload_0
    //   211: getfield 486	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:globalPrefId	Ljava/lang/String;
    //   214: invokevirtual 506	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   217: invokevirtual 504	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   220: aload 5
    //   222: invokespecial 513	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   225: invokestatic 524	org/eclipse/mylyn/commons/core/StatusHandler:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   228: iload 4
    //   230: ifne +48 -> 278
    //   233: invokestatic 525	org/eclipse/mylyn/context/core/ContextCore:getContextManager	()Lorg/eclipse/mylyn/context/core/IInteractionContextManager;
    //   236: iconst_0
    //   237: invokeinterface 593 2 0
    //   242: goto +36 -> 278
    //   245: astore 8
    //   247: iload 4
    //   249: ifne +12 -> 261
    //   252: invokestatic 525	org/eclipse/mylyn/context/core/ContextCore:getContextManager	()Lorg/eclipse/mylyn/context/core/IInteractionContextManager;
    //   255: iconst_0
    //   256: invokeinterface 593 2 0
    //   261: aload 8
    //   263: athrow
    //   264: iload 4
    //   266: ifne +12 -> 278
    //   269: invokestatic 525	org/eclipse/mylyn/context/core/ContextCore:getContextManager	()Lorg/eclipse/mylyn/context/core/IInteractionContextManager;
    //   272: iconst_0
    //   273: invokeinterface 593 2 0
    //   278: return
    // Line number table:
    //   Java source line #280	-> byte code offset #0
    //   Java source line #281	-> byte code offset #11
    //   Java source line #284	-> byte code offset #12
    //   Java source line #286	-> byte code offset #22
    //   Java source line #287	-> byte code offset #27
    //   Java source line #289	-> byte code offset #36
    //   Java source line #290	-> byte code offset #41
    //   Java source line #291	-> byte code offset #45
    //   Java source line #293	-> byte code offset #52
    //   Java source line #294	-> byte code offset #62
    //   Java source line #297	-> byte code offset #78
    //   Java source line #298	-> byte code offset #84
    //   Java source line #299	-> byte code offset #108
    //   Java source line #300	-> byte code offset #133
    //   Java source line #302	-> byte code offset #145
    //   Java source line #298	-> byte code offset #152
    //   Java source line #305	-> byte code offset #162
    //   Java source line #306	-> byte code offset #175
    //   Java source line #307	-> byte code offset #182
    //   Java source line #309	-> byte code offset #190
    //   Java source line #310	-> byte code offset #192
    //   Java source line #311	-> byte code offset #200
    //   Java source line #310	-> byte code offset #222
    //   Java source line #313	-> byte code offset #228
    //   Java source line #314	-> byte code offset #233
    //   Java source line #312	-> byte code offset #245
    //   Java source line #313	-> byte code offset #247
    //   Java source line #314	-> byte code offset #252
    //   Java source line #316	-> byte code offset #261
    //   Java source line #313	-> byte code offset #264
    //   Java source line #314	-> byte code offset #269
    //   Java source line #317	-> byte code offset #278
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	279	0	this	AbstractFocusViewAction
    //   0	279	1	action	IAction
    //   0	279	2	on	boolean
    //   0	279	3	store	boolean
    //   20	245	4	wasPaused	boolean
    //   82	3	5	viewers	List<StructuredViewer>
    //   190	31	5	t	Throwable
    //   106	42	6	viewer	StructuredViewer
    //   91	62	7	localIterator	java.util.Iterator
    //   245	17	8	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   22	187	190	java/lang/Throwable
    //   22	228	245	finally
  }
  
  protected void updateEnablement(IAction action)
  {
    if ((updateEnablementWithContextActivation()) && 
      (action != null)) {
      action.setEnabled(ContextCore.getContextManager().isContextActivePropertySet());
    }
  }
  
  private void updateLinking(boolean on)
  {
    if (on)
    {
      wasLinkingEnabled = isDefaultLinkingEnabled();
      MonitorUi.addWindowPostSelectionListener(this);
    }
    else
    {
      MonitorUi.removeWindowPostSelectionListener(this);
      setDefaultLinkingEnabled(wasLinkingEnabled);
    }
  }
  
  public void selectionChanged(IWorkbenchPart part, ISelection selection)
  {
    if ((manageLinking) && ((selection instanceof ITextSelection)) && ((part instanceof IEditorPart))) {
      try
      {
        List<StructuredViewer> viewers = getViewers();
        if (viewers.size() == 1)
        {
          StructuredViewer viewer = (StructuredViewer)getViewers().get(0);
          ITextSelection textSelection = (ITextSelection)selection;
          ISelection toSelect = resolveSelection((IEditorPart)part, textSelection, viewer);
          if (toSelect != null)
          {
            ISelection currentSelection = viewer.getSelection();
            if (!toSelect.equals(currentSelection)) {
              select(viewer, toSelect);
            }
          }
        }
      }
      catch (Throwable localThrowable) {}
    }
  }
  
  protected void select(StructuredViewer viewer, ISelection selection)
  {
    viewer.setSelection(selection, true);
  }
  
  protected ISelection resolveSelection(IEditorPart part, ITextSelection selection, StructuredViewer viewer)
    throws CoreException
  {
    return null;
  }
  
  protected void setDefaultLinkingEnabled(boolean on) {}
  
  protected boolean isDefaultLinkingEnabled()
  {
    return false;
  }
  
  protected void setManualFilteringAndLinkingEnabled(boolean on) {}
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    updateEnablement(action);
  }
  
  public void updateInterestFilter(boolean on, StructuredViewer viewer)
  {
    if (viewer != null) {
      if (on)
      {
        if ((showEmptyViewMessage) && ((viewer instanceof TreeViewer)))
        {
          Tree tree = ((TreeViewer)viewer).getTree();
          Listener drawingListener = (Listener)viewerToDrawerMap.get(viewer);
          if (drawingListener == null)
          {
            EmptyContextDrawer drawer = new EmptyContextDrawer(tree);
            viewerToDrawerMap.put(viewer, drawer);
            tree.addListener(9, drawer);
          }
        }
        installInterestFilter(viewer);
        ContextUiPlugin.getViewerManager().addFilteredViewer(viewer, this);
      }
      else
      {
        if ((showEmptyViewMessage) && ((viewer instanceof TreeViewer)))
        {
          Tree tree = ((TreeViewer)viewer).getTree();
          EmptyContextDrawer drawer = (EmptyContextDrawer)viewerToDrawerMap.remove(viewer);
          if (drawer != null) {
            tree.removeListener(9, drawer);
          }
        }
        ContextUiPlugin.getViewerManager().removeFilteredViewer(viewer);
        uninstallInterestFilter(viewer);
      }
    }
  }
  
  public abstract List<StructuredViewer> getViewers();
  
  private Set<String> getPreservedFilterClasses(boolean cacheFilters)
  {
    if ((ContextUiPlugin.getDefault() == null) || (viewPart == null)) {
      return Collections.emptySet();
    }
    if ((cachedPreservedFilters == null) && (cacheFilters)) {
      try
      {
        cachedPreservedFilters = ContextUiPlugin.getDefault().getPreservedFilterClasses(
          viewPart.getSite().getId());
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
          "Could not determine preserved filters", e));
      }
    }
    if (cachedPreservedFilters != null) {
      return cachedPreservedFilters;
    }
    return Collections.emptySet();
  }
  
  protected boolean installInterestFilter(StructuredViewer viewer)
  {
    if (viewer == null)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
        "The viewer to install interest filter is null", new Exception()));
      return false;
    }
    if ((viewer.getControl().isDisposed()) && (manageViewer)) {
      return false;
    }
    if ((previousFilters.containsKey(viewer)) && (hasInterestFilter(viewer))) {
      return false;
    }
    try
    {
      viewer.getControl().setRedraw(false);
      previousFilters.put(viewer, Arrays.asList(viewer.getFilters()));
      if ((viewPart != null) && (manageFilters))
      {
        Set<ViewerFilter> toAdd = new HashSet();
        Set<String> preservedFilterClasses = getPreservedFilterClasses(true);
        for (ViewerFilter filter : (List)previousFilters.get(viewer)) {
          if ((preservedFilterClasses.contains(filter.getClass().getName())) || (isPreservedFilter(filter))) {
            toAdd.add(filter);
          }
        }
        toAdd.add(interestFilter);
        viewer.setFilters((ViewerFilter[])toAdd.toArray(new ViewerFilter[toAdd.size()]));
      }
      else
      {
        viewer.addFilter(interestFilter);
      }
      if (((viewer instanceof TreeViewer)) && (!internalSuppressExpandAll)) {
        ((TreeViewer)viewer).expandAll();
      }
      return true;
    }
    catch (Throwable t)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
        "Could not install viewer filter on: " + globalPrefId, t));
    }
    finally
    {
      viewer.getControl().setRedraw(true);
      internalSuppressExpandAll = false;
    }
    return false;
  }
  
  private boolean hasInterestFilter(StructuredViewer viewer)
  {
    ViewerFilter[] arrayOfViewerFilter;
    int j = (arrayOfViewerFilter = viewer.getFilters()).length;
    for (int i = 0; i < j; i++)
    {
      ViewerFilter filter = arrayOfViewerFilter[i];
      if (filter == getInterestFilter()) {
        return true;
      }
    }
    return false;
  }
  
  protected boolean isPreservedFilter(ViewerFilter filter)
  {
    return false;
  }
  
  /* Error */
  protected void uninstallInterestFilter(StructuredViewer viewer)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +28 -> 29
    //   4: new 234	org/eclipse/core/runtime/Status
    //   7: dup
    //   8: iconst_4
    //   9: ldc_w 216
    //   12: ldc_w 215
    //   15: new 219	java/lang/Exception
    //   18: dup
    //   19: invokespecial 500	java/lang/Exception:<init>	()V
    //   22: invokespecial 513	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   25: invokestatic 524	org/eclipse/mylyn/commons/core/StatusHandler:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   28: return
    //   29: aload_1
    //   30: invokevirtual 521	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   33: invokevirtual 565	org/eclipse/swt/widgets/Control:isDisposed	()Z
    //   36: ifeq +15 -> 51
    //   39: invokestatic 557	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getViewerManager	()Lorg/eclipse/mylyn/internal/context/ui/FocusedViewerManager;
    //   42: aload_1
    //   43: aload_0
    //   44: getfield 494	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:viewPart	Lorg/eclipse/ui/IViewPart;
    //   47: invokevirtual 562	org/eclipse/mylyn/internal/context/ui/FocusedViewerManager:removeManagedViewer	(Lorg/eclipse/jface/viewers/StructuredViewer;Lorg/eclipse/ui/IWorkbenchPart;)V
    //   50: return
    //   51: aload_1
    //   52: invokevirtual 521	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   55: iconst_0
    //   56: invokevirtual 566	org/eclipse/swt/widgets/Control:setRedraw	(Z)V
    //   59: aload_0
    //   60: getfield 488	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:previousFilters	Ljava/util/Map;
    //   63: aload_1
    //   64: invokeinterface 578 2 0
    //   69: checkcast 229	java/util/List
    //   72: astore_2
    //   73: aload_2
    //   74: ifnull +103 -> 177
    //   77: aload_0
    //   78: getfield 494	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:viewPart	Lorg/eclipse/ui/IViewPart;
    //   81: ifnull +96 -> 177
    //   84: aload_0
    //   85: getfield 480	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:manageFilters	Z
    //   88: ifeq +89 -> 177
    //   91: new 227	java/util/HashSet
    //   94: dup
    //   95: aload_2
    //   96: invokespecial 511	java/util/HashSet:<init>	(Ljava/util/Collection;)V
    //   99: astore_3
    //   100: aload_3
    //   101: aload_1
    //   102: invokevirtual 517	org/eclipse/jface/viewers/StructuredViewer:getFilters	()[Lorg/eclipse/jface/viewers/ViewerFilter;
    //   105: invokestatic 507	java/util/Arrays:asList	([Ljava/lang/Object;)Ljava/util/List;
    //   108: invokeinterface 583 2 0
    //   113: pop
    //   114: aload_3
    //   115: invokeinterface 584 1 0
    //   120: astore 4
    //   122: goto +23 -> 145
    //   125: aload 4
    //   127: invokeinterface 572 1 0
    //   132: instanceof 249
    //   135: ifeq +10 -> 145
    //   138: aload 4
    //   140: invokeinterface 570 1 0
    //   145: aload 4
    //   147: invokeinterface 571 1 0
    //   152: ifne -27 -> 125
    //   155: aload_1
    //   156: aload_3
    //   157: aload_3
    //   158: invokeinterface 580 1 0
    //   163: anewarray 241	org/eclipse/jface/viewers/ViewerFilter
    //   166: invokeinterface 585 2 0
    //   171: checkcast 217	[Lorg/eclipse/jface/viewers/ViewerFilter;
    //   174: invokevirtual 520	org/eclipse/jface/viewers/StructuredViewer:setFilters	([Lorg/eclipse/jface/viewers/ViewerFilter;)V
    //   177: aload_1
    //   178: aload_0
    //   179: getfield 493	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:interestFilter	Lorg/eclipse/mylyn/context/ui/InterestFilter;
    //   182: invokevirtual 519	org/eclipse/jface/viewers/StructuredViewer:removeFilter	(Lorg/eclipse/jface/viewers/ViewerFilter;)V
    //   185: aload_0
    //   186: getfield 493	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:interestFilter	Lorg/eclipse/mylyn/context/ui/InterestFilter;
    //   189: invokevirtual 553	org/eclipse/mylyn/context/ui/InterestFilter:resetTemporarilyUnfiltered	()Z
    //   192: pop
    //   193: goto +63 -> 256
    //   196: astore_2
    //   197: new 234	org/eclipse/core/runtime/Status
    //   200: dup
    //   201: iconst_4
    //   202: ldc_w 216
    //   205: new 222	java/lang/StringBuilder
    //   208: dup
    //   209: ldc_w 213
    //   212: invokespecial 505	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   215: aload_0
    //   216: getfield 486	org/eclipse/mylyn/context/ui/AbstractFocusViewAction:globalPrefId	Ljava/lang/String;
    //   219: invokevirtual 506	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   222: invokevirtual 504	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   225: aload_2
    //   226: invokespecial 513	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   229: invokestatic 524	org/eclipse/mylyn/commons/core/StatusHandler:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   232: aload_1
    //   233: invokevirtual 521	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   236: iconst_1
    //   237: invokevirtual 566	org/eclipse/swt/widgets/Control:setRedraw	(Z)V
    //   240: goto +24 -> 264
    //   243: astore 5
    //   245: aload_1
    //   246: invokevirtual 521	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   249: iconst_1
    //   250: invokevirtual 566	org/eclipse/swt/widgets/Control:setRedraw	(Z)V
    //   253: aload 5
    //   255: athrow
    //   256: aload_1
    //   257: invokevirtual 521	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   260: iconst_1
    //   261: invokevirtual 566	org/eclipse/swt/widgets/Control:setRedraw	(Z)V
    //   264: return
    // Line number table:
    //   Java source line #532	-> byte code offset #0
    //   Java source line #534	-> byte code offset #4
    //   Java source line #535	-> byte code offset #12
    //   Java source line #534	-> byte code offset #22
    //   Java source line #536	-> byte code offset #28
    //   Java source line #537	-> byte code offset #29
    //   Java source line #539	-> byte code offset #39
    //   Java source line #540	-> byte code offset #50
    //   Java source line #544	-> byte code offset #51
    //   Java source line #546	-> byte code offset #59
    //   Java source line #547	-> byte code offset #73
    //   Java source line #549	-> byte code offset #91
    //   Java source line #550	-> byte code offset #100
    //   Java source line #552	-> byte code offset #114
    //   Java source line #553	-> byte code offset #125
    //   Java source line #554	-> byte code offset #138
    //   Java source line #552	-> byte code offset #145
    //   Java source line #557	-> byte code offset #155
    //   Java source line #559	-> byte code offset #177
    //   Java source line #560	-> byte code offset #185
    //   Java source line #561	-> byte code offset #196
    //   Java source line #562	-> byte code offset #197
    //   Java source line #563	-> byte code offset #205
    //   Java source line #562	-> byte code offset #226
    //   Java source line #565	-> byte code offset #232
    //   Java source line #564	-> byte code offset #243
    //   Java source line #565	-> byte code offset #245
    //   Java source line #566	-> byte code offset #253
    //   Java source line #565	-> byte code offset #256
    //   Java source line #567	-> byte code offset #264
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	265	0	this	AbstractFocusViewAction
    //   0	265	1	viewer	StructuredViewer
    //   72	24	2	restoreFilters	List<ViewerFilter>
    //   196	30	2	t	Throwable
    //   99	59	3	filters	Set<ViewerFilter>
    //   120	26	4	it	java.util.Iterator<ViewerFilter>
    //   243	11	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   51	193	196	java/lang/Throwable
    //   51	232	243	finally
  }
  
  public String getGlobalPrefId()
  {
    return globalPrefId;
  }
  
  public InterestFilter getInterestFilter()
  {
    return interestFilter;
  }
  
  protected String getEmptyViewMessage()
  {
    return Messages.AbstractFocusViewAction_Empty_task_context;
  }
}

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

import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.context.ui.ContextUiImages;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;

class AbstractFocusViewAction$EmptyContextDrawer
  implements Listener
{
  private final String LABEL;
  private final Image IMAGE;
  private final Tree tree;
  
  AbstractFocusViewAction$EmptyContextDrawer(AbstractFocusViewAction paramAbstractFocusViewAction, Tree tree)
  {
    LABEL = paramAbstractFocusViewAction.getEmptyViewMessage();
    
    IMAGE = CommonImages.getImage(ContextUiImages.CONTEXT_FOCUS);
    
    this.tree = tree;
  }
  
  public void handleEvent(Event event)
  {
    if ((tree != null) && (tree.getItemCount() == 0)) {
      switch (type)
      {
      case 9: 
        int offset = 7;
        gc.drawImage(IMAGE, offset, offset);
        gc.drawText(LABEL, offset + IMAGE.getBounds().width + 5, offset);
      }
    }
  }
}

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

import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchListener;

class AbstractFocusViewAction$2
  implements IWorkbenchListener
{
  AbstractFocusViewAction$2(AbstractFocusViewAction paramAbstractFocusViewAction) {}
  
  public boolean preShutdown(IWorkbench workbench, boolean forced)
  {
    if ((AbstractFocusViewAction.access$0(this$0)) && (AbstractFocusViewAction.access$1(this$0))) {
      this$0.setDefaultLinkingEnabled(AbstractFocusViewAction.access$2(this$0));
    }
    List<StructuredViewer> viewers = this$0.getViewers();
    Set<String> excludedFilters = AbstractFocusViewAction.access$3(this$0, false);
    for (StructuredViewer viewer : viewers) {
      if (this$0.previousFilters.containsKey(viewer))
      {
        for (ViewerFilter filter : (List)this$0.previousFilters.get(viewer)) {
          if (!excludedFilters.contains(filter.getClass().getName())) {
            try
            {
              viewer.addFilter(filter);
            }
            catch (Throwable t)
            {
              StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
                "Failed to restore filter: " + filter, t));
    
1 2 3 4 5 6 7 8 9

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