Trust panel, wip

This commit is contained in:
Zlatin Balevsky
2019-06-02 05:40:44 +01:00
parent 0f4533c867
commit ba596af778
2 changed files with 62 additions and 5 deletions

View File

@@ -45,6 +45,8 @@ class MainFrameModel {
def shared = [] def shared = []
def connectionList = [] def connectionList = []
def searches = new LinkedList() def searches = new LinkedList()
def trusted = []
def distrusted = []
@Observable int connections @Observable int connections
@Observable String me @Observable String me
@@ -56,6 +58,13 @@ class MainFrameModel {
volatile Core core volatile Core core
void updateTablePreservingSelection(String tableName) {
def downloadTable = builder.getVariable(tableName)
int selectedRow = downloadTable.getSelectedRow()
downloadTable.model.fireTableDataChanged()
downloadTable.selectionModel.setSelectionInterval(selectedRow,selectedRow)
}
void mvcGroupInit(Map<String, Object> args) { void mvcGroupInit(Map<String, Object> args) {
Timer timer = new Timer("download-pumper", true) Timer timer = new Timer("download-pumper", true)
@@ -65,10 +74,9 @@ class MainFrameModel {
return return
builder.getVariable("uploads-table")?.model.fireTableDataChanged() builder.getVariable("uploads-table")?.model.fireTableDataChanged()
def downloadTable = builder.getVariable("downloads-table") updateTablePreservingSelection("downloads-table")
int selectedRow = downloadTable.getSelectedRow() updateTablePreservingSelection("trusted-table")
downloadTable.model.fireTableDataChanged() updateTablePreservingSelection("distrusted-table")
downloadTable.selectionModel.setSelectionInterval(selectedRow,selectedRow)
} }
}, 1000, 1000) }, 1000, 1000)
@@ -100,7 +108,12 @@ class MainFrameModel {
}, retryInterval, retryInterval) }, retryInterval, retryInterval)
} }
runInsideUIAsync {
trusted.addAll(core.trustService.good.values())
distrusted.addAll(core.trustService.bad.values())
}
}) })
} }
void onUIResultEvent(UIResultEvent e) { void onUIResultEvent(UIResultEvent e) {
@@ -190,6 +203,14 @@ class MainFrameModel {
runInsideUIAsync { runInsideUIAsync {
JTable table = builder.getVariable("results-table") JTable table = builder.getVariable("results-table")
table.model.fireTableDataChanged() table.model.fireTableDataChanged()
trusted.clear()
trusted.addAll(core.trustService.good.values())
distrusted.clear()
distrusted.addAll(core.trustService.bad.values())
updateTablePreservingSelection("trusted-table")
updateTablePreservingSelection("distrusted-table")
} }
} }

View File

@@ -51,6 +51,7 @@ class MainFrameView {
button(text: "Searches", actionPerformed : showSearchWindow) button(text: "Searches", actionPerformed : showSearchWindow)
button(text: "Uploads", actionPerformed : showUploadsWindow) button(text: "Uploads", actionPerformed : showUploadsWindow)
button(text: "Monitor", actionPerformed : showMonitorWindow) button(text: "Monitor", actionPerformed : showMonitorWindow)
button(text: "Trust", actionPerformed : showTrustWindow)
} }
panel(id: "top-panel", constraints: BorderLayout.CENTER) { panel(id: "top-panel", constraints: BorderLayout.CENTER) {
cardLayout() cardLayout()
@@ -181,6 +182,36 @@ class MainFrameView {
} }
} }
} }
panel(constraints : "trust window") {
gridLayout(rows: 1, cols :3)
panel {
borderLayout()
panel (constraints : BorderLayout.NORTH) {
label("Trusted users")
}
scrollPane(constraints : BorderLayout.CENTER) {
table(id : "trusted-table") {
tableModel(list : model.trusted) {
closureColumn(type : String, read : { it.getHumanReadableName() } )
}
}
}
}
panel { label("buttons go here")}
panel {
borderLayout()
panel (constraints : BorderLayout.NORTH) {
label("Distrusted users")
}
scrollPane(constraints : BorderLayout.CENTER) {
table(id : "distrusted-table") {
tableModel(list : model.distrusted) {
closureColumn(type : String, read : { it.getHumanReadableName() } )
}
}
}
}
}
} }
panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) { panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) {
borderLayout() borderLayout()
@@ -234,6 +265,11 @@ class MainFrameView {
cardsPanel.getLayout().show(cardsPanel,"monitor window") cardsPanel.getLayout().show(cardsPanel,"monitor window")
} }
def showTrustWindow = {
def cardsPanel = builder.getVariable("cards-panel")
cardsPanel.getLayout().show(cardsPanel,"trust window")
}
def shareFiles = { def shareFiles = {
def chooser = new JFileChooser() def chooser = new JFileChooser()
chooser.setDialogTitle("Select file or directory to share") chooser.setDialogTitle("Select file or directory to share")