Skip to content

Commit

Permalink
If you fail and it's not your fault, complain LOUDLY
Browse files Browse the repository at this point in the history
Do not hesitate to speak up against anything wrong happening.
  • Loading branch information
cshubhamrao committed Aug 25, 2016
1 parent 8bebbdd commit 7a40a93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/main/java/com/github/cshubhamrao/AUtDv2/gui/UIController.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
*/
package com.github.cshubhamrao.AUtDv2.gui;

import com.github.cshubhamrao.AUtDv2.util.Log;
import com.github.cshubhamrao.AUtDv2.os.*;
import com.github.cshubhamrao.AUtDv2.util.Log;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Level;
import javafx.collections.FXCollections;
Expand Down Expand Up @@ -74,6 +73,17 @@ public class UIController {
public void initialize() {
logger.log(Level.INFO, "Initializing Controls");

if (OSLib.getCurrentArchitecture() == OSLib.Architecture.UNKNOWN
|| OSLib.getCurrentOS() == OSLib.OperatingSystem.UNKNOWN) {
new Alert(Alert.AlertType.ERROR, "Unable to determine current OS and/or System "
+ "Architecture. Any OS-dependent functionality will not work").showAndWait();
logger.log(Level.SEVERE, "Unable to detect OS and/or architecture reliably");
btn_NetBeans.setDisable(true);
btn_MySql.setDisable(true);
btn_backup.setDisable(true);
btn_restore.setDisable(true);
}

spinner_cwNo.setValueFactory(new IntegerSpinnerValueFactory(1, 199));
cb_topic.setItems(FXCollections.observableArrayList("Java", "MySQL"));
btn_NetBeans.setOnAction((e) -> new NetBeansRunner().run());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/github/cshubhamrao/AUtDv2/os/OSLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ public class OSLib {

private static final java.util.logging.Logger logger = Log.logger;

enum OperatingSystem {
public enum OperatingSystem {
WINDOWS,
LINUX,
MAC,
UNKNOWN
}

enum Architecture {
public enum Architecture {
i386,
AMD64,
UNKNOWN
}

static OperatingSystem getCurrentOS() {
public static OperatingSystem getCurrentOS() {
String os = System.getProperty("os.name");
if (os.startsWith("Linux")) return OperatingSystem.LINUX;
else if (os.startsWith("Windows")) return OperatingSystem.WINDOWS;
else if (os.startsWith("Mac")) return OperatingSystem.WINDOWS;
else return OperatingSystem.UNKNOWN;
}

static Architecture getCurrentArchitecture() {
public static Architecture getCurrentArchitecture() {
String arch = System.getProperty("os.arch");
if (arch.startsWith("amd64")) return Architecture.AMD64;
/*
Expand Down Expand Up @@ -88,7 +88,7 @@ GUI vs CMD... all on the (mobile)phone. Finally the GUI window opens, our warrio
return Architecture.UNKNOWN;
}

static List<Path> getProgramDirs() {
protected static List<Path> getProgramDirs() {
ArrayList<Path> dirs = new ArrayList(2);
if (getCurrentOS() == OperatingSystem.WINDOWS) {
switch (getCurrentArchitecture()) {
Expand Down

0 comments on commit 7a40a93

Please sign in to comment.