mirror of https://github.com/zlatinb/muwire
hook up search to controller
parent
d7cb534813
commit
2539461c0e
|
@ -1,18 +1,35 @@
|
|||
package com.muwire.gui
|
||||
|
||||
import griffon.core.GriffonApplication
|
||||
import griffon.core.artifact.GriffonController
|
||||
import griffon.core.controller.ControllerAction
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import javax.annotation.Nonnull
|
||||
import javax.inject.Inject
|
||||
|
||||
import com.muwire.core.Core
|
||||
|
||||
@ArtifactProviderFor(GriffonController)
|
||||
class MainFrameController {
|
||||
@Inject @Nonnull GriffonApplication application
|
||||
@MVCMember @Nonnull
|
||||
FactoryBuilderSupport builder
|
||||
|
||||
@MVCMember @Nonnull
|
||||
MainFrameModel model
|
||||
|
||||
private volatile Core core
|
||||
|
||||
private initCore() {
|
||||
if (core == null)
|
||||
core = application.getContext().get("core")
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void click() {
|
||||
model.clickCount++
|
||||
void search() {
|
||||
initCore()
|
||||
def search = builder.getVariable("search-field").text
|
||||
println "searching $search"
|
||||
}
|
||||
}
|
|
@ -13,8 +13,10 @@ class MainFrameModel {
|
|||
@Inject @Nonnull GriffonApplication application
|
||||
@Observable boolean coreInitialized = false
|
||||
|
||||
@Observable def results
|
||||
@Observable def downloads
|
||||
@Observable def results = []
|
||||
@Observable def downloads = []
|
||||
|
||||
String currentSearch
|
||||
|
||||
void mvcGroupInit(Map<String, Object> args) {
|
||||
application.addPropertyChangeListener("core", {e ->
|
||||
|
|
|
@ -26,7 +26,7 @@ class MainFrameView {
|
|||
FactoryBuilderSupport builder
|
||||
@MVCMember @Nonnull
|
||||
MainFrameModel model
|
||||
|
||||
|
||||
void initUI() {
|
||||
builder.with {
|
||||
application(size : [1024,768], id: 'main-frame',
|
||||
|
@ -48,10 +48,11 @@ class MainFrameView {
|
|||
panel(constraints: BorderLayout.CENTER) {
|
||||
borderLayout()
|
||||
label("Enter search here:", constraints: BorderLayout.WEST)
|
||||
textField(constraints: BorderLayout.CENTER)
|
||||
textField(id: "search-field", constraints: BorderLayout.CENTER, action : searchAction)
|
||||
|
||||
}
|
||||
panel( constraints: BorderLayout.EAST) {
|
||||
button("Search")
|
||||
button(text: "Search", searchAction)
|
||||
}
|
||||
}
|
||||
panel (id: "cards-panel", constraints : BorderLayout.CENTER) {
|
||||
|
|
Loading…
Reference in New Issue