Search in sources :

Example 1 with TaskPsiElement

use of com.intellij.tasks.doc.TaskPsiElement in project intellij-community by JetBrains.

the class GotoTaskAction method perform.

void perform(final Project project) {
    final Ref<Boolean> shiftPressed = Ref.create(false);
    final ChooseByNamePopup popup = createPopup(project, new GotoTaskPopupModel(project), new TaskItemProvider(project));
    popup.setShowListForEmptyPattern(true);
    popup.setSearchInAnyPlace(true);
    popup.setAlwaysHasMore(true);
    popup.setAdText("<html>Press SHIFT to merge with current context<br/>" + "Pressing " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_QUICK_JAVADOC)) + " would show task description and comments</html>");
    popup.registerAction("shiftPressed", KeyStroke.getKeyStroke("shift pressed SHIFT"), new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            shiftPressed.set(true);
        }
    });
    popup.registerAction("shiftReleased", KeyStroke.getKeyStroke("released SHIFT"), new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            shiftPressed.set(false);
        }
    });
    final DefaultActionGroup group = new DefaultActionGroup(new ConfigureServersAction() {

        @Override
        protected void serversChanged() {
            popup.rebuildList(true);
        }
    });
    final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
    actionToolbar.updateActionsImmediately();
    actionToolbar.getComponent().setFocusable(false);
    actionToolbar.getComponent().setBorder(null);
    popup.setToolArea(actionToolbar.getComponent());
    popup.setMaximumListSizeLimit(PAGE_SIZE);
    popup.setListSizeIncreasing(PAGE_SIZE);
    showNavigationPopup(new GotoActionCallback<Object>() {

        @Override
        public void elementChosen(ChooseByNamePopup popup, Object element) {
            TaskManager taskManager = TaskManager.getManager(project);
            if (element instanceof TaskPsiElement) {
                Task task = ((TaskPsiElement) element).getTask();
                LocalTask localTask = taskManager.findTask(task.getId());
                if (localTask != null) {
                    taskManager.activateTask(localTask, !shiftPressed.get());
                } else {
                    showOpenTaskDialog(project, task);
                }
            } else if (element == CREATE_NEW_TASK_ACTION) {
                LocalTask localTask = taskManager.createLocalTask(CREATE_NEW_TASK_ACTION.getTaskName());
                showOpenTaskDialog(project, localTask);
            }
        }
    }, null, popup);
}
Also used : Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) ActionEvent(java.awt.event.ActionEvent) LocalTask(com.intellij.tasks.LocalTask) TaskPsiElement(com.intellij.tasks.doc.TaskPsiElement) TaskManager(com.intellij.tasks.TaskManager)

Example 2 with TaskPsiElement

use of com.intellij.tasks.doc.TaskPsiElement in project intellij-community by JetBrains.

the class ShowTaskDescription method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = getProject(e);
    assert project != null;
    final LocalTask task = getActiveTask(e);
    FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.quickjavadoc.ctrln");
    CommandProcessor.getInstance().executeCommand(project, () -> DocumentationManager.getInstance(project).showJavaDocInfo(new TaskPsiElement(PsiManager.getInstance(project), task), null), getCommandName(), null);
}
Also used : Project(com.intellij.openapi.project.Project) LocalTask(com.intellij.tasks.LocalTask) TaskPsiElement(com.intellij.tasks.doc.TaskPsiElement)

Example 3 with TaskPsiElement

use of com.intellij.tasks.doc.TaskPsiElement in project intellij-community by JetBrains.

the class TaskCellRenderer method getListCellRendererComponent.

public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) {
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(UIUtil.getListBackground(sel));
    panel.setForeground(UIUtil.getListForeground(sel));
    if (value instanceof TaskPsiElement) {
        final Task task = ((TaskPsiElement) value).getTask();
        final SimpleColoredComponent c = new SimpleColoredComponent();
        final TaskManager taskManager = TaskManager.getManager(myProject);
        final boolean isLocalTask = taskManager.findTask(task.getId()) != null;
        final boolean isClosed = task.isClosed() || (task instanceof LocalTask && taskManager.isLocallyClosed((LocalTask) task));
        final Color bg = sel ? UIUtil.getListSelectionBackground() : isLocalTask ? UIUtil.getListBackground() : UIUtil.getDecoratedRowColor();
        panel.setBackground(bg);
        SimpleTextAttributes attr = getAttributes(sel, isClosed);
        c.setIcon(isClosed ? IconLoader.getTransparentIcon(task.getIcon()) : task.getIcon());
        SpeedSearchUtil.appendColoredFragmentForMatcher(task.getPresentableName(), c, attr, MatcherHolder.getAssociatedMatcher(list), bg, sel);
        panel.add(c, BorderLayout.CENTER);
    } else if ("...".equals(value)) {
        final SimpleColoredComponent c = new SimpleColoredComponent();
        c.setIcon(EmptyIcon.ICON_16);
        c.append((String) value);
        panel.add(c, BorderLayout.CENTER);
    } else if (GotoTaskAction.CREATE_NEW_TASK_ACTION == value) {
        final SimpleColoredComponent c = new SimpleColoredComponent();
        c.setIcon(LayeredIcon.create(TasksIcons.Unknown, AllIcons.Actions.New));
        c.append(GotoTaskAction.CREATE_NEW_TASK_ACTION.getActionText());
        panel.add(c, BorderLayout.CENTER);
    } else if (ChooseByNameBase.NON_PREFIX_SEPARATOR == value) {
        return ChooseByNameBase.renderNonPrefixSeparatorComponent(UIUtil.getListBackground());
    }
    return panel;
}
Also used : Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) TaskManager(com.intellij.tasks.TaskManager) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) LocalTask(com.intellij.tasks.LocalTask) TaskPsiElement(com.intellij.tasks.doc.TaskPsiElement) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Aggregations

LocalTask (com.intellij.tasks.LocalTask)3 TaskPsiElement (com.intellij.tasks.doc.TaskPsiElement)3 Task (com.intellij.tasks.Task)2 TaskManager (com.intellij.tasks.TaskManager)2 Project (com.intellij.openapi.project.Project)1 SimpleColoredComponent (com.intellij.ui.SimpleColoredComponent)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 ActionEvent (java.awt.event.ActionEvent)1