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.

IconRegistry.java 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v 2.0
  7. * which accompanies this distribution and is available at
  8. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. package org.aspectj.ajde;
  14. import java.net.URL;
  15. import javax.swing.Icon;
  16. import javax.swing.ImageIcon;
  17. import org.aspectj.ajde.ui.AbstractIcon;
  18. import org.aspectj.ajde.ui.AbstractIconRegistry;
  19. import org.aspectj.asm.IProgramElement;
  20. import org.aspectj.asm.IRelationship;
  21. /**
  22. * Default icons. Override behavior for custom icons.
  23. *
  24. * @author Mik Kersten
  25. */
  26. public class IconRegistry extends AbstractIconRegistry {
  27. //public static IconRegistry INSTANCE = null;
  28. protected String RESOURCE_PATH = "org/aspectj/ajde/resources/";
  29. private final Icon START_AJDE = makeIcon("actions/startAjde.gif");
  30. private final Icon STOP_AJDE = makeIcon("actions/stopAjde.gif");
  31. private final Icon BUILD = makeIcon("actions/build.gif");
  32. private final Icon DEBUG = makeIcon("actions/debug.gif");
  33. private final Icon EXECUTE = makeIcon("actions/execute.gif");
  34. private final Icon AJBROWSER = makeIcon("structure/advice.gif");
  35. private final Icon AJBROWSER_ENABLED = makeIcon("actions/browserEnabled.gif");
  36. private final Icon AJBROWSER_DISABLED = makeIcon("actions/browserDisabled.gif");
  37. private final Icon STRUCTURE_VIEW = makeIcon("actions/structureView.gif");
  38. private final Icon HIDE_ASSOCIATIONS = makeIcon("actions/hideAssociations.gif");
  39. private final Icon HIDE_NON_AJ = makeIcon("actions/hideNonAJ.gif");
  40. private final Icon GRANULARITY = makeIcon("actions/granularity.gif");
  41. private final Icon AJDE_SMALL = makeIcon("actions/ajdeSmall.gif");
  42. private final Icon ERROR = makeIcon("structure/error.gif");
  43. private final Icon WARNING = makeIcon("structure/warning.gif");
  44. private final Icon INFO = makeIcon("structure/info.gif");
  45. private final Icon POPUP = makeIcon("actions/popup.gif");
  46. private final Icon FILTER = makeIcon("actions/filter.gif");
  47. private final Icon RELATIONS = makeIcon("actions/relations.gif");
  48. private final Icon ORDER = makeIcon("actions/order.gif");
  49. private final Icon ZOOM_STRUCTURE_TO_FILE_MODE = makeIcon("actions/zoomStructureToFileMode.gif");
  50. private final Icon ZOOM_STRUCTURE_TO_GLOBAL_MODE = makeIcon("actions/zoomStructureToGlobalMode.gif");
  51. private final Icon SPLIT_STRUCTURE_VIEW = makeIcon("actions/splitStructureView.gif");
  52. private final Icon MERGE_STRUCTURE_VIEW = makeIcon("actions/mergeStructureView.gif");
  53. private final Icon BACK = makeIcon("actions/back.gif");
  54. private final Icon FORWARD = makeIcon("actions/forward.gif");
  55. private final Icon SEARCH = makeIcon("actions/search.gif");
  56. private final Icon OPEN_CONFIG = makeIcon("actions/openConfig.gif");
  57. private final Icon CLOSE_CONFIG = makeIcon("actions/closeConfig.gif");
  58. private final Icon SAVE = makeIcon("actions/save.gif");
  59. private final Icon SAVE_ALL = makeIcon("actions/saveAll.gif");
  60. private final Icon BROWSER_OPTIONS = makeIcon("actions/browseroptions.gif");
  61. private final Icon ACCESSIBILITY_PUBLIC = makeIcon("structure/accessibility-public.gif");
  62. private final Icon ACCESSIBILITY_PACKAGE = makeIcon("structure/accessibility-package.gif");
  63. private final Icon ACCESSIBILITY_PROTECTED = makeIcon("structure/accessibility-protected.gif");
  64. private final Icon ACCESSIBILITY_PRIVATE = makeIcon("structure/accessibility-private.gif");
  65. private final Icon ACCESSIBILITY_PRIVILEGED = makeIcon("structure/accessibility-privileged.gif");
  66. public Icon getAjdeSmallIcon() { return AJDE_SMALL; }
  67. public Icon getHideAssociationsIcon() { return HIDE_ASSOCIATIONS; }
  68. public Icon getHideNonAJIcon() { return HIDE_NON_AJ; }
  69. public Icon getGranularityIcon() { return GRANULARITY; }
  70. public Icon getErrorIcon() { return ERROR; }
  71. public Icon getWarningIcon() { return WARNING; }
  72. public Icon getInfoIcon() { return INFO; }
  73. public Icon getAJBrowserIcon() { return AJBROWSER; }
  74. public Icon getAJBrowserEnabledIcon() { return AJBROWSER_ENABLED; }
  75. public Icon getAJBrowserDisabledIcon() { return AJBROWSER_DISABLED; }
  76. public Icon getPopupIcon() { return POPUP; }
  77. public Icon getFilterIcon() { return FILTER; }
  78. public Icon getOrderIcon() { return ORDER; }
  79. public Icon getRelationsIcon() { return RELATIONS; }
  80. public Icon getStartAjdeIcon() { return START_AJDE; }
  81. public Icon getStopAjdeIcon() { return STOP_AJDE; }
  82. public Icon getBackIcon() { return BACK; }
  83. public Icon getForwardIcon() { return FORWARD; }
  84. public Icon getSearchIcon() { return SEARCH; }
  85. public Icon getBuildIcon() { return BUILD; }
  86. public Icon getDebugIcon() { return DEBUG; }
  87. public Icon getExecuteIcon() { return EXECUTE; }
  88. public Icon getOpenConfigIcon() { return OPEN_CONFIG; }
  89. public Icon getCloseConfigIcon() { return CLOSE_CONFIG; }
  90. public Icon getOpenIcon() { return OPEN_CONFIG; }
  91. public Icon getSaveIcon() { return SAVE; }
  92. public Icon getSaveAllIcon() { return SAVE_ALL; }
  93. public Icon getBrowserOptionsIcon() { return BROWSER_OPTIONS; }
  94. public Icon getZoomStructureToFileModeIcon() { return ZOOM_STRUCTURE_TO_FILE_MODE; }
  95. public Icon getZoomStructureToGlobalModeIcon() { return ZOOM_STRUCTURE_TO_GLOBAL_MODE; }
  96. public Icon getSplitStructureViewIcon() { return SPLIT_STRUCTURE_VIEW; }
  97. public Icon getMergeStructureViewIcon() { return MERGE_STRUCTURE_VIEW; }
  98. public Icon getStructureViewIcon() { return STRUCTURE_VIEW; }
  99. public Icon getAssociationSwingIcon(IRelationship.Kind relation) {
  100. return convertToSwingIcon(getIcon(relation));
  101. }
  102. public AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) {
  103. return getIcon(kind);
  104. }
  105. public Icon getStructureSwingIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) {
  106. return convertToSwingIcon(getStructureIcon(kind, accessibility));
  107. }
  108. public Icon getStructureSwingIcon(IProgramElement.Kind kind) {
  109. return convertToSwingIcon(getIcon(kind));
  110. }
  111. public Icon getAccessibilitySwingIcon(IProgramElement.Accessibility accessibility) {
  112. if (accessibility == IProgramElement.Accessibility.PUBLIC) {
  113. return ACCESSIBILITY_PUBLIC;
  114. } else if (accessibility == IProgramElement.Accessibility.PACKAGE) {
  115. return ACCESSIBILITY_PACKAGE;
  116. } else if (accessibility == IProgramElement.Accessibility.PROTECTED) {
  117. return ACCESSIBILITY_PROTECTED;
  118. } else if (accessibility == IProgramElement.Accessibility.PRIVATE) {
  119. return ACCESSIBILITY_PRIVATE;
  120. } else if (accessibility == IProgramElement.Accessibility.PRIVILEGED) {
  121. return ACCESSIBILITY_PRIVILEGED;
  122. } else {
  123. return null;
  124. }
  125. }
  126. public Icon convertToSwingIcon(AbstractIcon iconAdapter) {
  127. if (iconAdapter != null) {
  128. return (Icon)iconAdapter.getIconResource();
  129. } else {
  130. return null;
  131. }
  132. }
  133. protected AbstractIcon createIcon(String path) {
  134. URL resource = IconRegistry.class.getClassLoader().getResource(path);
  135. if (resource == null) {
  136. throw new IllegalStateException("Unable to find icon resource: "+path);
  137. }
  138. return new AbstractIcon(new ImageIcon(resource));
  139. // return new AbstractIcon(new ImageIcon(ClassLoader.getSystemResource(path)));
  140. }
  141. protected Icon makeIcon(String iconPath) {
  142. return new ImageIcon(IconRegistry.class.getClassLoader().getResource(RESOURCE_PATH + iconPath));
  143. // return new ImageIcon(ClassLoader.getSystemResource(RESOURCE_PATH + iconPath));
  144. }
  145. }