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.3KB

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