copy dialog modality/background/foreground,
This commit is contained in:
parent
0867fa0dab
commit
5c1ff8b441
@ -899,7 +899,7 @@ public class MainWindow extends JFrame {
|
||||
refreshItem.addActionListener(e -> refreshPanels());
|
||||
|
||||
JMenuItem queueItem = new JMenuItem("Operations Queue...");
|
||||
queueItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK));
|
||||
queueItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.ALT_DOWN_MASK));
|
||||
queueItem.addActionListener(e -> OperationQueueDialog.showQueue(this));
|
||||
|
||||
JMenuItem exitItem = new JMenuItem("Exit");
|
||||
|
||||
@ -64,6 +64,18 @@ public class OperationQueueDialog extends JDialog {
|
||||
buttonPanel.add(closeButton);
|
||||
add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
// Zapnutí zavírání pomocí ESC
|
||||
String cancelName = "cancel";
|
||||
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0), cancelName);
|
||||
ActionMap actionMap = getRootPane().getActionMap();
|
||||
actionMap.put(cancelName, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
FileOperationQueue.getInstance().addListener(tasks -> {
|
||||
SwingUtilities.invokeLater(() -> model.setTasks(tasks));
|
||||
});
|
||||
|
||||
@ -12,6 +12,7 @@ public class ProgressDialog extends JDialog {
|
||||
private final JLabel statusLabel;
|
||||
private final JLabel speedLabel;
|
||||
private final JButton pauseButton;
|
||||
private final JButton backgroundButton;
|
||||
private final JButton cancelButton;
|
||||
|
||||
private volatile boolean cancelled = false;
|
||||
@ -56,6 +57,7 @@ public class ProgressDialog extends JDialog {
|
||||
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
pauseButton = new JButton("Pause");
|
||||
backgroundButton = new JButton("Background");
|
||||
cancelButton = new JButton("Cancel");
|
||||
|
||||
pauseButton.addActionListener(e -> {
|
||||
@ -68,6 +70,14 @@ public class ProgressDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
backgroundButton.addActionListener(e -> {
|
||||
boolean wasModal = isModal();
|
||||
setVisible(false);
|
||||
setModal(!wasModal);
|
||||
backgroundButton.setText(wasModal ? "Foreground" : "Background");
|
||||
setVisible(true);
|
||||
});
|
||||
|
||||
cancelButton.addActionListener(e -> {
|
||||
cancelled = true;
|
||||
paused = false;
|
||||
@ -79,6 +89,7 @@ public class ProgressDialog extends JDialog {
|
||||
});
|
||||
|
||||
buttonPanel.add(pauseButton);
|
||||
buttonPanel.add(backgroundButton);
|
||||
buttonPanel.add(cancelButton);
|
||||
add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user