Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CertificateStatusRenderer.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright 2012 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.authority;
  17. import java.awt.Component;
  18. import javax.swing.ImageIcon;
  19. import javax.swing.JTable;
  20. import javax.swing.table.DefaultTableCellRenderer;
  21. import com.gitblit.client.Translation;
  22. /**
  23. * Displays a subscribed icon on the left of the repository name, if there is at
  24. * least one subscribed branch.
  25. *
  26. * @author James Moger
  27. *
  28. */
  29. public class CertificateStatusRenderer extends DefaultTableCellRenderer {
  30. private static final long serialVersionUID = 1L;
  31. private final ImageIcon unknownIcon;
  32. private final ImageIcon revokedIcon;
  33. private final ImageIcon expiredIcon;
  34. private final ImageIcon expiringIcon;
  35. private final ImageIcon okIcon;
  36. public CertificateStatusRenderer() {
  37. super();
  38. unknownIcon = new ImageIcon(getClass().getResource("/bullet_white.png"));
  39. revokedIcon = new ImageIcon(getClass().getResource("/bullet_delete.png"));
  40. expiredIcon = new ImageIcon(getClass().getResource("/bullet_red.png"));
  41. expiringIcon = new ImageIcon(getClass().getResource("/bullet_orange.png"));
  42. okIcon = new ImageIcon(getClass().getResource("/bullet_green.png"));
  43. }
  44. public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
  45. boolean hasFocus, int row, int column) {
  46. super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  47. if (value instanceof CertificateStatus) {
  48. CertificateStatus status = (CertificateStatus) value;
  49. switch(status) {
  50. case revoked:
  51. setText(Translation.get("gb.revoked"));
  52. setIcon(revokedIcon);
  53. break;
  54. case expiring:
  55. setText(Translation.get("gb.expiring"));
  56. setIcon(expiringIcon);
  57. break;
  58. case expired:
  59. setText(Translation.get("gb.expired"));
  60. setIcon(expiredIcon);
  61. break;
  62. case unknown:
  63. setText("");
  64. setIcon(unknownIcon);
  65. break;
  66. default:
  67. setText(Translation.get("gb.ok"));
  68. setIcon(okIcon);
  69. break;
  70. }
  71. }
  72. return this;
  73. }
  74. }