|
16 | 16 | import org.eclipse.core.runtime.Status;
|
17 | 17 |
|
18 | 18 | import io.sloeber.common.ConfigurationPreferences;
|
| 19 | +import io.sloeber.common.Const; |
19 | 20 | import io.sloeber.core.Activator;
|
20 | 21 |
|
21 | 22 | public class Tool {
|
22 | 23 |
|
23 |
| - private String name; |
24 |
| - private String version; |
25 |
| - private List<ToolSystem> systems; |
| 24 | + private static final String TOOLS = "tools"; |
| 25 | + private String name; |
| 26 | + private String version; |
| 27 | + private List<ToolSystem> systems; |
26 | 28 |
|
27 |
| - private transient Package pkg; |
| 29 | + private transient Package pkg; |
28 | 30 |
|
29 |
| - public void setOwner(Package pkg) { |
30 |
| - this.pkg = pkg; |
31 |
| - for (ToolSystem system : this.systems) { |
32 |
| - system.setOwner(this); |
| 31 | + public void setOwner(Package pkg) { |
| 32 | + this.pkg = pkg; |
| 33 | + for (ToolSystem system : this.systems) { |
| 34 | + system.setOwner(this); |
| 35 | + } |
33 | 36 | }
|
34 |
| - } |
35 | 37 |
|
36 |
| - public Package getPackage() { |
37 |
| - return this.pkg; |
38 |
| - } |
| 38 | + public Package getPackage() { |
| 39 | + return this.pkg; |
| 40 | + } |
39 | 41 |
|
40 |
| - public String getName() { |
41 |
| - return this.name; |
42 |
| - } |
| 42 | + public String getName() { |
| 43 | + return this.name; |
| 44 | + } |
43 | 45 |
|
44 |
| - public String getVersion() { |
45 |
| - return this.version; |
46 |
| - } |
| 46 | + public String getVersion() { |
| 47 | + return this.version; |
| 48 | + } |
47 | 49 |
|
48 |
| - public List<ToolSystem> getSystems() { |
49 |
| - return this.systems; |
50 |
| - } |
| 50 | + public List<ToolSystem> getSystems() { |
| 51 | + return this.systems; |
| 52 | + } |
51 | 53 |
|
52 |
| - public Path getInstallPath() { |
53 |
| - return Paths.get(ConfigurationPreferences.getInstallationPath().append("tools").append(this.pkg.getName()) //$NON-NLS-1$ |
54 |
| - .append(this.name).append(this.version).toString()); |
55 |
| - } |
| 54 | + public Path getInstallPath() { |
| 55 | + return Paths.get(ConfigurationPreferences.getInstallationPath().append(Const.PACKAGES_FOLDER_NAME) |
| 56 | + .append(this.pkg.getName()).append(TOOLS).append(this.name).append(this.version).toString()); |
56 | 57 |
|
57 |
| - public boolean isInstalled() { |
58 |
| - return getInstallPath().toFile().exists(); |
59 |
| - } |
| 58 | + } |
60 | 59 |
|
61 |
| - public IStatus install(IProgressMonitor monitor) { |
62 |
| - if (isInstalled()) { |
63 |
| - return Status.OK_STATUS; |
| 60 | + public boolean isInstalled() { |
| 61 | + return getInstallPath().toFile().exists(); |
64 | 62 | }
|
65 | 63 |
|
66 |
| - for (ToolSystem system : this.systems) { |
67 |
| - if (system.isApplicable()) { |
68 |
| - return system.install(monitor); |
69 |
| - } |
| 64 | + public IStatus install(IProgressMonitor monitor) { |
| 65 | + if (isInstalled()) { |
| 66 | + return Status.OK_STATUS; |
| 67 | + } |
| 68 | + |
| 69 | + for (ToolSystem system : this.systems) { |
| 70 | + if (system.isApplicable()) { |
| 71 | + return system.install(monitor); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + // No valid system |
| 76 | + return new Status(IStatus.ERROR, Activator.getId(), Messages.Tool_no_valid_system + this.name); |
70 | 77 | }
|
71 | 78 |
|
72 |
| - // No valid system |
73 |
| - return new Status(IStatus.ERROR, Activator.getId(), Messages.Tool_no_valid_system + this.name); |
74 |
| - } |
75 |
| - |
76 |
| - // public Properties getToolProperties() { |
77 |
| - // Properties properties = new Properties(); |
78 |
| - // properties.put("runtime.tools." + name + ".path", |
79 |
| - // ArduinoBuildConfiguration.pathString(getInstallPath())); // $NON-NLS-1$ |
80 |
| - // //$NON-NLS-2$ |
81 |
| - // return properties; |
82 |
| - // } |
| 79 | + // public Properties getToolProperties() { |
| 80 | + // Properties properties = new Properties(); |
| 81 | + // properties.put("runtime.tools." + name + ".path", |
| 82 | + // ArduinoBuildConfiguration.pathString(getInstallPath())); // $NON-NLS-1$ |
| 83 | + // //$NON-NLS-2$ |
| 84 | + // return properties; |
| 85 | + // } |
83 | 86 |
|
84 | 87 | }
|
0 commit comments