nvidia settingss.gradle 可以忽略吗

org.jetbrains.plugins.gradle.settings.GradleSettings
& Snippets apiwave
@@ -0,0 +1,37 @@
+ * Copyright
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.
+import com.intellij.openapi.actionSystem.AnActionE
+import com.intellij.openapi.externalSystem.action.ExternalSystemToggleA
+import org.jetbrains.plugins.gradle.settings.GradleS
+ * @author Vladislav.Soroka
+ * @since 10/20/2014
+public class ToggleOfflineAction extends ExternalSystemToggleAction {
protected boolean doIsSelected(AnActionEvent e) {
return GradleSettings.getInstance(getProject(e)).isOfflineWork();
public void setSelected(AnActionEvent e, boolean state) {
GradleSettings.getInstance(getProject(e)).setOfflineWork(state);
@@ -15,18 +15,39 @@
package org.jetbrains.plugins.gradle.service.
+import com.intellij.ide.util.projectWizard.WizardC
+import com.intellij.openapi.externalSystem.model.DataN
+import com.intellij.openapi.externalSystem.model.ProjectK
+import com.intellij.openapi.externalSystem.model.project.JavaProjectD
+import com.intellij.openapi.externalSystem.model.project.ProjectD
+import com.intellij.openapi.externalSystem.service.project.manage.*;
import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportB
+import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsM
+import com.intellij.openapi.externalSystem.util.ExternalSystemU
+import com.intellij.openapi.project.P
+import com.intellij.openapi.project.ProjectM
+import com.intellij.openapi.projectRoots.JavaSdkV
+import com.intellij.openapi.projectRoots.S
+import com.intellij.openapi.roots.LanguageLevelProjectE
+import com.intellij.pom.java.LanguageL
import icons.GradleI
import org.jetbrains.annotations.NotN
+import org.jetbrains.plugins.gradle.settings.GradleS
import org.jetbrains.plugins.gradle.util.GradleB
+import org.jetbrains.plugins.gradle.util.GradleC
import javax.swing.*;
+import java.io.F
* @author Denis Zhdanov
* @since 4/15/13 2:29 PM
-public class GradleProjectImportBuilder extends AbstractExternalProjectImportBuilder {
+public class GradleProjectImportBuilder extends AbstractExternalProjectImportBuilder&GradleConfigurable& {
public GradleProjectImportBuilder(@NotNull ExternalSystemSettingsManager settingsManager, @NotNull ProjectDataManager dataManager) {
super(settingsManager, dataManager, new GradleConfigurable(null), GradleConstants.SYSTEM_ID);
@@ -38,4 +59,68 @@ public class GradleProjectImportBuilder extends AbstractExternalProjectImportBui
public Icon getIcon() {
return GradleIcons.G
protected void doPrepare(@NotNull WizardContext context) {
String pathToUse = context.getProjectFileDirectory();
if (!pathToUse.endsWith(GradleConstants.DEFAULT_SCRIPT_NAME)) {
pathToUse = new File(pathToUse, GradleConstants.DEFAULT_SCRIPT_NAME).getAbsolutePath();
getConfigurable().setLinkedExternalProjectPath(pathToUse);
protected void beforeCommit(@NotNull DataNode&ProjectData& dataNode, @NotNull Project project) {
DataNode&JavaProjectData& javaProjectNode = ExternalSystemUtil.find(dataNode, ProjectKeys.JAVA_PROJECT);
if (javaProjectNode == null) {
final LanguageLevel externalLanguageLevel = javaProjectNode.getData().getLanguageLevel();
final LanguageLevelProjectExtension languageLevelExtension = LanguageLevelProjectExtension.getInstance(project);
if (externalLanguageLevel != languageLevelExtension.getLanguageLevel()) {
languageLevelExtension.setLanguageLevel(externalLanguageLevel);
protected void applyExtraSettings(@NotNull WizardContext context) {
DataNode&ProjectData& node = getExternalProjectNode();
if (node == null) {
DataNode&JavaProjectData& javaProjectNode = ExternalSystemUtil.find(node, ProjectKeys.JAVA_PROJECT);
if (javaProjectNode != null) {
JavaProjectData data = javaProjectNode.getData();
context.setCompilerOutputDirectory(data.getCompileOutputPath());
JavaSdkVersion version = data.getJdkVersion();
Sdk jdk = ExternalSystemUtil.findJdk(version);
if (jdk != null) {
context.setProjectJdk(jdk);
protected void onProjectInit(@NotNull Project project) {
GradleSettings settings = (GradleSettings)getSettingsManager().getSettings(project, GradleConstants.SYSTEM_ID);
settings.setPreferLocalInstallationToWrapper(getConfigurable().isPreferLocalInstallationToWrapper());
settings.setGradleHome(getConfigurable().getGradleHomePath());
// Reset linked gradle home for default project (legacy bug).
Project defaultProject = ProjectManager.getInstance().getDefaultProject();
getSettingsManager().getSettings(defaultProject, GradleConstants.SYSTEM_ID).setLinkedExternalProjectPath(null);
protected File getExternalProjectConfigToUse(@NotNull File file) {
if (file.isDirectory()) {
File candidate = new File(file, GradleConstants.DEFAULT_SCRIPT_NAME);
if (candidate.isFile()) {
@@ -0,0 +1,167 @@
+ * Copyright
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.codeI
+import com.intellij.ProjectT
+import com.intellij.openapi.diagnostic.L
+import com.intellij.openapi.externalSystem.util.ExternalSystemC
+import com.intellij.openapi.fileEditor.FileE
+import com.intellij.openapi.module.M
+import com.intellij.openapi.module.ModuleUtilC
+import com.intellij.openapi.progress.ProcessCanceledE
+import com.intellij.openapi.project.IndexNotReadyE
+import com.intellij.openapi.project.P
+import com.intellij.openapi.roots.ModuleRootA
+import com.intellij.openapi.roots.ModuleRootE
+import com.intellij.openapi.util.K
+import com.intellij.openapi.util.text.StringU
+import com.intellij.openapi.vfs.VirtualF
+import com.intellij.ui.EditorNotificationP
+import com.intellij.ui.EditorN
+import org.gradle.util.GU
+import org.gradle.wrapper.WrapperC
+import org.gradle.wrapper.WrapperE
+import org.jetbrains.annotations.NotN
+import org.jetbrains.annotations.N
+import org.jetbrains.plugins.gradle.settings.GradleProjectS
+import org.jetbrains.plugins.gradle.settings.GradleS
+import org.jetbrains.plugins.gradle.util.GradleB
+import org.jetbrains.plugins.gradle.util.GradleC
+import org.jetbrains.plugins.gradle.util.GradleU
+import java.io.F
+import java.net.URI;
+import java.util.P
+import java.util.regex.P
+ * @author Vladislav.Soroka
+ * @since 9/13/13
+public class UseDistributionWithSourcesNotificationProvider extends EditorNotifications.Provider&EditorNotificationPanel& {
public static final Pattern GRADLE_SRC_DISTIBUTION_PATTERN;
private static final Logger LOG = Logger.getInstance(&#& + UseDistributionWithSourcesNotificationProvider.class.getName());
private static final Key&EditorNotificationPanel& KEY = Key.create(&gradle.notifications.use.distribution.with.sources&);
private static final String ALL_ZIP_DISTRIBUTION_URI_SUFFIX = &-all.zip&;
private final Project myP
GRADLE_SRC_DISTIBUTION_PATTERN = Pattern.compile(&http\\\\?://services\\.gradle\\.org.*& + ALL_ZIP_DISTRIBUTION_URI_SUFFIX);
public UseDistributionWithSourcesNotificationProvider(Project project, final EditorNotifications notifications) {
myProject =
project.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
public void rootsChanged(ModuleRootEvent event) {
notifications.updateAllNotifications();
public Key&EditorNotificationPanel& getKey() {
return KEY;
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
if (GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName()) ||
GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())) {
final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module == null)
final String linkedProjectPath = getConfigPath(module);
if (linkedProjectPath == null)
final GradleProjectSettings settings = GradleSettings.getInstance(module.getProject()).getLinkedProjectSettings(linkedProjectPath);
if (settings == null)
if (settings.isDisableWrapperSourceDistributionNotification())
if (isWrapperDistributionWithSourcesUsed(linkedProjectPath))
final EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(GradleBundle.message(&gradle.notifications.use.distribution.with.sources&));
panel.createActionLabel(GradleBundle.message(&gradle.notifications.hide.tip&), new Runnable() {
public void run() {
settings.setDisableWrapperSourceDistributionNotification(true);
EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
panel.createActionLabel(GradleBundle.message(&gradle.notifications.apply.suggestion&), new Runnable() {
public void run() {
updateWrapperConfiguration(linkedProjectPath);
EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
catch (ProcessCanceledException ignored) {
catch (IndexNotReadyException ignored) {
private static void updateWrapperConfiguration(@NotNull String linkedProjectPath) {
final VirtualFile wrapperPropertiesFile = GradleUtil.findWrapperPropertiesFile(linkedProjectPath);
if (wrapperPropertiesFile == null)
final WrapperConfiguration wrapperConfiguration = GradleUtil.getWrapperConfiguration(linkedProjectPath);
if (wrapperConfiguration == null)
String currentDistributionUri = wrapperConfiguration.getDistribution().toString();
if (StringUtil.endsWith(currentDistributionUri, ALL_ZIP_DISTRIBUTION_URI_SUFFIX))
final String distributionUri =
currentDistributionUri.substring(0, currentDistributionUri.lastIndexOf('-')) + ALL_ZIP_DISTRIBUTION_URI_SUFFIX;
wrapperConfiguration.setDistribution(new URI(distributionUri));
Properties wrapperProperties = new Properties();
wrapperProperties.setProperty(WrapperExecutor.DISTRIBUTION_URL_PROPERTY, wrapperConfiguration.getDistribution().toString());
wrapperProperties.setProperty(WrapperExecutor.DISTRIBUTION_BASE_PROPERTY, wrapperConfiguration.getDistributionBase());
wrapperProperties.setProperty(WrapperExecutor.DISTRIBUTION_PATH_PROPERTY, wrapperConfiguration.getDistributionPath());
wrapperProperties.setProperty(WrapperExecutor.ZIP_STORE_BASE_PROPERTY, wrapperConfiguration.getZipBase());
wrapperProperties.setProperty(WrapperExecutor.ZIP_STORE_PATH_PROPERTY, wrapperConfiguration.getZipPath());
GUtil.saveProperties(wrapperProperties, new File(wrapperPropertiesFile.getPath()));
wrapperPropertiesFile.refresh(true, false);
catch (Exception e) {
LOG.error(e);
private static boolean isWrapperDistributionWithSourcesUsed(String linkedProjectPath) {
WrapperConfiguration wrapperConfiguration = GradleUtil.getWrapperConfiguration(linkedProjectPath);
// currently only wrapped distribution takes into account
if (wrapperConfiguration == null)
String distributionUri = wrapperConfiguration.getDistribution().toString();
return GRADLE_SRC_DISTIBUTION_PATTERN.matcher(distributionUri).matches();
private static String getConfigPath(@NotNull Module module) {
String externalSystemId = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
if (externalSystemId == null || !GradleConstants.SYSTEM_ID.toString().equals(externalSystemId)) {
String path = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
return StringUtil.isEmpty(path) ? null :
@@ -0,0 +1,98 @@
+ * Copyright
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.service.
+import com.intellij.ide.actions.ImportModuleA
+import com.intellij.ide.util.PropertiesC
+import com.intellij.ide.util.newProjectWizard.AddModuleW
+import com.intellij.notification.N
+import com.intellij.notification.NotificationL
+import com.intellij.notification.NotificationT
+import com.intellij.openapi.components.ServiceM
+import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataM
+import com.intellij.openapi.project.P
+import com.intellij.openapi.startup.StartupA
+import com.intellij.openapi.util.io.FileU
+import com.intellij.openapi.vfs.VfsUtilC
+import org.jetbrains.annotations.NonN
+import org.jetbrains.annotations.NotN
+import org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportB
+import org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportP
+import org.jetbrains.plugins.gradle.settings.GradleS
+import org.jetbrains.plugins.gradle.util.GradleB
+import org.jetbrains.plugins.gradle.util.GradleC
+import javax.swing.event.HyperlinkE
+import java.io.F
+import java.io.FilenameF
+ * @author Vladislav.Soroka
+ * @since 12/10/13
+public class GradleStartupActivity implements StartupActivity {
@NonNls private static final String SHOW_UNLINKED_GRADLE_POPUP = &show.inlinked.gradle.project.popup&;
private static final String IMPORT_EVENT_DESCRIPTION = &import&;
private static final String DO_NOT_SHOW_EVENT_DESCRIPTION = &do.not.show&;
public void runActivity(@NotNull Project project) {
showNotificationForUnlinkedGradleProject(project);
private static void showNotificationForUnlinkedGradleProject(@NotNull final Project project) {
if (!PropertiesComponent.getInstance(project).getBoolean(SHOW_UNLINKED_GRADLE_POPUP, true)
|| !GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty()) {
File baseDir = VfsUtilCore.virtualToIoFile(project.getBaseDir());
final File[] files = baseDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return FileUtil.namesEqual(GradleConstants.DEFAULT_SCRIPT_NAME, name);
if (files != null && files.length != 0) {
String message = String.format(&%s&br&\n%s&,
GradleBundle.message(&gradle.notifications.unlinked.project.found.msg&, IMPORT_EVENT_DESCRIPTION),
GradleBundle.message(&gradle.notifications.do.not.show&, DO_NOT_SHOW_EVENT_DESCRIPTION));
GradleNotification.getInstance(project).showBalloon(
GradleBundle.message(&gradle.notifications.unlinked.project.found.title&),
message, NotificationType.INFORMATION, new NotificationListener.Adapter() {
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
if (IMPORT_EVENT_DESCRIPTION.equals(e.getDescription())) {
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
GradleProjectImportBuilder gradleProjectImportBuilder = new GradleProjectImportBuilder(projectDataManager);
final GradleProjectImportProvider gradleProjectImportProvider = new GradleProjectImportProvider(gradleProjectImportBuilder);
AddModuleWizard wizard = new AddModuleWizard(null, files[0].getPath(), gradleProjectImportProvider);
if ((wizard.getStepCount() &= 0 || wizard.showAndGet())) {
ImportModuleAction.createFromWizard(project, wizard);
else if (DO_NOT_SHOW_EVENT_DESCRIPTION.equals(e.getDescription())) {
PropertiesComponent.getInstance(project).setValue(SHOW_UNLINKED_GRADLE_POPUP, Boolean.FALSE.toString());
@@ -0,0 +1,145 @@
+ * Copyright
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.service.
+import com.intellij.openapi.externalSystem.model.settings.LocationSettingT
+import com.intellij.openapi.externalSystem.service.settings.ExternalSettingsC
+import com.intellij.openapi.externalSystem.util.ExternalSystemApiU
+import com.intellij.openapi.externalSystem.util.ExternalSystemUiU
+import com.intellij.openapi.externalSystem.util.PaintAwareP
+import com.intellij.openapi.fileChooser.FileChooserD
+import com.intellij.openapi.ui.TextComponentA
+import com.intellij.openapi.ui.TextFieldWithBrowseB
+import com.intellij.openapi.util.C
+import com.intellij.openapi.util.text.StringU
+import org.jetbrains.annotations.NotN
+import org.jetbrains.annotations.N
+import org.jetbrains.plugins.gradle.settings.GradleS
+import org.jetbrains.plugins.gradle.util.GradleB
+import org.jetbrains.plugins.gradle.util.GradleC
+import javax.swing.*;
+import javax.swing.event.DocumentE
+import javax.swing.event.DocumentL
+import java.io.F
+ * Manages gradle settings not specific to particular project (e.g. 'use wrapper' is project-level setting but 'gradle user home' is
+ * a global one).
+ * @author Denis Zhdanov
+ * @since 4/28/13 11:06 AM
+public class GradleSystemSettingsControl implements ExternalSettingsControl&GradleSettings& {
@NotNull private final GradleSettings myInitialS
private JLabel
myServiceDirectoryL
private TextFieldWithBrowseButton myServiceDirectoryPathF
private boolean
myServiceDirectoryPathModifiedByU
public GradleSystemSettingsControl(@NotNull GradleSettings settings) {
myInitialSettings =
public void fillUi(@NotNull PaintAwarePanel canvas, int indentLevel) {
myServiceDirectoryLabel = new JLabel(GradleBundle.message(&gradle.settings.text.service.dir.path&));
preparePathControl();
canvas.add(myServiceDirectoryLabel, ExternalSystemUiUtil.getLabelConstraints(indentLevel));
canvas.add(myServiceDirectoryPathField, ExternalSystemUiUtil.getFillLineConstraints(0));
public void showUi(boolean show) {
myServiceDirectoryLabel.setVisible(show);
myServiceDirectoryPathField.setVisible(show);
private void preparePathControl() {
myServiceDirectoryPathField = new TextFieldWithBrowseButton();
myServiceDirectoryPathField.addBrowseFolderListener(
GradleBundle.message(&gradle.settings.title.service.dir.path&),
new FileChooserDescriptor(false, true, false, false, false, false),
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
myServiceDirectoryPathField.getTextField().getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
myServiceDirectoryPathModifiedByUser =
myServiceDirectoryPathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
public void removeUpdate(DocumentEvent e) {
myServiceDirectoryPathModifiedByUser =
myServiceDirectoryPathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
public void changedUpdate(DocumentEvent e) {
public void reset() {
myServiceDirectoryPathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
myServiceDirectoryPathField.setText(&&);
String path = myInitialSettings.getServiceDirectoryPath();
if (StringUtil.isEmpty(path)) {
deduceServiceDirectoryIfPossible();
myServiceDirectoryPathField.setText(path);
private void deduceServiceDirectoryIfPossible() {
String path = System.getenv().get(GradleConstants.SYSTEM_DIRECTORY_PATH_KEY);
if (StringUtil.isEmpty(path)) {
path = new File(System.getProperty(&user.home&), &.gradle&).getAbsolutePath();
myServiceDirectoryPathField.setText(path);
myServiceDirectoryPathField.getTextField().setForeground(LocationSettingType.DEDUCED.getColor());
myServiceDirectoryPathModifiedByUser =
public boolean isModified() {
return myServiceDirectoryPathModifiedByUser
&& !Comparing.equal(ExternalSystemApiUtil.normalizePath(myServiceDirectoryPathField.getText()),
ExternalSystemApiUtil.normalizePath(myInitialSettings.getServiceDirectoryPath()));
public String apply(@NotNull GradleSettings settings) {
if (myServiceDirectoryPathModifiedByUser) {
settings.setServiceDirectoryPath(ExternalSystemApiUtil.normalizePath(myServiceDirectoryPathField.getText()));
public void disposeUIResources() {
myServiceDirectoryLabel =
myServiceDirectoryPathField =
(C) apiwave 2015

我要回帖

更多关于 startup settings 的文章

 

随机推荐