Пример #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();
  }
 @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();
 }
Пример #4
0
 private void updateTitleImage() {
   if (task != null) {
     AbstractRepositoryConnectorUi connectorUi =
         TasksUiPlugin.getConnectorUi(task.getConnectorKind());
     if (connectorUi != null) {
       ImageDescriptor overlayDescriptor = connectorUi.getTaskKindOverlay(task);
       setTitleImage(
           CommonImages.getCompositeTaskImage(TasksUiImages.TASK, overlayDescriptor, false));
     } else {
       setTitleImage(CommonImages.getImage(TasksUiImages.TASK));
     }
     //		} else if (getEditorInput() instanceof AbstractRepositoryTaskEditorInput) {
     //			setTitleImage(CommonImages.getImage(TasksUiImages.TASK_REMOTE));
   } else {
     setTitleImage(CommonImages.getImage(TasksUiImages.TASK));
   }
 }
Пример #5
0
  private Image getBrandingImage() {
    String connectorKind;
    TaskRepository outgoingNewRepository = TasksUiUtil.getOutgoingNewTaskRepository(task);
    if (outgoingNewRepository != null) {
      connectorKind = outgoingNewRepository.getConnectorKind();
    } else {
      connectorKind = task.getConnectorKind();
    }

    if (LocalRepositoryConnector.CONNECTOR_KIND.equals(connectorKind)) {
      return CommonImages.getImage(TasksUiImages.TASK);
    } else {
      ImageDescriptor overlay;
      if (outgoingNewRepository != null) {
        overlay =
            TasksUiPlugin.getDefault().getBrandManager().getOverlayIcon(outgoingNewRepository);
      } else {
        overlay = TasksUiPlugin.getDefault().getBrandManager().getOverlayIcon(task);
      }
      Image image =
          CommonImages.getImageWithOverlay(TasksUiImages.REPOSITORY, overlay, false, false);
      return image;
    }
  }
Пример #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()));
      }
    }
  }