1 19 20 29 package org.netbeans.modules.web.monitor.client; 30 31 import javax.swing.JPanel ; 32 import javax.swing.JButton ; 33 import javax.swing.JLabel ; 34 import javax.swing.Box ; 35 import java.awt.Component ; 36 import java.awt.Container ; 37 import java.awt.Dimension ; 38 import java.awt.Font ; 39 import java.awt.GridBagLayout ; 40 import java.awt.GridBagConstraints ; 41 import java.awt.Insets ; 42 import org.netbeans.modules.web.monitor.data.DataRecord; 43 import org.netbeans.modules.web.monitor.data.Param; 44 45 abstract public class DataDisplay extends JPanel { 46 47 final static Insets zeroInsets = new Insets ( 0, 0, 0, 0); 51 final static Insets tableInsets = new Insets ( 0, 18, 12, 12); 52 final static Insets labelInsets = new Insets ( 0, 6, 0, 0); 53 final static Insets buttonInsets = new Insets ( 6, 0, 5, 6); 54 final static Insets sortButtonInsets = new Insets ( 0, 12, 0, 0); 55 final static Insets indentInsets = new Insets ( 0, 18, 0, 0); 56 final static Insets topSpacerInsets = new Insets (12, 0, 0, 0); 57 58 final static int fullGridWidth = java.awt.GridBagConstraints.REMAINDER; 59 final static double tableWeightX = 1.0; 60 final static double tableWeightY = 0; 61 62 public DataDisplay() { 63 super(); 64 setLayout(new GridBagLayout ()); 65 } 66 67 69 void addGridBagComponent(Container parent, 70 Component comp, 71 int gridx, int gridy, 72 int gridwidth, int gridheight, 73 double weightx, double weighty, 74 int anchor, int fill, 75 Insets insets, 76 int ipadx, int ipady) { 77 GridBagConstraints cons = new GridBagConstraints (); 78 cons.gridx = gridx; 79 cons.gridy = gridy; 80 cons.gridwidth = gridwidth; 81 cons.gridheight = gridheight; 82 cons.weightx = weightx; 83 cons.weighty = weighty; 84 cons.anchor = anchor; 85 cons.fill = fill; 86 cons.insets = insets; 87 cons.ipadx = ipadx; 88 cons.ipady = ipady; 89 parent.add(comp,cons); 90 } 91 92 93 98 static JButton createSortButton(DisplayTable dt) { 99 SortButton b = new SortButton(dt); 100 return(JButton )b; 101 } 102 103 static Component createTopSpacer() { 104 return Box.createVerticalStrut(1); 105 } 106 107 static Component createRigidArea() { 108 return Box.createRigidArea(new Dimension (0,5)); 109 } 110 111 static Component createGlue() { 112 return Box.createGlue(); 113 } 114 115 116 122 123 124 static JLabel createHeaderLabel(String label) { 125 return createHeaderLabel(label, ' ', null, null); 126 } 127 128 129 static JLabel createHeaderLabel(String label, char mnemonic, String ad, Component comp) { 130 JLabel jl = new JLabel (label); 131 Font labelFont = jl.getFont(); 132 Font boldFont = labelFont.deriveFont(Font.BOLD); 133 jl.setFont(boldFont); 134 if (mnemonic != ' ') 135 jl.setDisplayedMnemonic(mnemonic); 136 if (ad != null) 137 jl.getAccessibleContext().setAccessibleDescription(ad); 138 if (comp != null) 139 jl.setLabelFor(comp); 140 return jl; 141 } 142 143 static JLabel createDataLabel(String label) { 144 JLabel jl = new JLabel (label); 145 return jl; 146 } 147 148 149 static Component createSortButtonLabel(String label, final DisplayTable dt, char mnemonic, String ad) { 150 JPanel panel = new JPanel (); 151 panel.add(createHeaderLabel(label, mnemonic, ad, dt)); 152 panel.add(createSortButton(dt)); 153 return panel; 154 } 155 156 void log(String s) { 157 System.out.println("DataDisplay::" + s); } 159 160 161 Param findParam(Param [] myParams, String name, String value) { 162 163 for (int i=0; i < myParams.length; i++) { 164 165 Param param = myParams[i]; 166 if (name.equals(param.getName()) && 167 value.equals(param.getValue()) ) { 168 return param; 169 } 170 } 171 return null; 172 } 173 174 } | Popular Tags |