diff options
Diffstat (limited to 'plugins/gradle')
5 files changed, 130 insertions, 41 deletions
diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml index f15f424a10b8..f00346625e81 100644 --- a/plugins/gradle/src/META-INF/plugin.xml +++ b/plugins/gradle/src/META-INF/plugin.xml @@ -106,6 +106,7 @@ <applicationService serviceImplementation="org.jetbrains.plugins.gradle.service.GradleInstallationManager"/> + <applicationService serviceImplementation="org.jetbrains.plugins.gradle.settings.GradleSystemSettings"/> <projectService serviceImplementation="org.jetbrains.plugins.gradle.settings.GradleSettings"/> <projectService serviceImplementation="org.jetbrains.plugins.gradle.settings.GradleLocalSettings"/> <projectService serviceImplementation="org.jetbrains.plugins.gradle.service.project.GradleNotification"/> diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeSuiteEvent.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeSuiteEvent.java index 85e06cdc7dda..c9a69b0987d6 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeSuiteEvent.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeSuiteEvent.java @@ -47,10 +47,10 @@ public class BeforeSuiteEvent extends AbstractTestEvent { getConsoleManager().getTestsMap().put(testId, testProxy); final SMTestProxy parentTestProxy = getConsoleManager().getTestsMap().get(parentTestId); if (parentTestProxy != null) { - parentTestProxy.addChild(testProxy); addToInvokeLater(new Runnable() { @Override public void run() { + parentTestProxy.addChild(testProxy); getResultsViewer().onSuiteStarted(testProxy); } }); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeTestEvent.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeTestEvent.java index bd512bc65b8a..8b7976406e2f 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeTestEvent.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/events/BeforeTestEvent.java @@ -46,12 +46,22 @@ public class BeforeTestEvent extends AbstractTestEvent { getConsoleManager().getTestsMap().put(testId, testProxy); if (StringUtil.isEmpty(parentTestId)) { - getResultsViewer().getTestsRootNode().addChild(testProxy); + addToInvokeLater(new Runnable() { + @Override + public void run() { + getResultsViewer().getTestsRootNode().addChild(testProxy); + } + }); } else { final SMTestProxy parentTestProxy = getConsoleManager().getTestsMap().get(parentTestId); if (parentTestProxy != null) { - parentTestProxy.addChild(testProxy); + addToInvokeLater(new Runnable() { + @Override + public void run() { + parentTestProxy.addChild(testProxy); + } + }); } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java index d85e6cf1a742..db1569965d4a 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java @@ -30,26 +30,24 @@ import java.util.Set; /** * Holds shared project-level gradle-related settings (should be kept at the '*.ipr' or under '.idea'). - * + * * @author peter */ @State( - name = "GradleSettings", - storages = { - @Storage(file = StoragePathMacros.PROJECT_FILE), - @Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/gradle.xml", scheme = StorageScheme.DIRECTORY_BASED) - } + name = "GradleSettings", + storages = { + @Storage(file = StoragePathMacros.PROJECT_FILE), + @Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/gradle.xml", scheme = StorageScheme.DIRECTORY_BASED) + } ) public class GradleSettings extends AbstractExternalSystemSettings<GradleSettings, GradleProjectSettings, GradleSettingsListener> - implements PersistentStateComponent<GradleSettings.MyState> -{ + implements PersistentStateComponent<GradleSettings.MyState> { - @Nullable private String myServiceDirectoryPath; - @Nullable private String myGradleVmOptions; - private boolean myIsOfflineWork; + private final GradleSystemSettings mySystemSettings; public GradleSettings(@NotNull Project project) { super(GradleSettingsListener.TOPIC, project); + mySystemSettings = GradleSystemSettings.getInstance(); } @NotNull @@ -65,9 +63,6 @@ public class GradleSettings extends AbstractExternalSystemSettings<GradleSetting @Override protected void copyExtraSettingsFrom(@NotNull GradleSettings settings) { - myServiceDirectoryPath = settings.getServiceDirectoryPath(); - myGradleVmOptions = settings.getGradleVmOptions(); - myIsOfflineWork = settings.isOfflineWork(); } @SuppressWarnings("unchecked") @@ -76,58 +71,52 @@ public class GradleSettings extends AbstractExternalSystemSettings<GradleSetting public GradleSettings.MyState getState() { MyState state = new MyState(); fillState(state); - state.serviceDirectoryPath = myServiceDirectoryPath; - state.gradleVmOptions = myGradleVmOptions; - state.offlineWork = myIsOfflineWork; return state; } @Override public void loadState(MyState state) { super.loadState(state); - myServiceDirectoryPath = state.serviceDirectoryPath; - myGradleVmOptions = state.gradleVmOptions; - myIsOfflineWork = state.offlineWork; } /** * @return service directory path (if defined). 'Service directory' is a directory which is used internally by gradle during - * calls to the tooling api. E.g. it holds downloaded binaries (dependency jars). We allow to define it because there - * is a possible situation when a user wants to configure particular directory to be excluded from anti-virus protection - * in order to increase performance + * calls to the tooling api. E.g. it holds downloaded binaries (dependency jars). We allow to define it because there + * is a possible situation when a user wants to configure particular directory to be excluded from anti-virus protection + * in order to increase performance */ @Nullable public String getServiceDirectoryPath() { - return myServiceDirectoryPath; + return mySystemSettings.getServiceDirectoryPath(); } public void setServiceDirectoryPath(@Nullable String newPath) { + String myServiceDirectoryPath = mySystemSettings.getServiceDirectoryPath(); if (!Comparing.equal(myServiceDirectoryPath, newPath)) { - String oldPath = myServiceDirectoryPath; - myServiceDirectoryPath = newPath; - getPublisher().onServiceDirectoryPathChange(oldPath, newPath); - } + mySystemSettings.setServiceDirectoryPath(newPath); + getPublisher().onServiceDirectoryPathChange(myServiceDirectoryPath, newPath); + } } @Nullable public String getGradleVmOptions() { - return myGradleVmOptions; + return mySystemSettings.getGradleVmOptions(); } - + public void setGradleVmOptions(@Nullable String gradleVmOptions) { + String myGradleVmOptions = mySystemSettings.getGradleVmOptions(); if (!Comparing.equal(myGradleVmOptions, gradleVmOptions)) { - String old = myGradleVmOptions; - myGradleVmOptions = gradleVmOptions; - getPublisher().onGradleVmOptionsChange(old, gradleVmOptions); + mySystemSettings.setGradleVmOptions(gradleVmOptions); + getPublisher().onGradleVmOptionsChange(myGradleVmOptions, gradleVmOptions); } } public boolean isOfflineWork() { - return myIsOfflineWork; + return mySystemSettings.isOfflineWork(); } public void setOfflineWork(boolean isOfflineWork) { - myIsOfflineWork = isOfflineWork; + mySystemSettings.setOfflineWork(isOfflineWork); } @Override @@ -143,9 +132,6 @@ public class GradleSettings extends AbstractExternalSystemSettings<GradleSetting public static class MyState implements State<GradleProjectSettings> { private Set<GradleProjectSettings> myProjectSettings = ContainerUtilRt.newTreeSet(); - public String serviceDirectoryPath; - public String gradleVmOptions; - public boolean offlineWork; @AbstractCollection(surroundWithTag = false, elementTypes = {GradleProjectSettings.class}) public Set<GradleProjectSettings> getLinkedExternalProjectsSettings() { diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSystemSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSystemSettings.java new file mode 100644 index 000000000000..b24bd24cbf0d --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSystemSettings.java @@ -0,0 +1,92 @@ +/* + * Copyright 2000-2014 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 org.jetbrains.plugins.gradle.settings; + +import com.intellij.openapi.components.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Vladislav.Soroka + * @since 14/8/2014 + */ +@State( + name = "GradleSystemSettings", + storages = { + @Storage(file = StoragePathMacros.APP_CONFIG + "/gradle.settings.xml") + } +) +public class GradleSystemSettings implements PersistentStateComponent<GradleSystemSettings.MyState> { + + @Nullable private String myServiceDirectoryPath; + @Nullable private String myGradleVmOptions; + private boolean myIsOfflineWork; + + @NotNull + public static GradleSystemSettings getInstance() { + return ServiceManager.getService(GradleSystemSettings.class); + } + + @SuppressWarnings("unchecked") + @Nullable + @Override + public GradleSystemSettings.MyState getState() { + MyState state = new MyState(); + state.serviceDirectoryPath = myServiceDirectoryPath; + state.gradleVmOptions = myGradleVmOptions; + state.offlineWork = myIsOfflineWork; + return state; + } + + @Override + public void loadState(MyState state) { + myServiceDirectoryPath = state.serviceDirectoryPath; + myGradleVmOptions = state.gradleVmOptions; + myIsOfflineWork = state.offlineWork; + } + + @Nullable + public String getServiceDirectoryPath() { + return myServiceDirectoryPath; + } + + public void setServiceDirectoryPath(@Nullable String newPath) { + myServiceDirectoryPath = newPath; + } + + @Nullable + public String getGradleVmOptions() { + return myGradleVmOptions; + } + + public void setGradleVmOptions(@Nullable String gradleVmOptions) { + myGradleVmOptions = gradleVmOptions; + } + + public boolean isOfflineWork() { + return myIsOfflineWork; + } + + public void setOfflineWork(boolean isOfflineWork) { + myIsOfflineWork = isOfflineWork; + } + + public static class MyState { + public String serviceDirectoryPath; + public String gradleVmOptions; + public boolean offlineWork; + } +}
\ No newline at end of file |