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

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

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class ActivityExternalizationParticipant$1
  implements IPropertyChangeListener
{
  ActivityExternalizationParticipant$1(ActivityExternalizationParticipant paramActivityExternalizationParticipant) {}
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty().equals("org.eclipse.mylyn.monitor.activity.tracking.enabled")) {
      ActivityExternalizationParticipant.access$0(this$0);
    }
  }
}

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

import java.io.File;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
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.IInteractionContext;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.internal.monitor.ui.ActivityContextManager;
import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.externalization.AbstractExternalizationParticipant;
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationContext;
import org.eclipse.mylyn.internal.tasks.ui.Messages;
import org.eclipse.mylyn.monitor.ui.IUserAttentionListener;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
import org.eclipse.mylyn.tasks.ui.TasksUi;

public class ActiveContextExternalizationParticipant
  extends AbstractExternalizationParticipant
  implements ITaskActivityListener, IUserAttentionListener
{
  private boolean isDirty = false;
  private final ExternalizationManager manager;
  private long lastUpdate;
  private IInteractionContext currentlyActiveContext;
  private final AbstractContextListener listener = new AbstractContextListener()
  {
    public void contextChanged(ContextChangeEvent event)
    {
      switch (event.getEventKind())
      {
      case CLEARED: 
        currentlyActiveContext = event.getContext();
        break;
      case DEACTIVATED: 
        currentlyActiveContext = null;
        setDirty(false);
      }
    }
  };
  
  public ActiveContextExternalizationParticipant(ExternalizationManager manager)
  {
    this.manager = manager;
  }
  
  public void registerListeners()
  {
    ContextCore.getContextManager().addListener(listener);
    TasksUi.getTaskActivityManager().addActivityListener(this);
    MonitorUiPlugin.getDefault().getActivityContextManager().addListener(this);
    currentlyActiveContext = ContextCore.getContextManager().getActiveContext();
  }
  
  public void dispose()
  {
    ContextCore.getContextManager().removeListener(listener);
    TasksUi.getTaskActivityManager().removeActivityListener(this);
    if (MonitorUiPlugin.getDefault().getActivityContextManager() != null) {
      MonitorUiPlugin.getDefault().getActivityContextManager().removeListener(this);
    }
  }
  
  public void execute(IExternalizationContext context, IProgressMonitor monitor)
    throws CoreException
  {
    Assert.isNotNull(context);
    switch (context.getKind())
    {
    case LOAD: 
      if (shouldWriteContext())
      {
        setDirty(false);
        ContextCorePlugin.getContextManager().saveContext(currentlyActiveContext);
      }
      break;
    case SNAPSHOT: 
      break;
    }
  }
  
  public String getDescription()
  {
    return Messages.ActiveContextExternalizationParticipant_Active_Task_Context;
  }
  
  public ISchedulingRule getSchedulingRule()
  {
    return ITasksCoreConstants.ACTIVE_CONTEXT_SCHEDULING_RULE;
  }
  
  public boolean isDirty()
  {
    return isDirty(false);
  }
  
  public boolean isDirty(boolean full)
  {
    synchronized (this)
    {
      return (isDirty) || ((full) && (shouldWriteContext()));
    }
  }
  
  public void setDirty(boolean dirty)
  {
    synchronized (this)
    {
      isDirty = dirty;
    }
  }
  
  public String getFileName()
  {
    return null;
  }
  
  public void load(File sourceFile, IProgressMonitor monitor)
    throws CoreException
  {}
  
  public void save(File targetFile, IProgressMonitor monitor)
    throws CoreException
  {}
  
  public void elapsedTimeUpdated(ITask task, long newElapsedTime)
  {
    if (System.currentTimeMillis() - lastUpdate > 180000L)
    {
      setDirty(shouldWriteContext());
      if (isDirty()) {
        manager.requestSave();
      }
      lastUpdate = System.currentTimeMillis();
    }
  }
  
  private boolean shouldWriteContext()
  {
    if ((ContextCorePlugin.getContextManager() != null) && (currentlyActiveContext != null) && 
      (currentlyActiveContext.getAllElements().size() > 0)) {
      return true;
    }
    return false;
  }
  
  public void activityReset() {}
  
  public void userAttentionGained() {}
  
  public void userAttentionLost()
  {
    setDirty(shouldWriteContext());
    if (isDirty()) {
      manager.requestSave();
    }
    lastUpdate = System.currentTimeMillis();
  }
}

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

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
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.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContext;
import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
import org.eclipse.mylyn.tasks.core.activity.AbstractTaskActivityMonitor;

public class TaskActivityMonitor
  extends AbstractTaskActivityMonitor
{
  private final AbstractContextListener CONTEXT_LISTENER = new AbstractContextListener()
  {
    public void contextChanged(ContextChangeEvent event)
    {
      switch (event.getEventKind())
      {
      case INTEREST_CHANGED: 
        List<InteractionEvent> events = contextManager.getActivityMetaContext().getInteractionHistory();
        if (events.size() > 0)
        {
          InteractionEvent interactionEvent = (InteractionEvent)events.get(events.size() - 1);
          parseInteractionEvent(interactionEvent, false);
        }
        break;
      }
    }
  };
  private static ITaskActivationListener CONTEXT_TASK_ACTIVATION_LISTENER = new TaskActivationAdapter()
  {
    public void preTaskActivated(ITask task)
    {
      ContextUiPlugin.getDefault();
    }
    
    public void taskActivated(ITask task)
    {
      ContextCore.getContextManager().activateContext(task.getHandleIdentifier());
    }
    
    public void taskDeactivated(ITask task)
    {
      ContextCore.getContextManager().deactivateContext(task.getHandleIdentifier());
    }
  };
  private final InteractionContextManager contextManager;
  private TaskActivityManager taskActivityManager;
  private final TaskList taskList;
  private final List<ITask> activationHistory;
  private ActivityExternalizationParticipant externalizationParticipant;
  
  public TaskActivityMonitor()
  {
    contextManager = ContextCorePlugin.getContextManager();
    taskList = TasksUiPlugin.getTaskList();
    activationHistory = new ArrayList();
  }
  
  public void start(ITaskActivityManager taskActivityManager)
  {
    this.taskActivityManager = ((TaskActivityManager)taskActivityManager);
    taskActivityManager.addActivationListener(CONTEXT_TASK_ACTIVATION_LISTENER);
    contextManager.addActivityMetaContextListener(CONTEXT_LISTENER);
    
    ExternalizationManager externalizationManager = TasksUiPlugin.getExternalizationManager();
    ActivityExternalizationParticipant ACTIVITY_EXTERNALIZTAION_PARTICIPANT = new ActivityExternalizationParticipant(
      externalizationManager);
    externalizationManager.addParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
    taskActivityManager.addActivityListener(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
    setExternalizationParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
  }
  
  public boolean parseInteractionEvent(InteractionEvent event, boolean isReloading)
  {
    try
    {
      if (event.getKind().equals(InteractionEvent.Kind.COMMAND))
      {
        if (event.getDelta().equals("activated"))
        {
          AbstractTask activatedTask = taskList.getTask(event.getStructureHandle());
          if (activatedTask != null)
          {
            activationHistory.add(activatedTask);
            return true;
          }
        }
      }
      else if (event.getKind().equals(InteractionEvent.Kind.ATTENTION)) {
        if ((event.getDelta().equals("added")) || (event.getDelta().equals("add")))
        {
          if ((event.getDate().getTime() > 0L) && (event.getEndDate().getTime() > 0L)) {
            if (event.getStructureKind().equals("workingset"))
            {
              taskActivityManager.addWorkingSetElapsedTime(event.getStructureHandle(), event.getDate(), 
                event.getEndDate());
              if (!isReloading)
              {
                externalizationParticipant.setDirty(true);
                
                externalizationParticipant.elapsedTimeUpdated(null, 0L);
              }
            }
            else
            {
              AbstractTask activatedTask = taskList.getTask(event.getStructureHandle());
              if (activatedTask != null) {
                taskActivityManager.addElapsedTime(activatedTask, event.getDate(), event.getEndDate());
              }
            }
          }
        }
        else if (event.getDelta().equals("removed"))
        {
          ITask task = taskList.getTask(event.getStructureHandle());
          if (task != null) {
            taskActivityManager.removeElapsedTime(task, event.getDate(), event.getEndDate());
          }
        }
      }
    }
    catch (Throwable t)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.core", 
        "Error parsing interaction event", t));
    }
    return false;
  }
  
  public void stop()
  {
    contextManager.removeActivityMetaContextListener(CONTEXT_LISTENER);
  }
  
  public void reloadActivityTime()
  {
    activationHistory.clear();
    taskActivityManager.clearActivity();
    List<InteractionEvent> events = contextManager.getActivityMetaContext().getInteractionHistory();
    for (InteractionEvent event : events) {
      parseInteractionEvent(event, true);
    }
  }
  
  public void setExternalizationParticipant(ActivityExternalizationParticipant participant)
  {
    externalizationParticipant = participant;
  }
  
  public List<ITask> getActivationHistory()
  {
    return new ArrayList(activationHistory);
  }
  
  public void loadActivityTime()
  {
    ContextCorePlugin.getContextManager().loadActivityMetaContext();
    reloadActivityTime();
  }
  
  public boolean isEnabled()
  {
    return true;
  }
}

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

import org.eclipse.mylyn.commons.core.CommonListenerList.Notifier;

class TaskContextStore$2
  extends CommonListenerList.Notifier<TaskContextStoreListener>
{
  TaskContextStore$2(TaskContextStore paramTaskContextStore, TaskContextStoreEvent paramTaskContextStoreEvent) {}
  
  public void run(TaskContextStoreListener listener)
    throws Exception
  {
    listener.taskContextChanged(val$event);
  }
}

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

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.swt.graphics.Image;

final class InvisibleContextElementsPart$InteractionElementTableLabelProvider
  extends LabelProvider
  implements ITableLabelProvider
{
  private InvisibleContextElementsPart$InteractionElementTableLabelProvider(InvisibleContextElementsPart paramInvisibleContextElementsPart) {}
  
  public String getText(Object element)
  {
    if ((element instanceof IInteractionElement)) {
      return ((IInteractionElement)element).getHandleIdentifier();
    }
    return super.getText(element);
  }
  
  public Image getColumnImage(Object element, int columnIndex)
  {
    return null;
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    if ((element instanceof IInteractionElement))
    {
      if (columnIndex == 0) {
        return ((IInteractionElement)element).getHandleIdentifier();
      }
      if (columnIndex == 1) {
        return ((IInteractionElement)element).getContentType();
      }
    }
    return "";
  }
}

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

import java.util.List;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.forms.widgets.Section;

class InvisibleContextElementsPart$4$1
  implements Runnable
{
  InvisibleContextElementsPart$4$1(InvisibleContextElementsPart.4 param4, List paramList) {}
  
  public void run()
  {
    if ((InvisibleContextElementsPart.access$8(InvisibleContextElementsPart.4.access$0(this$1)) != null) && (!InvisibleContextElementsPart.access$8(InvisibleContextElementsPart.4.access$0(this$1)).isDisposed()))
    {
      InvisibleContextElementsPart.access$8(InvisibleContextElementsPart.4.access$0(this$1)).setText(NLS.bind(Messages.InvisibleContextElementsPart_Invisible_elements, 
        Integer.valueOf(val$allInvisibleElements.size())));
      InvisibleContextElementsPart.access$8(InvisibleContextElementsPart.4.access$0(this$1)).layout();
      if (val$allInvisibleElements.size() == 0)
      {
        InvisibleContextElementsPart.access$8(InvisibleContextElementsPart.4.access$0(this$1)).setExpanded(false);
        InvisibleContextElementsPart.access$8(InvisibleContextElementsPart.4.access$0(this$1)).setEnabled(false);
      }
      else
      {
        InvisibleContextElementsPart.access$8(InvisibleContextElementsPart.4.access$0(this$1)).setEnabled(true);
      }
    }
    if ((InvisibleContextElementsPart.access$7(InvisibleContextElementsPart.4.access$0(this$1)) != null) && (!InvisibleContextElementsPart.access$7(InvisibleContextElementsPart.4.access$0(this$1)).getTable().isDisposed())) {
      InvisibleContextElementsPart.access$7(InvisibleContextElementsPart.4.access$0(this$1)).setInput(val$allInvisibleElements);
    }
  }
}

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

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

class ContextEditorFormPage$4
  implements SelectionListener
{
  ContextEditorFormPage$4(ContextEditorFormPage paramContextEditorFormPage) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.updateFilterThreshold();
  }
  
  public void widgetDefaultSelected(SelectionEvent e) {}
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.context.core.AbstractContextListener;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextChangeEvent;
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.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.progress.IProgressService;

public class InvisibleContextElementsPart
{
  private static void collectItemData(TreeItem[] items, Set<Object> allVisible)
  {
    TreeItem[] arrayOfTreeItem = items;int j = items.length;
    for (int i = 0; i < j; i++)
    {
      TreeItem item = arrayOfTreeItem[i];
      allVisible.add(item.getData());
      collectItemData(item.getItems(), allVisible);
    }
  }
  
  private final class InteractionElementTableSorter
    extends ViewerSorter
  {
    private int criteria = 0;
    private boolean isDecending = true;
    private final ITableLabelProvider labelProvider;
    
    public InteractionElementTableSorter(ITableLabelProvider labelProvider)
    {
      this.labelProvider = labelProvider;
    }
    
    public int compare(Viewer viewer, Object e1, Object e2)
    {
      int result = 0;
      
      String value1 = labelProvider.getColumnText(e1, criteria);
      String value2 = labelProvider.getColumnText(e2, criteria);
      if ((value1 == null) && (value2 != null)) {
        result = -1;
      } else if ((value1 != null) && (value2 == null)) {
        result = 1;
      } else if ((value1 != null) && (value2 != null)) {
        result = value1.compareTo(value2);
      }
      return isDecending() ? result * -1 : result;
    }
    
    public boolean isDecending()
    {
      return isDecending;
    }
    
    public void setCriteria(int index)
    {
      if (criteria == index) {
        isDecending = (!isDecending);
      } else {
        isDecending = false;
      }
      criteria = index;
    }
  }
  
  private final AbstractContextListener CONTEXT_LISTENER = new AbstractContextListener()
  {
    public void contextChanged(ContextChangeEvent event)
    {
      switch (event.getEventKind())
      {
      case CLEARED: 
        if (InvisibleContextElementsPart.this.isActiveTask()) {
          InvisibleContextElementsPart.this.addToolbarActions();
        }
        break;
      case DEACTIVATED: 
        toolbarManager.removeAll();
        toolbarManager.update(true);
      }
    }
  };
  private TableViewer invisibleTable;
  private Section invisibleSection;
  private CommonViewer commonViewer;
  private final IInteractionContext context;
  private ToolBarManager toolbarManager;
  
  private final class InteractionElementTableLabelProvider
    extends LabelProvider
    implements ITableLabelProvider
  {
    private InteractionElementTableLabelProvider() {}
    
    public String getText(Object element)
    {
      if ((element instanceof IInteractionElement)) {
        return ((IInteractionElement)element).getHandleIdentifier();
      }
      return super.getText(element);
    }
    
    public Image getColumnImage(Object element, int columnIndex)
    {
      return null;
    }
    
    public String getColumnText(Object element, int columnIndex)
    {
      if ((element instanceof IInteractionElement))
      {
        if (columnIndex == 0) {
          return ((IInteractionElement)element).getHandleIdentifier();
        }
        if (columnIndex == 1) {
          return ((IInteractionElement)element).getContentType();
        }
      }
      return "";
    }
  }
  
  private final class RemoveInvisibleAction
    extends Action
  {
    public RemoveInvisibleAction()
    {
      setText(Messages.ContextEditorFormPage_Remove_Invisible_);
      setToolTipText(Messages.ContextEditorFormPage_Remove_Invisible_);
      setImageDescriptor(TasksUiImages.CONTEXT_CLEAR);
    }
    
    public void run()
    {
      if (commonViewer == null)
      {
        MessageDialog.openWarning(WorkbenchUtil.getShell(), Messages.ContextEditorFormPage_Remove_Invisible, 
          Messages.ContextEditorFormPage_Activate_task_to_remove_invisible);
        return;
      }
      boolean confirmed = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), 
        Messages.ContextEditorFormPage_Remove_Invisible, 
        Messages.ContextEditorFormPage_Remove_every_element_not_visible);
      if (confirmed) {
        if (ContextCore.getContextManager().isContextActive()) {
          try
          {
            final Collection<Object> allVisible = InvisibleContextElementsPart.this.getAllVisibleElementsInContextPage();
            PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress()
            {
              public void run(IProgressMonitor monitor)
                throws InvocationTargetException, InterruptedException
              {
                monitor.beginTask(Messages.InvisibleContextElementsPart_Collecting_all_invisible, 
                  -1);
                if (allVisible != null)
                {
                  final List<IInteractionElement> allToRemove = InvisibleContextElementsPart.this.getAllInvisibleElements(context, 
                    allVisible);
                  Display.getDefault().asyncExec(new Runnable()
                  {
                    public void run()
                    {
                      ContextCorePlugin.getContextManager().deleteElements(allToRemove, true);
                    }
                  });
                }
                else
                {
                  MessageDialog.openInformation(Display.getCurrent().getActiveShell(), 
                    Messages.ContextEditorFormPage_Remove_Invisible, 
                    Messages.ContextEditorFormPage_No_context_active);
                }
              }
            });
          }
          catch (InvocationTargetException e)
          {
            StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", e.getMessage(), e));
          }
          catch (InterruptedException e)
          {
            StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", e.getMessage(), e));
          }
        } else {
          MessageDialog.openInformation(Display.getCurrent().getActiveShell(), 
            Messages.ContextEditorFormPage_Remove_Invisible, 
            Messages.ContextEditorFormPage_No_context_active);
        }
      }
    }
  }
  
  public InvisibleContextElementsPart(CommonViewer commonViewer)
  {
    this.commonViewer = commonViewer;
    context = ContextCore.getContextManager().getActiveContext();
    ContextCore.getContextManager().addListener(CONTEXT_LISTENER);
  }
  
  public InvisibleContextElementsPart(CommonViewer commonViewer, IInteractionContext context)
  {
    this.commonViewer = commonViewer;
    this.context = context;
    ContextCore.getContextManager().addListener(CONTEXT_LISTENER);
  }
  
  public Control createControl(FormToolkit toolkit, Composite composite)
  {
    invisibleSection = toolkit.createSection(composite, 258);
    invisibleSection.setText(NLS.bind(Messages.InvisibleContextElementsPart_Invisible_elements, "0"));
    invisibleSection.setEnabled(false);
    
    Composite toolbarComposite = toolkit.createComposite(invisibleSection);
    toolbarComposite.setBackground(null);
    invisibleSection.setTextClient(toolbarComposite);
    RowLayout rowLayout = new RowLayout();
    marginTop = 0;
    marginBottom = 0;
    toolbarComposite.setLayout(rowLayout);
    
    toolbarManager = new ToolBarManager(8388608);
    toolbarManager.createControl(toolbarComposite);
    if (isActiveTask()) {
      addToolbarActions();
    }
    Composite invisibleSectionClient = toolkit.createComposite(invisibleSection);
    invisibleSectionClient.setLayout(new GridLayout());
    invisibleSection.setClient(invisibleSectionClient);
    
    Composite tableComposite = toolkit.createComposite(invisibleSectionClient);
    GridDataFactory.fillDefaults().hint(450, 200).grab(true, false).applyTo(tableComposite);
    TableColumnLayout layout = new TableColumnLayout();
    tableComposite.setLayout(layout);
    
    invisibleTable = new TableViewer(tableComposite, 101122);
    
    invisibleTable.setColumnProperties(new String[] { Messages.InvisibleContextElementsPart_Structure_handle, 
      Messages.InvisibleContextElementsPart_Structure_kind });
    invisibleTable.getTable().setHeaderVisible(true);
    
    Table table = invisibleTable.getTable();
    toolkit.adapt(table);
    table.setMenu(null);
    
    InteractionElementTableLabelProvider labelProvider = new InteractionElementTableLabelProvider(null);
    invisibleTable.setLabelProvider(labelProvider);
    invisibleTable.setContentProvider(new IStructuredContentProvider()
    {
      public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
      
      public void dispose() {}
      
      public Object[] getElements(Object inputElement)
      {
        if ((inputElement instanceof Collection)) {
          return ((Collection)inputElement).toArray();
        }
        return new Object[0];
      }
    });
    InteractionElementTableSorter invisibleTableSorter = new InteractionElementTableSorter(labelProvider);
    invisibleTableSorter.setCriteria(0);
    invisibleTable.setSorter(invisibleTableSorter);
    createColumn(layout, 0, Messages.InvisibleContextElementsPart_Structure_handle, 340, table, 
      invisibleTableSorter);
    createColumn(layout, 1, Messages.InvisibleContextElementsPart_Structure_kind, 100, table, invisibleTableSorter);
    table.setSortColumn(table.getColumn(0));
    table.setSortDirection(1024);
    
    Collection<Object> allVisible = getAllVisibleElementsInContextPage();
    if (allVisible != null) {
      updateInvisibleSectionInBackground(context, allVisible);
    }
    return invisibleSection;
  }
  
  private boolean isActiveTask()
  {
    if (ContextCore.getContextManager().isContextActive())
    {
      IInteractionContext activeContext = ContextCore.getContextManager().getActiveContext();
      if ((((context instanceof ContextWrapper)) && (((ContextWrapper)context).isForSameTaskAs(activeContext))) || 
        (context.equals(activeContext))) {
        return true;
      }
    }
    return false;
  }
  
  private void addToolbarActions()
  {
    toolbarManager.add(new RemoveInvisibleAction());
    toolbarManager.markDirty();
    toolbarManager.update(true);
  }
  
  private void createColumn(TableColumnLayout layout, final int index, String label, int weight, final Table table, final InteractionElementTableSorter invisibleTableSorter)
  {
    final TableColumn column = new TableColumn(table, 16384, index);
    column.setText(label);
    column.setToolTipText(label);
    column.setResizable(true);
    
    layout.setColumnData(column, new ColumnPixelData(weight, true));
    
    column.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        invisibleTableSorter.setCriteria(index);
        table.setSortColumn(column);
        if (invisibleTableSorter.isDecending()) {
          table.setSortDirection(128);
        } else {
          table.setSortDirection(1024);
        }
        invisibleTable.refresh();
      }
    });
  }
  
  public void updateInvisibleElementsSection()
  {
    Collection<Object> allVisible = getAllVisibleElementsInContextPage();
    if (allVisible != null) {
      updateInvisibleSectionInBackground(context, allVisible);
    }
  }
  
  private void updateInvisibleSectionInBackground(final IInteractionContext context, final Collection<Object> allVisible)
  {
    Job j = new Job(Messages.InvisibleContextElementsPart_Updating_invisible_element_list)
    {
      protected IStatus run(IProgressMonitor monitor)
      {
        monitor.beginTask(Messages.InvisibleContextElementsPart_Computing_invisible_elements, 
          -1);
        final List<IInteractionElement> allInvisibleElements = InvisibleContextElementsPart.this.getAllInvisibleElements(context, allVisible);
        Display.getDefault().asyncExec(new Runnable()
        {
          public void run()
          {
            if ((invisibleSection != null) && (!invisibleSection.isDisposed()))
            {
              invisibleSection.setText(NLS.bind(Messages.InvisibleContextElementsPart_Invisible_elements, 
                Integer.valueOf(allInvisibleElements.size())));
              invisibleSection.layout();
              if (allInvisibleElements.size() == 0)
              {
                invisibleSection.setExpanded(false);
                invisibleSection.setEnabled(false);
              }
              else
              {
                invisibleSection.setEnabled(true);
              }
            }
            if ((invisibleTable != null) && (!invisibleTable.getTable().isDisposed())) {
              invisibleTable.setInput(allInvisibleElements);
            }
          }
        });
        return Status.OK_STATUS;
      }
    };
    j.schedule();
  }
  
  private List<IInteractionElement> getAllInvisibleElements(IInteractionContext context, Collection<Object> allVisible)
  {
    if ((context == null) || (allVisible == null)) {
      return Collections.emptyList();
    }
    List<IInteractionElement> allToRemove = context.getAllElements();
    
    List<IInteractionElement> allVisibleElements = new ArrayList();
    for (Object visibleObject : allVisible)
    {
      for (AbstractContextStructureBridge bridge : ContextCorePlugin.getDefault().getStructureBridges().values()) {
        if (bridge != null)
        {
          String handle = bridge.getHandleIdentifier(visibleObject);
          if (handle != null)
          {
            IInteractionElement element = context.get(handle);
            if (element != null) {
              allVisibleElements.add(element);
            }
          }
        }
      }
      AbstractContextStructureBridge bridge = ContextCorePlugin.getDefault().getStructureBridge(
        "resource");
      if (bridge != null)
      {
        String handle = bridge.getHandleIdentifier(visibleObject);
        if (handle != null)
        {
          IInteractionElement element = context.get(handle);
          if (element != null) {
            allVisibleElements.add(element);
          }
        }
      }
    }
    IInteractionElement emptyElement = context.get("");
    if (emptyElement != null) {
      allVisibleElements.add(emptyElement);
    }
    allToRemove.removeAll(allVisibleElements);
    
    return allToRemove;
  }
  
  private Collection<Object> getAllVisibleElementsInContextPage()
  {
    if ((commonViewer == null) || (commonViewer.getTree() == null) || (commonViewer.getTree().isDisposed())) {
      return null;
    }
    Set<Object> allVisible = new HashSet();
    collectItemData(commonViewer.getTree().getItems(), allVisible);
    return allVisible;
  }
  
  protected void setCommonViewer(CommonViewer commonViewer)
  {
    this.commonViewer = commonViewer;
    updateInvisibleElementsSection();
  }
  
  public void dispose()
  {
    ContextCore.getContextManager().removeListener(CONTEXT_LISTENER);
  }
}

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

import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.mylyn.context.core.AbstractContextListener;
import org.eclipse.mylyn.context.core.ContextChangeEvent;

class InvisibleContextElementsPart$1
  extends AbstractContextListener
{
  InvisibleContextElementsPart$1(InvisibleContextElementsPart paramInvisibleContextElementsPart) {}
  
  public void contextChanged(ContextChangeEvent event)
  {
    switch (event.getEventKind())
    {
    case CLEARED: 
      if (InvisibleContextElementsPart.access$0(this$0)) {
        InvisibleContextElementsPart.access$1(this$0);
      }
      break;
    case DEACTIVATED: 
      InvisibleContextElementsPart.access$2(this$0).removeAll();
      InvisibleContextElementsPart.access$2(this$0).update(true);
    }
  }
}

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

import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.forms.editor.IFormPage;

public class ContextPageFactory
  extends AbstractTaskEditorPageFactory
{
  public static String ID_CONTEXT_PAGE_FACTORY = "org.eclipse.mylyn.context.ui.editor.context";
  
  public boolean canCreatePageFor(TaskEditorInput input)
  {
    return true;
  }
  
  public IFormPage createPage(TaskEditor parentEditor)
  {
    return new ContextEditorFormPage(parentEditor, ID_CONTEXT_PAGE_FACTORY, Messages.ContextPageFactory_Context);
  }
  
  public int getPriority()
  {
    return 20;
  }
  
  public Image getPageImage()
  {
    return CommonImages.getImage(TasksUiImages.CONTEXT_ACTIVE_CENTERED);
  }
  
  public String getPageText()
  {
    return Messages.ContextPageFactory_Context;
  }
}

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

import org.eclipse.mylyn.internal.tasks.ui.context.AttachContextHandler;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class ContextEditorFormPage$5
  extends HyperlinkAdapter
{
  ContextEditorFormPage$5(ContextEditorFormPage paramContextEditorFormPage) {}
  
  public void linkActivated(HyperlinkEvent e)
  {
    AttachContextHandler.run(ContextEditorFormPage.access$3(this$0));
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;

final class InvisibleContextElementsPart$RemoveInvisibleAction
  extends Action
{
  public InvisibleContextElementsPart$RemoveInvisibleAction(InvisibleContextElementsPart paramInvisibleContextElementsPart)
  {
    setText(Messages.ContextEditorFormPage_Remove_Invisible_);
    setToolTipText(Messages.ContextEditorFormPage_Remove_Invisible_);
    setImageDescriptor(TasksUiImages.CONTEXT_CLEAR);
  }
  
  public void run()
  {
    if (InvisibleContextElementsPart.access$3(this$0) == null)
    {
      MessageDialog.openWarning(WorkbenchUtil.getShell(), Messages.ContextEditorFormPage_Remove_Invisible, 
        Messages.ContextEditorFormPage_Activate_task_to_remove_invisible);
      return;
    }
    boolean confirmed = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), 
      Messages.ContextEditorFormPage_Remove_Invisible, 
      
1 2 3 4 5

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