11package org .glavo .viewer .gui ;
22
33import javafx .application .Application ;
4+ import javafx .beans .binding .Bindings ;
5+ import javafx .geometry .Pos ;
46import javafx .scene .Scene ;
7+ import javafx .scene .control .Hyperlink ;
58import javafx .scene .control .Tab ;
69import javafx .scene .input .*;
710import javafx .scene .layout .*;
11+ import javafx .scene .paint .Color ;
12+ import javafx .scene .text .Text ;
13+ import javafx .scene .text .TextAlignment ;
14+ import javafx .scene .text .TextFlow ;
815import javafx .stage .Stage ;
916import javafx .stage .StageStyle ;
1017import org .glavo .viewer .gui .filetypes .FileType ;
1926
2027public final class Viewer extends Application {
2128 public static final String TITLE = "ClassViewer" ;
29+ public static final ResourceBundle resource = ResourceBundle .getBundle ("org.glavo.viewer.gui.ViewerResources" );
2230
2331 public static final int DEFAULT_WIDTH = 1080 ;
2432 public static final int DEFAULT_HEIGHT = 608 ;
2533
26- public static void main (String [] args ) {
27- Options .init ();
28- Log .info ("launch application" );
29- Application .launch (Viewer .class , args );
30- }
31-
3234 private Stage stage ;
3335 private Scene scene ;
3436 private BorderPane pane ;
3537
38+ private Pane defaultText ;
39+
3640 private ViewerTopBar topBar ;
3741 private ViewerTabPane tabPane ;
3842
@@ -48,9 +52,16 @@ public void start(Stage stage) {
4852 this .pane = new BorderPane ();
4953 this .topBar = new ViewerTopBar (this );
5054 this .tabPane = new ViewerTabPane (this );
55+ this .defaultText = this .createDefaultText ();
5156
5257 pane .setTop (topBar );
53- pane .setCenter (tabPane );
58+ pane .setCenter (defaultText );
59+ pane .centerProperty ().bind (Bindings .createObjectBinding (() -> {
60+ if (tabPane .getTabs ().isEmpty ()) {
61+ return defaultText ;
62+ }
63+ return tabPane ;
64+ }, tabPane .getTabs ()));
5465 FontUtils .setUIFont (tabPane );
5566
5667 this .scene = new Scene (pane , DEFAULT_WIDTH , DEFAULT_HEIGHT );
@@ -226,4 +237,28 @@ public ViewerTopBar getTopBar() {
226237 public ViewerTabPane getTabPane () {
227238 return tabPane ;
228239 }
240+
241+ private Pane createDefaultText () {
242+ VBox pane = new VBox ();
243+ pane .setAlignment (Pos .CENTER );
244+
245+ Text openFileText = new Text (resource .getString ("defaultText.openFile" ));
246+ openFileText .setFill (Color .GRAY );
247+ Hyperlink openFileLink = new Hyperlink (topBar .getMenuBar ().fileMenu .openFileItem .getAccelerator ().getDisplayText ());
248+ openFileLink .setOnAction (event -> openFile ());
249+
250+ Text openFolderText = new Text (resource .getString ("defaultText.openFolder" ));
251+ openFolderText .setFill (Color .GRAY );
252+ Hyperlink openFolderLink = new Hyperlink (topBar .getMenuBar ().fileMenu .openFolderItem .getAccelerator ().getDisplayText ());
253+ openFolderLink .setOnAction (event -> openFolder ());
254+
255+ TextFlow text = new TextFlow (
256+ openFileText , new Text (" " ), openFileLink , new Text ("\n " ),
257+ openFolderText , new Text (" " ), openFolderLink
258+ );
259+ text .setTextAlignment (TextAlignment .CENTER );
260+
261+ pane .getChildren ().add (text );
262+ return pane ;
263+ }
229264}
0 commit comments