55import java .awt .Font ;
66import java .awt .event .ActionEvent ;
77import java .awt .event .ActionListener ;
8+ import java .awt .event .KeyEvent ;
9+ import java .awt .event .KeyListener ;
810import java .awt .event .MouseAdapter ;
911import java .awt .event .MouseEvent ;
1012import javax .swing .DefaultListModel ;
1113import javax .swing .ImageIcon ;
1214import javax .swing .JButton ;
15+ import javax .swing .JCheckBox ;
1316import javax .swing .JFrame ;
1417import javax .swing .JLabel ;
1518import javax .swing .JList ;
1619import javax .swing .JPanel ;
20+ import javax .swing .JScrollBar ;
1721import javax .swing .JScrollPane ;
1822import javax .swing .JTabbedPane ;
23+ import javax .swing .JTextArea ;
24+ import javax .swing .JTextField ;
1925import javax .swing .ListSelectionModel ;
2026import javax .swing .border .BevelBorder ;
2127import javax .swing .border .SoftBevelBorder ;
2228import javax .swing .event .ListSelectionEvent ;
2329import javax .swing .event .ListSelectionListener ;
2430import org .cyberpwn .react .ReactClient ;
2531import org .cyberpwn .react .network .NetworkedServer ;
32+ import org .cyberpwn .react .network .RequestCommand ;
33+ import org .cyberpwn .react .network .RequestCommandCallback ;
2634import org .cyberpwn .react .util .F ;
2735import org .cyberpwn .react .util .GList ;
2836import org .cyberpwn .react .util .GMap ;
@@ -43,7 +51,10 @@ public class ServerTab implements ListSelectionListener, ActionListener
4351 private JLabel label ;
4452 private JLabel label2 ;
4553 private JLabel lblNewLabel ;
54+ private JCheckBox chckbxNewCheckBox ;
4655
56+ private JScrollBar vertical ;
57+ private JTextArea textArea ;
4758 private JButton btnNewButton ;
4859 private JList <String > actionSet ;
4960 private DefaultListModel <String > actionList ;
@@ -62,6 +73,7 @@ public class ServerTab implements ListSelectionListener, ActionListener
6273
6374 private Grapher MAH ;
6475 private GList <Double > DMAH ;
76+ private JTextField textField ;
6577
6678 public ServerTab (JFrame frame , NetworkedServer server , JXTabbedPane tp )
6779 {
@@ -275,22 +287,72 @@ public void mouseReleased(MouseEvent e)
275287 panel_12 .add (btnNewButton , "cell 1 2" );
276288
277289 JPanel panel_3 = new JPanel ();
278- tabbedPane_1 .addTab ("Problems " , null , panel_3 , null );
290+ tabbedPane_1 .addTab ("Console " , null , panel_3 , null );
279291 panel_3 .setLayout (new MigLayout ("" , "[grow][grow]" , "[grow][grow]" ));
280292
281293 JPanel panel_18 = new JPanel ();
282294 panel_18 .setBorder (new SoftBevelBorder (BevelBorder .RAISED , null , null , null , null ));
283295 panel_18 .setBackground (Color .WHITE );
284296 panel_3 .add (panel_18 , "cell 0 0 2 2,grow" );
285- panel_18 .setLayout (new MigLayout ("" , "[]" , "[][]" ));
286-
287- JLabel lblNoIssuesFound = new JLabel ("No Issues Found (NOT YET IMPLEMENTED)" );
288- lblNoIssuesFound .setFont (new Font ("Segoe UI Light" , Font .PLAIN , 35 ));
289- panel_18 .add (lblNoIssuesFound , "cell 0 0" );
297+ panel_18 .setLayout (new MigLayout ("" , "[grow]" , "[grow][grow]" ));
298+
299+ textArea = new JTextArea ();
300+ textArea .setBackground (Color .DARK_GRAY );
301+ textArea .setForeground (Color .WHITE );
302+ textArea .setFont (new Font ("Lucida Console" , Font .PLAIN , 16 ));
303+ textArea .setEditable (false );
304+
305+ JScrollPane scrollConsole = new JScrollPane (textArea );
306+ panel_18 .add (scrollConsole , "cell 0 0,grow" );
307+
308+ textField = new JTextField ();
309+ textField .setFont (new Font ("Segoe UI Light" , Font .PLAIN , 14 ));
310+ panel_18 .add (textField , "flowx,cell 0 1,growx" );
311+ textField .setColumns (10 );
312+ textField .setDisabledTextColor (Color .RED );
313+ textField .addKeyListener (new KeyListener ()
314+ {
315+ @ Override
316+ public void keyTyped (KeyEvent e )
317+ {
318+
319+ }
320+
321+ @ Override
322+ public void keyPressed (KeyEvent e )
323+ {
324+
325+ }
326+
327+ @ Override
328+ public void keyReleased (KeyEvent e )
329+ {
330+ if (e .getKeyCode () == 10 )
331+ {
332+ String command = textField .getText ();
333+ textField .setEnabled (false );
334+
335+ new RequestCommand (ns , new RequestCommandCallback ()
336+ {
337+ @ Override
338+ public void run ()
339+ {
340+ textField .setEnabled (true );
341+ textField .setText ("" );
342+ textField .requestFocusInWindow ();
343+ }
344+ }, command ).start ();
345+ }
346+ }
347+ });
290348
291- JLabel lblNewLabel_1 = new JLabel ("Looks Like this server is doing fine for the moment!" );
292- lblNewLabel_1 .setFont (new Font ("Segoe UI Light" , Font .PLAIN , 18 ));
293- panel_18 .add (lblNewLabel_1 , "cell 0 1" );
349+ chckbxNewCheckBox = new JCheckBox ("Follow Log" );
350+ chckbxNewCheckBox .setBackground (Color .WHITE );
351+ chckbxNewCheckBox .setSelected (true );
352+ chckbxNewCheckBox .setFont (new Font ("Segoe UI Light" , Font .PLAIN , 14 ));
353+ panel_18 .add (chckbxNewCheckBox , "cell 0 1" );
354+ vertical = scrollConsole .getVerticalScrollBar ();
355+ vertical .setValue (vertical .getMaximum ());
294356 }
295357
296358 public void pushStartedActions ()
@@ -308,8 +370,18 @@ public void push(GList<String> actions)
308370 }
309371 }
310372
311- public void push (GMap <String , Double > sample )
373+ public void push (GMap <String , Double > sample , String console )
312374 {
375+ if (!textArea .getText ().equals (console ))
376+ {
377+ textArea .setText (console );
378+
379+ if (chckbxNewCheckBox .isSelected ())
380+ {
381+ textArea .setCaretPosition (textArea .getDocument ().getLength ());
382+ }
383+ }
384+
313385 lblServerName .setText (ns .getName ());
314386 lblUsingSpigot .setText (ns .getVersion ());
315387 lblTps .setText (F .f (sample .get ("tps" ), 2 ) + " TPS (" + F .pc (sample .get ("stability" ), 0 ) + " Stable)" );
0 commit comments