summaryrefslogtreecommitdiff
path: root/BKUWebStart
diff options
context:
space:
mode:
Diffstat (limited to 'BKUWebStart')
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java6
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/Autostart.java8
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartInterface.java1
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartLinux.java7
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartWindows.java7
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java6
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java7
7 files changed, 39 insertions, 3 deletions
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
index 3fa7f805..95d76a4a 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
@@ -294,9 +294,15 @@ public class Launcher implements BKUControllerInterface {
}
@Override
+ public boolean isAutostartPossible() {
+ return autostart.isPossible();
+ }
+
+ @Override
public boolean isAutostartEnabled() {
return autostart.isEnabled();
}
+
@Override
public boolean setAutostart(boolean doAutostart) {
return autostart.set(doAutostart);
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/Autostart.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/Autostart.java
index a3291d05..db27f0d4 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/Autostart.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/Autostart.java
@@ -37,13 +37,19 @@ public class Autostart {
_autostart = new AutostartLinux();
else if (os.toLowerCase().contains("windows"))
_autostart = new AutostartWindows();
- if (_webstartName != null)
+ if (_autostart != null && _webstartName != null)
_autostart.setWebstartName(_webstartName);
}
return _autostart;
}
+ public boolean isPossible() {
+ if (getAutostart() == null)
+ return false;
+ return getAutostart().isPossible();
+ }
+
public boolean isEnabled() {
if (getAutostart() == null)
return false;
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartInterface.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartInterface.java
index f085fc94..bcd87ac8 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartInterface.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartInterface.java
@@ -24,6 +24,7 @@
package at.gv.egiz.bku.webstart.autostart;
public interface AutostartInterface {
+ public boolean isPossible();
public boolean isEnabled();
public boolean set(boolean enable);
public void setWebstartName(String webstartName);
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartLinux.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartLinux.java
index 4fc91a30..59e06d95 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartLinux.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartLinux.java
@@ -68,6 +68,13 @@ public class AutostartLinux extends AbstractAutostart {
}
@Override
+ public boolean isPossible() {
+ Map<String, String> autostartFiles = getAutostartFiles();
+
+ return !autostartFiles.isEmpty();
+ }
+
+ @Override
public boolean isEnabled() {
Map<String, String> autostartFiles = getAutostartFiles();
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartWindows.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartWindows.java
index 50c38d97..6200c02b 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartWindows.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/autostart/AutostartWindows.java
@@ -154,6 +154,13 @@ public class AutostartWindows extends AbstractAutostart {
}
@Override
+ public boolean isPossible() {
+ String autostartFileName = getAutostartFileName();
+
+ return autostartFileName != null;
+ }
+
+ @Override
public boolean isEnabled() {
String autostartFileName = getAutostartFileName();
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java
index 91ce0e77..a340c980 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java
@@ -38,6 +38,12 @@ public interface BKUControllerInterface {
/**
+ * Check if MOCCA Autostart is possible
+ * @return autostart possibility
+ */
+ boolean isAutostartPossible();
+
+ /**
* Check if MOCCA Autostart is enabled
* @return autostart state
*/
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java
index d6dc6d5b..64b94424 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java
@@ -126,6 +126,7 @@ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener {
autostartItem.addItemListener(this);
autostartItem.setActionCommand(COMMANDS.AUTOSTART_COMMAND.name());
autostartItem.setState(controller.isAutostartEnabled());
+ autostartItem.setEnabled(controller.isAutostartPossible());
settingsMenu.add(autostartItem);
menu.addSeparator();
@@ -238,11 +239,13 @@ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener {
@Override
public void itemStateChanged(ItemEvent e) {
- log.debug("autostart toggle requested via tray menu");
CheckboxMenuItem item = (CheckboxMenuItem) e.getItemSelectable();
switch (COMMANDS.valueOf(item.getActionCommand())) {
case AUTOSTART_COMMAND:
- item.setState((controller.setAutostart(item.getState())));
+ boolean reqState = item.getState();
+ boolean newState = controller.setAutostart(reqState);
+ log.debug("autostart toggle requested via tray menu (" + reqState + " -> " + newState + ")");
+ item.setState(newState);
break;
default: