Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /antelope/, /antelope/src/docs/, /antelope/src/docs/manual/, /antelope/src/ise/antelope/common/, /antelope/src/ise/antelope/plugin/

antelope
Discussion topic

" : "") + target_name ); + button = new JCheckBox( ( isPrivate( target ) ? "" : "" ) + target_name ); button.addActionListener( _cb_listener ); button.setBackground( _button_panel.getBackground() ); } else { - button = new JButton( (isPrivate(target) ? "" : "") + target_name ); + button = new JButton( ( isPrivate( target ) ? "" : "" ) + target_name ); button.addActionListener( _button_listener ); } button.setActionCommand( target_name ); @@ -1080,7 +1081,7 @@ /// this is the "recommended" way, but throws an NPE //ProjectHelper ph = ProjectHelper.getProjectHelper(); //ph.parse(p, build_file); - ProjectHelper.configureProject(p, build_file); + ProjectHelper.configureProject( p, build_file ); p.setProperty( "ant.file", build_file.getAbsolutePath() ); p.setProperty( "ant.version", Main.getAntVersion() ); @@ -1173,8 +1174,13 @@ } } + /** + * Determines if a target should be considered a "private" target. + * @return true if the target name contains a "." or starts with "-" or has an + * empty description. + */ private boolean isPrivate( Target target ) { - if (target == null) + if ( target == null ) return true; String target_name = target.getName(); if ( target_name.indexOf( "." ) > 0 ) { File [changed]: AntelopeProperties.java Url: http://antelope.tigris.org/source/browse/antelope/src/ise/antelope/common/AntelopeProperties.java?r1=1.3&r2=1.4 Delta lines: +8 -4 ------------------- --- AntelopeProperties.java 24 Feb 2004 06:18:14 -0000 1.3 +++ AntelopeProperties.java 31 Mar 2004 05:37:19 -0000 1.4 @@ -1,4 +1,4 @@ -// $Id: AntelopeProperties.java,v 1.3 2004/02/24 06:18:14 danson Exp $ +// $Id: AntelopeProperties.java,v 1.4 2004/03/31 05:37:19 danson Exp $ /* * Based on the Apache Software License, Version 1.1 @@ -71,7 +71,7 @@ * A panel to display Ant properties. * * @author Dale Anson - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ public class AntelopeProperties { /** @@ -166,7 +166,9 @@ model.setValueAt( key, i, 0 ); model.setValueAt( value, i, 1 ); } - catch ( Exception ignored ) {} + catch ( Exception ignored ) { + // bad key/value mapping will throw NPE, ignore + } } ref_table.addMouseListener( new TableCellViewer( ref_table ) ); @@ -185,7 +187,9 @@ user_model.setValueAt( key, i, 0 ); user_model.setValueAt( value, i, 1 ); } - catch ( Exception ignored ) {} + catch ( Exception ignored ) { + // bad key/value mapping will throw NPE, ignore + } } user_table.addMouseListener( new TableCellViewer( user_table ) ); File [changed]: SAXNodeHandler.java Url: http://antelope.tigris.org/source/browse/antelope/src/ise/antelope/common/SAXNodeHandler.java?r1=1.6&r2=1.7 Delta lines: +51 -9 -------------------- --- SAXNodeHandler.java 26 Mar 2004 21:50:53 -0000 1.6 +++ SAXNodeHandler.java 31 Mar 2004 05:37:19 -0000 1.7 @@ -6,6 +6,7 @@ import java.io.Reader; import java.io.StringReader; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Stack; import javax.swing.tree.DefaultTreeModel; @@ -25,7 +26,7 @@ * <import> task introduced in Ant 1.6. * * @author Dale Anson, danson@germane-software.com - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class SAXNodeHandler extends DefaultHandler { @@ -42,10 +43,12 @@ private boolean isImported = false; + private HashMap propertyFiles = null; + // need to update occassionally as new versions of Ant are released. // these lists are from Ant 1.6.1. - private List taskList = Arrays.asList( new String[]{"propertyfile", "importtypelib", "vsscheckin", "sql", "cvspass", "p4reopen", "csc", "dirname", "wlrun", "p4label", "p4revert", "replaceregexp", "get", "jjtree", "sleep", "jarlib-display", "dependset", "zip", "patch", "jspc", "style", "test", "tstamp", "unwar", "vsshistory", "icontract", "cvschangelog", "p4submit", "ccmcheckin", "p4change", "bzip2", "sync", "p4delete", "vssadd", "javadoc", "p4integrate", "translate", "signjar", "cclock", "chown", "vajload", "jarlib-available", "WsdlToDotnet", "buildnumber", "jpcovmerge", "ejbjar", "war", "rename", "sequential", "serverdeploy", "property", "subant", "move", "ildasm", "copydir", "cccheckin", "ccunlock", "wljspc", "fixcrlf", "sosget", "pathconvert", "record", "p4sync", "exec", "ccmklabel", "p4edit", "manifest", "maudit", "antlr", "netrexxc", "jpcovreport", "execon", "ccmcheckout", "ant", "xmlvalidate", "xslt", "p4resolve", "iplanet-ejbc", "ccmcheckintask", "gzip", "native2ascii", "ccrmtype", "starteam", "ear", "input", "presetdef", "rmic", "checksum", "mail", "loadfile", "vsscheckout", "stylebook", "soscheckin", "mimemail", "stlabel", "gunzip", "concat", "cab", "touch", "parallel", "splash", "antcall", "ccmkbl", "cccheckout", "typedef", "p4have", "filter", "xmlproperty", "import", "copy", "jsharpc", "symlink", "antstructure", "script", "ccmcreatetask", "rpm", "delete", "replace", "mmetrics", "attrib", "waitfor", "untar", "loadproperties", "available", "echoproperties", "chgrp", "vajexport", "bunzip2", "whichresource", "copyfile", "p4labelsync", "vsscreate", "macrodef", "ejbc", "unjar", "vbc", "wsdltodotnet", "mkdir", "condition", "cvs", "tempfile", "junitreport", "taskdef", "echo", "ccupdate", "java", "vsslabel", "renameext", "basename", "javadoc2", "tar", "vsscp", "vajimport", "p4fstat", "setproxy", "p4counter", "wlstop", "ilasm", "soscheckout", "apply", "ccuncheckout", "jarlib-resolve", "jlink", "cvstagdiff", "javacc", "chmod", "pvcs", "jarlib-manifest", "jar", "ccmklbtype", "sound", "scriptdef", "defaultexcludes", "mparse", "blgenclient", "uptodate", "jjdoc", "genkey", "javah", "ccmreconfigure", "fail", "unzip", "javac", "p4add", "jpcoverage", "soslabel", "depend", "vssget", "deltree", "ddcreator"} ); - private List typeList = Arrays.asList( new String[]{"patternset", "assertions", "propertyset", "filterset", "libfileset", "filterreader", "scriptfilter", "extension", "fileset", "dirset", "filelist", "filterchain", "path", "classfileset", "selector", "xmlcatalog", "description", "mapper", "zipfileset", "substitution", "extensionSet", "regexp"} ); + private List taskList = Arrays.asList( new String[] {"propertyfile", "importtypelib", "vsscheckin", "sql", "cvspass", "p4reopen", "csc", "dirname", "wlrun", "p4label", "p4revert", "replaceregexp", "get", "jjtree", "sleep", "jarlib-display", "dependset", "zip", "patch", "jspc", "style", "test", "tstamp", "unwar", "vsshistory", "icontract", "cvschangelog", "p4submit", "ccmcheckin", "p4change", "bzip2", "sync", "p4delete", "vssadd", "javadoc", "p4integrate", "translate", "signjar", "cclock", "chown", "vajload", "jarlib-available", "WsdlToDotnet", "buildnumber", "jpcovmerge", "ejbjar", "war", "rename", "sequential", "serverdeploy", "property", "subant", "move", "ildasm", "copydir", "cccheckin", "ccunlock", "wljspc", "fixcrlf", "sosget", "pathconvert", "record", "p4sync", "exec", "ccmklabel", "p4edit", "manifest", "maudit", "antlr", "netrexxc", "jpcovreport", "execon", "ccmcheckout", "ant", "xmlvalidate", "xslt", "p4resolve", "iplanet-ejbc", "ccmcheckintask", "gzip", "native2ascii", "ccrmtype", "starteam", "ear", "input", "presetdef", "rmic", "checksum", "mail", "loadfile", "vsscheckout", "stylebook", "soscheckin", "mimemail", "stlabel", "gunzip", "concat", "cab", "touch", "parallel", "splash", "antcall", "ccmkbl", "cccheckout", "typedef", "p4have", "filter", "xmlproperty", "import", "copy", "jsharpc", "symlink", "antstructure", "script", "ccmcreatetask", "rpm", "delete", "replace", "mmetrics", "attrib", "waitfor", "untar", "loadproperties", "available", "echoproperties", "chgrp", "vajexport", "bunzip2", "whichresource", "copyfile", "p4labelsync", "vsscreate", "macrodef", "ejbc", "unjar", "vbc", "wsdltodotnet", "mkdir", "condition", "cvs", "tempfile", "junitreport", "taskdef", "echo", "ccupdate", "java", "vsslabel", "renameext", "basename", "javadoc2", "tar", "vsscp", "vajimport", "p4fstat", "setproxy", "p4counter", "wlstop", "ilasm", "soscheckout", "apply", "ccuncheckout", "jarlib-resolve", "jlink", "cvstagdiff", "javacc", "chmod", "pvcs", "jarlib-manifest", "jar", "ccmklbtype", "sound", "scriptdef", "defaultexcludes", "mparse", "blgenclient", "uptodate", "jjdoc", "genkey", "javah", "ccmreconfigure", "fail", "unzip", "javac", "p4add", "jpcoverage", "soslabel", "depend", "vssget", "deltree", "ddcreator"} ); + private List typeList = Arrays.asList( new String[] {"patternset", "assertions", "propertyset", "filterset", "libfileset", "filterreader", "scriptfilter", "extension", "fileset", "dirset", "filelist", "filterchain", "path", "classfileset", "selector", "xmlcatalog", "description", "mapper", "zipfileset", "substitution", "extensionSet", "regexp"} ); /** Constructor */ @@ -122,7 +125,7 @@ } child.setFile( f ); } - else if ( infile != null ){ + else if ( infile != null ) { child.setFile( infile ); } @@ -168,11 +171,20 @@ } } + // maybe store some dependant property files + if ( qName.equals( "property" ) && child.getAttributeValue( "file" ) != null ) { + addPropertyFile( child, "file" ); + } + else if ( qName.equals( "loadproperties" ) && child.getAttributeValue( "srcfile" ) != null ) { + addPropertyFile( child, "srcfile" ); + } + + if ( stack.empty() ) { rootNode = child; } else { - SAXTreeNode parent = (SAXTreeNode)stack.peek(); + SAXTreeNode parent = ( SAXTreeNode ) stack.peek(); parent.add( child ); } stack.push( child ); @@ -264,6 +276,36 @@ node.setTask( true ); else if ( typeList.contains( qname ) ) node.setType( true ); + } + + /** + * Add a file and timestamp to the propertyFile hashmap. + */ + private void addPropertyFile( SAXTreeNode child, String attr_name ) { + if ( propertyFiles == null ) + propertyFiles = new HashMap(); + String filename = child.getAttributeValue( attr_name ); + File f = new File( filename ); + if ( !f.exists() ) { + if ( child.getFile() != null ) { + f = new File( child.getFile().getParentFile(), filename ); + } + } + if ( f.exists() ) + propertyFiles.put( f, new Long( f.lastModified() ) ); + } + + /** + * Property files are files that properties are loaded from, for example, from + * a property task with a file attribute or a loadproperties task. The + * propertyFile hashmap keeps track of those files and the time the property file + * was last modified. This can be used to determine if a build file should be + * reloaded. + * @return a hashmap containing a File as key and its last modified time + * as value as a Long. May be null. + */ + public HashMap getPropertyFiles() { + return propertyFiles; } } File [changed]: SAXPanel.java Url: http://antelope.tigris.org/source/browse/antelope/src/ise/antelope/common/SAXPanel.java?r1=1.8&r2=1.9 Delta lines: +39 -54 --------------------- --- SAXPanel.java 30 Mar 2004 06:23:13 -0000 1.8 +++ SAXPanel.java 31 Mar 2004 05:37:19 -0000 1.9 @@ -131,60 +131,41 @@ dialog.setLocation( GUIUtils.getBestAnchorPoint( dialog, p.x + me.getX(), p.y + me.getY() ) ); dialog.setVisible( true ); } + return ; + } + + // show an "open" popup for certain tasks that use property files + String filename = null; + if ( node.getName().equals( "property" ) ) { + filename = node.getAttributeValue( "file" ); } - else if ( node.getName().equals( "property" ) ) { - String filename = node.getAttributeValue( "file" ); - File ft = null; - if ( filename != null ) { - ft = new File( filename ); + else if ( node.getName().equals( "loadproperties" ) ) { + filename = node.getAttributeValue( "srcfile" ); + } + if ( filename == null ) + return ; + try { + File ft = new File( filename ); if ( !ft.exists() ) { File dir = node.getFile(); if ( dir == null ) return ; ft = new File( dir.getParentFile(), filename ); } - } - else { - return ; - } final File f = ft; - try { - FileReader fr = new FileReader( f ); - StringWriter sw = new StringWriter(); - ise.library.FileUtilities.copyToWriter( fr, sw ); - - JPanel panel = new JPanel( new BorderLayout() ); - JTextArea tp = new JTextArea( sw.toString() ); - tp.setEditable( false ); - panel.add( new JScrollPane( tp ) ); - - MouseAdapter m2 = new MouseAdapter() { - public void mouseClicked( MouseEvent me ) { - _helper.openFile( f ); - } - }; - tp.addMouseListener(m2); + JPopupMenu popup = new JPopupMenu(); + JMenuItem mi = new JMenuItem( "Open" ); + popup.add( mi ); - final JDialog dialog = new JDialog( GUIUtils.getRootJFrame( SAXPanel.this ), "Properties: " + f.toString(), true ); - dialog.getContentPane().add( panel, BorderLayout.CENTER ); - JButton close_btn = new JButton( "Close" ); - JPanel btn_panel = new JPanel(); - btn_panel.add( close_btn ); - dialog.getContentPane().add( btn_panel, BorderLayout.SOUTH ); - close_btn.addActionListener( new ActionListener() { + mi.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ae ) { - dialog.hide(); - dialog.dispose(); + _helper.openFile( f ); } } ); - dialog.pack(); - dialog.setSize( 300, 300 ); - java.awt.Point p = SAXPanel.this.getLocation(); - SwingUtilities.convertPointToScreen( p, SAXPanel.this ); - dialog.setLocation( GUIUtils.getBestAnchorPoint( dialog, p.x + me.getX(), p.y + me.getY() ) ); - dialog.setVisible( true ); + + GUIUtils.showPopupMenu( popup, SAXPanel.this, me.getX(), me.getY() ); } catch ( Exception e ) {} } @@ -192,8 +173,6 @@ } } } - - } ; tree.addMouseListener( ma ); } @@ -284,7 +263,7 @@ continue; // load the build file using the SAXNodeHandler, get a project node - SAXTreeNode ant_root = SAXTreeModel.load( build_file ); + SAXTreeNode ant_root = (SAXTreeNode)new SAXTreeModel(build_file).getRoot(); // get the target name, default is the default target in the build file String ant_target_name = null; @@ -421,7 +400,13 @@ return nodes; } - + /** + * @return true if any file tracked by getPropertyFiles is newer than when it + * was first looked at. + */ + public boolean shouldReload() { + return ((SAXTreeModel)tree.getModel()).shouldReload(); + } /** * @return true if the file is an Ant build file, false if not. File [changed]: SAXTreeModel.java Url: http://antelope.tigris.org/source/browse/antelope/src/ise/antelope/common/SAXTreeModel.java?r1=1.3&r2=1.4 Delta lines: +48 -10 --------------------- --- SAXTreeModel.java 25 Mar 2004 03:11:13 -0000 1.3 +++ SAXTreeModel.java 31 Mar 2004 05:37:19 -0000 1.4 @@ -6,6 +6,8 @@ import java.io.File; import java.io.FileReader; import java.io.Reader; +import java.util.HashMap; +import java.util.Iterator; import java.util.Stack; import org.xml.sax.InputSource; @@ -25,22 +27,28 @@ */ public class SAXTreeModel extends DefaultTreeModel { - private static File infile = null; + private File infile = null; + private HashMap propertyFiles = null; + /** + * Creates a tree model based on the given xml. + */ public SAXTreeModel( String xml ) { - super( load( xml ) ); + super( null ); + setRoot( load( xml ) ); } public SAXTreeModel( File xmlFile ) { - super( load( xmlFile ) ); + super( null ); + setRoot( load( xmlFile ) ); } - public static SAXTreeNode load( String xml ) { + public SAXTreeNode load( String xml ) { StringReader sr = new StringReader( xml ); return load( sr ); } - public static SAXTreeNode load( File xmlFile ) { + public SAXTreeNode load( File xmlFile ) { try { infile = xmlFile; FileReader fr = new FileReader( xmlFile ); @@ -53,20 +61,50 @@ } } - public static SAXTreeNode load( Reader reader ) { + public SAXTreeNode load( Reader reader ) { try { InputSource source = new InputSource( reader ); SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); - SAXNodeHandler handler = new SAXNodeHandler(infile); + SAXNodeHandler handler = new SAXNodeHandler( infile ); handler.setDocumentLocator( new LocatorImpl() ); parser.parse( source, handler ); + propertyFiles = handler.getPropertyFiles(); return handler.getRoot(); } catch ( Exception e ) { /// not so sure this one is noise... - throw new RuntimeException(e); + throw new RuntimeException( e ); ///return null; } } + /** + * Property files are files that properties are loaded from, for example, from + * a property task with a file attribute or a loadproperties task. The + * propertyFile hashmap keeps track of those files and the time the property file + * was last modified. This can be used to determine if a build file should be + * reloaded. + * @return a hashmap containing a File as key and its last modified time + * as value as a Long. May be null. + */ + public HashMap getPropertyFiles() { + return propertyFiles; + } + + /** + * @return true if any file tracked by getPropertyFiles is newer than when it + * was first looked at. + */ + public boolean shouldReload() { + if ( propertyFiles == null ) + return false; + Iterator it = propertyFiles.keySet().iterator(); + while ( it.hasNext() ) { + File f = ( File ) it.next(); + Long lastModified = ( Long ) propertyFiles.get( f ); + if ( lastModified != null && lastModified.longValue() != f.lastModified() ) + return true; + } + return false; + } } File [changed]: version.txt Url: http://antelope.tigris.org/source/browse/antelope/src/ise/antelope/common/version.txt?r1=1.21&r2=1.22 Delta lines: +2 -2 ------------------- --- version.txt 30 Mar 2004 06:23:13 -0000 1.21 +++ version.txt 31 Mar 2004 05:37:19 -0000 1.22 @@ -1,2 +1,2 @@ VERSION=3.0.7 -DATE=March 29 2004 \ No newline at end of file +DATE=March 30 2004 \ No newline at end of file Directory: /antelope/src/ise/antelope/plugin/ ============================================= File [changed]: AntelopePlugin.java Url: http://antelope.tigris.org/source/browse/antelope/src/ise/antelope/plugin/AntelopePlugin.java?r1=1.5&r2=1.6 Delta lines: +2 -3 ------------------- --- AntelopePlugin.java 30 Mar 2004 06:23:14 -0000 1.5 +++ AntelopePlugin.java 31 Mar 2004 05:37:19 -0000 1.6 @@ -1,4 +1,4 @@ -// $Id: AntelopePlugin.java,v 1.5 2004/03/30 06:23:14 danson Exp $ +// $Id: AntelopePlugin.java,v 1.6 2004/03/31 05:37:19 danson Exp $ /* * Based on the Apache Software License, Version 1.1 * @@ -72,7 +72,7 @@ /** * This is the AntelopePlugin. * - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ public class AntelopePlugin extends EBPlugin implements Constants { /** @@ -718,7 +718,6 @@ base_dir = bd.getParentFile().getAbsolutePath(); StringTokenizer st1 = new StringTokenizer( base_dir, File.separator ); StringTokenizer st2 = new StringTokenizer( destination, File.separator ); - StringTokenizer shorter = st1.countTokens() <= st2.countTokens() ? st1 : st2; String token1, token2 = ""; while ( st1.hasMoreTokens() ) { token1 = st1.nextToken(); --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@antelope.tigris.org For additional commands, e-mail: cvs-help@antelope.tigris.org

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

Messages

Show all messages in topic

CVS update: /antelope/, /antelope/src/docs/, /antelope/src/docs/manual/, /antelope/src/ise/antelope/common/, /antelope/src/ise/antelope/plugin/ danson Dale Anson 2004-03-30 21:37:22 PST
Messages per page: