hook up search to controller
This commit is contained in:
@@ -1,18 +1,35 @@
|
|||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.GriffonApplication
|
||||||
import griffon.core.artifact.GriffonController
|
import griffon.core.artifact.GriffonController
|
||||||
import griffon.core.controller.ControllerAction
|
import griffon.core.controller.ControllerAction
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class MainFrameController {
|
class MainFrameController {
|
||||||
|
@Inject @Nonnull GriffonApplication application
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FactoryBuilderSupport builder
|
||||||
|
|
||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
MainFrameModel model
|
MainFrameModel model
|
||||||
|
|
||||||
|
private volatile Core core
|
||||||
|
|
||||||
|
private initCore() {
|
||||||
|
if (core == null)
|
||||||
|
core = application.getContext().get("core")
|
||||||
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void click() {
|
void search() {
|
||||||
model.clickCount++
|
initCore()
|
||||||
|
def search = builder.getVariable("search-field").text
|
||||||
|
println "searching $search"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,8 +13,10 @@ class MainFrameModel {
|
|||||||
@Inject @Nonnull GriffonApplication application
|
@Inject @Nonnull GriffonApplication application
|
||||||
@Observable boolean coreInitialized = false
|
@Observable boolean coreInitialized = false
|
||||||
|
|
||||||
@Observable def results
|
@Observable def results = []
|
||||||
@Observable def downloads
|
@Observable def downloads = []
|
||||||
|
|
||||||
|
String currentSearch
|
||||||
|
|
||||||
void mvcGroupInit(Map<String, Object> args) {
|
void mvcGroupInit(Map<String, Object> args) {
|
||||||
application.addPropertyChangeListener("core", {e ->
|
application.addPropertyChangeListener("core", {e ->
|
||||||
|
|||||||
@@ -48,10 +48,11 @@ class MainFrameView {
|
|||||||
panel(constraints: BorderLayout.CENTER) {
|
panel(constraints: BorderLayout.CENTER) {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
label("Enter search here:", constraints: BorderLayout.WEST)
|
label("Enter search here:", constraints: BorderLayout.WEST)
|
||||||
textField(constraints: BorderLayout.CENTER)
|
textField(id: "search-field", constraints: BorderLayout.CENTER, action : searchAction)
|
||||||
|
|
||||||
}
|
}
|
||||||
panel( constraints: BorderLayout.EAST) {
|
panel( constraints: BorderLayout.EAST) {
|
||||||
button("Search")
|
button(text: "Search", searchAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel (id: "cards-panel", constraints : BorderLayout.CENTER) {
|
panel (id: "cards-panel", constraints : BorderLayout.CENTER) {
|
||||||
|
|||||||
Reference in New Issue
Block a user