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());
|
refreshItem.addActionListener(e -> refreshPanels());
|
||||||
|
|
||||||
JMenuItem queueItem = new JMenuItem("Operations Queue...");
|
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));
|
queueItem.addActionListener(e -> OperationQueueDialog.showQueue(this));
|
||||||
|
|
||||||
JMenuItem exitItem = new JMenuItem("Exit");
|
JMenuItem exitItem = new JMenuItem("Exit");
|
||||||
|
|||||||
@ -64,6 +64,18 @@ public class OperationQueueDialog extends JDialog {
|
|||||||
buttonPanel.add(closeButton);
|
buttonPanel.add(closeButton);
|
||||||
add(buttonPanel, BorderLayout.SOUTH);
|
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 -> {
|
FileOperationQueue.getInstance().addListener(tasks -> {
|
||||||
SwingUtilities.invokeLater(() -> model.setTasks(tasks));
|
SwingUtilities.invokeLater(() -> model.setTasks(tasks));
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,6 +12,7 @@ public class ProgressDialog extends JDialog {
|
|||||||
private final JLabel statusLabel;
|
private final JLabel statusLabel;
|
||||||
private final JLabel speedLabel;
|
private final JLabel speedLabel;
|
||||||
private final JButton pauseButton;
|
private final JButton pauseButton;
|
||||||
|
private final JButton backgroundButton;
|
||||||
private final JButton cancelButton;
|
private final JButton cancelButton;
|
||||||
|
|
||||||
private volatile boolean cancelled = false;
|
private volatile boolean cancelled = false;
|
||||||
@ -56,6 +57,7 @@ public class ProgressDialog extends JDialog {
|
|||||||
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||||
pauseButton = new JButton("Pause");
|
pauseButton = new JButton("Pause");
|
||||||
|
backgroundButton = new JButton("Background");
|
||||||
cancelButton = new JButton("Cancel");
|
cancelButton = new JButton("Cancel");
|
||||||
|
|
||||||
pauseButton.addActionListener(e -> {
|
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 -> {
|
cancelButton.addActionListener(e -> {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
paused = false;
|
paused = false;
|
||||||
@ -79,6 +89,7 @@ public class ProgressDialog extends JDialog {
|
|||||||
});
|
});
|
||||||
|
|
||||||
buttonPanel.add(pauseButton);
|
buttonPanel.add(pauseButton);
|
||||||
|
buttonPanel.add(backgroundButton);
|
||||||
buttonPanel.add(cancelButton);
|
buttonPanel.add(cancelButton);
|
||||||
add(buttonPanel, BorderLayout.SOUTH);
|
add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user