diff options
author | Appu Goundan <appu@google.com> | 2014-04-07 20:21:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-04-07 20:21:16 +0000 |
commit | 686f7c2f9b8207504d3d2d2c2a63dffd8bd86824 (patch) | |
tree | 01a0e9057cb6274a88b22bae3995f982410040b8 /src/com | |
parent | 8bfd5949c5b5adaae632fd51d45bbd574c97e3c1 (diff) | |
parent | 4eceefab735bd12471f140688f96f99d9ad02b70 (diff) | |
download | cloud-686f7c2f9b8207504d3d2d2c2a63dffd8bd86824.tar.gz |
Merge "Choice of Sample Templates in the Google Cloud Tools setting tab in the Setting wizard." into idea133
Diffstat (limited to 'src/com')
3 files changed, 169 insertions, 0 deletions
diff --git a/src/com/google/gct/intellij/endpoints/synchronization/SampleSyncConfigurable.java b/src/com/google/gct/intellij/endpoints/synchronization/SampleSyncConfigurable.java new file mode 100644 index 0000000..10cc03c --- /dev/null +++ b/src/com/google/gct/intellij/endpoints/synchronization/SampleSyncConfigurable.java @@ -0,0 +1,86 @@ +/* + * 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.intellij.endpoints.synchronization; + + +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.options.ConfigurationException; + +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.Nullable; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JRadioButton; + +/** + * The Sample Templates Selection in the Google Cloud Tools setting tab. + */ +public class SampleSyncConfigurable implements Configurable { + private JPanel myPanel; + private JRadioButton builtInSampleRadioButton; + private JRadioButton repoRadioButton; + + @Nls + @Override + public String getDisplayName() { + return "Google Cloud Tools"; + } + + @Nullable + @Override + public String getHelpTopic() { + return null; + } + + @Nullable + @Override + public JComponent createComponent() { + if(SampleSyncConfiguration.usingBuiltInSamples()) { + builtInSampleRadioButton.setSelected(true); + } else { + repoRadioButton.setSelected(true); + } + + return (JComponent) myPanel; + } + + @Override + public boolean isModified() { + return true; + } + + @Override + public void apply() throws ConfigurationException { + // Save the user selected setting + SampleSyncConfiguration.setUseBuiltInSamples(builtInSampleRadioButton.isSelected()); + } + + + @Override + public void reset() { + if(SampleSyncConfiguration.usingBuiltInSamples()) { + builtInSampleRadioButton.setSelected(true); + } else { + repoRadioButton.setSelected(true); + } + } + + @Override + public void disposeUIResources() { + // do nothing + } +} diff --git a/src/com/google/gct/intellij/endpoints/synchronization/SampleSyncConfiguration.java b/src/com/google/gct/intellij/endpoints/synchronization/SampleSyncConfiguration.java new file mode 100644 index 0000000..efd610d --- /dev/null +++ b/src/com/google/gct/intellij/endpoints/synchronization/SampleSyncConfiguration.java @@ -0,0 +1,31 @@ +/* + * 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.intellij.endpoints.synchronization; + +import com.intellij.ide.util.PropertiesComponent; + +/** + * Sets and returns the setting for using built-in samples + */ +public class SampleSyncConfiguration { + public static boolean usingBuiltInSamples() { + return PropertiesComponent.getInstance().getBoolean("built.in.samples.templates", false); + } + + public static void setUseBuiltInSamples(boolean useBuiltInSamples) { + PropertiesComponent.getInstance().setValue("built.in.samples.templates", String.valueOf(useBuiltInSamples)); + } +} diff --git a/src/com/google/gct/intellij/endpoints/synchronization/SampleTemplatesForm.form b/src/com/google/gct/intellij/endpoints/synchronization/SampleTemplatesForm.form new file mode 100644 index 0000000..128772b --- /dev/null +++ b/src/com/google/gct/intellij/endpoints/synchronization/SampleTemplatesForm.form @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.google.gct.intellij.endpoints.synchronization.SampleSyncConfigurable"> + <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <xy x="20" y="20" width="500" height="400"/> + </constraints> + <properties/> + <border type="none"/> + <children> + <vspacer id="e99c"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + </constraints> + </vspacer> + <grid id="4da40" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + </constraints> + <properties/> + <border type="etched" title="Choice of Sample Templates"/> + <children> + <component id="30f7e" class="javax.swing.JRadioButton" binding="builtInSampleRadioButton"> + <constraints> + <grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text value="Built-in Sample Templates"/> + </properties> + </component> + <component id="64fb4" class="javax.swing.JRadioButton" binding="repoRadioButton"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text value="Sample Templates from Repository"/> + </properties> + </component> + </children> + </grid> + </children> + </grid> + <buttonGroups> + <group name="myButtonGroup1"> + <member id="39291"/> + <member id="b552c"/> + <member id="64fb4"/> + <member id="30f7e"/> + </group> + </buttonGroups> +</form> |