Skip to content

Commit cdc18a0

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into webstorm-typescript
# Conflicts: # src/ServiceStackIDEA/src/main/resources/META-INF/plugin.xml
2 parents eebc723 + 188824e commit cdc18a0

File tree

12 files changed

+916
-354
lines changed

12 files changed

+916
-354
lines changed

src/ServiceStackIDEA/.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceStackIDEA/.idea/workspace.xml

Lines changed: 643 additions & 344 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceStackIDEA/src/main/java/net/servicestack/idea/AddServiceStackRefHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static void handleOk(String addressUrl, String qualifiedPackageName,
7373
if (!writeDtoFile(javaCodeLines, dtoPath, errorMessage)) {
7474
return;
7575
}
76-
76+
Analytics.SubmitAnonymousAddReferenceUsage(getNativeTypesHandler(fileName));
7777
IDEAUtils.refreshFile(module, dtoPath, showDto);
7878
VirtualFileManager.getInstance().syncRefresh();
7979
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package net.servicestack.idea;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.net.URL;
7+
import java.net.URLConnection;
8+
9+
/**
10+
* Helper to submit anonymous add reference usage.
11+
*/
12+
public final class Analytics {
13+
14+
private final static String addRefUrl = "https://servicestack.net/stats/addref/record?Name=";
15+
16+
public static void SubmitAnonymousAddReferenceUsage(INativeTypesHandler typesHandler) {
17+
PluginSettingsService settings = PluginSettingsService.getInstance();
18+
if(!settings.optOutOfStats) {
19+
final String url = addRefUrl + typesHandler.getTypesLanguage().name();
20+
final URL[] serviceUrl = {null};
21+
final URLConnection[] responseConnection = {null};
22+
final BufferedReader[] responseReader = {null};
23+
Thread thread = new Thread(new Runnable() {
24+
@Override
25+
public void run() {
26+
try {
27+
serviceUrl[0] = new URL(url);
28+
responseConnection[0] = serviceUrl[0].openConnection();
29+
responseReader[0] = new BufferedReader(
30+
new InputStreamReader(
31+
responseConnection[0].getInputStream()));
32+
33+
responseReader[0].close();
34+
} catch (IOException e) {
35+
// Ignore failure (eg no internet connection).
36+
}
37+
}
38+
});
39+
thread.start();
40+
41+
}
42+
}
43+
}

src/ServiceStackIDEA/src/main/java/net/servicestack/idea/BaseNativeTypesHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class BaseNativeTypesHandler implements INativeTypesHandler {
1919
public List<String> getUpdatedCode(String baseUrl, Map<String, String> options) throws IOException, URISyntaxException {
2020
String url;
2121
List<String> javaCodeLines = new ArrayList<String>();
22-
URIBuilder urlBuilder = this.getUrl(baseUrl,options);
22+
URIBuilder urlBuilder = this.getUrl(baseUrl);
2323
for(Map.Entry<String, String> option : options.entrySet()) {
2424
urlBuilder.addParameter(option.getKey(),option.getValue());
2525
}
@@ -41,14 +41,15 @@ public List<String> getUpdatedCode(String baseUrl, Map<String, String> options)
4141
}
4242

4343
@Override
44-
public URIBuilder getUrl(String baseUrl, Map<String, String> options) throws MalformedURLException, URISyntaxException {
44+
public URIBuilder getUrl(String baseUrl) throws MalformedURLException, URISyntaxException {
4545
String serverUrl = baseUrl.endsWith("/") ? baseUrl : (baseUrl + "/");
4646
serverUrl = (serverUrl.startsWith("http://") || serverUrl.startsWith("https://")) ? serverUrl : ("http://" + serverUrl);
4747
URL url = new URL(serverUrl);
4848
String path = url.getPath().contains("?") ? url.getPath().split("\\?", 2)[0] : url.getPath();
4949
if (!path.endsWith(this.getRelativeTypesUrl() + "/")) {
5050
serverUrl += (this.getRelativeTypesUrl() + "/");
5151
}
52+
serverUrl = toParentPath(serverUrl);
5253
URIBuilder builder;
5354

5455
try {
@@ -59,4 +60,11 @@ public URIBuilder getUrl(String baseUrl, Map<String, String> options) throws Mal
5960
}
6061
return builder;
6162
}
63+
64+
public static String toParentPath(String path)
65+
{
66+
int pos = path.lastIndexOf("/");
67+
if (pos == -1) return "/";
68+
return path.substring(0, pos);
69+
}
6270
}

src/ServiceStackIDEA/src/main/java/net/servicestack/idea/INativeTypesHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public interface INativeTypesHandler {
1515
String getFileExtension();
16-
URIBuilder getUrl(String baseUrl, Map<String,String> options) throws MalformedURLException, URISyntaxException;
16+
URIBuilder getUrl(String baseUrl) throws MalformedURLException, URISyntaxException;
1717
List<String> getUpdatedCode(String baseUrl, Map<String, String> options) throws IOException, URISyntaxException;
1818
String getRelativeTypesUrl();
1919
NativeTypesLanguage getTypesLanguage();
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package net.servicestack.idea;
2+
3+
import com.intellij.application.options.CodeStyleAbstractConfigurable;
4+
import com.intellij.openapi.options.Configurable;
5+
import com.intellij.openapi.options.ConfigurableProvider;
6+
import com.intellij.openapi.options.ConfigurationException;
7+
import com.intellij.openapi.options.SearchableConfigurable;
8+
import com.intellij.util.ui.CheckBox;
9+
import org.jetbrains.annotations.Nls;
10+
import org.jetbrains.annotations.NotNull;
11+
import org.jetbrains.annotations.Nullable;
12+
13+
import javax.swing.*;
14+
15+
/**
16+
* Created by Layoric on 27/05/2016.
17+
*/
18+
public class PluginSettingsConfigurable implements SearchableConfigurable {
19+
20+
private PluginSettingsView view;
21+
22+
private PluginSettingsService settings;
23+
24+
public PluginSettingsConfigurable(@NotNull PluginSettingsService settings) {
25+
this.settings = settings;
26+
}
27+
28+
@NotNull
29+
@Override
30+
public String getId() {
31+
return "Settings.ServiceStackIDEA.Preview";
32+
}
33+
34+
@Nullable
35+
@Override
36+
public Runnable enableSearch(String s) {
37+
return null;
38+
}
39+
40+
@Nls
41+
@Override
42+
public String getDisplayName() {
43+
return "ServiceStackIDEA Settings";
44+
}
45+
46+
@Nullable
47+
@Override
48+
public String getHelpTopic() {
49+
return null;
50+
}
51+
52+
@Nullable
53+
@Override
54+
public JComponent createComponent() {
55+
return getForm().getSettingsPanel();
56+
}
57+
58+
59+
@Override
60+
public boolean isModified() {
61+
return !getForm().getOptOutOfUsage().equals(settings.optOutOfStats);
62+
}
63+
64+
@Override
65+
public void apply() throws ConfigurationException {
66+
if(settings == null)
67+
settings = PluginSettingsService.getInstance();
68+
settings.optOutOfStats = getForm().getOptOutOfUsage();
69+
}
70+
71+
@Override
72+
public void reset() {
73+
if(settings == null)
74+
settings = PluginSettingsService.getInstance();
75+
getForm().setOptOutOfUsage(settings.optOutOfStats);
76+
}
77+
78+
@Override
79+
public void disposeUIResources() {
80+
view = null;
81+
}
82+
83+
@NotNull
84+
public PluginSettingsView getForm() {
85+
if (view == null) {
86+
view = new PluginSettingsView();
87+
}
88+
return view;
89+
}
90+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.servicestack.idea;
2+
3+
import com.intellij.openapi.components.*;
4+
import com.intellij.util.xmlb.XmlSerializerUtil;
5+
import org.jetbrains.annotations.Nullable;
6+
7+
/**
8+
* Created by Layoric on 27/05/2016.
9+
*/
10+
@State(name = "PluginSettingsService", storages = @Storage(id = "default", file = StoragePathMacros.APP_CONFIG + "/servicestack-settings.xml"))
11+
public class PluginSettingsService implements PersistentStateComponent<PluginSettingsService> {
12+
public Boolean optOutOfStats = false;
13+
14+
@Nullable
15+
@Override
16+
public PluginSettingsService getState() {
17+
return this;
18+
}
19+
20+
@Override
21+
public void loadState(PluginSettingsService pluginSettingsService) {
22+
XmlSerializerUtil.copyBean(pluginSettingsService, this);
23+
}
24+
25+
public static PluginSettingsService getInstance() {
26+
return ServiceManager.getService( PluginSettingsService.class );
27+
}
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="net.servicestack.idea.PluginSettingsView">
3+
<grid id="27dc6" binding="settingsPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4+
<margin top="0" left="0" bottom="0" right="0"/>
5+
<constraints>
6+
<xy x="20" y="20" width="500" height="400"/>
7+
</constraints>
8+
<properties/>
9+
<border type="none"/>
10+
<children>
11+
<component id="c76c5" class="javax.swing.JCheckBox" binding="optOutOfUsageCheckBox" default-binding="true">
12+
<constraints>
13+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
14+
</constraints>
15+
<properties>
16+
<text value="Opt out of usage collection "/>
17+
</properties>
18+
</component>
19+
<vspacer id="32dbe">
20+
<constraints>
21+
<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"/>
22+
</constraints>
23+
</vspacer>
24+
</children>
25+
</grid>
26+
</form>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package net.servicestack.idea;
2+
3+
import com.intellij.uiDesigner.core.GridConstraints;
4+
import com.intellij.uiDesigner.core.GridLayoutManager;
5+
import com.intellij.uiDesigner.core.Spacer;
6+
7+
import javax.swing.*;
8+
import java.awt.*;
9+
10+
/**
11+
* Created by Layoric on 27/05/2016.
12+
*/
13+
public class PluginSettingsView {
14+
private JCheckBox optOutOfUsageCheckBox;
15+
private JPanel settingsPanel;
16+
17+
public Boolean getOptOutOfUsage() {
18+
return optOutOfUsageCheckBox.isSelected();
19+
}
20+
21+
public void setOptOutOfUsage(Boolean value) {
22+
optOutOfUsageCheckBox.setSelected(value);
23+
}
24+
25+
public JPanel getSettingsPanel() {
26+
return this.settingsPanel;
27+
}
28+
29+
{
30+
// GUI initializer generated by IntelliJ IDEA GUI Designer
31+
// >>> IMPORTANT!! <<<
32+
// DO NOT EDIT OR ADD ANY CODE HERE!
33+
$$$setupUI$$$();
34+
}
35+
36+
/**
37+
* Method generated by IntelliJ IDEA GUI Designer
38+
* >>> IMPORTANT!! <<<
39+
* DO NOT edit this method OR call it in your code!
40+
*
41+
* @noinspection ALL
42+
*/
43+
private void $$$setupUI$$$() {
44+
settingsPanel = new JPanel();
45+
settingsPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
46+
optOutOfUsageCheckBox = new JCheckBox();
47+
optOutOfUsageCheckBox.setText("Opt out of usage collection ");
48+
settingsPanel.add(optOutOfUsageCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
49+
final Spacer spacer1 = new Spacer();
50+
settingsPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
51+
}
52+
53+
/**
54+
* @noinspection ALL
55+
*/
56+
public JComponent $$$getRootComponent$$$() {
57+
return settingsPanel;
58+
}
59+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy