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

  //   45	7	5	e	org.eclipse.core.runtime.CoreException
    //   57	17	6	localObject	Object
    //   93	1	8	localOperationCanceledException	org.eclipse.core.runtime.OperationCanceledException
    // Exception table:
    //   from	to	target	type
    //   30	42	45	org/eclipse/core/runtime/CoreException
    //   30	57	57	finally
    //   11	90	93	org/eclipse/core/runtime/OperationCanceledException
    //   11	90	102	java/io/IOException
  }
}

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

import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.wizards.QueryWizardDialog;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.swt.widgets.Shell;

class TasksUiInternal$11
  extends QueryWizardDialog
{
  private static final String DIALOG_SETTINGS = "EditQueryWizardWizard";
  
  TasksUiInternal$11(Shell $anonymous0, IWizard $anonymous1, IRepositoryQuery paramIRepositoryQuery)
  {
    super($anonymous0, $anonymous1);
  }
  
  protected IDialogSettings getDialogBoundsSettings()
  {
    IDialogSettings settings = TasksUiPlugin.getDefault().getDialogSettings();
    String settingsSectionId = "EditQueryWizardWizard." + val$query.getRepositoryUrl();
    IDialogSettings section = settings.getSection(settingsSectionId);
    if (section == null) {
      section = settings.addNewSection(settingsSectionId);
    }
    return section;
  }
}

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

import org.eclipse.core.runtime.IProgressMonitor;

class TasksUiInternal$1$2
  implements Runnable
{
  TasksUiInternal$1$2(TasksUiInternal.1 param1) {}
  
  public void run()
  {
    this$1.getWrappedProgressMonitor().done();
  }
}

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

import org.eclipse.core.runtime.IStatus;

class TasksUiInternal$9
  implements Runnable
{
  TasksUiInternal$9(String paramString, IStatus paramIStatus) {}
  
  public void run()
  {
    TasksUiInternal.displayStatus(val$title, val$status);
  }
}

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

import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.ProgressMonitorWrapper;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.commons.core.CoreUtil;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.identity.core.Account;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.ui.CommonUiUtil;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskCategory;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.ITaskJobFactory;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.core.UncategorizedTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataState;
import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizationScheduler;
import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizationScheduler.Synchronizer;
import org.eclipse.mylyn.internal.tasks.ui.OpenRepositoryTaskJob;
import org.eclipse.mylyn.internal.tasks.ui.TaskJobFactory;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.internal.tasks.ui.wizards.MultiRepositoryAwareWizard;
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskWizardInternal;
import org.eclipse.mylyn.internal.tasks.ui.wizards.QueryWizardDialog;
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard;
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.activity.AbstractTaskActivityMonitor;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.ITaskDataManager;
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskHistory;
import org.eclipse.mylyn.tasks.core.data.TaskRevision;
import org.eclipse.mylyn.tasks.core.data.TaskRevision.Change;
import org.eclipse.mylyn.tasks.core.sync.SynchronizationJob;
import org.eclipse.mylyn.tasks.core.sync.TaskJob;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.services.IServiceLocator;
import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
import org.eclipse.ui.statushandlers.StatusAdapter;
import org.eclipse.ui.statushandlers.StatusManager;

public class TasksUiInternal
{
  private static SynchronizationScheduler synchronizationScheduler = new SynchronizationScheduler();
  private static final TaskDropHandler taskDropHandler = new TaskDropHandler();
  public static final int SWT_SHEET = 268435456;
  public static final String ID_MENU_ACTIVE_TASK = "org.eclipse.mylyn.tasks.ui.menus.activeTask";
  
  public static MultiRepositoryAwareWizard createNewTaskWizard(ITaskMapping taskSelection)
  {
    return new NewTaskWizardInternal(taskSelection);
  }
  
  public static Command getConfiguredDiscoveryWizardCommand()
  {
    ICommandService service = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
    Command discoveryWizardCommand = service.getCommand("org.eclipse.mylyn.tasks.ui.discoveryWizardCommand");
    if (discoveryWizardCommand != null)
    {
      IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getService(
        IHandlerService.class);
      EvaluationContext evaluationContext = createDiscoveryWizardEvaluationContext(handlerService);
      if (!discoveryWizardCommand.isEnabled()) {
        discoveryWizardCommand.setEnabled(evaluationContext);
      }
    }
    return discoveryWizardCommand;
  }
  
  public static EvaluationContext createDiscoveryWizardEvaluationContext(IHandlerService handlerService)
  {
    EvaluationContext evaluationContext = new EvaluationContext(handlerService.getCurrentState(), Platform.class);
    
    evaluationContext.addVariable("platform", Platform.class);
    return evaluationContext;
  }
  
  public static ImageDescriptor getPriorityImage(ITask task)
  {
    if (task.isCompleted()) {
      return CommonImages.COMPLETE;
    }
    return TasksUiImages.getImageDescriptorForPriority(ITask.PriorityLevel.fromString(task.getPriority()));
  }
  
  public static List<TaskEditor> getActiveRepositoryTaskEditors()
  {
    List<TaskEditor> repositoryTaskEditors = new ArrayList();
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    IWorkbenchWindow[] arrayOfIWorkbenchWindow1;
    int j = (arrayOfIWorkbenchWindow1 = windows).length;
    for (int i = 0; i < j; i++)
    {
      IWorkbenchWindow window = arrayOfIWorkbenchWindow1[i];
      IEditorReference[] editorReferences = window.getActivePage().getEditorReferences();
      IEditorReference[] arrayOfIEditorReference1;
      int m = (arrayOfIEditorReference1 = editorReferences).length;
      for (int k = 0; k < m; k++)
      {
        IEditorReference editorReference = arrayOfIEditorReference1[k];
        try
        {
          if ((editorReference.getEditorInput() instanceof TaskEditorInput))
          {
            TaskEditorInput input = (TaskEditorInput)editorReference.getEditorInput();
            if (input.getTask() != null)
            {
              IEditorPart editorPart = editorReference.getEditor(false);
              if ((editorPart instanceof TaskEditor)) {
                repositoryTaskEditors.add((TaskEditor)editorPart);
              }
            }
          }
        }
        catch (PartInitException localPartInitException) {}
      }
    }
    return repositoryTaskEditors;
  }
  
  public static IProgressMonitor getUiMonitor(IProgressMonitor monitor)
  {
    new ProgressMonitorWrapper(monitor)
    {
      public void beginTask(final String name, final int totalWork)
      {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            getWrappedProgressMonitor().beginTask(name, totalWork);
          }
        });
      }
      
      public void done()
      {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            getWrappedProgressMonitor().done();
          }
        });
      }
      
      public void subTask(final String name)
      {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            getWrappedProgressMonitor().subTask(name);
          }
        });
      }
      
      public void worked(final int work)
      {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            getWrappedProgressMonitor().worked(work);
          }
        });
      }
    };
  }
  
  public static void openEditor(TaskCategory category)
  {
    String name = category.getSummary();
    InputDialog dialog = new InputDialog(WorkbenchUtil.getShell(), Messages.TasksUiInternal_Rename_Category_Title, 
      Messages.TasksUiInternal_Rename_Category_Message, name, new IInputValidator()
      {
        public String isValid(String newName)
        {
          if ((newName.trim().length() == 0) || (newName.equals(TasksUiInternal.this))) {
            return "";
          }
          Set<AbstractTaskCategory> categories = TasksUiPlugin.getTaskList().getCategories();
          for (AbstractTaskCategory category : categories) {
            if (newName.equals(category.getSummary())) {
              return Messages.TasksUiInternal_Rename_Category_Name_already_exists_Error;
            }
          }
          return null;
        }
      });
    if (dialog.open() == 0) {
      TasksUiPlugin.getTaskList().renameContainer(category, dialog.getValue());
    }
  }
  
  public static void refreshAndOpenTaskListElement(IRepositoryElement element)
  {
    if ((element instanceof ITask))
    {
      AbstractTask task = (AbstractTask)element;
      if ((task instanceof LocalTask))
      {
        TasksUiUtil.openTask(task);
      }
      else
      {
        String repositoryKind = task.getConnectorKind();
        AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
          repositoryKind);
        
        TaskRepository repository = TasksUi.getRepositoryManager().getRepository(repositoryKind, 
          task.getRepositoryUrl());
        if (repository == null)
        {
          displayStatus(Messages.TasksUiInternal_Failed_to_open_task, new Status(4, 
            "org.eclipse.mylyn.tasks.ui", Messages.TasksUiInternal_No_repository_found));
          return;
        }
        if (connector != null)
        {
          boolean opened = false;
          if (TasksUiPlugin.getTaskDataManager().hasTaskData(task)) {
            opened = TasksUiUtil.openTask(task);
          }
          if (!opened) {
            if (connector.canSynchronizeTask(repository, task)) {
              synchronizeTask(connector, task, true, new JobChangeAdapter()
              {
                public void done(IJobChangeEvent event)
                {
                  PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
                  {
                    public void run()
                    {
                      TasksUiUtil.openTask(val$task);
                    }
                  });
                }
              });
            } else {
              TasksUiUtil.openTask(task);
            }
          }
        }
      }
    }
    else if ((element instanceof TaskCategory))
    {
      openEditor((TaskCategory)element);
    }
    else if ((element instanceof IRepositoryQuery))
    {
      RepositoryQuery query = (RepositoryQuery)element;
      AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(query.getConnectorKind());
      openEditQueryDialog(connectorUi, query);
    }
  }
  
  public static TaskJob updateRepositoryConfiguration(TaskRepository taskRepository)
  {
    synchronized (taskRepository)
    {
      taskRepository.setUpdating(true);
    }
    AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
      taskRepository.getConnectorKind());
    final TaskJob job = getJobFactory().createUpdateRepositoryConfigurationJob(connector, 
      taskRepository, null);
    job.addJobChangeListener(new JobChangeAdapter()
    {
      public void done(IJobChangeEvent event)
      {
        synchronized (TasksUiInternal.this)
        {
          setUpdating(false);
        }
        if (job.getStatus() != null) {
          TasksUiInternal.asyncLogAndDisplayStatus(Messages.TasksUiInternal_Configuration_Refresh_Failed, 
            job.getStatus());
        }
      }
    });
    job.schedule();
    return job;
  }
  
  private static void joinIfInTestMode(SynchronizationJob job)
  {
    if (CoreUtil.TEST_MODE) {
      try
      {
        job.join();
      }
      catch (InterruptedException e)
      {
        throw new RuntimeException(e);
      }
    }
  }
  
  public static final Job synchronizeQueries(AbstractRepositoryConnector connector, TaskRepository repository, Set<RepositoryQuery> queries, IJobChangeListener listener, boolean force)
  {
    Assert.isTrue(queries.size() > 0);
    
    TaskList taskList = TasksUiPlugin.getTaskList();
    for (RepositoryQuery query : queries) {
      query.setSynchronizing(true);
    }
    taskList.notifySynchronizationStateChanged(queries);
    
    SynchronizationJob job = TasksUiPlugin.getTaskJobFactory().createSynchronizeQueriesJob(connector, repository, 
      queries);
    job.setUser(force);
    if (force) {
      job.setProperty(WorkbenchUtil.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
    }
    if (listener != null) {
      job.addJobChangeListener(listener);
    }
    if (force)
    {
      RepositoryQuery query = (RepositoryQuery)queries.iterator().next();
      job.addJobChangeListener(new JobChangeAdapter()
      {
        public void done(IJobChangeEvent event)
        {
          if (getStatus() != null) {
            TasksUiInternal.asyncLogAndDisplayStatus(Messages.TasksUiInternal_Query_Synchronization_Failed, 
              getStatus());
          }
        }
      });
    }
    job.schedule();
    joinIfInTestMode(job);
    return job;
  }
  
  public static final Job synchronizeQuery(AbstractRepositoryConnector connector, RepositoryQuery repositoryQuery, IJobChangeListener listener, boolean force)
  {
    TaskRepository repository = TasksUi.getRepositoryManager().getRepository(repositoryQuery.getConnectorKind(), 
      repositoryQuery.getRepositoryUrl());
    return synchronizeQueries(connector, repository, Collections.singleton(repositoryQuery), listener, force);
  }
  
  public static SynchronizationJob synchronizeAllRepositories(boolean force)
  {
    SynchronizationJob job = TasksUiPlugin.getTaskJobFactory().createSynchronizeRepositoriesJob(null);
    job.setUser(force);
    if (force) {
      job.setProperty(WorkbenchUtil.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
    }
    job.schedule();
    joinIfInTestMode(job);
    return job;
  }
  
  public static void synchronizeRepositoryInBackground(TaskRepository repository)
  {
    synchronizationScheduler.schedule(repository, new SynchronizationScheduler.Synchronizer()
    {
      public SynchronizationJob createJob()
      {
        return TasksUiInternal.synchronizeRepositoryInternal(TasksUiInternal.this, false);
      }
    });
  }
  
  public static SynchronizationJob synchronizeRepository(TaskRepository repository, boolean force)
  {
    SynchronizationJob job = synchronizeRepositoryInternal(repository, force);
    synchronizationScheduler.cancel(repository);
    job.schedule();
    return job;
  }
  
  private static SynchronizationJob synchronizeRepositoryInternal(TaskRepository repository, boolean force)
  {
    SynchronizationJob job = getJobFactory().createSynchronizeRepositoriesJob(
      Collections.singleton(repository));
    
    job.setSystem(true);
    job.setUser(force);
    if (force) {
      job.setProperty(WorkbenchUtil.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
    }
    job.setFullSynchronization(false);
    return job;
  }
  
  public static void synchronizeTaskInBackground(AbstractRepositoryConnector connector, final ITask task)
  {
    synchronizationScheduler.schedule(task, new SynchronizationScheduler.Synchronizer()
    {
      public Job createJob()
      {
        SynchronizationJob job = TasksUiPlugin.getTaskJobFactory().createSynchronizeTasksJob(TasksUiInternal.this, 
          Collections.singleton(task));
        job.setUser(false);
        job.setSystem(true);
        return job;
      }
    });
  }
  
  public static Job synchronizeTask(AbstractRepositoryConnector connector, ITask task, boolean force, IJobChangeListener listener)
  {
    return synchronizeTasks(connector, Collections.singleton(task), force, listener);
  }
  
  public static Job synchronizeTasks(AbstractRepositoryConnector connector, Set<ITask> tasks, boolean force, IJobChangeListener listener)
  {
    ITaskList taskList = getTaskList();
    for (ITask task : tasks)
    {
      ((AbstractTask)task).setSynchronizing(true);
      synchronizationScheduler.cancel(task);
    }
    ((TaskList)taskList).notifySynchronizationStateChanged(tasks);
    
    SynchronizationJob job = TasksUiPlugin.getTaskJobFactory().createSynchronizeTasksJob(connector, tasks);
    job.setUser(force);
    job.setSystem(!force);
    job.setPriority(50);
    if (listener != null) {
      job.addJobChangeListener(listener);
    }
    if ((force) && (tasks.size() == 1))
    {
      ITask task = (ITask)tasks.iterator().next();
      job.addJobChangeListener(new JobChangeAdapter()
      {
        public void done(IJobChangeEvent event)
        {
          if (((TasksUiInternal.this instanceof AbstractTask)) && (((AbstractTask)TasksUiInternal.this).getStatus() != null)) {
            TasksUiInternal.asyncLogAndDisplayStatus(Messages.TasksUiInternal_Task_Synchronization_Failed, 
              ((AbstractTask)TasksUiInternal.this).getStatus());
          }
        }
      });
    }
    job.schedule();
    joinIfInTestMode(job);
    return job;
  }
  
  public static ITaskJobFactory getJobFactory()
  {
    return TasksUiPlugin.getTaskJobFactory();
  }
  
  public static NewAttachmentWizardDialog openNewAttachmentWizard(Shell shell, TaskRepository taskRepository, ITask task, TaskAttribute taskAttribute, TaskAttachmentWizard.Mode mode, AbstractTaskAttachmentSource source)
  {
    TaskAttachmentWizard attachmentWizard = new TaskAttachmentWizard(taskRepository, task, taskAttribute);
    attachmentWizard.setSource(source);
    attachmentWizard.setMode(mode);
    NewAttachmentWizardDialog dialog = new NewAttachmentWizardDialog(shell, attachmentWizard, false);
    dialog.setBlockOnOpen(false);
    dialog.create();
    dialog.open();
    return dialog;
  }
  
  private static MessageDialog createDialog(Shell shell, String title, String message, int type)
  {
    return new MessageDialog(shell, title, null, message, type, new String[] { IDialogConstants.OK_LABEL }, 0);
  }
  
  private static void displayStatus(Shell shell, String title, IStatus status, boolean showLinkToErrorLog)
  {
    if (CoreUtil.TEST_MODE)
    {
      StatusHandler.log(status);
      return;
    }
    if (((status instanceof RepositoryStatus)) && (((RepositoryStatus)status).isHtmlMessage()))
    {
      WebBrowserDialog.openAcceptAgreement(shell, title, status.getMessage(), 
        ((RepositoryStatus)status).getHtmlMessage());
    }
    else
    {
      String message = status.getMessage();
      if (showLinkToErrorLog) {
        message = message + "\n\n" + Messages.TasksUiInternal_See_error_log_for_details;
      }
      switch (status.getSeverity())
      {
      case 1: 
      case 8: 
        createDialog(shell, title, message, 2).open();
        break;
      case 2: 
        createDialog(shell, title, message, 4).open();
        break;
      case 3: 
      case 4: 
      case 5: 
      case 6: 
      case 7: 
      default: 
        createDialog(shell, title, message, 1).open();
      }
    }
  }
  
  public static void asyncDisplayStatus(String title, final IStatus status)
  {
    Display display = PlatformUI.getWorkbench().getDisplay();
    if (!display.isDisposed()) {
      display.asyncExec(new Runnable()
      {
        public void run()
        {
          TasksUiInternal.displayStatus(TasksUiInternal.this, status);
        }
      });
    } else {
      StatusHandler.log(status);
    }
  }
  
  public static void asyncLogAndDisplayStatus(String title, final IStatus status)
  {
    Display display = PlatformUI.getWorkbench().getDisplay();
    if (!display.isDisposed()) {
      display.asyncExec(new Runnable()
      {
        public void run()
        {
          TasksUiInternal.logAndDisplayStatus(TasksUiInternal.this, status);
        }
      });
    } else {
      StatusHandler.log(status);
    }
  }
  
  public static void logAndDisplayStatus(String title, IStatus status)
  {
    StatusHandler.log(status);
    IWorkbench workbench = PlatformUI.getWorkbench();
    if ((workbench != null) && (!workbench.getDisplay().isDisposed())) {
      displayStatus(WorkbenchUtil.getShell(), title, status, false);
    }
  }
  
  public static void displayStatus(String title, IStatus status)
  {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if ((workbench != null) && (!workbench.getDisplay().isDisposed())) {
      displayStatus(WorkbenchUtil.getShell(), title, status, false);
    } else {
      StatusHandler.log(status);
    }
  }
  
  public static LocalTask createNewLocalTask(String summary)
  {
    if (summary == null) {
      summary = LocalRepositoryConnector.DEFAULT_SUMMARY;
    }
    TaskList taskList = TasksUiPlugin.getTaskList();
    LocalTask newTask = new LocalTask(taskList.getNextLocalTaskId(), summary);
    newTask.setPriority(ITask.PriorityLevel.P3.toString());
    getTaskList().addTask(newTask);
    TasksUiPlugin.getTaskActivityManager().scheduleNewTask(newTask);
    
    TaskListView view = TaskListView.getFromActivePerspective();
    AbstractTaskCategory category = getSelectedCategory(view);
    if ((view != null) && (view.getDrilledIntoCategory() != null) && (view.getDrilledIntoCategory() != category)) {
      MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.TasksUiInternal_Create_Task, 
        MessageFormat.format(Messages.TasksUiInternal_The_new_task_will_be_added_to_the_X_container, new Object[] {
        UncategorizedTaskContainer.LABEL }));
    }
    taskList.addTask(newTask, category);
    return newTask;
  }
  
  public static AbstractTaskCategory getSelectedCategory(TaskListView view)
  {
    Object selectedObject = null;
    if (view != null) {
      selectedObject = ((IStructuredSelection)view.getViewer().getSelection()).getFirstElement();
    }
    if ((selectedObject instanceof TaskCategory)) {
      return (TaskCategory)selectedObject;
    }
    if ((selectedObject instanceof ITask))
    {
      ITask task = (ITask)selectedObject;
      AbstractTaskContainer container = TaskCategory.getParentTaskCategory(task);
      if ((container instanceof TaskCategory)) {
        return (TaskCategory)container;
      }
      if ((view != null) && ((view.getDrilledIntoCategory() instanceof TaskCategory))) {
        return (TaskCategory)view.getDrilledIntoCategory();
      }
    }
    else if ((view != null) && ((view.getDrilledIntoCategory() instanceof TaskCategory)))
    {
      return (TaskCategory)view.getDrilledIntoCategory();
    }
    return TasksUiPlugin.getTaskList().getDefaultCategory();
  }
  
  public static Set<AbstractTaskContainer> getContainersFromWorkingSet(Set<IWorkingSet> containers)
  {
    Set<AbstractTaskContainer> allTaskContainersInWorkingSets = new HashSet();
    int j;
    int i;
    for (Iterator localIterator = containers.iterator(); localIterator.hasNext(); i < j)
    {
      IWorkingSet workingSet = (IWorkingSet)localIterator.next();
      IAdaptable[] elements = workingSet.getElements();
      IAdaptable[] arrayOfIAdaptable1;
      j = (arrayOfIAdaptable1 = elements).length;i = 0; continue;IAdaptable adaptable = arrayOfIAdaptable1[i];
      if ((adaptable instanceof AbstractTaskContainer)) {
        allTaskContainersInWorkingSets.add((AbstractTaskContainer)adaptable);
      }
      i++;
    }
    return allTaskContainersInWorkingSets;
  }
  
  public static boolean openEditQueryDialog(AbstractRepositoryConnectorUi connectorUi, final IRepositoryQuery query)
  {
    try
    {
      TaskRepository repository = TasksUi.getRepositoryManager().getRepository(query.getConnectorKind(), 
        query.getRepositoryUrl());
      if (repository == null) {
        return false;
      }
      IWizard wizard = connectorUi.getQueryWizard(repository, query);
      
      Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
      if ((wizard != null) && (shell != null) && (!shell.isDisposed()))
      {
        QueryWizardDialog dialog = new QueryWizardDialog(shell, wizard)
        {
          private static final String DIALOG_SETTINGS = "EditQueryWizardWizard";
          
          protected IDialogSettings getDialogBoundsSettings()
          {
            IDialogSettings settings = TasksUiPlugin.getDefault().getDialogSettings();
            String settingsSectionId = "EditQueryWizardWizard." + query.getRepositoryUrl();
            IDialogSettings section = settings.getSection(settingsSectionId);
            if (section == null) {
              section = settings.addNewSection(settingsSectionId);
            }
            return section;
          }
        };
        dialog.create();
        dialog.setBlockOnOpen(true);
        if (dialog.open() == 1) {
          return false;
        }
        return true;
      }
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", "Failed to open query dialog", e));
    }
    return false;
  }
  
  public static ITaskList getTaskList()
  {
    return TasksUiPlugin.getTaskList();
  }
  
  public static boolean isAnimationsEnabled()
  {
    IPreferenceStore store = PlatformUI.getPreferenceStore();
    return store.getBoolean("ENABLE_ANIMATIONS");
  }
  
  public static boolean hasValidUrl(ITask task)
  {
    return isValidUrl(task.getUrl());
  }
  
  public static boolean isValidUrl(String url)
  {
    if ((url != null) && (!url.equals("")) && (!url.equals("http://")) && (!url.equals("https://"))) {
      try
      {
        new URL(url);
        return true;
      }
      catch (MalformedURLException localMalformedURLException)
      {
        return false;
      }
    }
    return false;
  }
  
  @Deprecated
  public static void closeEditorInActivePage(ITask task, boolean save)
  {
    Assert.isNotNull(task);
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
      return;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
      return;
    }
    TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(), 
      task.getRepositoryUrl());
    IEditorInput input = new TaskEditorInput(taskRepository, task);
    IEditorPart editor = page.findEditor(input);
    if (editor != null) {
      page.closeEditor(editor, save);
    }
  }
  
  public static void closeTaskEditorInAllPages(ITask task, boolean save)
  {
    Assert.isNotNull(task);
    TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(), 
      task.getRepositoryUrl());
    IEditorInput input = new TaskEditorInput(taskRepository, task);
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    IWorkbenchWindow[] arrayOfIWorkbenchWindow1;
    int j = (arrayOfIWorkbenchWindow1 = windows).length;
    for (int i = 0; i < j; i++)
    {
      IWorkbenchWindow window = arrayOfIWorkbenchWindow1[i];
      IWorkbenchPage[] pages = window.getPages();
      IWorkbenchPage[] arrayOfIWorkbenchPage1;
      int m = (arrayOfIWorkbenchPage1 = pages).length;
      for (int k = 0; k < m; k++)
      {
        IWorkbenchPage page = arrayOfIWorkbenchPage1[k];
        IEditorPart editor = page.findEditor(input);
        if (editor != null) {
          page.closeEditor(editor, save);
        }
      }
    }
  }
  
  public static boolean hasLocalCompletionState(ITask task)
  {
    TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(), 
      task.getRepositoryUrl());
    AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
      task.getConnectorKind());
    return connector.hasLocalCompletionState(taskRepository, task);
  }
  
  @Deprecated
  public static Shell getShell()
  {
    return WorkbenchUtil.getShell();
  }
  
  public static TaskData createTaskData(TaskRepository taskRepository, ITaskMapping initializationData, ITaskMapping selectionData, IProgressMonitor monitor)
    throws CoreException
  {
    AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
      taskRepository.getConnectorKind());
    AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
    TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(taskRepository);
    TaskData taskData = new TaskData(mapper, taskRepository.getConnectorKind(), taskRepository.getRepositoryUrl(), 
      "");
    boolean result = taskDataHandler.initializeTaskData(taskRepository, taskData, initializationData, monitor);
    if (!result) {
      throw new CoreException(new Status(4, "org.eclipse.mylyn.tasks.ui", 
        "Initialization of task failed. The provided data is insufficient."));
    }
    if (selectionData != null) {
      connector.getTaskMapping(taskData).merge(selectionData);
    }
    return taskData;
  }
  
  public static void createAndOpenNewTask(TaskData taskData)
    throws CoreException
  {
    ITask task = TasksUiUtil.createOutgoingNewTask(taskData.getConnectorKind(), taskData.getRepositoryUrl());
    AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
      taskData.getConnectorKind());
    ITaskMapping mapping = connector.getTaskMapping(taskData);
    String summary = mapping.getSummary();
    if ((summary != null) && (summary.length() > 0)) {
      task.setSummary(summary);
    }
    String taskKind = mapping.getTaskKind();
    if ((taskKind != null) && (taskKind.length() > 0)) {
      task.setTaskKind(taskKind);
    }
    UnsubmittedTaskContainer unsubmitted = TasksUiPlugin.getTaskList().getUnsubmittedContainer(
      taskData.getRepositoryUrl());
    if (unsubmitted != null) {
      TasksUiPlugin.getTaskList().addTask(task, unsubmitted);
    }
    ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(task, taskData);
    workingCopy.save(null, null);
    TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(taskData.getConnectorKind(), 
      taskData.getRepositoryUrl());
    connector.updateNewTaskFromTaskData(taskRepository, task, taskData);
    TaskRepository localTaskRepository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(), 
      task.getRepositoryUrl());
    TaskEditorInput editorInput = new TaskEditorInput(localTaskRepository, task);
    TasksUiUtil.openEditor(editorInput, "org.eclipse.mylyn.tasks.ui.editors.task", null);
  }
  
  public static boolean openTask(TaskRepository repository, String taskId, TaskOpenListener listener)
  {
    Assert.isNotNull(repository);
    Assert.isNotNull(taskId);
    
    AbstractTask task = (AbstractTask)getTaskList().getTask(repository.getRepositoryUrl(), taskId);
    if (task == null) {
      task = TasksUiPlugin.getTaskList().getTaskByKey(repository.getRepositoryUrl(), taskId);
    }
    if (task != null)
    {
      TaskOpenEvent event = openTask(task, taskId);
      if ((listener != null) && (event != null)) {
        listener.taskOpened(event);
      }
      return event != null;
    }
    AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(repository.getConnectorKind());
    if (connectorUi != null) {
      try
      {
        return openRepositoryTask(connectorUi.getConnectorKind(), 
          repository.getRepositoryUrl(), taskId, listener);
      }
      catch (Exception e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
          "Internal error while opening repository task", e));
      }
    }
    return false;
  }
  
  public static TaskOpenEvent openTask(ITask task, String taskId)
  {
    Assert.isNotNull(task);
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null)
    {
      TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(), 
        task.getRepositoryUrl());
      boolean openWithBrowser = !TasksUiPlugin.getDefault()
        .getPreferenceStore()
        .getBoolean("org.eclipse.mylyn.tasks.ui.reporting.open.editor");
      if (openWithBrowser)
      {
        TasksUiUtil.openWithBrowser(taskRepository, task);
        return new TaskOpenEvent(taskRepository, task, taskId, null, true);
      }
      IEditorInput editorInput = getTaskEditorInput(taskRepository, task);
      IEditorPart editor = refreshEditorContentsIfOpen(task, editorInput);
      if (editor != null)
      {
        synchronizeTask(taskRepository, task);
        return new TaskOpenEvent(taskRepository, task, taskId, editor, false);
      }
      IWorkbenchPage page = window.getActivePage();
      editor = TasksUiUtil.openEditor(editorInput, getTaskEditorId(task), page);
      if (editor != null)
      {
        synchronizeTask(taskRepository, task);
        return new TaskOpenEvent(taskRepository, task, taskId, editor, false);
      }
    }
    else
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", "Unable to open editor for \"" + 
        task.getSummary() + "\": no active workbench window"));
    }
    return null;
  }
  
  private static IEditorInput getTaskEditorInput(TaskRepository repository, ITask task)
  {
    Assert.isNotNull(task);
    Assert.isNotNull(repository);
    AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(task.getConnectorKind());
    IEditorInput editorInput = connectorUi.getTaskEditorInput(repository, task);
    if (editorInput != null) {
      return editorInput;
    }
    return new TaskEditorInput(repository
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