Skip to content

Commit 44274b9

Browse files
author
jantje
committed
Moved some stuff away from Const
Working on getting rid of the const class. I know not the right time but I couldn't stop myself
1 parent e7b3a5b commit 44274b9

File tree

12 files changed

+556
-511
lines changed

12 files changed

+556
-511
lines changed

io.sloeber.core/src/io/sloeber/common/Common.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424

2525
import io.sloeber.core.Activator;
2626

27+
@SuppressWarnings("nls")
2728
public class Common extends Const {
29+
private static final String ENV_PATTERN = "PATTERN";
30+
private static final String ENV_PROTOCOL = "PROTOCOL";
31+
protected static final String ENV_TOOL = "TOOL";
2832

2933
/**
3034
* This method makes sure that a string can be used as a file or folder name
@@ -282,4 +286,52 @@ public static void setBuildEnvironmentVariable(ICConfigurationDescription confde
282286
setBuildEnvironmentVariable(contribEnv, confdesc, key, value);
283287
}
284288

289+
/**
290+
* given a action return the environment key that matches it's protocol
291+
*
292+
* @param action
293+
* @return the environment variable key to find the protocol
294+
*/
295+
public static String get_ENV_KEY_PROTOCOL(String action) {
296+
return ERASE_START + action.toUpperCase() + DOT + ENV_PROTOCOL;
297+
}
298+
299+
/**
300+
* given a action return the environment key that matches it's tool
301+
*
302+
* @param action
303+
* @return the environment variable key to find the tool
304+
*/
305+
public static String get_ENV_KEY_TOOL(String action) {
306+
return ERASE_START + action.toUpperCase() + DOT + ENV_TOOL;
307+
}
308+
309+
/**
310+
* given a action return the environment key that matches it's recipe
311+
*
312+
* @param action
313+
* @return he environment variable key to find the recipe
314+
*/
315+
public static String get_ENV_KEY_RECIPE(String action) {
316+
return ERASE_START + action.toUpperCase() + DOT + ENV_PATTERN;
317+
}
318+
319+
public static String get_Jantje_KEY_PROTOCOL(String action) {
320+
return ENV_KEY_JANTJE_START + action.toUpperCase() + DOT + ENV_PROTOCOL;
321+
}
322+
323+
public static String get_Jantje_KEY_RECIPE(String action) {
324+
return ENV_KEY_JANTJE_START + action.toUpperCase() + DOT + ENV_PATTERN;
325+
}
326+
327+
/**
328+
* given a action and a tool return the environment key that matches it's
329+
* recipe
330+
*
331+
* @param action
332+
* @return he environment variable key to find the recipe
333+
*/
334+
public static String get_ENV_KEY_RECIPE(String tool, String action) {
335+
return ERASE_START + "TOOLS" + DOT + tool.toUpperCase() + DOT + action.toUpperCase() + DOT + ENV_PATTERN; //$NON-NLS-1$
336+
}
285337
}

io.sloeber.core/src/io/sloeber/common/ConfigurationPreferences.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
2323
import org.osgi.service.prefs.BackingStoreException;
2424

25+
import io.sloeber.core.Activator;
26+
2527
/**
2628
* Items on the Configuration level are linked to the ConfigurationScope
2729
* (=eclipse install base).
@@ -42,7 +44,7 @@ public class ConfigurationPreferences {
4244
private static final String DEFAULT_JSON_URLS = "http://downloads.arduino.cc/packages/package_index.json" //$NON-NLS-1$
4345
+ System.lineSeparator() + "http://arduino.esp8266.com/stable/package_esp8266com_index.json"; //$NON-NLS-1$
4446
// preference nodes
45-
public static final String NODE_ARDUINO = Const.PLUGIN_START + "arduino"; //$NON-NLS-1$
47+
public static final String NODE_ARDUINO = Activator.NODE_ARDUINO;
4648

4749
private ConfigurationPreferences() {
4850
}
@@ -139,7 +141,7 @@ public static String getDefaultBoardsPackageURLs() {
139141
}
140142

141143
public static String[] getBoardsPackageURLList() {
142-
return getBoardsPackageURLs().replaceAll(Const.RETURN, Const.EMPTY_STRING).split(stringSplitter);
144+
return getBoardsPackageURLs().replace("\r", Const.EMPTY_STRING).split(stringSplitter); //$NON-NLS-1$
143145
}
144146

145147
public static String getBoardsPackageKey() {

io.sloeber.core/src/io/sloeber/common/Const.java

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@ public class Const {
1616
public static final String SPACE = " ";
1717
public static final String FALSE = "FALSE";
1818
public static final String TRUE = "TRUE";
19-
public static final String NEWLINE = "\n";
20-
public static final String RETURN = "\r";
2119
public static final String MENU = "menu";
2220

2321
// General stuff
24-
public static final String PLUGIN_START = "io.sloeber.";
25-
public static final String CORE_PLUGIN_ID = PLUGIN_START + "arduino.core";
26-
protected static final String ENV_PATTERN = "PATTERN"; //$NON-NLS-1$
22+
public static final String CORE_PLUGIN_ID = "io.sloeber.arduino.core";
2723

2824
// Actions
2925
public static final String ACTION_UPLOAD = "UPLOAD";
@@ -39,10 +35,6 @@ public class Const {
3935
public static final String UPLOAD_CLASS = "UPLOAD_CLASS";
4036
public static final String UPLOAD_CLASS_DEFAULT = "arduinoUploader";
4137

42-
// Describers
43-
private static final String ENV_PROTOCOL = "PROTOCOL";
44-
protected static final String ENV_TOOL = "TOOL";
45-
4638
// properties keys
4739

4840
public static final String KEY_LAST_USED_EXAMPLES = "Last used Examples";
@@ -111,44 +103,6 @@ public class Const {
111103

112104
static final String EXAMPLE_FOLDER_NAME = "examples";
113105

114-
public static final String ARDUINO_NATURE_ID = PLUGIN_START + "arduinonature";
115-
116-
/**
117-
* given a action return the environment key that matches it's protocol
118-
*
119-
* @param action
120-
* @return the environment variable key to find the protocol
121-
*/
122-
public static String get_ENV_KEY_PROTOCOL(String action) {
123-
return ERASE_START + action.toUpperCase() + DOT + ENV_PROTOCOL;
124-
}
125-
126-
/**
127-
* given a action return the environment key that matches it's tool
128-
*
129-
* @param action
130-
* @return the environment variable key to find the tool
131-
*/
132-
public static String get_ENV_KEY_TOOL(String action) {
133-
return ERASE_START + action.toUpperCase() + DOT + ENV_TOOL;
134-
}
135-
136-
/**
137-
* given a action return the environment key that matches it's recipe
138-
*
139-
* @param action
140-
* @return he environment variable key to find the recipe
141-
*/
142-
public static String get_ENV_KEY_RECIPE(String action) {
143-
return ERASE_START + action.toUpperCase() + DOT + ENV_PATTERN;
144-
}
145-
146-
public static String get_Jantje_KEY_PROTOCOL(String action) {
147-
return ENV_KEY_JANTJE_START + action.toUpperCase() + DOT + ENV_PROTOCOL;
148-
}
149-
150-
public static String get_Jantje_KEY_RECIPE(String action) {
151-
return ENV_KEY_JANTJE_START + action.toUpperCase() + DOT + ENV_PATTERN;
152-
}
106+
public static final String ARDUINO_NATURE_ID = "io.sloeber.arduinonature";
153107

154108
}

0 commit comments

Comments
 (0)