mirror of https://github.com/zlatinb/muwire
make the browse host a tab. Fix multiple selection while sorting
parent
1ed74768fb
commit
5174810621
|
@ -55,16 +55,23 @@ class BrowseController {
|
|||
model.chatActionEnabled = e.results[0].chat
|
||||
model.results.addAll(e.results.toList())
|
||||
model.resultCount = model.results.size()
|
||||
|
||||
int [] selectedRows = view.resultsTable.getSelectedRows()
|
||||
if (view.lastSortEvent != null) {
|
||||
for (int i = 0; i < selectedRows.length; i ++)
|
||||
selectedRows[i] = view.resultsTable.rowSorter.convertRowIndexToModel(selectedRows[i])
|
||||
}
|
||||
view.resultsTable.model.fireTableDataChanged()
|
||||
if (view.lastSortEvent != null) {
|
||||
for (int i = 0; i < selectedRows.length; i ++)
|
||||
selectedRows[i] = view.resultsTable.rowSorter.convertRowIndexToView(selectedRows[i])
|
||||
}
|
||||
for (int row : selectedRows)
|
||||
view.resultsTable.selectionModel.addSelectionInterval(row, row)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void dismiss() {
|
||||
view.dialog.setVisible(false)
|
||||
mvcGroup.destroy()
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void download() {
|
||||
def selectedResults = view.selectedResults()
|
||||
|
@ -88,7 +95,6 @@ class BrowseController {
|
|||
}
|
||||
|
||||
group.view.showDownloadsWindow.call()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
|
@ -127,7 +133,6 @@ class BrowseController {
|
|||
|
||||
@ControllerAction
|
||||
void chat() {
|
||||
dismiss()
|
||||
def mainFrameGroup = application.mvcGroupManager.getGroups()['MainFrame']
|
||||
|
||||
mainFrameGroup.controller.startChat(model.host)
|
||||
|
|
|
@ -35,8 +35,7 @@ class BrowseView {
|
|||
@MVCMember @Nonnull
|
||||
BrowseController controller
|
||||
|
||||
def mainFrame
|
||||
def dialog
|
||||
def parent
|
||||
def p
|
||||
def resultsTable
|
||||
def lastSortEvent
|
||||
|
@ -44,9 +43,6 @@ class BrowseView {
|
|||
|
||||
void initUI() {
|
||||
int rowHeight = application.context.get("row-height")
|
||||
mainFrame = application.windowManager.findWindow("main-frame")
|
||||
dialog = new JDialog(mainFrame, model.host.getHumanReadableName(), true)
|
||||
dialog.setResizable(true)
|
||||
|
||||
p = builder.panel {
|
||||
borderLayout()
|
||||
|
@ -70,7 +66,6 @@ class BrowseView {
|
|||
button(text : trans("VIEW_COMMENT"), enabled : bind{model.viewCommentActionEnabled}, viewCommentAction)
|
||||
button(text : trans("VIEW_CERTIFICATES"), enabled : bind{model.viewCertificatesActionEnabled}, viewCertificatesAction)
|
||||
button(text : trans("CHAT"), enabled : bind {model.chatActionEnabled}, chatAction)
|
||||
button(text : trans("CLOSE"), dismissAction)
|
||||
label(text : trans("DOWNLOAD_SEQUENTIALLY"))
|
||||
sequentialDownloadCheckbox = checkBox()
|
||||
}
|
||||
|
@ -186,19 +181,30 @@ class BrowseView {
|
|||
def clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
|
||||
clipboard.setContents(selection, null)
|
||||
}
|
||||
|
||||
void mvcGroupInit(Map<String,String> args) {
|
||||
controller.register()
|
||||
|
||||
dialog.getContentPane().add(p)
|
||||
dialog.setSize(700, 400)
|
||||
dialog.setLocationRelativeTo(mainFrame)
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
||||
dialog.addWindowListener( new WindowAdapter() {
|
||||
public void windowClosed(WindowEvent e) {
|
||||
mvcGroup.destroy()
|
||||
def mainFrameGroup = application.mvcGroupManager.findGroup("MainFrame")
|
||||
parent = mainFrameGroup.view.builder.getVariable("result-tabs")
|
||||
parent.addTab(model.host.getHumanReadableName(), p)
|
||||
|
||||
int index = parent.indexOfComponent(p)
|
||||
parent.setSelectedIndex(index)
|
||||
|
||||
def tabPanel
|
||||
builder.with {
|
||||
tabPanel = panel {
|
||||
borderLayout()
|
||||
panel {
|
||||
label(text : model.host.getHumanReadableName(), constraints : BorderLayout.CENTER)
|
||||
}
|
||||
button(icon : imageIcon("/close_tab.png"), preferredSize : [20,20], constraints : BorderLayout.EAST, // TODO: in osx is probably WEST
|
||||
actionPerformed : closeTab )
|
||||
}
|
||||
})
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
parent.setTabComponentAt(index, tabPanel)
|
||||
}
|
||||
|
||||
|
||||
|
@ -217,4 +223,11 @@ class BrowseView {
|
|||
rv << model.results[i]
|
||||
rv
|
||||
}
|
||||
|
||||
def closeTab = {
|
||||
int index = parent.indexOfTab(model.host.getHumanReadableName())
|
||||
parent.removeTabAt(index)
|
||||
model.downloadActionEnabled = false
|
||||
mvcGroup.destroy()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue