@@ -0,0 +1,24 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!--JBuilder XML Project--> | |||
<project> | |||
<property category="sys" name="BackupPath" value="bak" /> | |||
<property category="sys" name="CheckStable" value="1" /> | |||
<property category="sys" name="Company" value="" /> | |||
<property category="sys" name="Copyright" value="Copyright (c) 2002" /> | |||
<property category="sys" name="Description" value="" /> | |||
<property category="sys" name="DocPath" value="doc" /> | |||
<property category="sys" name="ExcludeClassEnabled" value="0" /> | |||
<property category="sys" name="JDK" value="java 1.3.0_02" /> | |||
<property category="sys" name="LastTag" value="0" /> | |||
<property category="sys" name="Libraries" value="" /> | |||
<property category="sys" name="MakeStable" value="0" /> | |||
<property category="sys" name="OutPath" value="bin" /> | |||
<property category="sys" name="SourcePath" value="src;../ajde/src;../compiler/src;../util/src" /> | |||
<property category="sys" name="Title" value="" /> | |||
<property category="sys" name="Version" value="1.0" /> | |||
<property category="sys" name="WorkingDirectory" value="." /> | |||
<property category="sys" name="uidesign.size.org.aspectj.tools.ajbrowser.TopFrame" value="612,471" /> | |||
<node type="Package" name="org.aspectj.tools.ajbrowser" /> | |||
</project> | |||
@@ -0,0 +1,2 @@ | |||
ajbrowser.lst | |||
ajbrowserSrc.lst |
@@ -0,0 +1,242 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import javax.swing.JFrame; | |||
import org.aspectj.ajde.Ajde; | |||
import org.aspectj.ajde.BuildConfigManager; | |||
import org.aspectj.ajde.BuildListener; | |||
import org.aspectj.ajde.TaskListManager; | |||
import org.aspectj.ajde.ui.InvalidResourceException; | |||
import org.aspectj.ajde.ui.UserPreferencesAdapter; | |||
import org.aspectj.ajde.ui.internal.UserPreferencesStore; | |||
import org.aspectj.ajde.ui.swing.AjdeUIManager; | |||
import org.aspectj.ajde.ui.swing.BasicEditor; | |||
import org.aspectj.ajde.ui.swing.IconRegistry; | |||
import org.aspectj.ajde.ui.swing.MultiStructureViewPanel; | |||
/** | |||
* IDE manager for standalone AJDE application. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public class BrowserManager { | |||
private static final BrowserManager INSTANCE = new BrowserManager(); | |||
private BrowserProperties browserProjectProperties; | |||
public static BrowserManager getDefault() { | |||
return INSTANCE; | |||
} | |||
private List configFiles = new ArrayList(); | |||
public static final String TITLE = "AspectJ Browser"; | |||
private static TopFrame topFrame = null; | |||
public void init(String[] configFilesArgs, boolean visible) { | |||
try { | |||
UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(); | |||
browserProjectProperties = new BrowserProperties(preferencesAdapter); | |||
TaskListManager taskListManager = new CompilerMessagesPanel(); | |||
BasicEditor ajdeEditor = new BasicEditor(); | |||
BrowserUIAdapter browserUIAdapter = new BrowserUIAdapter(); | |||
topFrame = new TopFrame(); | |||
configFiles = getConfigFilesList(configFilesArgs); | |||
AjdeUIManager.getDefault().init( | |||
ajdeEditor, | |||
taskListManager, | |||
browserProjectProperties, | |||
preferencesAdapter, | |||
browserUIAdapter, | |||
new IconRegistry(), | |||
topFrame, | |||
true); | |||
Ajde.getDefault().getBuildManager().addListener(BUILD_MESSAGES_LISTENER); | |||
MultiStructureViewPanel multiViewPanel = new MultiStructureViewPanel( | |||
AjdeUIManager.getDefault().getViewManager().getBrowserPanel(), | |||
AjdeUIManager.getDefault().getFileStructurePanel() | |||
); | |||
topFrame.init( | |||
multiViewPanel, | |||
(CompilerMessagesPanel)taskListManager, | |||
Ajde.getDefault().getEditorManager().getEditorPanel() | |||
); | |||
if (visible) topFrame.setVisible(true); | |||
if (configFiles.size() == 0) { | |||
Ajde.getDefault().getErrorHandler().handleWarning( | |||
"No build configuration selected. " | |||
+ "Select a \".lst\" build configuration file in order to compile and navigate structure."); | |||
} else { | |||
//UiManager.getDefault().getViewManager().updateConfigsList(); | |||
} | |||
AjdeUIManager.getDefault().getOptionsFrame().addOptionsPanel(new BrowserOptionsPanel()); | |||
//String lastOpenFilePath = browserProjectProperties.getLastOpenSourceFilePath(); | |||
//Ajde.getDefault().getEditorManager().showSourceLine(lastOpenFilePath, 1, false); | |||
//Ajde.getDefault().getStructureViewManager().fireNavigationAction(lastOpenFilePath, 6); | |||
//Ajde.getDefault().enableLogging(System.out); | |||
if (configFilesArgs.length > 0 && configFilesArgs[0] != null) { | |||
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(configFilesArgs[0]); | |||
} | |||
} catch (Throwable t) { | |||
t.printStackTrace(); | |||
Ajde.getDefault().getErrorHandler().handleError( | |||
"AJDE failed to initialize.", | |||
t); | |||
} | |||
} | |||
public void resetEditorFrame() { | |||
topFrame.resetSourceEditorPanel(); | |||
} | |||
public void resetEditor() { | |||
BrowserManager.getDefault().getRootFrame().setSize(BrowserManager.getDefault().getRootFrame().getWidth()+1, BrowserManager.getDefault().getRootFrame().getHeight()+1); | |||
BrowserManager.getDefault().getRootFrame().doLayout(); | |||
BrowserManager.getDefault().getRootFrame().repaint(); | |||
} | |||
public void setStatusInformation(String text) { | |||
topFrame.statusText_label.setText(text); | |||
} | |||
public void setEditorStatusText(String text) { | |||
topFrame.setTitle(BrowserManager.TITLE + " - " + text); | |||
} | |||
public void run() { | |||
Runner.run(Ajde.getDefault().getProjectProperties().getClassToExecute()); | |||
} | |||
public void saveAll() { | |||
Ajde.getDefault().getEditorManager().saveContents(); | |||
} | |||
public void showMessages() { | |||
topFrame.showMessagesPanel(); | |||
} | |||
public void hideMessages() { | |||
topFrame.hideMessagesPanel(); | |||
} | |||
public JFrame getRootFrame() { | |||
return topFrame; | |||
} | |||
public void openFile(String filePath) { | |||
try { | |||
if (filePath.endsWith(".lst")) { | |||
AjdeUIManager.getDefault().getBuildConfigEditor().openFile(filePath); | |||
topFrame.setEditorPanel(AjdeUIManager.getDefault().getBuildConfigEditor()); | |||
} else if (filePath.endsWith(".java") || filePath.endsWith(".aj")){ | |||
Ajde.getDefault().getEditorManager().showSourceLine(filePath, 0, false); | |||
} else { | |||
Ajde.getDefault().getErrorHandler().handleError("File: " + filePath | |||
+ " could not be opened because the extension was not recoginzed."); | |||
} | |||
} catch (IOException ioe) { | |||
Ajde.getDefault().getErrorHandler().handleError("Could not open file: " + filePath, ioe); | |||
} catch (InvalidResourceException ire) { | |||
Ajde.getDefault().getErrorHandler().handleError("Invalid file: " + filePath, ire); | |||
} | |||
browserProjectProperties.setLastOpenSourceFilePath(filePath); | |||
} | |||
private List getConfigFilesList(String[] configFiles) { | |||
List configs = new ArrayList(); | |||
for (int i = 0; i < configFiles.length; i++) { | |||
if (configFiles[i].endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) { | |||
configs.add(configFiles[i]); | |||
} | |||
} | |||
return configs; | |||
} | |||
private static class Runner { | |||
public static void run(String className) { | |||
try { | |||
Process p = Runtime.getRuntime().exec("java " | |||
//+ "-classpath" + Ajde.getDefault().getProjectProperties().getClasspath() + " " | |||
+ className); | |||
} catch(IOException ioe) { | |||
Ajde.getDefault().getErrorHandler().handleError("Coud not run: " + className, ioe); | |||
} | |||
} | |||
public static void invoke(String className) { | |||
try { | |||
if (className == null || className.length() == 0) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("No main class specified, please select a class to run."); | |||
} else { | |||
Class[] argTypes = { String[].class }; | |||
java.lang.reflect.Method method = Class.forName(className).getDeclaredMethod("main", argTypes); | |||
Object[] args = { new String[0] }; | |||
method.invoke(null, args); | |||
} | |||
} catch(ClassNotFoundException cnfe) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Main class not found: " + className + | |||
"\nMake sure that you have \".\" on your classpath."); | |||
} catch(NoSuchMethodException nsme) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Class: " + className + " does not declare public static void main(String[])"); | |||
} catch(java.lang.reflect.InvocationTargetException ite) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Could not execute: " + className); | |||
} catch(IllegalAccessException iae) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Class: " + className + " does not declare public main method"); | |||
} | |||
} | |||
} | |||
private final BuildListener BUILD_MESSAGES_LISTENER = new BuildListener() { | |||
public void compileStarted(String buildConfigFile) { } | |||
public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) { | |||
int timeInSeconds = buildTime/1000; | |||
if (succeeded && !warnings) { | |||
hideMessages(); | |||
} else { | |||
showMessages(); | |||
} | |||
} | |||
public void compileAborted(String buildConfigFile, String message) { } | |||
}; | |||
public List getConfigFiles() { | |||
return configFiles; | |||
} | |||
public BrowserProperties getBrowserProjectProperties() { | |||
return browserProjectProperties; | |||
} | |||
} |
@@ -0,0 +1,136 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.io.*; | |||
import javax.swing.*; | |||
import java.awt.*; | |||
import javax.swing.border.*; | |||
import org.aspectj.ajde.ui.swing.*; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public class BrowserOptionsPanel extends OptionsPanel { | |||
private JPanel runOptions_panel = new JPanel(); | |||
private JPanel build_panel = new JPanel(); | |||
private FlowLayout flowLayout1 = new FlowLayout(); | |||
private JTextField classToRun_field = new JTextField(); | |||
private JLabel jLabel4 = new JLabel(); | |||
private BorderLayout borderLayout4 = new BorderLayout(); | |||
private JPanel buildPaths_panel = new JPanel(); | |||
private Box compileOptions_box2 = Box.createVerticalBox(); | |||
private JTextField classpath_field = new JTextField(); | |||
private JTextField outputPath_field = new JTextField(); | |||
private JLabel jLabel16 = new JLabel(); | |||
private JLabel jLabel15 = new JLabel(); | |||
private Box compileOptions_box3 = Box.createVerticalBox(); | |||
private BorderLayout borderLayout1 = new BorderLayout(); | |||
private Border border1; | |||
private TitledBorder titledBorder1; | |||
private Border border2; | |||
private Border border3; | |||
private TitledBorder titledBorder2; | |||
private Border border4; | |||
public BrowserOptionsPanel() { | |||
try { | |||
jbInit(); | |||
this.setName("AJBrowser Options"); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
public void loadOptions() throws IOException { | |||
outputPath_field.setText( | |||
BrowserManager.getDefault().getBrowserProjectProperties().getOutputPath() | |||
); | |||
classpath_field.setText( | |||
BrowserManager.getDefault().getBrowserProjectProperties().getClasspath() | |||
); | |||
classToRun_field.setText( | |||
BrowserManager.getDefault().getBrowserProjectProperties().getClassToExecute() | |||
); | |||
} | |||
public void saveOptions() throws IOException { | |||
BrowserManager.getDefault().getBrowserProjectProperties().setOutputPath( | |||
outputPath_field.getText() | |||
); | |||
BrowserManager.getDefault().getBrowserProjectProperties().setClasspath( | |||
classpath_field.getText() | |||
); | |||
BrowserManager.getDefault().getBrowserProjectProperties().setClassToExecute( | |||
classToRun_field.getText() | |||
); | |||
} | |||
private void jbInit() throws Exception { | |||
border1 = | |||
BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158)); | |||
titledBorder1 = new TitledBorder(border1, "ajc Build Paths"); | |||
border2 = | |||
BorderFactory.createCompoundBorder( | |||
titledBorder1, | |||
BorderFactory.createEmptyBorder(5, 5, 5, 5)); | |||
border3 = | |||
BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158)); | |||
titledBorder2 = new TitledBorder(border3, "Run Options"); | |||
border4 = | |||
BorderFactory.createCompoundBorder( | |||
titledBorder2, | |||
BorderFactory.createEmptyBorder(5, 5, 5, 5)); | |||
this.setLayout(borderLayout1); | |||
build_panel.setLayout(borderLayout4); | |||
classToRun_field.setFont(new java.awt.Font("SansSerif", 0, 11)); | |||
classToRun_field.setMinimumSize(new Dimension(200, 21)); | |||
classToRun_field.setPreferredSize(new Dimension(250, 21)); | |||
jLabel4.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
jLabel4.setText("Fully qualified name for main class to run: "); | |||
buildPaths_panel.setLayout(flowLayout1); | |||
runOptions_panel.setBorder(border4); | |||
buildPaths_panel.setBorder(border2); | |||
classpath_field.setFont(new java.awt.Font("SansSerif", 0, 11)); | |||
classpath_field.setMinimumSize(new Dimension(100, 21)); | |||
classpath_field.setPreferredSize(new Dimension(150, 21)); | |||
outputPath_field.setPreferredSize(new Dimension(225, 21)); | |||
outputPath_field.setMinimumSize(new Dimension(100, 21)); | |||
outputPath_field.setFont(new java.awt.Font("SansSerif", 0, 11)); | |||
jLabel16.setText("Classpath (defaults to current directory): "); | |||
jLabel16.setPreferredSize(new Dimension(200, 25)); | |||
jLabel16.setMaximumSize(new Dimension(400, 25)); | |||
jLabel16.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
jLabel15.setMaximumSize(new Dimension(400, 25)); | |||
jLabel15.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
jLabel15.setPreferredSize(new Dimension(230, 25)); | |||
jLabel15.setText("Output path (defaults to current directory): "); | |||
titledBorder1.setTitleFont(new java.awt.Font("Dialog", 0, 11)); | |||
titledBorder2.setTitleFont(new java.awt.Font("Dialog", 0, 11)); | |||
runOptions_panel.add(jLabel4, null); | |||
runOptions_panel.add(classToRun_field, null); | |||
build_panel.add(buildPaths_panel, BorderLayout.CENTER); | |||
build_panel.add(runOptions_panel, BorderLayout.SOUTH); | |||
compileOptions_box2.add(outputPath_field, null); | |||
compileOptions_box2.add(classpath_field, null); | |||
compileOptions_box3.add(jLabel15, null); | |||
compileOptions_box3.add(jLabel16, null); | |||
buildPaths_panel.add(compileOptions_box3, null); | |||
buildPaths_panel.add(compileOptions_box2, null); | |||
this.add(build_panel, BorderLayout.NORTH); | |||
} | |||
} |
@@ -0,0 +1,146 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.util.*; | |||
import java.io.*; | |||
import org.aspectj.ajde.*; | |||
import org.aspectj.ajde.ui.*; | |||
public class BrowserProperties implements ProjectPropertiesAdapter { | |||
UserPreferencesAdapter preferencesAdapter = null; | |||
public BrowserProperties(UserPreferencesAdapter preferencesAdapter) { | |||
this.preferencesAdapter = preferencesAdapter; | |||
} | |||
public String getLastOpenSourceFilePath() { | |||
return preferencesAdapter.getProjectPreference("editor.lastOpenFile"); | |||
} | |||
public void setLastOpenSourceFilePath(String value) { | |||
preferencesAdapter.setProjectPreference("editor.lastOpenFile",value); | |||
} | |||
public String getLastOpenSourceLineNumber() { | |||
return preferencesAdapter.getProjectPreference("editor.lastOpenLineNumber"); | |||
} | |||
public void setLastOpenSourceLineNumber(String value) { | |||
preferencesAdapter.setProjectPreference("editor.lastOpenLineNumber",value); | |||
} | |||
public List getBuildConfigFiles() { | |||
return BrowserManager.getDefault().getConfigFiles(); | |||
} | |||
public String getDefaultBuildConfigFile() { | |||
return null; | |||
} | |||
public String getLastActiveBuildConfigFile() { | |||
return null; | |||
} | |||
public String getProjectName() { | |||
return null; | |||
} | |||
public String getClassToExecute() { | |||
return preferencesAdapter.getProjectPreference("runtime.mainClass"); | |||
} | |||
public void setClassToExecute(String mainClass) { | |||
preferencesAdapter.setProjectPreference("runtime.mainClass", mainClass); | |||
} | |||
public String getRootProjectDir() { | |||
return new File(Ajde.getDefault().getConfigurationManager().getActiveConfigFile()).getParent(); | |||
} | |||
public String getExecutionArgs() { | |||
return null; | |||
} | |||
public List getProjectSourceFiles() { | |||
return null; | |||
} | |||
public String getVmArgs() { | |||
return null; | |||
} | |||
public String getProjectSourcePath() { | |||
return null; | |||
} | |||
public String getBootClasspath() { | |||
return System.getProperty("sun.boot.class.path"); | |||
} | |||
public void setAjcOptions(String flags) { | |||
preferencesAdapter.setProjectPreference("build.flags", flags); | |||
} | |||
public String getAjcOptions() { | |||
return preferencesAdapter.getProjectPreference("build.flags"); | |||
} | |||
public String getOutputPath() { | |||
String outputPath = preferencesAdapter.getProjectPreference("build.outputpath"); | |||
if (outputPath == null) { | |||
return "."; | |||
} else { | |||
return outputPath; | |||
} | |||
} | |||
public void setOutputPath(String path) { | |||
preferencesAdapter.setProjectPreference("build.outputpath", path); | |||
} | |||
public String getUserClasspath() { | |||
return preferencesAdapter.getProjectPreference("build.classpath"); | |||
} | |||
public String getClasspath() { | |||
String systemPath = System.getProperty("java.class.path", "."); | |||
String userPath = preferencesAdapter.getProjectPreference("build.classpath"); | |||
if (userPath != null && userPath.trim().length() != 0) { | |||
return userPath; | |||
} else { | |||
return systemPath; | |||
} | |||
} | |||
public void setClasspath(String path) { | |||
preferencesAdapter.setProjectPreference("build.classpath", path); | |||
} | |||
public String getAjcWorkingDir() { | |||
String workingDir = preferencesAdapter.getProjectPreference("build.workingdir"); | |||
if (workingDir == null || workingDir.equals(getOutputPath())) { | |||
return getOutputPath() + "./ajworkingdir"; | |||
} else { | |||
return workingDir; | |||
} | |||
} | |||
public void setAjcWorkingDir(String path) { | |||
preferencesAdapter.setProjectPreference("build.workingdir", path); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import org.aspectj.ajde.ui.*; | |||
public class BrowserUIAdapter implements IdeUIAdapter { | |||
public void displayStatusInformation(String message) { | |||
BrowserManager.getDefault().setStatusInformation(message); | |||
} | |||
} |
@@ -0,0 +1,93 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.awt.BorderLayout; | |||
import java.awt.event.MouseAdapter; | |||
import java.awt.event.MouseEvent; | |||
import java.awt.event.MouseListener; | |||
import javax.swing.DefaultListModel; | |||
import javax.swing.JList; | |||
import javax.swing.JPanel; | |||
import javax.swing.JScrollPane; | |||
import org.aspectj.ajde.Ajde; | |||
import org.aspectj.ajde.TaskListManager; | |||
import org.aspectj.ajde.ui.swing.CompilerMessage; | |||
import org.aspectj.ajde.ui.swing.CompilerMessagesCellRenderer; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.ISourceLocation; | |||
/** | |||
* Used to display a list of compiler messages that can be clicked in order | |||
* to seek to their corresponding sourceline. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public class CompilerMessagesPanel extends JPanel implements TaskListManager { | |||
private JScrollPane jScrollPane1 = new JScrollPane(); | |||
//private JScrollPane jScrollPane2 = new JScrollPane(); | |||
private JList list = new JList(); | |||
private DefaultListModel listModel = new DefaultListModel(); | |||
private BorderLayout borderLayout1 = new BorderLayout(); | |||
public CompilerMessagesPanel() { | |||
try { | |||
jbInit(); | |||
} | |||
catch(Exception e) { | |||
e.printStackTrace(); | |||
} | |||
list.setModel(listModel); | |||
MouseListener mouseListener = new MouseAdapter() { | |||
public void mouseClicked(MouseEvent e) { | |||
if (e.getClickCount() >= 1) { | |||
int index = list.locationToIndex(e.getPoint()); | |||
if (listModel.getSize() >= index && index != -1) { | |||
CompilerMessage cm = (CompilerMessage)listModel.getElementAt(index); | |||
Ajde.getDefault().getEditorManager().showSourceLine(cm.sourceLocation, true); | |||
} | |||
} | |||
} | |||
}; | |||
list.addMouseListener(mouseListener); | |||
list.setCellRenderer(new CompilerMessagesCellRenderer()); | |||
} | |||
public void addSourcelineTask(String message, ISourceLocation sourceLocation, IMessage.Kind kind) { | |||
listModel.addElement(new CompilerMessage(message, sourceLocation,kind)); | |||
BrowserManager.getDefault().showMessages(); | |||
} | |||
public void addProjectTask(String message, IMessage.Kind kind) { | |||
listModel.addElement(new CompilerMessage(message,kind)); | |||
BrowserManager.getDefault().showMessages(); | |||
} | |||
public void clearTasks() { | |||
listModel.clear(); | |||
} | |||
private void jbInit() throws Exception { | |||
this.setLayout(borderLayout1); | |||
this.add(jScrollPane1, BorderLayout.CENTER); | |||
jScrollPane1.getViewport().add(list, null); | |||
} | |||
} | |||
@@ -0,0 +1,73 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.lang.reflect.InvocationTargetException; | |||
import java.lang.reflect.Method; | |||
/** | |||
* Run ajbrowser if 0+ .lst file arguments, and ajc otherwise. | |||
*/ | |||
public class Main { | |||
/** | |||
* Run ajbrowser if args contains only .lst files | |||
* and ajc otherwise. | |||
* @param args the String[] of args to interpret | |||
*/ | |||
public static void main(String[] args) { | |||
if (!compilerMain(args)) { | |||
BrowserManager.getDefault().init(args, true); | |||
} | |||
} | |||
/** | |||
* Invoke the compiler if there are arguments and some are not .lst files. | |||
* @return false if compiler was not invoked and the browser main should be | |||
*/ | |||
static boolean compilerMain(String[] args) { | |||
if ((null == args) || (0 == args.length)) { | |||
return false; | |||
} | |||
int numConfigFiles = 0; | |||
for (int i = 0; i < args.length; i++) { | |||
if ((null != args[i]) && args[i].endsWith(".lst")) { | |||
numConfigFiles++; | |||
} | |||
} | |||
if (numConfigFiles != args.length) { | |||
try { | |||
Class ajc = Class.forName("org.aspectj.tools.ajc.Main"); | |||
Method main = ajc.getMethod("main", new Class[] { String[].class}); | |||
main.invoke(null, new Object[] { args}); | |||
return true; | |||
} catch (ClassNotFoundException e) { | |||
report(e); | |||
} catch (NoSuchMethodException e) { | |||
report(e); | |||
} catch (IllegalAccessException e) { | |||
report(e); | |||
} catch (InvocationTargetException e) { | |||
report(e.getTargetException()); | |||
} | |||
} | |||
return false; | |||
} | |||
private static void report(Throwable t) { | |||
t.printStackTrace(System.err); | |||
} | |||
} |
@@ -0,0 +1,534 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.awt.BorderLayout; | |||
import java.awt.Color; | |||
import java.awt.Dimension; | |||
import java.awt.FlowLayout; | |||
import java.awt.event.ActionEvent; | |||
import java.awt.event.KeyAdapter; | |||
import java.awt.event.KeyEvent; | |||
import java.awt.event.WindowEvent; | |||
import java.io.File; | |||
import javax.swing.AbstractAction; | |||
import javax.swing.BorderFactory; | |||
import javax.swing.ImageIcon; | |||
import javax.swing.JButton; | |||
import javax.swing.JFileChooser; | |||
import javax.swing.JFrame; | |||
import javax.swing.JLabel; | |||
import javax.swing.JMenu; | |||
import javax.swing.JMenuBar; | |||
import javax.swing.JMenuItem; | |||
import javax.swing.JPanel; | |||
import javax.swing.JPopupMenu; | |||
import javax.swing.JSplitPane; | |||
import javax.swing.JToolBar; | |||
import javax.swing.border.BevelBorder; | |||
import javax.swing.border.Border; | |||
import javax.swing.filechooser.FileFilter; | |||
import org.aspectj.ajde.Ajde; | |||
import org.aspectj.ajde.ui.swing.AJButtonMenuCombo; | |||
import org.aspectj.ajde.ui.swing.AjdeUIManager; | |||
import org.aspectj.ajde.ui.swing.BuildConfigPopupMenu; | |||
import org.aspectj.ajde.ui.swing.MultiStructureViewPanel; | |||
import org.aspectj.asm.ProgramElementNode; | |||
/** | |||
* UI for standalone operation. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public class TopFrame extends JFrame { | |||
JLabel statusText_label = new JLabel(); | |||
//private AJButtonMenuCombo lastBuildCombo = null; | |||
private JPanel editor_panel = null; | |||
private JPanel sourceEditor_panel = null; | |||
private JMenuBar menuBar = new JMenuBar(); | |||
private JMenu jMenu1 = new JMenu(); | |||
private JMenu jMenu2 = new JMenu(); | |||
private JMenuItem projectBuild_menuItem = new JMenuItem(); | |||
private FlowLayout left_flowLayout = new FlowLayout(); | |||
private Border border1; | |||
private Border border2; | |||
private JMenuItem jMenuItem1 = new JMenuItem(); | |||
private JMenuItem exit_menuItem = new JMenuItem(); | |||
private JSplitPane top_splitPane = new JSplitPane(); | |||
private BorderLayout borderLayout2 = new BorderLayout(); | |||
private BorderLayout borderLayout1 = new BorderLayout(); | |||
private BorderLayout borderLayout3 = new BorderLayout(); | |||
private JMenuItem projectRun_menuItem = new JMenuItem(); | |||
private Border border3; | |||
private JPanel status_panel = new JPanel(); | |||
private BorderLayout borderLayout4 = new BorderLayout(); | |||
private Border emptyBorder = BorderFactory.createEmptyBorder(); | |||
private JPanel toolbar_panel = new JPanel(); | |||
private JSplitPane right_splitPane = new JSplitPane(); | |||
private JPanel messages_panel = null; | |||
private JMenu tools_menu = new JMenu(); | |||
private JMenuItem joinpointProbe_menuItem = new JMenuItem(); | |||
private JMenuItem projectDebug_menuItem = new JMenuItem(); | |||
private Border border4; | |||
private Border border5; | |||
private Border border6; | |||
private Border border7; | |||
private JMenuItem svProperties_menuItem = new JMenuItem(); | |||
JPanel toolBar_panel = new JPanel(); | |||
JToolBar build_toolBar = new JToolBar(); | |||
JButton closeConfig_button = new JButton(); | |||
JButton openConfig_button = new JButton(); | |||
JButton run_button = new JButton(); | |||
JToolBar project_toolBar = new JToolBar(); | |||
JButton save_button = new JButton(); | |||
JButton options_button = new JButton(); | |||
JButton editConfig_button = new JButton(); | |||
JToolBar file_toolBar = new JToolBar(); | |||
JPanel filler_panel = new JPanel(); | |||
BorderLayout borderLayout5 = new BorderLayout(); | |||
BorderLayout borderLayout6 = new BorderLayout(); | |||
Border border8; | |||
JLabel jLabel1 = new JLabel(); | |||
JLabel jLabel2 = new JLabel(); | |||
JPanel multiView_panel; | |||
private AJButtonMenuCombo buildCombo; | |||
//JPanel view_panel; | |||
//JSplitPane structureView_pane = new JSplitPane(); | |||
//JPanel browser_panel = null; | |||
// public final BuildConfigListener CONFIGURATION_LISTENER = new BuildConfigListener() { | |||
// public void currConfigChanged(String configFilePath) { | |||
// AjdeUIManager.getDefault().getViewManager().updateView(); | |||
// } | |||
// | |||
// public void configsListUpdated(java.util.List configsList) { | |||
// //AjdeUIManager.getDefault().getViewManager().updateConfigsList(); | |||
// } | |||
// }; | |||
public void init(MultiStructureViewPanel multiViewPanel, JPanel compilerMessagesPanel, JPanel editorPanel) { | |||
try { | |||
this.multiView_panel = multiViewPanel; | |||
//this.browser_panel = browserPanel; | |||
//this.fileStructure_panel = fileStructurePanel; | |||
this.messages_panel = compilerMessagesPanel; | |||
this.editor_panel = editorPanel; | |||
this.sourceEditor_panel = editorPanel; | |||
jbInit(); | |||
svProperties_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getBrowserOptionsIcon()); | |||
projectBuild_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getBuildIcon()); | |||
projectRun_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon()); | |||
projectDebug_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getDebugIcon()); | |||
this.setJMenuBar(menuBar); | |||
this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.ADVICE)).getImage()); | |||
this.setLocation(75, 10); | |||
this.setSize(900, 650); | |||
this.setTitle(BrowserManager.TITLE); | |||
bindKeys(); | |||
fixButtonBorders(); | |||
messages_panel.setVisible(false); | |||
JPopupMenu orderMenu = new BuildConfigPopupMenu(new AbstractAction() { | |||
public void actionPerformed(ActionEvent arg0) { | |||
BrowserManager.getDefault().saveAll(); | |||
} | |||
}); | |||
buildCombo = new AJButtonMenuCombo( | |||
"Build", | |||
"Build", | |||
AjdeUIManager.getDefault().getIconRegistry().getBuildIcon(), | |||
orderMenu, | |||
false); | |||
build_toolBar.add(buildCombo, 1); | |||
refreshBuildMenu(); | |||
} | |||
catch(Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
private void refreshBuildMenu() { | |||
JPopupMenu orderMenu = new BuildConfigPopupMenu(new AbstractAction() { | |||
public void actionPerformed(ActionEvent arg0) { | |||
BrowserManager.getDefault().saveAll(); | |||
} | |||
}); | |||
buildCombo.setMenu(orderMenu); | |||
} | |||
public void setEditorPanel(JPanel panel) { | |||
editor_panel = panel; | |||
right_splitPane.remove(editor_panel); | |||
right_splitPane.add(panel, JSplitPane.TOP); | |||
panel.setVisible(true); | |||
} | |||
/** | |||
* @todo get rid of this method and make jbinit() work properly | |||
*/ | |||
private void fixButtonBorders() { | |||
run_button.setBorder(null); | |||
options_button.setBorder(null); | |||
openConfig_button.setBorder(null); | |||
closeConfig_button.setBorder(null); | |||
save_button.setBorder(null); | |||
editConfig_button.setBorder(null); | |||
} | |||
private void bindKeys() { | |||
this.addKeyListener(new KeyAdapter() { | |||
public void keyPressed(KeyEvent e) { | |||
if (e.getModifiers() == java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) { | |||
if (e.getKeyCode() == KeyEvent.VK_F11) { | |||
Ajde.getDefault().getBuildManager().build(); | |||
} else if (e.getKeyCode() == KeyEvent.VK_S) { | |||
Ajde.getDefault().getEditorManager().saveContents(); | |||
} else if (e.getKeyCode() == KeyEvent.VK_P) { | |||
AjdeUIManager.getDefault().showOptionsFrame(); | |||
} | |||
} | |||
} | |||
}); | |||
} | |||
private void jbInit() throws Exception { | |||
border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98)); | |||
border2 = BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)); | |||
border3 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98)); | |||
border4 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98)); | |||
border5 = BorderFactory.createEmptyBorder(); | |||
border6 = BorderFactory.createEmptyBorder(); | |||
border7 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98)); | |||
border8 = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(Color.white,new Color(156, 156, 158)),BorderFactory.createEmptyBorder(2,2,2,2)); | |||
emptyBorder = BorderFactory.createEmptyBorder(2,2,2,2); | |||
jMenu1.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
jMenu1.setText("File"); | |||
jMenu2.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
jMenu2.setText("Project"); | |||
projectBuild_menuItem.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
projectBuild_menuItem.setText("Build"); | |||
projectBuild_menuItem.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
projectBuild_menuItem_actionPerformed(e); | |||
} | |||
}); | |||
left_flowLayout.setAlignment(FlowLayout.LEFT); | |||
jMenuItem1.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
jMenuItem1.setText("Save"); | |||
jMenuItem1.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
jMenuItem1_actionPerformed(e); | |||
} | |||
}); | |||
exit_menuItem.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
exit_menuItem.setText("Exit"); | |||
exit_menuItem.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
exit_menuItem_actionPerformed(e); | |||
} | |||
}); | |||
top_splitPane.setPreferredSize(new Dimension(706, 800)); | |||
top_splitPane.setDividerSize(4); | |||
this.getContentPane().setLayout(borderLayout3); | |||
projectRun_menuItem.setEnabled(true); | |||
projectRun_menuItem.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
projectRun_menuItem.setText("Run"); | |||
projectRun_menuItem.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
projectRun_menuItem_actionPerformed(e); | |||
} | |||
}); | |||
statusText_label.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
statusText_label.setBorder(BorderFactory.createLoweredBevelBorder()); | |||
statusText_label.setMaximumSize(new Dimension(2000, 20)); | |||
statusText_label.setPreferredSize(new Dimension(300, 20)); | |||
status_panel.setLayout(borderLayout4); | |||
this.addWindowListener(new java.awt.event.WindowAdapter() { | |||
public void windowClosed(WindowEvent e) { | |||
this_windowClosed(e); | |||
} | |||
public void windowClosing(WindowEvent e) { | |||
this_windowClosing(e); | |||
} | |||
}); | |||
toolbar_panel.setLayout(borderLayout5); | |||
right_splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); | |||
right_splitPane.setBorder(null); | |||
right_splitPane.setDividerSize(4); | |||
tools_menu.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
tools_menu.setText("Tools"); | |||
projectDebug_menuItem.setEnabled(false); | |||
projectDebug_menuItem.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
projectDebug_menuItem.setText("Debug"); | |||
svProperties_menuItem.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
svProperties_menuItem_actionPerformed(e); | |||
} | |||
}); | |||
svProperties_menuItem.setText("Options..."); | |||
svProperties_menuItem.setActionCommand("AJDE Console..."); | |||
svProperties_menuItem.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
build_toolBar.setBorder(emptyBorder); | |||
build_toolBar.setFloatable(false); | |||
closeConfig_button.setMaximumSize(new Dimension(100, 20)); | |||
closeConfig_button.setEnabled(true); | |||
closeConfig_button.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
closeConfig_button.setBorder(null); | |||
closeConfig_button.setMinimumSize(new Dimension(24, 20)); | |||
closeConfig_button.setPreferredSize(new Dimension(20, 20)); | |||
closeConfig_button.setToolTipText("Close build configuration"); | |||
closeConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getCloseConfigIcon()); | |||
closeConfig_button.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
closeConfig_button_actionPerformed(e); | |||
} | |||
}); | |||
openConfig_button.setMaximumSize(new Dimension(100, 20)); | |||
openConfig_button.setEnabled(true); | |||
openConfig_button.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
openConfig_button.setBorder(null); | |||
openConfig_button.setMinimumSize(new Dimension(24, 20)); | |||
openConfig_button.setPreferredSize(new Dimension(20, 20)); | |||
openConfig_button.setToolTipText("Open build configuration..."); | |||
openConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getOpenConfigIcon()); | |||
openConfig_button.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
openConfig_button_actionPerformed(e); | |||
} | |||
}); | |||
run_button.setMaximumSize(new Dimension(60, 20)); | |||
run_button.setEnabled(true); | |||
run_button.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
run_button.setBorder(null); | |||
run_button.setMinimumSize(new Dimension(24, 20)); | |||
run_button.setPreferredSize(new Dimension(20, 20)); | |||
run_button.setToolTipText("Run"); | |||
run_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon()); | |||
run_button.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
run_button_actionPerformed(e); | |||
} | |||
}); | |||
project_toolBar.setBorder(emptyBorder); | |||
save_button.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
save_button_actionPerformed(e); | |||
} | |||
}); | |||
save_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getSaveIcon()); | |||
save_button.setText("Save"); | |||
save_button.setToolTipText("Save"); | |||
save_button.setPreferredSize(new Dimension(55, 20)); | |||
save_button.setMinimumSize(new Dimension(24, 20)); | |||
save_button.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
save_button.setBorder(null); | |||
save_button.setMaximumSize(new Dimension(60, 20)); | |||
options_button.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
options_button_actionPerformed(e); | |||
} | |||
}); | |||
options_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getBrowserOptionsIcon()); | |||
options_button.setText("Options"); | |||
options_button.setToolTipText("Options..."); | |||
options_button.setPreferredSize(new Dimension(60, 20)); | |||
options_button.setMinimumSize(new Dimension(24, 20)); | |||
options_button.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
options_button.setBorder(null); | |||
options_button.setMaximumSize(new Dimension(80, 20)); | |||
editConfig_button.addActionListener(new java.awt.event.ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
editConfig_button_actionPerformed(e); | |||
} | |||
}); | |||
editConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_LST)); | |||
editConfig_button.setText("Edit Config"); | |||
editConfig_button.setToolTipText("Edit Config..."); | |||
editConfig_button.setPreferredSize(new Dimension(80, 20)); | |||
editConfig_button.setMinimumSize(new Dimension(24, 20)); | |||
editConfig_button.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
editConfig_button.setBorder(null); | |||
editConfig_button.setMaximumSize(new Dimension(80, 20)); | |||
file_toolBar.setBorder(emptyBorder); | |||
toolBar_panel.setLayout(borderLayout6); | |||
jLabel1.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
jLabel1.setText(" Build: "); | |||
jLabel2.setText(" Run: "); | |||
jLabel2.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
//fileStructure_panel.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
//browser_panel.setFont(new java.awt.Font("Dialog", 0, 11)); | |||
this.getContentPane().add(top_splitPane, BorderLayout.CENTER); | |||
top_splitPane.add(right_splitPane, JSplitPane.RIGHT); | |||
top_splitPane.add(multiView_panel, JSplitPane.LEFT); | |||
right_splitPane.add(messages_panel, JSplitPane.BOTTOM); | |||
right_splitPane.add(editor_panel, JSplitPane.TOP); | |||
//structureView_pane.add(fileStructure_panel, JSplitPane.RIGHT); | |||
//structureView_pane.add(browser_panel, JSplitPane.LEFT); | |||
this.getContentPane().add(status_panel, BorderLayout.SOUTH); | |||
status_panel.add(statusText_label, BorderLayout.CENTER); | |||
this.getContentPane().add(toolbar_panel, BorderLayout.NORTH); | |||
toolbar_panel.add(filler_panel, BorderLayout.CENTER); | |||
toolbar_panel.add(toolBar_panel, BorderLayout.WEST); | |||
//file_toolBar.add(editConfig_button, null); | |||
file_toolBar.add(save_button, null); | |||
file_toolBar.add(options_button, null); | |||
toolBar_panel.add(build_toolBar, BorderLayout.WEST); | |||
toolBar_panel.add(project_toolBar, BorderLayout.CENTER); | |||
project_toolBar.add(jLabel2, null); | |||
project_toolBar.add(run_button, null); | |||
build_toolBar.add(jLabel1, null); | |||
build_toolBar.add(openConfig_button, null); | |||
build_toolBar.add(closeConfig_button, null); | |||
toolBar_panel.add(file_toolBar, BorderLayout.EAST); | |||
menuBar.add(jMenu1); | |||
menuBar.add(jMenu2); | |||
menuBar.add(tools_menu); | |||
jMenu1.add(jMenuItem1); | |||
jMenu1.addSeparator(); | |||
jMenu1.add(exit_menuItem); | |||
jMenu2.add(projectBuild_menuItem); | |||
jMenu2.add(projectRun_menuItem); | |||
//jMenu2.add(projectDebug_menuItem); | |||
tools_menu.add(joinpointProbe_menuItem); | |||
tools_menu.add(svProperties_menuItem); | |||
top_splitPane.setDividerLocation(380); | |||
right_splitPane.setDividerLocation(500); | |||
project_toolBar.addSeparator(); | |||
project_toolBar.addSeparator(); | |||
} | |||
private void exit_menuItem_actionPerformed(ActionEvent e) { | |||
quit(); | |||
} | |||
private void this_windowClosing(WindowEvent e) { | |||
quit(); | |||
} | |||
private void quit() { | |||
this.dispose(); | |||
System.exit(0); | |||
} | |||
void treeMode_comboBox_actionPerformed(ActionEvent e) { } | |||
void save_button_actionPerformed(ActionEvent e) { | |||
Ajde.getDefault().getEditorManager().saveContents(); | |||
} | |||
void this_windowClosed(WindowEvent e) { | |||
quit(); | |||
} | |||
public void showMessagesPanel() { | |||
right_splitPane.setDividerLocation(right_splitPane.getHeight()-100); | |||
messages_panel.setVisible(true); | |||
} | |||
public void hideMessagesPanel() { | |||
right_splitPane.setDividerLocation(right_splitPane.getHeight()); | |||
messages_panel.setVisible(false); | |||
} | |||
void emacsTest_button_actionPerformed(ActionEvent e) { | |||
// Tester.emacsCompile(TopManager.BROWSER_MANAGER.getCurrConfigFile()); | |||
} | |||
void jMenuItem1_actionPerformed(ActionEvent e) { | |||
Ajde.getDefault().getEditorManager().saveContents(); | |||
} | |||
void projectBuild_menuItem_actionPerformed(ActionEvent e) { | |||
BrowserManager.getDefault().saveAll(); | |||
Ajde.getDefault().getBuildManager().build(); | |||
} | |||
void run_button_actionPerformed(ActionEvent e) { | |||
BrowserManager.getDefault().run(); | |||
} | |||
void projectRun_menuItem_actionPerformed(ActionEvent e) { | |||
BrowserManager.getDefault().run(); | |||
} | |||
void build_button_actionPerformed(ActionEvent e) { | |||
BrowserManager.getDefault().saveAll(); | |||
Ajde.getDefault().getBuildManager().build(); | |||
} | |||
void options_button_actionPerformed(ActionEvent e) { | |||
AjdeUIManager.getDefault().showOptionsFrame(); | |||
} | |||
void editConfig_button_actionPerformed(ActionEvent e) { | |||
//Ajde.getDefault().getConfigurationManager().editConfigFile(UiManager.getDefault().getViewManager().getCurrConfigFile()); | |||
BrowserManager.getDefault().openFile(Ajde.getDefault().getConfigurationManager().getActiveConfigFile()); | |||
refreshBuildMenu(); | |||
} | |||
public void resetSourceEditorPanel() { | |||
right_splitPane.removeAll(); | |||
right_splitPane.add(sourceEditor_panel, JSplitPane.TOP); | |||
} | |||
private void svProperties_menuItem_actionPerformed(ActionEvent e) { | |||
AjdeUIManager.getDefault().showOptionsFrame(); | |||
} | |||
private void openConfig_button_actionPerformed(ActionEvent e) { | |||
JFileChooser fileChooser = new JFileChooser(); | |||
fileChooser.setFileFilter(new FileFilter() { | |||
public boolean accept(File f) { | |||
if (f.getPath().endsWith(".lst") || f.isDirectory()) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} | |||
public String getDescription() { | |||
return "AspectJ Build Configuration (*.lst)"; | |||
} | |||
}); | |||
int returnVal = fileChooser.showOpenDialog(this); | |||
if(returnVal == JFileChooser.APPROVE_OPTION) { | |||
String path = fileChooser.getSelectedFile().getAbsolutePath();//.replace('\\', '/'); | |||
BrowserManager.getDefault().getConfigFiles().add(0, path); | |||
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(path); | |||
refreshBuildMenu(); | |||
} | |||
} | |||
private void closeConfig_button_actionPerformed(ActionEvent e) { | |||
BrowserManager.getDefault().getConfigFiles().remove(Ajde.getDefault().getConfigurationManager().getActiveConfigFile()); | |||
if (!BrowserManager.getDefault().getConfigFiles().isEmpty()) { | |||
Ajde.getDefault().getConfigurationManager().setActiveConfigFile((String)BrowserManager.getDefault().getConfigFiles().get(0)); | |||
} | |||
refreshBuildMenu(); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
// default package | |||
import junit.framework.*; | |||
public class AjbrowserModuleTests extends TestCase { | |||
public static Test suite() { | |||
TestSuite suite = new TestSuite(AjbrowserModuleTests.class.getName()); | |||
suite.addTest(org.aspectj.tools.ajbrowser.AjbrowserTests.suite()); | |||
return suite; | |||
} | |||
public AjbrowserModuleTests(String name) { super(name); } | |||
} |
@@ -0,0 +1,32 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import junit.framework.*; | |||
public class AjbrowserTests extends TestCase { | |||
public static Test suite() { | |||
TestSuite suite = new TestSuite(AjbrowserTests.class.getName()); | |||
suite.addTestSuite(AjbrowserTests.class); | |||
//$JUnit-BEGIN$ | |||
//suite.addTestSuite(BrowserManagerTest.class); | |||
//$JUnit-END$ | |||
return suite; | |||
} | |||
public AjbrowserTests(String name) { super(name); } | |||
public void testNothing() {} | |||
} |
@@ -0,0 +1,93 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.io.File; | |||
import javax.swing.*; | |||
import junit.framework.*; | |||
//import org.aspectj.asm.*; | |||
import org.aspectj.bridge.*; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.ajde.*; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public class BrowserManagerTest extends TestCase { | |||
public BrowserManagerTest(String name) { | |||
super(name); | |||
} | |||
public static TestSuite suite() { | |||
TestSuite result = new TestSuite(); | |||
result.addTestSuite(BrowserManagerTest.class); | |||
return result; | |||
} | |||
public void testInitNoArgs() { | |||
//String[] args = { "C:/Dev/aspectj/modules/ajde/testdata/examples/figures-coverage/all.lst" }; | |||
String[] args = { }; | |||
BrowserManager.getDefault().init(args, true); | |||
} | |||
public void testAddProjectTask() { | |||
BrowserManager.getDefault().init(new String[]{}, true); | |||
Ajde.getDefault().getTaskListManager().addProjectTask( | |||
"project-level task", | |||
IMessage.ERROR); | |||
assertTrue("confirmation result", verifySuccess("Project task is visible.")); | |||
} | |||
public void testAddSourceLineTasks() { | |||
BrowserManager.getDefault().init(new String[]{}, true); | |||
ISourceLocation dummyLocation = new SourceLocation(new File("<file>"), -1, -1); | |||
Ajde.getDefault().getTaskListManager().addSourcelineTask( | |||
"error task", | |||
dummyLocation, | |||
IMessage.ERROR); | |||
Ajde.getDefault().getTaskListManager().addSourcelineTask( | |||
"warning task", | |||
dummyLocation, | |||
IMessage.WARNING); | |||
Ajde.getDefault().getTaskListManager().addSourcelineTask( | |||
"info task", | |||
dummyLocation, | |||
IMessage.INFO); | |||
assertTrue("confirmation result", verifySuccess("3 kinds of sourceline tasks are visible.")); | |||
} | |||
private boolean verifySuccess(String message) { | |||
int result = JOptionPane.showConfirmDialog( | |||
BrowserManager.getDefault().getRootFrame(), | |||
"Verify Results", | |||
message, | |||
JOptionPane.YES_NO_OPTION); | |||
return result == JOptionPane.YES_OPTION; | |||
} | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
} | |||
protected void tearDown() throws Exception { | |||
super.tearDown(); | |||
} | |||
} |
@@ -0,0 +1,80 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.tools.ajbrowser; | |||
// | |||
//import org.netbeans.jemmy.Test; | |||
//import org.netbeans.jemmy.Scenario; | |||
//import org.netbeans.jemmy.ClassReference; | |||
//import org.netbeans.jemmy.operators.JFrameOperator; | |||
//import org.netbeans.jemmy.operators.JButtonOperator; | |||
// | |||
///** | |||
// * Programmatically drives AJBrowser gui, | |||
// * currently to do a build. | |||
// */ | |||
//public class JemmyDriver implements Scenario { | |||
// | |||
// public static final String CUT | |||
// = "org.aspectj.tools.ajbrowser.Main"; | |||
// public static final String DRIVER | |||
// = "org.aspectj.tools.ajbrowser.JemmyDriver"; | |||
// | |||
// // XXX need to fix literal path locations | |||
// public static final String USERDIR | |||
// = "j:/home/wes/dev/tools/aj/examples"; | |||
// public static final String FILENAME_RELATIVE | |||
// = USERDIR + "spacewar/debug.lst"; | |||
// public static final String FILENAME | |||
// = USERDIR + "/" + FILENAME_RELATIVE; | |||
// | |||
// public static void main(String[] argv) { | |||
// // 0 is (this) class name | |||
// // 1 is the location of the work directory | |||
// // others are parameters | |||
// String[] params = {DRIVER, USERDIR, FILENAME}; | |||
// Test.main(params); | |||
// } | |||
// | |||
// public int runIt(Object param) { | |||
// try { | |||
// String[] args = new String[]{}; | |||
// // grab parameter - pass in .lst file | |||
// if (null != param) { | |||
// Class c = param.getClass(); | |||
// if (c.isArray() && | |||
// (String.class == c.getComponentType())) { | |||
// args = (String[]) param; | |||
// if (0 < args.length) { | |||
// if (FILENAME.equals(args[0])) { | |||
// System.out.println("got file..."); | |||
// } | |||
// } | |||
// } | |||
// } | |||
// // start application with our .lst file | |||
// new ClassReference(CUT).startApplication(args); | |||
// // wait frame | |||
// JFrameOperator mainFrame = new JFrameOperator("AspectJ Browser"); | |||
// // do a build - hangs if no list file | |||
// new JButtonOperator(mainFrame, "Build").push(); | |||
// | |||
// } catch(Exception e) { | |||
// e.printStackTrace(); | |||
// return(1); | |||
// } | |||
// return(0); | |||
// } | |||
// | |||
//} |
@@ -0,0 +1,14 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry kind="src" path="src"/> | |||
<classpathentry kind="src" path="testsrc"/> | |||
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/> | |||
<classpathentry kind="src" path="/util"/> | |||
<classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/> | |||
<classpathentry kind="src" path="/bridge"/> | |||
<classpathentry kind="src" path="/asm"/> | |||
<classpathentry kind="src" path="/org.aspectj.ajdt.core"/> | |||
<classpathentry kind="src" path="/org.eclipse.jdt.core"/> | |||
<classpathentry kind="lib" path="/lib/eclipse2.0/jdtDepends.jar" sourcepath="/lib/eclipse2.0/jdtDependsSrc.zip"/> | |||
<classpathentry kind="output" path="bin"/> | |||
</classpath> |
@@ -0,0 +1,22 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>ajde</name> | |||
<comment></comment> | |||
<projects> | |||
<project>asm</project> | |||
<project>bridge</project> | |||
<project>org.aspectj.ajdt.core</project> | |||
<project>org.eclipse.jdt.core</project> | |||
<project>util</project> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.eclipse.jdt.core.javabuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.eclipse.jdt.core.javanature</nature> | |||
</natures> | |||
</projectDescription> |
@@ -0,0 +1,47 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!--JBuilder XML Project--> | |||
<project> | |||
<property category="ajde" name="build.configs.active" value="<all project files>"/> | |||
<property category="idl" name="ProcessIDL" value="false"/> | |||
<property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.ApplicationRunner"/> | |||
<property category="runtime.0" name="appserver.ejbJarsSaved" value="1"/> | |||
<property category="runtime.0" name="appserver.parameters" value="-jts -jns -jss -jdb"/> | |||
<property category="runtime.0" name="appserver.servername" value="standard"/> | |||
<property category="runtime.0" name="appserver.vmparameters" value="-Dvbroker.agent.port=14000 -Djava.library.path=/BorlandEnterpriseServer/lib;/BorlandEnterpriseServer/bin -Dborland.enterprise.licenseDir=/BorlandEnterpriseServer/var/servers/ADVICE/adm -Dejb.module_preload=true"/> | |||
<property category="runtime.0" name="jsprunner.launchuri" value="/"/> | |||
<property category="runtime.0" name="test.harness" value="junit.textui.TestRunner"/> | |||
<property category="sys" name="AuthorLabel" value="@author"/> | |||
<property category="sys" name="BackupPath" value="bak"/> | |||
<property category="sys" name="CheckStable" value="1"/> | |||
<property category="sys" name="Company" value=""/> | |||
<property category="sys" name="CompanyLabel" value="Company:"/> | |||
<property category="sys" name="CompileOnDebug" value="0"/> | |||
<property category="sys" name="CompileOnRun" value="0"/> | |||
<property category="sys" name="Copyright" value="Copyright (c) 2002"/> | |||
<property category="sys" name="CopyrightLabel" value="Copyright:"/> | |||
<property category="sys" name="DefaultPath" value="../src"/> | |||
<property category="sys" name="Description" value=""/> | |||
<property category="sys" name="DescriptionLabel" value="Description:"/> | |||
<property category="sys" name="DocPath" value="doc"/> | |||
<property category="sys" name="ExcludeClassEnabled" value="0"/> | |||
<property category="sys" name="IncludeTestPath" value="1"/> | |||
<property category="sys" name="JDK" value="java 1.3.1-b24"/> | |||
<property category="sys" name="LastTag" value="0"/> | |||
<property category="sys" name="Libraries" value="AspectJ Tools;Open Tools SDK"/> | |||
<property category="sys" name="MakeStable" value="0"/> | |||
<property category="sys" name="OutPath" value="../bin"/> | |||
<property category="sys" name="SourcePath" value="../src;test"/> | |||
<property category="sys" name="TestPath" value="test"/> | |||
<property category="sys" name="Title" value=""/> | |||
<property category="sys" name="TitleLabel" value="Title:"/> | |||
<property category="sys" name="Version" value="1.0"/> | |||
<property category="sys" name="VersionLabel" value="@version"/> | |||
<property category="sys" name="WorkingDirectory" value="."/> | |||
<property category="sys" name="max.package.levels" value="5"/> | |||
<property category="sys" | |||
name="uidesign.size.org.aspectj.ajde.ui.swing.BrowserStructureViewToolPanel" value="518,92"/> | |||
<property category="sys" | |||
name="uidesign.size.org.aspectj.ajde.ui.swing.BuildConfigManagementPanel" value="299,86"/> | |||
<property category="sys" | |||
name="uidesign.size.org.aspectj.ajde.ui.swing.ErrorDialog" value="465,361"/> | |||
</project> |
@@ -0,0 +1,3 @@ | |||
* Source path needs to be same directory as ".lst" file, multiple sourcepaths not supported. | |||
@@ -0,0 +1,30 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<jardesc> | |||
<jar path="C:/Dev/eclipse/org.aspectj.ajde/ajde.jar"/> | |||
<options overwrite="true" compress="true" exportErrors="false" | |||
exportWarnings="true" saveDescription="true" | |||
descriptionLocation="/ajde/aspectj-ajdt.jardesc" | |||
useSourceFolders="false" buildIfNeeded="true"/> | |||
<manifest manifestVersion="1.0" usesManifest="true" | |||
reuseManifest="true" saveManifest="true" | |||
generateManifest="false" manifestLocation="/ajde/aspectj-ajdt.mf"> | |||
<sealing sealJar="false"> | |||
<packagesToSeal/> | |||
<packagesToUnSeal/> | |||
</sealing> | |||
</manifest> | |||
<selectedElements exportClassFiles="true" exportJavaFiles="true"> | |||
<javaElement handleIdentifier="=ajde/src<org.aspectj.ajde.resources.actions"/> | |||
<javaElement handleIdentifier="=asm/src<org.aspectj.asm.associations"/> | |||
<javaElement handleIdentifier="=ajde/src<org.aspectj.ajde.ui"/> | |||
<javaElement handleIdentifier="=ajde/src<org.aspectj.ajde.ui.swing"/> | |||
<javaElement handleIdentifier="=ajde/src<org.aspectj.ajde"/> | |||
<javaElement handleIdentifier="=asm/src<org.aspectj.asm.internal"/> | |||
<javaElement handleIdentifier="=asm/src<org.aspectj.asm.views"/> | |||
<javaElement handleIdentifier="=asm/src<org.aspectj.asm"/> | |||
<javaElement handleIdentifier="=ajde/src<org.aspectj.ajde.resources.structure"/> | |||
<javaElement handleIdentifier="=ajde/src<org.aspectj.ajde.internal"/> | |||
<javaElement handleIdentifier="=ajde/src<org.aspectj.ajde.ui.internal"/> | |||
<javaElement handleIdentifier="=bridge/src<org.aspectj.bridge"/> | |||
</selectedElements> | |||
</jardesc> |
@@ -0,0 +1,2 @@ | |||
Manifest-Version: 1.0 | |||
@@ -0,0 +1,65 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<jardesc> | |||
<jar path="C:/Dev/eclipse/org.aspectj.ajde/aspectjtools.jar"/> | |||
<options overwrite="true" compress="true" exportErrors="false" | |||
exportWarnings="true" saveDescription="true" | |||
descriptionLocation="/ajde/aspectjtools.jardesc" | |||
useSourceFolders="false" buildIfNeeded="true"/> | |||
<manifest manifestVersion="1.0" usesManifest="true" | |||
reuseManifest="true" saveManifest="true" | |||
generateManifest="false" manifestLocation="/ajde/aspectjtools.mf"> | |||
<sealing sealJar="false"> | |||
<packagesToSeal/> | |||
<packagesToUnSeal/> | |||
</sealing> | |||
</manifest> | |||
<selectedElements exportClassFiles="true" exportJavaFiles="true"> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util.gui"/> | |||
<javaElement handleIdentifier="=runtime/src<org.aspectj.lang"/> | |||
<javaElement handleIdentifier="=bcweaver/src<org.aspectj.weaver.patterns"/> | |||
<javaElement handleIdentifier="=runtime/src<org.aspectj.lang.reflect"/> | |||
<javaElement handleIdentifier="=runtime/src<org.aspectj.runtime"/> | |||
<javaElement handleIdentifier="=runtime/src<org.aspectj.runtime.reflect"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/dom"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/formatter"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/batch"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{NonLocalExit.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{IntList.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{FuzzyBoolean.java"/> | |||
<javaElement handleIdentifier="=runtime/src<org.aspectj.runtime.internal"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{StreamPrintWriter.java"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/model"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.internal.compiler.lookup"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{LineReader.java"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.workbench.resources"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/search"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.internal.compiler.parser"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/compiler"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{ConfigParser.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{ArgumentScanner.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{LineNumberTableMapper.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{InvertableSet.java"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.internal.compiler.ast"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{StackMap.java"/> | |||
<javaElement handleIdentifier="=bcweaver/src<org.aspectj.weaver.ast"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/codeassist"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{Reflection.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{PartialOrder.java"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.ajc"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{FileUtil.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{ConfigFileUtil.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{JavaStrings.java"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{CollectionUtil.java"/> | |||
<javaElement handleIdentifier="=bcweaver/src<org.aspectj.weaver.bcel"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{UnicodeEscapeWriter.java"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.internal.compiler.problem"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.tools.ajc"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.internal.compiler"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{TypeSafeEnum.java"/> | |||
<javaElement handleIdentifier="=org.eclipse.jdt.core/eval"/> | |||
<javaElement handleIdentifier="=bcweaver/src<org.aspectj.weaver"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.compiler"/> | |||
<javaElement handleIdentifier="=org.aspectj.ajdt.core/src<org.aspectj.ajdt.internal.core.builder"/> | |||
<javaElement handleIdentifier="=util/src<org.aspectj.util{LangUtil.java"/> | |||
</selectedElements> | |||
</jardesc> |
@@ -0,0 +1,2 @@ | |||
Manifest-Version: 1.0 | |||
@@ -0,0 +1,2 @@ | |||
ajde.lst | |||
ajdeSrc.lst |
@@ -0,0 +1,218 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.io.PrintStream; | |||
import java.util.List; | |||
import org.aspectj.ajde.internal.AspectJBuildManager; | |||
import org.aspectj.ajde.internal.LstBuildConfigManager; | |||
import org.aspectj.ajde.ui.*; | |||
import org.aspectj.asm.StructureModelManager; | |||
import org.aspectj.bridge.Version; | |||
/** | |||
* Singleton class responsible for AJDE initialization, and the main point of access to | |||
* Ajde functionality. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public class Ajde { | |||
private static final Ajde INSTANCE = new Ajde(); | |||
private static final String NOT_INITIALIZED_MESSAGE = "Ajde is not initialized."; | |||
private static boolean isInitialized = false; | |||
private BuildManager buildManager; | |||
private EditorManager editorManager; | |||
private StructureViewManager structureViewManager; | |||
private StructureSearchManager structureSearchManager; | |||
private BuildConfigManager configurationManager ; | |||
private ProjectPropertiesAdapter projectProperties; | |||
private TaskListManager taskListManager; | |||
private IdeUIAdapter ideUIAdapter; | |||
private ErrorHandler errorHandler; | |||
private PrintStream logPrintStream = null; | |||
/** | |||
* This class can only be constructured by itself (as a singleton) or by sub-classes. | |||
*/ | |||
protected Ajde() { | |||
configurationManager = new LstBuildConfigManager(); | |||
} | |||
/** | |||
* This method must be called before using Ajde. A <CODE>RuntimeException</CODE> will | |||
* be thrown if use is attempted before initialization. | |||
*/ | |||
public static void init( | |||
EditorAdapter editorAdapter, | |||
TaskListManager taskListManager, | |||
BuildProgressMonitor compileProgressMonitor, | |||
ProjectPropertiesAdapter projectProperties, | |||
BuildOptionsAdapter buildOptionsAdapter, | |||
StructureViewNodeFactory structureViewNodeFactory, | |||
IdeUIAdapter ideUIAdapter, | |||
ErrorHandler errorHandler) { | |||
try { | |||
INSTANCE.projectProperties = projectProperties; | |||
INSTANCE.errorHandler = errorHandler; | |||
INSTANCE.taskListManager = taskListManager; | |||
INSTANCE.editorManager = new EditorManager(editorAdapter); | |||
INSTANCE.buildManager = new AspectJBuildManager( | |||
taskListManager, | |||
compileProgressMonitor, | |||
buildOptionsAdapter); | |||
INSTANCE.buildManager.addListener(INSTANCE.BUILD_STATUS_LISTENER); | |||
INSTANCE.configurationManager.addListener(INSTANCE.STRUCTURE_UPDATE_CONFIG_LISTENER); | |||
INSTANCE.ideUIAdapter = ideUIAdapter; | |||
INSTANCE.structureSearchManager = new StructureSearchManager(); | |||
INSTANCE.structureViewManager = new StructureViewManager(structureViewNodeFactory); | |||
isInitialized = true; | |||
// INSTANCE.enableLogging(System.out); | |||
} catch (Throwable t) { | |||
System.err.println("AJDE ERROR: could not initialize Ajde."); | |||
t.printStackTrace(); | |||
} | |||
} | |||
/** | |||
* @return the default singleton instance of <CODE>Ajde</CODE> | |||
*/ | |||
public static Ajde getDefault() { | |||
if (!isInitialized) throw new RuntimeException(NOT_INITIALIZED_MESSAGE); | |||
return INSTANCE; | |||
} | |||
/** | |||
* Set a <CODE>ConfigurationManager</CODE> to use instead of the default one. | |||
*/ | |||
public void setConfigurationManager(BuildConfigManager configurationManager) { | |||
this.configurationManager = configurationManager; | |||
} | |||
public BuildManager getBuildManager() { | |||
return buildManager; | |||
} | |||
public EditorManager getEditorManager() { | |||
return editorManager; | |||
} | |||
public StructureViewManager getStructureViewManager() { | |||
return structureViewManager; | |||
} | |||
public StructureSearchManager getStructureSearchManager() { | |||
return structureSearchManager; | |||
} | |||
public BuildConfigManager getConfigurationManager() { | |||
return configurationManager; | |||
} | |||
public ProjectPropertiesAdapter getProjectProperties() { | |||
return projectProperties; | |||
} | |||
public TaskListManager getTaskListManager() { | |||
return taskListManager; | |||
} | |||
public IdeUIAdapter getIdeUIAdapter() { | |||
return ideUIAdapter; | |||
} | |||
public void setIdeUIAdapter(IdeUIAdapter ideUIAdapter) { | |||
this.ideUIAdapter = ideUIAdapter; | |||
} | |||
public ErrorHandler getErrorHandler() { | |||
return errorHandler; | |||
} | |||
public String getVersion() { | |||
return Version.text; | |||
} | |||
public void enableLogging(PrintStream logPrintStream) { | |||
this.logPrintStream = logPrintStream; | |||
} | |||
public void disableLogging() { | |||
this.logPrintStream = null; | |||
} | |||
/** | |||
* The structure manager is not a part of the public API and its | |||
* use should be avoided. Used <CODE>getStructureViewManager()</CODE> | |||
* instead. | |||
*/ | |||
public StructureModelManager getStructureModelManager() { | |||
return StructureModelManager.INSTANCE; | |||
} | |||
public void logEvent(String message) { | |||
if (logPrintStream != null) { | |||
logPrintStream.println("<AJDE> " + message); | |||
} | |||
} | |||
private final BuildConfigListener STRUCTURE_UPDATE_CONFIG_LISTENER = new BuildConfigListener() { | |||
public void currConfigChanged(String configFilePath) { | |||
if (configFilePath != null) Ajde.getDefault().getStructureModelManager().readStructureModel(configFilePath); | |||
} | |||
public void configsListUpdated(List configsList) { } | |||
}; | |||
private final BuildListener BUILD_STATUS_LISTENER = new BuildListener() { | |||
/** | |||
* Writes the default configuration file if it has been selected for compilation | |||
*/ | |||
public void compileStarted(String buildConfig) { | |||
String configFilePath = projectProperties.getDefaultBuildConfigFile(); | |||
if (buildConfig.equals(configFilePath)) { | |||
configurationManager.writePaths(configFilePath, projectProperties.getProjectSourceFiles()); | |||
logEvent("wrote default build config: " + configFilePath); | |||
} | |||
} | |||
/** | |||
* The strucutre model is annotated with error messages after an unsuccessful compile. | |||
*/ | |||
public void compileFinished(String buildConfig, int buildTime, boolean succeeded, boolean warnings) { | |||
String configFilePath = projectProperties.getDefaultBuildConfigFile(); | |||
if (!succeeded) { | |||
StructureModelManager.INSTANCE.fireModelUpdated(); | |||
} | |||
} | |||
/** | |||
* Ignored. | |||
*/ | |||
public void compileAborted(String buildConfigFile, String message) { } | |||
}; | |||
public void setErrorHandler(ErrorHandler errorHandler) { | |||
this.errorHandler = errorHandler; | |||
} | |||
} | |||
@@ -0,0 +1,36 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.*; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public interface BuildConfigListener extends EventListener { | |||
/** | |||
* Called when the current configuration has changed. | |||
* | |||
* @param configFilePath the path to the new current configuration file | |||
*/ | |||
public void currConfigChanged(String configFilePath); | |||
/** | |||
* Called when items are added to or deleted from the configurations list. | |||
*/ | |||
public void configsListUpdated(List configsList); | |||
} |
@@ -0,0 +1,91 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.List; | |||
import org.aspectj.ajde.ui.BuildConfigModel; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public interface BuildConfigManager { | |||
public static final String CONFIG_FILE_SUFFIX = ".lst"; | |||
public static final String DEFAULT_CONFIG_LABEL = "<all project files>"; | |||
/** | |||
* Returns the currently active build configuration file. The current active | |||
* build configuration file that is set in this class is used for building and | |||
* for updating the structure model. | |||
* | |||
* @return full path to the file | |||
*/ | |||
public String getActiveConfigFile(); | |||
/** | |||
* Sets the currently active build configuration file. | |||
* | |||
* @param full path to the file | |||
*/ | |||
public void setActiveConfigFile(String currConfigFilePath); | |||
/** | |||
* Add a listner that will be notified of build configuration change events | |||
*/ | |||
public void addListener(BuildConfigListener configurationListener); | |||
/** | |||
* Remove a configuration listener. | |||
*/ | |||
public void removeListener(BuildConfigListener configurationListener); | |||
/** | |||
* Build a model for the corresponding configuration file. | |||
* | |||
* @param full path to the file | |||
*/ | |||
public BuildConfigModel buildModel(String configFilePath); | |||
/** | |||
* Save the given configuration model to the file that it was generated from. | |||
*/ | |||
public void writeModel(BuildConfigModel model); | |||
/** | |||
* Write a list of source files into a configuration file. File paths will be | |||
* written relative to the path of the configuration file. | |||
*/ | |||
public void writePaths(String configFilePath, List paths); | |||
/** | |||
* Add files to a configuration. | |||
* | |||
* @param configFilePath full path to the configuration file | |||
* @param files list of full paths to the files to be added | |||
*/ | |||
public void addFilesToConfig(String configFilePath, List files); | |||
/** | |||
* Remove files from a configuration. | |||
* | |||
* @param configFilePath full path to the configuration file | |||
* @param files list of full paths to the files to be removed | |||
*/ | |||
public void removeFilesFromConfig(String configFilePath, List files); | |||
} | |||
@@ -0,0 +1,51 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.EventListener; | |||
/** | |||
* Compiler listeners get notified of compilation events. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public interface BuildListener extends EventListener { | |||
/** | |||
* Called when a new build is started. | |||
* | |||
* @param buildConfigFile configuration file used for the last compile | |||
*/ | |||
public void compileStarted(String buildConfigFile); | |||
/** | |||
* Called when a build completes. | |||
* | |||
* @param buildConfigFile configuration file used for the last compile | |||
* @param buildTime compilation time in miliseconds | |||
* @param succeeded true if build succeeded without errors | |||
*/ | |||
public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings); | |||
/** | |||
* Called when a build is aborted before completion. | |||
* | |||
* @param buildConfigFile configuration used for the last compile | |||
* @param message message explaining reason for abort | |||
*/ | |||
public void compileAborted(String buildConfigFile, String message); | |||
} | |||
@@ -0,0 +1,59 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
/** | |||
* Responsible for the build process, including compiler invocation, threading, and error | |||
* reporting. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public interface BuildManager { | |||
/** | |||
* Build the structure model for the default build configuration. No ".class" files | |||
* are generated. | |||
*/ | |||
public void buildStructure(); | |||
/** | |||
* Build the default build configuration. | |||
*/ | |||
public void build(); | |||
/** | |||
* Build the specified build configuration. | |||
*/ | |||
public void build(String configFile); | |||
/** | |||
* Exit the build immediately, before completion. | |||
*/ | |||
public void abortBuild(); | |||
public BuildOptionsAdapter getBuildOptions(); | |||
// public CompilerAdapter getCurrCompiler(); | |||
public boolean isStructureDirty(); | |||
public void setStructureDirty(boolean structureDirty); | |||
public void addListener(BuildListener compilerListener); | |||
public void removeListener(BuildListener compilerListener); | |||
} | |||
@@ -0,0 +1,74 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
/** | |||
* When a particular option is not set its documented default is used. | |||
*/ | |||
public interface BuildOptionsAdapter { | |||
/** | |||
* Use javac to generate .class files. The default is "false". | |||
*/ | |||
public boolean getUseJavacMode(); | |||
/** | |||
* Only relevant with Use Javac or Preprocess modes. Specify where to place | |||
* intermediate .java files. The default is "workingdir". | |||
*/ | |||
public String getWorkingOutputPath(); | |||
/** | |||
* Generate regular Java code into the Working OutputPath. Don't try to generate | |||
* any .class files. The default is "false". | |||
*/ | |||
public boolean getPreprocessMode(); | |||
/** | |||
* Specify character encoding used by source files. The default is the current | |||
* JVM's default. | |||
*/ | |||
public String getCharacterEncoding(); | |||
/** | |||
* Support assertions as defined in JLS-1.4. The default is "false". | |||
*/ | |||
public boolean getSourceOnePointFourMode(); | |||
/** | |||
* Be extra-lenient in interpreting the Java specification. The default is "false", | |||
* i.e. "regular" mode. | |||
*/ | |||
public boolean getLenientSpecMode(); | |||
/** | |||
* Be extra-strict in interpreting the Java specification. The default is "false", | |||
* i.e. "regular" mode. | |||
*/ | |||
public boolean getStrictSpecMode(); | |||
/** | |||
* Make the use of some features from pre-1.0 versions of AspectJ be warnings to ease | |||
* porting of old code. The default is "false". | |||
*/ | |||
public boolean getPortingMode(); | |||
/** | |||
* The non-standard, typically prefaced with -X when used with a command line compiler. | |||
* The default is no non-standard options. | |||
*/ | |||
public String getNonStandardOptions(); | |||
} |
@@ -0,0 +1,65 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
/** | |||
* This interface should be implemented by a progress monitor that that presents | |||
* the user with the current state of the compile and estimated finish. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public interface BuildProgressMonitor { | |||
/** | |||
* The heading that should be used in the title of the progress monitor. | |||
*/ | |||
public static final String PROGRESS_HEADING = "AspectJ Build"; | |||
/** | |||
* Start the progress monitor. | |||
*/ | |||
public void start(String configFile); | |||
/** | |||
* Sets the label describing the current progress phase. | |||
*/ | |||
public void setProgressText(String text); | |||
/** | |||
* Jumps the progress bar to <CODE>newVal</CODE>. | |||
*/ | |||
public void setProgressBarVal(int newVal); | |||
/** | |||
* Makes the progress bar by one. | |||
*/ | |||
public void incrementProgressBarVal(); | |||
/** | |||
* @param maxVal sets the value at which the progress will finish. | |||
*/ | |||
public void setProgressBarMax(int maxVal); | |||
/** | |||
* @return the value at which the progress monitoring will finish. | |||
*/ | |||
public int getProgressBarMax(); | |||
/** | |||
* Jump the progress bar to the end and finish progress monitoring. | |||
*/ | |||
public void finish(); | |||
} |
@@ -0,0 +1,36 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.*; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public interface ConfigurationListener extends EventListener { | |||
/** | |||
* Called when the current configuration has changed. | |||
* | |||
* @param configFilePath the path to the new current configuration file | |||
*/ | |||
public void currConfigChanged(String configFilePath); | |||
/** | |||
* Called when items are added to or deleted from the configurations list. | |||
*/ | |||
public void configsListUpdated(List configsList); | |||
} |
@@ -0,0 +1,75 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.io.IOException; | |||
import java.util.List; | |||
import org.aspectj.bridge.ISourceLocation; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public interface EditorAdapter { | |||
/** | |||
* Seek the editor to a source line in the file specified. | |||
*/ | |||
public void showSourceLine(String filePath, int lineNumber, boolean highlight); | |||
/** | |||
* Seek the editor to a {@link SourceLocation} and highlight if specified. | |||
*/ | |||
public void showSourceLine(ISourceLocation sourceLocation, boolean highlight); | |||
/** | |||
* Seek the editor to a source line in the current file. | |||
*/ | |||
public void showSourceLine(int lineNumber, boolean highlight); | |||
/** | |||
* @return full path to the file currently being edited. | |||
*/ | |||
public String getCurrFile(); | |||
/** | |||
* Save the contents of the current file being edited. | |||
*/ | |||
public void saveContents() throws IOException; | |||
/** | |||
* Paste text into the current caret position of the editor. | |||
*/ | |||
public void pasteToCaretPos(String text); | |||
/** | |||
* Implement if inline annotations are supported by the editor. Make null | |||
* implementation if inline annotations are not supported. | |||
* | |||
* @param filePath path to the file that should get the annotation | |||
* @param lineNumber line number for the annotation | |||
* @param items list of relations to be rendered as the annotation | |||
*/ | |||
public void showSourcelineAnnotation(String filePath, int lineNumber, List items); | |||
/** | |||
* Implement if multipe editor views are supported by the editor. Make null | |||
* implementation if multiple editor views are not supported. | |||
* | |||
* @param filePath path to the source file | |||
* @param lineNumber line number of the sourceline | |||
*/ | |||
//public void addEditorViewForSourceLine(String filePath, int lineNumber); | |||
} |
@@ -0,0 +1,32 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.EventListener; | |||
/** | |||
* Compiler listeners get notified of structure model update events. | |||
* | |||
* XXX remove, not used | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public interface EditorListener extends EventListener { | |||
/** | |||
* @param filePath full path to the current file being edited | |||
*/ | |||
public void currentFileChanged(String filePath); | |||
} |
@@ -0,0 +1,28 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public interface ErrorHandler { | |||
public void handleWarning(String message); | |||
public void handleError(String message); | |||
public void handleError(String message, Throwable t); | |||
} |
@@ -0,0 +1,58 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.List; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public interface ProjectPropertiesAdapter { | |||
public String getProjectName(); | |||
public String getRootProjectDir(); | |||
public List getBuildConfigFiles(); | |||
public String getDefaultBuildConfigFile(); | |||
/** | |||
* @return The last selected build configuration for this project. If no selection | |||
* is present the default build config file for this project is returned. | |||
*/ | |||
public String getLastActiveBuildConfigFile(); | |||
public List getProjectSourceFiles(); | |||
public String getProjectSourcePath(); | |||
public String getClasspath(); | |||
public String getOutputPath(); | |||
public String getAjcWorkingDir(); | |||
// @todo: move to build options | |||
public String getBootClasspath(); | |||
// @todo: move all below to execution options | |||
public String getClassToExecute(); | |||
public String getExecutionArgs(); | |||
public String getVmArgs(); | |||
} |
@@ -0,0 +1,48 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import org.aspectj.bridge.*; | |||
/** | |||
* Used for displaying tasks, such as compiler messages, to the user. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public interface TaskListManager { | |||
/** | |||
* Add a task associated with a particular line in a source file. | |||
* | |||
* @param message description of compiler message | |||
* @param sourceLocation can be null | |||
* @param kind one of <code>ERROR_MESSAGE, WARNING_MESSAGE, INFO_MESSAGE</code> | |||
*/ | |||
public void addSourcelineTask(String message, ISourceLocation sourceLocation, IMessage.Kind kind); | |||
/** | |||
* Add a task associated with the current project. | |||
* | |||
* @param message description of compiler message | |||
* @param kind one of <code>ERROR_MESSAGE, WARNING_MESSAGE, INFO_MESSAGE</code> | |||
*/ | |||
public void addProjectTask(String message, IMessage.Kind kind); | |||
/** | |||
* Delete all of the currently active tasks. | |||
*/ | |||
public void clearTasks(); | |||
} | |||
@@ -0,0 +1,417 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
import java.io.*; | |||
import java.util.*; | |||
import org.aspectj.ajde.*; | |||
import org.aspectj.asm.StructureNode; | |||
import org.aspectj.bridge.*; | |||
import org.aspectj.util.ConfigParser; | |||
/** | |||
* Responsible for the build process, including compiler invocation, threading, and error | |||
* reporting. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
public class AspectJBuildManager implements BuildManager { | |||
private CompilerAdapter compiler = null; | |||
private TaskListManager compilerMessages = null; | |||
private BuildProgressMonitor progressMonitor = null; | |||
private BuildOptionsAdapter buildOptions = null; | |||
private ArrayList compilerListeners = new ArrayList(); | |||
private String configFile = ""; | |||
private int lastCompileTime = 50; | |||
private boolean buildStrucutreOnly = false; | |||
public AspectJBuildManager( | |||
TaskListManager compilerMessages, | |||
BuildProgressMonitor progressMonitor, | |||
BuildOptionsAdapter buildOptions) { | |||
this.compilerMessages = compilerMessages; | |||
this.progressMonitor = progressMonitor; | |||
this.buildOptions = buildOptions; | |||
this.compiler = new CompilerAdapter(); | |||
} | |||
public void build() { | |||
if (Ajde.getDefault().getConfigurationManager().getActiveConfigFile() == null) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Nothing to compile, please add a \".lst\" file."); | |||
return; | |||
} else { | |||
build(Ajde.getDefault().getConfigurationManager().getActiveConfigFile()); | |||
} | |||
} | |||
public void buildStructure() { | |||
buildStrucutreOnly = true; | |||
build(); | |||
} | |||
public void build(String configFile) { | |||
buildStrucutreOnly = false; | |||
if (configFile == null) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Please add a configuration file to compile."); | |||
} else { | |||
this.configFile = configFile; | |||
CompilerThread compilerThread = new CompilerThread(); | |||
compilerThread.start(); | |||
} | |||
} | |||
public void abortBuild() { | |||
if (compiler != null) { | |||
compiler.requestCompileExit(); | |||
} | |||
} | |||
// public CompilerAdapter getCurrCompiler() { | |||
// return currCompiler; | |||
// } | |||
public boolean isStructureDirty() { | |||
if (compiler != null) { | |||
return compiler.isStructureDirty(); | |||
} else { | |||
return false; | |||
} | |||
} | |||
public void setStructureDirty(boolean structureDirty) { | |||
if (compiler != null) { | |||
compiler.setStructureDirty(structureDirty); | |||
} | |||
} | |||
public void addListener(BuildListener compilerListener) { | |||
compilerListeners.add(compilerListener); | |||
} | |||
public void removeListener(BuildListener compilerListener) { | |||
compilerListeners.remove(compilerListener); | |||
} | |||
private void notifyCompileFinished(String configFile, int buildTime, boolean succeeded, boolean warnings) { | |||
Ajde.getDefault().logEvent("build finished, succeeded: " + succeeded); | |||
for (Iterator it = compilerListeners.iterator(); it.hasNext(); ) { | |||
((BuildListener)it.next()).compileFinished(configFile, buildTime, succeeded, warnings); | |||
} | |||
} | |||
private void notifyCompileStarted(String configFile) { | |||
Ajde.getDefault().logEvent("build started: " + configFile); | |||
for (Iterator it = compilerListeners.iterator(); it.hasNext(); ) { | |||
((BuildListener)it.next()).compileStarted(configFile); | |||
} | |||
} | |||
private void notifyCompileAborted(String configFile, String message) { | |||
for (Iterator it = compilerListeners.iterator(); it.hasNext(); ) { | |||
((BuildListener)it.next()).compileAborted(configFile, message); | |||
} | |||
} | |||
/** | |||
* @todo use structured error messages instead | |||
*/ | |||
private void displayMessages(CompileResult compileResult) { | |||
String[] descriptions = compileResult.getDescriptions(); | |||
String[] files = compileResult.getfiles(); | |||
Integer[] lineNumbers = compileResult.getLineNumbers(); | |||
if (descriptions.length == 0 && compileResult.getResult().trim() != "") { | |||
//compilerMessages.addSourcelineTask(compileResult.getResult(), "", 0, 0, TaskListManager.ERROR_MESSAGE); | |||
compilerMessages.addSourcelineTask( | |||
compileResult.getResult(), | |||
new SourceLocation(null, 0, 0), | |||
IMessage.ERROR); | |||
return; | |||
} | |||
for ( int i = 0; i < descriptions.length && | |||
i < files.length && | |||
i < lineNumbers.length; i++ ) { | |||
String message = ""; | |||
if (files[i] != "") { | |||
message += "\"" + files[i] + "\": "; | |||
} | |||
if (lineNumbers[i].intValue() != -1 && lineNumbers[i].intValue() != 0) { | |||
message += descriptions[i] + ", at line: " + lineNumbers[i]; | |||
} else { | |||
message += descriptions[i]; | |||
} | |||
if (message.startsWith("Nothing to compile.")) { | |||
message = "Nothing to compile, please select the project, package(s), or class(es) to compile."; | |||
} | |||
IMessage.Kind kind = IMessage.ERROR; | |||
if (descriptions[i].endsWith("(warning)")) kind = IMessage.WARNING; | |||
compilerMessages.addSourcelineTask( | |||
message, | |||
new SourceLocation(new File(files[i]), lineNumbers[i].intValue(), 0), | |||
kind); | |||
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( | |||
files[i], | |||
lineNumbers[i].intValue() | |||
); | |||
if (node != null) { | |||
node.setMessage(new Message(message, kind, null, null)); | |||
} | |||
} | |||
} | |||
/** | |||
* @todo clean up this mess. | |||
*/ | |||
public class CompilerThread extends Thread { | |||
public void run() { | |||
boolean succeeded = true; | |||
boolean warnings = false; | |||
try { | |||
long timeStart = System.currentTimeMillis(); | |||
notifyCompileStarted(configFile); | |||
progressMonitor.start(configFile); | |||
compilerMessages.clearTasks(); | |||
Ajde.getDefault().logEvent("building with options: " | |||
+ getFormattedOptionsString(buildOptions, Ajde.getDefault().getProjectProperties())); | |||
succeeded = compiler.compile(configFile, progressMonitor); | |||
long timeEnd = System.currentTimeMillis(); | |||
lastCompileTime = (int)(timeEnd - timeStart); | |||
} catch (ConfigParser.ParseException pe) { | |||
Ajde.getDefault().getErrorHandler().handleWarning( | |||
"Config file entry invalid, file: " | |||
+ pe.getFile().getPath() | |||
+ ", line number: " | |||
+ pe.getLine()); | |||
// } | |||
// catch (ExitRequestException ere) { | |||
// if (ere.getValue() == 0) { | |||
// notifyCompileAborted(configFile, "Build cancelled by user."); | |||
// } else { | |||
// Ajde.getDefault().getErrorHandler().handleWarning("Compile could not complete. See the console for more details. " | |||
// + "If no console is available re-launch the application from the command line."); | |||
// } | |||
// } catch (InternalCompilerError compilerError) { | |||
// if (compilerError.uncaughtThrowable instanceof OutOfMemoryError) { | |||
// Ajde.getDefault().getErrorHandler().handleError("Out of memory. " | |||
// + "Increase memory by setting the -Xmx parameter that this VM was launched with.\n" | |||
// + "Note that some AJDE structure persists across compiles." , | |||
// compilerError.uncaughtThrowable); | |||
// } else if (compilerError.uncaughtThrowable instanceof MissingRuntimeError) { | |||
// Ajde.getDefault().getErrorHandler().handleWarning("Compilation aborted because the AspectJ runtime was not found. " | |||
// + "Please place aspectjrt.jar in the lib/ext directory."); | |||
// } else if (compilerError.uncaughtThrowable instanceof BadRuntimeError) { | |||
// Ajde.getDefault().getErrorHandler().handleWarning("Compilation aborted because an out-of-date version of " + | |||
// "the AspectJ runtime was found. " | |||
// + "Please place a current version of aspectjrt.jar in the lib/ext directory."); | |||
// } else { | |||
// Ajde.getDefault().getErrorHandler().handleError("Compile error.", compilerError.uncaughtThrowable); | |||
// } | |||
} catch (Throwable e) { | |||
Ajde.getDefault().getErrorHandler().handleError("Compile error, caught Throwable: " + e.toString(), e); | |||
} finally { | |||
progressMonitor.finish(); | |||
} | |||
notifyCompileFinished(configFile, lastCompileTime, succeeded, warnings); | |||
} | |||
private String getFormattedOptionsString(BuildOptionsAdapter buildOptions, ProjectPropertiesAdapter properties) { | |||
return "Building with settings: " | |||
+ "\n-> output path: " + properties.getOutputPath() | |||
+ "\n-> classpath: " + properties.getClasspath() | |||
+ "\n-> bootclasspath: " + properties.getBootClasspath() | |||
+ "\n-> non-standard options: " + buildOptions.getNonStandardOptions() | |||
+ "\n-> porting mode: " + buildOptions.getPortingMode() | |||
+ "\n-> source 1.4 mode: " + buildOptions.getSourceOnePointFourMode() | |||
+ "\n-> strict spec mode: " + buildOptions.getStrictSpecMode() | |||
+ "\n-> lenient spec mode: " + buildOptions.getLenientSpecMode() | |||
+ "\n-> use javac mode: " + buildOptions.getUseJavacMode() | |||
+ "\n-> preprocess mode: " + buildOptions.getPreprocessMode() | |||
+ "\n-> working dir: " + buildOptions.getWorkingOutputPath(); | |||
} | |||
} | |||
public BuildOptionsAdapter getBuildOptions() { | |||
return buildOptions; | |||
} | |||
// private void setCompilerOptions(AjdeCompiler compiler) { | |||
// String nonstandardOptions = buildOptions.getNonStandardOptions(); | |||
// if (nonstandardOptions != null && !nonstandardOptions.trim().equals("")) { | |||
// StringTokenizer st = new StringTokenizer(nonstandardOptions, " "); | |||
// while (st.hasMoreTokens()) { | |||
// String flag = (String)st.nextToken(); | |||
// compiler.getOptions().set(flag.substring(1, flag.length()), Boolean.TRUE); | |||
// } | |||
// } | |||
// | |||
// if (Ajde.getDefault().getProjectProperties().getOutputPath() != null | |||
// && !compiler.getOptions().XtargetNearSource) { | |||
// compiler.getOptions().outputDir = new File(Ajde.getDefault().getProjectProperties().getOutputPath()); | |||
// } | |||
// if (Ajde.getDefault().getProjectProperties().getBootClasspath() != null) { | |||
// compiler.getOptions().bootclasspath = Ajde.getDefault().getProjectProperties().getBootClasspath(); | |||
// } | |||
// if (Ajde.getDefault().getProjectProperties().getClasspath() != null) { | |||
// compiler.getOptions().classpath = Ajde.getDefault().getProjectProperties().getClasspath(); | |||
// } | |||
// if (buildOptions.getWorkingOutputPath() != null) { | |||
// compiler.getOptions().workingDir = new File(buildOptions.getWorkingOutputPath()); | |||
// } | |||
//// if (buildOptions.getCharacterEncoding() != null) { | |||
//// compiler.getOptions().encoding = buildOptions.getCharacterEncoding(); | |||
//// } | |||
// | |||
// compiler.getOptions().lenient = buildOptions.getLenientSpecMode(); | |||
// compiler.getOptions().strict = buildOptions.getStrictSpecMode(); | |||
// compiler.getOptions().usejavac = buildOptions.getUseJavacMode(); | |||
// compiler.getOptions().porting = buildOptions.getPortingMode(); | |||
// compiler.getOptions().preprocess = buildOptions.getPreprocessMode(); | |||
// | |||
// if (buildOptions.getSourceOnePointFourMode()) { | |||
// compiler.getOptions().source = "1.4"; | |||
// } | |||
// } | |||
static class CompileResult { | |||
private String[] files = null; | |||
private Integer[] lineNumbers = null; | |||
private String[] descriptions = null; | |||
private String resultString = ""; | |||
private boolean resultContainsErrors = false; | |||
/** | |||
* Parses out warning messages, error messages, "file not found" messages, javac "Note:" messages. | |||
* | |||
* @todo get error message structure directly from compiler | |||
*/ | |||
public CompileResult( String result ) | |||
{ | |||
resultString = result; | |||
BufferedReader reader = new BufferedReader( new StringReader( result ) ); | |||
Vector fileV = new Vector(); | |||
Vector lineV = new Vector(); | |||
Vector descV = new Vector(); | |||
try { | |||
for (String line = reader.readLine(); line != null; line = reader.readLine()) { | |||
String originalLine = line; | |||
String description = ""; | |||
String file = ""; | |||
Integer lineNo = new Integer(0); | |||
int index = line.indexOf( ":", 2 ); // @todo skip the initial drive ":" (fix, Windows only) | |||
try { | |||
if (line.indexOf("Note: ") != -1) { | |||
int index1 = line.indexOf(".java"); | |||
if (index1 != -1) { | |||
description = line.substring(index1+5) + " (warning)"; | |||
file = line.substring("Note: ".length(), index1+5); | |||
lineNo = new Integer(0); | |||
} else { | |||
description = line + " (warning)"; | |||
file = ""; | |||
lineNo = new Integer(-1); | |||
} | |||
} | |||
else if (line.indexOf("file not found: ") != -1) { | |||
description = "file not found: "; | |||
file = line.substring("file not found: ".length()); | |||
lineNo = new Integer(0); | |||
} | |||
else if (index != -1 && line.indexOf( "java" ) != -1) { | |||
file = line.substring( 0, index ); | |||
line = line.substring( index+1 ); | |||
index = line.indexOf( ":" ); | |||
lineNo = new Integer( Integer.parseInt( line.substring( 0, index ) ) ) ; | |||
line = line.substring( index+1 ); | |||
if (!resultContainsErrors) { | |||
if (!line.endsWith("(warning)")) { | |||
resultContainsErrors = true; | |||
} | |||
} | |||
description = line.substring( line.indexOf( ":" ) + 2 ); | |||
} | |||
} catch (Exception e) { | |||
description = "Internal ajc message: " + originalLine; | |||
file = ""; | |||
lineNo = new Integer(-1); | |||
} | |||
if (description.trim() != "") { | |||
descV.addElement(description); | |||
fileV.addElement(file); | |||
lineV.addElement(lineNo); | |||
} | |||
} | |||
} | |||
catch ( IOException ioe ) { | |||
resultString = "ERROR: could not parse result at line for string: " + result; | |||
} | |||
files = new String[fileV.size()]; | |||
lineNumbers = new Integer[lineV.size()]; | |||
descriptions = new String[descV.size()]; | |||
fileV.copyInto(files); | |||
lineV.copyInto(lineNumbers); | |||
descV.copyInto(descriptions); | |||
} | |||
public String toString() | |||
{ | |||
return resultString; | |||
} | |||
public String[] getfiles() | |||
{ | |||
return files; | |||
} | |||
public Integer[] getLineNumbers() | |||
{ | |||
return lineNumbers; | |||
} | |||
public String[] getDescriptions() | |||
{ | |||
return descriptions; | |||
} | |||
public String getResult() | |||
{ | |||
return resultString; | |||
} | |||
public boolean containsErrors() { | |||
return resultContainsErrors; | |||
} | |||
} | |||
} | |||
class ConfigFileDoesNotExistException extends Exception { | |||
public ConfigFileDoesNotExistException(String filePath) { | |||
super(filePath); | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
import org.aspectj.ajde.Ajde; | |||
import org.aspectj.ajde.BuildProgressMonitor; | |||
import org.eclipse.core.resources.IProject; | |||
import org.eclipse.core.runtime.OperationCanceledException; | |||
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; | |||
import org.eclipse.jdt.internal.core.builder.BuildNotifier; | |||
public class BuildNotifierAdapter extends BuildNotifier { | |||
private BuildProgressMonitor progressMonitor; | |||
private int numCompilationUnitPasses = 1; | |||
private int completedPasses = 0; | |||
private boolean cancelled = false; | |||
// ??? get rid of project coupling | |||
public BuildNotifierAdapter(IProject project, BuildProgressMonitor progressMonitor, int numFiles) { | |||
super(null, project); | |||
this.progressMonitor = progressMonitor; | |||
this.numCompilationUnitPasses = numFiles*2; | |||
} | |||
public void begin() { | |||
progressMonitor.start(Ajde.getDefault().getConfigurationManager().getActiveConfigFile()); | |||
progressMonitor.setProgressText("starting build..."); | |||
} | |||
public void cancelBuild() { | |||
progressMonitor.setProgressText("cancelling build..."); | |||
cancelled = true; | |||
} | |||
public void compiled(ICompilationUnit unit) { | |||
completedPasses++; | |||
float val = (float)completedPasses/numCompilationUnitPasses; | |||
int intVal = (int)((float)val*100); | |||
progressMonitor.setProgressBarVal(intVal); | |||
progressMonitor.setProgressText("compiled: " + new String(unit.getFileName())); | |||
} | |||
public void generatedBytecode(String message) { | |||
completedPasses++; | |||
float val = (float)completedPasses/numCompilationUnitPasses; | |||
int intVal = (int)((float)val*100); | |||
progressMonitor.setProgressBarVal(intVal); | |||
progressMonitor.setProgressText(message); | |||
} | |||
public void checkCancel() { | |||
if (cancelled) throw new OperationCanceledException(); | |||
} | |||
} |
@@ -0,0 +1,178 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
import java.io.File; | |||
import java.util.*; | |||
import org.aspectj.ajde.*; | |||
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig; | |||
import org.aspectj.ajdt.internal.core.builder.AjBuildManager; | |||
import org.aspectj.bridge.*; | |||
import org.aspectj.util.ConfigParser; | |||
import org.eclipse.core.runtime.OperationCanceledException; | |||
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | |||
public class CompilerAdapter { | |||
private AjBuildManager buildManager = null; | |||
private MessageHandlerAdapter messageHandler = null; | |||
private BuildNotifierAdapter currNotifier = null; | |||
private boolean initialized = false; | |||
private boolean structureDirty = true; | |||
private boolean firstBuild = true; | |||
public CompilerAdapter() { | |||
super(); | |||
} | |||
public void requestCompileExit() { | |||
if (currNotifier != null) currNotifier.cancelBuild(); | |||
// buildManager.getJavaBuilder().notifier.setCancelling(true); | |||
} | |||
public boolean isStructureDirty() { | |||
return structureDirty; | |||
} | |||
public void setStructureDirty(boolean structureDirty) { | |||
this.structureDirty = structureDirty; | |||
} | |||
public boolean compile(String configFile, BuildProgressMonitor progressMonitor) { | |||
init(); | |||
try { | |||
AjBuildConfig buildConfig = genBuildConfig(configFile); | |||
currNotifier = new BuildNotifierAdapter( | |||
AjBuildManager.DEFAULT_PROJECT, | |||
progressMonitor, | |||
buildConfig.getFiles().size()); | |||
buildManager.setBuildNotifier(currNotifier); | |||
messageHandler.setBuildNotifierAdapter(currNotifier); | |||
String rtInfo = buildManager.checkRtJar(buildConfig); // !!! will get called twice | |||
if (rtInfo != null) { | |||
Ajde.getDefault().getErrorHandler().handleWarning( | |||
"AspectJ Runtime error: " + rtInfo | |||
+ " Please place a valid aspectjrt.jar in the lib/ext directory."); | |||
return false; | |||
} | |||
if (firstBuild) { | |||
firstBuild = false; | |||
return buildManager.batchBuild(buildConfig, messageHandler); | |||
} else { | |||
return buildManager.batchBuild(buildConfig, messageHandler); // XXX incremental not implemented | |||
// return buildManager.incrementalBuild(buildConfig); | |||
} | |||
} catch (OperationCanceledException ce) { | |||
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("build cancelled by user"); | |||
return false; | |||
} catch (Throwable t) { | |||
t.printStackTrace(); | |||
return false; | |||
// messageHandler.handleMessage(new Message(t.toString(), Message.ERROR, t, null)); | |||
} | |||
} | |||
public AjBuildConfig genBuildConfig(String configFile) { | |||
AjBuildConfig buildConfig = new AjBuildConfig(); | |||
File config = new File(configFile); | |||
if (!config.exists()) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Config file \"" + configFile + "\" does not exist."); | |||
} else { | |||
ConfigParser configParser = new ConfigParser(); | |||
configParser.parseConfigFile(config); | |||
buildConfig.setFiles(configParser.getFiles()); | |||
buildConfig.setConfigFile(config); | |||
} | |||
String classpathString = | |||
Ajde.getDefault().getProjectProperties().getBootClasspath() | |||
+ File.pathSeparator | |||
+ Ajde.getDefault().getProjectProperties().getClasspath(); | |||
StringTokenizer st = new StringTokenizer( | |||
classpathString, | |||
File.pathSeparator | |||
); | |||
List classpath = new ArrayList(); | |||
while (st.hasMoreTokens()) classpath.add(st.nextToken()); | |||
buildConfig.setClasspath(classpath); | |||
Ajde.getDefault().logEvent("building with classpath: " + classpath); | |||
if (Ajde.getDefault().getBuildManager().getBuildOptions().getSourceOnePointFourMode()) { | |||
buildConfig.getJavaOptions().put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); | |||
} | |||
// XXX problematic restriction, support multiple source roots | |||
List sourceRoots = new ArrayList(); | |||
sourceRoots.add(new File(configFile).getParentFile()); | |||
buildConfig.setSourceRoots(sourceRoots); | |||
buildConfig.setOutputDir( | |||
new File(Ajde.getDefault().getProjectProperties().getOutputPath()) | |||
); | |||
buildConfig.setGenerateModelMode(true); | |||
return buildConfig; | |||
} | |||
private void init() { | |||
if (!initialized) { // XXX plug into AJDE initialization | |||
// Ajde.getDefault().setErrorHandler(new DebugErrorHandler()); | |||
this.messageHandler = new MessageHandlerAdapter(); | |||
buildManager = new AjBuildManager(messageHandler); | |||
initialized = true; | |||
} | |||
} | |||
class MessageHandlerAdapter implements IMessageHandler { | |||
private TaskListManager taskListManager; | |||
private BuildNotifierAdapter buildNotifierAdapter; | |||
public MessageHandlerAdapter() { | |||
this.taskListManager = Ajde.getDefault().getTaskListManager(); | |||
} | |||
public boolean handleMessage(IMessage message) throws AbortException { | |||
if (isIgnoring(message.getKind())) return true; | |||
// ??? relies on only info messages being class-file written messages | |||
if (message.getKind().equals(IMessage.INFO)) { | |||
if (buildNotifierAdapter != null) { | |||
buildNotifierAdapter.generatedBytecode(message.getMessage()); | |||
} | |||
} else { | |||
taskListManager.addSourcelineTask( | |||
message.getMessage(), | |||
message.getISourceLocation(), | |||
message.getKind() | |||
); | |||
} | |||
return true; | |||
} | |||
public boolean isIgnoring(IMessage.Kind kind) { | |||
// XXX implement for INFO, DEBUG? | |||
return false; | |||
} | |||
public void setBuildNotifierAdapter(BuildNotifierAdapter buildNotifierAdapter) { | |||
this.buildNotifierAdapter = buildNotifierAdapter; | |||
} | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
import org.aspectj.ajde.ErrorHandler; | |||
public class DebugErrorHandler implements ErrorHandler { | |||
public void handleWarning(String message) { | |||
System.err.println("> WARNING: " + message); | |||
} | |||
public void handleError(String errorMessage) { | |||
handleError(errorMessage, null); | |||
} | |||
public void handleError(String message, Throwable t) { | |||
System.err.println("> ERROR: " + message); | |||
throw (RuntimeException)t; | |||
} | |||
} |
@@ -0,0 +1,61 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.aspectj.util.ConfigParser; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public class LstBuildConfigFileParser extends ConfigParser { | |||
private List importedFiles = new ArrayList(); | |||
private List problemEntries = new ArrayList(); | |||
private String currFilePath; | |||
public LstBuildConfigFileParser(String currFilePath) { | |||
this.currFilePath = currFilePath; | |||
} | |||
protected void showWarning(String message) { | |||
problemEntries.add(message); | |||
} | |||
protected void parseImportedConfigFile(String relativeFilePath) { | |||
importedFiles.add(makeFile(relativeFilePath)); | |||
super.files.add(new File(relativeFilePath)); | |||
super.parseImportedConfigFile(relativeFilePath); | |||
} | |||
protected void showError(String message) { | |||
problemEntries.add(message); | |||
} | |||
public List getImportedFiles() { | |||
return importedFiles; | |||
} | |||
public List getProblemEntries() { | |||
return problemEntries; | |||
} | |||
} | |||
@@ -0,0 +1,196 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
import java.util.*; | |||
import java.io.*; | |||
import org.aspectj.ajde.Ajde; | |||
import org.aspectj.ajde.ui.*; | |||
import org.aspectj.util.ConfigParser; | |||
/** | |||
* Used for reading and writing build configuration (".lst") files. | |||
* | |||
* @author Mik Kersten | |||
*/ | |||
class LstBuildConfigFileUpdater { | |||
/** | |||
* Adds an entry to a build configuration file. | |||
*/ | |||
public void updateBuildConfigFile(String buildConfigFile, String update, boolean addToConfiguration) { | |||
List fileContents = readConfigFile(buildConfigFile); | |||
if (addToConfiguration) { | |||
fileContents.add(update); | |||
} else { | |||
fileContents.remove(update); | |||
} | |||
writeConfigFile(buildConfigFile, fileContents); | |||
} | |||
/** | |||
* Adds an entry to multiple build configuration files. | |||
*/ | |||
public void updateBuildConfigFiles(List buildConfigFiles, List filesToUpdate, boolean addToConfiguration) { | |||
for (int i = 0; i < buildConfigFiles.size(); i++) { | |||
List fileContents = readConfigFile((String)buildConfigFiles.get(i)); | |||
if (addToConfiguration) { | |||
for (int j = 0; j < filesToUpdate.size(); j++) { | |||
fileContents.add(filesToUpdate.get(j)); | |||
} | |||
} else { | |||
for (int k =0; k < filesToUpdate.size(); k++) { | |||
if (fileContents.contains(filesToUpdate.get(k))) { | |||
fileContents.remove(filesToUpdate.get(k)); | |||
} | |||
} | |||
} | |||
writeConfigFile((String)buildConfigFiles.get(i), fileContents); | |||
} | |||
} | |||
/** | |||
* Checks if an entry exists within a build configuration file. | |||
*/ | |||
public boolean exists(String entry, String configFile) { | |||
return exists(entry, configFile, ""); | |||
} | |||
public boolean exists(String entry, String configFile, String rootPath) { | |||
Iterator it = readConfigFile(configFile).iterator(); | |||
while (it.hasNext()) { | |||
if ((entry).equals(rootPath + "/" + (String)it.next())) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* Reads the entries of a configuration file. | |||
*/ | |||
public List readConfigFile(String filePath) { | |||
try { | |||
File configFile = new File(filePath); | |||
if (!configFile.exists()) { | |||
Ajde.getDefault().getErrorHandler().handleWarning("Config file: " + filePath + | |||
" does not exist. Update failed."); | |||
} | |||
List fileContents = new ArrayList(); | |||
BufferedReader reader = new BufferedReader(new FileReader(configFile)); | |||
String line = reader.readLine(); | |||
while (line != null) { | |||
fileContents.add(line.replace('\\', '/')); | |||
line = reader.readLine(); | |||
} | |||
return fileContents; | |||
} catch (IOException ioe) { | |||
Ajde.getDefault().getErrorHandler().handleError("Could not update build config file.", ioe); | |||
} | |||
return null; | |||
} | |||
public void writeConfigFile(String filePath, List files, List importedNodes) { | |||
//Set contentsSet = new TreeSet(fileContents); | |||
String fileContentsString = ""; | |||
//List filesToWrite = null; | |||
Set includedFiles = new HashSet(); | |||
for (Iterator it = importedNodes.iterator(); it.hasNext(); ) { | |||
BuildConfigNode node = (BuildConfigNode)it.next(); | |||
fileContentsString += '@' + node.getResourcePath() + "\n"; | |||
String parentPath = new File(filePath).getParent(); | |||
String importedFilePath = parentPath + File.separator + node.getResourcePath(); | |||
includedFiles.addAll(getIncludedFiles(importedFilePath, parentPath)); | |||
} | |||
for (Iterator it = files.iterator(); it.hasNext(); ) { | |||
BuildConfigNode node = (BuildConfigNode)it.next(); | |||
if (node.getName().endsWith(".lst") && !node.getResourcePath().startsWith("..")) { | |||
fileContentsString += '@'; | |||
fileContentsString += node.getResourcePath() + "\n"; | |||
} else { | |||
if (!includedFiles.contains(node.getResourcePath())) { | |||
fileContentsString += node.getResourcePath() + "\n"; | |||
} | |||
} | |||
} | |||
writeFile(fileContentsString, filePath); | |||
} | |||
private List getIncludedFiles(String path, String rootPath) { | |||
try { | |||
ConfigParser configParser = new ConfigParser(); | |||
configParser.parseConfigFile(new File(path)); | |||
List files = configParser.getFiles(); | |||
List relativeFiles = new ArrayList(); | |||
for (Iterator it = files.iterator(); it.hasNext(); ) { | |||
relativeFiles.add(relativizePath(((File)it.next()).getPath(), rootPath)); | |||
} | |||
return relativeFiles; | |||
} catch (ConfigParser.ParseException pe) { | |||
return new ArrayList(); | |||
} | |||
} | |||
private synchronized List getUniqueFileList(List list, Set set) { | |||
List uniqueList = new ArrayList(); | |||
for (Iterator it = list.iterator(); it.hasNext(); ) { | |||
BuildConfigNode node = (BuildConfigNode)it.next(); | |||
String file1 = node.getResourcePath(); | |||
if (set.contains(file1) && !uniqueList.contains(file1)) { | |||
uniqueList.add(file1); | |||
} | |||
} | |||
return uniqueList; | |||
} | |||
public String relativizePath(String path, String rootPath) { | |||
path = path.replace('\\', '/'); | |||
rootPath = rootPath.replace('\\', '/'); | |||
int pathIndex = path.indexOf(rootPath); | |||
if (pathIndex > -1) { | |||
return path.substring(pathIndex + rootPath.length() + 1); | |||
} else { | |||
return path; | |||
} | |||
} | |||
/** | |||
* Sorts and does not write duplicates. | |||
* | |||
* @param fileContents full paths representing file entries | |||
*/ | |||
public void writeConfigFile(String filePath, List fileContents) { | |||
Set contentsSet = new TreeSet(fileContents); | |||
String fileContentsString = ""; | |||
Iterator it = contentsSet.iterator(); | |||
while (it.hasNext()) { | |||
fileContentsString += it.next().toString() + "\n"; | |||
} | |||
writeFile(fileContentsString, filePath); | |||
} | |||
private void writeFile(String contents, String filePath) { | |||
try { | |||
FileOutputStream fos = new FileOutputStream(filePath, false); | |||
fos.write(contents.getBytes()); | |||
fos.close(); | |||
} catch (IOException ioe) { | |||
Ajde.getDefault().getErrorHandler().handleError("Could not update build config file: " + filePath, ioe); | |||
} | |||
} | |||
} | |||
@@ -0,0 +1,303 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
import java.util.*; | |||
import java.io.*; | |||
import org.aspectj.ajde.*; | |||
import org.aspectj.ajde.ui.*; | |||
import org.aspectj.asm.*; | |||
import org.aspectj.bridge.*; | |||
import org.aspectj.util.ConfigParser; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public class LstBuildConfigManager implements BuildConfigManager { | |||
private List configFiles = new ArrayList(); | |||
private List listeners = new ArrayList(); | |||
private LstBuildConfigFileUpdater fileUpdater = new LstBuildConfigFileUpdater(); | |||
protected String currConfigFilePath = null; | |||
private static final FilenameFilter SOURCE_FILE_FILTER = new FilenameFilter() { | |||
public boolean accept(File dir, String name) { | |||
return name.endsWith(".java") | |||
|| name.endsWith(".aj") | |||
|| name.endsWith(".lst"); | |||
} | |||
}; | |||
private static final FileFilter DIR_FILTER = new FileFilter() { | |||
public boolean accept(File file) { | |||
return file.isDirectory(); | |||
} | |||
}; | |||
public BuildConfigModel buildModel(String configFilePath) { | |||
File configFile = new File(configFilePath); | |||
String rootPath = configFile.getParent(); | |||
String configFileName = configFile.getName(); | |||
BuildConfigModel model = new BuildConfigModel(configFilePath); | |||
List configFiles = new ArrayList(); | |||
List importedFiles = new ArrayList(); | |||
List badEntries = null; | |||
try { | |||
LstBuildConfigFileParser configParser = new LstBuildConfigFileParser(configFilePath); | |||
configParser.parseConfigFile(new File(configFilePath)); | |||
configFiles = configParser.getFiles(); | |||
importedFiles = configParser.getImportedFiles(); | |||
badEntries = configParser.getProblemEntries(); | |||
} catch (ConfigParser.ParseException pe) { | |||
// String filePath = "<unknown>"; | |||
// if (pe.getFile() != null) filePath = pe.getFile().getAbsolutePath(); | |||
Ajde.getDefault().getTaskListManager().addSourcelineTask( | |||
pe.getMessage(), | |||
new SourceLocation(pe.getFile(), pe.getLine(), 1), | |||
IMessage.ERROR); | |||
} | |||
List relativePaths = relativizeFilePaths(configFiles, rootPath); | |||
BuildConfigNode root = new BuildConfigNode(configFileName, BuildConfigNode.Kind.FILE_LST, rootPath); | |||
buildDirTree(root, rootPath, importedFiles, configFileName); | |||
model.setRoot(root); | |||
addFilesToDirTree(model, relativePaths, badEntries); | |||
pruneEmptyDirs(root); | |||
sortModel((BuildConfigNode)model.getRoot(), ALPHABETICAL_COMPARATOR); | |||
//addImportedFilesToDirTree(model, importedFiles); | |||
addProblemEntries(root, badEntries); | |||
return model; | |||
} | |||
private void addProblemEntries(BuildConfigNode root, List badEntries) { | |||
for (Iterator it = badEntries.iterator(); it.hasNext(); ) { | |||
root.addChild(new BuildConfigNode( | |||
it.next().toString(), | |||
BuildConfigNode.Kind.ERROR, null) | |||
); | |||
} | |||
} | |||
public void writeModel(BuildConfigModel model) { | |||
// final List paths = new ArrayList(); | |||
// StructureWalker walker = new StructureWalker() { | |||
// protected void postProcess(StructureNode node) { | |||
// BuildConfigNode configNode = (BuildConfigNode)node; | |||
// if (configNode.isActive() && configNode.isValidResource()) { | |||
// paths.add(configNode.getResourcePath()); | |||
// } | |||
// } | |||
// }; | |||
// model.getRoot().walk(walker); | |||
List activeSourceFiles = model.getActiveNodes(BuildConfigNode.Kind.FILE_ASPECTJ); | |||
activeSourceFiles.addAll(model.getActiveNodes(BuildConfigNode.Kind.FILE_JAVA)); | |||
List activeImportedFiles = model.getActiveNodes(BuildConfigNode.Kind.FILE_LST); | |||
fileUpdater.writeConfigFile(model.getSourceFile(), activeSourceFiles, activeImportedFiles); | |||
} | |||
public void writePaths(String configFilePath, List files) { | |||
fileUpdater.writeConfigFile(configFilePath, files); | |||
} | |||
public void addFilesToConfig(String configFilePath, List paths) { | |||
} | |||
public void removeFilesFromConfig(String configFilePath, List files) { | |||
} | |||
private List relativizeFilePaths(List configFiles, String rootPath) { | |||
List relativePathsList = new ArrayList(); | |||
for (Iterator it = configFiles.iterator(); it.hasNext(); ) { | |||
File file = (File)it.next(); | |||
relativePathsList.add(fileUpdater.relativizePath(file.getPath(), rootPath)); | |||
} | |||
return relativePathsList; | |||
} | |||
// private String relativizePath(String path, String rootPath) { | |||
// path = path.replace('\\', '/'); | |||
// rootPath = rootPath.replace('\\', '/'); | |||
// int pathIndex = path.indexOf(rootPath); | |||
// if (pathIndex > -1) { | |||
// return path.substring(pathIndex + rootPath.length() + 1); | |||
// } else { | |||
// return path; | |||
// } | |||
// } | |||
private void buildDirTree(BuildConfigNode node, String rootPath, List importedFiles, String configFileName) { | |||
File[] dirs = new File(node.getResourcePath()).listFiles(DIR_FILTER); | |||
if (dirs == null) return; | |||
for (int i = 0; i < dirs.length; i++) { | |||
BuildConfigNode dir = new BuildConfigNode(dirs[i].getName(), BuildConfigNode.Kind.DIRECTORY, dirs[i].getPath()); | |||
File[] files = dirs[i].listFiles(SOURCE_FILE_FILTER); | |||
for (int j = 0; j < files.length; j++) { | |||
if (files[j] != null) {// && !files[j].getName().endsWith(".lst")) { | |||
String filePath = fileUpdater.relativizePath(files[j].getPath(), rootPath); | |||
BuildConfigNode.Kind kind = BuildConfigNode.Kind.FILE_JAVA; | |||
if (!files[j].getName().endsWith(".lst")) { | |||
//kind = BuildConfigNode.Kind.FILE_LST; | |||
BuildConfigNode file = new BuildConfigNode(files[j].getName(), kind, filePath); | |||
file.setActive(false); | |||
dir.addChild(file); | |||
} | |||
} | |||
} | |||
node.addChild(dir); | |||
boolean foundMatch = false; | |||
for (Iterator it = importedFiles.iterator(); it.hasNext(); ) { | |||
File importedFile = (File)it.next(); | |||
if (importedFile.getParentFile().getAbsolutePath().equals(dirs[i].getAbsolutePath())) { | |||
foundMatch = true; | |||
BuildConfigNode importedFileNode = new BuildConfigNode( | |||
importedFile.getName(), | |||
BuildConfigNode.Kind.FILE_LST, | |||
fileUpdater.relativizePath(importedFile.getPath(), rootPath)); | |||
importedFileNode.setActive(true); | |||
//dir.getChildren().clear(); | |||
boolean found = false; | |||
for (Iterator it2 = dir.getChildren().iterator(); it2.hasNext(); ) { | |||
if (((BuildConfigNode)it2.next()).getName().equals(importedFile.getName())) { | |||
found = true; | |||
} | |||
} | |||
if (!found) dir.addChild(importedFileNode); | |||
} | |||
} | |||
//if (!foundMatch) | |||
buildDirTree(dir, rootPath, importedFiles, configFileName); | |||
} | |||
if (node.getName().endsWith(".lst")) { | |||
File[] files = new File(rootPath).listFiles(SOURCE_FILE_FILTER); | |||
if (files == null) return; | |||
for (int i = 0; i < files.length; i++) { | |||
if (files[i] != null && !files[i].getName().equals(configFileName)) {// && !files[i].getName().endsWith(".lst")) { | |||
BuildConfigNode.Kind kind = BuildConfigNode.Kind.FILE_JAVA; | |||
if (files[i].getName().endsWith(".lst")) { | |||
kind = BuildConfigNode.Kind.FILE_LST; | |||
} | |||
BuildConfigNode file = new BuildConfigNode(files[i].getName(), kind, files[i].getName()); | |||
file.setActive(false); | |||
node.addChild(file); | |||
} | |||
} | |||
} | |||
} | |||
private void addFilesToDirTree(BuildConfigModel model, List configFiles, List badEntries) { | |||
for (Iterator it = configFiles.iterator(); it.hasNext(); ) { | |||
String path = (String)it.next(); | |||
if (path.startsWith("..")) { | |||
File file = new File(path); | |||
BuildConfigNode node = new BuildConfigNode(file.getName(), BuildConfigNode.Kind.FILE_JAVA, path); | |||
BuildConfigNode upPath = model.getNodeForPath(file.getParentFile().getPath()); | |||
if (upPath == model.getRoot()) { | |||
upPath = new BuildConfigNode(file.getParentFile().getPath(), BuildConfigNode.Kind.DIRECTORY, file.getParentFile().getAbsolutePath()); | |||
model.getRoot().addChild(upPath); | |||
} | |||
node.setActive(true); | |||
upPath.addChild(node); | |||
} else if (!(new File(path).isAbsolute())) { | |||
String name = new File(path).getName(); | |||
BuildConfigNode existingNode = model.getNodeForPath(path); | |||
existingNode.setActive(true); | |||
} else { | |||
badEntries.add("Use relative paths only, omitting: " + path); | |||
} | |||
} | |||
} | |||
private boolean pruneEmptyDirs(BuildConfigNode node) { | |||
List nodesToRemove = new ArrayList(); | |||
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { | |||
BuildConfigNode currNode = (BuildConfigNode)it.next(); | |||
boolean hasValidChildren = pruneEmptyDirs(currNode); | |||
if (!currNode.isValidResource() && !hasValidChildren) { | |||
nodesToRemove.add(currNode); | |||
} | |||
} | |||
for (Iterator it = nodesToRemove.iterator(); it.hasNext(); ) { | |||
StructureNode currNode = (StructureNode)it.next(); | |||
node.removeChild(currNode); | |||
} | |||
return node.getChildren().size() > 0; | |||
} | |||
public String getActiveConfigFile() { | |||
if (currConfigFilePath == null) return null; | |||
if (currConfigFilePath.equals(DEFAULT_CONFIG_LABEL)) { | |||
return Ajde.getDefault().getProjectProperties().getDefaultBuildConfigFile();// getDefaultConfigFile(); | |||
} else { | |||
return currConfigFilePath; | |||
} | |||
} | |||
public void setActiveConfigFile(String currConfigFilePath) { | |||
if (currConfigFilePath.equals(DEFAULT_CONFIG_LABEL)) { | |||
this.currConfigFilePath = Ajde.getDefault().getProjectProperties().getDefaultBuildConfigFile();//getDefaultConfigFile(); | |||
} else { | |||
this.currConfigFilePath = currConfigFilePath; | |||
} | |||
notifyConfigChanged(); | |||
} | |||
public void addListener(BuildConfigListener configurationListener) { | |||
listeners.add(configurationListener); | |||
} | |||
public void removeListener(BuildConfigListener configurationListener) { | |||
listeners.remove(configurationListener); | |||
} | |||
private void notifyConfigChanged() { | |||
for (Iterator it = listeners.iterator(); it.hasNext(); ) { | |||
((BuildConfigListener)it.next()).currConfigChanged(currConfigFilePath); | |||
} | |||
} | |||
private void notifyConfigsListUpdated() { | |||
for (Iterator it = listeners.iterator(); it.hasNext(); ) { | |||
((BuildConfigListener)it.next()).configsListUpdated(configFiles); | |||
} | |||
} | |||
private void sortModel(BuildConfigNode node, Comparator comparator) { | |||
if (node == null || node.getChildren() == null) return; | |||
Collections.sort(node.getChildren(), comparator); | |||
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { | |||
BuildConfigNode nextNode = (BuildConfigNode)it.next(); | |||
if (nextNode != null) sortModel(nextNode, comparator); | |||
} | |||
} | |||
private static final Comparator ALPHABETICAL_COMPARATOR = new Comparator() { | |||
public int compare(Object o1, Object o2) { | |||
BuildConfigNode n1 = (BuildConfigNode)o1; | |||
BuildConfigNode n2 = (BuildConfigNode)o2; | |||
return n1.getName().compareTo(n2.getName()); | |||
} | |||
}; | |||
} | |||
@@ -0,0 +1,89 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 1999-2001 Xerox Corporation, | |||
* 2002 Palo Alto Research Center, Incorporated (PARC). | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.internal; | |||
//import org.aspectj.ajde.compiler.AjdeCompiler; | |||
//import org.aspectj.compiler.structure.*; | |||
//import org.aspectj.compiler.structure.associations.*; | |||
/** | |||
* Utility class for building a structure model for a given compile. Typical command-line usage: <BR> | |||
* > <TT>java org.aspectj.tools.ajde.StructureManager @<config-file>.lst</TT> | |||
*/ | |||
public class StructureUtilities { | |||
// private static StructureManager structureManager = new StructureManager(); | |||
/** | |||
* Usage is the same as <CODE>org.aspectj.tools.ajc.Main</CODE>. | |||
*/ | |||
// public static void main(String[] args) throws IOException { | |||
// StructureNode model = buildStructureModel(args); | |||
// if (model == null) { | |||
// } else { | |||
// dumpStructure(model, ""); | |||
// } | |||
// } | |||
/** | |||
* Compiles and builds a structure model. | |||
* | |||
* @return the node representing the root for the structure model | |||
*/ | |||
// public static StructureNode buildStructureModel(String[] args) { | |||
// new StructureBuilder().buildStructure(args); | |||
// return structureManager.getStructureModel(); | |||
// } | |||
/** | |||
* Dumps the structure model by walking the | |||
* corresponding tree. | |||
* * @param node node to start traversal at, typically the root | |||
* @param indent whitespace accumulator for pretty-printing | |||
*/ | |||
// public static void dumpStructure(StructureNode node, String indent) { | |||
// if (node == null) return; | |||
// Syste.println(indent + node); | |||
// if (node.getChildren() != null) { | |||
// for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { | |||
// dumpStructure((StructureNode)it.next(), indent + " "); | |||
// } | |||
// } | |||
// if (node instanceof ProgramElementNode) { | |||
// if (((ProgramElementNode)node).getRelations() != null) { | |||
// for (Iterator it = ((ProgramElementNode)node).getRelations().iterator(); it.hasNext(); ) { | |||
// dumpStructure((StructureNode)it.next(), indent + " "); | |||
// } | |||
// } | |||
// } | |||
// } | |||
// | |||
// private static class StructureBuilder extends org.aspectj.tools.ajc.Main { | |||
// public void buildStructure(String[] args) { | |||
// compile(args); | |||
// } | |||
// | |||
// public JavaCompiler getCompiler() { | |||
// if (compiler != null) return compiler; | |||
// if (compiler == null) { | |||
// if (errorHandler == null) { | |||
// compiler = new AjdeCompiler(structureManager); | |||
// } | |||
// } | |||
// return compiler; | |||
// } | |||
// } | |||
} |