PMD code sweep, #6 don't add MyWindow twice to MyApplication
[fanfix.git] / src / jexer / demos / DemoTreeViewWindow.java
index a1f4a6152cc342b60e693a846ae32dc62d1b7430..a4bcbe25ef04ee854d85f99bd4ed3f9a54dbd27e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * The MIT License (MIT)
  *
- * Copyright (C) 2016 Kevin Lamonte
+ * Copyright (C) 2017 Kevin Lamonte
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -32,6 +32,9 @@ import java.io.IOException;
 
 import jexer.*;
 import jexer.event.*;
+import jexer.ttree.*;
+import static jexer.TCommand.*;
+import static jexer.TKeypress.*;
 
 /**
  * This window demonstates the TTreeView widget.
@@ -41,7 +44,7 @@ public class DemoTreeViewWindow extends TWindow {
     /**
      * Hang onto my TTreeView so I can resize it with the window.
      */
-    private TTreeView treeView;
+    private TTreeViewWidget treeView;
 
     /**
      * Public constructor.
@@ -53,8 +56,14 @@ public class DemoTreeViewWindow extends TWindow {
         super(parent, "Tree View", 0, 0, 44, 16, TWindow.RESIZABLE);
 
         // Load the treeview with "stuff"
-        treeView = addTreeView(1, 1, 40, 12);
+        treeView = addTreeViewWidget(1, 1, 40, 12);
         new TDirectoryTreeItem(treeView, ".", true);
+
+        statusBar = newStatusBar("Treeview demonstration");
+        statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
+        statusBar.addShortcutKeypress(kbF2, cmShell, "Shell");
+        statusBar.addShortcutKeypress(kbF3, cmOpen, "Open");
+        statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
     }
 
     /**
@@ -65,10 +74,10 @@ public class DemoTreeViewWindow extends TWindow {
     @Override
     public void onResize(final TResizeEvent resize) {
         if (resize.getType() == TResizeEvent.Type.WIDGET) {
-            // Resize the text field
-            treeView.setWidth(resize.getWidth() - 4);
-            treeView.setHeight(resize.getHeight() - 4);
-            treeView.reflow();
+            // Resize the treeView field
+            TResizeEvent treeSize = new TResizeEvent(TResizeEvent.Type.WIDGET,
+                resize.getWidth() - 4, resize.getHeight() - 4);
+            treeView.onResize(treeSize);
             return;
         }