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

setFocus();
      }
      else if ((stateMask == 0) && (
        (Character.isLetter((char)keyCode)) || (Character.isDigit((char)keyCode))))
      {
        String string = new Character((char)keyCode).toString();
        TaskListView.access$0(this$0).getFilterControl().setFocus();
        TaskListView.access$0(this$0).getFilterControl().setText(string);
        TaskListView.access$0(this$0).getFilterControl().setSelection(1, 1);
      }
    }
  }
  
  public void keyReleased(KeyEvent e) {}
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.layout.TreeColumnLayout;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeViewerListener;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.notifications.feed.ServiceMessageManager;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.ui.PlatformUiUtil;
import org.eclipse.mylyn.commons.ui.SelectionProviderAdapter;
import org.eclipse.mylyn.commons.ui.compatibility.CommonThemes;
import org.eclipse.mylyn.commons.workbench.DelayedRefreshJob;
import org.eclipse.mylyn.commons.workbench.GradientDrawer;
import org.eclipse.mylyn.commons.workbench.search.TextSearchControl;
import org.eclipse.mylyn.internal.commons.notifications.feed.ServiceMessage;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.internal.tasks.core.UncategorizedTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer;
import org.eclipse.mylyn.internal.tasks.ui.AbstractTaskListFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskArchiveFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskCompletionFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskPriorityFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskRepositoryUtil;
import org.eclipse.mylyn.internal.tasks.ui.TaskWorkingSetFilter;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.CollapseAllAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.ExpandAllAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.FilterCompletedTasksAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.GoUpAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.GroupSubTasksAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.LinkWithEditorAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenTaskListElementAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenTasksUiPreferencesAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.PresentationDropDownSelectionAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.PresentationDropDownSelectionAction.PresentationSelectionAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.RenameAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.ShowAllQueriesAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.ShowNonMatchingSubtasksAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeAutomaticallyAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListSortAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListViewActionGroup;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskListChangeAdapter;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListServiceMessageControl;
import org.eclipse.mylyn.internal.tasks.ui.search.AbstractSearchHandler;
import org.eclipse.mylyn.internal.tasks.ui.search.SearchUtil;
import org.eclipse.mylyn.internal.tasks.ui.util.SortCriterion;
import org.eclipse.mylyn.internal.tasks.ui.util.SortCriterion.SortKey;
import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator;
import org.eclipse.mylyn.internal.tasks.ui.util.TaskDragSourceListener;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker;
import org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker.TreeVisitor;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
import org.eclipse.mylyn.tasks.core.ITaskContainer;
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
import org.eclipse.mylyn.tasks.core.TaskActivityAdapter;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TaskElementLabelProvider;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.RTFTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.URLTransfer;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IDecoratorManager;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPageListener;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.ISizeProvider;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.handlers.CollapseAllHandler;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.DrillDownAdapter;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.ui.themes.ITheme;
import org.eclipse.ui.themes.IThemeManager;

public class TaskListView
  extends ViewPart
  implements IPropertyChangeListener, IShowInTarget
{
  private static final String ID_SEPARATOR_FILTERS = "filters";
  private static final String ID_SEPARATOR_SEARCH = "search";
  private static final String ID_SEPARATOR_TASKS = "tasks";
  private static final String ID_SEPARATOR_CONTEXT = "context";
  @Deprecated
  public static final String ID = "org.eclipse.mylyn.tasks.ui.views.tasks";
  
  private final class TaskListRefreshJob
    extends DelayedRefreshJob
  {
    private TaskListRefreshJob(TreeViewer treeViewer, String name)
    {
      super(name);
    }
    
    protected void doRefresh(Object[] items)
    {
      TreePath selection = preserveSelection();
      if (items == null) {
        viewer.refresh(true);
      } else if (items.length > 0) {
        try
        {
          Object localObject1;
          Object item;
          if (isFocusedMode())
          {
            Set<Object> children = new HashSet(Arrays.asList(items));
            Set<AbstractTaskContainer> parents = new HashSet();
            Object[] arrayOfObject2;
            int j = (arrayOfObject2 = items).length;
            for (int i = 0; i < j; i++)
            {
              Object item = arrayOfObject2[i];
              if ((item instanceof AbstractTask)) {
                parents.addAll(((AbstractTask)item).getParentContainers());
              }
            }
            children.removeAll(parents);
            for (AbstractTaskContainer parent : parents)
            {
              viewer.refresh(parent, false);
              
              viewer.update(parent, null);
            }
            for (Object item : children) {
              viewer.refresh(item, true);
            }
            j = (arrayOfObject2 = items).length;
            for (localObject1 = 0; localObject1 < j; localObject1++)
            {
              item = arrayOfObject2[localObject1];
              updateExpansionState(item);
            }
          }
          else
          {
            Set<AbstractTaskContainer> parents = new HashSet();
            Object[] arrayOfObject1;
            localObject1 = (arrayOfObject1 = items).length;
            for (item = 0; item < localObject1; item++)
            {
              Object item = arrayOfObject1[item];
              if ((item instanceof AbstractTask)) {
                parents.addAll(((AbstractTask)item).getParentContainers());
              }
              viewer.refresh(item, true);
              updateExpansionState(item);
            }
            for (item = parents.iterator(); ((Iterator)item).hasNext();)
            {
              AbstractTaskContainer parent = (AbstractTaskContainer)((Iterator)item).next();
              
              viewer.update(parent, null);
            }
          }
        }
        catch (SWTException e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", "Failed to refresh viewer: " + 
            viewer, e));
        }
      }
      TaskListView.this.updateToolTip(false);
      restoreSelection(selection);
    }
    
    private TreePath preserveSelection()
    {
      if ((viewer instanceof TreeViewer))
      {
        TreeViewer treeViewer = (TreeViewer)viewer;
        
        TreeItem[] selection = treeViewer.getTree().getSelection();
        if (selection.length > 0)
        {
          TreeWalker treeWalker = new TreeWalker(treeViewer);
          treeWalker.walk(new TreeWalker.TreeVisitor()
          {
            public boolean visit(Object object)
            {
              return true;
            }
          }, selection[(selection.length - 1)]);
        }
      }
      return null;
    }
    
    private void restoreSelection(TreePath treePath)
    {
      if (treePath != null)
      {
        ISelection newSelection = viewer.getSelection();
        if ((newSelection == null) || (newSelection.isEmpty())) {
          viewer.setSelection(new TreeSelection(treePath), true);
        }
      }
    }
    
    protected void updateExpansionState(Object item)
    {
      if ((isFocusedMode()) && (TaskListView.this.isAutoExpandMode())) {
        getViewer().expandToLevel(item, 3);
      }
    }
  }
  
  public static final String LABEL_VIEW = Messages.TaskListView_Task_List;
  @Deprecated
  private static final String MEMENTO_KEY_SORT_DIRECTION = "sortDirection";
  @Deprecated
  private static final String MEMENTO_KEY_SORTER = "sorter";
  @Deprecated
  private static final String MEMENTO_KEY_SORTER2 = "sorter2";
  @Deprecated
  private static final String MEMENTO_KEY_SORT_INDEX = "sortIndex";
  @Deprecated
  private static final String MEMENTO_SORT_INDEX = "org.eclipse.mylyn.tasklist.ui.views.tasklist.sortIndex";
  private static final String MEMENTO_SORTER = "sorter";
  private static final String MEMENTO_LINK_WITH_EDITOR = "linkWithEditor";
  private static final String MEMENTO_PRESENTATION = "presentation";
  private static final String LABEL_NO_TASKS = "no task active";
  private static final int SIZE_MAX_SELECTION_HISTORY = 10;
  static final String[] PRIORITY_LEVELS = { ITask.PriorityLevel.P1.toString(), ITask.PriorityLevel.P2.toString(), 
    ITask.PriorityLevel.P3.toString(), ITask.PriorityLevel.P4.toString(), ITask.PriorityLevel.P5.toString() };
  public static final String[] PRIORITY_LEVEL_DESCRIPTIONS = { ITask.PriorityLevel.P1.getDescription(), 
    ITask.PriorityLevel.P2.getDescription(), ITask.PriorityLevel.P3.getDescription(), ITask.PriorityLevel.P4.getDescription(), 
    ITask.PriorityLevel.P5.getDescription() };
  private static List<AbstractTaskListPresentation> presentationsPrimary = new ArrayList();
  private static List<AbstractTaskListPresentation> presentationsSecondary = new ArrayList();
  private boolean focusedMode;
  private boolean linkWithEditor;
  private final TaskListCellModifier taskListCellModifier = new TaskListCellModifier(this);
  private IThemeManager themeManager;
  private TaskListFilteredTree filteredTree;
  private SelectionProviderAdapter selectionProvider;
  private DrillDownAdapter drillDownAdapter;
  private AbstractTaskContainer drilledIntoCategory;
  private CollapseAllAction collapseAll;
  private ExpandAllAction expandAll;
  private FilterCompletedTasksAction filterCompleteTask;
  private GroupSubTasksAction groupSubTasksAction;
  private SynchronizeAutomaticallyAction synchronizeAutomatically;
  private OpenTasksUiPreferencesAction openPreferencesAction;
  private PriorityDropDownAction filterOnPriorityAction;
  private TaskListSortAction sortDialogAction;
  private NewTaskAction newTaskAction;
  private LinkWithEditorAction linkWithEditorAction;
  private final PresentationDropDownSelectionAction presentationDropDownSelectionAction = new PresentationDropDownSelectionAction(
    this);
  private final TaskPriorityFilter filterPriority = new TaskPriorityFilter();
  private final TaskCompletionFilter filterComplete = new TaskCompletionFilter();
  private final TaskArchiveFilter filterArchive = new TaskArchiveFilter();
  private final PresentationFilter filterPresentation = PresentationFilter.getInstance();
  private TaskWorkingSetFilter filterWorkingSet;
  private final Set<AbstractTaskListFilter> filters = new HashSet();
  protected String[] columnNames = { Messages.TaskListView_Summary };
  protected int[] columnWidths = { 200 };
  private TreeColumn[] columns;
  private IMemento taskListMemento;
  private AbstractTaskListPresentation currentPresentation;
  private TaskTableLabelProvider taskListTableLabelProvider;
  private TaskListSorter tableSorter;
  private TaskListViewActionGroup actionGroup;
  private CustomTaskListDecorationDrawer customDrawer;
  private TaskListServiceMessageControl serviceMessageControl;
  private long lastExpansionTime;
  private final IPageListener PAGE_LISTENER = new IPageListener()
  {
    public void pageActivated(IWorkbenchPage page)
    {
      filteredTree.indicateActiveTaskWorkingSet();
    }
    
    public void pageClosed(IWorkbenchPage page) {}
    
    public void pageOpened(IWorkbenchPage page) {}
  };
  private final LinkedHashMap<String, IStructuredSelection> lastSelectionByTaskHandle = new LinkedHashMap(
    10);
  protected boolean isPaused = false;
  private final ITaskActivityListener TASK_ACTIVITY_LISTENER = new TaskActivityAdapter()
  {
    public void activityReset()
    {
      PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          refreshJob.refresh();
        }
      });
    }
  };
  private final ITaskActivationListener TASK_ACTIVATION_LISTENER = new TaskActivationAdapter()
  {
    public void taskActivated(final ITask task)
    {
      if (task != null) {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            TaskListView.this.updateDescription();
            TaskListView.3.this.refresh(task);
            selectedAndFocusTask(task);
            filteredTree.indicateActiveTask(task);
          }
        });
      }
    }
    
    public void taskDeactivated(final ITask task)
    {
      PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          TaskListView.3.this.refresh(task);
          TaskListView.this.updateDescription();
          filteredTree.indicateNoActiveTask();
        }
      });
    }
    
    private void refresh(ITask task)
    {
      if (isScheduledPresentation()) {
        refreshJob.refresh();
      } else {
        refreshJob.refreshElement(task);
      }
    }
  };
  private final ITaskListChangeListener TASKLIST_CHANGE_LISTENER = new TaskListChangeAdapter()
  {
    public void containersChanged(final Set<TaskContainerDelta> deltas)
    {
      PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          for (TaskContainerDelta taskContainerDelta : deltas) {
            if (isScheduledPresentation()) {
              refreshJob.refresh();
            } else {
              switch (taskContainerDelta.getKind())
              {
              case ROOT: 
                refreshJob.refresh();
                break;
              case ADDED: 
              case CONTENT: 
                if (isFilteredContainer(taskContainerDelta))
                {
                  refreshJob.refresh();
                }
                else
                {
                  if (taskContainerDelta.getElement() != null) {
                    refreshJob.refreshElement(taskContainerDelta.getElement());
                  }
                  if (taskContainerDelta.getParent() != null) {
                    refreshJob.refreshElement(taskContainerDelta.getParent());
                  } else {
                    refreshJob.refresh();
                  }
                }
                break;
              case DELETED: 
                refreshJob.refreshElement(taskContainerDelta.getElement());
              }
            }
          }
        }
        
        private boolean isFilteredContainer(TaskContainerDelta taskContainerDelta)
        {
          ITaskContainer parent = taskContainerDelta.getParent();
          
          return ((parent instanceof UnsubmittedTaskContainer)) || ((parent instanceof UnmatchedTaskContainer)) || ((parent instanceof UncategorizedTaskContainer));
        }
      });
    }
  };
  private final IPropertyChangeListener THEME_CHANGE_LISTENER = new IPropertyChangeListener()
  {
    public void propertyChange(PropertyChangeEvent event)
    {
      if ((event.getProperty().equals("CHANGE_CURRENT_THEME")) || 
        (CommonThemes.isCommonTheme(event.getProperty())))
      {
        taskListTableLabelProvider.setCategoryBackgroundColor(themeManager.getCurrentTheme()
          .getColorRegistry()
          .get("org.eclipse.mylyn.tasks.ui.colors.category.gradient.end"));
        getViewer().refresh();
      }
    }
  };
  private final IPropertyChangeListener tasksUiPreferenceListener = new IPropertyChangeListener()
  {
    public void propertyChange(PropertyChangeEvent event)
    {
      if ("org.eclipse.mylyn.tasks.ui.task.list.tool.tip".equals(event.getProperty())) {
        TaskListView.this.updateTooltipEnablement();
      }
      if ((event.getProperty().equals("org.eclipse.mylyn.tasks.ui.strikethrough.for.completed")) || 
        (event.getProperty().equals("org.eclipse.mylyn.tasks.ui.overlays.incoming.tight"))) {
        refreshJob.refresh();
      }
      if ((event.getProperty().equals("org.eclipse.mylyn.tasks.ui.filters.hidden")) || 
        (event.getProperty().equals("org.eclipse.mylyn.tasks.ui.filters.nonmatching")) || 
        (event.getProperty().equals("org.eclipse.mylyn.tasks.ui.group.subtasks")))
      {
        filterPresentation.updateSettings();
        refresh(true);
      }
    }
  };
  private TaskListToolTip taskListToolTip;
  private static boolean initializedSynchronization;
  
  public static TaskListView getFromActivePerspective()
  {
    if (PlatformUI.isWorkbenchRunning())
    {
      IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      if (activeWorkbenchWindow != null)
      {
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        if (activePage != null)
        {
          IViewPart view = activePage.findView("org.eclipse.mylyn.tasks.ui.views.tasks");
          if ((view instanceof TaskListView)) {
            return (TaskListView)view;
          }
        }
      }
    }
    return null;
  }
  
  public TaskListView()
  {
    if (!initializedSynchronization)
    {
      initializedSynchronization = true;
      
      TasksUiPlugin.getDefault().initializeNotificationsAndSynchronization();
    }
  }
  
  public void dispose()
  {
    super.dispose();
    if (actionGroup != null) {
      actionGroup.dispose();
    }
    TasksUiPlugin.getDefault().getServiceMessageManager().removeServiceMessageListener(serviceMessageControl);
    TasksUiPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(tasksUiPreferenceListener);
    TasksUiInternal.getTaskList().removeChangeListener(TASKLIST_CHANGE_LISTENER);
    TasksUiPlugin.getTaskActivityManager().removeActivityListener(TASK_ACTIVITY_LISTENER);
    TasksUiPlugin.getTaskActivityManager().removeActivationListener(TASK_ACTIVATION_LISTENER);
    
    PlatformUI.getWorkbench().getWorkingSetManager().removePropertyChangeListener(this);
    if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePageListener(PAGE_LISTENER);
    }
    IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
    if (themeManager != null) {
      themeManager.removePropertyChangeListener(THEME_CHANGE_LISTENER);
    }
    if (editorListener != null) {
      getSite().getPage().removePartListener(editorListener);
    }
    if (searchHandler != null) {
      searchHandler.dispose();
    }
  }
  
  private void updateDescription()
  {
    ITask task = TasksUi.getTaskActivityManager().getActiveTask();
    if ((getSite() == null) || (getSite().getPage() == null)) {
      return;
    }
    IViewReference reference = getSite().getPage().findViewReference("org.eclipse.mylyn.tasks.ui.views.tasks");
    boolean shouldSetDescription = false;
    if ((reference != null) && (reference.isFastView()) && (!getSite().getPage().isPartVisible(this))) {
      shouldSetDescription = true;
    }
    if (task != null)
    {
      setTitleToolTip(LABEL_VIEW + " (" + task.getSummary() + ")");
      if (shouldSetDescription) {
        setContentDescription(task.getSummary());
      } else {
        setContentDescription("");
      }
    }
    else
    {
      setTitleToolTip(LABEL_VIEW);
      if (shouldSetDescription) {
        setContentDescription("no task active");
      } else {
        setContentDescription("");
      }
    }
  }
  
  public void init(IViewSite site, IMemento memento)
    throws PartInitException
  {
    init(site);
    taskListMemento = memento;
  }
  
  public void saveState(IMemento memento)
  {
    if (tableSorter != null)
    {
      IMemento child = memento.createChild("sorter");
      tableSorter.saveState(child);
    }
    memento.putString("linkWithEditor", Boolean.toString(linkWithEditor));
    memento.putString("presentation", currentPresentation.getId());
    if (filteredTree.getTextSearchControl() != null) {
      filteredTree.getTextSearchControl().saveState(memento);
    }
  }
  
  private void restoreState()
  {
    if (taskListMemento != null)
    {
      if (tableSorter != null)
      {
        IMemento sorterMemento = taskListMemento.getChild("sorter");
        if (sorterMemento != null)
        {
          tableSorter.restoreState(sorterMemento);
        }
        else
        {
          sorterMemento = taskListMemento.getChild("org.eclipse.mylyn.tasklist.ui.views.tasklist.sortIndex");
          if (sorterMemento != null) {
            migrateSorterState(tableSorter, sorterMemento);
          }
        }
      }
      applyPresentation(taskListMemento.getString("presentation"));
    }
    filterWorkingSet = new TaskWorkingSetFilter();
    filterWorkingSet.updateWorkingSet(getSite().getPage().getAggregateWorkingSet());
    filteredTree.setWorkingSetFilter(filterWorkingSet);
    addFilter(filterWorkingSet);
    addFilter(filterPriority);
    if (TasksUiPlugin.getDefault().getPreferenceStore().contains("org.eclipse.mylyn.tasks.ui.filters.complete")) {
      addFilter(filterComplete);
    }
    addFilter(filterPresentation);
    addFilter(filterArchive);
    
    boolean linkValue = true;
    if ((taskListMemento != null) && (taskListMemento.getString("linkWithEditor") != null)) {
      linkValue = Boolean.parseBoolean(taskListMemento.getString("linkWithEditor"));
    }
    setLinkWithEditor(linkValue);
    if ((taskListMemento != null) && (filteredTree.getTextSearchControl() != null)) {
      filteredTree.getTextSearchControl().restoreState(taskListMemento);
    }
    getViewer().refresh();
  }
  
  public void migrateSorterState(TaskListSorter tableSorter, IMemento sorterMemento)
  {
    int restoredSortIndex = 0;
    if (sorterMemento != null)
    {
      int sortDirection = -1;
      IMemento m = sorterMemento.getChild("sorter");
      if (m != null)
      {
        Integer sortIndexInt = m.getInteger("sortIndex");
        if (sortIndexInt != null) {
          restoredSortIndex = sortIndexInt.intValue();
        }
        Integer sortDirInt = m.getInteger("sortDirection");
        if (sortDirInt != null)
        {
          sortDirection = sortDirInt.intValue();
          tableSorter.getComparator().getSortCriterion(0).setDirection(sortDirection);
          switch (restoredSortIndex)
          {
          case 1: 
            tableSorter.getComparator().getSortCriterion(0).setKey(SortCriterion.SortKey.SUMMARY);
            break;
          case 2: 
            tableSorter.getComparator().getSortCriterion(0).setKey(SortCriterion.SortKey.DATE_CREATED);
            break;
          case 3: 
            tableSorter.getComparator().getSortCriterion(0).setKey(SortCriterion.SortKey.TASK_ID);
            break;
          default: 
            tableSorter.getComparator().getSortCriterion(0).setKey(SortCriterion.SortKey.PRIORITY);
          }
        }
      }
      IMemento m2 = sorterMemento.getChild("sorter2");
      if (m2 != null)
      {
        Integer sortIndexInt = m2.getInteger("sortIndex");
        if (sortIndexInt != null) {
          restoredSortIndex = sortIndexInt.intValue();
        }
        Integer sortDirInt = m2.getInteger("sortDirection");
        if (sortDirInt != null)
        {
          sortDirection = sortDirInt.intValue();
          tableSorter.getComparator().getSortCriterion(1).setDirection(sortDirection);
          switch (restoredSortIndex)
          {
          case 1: 
            tableSorter.getComparator().getSortCriterion(1).setKey(SortCriterion.SortKey.SUMMARY);
            break;
          case 2: 
            tableSorter.getComparator().getSortCriterion(1).setKey(SortCriterion.SortKey.DATE_CREATED);
            break;
          case 3: 
            tableSorter.getComparator().getSortCriterion(1).setKey(SortCriterion.SortKey.TASK_ID);
            break;
          default: 
            tableSorter.getComparator().getSortCriterion(1).setKey(SortCriterion.SortKey.PRIORITY);
          }
        }
      }
    }
  }
  
  public void createPartControl(Composite parent)
  {
    Composite body = new Composite(parent, 0);
    GridLayout layout = new GridLayout(1, false);
    marginHeight = 0;
    marginWidth = 0;
    horizontalSpacing = 0;
    verticalSpacing = 0;
    numColumns = 1;
    body.setLayout(layout);
    
    IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService)getSite().getAdapter(
      IWorkbenchSiteProgressService.class);
    if (progress != null) {
      progress.showBusyForFamily(ITasksCoreConstants.JOB_FAMILY_SYNCHRONIZATION);
    }
    selectionProvider = new SelectionProviderAdapter();
    getSite().setSelectionProvider(selectionProvider);
    
    this.themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
    this.themeManager.addPropertyChangeListener(THEME_CHANGE_LISTENER);
    
    searchHandler = SearchUtil.createSearchHandler();
    
    filteredTree = new TaskListFilteredTree(body, 66066, 
      searchHandler, getViewSite().getWorkbenchWindow());
    
    taskListToolTip = new TaskListToolTip(getViewer().getControl());
    updateTooltipEnablement();
    
    getSite().registerContextMenu("org.eclipse.mylyn.tasks.ui.menus.activeTask", filteredTree.getActiveTaskMenuManager(), 
      selectionProvider);
    filteredTree.setActiveTaskSelectionProvider(selectionProvider);
    
    getViewer().addSelectionChangedListener(selectionProvider);
    getViewer().getControl().addFocusListener(new FocusAdapter()
    {
      public void focusGained(FocusEvent e)
      {
        selectionProvider.setSelection(getViewer().getSelection());
      }
    });
    filteredTree.getFilterControl().addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        TaskListView.this.updateFilterEnablement();
      }
    });
    getViewer().getTree().setHeaderVisible(false);
    getViewer().setUseHashlookup(true);
    refreshJob = new TaskListRefreshJob(getViewer(), "Task List Refresh", null);
    
    configureColumns(columnNames, columnWidths);
    
    IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
    Color categoryBackground = themeManager.getCurrentTheme().getColorRegistry().get("org.eclipse.mylyn.tasks.ui.colors.category.gradient.end");
    taskListTableLabelProvider = new TaskTableLabelProvider(new TaskElementLabelProvider(true), 
      PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), categoryBackground);
    getViewer().setLabelProvider(taskListTableLabelProvider);
    
    CellEditor[] editors = new CellEditor[columnNames.length];
    TextCellEditor textEditor = new TextCellEditor(getViewer().getTree());
    ((Text)textEditor.getControl()).setOrientation(33554432);
    editors[0] = textEditor;
    
    getViewer().setCellEditors(editors);
    getViewer().setCellModifier(taskListCellModifier);
    
    tableSorter = new TaskListSorter();
    getViewer().setSorter(tableSorter);
    
    applyPresentation("org.eclipse.mylyn.tasks.ui.categorized");
    
    drillDownAdapter = new DrillDownAdapter(getViewer());
    getViewer().setInput(getViewSite());
    
    final int activationImageOffset = PlatformUiUtil.getTreeImageOffset();
    customDrawer = new CustomTaskListDecorationDrawer(activationImageOffset, false);
    getViewer().getTree().addListener(40, customDrawer);
    getViewer().getTree().addListener(42, customDrawer);
    
    Listener expandListener = new Listener()
    {
      public void handleEvent(Event event)
      {
        lastExpansionTime = System.currentTimeMillis();
      }
    };
    getViewer().getTree().addListener(17, expandListener);
    getViewer().getTree().addListener(18, expandListener);
    
    getViewer().getTree().addMouseListener(new MouseAdapter()
    {
      public void mouseUp(MouseEvent event)
      {
        long currentTime = System.currentTimeMillis();
        if ((currentTime - lastExpansionTime < 150L) && (currentTime >= lastExpansionTime)) {
          return;
        }
        if (button == 3) {
          return;
        }
        Object selectedNode = ((Tree)widget).getItem(new Point(x + 70, y));
        if ((selectedNode instanceof TreeItem))
        {
          Object selectedObject = ((TreeItem)selectedNode).getData();
          if (((selectedObject instanceof ITask)) && 
            (x > activationImageOffset) && (x < activationImageOffset + 13)) {
            taskListCellModifier.toggleTaskActivation((TreeItem)selectedNode, event);
          }
        }
      }
    });
    getViewer().getTree().addKeyListener(new KeyListener()
    {
      public void keyPressed(KeyEvent e)
      {
        if ((keyCode == 16777227) && (stateMask == 0))
        {
          if (actionGroup.getRenameAction().isEnabled()) {
            actionGroup.getRenameAction().run();
          }
        }
        else if ((keyCode & 0x1000000) == 0) {
          if (keyCode == 27)
          {
            taskListToolTip.hide();
          }
          else if ((keyCode == 102) && (stateMask == SWT.MOD1))
          {
            filteredTree.getFilterControl().setFocus();
          }
          else if ((stateMask == 0) && (
            (Character.isLetter((char)keyCode)) || (Character.isDigit((char)keyCode))))
          {
            String string = new Character((char)keyCode).toString();
            filteredTree.getFilterControl().setFocus();
            filteredTree.getFilterControl().setText(string);
            filteredTree.getFilterControl().setSelection(1, 1);
          }
        }
      }
      
      public void keyReleased(KeyEvent e) {}
    });
    getViewer().addTreeListener(new ITreeViewerListener()
    {
      public void treeCollapsed(final TreeExpansionEvent event)
      {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            getViewer().refresh(event.getElement());
          }
        });
      }
      
      public void treeExpanded(final TreeExpansionEvent event)
      {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            getViewer().refresh(event.getElement());
          }
        });
      }
    });
    getViewer().addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent event)
      {
        TaskListView.this.updateToolTip(true);
      }
    });
    getViewer().getTree().addFocusListener(new FocusAdapter()
    {
      public void focusLost(FocusEvent e)
      {
        taskListToolTip.hide();
      }
    });
    makeActions();
    hookGlobalActions();
    hookContextMenu();
    hookOpenAction();
    contributeToActionBars();
    initHandlers();
    
    new GradientDrawer(themeManager, getViewer());
    {
      protected boolean shouldApplyGradient(Event event)
      {
        return ((item.getData() instanceof ITaskContainer)) && (!(item.getData() instanceof ITask));
      }
    };
    initDragAndDrop(parent);
    expandToActiveTasks();
    restoreState();
    
    updateDescription();
    
    IContextService contextSupport = (IContextService)getSite().getService(IContextService.class);
    if (contextSupport != null) {
      contextSupport.activateContext("org.eclipse.mylyn.tasks.ui.views.tasks");
    }
    getSite().getPage().addPartListener(editorListener);
    
    updatePresentationSelectorImage();
    
    PlatformUI.getWorkbench().getWorkingSetManager().addPropertyChangeListener(this);
    TasksUiPlugin.getTaskActivityManager().addActivityListener(TASK_ACTIVITY_LISTENER);
    TasksUiPlugin.getTaskActivityManager().addActivationListener(TASK_ACTIVATION_LISTENER);
    TasksUiInternal.getTaskList().addChangeListener(TASKLIST_CHANGE_LISTENER);
    
    TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(tasksUiPreferenceListener);
    
    serviceMessageControl = new TaskListServiceMessageControl(body);
    
    List<TaskRepository> repos = TasksUi.getRepositoryManager().getAllRepositories();
    boolean showMessage = true;
    for (TaskRepository repository : repos) {
      if ((!repository.getConnectorKind().equals("local")) && 
        (!TaskRepositoryUtil.isAddAutomatically(repository.getRepositoryUrl())))
      {
        showMessage = false;
        break;
      }
    }
    String lastClosedId = TasksUiPlugin.getDefault()
      .getPreferenceStore()
      .getString("org.eclipse.mylyn.tasks.ui.servicemessage.id");
    if ((showMessage) && (lastClosedId.equals("")))
    {
      ServiceMessage message = new ServiceMessage("welcome");
      message.setDescription(Messages.TaskListView_Welcome_Message);
      message.setTitle(Messages.TaskListView_Welcome_Message_Title);
      message.setImage("dialog_messasge_info_image");
      message.setId("0");
      serviceMessageControl.setMessage(message);
    }
    TasksUiPlugin.getDefault().getServiceMessageManager().addServiceMessageListener(serviceMessageControl);
    
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPageListener(PAGE_LISTENER);
  }
  
  private void initHandlers()
  {
    IHandlerService handlerService = (IHandlerService)getSite().getService(IHandlerService.class);
    handlerService.activateHandler("org.eclipse.ui.navigate.collapseAll", new CollapseAllHandler(getViewer()));
  }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

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-2019. Infinite Loop Ltd