diff options
author | Benjamin Wulfe <benwu@google.com> | 2014-07-17 16:46:09 -0400 |
---|---|---|
committer | Benjamin Wulfe <benwu@google.com> | 2014-07-18 17:47:14 -0400 |
commit | 68c22f232859d63d7db8f8a6cc9b82f268b7ac42 (patch) | |
tree | 6ed0188aef525c4304cd02b2392d8b3511ece112 | |
parent | 673e72873a918c0b60595dc706089ee2f59b0939 (diff) | |
download | cloud-68c22f232859d63d7db8f8a6cc9b82f268b7ac42.tar.gz |
New appengine facet configuration persistence.
Fixes appengine properties to be saved via facet configuration.
This removes the need for a gradle sync to obtain sdkpath and other properties.
Change-Id: I1904d0dbbbe3f9b5beec4138ff83f45ec5a262ba
5 files changed, 69 insertions, 21 deletions
diff --git a/src/com/google/gct/idea/appengine/gradle/facet/AppEngineConfigurationProperties.java b/src/com/google/gct/idea/appengine/gradle/facet/AppEngineConfigurationProperties.java new file mode 100644 index 0000000..9baee10 --- /dev/null +++ b/src/com/google/gct/idea/appengine/gradle/facet/AppEngineConfigurationProperties.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * 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.google.gct.idea.appengine.gradle.facet; + +import com.intellij.util.xmlb.annotations.AbstractCollection; +import org.jetbrains.android.util.AndroidCommonUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Holds configuration property values for the AppEngine facet. + */ +public class AppEngineConfigurationProperties { + public String HTTP_ADDRESS; + public Integer HTTP_PORT; + @AbstractCollection(surroundWithTag = false, elementTag = "jvmflags", elementValueAttribute = "") + public List<String> JVM_FLAGS = new ArrayList<String>(); + public String WAR_DIR; + public String WEB_APP_DIR; + public String APPENGINE_SDKROOT; +} diff --git a/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacet.java b/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacet.java index 08ef0cd..48df14f 100644 --- a/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacet.java +++ b/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacet.java @@ -15,7 +15,6 @@ */ package com.google.gct.idea.appengine.gradle.facet; -import com.google.gct.idea.appengine.gradle.project.IdeaAppEngineProject; import com.intellij.facet.Facet; import com.intellij.facet.FacetManager; import com.intellij.facet.FacetType; @@ -38,8 +37,6 @@ public class AppEngineGradleFacet extends Facet<AppEngineGradleFacetConfiguratio public static final FacetTypeId<AppEngineGradleFacet> TYPE_ID = new FacetTypeId<AppEngineGradleFacet>(ID); - private IdeaAppEngineProject myIdeaAppEngineProject; - @Nullable public static AppEngineGradleFacet getInstance(@NotNull Module module) { return FacetManager.getInstance(module).getFacetByType(TYPE_ID); @@ -62,13 +59,4 @@ public class AppEngineGradleFacet extends Facet<AppEngineGradleFacetConfiguratio if (module == null) return null; return FacetManager.getInstance(module).getFacetByType(TYPE_ID); } - - public IdeaAppEngineProject getIdeaAppEngineProject() { - return myIdeaAppEngineProject; - } - - public void setIdeaAppEngineProject(IdeaAppEngineProject ideaAppEngineProject) { - myIdeaAppEngineProject = ideaAppEngineProject; - } - } diff --git a/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacetConfiguration.java b/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacetConfiguration.java index c5466e5..4a898f3 100644 --- a/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacetConfiguration.java +++ b/src/com/google/gct/idea/appengine/gradle/facet/AppEngineGradleFacetConfiguration.java @@ -19,16 +19,20 @@ import com.intellij.facet.FacetConfiguration; import com.intellij.facet.ui.FacetEditorContext; import com.intellij.facet.ui.FacetEditorTab; import com.intellij.facet.ui.FacetValidatorsManager; +import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.xmlb.XmlSerializer; import org.jdom.Element; +import org.jetbrains.annotations.Nullable; /** * Currently an empty configuration for App Engine Gradle configurations */ -public class AppEngineGradleFacetConfiguration implements FacetConfiguration { +public class AppEngineGradleFacetConfiguration implements FacetConfiguration, PersistentStateComponent<AppEngineConfigurationProperties> { + AppEngineConfigurationProperties myProperties = new AppEngineConfigurationProperties(); + @Override public FacetEditorTab[] createEditorTabs(FacetEditorContext editorContext, FacetValidatorsManager validatorsManager) { return new FacetEditorTab[] { @@ -46,4 +50,14 @@ public class AppEngineGradleFacetConfiguration implements FacetConfiguration { XmlSerializer.serializeInto(this, element); } + @Nullable + @Override + public AppEngineConfigurationProperties getState() { + return myProperties; + } + + @Override + public void loadState(AppEngineConfigurationProperties state) { + myProperties = state; + } } diff --git a/src/com/google/gct/idea/appengine/gradle/service/AppEngineGradleProjectDataService.java b/src/com/google/gct/idea/appengine/gradle/service/AppEngineGradleProjectDataService.java index 36b25de..01a4602 100644 --- a/src/com/google/gct/idea/appengine/gradle/service/AppEngineGradleProjectDataService.java +++ b/src/com/google/gct/idea/appengine/gradle/service/AppEngineGradleProjectDataService.java @@ -99,7 +99,18 @@ public class AppEngineGradleProjectDataService implements ProjectDataService<Ide model.commit(); } } - facet.setIdeaAppEngineProject(ideaAppEngineProject); + + //deserialize state from ideaAppEngineProject into facet config. + if (facet != null) { + facet.getConfiguration().getState().APPENGINE_SDKROOT = ideaAppEngineProject.getDelegate().getAppEngineSdkRoot(); + facet.getConfiguration().getState().HTTP_ADDRESS = ideaAppEngineProject.getDelegate().getHttpAddress(); + facet.getConfiguration().getState().HTTP_PORT = ideaAppEngineProject.getDelegate().getHttpPort(); + for(String flag : ideaAppEngineProject.getDelegate().getJvmFlags()) { + facet.getConfiguration().getState().JVM_FLAGS.add(flag); + } + facet.getConfiguration().getState().WAR_DIR = ideaAppEngineProject.getDelegate().getWarDir().getAbsolutePath(); + facet.getConfiguration().getState().WEB_APP_DIR = ideaAppEngineProject.getDelegate().getWebAppDir().getAbsolutePath(); + } } @NotNull diff --git a/src/com/google/gct/idea/appengine/run/AppEngineRunConfigurationSettingsEditor.java b/src/com/google/gct/idea/appengine/run/AppEngineRunConfigurationSettingsEditor.java index b77872b..eb9d315 100644 --- a/src/com/google/gct/idea/appengine/run/AppEngineRunConfigurationSettingsEditor.java +++ b/src/com/google/gct/idea/appengine/run/AppEngineRunConfigurationSettingsEditor.java @@ -15,7 +15,7 @@ */ package com.google.gct.idea.appengine.run; -import com.google.appengine.gradle.model.AppEngineModel; +import com.google.gct.idea.appengine.gradle.facet.AppEngineConfigurationProperties; import com.google.gct.idea.appengine.gradle.facet.AppEngineGradleFacet; import com.intellij.execution.ui.ConfigurationModuleSelector; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; @@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import org.jetbrains.annotations.NotNull; -import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JPanel; @@ -57,11 +56,11 @@ public class AppEngineRunConfigurationSettingsEditor extends SettingsEditor<AppE AppEngineGradleFacet facet = AppEngineGradleFacet.getInstance(moduleSelector.getModule()); if(facet != null) { // proof of concept of usefulness of Gradle model - AppEngineModel model = facet.getIdeaAppEngineProject().getDelegate(); - myServerPortField.setText(model.getHttpPort().toString()); - myServerAddressField.setText(model.getHttpAddress()); - myAppEngineSdkField.setText(model.getAppEngineSdkRoot()); - myWarPathField.setText(model.getWarDir().getAbsolutePath()); + AppEngineConfigurationProperties model = facet.getConfiguration().getState(); + myServerPortField.setText(model.HTTP_PORT.toString()); + myServerAddressField.setText(model.HTTP_ADDRESS); + myAppEngineSdkField.setText(model.APPENGINE_SDKROOT); + myWarPathField.setText(model.WAR_DIR); } } |