diff --git a/gui/griffon-app/controllers/com/muwire/gui/AdvancedSharingController.groovy b/gui/griffon-app/controllers/com/muwire/gui/AdvancedSharingController.groovy index 946e8ebe..6b82a4bd 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/AdvancedSharingController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/AdvancedSharingController.groovy @@ -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() diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index a3b9316e..bccb5247 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -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) } diff --git a/gui/griffon-app/controllers/com/muwire/gui/WatchedDirectoryController.groovy b/gui/griffon-app/controllers/com/muwire/gui/WatchedDirectoryController.groovy index 0c1df65a..205a299f 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/WatchedDirectoryController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/WatchedDirectoryController.groovy @@ -28,6 +28,7 @@ class WatchedDirectoryController { @ControllerAction void cancel() { - view.dialog.setVisible(false) + view.window.setVisible(false) + mvcGroup.destroy() } } \ No newline at end of file diff --git a/gui/griffon-app/i18n/messages.properties b/gui/griffon-app/i18n/messages.properties index 7fd54222..ea02b142 100644 --- a/gui/griffon-app/i18n/messages.properties +++ b/gui/griffon-app/i18n/messages.properties @@ -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) diff --git a/gui/griffon-app/models/com/muwire/gui/AdvancedSharingModel.groovy b/gui/griffon-app/models/com/muwire/gui/AdvancedSharingModel.groovy index 3a6f988b..653b85ad 100644 --- a/gui/griffon-app/models/com/muwire/gui/AdvancedSharingModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/AdvancedSharingModel.groovy @@ -28,7 +28,6 @@ class AdvancedSharingModel { Core core @Observable boolean syncActionEnabled - @Observable boolean configureActionEnabled void mvcGroupInit(Map args) { watchedDirectories.addAll(core.watchedDirectoryManager.watchedDirs.values()) diff --git a/gui/griffon-app/views/com/muwire/gui/AdvancedSharingView.groovy b/gui/griffon-app/views/com/muwire/gui/AdvancedSharingView.groovy index afc6648d..c38de215 100644 --- a/gui/griffon-app/views/com/muwire/gui/AdvancedSharingView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/AdvancedSharingView.groovy @@ -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()) } diff --git a/gui/griffon-app/views/com/muwire/gui/WatchedDirectoryView.groovy b/gui/griffon-app/views/com/muwire/gui/WatchedDirectoryView.groovy index 3918aab7..037abf78 100644 --- a/gui/griffon-app/views/com/muwire/gui/WatchedDirectoryView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/WatchedDirectoryView.groovy @@ -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 @@ -23,9 +26,8 @@ class WatchedDirectoryView { FactoryBuilderSupport builder @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())) @@ -73,11 +75,14 @@ class WatchedDirectoryView { autoWatchCheckbox.addChangeListener({e -> 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) } } \ No newline at end of file