예제 #1
0
 @Override
 protected IStatus run(IProgressMonitor monitor) {
   status =
       new MultiStatus(
           ITasksCoreConstants.ID_PLUGIN,
           IStatus.OK,
           "Problems occurred while deleting repository tasks",
           null); //$NON-NLS-1$
   try {
     monitor.beginTask(Messages.DeleteTasksJob_Deleting_tasks, tasksToDelete.size() * 100);
     for (ITask task : tasksToDelete) {
       // delete the task on the server using the repository connector
       AbstractRepositoryConnector repositoryConnector =
           repositoryManager.getRepositoryConnector(task.getConnectorKind());
       TaskRepository repository =
           repositoryManager.getRepository(task.getConnectorKind(), task.getRepositoryUrl());
       if (repositoryConnector.canDeleteTask(repository, task)) {
         try {
           repositoryConnector.deleteTask(repository, task, subMonitorFor(monitor, 100));
         } catch (OperationCanceledException e) {
           return Status.CANCEL_STATUS;
         } catch (Exception e) {
           String taskId = task.getTaskKey();
           if (taskId == null) {
             taskId = task.getTaskId();
           }
           status.add(
               new Status(
                   IStatus.ERROR,
                   ITasksCoreConstants.ID_PLUGIN,
                   NLS.bind(
                       "Problems occurred while deleting {0} from {1}.",
                       taskId, task.getRepositoryUrl()),
                   e)); //$NON-NLS-1$
         } catch (LinkageError e) {
           String taskId = task.getTaskKey();
           if (taskId == null) {
             taskId = task.getTaskId();
           }
           status.add(
               new Status(
                   IStatus.ERROR,
                   ITasksCoreConstants.ID_PLUGIN,
                   NLS.bind(
                       "Internal Error occurred while deleting {0} from {1}.",
                       taskId, task.getRepositoryUrl()),
                   e)); //$NON-NLS-1$
         }
       }
     }
   } finally {
     monitor.done();
   }
   return Status.OK_STATUS;
 }
예제 #2
0
  private static String getCurrentUser(ITask task) {
    TaskRepository repository =
        TasksUi.getRepositoryManager()
            .getRepository(task.getConnectorKind(), task.getRepositoryUrl());

    return repository.getUserName();
  }
예제 #3
0
  /**
   * Returns a commit comment specific to <code>task</code> and <code>resources</code>. If <code>
   * resources</code> is null or the associated projects do not specify a custom commit comment
   * template the global template is used.
   *
   * <p>This method must be invoked on the UI thread.
   *
   * @param checkTaskRepository if true, a warning dialog is displayed in case <code>task</code> is
   *     associated with a different repository than any of the <code>resources</code>
   * @param task the task to generate the commit comment for
   * @param resources that are being committed or null
   * @return a commit comment or an empty string if the user opted to abort generating the commit
   *     message
   * @since 3.5
   */
  public static String getComment(boolean checkTaskRepository, ITask task, IResource[] resources) {
    // lookup project specific template
    String template = null;
    Set<IProject> projects = new HashSet<IProject>();
    if (resources != null) {
      for (IResource resource : resources) {
        IProject project = resource.getProject();
        if (project != null && project.isAccessible() && !projects.contains(project)) {
          TeamPropertiesLinkProvider provider = new TeamPropertiesLinkProvider();
          template = provider.getCommitCommentTemplate(project);
          if (template != null) {
            break;
          }
          projects.add(project);
        }
      }
    }

    boolean proceed = true;

    // prompt if resources do not match task
    if (checkTaskRepository) {
      boolean unmatchedRepositoryFound = false;
      for (IProject project : projects) {
        TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project);
        if (repository != null) {
          if (!repository.getRepositoryUrl().equals(task.getRepositoryUrl())) {
            unmatchedRepositoryFound = true;
          }
        }
      }

      if (unmatchedRepositoryFound) {
        if (Display.getCurrent() != null) {
          proceed =
              MessageDialog.openQuestion(
                  WorkbenchUtil.getShell(),
                  Messages.ContextChangeSet_Mylyn_Change_Set_Management,
                  Messages.ContextChangeSet_ATTEMPTING_TO_COMMIT_RESOURCE);
        } else {
          proceed = false;
        }
      }
    }

    if (proceed) {
      if (template == null) {
        template =
            FocusedTeamUiPlugin.getDefault()
                .getPreferenceStore()
                .getString(FocusedTeamUiPlugin.COMMIT_TEMPLATE);
      }
      return FocusedTeamUiPlugin.getDefault()
          .getCommitTemplateManager()
          .generateComment(task, template);
    } else {
      return ""; //$NON-NLS-1$
    }
  }
예제 #4
0
 private void addIndexedAttributes(Document document, ITask task) {
   addIndexedAttribute(document, FIELD_TASK_KEY, task.getTaskKey());
   addIndexedAttribute(document, FIELD_REPOSITORY_URL, task.getRepositoryUrl());
   addIndexedAttribute(document, FIELD_SUMMARY, task.getSummary());
   addIndexedAttribute(document, FIELD_CONTENT, task.getSummary());
   addIndexedAttribute(document, FIELD_CONTENT, ((AbstractTask) task).getNotes());
   addIndexedDateAttributes(document, task);
 }
 @Override
 public Object[] getElements(Object parent) {
   people.clear();
   if (parent instanceof Person) {
     return getChildren(parent);
   } else {
     for (ITaskContainer container : applyFilter(TasksUiPlugin.getTaskList().getRootElements())) {
       for (ITask task : getAllTasks(container.getChildren())) {
         if (task.getOwner() != null && TasksUiInternal.shouldShowIncoming(task)) {
           people.add(
               new Person(task.getOwner(), task.getConnectorKind(), task.getRepositoryUrl()));
         }
       }
     }
   }
   return people.toArray();
 }
예제 #6
0
  private void addIndexedAttributes(Document document, ITask task, TaskAttribute root) {
    addIndexedAttribute(document, FIELD_TASK_KEY, task.getTaskKey());
    addIndexedAttribute(document, FIELD_REPOSITORY_URL, task.getRepositoryUrl());
    addIndexedAttribute(document, FIELD_SUMMARY, root.getMappedAttribute(TaskAttribute.SUMMARY));

    for (TaskAttribute contentAttribute : computeContentAttributes(root)) {
      addIndexedAttribute(document, FIELD_CONTENT, contentAttribute);
    }

    addIndexedDateAttributes(document, task);

    TaskData taskData = root.getTaskData();

    List<TaskAttribute> commentAttributes =
        taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_COMMENT);
    for (TaskAttribute commentAttribute : commentAttributes) {

      TaskComment taskComment =
          new TaskComment(
              taskData.getAttributeMapper().getTaskRepository(), task, commentAttribute);
      taskData.getAttributeMapper().updateTaskComment(taskComment, commentAttribute);

      String text = taskComment.getText();
      if (text.length() != 0) {
        addIndexedAttribute(document, FIELD_CONTENT, text);
      }
      IRepositoryPerson author = taskComment.getAuthor();
      if (author != null) {
        addIndexedAttribute(document, FIELD_PERSON, author.getPersonId());
      }
    }

    List<TaskAttribute> personAttributes =
        taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_PERSON);
    for (TaskAttribute personAttribute : personAttributes) {
      addIndexedAttribute(document, FIELD_PERSON, personAttribute);
    }

    TaskRepository repository =
        getRepositoryManager().getRepository(task.getConnectorKind(), task.getRepositoryUrl());

    if (repository != null) {
      List<TaskAttribute> attachmentAttributes =
          taskData
              .getAttributeMapper()
              .getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT);
      Set<String> attachmentNames = new HashSet<String>();
      for (TaskAttribute attribute : attachmentAttributes) {
        TaskAttachment taskAttachment = new TaskAttachment(repository, task, attribute);
        taskData.getAttributeMapper().updateTaskAttachment(taskAttachment, attribute);

        if (attachmentNames.add(taskAttachment.getFileName())) {
          addIndexedAttribute(document, FIELD_ATTACHMENT_NAME, taskAttachment.getFileName());
        }
        addIndexedAttribute(document, FIELD_CONTENT, taskAttachment.getDescription());
      }
    }

    for (AbstractTaskSchema.Field field : indexedFields) {
      if (!specialFields.contains(field)) {
        addIndexedAttribute(document, field, root.getMappedAttribute(field.getKey()));
      }
    }
  }