Tasks. Configure Servers action.

This commit is contained in:
Evgeny
2012-10-14 09:02:44 +04:00
parent 3099b2b129
commit 852132489a
8 changed files with 53 additions and 4 deletions
@@ -37,6 +37,8 @@
<keyboard-shortcut keymap="$default" first-keystroke="alt shift B"/>
</action>
<action id="tasks.analyze.stacktrace" class="com.intellij.tasks.actions.AnalyzeTaskStacktraceAction" text="Analyze _Stacktrace From Task..."/>
<separator/>
<action id="tasks.configure.servers" class="com.intellij.tasks.actions.ConfigureServersAction" text="Configure Servers..."/>
</group>
<group id="working.context">
@@ -35,6 +35,7 @@ public class AnalyzeTaskStacktraceAction extends BaseTaskAction {
public void update(AnActionEvent event) {
Task activeTask = getActiveTask(event);
event.getPresentation().setEnabled(activeTask != null && hasTexts(activeTask));
super.update(event);
}
public static boolean hasTexts(Task activeTask) {
@@ -25,6 +25,8 @@ import com.intellij.tasks.LocalTask;
import com.intellij.tasks.TaskManager;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author Dmitry Avdeev
*/
@@ -37,6 +39,10 @@ public abstract class BaseTaskAction extends AnAction implements DumbAware {
super(text);
}
protected BaseTaskAction(@Nullable final String text, @Nullable final String description, @Nullable final Icon icon) {
super(text, description, icon);
}
public void update(AnActionEvent event){
event.getPresentation().setEnabled(getProject(event) != null);
}
@@ -42,5 +42,6 @@ public class CloseTaskAction extends BaseTaskAction {
Presentation presentation = event.getPresentation();
Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
presentation.setEnabled(project != null && !TaskManager.getManager(project).getActiveTask().isDefault());
super.update(event);
}
}
@@ -0,0 +1,29 @@
package com.intellij.tasks.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.tasks.config.TaskRepositoriesConfigurable;
/**
* User: Evgeny Zakrevsky
*/
public class ConfigureServersAction extends BaseTaskAction {
public ConfigureServersAction() {
super("Configure Servers...", null, AllIcons.General.IdeOptions);
}
@Override
public void actionPerformed(AnActionEvent e) {
TaskRepositoriesConfigurable configurable = new TaskRepositoriesConfigurable(getProject(e));
if (ShowSettingsUtil.getInstance().editConfigurable(getProject(e), configurable)) {
serversChanged();
}
}
protected void serversChanged() {
}
}
@@ -41,6 +41,7 @@ public class CreateChangelistAction extends BaseTaskAction {
presentation.setText("Create changelist for '" + TaskUtil.getTrimmedSummary(manager.getActiveTask()) + "'");
presentation.setEnabled(true);
}
super.update(event);
}
@Override
@@ -5,9 +5,7 @@ import com.intellij.ide.util.gotoByName.ChooseByNameBase;
import com.intellij.ide.util.gotoByName.ChooseByNameItemProvider;
import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
import com.intellij.ide.util.gotoByName.SimpleChooseByNameModel;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
@@ -49,7 +47,7 @@ public class GotoTaskAction extends GotoActionBase {
myInAction = getClass();
final Ref<Boolean> shiftPressed = Ref.create(false);
ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, new GotoTaskPopupModel(project), new ChooseByNameItemProvider() {
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, new GotoTaskPopupModel(project), new ChooseByNameItemProvider() {
@NotNull
@Override
public List<String> filterNames(@NotNull ChooseByNameBase base, @NotNull String[] names, @NotNull String pattern) {
@@ -124,6 +122,16 @@ public class GotoTaskAction extends GotoActionBase {
}
});
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);
popup.setToolArea(actionToolbar.getComponent());
showNavigationPopup(new GotoActionCallback<Object>() {
@Override
public void elementChosen(ChooseByNamePopup popup, Object element) {
@@ -45,6 +45,7 @@ public class OpenTaskInBrowserAction extends BaseTaskAction {
} else {
presentation.setText("Open '" + TaskManager.getManager(project).getActiveTask().getPresentableName() + "' In _Browser");
}
super.update(event);
}
@Nullable