You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ExtendedListModeCellRenderer.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.addons.ui_swing.dialogs.channelsetting;
  18. import com.dmdirc.parser.common.ChannelListModeItem;
  19. import java.awt.Component;
  20. import java.util.Date;
  21. import javax.swing.JLabel;
  22. import javax.swing.JList;
  23. import javax.swing.JPanel;
  24. import javax.swing.JSeparator;
  25. import javax.swing.ListCellRenderer;
  26. import net.miginfocom.swing.MigLayout;
  27. /**
  28. * Extended list mode cell renderer.
  29. */
  30. public class ExtendedListModeCellRenderer extends JPanel implements
  31. ListCellRenderer<ChannelListModeItem> {
  32. /** A version number for this class. */
  33. private static final long serialVersionUID = 1;
  34. @Override
  35. public Component getListCellRendererComponent(final JList<? extends ChannelListModeItem> list,
  36. final ChannelListModeItem value, final int index, final boolean isSelected,
  37. final boolean cellHasFocus) {
  38. removeAll();
  39. setLayout(new MigLayout("fill, ins 0"));
  40. if (isSelected) {
  41. setBackground(list.getSelectionBackground());
  42. } else {
  43. setBackground(list.getBackground());
  44. }
  45. add(new JLabel(value.getItem()), "split 2, growx, pushx, gapleft 3");
  46. add(new JLabel(new Date(value.getTime() * 1000).toString()),
  47. "right, wrap, gapright 3");
  48. add(new JLabel(value.getOwner()), "growx, pushx, wrap, gapleft 3");
  49. add(new JSeparator(), "growx, pushx");
  50. return this;
  51. }
  52. }