├── .gitignore
├── AndroidGears
├── .idea
│ ├── .name
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── encodings.xml
│ ├── libraries
│ │ ├── antlr_2_7_7.xml
│ │ ├── antlr_runtime_3_1.xml
│ │ ├── commons_io_2_4.xml
│ │ ├── cssbox_4_5.xml
│ │ ├── cssbox_4_5__2_.xml
│ │ ├── gson_2_2_4.xml
│ │ ├── lobo_pub.xml
│ │ ├── swingbox_1_0.xml
│ │ └── swingbox_1_0_bin.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── scopes
│ │ └── scope_settings.xml
│ ├── uiDesigner.xml
│ └── vcs.xml
├── AndroidGears.iml
├── META-INF
│ └── plugin.xml
├── libs
│ ├── commons-io-2.4.jar
│ ├── gson-2.2.4-javadoc.jar
│ ├── gson-2.2.4.jar
│ ├── org.eclipse.jgit-3.3.1.201403241930-r-javadoc.jar
│ └── org.eclipse.jgit-3.3.1.201403241930-r.jar
├── out
│ └── production
│ │ └── AndroidGears
│ │ ├── Forms
│ │ ├── AndroidGearsHeader.png
│ │ ├── Search.png
│ │ └── loadinfo.net (1).gif
│ │ ├── Renderers
│ │ ├── GearStateDeclared.png
│ │ ├── GearStateInstalled.png
│ │ └── jarfile.png
│ │ └── icons
│ │ ├── GearStateDeclared.png
│ │ ├── GearStateInstalled.png
│ │ ├── androidGears.png
│ │ ├── androidGears@2x.png
│ │ ├── gears.png
│ │ ├── gears@2x.png
│ │ └── jarfile.png
├── resources
│ └── icons
│ │ ├── GearStateDeclared.png
│ │ ├── GearStateInstalled.png
│ │ ├── androidGears.png
│ │ ├── androidGears@2x.png
│ │ ├── gears.png
│ │ ├── gears@2x.png
│ │ └── jarfile.png
└── src
│ ├── Actions
│ ├── AboutGearsAction.java
│ ├── CreateGearAction.java
│ ├── LintGearAction.java
│ ├── ManageGearsAction.java
│ └── SettingsAction.java
│ ├── Forms
│ ├── AboutGearsForm.form
│ ├── AboutGearsForm.java
│ ├── AndroidGearsHeader.png
│ ├── Create Gear Form.form
│ ├── CreateGearForm.java
│ ├── Lint Gear Form.form
│ ├── LintGearForm.java
│ ├── Manage Android Gears.form
│ ├── ManageAndroidGearsForm.java
│ ├── Search.png
│ ├── Settings Form.form
│ ├── SettingsForm.java
│ └── loadinfo.net (1).gif
│ ├── GitComponent.java
│ ├── Interfaces
│ └── AndroidGearIcons.java
│ ├── Models
│ ├── GearSpec
│ │ ├── GearSpec.java
│ │ ├── GearSpecAuthor.java
│ │ ├── GearSpecDependency.java
│ │ ├── GearSpecSource.java
│ │ └── GearSpecUpdate.java
│ ├── GearSpecLinter
│ │ └── GearSpecLintResult.java
│ ├── GearSpecRegister
│ │ └── GearSpecRegister.java
│ └── Settings
│ │ ├── GearSpecSettings.java
│ │ └── ProjectSettings.java
│ ├── Panels
│ └── SpecDetailsPanel.java
│ ├── ProjectSettingsComponent.java
│ ├── Renderers
│ ├── GearSpecCellRenderer.java
│ ├── GearStateDeclared.png
│ ├── GearStateInstalled.png
│ ├── ModuleCellRenderer.java
│ ├── ProjectCellRenderer.java
│ └── jarfile.png
│ ├── Services
│ └── AutoCompleteSerivce
│ │ ├── AutoCompleteDocument.java
│ │ ├── CompletionService.java
│ │ └── GearsService.java
│ ├── Singletons
│ └── SettingsManager.java
│ ├── Utilities
│ ├── GearSpecLinter.java
│ ├── GearSpecManager.java
│ ├── GearSpecRegistrar.java
│ ├── OSValidator.java
│ └── Utils.java
│ └── Workers
│ ├── GetAllSpecsListWorker.java
│ ├── GetGearStateWorker.java
│ ├── GetProjectVersionsWorker.java
│ ├── Git
│ ├── GitWorker.java
│ └── IgnoreCheckWorker.java
│ ├── InstallUninstall
│ ├── DeclareSpecWorker.java
│ ├── InstallDependencyForSpecWorker.java
│ ├── UndeclareSpecWorker.java
│ ├── UninstallDependencyForSpecWorker.java
│ └── UpdateGearWorker.java
│ ├── Lint
│ └── LintGearSpecWorker.java
│ ├── Search
│ ├── SearchDeclaredDependenciesWorker.java
│ ├── SearchInstalledProjectsWorker.java
│ ├── SearchProjectListWorker.java
│ └── SearchUpdatableProjectsWorker.java
│ ├── Settings
│ ├── GetCreateIgnoreEntryWorker.java
│ └── SetCreateIgnoreEntryWorker.java
│ └── Sync
│ └── SyncGears.java
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | AndroidGears/.idea/workspace.xml
26 |
27 | AndroidGears/.idea/workspace.xml
28 |
29 | AndroidGears/.idea/workspace.xml
30 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/.name:
--------------------------------------------------------------------------------
1 | AndroidGears
--------------------------------------------------------------------------------
/AndroidGears/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/antlr_2_7_7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/antlr_runtime_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/commons_io_2_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/cssbox_4_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/cssbox_4_5__2_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/gson_2_2_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/lobo_pub.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/swingbox_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/libraries/swingbox_1_0_bin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 | -
41 |
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 | -
98 |
99 |
100 | -
101 |
102 |
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/AndroidGears/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AndroidGears/AndroidGears.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/AndroidGears/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | com.github.androidgears.plugin5
3 | Android Gears
4 | 0.5.4
5 | Android Gears
6 |
7 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | GitComponent
34 |
35 |
36 |
37 |
38 |
39 |
40 | ProjectSettingsComponent
41 |
42 |
43 |
44 |
45 |
46 |
47 |
49 |
50 |
52 |
53 |
58 |
59 |
60 |
61 |
63 |
64 |
65 |
66 |
68 |
69 |
70 |
71 |
73 |
74 |
75 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/AndroidGears/libs/commons-io-2.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/libs/commons-io-2.4.jar
--------------------------------------------------------------------------------
/AndroidGears/libs/gson-2.2.4-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/libs/gson-2.2.4-javadoc.jar
--------------------------------------------------------------------------------
/AndroidGears/libs/gson-2.2.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/libs/gson-2.2.4.jar
--------------------------------------------------------------------------------
/AndroidGears/libs/org.eclipse.jgit-3.3.1.201403241930-r-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/libs/org.eclipse.jgit-3.3.1.201403241930-r-javadoc.jar
--------------------------------------------------------------------------------
/AndroidGears/libs/org.eclipse.jgit-3.3.1.201403241930-r.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/libs/org.eclipse.jgit-3.3.1.201403241930-r.jar
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/Forms/AndroidGearsHeader.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/Forms/AndroidGearsHeader.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/Forms/Search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/Forms/Search.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/Forms/loadinfo.net (1).gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/Forms/loadinfo.net (1).gif
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/Renderers/GearStateDeclared.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/Renderers/GearStateDeclared.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/Renderers/GearStateInstalled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/Renderers/GearStateInstalled.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/Renderers/jarfile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/Renderers/jarfile.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/icons/GearStateDeclared.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/icons/GearStateDeclared.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/icons/GearStateInstalled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/icons/GearStateInstalled.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/icons/androidGears.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/icons/androidGears.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/icons/androidGears@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/icons/androidGears@2x.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/icons/gears.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/icons/gears.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/icons/gears@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/icons/gears@2x.png
--------------------------------------------------------------------------------
/AndroidGears/out/production/AndroidGears/icons/jarfile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/out/production/AndroidGears/icons/jarfile.png
--------------------------------------------------------------------------------
/AndroidGears/resources/icons/GearStateDeclared.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/resources/icons/GearStateDeclared.png
--------------------------------------------------------------------------------
/AndroidGears/resources/icons/GearStateInstalled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/resources/icons/GearStateInstalled.png
--------------------------------------------------------------------------------
/AndroidGears/resources/icons/androidGears.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/resources/icons/androidGears.png
--------------------------------------------------------------------------------
/AndroidGears/resources/icons/androidGears@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/resources/icons/androidGears@2x.png
--------------------------------------------------------------------------------
/AndroidGears/resources/icons/gears.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/resources/icons/gears.png
--------------------------------------------------------------------------------
/AndroidGears/resources/icons/gears@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/resources/icons/gears@2x.png
--------------------------------------------------------------------------------
/AndroidGears/resources/icons/jarfile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/resources/icons/jarfile.png
--------------------------------------------------------------------------------
/AndroidGears/src/Actions/AboutGearsAction.java:
--------------------------------------------------------------------------------
1 | package Actions;
2 |
3 | import Forms.AboutGearsForm;
4 | import Forms.SettingsForm;
5 | import com.intellij.openapi.actionSystem.AnAction;
6 | import com.intellij.openapi.actionSystem.AnActionEvent;
7 |
8 | import javax.swing.*;
9 |
10 | /**
11 | * Created by matthewyork on 12/3/14.
12 | */
13 | public class AboutGearsAction extends AnAction {
14 | public void actionPerformed(AnActionEvent e) {
15 | JFrame frame = new JFrame("About Android Gears");
16 | frame.setContentPane(new AboutGearsForm().MasterPanel);
17 | frame.setResizable(false);
18 | frame.pack();
19 | frame.setLocationRelativeTo(null);
20 | frame.setVisible(true);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AndroidGears/src/Actions/CreateGearAction.java:
--------------------------------------------------------------------------------
1 | package Actions;
2 |
3 | import Forms.CreateGearForm;
4 | import Forms.ManageAndroidGearsForm;
5 | import com.intellij.openapi.actionSystem.AnAction;
6 | import com.intellij.openapi.actionSystem.AnActionEvent;
7 |
8 | import javax.swing.*;
9 |
10 | /**
11 | * Created by matthewyork on 4/2/14.
12 | */
13 | public class CreateGearAction extends AnAction {
14 | public void actionPerformed(AnActionEvent e) {
15 | JFrame frame = new JFrame("Create Android Gear");
16 | frame.setContentPane(new CreateGearForm().MasterPanel);
17 | frame.pack();
18 | frame.setLocationRelativeTo(null);
19 | frame.setVisible(true);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AndroidGears/src/Actions/LintGearAction.java:
--------------------------------------------------------------------------------
1 | package Actions;
2 |
3 | import Forms.LintGearForm;
4 | import Forms.ManageAndroidGearsForm;
5 | import com.intellij.openapi.actionSystem.AnAction;
6 | import com.intellij.openapi.actionSystem.AnActionEvent;
7 |
8 | import javax.swing.*;
9 |
10 | /**
11 | * Created by matthewyork on 4/3/14.
12 | */
13 | public class LintGearAction extends AnAction {
14 | public void actionPerformed(AnActionEvent e) {
15 | JFrame frame = new JFrame("Lint Android Gear");
16 | frame.setContentPane(new LintGearForm().MasterPanel);
17 | frame.setResizable(false);
18 | frame.pack();
19 | frame.setLocationRelativeTo(null);
20 | frame.setVisible(true);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AndroidGears/src/Actions/ManageGearsAction.java:
--------------------------------------------------------------------------------
1 | package Actions;
2 |
3 | import com.intellij.openapi.actionSystem.AnAction;
4 | import com.intellij.openapi.actionSystem.AnActionEvent;
5 | import Forms.ManageAndroidGearsForm;
6 |
7 | import javax.swing.*;
8 | import java.awt.*;
9 |
10 | /**
11 | * Created by matthewyork on 3/31/14.
12 | */
13 | public class ManageGearsAction extends AnAction {
14 | public void actionPerformed(AnActionEvent e) {
15 | JFrame frame = new JFrame("Manage Android Gears");
16 | frame.setContentPane(new ManageAndroidGearsForm().MasterPanel);
17 | frame.setResizable(false);
18 | frame.pack();
19 | frame.setLocationRelativeTo(null);
20 | frame.setVisible(true);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AndroidGears/src/Actions/SettingsAction.java:
--------------------------------------------------------------------------------
1 | package Actions;
2 |
3 | import Forms.ManageAndroidGearsForm;
4 | import Forms.SettingsForm;
5 | import com.intellij.openapi.actionSystem.AnAction;
6 | import com.intellij.openapi.actionSystem.AnActionEvent;
7 |
8 | import javax.swing.*;
9 |
10 | /**
11 | * Created by matthewyork on 4/6/14.
12 | */
13 | public class SettingsAction extends AnAction {
14 | public void actionPerformed(AnActionEvent e) {
15 | JFrame frame = new JFrame("Android Gears Settings");
16 | frame.setContentPane(new SettingsForm().MasterPanel);
17 | frame.setResizable(false);
18 | frame.pack();
19 | frame.setLocationRelativeTo(null);
20 | frame.setVisible(true);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/AboutGearsForm.form:
--------------------------------------------------------------------------------
1 |
2 |
185 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/AboutGearsForm.java:
--------------------------------------------------------------------------------
1 | package Forms;
2 |
3 | import com.intellij.ide.plugins.PluginManager;
4 | import com.intellij.ide.plugins.PluginVendor;
5 | import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser;
6 | import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.UnknownFeature;
7 |
8 | import javax.swing.*;
9 |
10 | import java.util.List;
11 |
12 | import static com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser.Plugin;
13 |
14 | /**
15 | * Created by matthewyork on 12/3/14.
16 | */
17 | public class AboutGearsForm {
18 | public JPanel MasterPanel;
19 | private JLabel VersionNumberLabel;
20 |
21 | public AboutGearsForm() {
22 | //Implemente dynamic version number here
23 | //If only these classes were well documented...
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/AndroidGearsHeader.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/src/Forms/AndroidGearsHeader.png
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/CreateGearForm.java:
--------------------------------------------------------------------------------
1 | package Forms;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 | import Models.GearSpec.GearSpecDependency;
6 | import Models.GearSpec.GearSpecSource;
7 | import Models.GearSpecLinter.GearSpecLintResult;
8 | import Services.AutoCompleteSerivce.AutoCompleteDocument;
9 | import Services.AutoCompleteSerivce.GearsService;
10 | import Utilities.Utils;
11 | import Workers.Lint.LintGearSpecWorker;
12 | import com.google.gson.Gson;
13 | import com.google.gson.GsonBuilder;
14 | import org.apache.commons.io.FileUtils;
15 |
16 | import javax.swing.*;
17 | import javax.swing.table.DefaultTableModel;
18 | import javax.swing.text.Document;
19 | import java.awt.*;
20 | import java.awt.event.ActionEvent;
21 | import java.awt.event.ActionListener;
22 | import java.awt.event.WindowEvent;
23 | import java.io.File;
24 | import java.io.IOException;
25 | import java.util.ArrayList;
26 |
27 | /**
28 | * Created by AaronFleshner on 4/2/14.
29 | */
30 | public class CreateGearForm {
31 | public JPanel MasterPanel;
32 |
33 | private JTextField txtProjectName;
34 | private JTextField txtHomePage;
35 | private JTextField txtLicense;
36 | private JTextField txtCopyRight;
37 | private JTextField txtProjectVersion;
38 | private JTextField txtSourceURL;
39 | private JTextField txtSourceLibLocation;
40 | private JTextField txtLibraryTag;
41 | private JTextField txtAuthorName;
42 | private JTextField txtAuthorEmail;
43 | private JTextField txtProjectTags;
44 | private JTextField txtDependencyName;
45 | private JTextField txtDependencyVersion;
46 |
47 | private JTable authorsTable;
48 | private DefaultTableModel AuthorModel;
49 | private JTable dependencyTable;
50 | private DefaultTableModel DependencyModel;
51 |
52 | private JButton btnAddAuthor;
53 | private JButton btnAddDependency;
54 | private JButton btnCreateAndroidGearSpec;
55 | private JButton btnRemoveAuthor;
56 | private JButton btnRemoveDependency;
57 |
58 | private JTextArea txtReleaseNotes;
59 | private JTextArea txtProjectSummary;
60 | private JComboBox cbLibraryType;
61 | private JComboBox cbMinSDK;
62 | private JButton btnLoadGearSpec;
63 |
64 | private Gson gson;
65 | private ArrayList authors = new ArrayList();
66 | private ArrayList dependencies = new ArrayList();
67 |
68 | private GearSpec newSpec;
69 |
70 |
71 | public CreateGearForm() {
72 | this.gson = new GsonBuilder().setPrettyPrinting().create();
73 | initAuthorTable();
74 | initDependenciesTable();
75 | initButtons();
76 | initAutoCompleteDependencies();
77 | }
78 |
79 | private void initAutoCompleteDependencies() {
80 | GearsService gearsService = new GearsService();
81 |
82 |
83 | // Create the auto completing document model with a reference to the
84 | // service and the input field.
85 | Document autoCompleteDocument = new AutoCompleteDocument(gearsService,txtDependencyName);
86 | txtDependencyName.setDocument(autoCompleteDocument);
87 | }
88 |
89 | //Initialize the Table so that you are able to add authors to the table.
90 | private void initAuthorTable() {//TODO add lint for the same author being added twice
91 | ArrayList authors = new ArrayList();
92 | //Create AuthorModel model for AddAllNewAuthors to use.. To add coloumns
93 | AuthorModel = (DefaultTableModel) authorsTable.getModel();
94 | AuthorModel.addColumn("Author's Name");
95 | AuthorModel.addColumn("Author's Email");
96 | //Really not used yet but if you wanted to add authors by default we could save a file where you could read authors from.
97 | AddAllNewAuthors(authors);
98 | }
99 |
100 | private void initDependenciesTable() {//TODO add lint for the same library being added twice
101 | ArrayList dependencies = new ArrayList();
102 | //Create dependency Model for AddAllNewDependencies to use. To add coloumns
103 | DependencyModel = (DefaultTableModel) dependencyTable.getModel();
104 | DependencyModel.addColumn("Dependency's Name");
105 | DependencyModel.addColumn("Dependency's Version");
106 | //Really not used yet but if you wanted to add dependencies by default we could save a file where you could read dependencies from.
107 | AddAllNewDependencies(dependencies);
108 | }
109 |
110 | //populate authors from dependency list if there ary any
111 | private void AddAllNewAuthors(ArrayList authors) {
112 | for (GearSpecAuthor author : authors) {
113 | AddNewAuthor(author);
114 | }
115 | }
116 | //adds author row to AuthorModel
117 | private void AddNewAuthor(GearSpecAuthor gearSpecAuthor) {
118 | //add new author to arrayList
119 | authors.add(gearSpecAuthor);
120 | //Update table
121 | AuthorModel.addRow(new Object[]{gearSpecAuthor.getName(), gearSpecAuthor.getEmail()});
122 | }
123 |
124 | //populate dependencies from the authors list if there are any.
125 | private void AddAllNewDependencies(ArrayList dependencies) {
126 | for (GearSpecDependency dependency : dependencies) {
127 | AddNewDependency(dependency);
128 | }
129 | }
130 | //adds dependency to DependencyModel
131 | private void AddNewDependency(GearSpecDependency gearSpecDependency) {
132 | //add new dependency to arraylist
133 | dependencies.add(gearSpecDependency);
134 | DependencyModel.addRow(new Object[]{gearSpecDependency.getName(), gearSpecDependency.getVersion()});
135 | }
136 |
137 |
138 | private void initButtons() {
139 | btnCreateAndroidGearSpec.addActionListener(new ActionListener() {
140 | @Override
141 | public void actionPerformed(ActionEvent e) {
142 | newSpec = CreateNewGearSpec();
143 | lintSpec(newSpec);
144 | }
145 | });
146 |
147 | btnAddAuthor.addActionListener(new ActionListener() {
148 | @Override
149 | public void actionPerformed(ActionEvent e) {
150 | if (!txtAuthorName.getText().isEmpty() && !txtAuthorEmail.getText().isEmpty()) {
151 | //add new author to table
152 | AddNewAuthor(new GearSpecAuthor(txtAuthorName.getText(), txtAuthorEmail.getText()));
153 |
154 | //clear out fields
155 | txtAuthorName.setText("");
156 | txtAuthorEmail.setText("");
157 | }
158 | }
159 | });
160 |
161 | btnAddDependency.addActionListener(new ActionListener() {
162 | @Override
163 | public void actionPerformed(ActionEvent e) {
164 | if (!txtDependencyName.getText().isEmpty() && !txtDependencyVersion.getText().isEmpty()) {
165 | //add new dependency to table.
166 | AddNewDependency(new GearSpecDependency(txtDependencyName.getText(), txtDependencyVersion.getText()));
167 |
168 | //clear out fields
169 | txtDependencyName.setText("");
170 | txtDependencyVersion.setText("");
171 | }
172 | }
173 | });
174 | btnRemoveAuthor.addActionListener(new ActionListener() {
175 | @Override
176 | public void actionPerformed(ActionEvent e) {
177 | //remove author from table
178 | AuthorModel.removeRow(authorsTable.getSelectedRow());
179 | //remove author from arrayList
180 | authors.remove(authorsTable.getSelectedRow());
181 | }
182 | });
183 |
184 | btnRemoveDependency.addActionListener(new ActionListener() {
185 | @Override
186 | public void actionPerformed(ActionEvent e) {
187 | //remove dependency from table
188 | DependencyModel.removeRow(dependencyTable.getSelectedRow());
189 | //remove dependency from arraylist
190 | dependencies.remove(dependencyTable.getSelectedRow());
191 | }
192 | });
193 |
194 | btnLoadGearSpec.addActionListener(new ActionListener() {
195 | @Override
196 | public void actionPerformed(ActionEvent e) {
197 | GearSpec spec = loadGearSpec();
198 | if (spec != null) {
199 | //load Spec from file chooser
200 | loadSpecIntoForm(spec);
201 | }
202 | else {
203 | showLoadErrorDialog();
204 | }
205 | }
206 | });
207 | }
208 |
209 | //loads the spec into the form.
210 | private void loadSpecIntoForm(GearSpec spec) {
211 | txtProjectName.setText(spec.getName());
212 | txtProjectVersion.setText(spec.getVersion());
213 | cbMinSDK.setSelectedIndex(spec.getMinimum_api());
214 | cbLibraryType.setSelectedItem(spec.getType());
215 | txtProjectTags.setText(GetTags(spec.getTags()));
216 | txtLibraryTag.setText(spec.getSource().getTag());
217 | txtSourceLibLocation.setText(spec.getSource().getSource_files());
218 | txtSourceURL.setText(spec.getSource().getUrl());
219 | txtProjectSummary.setText(spec.getSummary());
220 | txtReleaseNotes.setText(spec.getRelease_notes());
221 | txtCopyRight.setText(spec.getCopyright());
222 | txtHomePage.setText(spec.getHomepage());
223 | txtLicense.setText(spec.getLicense());
224 | if(spec.getAuthors()!=null)
225 | AddAllNewAuthors(spec.getAuthors());
226 | if(spec.getDependencies()!=null)
227 | AddAllNewDependencies(spec.getDependencies());
228 | }
229 |
230 |
231 |
232 | //loads the tags into a string to set the tags.
233 | private String GetTags(ArrayList tags) {
234 | String temp="";
235 |
236 | //Iterate over all tags and concatenate them as comma separated strings
237 | if (tags != null){
238 | for(String tag:tags){
239 | temp = temp.concat(tag)+" , ";
240 | }
241 | return temp.substring(0,temp.length()-3);
242 | }
243 |
244 | return temp;
245 | }
246 |
247 | //Make sure that spec meets Android GearSpec Requirements.
248 | private void lintSpec(final GearSpec spec) {
249 | LintGearSpecWorker worker = new LintGearSpecWorker(spec) {
250 | @Override
251 | protected void done() {
252 | super.done();
253 |
254 | if (result.getPassed()) {
255 | if (saveSpec(spec)) {
256 | JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel);
257 | frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
258 | }
259 | } else {
260 | showLintErrorDialog(result);
261 | }
262 | }
263 | };
264 | worker.execute();
265 | }
266 | //Save Spec to file on computer.
267 | private Boolean saveSpec(GearSpec spec) {
268 |
269 | //Get top level frame
270 | JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel);
271 |
272 | //Create dialog for choosing gearspec file
273 | FileDialog fd = new FileDialog(topFrame, "Save .gearspec file", FileDialog.SAVE);
274 | fd.setDirectory(System.getProperty("user.home"));
275 | // Gets the name that is specified for the spec in the beginning
276 | fd.setFile(spec.getName()+".gearspec");
277 | fd.setVisible(true);
278 | //Get file
279 | String filename = fd.getFile();
280 | if (filename == null) {
281 | System.out.println("You cancelled the choice");
282 | return false;
283 | }
284 | else {
285 | System.out.println("You chose " + filename);
286 |
287 | //Get spec file
288 | File specFile = new File(fd.getDirectory() + Utils.pathSeparator() + filename);
289 |
290 | //Serialize spec to string
291 | String gearString = gson.toJson(spec);
292 |
293 | try {
294 | //If it exists, set it as the selected file path
295 | if (specFile.exists()) {
296 | FileUtils.forceDelete(specFile);
297 | }
298 |
299 | //Write new spec
300 | FileUtils.write(specFile, gearString);
301 | } catch (IOException e) {
302 | e.printStackTrace();
303 | showSaveErrorDialog();
304 | return false;
305 | }
306 |
307 | return true;
308 | }
309 | }
310 | //load gearspec from file on computer
311 | private GearSpec loadGearSpec() {
312 | //Get top level frame
313 | JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel);
314 |
315 | //Create dialog for choosing gearspec file
316 | FileDialog fd = new FileDialog(topFrame, "Choose a .gearspec file", FileDialog.LOAD);
317 | fd.setDirectory(System.getProperty("user.home"));
318 | fd.setFile("*.gearspec");
319 | fd.setVisible(true);
320 | //Get file
321 | String filename = fd.getFile();
322 | if (filename == null)
323 | System.out.println("You cancelled the choice");
324 | else {
325 | System.out.println("You chose " + filename);
326 |
327 | //Get spec file
328 | File specFile = new File(fd.getDirectory() + Utils.pathSeparator() + filename);
329 |
330 | //If it exists, set it as the selected file path
331 | if (specFile.exists()) {
332 | //Generate spec
333 | return Utils.specForFile(specFile);
334 | }
335 | }
336 |
337 | return null;
338 | }
339 |
340 | /**
341 | * Creates the Android Gear Spec Object
342 | */
343 | private GearSpec CreateNewGearSpec() {
344 | GearSpec newSpec = new GearSpec();
345 | if (!txtProjectName.getText().isEmpty())
346 | newSpec.setName(txtProjectName.getText());
347 |
348 | if (!txtProjectVersion.getText().isEmpty())
349 | newSpec.setVersion(txtProjectVersion.getText());
350 |
351 | if (!txtProjectTags.getText().isEmpty())
352 | newSpec.setTags(ParseStringWithCommas(txtProjectTags.getText()));
353 |
354 | if (!txtSourceURL.getText().isEmpty()){
355 | String tagString = (txtLibraryTag.getText().equals("")) ? null : txtLibraryTag.getText();
356 | String sourceString = (txtSourceLibLocation.getText().equals("")) ? null : txtSourceLibLocation.getText();
357 |
358 | newSpec.setSource(new GearSpecSource(sourceString, txtSourceURL.getText(), tagString));
359 | }
360 |
361 | if (!txtProjectSummary.getText().isEmpty())
362 | newSpec.setSummary(txtProjectSummary.getText());
363 |
364 | if (!txtReleaseNotes.getText().isEmpty())
365 | newSpec.setRelease_notes(txtReleaseNotes.getText());
366 |
367 | if (!txtCopyRight.getText().isEmpty())
368 | newSpec.setCopyright(txtCopyRight.getText());
369 |
370 | if (!txtHomePage.getText().isEmpty())
371 | newSpec.setHomepage(txtHomePage.getText());
372 |
373 | if (!txtLicense.getText().isEmpty())
374 | newSpec.setLicense(txtLicense.getText());
375 |
376 | if (!authors.isEmpty())
377 | newSpec.setAuthors(authors);
378 |
379 | if (!dependencies.isEmpty())
380 | newSpec.setDependencies(dependencies);
381 |
382 | newSpec.setType(cbLibraryType.getSelectedItem().toString());
383 | newSpec.setMinimum_api(Integer.parseInt(cbMinSDK.getSelectedItem().toString()));
384 |
385 | return newSpec;
386 | }
387 |
388 | //TODO Create checks.
389 | private ArrayList ParseStringWithCommas(String text) {
390 | String[] Strings = text.split(",");
391 | ArrayList temp = new ArrayList();
392 | for (int i = 0; i < Strings.length; i++) {
393 | //trims the whitespace from the beginning and the end of the string. leaving the whitespace in the middle alone
394 | Strings[i] = trimExtraWhiteSpace(Strings[i]);
395 | //Is empty check
396 | if (!Strings[i].isEmpty()) {
397 | temp.add(Strings[i]);
398 | }
399 | }
400 | return temp;
401 | }
402 |
403 | /**
404 | * Checks for spaces at the end of the string and at the beginning of the string and removes that whitespace.
405 | *
406 | * @param string String spaces are checked on
407 | * @return string with the whitespace trimmed off.
408 | */
409 | private String trimExtraWhiteSpace(String string) {
410 | //remove all whitespace after string and before string
411 | return string.replaceAll("\\s+$", "").replaceAll("^\\s+", "");
412 | }
413 |
414 | private void createUIComponents() {
415 | // TODO: place custom component creation code here
416 | }
417 |
418 | ///////////////////////
419 | // Dialogs
420 | ///////////////////////
421 |
422 | private void showLintErrorDialog(GearSpecLintResult result) {
423 | Object[] options = {"OK"};
424 | int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(MasterPanel),
425 | result.getResponseMessage(),
426 | "Lint Error",
427 | JOptionPane.OK_OPTION,
428 | JOptionPane.QUESTION_MESSAGE,
429 | null,
430 | options,
431 | options[0]);
432 | }
433 |
434 | private void showSaveErrorDialog() {
435 | Object[] options = {"OK"};
436 | int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(MasterPanel),
437 | "There was a problem saving your Gear Spec. Please try again.",
438 | "Lint Error",
439 | JOptionPane.OK_OPTION,
440 | JOptionPane.QUESTION_MESSAGE,
441 | null,
442 | options,
443 | options[0]);
444 | }
445 |
446 | private void showLoadErrorDialog() {
447 | Object[] options = {"OK"};
448 | int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(MasterPanel),
449 | "There was a problem loading your Gear Spec. Please try again.",
450 | "Lint Error",
451 | JOptionPane.OK_OPTION,
452 | JOptionPane.QUESTION_MESSAGE,
453 | null,
454 | options,
455 | options[0]);
456 | }
457 | }
458 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/Lint Gear Form.form:
--------------------------------------------------------------------------------
1 |
2 |
109 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/LintGearForm.java:
--------------------------------------------------------------------------------
1 | package Forms;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpecLinter.GearSpecLintResult;
5 | import Utilities.Utils;
6 | import Workers.Lint.LintGearSpecWorker;
7 |
8 | import javax.swing.*;
9 | import java.awt.*;
10 | import java.awt.event.ActionEvent;
11 | import java.awt.event.ActionListener;
12 | import java.io.File;
13 |
14 | /**
15 | * Created by matthewyork on 4/3/14.
16 | */
17 | public class LintGearForm extends Component {
18 | public JPanel MasterPanel;
19 | private JButton lintButton;
20 | private JTextField SpecUrlTextField;
21 | private JLabel LintExplanationLabel;
22 | private JButton FindURLButton;
23 | private JTextArea LintResultsTextArea;
24 | private JPanel LintProgressPanel;
25 | private JLabel LoadingSpinnerLabel;
26 | private JLabel LintingStatusLabel;
27 |
28 | public LintGearForm() {
29 | setupButtons();
30 | setupMiscUI();
31 | }
32 |
33 | private void setupButtons() {
34 | FindURLButton.addActionListener(new ActionListener() {
35 | @Override
36 | public void actionPerformed(ActionEvent actionEvent) {
37 | //Get top level frame
38 | JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel);
39 |
40 | //Create dialog for choosing gearspec file
41 | System.setProperty("apple.awt.fileDialogForDirectories", "false");
42 | FileDialog fd = new FileDialog(topFrame, "Choose a .gearspec file", FileDialog.LOAD);
43 | fd.setDirectory(System.getProperty("user.home"));
44 | fd.setFile("*.gearspec");
45 | fd.setVisible(true);
46 | //Get file
47 | String filename = fd.getFile();
48 | if (filename == null)
49 | System.out.println("You cancelled the choice");
50 | else {
51 | System.out.println("You chose " + filename);
52 |
53 | //Get spec file
54 | File specFile = new File(fd.getDirectory()+Utils.pathSeparator()+filename);
55 |
56 | //If it exists, set it as the selected file path
57 | if (specFile.exists()){
58 | SpecUrlTextField.setText(specFile.getAbsolutePath());
59 | }
60 | }
61 | }
62 | });
63 |
64 | lintButton.addActionListener(new ActionListener() {
65 | @Override
66 | public void actionPerformed(ActionEvent actionEvent) {
67 |
68 | lintSpec();
69 | }
70 | });
71 | }
72 |
73 | private void setupMiscUI() {
74 | LintExplanationLabel.setText(Utils.wrappedStringForString(LintExplanationLabel.getText(), 500));
75 | SpecUrlTextField.setText(System.getProperty("user.home"));
76 |
77 | //Hide linting spinner at the bottom
78 | LintingStatusLabel.setVisible(false);
79 | LoadingSpinnerLabel.setVisible(false);
80 | }
81 |
82 |
83 |
84 | /////////////////////
85 | // Spec Linting
86 | /////////////////////
87 |
88 | private void lintSpec() {
89 | //Show linting spinner
90 | LintingStatusLabel.setVisible(true);
91 | LoadingSpinnerLabel.setVisible(true);
92 |
93 | //Get spec file from url text field
94 | File specFile = new File(SpecUrlTextField.getText());
95 |
96 | //Generate spec
97 | GearSpec spec = Utils.specForFile(specFile);
98 |
99 | if(spec != null){
100 | //Lint spec
101 | LintGearSpecWorker worker = new LintGearSpecWorker(spec){
102 |
103 | @Override
104 | protected void done() {
105 | super.done();
106 |
107 | GearSpecLintResult result = this.result;
108 |
109 | //Show final linting results
110 | if (result != null){
111 | LintResultsTextArea.setText(result.getResponseMessage());
112 | }
113 | else {
114 | LintResultsTextArea.setText("Linting Error. Please try again");
115 | }
116 |
117 | //Hide linting spinner at the bottom
118 | LintingStatusLabel.setVisible(false);
119 | LoadingSpinnerLabel.setVisible(false);
120 | }
121 | };
122 | worker.execute();
123 | }
124 | else {
125 | LintResultsTextArea.setText("Linting Error\n\n- JSON syntax error.\n Please ensure your gearspec is a valid JSON object");
126 |
127 | //Hide linting spinner at the bottom
128 | LintingStatusLabel.setVisible(false);
129 | LoadingSpinnerLabel.setVisible(false);
130 | }
131 | }
132 |
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/Search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/src/Forms/Search.png
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/Settings Form.form:
--------------------------------------------------------------------------------
1 |
2 |
180 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/SettingsForm.java:
--------------------------------------------------------------------------------
1 | package Forms;
2 |
3 | import Singletons.SettingsManager;
4 | import Utilities.OSValidator;
5 | import Utilities.Utils;
6 | import Workers.Git.GitWorker;
7 | import Workers.Settings.SetCreateIgnoreEntryWorker;
8 | import org.apache.commons.io.FileUtils;
9 |
10 | import javax.swing.*;
11 | import java.awt.*;
12 | import java.awt.event.ActionEvent;
13 | import java.awt.event.ActionListener;
14 | import java.awt.event.ItemEvent;
15 | import java.awt.event.ItemListener;
16 | import java.io.File;
17 | import java.io.FilenameFilter;
18 | import java.io.IOException;
19 |
20 | /**
21 | * Created by matthewyork on 4/6/14.
22 | */
23 | public class SettingsForm {
24 |
25 | private static int SETTINGS_FRAME_WIDTH = 500;
26 |
27 | public JPanel MasterPanel;
28 | private JButton resynchronizeAndroidGearsButton;
29 | private JTextPane allowAndroidGearsToTextPane;
30 | private JTextPane normallyTheGearsPluginTextPane;
31 | private JCheckBox createGitignoreEntryCheckBox;
32 | private JCheckBox autoSyncGearsCheckBox;
33 | private JTextPane byCheckingYesAndroidTextPane;
34 | private JLabel LoadingSpinnerLabel;
35 | private JPanel ResyncProgressPanel;
36 | private JLabel ResyncStatusLabel;
37 | private JTextField SpecUrlTextField;
38 | private JButton FindURLButton;
39 | private JButton DefaultSpecPathButton;
40 |
41 | public SettingsForm() {
42 | SettingsManager.getInstance().loadSettings();
43 | setupCheckBoxes();
44 | setupButtons();
45 | setupMiscUI();
46 | }
47 |
48 | private void setupCheckBoxes() {
49 | //Set ignore checkbox. Add check/uncheck listener
50 | createGitignoreEntryCheckBox.setSelected(SettingsManager.getInstance().getAutoIgnore());
51 | createGitignoreEntryCheckBox.addItemListener(new ItemListener() {
52 | @Override
53 | public void itemStateChanged(ItemEvent itemEvent) {
54 | setCreateIgnoreSelected(createGitignoreEntryCheckBox.isSelected());
55 | }
56 | });
57 |
58 | //Set ignore checkbox. Add check/uncheck listener
59 | autoSyncGearsCheckBox.setSelected(SettingsManager.getInstance().getAutoSync());
60 | autoSyncGearsCheckBox.addItemListener(new ItemListener() {
61 | @Override
62 | public void itemStateChanged(ItemEvent itemEvent) {
63 | setAutoSync(autoSyncGearsCheckBox.isSelected());
64 | }
65 | });
66 | }
67 |
68 | private void setupButtons() {
69 | resynchronizeAndroidGearsButton.addActionListener(new ActionListener() {
70 | @Override
71 | public void actionPerformed(ActionEvent actionEvent) {
72 | showResyncLoadingMessage();
73 | resyncSpecs();
74 | }
75 | });
76 |
77 | FindURLButton.addActionListener(new ActionListener() {
78 | @Override
79 | public void actionPerformed(ActionEvent actionEvent) {
80 |
81 | if(OSValidator.isWindows()){
82 | JFileChooser chooser = new JFileChooser();
83 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
84 | chooser.setCurrentDirectory(new File(SettingsManager.getInstance().getSpecsPath()));
85 | int returnVal = chooser.showOpenDialog(MasterPanel.getTopLevelAncestor());
86 |
87 | if (returnVal == JFileChooser.APPROVE_OPTION) {
88 | File specsDirectory = chooser.getSelectedFile();
89 |
90 | setSpecsRepoDirectory(specsDirectory);
91 | }
92 | }
93 | else if (OSValidator.isMac()){
94 | //Get top level frame
95 | JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel);
96 |
97 | //Create dialog for choosing gearspec file
98 | System.setProperty("apple.awt.fileDialogForDirectories", "true");
99 | FileDialog fd = new FileDialog(topFrame, "Choose a directory", FileDialog.LOAD);
100 | fd.setDirectory(SettingsManager.getInstance().getSpecsPath());
101 | fd.setVisible(true);
102 |
103 | //Get file
104 | String filename = fd.getFile();
105 | if (filename == null)
106 | System.out.println("You cancelled the choice");
107 | else {
108 | System.out.println("You chose " + filename);
109 |
110 | //Get spec file
111 | File specsDirectory = new File(fd.getDirectory()+Utils.pathSeparator()+filename);
112 |
113 | //If it exists, set it as the selected file path
114 | setSpecsRepoDirectory(specsDirectory);
115 |
116 | }
117 | }
118 | }
119 | });
120 |
121 | DefaultSpecPathButton.addActionListener(new ActionListener() {
122 | @Override
123 | public void actionPerformed(ActionEvent actionEvent) {
124 | setSpecsRepoDirectory(Utils.getDefaultDirectory());
125 | }
126 | });
127 | }
128 |
129 | private void setupMiscUI() {
130 | ResyncProgressPanel.setVisible(false);
131 |
132 | //Set spec repository path
133 | SpecUrlTextField.setText(SettingsManager.getInstance().getSpecsPath());
134 | }
135 |
136 | private void setCreateIgnoreSelected(final Boolean selected){
137 | SetCreateIgnoreEntryWorker worker = new SetCreateIgnoreEntryWorker(selected){
138 | @Override
139 | protected void done() {
140 | super.done();
141 |
142 | //Give some feedback as to the success or failure of the ignore entry
143 | if (success){
144 | if (selected){
145 | showAddedIgnoreDialog(MasterPanel);
146 | }
147 | else {
148 | showRemovedIgnoreDialog(MasterPanel);
149 | }
150 | }
151 | else {
152 | if (selected){
153 | showFailedToAddIgnoreDialog(MasterPanel);
154 | }
155 | else {
156 | showFailedToRemoveIgnoreDialog(MasterPanel);
157 | }
158 | }
159 | }
160 | };
161 | worker.execute();
162 | }
163 |
164 | private void setAutoSync(final boolean selected){
165 | SettingsManager.getInstance().setAutoSync(selected);
166 | }
167 |
168 | ///////////////////////
169 | // Dialogs
170 | ///////////////////////
171 |
172 | private void showAddedIgnoreDialog(JPanel panel) {
173 | Object[] options = {"OK"};
174 | int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(panel),
175 | "Android Gears successfully added an entry to your ignore file",
176 | "Ignore File",
177 | JOptionPane.OK_OPTION,
178 | JOptionPane.QUESTION_MESSAGE,
179 | null,
180 | options,
181 | options[0]);
182 | }
183 |
184 | private void showFailedToAddIgnoreDialog(JPanel panel) {
185 | Object[] options = {"OK"};
186 | int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(panel),
187 | "Android Gears failed to add an entry to your ignore file, but will still attempt to do so for new projects. For best results, ignore the \"Gears\" folder in your project directory.",
188 | "Ignore File",
189 | JOptionPane.OK_OPTION,
190 | JOptionPane.QUESTION_MESSAGE,
191 | null,
192 | options,
193 | options[0]);
194 | }
195 |
196 | private void showRemovedIgnoreDialog(JPanel panel) {
197 | Object[] options = {"OK"};
198 | int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(panel),
199 | "Android Gears successfully removed its entry in your ignore file",
200 | "Ignore File",
201 | JOptionPane.OK_OPTION,
202 | JOptionPane.QUESTION_MESSAGE,
203 | null,
204 | options,
205 | options[0]);
206 | }
207 |
208 | private void showFailedToRemoveIgnoreDialog(JPanel panel) {
209 | Object[] options = {"OK"};
210 | int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(panel),
211 | "Android Gears failed to remove its entry in your ignore file. Please find and remove the \"Gears\" folder entry if you would like to stop the ignoring of Android Gears.",
212 | "Ignore File",
213 | JOptionPane.OK_OPTION,
214 | JOptionPane.QUESTION_MESSAGE,
215 | null,
216 | options,
217 | options[0]);
218 | }
219 |
220 | private void showResyncSuccessMessage(){
221 | LoadingSpinnerLabel.setVisible(false);
222 | ResyncStatusLabel.setText("Successfully synchronized Android Gears");
223 | resynchronizeAndroidGearsButton.setEnabled(true);
224 | }
225 |
226 | private void showResyncErrorMessage(){
227 | LoadingSpinnerLabel.setVisible(false);
228 | ResyncStatusLabel.setText("Failed to synchronize Android Gears. Please check your network connection.");
229 | resynchronizeAndroidGearsButton.setEnabled(true);
230 |
231 | }
232 |
233 | private void showResyncLoadingMessage(){
234 | LoadingSpinnerLabel.setVisible(true);
235 | ResyncStatusLabel.setText("Resynchronizing Android Gears Repository...");
236 | resynchronizeAndroidGearsButton.setEnabled(false);
237 | ResyncProgressPanel.setVisible(true);
238 | }
239 |
240 | private void setSpecsRepoDirectory(File specsDirectory){
241 | //Make sure the directory exists
242 | if (specsDirectory.exists()){
243 | //Double check that it is a directory
244 | if (specsDirectory.isDirectory()){
245 |
246 | if (Utils.androidGearsDirectory().exists()){
247 | //Make local copy of old specs directory
248 | File oldSpecsDirectory = Utils.androidGearsDirectory();
249 |
250 | Boolean failure = false;
251 | for (File file : oldSpecsDirectory.listFiles()){
252 | try {
253 | if (file.isDirectory()){
254 | FileUtils.moveDirectoryToDirectory(file, new File(specsDirectory.getAbsolutePath()+Utils.pathSeparator()+"repos"), true);
255 | }
256 | } catch (IOException e) {
257 |
258 | failure = true;
259 | e.printStackTrace();
260 | break;
261 | }
262 | }
263 |
264 | if (!failure){
265 | //Save new setting!
266 | SettingsManager.getInstance().setSpecsPath(specsDirectory.getAbsolutePath());
267 |
268 | //Delete previous path, if it exists
269 | FileUtils.deleteQuietly(oldSpecsDirectory);
270 |
271 | //Set specs directory in UI
272 | SpecUrlTextField.setText(specsDirectory.getAbsolutePath());
273 | }
274 | }
275 | else {
276 | //Set new directory
277 | SettingsManager.getInstance().setSpecsPath(specsDirectory.getAbsolutePath());
278 |
279 | //Clone specs repo in new path
280 | showResyncLoadingMessage();
281 | resyncSpecs();
282 | }
283 | }
284 | }
285 | }
286 |
287 | private void resyncSpecs() {
288 | //Get gears directory
289 | final File gearsDirectory = Utils.androidGearsDirectory();
290 | final File gearsDirectoryCopy = new File(Utils.androidGearsDirectory().getParentFile().getAbsolutePath()+Utils.pathSeparator()+"reposCopy");
291 |
292 |
293 | //First, make local copy of specNames for possible rollback
294 | try {
295 | if (!gearsDirectory.exists()){
296 | GitWorker worker = new GitWorker(){
297 | @Override
298 | protected void done() {
299 | super.done();
300 |
301 | if (successful){
302 | showResyncSuccessMessage();
303 | }
304 | else {
305 | showResyncErrorMessage();
306 | }
307 | }
308 |
309 | };
310 | worker.execute();
311 | }
312 | else {
313 | //Make local copy
314 | FileUtils.copyDirectory(gearsDirectory, gearsDirectoryCopy);
315 |
316 | //Delete original
317 | FileUtils.deleteQuietly(gearsDirectory);
318 |
319 | //Download new copy
320 | GitWorker worker = new GitWorker(){
321 | @Override
322 | protected void done() {
323 | super.done();
324 | //Delete copy
325 | try {
326 | if (successful){
327 | //Delete the copy you made
328 | FileUtils.deleteQuietly(gearsDirectoryCopy);
329 |
330 | //Close the dialog
331 | showResyncSuccessMessage();
332 | }
333 | else {
334 | //Delete the original, just in case
335 | if (gearsDirectory.exists()){
336 | FileUtils.deleteQuietly(gearsDirectory);
337 | }
338 |
339 | //Make local copy
340 | FileUtils.moveDirectory(gearsDirectoryCopy, gearsDirectory);
341 |
342 | //Close the dialog
343 | showResyncErrorMessage();
344 | }
345 |
346 | } catch (IOException e) {
347 | e.printStackTrace();
348 | showResyncErrorMessage();
349 | }
350 | }
351 |
352 | };
353 | worker.execute();
354 | }
355 | } catch (IOException e) {
356 | e.printStackTrace();
357 | showResyncErrorMessage();
358 | }
359 | }
360 | }
361 |
--------------------------------------------------------------------------------
/AndroidGears/src/Forms/loadinfo.net (1).gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/src/Forms/loadinfo.net (1).gif
--------------------------------------------------------------------------------
/AndroidGears/src/GitComponent.java:
--------------------------------------------------------------------------------
1 | import Workers.Git.GitWorker;
2 | import Workers.Git.IgnoreCheckWorker;
3 | import com.intellij.openapi.components.ApplicationComponent;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | /**
7 | * Created by matthewyork on 3/31/14.
8 | */
9 | public class GitComponent implements ApplicationComponent {
10 |
11 | private String REMOTE_SPECS_URL = "https://github.com/AndroidGears/Specs.git";
12 |
13 | public GitComponent() {
14 | }
15 |
16 | public void initComponent() {
17 |
18 | //Clones/Pulls on the specNames repo
19 | GitWorker worker = new GitWorker(){
20 | @Override
21 | protected void done() {
22 | super.done();
23 |
24 | }
25 | };
26 | worker.execute();
27 | }
28 |
29 | public void disposeComponent() {
30 | // TODO: insert component disposal logic here
31 | }
32 |
33 | @NotNull
34 | public String getComponentName() {
35 | return "GitComponent";
36 | }
37 |
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/AndroidGears/src/Interfaces/AndroidGearIcons.java:
--------------------------------------------------------------------------------
1 | package Interfaces;
2 |
3 | import com.intellij.openapi.util.IconLoader;
4 |
5 | import javax.swing.*;
6 |
7 | /**
8 | * Created by aaronfleshner on 4/22/14.
9 | */
10 | public interface AndroidGearIcons {
11 | public Icon ANDROID_GEAR_ICON = IconLoader.getIcon("/gears.png");
12 | public Icon declaredIcon =IconLoader.getIcon("/GearStateDeclared.png");//Fix
13 | public Icon installedIcon =IconLoader.getIcon("/GearStateInstalled.png");//Fix
14 | public Icon jarfile =IconLoader.getIcon("/jarfile.png");//Fix
15 | }
16 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/GearSpec/GearSpec.java:
--------------------------------------------------------------------------------
1 | package Models.GearSpec;
2 |
3 | import Models.GearSpecRegister.GearSpecRegister;
4 | import Utilities.GearSpecRegistrar;
5 | import com.intellij.openapi.project.Project;
6 |
7 | import java.util.ArrayList;
8 |
9 | /**
10 | * Created by matthewyork on 3/31/14.
11 | */
12 | public class GearSpec {
13 | public enum GearState {
14 | GearStateUninstalled,
15 | GearStateDeclared,
16 | GearStateInstalled
17 | };
18 |
19 | public static final String SPEC_TYPE_MODULE = "module";
20 | public static final String SPEC_TYPE_JAR = "jar";
21 |
22 | private GearState gearState;
23 | private String name;
24 | private String summary;
25 | private String release_notes;
26 | private String version;
27 | private String type;
28 | private String copyright;
29 | private String homepage;
30 | private String license;
31 | private ArrayList authors;
32 | private int minimum_api;
33 | private GearSpecSource source;
34 | private ArrayList dependencies;
35 | private ArrayList tags;
36 |
37 | public GearState getGearState() {
38 | return gearState;
39 | }
40 |
41 | public void setGearState(GearState gearState) {
42 | this.gearState = gearState;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | public String getSummary() {
54 | return summary;
55 | }
56 |
57 | public void setSummary(String summary) {
58 | this.summary = summary;
59 | }
60 |
61 | public String getRelease_notes() {
62 | return release_notes;
63 | }
64 |
65 | public void setRelease_notes(String release_notes) {
66 | this.release_notes = release_notes;
67 | }
68 |
69 | public String getVersion() {
70 | return version;
71 | }
72 |
73 | public void setVersion(String version) {
74 | this.version = version;
75 | }
76 |
77 | public String getType() {
78 | return type;
79 | }
80 |
81 | public void setType(String type) {
82 | this.type = type;
83 | }
84 |
85 | public String getCopyright() {
86 | return copyright;
87 | }
88 |
89 | public void setCopyright(String copyright) {
90 | this.copyright = copyright;
91 | }
92 |
93 | public String getHomepage() {
94 | return homepage;
95 | }
96 |
97 | public void setHomepage(String homepage) {
98 | this.homepage = homepage;
99 | }
100 |
101 | public String getLicense() {
102 | return license;
103 | }
104 |
105 | public void setLicense(String license) {
106 | this.license = license;
107 | }
108 |
109 | public ArrayList getAuthors() {
110 | return authors;
111 | }
112 |
113 | public void setAuthors(ArrayList authors) {
114 | this.authors = authors;
115 | }
116 |
117 | public int getMinimum_api() {
118 | return minimum_api;
119 | }
120 |
121 | public void setMinimum_api(int minimum_api) {
122 | this.minimum_api = minimum_api;
123 | }
124 |
125 | public GearSpecSource getSource() {
126 | return source;
127 | }
128 |
129 | public void setSource(GearSpecSource source) {
130 | this.source = source;
131 | }
132 |
133 | public ArrayList getDependencies() {
134 | return dependencies;
135 | }
136 |
137 | public void setDependencies(ArrayList dependencies) {
138 | this.dependencies = dependencies;
139 | }
140 |
141 | public ArrayList getTags() {
142 | return tags;
143 | }
144 |
145 | public void setTags(ArrayList tags) {
146 | this.tags = tags;
147 | }
148 |
149 | ///////////////////////
150 | // Helper Methods
151 | ///////////////////////
152 |
153 | public Boolean isRegistered(Project project){
154 | //Get register
155 | GearSpecRegister register = GearSpecRegistrar.getRegister(project);
156 |
157 | //Iterate over register
158 | if (register != null){
159 | if (register.declaredGears != null){
160 | for(GearSpec spec : register.declaredGears){
161 | if (this.getName().equals(spec.getName()) && this.getVersion().equals(spec.getVersion())){
162 | return true;
163 | }
164 | }
165 | }
166 | }
167 |
168 | return false;
169 | }
170 |
171 | public ArrayList dependentGears(Project project){
172 | //Get register
173 | GearSpecRegister register = GearSpecRegistrar.getRegister(project);
174 |
175 | //Setup dependents array
176 | ArrayList dependents = new ArrayList();
177 |
178 | //Iterate over register dependencies for potential dependents
179 | if (register != null) {
180 | if (register.declaredGears != null) {
181 | for (GearSpec spec : register.declaredGears) {
182 | if (this.getName().equals(spec.getName()) && this.getVersion().equals(spec.getVersion())){
183 | continue;
184 | }
185 | else { //For all not the calling spec
186 | if (spec.getDependencies() != null){
187 | for (GearSpecDependency dependency : spec.getDependencies()){
188 | //If a dependency matches the calling spec, add it as a dependent gear
189 | if (dependency.getName().equals(this.getName()) && dependency.getVersion().equals(this.getVersion())){
190 | dependents.add(spec);
191 | ArrayList dependentSpecs = spec.dependentGears(project);
192 | dependents.addAll(dependentSpecs);
193 | }
194 | }
195 | }
196 | }
197 | }
198 | }
199 | }
200 |
201 | return dependents;
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/GearSpec/GearSpecAuthor.java:
--------------------------------------------------------------------------------
1 | package Models.GearSpec;
2 |
3 | /**
4 | * Created by matthewyork on 3/31/14.
5 | */
6 | public class GearSpecAuthor {
7 | private String name;
8 | private String email;
9 |
10 | public GearSpecAuthor(String name, String email) {
11 | this.name = name;
12 | this.email = email;
13 | }
14 |
15 | public String getName() {
16 | return name;
17 | }
18 |
19 | public void setName(String name) {
20 | this.name = name;
21 | }
22 |
23 | public String getEmail() {
24 | return email;
25 | }
26 |
27 | public void setEmail(String email) {
28 | this.email = email;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/GearSpec/GearSpecDependency.java:
--------------------------------------------------------------------------------
1 | package Models.GearSpec;
2 |
3 | /**
4 | * Created by matthewyork on 3/31/14.
5 | */
6 | public class GearSpecDependency {
7 | private String name;
8 | private String version;
9 |
10 | public GearSpecDependency(String name, String version) {
11 | this.name = name;
12 | this.version = version;
13 | }
14 |
15 | public String getName() {
16 | return name;
17 | }
18 |
19 | public void setName(String name) {
20 | this.name = name;
21 | }
22 |
23 | public String getVersion() {
24 | return version;
25 | }
26 |
27 | public void setVersion(String version) {
28 | this.version = version;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/GearSpec/GearSpecSource.java:
--------------------------------------------------------------------------------
1 | package Models.GearSpec;
2 |
3 | /**
4 | * Created by matthewyork on 3/31/14.
5 | */
6 | public class GearSpecSource {
7 | private String url;
8 | private String tag;
9 | private String source_files;
10 |
11 | public GearSpecSource(String source_files, String url, String tag) {
12 | this.source_files = source_files;
13 | this.url = url;
14 | this.tag = tag;
15 | }
16 |
17 | public String getUrl() {
18 | return url;
19 | }
20 |
21 | public void setUrl(String url) {
22 | this.url = url;
23 | }
24 |
25 | public String getTag() {
26 | return tag;
27 | }
28 |
29 | public void setTag(String tag) {
30 | this.tag = tag;
31 | }
32 |
33 | public String getSource_files() {
34 | return source_files;
35 | }
36 |
37 | public void setSource_files(String source_files) {
38 | this.source_files = source_files;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/GearSpec/GearSpecUpdate.java:
--------------------------------------------------------------------------------
1 | package Models.GearSpec;
2 |
3 | import java.util.ArrayList;
4 |
5 | /**
6 | * Created by matthewyork on 4/9/14.
7 | * Updated by adfleshner on 4/22/14.
8 | */
9 | public class GearSpecUpdate extends GearSpec {
10 |
11 | public GearSpecUpdate(GearSpec spec) {
12 | setName(spec.getName());
13 | setSummary(spec.getSummary());
14 | setRelease_notes(spec.getRelease_notes());
15 | setVersion(spec.getVersion());
16 | setType(spec.getType());
17 | setCopyright(spec.getCopyright());
18 | setHomepage(spec.getHomepage());
19 | setLicense(spec.getLicense());
20 | setAuthors(spec.getAuthors());
21 | setMinimum_api(spec.getMinimum_api());
22 | setSource(spec.getSource());
23 | setDependencies(spec.getDependencies());
24 | setTags(spec.getTags());
25 | setGearState(spec.getGearState());
26 | }
27 |
28 | private String updateVersionNumber;
29 |
30 | public String getUpdateVersionNumber() {
31 | return updateVersionNumber;
32 | }
33 |
34 | public void setUpdateVersionNumber(String updateVersionNumber) {
35 | this.updateVersionNumber = updateVersionNumber;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/GearSpecLinter/GearSpecLintResult.java:
--------------------------------------------------------------------------------
1 | package Models.GearSpecLinter;
2 |
3 | /**
4 | * Created by matthewyork on 4/3/14.
5 | */
6 | public class GearSpecLintResult {
7 | private Boolean passed;
8 | private String responseMessage;
9 |
10 | public Boolean getPassed() {
11 | return passed;
12 | }
13 |
14 | public void setPassed(Boolean passed) {
15 | this.passed = passed;
16 | }
17 |
18 | public String getResponseMessage() {
19 | return responseMessage;
20 | }
21 |
22 | public void setResponseMessage(String responseMessage) {
23 | this.responseMessage = responseMessage;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/GearSpecRegister/GearSpecRegister.java:
--------------------------------------------------------------------------------
1 | package Models.GearSpecRegister;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecDependency;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by matthewyork on 4/5/14.
10 | */
11 | public class GearSpecRegister {
12 | public ArrayList declaredGears;
13 | }
14 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/Settings/GearSpecSettings.java:
--------------------------------------------------------------------------------
1 | package Models.Settings;
2 |
3 | /**
4 | * Created by matthewyork on 4/6/14.
5 | */
6 | public class GearSpecSettings {
7 |
8 | //Settings
9 | public boolean autoIgnore = true; //Defaults to true
10 | public boolean autosyncGears = false; //Defaults to false
11 | public String specsPath = null;
12 | }
13 |
--------------------------------------------------------------------------------
/AndroidGears/src/Models/Settings/ProjectSettings.java:
--------------------------------------------------------------------------------
1 | package Models.Settings;
2 |
3 | /**
4 | * Created by matthewyork on 4/7/14.
5 | */
6 | public class ProjectSettings {
7 | public String mainModule = "";
8 | }
9 |
--------------------------------------------------------------------------------
/AndroidGears/src/Panels/SpecDetailsPanel.java:
--------------------------------------------------------------------------------
1 | package Panels;
2 |
3 | import Forms.ManageAndroidGearsForm;
4 | import Models.GearSpec.GearSpec;
5 | import Models.GearSpec.GearSpecAuthor;
6 | import Models.GearSpec.GearSpecDependency;
7 | import Utilities.Utils;
8 |
9 | import javax.swing.*;
10 | import java.awt.*;
11 |
12 | /**
13 | * Created by matthewyork on 4/2/14.
14 | */
15 | public class SpecDetailsPanel extends JPanel{
16 | private GearSpec selectedSpec;
17 |
18 | public SpecDetailsPanel(GearSpec selectedSpec) {
19 | this.selectedSpec = selectedSpec;
20 |
21 | this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 15));
22 | this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
23 | this.setMaximumSize(new Dimension(ManageAndroidGearsForm.DETAILS_INNER_WIDTH, -1));
24 |
25 |
26 | //Add repo name
27 | if (selectedSpec.getName() != null){
28 | JLabel nameLabel = new JLabel(selectedSpec.getName(), JLabel.LEFT);
29 | nameLabel.setFont(new Font(nameLabel.getFont().getName(), Font.BOLD, 14));
30 | this.add(nameLabel);
31 | }
32 |
33 |
34 | //Add version and type
35 | if (selectedSpec.getVersion() != null){
36 | JLabel versionLabel = new JLabel(selectedSpec.getVersion() + " - " + selectedSpec.getType(), JLabel.LEFT);
37 | versionLabel.setFont(new Font(versionLabel.getFont().getName(), Font.BOLD, 12));
38 | this.add(versionLabel);
39 | }
40 |
41 | //Add summary
42 | if (selectedSpec.getSummary() != null) {
43 | JLabel summaryLabel = new JLabel(Utils.wrappedStringForString(selectedSpec.getSummary(), ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
44 | summaryLabel.setFont(new Font(summaryLabel.getFont().getName(), Font.PLAIN, 12));
45 | this.add(summaryLabel);
46 | }
47 |
48 | //Add authors
49 | if (selectedSpec.getRelease_notes() != null) {
50 | //Add header
51 | JLabel header = new JLabel(Utils.wrappedStringForString("
"+selectedSpec.getVersion()+" - Release Notes", ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
52 | header.setFont(new Font(header.getFont().getName(), Font.BOLD, 12));
53 | this.add(header);
54 |
55 | //Add release notes
56 | JLabel releaseNotesLabel = new JLabel(Utils.wrappedStringForString(selectedSpec.getRelease_notes(), ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
57 | releaseNotesLabel.setFont(new Font(releaseNotesLabel.getFont().getName(), Font.PLAIN, 12));
58 | this.add(releaseNotesLabel);
59 | }
60 |
61 | //Add authors
62 | if (selectedSpec.getAuthors() != null) {
63 | //Add header
64 | JLabel header = new JLabel(Utils.wrappedStringForString("
Authors", ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
65 | header.setFont(new Font(header.getFont().getName(), Font.BOLD, 12));
66 | this.add(header);
67 |
68 | //Add authors
69 | for (GearSpecAuthor author : selectedSpec.getAuthors()) {
70 | JLabel authorLabel = new JLabel(Utils.wrappedStringForString(author.getName() + " - " + author.getEmail(), ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
71 | authorLabel.setFont(new Font(authorLabel.getFont().getName(), Font.PLAIN, 12));
72 | this.add(authorLabel);
73 | }
74 | }
75 |
76 | //Add Dependencies
77 | if (selectedSpec.getDependencies() != null) {
78 | //Add header
79 | JLabel header = new JLabel(Utils.wrappedStringForString("
Dependencies", ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
80 | header.setFont(new Font(header.getFont().getName(), Font.BOLD, 12));
81 | this.add(header);
82 |
83 | //Add authors
84 | for (GearSpecDependency dependency : selectedSpec.getDependencies()) {
85 | JLabel authorLabel = new JLabel(Utils.wrappedStringForString(dependency.getName() + " - " + dependency.getVersion(), ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
86 | authorLabel.setFont(new Font(authorLabel.getFont().getName(), Font.PLAIN, 12));
87 | this.add(authorLabel);
88 | }
89 | }
90 |
91 | //Add License
92 | if (selectedSpec.getLicense() != null) {
93 | //Add header
94 | JLabel header = new JLabel(Utils.wrappedStringForString("
License", ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
95 | header.setFont(new Font(header.getFont().getName(), Font.BOLD, 12));
96 | this.add(header);
97 |
98 | //Add license
99 | JLabel licenseLabel = new JLabel(selectedSpec.getLicense(), JLabel.LEFT);
100 | licenseLabel.setFont(new Font(licenseLabel.getFont().getName(), Font.PLAIN, 12));
101 | this.add(licenseLabel);
102 | }
103 |
104 | //Add Copyright
105 | if (selectedSpec.getCopyright() != null) {
106 | //Add header
107 | JLabel header = new JLabel(Utils.wrappedStringForString("
Copyright", ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
108 | header.setFont(new Font(header.getFont().getName(), Font.BOLD, 12));
109 | this.add(header);
110 |
111 | //Add copyright
112 | JLabel copyrightLabel = new JLabel(selectedSpec.getCopyright(), JLabel.LEFT);
113 | copyrightLabel.setFont(new Font(copyrightLabel.getFont().getName(), Font.PLAIN, 12));
114 | this.add(copyrightLabel);
115 | }
116 |
117 | //Add homepage
118 | /*
119 | if (selectedSpec.getHomepage() != null) {
120 | //Add header
121 | JLabel header = new JLabel(Utils.wrappedStringForString("
Homepage", ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
122 | header.setFont(new Font(header.getFont().getName(), Font.BOLD, 12));
123 | this.add(header);
124 |
125 | //Add homepage
126 | JLabel homepageLabel = new JLabel(Utils.wrappedStringForString(selectedSpec.getHomepage(), ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
127 | homepageLabel.setMaximumSize(new Dimension(ManageAndroidGearsForm.DETAILS_INNER_WIDTH, 30));
128 | homepageLabel.setFont(new Font(homepageLabel.getFont().getName(), Font.PLAIN, 12));
129 | this.add(homepageLabel);
130 |
131 |
132 | }*/
133 |
134 | //Add Tags
135 | if (selectedSpec.getTags() != null) {
136 | //Add header
137 | JLabel header = new JLabel(Utils.wrappedStringForString("
Tags", ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
138 | header.setFont(new Font(header.getFont().getName(), Font.BOLD, 12));
139 | this.add(header);
140 |
141 | //Gather tags
142 | String tagsString = "";
143 | for (String tag : selectedSpec.getTags()) {
144 | tagsString = tagsString+tag+", ";
145 | }
146 | if (tagsString.length() > 2){
147 | tagsString = tagsString.substring(0, tagsString.length()-2);
148 | }
149 |
150 | //Create tags label
151 | JLabel tagsLabel = new JLabel(Utils.wrappedStringForString(tagsString, ManageAndroidGearsForm.DETAILS_INNER_WIDTH), JLabel.LEFT);
152 | tagsLabel.setFont(new Font(tagsLabel.getFont().getName(), Font.PLAIN, 12));
153 | this.add(tagsLabel);
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/AndroidGears/src/ProjectSettingsComponent.java:
--------------------------------------------------------------------------------
1 | import Singletons.SettingsManager;
2 | import Workers.Git.IgnoreCheckWorker;
3 | import Workers.Sync.SyncGears;
4 | import com.intellij.openapi.components.ProjectComponent;
5 | import com.intellij.openapi.module.Module;
6 | import com.intellij.openapi.module.ModuleManager;
7 | import com.intellij.openapi.project.Project;
8 | import com.intellij.openapi.project.ProjectManager;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | /**
12 | * Created by matthewyork on 4/8/14.
13 | */
14 | public class ProjectSettingsComponent implements ProjectComponent {
15 | public ProjectSettingsComponent(Project project) {
16 | }
17 |
18 | public void initComponent() {
19 |
20 | }
21 |
22 | public void disposeComponent() {
23 | // TODO: insert component disposal logic here
24 | }
25 |
26 | @NotNull
27 | public String getComponentName() {
28 | return "ProjectSettingsComponent";
29 | }
30 |
31 | public void projectOpened() {
32 | //Puts an entry in the ignore file, if you have such
33 | IgnoreCheckWorker ignoreCheckWorker = new IgnoreCheckWorker(){
34 |
35 | };
36 | ignoreCheckWorker.execute();
37 |
38 | //Auto-sync
39 | syncGears();
40 | }
41 |
42 | public void projectClosed() {
43 | // called when project is being closed
44 | }
45 |
46 | private void syncGears(){
47 | //Load settings
48 | SettingsManager.getInstance().loadSettings();
49 |
50 | //Get all projects
51 | ProjectManager pm = ProjectManager.getInstance();
52 | Project[] targetProjects = pm.getOpenProjects();
53 | Project p = targetProjects[0];
54 |
55 | //Load project settings
56 | SettingsManager.getInstance().loadProjectSettings(p);
57 |
58 | //Get all modules
59 | ModuleManager mm = ModuleManager.getInstance(p);
60 | Module[] targetModules = mm.getModules();
61 |
62 | //Get main module
63 | String mainModule = SettingsManager.getInstance().getMainModule();
64 |
65 | if (!mainModule.equals("")){
66 | //Find the module object from module name
67 | for (int ii = 0; ii < targetModules.length; ii++){
68 | //If module name matches target module, sync
69 | if (targetModules[ii].getName().equals(mainModule)){
70 |
71 | //Sync gears
72 | if (SettingsManager.getInstance().getAutoSync()){
73 | SyncGears syncWorker = new SyncGears(p, targetModules[ii]){
74 | @Override
75 | protected void done() {
76 | super.done();
77 |
78 | //Possibly show toast here...
79 | }
80 | };
81 | syncWorker.execute();
82 | }
83 |
84 | break;
85 | }
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/AndroidGears/src/Renderers/GearSpecCellRenderer.java:
--------------------------------------------------------------------------------
1 | package Renderers;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 |
6 | import javax.swing.*;
7 | import javax.swing.border.EmptyBorder;
8 | import java.awt.*;
9 |
10 | /**
11 | * Created by matthewyork on 4/1/14.
12 | */
13 |
14 | public class GearSpecCellRenderer extends JPanel implements ListCellRenderer {
15 | private static final Color HIGHLIGHT_COLOR = Color.decode("0x2B2B2B");
16 | private Color cellBackgroundColor = null;
17 |
18 | JPanel specInfoPanel;
19 | JLabel nameLabel;
20 | JLabel authorLabel;
21 | JLabel imageLabel;
22 | //JLabel jarLabel;
23 | ImageIcon declaredIcon = new ImageIcon(getClass().getResource("GearStateDeclared.png"));
24 | ImageIcon installedIcon = new ImageIcon(getClass().getResource("GearStateInstalled.png"));
25 | //ImageIcon jarfile = new ImageIcon(getClass().getResource("jarfile.png"));
26 |
27 | public GearSpecCellRenderer() {
28 | setOpaque(true);
29 | cellBackgroundColor = getBackground();
30 | }
31 |
32 | public Component getListCellRendererComponent(
33 | JList list,
34 | Object value,
35 | int index,
36 | boolean isSelected,
37 | boolean cellHasFocus)
38 | {
39 | GearSpec spec = (GearSpec)value;
40 |
41 | //Check for first runthrough
42 | if(nameLabel == null){
43 | //Initialize name panel
44 | this.setLayout(new BorderLayout());
45 | this.setBorder(new EmptyBorder(10,10,10,10));
46 | specInfoPanel = new JPanel();
47 | specInfoPanel.setLayout(new BoxLayout(specInfoPanel, BoxLayout.Y_AXIS));
48 | specInfoPanel.setOpaque(false);
49 |
50 | //Set name label
51 | nameLabel = new JLabel(spec.getName(), JLabel.LEFT);
52 | nameLabel.setFont(new Font(nameLabel.getFont().getName(), Font.PLAIN, 18));
53 |
54 | //Set author label
55 | authorLabel = new JLabel("", JLabel.LEFT);
56 | authorLabel.setFont(new Font(authorLabel.getFont().getName(), Font.PLAIN, 12));
57 |
58 | //Iterate over all authors for matches
59 | if (spec.getAuthors() != null){
60 | String authors = "";
61 | for (GearSpecAuthor author : spec.getAuthors()){
62 | authors = authors+author.getName()+", ";
63 | }
64 | //Remove last comma/space
65 | authors = authors.substring(0, authors.length()-2);
66 |
67 | //Set label text
68 | authorLabel.setText(authors);
69 | }
70 |
71 | //Set image
72 | imageLabel = new JLabel();
73 | //Set image
74 | switch (spec.getGearState().ordinal()){
75 | case 0: imageLabel.setIcon(new ImageIcon());
76 | break;
77 | case 1: imageLabel.setIcon(declaredIcon);
78 | break;
79 | case 2: imageLabel.setIcon(installedIcon);
80 | break;
81 | }
82 |
83 |
84 | //set jar image
85 | /*
86 | jarLabel = new JLabel();
87 | if(spec.getType().equals("jar")){
88 | jarLabel.setIcon(jarfile);
89 | }else{
90 | jarLabel.setIcon(new ImageIcon());
91 | }*/
92 |
93 |
94 | //Add components
95 | this.add(specInfoPanel, BorderLayout.WEST);
96 | specInfoPanel.add(nameLabel);
97 | specInfoPanel.add(authorLabel);
98 | this.add(imageLabel, BorderLayout.EAST);
99 | //this.add(jarLabel,BorderLayout.CENTER);
100 | }
101 | else {
102 | //Set name label
103 | nameLabel.setText(spec.getName());
104 |
105 | //Set author label
106 | if (spec.getAuthors() != null){
107 | String authors = "";
108 | for (GearSpecAuthor author : spec.getAuthors()){
109 | authors = authors+author.getName()+", ";
110 | }
111 | //Remove last comma/space
112 | authors = authors.substring(0, authors.length()-2);
113 |
114 | //Set label text
115 | authorLabel.setText(authors);
116 | }
117 |
118 | //Set image
119 | switch (spec.getGearState().ordinal()){
120 | case 0: imageLabel.setIcon(new ImageIcon());
121 | break;
122 | case 1: imageLabel.setIcon(declaredIcon);
123 | break;
124 | case 2: imageLabel.setIcon(installedIcon);
125 | break;
126 | }
127 | //set if jar
128 | /*
129 | if(spec.getType().equals("jar")){
130 | jarLabel.setIcon(jarfile);
131 | }else{
132 | jarLabel.setIcon(new ImageIcon());
133 | }*/
134 | }
135 |
136 | if(isSelected) {
137 | setBackground(cellBackgroundColor.darker());
138 | setOpaque(true);
139 | //setForeground(Color.white);
140 | } else {
141 | setOpaque(false);
142 | //setForeground(Color.black);
143 | }
144 | return this;
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/AndroidGears/src/Renderers/GearStateDeclared.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/src/Renderers/GearStateDeclared.png
--------------------------------------------------------------------------------
/AndroidGears/src/Renderers/GearStateInstalled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/src/Renderers/GearStateInstalled.png
--------------------------------------------------------------------------------
/AndroidGears/src/Renderers/ModuleCellRenderer.java:
--------------------------------------------------------------------------------
1 | package Renderers;
2 |
3 | import com.intellij.openapi.module.Module;
4 | import com.intellij.openapi.project.Project;
5 |
6 | import javax.swing.*;
7 | import java.awt.*;
8 |
9 | /**
10 | * Created by matthewyork on 4/7/14.
11 | */
12 | public class ModuleCellRenderer extends JPanel implements ListCellRenderer {
13 | private static final Color HIGHLIGHT_COLOR = Color.decode("0x2B2B2B");
14 | private Color cellBackgroundColor = null;
15 |
16 | JLabel nameLabel;
17 |
18 | public ModuleCellRenderer() {
19 | setOpaque(true);
20 | cellBackgroundColor = getBackground();
21 | }
22 |
23 | public Component getListCellRendererComponent(
24 | JList list,
25 | Object value,
26 | int index,
27 | boolean isSelected,
28 | boolean cellHasFocus)
29 | {
30 | Module module = (Module)value;
31 |
32 | //Check for first runthrough
33 | if(nameLabel == null){
34 | //Initialize name panel
35 | this.setLayout(new FlowLayout());
36 |
37 | //Set layout
38 | this.setLayout(new FlowLayout(FlowLayout.LEFT));
39 |
40 | //Set name label
41 | nameLabel = new JLabel(module.getName(), JLabel.LEFT);
42 | //nameLabel.setFont(new Font(nameLabel.getFont().getName(), Font.PLAIN, 18));
43 |
44 |
45 |
46 | //Add components
47 | this.add(nameLabel);
48 | }
49 | else {
50 | //Set name label
51 | nameLabel.setText(module.getName());
52 | }
53 |
54 | if(isSelected) {
55 | setBackground(cellBackgroundColor.darker());
56 | setOpaque(true);
57 | //setForeground(Color.white);
58 | } else {
59 | setOpaque(false);
60 | //setForeground(Color.black);
61 | }
62 | return this;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/AndroidGears/src/Renderers/ProjectCellRenderer.java:
--------------------------------------------------------------------------------
1 | package Renderers;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 | import com.intellij.openapi.project.Project;
6 |
7 | import javax.swing.*;
8 | import java.awt.*;
9 |
10 | /**
11 | * Created by matthewyork on 4/5/14.
12 | */
13 |
14 | public class ProjectCellRenderer extends JPanel implements ListCellRenderer {
15 | private static final Color HIGHLIGHT_COLOR = Color.decode("0x2B2B2B");
16 | private Color cellBackgroundColor = null;
17 |
18 | JLabel nameLabel;
19 |
20 | public ProjectCellRenderer() {
21 | setOpaque(true);
22 | cellBackgroundColor = getBackground();
23 | }
24 |
25 | public Component getListCellRendererComponent(
26 | JList list,
27 | Object value,
28 | int index,
29 | boolean isSelected,
30 | boolean cellHasFocus)
31 | {
32 | Project project = (Project)value;
33 |
34 | //Check for first runthrough
35 | if(nameLabel == null){
36 | //Initialize name panel
37 | this.setLayout(new FlowLayout());
38 |
39 | //Set layout
40 | this.setLayout(new FlowLayout(FlowLayout.LEFT));
41 |
42 | //Set name label
43 | nameLabel = new JLabel(project.getName(), JLabel.LEFT);
44 | //nameLabel.setFont(new Font(nameLabel.getFont().getName(), Font.PLAIN, 18));
45 |
46 |
47 |
48 | //Add components
49 | this.add(nameLabel);
50 | }
51 | else {
52 | //Set name label
53 | nameLabel.setText(project.getName());
54 | }
55 |
56 | if(isSelected) {
57 | setBackground(cellBackgroundColor.darker());
58 | setOpaque(true);
59 | //setForeground(Color.white);
60 | } else {
61 | setOpaque(false);
62 | //setForeground(Color.black);
63 | }
64 | return this;
65 | }
66 | }
--------------------------------------------------------------------------------
/AndroidGears/src/Renderers/jarfile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidGears/Plugin/015082ef2e3a17191dd0b3808347a97fe719ef73/AndroidGears/src/Renderers/jarfile.png
--------------------------------------------------------------------------------
/AndroidGears/src/Services/AutoCompleteSerivce/AutoCompleteDocument.java:
--------------------------------------------------------------------------------
1 | package Services.AutoCompleteSerivce;
2 |
3 | /**
4 | * Created by aaronfleshner on 4/27/14.
5 | */
6 |
7 | import javax.swing.text.AttributeSet;
8 | import javax.swing.text.BadLocationException;
9 | import javax.swing.text.Document;
10 | import javax.swing.text.JTextComponent;
11 | import javax.swing.text.PlainDocument;
12 |
13 | /**
14 | * A {@link Document} performing auto completion on the inserted text. This
15 | * document can be used on any {@link JTextComponent}.
16 | *
17 | * The completion will only happen for inserts, that is, when characters are
18 | * typed. If characters are erased, no new completion is suggested until a new
19 | * character is typed.
20 | *
21 | * @author Samuel Sjoberg, http://samuelsjoberg.com
22 | * @version 1.0.0
23 | * @see CompletionService
24 | */
25 | public class AutoCompleteDocument extends PlainDocument {
26 |
27 | /**
28 | * Default serial version UID.
29 | */
30 | private static final long serialVersionUID = 1L;
31 |
32 | /**
33 | * Completion service.
34 | */
35 | private CompletionService> completionService;
36 |
37 | /**
38 | * The document owner.
39 | */
40 | private JTextComponent documentOwner;
41 |
42 | /**
43 | * Create a new AutoCompletionDocument
.
44 | *
45 | * @param service the service to use when searching for completions
46 | * @param documentOwner the document owner
47 | */
48 | public AutoCompleteDocument(CompletionService> service,
49 | JTextComponent documentOwner) {
50 | this.completionService = service;
51 | this.documentOwner = documentOwner;
52 | }
53 |
54 | /**
55 | * Look up the completion string.
56 | *
57 | * @param str the prefix string to complete
58 | * @return the completion or null
if completion was found.
59 | */
60 | protected String complete(String str) {
61 | Object o = completionService.autoComplete(str);
62 | return o == null ? null : o.toString();
63 | }
64 |
65 | /**
66 | * {@inheritDoc}
67 | */
68 | @Override
69 | public void insertString(int offs, String str, AttributeSet a)
70 | throws BadLocationException {
71 | if (str == null || str.length() == 0) {
72 | return;
73 | }
74 |
75 | String text = getText(0, offs); // Current text.
76 | String completion = complete(text + str);
77 | int length = offs + str.length();
78 | if (completion != null && text.length() > 0) {
79 | str = completion.substring(length - 1);
80 | super.insertString(offs, str, a);
81 | documentOwner.select(length, getLength());
82 | } else {
83 | super.insertString(offs, str, a);
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/AndroidGears/src/Services/AutoCompleteSerivce/CompletionService.java:
--------------------------------------------------------------------------------
1 | package Services.AutoCompleteSerivce;
2 |
3 | /**
4 | * Created by aaronfleshner on 4/27/14.
5 | */
6 | /**
7 | * A service providing autocompletion support.
8 | *
9 | * @see AutoCompleteDocument
10 | *
11 | * @author Samuel Sjoberg, http://samuelsjoberg.com
12 | * @version 1.0.0
13 | *
14 | * @param
15 | * the type to be returned by the service
16 | */
17 | public interface CompletionService {
18 |
19 | /**
20 | * Autocomplete the passed string. The method will return the matching
21 | * object when one single object matches the search criteria. As long as
22 | * multiple objects stored in the service matches, the method will return
23 | * null
.
24 | *
25 | * @param startsWith
26 | * prefix string
27 | * @return the matching object or null
if multiple matches are
28 | * found.
29 | */
30 | T autoComplete(String startsWith);
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/AndroidGears/src/Services/AutoCompleteSerivce/GearsService.java:
--------------------------------------------------------------------------------
1 | package Services.AutoCompleteSerivce;
2 |
3 | import Workers.GetAllSpecsListWorker;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by aaronfleshner on 4/27/14.
9 | */
10 | public class GearsService implements CompletionService {
11 |
12 | /** Our name data. */
13 | private List data;
14 |
15 | /**
16 | * Create a new NameService
and populate it.
17 | */
18 | public GearsService() {
19 | getSpecs();
20 | }
21 |
22 | /** {@inheritDoc} */
23 | @Override
24 | public String toString() {
25 | StringBuilder b = new StringBuilder();
26 | for (String o : data) {
27 | b.append(o).append("\n");
28 | }
29 | return b.toString();
30 | }
31 |
32 | /** {@inheritDoc} */
33 | public String autoComplete(String startsWith) {
34 | startsWith = startsWith.toLowerCase();
35 |
36 | // Naive implementation, but good enough for the sample
37 | String hit = null;
38 | for (String o : data) {
39 | if (o.toLowerCase().startsWith(startsWith)) {
40 | // CompletionService contract states that we only
41 | // should return completion for unique hits.
42 | if (hit == null) {
43 | hit = o;
44 | } else {
45 | hit = null;
46 | break;
47 | }
48 | }
49 | }
50 | return hit;
51 | }
52 |
53 | private void getSpecs() {
54 | //Get availableGears and reload
55 | GetAllSpecsListWorker worker = new GetAllSpecsListWorker() {
56 | @Override
57 | protected void done() {
58 | super.done();
59 | data = this.specNames;
60 | }
61 | };
62 | worker.execute();
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/AndroidGears/src/Singletons/SettingsManager.java:
--------------------------------------------------------------------------------
1 | package Singletons;
2 |
3 | import Models.GearSpecRegister.GearSpecRegister;
4 | import Models.Settings.GearSpecSettings;
5 | import Models.Settings.ProjectSettings;
6 | import Utilities.OSValidator;
7 | import Utilities.Utils;
8 | import com.google.gson.Gson;
9 | import com.google.gson.GsonBuilder;
10 | import com.intellij.openapi.project.Project;
11 | import com.intellij.openapi.project.ProjectManager;
12 | import org.apache.commons.io.FileUtils;
13 |
14 | import javax.swing.*;
15 | import java.io.File;
16 | import java.io.IOException;
17 |
18 | /**
19 | * Created by matthewyork on 4/6/14.
20 | */
21 | public class SettingsManager {
22 | //Singleton instance for settings
23 | private static SettingsManager settingsManager;
24 | private Project[] targetProjects;
25 | private static String IGNORE_STRING = Utils.newLine()+Utils.newLine()+"#Android Gears"+Utils.newLine()+"Gears/";
26 | private static String IGNORE_COMMENT_STRING = "#Android Gears";
27 | private static String IGNORE_CONTENT_STRING = "Gears/";
28 |
29 | //Project Settings
30 | private ProjectSettings projectSettings = new ProjectSettings();
31 |
32 | private GearSpecSettings settings = new GearSpecSettings();
33 |
34 | protected SettingsManager() {
35 |
36 | }
37 |
38 | public static SettingsManager getInstance() {
39 | if (settingsManager == null) {
40 | settingsManager = new SettingsManager();
41 | }
42 |
43 | return settingsManager;
44 | }
45 |
46 | ///////////////////////
47 | // Loading / Saving
48 | ///////////////////////
49 |
50 | public Boolean loadSettings(){
51 |
52 | //Get settings file
53 | File settingsFile = new File(Utils.getDefaultDirectory().getAbsolutePath()+Utils.pathSeparator()+".gearssettings");
54 |
55 | if (settingsFile.exists()){
56 | //Create new Gson instance for use
57 | Gson gson = new Gson();
58 |
59 | String settingsString = null;
60 | try {
61 | settingsString = FileUtils.readFileToString(settingsFile);
62 | } catch (IOException e) {
63 | e.printStackTrace();
64 | return false;
65 | }
66 |
67 | //Load file into settings
68 | this.settings = new Gson().fromJson(settingsString, GearSpecSettings.class);
69 |
70 | }
71 | else {
72 | //Save a new default copy of the settings
73 | saveSettings();
74 | }
75 |
76 | return true;
77 | }
78 |
79 | public Boolean saveSettings(){
80 |
81 |
82 | //Get settings file
83 | File settingsFile = new File(Utils.getDefaultDirectory().getAbsolutePath()+Utils.pathSeparator()+".gearssettings");
84 |
85 | //Create new Gson instance for use
86 | Gson gson = new GsonBuilder().setPrettyPrinting().create();
87 |
88 | try {
89 | //Delete the settings, if they exist
90 | if (settingsFile.exists()){
91 | FileUtils.forceDelete(settingsFile);
92 | }
93 |
94 | //Write settings to file
95 | FileUtils.write(settingsFile, gson.toJson(settings));
96 | } catch (IOException e) {
97 | e.printStackTrace();
98 | return false;
99 | }
100 |
101 | return true;
102 | }
103 |
104 | public Boolean loadProjectSettings(Project project){
105 | //Get settings file
106 | File settingsFile = new File(project.getBasePath()+"/.gearsproject");
107 |
108 | if (settingsFile.exists()){
109 | //Create new Gson instance for use
110 | Gson gson = new Gson();
111 |
112 | String settingsString = null;
113 | try {
114 | settingsString = FileUtils.readFileToString(settingsFile);
115 | } catch (IOException e) {
116 | e.printStackTrace();
117 | return false;
118 | }
119 |
120 | //Load file into settings
121 | this.projectSettings = new Gson().fromJson(settingsString, ProjectSettings.class);
122 |
123 | }
124 |
125 | return true;
126 | }
127 |
128 | public Boolean saveProjectSettings(Project project){
129 | //Get settings file
130 | File settingsFile = new File(project.getBasePath()+"/.gearsproject");
131 |
132 | //Create new Gson instance for use
133 | Gson gson = new GsonBuilder().setPrettyPrinting().create();
134 |
135 | try {
136 | //Delete the settings, if they exist
137 | if (settingsFile.exists()){
138 | FileUtils.forceDelete(settingsFile);
139 | }
140 |
141 | //Write settings to file
142 | FileUtils.write(settingsFile, gson.toJson(projectSettings));
143 | } catch (IOException e) {
144 | e.printStackTrace();
145 | return false;
146 | }
147 |
148 | return true;
149 | }
150 |
151 | ///////////////////////
152 | // Auto Ignore
153 | ///////////////////////
154 |
155 | public Boolean getAutoIgnore(){
156 | return settings.autoIgnore;
157 | }
158 |
159 | public Boolean setCreateIgnore(boolean createIgnore){
160 |
161 |
162 | /*
163 | if (autoIgnore == true){
164 | if (addIgnoreEntry()){
165 | //showAddedIgnoreDialog(panel);
166 | }
167 | else {
168 | showFailedToAddIgnoreDialog(panel);
169 | }
170 | }
171 | else {
172 | if (removeIgnoreEntry()){
173 | showRemovedIgnoreDialog(panel);
174 | }
175 | else {
176 | showFailedToRemoveIgnoreDialog(panel);
177 | }
178 | }
179 |
180 | return true;*/
181 |
182 | //Set setting
183 | if (createIgnore){
184 | if (addIgnoreEntry()){
185 | settings.autoIgnore = createIgnore;
186 | saveSettings();
187 | return true;
188 | }
189 | }
190 | else {
191 | if (removeIgnoreEntry()){
192 | settings.autoIgnore = createIgnore;
193 | saveSettings();
194 | return true;
195 | }
196 | }
197 |
198 | return false;
199 | }
200 |
201 | public Boolean ignoreExists(){
202 |
203 | ProjectManager pm = ProjectManager.getInstance();
204 | targetProjects = pm.getOpenProjects();
205 |
206 | if (targetProjects.length > 0){
207 | Project project = targetProjects[0];
208 |
209 | //Get ignore file
210 | File ignoreFile = new File(project.getBasePath()+ Utils.pathSeparator()+".gitignore");
211 |
212 | if (ignoreFile.exists()){
213 | try {
214 | //Read back ignore file
215 | String ignoreFileString = FileUtils.readFileToString(ignoreFile);
216 |
217 | //Return true if it exists
218 | return ignoreFileString.contains(IGNORE_STRING);
219 | } catch (IOException e) {
220 | e.printStackTrace();
221 | return false;
222 | }
223 | }
224 | else {
225 | if (createIgnore(ignoreFile)){
226 | return true;
227 | }
228 | }
229 | }
230 |
231 | return false;
232 | }
233 |
234 | private Boolean addIgnoreEntry(){
235 | ProjectManager pm = ProjectManager.getInstance();
236 | targetProjects = pm.getOpenProjects();
237 |
238 | if (targetProjects.length > 0){
239 | Project project = targetProjects[0];
240 |
241 | //Get ignore file
242 | File gitignore = new File(project.getBasePath()+ Utils.pathSeparator()+".gitignore");
243 | File hgignoreFile = new File(project.getBasePath()+ Utils.pathSeparator()+".hgignore");
244 | File ignoreFile =null;
245 |
246 | //Find valid ignore file
247 | if (gitignore.exists()){
248 | ignoreFile = gitignore;
249 | }
250 | else if (hgignoreFile.exists()){
251 | ignoreFile = hgignoreFile;
252 | }
253 |
254 | if (ignoreFile.exists()){
255 | try {
256 | //Read back ignore file
257 | String ignoreFileString = FileUtils.readFileToString(ignoreFile);
258 |
259 | //Check if it exists already. If it does, we're good
260 | if (!ignoreFileString.contains(IGNORE_COMMENT_STRING) && !ignoreFileString.contains(IGNORE_CONTENT_STRING)){
261 | //Add entry
262 | ignoreFileString = ignoreFileString+IGNORE_STRING;
263 |
264 | //Write back changes to gitignore
265 | FileUtils.forceDelete(ignoreFile);
266 | FileUtils.write(ignoreFile, ignoreFileString);
267 | }
268 |
269 | return true;
270 | } catch (IOException e) {
271 | e.printStackTrace();
272 | return false;
273 | }
274 | }
275 | else {
276 | //If no gitignore exists, create one!
277 | if (createIgnore(gitignore)){
278 | return true;
279 | }
280 | }
281 | }
282 |
283 | return true;
284 | }
285 |
286 | private Boolean removeIgnoreEntry(){
287 | ProjectManager pm = ProjectManager.getInstance();
288 | targetProjects = pm.getOpenProjects();
289 |
290 | if (targetProjects.length > 0){
291 | Project project = targetProjects[0];
292 |
293 | //Get ignore file
294 | File gitignore = new File(project.getBasePath()+ Utils.pathSeparator()+".gitignore");
295 | File hgignoreFile = new File(project.getBasePath()+ Utils.pathSeparator()+".hgignore");
296 | File ignoreFile =null;
297 |
298 | //Find valid ignore file
299 | if (gitignore.exists()){
300 | ignoreFile = gitignore;
301 | }
302 | else if (hgignoreFile.exists()){
303 | ignoreFile = hgignoreFile;
304 | }
305 |
306 | if (ignoreFile != null){
307 | try {
308 | //Read back ignore file
309 | String ignoreFileString = FileUtils.readFileToString(ignoreFile);
310 |
311 | //remove entry
312 | ignoreFileString = ignoreFileString.replace(IGNORE_COMMENT_STRING, "");
313 | ignoreFileString = ignoreFileString.replace(IGNORE_CONTENT_STRING, "");
314 |
315 | //Write back changes to gitignore
316 | FileUtils.forceDelete(ignoreFile);
317 | FileUtils.write(ignoreFile, ignoreFileString);
318 | } catch (IOException e) {
319 | e.printStackTrace();
320 | return false;
321 | }
322 | }
323 | else {
324 | if (createIgnore(ignoreFile)){
325 | return true;
326 | }
327 | }
328 | }
329 |
330 | return true;
331 | }
332 |
333 | private Boolean createIgnore(File ignoreFile){
334 | try {
335 | //Delete the settings, if they exist
336 | if (ignoreFile.exists()){
337 | FileUtils.forceDelete(ignoreFile);
338 | }
339 |
340 | //Write settings to file
341 | FileUtils.write(ignoreFile, IGNORE_STRING);
342 | } catch (IOException e) {
343 | e.printStackTrace();
344 | return false;
345 | }
346 |
347 | return true;
348 | }
349 |
350 | ///////////////////////
351 | // Auto Sync
352 | ///////////////////////
353 |
354 | public Boolean getAutoSync(){
355 | return this.settings.autosyncGears;
356 | }
357 |
358 | public Boolean setAutoSync(Boolean autoSync){
359 | this.settings.autosyncGears = autoSync;
360 |
361 | return saveSettings();
362 | }
363 |
364 | ///////////////////////
365 | // Modules
366 | ///////////////////////
367 |
368 | public String getMainModule(){
369 | if (projectSettings != null){
370 | if (projectSettings.mainModule != null){
371 | return projectSettings.mainModule;
372 | }
373 | }
374 |
375 | return "";
376 | }
377 |
378 | public void setMainModule(String mainModule, Project project){
379 | if (mainModule != null){
380 | if (projectSettings != null){
381 | projectSettings.mainModule = mainModule;
382 | }
383 | saveProjectSettings(project);
384 | }
385 | }
386 |
387 | ///////////////////////
388 | // Spec Repository Path
389 | ///////////////////////
390 |
391 | public String getSpecsPath(){
392 | if (this.settings.specsPath == null){
393 | this.settings.specsPath = Utils.getDefaultDirectory().getAbsolutePath();
394 | saveSettings();
395 | }
396 |
397 | return this.settings.specsPath;
398 | }
399 |
400 | public void setSpecsPath(String path){
401 | if (path != null){
402 | this.settings.specsPath = path;
403 | saveSettings();
404 | }
405 | }
406 | }
407 |
408 |
--------------------------------------------------------------------------------
/AndroidGears/src/Utilities/GearSpecLinter.java:
--------------------------------------------------------------------------------
1 | package Utilities;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 | import Models.GearSpec.GearSpecDependency;
6 | import Models.GearSpecLinter.GearSpecLintResult;
7 | import Workers.Lint.LintGearSpecWorker;
8 | import org.apache.commons.io.FilenameUtils;
9 |
10 | import java.io.File;
11 | import java.util.ArrayList;
12 | import java.util.regex.Matcher;
13 | import java.util.regex.Pattern;
14 |
15 | /**
16 | * Created by matthewyork on 4/3/14.
17 | */
18 | public class GearSpecLinter {
19 | public static GearSpecLintResult lintSpec(GearSpec spec, LintGearSpecWorker worker){
20 |
21 | ArrayList failureReasons = new ArrayList();
22 | ArrayList successReasons = new ArrayList();
23 |
24 | //Check for spec existence
25 | if(spec == null){
26 | failureReasons.add("Spec file could not be linted either because it was not found or because of invalid syntax.\n Consider reviewing/linting your JSON syntax. http://jsonlint.com/\n For best results, use the \"Create Gear Spec\" utility in the Android Gears menu.");
27 | }
28 | else {
29 | successReasons.add("Spec correctly parsed from JSON.");
30 |
31 | //Check for name
32 | if (!existsAndNotBlank(spec.getName())){
33 | failureReasons.add("Spec must have a name.");
34 | }
35 | else {
36 | successReasons.add("Spec has valid name.");
37 | }
38 | //Check for summary
39 | if (!existsAndNotBlank(spec.getSummary())){
40 | failureReasons.add("Spec must have a summary.");
41 | }
42 | else {
43 | successReasons.add("Spec has valid summary.");
44 | }
45 | //Check for version
46 | if (!existsAndNotBlank(spec.getVersion())){
47 | failureReasons.add("Spec must have a version.");
48 | }
49 | else {
50 | if (checkVersionFormat(spec.getVersion())){
51 | successReasons.add("Spec has valid version number.");
52 | }
53 | else {
54 | failureReasons.add("Spec must conform to semantic versioning (i.e 1.1.0 or 42.23.19).");
55 | }
56 | }
57 | //Check for type
58 | if (!existsAndNotBlank(spec.getType())){
59 | failureReasons.add("Spec must have a type. (module or jar)");
60 | }
61 | else if (!spec.getType().equals("module") && !spec.getType().equals("jar")){
62 | failureReasons.add("Spec must be of type \"module\" or \"jar\". The type is case sensitive.");
63 | }
64 | else {
65 | successReasons.add("Spec has valid type.");
66 | }
67 | //Check for copyright
68 | if (!existsAndNotBlank(spec.getCopyright())){
69 | failureReasons.add("Spec must have a copyright.");
70 | }
71 | else {
72 | successReasons.add("Spec has valid copyright.");
73 | }
74 | //Check for homepage
75 | if (!existsAndNotBlank(spec.getHomepage())){
76 | failureReasons.add("Spec must have a homepage. If the project is hosted on github, use the projects github page (http://github.com/username/projectname)");
77 | }
78 | else {
79 | successReasons.add("Spec has valid homepage.");
80 | }
81 | //Check authors
82 | checkAuthors(spec, failureReasons, successReasons, worker);
83 |
84 | //Check for minimum api level
85 | if (spec.getMinimum_api() > 0){
86 | successReasons.add("Spec has valid api level.");
87 | }
88 | else {
89 | failureReasons.add("Spec must have a minimum api level above 0.");
90 | }
91 |
92 | //Check source
93 | checkSources(spec, failureReasons, successReasons, worker);
94 |
95 | //Check dependencies
96 | checkDependencies(spec, failureReasons, successReasons, worker);
97 | }
98 |
99 | //Return lint result
100 | if (failureReasons.size() > 0){
101 | return lintFailedForReason(failureReasons);
102 | }
103 | else {
104 | return lintPassed(successReasons);
105 | }
106 | }
107 |
108 | //////////////////////
109 | // Lint Helpers
110 | //////////////////////
111 |
112 | private static Boolean existsAndNotBlank(String string){
113 | if (string == null){
114 | return false;
115 | }
116 | else if (string.equals("")){
117 | return false;
118 | }
119 |
120 | return true;
121 | }
122 |
123 | private static Boolean checkVersionFormat(String string){
124 | String re1="(\\d+)"; // Integer Number 1
125 | String re2="(.)"; // Any Single Character 1
126 | String re3="(\\d+)"; // Integer Number 2
127 | String re4="(.)"; // Any Single Character 2
128 | String re5="(\\d+)"; // Integer Number 3
129 |
130 | Pattern p = Pattern.compile(re1+re2+re3+re4+re5,Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
131 | Matcher m = p.matcher(string);
132 |
133 | return m.matches();
134 | }
135 |
136 | private static void checkAuthors(GearSpec spec, ArrayList failureReasons, ArrayList successReasons, LintGearSpecWorker worker){
137 | if (spec.getAuthors() == null){
138 | failureReasons.add("Spec must have at least one author.");
139 | }
140 | else if (spec.getAuthors().size() > 0){
141 | for (GearSpecAuthor author : spec.getAuthors()){
142 | if (!existsAndNotBlank(author.getName()) || !existsAndNotBlank(author.getEmail())){
143 | failureReasons.add("Spec authors must have a name and email.");
144 | }
145 | else {
146 | successReasons.add("Spec has valid author: "+author.getName());
147 | }
148 | }
149 | }
150 | else {
151 | failureReasons.add("Spec must have at least one author.");
152 | }
153 | }
154 |
155 | private static void checkSources(GearSpec spec, ArrayList failureReasons, ArrayList successReasons, LintGearSpecWorker worker){
156 | if (spec.getSource() == null){
157 | failureReasons.add("Spec must have a source.");
158 | }
159 | else {
160 | if (!existsAndNotBlank(spec.getSource().getUrl())){
161 | failureReasons.add("Spec source must have a url.");
162 | }
163 |
164 | //Do specific checks based on type
165 | if (spec.getType() != null){
166 | //If a module
167 | if (spec.getType().equals("module")){
168 | if (!existsAndNotBlank(spec.getSource().getTag())) {
169 | failureReasons.add("Spec of type module must provide a tag in the source.");
170 | return;
171 | }
172 | if (!spec.getSource().getUrl().contains(".git")){
173 | failureReasons.add("Spec of type module must have a url leading to a .git repository.");
174 | return;
175 | }
176 |
177 | successReasons.add("Spec has valid api level.");
178 | }
179 | //If jar
180 | else if (spec.getType().equals("jar")){
181 |
182 | //If the url is a .jar, parse other fields
183 | if (FilenameUtils.getExtension(spec.getSource().getUrl()).equals("jar")){
184 | if (spec.getSource().getTag() != null){
185 | failureReasons.add("Spec of type jar should have null \"tag\" field when pointing directly to a jar file.");
186 | }
187 | else if (spec.getSource().getSource_files() != null){
188 | failureReasons.add("Spec of type jar should have null \"source_files\" field when pointing directly to a jar file.");
189 | }
190 | else if (!Utils.ping(spec.getSource().getUrl(), 2000)){
191 | failureReasons.add("Spec source jar was not reachable. However, this could be due to your internet connection.");
192 | }
193 | return;
194 | }
195 | else if (FilenameUtils.getExtension(spec.getSource().getUrl()).equals("git")){
196 | if (spec.getSource().getTag() == null){
197 | failureReasons.add("Spec of type jar should have a \"tag\" field when pointing to a git repository.");
198 | }
199 | else if (spec.getSource().getSource_files() == null){
200 | failureReasons.add("Spec of type jar should have a \"source_files\" field when pointing to a git repository.");
201 | }
202 |
203 | String jarUrl = spec.getSource().getUrl()+"/raw/"+spec.getSource().getTag()+"/"+spec.getSource().getSource_files();
204 | jarUrl = jarUrl.replace(".git", "");
205 | if (!Utils.ping(jarUrl, 2000)){
206 | failureReasons.add("Spec source jar was not reachable for tag "+spec.getSource().getTag()+".\n However, this could be due to your internet connection.");
207 | }
208 | return;
209 | }
210 | //Else, check the url link for .jar extension
211 | else {
212 | failureReasons.add("Spec of type jar must point directly to a jar or a git repository (url ending in .git) which specifies a jar in the \"source_files\" field.");
213 | return;
214 | }
215 | }
216 | }
217 | }
218 | }
219 |
220 | private static void checkDependencies(GearSpec spec, ArrayList failureReasons, ArrayList successReasons, LintGearSpecWorker worker){
221 | if (spec.getDependencies() != null){
222 | if (spec.getDependencies().size() > 0){
223 | //Iterate over all dependencies, checking for valid dependencies
224 | for (GearSpecDependency dependency : spec.getDependencies()){
225 | if (!existsAndNotBlank(dependency.getName())){
226 | failureReasons.add("Spec dependencies must have a name.");
227 | }
228 | else if(!versionExistsForDependency(dependency)){
229 | failureReasons.add("Could not find dependency "+dependency.getName()+" for version "+dependency.getVersion()+"Consider syncing Android Gears to pull any new changes from the specNames repository.");
230 | }
231 | else {
232 | successReasons.add("Spec has valid dependency: "+dependency.getName());
233 | }
234 | }
235 | }
236 | }
237 | }
238 |
239 | private static Boolean versionExistsForDependency(GearSpecDependency dependency){
240 |
241 | File projectDirectory = new File(Utils.androidGearsDirectory()+Utils.pathSeparator()+dependency.getName());
242 | if(projectDirectory.isDirectory() && projectDirectory.exists()){
243 | //Get project versions
244 | String[] projectVersions = versionsForProject(dependency.getName());
245 |
246 | //If no version is specified in the dependency, and a version exists in the system, return true
247 | if (dependency.getVersion() == null && projectVersions.length > 0){
248 | return true;
249 | }
250 | else if (dependency.getVersion() == null && projectVersions.length == 0){ //Problem getting versions...
251 | return false;
252 | }
253 | else {
254 | //Look for specified version. If you find it, return true!
255 | for (String version : projectVersions){
256 | if (version.equals(dependency.getVersion())){
257 | return true;
258 | }
259 | }
260 | }
261 |
262 | }
263 |
264 | return false;
265 | }
266 |
267 | private static String[] versionsForProject(String project){
268 | File versionsDirectory = new File(Utils.androidGearsDirectory().getAbsolutePath()+Utils.pathSeparator()+project);
269 | return versionsDirectory.list();
270 | }
271 |
272 | //////////////////////
273 | // Lint Results
274 | //////////////////////
275 |
276 | private static GearSpecLintResult lintFailedForReason(ArrayList reasons){
277 |
278 | GearSpecLintResult result = new GearSpecLintResult();
279 | result.setPassed(false);
280 | result.setResponseMessage("Gear Spec lint failed:\n");
281 |
282 | //Show all error reasons
283 | for (String reason : reasons){
284 | result.setResponseMessage(result.getResponseMessage()+"\n - "+reason);
285 | }
286 |
287 | return result;
288 | }
289 |
290 | private static GearSpecLintResult lintPassed(ArrayList reasons){
291 |
292 | GearSpecLintResult result = new GearSpecLintResult();
293 | result.setPassed(true);
294 | result.setResponseMessage("Gear Spec lint passed:\n");
295 |
296 | //Show all error reasons
297 | for (String reason : reasons){
298 | result.setResponseMessage(result.getResponseMessage()+"\n - "+reason);
299 | }
300 |
301 | return result;
302 | }
303 |
304 | }
305 |
--------------------------------------------------------------------------------
/AndroidGears/src/Utilities/GearSpecRegistrar.java:
--------------------------------------------------------------------------------
1 | package Utilities;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpecRegister.GearSpecRegister;
5 | import com.google.gson.Gson;
6 | import com.google.gson.GsonBuilder;
7 | import com.intellij.openapi.project.Project;
8 | import org.apache.commons.io.FileUtils;
9 |
10 | import java.io.File;
11 | import java.io.IOException;
12 | import java.util.ArrayList;
13 |
14 | /**
15 | * Created by matthewyork on 4/5/14.
16 | */
17 | public class GearSpecRegistrar {
18 | public static Boolean registerGear(GearSpec spec, Project project, GearSpec.GearState gearState){
19 |
20 | //Get specregister file
21 | File registrationFile = new File(project.getBasePath()+Utils.pathSeparator()+"GearSpecRegister");
22 |
23 | //Create new Gson instance for use
24 | Gson gson = new GsonBuilder().setPrettyPrinting().create();
25 |
26 | //Create spec register
27 | GearSpecRegister register = null;
28 |
29 | //Set gear spec state
30 | spec.setGearState(gearState);
31 |
32 | //If the file exists, pull it back and add the dependency to it
33 | if (registrationFile.exists()){
34 | //Read back register from file
35 | String registerString;
36 | try {
37 | registerString = FileUtils.readFileToString(registrationFile);
38 | } catch (IOException e) {
39 | e.printStackTrace();
40 | return null;
41 | }
42 | register = gson.fromJson(registerString, GearSpecRegister.class);
43 |
44 | //Check for array existence for safety
45 | if (register.declaredGears == null){
46 | register.declaredGears = new ArrayList();
47 | }
48 |
49 | //Check for matches already in the register (say, if you are installing an already declared spec)
50 | boolean match = false;
51 | int matchIndex = -1;
52 | for(int ii = 0; ii < register.declaredGears.size(); ii++){
53 | GearSpec declaredGear = register.declaredGears.get(ii);
54 | //Check for exact match
55 | if (declaredGear.getName().equals(spec.getName()) && declaredGear.getVersion().equals(spec.getVersion())){
56 | //Flag a match
57 | match = true;
58 |
59 | //Make sure that the match reflect the most up to date spec state
60 | declaredGear.setGearState(Utils.specStateForSpec(declaredGear, project));
61 |
62 | break;
63 | }
64 | //Check for a possible new version coming in.
65 | else if (declaredGear.getName().equals(spec.getName())){
66 | //Flag a match
67 | match = true;
68 |
69 | //Set match index so you know which value to replace with updated spec
70 | matchIndex = ii;
71 | }
72 | }
73 |
74 | //Finally, add the installed gear
75 | if (!match){
76 | register.declaredGears.add(spec);
77 | }
78 | else{
79 | //Set the gear with the new version
80 | if (matchIndex > -1){
81 | register.declaredGears.set(matchIndex, spec);
82 | }
83 | }
84 | }
85 | else {
86 | //Create register and
87 | register = new GearSpecRegister();
88 | register.declaredGears = new ArrayList() {};
89 | register.declaredGears.add(spec);
90 | }
91 |
92 | //Write specNames to file
93 | try {
94 | FileUtils.write(getRegisterPath(project), gson.toJson(register));
95 | } catch (IOException e) {
96 | e.printStackTrace();
97 | return false;
98 | }
99 |
100 | return true;
101 | }
102 |
103 | public static Boolean unregisterGear(GearSpec spec, Project project){
104 | //Get register
105 | GearSpecRegister register = GearSpecRegistrar.getRegister(project);
106 |
107 | if (register != null){
108 | if (register.declaredGears != null){
109 | for (GearSpec installedGear : register.declaredGears){
110 | if (installedGear.getName().equals(spec.getName()) && installedGear.getVersion().equals(spec.getVersion())){
111 | if (register.declaredGears.remove(installedGear)){
112 | //Create new Gson instance for use
113 | Gson gson = new GsonBuilder().setPrettyPrinting().create();
114 |
115 | //Write register to file
116 | try {
117 | FileUtils.forceDelete(getRegisterPath(project));
118 | FileUtils.write(getRegisterPath(project), gson.toJson(register));
119 | } catch (IOException e) {
120 | e.printStackTrace();
121 | return false;
122 | }
123 |
124 | return true;
125 | }
126 | }
127 | }
128 |
129 | }
130 | }
131 |
132 |
133 | return false;
134 | }
135 |
136 | public static GearSpecRegister getRegister(Project project){
137 | //Get specregister file
138 | File registrationFile = new File(project.getBasePath()+Utils.pathSeparator()+"GearSpecRegister");
139 |
140 | //If registration file exists, go get it!
141 | if (registrationFile.exists()){
142 | //Read back register from file
143 | String registerString = null;
144 | try {
145 | registerString = FileUtils.readFileToString(registrationFile);
146 | } catch (IOException e) {
147 | e.printStackTrace();
148 | return null;
149 | }
150 | return new Gson().fromJson(registerString, GearSpecRegister.class);
151 | }
152 |
153 | return null;
154 | }
155 |
156 | public static File getRegisterPath(Project project){
157 | return new File(project.getBasePath()+Utils.pathSeparator()+"GearSpecRegister");
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/AndroidGears/src/Utilities/OSValidator.java:
--------------------------------------------------------------------------------
1 | package Utilities;
2 |
3 | /**
4 | * Created by mkyong
5 | */
6 | public class OSValidator {
7 |
8 | private static String OS = System.getProperty("os.name").toLowerCase();
9 |
10 | public static void main(String[] args) {
11 |
12 | System.out.println(OS);
13 |
14 | if (isWindows()) {
15 | System.out.println("This is Windows");
16 | } else if (isMac()) {
17 | System.out.println("This is Mac");
18 | } else if (isUnix()) {
19 | System.out.println("This is Unix or Linux");
20 | } else if (isSolaris()) {
21 | System.out.println("This is Solaris");
22 | } else {
23 | System.out.println("Your OS is not support!!");
24 | }
25 | }
26 |
27 | public static boolean isWindows() {
28 |
29 | return (OS.indexOf("win") >= 0);
30 |
31 | }
32 |
33 | public static boolean isMac() {
34 |
35 | return (OS.indexOf("mac") >= 0);
36 |
37 | }
38 |
39 | public static boolean isUnix() {
40 |
41 | return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 );
42 |
43 | }
44 |
45 | public static boolean isSolaris() {
46 |
47 | return (OS.indexOf("sunos") >= 0);
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/AndroidGears/src/Utilities/Utils.java:
--------------------------------------------------------------------------------
1 | package Utilities;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecSource;
5 | import Singletons.SettingsManager;
6 | import com.google.gson.Gson;
7 | import com.google.gson.JsonSyntaxException;
8 | import com.intellij.openapi.project.Project;
9 | import org.apache.commons.io.FileUtils;
10 |
11 | import java.io.*;
12 | import java.net.HttpURLConnection;
13 | import java.net.URL;
14 |
15 | /**
16 | * Created by matthewyork on 4/1/14.
17 | */
18 | public class Utils {
19 |
20 | public static String wrappedStringForString(String inputString, int wrapWidth){
21 | inputString = inputString.replace("\n", "
");
22 | return String.format("%s
", wrapWidth, inputString);
23 | }
24 |
25 | public static File androidGearsDirectory(){
26 |
27 | return new File(SettingsManager.getInstance().getSpecsPath()+Utils.pathSeparator()+"repos");
28 | }
29 |
30 | public static File getDefaultDirectory(){
31 | File defaultDirectory;
32 | //Setup file
33 | if (OSValidator.isWindows()) {
34 | defaultDirectory = new File(System.getProperty("user.home")+"/AndroidGears"); //C drive
35 | } else if (OSValidator.isMac()) {
36 | defaultDirectory = new File(System.getProperty("user.home")+"/.androidgears"); //Home folder
37 | } else if (OSValidator.isUnix()) {
38 | defaultDirectory = new File("~/.androidgears"); //Home folder
39 | } else if (OSValidator.isSolaris()) {
40 | defaultDirectory = new File("~/AndroidGears");//Home folder
41 | } else {
42 | defaultDirectory = new File("~/AndroidGears");//Home folder
43 | }
44 |
45 | return defaultDirectory;
46 | }
47 |
48 | public static String pathSeparator(){
49 | return (OSValidator.isWindows()) ? "\\":"/";
50 | }
51 |
52 | public static String newLine(){
53 | return (OSValidator.isWindows()) ? "\r\n":"\n";
54 | }
55 |
56 | public static boolean ping(String url, int timeout) {
57 | //url = url.replaceFirst("https", "http"); // Otherwise an exception may be thrown on invalid SSL certificates.
58 |
59 | try {
60 | HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
61 | connection.setConnectTimeout(timeout);
62 | connection.setReadTimeout(timeout);
63 | connection.setRequestMethod("GET");
64 | int responseCode = connection.getResponseCode();
65 | return (200 <= responseCode && responseCode <= 399);
66 | } catch (IOException exception) {
67 | return false;
68 | }
69 | }
70 |
71 | public static GearSpec specForFile(File specFile){
72 | GearSpec spec = null;
73 |
74 | if (specFile != null){
75 | if(specFile.exists()) {
76 | //Get string data
77 | String specString = null;
78 | try {
79 | specString = FileUtils.readFileToString(specFile);
80 | } catch (IOException e) {
81 | e.printStackTrace();
82 | return null;
83 | }
84 | //Get spec
85 | try{
86 | spec = new Gson().fromJson(specString, GearSpec.class);
87 | }
88 | catch (JsonSyntaxException e){
89 | e.printStackTrace();
90 | }
91 | }
92 | }
93 |
94 | return spec;
95 | }
96 |
97 | public static GearSpec specForInfo(String name, String version){
98 | //Create spec file
99 | File specFile = null;
100 | if (version != null){
101 | specFile = new File(Utils.androidGearsDirectory()+Utils.pathSeparator()+name+Utils.pathSeparator()+version+Utils.pathSeparator()+name+".gearspec");
102 | }
103 | else {
104 | String[] versions = versionsForProject(name);
105 | if (versions.length > 0){
106 | specFile = new File(Utils.androidGearsDirectory()+Utils.pathSeparator()+name+Utils.pathSeparator()+versions[versions.length-1]+Utils.pathSeparator()+name+".gearspec");
107 | }
108 | }
109 |
110 | return specForFile(specFile);
111 | }
112 |
113 | public static String[] versionsForProject(String project){
114 | File versionsDirectory = new File(Utils.androidGearsDirectory().getAbsolutePath()+Utils.pathSeparator()+project);
115 | return versionsDirectory.list();
116 | }
117 |
118 | public static String jarFileNameForSpecSource(GearSpecSource source){
119 |
120 | //Get element with jar name in it
121 | String sourceString;
122 | if(source.getUrl().toLowerCase().contains(".jar")){
123 | sourceString = source.getUrl();
124 | }
125 | else {
126 | sourceString = source.getSource_files();
127 | }
128 |
129 | //Parse out jar name
130 | if (sourceString.contains("/")){
131 | int lastPathSeparatorIndex = sourceString.lastIndexOf("/");
132 | String fileName = sourceString.substring(lastPathSeparatorIndex+1);
133 |
134 | return fileName;
135 | }
136 | else {
137 | return source.getSource_files();
138 | }
139 | }
140 |
141 | public static GearSpec.GearState specStateForSpec(GearSpec spec, Project project){
142 | if (spec.isRegistered(project)){
143 | //Make local separator for speed
144 | String pathSeparator = Utils.pathSeparator();
145 |
146 | if (spec.getType().equals(GearSpec.SPEC_TYPE_JAR)){
147 | //TODO: Only checks for name, not version...
148 | if (new File(project.getBasePath()+pathSeparator+"Gears"+pathSeparator+"Jars"+pathSeparator+spec.getName()+pathSeparator+spec.getVersion()+pathSeparator+Utils.jarFileNameForSpecSource(spec.getSource())).exists()){
149 | return GearSpec.GearState.GearStateInstalled;
150 | }
151 | else {
152 | return GearSpec.GearState.GearStateDeclared;
153 | }
154 | }
155 | else if(spec.getType().equals(GearSpec.SPEC_TYPE_MODULE)){
156 | //TODO: Only checks for name, not version...
157 | if(new File(project.getBasePath()+Utils.pathSeparator()+"Gears"+pathSeparator+"Modules"+pathSeparator+spec.getName()+pathSeparator+spec.getVersion()).exists()){
158 | return GearSpec.GearState.GearStateInstalled;
159 | }
160 | else{
161 | return GearSpec.GearState.GearStateDeclared;
162 | }
163 | }
164 | else {
165 | return GearSpec.GearState.GearStateDeclared;
166 | }
167 | }
168 |
169 | return GearSpec.GearState.GearStateUninstalled;
170 | }
171 |
172 | public static File fileInstallPathForSpec(GearSpec spec, Project project){
173 | if (spec != null & project != null){
174 | //Make local separator for speed
175 | String pathSeparator = Utils.pathSeparator();
176 |
177 | if (spec.getType().equals(GearSpec.SPEC_TYPE_JAR)){
178 | return new File(project.getBasePath()+pathSeparator+"Gears"+pathSeparator+"Jars"+pathSeparator+spec.getName()+pathSeparator+spec.getVersion());
179 | }
180 | else if (spec.getType().equals(GearSpec.SPEC_TYPE_MODULE)){
181 | return new File(project.getBasePath()+pathSeparator+"Gears"+pathSeparator+"Modules"+pathSeparator+spec.getName()+pathSeparator+spec.getVersion());
182 | }
183 | }
184 |
185 | return null;
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/GetAllSpecsListWorker.java:
--------------------------------------------------------------------------------
1 | package Workers;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Utilities.Utils;
5 | import com.google.gson.Gson;
6 | import org.apache.commons.io.FileUtils;
7 |
8 | import javax.swing.*;
9 | import java.io.File;
10 | import java.io.FilenameFilter;
11 | import java.io.IOException;
12 | import java.util.ArrayList;
13 |
14 | /**
15 | * Created by aaronfleshner on 4/27/14.
16 | */
17 | public class GetAllSpecsListWorker extends SwingWorker {
18 |
19 | public ArrayList specNames = new ArrayList();
20 |
21 | public GetAllSpecsListWorker() {
22 |
23 | }
24 |
25 | @Override
26 | protected Void doInBackground() throws Exception {
27 | specNames = libsList(Utils.androidGearsDirectory());
28 | return null;
29 | }
30 |
31 | private ArrayList libsList(File androidGearsDirectory) {
32 | /*
33 | //Check for empty search string
34 | if(searchString.equals("")){
35 | return new ArrayList();
36 | }*/
37 |
38 | //Create gson instance for use in parsing specs
39 | final Gson gson = new Gson();
40 |
41 | //Create array for storing matched specs
42 | final ArrayList projectList = new ArrayList();
43 |
44 | //If there is a searchstring, get matches!
45 | String directories[] = androidGearsDirectory.list(new FilenameFilter() {
46 | @Override
47 | public boolean accept(File file, String name) {
48 | if (name.contains(".")) { //No hidden folders!
49 | return false;
50 | } else if (!(new File(file.getAbsolutePath() + Utils.pathSeparator() + name).isDirectory())) {
51 | return false;
52 | }
53 | //If it matches the filename, lets skip the metadata search and add it directly. Save the cycles!
54 | else {
55 | return true;
56 | }
57 | }
58 | });
59 | ArrayList specs = new ArrayList();
60 | for (String lib : directories) {
61 | specs.add(lib);
62 | }
63 | return specs;
64 | }
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/GetGearStateWorker.java:
--------------------------------------------------------------------------------
1 | package Workers;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpecRegister.GearSpecRegister;
5 | import Utilities.GearSpecRegistrar;
6 | import Utilities.Utils;
7 | import com.intellij.openapi.project.Project;
8 |
9 | import javax.swing.*;
10 |
11 | /**
12 | * Created by matthewyork on 4/6/14.
13 | */
14 | public class GetGearStateWorker extends SwingWorker {
15 |
16 | Project project;
17 | GearSpec selectedSpec;
18 | public GearSpec.GearState gearState;
19 |
20 | public GetGearStateWorker(Project project, GearSpec spec) {
21 | this.project = project;
22 | this.selectedSpec = spec;
23 | }
24 |
25 | @Override
26 | protected Void doInBackground() throws Exception {
27 |
28 | //Get register
29 | gearState = Utils.specStateForSpec(selectedSpec, project);
30 |
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/GetProjectVersionsWorker.java:
--------------------------------------------------------------------------------
1 | package Workers;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Utilities.OSValidator;
5 | import Utilities.Utils;
6 |
7 | import javax.swing.*;
8 | import java.io.File;
9 | import java.io.FilenameFilter;
10 | import java.util.ArrayList;
11 | import java.util.Arrays;
12 | import java.util.Collections;
13 |
14 | /**
15 | * Created by matthewyork on 4/2/14.
16 | */
17 | public class GetProjectVersionsWorker extends SwingWorker {
18 | private GearSpec spec;
19 | public ArrayList versions = new ArrayList();
20 |
21 | public GetProjectVersionsWorker(GearSpec spec) {
22 | this.spec = spec;
23 | }
24 |
25 | @Override
26 | protected Void doInBackground() throws Exception {
27 | versions = versionsForSpec(this.spec);
28 | return null;
29 | }
30 |
31 | private ArrayList versionsForSpec(GearSpec spec){
32 |
33 |
34 | //Get path separator
35 | String pathSeparator = (OSValidator.isWindows()) ? "\\":"/";
36 |
37 | //Get versions for spec
38 | return versionsForProject(spec.getName(), pathSeparator);
39 | }
40 |
41 | private ArrayList versionsForProject(String project, String pathSeparator){
42 | File versionsDirectory = new File(Utils.androidGearsDirectory().getAbsolutePath()+pathSeparator+project);
43 |
44 | ArrayList versions = new ArrayList(Arrays.asList(versionsDirectory.list(new FilenameFilter() {
45 | @Override
46 | public boolean accept(File file, String s) {
47 | return (s.equals(".DS_Store")) ? false: true;
48 | }
49 | })));
50 | Collections.reverse(versions);
51 | return versions;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Git/GitWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Git;
2 |
3 | import Singletons.SettingsManager;
4 | import Utilities.OSValidator;
5 | import Utilities.Utils;
6 | import org.eclipse.jgit.api.Git;
7 | import org.eclipse.jgit.api.PullResult;
8 | import org.eclipse.jgit.api.errors.GitAPIException;
9 |
10 | import javax.swing.*;
11 | import java.io.File;
12 | import java.io.IOException;
13 |
14 | /**
15 | * Created by matthewyork on 4/2/14.
16 | */
17 | public class GitWorker extends SwingWorker {
18 | private static final int DEFAULT_TIMEOUT = 5000; //10s
19 | private String REMOTE_SPECS_URL = "https://github.com/AndroidGears/Specs.git";
20 |
21 | public boolean successful = false;
22 |
23 | @Override
24 | protected Void doInBackground() throws Exception {
25 | SettingsManager.getInstance().loadSettings();
26 | syncAndroidGears();
27 | return null;
28 | }
29 |
30 | private void syncAndroidGears(){
31 | //Setup file
32 | File androidGearsDirectory = Utils.androidGearsDirectory();
33 |
34 | //Pull changes or clone repo
35 | if(androidGearsDirectory.exists()){
36 | successful = pullChanges(androidGearsDirectory);
37 | }
38 | else {
39 | androidGearsDirectory.mkdir();
40 | successful = cloneRepository(androidGearsDirectory);
41 | }
42 | }
43 |
44 | private Boolean cloneRepository(File androidGearsDirectory){
45 | try {
46 | Git git = Git.cloneRepository()
47 | .setURI(REMOTE_SPECS_URL)
48 | .setBranch("master")
49 | .setDirectory(androidGearsDirectory)
50 | .setTimeout(DEFAULT_TIMEOUT)
51 | .call();
52 |
53 | //Get repos directory
54 | File reposDirectory = git.getRepository().getDirectory().getParentFile();
55 |
56 | //Close git connection!
57 | git.close();
58 |
59 | //If everything was created successfully, return true
60 | if (reposDirectory != null){
61 | if (reposDirectory.exists()){
62 | if (reposDirectory.list().length > 1){
63 | return true;
64 | }
65 | }
66 | }
67 | } catch (GitAPIException e) {
68 | e.printStackTrace();
69 |
70 | }
71 |
72 | return false;
73 | }
74 |
75 | private Boolean pullChanges(File androidGearsDirectory){
76 | try {
77 | Git git = Git.open(new File(androidGearsDirectory.getAbsolutePath()+ Utils.pathSeparator()+".git"));
78 | PullResult result = git.pull().setTimeout(DEFAULT_TIMEOUT).call();
79 | git.close();
80 | return result.isSuccessful();
81 |
82 | /*
83 | PullCommand pullCmd = git.pull();
84 |
85 | PullResult result = pullCmd.call();
86 | FetchResult fetchResult = result.getFetchResult();
87 | MergeResult mergeResult = result.getMergeResult();
88 | mergeResult.getMergeStatus(); // this should be interesting*/
89 | }
90 | catch (IOException exception){
91 | //cloneRepository(androidGearsDirectory);
92 | }
93 | catch (GitAPIException exception){
94 | exception.printStackTrace();
95 | }
96 |
97 | return false;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Git/IgnoreCheckWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Git;
2 |
3 | import Singletons.SettingsManager;
4 | import Utilities.Utils;
5 | import com.intellij.openapi.project.Project;
6 | import com.intellij.openapi.project.ProjectManager;
7 | import org.apache.commons.io.FileUtils;
8 |
9 | import javax.swing.*;
10 | import java.io.File;
11 |
12 | /**
13 | * Created by matthewyork on 4/8/14.
14 | */
15 | public class IgnoreCheckWorker extends SwingWorker{
16 |
17 | @Override
18 | protected Void doInBackground() throws Exception {
19 |
20 | //Load settings from file
21 | SettingsManager.getInstance().loadSettings();
22 |
23 | //If the ignore is set, try and add it. If it already exists, the following won't do anything
24 | if (SettingsManager.getInstance().getAutoIgnore()){
25 | SettingsManager.getInstance().setCreateIgnore(true);
26 | }
27 |
28 | return null;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/InstallUninstall/DeclareSpecWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.InstallUninstall;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Utilities.GearSpecRegistrar;
5 | import com.intellij.openapi.project.Project;
6 |
7 | import javax.swing.*;
8 |
9 | /**
10 | * Created by matthewyork on 4/7/14.
11 | */
12 | public class DeclareSpecWorker extends SwingWorker {
13 | public Boolean success;
14 | GearSpec spec;
15 | Project project;
16 |
17 | public DeclareSpecWorker(GearSpec spec, Project project) {
18 | this.spec = spec;
19 | this.project = project;
20 | }
21 |
22 | @Override
23 | protected Void doInBackground() throws Exception {
24 |
25 | success = GearSpecRegistrar.registerGear(spec, project, GearSpec.GearState.GearStateDeclared);
26 |
27 | return null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/InstallUninstall/InstallDependencyForSpecWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.InstallUninstall;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecDependency;
5 | import Utilities.GearSpecManager;
6 | import Utilities.GearSpecRegistrar;
7 | import Utilities.Utils;
8 | import com.intellij.openapi.module.Module;
9 | import com.intellij.openapi.project.Project;
10 | import org.apache.commons.io.FileUtils;
11 | import org.eclipse.jgit.api.Git;
12 | import org.eclipse.jgit.api.errors.GitAPIException;
13 |
14 | import javax.swing.*;
15 | import java.io.File;
16 | import java.io.IOException;
17 | import java.net.URL;
18 |
19 | /**
20 | * Created by matthewyork on 4/4/14.
21 | */
22 | public class InstallDependencyForSpecWorker extends SwingWorker {
23 |
24 | private GearSpec selectedSpec;
25 | private Project project;
26 | private Module module;
27 | public boolean successful;
28 |
29 | public InstallDependencyForSpecWorker(GearSpec spec, Project project, Module module) {
30 | this.selectedSpec = spec;
31 | this.project = project;
32 | this.module = module;
33 | }
34 |
35 | @Override
36 | protected Void doInBackground() throws Exception {
37 |
38 | if (selectedSpec != null){
39 | successful = GearSpecManager.installGear(selectedSpec, project, module);
40 | }
41 |
42 | return null;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/InstallUninstall/UndeclareSpecWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.InstallUninstall;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Utilities.GearSpecRegistrar;
5 | import com.intellij.openapi.project.Project;
6 |
7 | import javax.swing.*;
8 |
9 | /**
10 | * Created by matthewyork on 4/7/14.
11 | */
12 | public class UndeclareSpecWorker extends SwingWorker {
13 | public Boolean success;
14 | GearSpec spec;
15 | Project project;
16 |
17 | public UndeclareSpecWorker(GearSpec spec, Project project) {
18 | this.spec = spec;
19 | this.project = project;
20 | }
21 |
22 | @Override
23 | protected Void doInBackground() throws Exception {
24 |
25 | success = GearSpecRegistrar.unregisterGear(spec, project);
26 |
27 | return null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/InstallUninstall/UninstallDependencyForSpecWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.InstallUninstall;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecDependency;
5 | import Utilities.GearSpecManager;
6 | import Utilities.GearSpecRegistrar;
7 | import Utilities.Utils;
8 | import com.intellij.openapi.module.Module;
9 | import com.intellij.openapi.project.Project;
10 | import org.apache.commons.io.FileUtils;
11 |
12 | import javax.swing.*;
13 | import java.io.File;
14 | import java.io.FilenameFilter;
15 | import java.io.IOException;
16 | import java.util.ArrayList;
17 |
18 | /**
19 | * Created by matthewyork on 4/4/14.
20 | */
21 | public class UninstallDependencyForSpecWorker extends SwingWorker {
22 |
23 | private ArrayList selectedSpecs;
24 | private Project project;
25 | private Module module;
26 | public boolean successful;
27 |
28 | public UninstallDependencyForSpecWorker(ArrayList selectedSpecs, Project project, Module module) {
29 | this.selectedSpecs = selectedSpecs;
30 | this.project = project;
31 | this.module = module;
32 | }
33 |
34 | @Override
35 | protected Void doInBackground() throws Exception {
36 |
37 | for (GearSpec selectedSpec : this.selectedSpecs){
38 | if(!GearSpecManager.uninstallGear(selectedSpec, project, module)){
39 | successful = false;
40 | break;
41 | }
42 | }
43 |
44 |
45 | successful = true;
46 | return null;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/InstallUninstall/UpdateGearWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.InstallUninstall;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecUpdate;
5 | import Utilities.GearSpecManager;
6 | import Utilities.Utils;
7 | import com.intellij.openapi.module.Module;
8 | import com.intellij.openapi.project.Project;
9 |
10 | import javax.swing.*;
11 |
12 | /**
13 | * Created by matthewyork on 4/9/14.
14 | */
15 | public class UpdateGearWorker extends SwingWorker {
16 |
17 | private GearSpecUpdate selectedSpec;
18 | private Project project;
19 | private Module module;
20 | public boolean successful = false;
21 |
22 | public UpdateGearWorker(GearSpecUpdate selectedSpec, Project project, Module module) {
23 | this.selectedSpec = selectedSpec;
24 | this.project = project;
25 | this.module = module;
26 | }
27 |
28 | @Override
29 | protected Void doInBackground() throws Exception {
30 |
31 | //Uninstall jar or module
32 | if (selectedSpec.getType().equals(GearSpec.SPEC_TYPE_JAR)){
33 | if (!GearSpecManager.uninstallJar(selectedSpec, project, module)){
34 | return null;
35 | }
36 | }
37 | else if (selectedSpec.getType().equals(GearSpec.SPEC_TYPE_MODULE)){
38 | if (!GearSpecManager.uninstallModule(selectedSpec, project, module)){
39 | return null;
40 | }
41 | }
42 |
43 | //Get the updatedSpec
44 | GearSpec updateSpec = Utils.specForInfo(selectedSpec.getName(), selectedSpec.getUpdateVersionNumber());
45 |
46 | if (updateSpec != null){
47 | //Install either the new jar or module. We have to do it this way in case someone changes library types
48 | if (updateSpec.getType().equals(GearSpec.SPEC_TYPE_JAR)){
49 | this.successful = GearSpecManager.installJar(updateSpec, project, module, null);
50 | }
51 | else if (selectedSpec.getType().equals(GearSpec.SPEC_TYPE_MODULE)){
52 | this.successful = GearSpecManager.installModule(updateSpec, project, module, null);
53 | }
54 | }
55 |
56 | return null;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Lint/LintGearSpecWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Lint;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpecLinter.GearSpecLintResult;
5 | import Utilities.GearSpecLinter;
6 |
7 | import javax.swing.*;
8 | import java.util.List;
9 | import java.util.concurrent.Callable;
10 |
11 | /**
12 | * Created by matthewyork on 4/3/14.
13 | */
14 | public class LintGearSpecWorker extends SwingWorker {
15 | private GearSpec spec;
16 | public GearSpecLintResult result = new GearSpecLintResult();
17 |
18 | public LintGearSpecWorker(GearSpec spec) {
19 | this.spec = spec;
20 | }
21 |
22 | @Override
23 | protected Void doInBackground() throws Exception {
24 | result = GearSpecLinter.lintSpec(this.spec, this);
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Search/SearchDeclaredDependenciesWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Search;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 | import Models.GearSpecRegister.GearSpecRegister;
6 | import Utilities.GearSpecRegistrar;
7 | import Utilities.Utils;
8 | import com.intellij.openapi.project.Project;
9 |
10 | import javax.swing.*;
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Created by matthewyork on 4/6/14.
15 | */
16 | public class SearchDeclaredDependenciesWorker extends SwingWorker {
17 |
18 | private Project project;
19 | private String searchString;
20 | public ArrayList specs = new ArrayList();
21 |
22 | public SearchDeclaredDependenciesWorker(Project project, String searchString) {
23 | this.project = project;
24 | this.searchString = searchString;
25 | }
26 |
27 | @Override
28 | protected Void doInBackground() throws Exception {
29 |
30 | //Get register
31 | GearSpecRegister register = GearSpecRegistrar.getRegister(this.project);
32 |
33 |
34 | if (register != null){
35 | //If not empty, search over all fields for matches
36 | String[] searchParameters = searchString.split(" ");
37 | ArrayList gears = new ArrayList();
38 | for (GearSpec spec : register.declaredGears){
39 | for (String searchParamter : searchParameters){
40 | String filterString = spec.getName().toLowerCase() + " " + spec.getVersion().toLowerCase();
41 |
42 | //Gather tags
43 | if (spec.getTags() != null){
44 | for (String tag : spec.getTags()) {
45 | filterString = filterString+tag.toLowerCase()+" ";
46 | }
47 | }
48 |
49 | //Gather authors
50 | for (GearSpecAuthor author : spec.getAuthors()) {
51 | filterString = filterString+author.getName().toLowerCase()+" ";
52 | }
53 |
54 | //Filter with the search string over spec metadata
55 | if(filterString.contains(searchParamter.toLowerCase())){
56 | //Set spec state
57 | spec.setGearState(Utils.specStateForSpec(spec, project));
58 |
59 | //Add gear
60 | gears.add(spec);
61 | break;
62 | }
63 | }
64 | }
65 |
66 | this.specs = gears;
67 | }
68 |
69 | return null;
70 | }
71 |
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Search/SearchInstalledProjectsWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Search;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 | import Models.GearSpecRegister.GearSpecRegister;
6 | import Utilities.GearSpecRegistrar;
7 | import Utilities.Utils;
8 | import com.intellij.openapi.project.Project;
9 |
10 | import javax.swing.*;
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Created by matthewyork on 4/5/14.
15 | */
16 | public class SearchInstalledProjectsWorker extends SwingWorker{
17 |
18 | private Project project;
19 | String searchString;
20 | public ArrayList specs = new ArrayList();
21 |
22 | public SearchInstalledProjectsWorker(Project project, String searchString) {
23 | this.project = project;
24 | this.searchString = searchString;
25 | }
26 |
27 | @Override
28 | protected Void doInBackground() throws Exception {
29 |
30 | GearSpecRegister register = GearSpecRegistrar.getRegister(this.project);
31 |
32 | if (register != null){
33 | ArrayList installedSpecs = new ArrayList();
34 | for (GearSpec declaredSpec : register.declaredGears){
35 | if (Utils.specStateForSpec(declaredSpec, project) == GearSpec.GearState.GearStateInstalled){
36 | declaredSpec.setGearState(Utils.specStateForSpec(declaredSpec, project));
37 |
38 | String[] searchParameters = searchString.split(" ");
39 | for (String searchParamter : searchParameters){
40 | String filterString = declaredSpec.getName().toLowerCase() + " " + declaredSpec.getVersion().toLowerCase();
41 |
42 | //Gather tags
43 | if (declaredSpec.getTags() != null){
44 | for (String tag : declaredSpec.getTags()) {
45 | filterString = filterString+tag.toLowerCase()+" ";
46 | }
47 | }
48 |
49 | //Gather authors
50 | for (GearSpecAuthor author : declaredSpec.getAuthors()) {
51 | filterString = filterString+author.getName().toLowerCase()+" ";
52 | }
53 |
54 | //Filter with the search string over spec metadata
55 | if(filterString.contains(searchParamter.toLowerCase())){
56 | //Add sepec
57 | installedSpecs.add(declaredSpec);
58 | }
59 | }
60 | }
61 | }
62 |
63 | this.specs = installedSpecs;
64 | return null;
65 | }
66 |
67 | return null;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Search/SearchProjectListWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Search;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 | import Utilities.Utils;
6 | import com.google.gson.Gson;
7 | import com.google.gson.JsonParseException;
8 | import com.intellij.openapi.project.Project;
9 | import org.apache.commons.io.FileUtils;
10 |
11 | import javax.swing.*;
12 | import java.io.File;
13 | import java.io.FilenameFilter;
14 | import java.io.IOException;
15 | import java.util.ArrayList;
16 |
17 | /**
18 | * Created by matthewyork on 4/2/14.
19 | */
20 | public class SearchProjectListWorker extends SwingWorker {
21 |
22 | private String searchString;
23 | private Project project;
24 | public ArrayList specs = new ArrayList();
25 |
26 | public SearchProjectListWorker(String searchString, Project project) {
27 | this.searchString = searchString;
28 | this.project = project;
29 | }
30 |
31 | @Override
32 | protected Void doInBackground() throws Exception {
33 | specs = projectsList(Utils.androidGearsDirectory(), searchString);
34 | return null;
35 | }
36 |
37 | private ArrayList projectsList(File androidGearsDirectory, final String searchString){
38 | /*
39 | //Check for empty search string
40 | if(searchString.equals("")){
41 | return new ArrayList();
42 | }*/
43 |
44 | //Create gson instance for use in parsing specNames
45 | final Gson gson = new Gson();
46 |
47 | //Create array for storing matched specNames
48 | final ArrayList projectList = new ArrayList();
49 |
50 | //If there is a searchstring, get matches!
51 | String directories[] = androidGearsDirectory.list(new FilenameFilter() {
52 | @Override
53 | public boolean accept(File file, String name) {
54 | if(name.contains(".")){ //No hidden folders!
55 | return false;
56 | }
57 | else if (!(new File(file.getAbsolutePath()+Utils.pathSeparator()+name).isDirectory())){
58 | return false;
59 | }
60 | //If it matches the filename, lets skip the metadata search and add it directly. Save the cycles!
61 | else if (name.toLowerCase().contains(searchString.toLowerCase())){ //Accept only those that match your search string
62 | //Get versions for spec
63 | String[] versions = versionsForProject(name, Utils.pathSeparator());
64 |
65 | //Build spec location
66 | File specFile = new File(Utils.androidGearsDirectory()+Utils.pathSeparator()+name+Utils.pathSeparator()+versions[versions.length-1]+Utils.pathSeparator()+name+".gearspec");
67 |
68 | if (specFile.exists()){
69 | String specString = null;
70 | try {
71 | specString = FileUtils.readFileToString(specFile);
72 | } catch (IOException e) {
73 | e.printStackTrace();
74 | return false;
75 | }
76 |
77 | GearSpec spec = gson.fromJson(specString, GearSpec.class);
78 | spec.setGearState(Utils.specStateForSpec(spec, project));
79 | projectList.add(spec);
80 | return true;
81 | }
82 | }
83 |
84 |
85 | //Get versions for spec
86 | String[] versions = versionsForProject(name, Utils.pathSeparator());
87 |
88 | //Build spec location
89 | File specFile = new File(Utils.androidGearsDirectory()+Utils.pathSeparator()+name+Utils.pathSeparator()+versions[versions.length-1]+Utils.pathSeparator()+name+".gearspec");
90 |
91 | if(specFile.exists()) {
92 | String specString = null;
93 | try {
94 | specString = FileUtils.readFileToString(specFile);
95 | } catch (IOException e) {
96 | e.printStackTrace();
97 | return false;
98 | }
99 |
100 | //Get spec
101 | try {
102 | GearSpec spec = gson.fromJson(specString, GearSpec.class);
103 |
104 | String[] searchParameters = searchString.split(" ");
105 | for (String searchParamter : searchParameters){
106 | String filterString = spec.getName().toLowerCase() + " " + spec.getVersion().toLowerCase();
107 |
108 | //Gather tags
109 | if (spec.getTags() != null){
110 | for (String tag : spec.getTags()) {
111 | filterString = filterString+tag.toLowerCase()+" ";
112 | }
113 | }
114 |
115 | //Gather authors
116 | for (GearSpecAuthor author : spec.getAuthors()) {
117 | filterString = filterString+author.getName().toLowerCase()+" ";
118 | }
119 |
120 | //Filter with the search string over spec metadata
121 | if(filterString.contains(searchParamter.toLowerCase())){
122 | //Set spec state
123 | spec.setGearState(Utils.specStateForSpec(spec, project));
124 | projectList.add(spec);
125 | return true;
126 | }
127 | }
128 | }
129 | catch (JsonParseException exception){
130 |
131 | }
132 | catch (Exception exception){
133 |
134 | }
135 | }
136 |
137 | return false;
138 | }
139 | });
140 |
141 | return projectList;
142 | }
143 |
144 | private String[] versionsForProject(String project, String pathSeparator){
145 | File versionsDirectory = new File(Utils.androidGearsDirectory().getAbsolutePath()+pathSeparator+project);
146 | return versionsDirectory.list();
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Search/SearchUpdatableProjectsWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Search;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpec.GearSpecAuthor;
5 | import Models.GearSpec.GearSpecUpdate;
6 | import Models.GearSpecRegister.GearSpecRegister;
7 | import Utilities.GearSpecRegistrar;
8 | import Utilities.Utils;
9 | import com.intellij.openapi.project.Project;
10 |
11 | import javax.swing.*;
12 | import java.util.ArrayList;
13 |
14 | /**
15 | * Created by matthewyork on 4/9/14.
16 | */
17 | public class SearchUpdatableProjectsWorker extends SwingWorker{
18 |
19 | private Project project;
20 | private String searchString;
21 | public ArrayList specs = new ArrayList();
22 |
23 | public SearchUpdatableProjectsWorker(Project project, String searchString) {
24 | this.project = project;
25 | this.searchString = searchString;
26 | }
27 |
28 | @Override
29 | protected Void doInBackground() throws Exception {
30 |
31 | //Get specNames register
32 | GearSpecRegister register = GearSpecRegistrar.getRegister(this.project);
33 |
34 | //Populate a list of installed gears
35 | if (register != null){
36 | ArrayList installedSpecs = new ArrayList();
37 | for (GearSpec declaredSpec : register.declaredGears){
38 | if (Utils.specStateForSpec(declaredSpec, project) == GearSpec.GearState.GearStateInstalled){
39 | declaredSpec.setGearState(Utils.specStateForSpec(declaredSpec, project));
40 | installedSpecs.add(declaredSpec);
41 | }
42 | }
43 |
44 | //Filter down to only those gears with updates
45 | filterInstalledGears(installedSpecs);
46 |
47 | return null;
48 | }
49 |
50 | return null;
51 | }
52 |
53 | private void filterInstalledGears(ArrayList installedGears) {
54 | //Iterate over all installed gears
55 | for (GearSpec spec : installedGears){
56 |
57 | //Get all versions for spec
58 | String[] versions = Utils.versionsForProject(spec.getName());
59 |
60 | //If the version does not match the latest version, mark it as updateable and
61 | if (versions.length > 0){
62 | //If the version does not equal the last available version, then a
63 | if (!versions[versions.length -1].equals(spec.getVersion())){
64 | GearSpecUpdate updateSpec = new GearSpecUpdate(spec);
65 | updateSpec.setUpdateVersionNumber(versions[versions.length -1]);
66 |
67 | String[] searchParameters = searchString.split(" ");
68 | for (String searchParamter : searchParameters){
69 | String filterString = spec.getName().toLowerCase() + " " + spec.getVersion().toLowerCase();
70 |
71 | //Gather tags
72 | if (spec.getTags() != null){
73 | for (String tag : spec.getTags()) {
74 | filterString = filterString+tag.toLowerCase()+" ";
75 | }
76 | }
77 |
78 | //Gather authors
79 | for (GearSpecAuthor author : spec.getAuthors()) {
80 | filterString = filterString+author.getName().toLowerCase()+" ";
81 | }
82 |
83 | //Filter with the search string over spec metadata
84 | if(filterString.contains(searchParamter.toLowerCase())){
85 | //Add sepec
86 | this.specs.add(updateSpec);
87 | }
88 | }
89 | }
90 | }
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Settings/GetCreateIgnoreEntryWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Settings;
2 |
3 | import javax.swing.*;
4 |
5 | /**
6 | * Created by matthewyork on 4/8/14.
7 | */
8 | public class GetCreateIgnoreEntryWorker extends SwingWorker {
9 |
10 |
11 | @Override
12 | protected Void doInBackground() throws Exception {
13 | return null;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Settings/SetCreateIgnoreEntryWorker.java:
--------------------------------------------------------------------------------
1 | package Workers.Settings;
2 |
3 | import Singletons.SettingsManager;
4 |
5 | import javax.swing.*;
6 |
7 | /**
8 | * Created by matthewyork on 4/8/14.
9 | */
10 | public class SetCreateIgnoreEntryWorker extends SwingWorker {
11 |
12 | private boolean createIgnore;
13 | public boolean success;
14 |
15 | public SetCreateIgnoreEntryWorker(boolean createIgnore) {
16 | this.createIgnore = createIgnore;
17 | }
18 |
19 | @Override
20 | protected Void doInBackground() throws Exception {
21 |
22 | //Set the ignore function
23 | if (createIgnore){
24 | success = SettingsManager.getInstance().setCreateIgnore(true);
25 | }
26 | else {
27 | success = SettingsManager.getInstance().setCreateIgnore(false);
28 | }
29 |
30 | return null;
31 | }
32 | }
--------------------------------------------------------------------------------
/AndroidGears/src/Workers/Sync/SyncGears.java:
--------------------------------------------------------------------------------
1 | package Workers.Sync;
2 |
3 | import Models.GearSpec.GearSpec;
4 | import Models.GearSpecRegister.GearSpecRegister;
5 | import Utilities.GearSpecManager;
6 | import Utilities.GearSpecRegistrar;
7 | import Utilities.Utils;
8 | import com.intellij.openapi.module.Module;
9 | import com.intellij.openapi.project.Project;
10 | import org.apache.commons.io.FileUtils;
11 |
12 | import javax.swing.*;
13 | import java.io.File;
14 | import java.io.IOException;
15 | import java.util.ArrayList;
16 |
17 | /**
18 | * Created by matthewyork on 4/10/14.
19 | */
20 | public class SyncGears extends SwingWorker{
21 |
22 | Project project;
23 | Module module;
24 | public boolean success = false;
25 |
26 | public SyncGears(Project project, Module module) {
27 | this.project = project;
28 | this.module = module;
29 | }
30 |
31 | @Override
32 | protected Void doInBackground() throws Exception {
33 |
34 | //Get gear spec register
35 | GearSpecRegister register = GearSpecRegistrar.getRegister(project);
36 |
37 | //Handle any gears that should be deleted (i.e. aren't in the specNames register)
38 | handleNewDeletions(register);
39 |
40 | //Handle any new gears that need to be installed
41 | handleNewAdditions(register);
42 |
43 | return null;
44 | }
45 |
46 | private void handleNewDeletions(GearSpecRegister register) {
47 | //Make local copy for speed
48 | String pathSeparator = Utils.pathSeparator();
49 |
50 | //Get Gear Directories
51 | File jarsDirectory = new File(project.getBasePath() + pathSeparator+ "Gears"+ pathSeparator + "Jars");
52 | File modulesDirectory = new File(project.getBasePath() + pathSeparator+ "Gears"+ pathSeparator + "Modules");
53 |
54 | //Array to hold all gears to be removed
55 | ArrayList gearsToBeRemoved = new ArrayList();
56 |
57 | //Collect unnecessary jars
58 | gearsToBeRemoved.addAll(collectGearsToRemove(jarsDirectory, register, pathSeparator));
59 |
60 | //Collect unnecessary modules
61 | gearsToBeRemoved.addAll(collectGearsToRemove(modulesDirectory, register, pathSeparator));
62 |
63 | //Remove all jars and modules that were not listed in the Gearspec
64 | for (File gearDirectory : gearsToBeRemoved){
65 | String versionNumber = "";
66 |
67 | //Find the version from the gear directory (should only be one directory!)
68 | for (File versionDirectory : gearDirectory.listFiles()){
69 | if (versionDirectory.isDirectory()){
70 | versionNumber = versionDirectory.getName();
71 | }
72 | }
73 |
74 | //Fetch gear from name and version number
75 | GearSpec spec = Utils.specForInfo(gearDirectory.getName(), versionNumber);
76 |
77 | //Uninstall spec
78 | GearSpecManager.uninstallGear(spec, project, module);
79 | }
80 |
81 | }
82 |
83 | private ArrayList collectGearsToRemove(File gearTypeDirectory, GearSpecRegister register, String pathSeparator){
84 |
85 | //Array to hold all gears to be removed
86 | ArrayList gearsToBeRemoved = new ArrayList();
87 |
88 | //Remove unneccessary gears
89 | if (gearTypeDirectory.exists()){
90 | //Iterate over all jars
91 | for (File gearDirectory : gearTypeDirectory.listFiles()){
92 | if (gearDirectory.isDirectory()){
93 | Boolean match = false;
94 |
95 | //Iterate through specNames register to find a match.
96 | for (GearSpec spec : register.declaredGears){
97 | //If there is a spec listed, by that name, check its version
98 | if (gearDirectory.getName().equals(spec.getName())){
99 | File versionDirectory = new File(gearDirectory.getAbsolutePath() + pathSeparator + spec.getVersion());
100 |
101 | if (versionDirectory.exists()){
102 | match = true;
103 | break;
104 | }
105 | }
106 | }
107 |
108 | //If no match is found, trash the directory
109 | if (!match){
110 | gearsToBeRemoved.add(gearDirectory);
111 | }
112 | }
113 | }
114 | }
115 |
116 | return gearsToBeRemoved;
117 | }
118 |
119 | private void handleNewAdditions(GearSpecRegister register){
120 | if (register != null){
121 | for (GearSpec spec : register.declaredGears){
122 | //Set gear state
123 | spec.setGearState(Utils.specStateForSpec(spec, project));
124 |
125 | //Check to see if it is declared, if it is install it and its dependencies
126 | if (spec.getGearState() == GearSpec.GearState.GearStateDeclared){
127 | //Install gear
128 | GearSpecManager.installGear(spec, project, module);
129 | }
130 | }
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 AndroidGears
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------