Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

AjdeUIManager.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 java.awt.Frame;
  15. import org.aspectj.ajde.Ajde;
  16. import org.aspectj.ajde.BuildListener;
  17. import org.aspectj.ajde.BuildProgressMonitor;
  18. import org.aspectj.ajde.EditorAdapter;
  19. import org.aspectj.ajde.ErrorHandler;
  20. import org.aspectj.ajde.ProjectPropertiesAdapter;
  21. import org.aspectj.ajde.TaskListManager;
  22. import org.aspectj.ajde.ui.FileStructureView;
  23. import org.aspectj.ajde.ui.IdeUIAdapter;
  24. import org.aspectj.ajde.ui.UserPreferencesAdapter;
  25. import org.aspectj.ajde.ui.internal.AjcBuildOptions;
  26. /**
  27. * @author Mik Kersten
  28. */
  29. public class AjdeUIManager {
  30. protected static final AjdeUIManager INSTANCE = new AjdeUIManager();
  31. private BrowserViewManager viewManager = null;
  32. // private BuildProgressMonitor buildProgressMonitor = null;
  33. // private ErrorHandler errorHandler = null;
  34. // private UserPreferencesAdapter userPreferencesAdapter = null;
  35. private AjcBuildOptions buildOptionsAdapter = null;
  36. private IdeUIAdapter ideUIAdapter = null;
  37. private TreeViewBuildConfigEditor buildConfigEditor = null;
  38. private IconRegistry iconRegistry;
  39. private boolean initialized = false;
  40. private OptionsFrame optionsFrame = null;
  41. private Frame rootFrame = null;
  42. private StructureViewPanel fileStructurePanel = null;
  43. public void init(
  44. EditorAdapter editorAdapter,
  45. TaskListManager taskListManager,
  46. ProjectPropertiesAdapter projectProperties,
  47. UserPreferencesAdapter userPreferencesAdapter,
  48. IdeUIAdapter ideUIAdapter,
  49. IconRegistry iconRegistry,
  50. Frame rootFrame,
  51. boolean useFileView) {
  52. init(editorAdapter,
  53. taskListManager,
  54. projectProperties,
  55. userPreferencesAdapter,
  56. ideUIAdapter,
  57. iconRegistry,
  58. rootFrame,
  59. new DefaultBuildProgressMonitor(rootFrame),
  60. new AjdeErrorHandler(),
  61. useFileView);
  62. }
  63. /**
  64. * Order of initialization is critical here.
  65. */
  66. public void init(
  67. EditorAdapter editorAdapter,
  68. TaskListManager taskListManager,
  69. ProjectPropertiesAdapter projectProperties,
  70. UserPreferencesAdapter userPreferencesAdapter,
  71. IdeUIAdapter ideUIAdapter,
  72. IconRegistry iconRegistry,
  73. Frame rootFrame,
  74. BuildProgressMonitor progressMonitor,
  75. ErrorHandler errorHandler,
  76. boolean useFileView) {
  77. try {
  78. this.iconRegistry = iconRegistry;
  79. //ConfigurationManager configManager = new LstConfigurationManager();
  80. this.ideUIAdapter = ideUIAdapter;
  81. // this.userPreferencesAdapter = userPreferencesAdapter;
  82. this.buildOptionsAdapter = new AjcBuildOptions(userPreferencesAdapter);
  83. this.buildConfigEditor = new TreeViewBuildConfigEditor();
  84. this.rootFrame = rootFrame;
  85. Ajde.init(
  86. editorAdapter,
  87. taskListManager,
  88. progressMonitor,
  89. projectProperties,
  90. buildOptionsAdapter,
  91. new SwingTreeViewNodeFactory(iconRegistry),
  92. ideUIAdapter,
  93. errorHandler);
  94. Ajde.getDefault().getBuildManager().addListener(STATUS_TEXT_UPDATER);
  95. //Ajde.getDefault().setConfigurationManager(configManager);
  96. if (useFileView) {
  97. FileStructureView structureView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(
  98. Ajde.getDefault().getEditorAdapter().getCurrFile(),
  99. Ajde.getDefault().getStructureViewManager().getDefaultViewProperties()
  100. );
  101. Ajde.getDefault().getStructureViewManager().setDefaultFileView(structureView);
  102. fileStructurePanel = new StructureViewPanel(structureView);
  103. }
  104. viewManager = new BrowserViewManager();
  105. optionsFrame = new OptionsFrame(iconRegistry);
  106. //Ajde.getDefault().getStructureViewManager().refreshView(
  107. // Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView()
  108. //);
  109. //viewManager.updateView();
  110. initialized = true;
  111. } catch (Throwable t) {
  112. Ajde.getDefault().getErrorHandler().handleError("AJDE failed to initialize.", t);
  113. }
  114. }
  115. public static AjdeUIManager getDefault() {
  116. return INSTANCE;
  117. }
  118. public BrowserViewManager getViewManager() {
  119. return viewManager;
  120. }
  121. public Frame getRootFrame() {
  122. return rootFrame;
  123. }
  124. public OptionsFrame getOptionsFrame() {
  125. return optionsFrame;
  126. }
  127. public void showOptionsFrame() {
  128. int x = (rootFrame.getWidth()/2) + rootFrame.getX() - optionsFrame.getWidth()/2;
  129. int y = (rootFrame.getHeight()/2) + rootFrame.getY() - optionsFrame.getHeight()/2;
  130. optionsFrame.setLocation(x, y);
  131. optionsFrame.setVisible(true);
  132. }
  133. public AjcBuildOptions getBuildOptions() {
  134. return buildOptionsAdapter;
  135. }
  136. private final BuildListener STATUS_TEXT_UPDATER = new BuildListener() {
  137. public void compileStarted(String buildConfigFile) {
  138. ideUIAdapter.displayStatusInformation(" Building: " + buildConfigFile + "...");
  139. }
  140. public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) {
  141. int timeInSeconds = buildTime/1000;
  142. if (succeeded) {
  143. ideUIAdapter.displayStatusInformation(" Build succeeded in " + timeInSeconds + " second(s).");
  144. //hideMessages();
  145. } else {
  146. ideUIAdapter.displayStatusInformation(" Build failed in " + timeInSeconds + " second(s)");
  147. //showMessages();
  148. }
  149. }
  150. public void compileAborted(String buildConfigFile, String message) {
  151. ideUIAdapter.displayStatusInformation("Compile aborted: " + message);
  152. }
  153. };
  154. public IdeUIAdapter getIdeUIAdapter() {
  155. return ideUIAdapter;
  156. }
  157. public TreeViewBuildConfigEditor getBuildConfigEditor() {
  158. return buildConfigEditor;
  159. }
  160. public StructureViewPanel getFileStructurePanel() {
  161. return fileStructurePanel;
  162. }
  163. public IconRegistry getIconRegistry() {
  164. return iconRegistry;
  165. }
  166. public boolean isInitialized() {
  167. return initialized;
  168. }
  169. }
  170. //public abstract class AjdeAction {
  171. // public abstract void actionPerformed(ActionEvent e);
  172. //
  173. // public abstract String getName();
  174. //
  175. // public abstract ImageIcon getIcon();
  176. //}