changeset 37:de1ba9325973

Started on TabColumns
author Fox
date Wed, 19 Oct 2022 12:38:56 +0200
parents 11bf54badc99
children 2fab4ac14aaf
files src/junotu/Main.java src/junotu/TabColumns.java src/junotu/Window.java
diffstat 3 files changed, 188 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/junotu/Main.java	Wed Oct 19 12:36:59 2022 +0200
+++ b/src/junotu/Main.java	Wed Oct 19 12:38:56 2022 +0200
@@ -17,7 +17,8 @@
     public static void main(String[] args) throws Exception
     {
 	database = new Database();
-        windowAdd( Tab.SEARCH );
+        //windowAdd( Tab.SEARCH );
+        windowAdd( Tab.COLUMNS );
     }
 
     public static void windowAdd( Tab tab )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/junotu/TabColumns.java	Wed Oct 19 12:38:56 2022 +0200
@@ -0,0 +1,177 @@
+package junotu;
+
+/* TODO: Clean-up exports. */
+
+import java.lang.RuntimeException;
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.DocumentEvent;
+
+import javax.swing.JPanel;
+import javax.swing.Box;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.JScrollPane;
+import javax.swing.JScrollBar;
+
+import javax.swing.BorderFactory;
+import javax.swing.border.TitledBorder;
+
+import junotu.Main;
+import junotu.Window.Tab;
+import junotu.Card;
+
+public class TabColumns extends JPanel {
+
+    private class ColumnWidget extends JPanel {
+	JLabel title;
+	JTextField titleEdit;
+	Box cards;
+
+	public ColumnWidget()
+	{
+	    this.setLayout( new BorderLayout() );
+	    
+	    title = new JLabel("");
+	    cards = Box.createVerticalBox();
+
+	    title.setFont( new Font( "Monospaced", Font.PLAIN, 16 ) );
+
+	    //this.add( title, BorderLayout.NORTH );
+	    this.add( cards, BorderLayout.CENTER );
+
+	    this.setPreferredSize( new Dimension( 256+16, 384 ) );
+	    this.setMaximumSize( new Dimension( 256+16, 1000000 ) );
+
+	    this.setBorder(
+	        BorderFactory.createTitledBorder(
+		    BorderFactory.createEtchedBorder(),
+		    "Border title, but very very very long",
+		    TitledBorder.LEADING,
+		    TitledBorder.TOP,
+		    new Font( "Monospaced", Font.BOLD, 16 )
+		)
+	    );
+	    
+	}
+
+	public void titleSet( String title_ )
+	{
+	    title.setText(title_);
+	}
+
+	public String titleGet()
+	{
+	    return title.getText();
+	}
+	
+	public void insertCard( Card card, int at )
+	{
+	    if( at == -1 ) {
+		at = cards.getComponentCount();
+	    }
+	    ColumnCardWidget cardWidget = new ColumnCardWidget( card );
+	    /* TODO: Check if works properly. */
+	    cards.add( cardWidget, at );
+	}
+    }
+
+    private class ColumnCardWidget extends JPanel {
+
+	public long identifier;
+	
+	public ColumnCardWidget( Card card )
+	{
+	    this.setLayout( new BorderLayout() );
+	    
+	    identifier = card.identifierGet();
+	    JTextArea title = new JTextArea( card.titleGet() );
+	    
+	    title.setFont( new Font( "Monospaced", Font.BOLD, 16 ) );
+		
+	    this.setMinimumSize( new Dimension( 256, 64 ) );
+	    this.setPreferredSize( new Dimension( 256, 64 ) );
+	    this.setMaximumSize( new Dimension( 256, 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 );
+	    
+	}
+	
+    }
+
+    long columnsCard;
+    JLabel title;
+    Box columns;
+    JScrollPane scroll;
+
+    public TabColumns()
+    {
+	this.setLayout( new BorderLayout() );
+
+	title = new JLabel("");
+	columns = Box.createHorizontalBox();
+	scroll = new JScrollPane( columns );
+
+	title.setFont( new Font( "Monospaced", Font.PLAIN, 32 ) );
+
+	this.add( title, BorderLayout.NORTH );
+	this.add( scroll, BorderLayout.CENTER );
+
+	/* TODO: DEBUG */
+	columnsNew();
+	
+    }
+
+    public void columnsNew()
+    {
+	title.setText("New board");
+	columns.removeAll();
+	Card testCard = new Card();
+	testCard.titleSet("Test card");
+	testCard.contentSet("Content.");
+	for( int i = 0; i < 5; i++ ) {
+	    ColumnWidget column = new ColumnWidget();
+	    column.titleSet("New column");
+
+	    for( int j = 0; j < i; j++ ) {
+		column.insertCard( testCard, -1 );
+	    }
+
+	    columns.add( Box.createHorizontalStrut(16) );
+	    columns.add(column);
+	}
+    }
+
+    public void columnsEdit( Card columnsCard )
+    {
+	
+    }
+
+    public void columnsSave()
+    {
+	
+    }
+    
+}
--- a/src/junotu/Window.java	Wed Oct 19 12:36:59 2022 +0200
+++ b/src/junotu/Window.java	Wed Oct 19 12:38:56 2022 +0200
@@ -19,21 +19,25 @@
 
 import junotu.TabEdit;
 import junotu.TabSimpleSearch;
+import junotu.TabColumns;
 
 public class Window extends JFrame {
 
     public enum Tab {
 	SEARCH,
 	EDIT,
+	COLUMNS,
     };
 
     private static final String[] TAB_NAMES = {
 	"Search",
 	"Edit",
+	"Columns",
     };
 
     public TabSimpleSearch tabSearch;
     public TabEdit         tabEdit;
+    public TabColumns      tabColumns;
     
     private JPanel tabs;
     private CardLayout tabsLayout;
@@ -82,12 +86,15 @@
 
 	tabSearch = new TabSimpleSearch();
 	tabEdit = new TabEdit();
+	tabColumns = new TabColumns();
 
 	this.add(tabs);
 	tabs.add(tabSearch);
 	tabs.add(tabEdit);
-	tabsLayout.addLayoutComponent( tabSearch, TAB_NAMES[Tab.SEARCH.ordinal()] );
-	tabsLayout.addLayoutComponent( tabEdit,   TAB_NAMES[Tab.EDIT.ordinal()] );
+	tabs.add(tabColumns);
+	tabsLayout.addLayoutComponent( tabSearch,  TAB_NAMES[Tab.SEARCH.ordinal()] );
+	tabsLayout.addLayoutComponent( tabEdit,    TAB_NAMES[Tab.EDIT.ordinal()] );
+	tabsLayout.addLayoutComponent( tabColumns, TAB_NAMES[Tab.COLUMNS.ordinal()] );
 	
     }