[hg] main-silver: #224157: When adding hint to module of NetBean...

  • From: Martin Kozeny < >
  • To:
  • Subject: [hg] main-silver: #224157: When adding hint to module of NetBean...
  • Date: Thu, 16 May 2013 04:50:53 -0700

changeset 80d863f76d21 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/80d863f76d21
description:
        #224157: When adding hint to module of NetBeans Platform Application, 
platform does not include necessary modules and clusters, for that action. I 
developed routine, which adds those modules and clusters to target platform, 
so application can be build without any errors. I left in test hint java 
class 'add test dependency on Java Hints Test API (and JUnit 4)' TODO text, 
because I am unable to add it by this routine. For suite or standalone 
modules I've omitted this TODO text in test hint java class, because as you 
mentioned before, there is unnecessary.

diffstat:

 
apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
                            |   1 +
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
                       |   2 +
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
                      |  85 +---------
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
                         |   7 +
 apisupport.project/apichanges.xml                                            
                              |  10 +-
 
apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
                  |  14 +-
 
apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
 |   6 +-
 7 files changed, 35 insertions(+), 90 deletions(-)

diffs (322 lines):

diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
@@ -322,6 +322,7 @@
         ic.add(new AntArtifactProviderImpl(this, helper, evaluator()));
         ic.add(new CustomizerProviderImpl(this, getHelper(), evaluator()));
         ic.add(new NbModuleProviderImpl(this));
+        ic.add(new NbProjectProviderImpl(this));
         ic.add(new PrivilegedTemplatesImpl());
         ic.add(new ModuleProjectClassPathExtender(this));
         ic.add(new LocalizedBundleInfoProvider());
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
@@ -127,6 +127,7 @@
     }
 
     @Override public void 
addModulesToTargetPlatform(NbModuleProvider.ModuleDependency[] dependencies) 
throws IOException {
+        if(prj.getModuleType() == NbModuleType.SUITE_COMPONENT) {
         final Project suiteProject = ApisupportAntUtils.getSuiteProject(prj);
         if(suiteProject!=null) {
             final SuiteProperties suiteProps = 
ApisupportAntUtils.getSuiteProperties((SuiteProject)suiteProject);
@@ -141,6 +142,7 @@
             }
         }
     }
+    }
 
     @Override public SpecificationVersion getDependencyVersion(String 
codenamebase) throws IOException {
         ModuleEntry entry = prj.getModuleList().getEntry(codenamebase);
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
@@ -1,84 +1,1 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License.  When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- *
- * Contributor(s):
- *
- * Portions Copyrighted 2013 Sun Microsystems, Inc.
- */
-
-package org.netbeans.modules.apisupport.project;
-
-import java.io.File;
-import java.io.IOException;
-import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.modules.apisupport.project.spi.NbProjectProvider;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-
-/**
- *
- * @author mkozeny
- */
-public class NbProjectProviderImpl implements NbProjectProvider{
-    
-    private final Project prj;
-
-    NbProjectProviderImpl(Project prj) {
-        this.prj = prj;
-    }
-
-    @Override
-    public boolean isNbPlatformApplication() {
-        File suiteDirectory = 
prj.getLookup().lookup(SuiteProvider.class).getSuiteDirectory();
-        if(suiteDirectory!=null) {
-            FileObject suiteDirectoryFO = 
FileUtil.toFileObject(suiteDirectory);
-            if(suiteDirectoryFO != null) {
-                try {
-                    final Project suiteProject = 
ProjectManager.getDefault().findProject(suiteDirectoryFO);
-                } catch (IOException ex) {
-                    Exceptions.printStackTrace(ex);
-                } catch (IllegalArgumentException ex) {
-                    Exceptions.printStackTrace(ex);
-                }
-            }
-        }
-        return false;
-    }
-    
-}
+/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
 *
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
 * Other names may be trademarks of their respective owners.
 *
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common
 * Development and Distribution License("CDDL") (collectively, the
 * "License"). You may not use this file except in compliance with the
 * License. You can obtain a copy of the License at
 * http://www.netbeans.org/cddl-gplv2.html
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 * specific language governing permissions and limitations under the
 * License.  When distributing the software, include this License Header
 * Notice in each file and include the License file at
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the GPL Version 2 section of the License file that
 * accompanied this code. If applicable, add the following below the
 * License Header, with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * If you wish your version of this file to be governed by only the CDDL
 * or only the GPL Version 2, indicate your decision by adding
 * "[Contributor] elects to include this software in this distribution
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 * single choice of license, a recipient has the option to distribute
 * your version of this file under either the CDDL, the GPL Version 2 or
 * to extend the choice of license to its licensees as provided above.
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 * Version 2 license, then the option applies only if the new code is
 * made subject to such option by the copyright holder.
 *
 * Contributor(s):
 *
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
 */

package org.netbeans.modules.apisupport.project;

import java.io.File;
import java.io.IOException;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.modules.apisupport.project.spi.NbProjectProvider;
import org.netbeans.modules.apisupport.project.suite.SuiteProject;
import org.netbeans.modules.apisupport.project.suite.SuiteType;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;

/**
 *
 * @author mkozeny
 */
public class NbProjectProviderImpl implements NbProjectProvider{
    
    private final Project prj;

    NbProjectProviderImpl(Project prj) {
        this.prj = prj;
    }

    @Override
    public boolean isNbPlatformApplication() {
        NbModuleProject target = 
prj.getLookup().lookup(NbModuleProject.class);
        if(target != null && target.getModuleType() == 
NbModuleType.SUITE_COMPONENT) {
            File suiteDirectory = 
target.getLookup().lookup(SuiteProvider.class).getSuiteDirectory();
            if(suiteDirectory!=null) {
                FileObject suiteDirectoryFO = 
FileUtil.toFileObject(suiteDirectory);
                if(suiteDirectoryFO != null) {
                    try {
                        Project suitePrj = 
ProjectManager.getDefault().findProject(suiteDirectoryFO);
                        if(suitePrj != null) {
                            SuiteProject suiteProject = 
suitePrj.getLookup().lookup(SuiteProject.class);
                            if(suiteProject != null && 
suiteProject.getSuiteType() == SuiteType.APPLICATION) {
                                return true;
                            }
                        }
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    } catch (IllegalArgumentException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            }
        }
        return false;
    }
    
    public boolean isSuiteComponent() {
        NbModuleProject target = 
prj.getLookup().lookup(NbModuleProject.class);
        if(target != null && target.getModuleType() == 
NbModuleType.SUITE_COMPONENT) {
            return true;
        }
        return false;
    }
    
}
\ No newline at end of file
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
@@ -412,4 +412,11 @@
 
     }
     
+    public SuiteType getSuiteType() {
+        
if(this.helper.getProperties("nbproject/platform.properties").getProperty("branding.token")
 != null) {
+            return SuiteType.APPLICATION;
+        } else {
+            return SuiteType.SUITE;
 }
+    }
+}
diff --git a/apisupport.project/apichanges.xml 
b/apisupport.project/apichanges.xml
--- a/apisupport.project/apichanges.xml
+++ b/apisupport.project/apichanges.xml
@@ -110,16 +110,20 @@
     <changes>
         <change>
             <api name="apisupport_spi"/>
-            <summary>Modified NB module provider for aadding modules to 
target platform</summary>
+            <summary>Modified NB module provider for aadding modules to 
target platform, 
+            New interface for getting information about the project</summary>
             <version major="1" minor="64"/>
-            <date day="14" month="5" year="2013"/>
+            <date day="15" month="5" year="2013"/>
             <author login="mkozeny"/>
             <compatibility addition="yes"/>
             <description>
                 <code>NbModuleProvider</code> interface now contains method 
<code>addModulesToTargetPlatform</code>
-                for adding modules to target platform also with its clusters 
if necessary.
+                for adding modules to target platform also with its clusters 
if necessary. <code>NbProjectProvider</code> 
+                interface contains methods 
<code>isNbPlatformApplication</code>
+                and  <code>isSuiteComponent</code> in order to get 
information about particular project.
             </description>
             <class package="org.netbeans.modules.apisupport.project.spi" 
name="NbModuleProvider"/>
+            <class package="org.netbeans.modules.apisupport.project.spi" 
name="NbProjectProvider"/>
         </change>
         <change>
             <api name="apisupport_spi"/>
diff --git 
a/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
 
b/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
--- 
a/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
+++ 
b/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
@@ -43,10 +43,22 @@
 package org.netbeans.modules.apisupport.project.spi;
 
 /**
+ * Interface to be implemented by NetBeans module projects. 
  *
- * @author mkozeny
+ * @author Martin Kozeny
+ * @since org.netbeans.modules.apisupport.project 1.64
  */
 public interface NbProjectProvider {
     
+    /**
+     * Returns whether given project is Nb Platform Application
+     * @return 
+     */
     boolean isNbPlatformApplication();
+    
+    /**
+     * Returns whether given project is Suite Component
+     * @return 
+     */
+    boolean isSuiteComponent();
 }
diff --git 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
--- 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
+++ 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
@@ -95,7 +95,9 @@
         cmf.add(cmf.addTestModuleDependency("org.netbeans.libs.junit4", 
"extra"));
         cmf.add(cmf.addTestModuleDependency("org.netbeans.modules.nbjunit", 
"harness")); // NOI18N
         
+        NbProjectProvider nbProjectProvider = 
getProjectProvider(model.getProject());
 
+        if(nbProjectProvider.isSuiteComponent()) {
         //add module to target platform
         
         //java cluster
@@ -157,7 +159,7 @@
         
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.autoupdate.services",
 "platform")); // NOI18N
         
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.autoupdate.ui", 
"platform")); // NOI18N
         cmf.add(cmf.addModuleToTargetPlatform("org.openide.execution", 
"platform")); // NOI18N
-        
+        }
         
         String className = model.getClassName();
         FileObject hintTemplate = 
CreatedModifiedFiles.getTemplate("javaHint.java"); // NOI18N
@@ -180,7 +182,7 @@
 
         String testPath = model.getDefaultPackagePath(className + 
"Test.java", false, true); // NOI18N
         FileObject testTemplate = null;
-        if(getProjectProvider(model.getProject()).isNbPlatformApplication()) 
{
+        if(nbProjectProvider.isNbPlatformApplication()) {
             testTemplate = 
CreatedModifiedFiles.getTemplate("javaHintTestApp.java"); // NOI18N
         } else {
             testTemplate = 
CreatedModifiedFiles.getTemplate("javaHintTest.java"); // NOI18N

[hg] main-silver: #224157: When adding hint to module of NetBean...

Martin Kozeny 05/16/2013

<Possible follow-up(s)>

[hg] main-silver: #224157: When adding hint to module of NetBean...

Martin Kozeny 05/16/2013

Project Features

About this Project

APIsupport was started in November 2009, is owned by Antonin Nebuzelsky, and has 43 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close