Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

CertificateChainEntryCellRenderer.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.components.renderers;
  18. import com.dmdirc.addons.ui_swing.components.IconManager;
  19. import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateChainEntry;
  20. import javax.swing.Icon;
  21. import javax.swing.JLabel;
  22. import javax.swing.ListCellRenderer;
  23. /**
  24. * Renderer for Certificate chain entries, shows the verified icon and name.
  25. */
  26. public class CertificateChainEntryCellRenderer extends DMDircListCellRenderer<CertificateChainEntry> {
  27. /** Serial version UID. */
  28. private static final long serialVersionUID = 1;
  29. /** Icon to use for invalid entries. */
  30. private final Icon invalidIcon;
  31. /** Icon to use for trusted entries. */
  32. private final Icon trustedIcon;
  33. /** Icon to use for other entries. */
  34. private final Icon icon;
  35. /**
  36. * Creates a new renderer.
  37. *
  38. * @param iconManager Icon manager
  39. * @param renderer Parent renderer
  40. */
  41. public CertificateChainEntryCellRenderer(final IconManager iconManager,
  42. final ListCellRenderer<? super CertificateChainEntry> renderer) {
  43. super(renderer);
  44. icon = iconManager.getIcon("nothing");
  45. trustedIcon = iconManager.getIcon("tick");
  46. invalidIcon = iconManager.getIcon("cross");
  47. }
  48. @Override
  49. protected void renderValue(final JLabel label, final CertificateChainEntry value,
  50. final int index, final boolean isSelected,
  51. final boolean hasFocus) {
  52. label.setText(value.getName());
  53. if (value.isInvalid()) {
  54. label.setIcon(invalidIcon);
  55. } else if (value.isTrusted()) {
  56. label.setIcon(trustedIcon);
  57. } else {
  58. label.setIcon(icon);
  59. }
  60. }
  61. }