fixed [IDEADEV-41319] test runner: do not show green balloon and green progress bar...
[fedora-idea.git] / platform / testRunner / src / com / intellij / execution / testframework / ToolbarPanel.java
blobb29b0d3f5f765bb26df035268cb5a0264603db93
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * User: anna
19 * Date: 25-May-2007
21 package com.intellij.execution.testframework;
23 import com.intellij.execution.ExecutionBundle;
24 import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
25 import com.intellij.execution.configurations.RunnerSettings;
26 import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
27 import com.intellij.execution.testframework.actions.ShowStatisticsAction;
28 import com.intellij.execution.testframework.actions.TestFrameworkActions;
29 import com.intellij.execution.testframework.actions.TestTreeExpander;
30 import com.intellij.ide.CommonActionsManager;
31 import com.intellij.ide.OccurenceNavigator;
32 import com.intellij.openapi.Disposable;
33 import com.intellij.openapi.actionSystem.ActionManager;
34 import com.intellij.openapi.actionSystem.ActionPlaces;
35 import com.intellij.openapi.actionSystem.AnAction;
36 import com.intellij.openapi.actionSystem.DefaultActionGroup;
37 import com.intellij.openapi.extensions.Extensions;
38 import com.intellij.openapi.util.IconLoader;
39 import com.intellij.util.config.ToggleBooleanProperty;
41 import javax.swing.*;
42 import java.awt.*;
43 import java.util.ArrayList;
45 public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposable {
46 protected final TestTreeExpander myTreeExpander = new TestTreeExpander();
47 protected final FailedTestsNavigator myOccurenceNavigator;
48 protected final ScrollToTestSourceAction myScrollToSource;
50 private ArrayList<ToggleModelAction> myActions = new ArrayList<ToggleModelAction>();
52 public ToolbarPanel(final TestConsoleProperties properties,
53 final RunnerSettings runnerSettings,
54 final ConfigurationPerRunnerSettings configurationSettings, JComponent parent) {
55 super (new BorderLayout());
56 final DefaultActionGroup actionGroup = new DefaultActionGroup(null, false);
57 actionGroup.addAction(new ToggleBooleanProperty(ExecutionBundle.message("junit.run.hide.passed.action.name"),
58 ExecutionBundle.message("junit.run.hide.passed.action.description"),
59 TestsUIUtil.loadIcon("hidePassed"),
60 properties, TestConsoleProperties.HIDE_PASSED_TESTS));
61 actionGroup.addSeparator();
63 actionGroup.addAction(new ToggleBooleanProperty(ExecutionBundle.message("junit.runing.info.track.test.action.name"),
64 ExecutionBundle.message("junit.runing.info.track.test.action.description"),
65 TestsUIUtil.loadIcon("trackTests"),
66 properties, TestConsoleProperties.TRACK_RUNNING_TEST)).setAsSecondary(true);
68 AnAction action = CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, parent);
69 action.getTemplatePresentation().setDescription(ExecutionBundle.message("junit.runing.info.collapse.test.action.name"));
70 actionGroup.add(action);
72 action = CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, parent);
73 action.getTemplatePresentation().setDescription(ExecutionBundle.message("junit.runing.info.expand.test.action.name"));
74 actionGroup.add(action);
76 actionGroup.addSeparator();
77 final CommonActionsManager actionsManager = CommonActionsManager.getInstance();
78 myOccurenceNavigator = new FailedTestsNavigator();
79 actionGroup.add(actionsManager.createPrevOccurenceAction(myOccurenceNavigator));
80 actionGroup.add(actionsManager.createNextOccurenceAction(myOccurenceNavigator));
82 actionGroup.addAction(new ToggleBooleanProperty(ExecutionBundle.message("junit.runing.info.select.first.failed.action.name"),
83 null,
84 TestsUIUtil.loadIcon("selectFirstDefect"),
85 properties, TestConsoleProperties.SELECT_FIRST_DEFECT)).setAsSecondary(true);
86 actionGroup.addAction(new ToggleBooleanProperty(ExecutionBundle.message("junit.runing.info.scroll.to.stacktrace.action.name"),
87 ExecutionBundle.message("junit.runing.info.scroll.to.stacktrace.action.description"),
88 IconLoader.getIcon("/runConfigurations/scrollToStackTrace.png"),
89 properties, TestConsoleProperties.SCROLL_TO_STACK_TRACE)).setAsSecondary(true);
90 myScrollToSource = new ScrollToTestSourceAction(properties);
91 actionGroup.addAction(myScrollToSource).setAsSecondary(true);
92 actionGroup.addAction(new ToggleBooleanProperty(ExecutionBundle.message("junit.runing.info.open.source.at.exception.action.name"),
93 ExecutionBundle.message("junit.runing.info.open.source.at.exception.action.description"),
94 IconLoader.getIcon("/runConfigurations/sourceAtException.png"),
95 properties, TestConsoleProperties.OPEN_FAILURE_LINE)).setAsSecondary(true);
97 actionGroup.addAction(new ShowStatisticsAction(properties)).setAsSecondary(true);
99 for (ToggleModelActionProvider actionProvider : Extensions.getExtensions(ToggleModelActionProvider.EP_NAME)) {
100 final ToggleModelAction toggleModelAction = actionProvider.createToggleModelAction(properties);
101 myActions.add(toggleModelAction);
102 actionGroup.add(toggleModelAction);
104 appendAdditionalActions(actionGroup, properties, runnerSettings, configurationSettings, parent);
106 add(ActionManager.getInstance().
107 createActionToolbar(ActionPlaces.TESTTREE_VIEW_TOOLBAR, actionGroup, true).
108 getComponent(), BorderLayout.CENTER);
111 protected void appendAdditionalActions(DefaultActionGroup actionGroup, TestConsoleProperties properties, RunnerSettings runnerSettings,
112 ConfigurationPerRunnerSettings configurationSettings,
113 JComponent parent) {
116 public void setModel(final TestFrameworkRunningModel model) {
117 TestFrameworkActions.installFilterAction(model);
118 myScrollToSource.setModel(model);
119 myTreeExpander.setModel(model);
120 myOccurenceNavigator.setModel(model);
121 for (ToggleModelAction action : myActions) {
122 action.setModel(model);
126 public boolean hasNextOccurence() {
127 return myOccurenceNavigator.hasNextOccurence();
130 public boolean hasPreviousOccurence() {
131 return myOccurenceNavigator.hasPreviousOccurence();
134 public OccurenceInfo goNextOccurence() {
135 return myOccurenceNavigator.goNextOccurence();
138 public OccurenceInfo goPreviousOccurence() {
139 return myOccurenceNavigator.goPreviousOccurence();
142 public String getNextOccurenceActionName() {
143 return myOccurenceNavigator.getNextOccurenceActionName();
146 public String getPreviousOccurenceActionName() {
147 return myOccurenceNavigator.getPreviousOccurenceActionName();
150 public void dispose() {
151 myScrollToSource.setModel(null);