@Deprecated
  public void promptToAddQuery(TaskRepository taskRepository) {
    IPreferenceStore preferenceStore = TasksUiPlugin.getDefault().getPreferenceStore();
    if (!preferenceStore.getBoolean(PREF_ADD_QUERY)) {
      Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
      MessageDialogWithToggle messageDialog =
          MessageDialogWithToggle.openYesNoQuestion(
              shell,
              Messages.AddRepositoryAction_Add_new_query,
              Messages.AddRepositoryAction_Add_a_query_to_the_Task_List,
              Messages.AddRepositoryAction_Do_not_show_again,
              false,
              preferenceStore,
              PREF_ADD_QUERY);
      preferenceStore.setValue(PREF_ADD_QUERY, messageDialog.getToggleState());
      if (messageDialog.getReturnCode() == IDialogConstants.YES_ID) {
        AbstractRepositoryConnectorUi connectorUi =
            TasksUiPlugin.getConnectorUi(taskRepository.getConnectorKind());
        IWizard queryWizard = connectorUi.getQueryWizard(taskRepository, null);
        if (queryWizard instanceof Wizard) {
          ((Wizard) queryWizard).setForcePreviousAndNextButtons(true);
        }

        WizardDialog queryDialog = new WizardDialog(shell, queryWizard);
        queryDialog.create();
        queryDialog.setBlockOnOpen(true);
        queryDialog.open();
      }
    }
  }
  @Override
  public void setUp() throws Exception {
    taskList = TasksUiPlugin.getTaskList();

    TaskTestUtil.resetTaskListAndRepositories();
    TasksUiPlugin.getDefault().getLocalTaskRepository();

    cat1 = new TaskCategory("First Category");
    taskList.addCategory(cat1);

    cat1task1 = TasksUiInternal.createNewLocalTask("task 1");
    cat1task1.setPriority(PriorityLevel.P1.toString());
    cat1task1.setCompletionDate(new Date());
    taskList.addTask(cat1task1, cat1);

    cat1task2 = TasksUiInternal.createNewLocalTask("task 2");
    cat1task2.setPriority(PriorityLevel.P2.toString());
    taskList.addTask(cat1task2, cat1);

    assertEquals(cat1.getChildren().size(), 2);

    activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    assertTrue(activePage.closeAllEditors(false));
    assertEquals(0, activePage.getEditorReferences().length);
  }
示例#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$
    }
  }
 public ShowNonMatchingSubtasksAction() {
   setText(Messages.ShowNonMatchingSubtasksAction_Show_Non_Matching_Subtasks);
   setToolTipText(Messages.ShowNonMatchingSubtasksAction_Show_Non_Matching_Subtasks);
   setChecked(
       !TasksUiPlugin.getDefault()
           .getPreferenceStore()
           .getBoolean(ITasksUiPreferenceConstants.FILTER_NON_MATCHING));
 }
示例#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;
    }
  }
 public void update() {
   setChecked(
       !TasksUiPlugin.getDefault()
           .getPreferenceStore()
           .getBoolean(ITasksUiPreferenceConstants.FILTER_NON_MATCHING));
 }
 @Override
 public void run() {
   TasksUiPlugin.getDefault()
       .getPreferenceStore()
       .setValue(ITasksUiPreferenceConstants.FILTER_NON_MATCHING, !isChecked());
 }
示例#8
0
 @Override
 protected FormToolkit createToolkit(Display display) {
   // create a toolkit that shares colors between editors.
   return new FormToolkit(TasksUiPlugin.getDefault().getFormColors(display));
 }
示例#9
0
  @Override
  protected void addPages() {
    initialize();

    // determine factories
    Set<String> conflictingIds = new HashSet<String>();
    ArrayList<AbstractTaskEditorPageFactory> pageFactories =
        new ArrayList<AbstractTaskEditorPageFactory>();
    for (AbstractTaskEditorPageFactory pageFactory :
        TasksUiPlugin.getDefault().getTaskEditorPageFactories()) {
      if (pageFactory.canCreatePageFor(getTaskEditorInput())
          && WorkbenchUtil.allowUseOf(pageFactory)) {
        pageFactories.add(pageFactory);
        String[] ids = pageFactory.getConflictingIds(getTaskEditorInput());
        if (ids != null) {
          conflictingIds.addAll(Arrays.asList(ids));
        }
      }
    }
    for (Iterator<AbstractTaskEditorPageFactory> it = pageFactories.iterator(); it.hasNext(); ) {
      if (conflictingIds.contains(it.next().getId())) {
        it.remove();
      }
    }

    // sort by priority
    Collections.sort(
        pageFactories,
        new Comparator<AbstractTaskEditorPageFactory>() {
          public int compare(AbstractTaskEditorPageFactory o1, AbstractTaskEditorPageFactory o2) {
            return o1.getPriority() - o2.getPriority();
          }
        });

    // create pages
    for (AbstractTaskEditorPageFactory factory : pageFactories) {
      try {
        IFormPage page = factory.createPage(this);
        int index = addPage(page);
        setPageImage(index, factory.getPageImage(this, page));
        setPageText(index, factory.getPageText(this, page));
        if (factory.getPriority() == AbstractTaskEditorPageFactory.PRIORITY_TASK) {
          setActivePage(index);
        }
        if (page instanceof ISelectionProvider) {
          ((ISelectionProvider) page).addSelectionChangedListener(getActionBarContributor());
        }
      } catch (Exception e) {
        StatusHandler.log(
            new Status(
                IStatus.ERROR,
                TasksUiPlugin.ID_PLUGIN,
                "Could not create editor via factory: " + factory,
                e)); //$NON-NLS-1$
      }
    }

    updateTitleImage();
    updateHeaderToolBar();
    installTitleDrag(getHeaderForm().getForm().getForm());

    // do this late to allow pages to replace the selection provider
    getEditorSite().registerContextMenu(menuManager, getEditorSite().getSelectionProvider(), true);
  }