Mercurial Hosting > junotu
changeset 61:07a05c60abef
TabBoard: Improved column removal
Now column cards are removed.
author | Fox |
---|---|
date | Fri, 23 Dec 2022 17:57:33 +0100 |
parents | cda50e8f5135 |
children | e28cb683c561 |
files | src/junotu/Card.java src/junotu/TabBoard.java |
diffstat | 2 files changed, 58 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/junotu/Card.java Fri Dec 23 17:10:09 2022 +0100 +++ b/src/junotu/Card.java Fri Dec 23 17:57:33 2022 +0100 @@ -20,11 +20,18 @@ public static final String TAG_BOARD = TAG_CORE_PREFIX+"board"; public static final String TAG_BOARD_COLUMNS = TAG_CORE_PREFIX+"board_columns"; public static final String TAG_BOARD_COLUMN_CARDS = TAG_CORE_PREFIX+"board_column_cards"; + public static final String TAG_BOARD_COLUMN_CARD = TAG_CORE_PREFIX+"board_column_card"; + + public static final String VALUE_BOARD_COLUMN_CARD_ONLY = "only"; public static final String HIDE_TAGS[] = { TAG_BOARD_COLUMN_CARDS, }; + public static final String HIDE_TAG_VALUES[] = { + TAG_BOARD_COLUMN_CARD, VALUE_BOARD_COLUMN_CARD_ONLY, + }; + public SortedMap< String, Set<Object> > tags = new TreeMap< String, Set<Object> >(); public Card()
--- a/src/junotu/TabBoard.java Fri Dec 23 17:10:09 2022 +0100 +++ b/src/junotu/TabBoard.java Fri Dec 23 17:57:33 2022 +0100 @@ -209,12 +209,12 @@ Card childCard = Main.database.cardGetByIdentifier(identifier); if( childCard == null ){ - System.out.print("Column '"+card.titleGet()+"', identifier"+Long.toString(card.identifierGet())+": Failed to load card by identifier"+Long.toString(identifier)+"\n"); + System.out.print("Column '"+card.titleGet()+"', identifier "+Long.toString(card.identifierGet())+": Failed to load card by identifier "+Long.toString(identifier)+"\n"); } insertCard( childCard, -1 ); } catch( NumberFormatException e ) { - System.out.print("Column '"+card.titleGet()+"', identifier"+Long.toString(card.identifierGet())+": Failed to convert card identifier '"+cardsSplit[i]+"' to long, aborting cards loading. Full cards tag: '"+cardsString+"'\n"); + System.out.print("Column '"+card.titleGet()+"', identifier "+Long.toString(card.identifierGet())+": Failed to convert card identifier '"+cardsSplit[i]+"' to long, aborting cards loading. Full cards tag: '"+cardsString+"'\n"); break; } catch( Exception e ) { throw new RuntimeException(e); @@ -359,6 +359,45 @@ } + public void delete() + { + Component[] cardList = cards.getComponents(); + for( int i = 0; i < cardList.length; i++ ) { + ColumnCardWidget cardWidget = (ColumnCardWidget)cardList[i]; + if( cardWidget.newCard ) { + continue; + } + + Card card; + + try { + card = Main.database.cardGetByIdentifier(cardWidget.identifier); + } catch( Exception e ) { + throw new RuntimeException(e); + } + + if( card == null ) { + throw new RuntimeException(); + } + + if( card.<String>tagGetAsOr( Card.TAG_BOARD_COLUMN_CARD, "" ).equals(Card.VALUE_BOARD_COLUMN_CARD_ONLY) ) { + System.out.print("Deleting card with identifier "+Long.toString(card.identifierGet())+" because it was only present in column identifier "+Long.toString(identifier)+" ('"+titleGet()+"') which is being deleted.\n"); + try { + Main.database.cardDelete(card.identifierGet()); + } catch( Exception e ) { + throw new RuntimeException(e); + } + } + } + if( !newCard ) { + try { + Main.database.cardDelete(identifier); + } catch( Exception e ) { + throw new RuntimeException(e); + } + } + } + public void actionPerformed( ActionEvent e ) { Object source = e.getSource(); @@ -474,6 +513,7 @@ if( newCard ) { Card card = new Card(); card.titleSet( title.getText() ); + card.tagValueSetOnly( Card.TAG_BOARD_COLUMN_CARD, Card.VALUE_BOARD_COLUMN_CARD_ONLY ); identifier = Main.database.cardAdd(card); newCard = false; @@ -567,7 +607,7 @@ Card columnCard = Main.database.cardGetByIdentifier(identifier); if( columnCard == null ){ - System.out.print("Board '"+card.titleGet()+"': Failed to load column by identifier"+Long.toString(identifier)+"\n"); + System.out.print("Board '"+card.titleGet()+"': Failed to load column by identifier "+Long.toString(identifier)+"\n"); } ColumnWidget column = new ColumnWidget(this, columnCard); @@ -652,6 +692,13 @@ return -1; } + public void removeColumn( ColumnWidget columnWidget ) { + columnWidget.delete(); + columns.remove( columnWidget ); + columns.validate(); + columns.repaint(); + } + public void moveCard( int from, int at, int to ) { ColumnWidget fromColumn = (ColumnWidget)columns.getComponent(from); @@ -722,10 +769,7 @@ if( !(e.getSource() instanceof ColumnWidget) ) return; - columns.remove( (ColumnWidget)e.getSource() ); - //columns.revalidate(); - columns.validate(); - columns.repaint(); + removeColumn( (ColumnWidget)e.getSource() ); } }