Commits

CMPT 371 - Team 2  committed 210f9a6

Cleaned up ui package.

  • Participants
  • Parent commits f835cce

Comments (0)

Files changed (6)

File src/ca/usask/cs/giraffe/ui/AnimationPanel.java

 import java.awt.BorderLayout;
 import java.awt.Font;
 
-import java.awt.Rectangle;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionAdapter;
-import java.awt.event.MouseMotionListener;
-
-
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
+
 import ca.usask.cs.giraffe.ui.anim.AnimationDisplay;
 
 /**
  * @author Joanne
  * 
  */
-@SuppressWarnings("serial")
 public class AnimationPanel extends JPanel {
+	private static final long serialVersionUID = 1L;
 
 	/**
 	 * Instance of AnimationDisplay

File src/ca/usask/cs/giraffe/ui/GiraffeGUI.java

 import ca.usask.cs.giraffe.compiler.anim.UpdateDescriptor;
 import ca.usask.cs.giraffe.core.GiraffeAction;
 
-import java.util.EnumSet;
-
 /**
  * An interface encapsulating one-way communication between the Controller and
  * some view manager.
 	 * 
 	 * @param message A user-friendly error message indicating the error that
 	 *                occurred.
-	 *                <p>
-	 *                FIXME - If the above error conditions are disjoint and
-	 *                comprehensive it may make more sense to have fixed error
-	 *                messages for each of the above cases.
 	 * @param startIndex The start character index of the loaded source file that caused the error, or -1 if there is no reasonable location.
 	 * @param endIndex The end character index of the loaded source file that caused the error, or -1 if there is no reasonable location.
 	 */

File src/ca/usask/cs/giraffe/ui/InputTextArea.java

 
 import java.awt.Color;
 import java.awt.Font;
-import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseEvent;
 
 			@Override
 			public void mouseEntered(MouseEvent arg0) {
-				// TODO Auto-generated method stub
-				
+				// don't care
 			}
 
 			@Override
 			public void mouseExited(MouseEvent arg0) {
-				// TODO Auto-generated method stub
-				
+				// don't care
 			}
 
 			@Override
 			public void mousePressed(MouseEvent arg0) {
-				// TODO Auto-generated method stub
-				
+				// don't care
 			}
 
 			@Override
 			public void mouseReleased(MouseEvent arg0) {
-				// TODO Auto-generated method stub
-				
+				// don't care
 			}
-			
 		});
-		
 	}
 
 	/**
-	 * retrieves the input from the terminal
+	 * Retrieves the input from the terminal.
 	 */
-	public void readInput() {
+	protected void readInput() {
 		
 		String input = this.getText().substring(inputEndPoint, this.getText().length());
 		
 		controller.sendInput(input);
 	}
 	
-	public void resetInput(){
+	/**
+	 * Resets this terminal's input.
+	 */
+	protected void resetInput(){
 		this.setText("");
 	}
 	
 			}
 			if(arg0.getKeyCode() == KeyEvent.VK_BACK_SPACE){
 				InputTextArea textarea = (InputTextArea) arg0.getSource();
-				//textarea.setBackground(Color.WHITE);
 				textarea.getCaretPosition();
 				try {
 					if("\n".equals(textarea.getText(textarea.getCaretPosition() - 1, 1))){
 						textarea.insert("\n",textarea.getCaretPosition() - 1);
 					}
 				} catch (BadLocationException e) {
-					// nothing.
+					// nothing - user tried backspacing over a newline
 				}
 			}
 			if(arg0.getKeyCode() == KeyEvent.VK_LEFT ){
 				InputTextArea textarea = (InputTextArea) arg0.getSource();
-				//textarea.setBackground(Color.WHITE);
 				try {
 					if("\n".equals(textarea.getText(textarea.getCaretPosition() - 1, 1))){
 						textarea.setCaretPosition(textarea.getCaretPosition() + 1);
 						//textarea.getInputMap().put(KeyStroke.getKeyStroke("LEFT"), "none");
 					}
 				} catch (BadLocationException e) {
-					// nothing
+					// nothing - user tried backspacing over a newline
 				}
 			}
 		}
 
 		@Override
 		public void keyReleased(KeyEvent arg0) {
-			
 		}
 
 		@Override
 		public void keyTyped(KeyEvent arg0) {
-			// FIXME - backspace can go past input!
 		}
 	}
 }

File src/ca/usask/cs/giraffe/ui/OutputTextArea.java

  * The textarea that represents the system's terminal
  * 
  * @author Joanne
- * 
  */
-@SuppressWarnings("serial")
 public class OutputTextArea extends JTextArea {
+	private static final long serialVersionUID = 1L;
 
-	
-	private int outputEndPoint = 0;
 	/**
 	 * Constructor for TerminalTextArea
 	 */
 	 * @param output
 	 */
 	public void displayOutput(String output) {
-		
 		this.setText(this.getText() + output);
-		outputEndPoint = this.getText().lastIndexOf(output);
 	}
 	
 	public void resetOutput(){
 		this.setText("");
 	}
-
 }

File src/ca/usask/cs/giraffe/ui/StaticGUI.java

 import javax.swing.UnsupportedLookAndFeelException;
 
 import ca.usask.cs.giraffe.UIController;
+import ca.usask.cs.giraffe.core.GiraffeLogger;
 
 /**
  * The main window for Giraffe's GUI, which also handles the coordination of the
  * @author Alex Mair
  * 
  */
-@SuppressWarnings("serial")
 public class StaticGUI extends JFrame {
+	private static final long serialVersionUID = 1L;
+
 	/**
 	 * The default main window title string.
 	 */
 	 * @param controller The Controller which we send translated view events to.
 	 */
 	public StaticGUI(final UIController controller) {
-
-		// format the components of the GUI
-
 		try {
-			// Attempt to make the GUI look native to the OS
 			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 		} catch (UnsupportedLookAndFeelException e) {
-			// do nothing
+			GiraffeLogger.error("Can't set look and feel to native!");
 		} catch (ClassNotFoundException e) {
-			// do nothing
+			GiraffeLogger.error("Can't set look and feel to native!");
 		} catch (InstantiationException e) {
-			// do nothing
+			GiraffeLogger.error("Can't set look and feel to native!");
 		} catch (IllegalAccessException e) {
-			// do nothing
+			GiraffeLogger.error("Can't set look and feel to native!");
 		}
 
 		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 		 * target environments (i.e., the school computers).
 		 */
 		this.setMinimumSize(MIN_SIZE);
+		
 		this.setSize(DEFAULT_SIZE);
 		this.setTitle(StaticGUI.DEFAULT_TITLE);
 		//this.setIconImage(Toolkit.getDefaultToolkit().createImage(ClassLoader.getSystemResource(GiraffeGUI.baseIconPath+"icon_win32-gnulinux_32.png")));
 		c.gridx=0;
 		c.gridy=0;
 		c.weightx=0;
+		
 		/*
 		 * FIXME magic constant is derived based on what looks good - this should
 		 * be determined programmatically based on:
 		 * skip it for the purposes of CMPT 370
 		 */
 		c.ipadx=550;
+		
 		c.fill=GridBagConstraints.BOTH;
 		innerPanel.add(programPanel,c);
 		

File src/ca/usask/cs/giraffe/ui/UI.java

 		}
 		this.window.dispose();
 	}
-	
-
 }