persist watched keywords and regexes
This commit is contained in:
@@ -6,6 +6,7 @@ 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
|
||||||
import com.muwire.core.EventBus
|
import com.muwire.core.EventBus
|
||||||
import com.muwire.core.content.ContentControlEvent
|
import com.muwire.core.content.ContentControlEvent
|
||||||
|
|
||||||
@@ -16,12 +17,19 @@ class ContentPanelController {
|
|||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
ContentPanelView view
|
ContentPanelView view
|
||||||
|
|
||||||
EventBus eventBus
|
Core core
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void addRule() {
|
void addRule() {
|
||||||
def term = view.ruleTextField.text
|
def term = view.ruleTextField.text
|
||||||
eventBus.publish(new ContentControlEvent(term : term, regex : model.regex, add:true))
|
|
||||||
|
if (model.regex)
|
||||||
|
core.muOptions.watchedRegexes.add(term)
|
||||||
|
else
|
||||||
|
core.muOptions.watchedKeywords.add(term)
|
||||||
|
saveMuWireSettings()
|
||||||
|
|
||||||
|
core.eventBus.publish(new ContentControlEvent(term : term, regex : model.regex, add:true))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
@@ -38,4 +46,11 @@ class ContentPanelController {
|
|||||||
void regex() {
|
void regex() {
|
||||||
model.regex = true
|
model.regex = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void saveMuWireSettings() {
|
||||||
|
File f = new File(core.home, "MuWire.properties")
|
||||||
|
f.withOutputStream {
|
||||||
|
core.muOptions.write(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -2,6 +2,7 @@ package com.muwire.gui
|
|||||||
|
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
import com.muwire.core.EventBus
|
import com.muwire.core.EventBus
|
||||||
import com.muwire.core.content.ContentControlEvent
|
import com.muwire.core.content.ContentControlEvent
|
||||||
import com.muwire.core.content.ContentManager
|
import com.muwire.core.content.ContentManager
|
||||||
@@ -17,7 +18,7 @@ class ContentPanelModel {
|
|||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
ContentPanelView view
|
ContentPanelView view
|
||||||
|
|
||||||
EventBus eventBus
|
Core core
|
||||||
|
|
||||||
private ContentManager contentManager
|
private ContentManager contentManager
|
||||||
|
|
||||||
@@ -29,11 +30,11 @@ class ContentPanelModel {
|
|||||||
void mvcGroupInit(Map<String,String> args) {
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
contentManager = application.context.get("core").contentManager
|
contentManager = application.context.get("core").contentManager
|
||||||
rules.addAll(contentManager.matchers)
|
rules.addAll(contentManager.matchers)
|
||||||
eventBus.register(ContentControlEvent.class, this)
|
core.eventBus.register(ContentControlEvent.class, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
void mvcGroupDestroy() {
|
void mvcGroupDestroy() {
|
||||||
eventBus.unregister(ContentControlEvent.class, this)
|
core.eventBus.unregister(ContentControlEvent.class, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh() {
|
void refresh() {
|
||||||
|
@@ -17,6 +17,7 @@ import com.muwire.core.RouterDisconnectedEvent
|
|||||||
import com.muwire.core.connection.ConnectionAttemptStatus
|
import com.muwire.core.connection.ConnectionAttemptStatus
|
||||||
import com.muwire.core.connection.ConnectionEvent
|
import com.muwire.core.connection.ConnectionEvent
|
||||||
import com.muwire.core.connection.DisconnectionEvent
|
import com.muwire.core.connection.DisconnectionEvent
|
||||||
|
import com.muwire.core.content.ContentControlEvent
|
||||||
import com.muwire.core.download.DownloadStartedEvent
|
import com.muwire.core.download.DownloadStartedEvent
|
||||||
import com.muwire.core.download.Downloader
|
import com.muwire.core.download.Downloader
|
||||||
import com.muwire.core.files.AllFilesLoadedEvent
|
import com.muwire.core.files.AllFilesLoadedEvent
|
||||||
@@ -164,6 +165,13 @@ class MainFrameModel {
|
|||||||
core.eventBus.register(UpdateDownloadedEvent.class, this)
|
core.eventBus.register(UpdateDownloadedEvent.class, this)
|
||||||
core.eventBus.register(TrustSubscriptionUpdatedEvent.class, this)
|
core.eventBus.register(TrustSubscriptionUpdatedEvent.class, this)
|
||||||
|
|
||||||
|
core.muOptions.watchedKeywords.each {
|
||||||
|
core.eventBus.publish(new ContentControlEvent(term : it, regex: false, add: true))
|
||||||
|
}
|
||||||
|
core.muOptions.watchedRegexes.each {
|
||||||
|
core.eventBus.publish(new ContentControlEvent(term : it, regex: true, add: true))
|
||||||
|
}
|
||||||
|
|
||||||
timer.schedule({
|
timer.schedule({
|
||||||
if (core.shutdown.get())
|
if (core.shutdown.get())
|
||||||
return
|
return
|
||||||
|
@@ -74,7 +74,7 @@ class MainFrameView {
|
|||||||
menuItem("Configuration", actionPerformed : {mvcGroup.createMVCGroup("Options")})
|
menuItem("Configuration", actionPerformed : {mvcGroup.createMVCGroup("Options")})
|
||||||
menuItem("Content Control", actionPerformed : {
|
menuItem("Content Control", actionPerformed : {
|
||||||
def env = [:]
|
def env = [:]
|
||||||
env["eventBus"] = model.core.eventBus
|
env["core"] = model.core
|
||||||
mvcGroup.createMVCGroup("content-panel", env)
|
mvcGroup.createMVCGroup("content-panel", env)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user