mirror of https://github.com/zlatinb/muwire
remove the watched directories table
parent
feb712c253
commit
70fb789abf
|
@ -291,20 +291,6 @@ class MainFrameController {
|
||||||
mvcGroup.createMVCGroup("add-comment", "Add Comment", params)
|
mvcGroup.createMVCGroup("add-comment", "Add Comment", params)
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopWatchingDirectory() {
|
|
||||||
List<String> directories = mvcGroup.view.getSelectedWatchedDirectories()
|
|
||||||
if (directories == null)
|
|
||||||
return
|
|
||||||
directories.each { directory ->
|
|
||||||
core.muOptions.watchedDirectories.remove(directory)
|
|
||||||
core.eventBus.publish(new DirectoryUnsharedEvent(directory : new File(directory)))
|
|
||||||
model.watched.remove(directory)
|
|
||||||
}
|
|
||||||
saveMuWireSettings()
|
|
||||||
|
|
||||||
builder.getVariable("watched-directories-table").model.fireTableDataChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveMuWireSettings() {
|
void saveMuWireSettings() {
|
||||||
File f = new File(core.home, "MuWire.properties")
|
File f = new File(core.home, "MuWire.properties")
|
||||||
f.withOutputStream {
|
f.withOutputStream {
|
||||||
|
|
|
@ -76,7 +76,6 @@ class MainFrameModel {
|
||||||
def sharedTree
|
def sharedTree
|
||||||
def treeRoot
|
def treeRoot
|
||||||
final Map<SharedFile, TreeNode> fileToNode = new HashMap<>()
|
final Map<SharedFile, TreeNode> fileToNode = new HashMap<>()
|
||||||
def watched = []
|
|
||||||
def connectionList = []
|
def connectionList = []
|
||||||
def searches = new LinkedList()
|
def searches = new LinkedList()
|
||||||
def trusted = []
|
def trusted = []
|
||||||
|
@ -248,9 +247,7 @@ class MainFrameModel {
|
||||||
|
|
||||||
void onAllFilesLoadedEvent(AllFilesLoadedEvent e) {
|
void onAllFilesLoadedEvent(AllFilesLoadedEvent e) {
|
||||||
runInsideUIAsync {
|
runInsideUIAsync {
|
||||||
watched.addAll(core.muOptions.watchedDirectories)
|
core.muOptions.watchedDirectories.each { core.eventBus.publish(new FileSharedEvent(file : new File(it))) }
|
||||||
builder.getVariable("watched-directories-table").model.fireTableDataChanged()
|
|
||||||
watched.each { core.eventBus.publish(new FileSharedEvent(file : new File(it))) }
|
|
||||||
|
|
||||||
core.muOptions.trustSubscriptions.each {
|
core.muOptions.trustSubscriptions.each {
|
||||||
core.eventBus.publish(new TrustSubscriptionEvent(persona : it, subscribe : true))
|
core.eventBus.publish(new TrustSubscriptionEvent(persona : it, subscribe : true))
|
||||||
|
|
|
@ -59,7 +59,6 @@ class MainFrameView {
|
||||||
def downloadsTable
|
def downloadsTable
|
||||||
def lastDownloadSortEvent
|
def lastDownloadSortEvent
|
||||||
def lastSharedSortEvent
|
def lastSharedSortEvent
|
||||||
def lastWatchedSortEvent
|
|
||||||
def trustTablesSortEvents = [:]
|
def trustTablesSortEvents = [:]
|
||||||
|
|
||||||
UISettings settings
|
UISettings settings
|
||||||
|
@ -198,18 +197,8 @@ class MainFrameView {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
panel (border : etchedBorder(), constraints : BorderLayout.CENTER) {
|
panel (border : etchedBorder(), constraints : BorderLayout.CENTER) {
|
||||||
gridLayout(cols : 2, rows : 1)
|
borderLayout()
|
||||||
panel {
|
panel (id : "shared-files-panel", constraints : BorderLayout.CENTER){
|
||||||
borderLayout()
|
|
||||||
scrollPane (constraints : BorderLayout.CENTER) {
|
|
||||||
table(id : "watched-directories-table", autoCreateRowSorter: true) {
|
|
||||||
tableModel(list : model.watched) {
|
|
||||||
closureColumn(header: "Watched Directories", type : String, read : { it })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panel (id : "shared-files-panel"){
|
|
||||||
cardLayout()
|
cardLayout()
|
||||||
panel (constraints : "shared files table") {
|
panel (constraints : "shared files table") {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
|
@ -236,8 +225,8 @@ class MainFrameView {
|
||||||
panel (constraints : BorderLayout.SOUTH) {
|
panel (constraints : BorderLayout.SOUTH) {
|
||||||
gridLayout(rows:1, cols:2)
|
gridLayout(rows:1, cols:2)
|
||||||
panel {
|
panel {
|
||||||
button(text : "Add directories to watch", actionPerformed : watchDirectories)
|
|
||||||
button(text : "Share files", actionPerformed : shareFiles)
|
button(text : "Share files", actionPerformed : shareFiles)
|
||||||
|
button(text : "Add Comment", enabled : bind {model.addCommentButtonEnabled}, addCommentAction)
|
||||||
}
|
}
|
||||||
panel {
|
panel {
|
||||||
gridLayout(rows : 1, cols : 2)
|
gridLayout(rows : 1, cols : 2)
|
||||||
|
@ -245,9 +234,6 @@ class MainFrameView {
|
||||||
label("Shared:")
|
label("Shared:")
|
||||||
label(text : bind {model.loadedFiles}, id : "shared-files-count")
|
label(text : bind {model.loadedFiles}, id : "shared-files-count")
|
||||||
}
|
}
|
||||||
panel {
|
|
||||||
button(text : "Add Comment", enabled : bind {model.addCommentButtonEnabled}, addCommentAction)
|
|
||||||
}
|
|
||||||
panel {
|
panel {
|
||||||
buttonGroup(id : "sharedViewType")
|
buttonGroup(id : "sharedViewType")
|
||||||
radioButton(text : "Tree", selected : true, buttonGroup : sharedViewType, actionPerformed : showSharedFilesTree)
|
radioButton(text : "Tree", selected : true, buttonGroup : sharedViewType, actionPerformed : showSharedFilesTree)
|
||||||
|
@ -588,27 +574,6 @@ class MainFrameView {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// watched directories table
|
|
||||||
def watchedTable = builder.getVariable("watched-directories-table")
|
|
||||||
watchedTable.rowSorter.addRowSorterListener({evt -> lastWatchedSortEvent = evt})
|
|
||||||
watchedTable.rowSorter.setSortsOnUpdates(true)
|
|
||||||
JPopupMenu watchedMenu = new JPopupMenu()
|
|
||||||
JMenuItem stopWatching = new JMenuItem("Stop sharing")
|
|
||||||
stopWatching.addActionListener({mvcGroup.controller.stopWatchingDirectory()})
|
|
||||||
watchedMenu.add(stopWatching)
|
|
||||||
watchedTable.addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
if (e.isPopupTrigger())
|
|
||||||
showPopupMenu(watchedMenu, e)
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
if (e.isPopupTrigger())
|
|
||||||
showPopupMenu(watchedMenu, e)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// subscription table
|
// subscription table
|
||||||
def subscriptionTable = builder.getVariable("subscription-table")
|
def subscriptionTable = builder.getVariable("subscription-table")
|
||||||
subscriptionTable.setDefaultRenderer(Integer.class, centerRenderer)
|
subscriptionTable.setDefaultRenderer(Integer.class, centerRenderer)
|
||||||
|
@ -903,45 +868,6 @@ class MainFrameView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def watchDirectories = {
|
|
||||||
def chooser = new JFileChooser()
|
|
||||||
chooser.setFileHidingEnabled(false)
|
|
||||||
chooser.setDialogTitle("Select directory to watch")
|
|
||||||
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
|
|
||||||
chooser.setMultiSelectionEnabled(true)
|
|
||||||
int rv = chooser.showOpenDialog(null)
|
|
||||||
if (rv == JFileChooser.APPROVE_OPTION) {
|
|
||||||
chooser.getSelectedFiles().each { f ->
|
|
||||||
watchDirectory(f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void watchDirectory(File f) {
|
|
||||||
model.watched << f.getAbsolutePath()
|
|
||||||
application.context.get("muwire-settings").watchedDirectories << f.getAbsolutePath()
|
|
||||||
mvcGroup.controller.saveMuWireSettings()
|
|
||||||
builder.getVariable("watched-directories-table").model.fireTableDataChanged()
|
|
||||||
model.core.eventBus.publish(new FileSharedEvent(file : f))
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> getSelectedWatchedDirectories() {
|
|
||||||
def watchedTable = builder.getVariable("watched-directories-table")
|
|
||||||
int[] selectedRows = watchedTable.getSelectedRows()
|
|
||||||
if (selectedRows.length == 0)
|
|
||||||
return null
|
|
||||||
if (lastWatchedSortEvent != null) {
|
|
||||||
for(int i = 0;i < selectedRows.length; i++)
|
|
||||||
selectedRows[i] = watchedTable.rowSorter.convertRowIndexToModel(selectedRows[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> rv = new ArrayList<>()
|
|
||||||
selectedRows.each {
|
|
||||||
rv.add(model.watched[it])
|
|
||||||
}
|
|
||||||
rv
|
|
||||||
}
|
|
||||||
|
|
||||||
int getSelectedTrustTablesRow(String tableName) {
|
int getSelectedTrustTablesRow(String tableName) {
|
||||||
def table = builder.getVariable(tableName)
|
def table = builder.getVariable(tableName)
|
||||||
int selectedRow = table.getSelectedRow()
|
int selectedRow = table.getSelectedRow()
|
||||||
|
|
Loading…
Reference in New Issue