show a warning when user tries to certify
This commit is contained in:
@ -91,4 +91,9 @@ mvcGroups {
|
||||
view = 'com.muwire.gui.FetchCertificatesView'
|
||||
controller = 'com.muwire.gui.FetchCertificatesController'
|
||||
}
|
||||
'certificate-warning' {
|
||||
model = 'com.muwire.gui.CertificateWarningModel'
|
||||
view = 'com.muwire.gui.CertificateWarningView'
|
||||
controller = 'com.muwire.gui.CertificateWarningController'
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.muwire.gui
|
||||
|
||||
import griffon.core.artifact.GriffonController
|
||||
import griffon.core.controller.ControllerAction
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import javax.annotation.Nonnull
|
||||
|
||||
@ArtifactProviderFor(GriffonController)
|
||||
class CertificateWarningController {
|
||||
@MVCMember @Nonnull
|
||||
CertificateWarningView view
|
||||
|
||||
UISettings settings
|
||||
File home
|
||||
|
||||
@ControllerAction
|
||||
void dismiss() {
|
||||
if (view.checkbox.model.isSelected()) {
|
||||
settings.certificateWarning = false
|
||||
File propsFile = new File(home, "gui.properties")
|
||||
propsFile.withOutputStream { settings.write(it) }
|
||||
}
|
||||
view.dialog.setVisible(false)
|
||||
mvcGroup.destroy()
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ import java.nio.charset.StandardCharsets
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
import javax.inject.Inject
|
||||
import javax.swing.JOptionPane
|
||||
import javax.swing.JTable
|
||||
|
||||
import com.muwire.core.Core
|
||||
@ -342,8 +343,16 @@ class MainFrameController {
|
||||
|
||||
@ControllerAction
|
||||
void issueCertificate() {
|
||||
view.selectedSharedFiles().each {
|
||||
core.eventBus.publish(new UICreateCertificateEvent(sharedFile : it))
|
||||
if (view.settings.certificateWarning) {
|
||||
def params = [:]
|
||||
params['settings'] = view.settings
|
||||
params['home'] = core.home
|
||||
mvcGroup.createMVCGroup("certificate-warning", params)
|
||||
} else {
|
||||
view.selectedSharedFiles().each {
|
||||
core.eventBus.publish(new UICreateCertificateEvent(sharedFile : it))
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, "Certificate(s) have been issued")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.muwire.gui
|
||||
|
||||
import griffon.core.artifact.GriffonModel
|
||||
import griffon.transform.Observable
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
|
||||
@ArtifactProviderFor(GriffonModel)
|
||||
class CertificateWarningModel {
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.muwire.gui
|
||||
|
||||
import griffon.core.artifact.GriffonView
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
|
||||
import javax.swing.JDialog
|
||||
import javax.swing.SwingConstants
|
||||
|
||||
import java.awt.GridBagConstraints
|
||||
import java.awt.event.WindowAdapter
|
||||
import java.awt.event.WindowEvent
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
|
||||
@ArtifactProviderFor(GriffonView)
|
||||
class CertificateWarningView {
|
||||
@MVCMember @Nonnull
|
||||
FactoryBuilderSupport builder
|
||||
|
||||
def mainFrame
|
||||
def dialog
|
||||
def panel
|
||||
def checkbox
|
||||
|
||||
void initUI() {
|
||||
mainFrame = application.windowManager.findWindow("main-frame")
|
||||
dialog = new JDialog(mainFrame, "Certificate Warning", true)
|
||||
|
||||
panel = builder.panel {
|
||||
gridBagLayout()
|
||||
label(text : "When you certify a file, you create a proof that you shared this file.", constraints :gbc(gridx: 0, gridy : 0, gridwidth : 2))
|
||||
label(text : "Even if you delete the certificate from your disk, others may already have it.", constraints : gbc(gridx:0, gridy : 1, gridwidth: 2))
|
||||
label(text : "If you are sure you want to do this, check the checkbox below, then click \"Certify\" again.", constraints : gbc(gridx:0, gridy: 2, gridwidth:2))
|
||||
label(text : "\n", constraints : gbc(gridx:0, gridy:3)) // TODO: real padding
|
||||
label(text : "I understand, do not show this warning again", constraints : gbc(gridx:0, gridy:4, anchor : GridBagConstraints.LINE_END))
|
||||
checkbox = checkBox(constraints : gbc(gridx:1, gridy:4, anchor : GridBagConstraints.LINE_START))
|
||||
panel (constraints : gbc(gridx :0, gridy : 5, gridwidth : 2)) {
|
||||
button(text : "Ok", dismissAction)
|
||||
}
|
||||
}
|
||||
|
||||
dialog.getContentPane().add(panel)
|
||||
dialog.pack()
|
||||
dialog.setResizable(false)
|
||||
dialog.setLocationRelativeTo(mainFrame)
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosed(WindowEvent e) {
|
||||
dialog.setVisible(false)
|
||||
mvcGroup.destroy()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
void mvcGroupInit(Map<String,String> args) {
|
||||
dialog.show()
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ class UISettings {
|
||||
boolean excludeLocalResult
|
||||
boolean showSearchHashes
|
||||
boolean closeWarning
|
||||
boolean certificateWarning
|
||||
boolean exitOnClose
|
||||
boolean clearUploads
|
||||
boolean storeSearchHistory
|
||||
@ -31,6 +32,7 @@ class UISettings {
|
||||
autoFontSize = Boolean.parseBoolean(props.getProperty("autoFontSize","false"))
|
||||
fontSize = Integer.parseInt(props.getProperty("fontSize","12"))
|
||||
closeWarning = Boolean.parseBoolean(props.getProperty("closeWarning","true"))
|
||||
certificateWarning = Boolean.parseBoolean(props.getProperty("certificateWarning","true"))
|
||||
exitOnClose = Boolean.parseBoolean(props.getProperty("exitOnClose","false"))
|
||||
clearUploads = Boolean.parseBoolean(props.getProperty("clearUploads","false"))
|
||||
storeSearchHistory = Boolean.parseBoolean(props.getProperty("storeSearchHistory","true"))
|
||||
@ -50,6 +52,7 @@ class UISettings {
|
||||
props.setProperty("autoFontSize", String.valueOf(autoFontSize))
|
||||
props.setProperty("fontSize", String.valueOf(fontSize))
|
||||
props.setProperty("closeWarning", String.valueOf(closeWarning))
|
||||
props.setProperty("certificateWarning", String.valueOf(certificateWarning))
|
||||
props.setProperty("exitOnClose", String.valueOf(exitOnClose))
|
||||
props.setProperty("clearUploads", String.valueOf(clearUploads))
|
||||
props.setProperty("storeSearchHistory", String.valueOf(storeSearchHistory))
|
||||
|
Reference in New Issue
Block a user