Do not hardcode the value on main function
This commit is contained in:
@@ -35,6 +35,7 @@ import com.sheepit.client.standalone.swing.activity.Settings;
|
|||||||
import com.sheepit.client.standalone.swing.activity.Working;
|
import com.sheepit.client.standalone.swing.activity.Working;
|
||||||
|
|
||||||
public class GuiSwing extends JFrame implements Gui {
|
public class GuiSwing extends JFrame implements Gui {
|
||||||
|
public static final String type = "swing";
|
||||||
public enum ActivityType {
|
public enum ActivityType {
|
||||||
WORKING, SETTINGS
|
WORKING, SETTINGS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import com.sheepit.client.Gui;
|
|||||||
import com.sheepit.client.Log;
|
import com.sheepit.client.Log;
|
||||||
|
|
||||||
public class GuiText implements Gui {
|
public class GuiText implements Gui {
|
||||||
|
public static final String type = "text";
|
||||||
|
|
||||||
private int framesRendered;
|
private int framesRendered;
|
||||||
private Log log;
|
private Log log;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.sheepit.client.Client;
|
|||||||
import com.sheepit.client.Gui;
|
import com.sheepit.client.Gui;
|
||||||
|
|
||||||
public class GuiTextOneLine implements Gui {
|
public class GuiTextOneLine implements Gui {
|
||||||
|
public static final String type = "oneLine";
|
||||||
|
|
||||||
private int rendered;
|
private int rendered;
|
||||||
private int remaining;
|
private int remaining;
|
||||||
private String status;
|
private String status;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class Worker {
|
|||||||
private String extras = null;
|
private String extras = null;
|
||||||
|
|
||||||
@Option(name = "-ui", usage = "Specify the user interface to use, default 'swing', available 'oneline', 'text', 'swing' (graphical)", required = false)
|
@Option(name = "-ui", usage = "Specify the user interface to use, default 'swing', available 'oneline', 'text', 'swing' (graphical)", required = false)
|
||||||
private String ui_type = "swing";
|
private String ui_type = GuiSwing.type;
|
||||||
|
|
||||||
@Option(name = "-config", usage = "Specify the configuration file", required = false)
|
@Option(name = "-config", usage = "Specify the configuration file", required = false)
|
||||||
private String config_file = null;
|
private String config_file = null;
|
||||||
@@ -261,7 +261,6 @@ public class Worker {
|
|||||||
|
|
||||||
config.setComputeMethod(compute_method);
|
config.setComputeMethod(compute_method);
|
||||||
|
|
||||||
|
|
||||||
if (config_file != null) {
|
if (config_file != null) {
|
||||||
if (new File(config_file).exists() == false) {
|
if (new File(config_file).exists() == false) {
|
||||||
System.err.println("Configuration file not found.");
|
System.err.println("Configuration file not found.");
|
||||||
@@ -275,14 +274,14 @@ public class Worker {
|
|||||||
|
|
||||||
Gui gui;
|
Gui gui;
|
||||||
switch (ui_type) {
|
switch (ui_type) {
|
||||||
case "oneline":
|
case GuiTextOneLine.type:
|
||||||
if (config.getPrintLog()) {
|
if (config.getPrintLog()) {
|
||||||
System.out.println("OneLine UI can not be used if verbose mode is enabled");
|
System.out.println("OneLine UI can not be used if verbose mode is enabled");
|
||||||
System.exit(2);
|
System.exit(2);
|
||||||
}
|
}
|
||||||
gui = new GuiTextOneLine();
|
gui = new GuiTextOneLine();
|
||||||
break;
|
break;
|
||||||
case "swing":
|
case GuiSwing.type:
|
||||||
if (java.awt.GraphicsEnvironment.isHeadless()) {
|
if (java.awt.GraphicsEnvironment.isHeadless()) {
|
||||||
System.out.println("Graphical ui can not be launch.");
|
System.out.println("Graphical ui can not be launch.");
|
||||||
System.out.println("You should set a DISPLAY or use a text ui (via -ui oneline or -ui text).");
|
System.out.println("You should set a DISPLAY or use a text ui (via -ui oneline or -ui text).");
|
||||||
|
|||||||
Reference in New Issue
Block a user