1   package main;
2   
3   import intellego.Intellego;
4   import util.*;
5   import interfaces.*;
6   import real.*;
7   
8   import java.awt.*;
9   import java.lang.*;
10  import java.awt.event.*;
11  import javax.swing.*;
12  import java.io.*;
13  import java.net.*;
14  
15  /** Provides a window which displays messages from external processes to the user,
16   * within the main interface.
17   * @author Graham Ritchie
18   * @modifyer Simon Zienkiewicz
19   */
20  public class ExternalMessager extends JInternalFrame
21  {
22      /** The pane which communicates to the user the results of the proccesses. */    
23      private JEditorPane messagePane;
24      static final int xOffset = 30, yOffset = 30;
25      static int openFrameCount = 0;
26  
27      /** Sets up the message display window
28       * @param num the index refering to the type of external messenger created
29       */
30      public ExternalMessager(int num)
31      {
32          //super("Compile/Upload Status Window: ",true,true,true,true);
33          super("",true,true,true,true);
34  
35          if(num ==0)this.setTitle("Compile Status Window:");
36          else if(num ==1) this.setTitle("Upload Status Window:");
37          else if(num ==3) this.setTitle("Upload Firmware Status Window:");
38  
39          openFrameCount++;
40  
41          // create and add the editor pane
42          messagePane=new JEditorPane();
43          messagePane.setBackground(Color.darkGray);
44          messagePane.setForeground(Color.yellow);
45          messagePane.setVisible(true);
46          messagePane.setEditable(false);
47  
48          // put it in a scroll pane
49          JScrollPane messageScrollPane = new JScrollPane(messagePane);
50          messageScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
51          messageScrollPane.setPreferredSize(new Dimension(400,600));
52          messageScrollPane.setMinimumSize(new Dimension(10, 10));
53          (messageScrollPane.getVerticalScrollBar()).setBackground(Color.darkGray);
54          (messageScrollPane.getHorizontalScrollBar()).setBackground(Color.darkGray);
55          (messageScrollPane.getViewport()).setBackground(Color.darkGray);
56  
57          // and add this to a main content pane
58          JPanel contentPane = new JPanel();
59          BoxLayout box = new BoxLayout(contentPane, BoxLayout.X_AXIS);
60          contentPane.setLayout(box);
61          contentPane.add(messageScrollPane);
62          setContentPane(contentPane);
63  
64      // set the window size
65      setSize(500,300);
66  
67      // and set the window's location.
68      setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
69      }
70  
71      /**
72      * Appends a message to the message pane of the main window
73      *
74      * @param text the test to be appended
75      */
76      public void append(String text)
77      {
78          messagePane.setText(messagePane.getText()+text);
79      }
80  
81      /** Returns the status of the compilation of the code.
82       * @return true if the compile was successful, false otherwise
83       */        
84      public boolean successfullCompile(){
85          if(messagePane.getText().equals(""))
86          {
87              return true;
88          }
89          else
90          { 
91              return false;
92          }
93  
94  
95      }
96  }
97