View Javadoc
1 package edu.psu.geovista.app.table; 2 import java.awt.*; 3 import java.awt.event.*; 4 import javax.swing.*; 5 import javax.swing.table.*; 6 import java.util.EventObject; 7 import java.net.*; 8 9 public class MxmTableCellEditor extends AbstractCellEditor { 10 private DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); 11 private String myValue=null; 12 private TableBrowser myTB=null; 13 public Object getCellEditorValue() 14 { 15 return new Object(); 16 } 17 public MxmTableCellEditor(TableBrowser tb) { 18 19 myTB=tb; 20 21 final JPopupMenu popup = new JPopupMenu(); 22 JMenuItem menuItem = new JMenuItem("Study information"); 23 menuItem.addActionListener(new ActionListener() 24 { 25 public void actionPerformed(ActionEvent event) 26 { 27 28 JEditorPane myEP= new JEditorPane(); 29 myEP.setEditable(false); 30 myEP.setContentType("text/html"); 31 myEP.setText("Data source of this report is EIA-878, one of the two weekly Computer Assisted Telephone Interview surveys which EIA conducts to collect prices at the outlet level. EIA-878 collects prices of regular, midgrade, and premium motor gasoline by formulation from service stations across the country each Monday morning. Average prices of gasoline and diesel fuel through outlets at the five Petroleum Allocation for Defense District (PADD) levels, regions of the country, sub-PADD levels, and the state of California are released by the end of the day through Listserv, the Web, Fax, and telephone hotline"); 32 //myTB.addMetaFrame("Meta data",myEP); 33 } 34 35 }); 36 popup.add(menuItem); 37 menuItem = new JMenuItem("Authority and Contact Information"); 38 menuItem.addActionListener(new ActionListener() 39 { 40 public void actionPerformed(ActionEvent event) 41 { 42 //JEditorPane myEP=myTB.getMetaPane(); 43 JEditorPane myEP= new JEditorPane(); 44 myEP.setEditable(false); 45 myEP.setContentType("text/html"); 46 String metaCont= "<html>" 47 +"<head> " 48 +"<title>Test Page</title>" 49 +"</head>" 50 +"<body bgcolor= #FFFFFF > " 51 +" Your hypertext is here " 52 +"</body> " 53 +"</html> "; 54 55 myEP.setText(metaCont); 56 //myEP.setText("In determining residence, the Census Bureau counts each person as an inhabitant of a usual place of residence (i.e., the place where one usually lives and sleeps)."); 57 //myTB.addMetaFrame("Meta data",myEP); 58 } 59 60 }); 61 popup.add(menuItem); 62 63 64 renderer.addMouseListener(new MouseAdapter() { 65 public void mousePressed(MouseEvent e) { 66 if(e.getClickCount() == 2) 67 { 68 JEditorPane myEP= new JEditorPane(); 69 myEP.setEditable(false); 70 myEP.setContentType("text/html"); 71 String metaContent=""; 72 String abc=myTB.getCurrentTable().getName(); 73 if(abc.endsWith("table12.xml")) 74 { 75 76 int currentColumn=myTB.getCurrentTable().getSelectedColumn(); 77 int currentRow =myTB.getCurrentTable().getSelectedRow(); 78 if(currentColumn==0) 79 { 80 81 if(currentRow<=12) 82 { 83 84 } 85 else if(currentRow==15) 86 { 87 88 } 89 90 91 } 92 93 94 } 95 else 96 { 97 myEP.setText("The table belongs to a section presenting statistics on the growth, distribution, and characteristics of the U.S. population. The principal source of these data, the U.S. Census Bureau, conducts a decennial census of population, a monthly population survey, a program of population estimates and projections, and a number of other periodic surveys relating to population characteristics. For a list of relevant publications, see the Guide to Sources of Statistics in Appendix 1<br>"); 98 } 99 //myTB.addMetaFrame("Meta data",myEP); 100 } 101 102 if(SwingUtilities.isRightMouseButton(e)) 103 { 104 popup.show(e.getComponent(),e.getX(), e.getY()); 105 } 106 107 108 if(SwingUtilities.isMiddleMouseButton(e)) 109 { 110 JEditorPane myEP= new JEditorPane(); 111 myEP.setEditable(false); 112 myEP.setContentType("text/html"); 113 myEP.setText(" You pressed the middle button"); 114 //myTB.addMetaFrame("Meta data",myEP); 115 } 116 117 if(SwingUtilities.isLeftMouseButton(e)&&(e.getClickCount()==1)) 118 { 119 fireEditingCanceled(); 120 } 121 122 123 124 } 125 }); 126 } 127 public Component getTableCellEditorComponent( 128 JTable table, Object value, 129 boolean isSelected, 130 int row, int column) { 131 132 133 myValue=(String)value; 134 renderer.setText(myValue); 135 return renderer; 136 } 137 138 public boolean isCellEditable(EventObject anEvent) { 139 140 return true; 141 } 142 143 144 145 public boolean stopCellEditing() { 146 //setCellEditorValue(myValue); 147 148 return super.stopCellEditing(); 149 } 150 151 152 }

This page was automatically generated by Maven