99import com .msc .serverbrowser .gui .View ;
1010import com .msc .serverbrowser .gui .controllers .interfaces .ViewController ;
1111import com .msc .serverbrowser .logging .Logging ;
12+ import com .msc .serverbrowser .util .windows .OSUtility ;
1213
1314import javafx .application .Platform ;
1415import javafx .beans .property .DoubleProperty ;
1516import javafx .fxml .FXML ;
1617import javafx .fxml .FXMLLoader ;
18+ import javafx .scene .Node ;
1719import javafx .scene .Parent ;
20+ import javafx .scene .control .Hyperlink ;
1821import javafx .scene .control .Label ;
1922import javafx .scene .control .ProgressBar ;
2023import javafx .scene .control .ScrollPane ;
21- import javafx .scene .layout .StackPane ;
24+ import javafx .scene .control .ToggleButton ;
25+ import javafx .scene .control .ToggleGroup ;
26+ import javafx .scene .control .Tooltip ;
27+ import javafx .scene .layout .HBox ;
28+ import javafx .scene .text .Font ;
2229
2330/**
2431 * Controller for the Main view, e.g. the view that contains the menu bar, the
3037public class MainController implements ViewController
3138{
3239 @ FXML
33- private StackPane menuItemFav ;
40+ private ToggleButton menuItemFav ;
3441 @ FXML
35- private StackPane menuItemAll ;
42+ private ToggleButton menuItemAll ;
3643 @ FXML
37- private StackPane menuItemUser ;
44+ private ToggleButton menuItemUser ;
3845 @ FXML
39- private StackPane menuItemVersion ;
46+ private ToggleButton menuItemVersion ;
4047 @ FXML
41- private StackPane menuItemFiles ;
48+ private ToggleButton menuItemFiles ;
4249 @ FXML
43- private StackPane menuItemSettings ;
50+ private ToggleButton menuItemSettings ;
4451
4552 @ FXML
46- private ScrollPane activeViewContainer ;
47- private View activeView ;
53+ private ScrollPane activeViewContainer ;
54+ private View activeView ;
4855
4956 @ FXML
50- private Label globalProgressLabel ;
57+ private Hyperlink hyperlinkGitHub ;
5158 @ FXML
52- private ProgressBar globalProgressBar ;
59+ private Hyperlink hyperlinkHelp ;
60+
61+ @ FXML
62+ private HBox bottomBarCustom ;
63+
64+ @ FXML
65+ private Label globalProgressLabel ;
66+ @ FXML
67+ private ProgressBar globalProgressBar ;
5368
5469 @ Override
5570 public void initialize ()
5671 {
72+ Font .loadFont (MainController .class .getResource ("/com/msc/serverbrowser/fonts/FontAwesome.otf" ).toExternalForm (),
73+ 12 );
74+
75+ final ToggleGroup menuToggleGroup = new ToggleGroup ();
76+ menuItemFav .setToggleGroup (menuToggleGroup );
77+ menuItemAll .setToggleGroup (menuToggleGroup );
78+ menuItemUser .setToggleGroup (menuToggleGroup );
79+ menuItemVersion .setToggleGroup (menuToggleGroup );
80+ menuItemFiles .setToggleGroup (menuToggleGroup );
81+ menuItemSettings .setToggleGroup (menuToggleGroup );
82+
83+ menuItemFav .setText ("\uf005 " );
84+ menuItemAll .setText ("\uf0c9 " );
85+ menuItemUser .setText ("\uf007 " );
86+ menuItemVersion .setText ("\uf0ed " );
87+ menuItemFiles .setText ("\uf07b " );
88+ menuItemSettings .setText ("\uf013 " );
89+
90+ hyperlinkGitHub .setText ("\uf09b " );
91+ hyperlinkHelp .setText ("\uf059 " );
92+
93+ hyperlinkGitHub .setTooltip (new Tooltip ("Opens the GitHub project page." ));
94+ hyperlinkHelp .setTooltip (new Tooltip ("Opens the GitHub projects wiki page." ));
95+
5796 if (ClientPropertiesController .getPropertyAsBoolean (Property .SAVE_LAST_VIEW ))
5897 {
5998 loadView (View .valueOf (ClientPropertiesController .getPropertyAsInt (Property .LAST_VIEW )));
@@ -65,11 +104,43 @@ public void initialize()
65104
66105 }
67106
107+ @ FXML
108+ private void openGitHub ()
109+ {
110+ OSUtility .browse ("https://github.com/Bios-Marcel/SererBrowser" );
111+ }
112+
113+ @ FXML
114+ private void openHelp ()
115+ {
116+ OSUtility .browse ("https://github.com/Bios-Marcel/SererBrowser/wiki" );
117+ }
118+
119+ /**
120+ * Adds nodes to the Clients bottom bar.
121+ *
122+ * @param nodes
123+ * the node that will be added
124+ */
125+ public void addItemsToBottomBar (final Node ... nodes )
126+ {
127+ bottomBarCustom .getChildren ().addAll (nodes );
128+ }
129+
130+ /**
131+ * @return the progress {@link DoubleProperty} of the {@link #globalProgressBar}
132+ */
68133 public DoubleProperty progressProperty ()
69134 {
70135 return globalProgressBar .progressProperty ();
71136 }
72137
138+ /**
139+ * Sets the text infront of the global {@link ProgressBar} bar.
140+ *
141+ * @param text
142+ * the text tht appears infront of the global {@link ProgressBar}
143+ */
73144 public void setGlobalProgressText (final String text )
74145 {
75146 globalProgressLabel .setText (text );
@@ -113,34 +184,27 @@ private void onSettingsMenuItemClicked()
113184
114185 private void loadView (final View view )
115186 {
116- final String CLICKED_STYLE_CLASS = "clickedItem" ;
117-
118- menuItemFav .getStyleClass ().remove (CLICKED_STYLE_CLASS );
119- menuItemSettings .getStyleClass ().remove (CLICKED_STYLE_CLASS );
120- menuItemUser .getStyleClass ().remove (CLICKED_STYLE_CLASS );
121- menuItemAll .getStyleClass ().remove (CLICKED_STYLE_CLASS );
122- menuItemVersion .getStyleClass ().remove (CLICKED_STYLE_CLASS );
123- menuItemFiles .getStyleClass ().remove (CLICKED_STYLE_CLASS );
187+ bottomBarCustom .getChildren ().clear ();
124188
125189 switch (view )
126190 {
127191 case SERVERS_FAV :
128- menuItemFav .getStyleClass (). add ( CLICKED_STYLE_CLASS );
192+ menuItemFav .setSelected ( true );
129193 break ;
130194 case SERVERS_ALL :
131- menuItemAll .getStyleClass (). add ( CLICKED_STYLE_CLASS );
195+ menuItemAll .setSelected ( true );
132196 break ;
133197 case USERNAME_CHANGER :
134- menuItemUser .getStyleClass (). add ( CLICKED_STYLE_CLASS );
198+ menuItemUser .setSelected ( true );
135199 break ;
136200 case VERSION_CHANGER :
137- menuItemVersion .getStyleClass (). add ( CLICKED_STYLE_CLASS );
201+ menuItemVersion .setSelected ( true );
138202 break ;
139203 case FILES :
140- menuItemFiles .getStyleClass (). add ( CLICKED_STYLE_CLASS );
204+ menuItemFiles .setSelected ( true );
141205 break ;
142206 case SETTINGS :
143- menuItemSettings .getStyleClass (). add ( CLICKED_STYLE_CLASS );
207+ menuItemSettings .setSelected ( true );
144208 break ;
145209 default :
146210 throw new IllegalArgumentException ("This View hasn't been implemented or is invalid: " + view );
@@ -156,6 +220,9 @@ private void loadFXML(final View view)
156220 {
157221 final FXMLLoader loader = new FXMLLoader ();
158222 loader .setLocation (getClass ().getResource (view .getFXMLPath ()));
223+
224+ // Creating a new instance of the specified controller, controllers never have
225+ // constructor arguments, therefore this is supposedly fine.
159226 loader .setController (view .getControllerType ().newInstance ());
160227 final Parent toLoad = loader .load ();
161228 toLoad .getStylesheets ().setAll (view .getStylesheetPath ());
0 commit comments