convert watched directory configuration dialog to a frame

dbus-notify
Zlatin Balevsky 2022-05-04 18:24:52 +01:00
parent 3efee7ef68
commit 54def4ba89
No known key found for this signature in database
GPG Key ID: A72832072D525E41
7 changed files with 29 additions and 41 deletions

View File

@ -16,18 +16,6 @@ class AdvancedSharingController {
@MVCMember @Nonnull @MVCMember @Nonnull
AdvancedSharingView view 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 @ControllerAction
void sync() { void sync() {
def wd = view.selectedWatchedDirectory() def wd = view.selectedWatchedDirectory()

View File

@ -658,7 +658,7 @@ class MainFrameController {
def props = [:] def props = [:]
props.core = model.core props.core = model.core
props.directory = wd props.directory = wd
mvcGroup.createMVCGroup("watched-directory", props).destroy() mvcGroup.createMVCGroup("watched-directory", UUID.randomUUID().toString(), props)
} }

View File

@ -28,6 +28,7 @@ class WatchedDirectoryController {
@ControllerAction @ControllerAction
void cancel() { void cancel() {
view.dialog.setVisible(false) view.window.setVisible(false)
mvcGroup.destroy()
} }
} }

View File

@ -566,8 +566,8 @@ ROOM=Room
FEED_CONFIGURATION=Feed Configuration FEED_CONFIGURATION=Feed Configuration
FEED_CONFIGURATION_FOR=Configuration for feed {0} FEED_CONFIGURATION_FOR=Configuration for feed {0}
## Watched directory configuration dialog ## Watched directory configuration frame
WATCHED_DIRECTORY_CONFIGURATION=Watched Folder Configuration WATCHED_DIRECTORY_CONFIGURATION=Shared Folder Configuration
WATCHED_DIRECTORY_CONFIGURATION_FOR=Configuration for folder {0} WATCHED_DIRECTORY_CONFIGURATION_FOR=Configuration for folder {0}
WATCHED_DIRECTORY_AUTO=Auto-watch folder using operating system WATCHED_DIRECTORY_AUTO=Auto-watch folder using operating system
WATCHED_DIRECTORY_INTERVAL=Folder sync frequency (seconds, 0 means never) WATCHED_DIRECTORY_INTERVAL=Folder sync frequency (seconds, 0 means never)

View File

@ -28,7 +28,6 @@ class AdvancedSharingModel {
Core core Core core
@Observable boolean syncActionEnabled @Observable boolean syncActionEnabled
@Observable boolean configureActionEnabled
void mvcGroupInit(Map<String,String> args) { void mvcGroupInit(Map<String,String> args) {
watchedDirectories.addAll(core.watchedDirectoryManager.watchedDirs.values()) watchedDirectories.addAll(core.watchedDirectoryManager.watchedDirs.values())

View File

@ -68,8 +68,6 @@ class AdvancedSharingView {
} }
} }
panel (constraints : BorderLayout.SOUTH) { 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"), button(text : trans("SYNC"), toolTipText: trans("TOOLTIP_TOOLS_FOLDER_SYNC"),
enabled : bind{model.syncActionEnabled}, syncAction) enabled : bind{model.syncActionEnabled}, syncAction)
button(text : trans("CLOSE"), closeAction) button(text : trans("CLOSE"), closeAction)
@ -98,7 +96,6 @@ class AdvancedSharingView {
selectionModel.addListSelectionListener({ selectionModel.addListSelectionListener({
def directory = selectedWatchedDirectory() def directory = selectedWatchedDirectory()
model.syncActionEnabled = !(directory == null || directory.autoWatch) model.syncActionEnabled = !(directory == null || directory.autoWatch)
model.configureActionEnabled = directory != null
}) })
watchedDirsTable.addMouseListener(new MouseAdapter() { watchedDirsTable.addMouseListener(new MouseAdapter() {
@ -114,16 +111,14 @@ class AdvancedSharingView {
} }
private void showMenu(MouseEvent e) { private void showMenu(MouseEvent e) {
JPopupMenu menu = new JPopupMenu() if (!model.syncActionEnabled)
JMenuItem configure = new JMenuItem(trans("CONFIGURE")) return
configure.addActionListener({controller.configure()})
menu.add(configure)
if (model.syncActionEnabled) { JPopupMenu menu = new JPopupMenu()
JMenuItem sync = new JMenuItem(trans("SYNC"))
sync.addActionListener({controller.sync()}) JMenuItem sync = new JMenuItem(trans("SYNC"))
menu.add(sync) sync.addActionListener({controller.sync()})
} menu.add(sync)
menu.show(e.getComponent(), e.getX(), e.getY()) menu.show(e.getComponent(), e.getX(), e.getY())
} }

View File

@ -2,6 +2,9 @@
package com.muwire.gui package com.muwire.gui
import griffon.core.artifact.GriffonView import griffon.core.artifact.GriffonView
import javax.swing.JFrame
import static com.muwire.gui.Translator.trans import static com.muwire.gui.Translator.trans
import griffon.inject.MVCMember import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor import griffon.metadata.ArtifactProviderFor
@ -23,9 +26,8 @@ class WatchedDirectoryView {
FactoryBuilderSupport builder FactoryBuilderSupport builder
@MVCMember @Nonnull @MVCMember @Nonnull
WatchedDirectoryModel model WatchedDirectoryModel model
def dialog JFrame window
def p
def mainFrame def mainFrame
def autoWatchCheckbox def autoWatchCheckbox
@ -34,10 +36,10 @@ class WatchedDirectoryView {
void initUI() { void initUI() {
mainFrame = application.windowManager.findWindow("main-frame") 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() borderLayout()
panel (constraints : BorderLayout.NORTH) { panel (constraints : BorderLayout.NORTH) {
label(trans("WATCHED_DIRECTORY_CONFIGURATION_FOR",model.directory.directory.toString())) label(trans("WATCHED_DIRECTORY_CONFIGURATION_FOR",model.directory.directory.toString()))
@ -73,11 +75,14 @@ class WatchedDirectoryView {
autoWatchCheckbox.addChangeListener({e -> autoWatchCheckbox.addChangeListener({e ->
model.autoWatch = autoWatchCheckbox.model.isSelected() model.autoWatch = autoWatchCheckbox.model.isSelected()
} as ChangeListener) } as ChangeListener)
dialog.getContentPane().add(p) window.addWindowListener( new WindowAdapter() {
dialog.pack() void windowClosed(WindowEvent event) {
dialog.setLocationRelativeTo(mainFrame) mvcGroup.destroy()
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE) }
dialog.show() })
window.pack()
window.setLocationRelativeTo(mainFrame)
window.setVisible(true)
} }
} }