subscribe button
This commit is contained in:
@@ -14,6 +14,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
import com.muwire.core.Constants
|
import com.muwire.core.Constants
|
||||||
import com.muwire.core.Core
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.Persona
|
||||||
import com.muwire.core.SharedFile
|
import com.muwire.core.SharedFile
|
||||||
import com.muwire.core.download.DownloadStartedEvent
|
import com.muwire.core.download.DownloadStartedEvent
|
||||||
import com.muwire.core.download.UIDownloadCancelledEvent
|
import com.muwire.core.download.UIDownloadCancelledEvent
|
||||||
@@ -26,6 +27,7 @@ import com.muwire.core.search.QueryEvent
|
|||||||
import com.muwire.core.search.SearchEvent
|
import com.muwire.core.search.SearchEvent
|
||||||
import com.muwire.core.trust.TrustEvent
|
import com.muwire.core.trust.TrustEvent
|
||||||
import com.muwire.core.trust.TrustLevel
|
import com.muwire.core.trust.TrustLevel
|
||||||
|
import com.muwire.core.trust.TrustSubscriptionEvent
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class MainFrameController {
|
class MainFrameController {
|
||||||
@@ -184,7 +186,7 @@ class MainFrameController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void markTrust(String tableName, TrustLevel level, def list) {
|
private void markTrust(String tableName, TrustLevel level, def list) {
|
||||||
int row = builder.getVariable(tableName).getSelectedRow()
|
int row = view.getSelectedTrustTablesRow(tableName)
|
||||||
if (row < 0)
|
if (row < 0)
|
||||||
return
|
return
|
||||||
core.eventBus.publish(new TrustEvent(persona : list[row], level : level))
|
core.eventBus.publish(new TrustEvent(persona : list[row], level : level))
|
||||||
@@ -210,6 +212,15 @@ class MainFrameController {
|
|||||||
markTrust("trusted-table", TrustLevel.NEUTRAL, model.trusted)
|
markTrust("trusted-table", TrustLevel.NEUTRAL, model.trusted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void subscribe() {
|
||||||
|
int row = view.getSelectedTrustTablesRow("trusted-table")
|
||||||
|
if (row < 0)
|
||||||
|
return
|
||||||
|
Persona p = model.trusted[row]
|
||||||
|
core.eventBus.publish(new TrustSubscriptionEvent(persona : p, subscribe : true))
|
||||||
|
}
|
||||||
|
|
||||||
void unshareSelectedFile() {
|
void unshareSelectedFile() {
|
||||||
SharedFile sf = view.selectedSharedFile()
|
SharedFile sf = view.selectedSharedFile()
|
||||||
if (sf == null)
|
if (sf == null)
|
||||||
|
@@ -54,6 +54,7 @@ class MainFrameView {
|
|||||||
def lastDownloadSortEvent
|
def lastDownloadSortEvent
|
||||||
def lastSharedSortEvent
|
def lastSharedSortEvent
|
||||||
def lastWatchedSortEvent
|
def lastWatchedSortEvent
|
||||||
|
def trustTablesSortEvents = [:]
|
||||||
|
|
||||||
void initUI() {
|
void initUI() {
|
||||||
UISettings settings = application.context.get("ui-settings")
|
UISettings settings = application.context.get("ui-settings")
|
||||||
@@ -267,6 +268,7 @@ class MainFrameView {
|
|||||||
gridBagLayout()
|
gridBagLayout()
|
||||||
button(text : "Mark Neutral", constraints : gbc(gridx: 0, gridy: 0), markNeutralFromTrustedAction)
|
button(text : "Mark Neutral", constraints : gbc(gridx: 0, gridy: 0), markNeutralFromTrustedAction)
|
||||||
button(text : "Mark Distrusted", constraints : gbc(gridx: 0, gridy:1), markDistrustedAction)
|
button(text : "Mark Distrusted", constraints : gbc(gridx: 0, gridy:1), markDistrustedAction)
|
||||||
|
button(text : "Subscribe", constraints : gbc(gridx: 0, gridy : 2), subscribeAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel (border : etchedBorder()){
|
panel (border : etchedBorder()){
|
||||||
@@ -298,7 +300,10 @@ class MainFrameView {
|
|||||||
closureColumn(header : "Distrusted", type: Integer, read : {it.bad.size()})
|
closureColumn(header : "Distrusted", type: Integer, read : {it.bad.size()})
|
||||||
closureColumn(header : "Status", type: String, read : {it.status.toString()})
|
closureColumn(header : "Status", type: String, read : {it.status.toString()})
|
||||||
closureColumn(header : "Last Updated", type : String, read : {
|
closureColumn(header : "Last Updated", type : String, read : {
|
||||||
String.valueOf(new Date(it.timestamp))
|
if (it.timestamp == 0)
|
||||||
|
return "Never"
|
||||||
|
else
|
||||||
|
return String.valueOf(new Date(it.timestamp))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,6 +458,20 @@ class MainFrameView {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// subscription table
|
||||||
|
def subscriptionTable = builder.getVariable("subscription-table")
|
||||||
|
subscriptionTable.rowSorter.addRowSorterListener({evt -> trustTablesSortEvents["subscription-table"] = evt})
|
||||||
|
subscriptionTable.rowSorter.setSortsOnUpdates(true)
|
||||||
|
|
||||||
|
// trusted table
|
||||||
|
def trustedTable = builder.getVariable("trusted-table")
|
||||||
|
trustedTable.rowSorter.addRowSortListener({evt -> trustTablesSortEvents["trusted-table"] = evt})
|
||||||
|
trustedTable.rowSorter.setSortsOnUpdates(true)
|
||||||
|
|
||||||
|
// distrusted table
|
||||||
|
def distrustedTable = builder.getVariable("distrusted-table")
|
||||||
|
distrustedTable.rowSorter.addRowSortListener({evt -> trustTablesSortEvents["distrusted-table"] = evt})
|
||||||
|
distrustedTable.rowSorter.setSortsOnUpdates(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showPopupMenu(JPopupMenu menu, MouseEvent event) {
|
private static void showPopupMenu(JPopupMenu menu, MouseEvent event) {
|
||||||
@@ -617,4 +636,14 @@ class MainFrameView {
|
|||||||
selectedRow = watchedTable.rowSorter.convertRowIndexToModel(selectedRow)
|
selectedRow = watchedTable.rowSorter.convertRowIndexToModel(selectedRow)
|
||||||
model.watched[selectedRow]
|
model.watched[selectedRow]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSelectedTrustTablesRow(String tableName) {
|
||||||
|
def table = builder.getVariable(tableName)
|
||||||
|
int selectedRow = table.getSelectedRow()
|
||||||
|
if (selectedRow < 0)
|
||||||
|
return -1
|
||||||
|
if (trustTablesSortEvents.get(tableName) != null)
|
||||||
|
selectedRow = table.rowSorter.convertRowIndexToModel(selectedRow)
|
||||||
|
selectedRow
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user