mirror of https://github.com/zlatinb/muwire
individual feed configuration panel
parent
2bb07ff7b5
commit
c082e25c81
|
@ -126,4 +126,9 @@ mvcGroups {
|
||||||
view = 'com.muwire.gui.ChatMonitorView'
|
view = 'com.muwire.gui.ChatMonitorView'
|
||||||
controller = 'com.muwire.gui.ChatMonitorController'
|
controller = 'com.muwire.gui.ChatMonitorController'
|
||||||
}
|
}
|
||||||
|
'feed-configuration' {
|
||||||
|
model = 'com.muwire.gui.FeedConfigurationModel'
|
||||||
|
view = 'com.muwire.gui.FeedConfigurationView'
|
||||||
|
controller = 'com.muwire.gui.FeedConfigurationController'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonController
|
||||||
|
import griffon.core.controller.ControllerAction
|
||||||
|
import griffon.inject.MVCMember
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
import com.muwire.core.filefeeds.UIFeedConfigurationEvent
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonController)
|
||||||
|
class FeedConfigurationController {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FeedConfigurationModel model
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FeedConfigurationView view
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void save() {
|
||||||
|
|
||||||
|
model.feed.setAutoDownload(view.autoDownloadCheckbox.model.isSelected())
|
||||||
|
model.feed.setSequential(view.sequentialCheckbox.model.isSelected())
|
||||||
|
model.feed.setItemsToKeep(Integer.parseInt(view.itemsToKeepField.text))
|
||||||
|
model.feed.setUpdateInterval(Integer.parseInt(view.updateIntervalField.text) * 60000)
|
||||||
|
|
||||||
|
model.core.eventBus.publish(new UIFeedConfigurationEvent(feed : model.feed))
|
||||||
|
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void cancel() {
|
||||||
|
view.dialog.setVisible(false)
|
||||||
|
mvcGroup.destroy()
|
||||||
|
}
|
||||||
|
}
|
|
@ -556,7 +556,14 @@ class MainFrameController {
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void configureFileFeed() {
|
void configureFileFeed() {
|
||||||
|
Feed feed = view.selectedFeed()
|
||||||
|
if (feed == null)
|
||||||
|
return
|
||||||
|
|
||||||
|
def params = [:]
|
||||||
|
params['core'] = core
|
||||||
|
params['feed'] = feed
|
||||||
|
mvcGroup.createMVCGroup("feed-configuration", params)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.filefeeds.Feed
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonModel
|
||||||
|
import griffon.transform.Observable
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonModel)
|
||||||
|
class FeedConfigurationModel {
|
||||||
|
Core core
|
||||||
|
Feed feed
|
||||||
|
|
||||||
|
@Observable boolean autoDownload
|
||||||
|
@Observable boolean sequential
|
||||||
|
@Observable int updateInterval
|
||||||
|
@Observable int itemsToKeep
|
||||||
|
|
||||||
|
void mvcGroupInit(Map<String, String> args) {
|
||||||
|
autoDownload = feed.isAutoDownload()
|
||||||
|
sequential = feed.isSequential()
|
||||||
|
updateInterval = feed.getUpdateInterval() / 60000
|
||||||
|
itemsToKeep = feed.getItemsToKeep()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonView
|
||||||
|
import griffon.inject.MVCMember
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
|
import javax.swing.JDialog
|
||||||
|
import javax.swing.SwingConstants
|
||||||
|
|
||||||
|
import java.awt.BorderLayout
|
||||||
|
import java.awt.GridBagConstraints
|
||||||
|
import java.awt.event.WindowAdapter
|
||||||
|
import java.awt.event.WindowEvent
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonView)
|
||||||
|
class FeedConfigurationView {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FactoryBuilderSupport builder
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FeedConfigurationModel model
|
||||||
|
|
||||||
|
def dialog
|
||||||
|
def p
|
||||||
|
def mainFrame
|
||||||
|
|
||||||
|
def autoDownloadCheckbox
|
||||||
|
def sequentialCheckbox
|
||||||
|
def itemsToKeepField
|
||||||
|
def updateIntervalField
|
||||||
|
|
||||||
|
void initUI() {
|
||||||
|
mainFrame = application.windowManager.findWindow("main-frame")
|
||||||
|
dialog = new JDialog(mainFrame, "Feed Configuration", true)
|
||||||
|
dialog.setResizable(false)
|
||||||
|
|
||||||
|
p = builder.panel {
|
||||||
|
borderLayout()
|
||||||
|
panel (constraints : BorderLayout.NORTH) {
|
||||||
|
label("Configuration for feed " + model.feed.getPublisher().getHumanReadableName())
|
||||||
|
}
|
||||||
|
panel (constraints : BorderLayout.CENTER) {
|
||||||
|
gridBagLayout()
|
||||||
|
label(text : "Automatically download files from feed", constraints : gbc(gridx: 0, gridy : 0, anchor : GridBagConstraints.LINE_START, weightx: 100))
|
||||||
|
autoDownloadCheckbox = checkBox(selected : bind {model.autoDownload}, constraints : gbc(gridx: 1, gridy : 0, anchor : GridBagConstraints.LINE_END))
|
||||||
|
label(text : "Download files from feed sequentially", constraints : gbc(gridx: 0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx: 100))
|
||||||
|
sequentialCheckbox = checkBox(selected : bind {model.sequential}, constraints : gbc(gridx: 1, gridy : 1, anchor : GridBagConstraints.LINE_END))
|
||||||
|
label(text : "Feed items to store on disk (-1 means unlimited)", constraints : gbc(gridx: 0, gridy : 2, anchor : GridBagConstraints.LINE_START, weightx: 100))
|
||||||
|
itemsToKeepField = textField(text : bind {model.itemsToKeep}, constraints:gbc(gridx :1, gridy:2, anchor : GridBagConstraints.LINE_END))
|
||||||
|
label(text : "Feed refresh frequency in minutes", constraints : gbc(gridx: 0, gridy : 3, anchor : GridBagConstraints.LINE_START, weightx: 100))
|
||||||
|
updateIntervalField = textField(text : bind {model.updateInterval}, constraints:gbc(gridx :1, gridy:3, anchor : GridBagConstraints.LINE_END))
|
||||||
|
}
|
||||||
|
panel (constraints : BorderLayout.SOUTH) {
|
||||||
|
button(text : "Save", saveAction)
|
||||||
|
button(text : "Cancel", cancelAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
|
dialog.getContentPane().add(p)
|
||||||
|
dialog.pack()
|
||||||
|
dialog.setLocationRelativeTo(mainFrame)
|
||||||
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
||||||
|
dialog.addWindowListener(new WindowAdapter() {
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
mvcGroup.destroy()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue