* fixed another thread blocking problem
* made ConfigFile behave more appropriately with missing config files * SysTray now behaves correctly when a file dialog has been canceled without any choices being made
This commit is contained in:
@ -57,31 +57,32 @@ public class ConfigFile {
|
|||||||
try {
|
try {
|
||||||
fileInputStream = new FileInputStream(_configFile);
|
fileInputStream = new FileInputStream(_configFile);
|
||||||
_properties.load(fileInputStream);
|
_properties.load(fileInputStream);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fileInputStream.close();
|
fileInputStream.close();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e) {
|
||||||
// No worries.
|
// No worries.
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeConfigFile() {
|
private boolean writeConfigFile() {
|
||||||
|
|
||||||
FileOutputStream fileOutputStream = null;
|
FileOutputStream fileOutputStream = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fileOutputStream = new FileOutputStream(_configFile);
|
fileOutputStream = new FileOutputStream(_configFile);
|
||||||
_properties.store(fileOutputStream, null);
|
_properties.store(fileOutputStream, null);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
System.exit(1);
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e) {
|
||||||
// No worries.
|
// No worries.
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public class ShellCommand {
|
|||||||
return _outputStream;
|
return _outputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean execute(String shellCommand, boolean consumeOutput, boolean waitForExitStatus) {
|
private boolean execute(String shellCommand, boolean consumeOutput, boolean waitForExitStatus) {
|
||||||
|
|
||||||
StreamConsumer processStderrConsumer;
|
StreamConsumer processStderrConsumer;
|
||||||
StreamConsumer processStdoutConsumer;
|
StreamConsumer processStdoutConsumer;
|
||||||
|
@ -27,15 +27,15 @@ public class SysTray implements SysTrayMenuListener {
|
|||||||
private String _browserString;
|
private String _browserString;
|
||||||
private ConfigFile _configFile = new ConfigFile();
|
private ConfigFile _configFile = new ConfigFile();
|
||||||
private Frame _frame;
|
private Frame _frame;
|
||||||
private SysTrayMenuItem _itemExit = new SysTrayMenuItem("Exit I2P systray", "exit");
|
private SysTrayMenuItem _itemSelectBrowser = new SysTrayMenuItem("Select browser...", "selectbrowser");
|
||||||
private SysTrayMenuItem _itemSelectBrowser = new SysTrayMenuItem("Select preferred browser...", "selectbrowser");
|
private SysTrayMenuItem _itemShutdown = new SysTrayMenuItem("Shut down I2P router", "shutdown");
|
||||||
private SysTrayMenuIcon _sysTrayMenuIcon = new SysTrayMenuIcon("../icons/iggy");
|
private SysTrayMenuIcon _sysTrayMenuIcon = new SysTrayMenuIcon("icons/iggy");
|
||||||
private SysTrayMenu _sysTrayMenu = new SysTrayMenu(_sysTrayMenuIcon, "I2P Router Console");
|
private SysTrayMenu _sysTrayMenu = new SysTrayMenu(_sysTrayMenuIcon, "I2P Router Console");
|
||||||
private UrlLauncher _urlLauncher = new UrlLauncher();
|
private UrlLauncher _urlLauncher = new UrlLauncher();
|
||||||
|
|
||||||
public SysTray() {
|
public SysTray() {
|
||||||
|
|
||||||
if (!_configFile.init("../systray.config"))
|
if (!_configFile.init("systray.config"))
|
||||||
_configFile.setProperty("browser", "default");
|
_configFile.setProperty("browser", "default");
|
||||||
|
|
||||||
_browserString = _configFile.getProperty("browser", "default");
|
_browserString = _configFile.getProperty("browser", "default");
|
||||||
@ -74,16 +74,18 @@ public class SysTray implements SysTrayMenuListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((browser = promptForBrowser("Please select another browser")) != null)
|
if (!(browser = promptForBrowser("Please select another browser")).equals("nullnull"))
|
||||||
setBrowser(browser);
|
setBrowser(browser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void menuItemSelected(SysTrayMenuEvent e) {
|
public void menuItemSelected(SysTrayMenuEvent e) {
|
||||||
if (e.getActionCommand().equals("exit")) {
|
|
||||||
|
String browser = null;
|
||||||
|
|
||||||
|
if (e.getActionCommand().equals("shutdown")) {
|
||||||
_browserChooser = null;
|
_browserChooser = null;
|
||||||
_frame = null;
|
_frame = null;
|
||||||
_itemExit = null;
|
_itemShutdown = null;
|
||||||
_itemSelectBrowser = null;
|
_itemSelectBrowser = null;
|
||||||
_sysTrayMenuIcon = null;
|
_sysTrayMenuIcon = null;
|
||||||
_sysTrayMenu = null;
|
_sysTrayMenu = null;
|
||||||
@ -91,14 +93,16 @@ public class SysTray implements SysTrayMenuListener {
|
|||||||
_frame = null;
|
_frame = null;
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} else if (e.getActionCommand().equals("selectbrowser")) {
|
} else if (e.getActionCommand().equals("selectbrowser")) {
|
||||||
setBrowser(promptForBrowser("Select preferred browser"));
|
|
||||||
|
if (!(browser = promptForBrowser("Select browser")).equals("nullnull"))
|
||||||
|
setBrowser(browser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSysTrayMenu() {
|
private void createSysTrayMenu() {
|
||||||
_itemSelectBrowser.addSysTrayMenuListener(this);
|
_itemSelectBrowser.addSysTrayMenuListener(this);
|
||||||
_itemExit.addSysTrayMenuListener(this);
|
_itemShutdown.addSysTrayMenuListener(this);
|
||||||
_sysTrayMenu.addItem(_itemExit);
|
_sysTrayMenu.addItem(_itemShutdown);
|
||||||
_sysTrayMenu.addSeparator();
|
_sysTrayMenu.addSeparator();
|
||||||
_sysTrayMenu.addItem(_itemSelectBrowser);
|
_sysTrayMenu.addItem(_itemSelectBrowser);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user