Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
  @Override
  public void selectionChanged(IAction action, ISelection selection) {
    super.selectionChanged(action, selection);

    task = null;

    if (selection instanceof IStructuredSelection) {

      IStructuredSelection ss = (IStructuredSelection) selection;

      if (!ss.isEmpty()) {

        Iterator<?> iter = ss.iterator();
        while (iter.hasNext()) {
          Object sel = iter.next();
          if (sel instanceof IJiraTask) {
            task = ((IJiraTask) sel).getTask();
            try {
              taskData = TasksUiPlugin.getTaskDataManager().getTaskData(task);
            } catch (CoreException e) {
              handleError(
                  Messages.JiraConnectorUiActions_Cannot_get_task_data + task.getTaskKey(), e);
            }

            break;
          }
        }
      }
    }

    update(action);
  }
Ejemplo n.º 3
0
  private void updateHeaderLabel() {
    TaskRepository outgoingNewRepository = TasksUiUtil.getOutgoingNewTaskRepository(task);
    final TaskRepository taskRepository =
        (outgoingNewRepository != null)
            ? outgoingNewRepository
            : taskEditorInput.getTaskRepository();

    //		if (taskRepository.getConnectorKind().equals(LocalRepositoryConnector.CONNECTOR_KIND)) {
    //			getHeaderForm().getForm().setText(Messages.TaskEditor_Task_ + task.getSummary());
    //		} else {
    AbstractRepositoryConnectorUi connectorUi =
        TasksUiPlugin.getConnectorUi(taskRepository.getConnectorKind());
    String kindLabel = Messages.TaskEditor_Task;
    if (connectorUi != null) {
      kindLabel = connectorUi.getTaskKindLabel(task);
    }

    String idLabel = task.getTaskKey();
    if (idLabel != null) {
      kindLabel += " " + idLabel; // $NON-NLS-1$
    }

    if (hasLeftToolBar() && titleLabel != null) {
      titleLabel.setText(kindLabel);
      getHeaderForm().getForm().setText(null);
      setHeaderImage(null);
    } else {
      getHeaderForm().getForm().setText(kindLabel);
    }
  }
Ejemplo n.º 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);
 }
Ejemplo n.º 5
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()));
      }
    }
  }