Skip to content

Commit 41b740b

Browse files
committed
While iconEditDialog is open, no Cell or EditPanel can be selected.
1 parent a78671e commit 41b740b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/edit/CellEditDialog.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class CellEditDialog
6464

6565
private static String[] possibleActionsArray = new String[] {"", "text_to_clipboard", "file_to_clipboard"};
6666

67+
public static boolean iconEditEditorOpen = false;
6768
private static boolean selectedByUser = true;
6869

6970
public static void initializeCellEditDialog()
@@ -255,6 +256,9 @@ public static void hideEditDialog()
255256

256257
public static void processCell(Cell cell)
257258
{
259+
if (iconEditEditorOpen)
260+
return;
261+
258262
// cell
259263
if (selectedCell != null)
260264
selectedCell.setDefaultBorder();
@@ -374,6 +378,9 @@ public void mouseClicked(MouseEvent e)
374378

375379
private static void processEditPanel(EditPanel edit_panel)
376380
{
381+
if (iconEditEditorOpen)
382+
return;
383+
377384
if (selectedCellPanel != null)
378385
selectedCellPanel.setDefaultBorder();
379386
selectedCellPanel = edit_panel;
@@ -435,13 +442,23 @@ private static ActionListener getIconEditListener()
435442
JLabel main_image_label;
436443
JLabel layered_image_label;
437444

445+
private void closeDialog(JDialog dialog)
446+
{
447+
iconEditEditorOpen = false;
448+
dialog.dispose();
449+
}
450+
438451
@Override
439452
public void actionPerformed(ActionEvent ae)
440453
{
454+
iconEditEditorOpen = true;
455+
441456
main_image_abbr = ( (EditIconLabel) selectedCellPanel).getMainImageAbbr();
442457
layered_image_abbr = ( (EditIconLabel) selectedCellPanel).getLayeredImageAbbr();
443458

444459
JDialog icon_dialog = new JDialog(CellEditDialog.cellEditDialog, "Edit cell icon");
460+
icon_dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
461+
icon_dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { closeDialog(icon_dialog); } } );
445462

446463
JPanel main_panel = new JPanel();
447464
main_panel.setBackground(ColorSettings.getBackgroundColor() );
@@ -651,12 +668,12 @@ public void itemStateChanged(ItemEvent e) {
651668
else
652669
( (EditIconLabel) selectedCellPanel).updateIcon(main_image_abbr);
653670
CellEditDialog.cellEditDialog.pack();
654-
icon_dialog.dispose();
671+
closeDialog(icon_dialog);
655672
});
656673

657674
JButton button_cancel = new JButton("Cancel");
658675
control_panel.add(button_cancel);
659-
button_cancel.addActionListener(e -> { icon_dialog.dispose(); } );
676+
button_cancel.addActionListener(e -> closeDialog(icon_dialog) );
660677

661678
icon_dialog.pack();
662679
icon_dialog.setVisible(true);

0 commit comments

Comments
 (0)