Mercurial Hosting > junotu
changeset 109:c5bd33a186fa
Changed 'Cancel' button to just 'Back' if no changes were made
author | Fox |
---|---|
date | Mon, 29 May 2023 01:36:38 +0200 |
parents | 7852a62809ba |
children | 487ba392d38a |
files | src/junotu/TabEdit.java |
diffstat | 1 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/junotu/TabEdit.java Mon May 29 01:35:51 2023 +0200 +++ b/src/junotu/TabEdit.java Mon May 29 01:36:38 2023 +0200 @@ -105,7 +105,7 @@ addTag = new JButton("+"); Box bottom = Box.createHorizontalBox(); - back = new JButton("Cancel"); + back = new JButton(); /* Text set in 'updateStatus()'. */ delete = new JButton("Delete"); editAsBoard = new JButton("As board"); save = new JButton("Save"); @@ -231,7 +231,7 @@ ghost = false; card = new Card(); dirty = true; - updateTitle(); + updateStatus(); delete.setVisible(false); updateTags(); } @@ -244,7 +244,7 @@ title.setText( card.titleGet() ); content.setText( card.contentGet() ); dirty = false; - updateTitle(); + updateStatus(); delete.setVisible(true); updateTags(); /* TODO: Is this needed? */ @@ -262,7 +262,7 @@ public void markDirty() { dirty = true; - updateTitle(); + updateStatus(); } public void markGhost() @@ -270,7 +270,7 @@ ghost = true; newCard = true; dirty = true; - updateTitle(); + updateStatus(); } public void linkGhost( Card card ) @@ -292,10 +292,10 @@ ghost = false; } - private void updateTitle() + private void updateStatus() { Window window = (Window)this.getTopLevelAncestor(); - + String text = title.getText(); String action; @@ -306,13 +306,20 @@ } else { action = "Edit"; } - + if( text.length() > 0 ) { window.setTitle( window.preferredTitle( action+": "+text ) ); } else { window.setTitle( window.preferredTitle( action ) ); } - + + if( !dirty ) { + back.setText("Back"); + back.revalidate(); /* Seems slow to change to 'back' otherwise. */ + } else { + back.setText("Cancel"); + } + } private void updateTags() @@ -580,7 +587,7 @@ if( newCard ) { cardEdit( this.card ); } else { - updateTitle(); /* Dirty state might have changed. */ + updateStatus(); /* Dirty state might have changed. */ } } else { reset();