mirror of https://github.com/zlatinb/muwire
prompt for nickname even if MuWire.properties exists so that docker can ship a MuWire.properties #32
parent
3db4317fc1
commit
d90067ff39
|
@ -44,6 +44,8 @@ class Ready extends AbstractLifecycleHandler {
|
||||||
propsFile.withReader("UTF-8", {
|
propsFile.withReader("UTF-8", {
|
||||||
props.load(it)
|
props.load(it)
|
||||||
})
|
})
|
||||||
|
if (!props.containsKey("nickname"))
|
||||||
|
props.setProperty("nickname", selectNickname())
|
||||||
props = new MuWireSettings(props)
|
props = new MuWireSettings(props)
|
||||||
if (props.incompleteLocation == null)
|
if (props.incompleteLocation == null)
|
||||||
props.incompleteLocation = new File(home, "incompletes")
|
props.incompleteLocation = new File(home, "incompletes")
|
||||||
|
@ -53,29 +55,7 @@ class Ready extends AbstractLifecycleHandler {
|
||||||
props.incompleteLocation = new File(home, "incompletes")
|
props.incompleteLocation = new File(home, "incompletes")
|
||||||
props.embeddedRouter = Boolean.parseBoolean(System.getProperties().getProperty("embeddedRouter"))
|
props.embeddedRouter = Boolean.parseBoolean(System.getProperties().getProperty("embeddedRouter"))
|
||||||
props.updateType = System.getProperty("updateType","jar")
|
props.updateType = System.getProperty("updateType","jar")
|
||||||
def nickname
|
props.setNickname(selectNickname())
|
||||||
while (true) {
|
|
||||||
nickname = JOptionPane.showInputDialog(null,
|
|
||||||
"Your nickname is displayed when you send search results so other MuWire users can choose to trust you",
|
|
||||||
"Please choose a nickname", JOptionPane.PLAIN_MESSAGE)
|
|
||||||
if (nickname == null) {
|
|
||||||
JOptionPane.showMessageDialog(null, "MuWire cannot start without a nickname and will now exit", JOptionPane.PLAIN_MESSAGE)
|
|
||||||
System.exit(0)
|
|
||||||
}
|
|
||||||
if (nickname.trim().length() == 0) {
|
|
||||||
JOptionPane.showMessageDialog(null, "Nickname cannot be empty", "Select another nickname",
|
|
||||||
JOptionPane.WARNING_MESSAGE)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (nickname.contains("@")) {
|
|
||||||
JOptionPane.showMessageDialog(null, "Nickname cannot contain @, choose another",
|
|
||||||
"Select another nickname", JOptionPane.WARNING_MESSAGE)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
nickname = nickname.trim()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
props.setNickname(nickname)
|
|
||||||
|
|
||||||
|
|
||||||
def portableDownloads = System.getProperty("portable.downloads")
|
def portableDownloads = System.getProperty("portable.downloads")
|
||||||
|
@ -120,5 +100,31 @@ class Ready extends AbstractLifecycleHandler {
|
||||||
|
|
||||||
core.eventBus.publish(new UILoadedEvent())
|
core.eventBus.publish(new UILoadedEvent())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String selectNickname() {
|
||||||
|
String nickname
|
||||||
|
while (true) {
|
||||||
|
nickname = JOptionPane.showInputDialog(null,
|
||||||
|
"Your nickname is displayed when you send search results so other MuWire users can choose to trust you",
|
||||||
|
"Please choose a nickname", JOptionPane.PLAIN_MESSAGE)
|
||||||
|
if (nickname == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "MuWire cannot start without a nickname and will now exit", JOptionPane.PLAIN_MESSAGE)
|
||||||
|
System.exit(0)
|
||||||
|
}
|
||||||
|
if (nickname.trim().length() == 0) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Nickname cannot be empty", "Select another nickname",
|
||||||
|
JOptionPane.WARNING_MESSAGE)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (nickname.contains("@")) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Nickname cannot contain @, choose another",
|
||||||
|
"Select another nickname", JOptionPane.WARNING_MESSAGE)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
nickname = nickname.trim()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
nickname
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue