trust and distrust buttons
This commit is contained in:
@@ -9,8 +9,11 @@ import javax.annotation.Nonnull
|
|||||||
import com.muwire.core.Core
|
import com.muwire.core.Core
|
||||||
import com.muwire.core.EventBus
|
import com.muwire.core.EventBus
|
||||||
import com.muwire.core.content.ContentControlEvent
|
import com.muwire.core.content.ContentControlEvent
|
||||||
|
import com.muwire.core.content.Match
|
||||||
import com.muwire.core.content.Matcher
|
import com.muwire.core.content.Matcher
|
||||||
import com.muwire.core.content.RegexMatcher
|
import com.muwire.core.content.RegexMatcher
|
||||||
|
import com.muwire.core.trust.TrustEvent
|
||||||
|
import com.muwire.core.trust.TrustLevel
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class ContentPanelController {
|
class ContentPanelController {
|
||||||
@@ -67,12 +70,20 @@ class ContentPanelController {
|
|||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void trust() {
|
void trust() {
|
||||||
|
int selectedHit = view.getSelectedHit()
|
||||||
|
if (selectedHit < 0)
|
||||||
|
return
|
||||||
|
Match m = model.hits[selectedHit]
|
||||||
|
core.eventBus.publish(new TrustEvent(persona : m.persona, level : TrustLevel.TRUSTED))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void distrust() {
|
void distrust() {
|
||||||
|
int selectedHit = view.getSelectedHit()
|
||||||
|
if (selectedHit < 0)
|
||||||
|
return
|
||||||
|
Match m = model.hits[selectedHit]
|
||||||
|
core.eventBus.publish(new TrustEvent(persona : m.persona, level : TrustLevel.DISTRUSTED))
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveMuWireSettings() {
|
void saveMuWireSettings() {
|
||||||
|
@@ -32,6 +32,7 @@ class ContentPanelView {
|
|||||||
def ruleTextField
|
def ruleTextField
|
||||||
def lastRulesSortEvent
|
def lastRulesSortEvent
|
||||||
def hitsTable
|
def hitsTable
|
||||||
|
def lastHitsSortEvent
|
||||||
|
|
||||||
void initUI() {
|
void initUI() {
|
||||||
mainFrame = application.windowManager.findWindow("main-frame")
|
mainFrame = application.windowManager.findWindow("main-frame")
|
||||||
@@ -91,6 +92,15 @@ class ContentPanelView {
|
|||||||
selectedRow
|
selectedRow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSelectedHit() {
|
||||||
|
int selectedRow = hitsTable.getSelectedRow()
|
||||||
|
if (selectedRow < 0)
|
||||||
|
return -1
|
||||||
|
if (lastHitsSortEvent != null)
|
||||||
|
selectedRow = hitsTable.rowSorter.convertRowIndexToModel(selectedRow)
|
||||||
|
selectedRow
|
||||||
|
}
|
||||||
|
|
||||||
void mvcGroupInit(Map<String,String> args) {
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
|
|
||||||
rulesTable.rowSorter.addRowSorterListener({evt -> lastRulesSortEvent = evt})
|
rulesTable.rowSorter.addRowSorterListener({evt -> lastRulesSortEvent = evt})
|
||||||
@@ -111,6 +121,14 @@ class ContentPanelView {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
hitsTable.rowSorter.addRowSorterListener({evt -> lastHitsSortEvent = evt})
|
||||||
|
hitsTable.rowSorter.setSortsOnUpdates(true)
|
||||||
|
selectionModel = hitsTable.getSelectionModel()
|
||||||
|
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
|
||||||
|
selectionModel.addListSelectionListener({
|
||||||
|
int selectedRow = getSelectedHit()
|
||||||
|
model.trustButtonsEnabled = selectedRow >= 0
|
||||||
|
})
|
||||||
|
|
||||||
dialog.getContentPane().add(mainPanel)
|
dialog.getContentPane().add(mainPanel)
|
||||||
dialog.pack()
|
dialog.pack()
|
||||||
|
Reference in New Issue
Block a user