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

   String storedUrl = storedHandle.substring(0, delimIndex);
                if (oldUrl.equals(storedUrl))
                {
                  String id = RepositoryTaskHandleUtil.getTaskId(storedHandle);
                  String newHandle = RepositoryTaskHandleUtil.getHandle(newUrl, id);
                  File newFile = ContextCorePlugin.getContextStore().getFileForContext(newHandle);
                  file.renameTo(newFile);
                }
              }
            }
            catch (Exception e)
            {
              StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
                "Could not move context file: " + file.getName(), e));
            }
          }
        }
      }
    }
  }
  
  private void refactorMetaContextHandles(String oldRepositoryUrl, String newRepositoryUrl)
  {
    InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
    ContextCorePlugin.getContextManager().resetActivityMetaContext();
    InteractionContext newMetaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
    for (InteractionEvent event : metaContext.getInteractionHistory())
    {
      if (event.getStructureHandle() != null)
      {
        String storedUrl = RepositoryTaskHandleUtil.getRepositoryUrl(event.getStructureHandle());
        if ((storedUrl != null) && 
          (oldRepositoryUrl.equals(storedUrl)))
        {
          String taskId = RepositoryTaskHandleUtil.getTaskId(event.getStructureHandle());
          if (taskId != null)
          {
            String newHandle = RepositoryTaskHandleUtil.getHandle(newRepositoryUrl, taskId);
            event = new InteractionEvent(event.getKind(), event.getStructureKind(), newHandle, 
              event.getOriginId(), event.getNavigation(), event.getDelta(), 
              event.getInterestContribution(), event.getDate(), event.getEndDate());
          }
        }
      }
      newMetaContext.parseEvent(event);
    }
  }
  
  private void refactorRepositoryLocation(TaskRepository repository, String oldRepositoryUrl, String newRepositoryUrl)
  {
    IPath oldPath = new Path(repository.getConnectorKind() + "-" + CoreUtil.asFileName(oldRepositoryUrl)).append("data");
    IPath newPath = new Path(repository.getConnectorKind() + "-" + CoreUtil.asFileName(newRepositoryUrl)).append("data");
    try
    {
      getTaskStore().move(oldPath, newPath);
    }
    catch (CoreException e)
    {
      StatusHandler.log(new Status(2, "org.eclipse.mylyn.tasks.ui", NLS.bind(
        "Failed to migrate data store for repository {0}", newRepositoryUrl), e));
    }
  }
  
  public ContextStatePersistenceHandler getStateHandler()
  {
    return stateHandler;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.context.tasks.ui.TaskContextStore
 * 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.CoreUtil;
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.internal.context.ui.ContextUiPlugin;
import org.eclipse.mylyn.internal.context.ui.state.EditorStateParticipant;
import org.eclipse.mylyn.internal.tasks.ui.context.RetrieveLatestContextDialog;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskMigrator;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;

class ContextTasksStartupHandler$1
  extends TaskActivationAdapter
{
  public void preTaskDeactivated(ITask task)
  {
    ContextUiPlugin.getEditorStateParticipant().setEnabled(!TaskMigrator.isActive());
  }
  
  public void preTaskActivated(ITask task)
  {
    ContextUiPlugin.getEditorStateParticipant().setEnabled(!TaskMigrator.isActive());
  }
  
  public void taskActivated(ITask task)
  {
    if (CoreUtil.TEST_MODE) {
      return;
    }
    boolean hasLocalContext = ContextCore.getContextManager().hasContext(task.getHandleIdentifier());
    if ((!hasLocalContext) && 
      (AttachmentUtil.hasContextAttachment(task))) {
      RetrieveLatestContextDialog.openQuestion(WorkbenchUtil.getShell(), task);
    }
  }
}

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

import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;

class TaskActivityMonitor$2
  extends 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());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.context.tasks.ui.TaskActivityMonitor.2
 * 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$4
  extends CommonListenerList.Notifier<TaskContextStoreListener>
{
  TaskContextStore$4(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.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.context.tasks.ui;

import org.eclipse.jface.operation.IRunnableWithProgress;

class ContextTasksStartupHandler$2
  implements IRunnableWithProgress
{
  ContextTasksStartupHandler$2(ContextTasksStartupHandler paramContextTasksStartupHandler) {}
  
  /* Error */
  public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
    throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
  {
    // Byte code:
    //   0: aload_1
    //   1: invokestatic 73	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/SubMonitor;
    //   4: astore_2
    //   5: new 41	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator
    //   8: dup
    //   9: invokestatic 78	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getDefault	()Lorg/eclipse/mylyn/internal/context/ui/ContextUiPlugin;
    //   12: invokevirtual 79	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getStateManager	()Lorg/eclipse/mylyn/internal/context/ui/state/ContextStateManager;
    //   15: invokespecial 76	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator:<init>	(Lorg/eclipse/mylyn/internal/context/ui/state/ContextStateManager;)V
    //   18: astore_3
    //   19: aload_3
    //   20: iconst_1
    //   21: invokevirtual 75	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator:setDeleteOldDataEnabled	(Z)V
    //   24: aload_3
    //   25: aload_2
    //   26: invokevirtual 77	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator:migrateContextMementos	(Lorg/eclipse/core/runtime/SubMonitor;)Lorg/eclipse/core/runtime/IStatus;
    //   29: astore 4
    //   31: aload 4
    //   33: invokeinterface 81 1 0
    //   38: ifne +22 -> 60
    //   41: aload 4
    //   43: invokestatic 74	org/eclipse/mylyn/commons/core/StatusHandler:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   46: goto +14 -> 60
    //   49: astore 5
    //   51: aload_1
    //   52: invokeinterface 80 1 0
    //   57: aload 5
    //   59: athrow
    //   60: aload_1
    //   61: invokeinterface 80 1 0
    //   66: return
    // Line number table:
    //   Java source line #180	-> byte code offset #0
    //   Java source line #181	-> byte code offset #5
    //   Java source line #182	-> byte code offset #12
    //   Java source line #181	-> byte code offset #15
    //   Java source line #183	-> byte code offset #19
    //   Java source line #184	-> byte code offset #24
    //   Java source line #185	-> byte code offset #31
    //   Java source line #186	-> byte code offset #41
    //   Java source line #188	-> byte code offset #49
    //   Java source line #189	-> byte code offset #51
    //   Java source line #190	-> byte code offset #57
    //   Java source line #189	-> byte code offset #60
    //   Java source line #191	-> byte code offset #66
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	67	0	this	2
    //   0	67	1	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   4	22	2	progress	org.eclipse.core.runtime.SubMonitor
    //   18	7	3	migrator	ContextMementoMigrator
    //   29	13	4	status	org.eclipse.core.runtime.IStatus
    //   49	9	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	49	49	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.context.tasks.ui.ContextTasksStartupHandler.2
 * 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 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.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
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.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivityListener;

public class ActivityExternalizationParticipant
  extends AbstractExternalizationParticipant
  implements ITaskActivityListener
{
  private boolean isDirty = false;
  private final ExternalizationManager manager;
  private long lastUpdate;
  
  public ActivityExternalizationParticipant(ExternalizationManager manager)
  {
    this.manager = manager;
    MonitorUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent event)
      {
        if (event.getProperty().equals("org.eclipse.mylyn.monitor.activity.tracking.enabled")) {
          ActivityExternalizationParticipant.this.requestSave();
        }
      }
    });
  }
  
  public void execute(IExternalizationContext context, IProgressMonitor monitor)
    throws CoreException
  {
    Assert.isNotNull(context);
    switch (context.getKind())
    {
    case LOAD: 
      if ((ContextCorePlugin.getDefault() != null) && (MonitorUiPlugin.getDefault().isActivityTrackingEnabled()) && 
        (ContextCorePlugin.getContextManager() != null))
      {
        setDirty(false);
        ContextCorePlugin.getContextManager().saveActivityMetaContext();
      }
      break;
    case SNAPSHOT: 
      ContextCorePlugin.getContextManager().loadActivityMetaContext();
      break;
    }
  }
  
  public String getDescription()
  {
    return Messages.ActivityExternalizationParticipant_Activity_Context;
  }
  
  public ISchedulingRule getSchedulingRule()
  {
    return ITasksCoreConstants.ACTIVITY_SCHEDULING_RULE;
  }
  
  public boolean isDirty()
  {
    return isDirty(false);
  }
  
  public boolean isDirty(boolean full)
  {
    synchronized (this)
    {
      return (isDirty) || (full);
    }
  }
  
  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 activityReset() {}
  
  public void elapsedTimeUpdated(ITask task, long newElapsedTime)
  {
    if (System.currentTimeMillis() - lastUpdate > 60000L) {
      requestSave();
    }
  }
  
  private void requestSave()
  {
    setDirty(true);
    manager.requestSave();
    lastUpdate = System.currentTimeMillis();
  }
}

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

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

class ActiveContextExternalizationParticipant$1
  extends AbstractContextListener
{
  ActiveContextExternalizationParticipant$1(ActiveContextExternalizationParticipant paramActiveContextExternalizationParticipant) {}
  
  public void contextChanged(ContextChangeEvent event)
  {
    switch (event.getEventKind())
    {
    case CLEARED: 
      ActiveContextExternalizationParticipant.access$0(this$0, event.getContext());
      break;
    case DEACTIVATED: 
      ActiveContextExternalizationParticipant.access$0(this$0, null);
      this$0.setDirty(false);
    }
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.commons.core.CoreUtil;
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.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.ui.IContextUiStartup;
import org.eclipse.mylyn.internal.context.ui.ContextPopulationStrategy;
import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
import org.eclipse.mylyn.internal.context.ui.state.EditorStateParticipant;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.context.RetrieveLatestContextDialog;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskMigrator;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.tasks.core.IRepositoryModel;
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.data.ITaskDataWorkingCopy;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;

public class ContextTasksStartupHandler
  implements IContextUiStartup
{
  final class TaskContentAdapter
    implements IAdaptable
  {
    private final TaskData taskData;
    private final ITask task;
    
    TaskContentAdapter(TaskData taskData, ITask task)
    {
      this.taskData = taskData;
      this.task = task;
    }
    
    public Object getAdapter(Class adapter)
    {
      if (adapter == ITask.class) {
        return task;
      }
      if (adapter == TaskData.class) {
        return taskData;
      }
      if (adapter == String.class)
      {
        if (taskData != null)
        {
          TaskAttribute attribute = taskData.getRoot().getMappedAttribute("task.common.description");
          if (attribute != null)
          {
            String description = attribute.getValue();
            if ((description != null) && (description.length() > 0)) {
              return description;
            }
          }
          attribute = taskData.getRoot().getMappedAttribute("task.common.comment.new");
          if (attribute != null)
          {
            String description = attribute.getValue();
            if ((description != null) && (description.length() > 0)) {
              return description;
            }
          }
        }
        if ((task instanceof AbstractTask))
        {
          String description = ((AbstractTask)task).getNotes();
          if ((description != null) && (description.length() > 0)) {
            return description;
          }
        }
      }
      return null;
    }
  }
  
  private class ContextActivationListener
    extends AbstractContextListener
  {
    private ContextStatePersistenceHandler stateHandler;
    
    private ContextActivationListener() {}
    
    public void contextChanged(ContextChangeEvent event)
    {
      switch (event.getEventKind())
      {
      case ACTIVATED: 
        contextActivated(event);
        break;
      case CLEARED: 
        getStateHandler().activated(event.getContext());
        break;
      case DEACTIVATED: 
        getStateHandler().deactivated(event.getContext());
        break;
      case ELEMENTS_DELETED: 
        getStateHandler().clear(event.getContextHandle(), event.isActiveContext());
      }
    }
    
    private ContextStatePersistenceHandler getStateHandler()
    {
      return ((TaskContextStore)TasksUiPlugin.getContextStore()).getStateHandler();
    }
  }
  
  private static final ITaskActivationListener TASK_ACTIVATION_LISTENER = new TaskActivationAdapter()
  {
    public void preTaskDeactivated(ITask task)
    {
      ContextUiPlugin.getEditorStateParticipant().setEnabled(!TaskMigrator.isActive());
    }
    
    public void preTaskActivated(ITask task)
    {
      ContextUiPlugin.getEditorStateParticipant().setEnabled(!TaskMigrator.isActive());
    }
    
    public void taskActivated(ITask task)
    {
      if (CoreUtil.TEST_MODE) {
        return;
      }
      boolean hasLocalContext = ContextCore.getContextManager().hasContext(task.getHandleIdentifier());
      if ((!hasLocalContext) && 
        (AttachmentUtil.hasContextAttachment(task))) {
        RetrieveLatestContextDialog.openQuestion(WorkbenchUtil.getShell(), task);
      }
    }
  };
  private final ContextPopulationStrategy contextPopulationStrategy = new ContextPopulationStrategy();
  private final ContextActivationListener contextActivationListener = new ContextActivationListener(null);
  
  public void lazyStartup()
  {
    ExternalizationManager externalizationManager = TasksUiPlugin.getExternalizationManager();
    ActiveContextExternalizationParticipant activeContextExternalizationParticipant = new ActiveContextExternalizationParticipant(
      externalizationManager);
    externalizationManager.addParticipant(activeContextExternalizationParticipant);
    activeContextExternalizationParticipant.registerListeners();
    try
    {
      PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress()
      {
        /* Error */
        public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
          throws InvocationTargetException, InterruptedException
        {
          // Byte code:
          //   0: aload_1
          //   1: invokestatic 73	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/SubMonitor;
          //   4: astore_2
          //   5: new 41	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator
          //   8: dup
          //   9: invokestatic 78	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getDefault	()Lorg/eclipse/mylyn/internal/context/ui/ContextUiPlugin;
          //   12: invokevirtual 79	org/eclipse/mylyn/internal/context/ui/ContextUiPlugin:getStateManager	()Lorg/eclipse/mylyn/internal/context/ui/state/ContextStateManager;
          //   15: invokespecial 76	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator:<init>	(Lorg/eclipse/mylyn/internal/context/ui/state/ContextStateManager;)V
          //   18: astore_3
          //   19: aload_3
          //   20: iconst_1
          //   21: invokevirtual 75	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator:setDeleteOldDataEnabled	(Z)V
          //   24: aload_3
          //   25: aload_2
          //   26: invokevirtual 77	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator:migrateContextMementos	(Lorg/eclipse/core/runtime/SubMonitor;)Lorg/eclipse/core/runtime/IStatus;
          //   29: astore 4
          //   31: aload 4
          //   33: invokeinterface 81 1 0
          //   38: ifne +22 -> 60
          //   41: aload 4
          //   43: invokestatic 74	org/eclipse/mylyn/commons/core/StatusHandler:log	(Lorg/eclipse/core/runtime/IStatus;)V
          //   46: goto +14 -> 60
          //   49: astore 5
          //   51: aload_1
          //   52: invokeinterface 80 1 0
          //   57: aload 5
          //   59: athrow
          //   60: aload_1
          //   61: invokeinterface 80 1 0
          //   66: return
          // Line number table:
          //   Java source line #180	-> byte code offset #0
          //   Java source line #181	-> byte code offset #5
          //   Java source line #182	-> byte code offset #12
          //   Java source line #181	-> byte code offset #15
          //   Java source line #183	-> byte code offset #19
          //   Java source line #184	-> byte code offset #24
          //   Java source line #185	-> byte code offset #31
          //   Java source line #186	-> byte code offset #41
          //   Java source line #188	-> byte code offset #49
          //   Java source line #189	-> byte code offset #51
          //   Java source line #190	-> byte code offset #57
          //   Java source line #189	-> byte code offset #60
          //   Java source line #191	-> byte code offset #66
          // Local variable table:
          //   start	length	slot	name	signature
          //   0	67	0	this	2
          //   0	67	1	monitor	org.eclipse.core.runtime.IProgressMonitor
          //   4	22	2	progress	org.eclipse.core.runtime.SubMonitor
          //   18	7	3	migrator	ContextMementoMigrator
          //   29	13	4	status	org.eclipse.core.runtime.IStatus
          //   49	9	5	localObject	Object
          // Exception table:
          //   from	to	target	type
          //   0	49	49	finally
        }
      });
    }
    catch (InvocationTargetException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.context.ui", 
        "Unexpected error migrating context state", e));
    }
    catch (InterruptedException localInterruptedException) {}
    TasksUi.getTaskActivityManager().addActivationListener(TASK_ACTIVATION_LISTENER);
    
    ContextUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent event)
      {
        if ("org.eclipse.mylyn.ide.ui.expansion.auto.manage".equals(event.getProperty())) {
          ContextTasksStartupHandler.this.updateAutoManageExpansionPreference();
        }
      }
    });
    updateAutoManageExpansionPreference();
    
    ContextCore.getContextManager().addListener(contextActivationListener);
  }
  
  private void lazyStop()
  {
    ContextCore.getContextManager().removeListener(contextActivationListener);
    
    TasksUi.getTaskActivityManager().removeActivationListener(TASK_ACTIVATION_LISTENER);
  }
  
  private void updateAutoManageExpansionPreference()
  {
    boolean value = ContextUiPlugin.getDefault()
      .getPreferenceStore()
      .getBoolean("org.eclipse.mylyn.ide.ui.expansion.auto.manage");
    TasksUiPlugin.getDefault()
      .getPreferenceStore()
      .setValue("org.eclipse.mylyn.tasks.ui.auto.expand", value);
  }
  
  void contextActivated(ContextChangeEvent event)
  {
    if (contextPopulationStrategy.isDisabled()) {
      return;
    }
    if (event.getContext().getAllElements().isEmpty())
    {
      ITask task = TasksUi.getRepositoryModel().getTask(event.getContextHandle());
      if (task != null) {
        try
        {
          TaskData taskData;
          TaskData taskData;
          if (TasksUiPlugin.getTaskDataManager().hasTaskData(task)) {
            taskData = TasksUiPlugin.getTaskDataManager().getWorkingCopy(task, false).getLocalData();
          } else {
            taskData = null;
          }
          IInteractionContext context = event.getContext();
          IAdaptable input = new TaskContentAdapter(taskData, task);
          contextPopulationStrategy.populateContext(context, input);
        }
        catch (CoreException e)
        {
          ContextUiPlugin.getDefault().getLog().log(e.getStatus());
        }
      }
    }
  }
}

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

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;

final class ContextTasksStartupHandler$TaskContentAdapter
  implements IAdaptable
{
  private final TaskData taskData;
  private final ITask task;
  
  ContextTasksStartupHandler$TaskContentAdapter(ContextTasksStartupHandler paramContextTasksStartupHandler, TaskData taskData, ITask task)
  {
    this.taskData = taskData;
    this.task = task;
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == ITask.class) {
      return task;
    }
    if (adapter == TaskData.class) {
      return taskData;
    }
    if (adapter == String.class)
    {
      if (taskData != null)
      {
        TaskAttribute attribute = taskData.getRoot().getMappedAttribute("task.common.description");
        if (attribute != null)
        {
          String description = attribute.getValue();
          if ((description != null) && (description.length() > 0)) {
            return description;
          }
        }
        attribute = taskData.getRoot().getMappedAttribute("task.common.comment.new");
        if (attribute != null)
        {
          String description = attribute.getValue();
          if ((description != null) && (description.length() > 0)) {
            return description;
          }
        }
      }
      if ((task instanceof AbstractTask))
      {
        String description = ((AbstractTask)task).getNotes();
        if ((description != null) && (description.length() > 0)) {
          return description;
        }
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.context.tasks.ui.ContextTasksStartupHandler.TaskContentAdapter
 * 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$5
  extends CommonListenerList.Notifier<TaskContextStoreListener>
{
  TaskContextStore$5(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.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.context.tasks.ui;

import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.tasks.core.ITask;

public class TaskContextStoreEvent
{
  private final ITask sourceTask;
  private final ITask targetTask;
  private final Kind kind;
  
  public static enum Kind
  {
    CLEAR,  COPY,  DELETE,  MERGE,  MOVE,  SAVE;
  }
  
  public TaskContextStoreEvent(Kind kind, ITask sourceTask, ITask targetTask)
  {
    Assert.isNotNull(kind);
    Assert.isNotNull(sourceTask);
    this.kind = kind;
    this.sourceTask = sourceTask;
    this.targetTask = targetTask;
  }
  
  public TaskContextStoreEvent(Kind kind, ITask sourceTask)
  {
    this(kind, sourceTask, null);
  }
  
  public Kind getKind()
  {
    return kind;
  }
  
  public ITask getSourceTask()
  {
    return sourceTask;
  }
  
  public ITask getTargetTask()
  {
    return targetTask;
  }
}

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

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

class ContextTasksStartupHandler$3
  implements IPropertyChangeListener
{
  ContextTasksStartupHandler$3(ContextTasksStartupHandler paramContextTasksStartupHandler) {}
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if ("org.eclipse.mylyn.ide.ui.expansion.auto.manage".equals(event.getProperty())) {
      ContextTasksStartupHandler.access$0(this$0);
    }
  }
}

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

import java.io.IOException;
import java.io.StringReader;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.internal.context.core.InteractionContext;
import org.eclipse.mylyn.internal.context.ui.state.ContextState;
import org.eclipse.mylyn.internal.context.ui.state.ContextStateManager;
import org.eclipse.mylyn.tasks.core.IRepositoryModel;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.XMLMemento;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.service.prefs.BackingStoreException;

public class ContextMementoMigrator
{
  @Deprecated
  public static final String PREFIX_TASK_TO_PERSPECTIVE = "org.eclipse.mylyn.ui.perspectives.task.";
  @Deprecated
  public static final String EDITOR_MEMENTO_PREFS_PREFIX = "editors.task.";
  private final ContextStateManager stateManager;
  private boolean deleteOldDataEnabled;
  
  public ContextMementoMigrator(ContextStateManager stateManager)
  {
    this.stateManager = stateManager;
  }
  
  public void setDeleteOldDataEnabled(boolean deleteOldDataEnabled)
  {
    this.deleteOldDataEnabled = deleteOldDataEnabled;
  }
  
  public boolean isDeleteOldDataEnabled()
  {
    return deleteOldDataEnabled;
  }
  
  public IStatus migrateContextMementos(SubMonitor monitor)
  {
    MultiStatus status = new MultiStatus("org.eclipse.mylyn.context.ui", 0, 
      "Errors migrating saved editors and perspective settings", null);
    
    ScopedPreferenceStore perspectivePreferenceStore = new ScopedPreferenceStore(new InstanceScope(), 
      "org.eclipse.mylyn.context.ui");
    ScopedPreferenceStore editorPreferenceStore = new ScopedPreferenceStore(new InstanceScope(), 
      "org.eclipse.mylyn.resources.ui");
    
    IEclipsePreferences[] perspectiveNodes = perspectivePreferenceStore.getPreferenceNodes(false);
    IEclipsePreferences[] editorNodes = editorPreferenceStore.getPreferenceNodes(false);
    
    monitor.beginTask("Migrating context information", 100);
    String[] arrayOfString1;
    int j;
    int i;
    if (editorNodes.length > 0) {
      try
      {
        String[] keys = editorNodes[0].keys();
        SubMonitor progress = monitor.newChild(80);
        progress.setWorkRemaining(keys.length);
        j = (arrayOfString1 = keys).length;
        for (i = 0; i < j; i++)
        {
          String key = arrayOfString1[i];
          if (key.startsWith("editors.task."))
          {
            String contextHandle = key.substring("editors.task.".length());
            String mementoString = editorPreferenceStore.getString(key);
            if ((mementoString != null) && (!mementoString.trim().equals(""))) {
              try
              {
                IMemento oldMemento = XMLMemento.createReadRoot(new StringReader(mementoString));
                InteractionContext context = new InteractionContext(contextHandle, 
                  ContextCore.getCommonContextScaling());
                ContextState state = stateManager.createMemento(context, contextHandle);
                
                IMemento newMemnto = state.createMemento("org.eclipse.mylyn.context.ui.editors");
                newMemnto.putMemento(oldMemento);
                
                String perspectiveId = perspectivePreferenceStore.getString("org.eclipse.mylyn.ui.perspectives.task." + 
                  contextHandle);
                if ((perspectiveId != null) && (perspectiveId.length() > 0))
                {
                  IMemento perspectiveMemento = state.createMemento("org.eclipse.mylyn.context.ui.perspectives");
                  perspectiveMemento.putString("activeId", 
                    perspectiveId);
                }
                ITask task = TasksUi.getRepositoryModel().getTask(contextHandle);
                if (task != null) {
                  write(state, task);
                }
              }
              catch (Exception e)
              {
                status.add(new Status(2, "org.eclipse.mylyn.context.ui", NLS.bind(
                  "Migration of editor memento failed for {0}", contextHandle), e));
              }
            }
            if (isDeleteOldDataEnabled())
            {
              editorNodes[0].remove(key);
              if (perspectiveNodes.length > 0) {
                perspectiveNodes[0].remove("org.eclipse.mylyn.ui.perspectives.task." + contextHandle);
              }
            }
          }
          progress.worked(1);
        }
        progress.done();
      }
      catch (BackingStoreException e)
      {
        status.add(new Status(4, "org.eclipse.mylyn.context.ui", "Reading of editor mementos failed", e));
      }
    }
    if (perspectiveNodes.length > 0) {
      try
      {
        String[] keys = perspectiveNodes[0].keys();
        SubMonitor progress = monitor.newChild(20);
        progress.setWorkRemaining(keys.length);
        j = (arrayOfString1 = keys).length;
        for (i = 0; i < j; i++)
        {
          String key = arrayOfString1[i];
          if ((key.startsWith("org.eclipse.mylyn.ui.perspectives.task.")) && 
            (!key.equals("org.eclipse.mylyn.ui.perspectives.task.none")))
          {
            String contextHandle = key.substring("org.eclipse.mylyn.ui.perspectives.task.".length());
            String perspectiveId = perspectivePreferenceStore.getString(key);
            if ((perspectiveId != null) && (perspectiveId.length() > 0)) {
              try
              {
                InteractionContext context = new InteractionContext(contextHandle, 
                  ContextCore.getCommonContextScaling());
                ContextState state = stateManager.createMemento(context, contextHandle);
                
                IMemento perspectiveMemento = state.createMemento("org.eclipse.mylyn.context.ui.perspectives");
                perspectiveMemento.putString("activeId", perspectiveId);
                
                ITask task = TasksUi.getRepositoryModel().getTask(contextHandle);
                if (task != null) {
                  write(state, task);
                }
              }
              catch (Exception e)
              {
                status.add(new Status(2, "org.eclipse.mylyn.context.ui", NLS.bind(
                  "Migration of editor memento failed for {0}", contextHandle), e));
              }
            }
            if (isDeleteOldDataEnabled()) {
              perspectiveNodes[0].remove(key);
            }
          }
          progress.worked(1);
        }
        progress.done();
      }
      catch (BackingStoreException e)
      {
        status.add(new Status(4, "org.eclipse.mylyn.context.ui", 
          "Reading of perspective mementos failed", e));
      }
    }
    try
    {
      editorPreferenceStore.save();
    }
    catch (IOException e)
    {
      status.add(new Status(4, "org.eclipse.mylyn.context.ui", "Saving of preference store failed", e));
    }
    try
    {
      perspectivePreferenceStore.save();
    }
    catch (IOException e)
    {
      status.add(new Status(4, "org.eclipse.mylyn.context.ui", "Saving of preference store failed", e));
    }
    return status;
  }
  
  /* Error */
  private void write(ContextState state, ITask task)
    throws IOException, org.eclipse.core.runtime.CoreException
  {
    // Byte code:
    //   0: invokestatic 280	org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin:getContextStore	()Lorg/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore;
    //   3: checkcast 145	org/eclipse/mylyn/internal/context/tasks/ui/TaskContextStore
    //   6: aload_2
    //   7: invokevirtual 276	org/eclipse/mylyn/internal/context/tasks/ui/TaskContextStore:getStorable	(Lorg/eclipse/mylyn/tasks/core/ITask;)Lorg/eclipse/mylyn/commons/core/storage/ICommonStorable;
    //   10: astore_3
    //   11: aload_3
    //   12: ldc_w 127
    //   15: invokeinterface 291 2 0
    //   20: ifne +57 -> 77
    //   23: aload_3
    //   24: ldc_w 127
    //   27: aconst_null
    //   28: invokeinterface 292 3 0
    //   33: astore 4
    //   35: aload_0
    //   36: getfield 251	org/eclipse/mylyn/internal/context/tasks/ui/ContextMementoMigrator:stateManager	Lorg/eclipse/mylyn/internal/context/ui/state/ContextStateManager;
    //   39: aload 4
    //   41: aload_1
    //   42: invokevirtual 278	org/eclipse/mylyn/internal/context/ui/state/ContextStateManager:write	(Ljava/io/OutputStream;Lorg/eclipse/mylyn/internal/context/ui/state/ContextState;)V
    //   45: goto +13 -> 58
    //   48: astore 5
    //   50: aload 4
    //   52: invokevirtual 252	java/io/OutputStream:close	()V
    //   55: aload 5
    //   57: athrow
    //   58: aload 4
    //   60: invokevirtual 252	java/io/OutputStream:clo
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-2019. Infinite Loop Ltd