mirror of https://github.com/zlatinb/muwire
convert watched directory configuration dialog to a frame
parent
3efee7ef68
commit
54def4ba89
|
@ -16,18 +16,6 @@ class AdvancedSharingController {
|
|||
@MVCMember @Nonnull
|
||||
AdvancedSharingView view
|
||||
|
||||
@ControllerAction
|
||||
void configure() {
|
||||
def wd = view.selectedWatchedDirectory()
|
||||
if (wd == null)
|
||||
return
|
||||
|
||||
def params = [:]
|
||||
params['core'] = model.core
|
||||
params['directory'] = wd
|
||||
mvcGroup.createMVCGroup("watched-directory",params).destroy()
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void sync() {
|
||||
def wd = view.selectedWatchedDirectory()
|
||||
|
|
|
@ -658,7 +658,7 @@ class MainFrameController {
|
|||
def props = [:]
|
||||
props.core = model.core
|
||||
props.directory = wd
|
||||
mvcGroup.createMVCGroup("watched-directory", props).destroy()
|
||||
mvcGroup.createMVCGroup("watched-directory", UUID.randomUUID().toString(), props)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ class WatchedDirectoryController {
|
|||
|
||||
@ControllerAction
|
||||
void cancel() {
|
||||
view.dialog.setVisible(false)
|
||||
view.window.setVisible(false)
|
||||
mvcGroup.destroy()
|
||||
}
|
||||
}
|
|
@ -566,8 +566,8 @@ ROOM=Room
|
|||
FEED_CONFIGURATION=Feed Configuration
|
||||
FEED_CONFIGURATION_FOR=Configuration for feed {0}
|
||||
|
||||
## Watched directory configuration dialog
|
||||
WATCHED_DIRECTORY_CONFIGURATION=Watched Folder Configuration
|
||||
## Watched directory configuration frame
|
||||
WATCHED_DIRECTORY_CONFIGURATION=Shared Folder Configuration
|
||||
WATCHED_DIRECTORY_CONFIGURATION_FOR=Configuration for folder {0}
|
||||
WATCHED_DIRECTORY_AUTO=Auto-watch folder using operating system
|
||||
WATCHED_DIRECTORY_INTERVAL=Folder sync frequency (seconds, 0 means never)
|
||||
|
|
|
@ -28,7 +28,6 @@ class AdvancedSharingModel {
|
|||
Core core
|
||||
|
||||
@Observable boolean syncActionEnabled
|
||||
@Observable boolean configureActionEnabled
|
||||
|
||||
void mvcGroupInit(Map<String,String> args) {
|
||||
watchedDirectories.addAll(core.watchedDirectoryManager.watchedDirs.values())
|
||||
|
|
|
@ -68,8 +68,6 @@ class AdvancedSharingView {
|
|||
}
|
||||
}
|
||||
panel (constraints : BorderLayout.SOUTH) {
|
||||
button(text : trans("CONFIGURE"), toolTipText: trans("TOOLTIP_TOOLS_FOLDER_CONFIGURE"),
|
||||
enabled : bind{model.configureActionEnabled}, configureAction)
|
||||
button(text : trans("SYNC"), toolTipText: trans("TOOLTIP_TOOLS_FOLDER_SYNC"),
|
||||
enabled : bind{model.syncActionEnabled}, syncAction)
|
||||
button(text : trans("CLOSE"), closeAction)
|
||||
|
@ -98,7 +96,6 @@ class AdvancedSharingView {
|
|||
selectionModel.addListSelectionListener({
|
||||
def directory = selectedWatchedDirectory()
|
||||
model.syncActionEnabled = !(directory == null || directory.autoWatch)
|
||||
model.configureActionEnabled = directory != null
|
||||
})
|
||||
|
||||
watchedDirsTable.addMouseListener(new MouseAdapter() {
|
||||
|
@ -114,16 +111,14 @@ class AdvancedSharingView {
|
|||
}
|
||||
|
||||
private void showMenu(MouseEvent e) {
|
||||
JPopupMenu menu = new JPopupMenu()
|
||||
JMenuItem configure = new JMenuItem(trans("CONFIGURE"))
|
||||
configure.addActionListener({controller.configure()})
|
||||
menu.add(configure)
|
||||
if (!model.syncActionEnabled)
|
||||
return
|
||||
|
||||
if (model.syncActionEnabled) {
|
||||
JMenuItem sync = new JMenuItem(trans("SYNC"))
|
||||
sync.addActionListener({controller.sync()})
|
||||
menu.add(sync)
|
||||
}
|
||||
JPopupMenu menu = new JPopupMenu()
|
||||
|
||||
JMenuItem sync = new JMenuItem(trans("SYNC"))
|
||||
sync.addActionListener({controller.sync()})
|
||||
menu.add(sync)
|
||||
|
||||
menu.show(e.getComponent(), e.getX(), e.getY())
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
package com.muwire.gui
|
||||
|
||||
import griffon.core.artifact.GriffonView
|
||||
|
||||
import javax.swing.JFrame
|
||||
|
||||
import static com.muwire.gui.Translator.trans
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
|
@ -24,8 +27,7 @@ class WatchedDirectoryView {
|
|||
@MVCMember @Nonnull
|
||||
WatchedDirectoryModel model
|
||||
|
||||
def dialog
|
||||
def p
|
||||
JFrame window
|
||||
def mainFrame
|
||||
|
||||
def autoWatchCheckbox
|
||||
|
@ -34,10 +36,10 @@ class WatchedDirectoryView {
|
|||
|
||||
void initUI() {
|
||||
mainFrame = application.windowManager.findWindow("main-frame")
|
||||
dialog = new JDialog(mainFrame, trans("WATCHED_DIRECTORY_CONFIGURATION"), true)
|
||||
dialog.setResizable(false)
|
||||
|
||||
p = builder.panel {
|
||||
window = builder.frame(visible: false, defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE,
|
||||
iconImage: builder.imageIcon("/MuWire-48x48.png").image,
|
||||
title: trans("WATCHED_DIRECTORY_CONFIGURATION")) {
|
||||
borderLayout()
|
||||
panel (constraints : BorderLayout.NORTH) {
|
||||
label(trans("WATCHED_DIRECTORY_CONFIGURATION_FOR",model.directory.directory.toString()))
|
||||
|
@ -74,10 +76,13 @@ class WatchedDirectoryView {
|
|||
model.autoWatch = autoWatchCheckbox.model.isSelected()
|
||||
} as ChangeListener)
|
||||
|
||||
dialog.getContentPane().add(p)
|
||||
dialog.pack()
|
||||
dialog.setLocationRelativeTo(mainFrame)
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
||||
dialog.show()
|
||||
window.addWindowListener( new WindowAdapter() {
|
||||
void windowClosed(WindowEvent event) {
|
||||
mvcGroup.destroy()
|
||||
}
|
||||
})
|
||||
window.pack()
|
||||
window.setLocationRelativeTo(mainFrame)
|
||||
window.setVisible(true)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue