add chat pane and associated components
This commit is contained in:
@@ -111,4 +111,14 @@ mvcGroups {
|
|||||||
view = "com.muwire.gui.DownloadPreviewView"
|
view = "com.muwire.gui.DownloadPreviewView"
|
||||||
controller = "com.muwire.gui.DownloadPreviewController"
|
controller = "com.muwire.gui.DownloadPreviewController"
|
||||||
}
|
}
|
||||||
|
'chat-server' {
|
||||||
|
model = 'com.muwire.gui.ChatServerModel'
|
||||||
|
view = 'com.muwire.gui.ChatServerView'
|
||||||
|
controller = 'com.muwire.gui.ChatServerController'
|
||||||
|
}
|
||||||
|
'chat-room' {
|
||||||
|
model = 'com.muwire.gui.ChatRoomModel'
|
||||||
|
view = 'com.muwire.gui.ChatRoomView'
|
||||||
|
controller = 'com.muwire.gui.ChatRoomController'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,17 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonController)
|
||||||
|
class ChatRoomController {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
ChatRoomModel model
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void say() {
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,17 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonController)
|
||||||
|
class ChatServerController {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
ChatServerModel model
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void disconnect() {
|
||||||
|
}
|
||||||
|
}
|
@@ -421,6 +421,30 @@ class MainFrameController {
|
|||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void startChatServer() {
|
||||||
|
model.core.chatServer.start()
|
||||||
|
model.chatServerRunning = true
|
||||||
|
|
||||||
|
if (!mvcGroup.getChildrenGroups().containsKey("local-chat-server")) {
|
||||||
|
def params = [:]
|
||||||
|
params['core'] = model.core
|
||||||
|
params['host'] = model.core.me
|
||||||
|
mvcGroup.createMVCGroup("chat-server","local-chat-server", params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void stopChatServer() {
|
||||||
|
model.core.chatServer.stop()
|
||||||
|
model.chatServerRunning = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void connectChatServer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void saveMuWireSettings() {
|
void saveMuWireSettings() {
|
||||||
core.saveMuSettings()
|
core.saveMuSettings()
|
||||||
}
|
}
|
||||||
|
14
gui/griffon-app/models/com/muwire/gui/ChatRoomModel.groovy
Normal file
14
gui/griffon-app/models/com/muwire/gui/ChatRoomModel.groovy
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonModel
|
||||||
|
import griffon.transform.Observable
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonModel)
|
||||||
|
class ChatRoomModel {
|
||||||
|
Core core
|
||||||
|
String tabName
|
||||||
|
String room
|
||||||
|
}
|
21
gui/griffon-app/models/com/muwire/gui/ChatServerModel.groovy
Normal file
21
gui/griffon-app/models/com/muwire/gui/ChatServerModel.groovy
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.Persona
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonModel
|
||||||
|
import griffon.transform.Observable
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonModel)
|
||||||
|
class ChatServerModel {
|
||||||
|
Persona host
|
||||||
|
Core core
|
||||||
|
|
||||||
|
@Observable boolean disconnectActionEnabled
|
||||||
|
|
||||||
|
|
||||||
|
void mvcGroupInit(Map<String, String> params) {
|
||||||
|
disconnectActionEnabled = host != core.me // can't disconnect from myself
|
||||||
|
}
|
||||||
|
}
|
@@ -117,6 +117,9 @@ class MainFrameModel {
|
|||||||
@Observable boolean uploadsPaneButtonEnabled
|
@Observable boolean uploadsPaneButtonEnabled
|
||||||
@Observable boolean monitorPaneButtonEnabled
|
@Observable boolean monitorPaneButtonEnabled
|
||||||
@Observable boolean trustPaneButtonEnabled
|
@Observable boolean trustPaneButtonEnabled
|
||||||
|
@Observable boolean chatPaneButtonEnabled
|
||||||
|
|
||||||
|
@Observable boolean chatServerRunning
|
||||||
|
|
||||||
@Observable Downloader downloader
|
@Observable Downloader downloader
|
||||||
|
|
||||||
@@ -218,6 +221,8 @@ class MainFrameModel {
|
|||||||
core.eventBus.publish(new ContentControlEvent(term : it, regex: true, add: true))
|
core.eventBus.publish(new ContentControlEvent(term : it, regex: true, add: true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chatServerRunning = core.chatServer.running.get()
|
||||||
|
|
||||||
timer.schedule({
|
timer.schedule({
|
||||||
if (core.shutdown.get())
|
if (core.shutdown.get())
|
||||||
return
|
return
|
||||||
|
61
gui/griffon-app/views/com/muwire/gui/ChatRoomView.groovy
Normal file
61
gui/griffon-app/views/com/muwire/gui/ChatRoomView.groovy
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonView
|
||||||
|
import griffon.inject.MVCMember
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
import javax.swing.SwingConstants
|
||||||
|
|
||||||
|
import java.awt.BorderLayout
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonView)
|
||||||
|
class ChatRoomView {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FactoryBuilderSupport builder
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
ChatRoomModel model
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
ChatRoomController controller
|
||||||
|
|
||||||
|
def pane
|
||||||
|
def parent
|
||||||
|
|
||||||
|
void initUI() {
|
||||||
|
pane = builder.panel {
|
||||||
|
borderLayout()
|
||||||
|
panel(constraints : BorderLayout.CENTER) {
|
||||||
|
textArea(editable : false)
|
||||||
|
}
|
||||||
|
panel(constraints : BorderLayout.SOUTH) {
|
||||||
|
borderLayout()
|
||||||
|
textField(actionPerformed : {controller.say()}, constraints : BorderLayout.CENTER)
|
||||||
|
button(text : "Say", constraints : BorderLayout.EAST, sayAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
|
parent = mvcGroup.parentGroup.view.builder.getVariable(model.tabName)
|
||||||
|
parent.addTab(model.room, pane)
|
||||||
|
|
||||||
|
int index = parent.indexOfComponent(pane)
|
||||||
|
parent.setSelectedIndex(index)
|
||||||
|
|
||||||
|
def tabPanel = builder.panel {
|
||||||
|
borderLayout()
|
||||||
|
panel (constraints : BorderLayout.CENTER) {
|
||||||
|
label(text : model.room)
|
||||||
|
}
|
||||||
|
button(icon : imageIcon("/close_tab.png"), preferredSize: [20, 20], constraints : BorderLayout.EAST,
|
||||||
|
actionPerformed : closeTab )
|
||||||
|
}
|
||||||
|
parent.setTabComponentAt(index, tabPanel)
|
||||||
|
}
|
||||||
|
|
||||||
|
def closeTab = {
|
||||||
|
int index = parent.indexOfComponent(pane)
|
||||||
|
parent.removeTabAt(index)
|
||||||
|
mvcGroup.destroy()
|
||||||
|
}
|
||||||
|
}
|
65
gui/griffon-app/views/com/muwire/gui/ChatServerView.groovy
Normal file
65
gui/griffon-app/views/com/muwire/gui/ChatServerView.groovy
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonView
|
||||||
|
import griffon.inject.MVCMember
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
import javax.swing.SwingConstants
|
||||||
|
|
||||||
|
import java.awt.BorderLayout
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonView)
|
||||||
|
class ChatServerView {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FactoryBuilderSupport builder
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
ChatServerModel model
|
||||||
|
|
||||||
|
def pane
|
||||||
|
def parent
|
||||||
|
|
||||||
|
void initUI() {
|
||||||
|
pane = builder.panel {
|
||||||
|
borderLayout()
|
||||||
|
tabbedPane(id : model.host.getHumanReadableName()+"-chat-rooms", constraints : BorderLayout.CENTER)
|
||||||
|
panel(constraints : BorderLayout.SOUTH) {
|
||||||
|
button(text : "Disconnect", enabled : bind {model.disconnectActionEnabled}, disconnectAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
|
parent = mvcGroup.parentGroup.view.builder.getVariable("chat-tabs")
|
||||||
|
parent.addTab(model.host.getHumanReadableName(), pane)
|
||||||
|
|
||||||
|
int index = parent.indexOfComponent(pane)
|
||||||
|
parent.setSelectedIndex(index)
|
||||||
|
|
||||||
|
def tabPanel
|
||||||
|
builder.with {
|
||||||
|
tabPanel = panel {
|
||||||
|
borderLayout()
|
||||||
|
panel (constraints : BorderLayout.CENTER) {
|
||||||
|
String text = model.host == model.core.me ? "Local Server" : model.host.getHumanReadableName()
|
||||||
|
label(text : text)
|
||||||
|
}
|
||||||
|
button(icon : imageIcon("/close_tab.png"), preferredSize: [20, 20], constraints : BorderLayout.EAST,
|
||||||
|
actionPerformed : closeTab )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parent.setTabComponentAt(index, tabPanel)
|
||||||
|
|
||||||
|
def params = [:]
|
||||||
|
params['core'] = model.core
|
||||||
|
params['tabName'] = model.host.getHumanReadableName() + "-chat-rooms"
|
||||||
|
params['room'] = 'Console'
|
||||||
|
mvcGroup.createMVCGroup("chat-room","Console", params)
|
||||||
|
}
|
||||||
|
|
||||||
|
def closeTab = {
|
||||||
|
int index = parent.indexOfComponent(pane)
|
||||||
|
parent.removeTabAt(index)
|
||||||
|
mvcGroup.destroy()
|
||||||
|
}
|
||||||
|
}
|
@@ -142,6 +142,7 @@ class MainFrameView {
|
|||||||
if (settings.showMonitor)
|
if (settings.showMonitor)
|
||||||
button(text: "Monitor", enabled: bind{model.monitorPaneButtonEnabled},actionPerformed : showMonitorWindow)
|
button(text: "Monitor", enabled: bind{model.monitorPaneButtonEnabled},actionPerformed : showMonitorWindow)
|
||||||
button(text: "Trust", enabled:bind{model.trustPaneButtonEnabled},actionPerformed : showTrustWindow)
|
button(text: "Trust", enabled:bind{model.trustPaneButtonEnabled},actionPerformed : showTrustWindow)
|
||||||
|
button(text: "Chat", enabled : bind{model.chatPaneButtonEnabled}, actionPerformed : showChatWindow)
|
||||||
}
|
}
|
||||||
panel(id: "top-panel", constraints: BorderLayout.CENTER) {
|
panel(id: "top-panel", constraints: BorderLayout.CENTER) {
|
||||||
cardLayout()
|
cardLayout()
|
||||||
@@ -475,6 +476,15 @@ class MainFrameView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
panel(constraints : "chat window") {
|
||||||
|
borderLayout()
|
||||||
|
tabbedPane(id : "chat-tabs", constraints : BorderLayout.CENTER)
|
||||||
|
panel(constraints : BorderLayout.SOUTH) {
|
||||||
|
button(text : "Start Chat Server", enabled : bind {!model.chatServerRunning}, startChatServerAction)
|
||||||
|
button(text : "Stop Chat Server", enabled : bind {model.chatServerRunning}, stopChatServerAction)
|
||||||
|
button(text : "Connect To Remote Server", connectChatServerAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) {
|
panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
@@ -986,6 +996,7 @@ class MainFrameView {
|
|||||||
model.uploadsPaneButtonEnabled = true
|
model.uploadsPaneButtonEnabled = true
|
||||||
model.monitorPaneButtonEnabled = true
|
model.monitorPaneButtonEnabled = true
|
||||||
model.trustPaneButtonEnabled = true
|
model.trustPaneButtonEnabled = true
|
||||||
|
model.chatPaneButtonEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
def showDownloadsWindow = {
|
def showDownloadsWindow = {
|
||||||
@@ -996,6 +1007,7 @@ class MainFrameView {
|
|||||||
model.uploadsPaneButtonEnabled = true
|
model.uploadsPaneButtonEnabled = true
|
||||||
model.monitorPaneButtonEnabled = true
|
model.monitorPaneButtonEnabled = true
|
||||||
model.trustPaneButtonEnabled = true
|
model.trustPaneButtonEnabled = true
|
||||||
|
model.chatPaneButtonEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
def showUploadsWindow = {
|
def showUploadsWindow = {
|
||||||
@@ -1006,6 +1018,7 @@ class MainFrameView {
|
|||||||
model.uploadsPaneButtonEnabled = false
|
model.uploadsPaneButtonEnabled = false
|
||||||
model.monitorPaneButtonEnabled = true
|
model.monitorPaneButtonEnabled = true
|
||||||
model.trustPaneButtonEnabled = true
|
model.trustPaneButtonEnabled = true
|
||||||
|
model.chatPaneButtonEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
def showMonitorWindow = {
|
def showMonitorWindow = {
|
||||||
@@ -1016,6 +1029,7 @@ class MainFrameView {
|
|||||||
model.uploadsPaneButtonEnabled = true
|
model.uploadsPaneButtonEnabled = true
|
||||||
model.monitorPaneButtonEnabled = false
|
model.monitorPaneButtonEnabled = false
|
||||||
model.trustPaneButtonEnabled = true
|
model.trustPaneButtonEnabled = true
|
||||||
|
model.chatPaneButtonEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
def showTrustWindow = {
|
def showTrustWindow = {
|
||||||
@@ -1026,6 +1040,18 @@ class MainFrameView {
|
|||||||
model.uploadsPaneButtonEnabled = true
|
model.uploadsPaneButtonEnabled = true
|
||||||
model.monitorPaneButtonEnabled = true
|
model.monitorPaneButtonEnabled = true
|
||||||
model.trustPaneButtonEnabled = false
|
model.trustPaneButtonEnabled = false
|
||||||
|
model.chatPaneButtonEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
def showChatWindow = {
|
||||||
|
def cardsPanel = builder.getVariable("cards-panel")
|
||||||
|
cardsPanel.getLayout().show(cardsPanel, "chat window")
|
||||||
|
model.searchesPaneButtonEnabled = true
|
||||||
|
model.downloadsPaneButtonEnabled = true
|
||||||
|
model.uploadsPaneButtonEnabled = true
|
||||||
|
model.monitorPaneButtonEnabled = true
|
||||||
|
model.trustPaneButtonEnabled = true
|
||||||
|
model.chatPaneButtonEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
def showSharedFilesTable = {
|
def showSharedFilesTable = {
|
||||||
|
Reference in New Issue
Block a user