1 54 55 package com.mullassery.act.gui; 56 57 import java.awt.BorderLayout ; 58 import java.awt.Dimension ; 59 import java.awt.Toolkit ; 60 61 import javax.swing.JPanel ; 62 import javax.swing.JScrollPane ; 63 import javax.swing.JTextArea ; 64 65 import org.apache.tools.ant.BuildEvent; 66 import org.apache.tools.ant.BuildListener; 67 68 73 public class OutputPanel extends JPanel implements BuildListener { 74 private static final String NEW_LINE_CHAR = 75 System.getProperty("line.separator", "\n"); 76 private JTextArea jta; 77 private boolean isLogging; 78 private JScrollPane jsp; 80 81 82 public OutputPanel() { 83 jsp = new JScrollPane (); 84 setLayout(new BorderLayout ()); 85 jta = new JTextArea (); 89 jsp.setViewportView(jta); 90 jsp.setPreferredSize(new Dimension (200, 50)); 91 add(jsp, BorderLayout.CENTER); 92 } 93 94 private void addMessage(String evt) { 95 if (!isLogging || evt == null) 98 return; 99 jta.append(evt + NEW_LINE_CHAR); 100 jta.setCaretPosition(jta.getDocument().getLength()); 101 } 102 103 public void messageLogged(BuildEvent evt) { 104 addMessage(evt.getMessage()); 105 } 106 107 public void buildFinished(BuildEvent arg0) { 108 } 109 110 public void buildStarted(BuildEvent arg0) { 111 } 112 113 public void targetFinished(BuildEvent arg0) { 114 } 115 116 public void targetStarted(BuildEvent arg0) { 117 } 118 119 public void taskFinished(BuildEvent evt) { 120 addMessage( 122 "================ " 123 + evt.getTask().getTaskName() 124 + " Task Completed ================"); 125 isLogging = false; 126 Toolkit.getDefaultToolkit().beep(); 127 } 128 129 public void taskStarted(BuildEvent evt) { 130 isLogging = true; 132 addMessage( 133 "================ Starting " 134 + evt.getTask().getTaskName() 135 + " Task ================"); 136 } 137 } 138 | Popular Tags |