Mercurial Hosting > junotu
changeset 93:1df77c040218
Separated ColumnCardWidget into separate file (from TabBoard and TabCalendarBoard)
author | Fox |
---|---|
date | Sun, 19 Feb 2023 09:25:43 +0100 |
parents | 0359e47f38c9 |
children | ce163f6cecdb |
files | src/junotu/ColumnCardWidget.java src/junotu/TabBoard.java src/junotu/TabCalendarBoard.java |
diffstat | 3 files changed, 120 insertions(+), 192 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/junotu/ColumnCardWidget.java Sun Feb 19 09:25:43 2023 +0100 @@ -0,0 +1,118 @@ +package junotu; + +import java.lang.RuntimeException; + +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseAdapter; + +import javax.swing.JPanel; + +import java.awt.BorderLayout; + +import java.awt.Component; +import javax.swing.JTextArea; + +import javax.swing.BorderFactory; + +import junotu.Main; +import junotu.Card; +import junotu.TabBoard; + +class ColumnCardWidget extends JPanel { + + public boolean newCard; + public long identifier; + public JTextArea title; + + public ColumnCardWidget( Card card ) + { + this.setLayout( new BorderLayout() ); + + title = new JTextArea(""); + + title.setFont( new Font( "Monospaced", Font.BOLD, 16 ) ); + + this.setMinimumSize( new Dimension( TabBoard.COLUMN_CONTENT_WIDTH, 64 ) ); + this.setPreferredSize( new Dimension( TabBoard.COLUMN_CONTENT_WIDTH, 64 ) ); + this.setMaximumSize( new Dimension( TabBoard.COLUMN_CONTENT_WIDTH, 128 ) ); + + //title.setMinimumSize( new Dimension( 32, 32 ) ); + + this.setBorder( BorderFactory.createRaisedBevelBorder() ); + title.setEditable( true ); + title.setLineWrap( true ); + title.setWrapStyleWord( true ); + title.setOpaque( false ); + + this.add( title, BorderLayout.CENTER ); + + MouseAdapter mouseListener = new MouseAdapter() + { + @Override + public void mouseClicked( MouseEvent e ) + { + e.setSource(ColumnCardWidget.this); + processMouseEvent(e); + } + }; + + title.addMouseListener( mouseListener ); + + newCard = card == null; + if( !newCard ) { + identifier = card.identifierGet(); + title.setText(card.titleGet()); + } + + } + + public void save() + { + try { + 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; + + } else { + Card card = Main.database.cardGetByIdentifier(identifier); + + if( card == null ) { + throw new RuntimeException("Null card on update try."); + } + + card.titleSet( title.getText() ); + Main.database.cardUpdate(card); + + } + } catch( Exception e ) { + throw new RuntimeException(e); + } + } + + public void delete() + { + if( newCard ) { + return; + } + + Main.database.cardDeleteByIdentifier(identifier, true); + } + + public boolean isSelected() + { + return title.isFocusOwner(); + } + + public void select() + { + title.requestFocusInWindow(); + } + +}
--- a/src/junotu/TabBoard.java Sun Feb 19 09:09:53 2023 +0100 +++ b/src/junotu/TabBoard.java Sun Feb 19 09:25:43 2023 +0100 @@ -46,6 +46,7 @@ import junotu.Main; import junotu.Window.Tab; import junotu.Card; +import junotu.ColumnCardWidget; public class TabBoard extends JPanel implements ActionListener, MouseListener { @@ -421,102 +422,6 @@ } - private class ColumnCardWidget extends JPanel { - - public boolean newCard; - public long identifier; - public JTextArea title; - - public ColumnCardWidget( Card card ) - { - this.setLayout( new BorderLayout() ); - - title = new JTextArea(""); - - title.setFont( new Font( "Monospaced", Font.BOLD, 16 ) ); - - this.setMinimumSize( new Dimension( COLUMN_CONTENT_WIDTH, 64 ) ); - this.setPreferredSize( new Dimension( COLUMN_CONTENT_WIDTH, 64 ) ); - this.setMaximumSize( new Dimension( COLUMN_CONTENT_WIDTH, 128 ) ); - - //title.setMinimumSize( new Dimension( 32, 32 ) ); - - this.setBorder( BorderFactory.createRaisedBevelBorder() ); - title.setEditable( true ); - title.setLineWrap( true ); - title.setWrapStyleWord( true ); - title.setOpaque( false ); - - this.add( title, BorderLayout.CENTER ); - - MouseAdapter mouseListener = new MouseAdapter() - { - @Override - public void mouseClicked( MouseEvent e ) - { - e.setSource(ColumnCardWidget.this); - processMouseEvent(e); - } - }; - - title.addMouseListener( mouseListener ); - - newCard = card == null; - if( !newCard ) { - identifier = card.identifierGet(); - title.setText(card.titleGet()); - } - - } - - public void save() - { - try { - 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; - - } else { - Card card = Main.database.cardGetByIdentifier(identifier); - - if( card == null ) { - throw new RuntimeException("Null card on update try."); - } - - card.titleSet( title.getText() ); - Main.database.cardUpdate(card); - - } - } catch( Exception e ) { - throw new RuntimeException(e); - } - } - - public void delete() - { - if( newCard ) { - return; - } - - Main.database.cardDeleteByIdentifier(identifier, true); - } - - public boolean isSelected() - { - return title.isFocusOwner(); - } - - public void select() - { - title.requestFocusInWindow(); - } - - } - long identifier; JTextField title; Box columns;
--- a/src/junotu/TabCalendarBoard.java Sun Feb 19 09:09:53 2023 +0100 +++ b/src/junotu/TabCalendarBoard.java Sun Feb 19 09:25:43 2023 +0100 @@ -63,6 +63,7 @@ import junotu.Window.Tab; import junotu.Window.TabInterface; import junotu.Card; +import junotu.ColumnCardWidget; public class TabCalendarBoard extends JPanel implements TabInterface, ActionListener, MouseListener, ChangeListener { @@ -424,102 +425,6 @@ } - private class ColumnCardWidget extends JPanel { - - public boolean newCard; - public long identifier; - public JTextArea title; - - public ColumnCardWidget( Card card ) - { - this.setLayout( new BorderLayout() ); - - title = new JTextArea(""); - - title.setFont( new Font( "Monospaced", Font.BOLD, 16 ) ); - - this.setMinimumSize( new Dimension( COLUMN_CONTENT_WIDTH, 64 ) ); - this.setPreferredSize( new Dimension( COLUMN_CONTENT_WIDTH, 64 ) ); - this.setMaximumSize( new Dimension( COLUMN_CONTENT_WIDTH, 128 ) ); - - //title.setMinimumSize( new Dimension( 32, 32 ) ); - - this.setBorder( BorderFactory.createRaisedBevelBorder() ); - title.setEditable( true ); - title.setLineWrap( true ); - title.setWrapStyleWord( true ); - title.setOpaque( false ); - - this.add( title, BorderLayout.CENTER ); - - MouseAdapter mouseListener = new MouseAdapter() - { - @Override - public void mouseClicked( MouseEvent e ) - { - e.setSource(ColumnCardWidget.this); - processMouseEvent(e); - } - }; - - title.addMouseListener( mouseListener ); - - newCard = card == null; - if( !newCard ) { - identifier = card.identifierGet(); - title.setText(card.titleGet()); - } - - } - - public void save() - { - try { - 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; - - } else { - Card card = Main.database.cardGetByIdentifier(identifier); - - if( card == null ) { - throw new RuntimeException("Null card on update try."); - } - - card.titleSet( title.getText() ); - Main.database.cardUpdate(card); - - } - } catch( Exception e ) { - throw new RuntimeException(e); - } - } - - public void delete() - { - if( newCard ) { - return; - } - - Main.database.cardDeleteByIdentifier(identifier, true); - } - - public boolean isSelected() - { - return title.isFocusOwner(); - } - - public void select() - { - title.requestFocusInWindow(); - } - - } - long identifier = -1; Box columns; JScrollPane scroll;