mirror of https://github.com/zlatinb/muwire
add contact selector for custom contacts visibility type
parent
d889a12a43
commit
5fcc3a0b88
|
@ -22,7 +22,8 @@ class WatchedDirectoryController {
|
||||||
autoWatch : view.autoWatchCheckbox.model.isSelected(),
|
autoWatch : view.autoWatchCheckbox.model.isSelected(),
|
||||||
syncInterval : Integer.parseInt(view.syncIntervalField.text),
|
syncInterval : Integer.parseInt(view.syncIntervalField.text),
|
||||||
subfolders: view.applySubCheckbox.model.isSelected(),
|
subfolders: view.applySubCheckbox.model.isSelected(),
|
||||||
visibility: model.visibility)
|
visibility: model.visibility,
|
||||||
|
customVisibility: view.contactSelector.model.contacts)
|
||||||
model.core.eventBus.publish(event)
|
model.core.eventBus.publish(event)
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
import com.muwire.core.Core
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.Persona
|
||||||
import com.muwire.core.files.directories.Visibility
|
import com.muwire.core.files.directories.Visibility
|
||||||
import com.muwire.core.files.directories.WatchedDirectory
|
import com.muwire.core.files.directories.WatchedDirectory
|
||||||
|
|
||||||
|
@ -16,10 +17,13 @@ class WatchedDirectoryModel {
|
||||||
@Observable boolean autoWatch
|
@Observable boolean autoWatch
|
||||||
@Observable int syncInterval
|
@Observable int syncInterval
|
||||||
@Observable Visibility visibility
|
@Observable Visibility visibility
|
||||||
|
Set<Persona> allowedContacts = new HashSet<>()
|
||||||
|
|
||||||
void mvcGroupInit(Map<String,String> args) {
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
autoWatch = directory.autoWatch
|
autoWatch = directory.autoWatch
|
||||||
syncInterval = directory.syncInterval
|
syncInterval = directory.syncInterval
|
||||||
visibility = directory.visibility
|
visibility = directory.visibility
|
||||||
|
if (directory.customVisibility != null)
|
||||||
|
allowedContacts.addAll(directory.customVisibility)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@ package com.muwire.gui
|
||||||
|
|
||||||
import com.muwire.core.files.directories.Visibility
|
import com.muwire.core.files.directories.Visibility
|
||||||
import griffon.core.artifact.GriffonView
|
import griffon.core.artifact.GriffonView
|
||||||
|
import griffon.core.mvc.MVCGroup
|
||||||
|
|
||||||
import javax.swing.JFrame
|
import javax.swing.JFrame
|
||||||
import javax.swing.border.TitledBorder
|
import javax.swing.border.TitledBorder
|
||||||
|
@ -36,9 +37,15 @@ class WatchedDirectoryView {
|
||||||
def syncIntervalField
|
def syncIntervalField
|
||||||
def applySubCheckbox
|
def applySubCheckbox
|
||||||
|
|
||||||
|
MVCGroup contactSelector
|
||||||
|
|
||||||
void initUI() {
|
void initUI() {
|
||||||
mainFrame = application.windowManager.findWindow("main-frame")
|
mainFrame = application.windowManager.findWindow("main-frame")
|
||||||
|
|
||||||
|
def params = [:]
|
||||||
|
params.contacts = model.allowedContacts
|
||||||
|
contactSelector = mvcGroup.createMVCGroup("contact-selector", UUID.randomUUID().toString(), params)
|
||||||
|
|
||||||
window = builder.frame(visible: false, defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE,
|
window = builder.frame(visible: false, defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE,
|
||||||
iconImage: builder.imageIcon("/MuWire-48x48.png").image,
|
iconImage: builder.imageIcon("/MuWire-48x48.png").image,
|
||||||
title: trans("WATCHED_DIRECTORY_CONFIGURATION")) {
|
title: trans("WATCHED_DIRECTORY_CONFIGURATION")) {
|
||||||
|
@ -47,7 +54,7 @@ class WatchedDirectoryView {
|
||||||
label(trans("WATCHED_DIRECTORY_CONFIGURATION_FOR",model.directory.directory.toString()))
|
label(trans("WATCHED_DIRECTORY_CONFIGURATION_FOR",model.directory.directory.toString()))
|
||||||
}
|
}
|
||||||
panel (constraints : BorderLayout.CENTER) {
|
panel (constraints : BorderLayout.CENTER) {
|
||||||
gridLayout(rows: 2, cols: 1)
|
gridLayout(rows: 3, cols: 1)
|
||||||
panel(border: titledBorder(title: trans("WATCHED_DIRECTORY_SYNC_CONFIG"), border: etchedBorder(),
|
panel(border: titledBorder(title: trans("WATCHED_DIRECTORY_SYNC_CONFIG"), border: etchedBorder(),
|
||||||
titlePosition: TitledBorder.TOP)) {
|
titlePosition: TitledBorder.TOP)) {
|
||||||
gridBagLayout()
|
gridBagLayout()
|
||||||
|
@ -74,6 +81,7 @@ class WatchedDirectoryView {
|
||||||
selected: bind { model.visibility == Visibility.CUSTOM },
|
selected: bind { model.visibility == Visibility.CUSTOM },
|
||||||
buttonGroup : visibilityGroup, actionPerformed : actionCustom)
|
buttonGroup : visibilityGroup, actionPerformed : actionCustom)
|
||||||
}
|
}
|
||||||
|
widget(contactSelector.view.component)
|
||||||
}
|
}
|
||||||
panel (constraints : BorderLayout.SOUTH) {
|
panel (constraints : BorderLayout.SOUTH) {
|
||||||
gridLayout(rows: 1, cols: 3)
|
gridLayout(rows: 1, cols: 3)
|
||||||
|
@ -94,6 +102,8 @@ class WatchedDirectoryView {
|
||||||
autoWatchCheckbox.addChangeListener({e ->
|
autoWatchCheckbox.addChangeListener({e ->
|
||||||
model.autoWatch = autoWatchCheckbox.model.isSelected()
|
model.autoWatch = autoWatchCheckbox.model.isSelected()
|
||||||
} as ChangeListener)
|
} as ChangeListener)
|
||||||
|
|
||||||
|
contactSelector.view.component.setEnabled(model.visibility == Visibility.CUSTOM)
|
||||||
|
|
||||||
window.addWindowListener( new WindowAdapter() {
|
window.addWindowListener( new WindowAdapter() {
|
||||||
void windowClosed(WindowEvent event) {
|
void windowClosed(WindowEvent event) {
|
||||||
|
@ -105,15 +115,22 @@ class WatchedDirectoryView {
|
||||||
window.setVisible(true)
|
window.setVisible(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mvcGroupDestroy() {
|
||||||
|
contactSelector?.destroy()
|
||||||
|
}
|
||||||
|
|
||||||
def actionEveryone = {
|
def actionEveryone = {
|
||||||
|
contactSelector.view.component.setEnabled(false)
|
||||||
model.visibility = Visibility.EVERYONE
|
model.visibility = Visibility.EVERYONE
|
||||||
}
|
}
|
||||||
|
|
||||||
def actionContacts = {
|
def actionContacts = {
|
||||||
|
contactSelector.view.component.setEnabled(false)
|
||||||
model.visibility = Visibility.CONTACTS
|
model.visibility = Visibility.CONTACTS
|
||||||
}
|
}
|
||||||
|
|
||||||
def actionCustom = {
|
def actionCustom = {
|
||||||
|
contactSelector.view.component.setEnabled(true)
|
||||||
model.visibility = Visibility.CUSTOM
|
model.visibility = Visibility.CUSTOM
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue