mirror of https://github.com/zlatinb/muwire
merge the two tables in the remote trust list view into one. Replace trust/distrust buttons with View Profile
parent
dd5d79e27a
commit
e10029a82e
|
@ -201,7 +201,7 @@ class BrowseController {
|
||||||
params.core = core
|
params.core = core
|
||||||
params.persona = model.host
|
params.persona = model.host
|
||||||
params.uuid = uuid
|
params.uuid = uuid
|
||||||
params.profileTitle = HTMLSanitizer.sanitize(header?.getTitle())
|
params.profileHeader = header
|
||||||
|
|
||||||
mvcGroup.createMVCGroup("view-profile", uuid.toString(), params)
|
mvcGroup.createMVCGroup("view-profile", uuid.toString(), params)
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ class MainFrameController {
|
||||||
Map<String,Object> env = new HashMap<>()
|
Map<String,Object> env = new HashMap<>()
|
||||||
env["trustList"] = list
|
env["trustList"] = list
|
||||||
env["trustService"] = core.trustService
|
env["trustService"] = core.trustService
|
||||||
env["eventBus"] = core.eventBus
|
env["core"] = core
|
||||||
mvcGroup.createMVCGroup("trust-list", env)
|
mvcGroup.createMVCGroup("trust-list", env)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.profile.MWProfileHeader
|
||||||
import com.muwire.gui.profile.TrustPOP
|
import com.muwire.gui.profile.TrustPOP
|
||||||
import griffon.core.artifact.GriffonController
|
import griffon.core.artifact.GriffonController
|
||||||
import griffon.core.controller.ControllerAction
|
import griffon.core.controller.ControllerAction
|
||||||
|
@ -20,53 +22,30 @@ class TrustListController {
|
||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
TrustListView view
|
TrustListView view
|
||||||
|
|
||||||
EventBus eventBus
|
Core core
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void trustFromTrusted() {
|
void viewProfile() {
|
||||||
int selectedRow = view.getSelectedRow("trusted-table")
|
int selectedRow = view.getSelectedRow()
|
||||||
if (selectedRow < 0)
|
if (selectedRow < 0)
|
||||||
return
|
return
|
||||||
String reason = JOptionPane.showInputDialog("Enter reason (optional)")
|
|
||||||
TrustPOP tp = model.trusted[selectedRow]
|
Persona persona = model.contacts[selectedRow].persona
|
||||||
eventBus.publish(new TrustEvent(persona : tp.getPersona(), level : TrustLevel.TRUSTED,
|
MWProfileHeader profileHeader = model.contacts[selectedRow].getHeader()
|
||||||
reason : reason, profileHeader: tp.getHeader()))
|
UUID uuid = UUID.randomUUID()
|
||||||
view.fireUpdate("trusted-table")
|
|
||||||
|
def params = [:]
|
||||||
|
params.persona = persona
|
||||||
|
params.core = core
|
||||||
|
params.uuid = uuid
|
||||||
|
params.profileHeader = profileHeader
|
||||||
|
|
||||||
|
mvcGroup.createMVCGroup("view-profile", uuid.toString(), params)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void trustFromDistrusted() {
|
void close() {
|
||||||
int selectedRow = view.getSelectedRow("distrusted-table")
|
view.window.setVisible(false)
|
||||||
if (selectedRow < 0)
|
mvcGroup.destroy()
|
||||||
return
|
|
||||||
String reason = JOptionPane.showInputDialog("Enter reason (optional)")
|
|
||||||
TrustPOP tp = model.distrusted[selectedRow]
|
|
||||||
eventBus.publish(new TrustEvent(persona : tp.getPersona(), level : TrustLevel.TRUSTED,
|
|
||||||
reason : reason, profileHeader: tp.getHeader()))
|
|
||||||
view.fireUpdate("distrusted-table")
|
|
||||||
}
|
|
||||||
|
|
||||||
@ControllerAction
|
|
||||||
void distrustFromTrusted() {
|
|
||||||
int selectedRow = view.getSelectedRow("trusted-table")
|
|
||||||
if (selectedRow < 0)
|
|
||||||
return
|
|
||||||
String reason = JOptionPane.showInputDialog("Enter reason (optional)")
|
|
||||||
TrustPOP tp = model.trusted[selectedRow]
|
|
||||||
eventBus.publish(new TrustEvent(persona : tp.getPersona(), level : TrustLevel.DISTRUSTED,
|
|
||||||
reason : reason, profileHeader: tp.getHeader()))
|
|
||||||
view.fireUpdate("trusted-table")
|
|
||||||
}
|
|
||||||
|
|
||||||
@ControllerAction
|
|
||||||
void distrustFromDistrusted() {
|
|
||||||
int selectedRow = view.getSelectedRow("distrusted-table")
|
|
||||||
if (selectedRow < 0)
|
|
||||||
return
|
|
||||||
String reason = JOptionPane.showInputDialog("Enter reason (optional)")
|
|
||||||
TrustPOP tp = model.distrusted[selectedRow]
|
|
||||||
eventBus.publish(new TrustEvent(persona : tp.getPersona(), level : TrustLevel.DISTRUSTED,
|
|
||||||
reason : reason, profileHeader: tp.getHeader()))
|
|
||||||
view.fireUpdate("distrusted-table")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,14 +29,14 @@ class ViewProfileController {
|
||||||
void addContact() {
|
void addContact() {
|
||||||
String reason = JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
String reason = JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
||||||
model.core.eventBus.publish(new TrustEvent(persona: model.persona, level: TrustLevel.TRUSTED,
|
model.core.eventBus.publish(new TrustEvent(persona: model.persona, level: TrustLevel.TRUSTED,
|
||||||
reason: reason, profileHeader: model.profile?.getHeader()))
|
reason: reason, profileHeader: model.profileHeader))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void block() {
|
void block() {
|
||||||
String reason = JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
String reason = JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
||||||
model.core.eventBus.publish(new TrustEvent(persona: model.persona, level: TrustLevel.DISTRUSTED,
|
model.core.eventBus.publish(new TrustEvent(persona: model.persona, level: TrustLevel.DISTRUSTED,
|
||||||
reason: reason, profileHeader: model.profile?.getHeader()))
|
reason: reason, profileHeader: model.profileHeader))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
|
|
|
@ -458,6 +458,7 @@ MAX=Max
|
||||||
## Trust List panel
|
## Trust List panel
|
||||||
TRUST_LIST_OF=Contact List of {0}
|
TRUST_LIST_OF=Contact List of {0}
|
||||||
YOUR_TRUST=Your Trust
|
YOUR_TRUST=Your Trust
|
||||||
|
BLOCK=Block
|
||||||
|
|
||||||
## Content Control panel
|
## Content Control panel
|
||||||
CONTENT_CONTROL_PANEL=Content Control Panel
|
CONTENT_CONTROL_PANEL=Content Control Panel
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
import com.muwire.core.trust.RemoteTrustList
|
import com.muwire.core.trust.RemoteTrustList
|
||||||
|
import com.muwire.core.trust.TrustLevel
|
||||||
import com.muwire.core.trust.TrustService
|
import com.muwire.core.trust.TrustService
|
||||||
|
import com.muwire.core.trust.TrustService.TrustEntry
|
||||||
import com.muwire.gui.profile.TrustPOP
|
import com.muwire.gui.profile.TrustPOP
|
||||||
import griffon.core.artifact.GriffonModel
|
import griffon.core.artifact.GriffonModel
|
||||||
import griffon.transform.Observable
|
import griffon.transform.Observable
|
||||||
|
@ -12,11 +14,18 @@ class TrustListModel {
|
||||||
RemoteTrustList trustList
|
RemoteTrustList trustList
|
||||||
TrustService trustService
|
TrustService trustService
|
||||||
|
|
||||||
List<TrustPOP> trusted
|
List<RemoteTrustPOP> contacts
|
||||||
List<TrustPOP> distrusted
|
|
||||||
|
|
||||||
void mvcGroupInit(Map<String,String> args) {
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
trusted = trustList.good.collect {new TrustPOP(it)}
|
contacts = trustList.good.collect {new RemoteTrustPOP(it, TrustLevel.TRUSTED)}
|
||||||
distrusted = trustList.bad.collect {new TrustPOP(it)}
|
contacts.addAll(trustList.bad.collect {new RemoteTrustPOP(it, TrustLevel.DISTRUSTED)})
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RemoteTrustPOP extends TrustPOP {
|
||||||
|
final TrustLevel level
|
||||||
|
RemoteTrustPOP(TrustEntry entry, TrustLevel level) {
|
||||||
|
super(entry)
|
||||||
|
this.level = level
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ import com.muwire.core.profile.MWProfileFetchEvent
|
||||||
import com.muwire.core.profile.MWProfileFetchStatus
|
import com.muwire.core.profile.MWProfileFetchStatus
|
||||||
import com.muwire.core.profile.MWProfileHeader
|
import com.muwire.core.profile.MWProfileHeader
|
||||||
import com.muwire.core.profile.UIProfileFetchEvent
|
import com.muwire.core.profile.UIProfileFetchEvent
|
||||||
|
import com.muwire.gui.HTMLSanitizer
|
||||||
import griffon.core.artifact.GriffonModel
|
import griffon.core.artifact.GriffonModel
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
@ -23,6 +24,7 @@ class ViewProfileModel {
|
||||||
Persona persona
|
Persona persona
|
||||||
UUID uuid
|
UUID uuid
|
||||||
String profileTitle
|
String profileTitle
|
||||||
|
MWProfileHeader profileHeader
|
||||||
|
|
||||||
@Observable MWProfileFetchStatus status
|
@Observable MWProfileFetchStatus status
|
||||||
MWProfile profile
|
MWProfile profile
|
||||||
|
@ -30,6 +32,8 @@ class ViewProfileModel {
|
||||||
private boolean registered
|
private boolean registered
|
||||||
|
|
||||||
void mvcGroupInit(Map<String, String> args) {
|
void mvcGroupInit(Map<String, String> args) {
|
||||||
|
if (profileHeader != null)
|
||||||
|
profileTitle = HTMLSanitizer.sanitize(profileHeader.getTitle())
|
||||||
}
|
}
|
||||||
|
|
||||||
void register() {
|
void register() {
|
||||||
|
@ -53,6 +57,7 @@ class ViewProfileModel {
|
||||||
if (status == MWProfileFetchStatus.FINISHED) {
|
if (status == MWProfileFetchStatus.FINISHED) {
|
||||||
view.profileFetched(event.profile)
|
view.profileFetched(event.profile)
|
||||||
profile = event.profile
|
profile = event.profile
|
||||||
|
profileHeader = profile.getHeader()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,9 @@ import griffon.core.artifact.GriffonView
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
|
import javax.swing.JFrame
|
||||||
import javax.swing.JTable
|
import javax.swing.JTable
|
||||||
|
import java.awt.Dimension
|
||||||
|
|
||||||
import static com.muwire.gui.Translator.trans
|
import static com.muwire.gui.Translator.trans
|
||||||
import javax.swing.JDialog
|
import javax.swing.JDialog
|
||||||
|
@ -28,17 +30,20 @@ class TrustListView {
|
||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
TrustListModel model
|
TrustListModel model
|
||||||
|
|
||||||
def dialog
|
JFrame window
|
||||||
def mainFrame
|
JFrame mainFrame
|
||||||
def mainPanel
|
JTable contactsTable
|
||||||
|
|
||||||
def sortEvents = [:]
|
|
||||||
|
|
||||||
void initUI() {
|
void initUI() {
|
||||||
mainFrame = application.windowManager.findWindow("main-frame")
|
|
||||||
int rowHeight = application.context.get("row-height")
|
int rowHeight = application.context.get("row-height")
|
||||||
dialog = new JDialog(mainFrame, model.trustList.persona.getHumanReadableName(), true)
|
mainFrame = application.windowManager.findWindow("main-frame")
|
||||||
mainPanel = builder.panel {
|
|
||||||
|
int dimX = Math.max(600, (int)(mainFrame.getWidth() / 2))
|
||||||
|
int dimY = Math.max(500, (int)(mainFrame.getHeight() / 2))
|
||||||
|
|
||||||
|
window = builder.frame(visible: false, defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE,
|
||||||
|
iconImage: builder.imageIcon("/MuWire-48x48.png").image,
|
||||||
|
title: model.trustList.persona.getHumanReadableName()) {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
panel(constraints : BorderLayout.NORTH) {
|
panel(constraints : BorderLayout.NORTH) {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
|
@ -50,49 +55,30 @@ class TrustListView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel(constraints : BorderLayout.CENTER) {
|
panel(constraints : BorderLayout.CENTER) {
|
||||||
gridLayout(rows : 1, cols : 2)
|
borderLayout()
|
||||||
panel {
|
scrollPane (constraints : BorderLayout.CENTER){
|
||||||
borderLayout()
|
contactsTable = table(id : "contacts-table", autoCreateRowSorter : true, rowHeight : rowHeight) {
|
||||||
scrollPane (constraints : BorderLayout.CENTER){
|
tableModel(list : model.contacts) {
|
||||||
table(id : "trusted-table", autoCreateRowSorter : true, rowHeight : rowHeight) {
|
closureColumn(header: trans("CONTACTS"), preferredWidth: 200, type : PersonaOrProfile, read : {it})
|
||||||
tableModel(list : model.trusted) {
|
closureColumn(header: trans("TRUST_STATUS"), preferredWidth: 20, type: String, read: {
|
||||||
closureColumn(header: trans("TRUSTED_USERS"), type : PersonaOrProfile, read : {it})
|
trans(it.level.name())
|
||||||
closureColumn(header: trans("REASON"), type : String, read : {it.reason})
|
})
|
||||||
closureColumn(header: trans("YOUR_TRUST"), type : String, read : {
|
closureColumn(header: trans("REASON"), preferredWidth: 200, type : String, read : {it.reason})
|
||||||
Persona p = it.persona
|
closureColumn(header: trans("YOUR_TRUST"), preferredWidth: 20, type : String, read : {
|
||||||
trans(model.trustService.getLevel(p.destination).name())
|
Persona p = it.persona
|
||||||
})
|
trans(model.trustService.getLevel(p.destination).name())
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel (constraints : BorderLayout.SOUTH) {
|
|
||||||
gridBagLayout()
|
|
||||||
button(text : trans("TRUST_VERB"), constraints : gbc(gridx : 0, gridy : 0), trustFromTrustedAction)
|
|
||||||
button(text : trans("DISTRUST"), constraints : gbc(gridx : 1, gridy : 0), distrustFromTrustedAction)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
panel {
|
panel (constraints : BorderLayout.SOUTH) {
|
||||||
borderLayout()
|
gridBagLayout()
|
||||||
scrollPane (constraints : BorderLayout.CENTER ){
|
button(text : trans("VIEW_PROFILE"), constraints : gbc(gridx : 0, gridy : 0), viewProfileAction)
|
||||||
table(id : "distrusted-table", autoCreateRowSorter : true, rowHeight : rowHeight) {
|
button(text : trans("CLOSE"), constraints : gbc(gridx : 1, gridy : 0), closeAction)
|
||||||
tableModel(list : model.distrusted) {
|
|
||||||
closureColumn(header: trans("DISTRUSTED_USERS"), type : PersonaOrProfile, read : {it})
|
|
||||||
closureColumn(header: trans("REASON"), type:String, read : {it.reason})
|
|
||||||
closureColumn(header: trans("YOUR_TRUST"), type : String, read : {
|
|
||||||
Persona p = it.persona
|
|
||||||
trans(model.trustService.getLevel(p.destination).name())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panel(constraints : BorderLayout.SOUTH) {
|
|
||||||
gridBagLayout()
|
|
||||||
button(text : trans("TRUST_VERB"), constraints : gbc(gridx : 0, gridy : 0), trustFromDistrustedAction)
|
|
||||||
button(text : trans("DISTRUST"), constraints : gbc(gridx : 1, gridy : 0), distrustFromDistrustedAction)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
window.setPreferredSize([dimX, dimY] as Dimension)
|
||||||
}
|
}
|
||||||
|
|
||||||
void mvcGroupInit(Map<String,String> args) {
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
|
@ -100,44 +86,29 @@ class TrustListView {
|
||||||
def popRenderer = new PersonaOrProfileCellRenderer()
|
def popRenderer = new PersonaOrProfileCellRenderer()
|
||||||
def popComparator = new PersonaOrProfileComparator()
|
def popComparator = new PersonaOrProfileComparator()
|
||||||
|
|
||||||
JTable trustedTable = builder.getVariable("trusted-table")
|
contactsTable.setDefaultRenderer(PersonaOrProfile.class, popRenderer)
|
||||||
trustedTable.setDefaultRenderer(PersonaOrProfile.class, popRenderer)
|
contactsTable.rowSorter.setComparator(0, popComparator)
|
||||||
trustedTable.rowSorter.setComparator(0, popComparator)
|
contactsTable.rowSorter.setSortsOnUpdates(true)
|
||||||
trustedTable.rowSorter.addRowSorterListener({evt -> sortEvents["trusted-table"] = evt})
|
contactsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
|
||||||
trustedTable.rowSorter.setSortsOnUpdates(true)
|
|
||||||
trustedTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
|
|
||||||
|
|
||||||
JTable distrustedTable = builder.getVariable("distrusted-table")
|
window.pack()
|
||||||
distrustedTable.setDefaultRenderer(Persona.class, popRenderer)
|
window.setLocationRelativeTo(mainFrame)
|
||||||
distrustedTable.rowSorter.setComparator(0, popComparator)
|
window.addWindowListener(new WindowAdapter() {
|
||||||
distrustedTable.rowSorter.addRowSorterListener({evt -> sortEvents["distrusted-table"] = evt})
|
|
||||||
distrustedTable.rowSorter.setSortsOnUpdates(true)
|
|
||||||
distrustedTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
|
|
||||||
|
|
||||||
dialog.getContentPane().add(mainPanel)
|
|
||||||
dialog.pack()
|
|
||||||
dialog.setLocationRelativeTo(mainFrame)
|
|
||||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
|
||||||
dialog.addWindowListener(new WindowAdapter() {
|
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
mvcGroup.destroy()
|
mvcGroup.destroy()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
dialog.show()
|
window.setVisible(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSelectedRow(String tableName) {
|
int getSelectedRow() {
|
||||||
def table = builder.getVariable(tableName)
|
int selectedRow = contactsTable.getSelectedRow()
|
||||||
int selectedRow = table.getSelectedRow()
|
|
||||||
if (selectedRow < 0)
|
if (selectedRow < 0)
|
||||||
return -1
|
return -1
|
||||||
if (sortEvents.get(tableName) != null)
|
contactsTable.rowSorter.convertRowIndexToModel(selectedRow)
|
||||||
selectedRow = table.rowSorter.convertRowIndexToModel(selectedRow)
|
|
||||||
selectedRow
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fireUpdate(String tableName) {
|
void updateTable() {
|
||||||
def table = builder.getVariable(tableName)
|
contactsTable.model.fireTableDataChanged()
|
||||||
table.model.fireTableDataChanged()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue