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;
|
||||
|
||||
public class GuiSwing extends JFrame implements Gui {
|
||||
public static final String type = "swing";
|
||||
public enum ActivityType {
|
||||
WORKING, SETTINGS
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import com.sheepit.client.Gui;
|
||||
import com.sheepit.client.Log;
|
||||
|
||||
public class GuiText implements Gui {
|
||||
public static final String type = "text";
|
||||
|
||||
private int framesRendered;
|
||||
private Log log;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.sheepit.client.Client;
|
||||
import com.sheepit.client.Gui;
|
||||
|
||||
public class GuiTextOneLine implements Gui {
|
||||
public static final String type = "oneLine";
|
||||
|
||||
private int rendered;
|
||||
private int remaining;
|
||||
private String status;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Worker {
|
||||
private String extras = null;
|
||||
|
||||
@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)
|
||||
private String config_file = null;
|
||||
@@ -261,7 +261,6 @@ public class Worker {
|
||||
|
||||
config.setComputeMethod(compute_method);
|
||||
|
||||
|
||||
if (config_file != null) {
|
||||
if (new File(config_file).exists() == false) {
|
||||
System.err.println("Configuration file not found.");
|
||||
@@ -275,14 +274,14 @@ public class Worker {
|
||||
|
||||
Gui gui;
|
||||
switch (ui_type) {
|
||||
case "oneline":
|
||||
case GuiTextOneLine.type:
|
||||
if (config.getPrintLog()) {
|
||||
System.out.println("OneLine UI can not be used if verbose mode is enabled");
|
||||
System.exit(2);
|
||||
}
|
||||
gui = new GuiTextOneLine();
|
||||
break;
|
||||
case "swing":
|
||||
case GuiSwing.type:
|
||||
if (java.awt.GraphicsEnvironment.isHeadless()) {
|
||||
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).");
|
||||
|
||||
Reference in New Issue
Block a user