59 lines
2.0 KiB
Groovy
59 lines
2.0 KiB
Groovy
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 CloseWarningView {
|
|
@MVCMember @Nonnull
|
|
FactoryBuilderSupport builder
|
|
@MVCMember @Nonnull
|
|
CloseWarningModel model
|
|
|
|
def mainFrame
|
|
def dialog
|
|
def panel
|
|
def checkbox
|
|
|
|
void initUI() {
|
|
mainFrame = application.windowManager.findWindow("main-frame")
|
|
|
|
dialog = new JDialog(mainFrame, "Close MuWire?", true)
|
|
panel = builder.panel {
|
|
gridBagLayout()
|
|
label(text : "Would you like to minimize to system tray or exit immediately?", constraints : gbc(gridx: 0, gridy: 0, gridwidth : 2))
|
|
label(text : "\n", constraints : gbc(gridx : 0, gridy : 1)) // TODO: real padding
|
|
label(text : "Remember my decision", constraints : gbc(gridx: 0, gridy : 2, weightx: 100, anchor : GridBagConstraints.LINE_END))
|
|
checkbox = checkBox(selected : bind {model.closeWarning}, constraints : gbc(gridx: 1, gridy :2))
|
|
panel (constraints : gbc(gridx: 0, gridy : 3, gridwidth : 2)) {
|
|
button(text : "Minimize To Tray", closeAction)
|
|
button(text : "Exit MuWire", exitAction)
|
|
}
|
|
}
|
|
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) {
|
|
mainFrame.setVisible(false)
|
|
mvcGroup.destroy()
|
|
}
|
|
})
|
|
}
|
|
|
|
void mvcGroupInit(Map<String,String> args) {
|
|
dialog.show()
|
|
}
|
|
} |