]> source.dussan.org Git - aspectj.git/commitdiff
Fix for bug#40771
authormkersten <mkersten>
Fri, 25 Jul 2003 15:07:57 +0000 (15:07 +0000)
committermkersten <mkersten>
Fri, 25 Jul 2003 15:07:57 +0000 (15:07 +0000)
De-coupled AJDE APIs from javax.swing, and moved browser-specific funtionality into the the ajbrowser module.

22 files changed:
ajbrowser/src/org/aspectj/tools/ajbrowser/BasicEditor.java [new file with mode: 0644]
ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
ajbrowser/src/org/aspectj/tools/ajbrowser/BuildConfigPopupMenu.java [new file with mode: 0644]
ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java
ajbrowser/src/org/aspectj/tools/ajbrowser/EditorManager.java [new file with mode: 0644]
ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java
ajde/ajsrc/org/aspectj/ajde/AjdeApiRules.aj [new file with mode: 0644]
ajde/src/org/aspectj/ajde/Ajde.java
ajde/src/org/aspectj/ajde/ui/EditorManager.java [deleted file]
ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java
ajde/src/org/aspectj/ajde/ui/swing/BasicEditor.java [deleted file]
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java
ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java [deleted file]
ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java
ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java
ajde/testsrc/AjdeModuleTests.java
ajde/testsrc/org/aspectj/ajde/CompilerMessagesTest.java
ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java [new file with mode: 0644]
ajde/testsrc/org/aspectj/ajde/NullIdeManager.java

diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BasicEditor.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BasicEditor.java
new file mode 100644 (file)
index 0000000..8913b21
--- /dev/null
@@ -0,0 +1,182 @@
+/* *******************************************************************
+ * 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.Font;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.swing.JEditorPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultHighlighter;
+
+import org.aspectj.ajde.Ajde;
+import org.aspectj.ajde.EditorAdapter;
+import org.aspectj.bridge.ISourceLocation;
+
+/**
+ * Bare-bones editor implementation used when the framework is being used
+ * standalone.
+ *
+ * @author Mik Kersten
+ */
+public class BasicEditor implements EditorAdapter {
+
+       private String NO_FILE = "<no file selected>";
+    private String filePath = NO_FILE;
+    private JPanel editor_panel = new JPanel();
+
+    // @todo    get rid of these
+    private int currHighlightStart = 0;
+    private int currHighlightEnd = 0;
+
+    private BorderLayout borderLayout1 = new BorderLayout();
+    private JScrollPane jScrollPane1 = new JScrollPane();
+    private JEditorPane editorPane = new JEditorPane();
+
+    public BasicEditor() {
+        try {
+            editorPane.setEditable(true);
+            editorPane.setContentType("text/plain");
+            editorPane.setFont(new Font("Monospaced", 0, 11));
+            editor_panel.add(editorPane);
+            jbInit();
+        }
+        catch(Exception e) {
+            Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
+        }
+    }
+
+    public String getCurrFile() {
+               return filePath;
+    }
+
+    public void showSourceLine(ISourceLocation sourceLocation, boolean highlight) {
+               showSourceLine(sourceLocation.getSourceFile().getAbsolutePath(), sourceLocation.getLine(), highlight);
+       }
+
+    public void showSourceLine(int lineNumber, boolean highlight) {
+        showSourceLine(filePath, lineNumber, highlight);
+    }
+
+    public void pasteToCaretPos(String text) {
+        if (currHighlightEnd < 1) return;
+        String contents = editorPane.getText();
+        String pasted = contents.substring(0, currHighlightEnd) +
+            text + contents.substring(currHighlightEnd, contents.length());
+        editorPane.setText(pasted);
+    }
+
+    public void showSourceLine(String filePath, int lineNumber, boolean highlight) {
+       //AjdeUIManager.getDefault().getIdeUIAdapter().resetEditor();
+        
+        String oldPath = this.filePath;
+        this.filePath = filePath;
+//        if (oldPath != filePath && !Ajde.INSTANCE.BROWSER_MANAGER.isGlobalMode()) {
+//            Ajde.INSTANCE.BROWSER_MANAGER.updateView();
+//        }
+
+//        Ajde.IDE_MANAGER.setEditorStatusText(filePath);
+
+        currHighlightStart = 0;
+        currHighlightEnd = 0;
+        editorPane.setText(readFile(filePath, lineNumber));
+        try {
+            editorPane.getHighlighter().addHighlight(currHighlightStart, currHighlightEnd, DefaultHighlighter.DefaultPainter);
+            editorPane.setCaretPosition(currHighlightStart);
+        } catch (BadLocationException ble) {
+            Ajde.getDefault().getErrorHandler().handleError("Could not highlight location.", ble);
+        }
+        BrowserManager.getDefault().getEditorManager().notifyCurrentFileChanged(filePath);
+    }
+
+    /**
+     * Not implemented.
+     */
+    public void showSourcelineAnnotation(String filePath, int lineNumber, java.util.List items) { }
+
+       public void addEditorViewForSourceLine(String filePath, int lineNumber) {
+               
+       }
+
+    public void saveContents() throws IOException {
+        if (filePath != NO_FILE && filePath != "" && editorPane.getText() != "") {
+            BufferedWriter writer = new BufferedWriter(new FileWriter(filePath));
+            writer.write(editorPane.getText());
+            writer.flush();
+        }
+    }
+
+    public JPanel getPanel() {
+        return editor_panel;
+    }
+
+    public void showSourceForFile(String filePath) { }
+
+    public void showSourceForLine(int lineNumber, boolean highlight) { }
+
+    public void showSourceForSourceLine(String filePath, int lineNumber, boolean highlight) { }
+
+    public String getCurrSourceFilePath() { return null; }
+
+    public void setBreakpointRequest(String filePath, int lineNumber, boolean isDeferred) { }
+
+    public void clearBreakpointRequest(String filePath, int lineNumber) { }
+
+    private String readFile(String filePath, int lineNumber) {
+        try {
+            URL url = ClassLoader.getSystemResource(filePath);
+            File file = new File(filePath);
+            if (!file.exists()) {
+                return "ERROR: file \"" + filePath + "\" does not exist.";
+            }
+            BufferedReader reader = new BufferedReader(new FileReader(file));
+            StringBuffer contents = new StringBuffer();
+            String line = reader.readLine();
+            int numChars = 0;
+            int numLines = 0;
+            while (line != null) {
+                numLines++;
+                if (numLines < lineNumber) {
+                    currHighlightStart += line.length()+1;
+                }
+                if (numLines == lineNumber) {
+                    currHighlightEnd = currHighlightStart + line.length();
+                }
+                contents.append(line);
+                contents.append('\n');
+                line = reader.readLine();
+            }
+            return contents.toString();
+        } catch (IOException ioe) {
+            return "ERROR: could not read file \"" + filePath + "\", make sure that you have mounted /project/aop on X:\\";
+        }
+    }
+
+    private void jbInit() throws Exception {
+        editor_panel.setFont(new java.awt.Font("DialogInput", 1, 12));
+        editor_panel.setLayout(borderLayout1);
+        editor_panel.add(jScrollPane1, BorderLayout.CENTER);
+        jScrollPane1.getViewport().add(editorPane, null);
+    }
+}
index ac8d41c1998805bbfd421ec042dee9d5779c9ecc..5f6f9e6e8a8e9224f9a88c2594bf063708e0d81e 100644 (file)
 package org.aspectj.tools.ajbrowser;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 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.*;
+import org.aspectj.ajde.ui.*;
 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;
+import org.aspectj.ajde.ui.swing.*;
+import org.aspectj.asm.*;
 
 /**
  * IDE manager for standalone AJDE application.
@@ -41,6 +34,8 @@ public class BrowserManager {
        
        private static final BrowserManager INSTANCE = new BrowserManager();
        private BrowserProperties browserProjectProperties;
+       private EditorManager editorManager;
+       private StructureViewPanel fileStructurePanel = null;
        
        public static BrowserManager getDefault() {
                return INSTANCE;
@@ -52,6 +47,15 @@ public class BrowserManager {
     
     private static TopFrame topFrame = null;
     
+       public final StructureModelListener VIEW_LISTENER = new StructureModelListener() {
+               public void modelUpdated(StructureModel model) {                
+                       FileStructureView fsv = Ajde.getDefault().getStructureViewManager().getDefaultFileView();
+                       if (fsv != null) {
+                               fsv.setSourceFile(BrowserManager.getDefault().getEditorManager().getCurrFile());
+                       }
+               }
+       }; 
+    
        public void init(String[] configFilesArgs, boolean visible) {
                try {
                        UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(true);
@@ -69,20 +73,28 @@ public class BrowserManager {
                                preferencesAdapter,
                                browserUIAdapter,
                                new IconRegistry(),
-                               topFrame,
-                               true);  
+                               topFrame);      
+                       
+                       editorManager = new EditorManager(ajdeEditor);
+                       
+                       FileStructureView structureView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(
+                               editorManager.getCurrFile(),
+                               Ajde.getDefault().getStructureViewManager().getDefaultViewProperties()
+                       );
+                       Ajde.getDefault().getStructureViewManager().setDefaultFileView(structureView);                  
+                       fileStructurePanel = new StructureViewPanel(structureView);
                        
                        Ajde.getDefault().getBuildManager().addListener(BUILD_MESSAGES_LISTENER);
                        
                        MultiStructureViewPanel multiViewPanel = new MultiStructureViewPanel(
                                AjdeUIManager.getDefault().getViewManager().getBrowserPanel(),
-                               AjdeUIManager.getDefault().getFileStructurePanel()
+                               fileStructurePanel
                        );
                        
                        topFrame.init(
                                multiViewPanel,
                                (CompilerMessagesPanel)taskListManager,
-                               Ajde.getDefault().getEditorManager().getEditorPanel()
+                               editorManager.getEditorPanel()
                        );
                                
                        if (visible) topFrame.setVisible(true);
@@ -97,8 +109,10 @@ public class BrowserManager {
                
                        AjdeUIManager.getDefault().getOptionsFrame().addOptionsPanel(new BrowserOptionsPanel());
                
+                       StructureModelManager.getDefault().addListener(VIEW_LISTENER);  
+               
                        //String lastOpenFilePath = browserProjectProperties.getLastOpenSourceFilePath();
-                       //Ajde.getDefault().getEditorManager().showSourceLine(lastOpenFilePath, 1, false);      
+                       //editorManager.showSourceLine(lastOpenFilePath, 1, false);     
                        //Ajde.getDefault().getStructureViewManager().fireNavigationAction(lastOpenFilePath, 6);
                        //Ajde.getDefault().enableLogging(System.out); 
                
@@ -132,7 +146,7 @@ public class BrowserManager {
     }
 
     public void saveAll() {
-        Ajde.getDefault().getEditorManager().saveContents();
+        editorManager.saveContents();
     }
 
     public void showMessages() {
@@ -153,7 +167,7 @@ public class BrowserManager {
                                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);                
+                               editorManager.showSourceLine(filePath, 0, false);               
                        } else {
                                Ajde.getDefault().getErrorHandler().handleError("File: " + filePath 
                                        + " could not be opened because the extension was not recoginzed.");    
@@ -226,4 +240,11 @@ public class BrowserManager {
        public BrowserProperties getBrowserProjectProperties() {
                return browserProjectProperties;
        }
+       /**
+        * @return
+        */
+       public EditorManager getEditorManager() {
+               return editorManager;
+       }
+
 }
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BuildConfigPopupMenu.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BuildConfigPopupMenu.java
new file mode 100644 (file)
index 0000000..8ca49e7
--- /dev/null
@@ -0,0 +1,54 @@
+/* *******************************************************************
+ * 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.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Iterator;
+
+import javax.swing.AbstractAction;
+import javax.swing.Icon;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import org.aspectj.ajde.Ajde;
+import org.aspectj.ajde.ui.swing.*;
+import org.aspectj.asm.ProgramElementNode;
+
+public class BuildConfigPopupMenu extends JPopupMenu {
+
+       public BuildConfigPopupMenu(final AbstractAction action) {
+               java.util.List configFiles = Ajde.getDefault().getProjectProperties().getBuildConfigFiles();
+               for (Iterator it = configFiles.iterator(); it.hasNext(); ) {
+               final String buildConfig = (String)it.next();
+               JMenuItem buildItem = new JMenuItem(buildConfig);
+               buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
+               buildItem.addActionListener(
+                       new ActionListener() {
+                               public void actionPerformed(ActionEvent e) {
+                                       Ajde.getDefault().getConfigurationManager().setActiveConfigFile(buildConfig);
+                        if (EditorManager.isShiftDown(e.getModifiers())) {
+                            Ajde.getDefault().getBuildManager().buildFresh();
+                        } else {
+                            Ajde.getDefault().getBuildManager().build();
+                        }
+                                       action.actionPerformed(e);
+                                       }
+                       });
+               buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(ProgramElementNode.Kind.FILE_LST).getIconResource());
+               this.add(buildItem);
+               }
+       }
+}
index 46a162c1ed6d3222cf680c39f30cc98b747e1e43..e03885ef68e5ebe2d9bf7b0c83cd5481749260e1 100644 (file)
@@ -85,7 +85,7 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager {
      */
     protected void displayMessage(IMessage message) {
         ISourceLocation loc = message.getISourceLocation();
-        Ajde.getDefault().getEditorManager().showSourceLine(loc, true);
+               BrowserManager.getDefault().getEditorManager().showSourceLine(loc, true);
         // show dialog with stack trace if thrown
         Throwable thrown = message.getThrown();
         if (null != thrown) { 
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/EditorManager.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/EditorManager.java
new file mode 100644 (file)
index 0000000..1c09802
--- /dev/null
@@ -0,0 +1,167 @@
+/* *******************************************************************
+ * 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.KeyEvent;
+import java.io.IOException;
+import java.util.*;
+
+import javax.swing.*;
+
+import org.aspectj.ajde.*;
+import org.aspectj.bridge.ISourceLocation;
+
+/**
+ * Responsible for controlling the editor.
+ *
+ * @todo    remove coupling to <CODE>BasicEditor</CODE>
+ * @author  Mik Kersten
+ */
+public class EditorManager {
+
+    /** @return true if input modifiers have shift down */
+    public static boolean isShiftDown(int modifiers) {
+        return (0 != (modifiers & KeyEvent.SHIFT_MASK));
+    }
+
+    private EditorAdapter editor = null;
+    private BasicEditor basicEditor = null;
+    private ArrayList editorListeners = new ArrayList();
+    private Vector editors = new Vector();
+    private JPanel editor_panel = null;
+    private Box editors_box = Box.createVerticalBox();
+
+    public EditorManager(EditorAdapter ajdeEditor) {
+       if (ajdeEditor instanceof BasicEditor) {
+               this.basicEditor = (BasicEditor)ajdeEditor;
+               editors.add(basicEditor);
+               editors_box.add(basicEditor.getPanel());
+               editor_panel = new JPanel(new BorderLayout());
+               editor_panel.add(editors_box, BorderLayout.CENTER);     
+       } else {
+               editors.add(ajdeEditor);
+               this.editor = ajdeEditor;               
+       }
+    }
+
+    public void addListener(EditorListener editorListener) {
+        editorListeners.add(editorListener);
+    }
+
+    public void removeListener(EditorListener editorListener) {
+        editorListeners.remove(editorListener);
+    }
+
+    public void notifyCurrentFileChanged(String filePath) {
+        for (Iterator it = editorListeners.iterator(); it.hasNext(); ) {
+            ((EditorListener)it.next()).currentFileChanged(filePath);
+        }
+    }
+
+    public void addViewForSourceLine(final String filePath, final int lineNumber) {
+        if (basicEditor == null) return;
+        editors_box.remove(basicEditor.getPanel());
+        final BasicEditor newEditor = new BasicEditor();
+        editors.add(newEditor);
+        
+        Runnable update = new Runnable() {
+            public void run() {
+                editors_box.add(newEditor.getPanel());
+                newEditor.showSourceLine(filePath, lineNumber, true);
+                //AjdeUIManager.getDefault().getIdeUIAdapter().resetGUI();
+            }
+        };
+
+        if (SwingUtilities.isEventDispatchThread()) {
+            update.run(); 
+        } else {
+            try {
+                SwingUtilities.invokeAndWait(update);
+            } catch (Exception e) {
+                Ajde.getDefault().getErrorHandler().handleError("Could not add view for source line.", e);
+            }
+        }
+    }
+
+    public String getCurrFile() {
+       if (basicEditor != null) {
+               return basicEditor.getCurrFile();
+       } else {
+               return editor.getCurrFile();
+       }
+    }
+
+       
+       public void showSourceLine(ISourceLocation sourceLocation, boolean highlight) {
+               if (sourceLocation != null) {
+                       showSourceLine(
+                               sourceLocation.getSourceFile().getAbsolutePath(),
+                               sourceLocation.getLine(),
+                               highlight);     
+               }       
+       }
+
+    /**
+     * @todo    remove "instanceof AjdeManager" hack
+     */
+    public void showSourceLine(String filePath, int lineNumber, boolean highlight) {
+        if (editors.size() > 1) {
+            editors_box.removeAll();
+            editors_box.add(basicEditor.getPanel());
+            //AjdeUIManager.getDefault().getIdeUIAdapter().resetGUI();
+            editors.removeAllElements();
+            editors.add(basicEditor);
+        } 
+        
+        if (basicEditor != null) {
+               basicEditor.showSourceLine(filePath, lineNumber, highlight);
+        } else {
+               editor.showSourceLine(filePath, lineNumber, highlight);
+        }
+    }
+
+    public void pasteToCaretPos(String text) {
+        if (basicEditor != null) {
+               basicEditor.pasteToCaretPos(text);
+        } else {
+               editor.pasteToCaretPos(text);
+        }      
+    }
+
+    public void showSourcelineAnnotation(String filePath, int lineNumber, java.util.List items) {
+        editor.showSourcelineAnnotation(filePath, lineNumber, items);
+    }
+
+    public void saveContents() {
+        try {
+            for (Iterator it = editors.iterator(); it.hasNext(); ) {
+                ((EditorAdapter)it.next()).saveContents();
+            }
+        } catch (IOException ioe) {
+            Ajde.getDefault().getErrorHandler().handleError("Editor could not save the current file.", ioe);
+        }
+    }
+
+    public JPanel getEditorPanel() {
+        if (editor_panel != null) {
+            return editor_panel;
+        } else {
+            return basicEditor.getPanel();
+        }
+    }
+}
+
+
index 7e3afb82dc93e60ccfaa9488b2164c863d09f9b4..e97ae9dd1a60d60cb888f6ab05e814f6944dad1e 100644 (file)
 
 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.KeyEvent;
-import java.awt.event.WindowEvent;
+import java.awt.*;
+import java.awt.event.*;
 import java.io.File;
 
 import javax.swing.*;
-import javax.swing.border.BevelBorder;
-import javax.swing.border.Border;
+import javax.swing.border.*;
 import javax.swing.filechooser.FileFilter;
 
 import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.ui.EditorManager;
-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.ajde.ui.swing.*;
 import org.aspectj.asm.ProgramElementNode;
 
 /**
@@ -465,7 +455,7 @@ public class TopFrame extends JFrame {
     void treeMode_comboBox_actionPerformed(ActionEvent e) { }
 
     void save_button_actionPerformed(ActionEvent e) {
-        Ajde.getDefault().getEditorManager().saveContents();
+        BrowserManager.getDefault().getEditorManager().saveContents();
     }
 
 
@@ -483,13 +473,8 @@ public class TopFrame extends JFrame {
         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();
+               BrowserManager.getDefault().getEditorManager().saveContents();
     }
 
     void projectBuild_menuItem_actionPerformed(ActionEvent e) {
diff --git a/ajde/ajsrc/org/aspectj/ajde/AjdeApiRules.aj b/ajde/ajsrc/org/aspectj/ajde/AjdeApiRules.aj
new file mode 100644 (file)
index 0000000..91f67ce
--- /dev/null
@@ -0,0 +1,24 @@
+/* *******************************************************************\r
+ * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC),\r
+ *               2003 Contributors.\r
+ * All rights reserved. \r
+ * This program and the accompanying materials are made available \r
+ * under the terms of the Common Public License v1.0 \r
+ * which accompanies this distribution and is available at \r
+ * http://www.eclipse.org/legal/cpl-v10.html \r
+ *  \r
+ * Contributors: \r
+ *     Xerox/PARC      initial implementation \r
+ *     AMC 01.20.2003  extended to support new AspectJ 1.1 options,\r
+ *                                    bugzilla #29769\r
+ * ******************************************************************/\r
+\r
+public aspect AjdeApiRules {\r
+       \r
+\r
+       declare warning:\r
+               call(* javax.swing..*(..)) && !within(org.aspectj.ajde.ui.swing..*):\r
+               "do not use Swing outside of org.aspectj.ajde.swing";\r
+\r
+}\r
+   
\ No newline at end of file
index b1a473d7e57658e96cd671df43f567fee737dc0f..f75e3de8205dde3cbd32f89812702716bb5a568f 100644 (file)
@@ -16,7 +16,6 @@ package org.aspectj.ajde;
 
 import org.aspectj.ajde.internal.AspectJBuildManager;
 import org.aspectj.ajde.internal.LstBuildConfigManager;
-import org.aspectj.ajde.ui.EditorManager;
 import org.aspectj.ajde.ui.IdeUIAdapter;
 import org.aspectj.ajde.ui.StructureSearchManager;
 import org.aspectj.ajde.ui.StructureViewManager;
@@ -36,14 +35,15 @@ import java.util.List;
  *
  * @author Mik Kersten
  */
-public class Ajde {  
+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 EditorManager editorManager;
+       private EditorAdapter editorAdapter;
        private StructureViewManager structureViewManager;
        private StructureSearchManager structureSearchManager;
        private BuildConfigManager configurationManager ;
@@ -77,7 +77,8 @@ public class Ajde {
                        INSTANCE.projectProperties = projectProperties;
                        INSTANCE.errorHandler = errorHandler;
                        INSTANCE.taskListManager = taskListManager;
-                       INSTANCE.editorManager = new EditorManager(editorAdapter);
+//                     INSTANCE.editorManager = new EditorManager(editorAdapter);
+                       INSTANCE.editorAdapter = editorAdapter;
                        INSTANCE.buildManager = new AspectJBuildManager(
                                taskListManager, 
                                compileProgressMonitor,
@@ -117,9 +118,13 @@ public class Ajde {
                return buildManager;
        }
        
-       public EditorManager getEditorManager() {
-               return editorManager;
-       }       
+//     public EditorManager getEditorManager() {
+//             return editorManager;
+//     }       
+       
+       public EditorAdapter getEditorAdapter() {
+               return editorAdapter;
+       }
        
        public StructureViewManager getStructureViewManager() {
                return structureViewManager;    
@@ -171,7 +176,7 @@ public class Ajde {
         * instead.
         */
        public StructureModelManager getStructureModelManager() {
-               return StructureModelManager.INSTANCE;  
+               return StructureModelManager.getDefault();      
        }
        
        public void logEvent(String message) {
@@ -302,7 +307,7 @@ public class Ajde {
         public void compileFinished(String buildConfig, int buildTime, boolean succeeded, boolean warnings) { 
                String configFilePath = projectProperties.getDefaultBuildConfigFile();
                if (!succeeded) {
-                       StructureModelManager.INSTANCE.fireModelUpdated();      
+                       StructureModelManager.getDefault().fireModelUpdated();  
            }
         }
         
@@ -355,6 +360,9 @@ public class Ajde {
             this.valid = valid;
         }
     }
+
+
+
 }
 
 
diff --git a/ajde/src/org/aspectj/ajde/ui/EditorManager.java b/ajde/src/org/aspectj/ajde/ui/EditorManager.java
deleted file mode 100644 (file)
index e47728d..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/* *******************************************************************
- * 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.ui;
-
-import java.awt.BorderLayout;
-import java.awt.event.KeyEvent;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Vector;
-
-import javax.swing.Box;
-import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
-
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.EditorAdapter;
-import org.aspectj.ajde.EditorListener;
-import org.aspectj.ajde.ui.swing.BasicEditor;
-import org.aspectj.bridge.ISourceLocation;
-
-/**
- * Responsible for controlling the editor.
- *
- * @todo    remove coupling to <CODE>BasicEditor</CODE>
- * @author  Mik Kersten
- */
-public class EditorManager {
-
-    /** @return true if input modifiers have shift down */
-    public static boolean isShiftDown(int modifiers) {
-        return (0 != (modifiers & KeyEvent.SHIFT_MASK));
-    }
-
-    private EditorAdapter editor = null;
-    private BasicEditor basicEditor = null;
-    private ArrayList editorListeners = new ArrayList();
-    private Vector editors = new Vector();
-    private JPanel editor_panel = null;
-    private Box editors_box = Box.createVerticalBox();
-
-    public EditorManager(EditorAdapter ajdeEditor) {
-       if (ajdeEditor instanceof BasicEditor) {
-               this.basicEditor = (BasicEditor)ajdeEditor;
-               editors.add(basicEditor);
-               editors_box.add(basicEditor.getPanel());
-               editor_panel = new JPanel(new BorderLayout());
-               editor_panel.add(editors_box, BorderLayout.CENTER);     
-       } else {
-               editors.add(ajdeEditor);
-               this.editor = ajdeEditor;               
-       }
-    }
-
-    public void addListener(EditorListener editorListener) {
-        editorListeners.add(editorListener);
-    }
-
-    public void removeListener(EditorListener editorListener) {
-        editorListeners.remove(editorListener);
-    }
-
-    public void notifyCurrentFileChanged(String filePath) {
-        for (Iterator it = editorListeners.iterator(); it.hasNext(); ) {
-            ((EditorListener)it.next()).currentFileChanged(filePath);
-        }
-    }
-
-    public void addViewForSourceLine(final String filePath, final int lineNumber) {
-        if (basicEditor == null) return;
-        editors_box.remove(basicEditor.getPanel());
-        final BasicEditor newEditor = new BasicEditor();
-        editors.add(newEditor);
-        
-        Runnable update = new Runnable() {
-            public void run() {
-                editors_box.add(newEditor.getPanel());
-                newEditor.showSourceLine(filePath, lineNumber, true);
-                //AjdeUIManager.getDefault().getIdeUIAdapter().resetGUI();
-            }
-        };
-
-        if (SwingUtilities.isEventDispatchThread()) {
-            update.run(); 
-        } else {
-            try {
-                SwingUtilities.invokeAndWait(update);
-            } catch (Exception e) {
-                Ajde.getDefault().getErrorHandler().handleError("Could not add view for source line.", e);
-            }
-        }
-    }
-
-    public String getCurrFile() {
-       if (basicEditor != null) {
-               return basicEditor.getCurrFile();
-       } else {
-               return editor.getCurrFile();
-       }
-    }
-
-       
-       public void showSourceLine(ISourceLocation sourceLocation, boolean highlight) {
-               if (sourceLocation != null) {
-                       showSourceLine(
-                               sourceLocation.getSourceFile().getAbsolutePath(),
-                               sourceLocation.getLine(),
-                               highlight);     
-               }       
-       }
-
-    /**
-     * @todo    remove "instanceof AjdeManager" hack
-     */
-    public void showSourceLine(String filePath, int lineNumber, boolean highlight) {
-        if (editors.size() > 1) {
-            editors_box.removeAll();
-            editors_box.add(basicEditor.getPanel());
-            //AjdeUIManager.getDefault().getIdeUIAdapter().resetGUI();
-            editors.removeAllElements();
-            editors.add(basicEditor);
-        } 
-        
-        if (basicEditor != null) {
-               basicEditor.showSourceLine(filePath, lineNumber, highlight);
-        } else {
-               editor.showSourceLine(filePath, lineNumber, highlight);
-        }
-    }
-
-    public void pasteToCaretPos(String text) {
-        if (basicEditor != null) {
-               basicEditor.pasteToCaretPos(text);
-        } else {
-               editor.pasteToCaretPos(text);
-        }      
-    }
-
-    public void showSourcelineAnnotation(String filePath, int lineNumber, java.util.List items) {
-        editor.showSourcelineAnnotation(filePath, lineNumber, items);
-    }
-
-    public void saveContents() {
-        try {
-            for (Iterator it = editors.iterator(); it.hasNext(); ) {
-                ((EditorAdapter)it.next()).saveContents();
-            }
-        } catch (IOException ioe) {
-            Ajde.getDefault().getErrorHandler().handleError("Editor could not save the current file.", ioe);
-        }
-    }
-
-    public JPanel getEditorPanel() {
-        if (editor_panel != null) {
-            return editor_panel;
-        } else {
-            return basicEditor.getPanel();
-        }
-    }
-}
-
-
index 8415b6dfeeb0f360bdbdf69b5c803026444b910e..81d33f75c10cce5c321d6b28a36e717f7ebc75ff 100644 (file)
@@ -52,7 +52,7 @@ public class StructureModelUtil {
        public static Map getLinesToAspectMap(String sourceFilePath) {
 
                Map annotationsMap =
-                       StructureModelManager.INSTANCE.getInlineAnnotations(
+                       StructureModelManager.getDefault().getInlineAnnotations(
                                sourceFilePath,
                                true,
                                true);
index a6a13a522305cd9075ddb22e5d1813acca33cf79..ad2be9c79645fb961ab4585f040785a014b705ec 100644 (file)
@@ -50,10 +50,10 @@ public class StructureViewManager {
     public final StructureModelListener VIEW_LISTENER = new StructureModelListener() {
         public void modelUpdated(StructureModel model) {               
                Ajde.getDefault().logEvent("updating structure views: " + structureViews);
-               
-               if (defaultFileView != null) {
-                       defaultFileView.setSourceFile(Ajde.getDefault().getEditorManager().getCurrFile());
-               }
+//             
+//             if (defaultFileView != null) {
+//                     defaultFileView.setSourceFile(Ajde.getDefault().getEditorManager().getCurrFile());
+//             }
                
                for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
                        treeViewBuilder.buildView((StructureView)it.next(), (StructureModel)model);
@@ -67,7 +67,7 @@ public class StructureViewManager {
        public StructureViewManager(StructureViewNodeFactory nodeFactory) {
                treeViewBuilder = new TreeStructureViewBuilder(nodeFactory);
                                
-               StructureModelManager.INSTANCE.addListener(VIEW_LISTENER);                      
+               StructureModelManager.getDefault().addListener(VIEW_LISTENER);                  
        }
        
        public void fireNavigateBackAction(StructureView view) {
@@ -138,7 +138,7 @@ public class StructureViewManager {
                        if (defaultFileView.getSourceFile() != null
                                && !defaultFileView.getSourceFile().equals(newFilePath)) {
                                defaultFileView.setSourceFile(newFilePath);
-                               treeViewBuilder.buildView(defaultFileView, StructureModelManager.INSTANCE.getStructureModel());
+                               treeViewBuilder.buildView(defaultFileView, StructureModelManager.getDefault().getStructureModel());
                        }
                }
                   
@@ -206,7 +206,7 @@ public class StructureViewManager {
                if (properties == null) properties = DEFAULT_VIEW_PROPERTIES;
                FileStructureView view = new FileStructureView(properties);
                view.setSourceFile(sourceFilePath);
-               treeViewBuilder.buildView(view, StructureModelManager.INSTANCE.getStructureModel()); 
+               treeViewBuilder.buildView(view, StructureModelManager.getDefault().getStructureModel()); 
                structureViews.add(view);
                return view; 
        }
@@ -222,6 +222,10 @@ public class StructureViewManager {
                this.defaultFileView = defaultFileView;
        }
 
+       public FileStructureView getDefaultFileView() {
+               return defaultFileView;
+       }
+
        static {
                AVAILABLE_RELATIONS = new ArrayList();
         AVAILABLE_RELATIONS.add(AdviceAssociation.METHOD_CALL_SITE_RELATION);
@@ -242,6 +246,7 @@ public class StructureViewManager {
         DEFAULT_VIEW_PROPERTIES = new StructureViewProperties();
         DEFAULT_VIEW_PROPERTIES.setRelations(AVAILABLE_RELATIONS);
        }   
+
 }
 
 //             this.multiFileViewMode = multiFileViewMode;
index 6fe610e006ec4bda129687b80e0d71954e6b38b9..f7228aea2a9c4b8964413a7a77a0862c7ff29f33 100644 (file)
@@ -16,16 +16,8 @@ package org.aspectj.ajde.ui.swing;
 
 import java.awt.Frame;
 
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.BuildListener;
-import org.aspectj.ajde.BuildProgressMonitor;
-import org.aspectj.ajde.EditorAdapter;
-import org.aspectj.ajde.ErrorHandler;
-import org.aspectj.ajde.ProjectPropertiesAdapter;
-import org.aspectj.ajde.TaskListManager;
-import org.aspectj.ajde.ui.FileStructureView;
-import org.aspectj.ajde.ui.IdeUIAdapter;
-import org.aspectj.ajde.ui.UserPreferencesAdapter;
+import org.aspectj.ajde.*;
+import org.aspectj.ajde.ui.*;
 import org.aspectj.ajde.ui.internal.AjcBuildOptions;
 
 /**
@@ -45,7 +37,6 @@ public class AjdeUIManager {
        
        private OptionsFrame optionsFrame = null;
        private Frame rootFrame = null;
-       private StructureViewPanel fileStructurePanel = null;
 
        /**
         * Order of initialization is critical here.
@@ -57,8 +48,7 @@ public class AjdeUIManager {
                UserPreferencesAdapter userPreferencesAdapter,
                IdeUIAdapter ideUIAdapter,
                IconRegistry iconRegistry,
-               Frame rootFrame,
-               boolean useFileView) {
+               Frame rootFrame) {
                try {   
                        BuildProgressMonitor compileProgress = new DefaultBuildProgressMonitor(rootFrame);
                        ErrorHandler errorHandler = new AjdeErrorHandler();
@@ -82,15 +72,6 @@ public class AjdeUIManager {
                        Ajde.getDefault().getBuildManager().addListener(STATUS_TEXT_UPDATER);
                        //Ajde.getDefault().setConfigurationManager(configManager);     
                        
-                       if (useFileView) {
-                               FileStructureView structureView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(
-                               Ajde.getDefault().getEditorManager().getCurrFile(),
-                               Ajde.getDefault().getStructureViewManager().getDefaultViewProperties()
-                       );
-                       Ajde.getDefault().getStructureViewManager().setDefaultFileView(structureView);                  
-                               fileStructurePanel = new StructureViewPanel(structureView);
-                       }
-                       
                        viewManager = new BrowserViewManager();
                        optionsFrame = new OptionsFrame(iconRegistry);
                        
@@ -161,10 +142,6 @@ public class AjdeUIManager {
                return buildConfigEditor;
        }
 
-       public StructureViewPanel getFileStructurePanel() {
-               return fileStructurePanel;
-       }
-       
        public IconRegistry getIconRegistry() {
                return iconRegistry;
        }
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BasicEditor.java b/ajde/src/org/aspectj/ajde/ui/swing/BasicEditor.java
deleted file mode 100644 (file)
index 7d0a469..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/* *******************************************************************
- * 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.ui.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Font;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.swing.JEditorPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.DefaultHighlighter;
-
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.EditorAdapter;
-import org.aspectj.bridge.ISourceLocation;
-
-/**
- * Bare-bones editor implementation used when the framework is being used
- * standalone.
- *
- * @author Mik Kersten
- */
-public class BasicEditor implements EditorAdapter {
-
-       private String NO_FILE = "<no file selected>";
-    private String filePath = NO_FILE;
-    private JPanel editor_panel = new JPanel();
-
-    // @todo    get rid of these
-    private int currHighlightStart = 0;
-    private int currHighlightEnd = 0;
-
-    private BorderLayout borderLayout1 = new BorderLayout();
-    private JScrollPane jScrollPane1 = new JScrollPane();
-    private JEditorPane editorPane = new JEditorPane();
-
-    public BasicEditor() {
-        try {
-            editorPane.setEditable(true);
-            editorPane.setContentType("text/plain");
-            editorPane.setFont(new Font("Monospaced", 0, 11));
-            editor_panel.add(editorPane);
-            jbInit();
-        }
-        catch(Exception e) {
-            Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
-        }
-    }
-
-    public String getCurrFile() {
-               return filePath;
-    }
-
-    public void showSourceLine(ISourceLocation sourceLocation, boolean highlight) {
-               showSourceLine(sourceLocation.getSourceFile().getAbsolutePath(), sourceLocation.getLine(), highlight);
-       }
-
-    public void showSourceLine(int lineNumber, boolean highlight) {
-        showSourceLine(filePath, lineNumber, highlight);
-    }
-
-    public void pasteToCaretPos(String text) {
-        if (currHighlightEnd < 1) return;
-        String contents = editorPane.getText();
-        String pasted = contents.substring(0, currHighlightEnd) +
-            text + contents.substring(currHighlightEnd, contents.length());
-        editorPane.setText(pasted);
-    }
-
-    public void showSourceLine(String filePath, int lineNumber, boolean highlight) {
-       //AjdeUIManager.getDefault().getIdeUIAdapter().resetEditor();
-        
-        String oldPath = this.filePath;
-        this.filePath = filePath;
-//        if (oldPath != filePath && !Ajde.INSTANCE.BROWSER_MANAGER.isGlobalMode()) {
-//            Ajde.INSTANCE.BROWSER_MANAGER.updateView();
-//        }
-
-//        Ajde.IDE_MANAGER.setEditorStatusText(filePath);
-
-        currHighlightStart = 0;
-        currHighlightEnd = 0;
-        editorPane.setText(readFile(filePath, lineNumber));
-        try {
-            editorPane.getHighlighter().addHighlight(currHighlightStart, currHighlightEnd, DefaultHighlighter.DefaultPainter);
-            editorPane.setCaretPosition(currHighlightStart);
-        } catch (BadLocationException ble) {
-            Ajde.getDefault().getErrorHandler().handleError("Could not highlight location.", ble);
-        }
-        Ajde.getDefault().getEditorManager().notifyCurrentFileChanged(filePath);
-    }
-
-    /**
-     * Not implemented.
-     */
-    public void showSourcelineAnnotation(String filePath, int lineNumber, java.util.List items) { }
-
-       public void addEditorViewForSourceLine(String filePath, int lineNumber) {
-               
-       }
-
-    public void saveContents() throws IOException {
-        if (filePath != NO_FILE && filePath != "" && editorPane.getText() != "") {
-            BufferedWriter writer = new BufferedWriter(new FileWriter(filePath));
-            writer.write(editorPane.getText());
-            writer.flush();
-        }
-    }
-
-    public JPanel getPanel() {
-        return editor_panel;
-    }
-
-    public void showSourceForFile(String filePath) { }
-
-    public void showSourceForLine(int lineNumber, boolean highlight) { }
-
-    public void showSourceForSourceLine(String filePath, int lineNumber, boolean highlight) { }
-
-    public String getCurrSourceFilePath() { return null; }
-
-    public void setBreakpointRequest(String filePath, int lineNumber, boolean isDeferred) { }
-
-    public void clearBreakpointRequest(String filePath, int lineNumber) { }
-
-    private String readFile(String filePath, int lineNumber) {
-        try {
-            URL url = ClassLoader.getSystemResource(filePath);
-            File file = new File(filePath);
-            if (!file.exists()) {
-                return "ERROR: file \"" + filePath + "\" does not exist.";
-            }
-            BufferedReader reader = new BufferedReader(new FileReader(file));
-            StringBuffer contents = new StringBuffer();
-            String line = reader.readLine();
-            int numChars = 0;
-            int numLines = 0;
-            while (line != null) {
-                numLines++;
-                if (numLines < lineNumber) {
-                    currHighlightStart += line.length()+1;
-                }
-                if (numLines == lineNumber) {
-                    currHighlightEnd = currHighlightStart + line.length();
-                }
-                contents.append(line);
-                contents.append('\n');
-                line = reader.readLine();
-            }
-            return contents.toString();
-        } catch (IOException ioe) {
-            return "ERROR: could not read file \"" + filePath + "\", make sure that you have mounted /project/aop on X:\\";
-        }
-    }
-
-    private void jbInit() throws Exception {
-        editor_panel.setFont(new java.awt.Font("DialogInput", 1, 12));
-        editor_panel.setLayout(borderLayout1);
-        editor_panel.add(jScrollPane1, BorderLayout.CENTER);
-        jScrollPane1.getViewport().add(editorPane, null);
-    }
-}
index a1798c125864dd380bff8b2533e4703f847c0669..2e21a363183e7cdd981f6398c557ca6769603f15 100644 (file)
 
 package org.aspectj.ajde.ui.swing;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Stack;
+import java.util.*;
 
 import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.ui.GlobalStructureView;
-import org.aspectj.ajde.ui.GlobalViewProperties;
-import org.aspectj.ajde.ui.StructureViewProperties;
-import org.aspectj.asm.AdviceAssociation;
-import org.aspectj.asm.InheritanceAssociation;
-import org.aspectj.asm.LinkNode;
-import org.aspectj.asm.ProgramElementNode;
-import org.aspectj.asm.StructureNode;
-import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.ajde.ui.*;
+import org.aspectj.asm.*;
 
 /**
  * Responsible for displaying and controlling the configuration and output of a
@@ -66,24 +57,6 @@ public class BrowserViewManager {
         return browserPanel;
     }
 
-    public void showSourcesNodes(java.util.List nodes) {
-        for (Iterator it = nodes.iterator(); it.hasNext(); ) {
-            ProgramElementNode currNode = null;
-            StructureNode structureNode = (StructureNode)it.next();
-            if (structureNode instanceof LinkNode) {
-                currNode = ((LinkNode)structureNode).getProgramElementNode();
-            } else {
-                currNode = (ProgramElementNode)structureNode;
-            }
-            ISourceLocation sourceLoc = currNode.getSourceLocation();
-            if (null != sourceLoc) {
-                Ajde.getDefault().getEditorManager().addViewForSourceLine(
-                    sourceLoc.getSourceFile().getAbsolutePath(),
-                    sourceLoc.getLine());
-            }
-        }
-    }
-
     public void extractAndInsertSignatures(java.util.List signatures, boolean calls) {
         PointcutWizard pointcutWizard = new PointcutWizard(signatures);
         pointcutWizard.setVisible(true);
index 2dbc95fa40041713191bee56353bc8b01ad6ed14..814d48e045022a3cb3dba44f951551a5f99ec5c1 100644 (file)
@@ -119,6 +119,25 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener {
             showSourcesItem.addActionListener(new AbstractAction() {
                 public void actionPerformed(ActionEvent e) {
                     //AjdeUIManager.getDefault().getViewManager().showSourcesNodes(signatures);
+                    // USED THE FOLLOWING FROM: BrowserViewManager:
+//                                     public void showSourcesNodes(java.util.List nodes) {
+//                                             for (Iterator it = nodes.iterator(); it.hasNext(); ) {
+//                                                     ProgramElementNode currNode = null;
+//                                                     StructureNode structureNode = (StructureNode)it.next();
+//                                                     if (structureNode instanceof LinkNode) {
+//                                                             currNode = ((LinkNode)structureNode).getProgramElementNode();
+//                                                     } else {
+//                                                             currNode = (ProgramElementNode)structureNode;
+//                                                     }
+//                                                     ISourceLocation sourceLoc = currNode.getSourceLocation();
+//                                                     if (null != sourceLoc) {
+//                                                             Ajde.getDefault().getEditorManager().addViewForSourceLine(
+//                                                                     sourceLoc.getSourceFile().getAbsolutePath(),
+//                                                                     sourceLoc.getLine());
+//                                                     }
+//                                             }
+//                                     }
+
                 }
             });
             popup.add(showSourcesItem);
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java b/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java
deleted file mode 100644 (file)
index 97904a5..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* *******************************************************************
- * 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.ui.swing;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Iterator;
-
-import javax.swing.AbstractAction;
-import javax.swing.Icon;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.ui.EditorManager;
-import org.aspectj.asm.ProgramElementNode;
-
-public class BuildConfigPopupMenu extends JPopupMenu {
-
-       public BuildConfigPopupMenu(final AbstractAction action) {
-               java.util.List configFiles = Ajde.getDefault().getProjectProperties().getBuildConfigFiles();
-               for (Iterator it = configFiles.iterator(); it.hasNext(); ) {
-               final String buildConfig = (String)it.next();
-               JMenuItem buildItem = new JMenuItem(buildConfig);
-               buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
-               buildItem.addActionListener(
-                       new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       Ajde.getDefault().getConfigurationManager().setActiveConfigFile(buildConfig);
-                        if (EditorManager.isShiftDown(e.getModifiers())) {
-                            Ajde.getDefault().getBuildManager().buildFresh();
-                        } else {
-                            Ajde.getDefault().getBuildManager().build();
-                        }
-                                       action.actionPerformed(e);
-                                       }
-                       });
-               buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(ProgramElementNode.Kind.FILE_LST).getIconResource());
-               this.add(buildItem);
-               }
-       }
-}
index 91d450ed14e4ce86653bc19e7a952b5208471e6a..045f361a367457747a737a2069b9e5eb168063e8 100644 (file)
 
 package org.aspectj.ajde.ui.swing;
 
-import java.awt.BorderLayout;
-import java.awt.Dimension;
+import java.awt.*;
 import java.awt.event.ActionEvent;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
 
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
+import javax.swing.*;
 
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.ui.GlobalViewProperties;
-import org.aspectj.ajde.ui.StructureViewProperties;
+import org.aspectj.ajde.ui.*;
 import org.aspectj.asm.InheritanceAssociation;
-import org.aspectj.asm.ProgramElementNode;
 
 /**
  * @author Mik Kersten
@@ -65,15 +53,17 @@ class PointcutWizard extends JFrame {
         ArrayList views = new ArrayList();
         views.add(StructureViewProperties.Hierarchy.INHERITANCE);
         typeTreeView = new BrowserViewPanel(AjdeUIManager.getDefault().getIconRegistry(), views, StructureViewProperties.Hierarchy.INHERITANCE);
-        typeTreeView.updateTree(Ajde.getDefault().getEditorManager().getCurrFile());
-        try {
-            jbInit();
-        }
-        catch(Exception e) {
-            Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
-        }
-        this.setSize(400, 400);
-        this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT)).getImage());
+        
+        throw new RuntimeException("unimplemented, can't get the current file");
+        //typeTreeView.updateTree(Ajde.getDefault().getEditorManager().getCurrFile());
+//        try {
+//            jbInit();
+//        }
+//        catch(Exception e) {
+//            Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
+//        }
+//        this.setSize(400, 400);
+//        this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT)).getImage());
     }
 
     private Map getViewProperties() {
@@ -143,8 +133,9 @@ class PointcutWizard extends JFrame {
     }
 
     private void ok_button_actionPerformed(ActionEvent e) {
-        Ajde.getDefault().getEditorManager().pasteToCaretPos(generatePcd());
-        this.dispose();
+               throw new RuntimeException("unimplemented, can't paste");
+//        Ajde.getDefault().getEditorManager().pasteToCaretPos(generatePcd());
+//        this.dispose();
     }
 
     private void cancel_button_actionPerformed(ActionEvent e) {
index 8bbb43fea0603afd2816f1a70b1908bbf0afa002..89ece89e3af18046972bdb54032c0a4fdd746dca 100644 (file)
@@ -102,7 +102,7 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer
                ProgramElementNode pNode = (ProgramElementNode)node.getStructureNode();
                treeManager.highlightNode(pNode);
                if (pNode.getSourceLocation() != null) {
-                       Ajde.getDefault().getEditorManager().showSourceLine(
+                       Ajde.getDefault().getEditorAdapter().showSourceLine(
                                pNode.getSourceLocation().getSourceFile().getAbsolutePath(),
                                pNode.getSourceLocation().getLine() + lineOffset,
                                true
index c26330ed9aca1ea6abafaf23dab00920d90e1c87..58d6c03d69e77c2333236453f735b6502d84dcdf 100644 (file)
@@ -18,7 +18,7 @@ import junit.framework.*;
 
 public class AjdeModuleTests extends TestCase {
 
-    public static Test suite() { 
+    public static TestSuite suite() { 
         TestSuite suite = new TestSuite(AjdeModuleTests.class.getName());
         suite.addTest(org.aspectj.ajde.AjdeTests.suite()); 
         suite.addTest(org.aspectj.ajde.internal.AjdeInternalTests.suite()); 
index 178d92efee44f03de1b88e02b62a96f123289d96..0506eb36d8d82cb1c52f47954a3e40779ef5a2a0 100644 (file)
@@ -13,7 +13,6 @@
 package org.aspectj.ajde;
 
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.List;
 
 /**
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java b/ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java
new file mode 100644 (file)
index 0000000..2dc4167
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Created on Jul 25, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.aspectj.ajde;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.aspectj.bridge.ISourceLocation;
+
+/**
+ * @author beatmik
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class NullIdeEditorAdapter implements EditorAdapter {
+
+       public void showSourceLine(
+               String filePath,
+               int lineNumber,
+               boolean highlight) {
+
+       }
+
+       public void showSourceLine(
+               ISourceLocation sourceLocation,
+               boolean highlight) {
+
+       }
+
+       public void showSourceLine(int lineNumber, boolean highlight) {
+
+       }
+
+       public String getCurrFile() {
+               return null;
+       }
+
+       public void saveContents() throws IOException {
+       }
+
+       public void pasteToCaretPos(String text) {
+
+       }
+
+
+       public void showSourcelineAnnotation(
+               String filePath,
+               int lineNumber,
+               List items) {
+
+       }
+
+}
index 71a50575ea49526461a938630232952c2584040a..c659dd2c8c05c76dff3bf54936fef591531081c1 100644 (file)
@@ -45,7 +45,7 @@ public class NullIdeManager {
                        UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(false);
                        ProjectPropertiesAdapter browserProjectProperties = new NullIdeProperties(testProjectPath);
                        taskListManager = new NullIdeTaskListManager();
-                       BasicEditor ajdeEditor = new BasicEditor();
+                       EditorAdapter ajdeEditor = new NullIdeEditorAdapter();
                        IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
                        JFrame nullFrame = new JFrame();
                        //configurationManager.setConfigFiles(getConfigFilesList(configFiles)); 
@@ -57,8 +57,7 @@ public class NullIdeManager {
                                preferencesAdapter,
                                uiAdapter,
                                new IconRegistry(),
-                               nullFrame,
-                               true);  
+                               nullFrame);     
                                
                        //Ajde.getDefault().enableLogging( System.out );
                } catch (Throwable t) {