mirror of https://github.com/zlatinb/muwire
options panel for i2p tunnel options
parent
5435518212
commit
de682a802a
|
@ -90,6 +90,10 @@ public class Core {
|
||||||
i2pOptionsFile.withInputStream { i2pOptions.load(it) }
|
i2pOptionsFile.withInputStream { i2pOptions.load(it) }
|
||||||
} else {
|
} else {
|
||||||
i2pOptions["inbound.nickname"] = "MuWire"
|
i2pOptions["inbound.nickname"] = "MuWire"
|
||||||
|
i2pOptions["inbound.length"] = "3"
|
||||||
|
i2pOptions["inbound.quantity"] = "2"
|
||||||
|
i2pOptions["outbound.length"] = "3"
|
||||||
|
i2pOptions["outbound.quantity"] = "2"
|
||||||
}
|
}
|
||||||
|
|
||||||
// options like tunnel length and quantity
|
// options like tunnel length and quantity
|
||||||
|
|
|
@ -6,6 +6,8 @@ import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class OptionsController {
|
class OptionsController {
|
||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
|
@ -15,9 +17,35 @@ class OptionsController {
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void save() {
|
void save() {
|
||||||
String text = view.retryField.text
|
String text
|
||||||
model.downloadRetryInterval = text
|
Core core = application.context.get("core")
|
||||||
|
|
||||||
|
def i2pProps = core.i2pOptions
|
||||||
|
|
||||||
|
text = view.inboundLengthField.text
|
||||||
|
model.inboundLength = text
|
||||||
|
i2pProps["inbound.length"] = text
|
||||||
|
|
||||||
|
text = view.inboundQuantityField.text
|
||||||
|
model.inboundQuantity = text
|
||||||
|
i2pProps["inbound.quantity"] = text
|
||||||
|
|
||||||
|
text = view.outboundQuantityField.text
|
||||||
|
model.outboundQuantity = text
|
||||||
|
i2pProps["outbound.quantity"] = text
|
||||||
|
|
||||||
|
text = view.outboundLengthField.text
|
||||||
|
model.outboundLength = text
|
||||||
|
i2pProps["outbound.length"] = text
|
||||||
|
|
||||||
|
File i2pSettingsFile = new File(core.home, "i2p.properties")
|
||||||
|
i2pSettingsFile.withOutputStream {
|
||||||
|
i2pProps.store(it,"")
|
||||||
|
}
|
||||||
|
|
||||||
|
text = view.retryField.text
|
||||||
|
model.downloadRetryInterval = text
|
||||||
|
|
||||||
def settings = application.context.get("muwire-settings")
|
def settings = application.context.get("muwire-settings")
|
||||||
settings.downloadRetryInterval = Integer.valueOf(text)
|
settings.downloadRetryInterval = Integer.valueOf(text)
|
||||||
|
|
||||||
|
@ -25,7 +53,7 @@ class OptionsController {
|
||||||
model.updateCheckInterval = text
|
model.updateCheckInterval = text
|
||||||
settings.updateCheckInterval = Integer.valueOf(text)
|
settings.updateCheckInterval = Integer.valueOf(text)
|
||||||
|
|
||||||
File settingsFile = new File(application.context.get("core").home, "MuWire.properties")
|
File settingsFile = new File(core.home, "MuWire.properties")
|
||||||
settingsFile.withOutputStream {
|
settingsFile.withOutputStream {
|
||||||
settings.write(it)
|
settings.write(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
|
||||||
import griffon.core.artifact.GriffonModel
|
import griffon.core.artifact.GriffonModel
|
||||||
import griffon.transform.Observable
|
import griffon.transform.Observable
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
@ -9,8 +11,20 @@ class OptionsModel {
|
||||||
@Observable String downloadRetryInterval
|
@Observable String downloadRetryInterval
|
||||||
@Observable String updateCheckInterval
|
@Observable String updateCheckInterval
|
||||||
|
|
||||||
|
// i2p options
|
||||||
|
@Observable String inboundLength
|
||||||
|
@Observable String inboundQuantity
|
||||||
|
@Observable String outboundLength
|
||||||
|
@Observable String outboundQuantity
|
||||||
|
|
||||||
void mvcGroupInit(Map<String, String> args) {
|
void mvcGroupInit(Map<String, String> args) {
|
||||||
downloadRetryInterval = application.context.get("muwire-settings").downloadRetryInterval
|
downloadRetryInterval = application.context.get("muwire-settings").downloadRetryInterval
|
||||||
updateCheckInterval = application.context.get("muwire-settings").updateCheckInterval
|
updateCheckInterval = application.context.get("muwire-settings").updateCheckInterval
|
||||||
|
|
||||||
|
Core core = application.context.get("core")
|
||||||
|
inboundLength = core.i2pOptions["inbound.length"]
|
||||||
|
inboundQuantity = core.i2pOptions["inbound.quantity"]
|
||||||
|
outboundLength = core.i2pOptions["outbound.length"]
|
||||||
|
outboundQuantity = core.i2pOptions["outbound.quantity"]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,8 +5,11 @@ import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
import javax.swing.JDialog
|
import javax.swing.JDialog
|
||||||
|
import javax.swing.JPanel
|
||||||
|
import javax.swing.JTabbedPane
|
||||||
import javax.swing.SwingConstants
|
import javax.swing.SwingConstants
|
||||||
|
|
||||||
|
import java.awt.BorderLayout
|
||||||
import java.awt.event.WindowAdapter
|
import java.awt.event.WindowAdapter
|
||||||
import java.awt.event.WindowEvent
|
import java.awt.event.WindowEvent
|
||||||
|
|
||||||
|
@ -21,8 +24,17 @@ class OptionsView {
|
||||||
|
|
||||||
def d
|
def d
|
||||||
def p
|
def p
|
||||||
|
def i
|
||||||
def retryField
|
def retryField
|
||||||
def updateField
|
def updateField
|
||||||
|
|
||||||
|
def inboundLengthField
|
||||||
|
def inboundQuantityField
|
||||||
|
def outboundLengthField
|
||||||
|
def outboundQuantityField
|
||||||
|
|
||||||
|
def buttonsPanel
|
||||||
|
|
||||||
def mainFrame
|
def mainFrame
|
||||||
|
|
||||||
void initUI() {
|
void initUI() {
|
||||||
|
@ -39,13 +51,37 @@ class OptionsView {
|
||||||
updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 1))
|
updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 1))
|
||||||
label(text : "hours", constraints : gbc(gridx: 2, gridy : 1))
|
label(text : "hours", constraints : gbc(gridx: 2, gridy : 1))
|
||||||
|
|
||||||
|
}
|
||||||
|
i = builder.panel {
|
||||||
|
gridBagLayout()
|
||||||
|
label(text : "Changing these settings requires a restart", constraints : gbc(gridx : 0, gridy : 0, gridwidth: 2))
|
||||||
|
label(text : "Inbound Length", constraints : gbc(gridx:0, gridy:1))
|
||||||
|
inboundLengthField = textField(text : bind {model.inboundLength}, columns : 2, constraints : gbc(gridx:1, gridy:1))
|
||||||
|
label(text : "Inbound Quantity", constraints : gbc(gridx:0, gridy:2))
|
||||||
|
inboundQuantityField = textField(text : bind {model.inboundQuantity}, columns : 2, constraints : gbc(gridx:1, gridy:2))
|
||||||
|
label(text : "Outbound Length", constraints : gbc(gridx:0, gridy:3))
|
||||||
|
outboundLengthField = textField(text : bind {model.outboundLength}, columns : 2, constraints : gbc(gridx:1, gridy:3))
|
||||||
|
label(text : "Outbound Quantity", constraints : gbc(gridx:0, gridy:4))
|
||||||
|
outboundQuantityField = textField(text : bind {model.outboundQuantity}, columns : 2, constraints : gbc(gridx:1, gridy:4))
|
||||||
|
}
|
||||||
|
buttonsPanel = builder.panel {
|
||||||
|
gridBagLayout()
|
||||||
button(text : "Save", constraints : gbc(gridx : 1, gridy: 2), saveAction)
|
button(text : "Save", constraints : gbc(gridx : 1, gridy: 2), saveAction)
|
||||||
button(text : "Cancel", constraints : gbc(gridx : 2, gridy: 2), cancelAction)
|
button(text : "Cancel", constraints : gbc(gridx : 2, gridy: 2), cancelAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mvcGroupInit(Map<String,String> args) {
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
d.getContentPane().add(p)
|
def tabbedPane = new JTabbedPane()
|
||||||
|
tabbedPane.addTab("MuWire Options", p)
|
||||||
|
tabbedPane.addTab("I2P Options", i)
|
||||||
|
|
||||||
|
JPanel panel = new JPanel()
|
||||||
|
panel.setLayout(new BorderLayout())
|
||||||
|
panel.add(tabbedPane, BorderLayout.CENTER)
|
||||||
|
panel.add(buttonsPanel, BorderLayout.SOUTH)
|
||||||
|
|
||||||
|
d.getContentPane().add(panel)
|
||||||
d.pack()
|
d.pack()
|
||||||
d.setLocationRelativeTo(mainFrame)
|
d.setLocationRelativeTo(mainFrame)
|
||||||
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
||||||
|
|
Loading…
Reference in New Issue