| 1 24 25 package org.aspectj.ajde.ui.swing; 26 27 import java.util.*; 28 import java.awt.Frame ; 29 import org.aspectj.ajde.*; 30 import org.aspectj.ajde.internal.*; 31 import org.aspectj.ajde.ui.*; 32 import org.aspectj.ajde.ui.IdeUIAdapter; 33 import org.aspectj.ajde.ui.UserPreferencesAdapter; 34 import org.aspectj.ajde.ui.internal.AjcBuildOptions; 35 36 39 public class AjdeUIManager { 40 41 protected static final AjdeUIManager INSTANCE = new AjdeUIManager(); 42 private BrowserViewManager viewManager = null; 43 private BuildProgressMonitor buildProgressMonitor = null; 44 private ErrorHandler errorHandler = null; 45 private UserPreferencesAdapter userPreferencesAdapter = null; 46 private AjcBuildOptions buildOptionsAdapter = null; 47 private IdeUIAdapter ideUIAdapter = null; 48 private TreeViewBuildConfigEditor buildConfigEditor = null; 49 private IconRegistry iconRegistry; 50 51 private OptionsFrame optionsFrame = null; 52 private Frame rootFrame = null; 53 private StructureViewPanel fileStructurePanel = null; 54 55 58 public void init( 59 EditorAdapter editorAdapter, 60 TaskListManager taskListManager, 61 ProjectPropertiesAdapter projectProperties, 62 UserPreferencesAdapter userPreferencesAdapter, 63 IdeUIAdapter ideUIAdapter, 64 IconRegistry iconRegistry, 65 Frame rootFrame, 66 boolean useFileView) { 67 try { 68 BuildProgressMonitor compileProgress = new DefaultBuildProgressMonitor(rootFrame); 69 ErrorHandler errorHandler = new AjdeErrorHandler(); 70 this.iconRegistry = iconRegistry; 71 this.ideUIAdapter = ideUIAdapter; 73 this.userPreferencesAdapter = userPreferencesAdapter; 74 this.buildOptionsAdapter = new AjcBuildOptions(userPreferencesAdapter); 75 this.buildConfigEditor = new TreeViewBuildConfigEditor(); 76 this.rootFrame = rootFrame; 77 Ajde.init( 78 editorAdapter, 79 taskListManager, 80 compileProgress, 81 projectProperties, 82 buildOptionsAdapter, 83 new SwingTreeViewNodeFactory(iconRegistry), 84 ideUIAdapter, 85 errorHandler); 86 87 Ajde.getDefault().getBuildManager().addListener(STATUS_TEXT_UPDATER); 88 90 if (useFileView) { 91 FileStructureView structureView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile( 92 Ajde.getDefault().getEditorManager().getCurrFile(), 93 Ajde.getDefault().getStructureViewManager().getDefaultViewProperties() 94 ); 95 Ajde.getDefault().getStructureViewManager().setDefaultFileView(structureView); 96 fileStructurePanel = new StructureViewPanel(structureView); 97 } 98 99 viewManager = new BrowserViewManager(); 100 optionsFrame = new OptionsFrame(iconRegistry); 101 102 106 } catch (Throwable t) { 108 Ajde.getDefault().getErrorHandler().handleError("AJDE failed to initialize.", t); 109 } 110 } 111 112 public static AjdeUIManager getDefault() { 113 return INSTANCE; 114 } 115 116 public BrowserViewManager getViewManager() { 117 return viewManager; 118 } 119 120 public Frame getRootFrame() { 121 return rootFrame; 122 } 123 124 public OptionsFrame getOptionsFrame() { 125 return optionsFrame; 126 } 127 128 public void showOptionsFrame() { 129 int x = (rootFrame.getWidth()/2) + rootFrame.getX() - optionsFrame.getWidth()/2; 130 int y = (rootFrame.getHeight()/2) + rootFrame.getY() - optionsFrame.getHeight()/2; 131 optionsFrame.setLocation(x, y); 132 optionsFrame.show(); 133 } 134 135 public AjcBuildOptions getBuildOptions() { 136 return buildOptionsAdapter; 137 } 138 139 private final BuildListener STATUS_TEXT_UPDATER = new BuildListener() { 140 141 public void compileStarted(String buildConfigFile) { 142 ideUIAdapter.displayStatusInformation(" Building: " + buildConfigFile + "..."); 143 } 144 145 public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) { 146 int timeInSeconds = buildTime/1000; 147 if (succeeded) { 148 ideUIAdapter.displayStatusInformation(" Build succeeded in " + timeInSeconds + " second(s)."); 149 } else { 151 ideUIAdapter.displayStatusInformation(" Build failed in " + timeInSeconds + " second(s)"); 152 } 154 } 155 156 public void compileAborted(String buildConfigFile, String message) { 157 ideUIAdapter.displayStatusInformation("Compile aborted: " + message); 158 } 159 }; 160 161 public IdeUIAdapter getIdeUIAdapter() { 162 return ideUIAdapter; 163 } 164 165 public TreeViewBuildConfigEditor getBuildConfigEditor() { 166 return buildConfigEditor; 167 } 168 169 public StructureViewPanel getFileStructurePanel() { 170 return fileStructurePanel; 171 } 172 173 public IconRegistry getIconRegistry() { 174 return iconRegistry; 175 } 176 } 177 178 186 | Popular Tags |