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 connectionList = []
def searches = new LinkedList()
def trusted = []
def distrusted = []
@Observable int connections
@Observable String me
@@ -56,6 +58,13 @@ class MainFrameModel {
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) {
Timer timer = new Timer("download-pumper", true)
@@ -64,11 +73,10 @@ class MainFrameModel {
if (!mvcGroup.alive)
return
builder.getVariable("uploads-table")?.model.fireTableDataChanged()
def downloadTable = builder.getVariable("downloads-table")
int selectedRow = downloadTable.getSelectedRow()
downloadTable.model.fireTableDataChanged()
downloadTable.selectionModel.setSelectionInterval(selectedRow,selectedRow)
updateTablePreservingSelection("downloads-table")
updateTablePreservingSelection("trusted-table")
updateTablePreservingSelection("distrusted-table")
}
}, 1000, 1000)
@@ -100,7 +108,12 @@ class MainFrameModel {
}, retryInterval, retryInterval)
}
runInsideUIAsync {
trusted.addAll(core.trustService.good.values())
distrusted.addAll(core.trustService.bad.values())
}
})
}
void onUIResultEvent(UIResultEvent e) {
@@ -190,6 +203,14 @@ class MainFrameModel {
runInsideUIAsync {
JTable table = builder.getVariable("results-table")
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: "Uploads", actionPerformed : showUploadsWindow)
button(text: "Monitor", actionPerformed : showMonitorWindow)
button(text: "Trust", actionPerformed : showTrustWindow)
}
panel(id: "top-panel", constraints: BorderLayout.CENTER) {
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) {
borderLayout()
@@ -234,6 +265,11 @@ class MainFrameView {
cardsPanel.getLayout().show(cardsPanel,"monitor window")
}
def showTrustWindow = {
def cardsPanel = builder.getVariable("cards-panel")
cardsPanel.getLayout().show(cardsPanel,"trust window")
}
def shareFiles = {
def chooser = new JFileChooser()
chooser.setDialogTitle("Select file or directory to share")