select nickname on startup
This commit is contained in:
@@ -8,6 +8,7 @@ import com.muwire.core.MuWireSettings
|
|||||||
|
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.swing.JOptionPane
|
||||||
|
|
||||||
import static griffon.util.GriffonApplicationUtils.isMacOSX
|
import static griffon.util.GriffonApplicationUtils.isMacOSX
|
||||||
import static groovy.swing.SwingBuilder.lookAndFeel
|
import static groovy.swing.SwingBuilder.lookAndFeel
|
||||||
@@ -40,8 +41,25 @@ class Ready extends AbstractLifecycleHandler {
|
|||||||
}
|
}
|
||||||
props = new MuWireSettings(props)
|
props = new MuWireSettings(props)
|
||||||
} else {
|
} else {
|
||||||
log.info("creating default properties")
|
log.info("creating new properties")
|
||||||
props = new MuWireSettings()
|
props = new MuWireSettings()
|
||||||
|
def 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 || nickname.trim().length() == 0) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Nickname cannot be empty")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (nickname.contains("@")) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Nickname cannot contain @, choose another")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
nickname = nickname.trim()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
props.setNickname(nickname)
|
||||||
propsFile.withOutputStream {
|
propsFile.withOutputStream {
|
||||||
props.write(it)
|
props.write(it)
|
||||||
}
|
}
|
||||||
@@ -49,6 +67,7 @@ class Ready extends AbstractLifecycleHandler {
|
|||||||
|
|
||||||
Core core = new Core(props, home)
|
Core core = new Core(props, home)
|
||||||
core.startServices()
|
core.startServices()
|
||||||
|
application.context.put("muwire-settings", props)
|
||||||
application.context.put("core",core)
|
application.context.put("core",core)
|
||||||
application.getPropertyChangeListeners("core").each {
|
application.getPropertyChangeListeners("core").each {
|
||||||
it.propertyChange(new PropertyChangeEvent(this, "core", null, core))
|
it.propertyChange(new PropertyChangeEvent(this, "core", null, core))
|
||||||
|
|||||||
Reference in New Issue
Block a user