wip on feeds table

This commit is contained in:
Zlatin Balevsky
2020-03-10 07:33:29 +00:00
parent e2a9db8056
commit 1610766e01
2 changed files with 63 additions and 1 deletions

View File

@@ -28,6 +28,8 @@ import com.muwire.core.content.ContentControlEvent
import com.muwire.core.download.DownloadStartedEvent
import com.muwire.core.download.Downloader
import com.muwire.core.filecert.CertificateCreatedEvent
import com.muwire.core.filefeeds.FeedFetchEvent
import com.muwire.core.filefeeds.FeedLoadedEvent
import com.muwire.core.files.AllFilesLoadedEvent
import com.muwire.core.files.DirectoryUnsharedEvent
import com.muwire.core.files.DirectoryWatchedEvent
@@ -89,6 +91,8 @@ class MainFrameModel {
def trusted = []
def distrusted = []
def subscriptions = []
def feeds = []
def feedItems = []
boolean sessionRestored
@@ -218,6 +222,8 @@ class MainFrameModel {
core.eventBus.register(TrustSubscriptionUpdatedEvent.class, this)
core.eventBus.register(SearchEvent.class, this)
core.eventBus.register(CertificateCreatedEvent.class, this)
core.eventBus.register(FeedLoadedEvent.class, this)
core.eventBus.register(FeedFetchEvent.class, this)
core.muOptions.watchedKeywords.each {
core.eventBus.publish(new ContentControlEvent(term : it, regex: false, add: true))
@@ -656,4 +662,17 @@ class MainFrameModel {
int requests
boolean finished
}
void onFeedLoadedEvent(FeedLoadedEvent e) {
runInsideUIAsync {
feeds << e.feed
view.refreshFeeds()
}
}
void onFeedFetchEvent(FeedFetchEvent e) {
runInsideUIAsync {
view.refreshFeeds()
}
}
}

View File

@@ -76,6 +76,8 @@ class MainFrameView {
def lastSharedSortEvent
def trustTablesSortEvents = [:]
def expansionListener = new TreeExpansions()
def lastFeedsSortEvent
def lastFeedItemsSortEvent
UISettings settings
@@ -430,7 +432,33 @@ class MainFrameView {
}
}
panel(constraints : "feeds window") {
label(text : "Feeds go here")
gridLayout(rows : 2, cols : 1)
panel {
borderLayout()
panel (constraints : BorderLayout.NORTH) {
label(text: "Subscriptions")
}
scrollPane(constraints : BorderLayout.CENTER) {
table(id : "feeds-table", autoCreateRowSorter : true, rowHeight : rowHeight) {
tableModel(list : model.feeds) {
}
}
}
}
panel {
borderLayout()
panel (constraints : BorderLayout.NORTH) {
label(text : "Published Items")
}
scrollPane(constraints : BorderLayout.CENTER) {
table(id : "feed-items-table", autoCreateRowSorter : true, rowHeight : rowHeight) {
tableModel(list : model.feedItems) {
}
}
}
}
}
panel(constraints : "trust window") {
gridLayout(rows : 2, cols : 1)
@@ -768,6 +796,13 @@ class MainFrameView {
}
})
// feeds table
def feedsTable = builder.getVariable("feeds-table")
feedsTable.rowSorter.addRowSorterListener({evt -> lastFeedsSortEvent = evt})
selectionModel = feedsTable.getSelectionModel()
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
// TODO: hook up with feedItems table
// subscription table
def subscriptionTable = builder.getVariable("subscription-table")
subscriptionTable.setDefaultRenderer(Integer.class, centerRenderer)
@@ -1214,6 +1249,14 @@ class MainFrameView {
builder.getVariable("shared-files-table").model.fireTableDataChanged()
}
public void refreshFeeds() {
JTable feedsTable = builder.getVariable("feeds-table")
int selectedFeed = feedsTable.getSelectedRow()
feedsTable.model.fireTableDataChanged()
if (selectedFeed >= 0)
feedsTable.selectionModel.setSelectionInterval(selectedFeed, selectedFeed)
}
private void closeApplication() {
Core core = application.getContext().get("core")