Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /antelope/src/ise/antelope/app/, /antelope/src/ise/antelope/app/jedit/, /antelope/src/ise/antelope/common/

antelope
Discussion topic

Back to topic list

CVS update: /antelope/src/ise/antelope/app/, /antelope/src/ise/antelope/app/jedit/, /antelope/src/ise/antelope/common/

Author danson
Full name Dale Anson
Date 2004-03-24 19:11:15 PST
Message User: danson
Date: 04/03/24 19:11:15

Modified:
 /antelope/src/ise/antelope/app/
  Antelope.java
 /antelope/src/ise/an​telope/app/jedit/
  SyntaxDocument.java
 /antelope/src/ise/an​telope/common/
  SAXPanel.java, SAXTreeModel.java, version.txt

Log:
 fixed saving error when multiple files are opened via new edit panel.
 

File Changes:

Directory: /antelope/src/ise/antelope/app/
====================​====================​==

File [changed]: Antelope.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/Antelope.​java?r1=1.3&r2=1​.4
Delta lines: +10 -5
--------------------
--- Antelope.java 23 Mar 2004 06:42:20 -0000 1.3
+++ Antelope.java 25 Mar 2004 03:11:13 -0000 1.4
@@ -1,4 +1,4 @@
-// $Id: Antelope.java,v 1.3 2004/03/23 06:42:20 danson Exp $
+// $Id: Antelope.java,v 1.4 2004/03/25 03:11:13 danson Exp $
 
 /*
  * Based on the Apache Software License, Version 1.1
@@ -68,7 +68,7 @@
 /**
  * Main entry point for Antelope application.
  *
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
  */
 public class Antelope extends JFrame implements Constants, CommonHelper {
 
@@ -569,6 +569,7 @@
          FileUtilities.copyToWriter( reader, writer );
          TextAreaDefaults defaults = TextAreaDefaults.getDefaults();
          SyntaxDocument doc = defaults.document;
+ doc.putProperty(Synt​axDocument.FILE, build_file);
          doc.remove( 0, doc.getLength() );
          doc.insertString( 0, writer.toString(), null );
          _editor.setDocument( doc );
@@ -596,11 +597,15 @@
 
    /**
     * Saves the contents of the editor to the current build file from the
- * AntelopePanel.
+ * AntelopePanel. Whoa, Nelly! It is possible that the build file in the
+ * editor is NOT the build file open in the AntelopePanel!
     */
    private void saveBuildFile() {
-
- File build_file = _antelope_panel.getBuildFile();
+ // don't do this:
+ //File build_file = _antelope_panel.getBuildFile();
+ // instead, do this:
+ SyntaxDocument doc = (SyntaxDocument)_edi​tor.getDocument();
+ File build_file = (File)doc.getPropert​y(SyntaxDocument.FIL​E);
       if ( build_file == null )
          return ;
 

Directory: /antelope/src/ise/an​telope/app/jedit/
====================​====================​========

File [changed]: SyntaxDocument.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/jedit/Syn​taxDocument.java?r1=​1.1&r2=1.2
Delta lines: +143 -151
-----------------------
--- SyntaxDocument.java 16 Feb 2004 02:39:39 -0000 1.1
+++ SyntaxDocument.java 25 Mar 2004 03:11:13 -0000 1.2
@@ -1,11 +1,11 @@
 /*
- * SyntaxDocument.java - Document that can be tokenized
- * Copyright (C) 1999 Slava Pestov
- *
- * You may use and modify this package for any purpose. Redistribution is
- * permitted, in both source and binary form, provided that this notice
- * remains intact in all source distributions of this package.
- */
+* SyntaxDocument.java - Document that can be tokenized
+* Copyright (C) 1999 Slava Pestov
+*
+* You may use and modify this package for any purpose. Redistribution is
+* permitted, in both source and binary form, provided that this notice
+* remains intact in all source distributions of this package.
+*/
 
 package ise.antelope.app.jedit;
 
@@ -18,17 +18,20 @@
  * system.
  *
  * @author Slava Pestov
- * @version $Id: SyntaxDocument.java,v 1.1 2004/02/16 02:39:39 danson Exp $
+ * @version $Id: SyntaxDocument.java,v 1.2 2004/03/25 03:11:13 danson Exp $
+ */
+public class SyntaxDocument extends PlainDocument {
+ /**
+ * Key for storing the filename representing the contents of this document.
  */
-public class SyntaxDocument extends PlainDocument
-{
+ public static String FILE = "_file_";
+
     /**
      * Returns the token marker that is to be used to split lines
      * of this document up into tokens. May return null if this
      * document is not to be colorized.
      */
- public TokenMarker getTokenMarker()
- {
+ public TokenMarker getTokenMarker() {
         return tokenMarker;
     }
 
@@ -38,13 +41,12 @@
      * this is not supported for this type of document.
      * @param tm The new token marker
      */
- public void setTokenMarker(TokenMarker tm)
- {
+ public void setTokenMarker( TokenMarker tm ) {
         tokenMarker = tm;
- if(tm == null)
- return;
- tokenMarker.insertLi​nes(0,getDefaultRoot​Element()
- .getElementCount());
+ if ( tm == null )
+ return ;
+ tokenMarker.insertLines( 0, getDefaultRootElement()
+ .getElementCount() );
         tokenizeLines();
     }
 
@@ -53,9 +55,8 @@
      * marker. This should be called after the document is first
      * loaded.
      */
- public void tokenizeLines()
- {
- tokenizeLines(0,getD​efaultRootElement().​getElementCount());
+ public void tokenizeLines() {
+ tokenizeLines( 0, getDefaultRootElemen​t().getElementCount(​) );
     }
 
     /**
@@ -65,29 +66,25 @@
      * @param start The first line to parse
      * @param len The number of lines, after the first one to parse
      */
- public void tokenizeLines(int start, int len)
- {
- if(tokenMarker == null || !tokenMarker.support​sMultilineTokens())
- return;
+ public void tokenizeLines( int start, int len ) {
+ if ( tokenMarker == null || !tokenMarker.support​sMultilineTokens() )
+ return ;
 
         Segment lineSegment = new Segment();
         Element map = getDefaultRootElement();
 
         len += start;
 
- try
- {
- for(int i = start; i < len; i++)
- {
- Element lineElement = map.getElement(i);
+ try {
+ for ( int i = start; i < len; i++ ) {
+ Element lineElement = map.getElement( i );
                 int lineStart = lineElement.getStartOffset();
- getText(lineStart,li​neElement.getEndOffs​et()
- - lineStart - 1,lineSegment);
- tokenMarker.markToke​ns(lineSegment,i);
+ getText( lineStart, lineElement.getEndOffset()
+ - lineStart - 1, lineSegment );
+ tokenMarker.markTokens( lineSegment, i );
             }
         }
- catch(BadLocationException bl)
- {
+ catch ( BadLocationException bl ) {
             bl.printStackTrace();
         }
     }
@@ -115,9 +112,10 @@
      *
      * @since jEdit 2.2pre1
      */
- public void addUndoableEdit(UndoableEdit edit) {}
+ public void addUndoableEdit( UndoableEdit edit ) {}
 
     // protected members
+
     protected TokenMarker tokenMarker;
 
     /**
@@ -125,21 +123,18 @@
      * state immediately so that any event listeners get a
      * consistent token marker.
      */
- protected void fireInsertUpdate(DocumentEvent evt)
- {
- if(tokenMarker != null)
- {
+ protected void fireInsertUpdate( DocumentEvent evt ) {
+ if ( tokenMarker != null ) {
             DocumentEvent.ElementChange ch = evt.getChange(
- getDefaultRootElement());
- if(ch != null)
- {
- tokenMarker.insertLi​nes(ch.getIndex() + 1,
+ getDefaultRootElement() );
+ if ( ch != null ) {
+ tokenMarker.insertLines( ch.getIndex() + 1,
                     ch.getChildrenAdded().length -
- ch.getChildrenRemove​d().length);
+ ch.getChildrenRemoved().length );
             }
         }
 
- super.fireInsertUpdate(evt);
+ super.fireInsertUpdate( evt );
     }
     
     /**
@@ -147,20 +142,17 @@
      * state immediately so that any event listeners get a
      * consistent token marker.
      */
- protected void fireRemoveUpdate(DocumentEvent evt)
- {
- if(tokenMarker != null)
- {
+ protected void fireRemoveUpdate( DocumentEvent evt ) {
+ if ( tokenMarker != null ) {
             DocumentEvent.ElementChange ch = evt.getChange(
- getDefaultRootElement());
- if(ch != null)
- {
- tokenMarker.deleteLi​nes(ch.getIndex() + 1,
+ getDefaultRootElement() );
+ if ( ch != null ) {
+ tokenMarker.deleteLines( ch.getIndex() + 1,
                     ch.getChildrenRemoved().length -
- ch.getChildrenAdded().length);
+ ch.getChildrenAdded().length );
             }
         }
 
- super.fireRemoveUpdate(evt);
+ super.fireRemoveUpdate( evt );
     }
 }

Directory: /antelope/src/ise/an​telope/common/
====================​====================​=====

File [changed]: SAXPanel.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/common/SAXPan​el.java?r1=1.5&r​2=1.6
Delta lines: +78 -51
---------------------
--- SAXPanel.java 24 Mar 2004 04:38:13 -0000 1.5
+++ SAXPanel.java 25 Mar 2004 03:11:13 -0000 1.6
@@ -100,10 +100,9 @@
                            Object object = path.getLastPathComponent();
                            if ( object instanceof SAXTreeNode ) {
                               SAXTreeNode node = ( SAXTreeNode ) object;
- TreeModel tm = getDependencyModel( node );
+ TreeModel tm = SAXPanel.this.getDep​endencyModel( node, (SAXTreeNode)node.getRoot() );
                               if ( tm != null ) {
                                  JPanel panel = new JPanel( new BorderLayout() );
- panel.add( new JLabel( "Dependency Tree" ), BorderLayout.NORTH );
                                  JTree dt = new JTree( tm );
                                  dt.addMouseListener( this );
                                  dt.setCellRenderer( new SAXTreeCellRenderer() );
@@ -111,9 +110,21 @@
                                     dt.expandRow( i );
                                  }
                                  panel.add( new JScrollPane( dt ) );
- JPopupMenu pm = new JPopupMenu();
- pm.add( panel );
- GUIUtils.showPopupMenu( pm, SAXPanel.this, me.getX(), me.getY() );
+ final JDialog dialog = new JDialog(GUIUtils.get​RootJFrame(SAXPanel.​this), "Dependency Tree", true);
+ dialog.getContentPan​e().add(panel, BorderLayout.CENTER);
+ dialog.setLocation(new java.awt.Point(me.getX(), me.getY()));
+ JButton close_btn = new JButton("Close");
+ JPanel btn_panel = new JPanel();
+ btn_panel.add(close_btn);
+ dialog.getContentPan​e().add(btn_panel, BorderLayout.SOUTH);
+ close_btn.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent ae) {
+ dialog.hide();
+ dialog.dispose();
+ }
+ });
+ dialog.pack();
+ dialog.setVisible(true);
                               }
                            }
                         }
@@ -141,31 +152,31 @@
     */
    public TreeModel getDependencyModel( String target_name ) {
       SAXTreeNode initial_target = getTargetNode( target_name, ( SAXTreeNode ) tree.getModel().getRoot() );
- return getDependencyModel( initial_target );
+ return getDependencyModel( initial_target, ( SAXTreeNode ) tree.getModel().getRoot() );
    }
 
    /**
     * @return a TreeModel representing the dependency tree of the given
     * target. Returns null if the target is not found.
     */
- public TreeModel getDependencyModel( SAXTreeNode node ) {
+ public TreeModel getDependencyModel( SAXTreeNode node, SAXTreeNode tree_root ) {
       if ( node == null )
          return null;
- SAXTreeNode root = (SAXTreeNode)node.clone();//new SAXTreeNode( node.getName(), node.getLocation(), node.getAttributes() );
+ SAXTreeNode root = ( SAXTreeNode ) node.clone(); //new SAXTreeNode( node.getName(), node.getLocation(), node.getAttributes() );
       root.setFile( node.getFile() );
- addDependentTargetNodes( root );
- addCalledTargetNodes( node, root );
+ addDependentTargetNodes( root, tree_root );
+ addCalledTargetNodes( node, root, tree_root );
       return new DefaultTreeModel( root );
    }
 
- private void addCalledTargetNodes( SAXTreeNode src, SAXTreeNode dest ) {
- SAXTreeNode[] called_targets = getCalledTargetNodes(src);
- if (called_targets.length > 0) {
+ private void addCalledTargetNodes( SAXTreeNode src, SAXTreeNode dest, SAXTreeNode tree_root ) {
+ SAXTreeNode[] called_targets = getCalledTargetNodes( src, tree_root );
+ if ( called_targets.length > 0 ) {
          SAXTreeNode called_root = new SAXTreeNode( "Calls", dest.getLocation(), null, dest.getFile() );
- for (int i = 0; i < called_targets.length; i++) {
- called_root.add(call​ed_targets[i]);
+ for ( int i = 0; i < called_targets.length; i++ ) {
+ called_root.add( called_targets[ i ] );
          }
- dest.add(called_root);
+ dest.add( called_root );
       }
    }
 
@@ -174,19 +185,19 @@
     * @return an array of child nodes representing ant and/or antcall tasks.
     * The array may be empty, but won't be null.
     */
- private SAXTreeNode[] getCalledTargetNodes( SAXTreeNode node ) {
+ private SAXTreeNode[] getCalledTargetNodes( SAXTreeNode node, SAXTreeNode tree_root ) {
       int child_count = node.getChildCount();
       ArrayList children = new ArrayList();
       for ( int i = 0; i < child_count; i++ ) {
          SAXTreeNode child_node = ( SAXTreeNode ) node.getChildAt( i );
          String child_name = child_node.getName();
- if ( child_name.equals( "antcall" ) || child_name.equals("call") || child_name.equals("runtarget") || child_name.equals("a​ntcallback")) {
             Attributes attrs = child_node.getAttributes();
+ if ( child_name.equals( "antcall" ) || child_name.equals( "call" ) || child_name.equals( "runtarget" ) || child_name.equals( "antcallback" ) ) {
             int index = attrs.getIndex( "target" );
             if ( index == -1 )
                continue;
             String called_target = attrs.getValue( "target" );
- SAXTreeNode called_node = getTargetNode( called_target, ( SAXTreeNode ) tree.getModel().getRoot() );
+ SAXTreeNode called_node = getTargetNode( called_target, tree_root );
             if ( called_node != null ) {
                called_node.setCalled( true );
                children.add( called_node );
@@ -195,45 +206,61 @@
          if ( child_name.equals( "ant" ) ) {
             // get the build file name, default is build.xml
             String antfile = "build.xml";
- int index = attrs.getIndex("antfile");
- if (index > -1)
- antfile = attrs.getValue("antfile");
+ int index = attrs.getIndex( "antfile" );
+ if ( index > -1 )
+ antfile = attrs.getValue( "antfile" );
             
             // get the directory, default is the basedir of the current project
- String dir = node.getFile() != null ? node.getFile().getPa​rent().getAbsolutePa​th() : "";
- index = attrs.getIndex("dir");
- if (index > -1)
- dir = attrs.getValue("dir");
+ String dir = node.getFile() != null ? node.getFile().getParent() : "";
+ index = attrs.getIndex( "dir" );
+ if ( index > -1 )
+ dir = attrs.getValue( "dir" );
             
             // make sure the build file exists
- File build_file = new File(dir, antfile);
- if (!build_file.exists())
+ File build_file = new File( dir, antfile );
+ if ( !build_file.exists() )
                continue;
             
             // load the build file using the SAXNodeHandler, get a project node
+ SAXTreeNode ant_root = SAXTreeModel.load( build_file );
             
             // get the target name, default is the default target in the build file
+ String ant_target_name = null;
+ index = attrs.getIndex( "target" );
+ if ( index > -1 )
+ ant_target_name = attrs.getValue( "target" );
+ else {
+ Attributes ant_attrs = ant_root.getAttributes();
+ index = ant_attrs.getIndex( "default" );
+ if ( index > -1 )
+ ant_target_name = ant_attrs.getValue( "default" );
+ }
+ if ( ant_target_name == null )
+ continue;
             
             // get the target dependencies and called targets
-
- // add some nodes
+ SAXTreeNode ant_target = getTargetNode( ant_target_name, ant_root );
+ SAXTreeNode ant_target_copy = ( SAXTreeNode ) ant_target.clone(); //new SAXTreeNode( node.getName(), node.getLocation(), node.getAttributes() );
+ addDependentTargetNodes( ant_target_copy, tree_root );
+ addCalledTargetNodes( ant_target, ant_target_copy, tree_root );
+ children.add( ant_target_copy );
          }
       }
- SAXTreeNode[] nodes = new SAXTreeNode[children.size()];
+ SAXTreeNode[] nodes = new SAXTreeNode[ children.size() ];
       Iterator it = children.iterator();
- for (int i = 0; it.hasNext(); i++) {
- nodes[i] = (SAXTreeNode)it.next();
+ for ( int i = 0; it.hasNext(); i++ ) {
+ nodes[ i ] = ( SAXTreeNode ) it.next();
       }
       return nodes;
    }
 
- private void addDependentTargetNodes( SAXTreeNode node ) {
+ private void addDependentTargetNodes( SAXTreeNode node, SAXTreeNode tree_root ) {
       SAXTreeNode depends_root = new SAXTreeNode( "Depends on", node.getLocation(), null, node.getFile() );
- SAXTreeNode[] depends = getDependentTargetNodes( node );
+ SAXTreeNode[] depends = getDependentTargetNodes( node, tree_root );
       for ( int i = 0; i < depends.length; i++ ) {
          if ( depends[ i ] != null ) {
             depends_root.add( depends[ i ] );
- //addDependentTargetNodes( depends[ i ] );
+ //addDependentTargetNodes( depends[ i ], tree_root );
          }
       }
       if ( depends_root.getChildCount() > 0 )
@@ -249,14 +276,14 @@
     * null if no target with that name is found. Note that in the case of
     * duplicate target names, the first one found will be returned.
     */
- private SAXTreeNode getTargetNode( String target_name, SAXTreeNode root ) {
+ private SAXTreeNode getTargetNode( String target_name, SAXTreeNode tree_root ) {
       if ( target_name == null )
          return null;
       try {
- int child_count = root.getChildCount( );
+ int child_count = tree_root.getChildCount( );
          SAXTreeNode candidate = null;
          for ( int i = 0; i < child_count; i++ ) {
- SAXTreeNode node = ( SAXTreeNode ) root.getChildAt( i );
+ SAXTreeNode node = ( SAXTreeNode ) tree_root.getChildAt( i );
 
             // check targets in imported projects
             if ( node.getName().equals( "project" ) && candidate == null ) {
@@ -277,7 +304,7 @@
                      if ( target_name.startsWith( subproject_name ) ) {
                         String tn = target_name.substring( subproject_name.length() + 1 ); // +1 for the dot
                         if ( tn.equals( name ) ) {
- candidate = (SAXTreeNode)sub_node.clone();
+ candidate = ( SAXTreeNode ) sub_node.clone();
                            candidate.setImported( sub_node.isImported() );
                         }
                      }
@@ -294,9 +321,9 @@
                continue;
             String name = attrs.getValue( index );
             if ( target_name.equals( name ) ) {
- candidate = (SAXTreeNode)node.clone();
- addDependentTargetNo​des(candidate);
- addCalledTargetNodes(node, candidate);
+ candidate = ( SAXTreeNode ) node.clone();
+ addDependentTargetNodes( candidate, tree_root );
+ addCalledTargetNodes( node, candidate, tree_root );
                return candidate;
             }
          }
@@ -314,7 +341,7 @@
     * @return an array of tree nodes that represent dependency targets. This
     * array may be empty.
     */
- private SAXTreeNode[] getDependentTargetNodes( SAXTreeNode target_node ) {
+ private SAXTreeNode[] getDependentTargetNodes( SAXTreeNode target_node, SAXTreeNode tree_root ) {
       Attributes attrs = target_node.getAttributes();
       int index = attrs.getIndex( "depends" );
       if ( index == -1 )
@@ -326,7 +353,7 @@
          return new SAXTreeNode[ 0 ];
       SAXTreeNode[] nodes = new SAXTreeNode[ size ];
       for ( int i = 0; st.hasMoreTokens(); i++ ) {
- SAXTreeNode node = getTargetNode( st.nextToken().trim(), ( SAXTreeNode ) tree.getModel().getRoot() );
+ SAXTreeNode node = getTargetNode( st.nextToken().trim(), tree_root );
          nodes[ i ] = node;
       }
       return nodes;

File [changed]: SAXTreeModel.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/common/SAXTre​eModel.java?r1=1.2​&r2=1.3
Delta lines: +5 -5
-------------------
--- SAXTreeModel.java 22 Mar 2004 23:40:36 -0000 1.2
+++ SAXTreeModel.java 25 Mar 2004 03:11:13 -0000 1.3
@@ -35,12 +35,12 @@
       super( load( xmlFile ) );
    }
 
- private static SAXTreeNode load( String xml ) {
+ public static SAXTreeNode load( String xml ) {
       StringReader sr = new StringReader( xml );
       return load( sr );
    }
 
- private static SAXTreeNode load( File xmlFile ) {
+ public static SAXTreeNode load( File xmlFile ) {
       try {
          infile = xmlFile;
          FileReader fr = new FileReader( xmlFile );
@@ -53,7 +53,7 @@
       }
    }
 
- private static SAXTreeNode load( Reader reader ) {
+ public static SAXTreeNode load( Reader reader ) {
       try {
          InputSource source = new InputSource( reader );
          SAXParser parser = SAXParserFactory.new​Instance().newSAXPar​ser();
@@ -64,8 +64,8 @@
       }
       catch ( Exception e ) {
          /// not so sure this one is noise...
- ///throw new RuntimeException(e);
- return null;
+ throw new RuntimeException(e);
+ ///return null;
       }
    }
    

File [changed]: version.txt
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/common/versio​n.txt?r1=1.17&r2​=1.18
Delta lines: +1 -1
-------------------
--- version.txt 23 Mar 2004 16:28:10 -0000 1.17
+++ version.txt 25 Mar 2004 03:11:13 -0000 1.18
@@ -1,2 +1,2 @@
 VERSION=3.0.5
-DATE=March 23 2004
\ No newline at end of file
+DATE=March 24 2004
\ No newline at end of file




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@ante​lope.tigris.org
For additional commands, e-mail: cvs-help at antelope dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /antelope/src/ise/antelope/app/, /antelope/src/ise/antelope/app/jedit/, /antelope/src/ise/antelope/common/ danson Dale Anson 2004-03-24 19:11:15 PST
Messages per page: