hook up rule creation
This commit is contained in:
@@ -6,13 +6,22 @@ import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import javax.annotation.Nonnull
|
||||
|
||||
import com.muwire.core.EventBus
|
||||
import com.muwire.core.content.ContentControlEvent
|
||||
|
||||
@ArtifactProviderFor(GriffonController)
|
||||
class ContentPanelController {
|
||||
@MVCMember @Nonnull
|
||||
ContentPanelModel model
|
||||
@MVCMember @Nonnull
|
||||
ContentPanelView view
|
||||
|
||||
EventBus eventBus
|
||||
|
||||
@ControllerAction
|
||||
void addRule() {
|
||||
def term = view.ruleTextField.text
|
||||
eventBus.publish(new ContentControlEvent(term : term, regex : model.regex, add:true))
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
|
@@ -1,14 +1,24 @@
|
||||
package com.muwire.gui
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
|
||||
import com.muwire.core.EventBus
|
||||
import com.muwire.core.content.ContentControlEvent
|
||||
import com.muwire.core.content.ContentManager
|
||||
|
||||
import griffon.core.artifact.GriffonModel
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.transform.Observable
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
|
||||
@ArtifactProviderFor(GriffonModel)
|
||||
class ContentPanelModel {
|
||||
|
||||
@MVCMember @Nonnull
|
||||
ContentPanelView view
|
||||
|
||||
EventBus eventBus
|
||||
|
||||
private ContentManager contentManager
|
||||
|
||||
def rules = []
|
||||
@@ -18,13 +28,24 @@ class ContentPanelModel {
|
||||
|
||||
void mvcGroupInit(Map<String,String> args) {
|
||||
contentManager = application.context.get("core").contentManager
|
||||
refresh()
|
||||
rules.addAll(contentManager.matchers)
|
||||
eventBus.register(ContentControlEvent.class, this)
|
||||
}
|
||||
|
||||
void mvcGroupDestroy() {
|
||||
eventBus.unregister(ContentControlEvent.class, this)
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
rules.clear()
|
||||
rules.addAll(contentManager.matchers)
|
||||
hits.clear()
|
||||
// TODO: fire table data changed event
|
||||
view.rulesTable.model.fireTableDataChanged()
|
||||
}
|
||||
|
||||
void onContentControlEvent(ContentControlEvent e) {
|
||||
runInsideUIAsync {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
@@ -47,12 +47,15 @@ class ContentPanelView {
|
||||
}
|
||||
}
|
||||
panel (constraints : BorderLayout.SOUTH) {
|
||||
ruleTextField = textField(action: addRuleAction)
|
||||
buttonGroup(id : "ruleType")
|
||||
radioButton(text: "Keyword", selected : true, buttonGroup: ruleType, keywordAction)
|
||||
radioButton(text: "Regex", selected : false, buttonGroup: ruleType, regexAction)
|
||||
button(text : "Add Rule", addRuleAction)
|
||||
button(text : "Delete Rule", deleteRuleAction) // TODO: enable/disable
|
||||
borderLayout()
|
||||
ruleTextField = textField(constraints: BorderLayout.CENTER, action: addRuleAction)
|
||||
panel (constraints: BorderLayout.EAST) {
|
||||
buttonGroup(id : "ruleType")
|
||||
radioButton(text: "Keyword", selected : true, buttonGroup: ruleType, keywordAction)
|
||||
radioButton(text: "Regex", selected : false, buttonGroup: ruleType, regexAction)
|
||||
button(text : "Add Rule", addRuleAction)
|
||||
button(text : "Delete Rule", deleteRuleAction) // TODO: enable/disable
|
||||
}
|
||||
}
|
||||
}
|
||||
panel {
|
||||
|
@@ -72,7 +72,11 @@ class MainFrameView {
|
||||
menuBar {
|
||||
menu (text : "Options") {
|
||||
menuItem("Configuration", actionPerformed : {mvcGroup.createMVCGroup("Options")})
|
||||
menuItem("Content Control", actionPerformed : {mvcGroup.createMVCGroup("content-panel")})
|
||||
menuItem("Content Control", actionPerformed : {
|
||||
def env = [:]
|
||||
env["eventBus"] = model.core.eventBus
|
||||
mvcGroup.createMVCGroup("content-panel", env)
|
||||
})
|
||||
}
|
||||
menu (text : "Status") {
|
||||
menuItem("MuWire", actionPerformed : {mvcGroup.createMVCGroup("mu-wire-status")})
|
||||
|
Reference in New Issue
Block a user