KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > swing > AjdeUIManager


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the IDE support for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

24
25 package org.aspectj.ajde.ui.swing;
26
27 import java.util.*;
28 import java.awt.Frame JavaDoc;
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 /**
37  * @author Mik Kersten
38  */

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 JavaDoc rootFrame = null;
53     private StructureViewPanel fileStructurePanel = null;
54
55     /**
56      * Order of initialization is critical here.
57      */

58     public void init(
59         EditorAdapter editorAdapter,
60         TaskListManager taskListManager,
61         ProjectPropertiesAdapter projectProperties,
62         UserPreferencesAdapter userPreferencesAdapter,
63         IdeUIAdapter ideUIAdapter,
64         IconRegistry iconRegistry,
65         Frame JavaDoc rootFrame,
66         boolean useFileView) {
67         try {
68             BuildProgressMonitor compileProgress = new DefaultBuildProgressMonitor(rootFrame);
69             ErrorHandler errorHandler = new AjdeErrorHandler();
70             this.iconRegistry = iconRegistry;
71             //ConfigurationManager configManager = new LstConfigurationManager();
72
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             //Ajde.getDefault().setConfigurationManager(configManager);
89

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             //Ajde.getDefault().getStructureViewManager().refreshView(
103
// Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView()
104
//);
105

106             //viewManager.updateView();
107
} catch (Throwable JavaDoc 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 JavaDoc 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 JavaDoc buildConfigFile) {
142             ideUIAdapter.displayStatusInformation(" Building: " + buildConfigFile + "...");
143         }
144         
145         public void compileFinished(String JavaDoc 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                 //hideMessages();
150
} else {
151                 ideUIAdapter.displayStatusInformation(" Build failed in " + timeInSeconds + " second(s)");
152                 //showMessages();
153
}
154         }
155         
156         public void compileAborted(String JavaDoc buildConfigFile, String JavaDoc 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 //public abstract class AjdeAction {
179
// public abstract void actionPerformed(ActionEvent e);
180
//
181
// public abstract String getName();
182
//
183
// public abstract ImageIcon getIcon();
184
//}
185

186
Popular Tags