mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
autotest delay is customizable now
default is back to 3 seconds #RUBY-10517 fixed #PY-10711 fixed
This commit is contained in:
@@ -22,10 +22,8 @@ package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
|
||||
import com.intellij.execution.testframework.actions.ShowStatisticsAction;
|
||||
import com.intellij.execution.testframework.actions.TestFrameworkActions;
|
||||
import com.intellij.execution.testframework.actions.TestTreeExpander;
|
||||
import com.intellij.execution.testframework.actions.*;
|
||||
import com.intellij.execution.testframework.autotest.AdjustAutotestDelayActionGroup;
|
||||
import com.intellij.execution.testframework.export.ExportTestResultsAction;
|
||||
import com.intellij.execution.testframework.ui.AbstractTestTreeBuilder;
|
||||
import com.intellij.icons.AllIcons;
|
||||
@@ -104,6 +102,7 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab
|
||||
properties, TestConsoleProperties.OPEN_FAILURE_LINE)).setAsSecondary(true);
|
||||
|
||||
actionGroup.addAction(new ShowStatisticsAction(properties)).setAsSecondary(true);
|
||||
actionGroup.addAction(new AdjustAutotestDelayActionGroup(environment)).setAsSecondary(true);
|
||||
|
||||
for (ToggleModelActionProvider actionProvider : Extensions.getExtensions(ToggleModelActionProvider.EP_NAME)) {
|
||||
final ToggleModelAction toggleModelAction = actionProvider.createToggleModelAction(properties);
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.testframework.autotest;
|
||||
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Dennis.Ushakov
|
||||
*/
|
||||
public class AdjustAutotestDelayActionGroup extends ActionGroup {
|
||||
public static final int MAX_DELAY = 10;
|
||||
private final ExecutionEnvironment myEnvironment;
|
||||
|
||||
public AdjustAutotestDelayActionGroup(ExecutionEnvironment environment) {
|
||||
super("Set AutoTest Delay", true);
|
||||
myEnvironment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setVisible(Boolean.TRUE == myEnvironment.getUserData(AutoTestManager.AUTOTESTABLE));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
final AnAction[] actions = new AnAction[MAX_DELAY];
|
||||
for (int i = 0; i < MAX_DELAY; i++) {
|
||||
actions[i] = new SetAutoTestDelayAction(i + 1);
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
private static class SetAutoTestDelayAction extends ToggleAction {
|
||||
private final int myDelay;
|
||||
|
||||
public SetAutoTestDelayAction(int delay) {
|
||||
super(delay + "s");
|
||||
myDelay = delay * 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return AutoTestManager.getInstance(e.getProject()).getDelay() == myDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
AutoTestManager.getInstance(e.getProject()).setDelay(myDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
-3
@@ -4,10 +4,12 @@ import com.intellij.execution.DelayedDocumentWatcher;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentManagerImpl;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.util.Alarm;
|
||||
@@ -20,9 +22,12 @@ import java.util.Collection;
|
||||
* @author yole
|
||||
*/
|
||||
public class AutoTestManager {
|
||||
private static final int AUTOTEST_DELAY = 10000;
|
||||
static final Key<Boolean> AUTOTESTABLE = Key.create("auto.test.manager.supported");
|
||||
|
||||
private final DelayedDocumentWatcher myDocumentWatcher;
|
||||
private final Project myProject;
|
||||
|
||||
private int myDelay;
|
||||
private DelayedDocumentWatcher myDocumentWatcher;
|
||||
private final Collection<Content> myEnabledDescriptors = new WeakList<Content>();
|
||||
|
||||
public static AutoTestManager getInstance(Project project) {
|
||||
@@ -30,7 +35,13 @@ public class AutoTestManager {
|
||||
}
|
||||
|
||||
public AutoTestManager(Project project) {
|
||||
myDocumentWatcher = new DelayedDocumentWatcher(project, new Alarm(Alarm.ThreadToUse.SWING_THREAD, project), AUTOTEST_DELAY, new Consumer<VirtualFile[]>() {
|
||||
myProject = project;
|
||||
myDocumentWatcher = createWatcher();
|
||||
myDelay = PropertiesComponent.getInstance(myProject).getOrInitInt("auto.test.manager.delay", 3000);
|
||||
}
|
||||
|
||||
private DelayedDocumentWatcher createWatcher() {
|
||||
return new DelayedDocumentWatcher(myProject, new Alarm(Alarm.ThreadToUse.SWING_THREAD, myProject), myDelay, new Consumer<VirtualFile[]>() {
|
||||
@Override
|
||||
public void consume(VirtualFile[] files) {
|
||||
for (Content content : myEnabledDescriptors) {
|
||||
@@ -81,4 +92,17 @@ public class AutoTestManager {
|
||||
}
|
||||
restarter.run();
|
||||
}
|
||||
|
||||
int getDelay() {
|
||||
return myDelay;
|
||||
}
|
||||
|
||||
void setDelay(int delay) {
|
||||
myDelay = delay;
|
||||
myDocumentWatcher.deactivate();
|
||||
myDocumentWatcher = createWatcher();
|
||||
if (!myEnabledDescriptors.isEmpty()) {
|
||||
myDocumentWatcher.activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,11 +1,11 @@
|
||||
package com.intellij.execution.testframework.autotest;
|
||||
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentManager;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
@@ -13,9 +13,10 @@ import com.intellij.openapi.project.Project;
|
||||
* @author yole
|
||||
*/
|
||||
public class ToggleAutoTestAction extends ToggleAction {
|
||||
public ToggleAutoTestAction() {
|
||||
public ToggleAutoTestAction(ExecutionEnvironment environment) {
|
||||
super("Toggle auto-test", "Toggle automatic rerun of tests on code changes",
|
||||
AllIcons.Actions.SwapPanels);
|
||||
environment.putUserData(AutoTestManager.AUTOTESTABLE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user