6cda3e6261b437cfbba61a786a858309edd403cb
1 package be
.nikiroo
.jvcard
.test
;
4 import java
.io
.IOException
;
5 import java
.util
.LinkedList
;
8 import be
.nikiroo
.jvcard
.Card
;
9 import be
.nikiroo
.jvcard
.parsers
.Format
;
10 import be
.nikiroo
.jvcard
.tui
.MainWindow
;
11 import be
.nikiroo
.jvcard
.tui
.TuiLauncher
;
12 import be
.nikiroo
.jvcard
.tui
.panes
.ContactList
;
13 import be
.nikiroo
.jvcard
.tui
.panes
.FileList
;
15 import com
.googlecode
.lanterna
.TerminalSize
;
16 import com
.googlecode
.lanterna
.TextColor
;
17 import com
.googlecode
.lanterna
.gui2
.BasicWindow
;
18 import com
.googlecode
.lanterna
.gui2
.Button
;
19 import com
.googlecode
.lanterna
.gui2
.DefaultWindowManager
;
20 import com
.googlecode
.lanterna
.gui2
.EmptySpace
;
21 import com
.googlecode
.lanterna
.gui2
.GridLayout
;
22 import com
.googlecode
.lanterna
.gui2
.Label
;
23 import com
.googlecode
.lanterna
.gui2
.MultiWindowTextGUI
;
24 import com
.googlecode
.lanterna
.gui2
.Panel
;
25 import com
.googlecode
.lanterna
.gui2
.TextBox
;
26 import com
.googlecode
.lanterna
.gui2
.Window
;
27 import com
.googlecode
.lanterna
.gui2
.table
.Table
;
28 import com
.googlecode
.lanterna
.screen
.Screen
;
29 import com
.googlecode
.lanterna
.screen
.TerminalScreen
;
30 import com
.googlecode
.lanterna
.terminal
.DefaultTerminalFactory
;
31 import com
.googlecode
.lanterna
.terminal
.Terminal
;
33 public class TestCli
{
34 public static void main(String
[] args
) throws IOException
{
35 Boolean textMode
= null;
36 if (args
.length
> 0 && args
[0].equals("--tui"))
38 if (args
.length
> 0 && args
[0].equals("--gui"))
43 // TODO: do not hardcode that:
44 Card card
= new Card(new File("/home/niki/.addressbook"), Format
.Abook
);
45 win
= new MainWindow(new ContactList(card
));
47 List
<File
> files
= new LinkedList
<File
>();
48 files
.add(new File("/home/niki/vcf/coworkers.vcf"));
49 files
.add(new File("/home/niki/vcf/oce.vcf"));
50 win
= new MainWindow(new FileList(files
));
53 TuiLauncher
.start(textMode
, win
);
56 * String file = args.length > 0 ? args[0] : null; String file2 =
57 * args.length > 1 ? args[1] : null;
59 * if (file == null) file =
60 * "/home/niki/workspace/rcard/utils/CVcard/test.vcf"; if (file2 ==
61 * null) file2 = "/home/niki/workspace/rcard/utils/CVcard/test.abook";
63 * Card card = new Card(new File(file), Format.VCard21);
64 * System.out.println(card.toString());
66 * System.out.println("\n -- PINE -- \n");
68 * card = new Card(new File(file2), Format.Abook);
69 * System.out.println(card.toString(Format.Abook));
73 static private Table
test2() throws IOException
{
74 final Table
<String
> table
= new Table
<String
>("Column 1", "Column 2",
76 table
.getTableModel().addRow("1", "2", "3");
77 table
.setSelectAction(new Runnable() {
80 List
<String
> data
= table
.getTableModel().getRow(
81 table
.getSelectedRow());
82 for (int i
= 0; i
< data
.size(); i
++) {
83 System
.out
.println(data
.get(i
));
91 static private void test() throws IOException
{
92 // Setup terminal and screen layers
93 Terminal terminal
= new DefaultTerminalFactory().createTerminal();
94 Screen screen
= new TerminalScreen(terminal
);
97 // Create panel to hold components
98 Panel panel
= new Panel();
99 panel
.setLayoutManager(new GridLayout(2));
101 panel
.addComponent(new Label("Forename"));
102 panel
.addComponent(new TextBox());
104 panel
.addComponent(new Label("Surname"));
105 panel
.addComponent(new TextBox());
107 panel
.addComponent(new EmptySpace(new TerminalSize(0, 0))); // Empty
111 panel
.addComponent(new Button("Submit"));
113 // Create window to hold the panel
114 BasicWindow window
= new BasicWindow();
115 window
.setComponent(panel
);
117 // Create gui and start gui
118 MultiWindowTextGUI gui
= new MultiWindowTextGUI(screen
,
119 new DefaultWindowManager(), new EmptySpace(TextColor
.ANSI
.BLUE
));
120 gui
.addWindowAndWait(window
);