From c51e3874dabe38e666049259bba08282a4628599 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 2 Jun 2019 04:12:11 +0100 Subject: [PATCH] show a message instead of search bar while disconnected --- .../com/muwire/gui/MainFrameModel.groovy | 11 ++++++++ .../views/com/muwire/gui/MainFrameView.groovy | 25 +++++++++++++------ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index 08f16422..2bb64964 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -120,6 +120,11 @@ class MainFrameModel { runInsideUIAsync { connections = core.connectionManager.getConnections().size() + if (connections > 0) { + def topPanel = builder.getVariable("top-panel") + topPanel.getLayout().show(topPanel, "top-search-panel") + } + connectionList.add(e.endpoint.destination) JTable table = builder.getVariable("connections-table") table.model.fireTableDataChanged() @@ -129,6 +134,12 @@ class MainFrameModel { void onDisconnectionEvent(DisconnectionEvent e) { runInsideUIAsync { connections = core.connectionManager.getConnections().size() + + if (connections == 0) { + def topPanel = builder.getVariable("top-panel") + topPanel.getLayout().show(topPanel, "top-connect-panel") + } + connectionList.remove(e.destination) JTable table = builder.getVariable("connections-table") table.model.fireTableDataChanged() diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index ce461885..7209eb59 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -52,14 +52,23 @@ class MainFrameView { button(text: "Uploads", actionPerformed : showUploadsWindow) button(text: "Monitor", actionPerformed : showMonitorWindow) } - panel(constraints: BorderLayout.CENTER) { - borderLayout() - label(" Enter search here:", constraints: BorderLayout.WEST) // TODO: fix this - textField(id: "search-field", constraints: BorderLayout.CENTER, action : searchAction) - - } - panel( constraints: BorderLayout.EAST) { - button(text: "Search", searchAction) + panel(id: "top-panel", constraints: BorderLayout.CENTER) { + cardLayout() + panel(constraints : "top-connect-panel") { + label(text : "MuWire is connecting, please wait. You will be able to search soon.") + } + panel(constraints : "top-search-panel") { + borderLayout() + panel(constraints: BorderLayout.CENTER) { + borderLayout() + label(" Enter search here:", constraints: BorderLayout.WEST) // TODO: fix this + textField(id: "search-field", constraints: BorderLayout.CENTER, action : searchAction) + + } + panel( constraints: BorderLayout.EAST) { + button(text: "Search", searchAction) + } + } } } panel (id: "cards-panel", constraints : BorderLayout.CENTER) {