diff options
author | wisberg <wisberg> | 2002-12-16 17:58:19 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 17:58:19 +0000 |
commit | d842c4f1139629c1f062b74ba818d233b2c31043 (patch) | |
tree | 842d3871620bc0eb60edcd95e55804d67e0f61fa /ajbrowser | |
parent | 3ce247199704eae6b2c92c6e38c69584e3250c52 (diff) | |
download | aspectj-d842c4f1139629c1f062b74ba818d233b2c31043.tar.gz aspectj-d842c4f1139629c1f062b74ba818d233b2c31043.zip |
initial version
Diffstat (limited to 'ajbrowser')
13 files changed, 1508 insertions, 0 deletions
diff --git a/ajbrowser/AJBrowser.jpx b/ajbrowser/AJBrowser.jpx new file mode 100644 index 000000000..9a0e5f415 --- /dev/null +++ b/ajbrowser/AJBrowser.jpx @@ -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>
+
diff --git a/ajbrowser/src/.cvsignore b/ajbrowser/src/.cvsignore new file mode 100644 index 000000000..cf9a8cca3 --- /dev/null +++ b/ajbrowser/src/.cvsignore @@ -0,0 +1,2 @@ +ajbrowser.lst +ajbrowserSrc.lst diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java new file mode 100644 index 000000000..b2ec90571 --- /dev/null +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java @@ -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; + } +} diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserOptionsPanel.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserOptionsPanel.java new file mode 100644 index 000000000..f09d68f81 --- /dev/null +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserOptionsPanel.java @@ -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); + } + +} diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java new file mode 100644 index 000000000..9c69722ce --- /dev/null +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java @@ -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); + } +} diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserUIAdapter.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserUIAdapter.java new file mode 100644 index 000000000..8583befca --- /dev/null +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserUIAdapter.java @@ -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); + } +} diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java new file mode 100644 index 000000000..61a808aab --- /dev/null +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java @@ -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); + } +} + + + diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/Main.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/Main.java new file mode 100644 index 000000000..fed24f99d --- /dev/null +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/Main.java @@ -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); + } +} diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java new file mode 100644 index 000000000..2b7b66ebf --- /dev/null +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java @@ -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(); + } +} diff --git a/ajbrowser/testsrc/AjbrowserModuleTests.java b/ajbrowser/testsrc/AjbrowserModuleTests.java new file mode 100644 index 000000000..ba3ba08a9 --- /dev/null +++ b/ajbrowser/testsrc/AjbrowserModuleTests.java @@ -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); } + +} diff --git a/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/AjbrowserTests.java b/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/AjbrowserTests.java new file mode 100644 index 000000000..0830ab385 --- /dev/null +++ b/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/AjbrowserTests.java @@ -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() {} +} diff --git a/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/BrowserManagerTest.java b/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/BrowserManagerTest.java new file mode 100644 index 000000000..4c14046b2 --- /dev/null +++ b/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/BrowserManagerTest.java @@ -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(); + } +} diff --git a/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/JemmyDriver.java b/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/JemmyDriver.java new file mode 100644 index 000000000..effc3c681 --- /dev/null +++ b/ajbrowser/testsrc/org/aspectj/tools/ajbrowser/JemmyDriver.java @@ -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); +// } +// +//} |