mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (annotations; formatting)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -13,64 +13,56 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.execution.util;
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.util.config.AbstractProperty;
|
||||
import com.intellij.util.config.Storage;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StoringPropertyContainer extends AbstractProperty.AbstractPropertyContainer<AbstractProperty<Boolean>> {
|
||||
private final HashMap<AbstractProperty<Boolean>, Boolean> myValues = new HashMap<AbstractProperty<Boolean>, Boolean>();
|
||||
private final Map<AbstractProperty<Boolean>, Boolean> myValues = new HashMap<AbstractProperty<Boolean>, Boolean>();
|
||||
private final Storage myStorage;
|
||||
|
||||
public StoringPropertyContainer(@NonNls final String groupName, final PropertiesComponent propertiesComponent) {
|
||||
public StoringPropertyContainer(String groupName, PropertiesComponent propertiesComponent) {
|
||||
this(new Storage.PropertiesComponentStorage(groupName, propertiesComponent));
|
||||
}
|
||||
|
||||
public StoringPropertyContainer(final Storage storage) {
|
||||
public StoringPropertyContainer(@NotNull Storage storage) {
|
||||
myStorage = storage;
|
||||
}
|
||||
|
||||
public void setIfUndefined(AbstractProperty<Boolean> property, boolean value) {
|
||||
public void setIfUndefined(@NotNull AbstractProperty<Boolean> property, boolean value) {
|
||||
if (myStorage.get(property.getName()) == null) {
|
||||
setValueOf(property, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setValueOf(final AbstractProperty<Boolean> property, final Object value) {
|
||||
protected void setValueOf(@NotNull AbstractProperty<Boolean> property, Object value) {
|
||||
myValues.put(property, (Boolean)value);
|
||||
onPropertyChanged(property, (Boolean)value);
|
||||
myStorage.put(property.getName(), stringValue(value));
|
||||
}
|
||||
|
||||
private String stringValue(final Object value) {
|
||||
return value.toString();
|
||||
myStorage.put(property.getName(), value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProperty(final AbstractProperty property) {
|
||||
public boolean hasProperty(@NotNull AbstractProperty property) {
|
||||
return myValues.containsKey(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getValueOf(final AbstractProperty<Boolean> property) {
|
||||
protected Object getValueOf(@NotNull AbstractProperty<Boolean> property) {
|
||||
Object value = myValues.get(property);
|
||||
if (value == null) {
|
||||
final String stringValue = myStorage.get(property.getName());
|
||||
value = stringValue != null ? parseValue(stringValue) : property.getDefault(this);
|
||||
String stringValue = myStorage.get(property.getName());
|
||||
value = stringValue != null ? Boolean.valueOf(stringValue) : property.getDefault(this);
|
||||
myValues.put(property, (Boolean)value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private Boolean parseValue(final String stringValue) {
|
||||
return Boolean.valueOf(stringValue);
|
||||
}
|
||||
|
||||
protected <T> void onPropertyChanged(final AbstractProperty<T> property, final T value) {}
|
||||
protected <T> void onPropertyChanged(@NotNull AbstractProperty<T> property, T value) { }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -24,48 +24,53 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public interface Storage {
|
||||
void put(String key, String value);
|
||||
String get(String key);
|
||||
|
||||
class PropertiesComponentStorage implements Storage {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.config.Storage.PropertiesComponentStorage");
|
||||
|
||||
private final PropertiesComponent myPropertiesComponent;
|
||||
private final String myPrefix;
|
||||
|
||||
public PropertiesComponentStorage(@NonNls String prefix, PropertiesComponent propertiesComponent) {
|
||||
public PropertiesComponentStorage(String prefix, PropertiesComponent propertiesComponent) {
|
||||
LOG.assertTrue(propertiesComponent != null || ApplicationManager.getApplication().isUnitTestMode());
|
||||
myPropertiesComponent = propertiesComponent;
|
||||
myPrefix = prefix;
|
||||
}
|
||||
|
||||
public PropertiesComponentStorage(@NonNls String prefix) {
|
||||
public PropertiesComponentStorage(String prefix) {
|
||||
this(prefix, PropertiesComponent.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
if (myPropertiesComponent != null)
|
||||
if (myPropertiesComponent != null) {
|
||||
myPropertiesComponent.setValue(myPrefix + key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return myPropertiesComponent != null ? myPropertiesComponent.getValue(myPrefix + key) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return "PropertiesComponentStorage: " + myPrefix;
|
||||
}
|
||||
}
|
||||
|
||||
class MapStorage implements Storage {
|
||||
private final Map<String, String> myValues = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return myValues.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
myValues.put(key, value);
|
||||
}
|
||||
|
||||
+6
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -67,14 +67,16 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements
|
||||
@NotNull String testFrameworkName,
|
||||
@NotNull Executor executor,
|
||||
boolean printTestingStartedTime) {
|
||||
super(new Storage.PropertiesComponentStorage(testFrameworkName + "Support.", PropertiesComponent.getInstance()),
|
||||
config.getProject(),
|
||||
executor);
|
||||
super(getStorage(testFrameworkName), config.getProject(), executor);
|
||||
myConfiguration = config;
|
||||
myCustomFilter = new CompositeFilter(config.getProject());
|
||||
myPrintTestingStartedTime = printTestingStartedTime;
|
||||
}
|
||||
|
||||
private static Storage.PropertiesComponentStorage getStorage(String testFrameworkName) {
|
||||
return new Storage.PropertiesComponentStorage(testFrameworkName + "Support.", PropertiesComponent.getInstance());
|
||||
}
|
||||
|
||||
public RunConfiguration getConfiguration() {
|
||||
return myConfiguration;
|
||||
}
|
||||
|
||||
+3
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -21,10 +21,8 @@ import com.intellij.execution.testframework.*;
|
||||
import com.intellij.execution.testframework.sm.SMRunnerUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.*;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.statistics.StatisticsPanel;
|
||||
import com.intellij.execution.testframework.ui.AbstractTestTreeBuilder;
|
||||
import com.intellij.execution.testframework.ui.TestResultsPanel;
|
||||
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.progress.util.ColorProgressBar;
|
||||
@@ -218,12 +216,10 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
|
||||
myStartTime = System.currentTimeMillis();
|
||||
boolean printTestingStartedTime = true;
|
||||
if (myConsoleProperties instanceof SMTRunnerConsoleProperties) {
|
||||
printTestingStartedTime = ((SMTRunnerConsoleProperties) myConsoleProperties).isPrintTestingStartedTime();
|
||||
printTestingStartedTime = ((SMTRunnerConsoleProperties)myConsoleProperties).isPrintTestingStartedTime();
|
||||
}
|
||||
if (printTestingStartedTime) {
|
||||
myTestsRootNode.addSystemOutput("Testing started at "
|
||||
+ DateFormatUtil.formatTime(myStartTime)
|
||||
+ " ...\n");
|
||||
myTestsRootNode.addSystemOutput("Testing started at " + DateFormatUtil.formatTime(myStartTime) + " ...\n");
|
||||
}
|
||||
|
||||
updateStatusLabel(false);
|
||||
|
||||
+36
-39
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 25-May-2007
|
||||
*/
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
@@ -39,14 +34,19 @@ import com.intellij.util.config.AbstractProperty;
|
||||
import com.intellij.util.config.BooleanProperty;
|
||||
import com.intellij.util.config.Storage;
|
||||
import com.intellij.util.config.ToggleBooleanProperty;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 25-May-2007
|
||||
*/
|
||||
public abstract class TestConsoleProperties extends StoringPropertyContainer implements Disposable {
|
||||
public static final BooleanProperty SCROLL_TO_STACK_TRACE = new BooleanProperty("scrollToStackTrace", false);
|
||||
public static final BooleanProperty SORT_ALPHABETICALLY = new BooleanProperty("sortTestsAlphabetically", false);
|
||||
@@ -66,10 +66,9 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
private boolean myUsePredefinedMessageFilter = true;
|
||||
private GlobalSearchScope myScope;
|
||||
|
||||
protected final HashMap<AbstractProperty, ArrayList<TestFrameworkPropertyListener>> myListeners =
|
||||
new HashMap<AbstractProperty, ArrayList<TestFrameworkPropertyListener>>();
|
||||
protected final Map<AbstractProperty, List<TestFrameworkPropertyListener>> myListeners = ContainerUtil.newHashMap();
|
||||
|
||||
public TestConsoleProperties(final Storage storage, Project project, Executor executor) {
|
||||
public TestConsoleProperties(Storage storage, Project project, Executor executor) {
|
||||
super(storage);
|
||||
myProject = project;
|
||||
myExecutor = executor;
|
||||
@@ -91,8 +90,11 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
if (!(configuration instanceof ModuleRunProfile)) {
|
||||
return GlobalSearchScope.allScope(myProject);
|
||||
}
|
||||
Module[] modules = ((ModuleRunProfile) configuration).getModules();
|
||||
if (modules.length == 0) return GlobalSearchScope.allScope(myProject);
|
||||
|
||||
Module[] modules = ((ModuleRunProfile)configuration).getModules();
|
||||
if (modules.length == 0) {
|
||||
return GlobalSearchScope.allScope(myProject);
|
||||
}
|
||||
|
||||
GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
|
||||
for (Module each : modules) {
|
||||
@@ -101,22 +103,21 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
return scope;
|
||||
}
|
||||
|
||||
public <T> void addListener(final AbstractProperty<T> property, final TestFrameworkPropertyListener<T> listener) {
|
||||
ArrayList<TestFrameworkPropertyListener> listeners = myListeners.get(property);
|
||||
public <T> void addListener(@NotNull AbstractProperty<T> property, @NotNull TestFrameworkPropertyListener<T> listener) {
|
||||
List<TestFrameworkPropertyListener> listeners = myListeners.get(property);
|
||||
if (listeners == null) {
|
||||
listeners = new ArrayList<TestFrameworkPropertyListener>();
|
||||
myListeners.put(property, listeners);
|
||||
myListeners.put(property, (listeners = ContainerUtil.newArrayList()));
|
||||
}
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public <T> void addListenerAndSendValue(final AbstractProperty<T> property, final TestFrameworkPropertyListener<T> listener) {
|
||||
public <T> void addListenerAndSendValue(@NotNull AbstractProperty<T> property, @NotNull TestFrameworkPropertyListener<T> listener) {
|
||||
addListener(property, listener);
|
||||
listener.onChanged(property.get(this));
|
||||
}
|
||||
|
||||
public <T> void removeListener(final AbstractProperty<T> property, final TestFrameworkPropertyListener listener) {
|
||||
final ArrayList<TestFrameworkPropertyListener> listeners = myListeners.get(property);
|
||||
public <T> void removeListener(@NotNull AbstractProperty<T> property, @NotNull TestFrameworkPropertyListener listener) {
|
||||
List<TestFrameworkPropertyListener> listeners = myListeners.get(property);
|
||||
if (listeners != null) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
@@ -131,25 +132,26 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
final XDebugSession debuggerSession = XDebuggerManager.getInstance(myProject).getDebugSession(getConsole());
|
||||
XDebugSession debuggerSession = XDebuggerManager.getInstance(myProject).getDebugSession(getConsole());
|
||||
return debuggerSession != null && debuggerSession.isPaused();
|
||||
}
|
||||
|
||||
protected <T> void onPropertyChanged(final AbstractProperty<T> property, final T value) {
|
||||
final ArrayList<TestFrameworkPropertyListener> listeners = myListeners.get(property);
|
||||
if (listeners == null) return;
|
||||
final Object[] propertyListeners = listeners.toArray();
|
||||
for (Object propertyListener : propertyListeners) {
|
||||
final TestFrameworkPropertyListener<T> listener = (TestFrameworkPropertyListener<T>)propertyListener;
|
||||
listener.onChanged(value);
|
||||
@Override
|
||||
protected <T> void onPropertyChanged(@NotNull AbstractProperty<T> property, T value) {
|
||||
List<TestFrameworkPropertyListener> listeners = myListeners.get(property);
|
||||
if (listeners != null) {
|
||||
for (Object o : listeners.toArray()) {
|
||||
@SuppressWarnings("unchecked") TestFrameworkPropertyListener<T> listener = (TestFrameworkPropertyListener<T>)o;
|
||||
listener.onChanged(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setConsole(final ConsoleView console) {
|
||||
public void setConsole(ConsoleView console) {
|
||||
myConsole = console;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myListeners.clear();
|
||||
}
|
||||
@@ -164,7 +166,6 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
* switching to any other test/suite in tests results view. It's highly not recommended to change
|
||||
* default behaviour. Please do it only in critical cases and only if you are sure that you need this feature.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* NB2: If you are using Service Messages based test runner please ensure that before each service message
|
||||
* (e.g. #teamcity[...]) you always send "\n" to the output stream.
|
||||
*
|
||||
@@ -186,16 +187,12 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
myUsePredefinedMessageFilter = usePredefinedMessageFilter;
|
||||
}
|
||||
|
||||
protected void appendAdditionalActions(DefaultActionGroup actionGroup,
|
||||
ExecutionEnvironment environment, JComponent parent) {
|
||||
}
|
||||
protected void appendAdditionalActions(DefaultActionGroup actionGroup, ExecutionEnvironment environment, JComponent parent) { }
|
||||
|
||||
@NotNull
|
||||
protected ToggleBooleanProperty createIncludeNonStartedInRerun() {
|
||||
return new ToggleBooleanProperty(
|
||||
ExecutionBundle.message("junit.runing.info.include.non.started.in.rerun.failed.action.name"),
|
||||
null,
|
||||
AllIcons.RunConfigurations.IncludeNonStartedTests_Rerun,
|
||||
this, TestConsoleProperties.INCLUDE_NON_STARTED_IN_RERUN_FAILED);
|
||||
String text = ExecutionBundle.message("junit.runing.info.include.non.started.in.rerun.failed.action.name");
|
||||
Icon icon = AllIcons.RunConfigurations.IncludeNonStartedTests_Rerun;
|
||||
return new ToggleBooleanProperty(text, null, icon, this, INCLUDE_NON_STARTED_IN_RERUN_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user