Fixed maven project bug, partially cleared code for 6.0
authormikk@netbeans.org
Wed, 05 Dec 2007 16:19:14 +0000
changeset 2737df5f4f3b083e
parent 2736 f951b3102e11
child 2738 bac2b7ac1618
Fixed maven project bug, partially cleared code for 6.0
codecoverage/CoverageViewerApp/nbproject/genfiles.properties
codecoverage/CoverageViewerApp/src/META-INF/services/org.apache.tools.ant.module.spi.AntLogger
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/Bundle.properties
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/ProjectMenuAction.java
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/config/Config.java
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/config/ProjectPropertiesReader.java
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/CoverageAntLogger.java
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/CoverageUtils.java
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/NbModuleProjectCoveragePreparer.java
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/layer.xml
codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/utils/ProjectStructureUtils.java
     1.1 --- a/codecoverage/CoverageViewerApp/nbproject/genfiles.properties	Tue Dec 04 23:33:09 2007 +0000
     1.2 +++ b/codecoverage/CoverageViewerApp/nbproject/genfiles.properties	Wed Dec 05 16:19:14 2007 +0000
     1.3 @@ -4,7 +4,7 @@
     1.4  build.xml.data.CRC32=a2984bce
     1.5  >>>>>>> 1.3
     1.6  build.xml.script.CRC32=eb973d5b
     1.7 -build.xml.stylesheet.CRC32=05353c81
     1.8 +build.xml.stylesheet.CRC32=79c3b980
     1.9  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    1.10  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    1.11  <<<<<<< genfiles.properties
    1.12 @@ -13,4 +13,4 @@
    1.13  nbproject/build-impl.xml.data.CRC32=a2984bce
    1.14  >>>>>>> 1.3
    1.15  nbproject/build-impl.xml.script.CRC32=e53ce5cb
    1.16 -nbproject/build-impl.xml.stylesheet.CRC32=3f8b4615
    1.17 +nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
     2.1 --- a/codecoverage/CoverageViewerApp/src/META-INF/services/org.apache.tools.ant.module.spi.AntLogger	Tue Dec 04 23:33:09 2007 +0000
     2.2 +++ b/codecoverage/CoverageViewerApp/src/META-INF/services/org.apache.tools.ant.module.spi.AntLogger	Wed Dec 05 16:19:14 2007 +0000
     2.3 @@ -1,1 +1,1 @@
     2.4 -org.netbeans.modules.coverage.annotations.CoverageAntLogger
     2.5 \ No newline at end of file
     2.6 +org.netbeans.modules.coverage.instrumentation.CoverageAntLogger
     2.7 \ No newline at end of file
     3.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/Bundle.properties	Tue Dec 04 23:33:09 2007 +0000
     3.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/Bundle.properties	Wed Dec 05 16:19:14 2007 +0000
     3.3 @@ -1,6 +1,6 @@
     3.4  OpenIDE-Module-Name=Unit Tests Code Coverage Viewer
     3.5  OpenIDE-Module-Short-Description=Code Coverage Netbeans plugin for test coverage visualization
     3.6 -OpenIDE-Module-Long-Description=The Code Coverage Plugin is a Netbeans 5.0 (5.5) plugin that enhances the existing Netbeans functionality with new code coverage features. The plugin works as a transparent additional service that colors all java files according to the unit tests coverage information.With code Coverage plugin enabled user continues to work with his/her project in the usual way but can easily view the test coverage of the project classes. The code coverage plugin will update the code coverage data and refresh editors markup every time a unit test is executed for the project.Currently the Java Application, Java Library, Java Project with Existing Sources and Netbeans module projects are supported. 
     3.7 +OpenIDE-Module-Long-Description=The Code Coverage Plugin is a Netbeans 6.0 plugin that enhances the existing Netbeans functionality with new code coverage features. The plugin works as a transparent additional service that colors all java files according to the unit tests coverage information.With code Coverage plugin enabled user continues to work with his/her project in the usual way but can easily view the test coverage of the project classes. The code coverage plugin will update the code coverage data and refresh editors markup every time a unit test is executed for the project.Currently the Java Application, Java Library, Java Project with Existing Sources and Netbeans module projects are supported. 
     3.8  OpenIDE-Module-Display-Category=Tools
     3.9  ############################################
    3.10  ### menu items                           ###
    3.11 @@ -9,33 +9,11 @@
    3.12  # project menu items
    3.13  CTL_Project_CoverageActivityOn=Activate Coverage Collection
    3.14  CTL_Project_CoverageActivityOff=Deactivate Coverage Collection
    3.15 -CTL_Project_AnnotateTree=Markup Project Tree
    3.16 -CTL_Project_RemoveAllCoverageDecoration=Refresh Coverage Markup
    3.17 -# class menu items
    3.18  CTL_Class_MarkupCoverage=Refresh Coverage Markup
    3.19 -CTL_Class_RemoveCoverageDecoration=Clear Class Decoration
    3.20 -# editor menu items
    3.21 -CTL_Line_MarkupCoverage=Markup Selected Lines
    3.22 -CTL_Line_RemoveCoverageDecoration=Clear Selected Lines Decoration
    3.23 -
    3.24 -DLG_Class_Question_AnotherVersion_Title=Question - Show Results for Another Version of the File
    3.25 -DLG_Class_Question_AnotherVersion_Message=There are no Coverage Results your version of the file.\nWould you like to see the latest results for another file version?
    3.26 -
    3.27 -DLG_Lines_Question_AnotherVersion_Title=Question - Show Results for Another Version of the File
    3.28 -DLG_Lines_Question_AnotherVersion_Message=There are no Coverage Results for selected lines in your version of the file.\nWould you like to see the latest results for another file version?
    3.29 -
    3.30 -DLG_Question_CoverageModuleSetup_Title=Question - Switch Coverage module On
    3.31 -DLG_Question_CoverageModuleSetup_Message=It is necessary to switch Coverage Module On before using it.\n Would you like to make it now?\nOtherwise you can do it later using 'Setup Coverage Module' command in popup menu for your project.
    3.32  
    3.33  ############################################
    3.34  ### default coverage module setup values ###
    3.35  # Local storage setup values 
    3.36  PROP_coverage_coverageFile=coverage/coverage.emma
    3.37  PROP_coverage_templateFile=coverage/template.emma
    3.38 -# Connection to DB - is not used temporarily
    3.39 -PROP_coverage_dbUrl=jdbc\:mysql\://jseqe.sfbay.sun.com\:3306/coverage
    3.40 -PROP_coverage_dbUser=orion
    3.41 -PROP_coverage_dbPass=orion
    3.42 -PROP_coverage_dbDriver=org.gjt.mm.mysql.Driver
    3.43 -# default testrun ID. '-1' can be used for LATEST
    3.44 -PROP_coverage_testrunId=-1
    3.45 +
     4.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/ProjectMenuAction.java	Tue Dec 04 23:33:09 2007 +0000
     4.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/ProjectMenuAction.java	Wed Dec 05 16:19:14 2007 +0000
     4.3 @@ -38,7 +38,6 @@
     4.4   * Version 2 license, then the option applies only if the new code is
     4.5   * made subject to such option by the copyright holder.
     4.6   */
     4.7 -
     4.8  package org.netbeans.modules.coverage;
     4.9  
    4.10  import java.awt.event.ActionEvent;
    4.11 @@ -48,6 +47,7 @@
    4.12  import javax.swing.JMenuItem;
    4.13  import javax.swing.JSeparator;
    4.14  import org.netbeans.api.project.Project;
    4.15 +import org.netbeans.modules.coverage.config.Config;
    4.16  import org.netbeans.modules.coverage.utils.ModuleActivityModes;
    4.17  import org.netbeans.modules.coverage.utils.ProjectStructureUtils;
    4.18  import org.openide.awt.Actions;
    4.19 @@ -65,87 +65,108 @@
    4.20   * The action that holds the Coverage Plugin On/Off actions
    4.21   * The action is attached to the project node
    4.22   */
    4.23 -public final class ProjectMenuAction extends CookieAction  implements ContextAwareAction  {
    4.24 +public final class ProjectMenuAction extends CookieAction implements ContextAwareAction {
    4.25 +
    4.26      private static final String name = NbBundle.getMessage(ProjectMenuAction.class, "CTL_Coverage_Menu");
    4.27 +
    4.28 +    
    4.29      
    4.30      protected void performAction(Node[] activatedNodes) {
    4.31 -        // do nothing, this is a popup menu
    4.32 +    // do nothing, this is a popup menu
    4.33      }
    4.34 +
    4.35      public Action createContextAwareInstance(Lookup actionContext) {
    4.36          return new ProjectContextAwareMenuAction(actionContext);
    4.37      }
    4.38 -    
    4.39 -    
    4.40 +
    4.41      protected int mode() {
    4.42          return CookieAction.MODE_EXACTLY_ONE;
    4.43      }
    4.44      
    4.45 +    @Override
    4.46 +    protected boolean enable(Node[] activatedNodes){
    4.47 +        return false;
    4.48 +    }
    4.49 +
    4.50      public String getName() {
    4.51          return name;
    4.52 -        
    4.53      }
    4.54 -    
    4.55 +
    4.56      public String iconResource() {
    4.57          return null;
    4.58      }
    4.59 -    
    4.60 +
    4.61      public HelpCtx getHelpCtx() {
    4.62          return HelpCtx.DEFAULT_HELP;
    4.63      }
    4.64 -    
    4.65 +
    4.66      protected Class[] cookieClasses() {
    4.67 -        return new Class[] {
    4.68 +        
    4.69 +        return new Class[]{
    4.70              Project.class
    4.71          };
    4.72      }
    4.73 -    
    4.74 +
    4.75      protected boolean asynchronous() {
    4.76          return false;
    4.77      }
    4.78 -    
    4.79 -    
    4.80 +
    4.81      private static class ProjectContextAwareMenuAction extends AbstractAction implements Presenter.Popup {
    4.82 +
    4.83          private Lookup context;
    4.84 -        
    4.85 -        public ProjectContextAwareMenuAction(Lookup actionContext){
    4.86 +
    4.87 +        public ProjectContextAwareMenuAction(Lookup actionContext) {
    4.88              super(name);
    4.89              this.context = actionContext;
    4.90 -            
    4.91 +
    4.92          }
    4.93 -        
    4.94 +
    4.95 +       
    4.96          public JMenuItem getPopupPresenter() {
    4.97              return new ProjectMenuItems();
    4.98          }
    4.99 -        
   4.100 +
   4.101          public void actionPerformed(ActionEvent e) {
   4.102 -            // do nothing, this is a popup menu
   4.103 +        // do nothing, this is a popup menu
   4.104          }
   4.105 -        
   4.106 +
   4.107          private class ProjectMenuItems extends JMenu {
   4.108 +
   4.109              private boolean popupContructed;
   4.110              static final long serialVersionUID = 1L;
   4.111 -            
   4.112 +
   4.113              public ProjectMenuItems() {
   4.114                  Mnemonics.setLocalizedText(this, name);
   4.115 +                Node[] nodes = (Node[]) context.lookup(new Lookup.Template(Node.class)).allInstances().toArray(new Node[0]);
   4.116 +                if (nodes.length != 1){
   4.117 +                    this.setEnabled(false);
   4.118 +                }
   4.119 +
   4.120 +                Project project = ProjectStructureUtils.selectProjectByName(nodes[0].getDisplayName());
   4.121 +                if (!Config.isSupportedProject(project)){
   4.122 +                    setEnabled(false);
   4.123 +                }
   4.124 +                
   4.125 +
   4.126              }
   4.127 -            
   4.128 +
   4.129              /**
   4.130               * Initializes the sub actions and turns one of them off according to the coverage module
   4.131               * state.
   4.132               */
   4.133              public void setSelected(boolean selected) {
   4.134 -                
   4.135 +
   4.136                  if (selected && popupContructed == false) {
   4.137                      // lazy submenu construction
   4.138 -                    Action [] actions = getActions();
   4.139 -                    
   4.140 +                    Action[] actions = getActions();
   4.141 +
   4.142                      for (int i = 0; i < actions.length; i++) {
   4.143                          Action action = actions[i];
   4.144                          if (action == null) {
   4.145                              add(new JSeparator());    // workaround openide bug
   4.146                          } else {
   4.147                              JMenuItem item = new JMenuItem();
   4.148 -                            Actions.connect(item, actions[i],true);
   4.149 +                            Actions.connect(item, actions[i], true);
   4.150                              Mnemonics.setLocalizedText(item, item.getText());
   4.151                              add(item);
   4.152                          }
   4.153 @@ -153,39 +174,36 @@
   4.154                      popupContructed = true;
   4.155                  }
   4.156                  super.setSelected(selected);
   4.157 -                
   4.158 +
   4.159              }
   4.160 -            
   4.161 +
   4.162              /**
   4.163               * Initializes the sub actions (the actions that enable/disable coverage collection) according 
   4.164               *to the project state.
   4.165               * @return Returns the array of properly initialised subactions. The array is never null.
   4.166               */
   4.167 -            private Action[] getActions(){
   4.168 -                Node [] nodes = (Node[]) context.lookup(new Lookup.Template(Node.class)).allInstances().toArray(new Node[0]);
   4.169 -                Project project = ProjectStructureUtils.selectProjectByName(nodes[0].getName());
   4.170 -                
   4.171 +            private Action[] getActions() {
   4.172 +                Node[] nodes = (Node[]) context.lookup(new Lookup.Template(Node.class)).allInstances().toArray(new Node[0]);
   4.173 +
   4.174 +                Project project = ProjectStructureUtils.selectProjectByName(nodes[0].getDisplayName());
   4.175 +
   4.176                  Action _ProjectCoverageActivityOnAction = SystemAction.get(ProjectCoverageActivityOnAction.class);
   4.177                  Action _ProjectCoverageActivityOffAction = SystemAction.get(ProjectCoverageActivityOffAction.class);
   4.178 -                
   4.179 -                if(ModuleActivityModes.isModuleActive(project)){
   4.180 +
   4.181 +                if (ModuleActivityModes.isModuleActive(project)) {
   4.182                      _ProjectCoverageActivityOnAction.setEnabled(false);
   4.183                      _ProjectCoverageActivityOffAction.setEnabled(true);
   4.184                  } else {
   4.185                      _ProjectCoverageActivityOnAction.setEnabled(true);
   4.186                      _ProjectCoverageActivityOffAction.setEnabled(false);
   4.187                  }
   4.188 -                Action[] actions =  new Action[] {
   4.189 +                Action[] actions = new Action[]{
   4.190                      _ProjectCoverageActivityOnAction,
   4.191                      _ProjectCoverageActivityOffAction
   4.192                  };
   4.193                  return actions;
   4.194              }
   4.195 -            
   4.196 -            
   4.197          }
   4.198 -        
   4.199      }
   4.200 -    
   4.201  }
   4.202  
     5.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/config/Config.java	Tue Dec 04 23:33:09 2007 +0000
     5.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/config/Config.java	Wed Dec 05 16:19:14 2007 +0000
     5.3 @@ -193,4 +193,8 @@
     5.4          return getProjectType(project).equals(NB_MODULE);
     5.5      }
     5.6      
     5.7 +    public static boolean isSupportedProject(Project project){
     5.8 +        return (isNbModuleProject(project) || isJavaProject(project));
     5.9 +    }
    5.10 +    
    5.11  }
     6.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/config/ProjectPropertiesReader.java	Tue Dec 04 23:33:09 2007 +0000
     6.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/config/ProjectPropertiesReader.java	Wed Dec 05 16:19:14 2007 +0000
     6.3 @@ -115,6 +115,7 @@
     6.4          }
     6.5          return props;
     6.6      }
     6.7 +    
     6.8      /**
     6.9       *Stores project configuration properties to file
    6.10       *
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/CoverageAntLogger.java	Wed Dec 05 16:19:14 2007 +0000
     7.3 @@ -0,0 +1,190 @@
     7.4 +/*
     7.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     7.6 + *
     7.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     7.8 + *
     7.9 + * The contents of this file are subject to the terms of either the GNU
    7.10 + * General Public License Version 2 only ("GPL") or the Common
    7.11 + * Development and Distribution License("CDDL") (collectively, the
    7.12 + * "License"). You may not use this file except in compliance with the
    7.13 + * License. You can obtain a copy of the License at
    7.14 + * http://www.netbeans.org/cddl-gplv2.html
    7.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    7.16 + * specific language governing permissions and limitations under the
    7.17 + * License.  When distributing the software, include this License Header
    7.18 + * Notice in each file and include the License file at
    7.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    7.20 + * particular file as subject to the "Classpath" exception as provided
    7.21 + * by Sun in the GPL Version 2 section of the License file that
    7.22 + * accompanied this code. If applicable, add the following below the
    7.23 + * License Header, with the fields enclosed by brackets [] replaced by
    7.24 + * your own identifying information:
    7.25 + * "Portions Copyrighted [year] [name of copyright owner]"
    7.26 + *
    7.27 + * Contributor(s):
    7.28 + *
    7.29 + * The Original Software is NetBeans. The Initial Developer of the Original
    7.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    7.31 + * Microsystems, Inc. All Rights Reserved.
    7.32 + *
    7.33 + * If you wish your version of this file to be governed by only the CDDL
    7.34 + * or only the GPL Version 2, indicate your decision by adding
    7.35 + * "[Contributor] elects to include this software in this distribution
    7.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    7.37 + * single choice of license, a recipient has the option to distribute
    7.38 + * your version of this file under either the CDDL, the GPL Version 2 or
    7.39 + * to extend the choice of license to its licensees as provided above.
    7.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    7.41 + * Version 2 license, then the option applies only if the new code is
    7.42 + * made subject to such option by the copyright holder.
    7.43 + */
    7.44 +
    7.45 +package org.netbeans.modules.coverage.instrumentation;
    7.46 +
    7.47 +import java.io.File;
    7.48 +import java.util.HashMap;
    7.49 +import org.apache.tools.ant.module.spi.AntEvent;
    7.50 +import org.apache.tools.ant.module.spi.AntLogger;
    7.51 +import org.apache.tools.ant.module.spi.AntSession;
    7.52 +import org.netbeans.api.project.Project;
    7.53 +import org.netbeans.modules.coverage.actionperformers.RefreshProjectOpenedEditors;
    7.54 +import org.netbeans.modules.coverage.config.Config;
    7.55 +import org.netbeans.modules.coverage.instrumentation.AntSessionContext;
    7.56 +import org.netbeans.modules.coverage.instrumentation.CoverageUtils;
    7.57 +import org.netbeans.modules.coverage.utils.ModuleActivityModes;
    7.58 +
    7.59 +/**
    7.60 + * This class is used to track actions performed on the project and invokes some
    7.61 + * coverage module specific targets to generate coverage data when tests are executed
    7.62 + * TODO: This class will be moved to different package later
    7.63 + * @author mikk@netbeans.org, Alexander Pepin
    7.64 + */
    7.65 +public class CoverageAntLogger extends AntLogger{
    7.66 +    
    7.67 +    private StartTargetDispatcher startTarget = new StartTargetDispatcher();
    7.68 +    private FinishTargetDispatcher finishTarget = new FinishTargetDispatcher();
    7.69 +    /** Creates a new instance of CoverageAntLogger */
    7.70 +    public CoverageAntLogger() {
    7.71 +        initTargetsMap();
    7.72 +    }
    7.73 +    
    7.74 +        
    7.75 +    public boolean interestedInSession(AntSession session) {
    7.76 +        return true;
    7.77 +    }
    7.78 +    
    7.79 +    public boolean interestedInAllScripts(AntSession session){
    7.80 +        return true;
    7.81 +    }
    7.82 +    
    7.83 +    public boolean interestedInScript(File script, AntSession session) {
    7.84 +        return true;
    7.85 +    }
    7.86 +    
    7.87 +    public String[] interestedInTargets(AntSession session) {
    7.88 +        return AntLogger.ALL_TARGETS;
    7.89 +    }
    7.90 +    
    7.91 +    public String[] interestedInTasks(AntSession session) {
    7.92 +        return AntLogger.NO_TASKS;
    7.93 +    }
    7.94 +    
    7.95 +    public void targetStarted(AntEvent antEvent) {
    7.96 +        processAntEvent(antEvent, startTarget);
    7.97 +    }
    7.98 +    
    7.99 +    public void targetFinished(AntEvent antEvent) {
   7.100 +        processAntEvent(antEvent, finishTarget);
   7.101 +    }
   7.102 +    
   7.103 +    
   7.104 +   
   7.105 +    
   7.106 +    private void processAntEvent(AntEvent antEvent, TargetDispatcher dispatcher){
   7.107 +        String antTarget = antEvent.getTargetName();
   7.108 +        if (isAcceptedTarget(antTarget)){
   7.109 +            AntSessionContext context = new AntSessionContext(antEvent);
   7.110 +           
   7.111 +            Project project = context.getOwnerProject();
   7.112 +            if (project != null && ModuleActivityModes.isModuleActive(project)){
   7.113 +                //perform actions based on the target
   7.114 +                dispatcher.dispatch(targets.get(antTarget), context);                
   7.115 +            }
   7.116 +        }
   7.117 +    }
   7.118 +    
   7.119 +    class StartTargetDispatcher implements TargetDispatcher{
   7.120 +        public void dispatch(Targets target, AntSessionContext context){
   7.121 +            switch(target){
   7.122 +                //for java project
   7.123 +                case DO_TEST_RUN:
   7.124 +                case DO_TEST_RUN_SINGLE:
   7.125 +                    if(Config.isJavaProject(context.getOwnerProject())){
   7.126 +                        CoverageUtils.prepareJavaProject(context);
   7.127 +                    }
   7.128 +                    break;
   7.129 +                    //for nbmodule project
   7.130 +                case TEST_START:
   7.131 +                    if(Config.isNbModuleProject(context.getOwnerProject())){
   7.132 +                        CoverageUtils.prepareNbProject(context);
   7.133 +                    }
   7.134 +                    break;
   7.135 +            }
   7.136 +        }
   7.137 +    }
   7.138 +    
   7.139 +    class FinishTargetDispatcher implements TargetDispatcher{
   7.140 +        public void dispatch(Targets target, AntSessionContext context){
   7.141 +            switch(target){
   7.142 +
   7.143 +                //for java project
   7.144 +                case DO_TEST_RUN:
   7.145 +                case DO_TEST_RUN_SINGLE:
   7.146 +                    if(Config.isJavaProject(context.getOwnerProject())){
   7.147 +                        CoverageUtils.completeJavaProject(context);
   7.148 +                        RefreshProjectOpenedEditors.refreshProject(context.getOwnerProject());
   7.149 +                    }
   7.150 +                    break;
   7.151 +
   7.152 +                case TEST_END:
   7.153 +                    if(Config.isNbModuleProject(context.getOwnerProject())){
   7.154 +                        //return jar get coverage
   7.155 +                        CoverageUtils.completeNbProject(context);
   7.156 +                        RefreshProjectOpenedEditors.refreshProject(context.getOwnerProject());
   7.157 +                    }
   7.158 +                    break;
   7.159 +            }
   7.160 +        }
   7.161 +    }
   7.162 +    
   7.163 +    
   7.164 +    private HashMap<String, Targets> targets = new HashMap<String, Targets>();
   7.165 +    
   7.166 +    private void initTargetsMap(){
   7.167 +        for(Targets target: Targets.values()){
   7.168 +            targets.put(target.toString(), target);
   7.169 +        }
   7.170 +    }
   7.171 +    
   7.172 +    private boolean isAcceptedTarget(String target){
   7.173 +        return targets.containsKey(target);
   7.174 +    }
   7.175 +    
   7.176 +    //desired targets should be defined here
   7.177 +    enum Targets {//COV_RESTORE("cov-restore"),
   7.178 +        //java project targets
   7.179 +        DO_TEST_RUN("-do-test-run"),
   7.180 +        DO_TEST_RUN_SINGLE("-do-test-run-single"),
   7.181 +        TEST_START("test-dep-build"),
   7.182 +        TEST_END("test");
   7.183 +        
   7.184 +        private Targets(String name){targetName = name;}
   7.185 +        public String toString(){return targetName;}
   7.186 +        private String targetName;
   7.187 +    };
   7.188 +    
   7.189 +    interface TargetDispatcher{
   7.190 +        public void dispatch(Targets target, AntSessionContext context);
   7.191 +    }
   7.192 +}
   7.193 +
     8.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/CoverageUtils.java	Tue Dec 04 23:33:09 2007 +0000
     8.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/CoverageUtils.java	Wed Dec 05 16:19:14 2007 +0000
     8.3 @@ -57,9 +57,11 @@
     8.4  public class CoverageUtils {
     8.5      static final String fsRoot = System.getProperty("os.name").toLowerCase().startsWith("windows")? "" : "/";
     8.6      static private String emmaPath = "";
     8.7 +    
     8.8      public static void setEmmaPath(String pathToEmma){
     8.9          emmaPath = normalizePath(pathToEmma);
    8.10      }
    8.11 +    
    8.12      public static String getEmmaPath(){
    8.13          return emmaPath;
    8.14      }
    8.15 @@ -68,19 +70,11 @@
    8.16      public CoverageUtils() {
    8.17      }
    8.18      
    8.19 -    public static void instrumentJavaProject(AntSessionContext context){
    8.20 -    }
    8.21 -    
    8.22 -    public static void instrumentNbProject(AntSessionContext context){
    8.23 -        
    8.24 -    }
    8.25 -    
    8.26 +       
    8.27      public static void prepareJavaProject(AntSessionContext context){
    8.28          try{
    8.29              FileObject projectDir = context.getOwnerProject().getProjectDirectory();
    8.30              FileObject pluginDir = projectDir.getFileObject("coverage");
    8.31 -//            FileObject buildDir = projectDir.getFileObject("build");
    8.32 -//            FileObject classesDir = toFileObject(normalizePath(fsRoot+context.getProperty("build.classes.dir")));
    8.33              FileObject classesDir = projectDir.getFileObject(context.getProperty("build.classes.dir"));
    8.34              //copy classes to ${plugindir}/tmp
    8.35              FileObject tmp = recreateDir(pluginDir, "tmp");
    8.36 @@ -94,19 +88,19 @@
    8.37                  System.out.println("Project instrumentation failed");
    8.38                  return;
    8.39              }
    8.40 -
    8.41          }catch(IOException e){
    8.42              e.printStackTrace();
    8.43          }
    8.44      }
    8.45      
    8.46 +    
    8.47 +    
    8.48      public static void completeJavaProject(AntSessionContext context){
    8.49          try{
    8.50              FileObject projectDir = context.getOwnerProject().getProjectDirectory();
    8.51              FileObject pluginDir = projectDir.getFileObject("coverage");
    8.52              //copy ${plugindir}/tmp to ${builddir}/classes
    8.53              FileObject tmp = pluginDir.getFileObject("tmp");
    8.54 -//            FileObject classesDir = recreateDir(buildDir, "classes");
    8.55              FileObject classesDir = recreateDir(normalizePath(fsRoot+
    8.56                      projectDir.getFileObject(context.getProperty("build.classes.dir")).getPath()));
    8.57              copyDir(tmp, classesDir);
    8.58 @@ -115,7 +109,6 @@
    8.59              FileObject old_coverage = pluginDir.getFileObject("coverage", "emma");
    8.60              if(old_coverage != null)
    8.61                  old_coverage.delete();
    8.62 -//            FileObject coverage = projectDir.getFileObject("coverage", "ec");
    8.63              FileObject coverage = toFileObject(context.getProperty("work.dir")+"/coverage.ec");
    8.64              coverage.copy(pluginDir, "coverage", "emma");
    8.65              coverage.delete();
    8.66 @@ -174,6 +167,14 @@
    8.67              e.printStackTrace();
    8.68          }*/
    8.69          try{
    8.70 +            
    8.71 +            /*
    8.72 +             The current 'problem' with the implementation below is that I can not                
    8.73 +             restore the original jar after finishing running tests. Why? Because of some
    8.74 +             threading issue the instrumented jar is not released even after task.result() returns
    8.75 +             *
    8.76 +             TODO: recheck this!
    8.77 +            */
    8.78              FileObject projectDir = context.getOwnerProject().getProjectDirectory();
    8.79              FileObject pluginDir = projectDir.getFileObject("coverage");
    8.80              
    8.81 @@ -207,14 +208,13 @@
    8.82          File old_template = new File(outputPath+"/template.emma");
    8.83          if(old_template.exists())
    8.84              old_template.delete();
    8.85 -        //
    8.86 +        
    8.87          DataObject dataObj = DataObject.find(scriptToExecute);
    8.88          AntProjectCookie antCookie = (AntProjectCookie)dataObj.getCookie(AntProjectCookie.class);
    8.89          AntTargetExecutor.Env env = new AntTargetExecutor.Env();
    8.90          AntTargetExecutor executor = AntTargetExecutor.createTargetExecutor(env);
    8.91  
    8.92          Properties props = new Properties();
    8.93 -//            System.out.println("BUILDPATH:"+coverageDir.getPath());
    8.94          props.setProperty("jarfiles", sourcePath);
    8.95          props.setProperty("emma", emmaPath);
    8.96          props.setProperty("output.dir", outputPath);
    8.97 @@ -273,20 +273,5 @@
    8.98          return newPath;
    8.99      }
   8.100      
   8.101 -    static class DeleteThread implements Runnable {
   8.102 -        private FileObject fo;
   8.103 -        public DeleteThread(FileObject f){
   8.104 -            fo = f;
   8.105 -            
   8.106 -        }
   8.107 -        // This method is called when the thread runs
   8.108 -        public void run() {
   8.109 -            try{
   8.110 -                Thread.sleep(200);
   8.111 -                fo.delete();
   8.112 -            }catch(Exception e){
   8.113 -            }
   8.114 -        }
   8.115 -    }
   8.116      
   8.117  }
     9.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/NbModuleProjectCoveragePreparer.java	Tue Dec 04 23:33:09 2007 +0000
     9.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/instrumentation/NbModuleProjectCoveragePreparer.java	Wed Dec 05 16:19:14 2007 +0000
     9.3 @@ -43,7 +43,6 @@
     9.4  
     9.5  import org.netbeans.api.project.Project;
     9.6  import org.openide.filesystems.FileObject;
     9.7 -import org.openide.filesystems.Repository;
     9.8  
     9.9  /**
    9.10   *
    10.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/layer.xml	Tue Dec 04 23:33:09 2007 +0000
    10.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/layer.xml	Wed Dec 05 16:19:14 2007 +0000
    10.3 @@ -12,7 +12,8 @@
    10.4          <folder name="Tools">
    10.5              <!-- Project actions -->
    10.6              <file name="org-netbeans-modules-coverage-ProjectMenuAction.instance">
    10.7 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ProjectMenuAction"/>
    10.8 +                <!-- <attr name="instanceCreate" methodvalue="org.netbeans.modules.coverage.ProjectMenuAction.compile"/>-->
    10.9 +               <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ProjectMenuAction"/>
   10.10              </file>
   10.11              <file name="org-netbeans-modules-coverage-ProjectCoverageActivityOffAction.instance">
   10.12                  <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ProjectCoverageActivityOffAction"/>
   10.13 @@ -20,58 +21,10 @@
   10.14              <file name="org-netbeans-modules-coverage-ProjectCoverageActivityOnAction.instance">
   10.15                  <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ProjectCoverageActivityOnAction"/>
   10.16              </file>
   10.17 -            <file name="org-netbeans-modules-coverage-ProjectRefreshCoverageMarkupAction.instance">
   10.18 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ProjectRefreshCoverageMarkupAction"/>
   10.19 -            </file>
   10.20 -            
   10.21 -            
   10.22 -            <!-- Class actions -->            
   10.23 -            <!--
   10.24 -            <file name="org-netbeans-modules-coverage-ClassMenuAction.instance">
   10.25 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ClassMenuAction"/>
   10.26 -            </file>
   10.27 -            -->
   10.28 -            <!--
   10.29 -            <file name="org-netbeans-modules-coverage-ClassMarkupCoverageAction.instance">
   10.30 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ClassMarkupCoverageAction"/>
   10.31 -            </file>
   10.32 -            -->
   10.33 -            <!--
   10.34 -            <file name="org-netbeans-modules-coverage-ClassShowTestsAction.instance">
   10.35 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ClassShowTestsAction"/>
   10.36 -            </file>
   10.37 -            <file name="org-netbeans-modules-coverage-ClassRemoveAnnotationsAction.instance">
   10.38 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.ClassRemoveAnnotationsAction"/>
   10.39 -            </file>
   10.40 -            -->
   10.41 -            <!-- Line actions -->        
   10.42 -    <!--
   10.43 -            <file name="org-netbeans-modules-coverage-LineRemoveAnnotationsAction.instance">
   10.44 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.LineRemoveAnnotationsAction"/>
   10.45 -            </file>
   10.46 -            -->
   10.47 -            <!--
   10.48 -            <file name="org-netbeans-modules-coverage-LineMenuAction.instance">
   10.49 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.LineMenuAction"/>
   10.50 -            </file>
   10.51 -            -->
   10.52 -            <!--
   10.53 -            <file name="org-netbeans-modules-coverage-LineMarkupCoverageAction.instance">
   10.54 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.LineMarkupCoverageAction"/>
   10.55 -            </file>
   10.56 -            <file name="org-netbeans-modules-coverage-LineShowTestsAction.instance">
   10.57 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.LineShowTestsAction"/>
   10.58 -            </file>
   10.59 -            <file name="org-netbeans-modules-coverage-RunTestsForLinesAction.instance">
   10.60 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.coverage.RunTestsForLinesAction"/>
   10.61 -            </file>
   10.62 -            -->
   10.63 -
   10.64          </folder>
   10.65      </folder>
   10.66      <folder name="Projects">
   10.67 -        <folder name="Actions">
   10.68 -    
   10.69 +        <folder name="Actions">    
   10.70              <file name="Projects_separatorBefore.instance">
   10.71                  <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
   10.72              </file>
   10.73 @@ -82,8 +35,7 @@
   10.74              <attr name="org-netbeans-modules-coverage-ProjectMenuAction.shadow/Projects_separatorAfter.instance" boolvalue="true"/>
   10.75              <file name="Projects_separatorAfter.instance">
   10.76                  <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
   10.77 -            </file>
   10.78 -       
   10.79 +            </file>       
   10.80          </folder>
   10.81      </folder>
   10.82      <folder name="Editors">
   10.83 @@ -92,59 +44,14 @@
   10.84              <file name="annotation_complete.xml" url="resources/annotation_complete.xml"/>            
   10.85          </folder>
   10.86          <folder name="text">
   10.87 -            <folder name="x-java">
   10.88 -                <!--
   10.89 -                <folder name="Popup">
   10.90 -                    <attr name="org-openide-actions-PasteAction.instance/editor_separatorBefore.instance" boolvalue="true"/>
   10.91 -                    <file name="editor_separatorBefore.instance">
   10.92 -                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
   10.93 -                    </file>
   10.94 -                    <attr name="editor_separatorBefore.instance/org-netbeans-modules-coverage-LineMenuAction.shadow" boolvalue="true"/>
   10.95 -                    <file name="org-netbeans-modules-coverage-LineMenuAction.shadow">
   10.96 -                        <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-coverage-LineMenuAction.instance"/>
   10.97 -                    </file>
   10.98 -                </folder>
   10.99 -                -->
  10.100 +            <folder name="x-java">             
  10.101              </folder>
  10.102          </folder>
  10.103      </folder>
  10.104      <folder name="Loaders">
  10.105          <folder name="text">
  10.106              <folder name="x-java">
  10.107 -                <folder name="Actions">
  10.108 -                    <!--
  10.109 -                    <attr name="PropertiesAction.instance/node_separatorBefore.instance" boolvalue="true"/>
  10.110 -                    <file name="node_separatorBefore.instance">
  10.111 -                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
  10.112 -                    </file>
  10.113 -                    <attr name="node_separatorBefore.instance/org-netbeans-modules-coverage-ClassMarkupCoverageAction.shadow" boolvalue="true"/>
  10.114 -
  10.115 -                    <file name="org-netbeans-modules-coverage-ClassMarkupCoverageAction.shadow">
  10.116 -                        <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-coverage-ClassMarkupCoverageAction.instance"/>
  10.117 -                    </file>
  10.118 -                    <attr name="org-netbeans-modules-coverage-ClassMarkupCoverageAction.shadow/org-netbeans-modules-coverage-ClassRemoveAnnotationsAction.shadow" boolvalue="true"/>
  10.119 -                    <file name="org-netbeans-modules-coverage-ClassRemoveAnnotationsAction.shadow">
  10.120 -                        <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-coverage-ClassRemoveAnnotationsAction.instance"/>
  10.121 -                    </file>
  10.122 -                    <attr name="org-netbeans-modules-coverage-ClassRemoveAnnotationsAction.shadow/node_separatorAfter.instance" boolvalue="true"/>
  10.123 -                    <file name="node_separatorAfter.instance">
  10.124 -                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
  10.125 -                    </file>
  10.126 -                    -->
  10.127 -                    <!--
  10.128 -                    <attr name="PropertiesAction.instance/node_separatorBefore.instance" boolvalue="true"/>
  10.129 -                    <file name="node_separatorBefore.instance">
  10.130 -                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
  10.131 -                    </file>
  10.132 -                    <attr name="node_separatorBefore.instance/org-netbeans-modules-coverage-ClassMenuAction.shadow" boolvalue="true"/>
  10.133 -                    <file name="org-netbeans-modules-coverage-ClassMenuAction.shadow">
  10.134 -                        <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-coverage-ClassMenuAction.instance"/>
  10.135 -                    </file>
  10.136 -                    <attr name="org-netbeans-modules-coverage-ClassMenuAction.shadow/node_separatorAfter.instance" boolvalue="true"/>
  10.137 -                    <file name="node_separatorAfter.instance">
  10.138 -                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
  10.139 -                    </file>
  10.140 -                    -->
  10.141 +                <folder name="Actions">                    
  10.142                  </folder>
  10.143              </folder>
  10.144          </folder>
    11.1 --- a/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/utils/ProjectStructureUtils.java	Tue Dec 04 23:33:09 2007 +0000
    11.2 +++ b/codecoverage/CoverageViewerApp/src/org/netbeans/modules/coverage/utils/ProjectStructureUtils.java	Wed Dec 05 16:19:14 2007 +0000
    11.3 @@ -56,15 +56,18 @@
    11.4          Project project = null;
    11.5          Project[] projects = OpenProjects.getDefault ().getOpenProjects();
    11.6          ProjectInformation pInfo = null;
    11.7 +        System.err.println("PName:"+pName);
    11.8          for (int i = 0; i < projects.length; i++){
    11.9              pInfo = ProjectUtils.getInformation(projects[i]);
   11.10 +            System.err.println(pInfo.getDisplayName());
   11.11              // TEMP action.
   11.12              // getDisplayName used for modules in nb5.0
   11.13              // getName will work for java project in nb5.0
   11.14              // and java project/nb module in nb5.5
   11.15              if ( pInfo.getDisplayName().equalsIgnoreCase(pName)
   11.16 -            || pInfo.getName().equalsIgnoreCase(pName)){
   11.17 +            || pName.equalsIgnoreCase(pInfo.getDisplayName()+" [Main]")){
   11.18                  project = projects[i];
   11.19 +                System.err.println("ddfdfdf" + pInfo.getDisplayName());
   11.20                  break;
   11.21              }
   11.22          }