()
| 223 | } |
| 224 | |
| 225 | protected void initGUI(){ |
| 226 | getContentPane().setLayout(new GridBagLayout()); |
| 227 | GridBagConstraints constraints = new GridBagConstraints(); |
| 228 | constraints.fill = GridBagConstraints.HORIZONTAL; |
| 229 | constraints.anchor = GridBagConstraints.WEST; |
| 230 | constraints.insets = new Insets(2, 2, 2, 2); |
| 231 | constraints.weightx = 1; |
| 232 | |
| 233 | /******************************************* |
| 234 | * First row - Settings and 'Compare' button * |
| 235 | *******************************************/ |
| 236 | |
| 237 | constraints.gridy = 0; |
| 238 | JLabel keyDocLabel = new JLabel("Key doc:"); |
| 239 | keyDocLabel.setToolTipText("Key document"); |
| 240 | getContentPane().add(keyDocLabel, constraints); |
| 241 | keyDocCombo = new JComboBox<String>(); |
| 242 | keyDocCombo.setPrototypeDisplayValue("long_document_name"); |
| 243 | // add the value of the combobox in a tooltip for long value |
| 244 | keyDocCombo.setRenderer(new DefaultListCellRenderer() { |
| 245 | @Override |
| 246 | public Component getListCellRendererComponent(JList<?> list, Object value, |
| 247 | int index, boolean isSelected, boolean cellHasFocus) { |
| 248 | super.getListCellRendererComponent( |
| 249 | list, value, index, isSelected, cellHasFocus); |
| 250 | if (value != null) { |
| 251 | Rectangle textRectangle = new Rectangle(keyDocCombo.getSize().width, |
| 252 | getPreferredSize().height); |
| 253 | String shortText = SwingUtilities.layoutCompoundLabel(this, |
| 254 | getFontMetrics(getFont()), value.toString(), null, |
| 255 | getVerticalAlignment(), getHorizontalAlignment(), |
| 256 | getHorizontalTextPosition(), getVerticalTextPosition(), |
| 257 | textRectangle, new Rectangle(), textRectangle, getIconTextGap()); |
| 258 | if (shortText.equals(value)) { // no tooltip |
| 259 | if (index == -1) { |
| 260 | keyDocCombo.setToolTipText(null); |
| 261 | } else { |
| 262 | setToolTipText(null); |
| 263 | } |
| 264 | } else { // add tooltip because text is shortened |
| 265 | if (index == -1) { |
| 266 | keyDocCombo.setToolTipText(value.toString()); |
| 267 | } else { |
| 268 | setToolTipText(value.toString()); |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | return this; |
| 273 | } |
| 274 | }); |
| 275 | constraints.weightx = 3; |
| 276 | getContentPane().add(keyDocCombo, constraints); |
| 277 | constraints.weightx = 1; |
| 278 | JLabel keySetLabel = new JLabel("Key set:"); |
| 279 | keySetLabel.setToolTipText("Key annotation set"); |
| 280 | getContentPane().add(keySetLabel, constraints); |
| 281 | keySetCombo = new JComboBox<String>(); |
| 282 | keySetCombo.setPrototypeDisplayValue("long_set_name"); |
no test coverage detected