Go to the documentation of this file.00001 package instruction.gui.tab;
00002
00003 import instruction.gui.internal.PlanImporterWrapper;
00004
00005 import java.awt.BorderLayout;
00006 import java.awt.Font;
00007 import java.awt.event.ComponentEvent;
00008 import java.awt.event.ComponentListener;
00009 import java.util.Iterator;
00010 import java.util.List;
00011
00012 import javax.swing.BorderFactory;
00013 import javax.swing.JPanel;
00014 import javax.swing.JScrollPane;
00015 import javax.swing.JTextPane;
00016 import javax.swing.SwingUtilities;
00017
00018 public class CycViewTab extends JPanel {
00019
00020 private static final long serialVersionUID = 6023046063791085728L;
00021
00022 public static String TITLE = "Cyc Assertions";
00023
00024 JScrollPane scroll = null;
00025 JTextPane text = null;
00026
00027 public CycViewTab () {
00028
00029 initialize();
00030 }
00031
00032 public void initialize() {
00033
00034 setLayout( new BorderLayout() );
00035
00036 text = new JTextPane();
00037 text.setEditable( false );
00038 text.setBorder( BorderFactory.createLoweredBevelBorder() );
00039 text.setFont( new Font( "DialogInput", Font.PLAIN, 14 ) );
00040
00041
00042 addComponentListener( new ComponentListener() {
00043
00044 public void componentHidden( ComponentEvent e ) {
00045 }
00046
00047 public void componentMoved( ComponentEvent e ) {
00048 }
00049
00050 public void componentResized( ComponentEvent e ) {
00051 }
00052
00053 public void componentShown( ComponentEvent e ) {
00054
00055 List<String> assertions = PlanImporterWrapper.getImporter().getAssertions();
00056 text.setText( "" );
00057 if ( assertions == null || assertions.isEmpty() ) {
00058 text.setText( "No assertions to display." );
00059 }
00060 else {
00061 for ( Iterator<String> i = assertions.iterator(); i.hasNext(); ) {
00062 text.setText( text.getText() + (text.getText().isEmpty() ? "" : "\n") + i.next() );
00063 }
00064 }
00065
00066 SwingUtilities.invokeLater( new Runnable() {
00067 public void run() {
00068 scroll.getVerticalScrollBar().setValue(0);
00069 }
00070 } );
00071 }
00072
00073 } );
00074
00075 scroll = new JScrollPane( text );
00076 add( scroll, BorderLayout.CENTER );
00077 }
00078
00079 }