Merging default into netigso-as-module to get Jesse's changes for plain OSGi support
1.1 --- a/apisupport.harness/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
1.2 +++ b/apisupport.harness/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
1.3 @@ -84,6 +84,7 @@
1.4 org/netbeans/nbbuild/MakeListOfNBM*.class,\
1.5 org/netbeans/nbbuild/MakeMasterJNLP*.class,\
1.6 org/netbeans/nbbuild/MakeNBM*.class,\
1.7 + org/netbeans/nbbuild/MakeOSGi*.class,\
1.8 org/netbeans/nbbuild/MakeUpdateDesc*.class,\
1.9 org/netbeans/nbbuild/ModuleListParser*.class,\
1.10 org/netbeans/nbbuild/ModuleSelector*.class,\
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/apisupport.harness/release/osgi.xml Mon Feb 01 12:24:26 2010 +0100
2.3 @@ -0,0 +1,107 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.5 +<!--
2.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.7 +
2.8 +Copyright 2010 Sun Microsystems, Inc. All rights reserved.
2.9 +
2.10 +The contents of this file are subject to the terms of either the GNU
2.11 +General Public License Version 2 only ("GPL") or the Common
2.12 +Development and Distribution License("CDDL") (collectively, the
2.13 +"License"). You may not use this file except in compliance with the
2.14 +License. You can obtain a copy of the License at
2.15 +http://www.netbeans.org/cddl-gplv2.html
2.16 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.17 +specific language governing permissions and limitations under the
2.18 +License. When distributing the software, include this License Header
2.19 +Notice in each file and include the License file at
2.20 +nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
2.21 +particular file as subject to the "Classpath" exception as provided
2.22 +by Sun in the GPL Version 2 section of the License file that
2.23 +accompanied this code. If applicable, add the following below the
2.24 +License Header, with the fields enclosed by brackets [] replaced by
2.25 +your own identifying information:
2.26 +"Portions Copyrighted [year] [name of copyright owner]"
2.27 +
2.28 +Contributor(s):
2.29 +
2.30 +The Original Software is NetBeans. The Initial Developer of the Original
2.31 +Software is Sun Microsystems, Inc. Portions Copyright 2010 Sun
2.32 +Microsystems, Inc. All Rights Reserved.
2.33 +
2.34 +If you wish your version of this file to be governed by only the CDDL
2.35 +or only the GPL Version 2, indicate your decision by adding
2.36 +"[Contributor] elects to include this software in this distribution
2.37 +under the [CDDL or GPL Version 2] license." If you do not indicate a
2.38 +single choice of license, a recipient has the option to distribute
2.39 +your version of this file under either the CDDL, the GPL Version 2 or
2.40 +to extend the choice of license to its licensees as provided above.
2.41 +However, if you add GPL Version 2 code and therefore, elected the GPL
2.42 +Version 2 license, then the option applies only if the new code is
2.43 +made subject to such option by the copyright holder.
2.44 +-->
2.45 +<project name="suite-osgi" basedir=".">
2.46 +
2.47 + <target name="init">
2.48 + <property name="osgi.dest.dir" location="build/osgi"/>
2.49 + <property name="osgi.cache.dir" location="build/osgi-cache"/>
2.50 + <property name="disabled.modules" value=""/>
2.51 + <property name="enabled.clusters" value=""/>
2.52 + <property name="disabled.clusters" value=""/>
2.53 + </target>
2.54 +
2.55 + <target name="build" depends="init">
2.56 + <mkdir dir="${osgi.dest.dir}"/>
2.57 + <makeosgi destdir="${osgi.dest.dir}">
2.58 + <pathfileset>
2.59 + <path refid="cluster.path.id"/>
2.60 + <and>
2.61 + <or>
2.62 + <filename name="modules/*.jar"/>
2.63 + <filename name="lib/*.jar"/>
2.64 + <filename name="core/*.jar"/>
2.65 + </or>
2.66 + <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
2.67 + <param name="excludeModules" value="${disabled.modules}"/>
2.68 + <param name="includeClusters" value="${enabled.clusters}"/>
2.69 + <param name="excludeClusters" value="${disabled.clusters}"/>
2.70 + </custom>
2.71 + </and>
2.72 + </pathfileset>
2.73 + <fileset dir="${cluster}">
2.74 + <include name="modules/*.jar"/>
2.75 + <include name="lib/*.jar"/>
2.76 + <include name="core/*.jar"/>
2.77 + </fileset>
2.78 + </makeosgi>
2.79 + </target>
2.80 +
2.81 + <target name="run" depends="init">
2.82 + <!-- XXX Felix cache does not seem to work correctly, uses stale JARs; and org.osgi.framework.storage.clean=onFirstInit broken too: -->
2.83 + <delete dir="${osgi.cache.dir}"/>
2.84 + <mkdir dir="${osgi.cache.dir}"/>
2.85 + <!-- From felix/main/src/main/resources/config.properties; XXX is there a better way to grab these? -->
2.86 + <property name="felix-sys-prop.felix.auto.deploy.action" value="install,start"/>
2.87 + <property name="felix-sys-prop.felix.log.level" value="4"/>
2.88 + <property name="felix-sys-prop.org.osgi.service.http.port" value="8080"/>
2.89 + <property name="felix-sys-prop.obr.repository.url" value="http://felix.apache.org/obr/releases.xml"/>
2.90 + <java fork="true" classname="org.apache.felix.main.Main">
2.91 + <classpath>
2.92 + <pathfileset>
2.93 + <path refid="cluster.path.id"/>
2.94 + <or>
2.95 + <filename name="core/osgi*.jar"/>
2.96 + <filename name="modules/ext/felix*.jar"/>
2.97 + </or>
2.98 + </pathfileset>
2.99 + </classpath>
2.100 + <arg value="-b"/>
2.101 + <arg file="${osgi.dest.dir}"/>
2.102 + <arg file="${osgi.cache.dir}"/>
2.103 + <syspropertyset>
2.104 + <propertyref prefix="felix-sys-prop."/>
2.105 + <mapper type="glob" from="felix-sys-prop.*" to="*"/>
2.106 + </syspropertyset>
2.107 + </java>
2.108 + </target>
2.109 +
2.110 +</project>
3.1 --- a/apisupport.harness/release/suite.xml Mon Feb 01 12:23:06 2010 +0100
3.2 +++ b/apisupport.harness/release/suite.xml Mon Feb 01 12:24:26 2010 +0100
3.3 @@ -510,7 +510,20 @@
3.4 <property name="jnlp.generate.versions" value="false"/> <!-- versioning is not enabled w/o app server-->
3.5 </ant>
3.6 </target>
3.7 -
3.8 +
3.9 + <target name="build-osgi" depends="build,-jdk-init" description="Converts this suite into OSGi-compatible bundles.">
3.10 + <echo>OSGi support is EXPERIMENTAL for now; see: http://wiki.netbeans.org/NetBeansInOSGi</echo>
3.11 + <ant antfile="${harness.dir}/osgi.xml" target="build">
3.12 + <reference refid="cluster.path.id"/>
3.13 + </ant>
3.14 + </target>
3.15 +
3.16 + <target name="run-osgi" depends="build-osgi" description="Runs this suite in an OSGi container.">
3.17 + <ant antfile="${harness.dir}/osgi.xml" target="run">
3.18 + <reference refid="cluster.path.id"/>
3.19 + </ant>
3.20 + </target>
3.21 +
3.22 <target name="test" depends="build" description="Runs tests for all modules in the suite.">
3.23 <sortsuitemodules unsortedmodules="${modules}" sortedmodulesproperty="modules.test.sorted" sorttests="true"/>
3.24 <property name="continue.after.failing.tests" value="true"/> <!-- fallback -->
4.1 --- a/apisupport.harness/taskdefs.properties Mon Feb 01 12:23:06 2010 +0100
4.2 +++ b/apisupport.harness/taskdefs.properties Mon Feb 01 12:24:26 2010 +0100
4.3 @@ -43,6 +43,7 @@
4.4 makenbm=org.netbeans.nbbuild.MakeNBM
4.5 makejnlp=org.netbeans.nbbuild.MakeJNLP
4.6 makemasterjnlp=org.netbeans.nbbuild.MakeMasterJNLP
4.7 +makeosgi=org.netbeans.nbbuild.MakeOSGi
4.8 parseprojectxml=org.netbeans.nbbuild.ParseProjectXml
4.9 genlist=org.netbeans.nbbuild.MakeListOfNBM
4.10 arch=org.netbeans.nbbuild.Arch
5.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java Mon Feb 01 12:23:06 2010 +0100
5.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java Mon Feb 01 12:24:26 2010 +0100
5.3 @@ -111,6 +111,7 @@
5.4 }
5.5 }
5.6 }
5.7 + // XXX $suite/build/osgi/$cnb-*.jar => $cnb in $suite
5.8 NbPlatform supposedPlaf = null;
5.9 for (NbPlatform plaf : NbPlatform.getPlatforms()) {
5.10 // XXX more robust condition?
6.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
6.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
6.3 @@ -131,6 +131,8 @@
6.4 SUITE_ACTION_build_jnlp=Build JNLP Application
6.5 SUITE_ACTION_run_jnlp=Run JNLP Application
6.6 SUITE_ACTION_debug_jnlp=Debug JNLP Application
6.7 +SUITE_ACTION_build_osgi=Build OSGi Bundles
6.8 +SUITE_ACTION_run_osgi=Run in OSGi
6.9 SUITE_ACTION_nbms=Create NBMs
6.10 SUITE_ACTION_mac=Build Mac OS X Application
6.11
7.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/SuiteActions.java Mon Feb 01 12:23:06 2010 +0100
7.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/SuiteActions.java Mon Feb 01 12:24:26 2010 +0100
7.3 @@ -99,6 +99,11 @@
7.4 actions.add(ProjectSensitiveActions.projectCommandAction("run-jnlp", NbBundle.getMessage(SuiteActions.class, "SUITE_ACTION_run_jnlp"), null));
7.5 actions.add(ProjectSensitiveActions.projectCommandAction("debug-jnlp", NbBundle.getMessage(SuiteActions.class, "SUITE_ACTION_debug_jnlp"), null));
7.6 actions.add(null);
7.7 + if (platform != null && platform.getHarnessVersion().compareTo(HarnessVersion.V69) >= 0 && platform.getModule("org.netbeans.core.netigso") != null) {
7.8 + actions.add(ProjectSensitiveActions.projectCommandAction("build-osgi", NbBundle.getMessage(SuiteActions.class, "SUITE_ACTION_build_osgi"), null));
7.9 + actions.add(ProjectSensitiveActions.projectCommandAction("run-osgi", NbBundle.getMessage(SuiteActions.class, "SUITE_ACTION_run_osgi"), null));
7.10 + actions.add(null);
7.11 + }
7.12 if (platform != null && platform.getHarnessVersion().compareTo(HarnessVersion.V55u1) >= 0) {
7.13 actions.add(ProjectSensitiveActions.projectCommandAction("build-mac", NbBundle.getMessage(SuiteActions.class, "SUITE_ACTION_mac"), null));
7.14 actions.add(null);
7.15 @@ -141,6 +146,8 @@
7.16 "build-jnlp", // NOI18N
7.17 "run-jnlp", // NOI18N
7.18 "debug-jnlp", // NOI18N
7.19 + "build-osgi", // NOI18N
7.20 + "run-osgi", // NOI18N
7.21 "build-mac", // NOI18N
7.22 "nbms", // NOI18N
7.23 "profile", // NOI18N
7.24 @@ -250,12 +257,8 @@
7.25 return null;
7.26 }
7.27 targetNames = new String[] {"debug-jnlp"}; // NOI18N
7.28 - } else if (command.equals("build-mac")) { // NOI18N
7.29 - targetNames = new String[] {"build-mac"}; // NOI18N
7.30 - } else if (command.equals("nbms")) { // NOI18N
7.31 - targetNames = new String[] {"nbms"}; // NOI18N
7.32 - } else if (command.equals("profile")) { // NOI18N
7.33 - targetNames = new String[] {"profile"}; // NOI18N
7.34 + } else if (command.matches("build-osgi|run-osgi|build-mac|nbms|profile")) { // NOI18N
7.35 + targetNames = new String[] {command}; // NOI18N
7.36 } else {
7.37 throw new IllegalArgumentException(command);
7.38 }
8.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java Mon Feb 01 12:23:06 2010 +0100
8.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java Mon Feb 01 12:24:26 2010 +0100
8.3 @@ -270,12 +270,14 @@
8.4 }
8.5
8.6 private void addExtCluster(ClusterInfo ci) {
8.7 + Set<String> disabledModuleCNB = new HashSet<String>(Arrays.asList(getProperties().getDisabledModules()));
8.8 Children.SortedArray moduleCh = new Children.SortedArray();
8.9 try {
8.10 ModuleList ml = ModuleList.scanCluster(ci.getClusterDir(), null, false, ci);
8.11 moduleCh.setComparator(MODULES_COMPARATOR);
8.12 for (ModuleEntry entry : ml.getAllEntries()) {
8.13 - moduleCh.add(new Node[] { new BinaryModuleNode(entry, ci.isEnabled()) });
8.14 + moduleCh.add(new Node[] { new BinaryModuleNode(entry,
8.15 + ! disabledModuleCNB.contains(entry.getCodeNameBase()) && ci.isEnabled()) });
8.16 extraBinaryModules.add(entry);
8.17 }
8.18 } catch (IOException e) {
8.19 @@ -290,11 +292,13 @@
8.20 assert ci.getProject() != null;
8.21 assert ci.getProject().getLookup().lookup(SuiteProvider.class) != null;
8.22
8.23 + Set<String> disabledModuleCNB = new HashSet<String>(Arrays.asList(getProperties().getDisabledModules()));
8.24 Children.SortedArray moduleCh = new Children.SortedArray();
8.25 moduleCh.setComparator(MODULES_COMPARATOR);
8.26 Set<NbModuleProject> modules = SuiteUtils.getSubProjects(ci.getProject());
8.27 for (NbModuleProject modPrj : modules) {
8.28 - moduleCh.add(new Node[] { new SuiteComponentNode(modPrj, ci.isEnabled()) });
8.29 + moduleCh.add(new Node[] { new SuiteComponentNode(modPrj,
8.30 + ! disabledModuleCNB.contains(modPrj.getCodeNameBase()) && ci.isEnabled()) });
8.31 }
8.32 return new ClusterNode(ci, moduleCh);
8.33 }
9.1 --- a/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/actions/GdbActionHandlerFactory.java Mon Feb 01 12:23:06 2010 +0100
9.2 +++ b/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/actions/GdbActionHandlerFactory.java Mon Feb 01 12:24:26 2010 +0100
9.3 @@ -42,7 +42,7 @@
9.4 package org.netbeans.modules.cnd.debugger.gdb.actions;
9.5
9.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
9.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
9.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
9.9 import org.netbeans.modules.cnd.debugger.common.actions.CndDebuggerActionHandlerFactory;
9.10 import org.netbeans.modules.cnd.makeproject.api.ProjectActionEvent.Type;
9.11 import org.netbeans.modules.cnd.makeproject.api.ProjectActionHandler;
10.1 --- a/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/profiles/GdbProfile.java Mon Feb 01 12:23:06 2010 +0100
10.2 +++ b/cnd.debugger.gdb/src/org/netbeans/modules/cnd/debugger/gdb/profiles/GdbProfile.java Mon Feb 01 12:24:26 2010 +0100
10.3 @@ -45,11 +45,10 @@
10.4 import java.beans.PropertyChangeSupport;
10.5 import java.io.File;
10.6 import java.util.ArrayList;
10.7 -import org.netbeans.modules.cnd.toolchain.actions.BuildToolsAction;
10.8 +import org.netbeans.modules.cnd.toolchain.ui.api.BuildToolsAction;
10.9
10.10 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
10.11 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
10.12 -import org.netbeans.modules.cnd.toolchain.api.Tool;
10.13 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
10.14 import org.netbeans.modules.cnd.api.remote.ServerList;
10.15 import org.netbeans.modules.nativeexecution.api.util.Path;
10.16 import org.openide.nodes.Sheet;
10.17 @@ -63,6 +62,9 @@
10.18 import org.netbeans.modules.cnd.makeproject.api.configurations.Configuration;
10.19 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
10.20 import org.netbeans.modules.cnd.settings.CppSettings;
10.21 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
10.22 +import org.netbeans.modules.cnd.toolchain.api.Tool;
10.23 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetFactory;
10.24 import org.netbeans.modules.cnd.toolchain.ui.api.LocalToolsPanelModel;
10.25 import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelModel;
10.26 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
10.27 @@ -97,6 +99,7 @@
10.28 initialize();
10.29 }
10.30
10.31 + @Override
10.32 public void initialize() {
10.33 if (gdb_command == null) {
10.34 if (GdbDebugger.isUnitTest()) {
10.35 @@ -107,6 +110,7 @@
10.36 }
10.37 }
10.38
10.39 + @Override
10.40 public boolean shared() {
10.41 return false;
10.42 }
10.43 @@ -115,6 +119,7 @@
10.44 * Returns a unique id (String) used to retrive this object from the
10.45 * pool of aux objects.
10.46 */
10.47 + @Override
10.48 public String getId() {
10.49 return GDB_PROFILE_ID;
10.50 }
10.51 @@ -145,14 +150,14 @@
10.52
10.53 if (csconf.isValid()) {
10.54 csname = csconf.getOption();
10.55 - cs = CompilerSetManager.getDefault(conf.getDevelopmentHost().getExecutionEnvironment()).getCompilerSet(csname);
10.56 + cs = CompilerSetManager.get(conf.getDevelopmentHost().getExecutionEnvironment()).getCompilerSet(csname);
10.57 } else {
10.58 csname = csconf.getOldName();
10.59 - cs = CompilerSet.getCompilerSet(conf.getDevelopmentHost().getExecutionEnvironment(), csname, conf.getPlatformInfo().getPlatform());
10.60 - CompilerSetManager.getDefault(conf.getDevelopmentHost().getExecutionEnvironment()).add(cs);
10.61 + cs = CompilerSetFactory.getCompilerSet(conf.getDevelopmentHost().getExecutionEnvironment(), csname, conf.getPlatformInfo().getPlatform());
10.62 + CompilerSetManager.get(conf.getDevelopmentHost().getExecutionEnvironment()).add(cs);
10.63 csconf.setValid();
10.64 }
10.65 - Tool debuggerTool = cs.getTool(Tool.DebuggerTool);
10.66 + Tool debuggerTool = cs.getTool(ToolKind.DebuggerTool);
10.67 ExecutionEnvironment execEnv = null;
10.68 if (debuggerTool != null) {
10.69 String gdbPath = debuggerTool.getPath();
10.70 @@ -199,8 +204,8 @@
10.71 // setGdbCommand(model.getGdbName());
10.72 // }
10.73 conf.getCompilerSet().setValue(model.getSelectedCompilerSetName());
10.74 - cs = CompilerSetManager.getDefault(conf.getDevelopmentHost().getExecutionEnvironment()).getCompilerSet(model.getSelectedCompilerSetName());
10.75 - return cs.getTool(Tool.DebuggerTool).getPath();
10.76 + cs = CompilerSetManager.get(conf.getDevelopmentHost().getExecutionEnvironment()).getCompilerSet(model.getSelectedCompilerSetName());
10.77 + return cs.getTool(ToolKind.DebuggerTool).getPath();
10.78 }
10.79 }
10.80 return null;
10.81 @@ -299,20 +304,24 @@
10.82 // This stuff ends up in <projectdir>/nbproject/private/profiles.xml
10.83 //
10.84
10.85 + @Override
10.86 public XMLDecoder getXMLDecoder() {
10.87 return new GdbProfileXMLCodec(this);
10.88 }
10.89
10.90 + @Override
10.91 public XMLEncoder getXMLEncoder() {
10.92 return new GdbProfileXMLCodec(this);
10.93 }
10.94
10.95 // interface ProfileAuxObject
10.96 + @Override
10.97 public boolean hasChanged() {
10.98 return needSave;
10.99 }
10.100
10.101 // interface ProfileAuxObject
10.102 + @Override
10.103 public void clearChanged() {
10.104 needSave = false;
10.105 }
10.106 @@ -323,6 +332,7 @@
10.107 * Assign all values from a profileAuxObject to this object (reverse
10.108 * of clone)
10.109 */
10.110 + @Override
10.111 public void assign(ConfigurationAuxObject profileAuxObject) {
10.112 assert profileAuxObject instanceof GdbProfile;
10.113
10.114 @@ -366,10 +376,12 @@
10.115 true, false);
10.116 }
10.117
10.118 + @Override
10.119 public String getValue() {
10.120 return getGdbCommand();
10.121 }
10.122
10.123 + @Override
10.124 public void setValue(String v) {
10.125 // TODO: shouldn't we check for null here?
10.126 setGdbCommand(v);
10.127 @@ -384,10 +396,12 @@
10.128 true, true);
10.129 }
10.130
10.131 + @Override
10.132 public Integer getValue() {
10.133 return getArrayRepeatThreshold();
10.134 }
10.135
10.136 + @Override
10.137 public void setValue(Integer v) {
10.138 // TODO: why do we need to check it here?
10.139 if (v != null) {
11.1 --- a/cnd.debugger.gdb/test/unit/src/org/netbeans/modules/cnd/debugger/gdb/GdbTestCase.java Mon Feb 01 12:23:06 2010 +0100
11.2 +++ b/cnd.debugger.gdb/test/unit/src/org/netbeans/modules/cnd/debugger/gdb/GdbTestCase.java Mon Feb 01 12:24:26 2010 +0100
11.3 @@ -49,8 +49,7 @@
11.4 import org.netbeans.api.debugger.DebuggerInfo;
11.5 import org.netbeans.api.debugger.DebuggerManager;
11.6 import org.netbeans.api.project.Project;
11.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
11.8 -import org.netbeans.modules.cnd.toolchain.api.Tool;
11.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
11.10 import org.netbeans.modules.cnd.debugger.gdb.GdbDebugger.State;
11.11 import org.netbeans.modules.cnd.debugger.common.breakpoints.FunctionBreakpoint;
11.12 import org.netbeans.modules.cnd.debugger.common.breakpoints.CndBreakpoint;
11.13 @@ -61,6 +60,8 @@
11.14 import org.netbeans.modules.cnd.makeproject.api.runprofiles.RunProfile;
11.15 import org.netbeans.spi.debugger.ContextProvider;
11.16 import org.netbeans.modules.cnd.test.CndBaseTestCase;
11.17 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
11.18 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
11.19 import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
11.20
11.21 /**
11.22 @@ -107,7 +108,7 @@
11.23 project_dir = new File(testapp_dir, testproj).getAbsolutePath();
11.24 conf = new TestConfiguration(args);
11.25 pae = new ProjectActionEvent(project, ProjectActionEvent.Type.DEBUG_STEPINTO, testapp, executable, conf, null, false);
11.26 - CompilerSetManager.getDefault().getCompilerSet(0).getTool(Tool.DebuggerTool).setPath("/opt/csw/bin/gdb");
11.27 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSet(0).getTool(ToolKind.DebuggerTool).setPath("/opt/csw/bin/gdb");
11.28 dm.startDebugging(DebuggerInfo.create(GdbDebugger.SESSION_PROVIDER_ID,
11.29 new Object[]{pae}));
11.30 debugger = GdbDebugger.getGdbDebugger();
12.1 --- a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/api/QtInfoProvider.java Mon Feb 01 12:23:06 2010 +0100
12.2 +++ b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/api/QtInfoProvider.java Mon Feb 01 12:24:26 2010 +0100
12.3 @@ -48,11 +48,12 @@
12.4 import java.util.logging.Level;
12.5 import java.util.logging.Logger;
12.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
12.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
12.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
12.9 import org.netbeans.modules.cnd.api.utils.IpeUtils;
12.10 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
12.11 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
12.12 import org.netbeans.modules.cnd.makeproject.api.configurations.QmakeConfiguration;
12.13 +import org.netbeans.modules.cnd.toolchain.api.Tool;
12.14 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
12.15 import org.netbeans.modules.nativeexecution.api.NativeProcess;
12.16 import org.netbeans.modules.nativeexecution.api.NativeProcessBuilder;
12.17 @@ -92,6 +93,7 @@
12.18 * @param conf Qt project configuration
12.19 * @return list of include directories, may be empty if qmake is not found
12.20 */
12.21 + @Override
12.22 public List<String> getQtIncludeDirectories(MakeConfiguration conf) {
12.23 String baseDir = getBaseQtIncludeDir(conf);
12.24 List<String> result;
12.25 @@ -144,7 +146,7 @@
12.26 private static String getQmakePath(MakeConfiguration conf) {
12.27 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
12.28 if (compilerSet != null) {
12.29 - Tool qmakeTool = compilerSet.getTool(Tool.QMakeTool);
12.30 + Tool qmakeTool = compilerSet.getTool(ToolKind.QMakeTool);
12.31 if (qmakeTool != null && 0 < qmakeTool.getPath().length()) {
12.32 return qmakeTool.getPath();
12.33 }
13.1 --- a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ImportProject.java Mon Feb 01 12:23:06 2010 +0100
13.2 +++ b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ImportProject.java Mon Feb 01 12:24:26 2010 +0100
13.3 @@ -69,7 +69,6 @@
13.4 import org.netbeans.modules.cnd.actions.MakeAction;
13.5 import org.netbeans.modules.cnd.actions.QMakeAction;
13.6 import org.netbeans.modules.cnd.actions.ShellRunAction;
13.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
13.8 import org.netbeans.modules.nativeexecution.api.ExecutionListener;
13.9 import org.netbeans.modules.cnd.api.model.CsmFile;
13.10 import org.netbeans.modules.cnd.api.model.CsmListeners;
13.11 @@ -81,6 +80,7 @@
13.12 import org.netbeans.modules.cnd.api.project.NativeFileItem;
13.13 import org.netbeans.modules.cnd.api.project.NativeProject;
13.14 import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
13.15 +import org.netbeans.modules.cnd.api.remote.ServerList;
13.16 import org.netbeans.modules.cnd.modelimpl.csm.core.ModelImpl;
13.17 import org.netbeans.modules.cnd.api.utils.AllSourceFileFilter;
13.18 import org.netbeans.modules.cnd.api.utils.IpeUtils;
13.19 @@ -530,7 +530,7 @@
13.20
13.21 private void downloadRemoteFile(File file){
13.22 if (file != null && !file.exists()) {
13.23 - ExecutionEnvironment developmentHost = CompilerSetManager.getDefaultExecutionEnvironment();
13.24 + ExecutionEnvironment developmentHost = ServerList.getDefaultRecord().getExecutionEnvironment();
13.25 if (developmentHost.isRemote()) {
13.26 String remoteFile = HostInfoProvider.getMapper(developmentHost).getRemotePath(file.getAbsolutePath());
13.27 try {
14.1 --- a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ReconfigureProject.java Mon Feb 01 12:23:06 2010 +0100
14.2 +++ b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ReconfigureProject.java Mon Feb 01 12:24:26 2010 +0100
14.3 @@ -39,6 +39,7 @@
14.4
14.5 package org.netbeans.modules.cnd.discovery.projectimport;
14.6
14.7 +import static java.util.logging.Logger.getLogger;
14.8 import java.io.IOException;
14.9 import java.util.ArrayList;
14.10 import java.util.List;
14.11 @@ -56,7 +57,7 @@
14.12 import org.netbeans.modules.cnd.actions.ShellRunAction;
14.13 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
14.14 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
14.15 -import org.netbeans.modules.cnd.toolchain.api.Tool;
14.16 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
14.17 import org.netbeans.modules.nativeexecution.api.ExecutionListener;
14.18 import org.netbeans.modules.cnd.builds.ImportUtils;
14.19 import org.netbeans.modules.cnd.execution.ShellExecSupport;
14.20 @@ -66,6 +67,7 @@
14.21 import org.netbeans.modules.cnd.makeproject.api.configurations.Folder;
14.22 import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
14.23 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
14.24 +import org.netbeans.modules.cnd.toolchain.api.Tool;
14.25 import org.netbeans.modules.cnd.utils.MIMENames;
14.26 import org.openide.loaders.DataObject;
14.27 import org.openide.nodes.Node;
14.28 @@ -80,7 +82,7 @@
14.29 */
14.30 public class ReconfigureProject {
14.31 private static boolean TRACE = Boolean.getBoolean("cnd.discovery.trace.projectimport"); // NOI18N
14.32 - private Logger logger = Logger.getLogger("org.netbeans.modules.cnd.discovery.projectimport.ImportProject"); // NOI18N
14.33 + private static final Logger logger = getLogger("org.netbeans.modules.cnd.discovery.projectimport.ImportProject"); // NOI18N
14.34 private final Project makeProject;
14.35 private final ConfigurationDescriptorProvider pdp;
14.36 private final boolean isSunCompiler;
14.37 @@ -110,7 +112,7 @@
14.38 CompilerSet2Configuration set = configuration.getCompilerSet();
14.39 compilerSet = set.getCompilerSet();
14.40 assert compilerSet != null;
14.41 - isSunCompiler = compilerSet.isSunCompiler();
14.42 + isSunCompiler = compilerSet.getCompilerFlavor().isSunStudioCompiler();
14.43 Folder important = pdp.getConfigurationDescriptor().getExternalFileItems();
14.44 for(Item item : important.getAllItemsAsArray()){
14.45 DataObject dao = item.getDataObject();
14.46 @@ -156,6 +158,7 @@
14.47 public void reconfigure(final String cFlags, final String cxxFlags, final String linkerFlags, final InputOutput io){
14.48 if (SwingUtilities.isEventDispatchThread()){
14.49 RequestProcessor.getDefault().post(new Runnable() {
14.50 + @Override
14.51 public void run() {
14.52 reconfigure(cFlags, cxxFlags, linkerFlags, getRestOptions(), true, io);
14.53 }
14.54 @@ -171,8 +174,10 @@
14.55 final AtomicInteger res = new AtomicInteger();
14.56 final AtomicBoolean finished = new AtomicBoolean(false);
14.57 ExecutionListener listener = new ExecutionListener() {
14.58 + @Override
14.59 public void executionStarted(int pid) {
14.60 }
14.61 + @Override
14.62 public void executionFinished(int rc) {
14.63 res.set(rc);
14.64 finished.set(true);
14.65 @@ -226,11 +231,13 @@
14.66 }
14.67 }
14.68 ExecutionListener listener = new ExecutionListener() {
14.69 + @Override
14.70 public void executionStarted(int pid) {
14.71 for(ExecutionListener listener : listeners){
14.72 listener.executionStarted(pid);
14.73 }
14.74 }
14.75 + @Override
14.76 public void executionFinished(int rc) {
14.77 if (rc == 0) {
14.78 postClean(false);
14.79 @@ -242,7 +249,7 @@
14.80 }
14.81 };
14.82 if (TRACE) {
14.83 - logger.log(Level.INFO, "#" + cmake.getPrimaryFile().getPath() + " " + arguments); // NOI18N
14.84 + logger.log(Level.INFO, "#{0} {1}", new Object[]{cmake.getPrimaryFile().getPath(), arguments}); // NOI18N
14.85 }
14.86 if (canceled.get()) {
14.87 listener.executionFinished(-1);
14.88 @@ -260,11 +267,13 @@
14.89 }
14.90 }
14.91 ExecutionListener listener = new ExecutionListener() {
14.92 + @Override
14.93 public void executionStarted(int pid) {
14.94 for(ExecutionListener listener : listeners){
14.95 listener.executionStarted(pid);
14.96 }
14.97 }
14.98 + @Override
14.99 public void executionFinished(int rc) {
14.100 if (rc == 0) {
14.101 postClean(false);
14.102 @@ -276,7 +285,7 @@
14.103 }
14.104 };
14.105 if (TRACE) {
14.106 - logger.log(Level.INFO, "#" + qmake.getPrimaryFile().getPath() + " " + arguments); // NOI18N
14.107 + logger.log(Level.INFO, "#{0} {1}", new Object[]{qmake.getPrimaryFile().getPath(), arguments}); // NOI18N
14.108 }
14.109 if (canceled.get()) {
14.110 listener.executionFinished(-1);
14.111 @@ -296,11 +305,13 @@
14.112 }
14.113 }
14.114 ExecutionListener listener = new ExecutionListener() {
14.115 + @Override
14.116 public void executionStarted(int pid) {
14.117 for(ExecutionListener listener : listeners){
14.118 listener.executionStarted(pid);
14.119 }
14.120 }
14.121 + @Override
14.122 public void executionFinished(int rc) {
14.123 if (rc == 0) {
14.124 postClean(false);
14.125 @@ -312,7 +323,7 @@
14.126 }
14.127 };
14.128 if (TRACE) {
14.129 - logger.log(Level.INFO, "#" + configure.getPrimaryFile().getPath() + " " + arguments); // NOI18N
14.130 + logger.log(Level.INFO, "#{0} {1}", new Object[]{configure.getPrimaryFile().getPath(), arguments}); // NOI18N
14.131 }
14.132 if (canceled.get()) {
14.133 listener.executionFinished(-1);
14.134 @@ -328,6 +339,7 @@
14.135
14.136 private void postClean(final boolean notifyStart) {
14.137 ExecutionListener listener = new ExecutionListener() {
14.138 + @Override
14.139 public void executionStarted(int pid) {
14.140 if (notifyStart) {
14.141 for(ExecutionListener listener : listeners){
14.142 @@ -335,12 +347,13 @@
14.143 }
14.144 }
14.145 }
14.146 + @Override
14.147 public void executionFinished(int rc) {
14.148 postMake();
14.149 }
14.150 };
14.151 if (TRACE) {
14.152 - logger.log(Level.INFO, "#make -f " + make.getPrimaryFile().getPath() + " clean"); // NOI18N
14.153 + logger.log(Level.INFO, "#make -f {0} clean", make.getPrimaryFile().getPath()); // NOI18N
14.154 }
14.155 if (canceled.get()) {
14.156 listener.executionFinished(-1);
14.157 @@ -352,7 +365,7 @@
14.158 private void postMake(){
14.159 String arguments = getConfigureArguments(make.getPrimaryFile().getPath(), null, cFlags, cxxFlags, linkerFlags, isSunCompiler());
14.160 if (TRACE) {
14.161 - logger.log(Level.INFO, "#make -f " + make.getPrimaryFile().getPath()); // NOI18N
14.162 + logger.log(Level.INFO, "#make -f {0}", make.getPrimaryFile().getPath()); // NOI18N
14.163 }
14.164 Node node = make.getNodeDelegate();
14.165 ExecutionSupport ses = node.getCookie(ExecutionSupport.class);
14.166 @@ -365,8 +378,10 @@
14.167 }
14.168 }
14.169 ExecutionListener listener = new ExecutionListener() {
14.170 + @Override
14.171 public void executionStarted(int pid) {
14.172 }
14.173 + @Override
14.174 public void executionFinished(int rc) {
14.175 for(ExecutionListener listener : listeners){
14.176 listener.executionFinished(rc);
14.177 @@ -605,7 +620,7 @@
14.178 }
14.179
14.180 private String getCCompilerName(){
14.181 - String path = getToolPath(Tool.CCompiler);
14.182 + String path = getToolPath(ToolKind.CCompiler);
14.183 if (path == null) {
14.184 if (isSunCompiler()) {
14.185 return "cc"; // NOI18N
14.186 @@ -617,7 +632,7 @@
14.187 }
14.188
14.189 private String getCppCompilerName(){
14.190 - String path = getToolPath(Tool.CCCompiler);
14.191 + String path = getToolPath(ToolKind.CCCompiler);
14.192 if (path == null) {
14.193 if (isSunCompiler()) {
14.194 return "CC"; // NOI18N
14.195 @@ -628,7 +643,7 @@
14.196 return path;
14.197 }
14.198
14.199 - private String getToolPath(int tool){
14.200 + private String getToolPath(ToolKind tool){
14.201 Tool compiler = compilerSet.findTool(tool);
14.202 if (compiler == null) {
14.203 return null;
15.1 --- a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/wizard/bridge/ProjectBridge.java Mon Feb 01 12:23:06 2010 +0100
15.2 +++ b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/wizard/bridge/ProjectBridge.java Mon Feb 01 12:24:26 2010 +0100
15.3 @@ -54,7 +54,7 @@
15.4 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
15.5 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
15.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
15.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
15.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
15.9 import org.netbeans.modules.cnd.api.utils.IpeUtils;
15.10 import org.netbeans.modules.cnd.makeproject.api.ProjectGenerator;
15.11 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
15.12 @@ -195,13 +195,13 @@
15.13 MakeConfiguration makeConfiguration = item.getFolder().getConfigurationDescriptor().getActiveConfiguration();
15.14 ItemConfiguration itemConfiguration = item.getItemConfiguration(makeConfiguration);
15.15 switch(itemConfiguration.getTool()) {
15.16 - case Tool.CCCompiler:
15.17 + case CCCompiler:
15.18 itemConfiguration.setCCCompilerConfiguration(conf.getCCCompilerConfiguration());
15.19 break;
15.20 - case Tool.CCompiler:
15.21 + case CCompiler:
15.22 itemConfiguration.setCCompilerConfiguration(conf.getCCompilerConfiguration());
15.23 break;
15.24 - case Tool.CustomTool:
15.25 + case CustomTool:
15.26 itemConfiguration.setCustomToolConfiguration(conf.getCustomToolConfiguration());
15.27 break;
15.28 }
15.29 @@ -376,8 +376,8 @@
15.30 if (itemConfiguration == null) {
15.31 return;
15.32 }
15.33 - if (itemConfiguration.getTool() == Tool.CCCompiler || itemConfiguration.getTool() == Tool.CCompiler) {
15.34 - itemConfiguration.setTool(Tool.CustomTool);
15.35 + if (itemConfiguration.getTool() == ToolKind.CCCompiler || itemConfiguration.getTool() == ToolKind.CCompiler) {
15.36 + itemConfiguration.setTool(ToolKind.CustomTool);
15.37 }
15.38 }
15.39
15.40 @@ -388,12 +388,12 @@
15.41 return;
15.42 }
15.43 if (isCPP) {
15.44 - if (itemConfiguration.getTool() != Tool.CCCompiler) {
15.45 - itemConfiguration.setTool(Tool.CCCompiler);
15.46 + if (itemConfiguration.getTool() != ToolKind.CCCompiler) {
15.47 + itemConfiguration.setTool(ToolKind.CCCompiler);
15.48 }
15.49 } else {
15.50 - if (itemConfiguration.getTool() != Tool.CCompiler) {
15.51 - itemConfiguration.setTool(Tool.CCompiler);
15.52 + if (itemConfiguration.getTool() != ToolKind.CCompiler) {
15.53 + itemConfiguration.setTool(ToolKind.CCompiler);
15.54 }
15.55 }
15.56 }
15.57 @@ -489,7 +489,7 @@
15.58
15.59 private CompilerSet getCompilerSet(){
15.60 MakeConfiguration makeConfiguration = makeConfigurationDescriptor.getActiveConfiguration();
15.61 - return CompilerSetManager.getDefault(makeConfiguration.getDevelopmentHost().getExecutionEnvironment()).getCompilerSet(makeConfiguration.getCompilerSet().getValue());
15.62 + return CompilerSetManager.get(makeConfiguration.getDevelopmentHost().getExecutionEnvironment()).getCompilerSet(makeConfiguration.getCompilerSet().getValue());
15.63 }
15.64
15.65 public String getCygwinDrive(){
15.66 @@ -522,9 +522,9 @@
15.67 CompilerSet compilerSet = getCompilerSet();
15.68 BasicCompiler compiler;
15.69 if (isCPP) {
15.70 - compiler = (BasicCompiler)compilerSet.getTool(Tool.CCCompiler);
15.71 + compiler = (BasicCompiler)compilerSet.getTool(ToolKind.CCCompiler);
15.72 } else {
15.73 - compiler = (BasicCompiler)compilerSet.getTool(Tool.CCompiler);
15.74 + compiler = (BasicCompiler)compilerSet.getTool(ToolKind.CCompiler);
15.75 }
15.76 for(Object o :compiler.getSystemIncludeDirectories()){
15.77 String path = (String)o;
15.78 @@ -568,9 +568,9 @@
15.79 CompilerSet compilerSet = getCompilerSet();
15.80 BasicCompiler compiler;
15.81 if (isCPP) {
15.82 - compiler = (BasicCompiler)compilerSet.getTool(Tool.CCCompiler);
15.83 + compiler = (BasicCompiler)compilerSet.getTool(ToolKind.CCCompiler);
15.84 } else {
15.85 - compiler = (BasicCompiler)compilerSet.getTool(Tool.CCompiler);
15.86 + compiler = (BasicCompiler)compilerSet.getTool(ToolKind.CCompiler);
15.87 }
15.88 for(Object o :compiler.getSystemPreprocessorSymbols()){
15.89 String macro = (String)o;
16.1 --- a/cnd.discovery/test/unit/src/org/netbeans/modules/cnd/discovery/project/MakeProjectTestBase.java Mon Feb 01 12:23:06 2010 +0100
16.2 +++ b/cnd.discovery/test/unit/src/org/netbeans/modules/cnd/discovery/project/MakeProjectTestBase.java Mon Feb 01 12:24:26 2010 +0100
16.3 @@ -129,7 +129,7 @@
16.4 shutdownModel();
16.5 }
16.6
16.7 - private final void shutdownModel() {
16.8 + private void shutdownModel() {
16.9 ModelImpl model = (ModelImpl) CsmModelAccessor.getModel();
16.10 waitModelTasks(model);
16.11 model.shutdown();
16.12 @@ -172,28 +172,28 @@
16.13
16.14 public void performTestProject(String URL, List<String> additionalScripts, boolean useSunCompilers, final String subFolder){
16.15 Map<String, String> tools = findTools();
16.16 - CompilerSet def = CompilerSetManager.getDefault().getDefaultCompilerSet();
16.17 + CompilerSet def = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
16.18 if (useSunCompilers) {
16.19 - if (def != null && def.isGnuCompiler()) {
16.20 - for(CompilerSet set : CompilerSetManager.getDefault().getCompilerSets()){
16.21 - if (set.isSunCompiler()) {
16.22 - CompilerSetManager.getDefault().setDefault(set);
16.23 + if (def != null && def.getCompilerFlavor().isGnuCompiler()) {
16.24 + for(CompilerSet set : CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSets()){
16.25 + if (set.getCompilerFlavor().isSunStudioCompiler()) {
16.26 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).setDefault(set);
16.27 break;
16.28 }
16.29 }
16.30 }
16.31 } else {
16.32 - if (def != null && def.isSunCompiler()) {
16.33 - for(CompilerSet set : CompilerSetManager.getDefault().getCompilerSets()){
16.34 - if (set.isGnuCompiler()) {
16.35 - CompilerSetManager.getDefault().setDefault(set);
16.36 + if (def != null && def.getCompilerFlavor().isSunStudioCompiler()) {
16.37 + for(CompilerSet set : CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSets()){
16.38 + if (set.getCompilerFlavor().isGnuCompiler()) {
16.39 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).setDefault(set);
16.40 break;
16.41 }
16.42 }
16.43 }
16.44 }
16.45 - def = CompilerSetManager.getDefault().getDefaultCompilerSet();
16.46 - final boolean isSUN = def != null ? def.isSunCompiler() : false;
16.47 + def = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
16.48 + final boolean isSUN = def != null ? def.getCompilerFlavor().isSunStudioCompiler() : false;
16.49 if (tools == null) {
16.50 assertTrue("Please install required tools.", false);
16.51 System.err.println("Test did not run because required tools do not found");
16.52 @@ -257,9 +257,9 @@
16.53 return "-spec macx-g++ QMAKE_CFLAGS=\"-g3 -gdwarf-2\" QMAKE_CXXFLAGS=\"-g3 -gdwarf-2\"";
16.54 } else {
16.55 if (Utilities.isWindows()) {
16.56 - for (CompilerSet set : CompilerSetManager.getDefault().getCompilerSets()){
16.57 + for (CompilerSet set : CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSets()){
16.58 if (set.getCompilerFlavor().getToolchainDescriptor().getName().startsWith("MinGW")) {
16.59 - CompilerSetManager.getDefault().setDefault(set);
16.60 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).setDefault(set);
16.61 break;
16.62 }
16.63 }
17.1 --- a/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/GizmoConfigurationOptions.java Mon Feb 01 12:23:06 2010 +0100
17.2 +++ b/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/GizmoConfigurationOptions.java Mon Feb 01 12:24:26 2010 +0100
17.3 @@ -124,13 +124,13 @@
17.4 }
17.5
17.6 //if we have sun studio compiler along compiler collections presentedCompiler
17.7 - CompilerSetManager compilerSetManager = CompilerSetManager.getDefault(((MakeConfiguration) activeConfiguration).getDevelopmentHost().getExecutionEnvironment());
17.8 + CompilerSetManager compilerSetManager = CompilerSetManager.get(((MakeConfiguration) activeConfiguration).getDevelopmentHost().getExecutionEnvironment());
17.9 List<CompilerSet> compilers = compilerSetManager.getCompilerSets();
17.10
17.11 boolean hasSunStudio = false;
17.12
17.13 for (CompilerSet cs : compilers) {
17.14 - if (cs.isSunCompiler()) {
17.15 + if (cs.getCompilerFlavor().isSunStudioCompiler()) {
17.16 hasSunStudio = true;
17.17 break;
17.18 }
17.19 @@ -261,7 +261,7 @@
17.20 }
17.21 }
17.22
17.23 - private final void notifyListeners(String toolName, boolean isEnabled) {
17.24 + private void notifyListeners(String toolName, boolean isEnabled) {
17.25 synchronized (this) {
17.26 for (DLightConfigurationOptionsListener l : listeners) {
17.27 l.dlightToolEnabling(toolName, isEnabled);
18.1 --- a/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/SunStudioLocatorCndImpl.java Mon Feb 01 12:23:06 2010 +0100
18.2 +++ b/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/SunStudioLocatorCndImpl.java Mon Feb 01 12:24:26 2010 +0100
18.3 @@ -45,6 +45,7 @@
18.4 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
18.5 import org.netbeans.modules.dlight.spi.SunStudioLocator;
18.6 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
18.7 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
18.8
18.9 /**
18.10 *
18.11 @@ -62,13 +63,13 @@
18.12 @Override
18.13 public Collection<SunStudioDescription> getSunStudioLocations() {
18.14 Collection<SunStudioDescription> result = new ArrayList<SunStudioDescription>();
18.15 - List<CompilerSet> compilerCollections = env.isLocal() ? CompilerSetManager.getDefault().getCompilerSets() : CompilerSetManager.getDefault(env).getCompilerSets(); // NOI18N
18.16 + List<CompilerSet> compilerCollections = env.isLocal() ? CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSets() : CompilerSetManager.get(env).getCompilerSets(); // NOI18N
18.17 if (compilerCollections.size() == 1 && compilerCollections.get(0).getName().equals(CompilerSet.None)) {
18.18 return result;
18.19 }
18.20
18.21 for (CompilerSet compilerSet : compilerCollections) {
18.22 - if (!compilerSet.isSunCompiler()) {
18.23 + if (!compilerSet.getCompilerFlavor().isSunStudioCompiler()) {
18.24 continue;
18.25 }
18.26 String binDir = compilerSet.getDirectory();
19.1 --- a/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/actions/GizmoRunActionHandler.java Mon Feb 01 12:23:06 2010 +0100
19.2 +++ b/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/actions/GizmoRunActionHandler.java Mon Feb 01 12:24:26 2010 +0100
19.3 @@ -157,12 +157,12 @@
19.4 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
19.5 String binDir = compilerSet.getDirectory();
19.6 String demangle_utility = SS_FAMILIY;
19.7 - if (compilerSet.isGnuCompiler()) {
19.8 + if (compilerSet.getCompilerFlavor().isGnuCompiler()) {
19.9 demangle_utility = GNU_FAMILIY;
19.10 }
19.11 String dem_util_path = binDir + "/" + demangle_utility; //NOI18N BTW: isn't it better to use File.Separator?
19.12 targetConf.putInfo(GizmoServiceInfo.GIZMO_DEMANGLE_UTILITY, dem_util_path);
19.13 - targetConf.putInfo(GizmoServiceInfo.CPP_COMPILER, compilerSet.isGnuCompiler() ? CppSymbolDemanglerFactoryImpl.CPPCompiler.GNU.toString() : CppSymbolDemanglerFactoryImpl.CPPCompiler.SS.toString());
19.14 + targetConf.putInfo(GizmoServiceInfo.CPP_COMPILER, compilerSet.getCompilerFlavor().isGnuCompiler() ? CppSymbolDemanglerFactoryImpl.CPPCompiler.GNU.toString() : CppSymbolDemanglerFactoryImpl.CPPCompiler.SS.toString());
19.15 targetConf.putInfo(GizmoServiceInfo.CPP_COMPILER_BIN_PATH, binDir);
19.16 targetConf.setWorkingDirectory(runDirectory);
19.17 int consoleType = pae.getProfile().getConsoleType().getValue();
20.1 --- a/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/options/GizmoOptionsImpl.java Mon Feb 01 12:23:06 2010 +0100
20.2 +++ b/cnd.gizmo/src/org/netbeans/modules/cnd/gizmo/options/GizmoOptionsImpl.java Mon Feb 01 12:24:26 2010 +0100
20.3 @@ -200,11 +200,11 @@
20.4 ExecutionEnvironment execEnv = getMakeConfiguration().getDevelopmentHost().getExecutionEnvironment();
20.5
20.6 //if we have sun studio compiler along compiler collections presentedCompiler
20.7 - CompilerSetManager compilerSetManager = CompilerSetManager.getDefault(execEnv);
20.8 + CompilerSetManager compilerSetManager = CompilerSetManager.get(execEnv);
20.9 List<CompilerSet> compilers = compilerSetManager.getCompilerSets();
20.10 boolean hasSunStudio = false;
20.11 for (CompilerSet cs : compilers) {
20.12 - if (cs.isSunCompiler()) {
20.13 + if (cs.getCompilerFlavor().isSunStudioCompiler()) {
20.14 hasSunStudio = true;
20.15 break;
20.16 }
21.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/DefaultSystemSettingsImpl.java Mon Feb 01 12:23:06 2010 +0100
21.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/DefaultSystemSettingsImpl.java Mon Feb 01 12:24:26 2010 +0100
21.3 @@ -42,11 +42,13 @@
21.4 import java.util.Collections;
21.5 import java.util.List;
21.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
21.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
21.8 -import org.netbeans.modules.cnd.toolchain.api.Tool;
21.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
21.10 import org.netbeans.modules.cnd.api.project.DefaultSystemSettings;
21.11 import org.netbeans.modules.cnd.api.project.NativeFileItem;
21.12 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
21.13 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
21.14 +import org.netbeans.modules.cnd.toolchain.api.Tool;
21.15 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
21.16
21.17 /**
21.18 * This is an implementation of DefaultSystemSetting.
21.19 @@ -56,18 +58,18 @@
21.20 @org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.cnd.api.project.DefaultSystemSettings.class)
21.21 public class DefaultSystemSettingsImpl extends DefaultSystemSettings {
21.22 private static BasicCompiler getDefaultCompiler(NativeFileItem.Language language) {
21.23 - int kind;
21.24 + ToolKind kind;
21.25 switch (language) {
21.26 case C:
21.27 - kind = Tool.CCompiler;
21.28 + kind = ToolKind.CCompiler;
21.29 break;
21.30 case CPP:
21.31 - kind = Tool.CCCompiler;
21.32 + kind = ToolKind.CCCompiler;
21.33 break;
21.34 default:
21.35 return null;
21.36 }
21.37 - CompilerSet compilerSet = CompilerSetManager.getDefault().getDefaultCompilerSet();
21.38 + CompilerSet compilerSet = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
21.39 Tool compiler = compilerSet.getTool(kind);
21.40 if (compiler instanceof BasicCompiler) {
21.41 return (BasicCompiler)compiler;
21.42 @@ -75,6 +77,7 @@
21.43 return null;
21.44 }
21.45
21.46 + @Override
21.47 public List<String> getSystemIncludes(NativeFileItem.Language language) {
21.48 BasicCompiler compiler = getDefaultCompiler(language);
21.49 if (compiler != null) {
21.50 @@ -84,6 +87,7 @@
21.51 }
21.52 }
21.53
21.54 + @Override
21.55 public List<String> getSystemMacros(NativeFileItem.Language language) {
21.56 BasicCompiler compiler = getDefaultCompiler(language);
21.57 if (compiler != null) {
22.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java Mon Feb 01 12:23:06 2010 +0100
22.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java Mon Feb 01 12:24:26 2010 +0100
22.3 @@ -59,10 +59,10 @@
22.4 import javax.swing.SwingUtilities;
22.5 import org.netbeans.api.project.ProjectInformation;
22.6 import org.netbeans.api.project.ProjectUtils;
22.7 -import org.netbeans.modules.cnd.toolchain.actions.BuildToolsAction;
22.8 +import org.netbeans.modules.cnd.toolchain.ui.api.BuildToolsAction;
22.9 import org.netbeans.modules.cnd.actions.ShellRunAction;
22.10 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
22.11 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
22.12 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
22.13 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
22.14 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
22.15 import org.netbeans.modules.cnd.makeproject.api.MakeArtifact;
22.16 @@ -82,7 +82,7 @@
22.17 import org.netbeans.modules.cnd.makeproject.api.runprofiles.RunProfile;
22.18 import org.netbeans.modules.cnd.makeproject.ui.utils.ConfSelectorPanel;
22.19 import org.netbeans.modules.cnd.api.utils.IpeUtils;
22.20 -import org.netbeans.modules.cnd.toolchain.api.Tool;
22.21 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
22.22 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
22.23 import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
22.24 import org.netbeans.modules.cnd.api.remote.ServerList;
22.25 @@ -101,6 +101,9 @@
22.26 import org.netbeans.modules.cnd.makeproject.api.platforms.Platform;
22.27 import org.netbeans.modules.cnd.makeproject.api.platforms.Platforms;
22.28 import org.netbeans.modules.cnd.makeproject.api.wizards.ValidateInstrumentationProvider;
22.29 +import org.netbeans.modules.cnd.toolchain.api.Tool;
22.30 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
22.31 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetFactory;
22.32 import org.netbeans.modules.cnd.toolchain.ui.api.LocalToolsPanelModel;
22.33 import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelModel;
22.34 import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelSupport;
22.35 @@ -360,8 +363,8 @@
22.36 }
22.37 record.validate(true);
22.38 // initialize compiler sets for remote host if needed
22.39 - CompilerSetManager csm = CompilerSetManager.getDefault(record.getExecutionEnvironment());
22.40 - csm.initialize(true, true);
22.41 + CompilerSetManager csm = CompilerSetManager.get(record.getExecutionEnvironment());
22.42 + csm.initialize(true, true, null);
22.43 } catch (CancellationException ex) {
22.44 cancel();
22.45 } catch (Exception e) {
22.46 @@ -780,24 +783,24 @@
22.47 if (itemConfiguration.getExcluded().getValue()) {
22.48 return false;
22.49 }
22.50 - if (itemConfiguration.getTool() == Tool.CustomTool && !itemConfiguration.getCustomToolConfiguration().getModified()) {
22.51 + if (itemConfiguration.getTool() == ToolKind.CustomTool && !itemConfiguration.getCustomToolConfiguration().getModified()) {
22.52 return false;
22.53 }
22.54 MakeArtifact makeArtifact = new MakeArtifact(pd, conf);
22.55 String outputFile = null;
22.56 - if (itemConfiguration.getTool() == Tool.CCompiler) {
22.57 + if (itemConfiguration.getTool() == ToolKind.CCompiler) {
22.58 CCompilerConfiguration cCompilerConfiguration = itemConfiguration.getCCompilerConfiguration();
22.59 outputFile = cCompilerConfiguration.getOutputFile(item, conf, true);
22.60 - } else if (itemConfiguration.getTool() == Tool.CCCompiler) {
22.61 + } else if (itemConfiguration.getTool() == ToolKind.CCCompiler) {
22.62 CCCompilerConfiguration ccCompilerConfiguration = itemConfiguration.getCCCompilerConfiguration();
22.63 outputFile = ccCompilerConfiguration.getOutputFile(item, conf, true);
22.64 - } else if (itemConfiguration.getTool() == Tool.FortranCompiler) {
22.65 + } else if (itemConfiguration.getTool() == ToolKind.FortranCompiler) {
22.66 FortranCompilerConfiguration fortranCompilerConfiguration = itemConfiguration.getFortranCompilerConfiguration();
22.67 outputFile = fortranCompilerConfiguration.getOutputFile(item, conf, true);
22.68 - } else if (itemConfiguration.getTool() == Tool.Assembler) {
22.69 + } else if (itemConfiguration.getTool() == ToolKind.Assembler) {
22.70 AssemblerConfiguration assemblerConfiguration = itemConfiguration.getAssemblerConfiguration();
22.71 outputFile = assemblerConfiguration.getOutputFile(item, conf, true);
22.72 - } else if (itemConfiguration.getTool() == Tool.CustomTool) {
22.73 + } else if (itemConfiguration.getTool() == ToolKind.CustomTool) {
22.74 CustomToolConfiguration customToolConfiguration = itemConfiguration.getCustomToolConfiguration();
22.75 outputFile = customToolConfiguration.getOutputs().getValue();
22.76 }
22.77 @@ -883,7 +886,7 @@
22.78 Item item = getProjectDescriptor().getProjectItems()[i];
22.79 ItemConfiguration itemConfiguration = item.getItemConfiguration(conf);
22.80 if (!itemConfiguration.getExcluded().getValue() &&
22.81 - (itemConfiguration.getTool() != Tool.CustomTool || itemConfiguration.getCustomToolConfiguration().getCommandLine().getValue().length() > 0)) {
22.82 + (itemConfiguration.getTool() != ToolKind.CustomTool || itemConfiguration.getCustomToolConfiguration().getCommandLine().getValue().length() > 0)) {
22.83 ret = true;
22.84 break;
22.85 }
22.86 @@ -983,7 +986,7 @@
22.87 if (itemConfiguration.getExcluded().getValue()) {
22.88 return false;
22.89 }
22.90 - if (itemConfiguration.getTool() == Tool.CustomTool && !itemConfiguration.getCustomToolConfiguration().getModified()) {
22.91 + if (itemConfiguration.getTool() == ToolKind.CustomTool && !itemConfiguration.getCustomToolConfiguration().getModified()) {
22.92 return false;
22.93 }
22.94 if (conf.isMakefileConfiguration()) {
22.95 @@ -1025,7 +1028,7 @@
22.96 String cmd = null;
22.97 CompilerSet cs = conf.getCompilerSet().getCompilerSet();
22.98 if (cs != null) {
22.99 - cmd = cs.getTool(Tool.MakeTool).getPath();
22.100 + cmd = cs.getTool(ToolKind.MakeTool).getPath();
22.101 } else {
22.102 assert false;
22.103 cmd = "make"; // NOI18N
22.104 @@ -1073,7 +1076,7 @@
22.105 // Check build/run/debug platform vs. host platform
22.106 int buildPlatformId = conf.getDevelopmentHost().getBuildPlatform();
22.107 ExecutionEnvironment execEnv = conf.getDevelopmentHost().getExecutionEnvironment();
22.108 - int hostPlatformId = CompilerSetManager.getDefault(execEnv).getPlatform();
22.109 + int hostPlatformId = CompilerSetManager.get(execEnv).getPlatform();
22.110 if (buildPlatformId != hostPlatformId) {
22.111 if (!conf.isMakefileConfiguration()) {
22.112 Platform buildPlatform = Platforms.getPlatform(buildPlatformId);
22.113 @@ -1089,35 +1092,35 @@
22.114 if (csconf.getFlavor() != null && csconf.getFlavor().equals("Unknown")) { // NOI18N
22.115 // Confiiguration was created with unknown tool set. Use the now default one.
22.116 csname = csconf.getOption();
22.117 - cs = CompilerSetManager.getDefault(env).getCompilerSet(csname);
22.118 + cs = CompilerSetManager.get(env).getCompilerSet(csname);
22.119 if (cs == null) {
22.120 - cs = CompilerSetManager.getDefault(env).getDefaultCompilerSet();
22.121 + cs = CompilerSetManager.get(env).getDefaultCompilerSet();
22.122 }
22.123 errs.add(NbBundle.getMessage(MakeActionProvider.class, "ERR_UnknownCompiler", csname)); // NOI18N
22.124 runBTA = true;
22.125 } else if (csconf.isValid()) {
22.126 csname = csconf.getOption();
22.127 - cs = CompilerSetManager.getDefault(env).getCompilerSet(csname);
22.128 + cs = CompilerSetManager.get(env).getCompilerSet(csname);
22.129 } else {
22.130 csname = csconf.getOldName();
22.131 CompilerFlavor flavor = null;
22.132 if (csconf.getFlavor() != null) {
22.133 - flavor = CompilerFlavor.toFlavor(csconf.getFlavor(), conf.getPlatformInfo().getPlatform());
22.134 + flavor = CompilerFlavorAccessor.toFlavor(csconf.getFlavor(), conf.getPlatformInfo().getPlatform());
22.135 }
22.136 if (flavor == null) {
22.137 - flavor = CompilerFlavor.getUnknown(conf.getPlatformInfo().getPlatform());
22.138 + flavor = CompilerFlavorAccessor.getUnknown(conf.getPlatformInfo().getPlatform());
22.139 }
22.140 - cs = CompilerSet.getCustomCompilerSet("", flavor, csconf.getOldName());
22.141 - CompilerSetManager.getDefault(env).add(cs);
22.142 + cs = CompilerSetFactory.getCustomCompilerSet("", flavor, csconf.getOldName());
22.143 + CompilerSetManager.get(env).add(cs);
22.144 csconf.setValid();
22.145 }
22.146
22.147 - Tool cTool = cs.getTool(Tool.CCompiler);
22.148 - Tool cppTool = cs.getTool(Tool.CCCompiler);
22.149 - Tool fTool = cs.getTool(Tool.FortranCompiler);
22.150 - Tool asTool = cs.getTool(Tool.Assembler);
22.151 - Tool makeTool = cs.getTool(Tool.MakeTool);
22.152 - Tool qmakeTool = cs.getTool(Tool.QMakeTool);
22.153 + Tool cTool = cs.getTool(ToolKind.CCompiler);
22.154 + Tool cppTool = cs.getTool(ToolKind.CCCompiler);
22.155 + Tool fTool = cs.getTool(ToolKind.FortranCompiler);
22.156 + Tool asTool = cs.getTool(ToolKind.Assembler);
22.157 + Tool makeTool = cs.getTool(ToolKind.MakeTool);
22.158 + Tool qmakeTool = cs.getTool(ToolKind.QMakeTool);
22.159
22.160 if (cancelled.get()) {
22.161 return false;
22.162 @@ -1306,7 +1309,7 @@
22.163 /** cache for valid executables */
22.164 private static Map<String, Boolean> validExecutablesCache = new HashMap<String, Boolean>();
22.165
22.166 - private static final boolean isValidExecutable(String path, PlatformInfo pi) {
22.167 + private static boolean isValidExecutable(String path, PlatformInfo pi) {
22.168 return existsImpl(path, pi, true);
22.169 }
22.170 private static boolean exists(String path, PlatformInfo pi) {
23.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java Mon Feb 01 12:23:06 2010 +0100
23.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java Mon Feb 01 12:24:26 2010 +0100
23.3 @@ -70,7 +70,7 @@
23.4 import org.netbeans.api.project.SourceGroup;
23.5 import org.netbeans.api.queries.FileEncodingQuery;
23.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
23.7 -import org.netbeans.modules.cnd.toolchain.api.ToolchainProject;
23.8 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainProject;
23.9 import org.netbeans.modules.cnd.api.remote.RemoteProject;
23.10 import org.netbeans.modules.cnd.api.utils.CndFileVisibilityQuery;
23.11 import org.netbeans.modules.cnd.api.utils.IpeUtils;
24.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java Mon Feb 01 12:23:06 2010 +0100
24.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java Mon Feb 01 12:24:26 2010 +0100
24.3 @@ -59,7 +59,7 @@
24.4 import org.netbeans.modules.cnd.api.project.NativeProject;
24.5 import org.netbeans.modules.cnd.api.project.NativeProjectItemsListener;
24.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
24.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
24.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
24.9 import org.netbeans.modules.cnd.makeproject.api.configurations.BooleanConfiguration;
24.10 import org.netbeans.modules.cnd.makeproject.api.configurations.Configuration;
24.11 import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider;
24.12 @@ -90,6 +90,7 @@
24.13 this.projectDescriptorProvider = projectDescriptorProvider;
24.14 }
24.15
24.16 + @Override
24.17 public void runOnCodeModelReadiness(Runnable task) {
24.18 if (getMakeConfigurationDescriptor() != null) {
24.19 getMakeConfigurationDescriptor().getConfs().runOnCodeModelReadiness(task);
24.20 @@ -120,10 +121,12 @@
24.21 return null;
24.22 }
24.23
24.24 + @Override
24.25 public Object getProject() {
24.26 return this.project;
24.27 }
24.28
24.29 + @Override
24.30 public List<String> getSourceRoots() {
24.31 MakeConfigurationDescriptor descriptor = getMakeConfigurationDescriptor();
24.32 if (descriptor != null) {
24.33 @@ -135,14 +138,17 @@
24.34 return Collections.<String>emptyList();
24.35 }
24.36
24.37 + @Override
24.38 public String getProjectRoot() {
24.39 return FileUtil.toFile(project.getProjectDirectory()).getPath();
24.40 }
24.41
24.42 + @Override
24.43 public String getProjectDisplayName() {
24.44 return ProjectUtils.getInformation(project).getDisplayName();
24.45 }
24.46
24.47 + @Override
24.48 public List<NativeFileItem> getAllFiles() {
24.49 List<NativeFileItem> list = new ArrayList<NativeFileItem>();
24.50 if (getMakeConfigurationDescriptor() == null || getMakeConfiguration() == null) {
24.51 @@ -163,6 +169,7 @@
24.52 }
24.53
24.54 private Reference<List<NativeProject>> cachedDependency = new SoftReference<List<NativeProject>>(null);
24.55 + @Override
24.56 public List<NativeProject> getDependences() {
24.57 List<NativeProject> cachedList = cachedDependency.get();
24.58 if (cachedList == null) {
24.59 @@ -193,19 +200,21 @@
24.60 return cachedList;
24.61 }
24.62
24.63 + @Override
24.64 public void addProjectItemsListener(NativeProjectItemsListener listener) {
24.65 synchronized (listeners) {
24.66 - if (listeners.size() == 0) {
24.67 + if (listeners.isEmpty()) {
24.68 addMyListeners();
24.69 }
24.70 listeners.add(listener);
24.71 }
24.72 }
24.73
24.74 + @Override
24.75 public void removeProjectItemsListener(NativeProjectItemsListener listener) {
24.76 synchronized (listeners) {
24.77 listeners.remove(listener);
24.78 - if (listeners.size() == 0) {
24.79 + if (listeners.isEmpty()) {
24.80 removeMyListeners();
24.81 }
24.82 }
24.83 @@ -220,8 +229,8 @@
24.84 Iterator<NativeFileItem> iter = nativeFileIetms.iterator();
24.85 while (iter.hasNext()) {
24.86 NativeFileItem nativeFileIetm = iter.next();
24.87 - int tool = ((Item) nativeFileIetm).getDefaultTool();
24.88 - if (tool == Tool.CustomTool
24.89 + ToolKind tool = ((Item) nativeFileIetm).getDefaultTool();
24.90 + if (tool == ToolKind.CustomTool
24.91 // check of mime type is better to support headers without extensions
24.92 && !MIMENames.HEADER_MIME_TYPE.equals(((Item) nativeFileIetm).getMIMEType())) {
24.93 continue; // IZ 87407
24.94 @@ -320,10 +329,11 @@
24.95 @SuppressWarnings("unchecked")
24.96 private List<NativeProjectItemsListener> getListenersCopy() {
24.97 synchronized (listeners) {
24.98 - return (listeners.size() == 0) ? Collections.EMPTY_LIST : new ArrayList<NativeProjectItemsListener>(listeners);
24.99 + return (listeners.isEmpty()) ? Collections.EMPTY_LIST : new ArrayList<NativeProjectItemsListener>(listeners);
24.100 }
24.101 }
24.102
24.103 + @Override
24.104 public NativeFileItem findFileItem(File file) {
24.105 MakeConfigurationDescriptor descr = getMakeConfigurationDescriptor();
24.106 if (descr != null) {
24.107 @@ -338,6 +348,7 @@
24.108 }
24.109 if (SwingUtilities.isEventDispatchThread()) {
24.110 RequestProcessor.getDefault().post(new Runnable() {
24.111 + @Override
24.112 public void run() {
24.113 checkConfigurationChangedWorker(oldConf, newConf);
24.114 }
24.115 @@ -355,7 +366,7 @@
24.116 List<NativeFileItem> deleted = new ArrayList<NativeFileItem>();
24.117
24.118 synchronized (listeners) {
24.119 - if (listeners.size() == 0) {
24.120 + if (listeners.isEmpty()) {
24.121 return;
24.122 }
24.123 }
24.124 @@ -405,8 +416,8 @@
24.125 }
24.126
24.127 if ((newItemConf.getExcluded().getValue() ^ oldItemConf.getExcluded().getValue()) &&
24.128 - (newItemConf.getTool() == Tool.CCompiler ||
24.129 - newItemConf.getTool() == Tool.CCCompiler ||
24.130 + (newItemConf.getTool() == ToolKind.CCompiler ||
24.131 + newItemConf.getTool() == ToolKind.CCCompiler ||
24.132 items[i].hasHeaderOrSourceExtension(true, true))) {
24.133 if (newItemConf.getExcluded().getValue()) {
24.134 // excluded
24.135 @@ -422,8 +433,8 @@
24.136 continue;
24.137 }
24.138
24.139 - if (newItemConf.getTool() == Tool.CCompiler) {
24.140 - if (oldItemConf.getTool() != Tool.CCompiler) {
24.141 + if (newItemConf.getTool() == ToolKind.CCompiler) {
24.142 + if (oldItemConf.getTool() != ToolKind.CCompiler) {
24.143 list.add(items[i]);
24.144 continue;
24.145 }
24.146 @@ -436,8 +447,8 @@
24.147 continue;
24.148 }
24.149 }
24.150 - if (newItemConf.getTool() == Tool.CCCompiler) {
24.151 - if (oldItemConf.getTool() != Tool.CCCompiler) {
24.152 + if (newItemConf.getTool() == ToolKind.CCCompiler) {
24.153 + if (oldItemConf.getTool() != ToolKind.CCCompiler) {
24.154 list.add(items[i]);
24.155 continue;
24.156 }
24.157 @@ -459,6 +470,7 @@
24.158 public void checkForChangedItems(final Folder folder, final Item item) {
24.159 if (SwingUtilities.isEventDispatchThread()) {
24.160 RequestProcessor.getDefault().post(new Runnable() {
24.161 + @Override
24.162 public void run() {
24.163 checkForChangedItemsWorker(folder, item);
24.164 }
24.165 @@ -471,7 +483,7 @@
24.166 private void checkForChangedItemsWorker(Folder folder, Item item) {
24.167 clearCache();
24.168 synchronized (listeners) {
24.169 - if (listeners.size() == 0) {
24.170 + if (listeners.isEmpty()) {
24.171 return;
24.172 }
24.173 }
24.174 @@ -518,13 +530,13 @@
24.175 items = folder.getAllItemsAsArray();
24.176 } else if (item != null) {
24.177 ItemConfiguration itemConfiguration = item.getItemConfiguration(getMakeConfiguration()); //ItemConfiguration)getMakeConfiguration().getAuxObject(ItemConfiguration.getId(item.getPath()));
24.178 - if (itemConfiguration.getTool() == Tool.CCompiler) {
24.179 + if (itemConfiguration.getTool() == ToolKind.CCompiler) {
24.180 cIncludeDirectories = itemConfiguration.getCCompilerConfiguration().getIncludeDirectories();
24.181 cInheritIncludes = itemConfiguration.getCCompilerConfiguration().getInheritIncludes();
24.182 cInheritMacros = itemConfiguration.getCCompilerConfiguration().getInheritPreprocessor();
24.183 cPpreprocessorOption = itemConfiguration.getCCompilerConfiguration().getPreprocessorConfiguration();
24.184 }
24.185 - if (itemConfiguration.getTool() == Tool.CCCompiler) {
24.186 + if (itemConfiguration.getTool() == ToolKind.CCCompiler) {
24.187 ccIncludeDirectories = itemConfiguration.getCCCompilerConfiguration().getIncludeDirectories();
24.188 ccInheritIncludes = itemConfiguration.getCCCompilerConfiguration().getInheritIncludes();
24.189 ccPreprocessorOption = itemConfiguration.getCCCompilerConfiguration().getPreprocessorConfiguration();
24.190 @@ -598,8 +610,8 @@
24.191 deleted.add(items[i]);
24.192 continue;
24.193 }
24.194 - if ((cFiles && itemConfiguration.getTool() == Tool.CCompiler) ||
24.195 - (ccFiles && itemConfiguration.getTool() == Tool.CCCompiler) ||
24.196 + if ((cFiles && itemConfiguration.getTool() == ToolKind.CCompiler) ||
24.197 + (ccFiles && itemConfiguration.getTool() == ToolKind.CCCompiler) ||
24.198 items[i].hasHeaderOrSourceExtension(cFiles, ccFiles)) {
24.199 list.add(items[i]);
24.200 }
24.201 @@ -621,6 +633,7 @@
24.202 }
24.203 }
24.204
24.205 + @Override
24.206 public void propertyChange(PropertyChangeEvent evt) {
24.207 if (TRACE){
24.208 System.out.println("propertyChange " + evt.getPropertyName()); // NOI18N
24.209 @@ -639,6 +652,7 @@
24.210 /*
24.211 * Return C++ settings
24.212 **/
24.213 + @Override
24.214 public List<String> getSystemIncludePaths() {
24.215 ArrayList<String> vec = new ArrayList<String>();
24.216 MakeConfiguration makeConfiguration = getMakeConfiguration();
24.217 @@ -647,7 +661,7 @@
24.218 if (compilerSet == null) {
24.219 return vec;
24.220 }
24.221 - BasicCompiler compiler = (BasicCompiler) compilerSet.getTool(Tool.CCCompiler);
24.222 + BasicCompiler compiler = (BasicCompiler) compilerSet.getTool(ToolKind.CCCompiler);
24.223 if (compiler != null) {
24.224 vec.addAll(compiler.getSystemIncludeDirectories());
24.225 }
24.226 @@ -664,6 +678,7 @@
24.227 /*
24.228 * Return C++ settings
24.229 **/
24.230 + @Override
24.231 public List<String> getUserIncludePaths() {
24.232 ArrayList<String> vec = new ArrayList<String>();
24.233 MakeConfiguration makeConfiguration = getMakeConfiguration();
24.234 @@ -688,6 +703,7 @@
24.235 /*
24.236 * Return C++ settings
24.237 **/
24.238 + @Override
24.239 public List<String> getSystemMacroDefinitions() {
24.240 ArrayList<String> vec = new ArrayList<String>();
24.241 MakeConfiguration makeConfiguration = getMakeConfiguration();
24.242 @@ -696,7 +712,7 @@
24.243 if (compilerSet == null) {
24.244 return vec;
24.245 }
24.246 - BasicCompiler compiler = (BasicCompiler) compilerSet.getTool(Tool.CCCompiler);
24.247 + BasicCompiler compiler = (BasicCompiler) compilerSet.getTool(ToolKind.CCCompiler);
24.248 if (compiler != null) {
24.249 vec.addAll(compiler.getSystemPreprocessorSymbols());
24.250 }
24.251 @@ -712,6 +728,7 @@
24.252 /*
24.253 * Return C++ settings
24.254 **/
24.255 + @Override
24.256 public List<String> getUserMacroDefinitions() {
24.257 ArrayList<String> vec = new ArrayList<String>();
24.258 MakeConfiguration makeConfiguration = getMakeConfiguration();
25.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/DefaultProjectActionHandler.java Mon Feb 01 12:23:06 2010 +0100
25.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/DefaultProjectActionHandler.java Mon Feb 01 12:24:26 2010 +0100
25.3 @@ -62,7 +62,7 @@
25.4 import org.netbeans.api.extexecution.print.LineConvertor;
25.5 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
25.6 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
25.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
25.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
25.9 import org.netbeans.modules.nativeexecution.api.ExecutionListener;
25.10 import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
25.11 import org.netbeans.modules.cnd.api.remote.ServerList;
25.12 @@ -73,6 +73,7 @@
25.13 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
25.14 import org.netbeans.modules.cnd.makeproject.api.remote.FilePathAdaptor;
25.15 import org.netbeans.modules.cnd.makeproject.api.runprofiles.RunProfile;
25.16 +import org.netbeans.modules.cnd.makeproject.configurations.CppUtils;
25.17 import org.netbeans.modules.cnd.utils.CndUtils;
25.18 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
25.19 import org.netbeans.modules.nativeexecution.api.NativeProcess;
25.20 @@ -102,6 +103,7 @@
25.21 // second is in canCancel
25.22 private static final boolean RUN_REMOTE_IN_OUTPUT_WINDOW = true;
25.23
25.24 + @Override
25.25 public void init(ProjectActionEvent pae, ProjectActionEvent[] paes) {
25.26 this.pae = pae;
25.27 }
25.28 @@ -120,9 +122,11 @@
25.29 return pae.getProfile().getEnvironment().getenv();
25.30 }
25.31
25.32 + @Override
25.33 public void execute(final InputOutput io) {
25.34 if (SwingUtilities.isEventDispatchThread()) {
25.35 RequestProcessor.getDefault().post(new Runnable() {
25.36 + @Override
25.37 public void run() {
25.38 _execute(io);
25.39 }
25.40 @@ -215,8 +219,8 @@
25.41 env.put(pi.getPathName(), path);
25.42 // Pass QMAKE from compiler set to the Makefile (IZ 174731)
25.43 if (conf.isQmakeConfiguration()) {
25.44 - String qmakePath = conf.getCompilerSet().getCompilerSet().getTool(Tool.QMakeTool).getPath();
25.45 - qmakePath = conf.getCompilerSet().getCompilerSet().normalizeDriveLetter(qmakePath.replace('\\', '/')); // NOI18N
25.46 + String qmakePath = conf.getCompilerSet().getCompilerSet().getTool(ToolKind.QMakeTool).getPath();
25.47 + qmakePath = CppUtils.normalizeDriveLetter(conf.getCompilerSet().getCompilerSet(), qmakePath.replace('\\', '/')); // NOI18N
25.48 args.add("QMAKE=" + IpeUtils.escapeOddCharacters(qmakePath)); // NOI18N
25.49 }
25.50 }
25.51 @@ -312,22 +316,27 @@
25.52 }
25.53 }
25.54
25.55 + @Override
25.56 public void addExecutionListener(ExecutionListener l) {
25.57 if (!listeners.contains(l)) {
25.58 listeners.add(l);
25.59 }
25.60 }
25.61
25.62 + @Override
25.63 public void removeExecutionListener(ExecutionListener l) {
25.64 listeners.remove(l);
25.65 }
25.66
25.67 + @Override
25.68 public boolean canCancel() {
25.69 return true;
25.70 }
25.71
25.72 + @Override
25.73 public void cancel() {
25.74 RequestProcessor.getDefault().post(new Runnable() {
25.75 + @Override
25.76 public void run() {
25.77 Future<Integer> et = executorTask;
25.78 if (et != null) {
25.79 @@ -337,12 +346,14 @@
25.80 });
25.81 }
25.82
25.83 + @Override
25.84 public void executionStarted(int pid) {
25.85 for (ExecutionListener l : listeners) {
25.86 l.executionStarted(pid);
25.87 }
25.88 }
25.89
25.90 + @Override
25.91 public void executionFinished(int rc) {
25.92 for (ExecutionListener l : listeners) {
25.93 l.executionFinished(rc);
25.94 @@ -354,7 +365,7 @@
25.95 return NbBundle.getBundle(DefaultProjectActionHandler.class).getString(s);
25.96 }
25.97
25.98 - protected final static String getString(String key, String ... a1) {
25.99 + protected static String getString(String key, String ... a1) {
25.100 return NbBundle.getMessage(DefaultProjectActionHandler.class, key, a1);
25.101 }
25.102
25.103 @@ -380,6 +391,7 @@
25.104 this.rcfile = rcfile;
25.105 }
25.106
25.107 + @Override
25.108 public void stateChanged(ChangeEvent e) {
25.109 if (!(e instanceof NativeProcessChangeEvent)) {
25.110 return;
25.111 @@ -411,6 +423,7 @@
25.112 {
25.113 closeOutputListener();
25.114 postRunnable = new Runnable() {
25.115 + @Override
25.116 public void run() {
25.117 StringBuilder res = new StringBuilder();
25.118 res.append(MessageFormat.format(getString("TERMINATED"), actionName.toUpperCase())); // NOI18N
25.119 @@ -437,6 +450,7 @@
25.120 {
25.121 closeOutputListener();
25.122 postRunnable = new Runnable() {
25.123 + @Override
25.124 public void run() {
25.125 StringBuilder res = new StringBuilder();
25.126 res.append(MessageFormat.format(getString("FAILED"), actionName.toUpperCase())); // NOI18N
25.127 @@ -463,6 +477,7 @@
25.128 {
25.129 closeOutputListener();
25.130 postRunnable = new Runnable() {
25.131 + @Override
25.132 public void run() {
25.133 StringBuilder res = new StringBuilder();
25.134 int rc = readReturnCode(rcfile, process.exitValue());
25.135 @@ -490,6 +505,7 @@
25.136 }
25.137 }
25.138
25.139 + @Override
25.140 public void run() {
25.141 if (postRunnable != null) {
25.142 postRunnable.run();
25.143 @@ -543,6 +559,7 @@
25.144 return rc;
25.145 }
25.146
25.147 + @Override
25.148 public LineConvertor newLineConvertor() {
25.149 return new LineConvertor() {
25.150 @Override
25.151 @@ -585,15 +602,15 @@
25.152 long minutes = seconds/60;
25.153 long hours = minutes/60;
25.154 if (hours > 0) {
25.155 - res.append(" " + hours + getString("HOUR")); // NOI18N
25.156 + res.append(" ").append(hours).append(getString("HOUR")); // NOI18N
25.157 }
25.158 if (minutes > 0) {
25.159 - res.append(" " + (minutes-hours*60) + getString("MINUTE")); // NOI18N
25.160 + res.append(" ").append(minutes - hours * 60).append(getString("MINUTE")); // NOI18N
25.161 }
25.162 if (seconds > 0) {
25.163 - res.append(" " + (seconds-minutes*60) + getString("SECOND")); // NOI18N
25.164 + res.append(" ").append(seconds - minutes * 60).append(getString("SECOND")); // NOI18N
25.165 } else {
25.166 - res.append(" " + (millis-seconds*1000) + getString("MILLISECOND")); // NOI18N
25.167 + res.append(" ").append(millis - seconds * 1000).append(getString("MILLISECOND")); // NOI18N
25.168 }
25.169 return res.toString();
25.170 }
26.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/Assembler.java Mon Feb 01 12:23:06 2010 +0100
26.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/Assembler.java Mon Feb 01 12:24:26 2010 +0100
26.3 @@ -40,14 +40,15 @@
26.4 */
26.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
26.6
26.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
26.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
26.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
26.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
26.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
26.12
26.13 public class Assembler extends BasicCompiler {
26.14
26.15 /** Creates a new instance of GNUCCompiler */
26.16 - private Assembler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
26.17 + private Assembler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
26.18 super(env, flavor, kind, name, displayName, path); // NOI18N
26.19 }
26.20
26.21 @@ -58,7 +59,7 @@
26.22 return copy;
26.23 }
26.24
26.25 - public static Assembler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
26.26 + public static Assembler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
26.27 return new Assembler(env, flavor, kind, name, displayName, path);
26.28 }
26.29
27.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/BasicCompiler.java Mon Feb 01 12:23:06 2010 +0100
27.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/BasicCompiler.java Mon Feb 01 12:24:26 2010 +0100
27.3 @@ -43,8 +43,9 @@
27.4 import java.io.File;
27.5 import java.util.List;
27.6 import java.util.Vector;
27.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
27.8 import org.netbeans.modules.cnd.toolchain.api.Tool;
27.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
27.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
27.11 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
27.12 import org.netbeans.modules.cnd.utils.cache.CndFileUtils;
27.13 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
27.14 @@ -52,7 +53,7 @@
27.15 public abstract class BasicCompiler extends Tool {
27.16
27.17 /** Creates a new instance of GenericCompiler */
27.18 - protected BasicCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
27.19 + protected BasicCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
27.20 super(env, flavor, kind, name, displayName, path);
27.21 if (!env.isLocal()) {
27.22 includeFilePrefix = getIncludeFilePrefix(env);
28.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/CCCCompiler.java Mon Feb 01 12:23:06 2010 +0100
28.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/CCCCompiler.java Mon Feb 01 12:24:26 2010 +0100
28.3 @@ -50,11 +50,12 @@
28.4 import java.util.Arrays;
28.5 import java.util.Iterator;
28.6 import java.util.List;
28.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
28.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
28.9 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
28.10 import org.netbeans.modules.nativeexecution.api.util.LinkSupport;
28.11 import org.netbeans.modules.cnd.api.utils.IpeUtils;
28.12 import org.netbeans.modules.cnd.api.utils.PlatformInfo;
28.13 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
28.14 import org.netbeans.modules.cnd.utils.CndUtils;
28.15 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
28.16 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
28.17 @@ -71,7 +72,7 @@
28.18 private volatile Pair compilerDefinitions;
28.19 private static File emptyFile = null;
28.20
28.21 - protected CCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
28.22 + protected CCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
28.23 super(env, flavor, kind, name, displayName, path);
28.24 }
28.25
28.26 @@ -280,7 +281,7 @@
28.27 int defineIndex = line.indexOf("-D"); // NOI18N
28.28 while (defineIndex >= 0) {
28.29 String token;
28.30 - int spaceIndex = line.indexOf(" ", defineIndex + 1); // NOI18N
28.31 + int spaceIndex = line.indexOf(' ', defineIndex + 1); // NOI18N
28.32 if (spaceIndex > 0) {
28.33 token = line.substring(defineIndex+2, spaceIndex);
28.34 if (defineIndex > 0 && line.charAt(defineIndex-1)=='"') {
29.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/CustomTool.java Mon Feb 01 12:23:06 2010 +0100
29.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/CustomTool.java Mon Feb 01 12:24:26 2010 +0100
29.3 @@ -41,16 +41,17 @@
29.4
29.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
29.6
29.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
29.8 +import org.netbeans.modules.cnd.toolchain.api.Tool;
29.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
29.10 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
29.11 -import org.netbeans.modules.cnd.toolchain.api.Tool;
29.12 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
29.13 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
29.14 import org.openide.util.NbBundle;
29.15
29.16 public final class CustomTool extends Tool {
29.17
29.18 private CustomTool(ExecutionEnvironment env) {
29.19 - super(env, CompilerFlavor.getUnknown(PlatformTypes.getDefaultPlatform()), CustomTool, "", NbBundle.getMessage(CustomTool.class, "LBL_CustomTool"), null); // NOI18N
29.20 + super(env, CompilerFlavorAccessor.getUnknown(PlatformTypes.getDefaultPlatform()), ToolKind.CustomTool, "", NbBundle.getMessage(CustomTool.class, "LBL_CustomTool"), null); // NOI18N
29.21 }
29.22
29.23 public static CustomTool create(ExecutionEnvironment env) {
30.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCCCompiler.java Mon Feb 01 12:23:06 2010 +0100
30.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCCCompiler.java Mon Feb 01 12:24:26 2010 +0100
30.3 @@ -41,7 +41,8 @@
30.4
30.5 import java.io.BufferedReader;
30.6 import java.io.IOException;
30.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
30.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
30.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
30.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
30.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
30.12 import org.openide.DialogDisplayer;
30.13 @@ -55,7 +56,7 @@
30.14 */
30.15 public abstract class GNUCCCCompiler extends CCCCompiler {
30.16
30.17 - public GNUCCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
30.18 + public GNUCCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
30.19 super(env, flavor, kind, name, displayName, path);
30.20 }
30.21
30.22 @@ -75,6 +76,7 @@
30.23 return ""; // NOI18N
30.24 }
30.25
30.26 + @Override
30.27 protected Pair getFreshSystemIncludesAndDefines() {
30.28 Pair res = new Pair();
30.29 try {
31.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCCompiler.java Mon Feb 01 12:23:06 2010 +0100
31.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCCompiler.java Mon Feb 01 12:24:26 2010 +0100
31.3 @@ -41,14 +41,15 @@
31.4
31.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
31.6
31.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
31.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
31.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
31.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
31.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
31.12
31.13 public class GNUCCCompiler extends GNUCCCCompiler {
31.14
31.15 /** Creates a new instance of GNUCCompiler */
31.16 - protected GNUCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
31.17 + protected GNUCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
31.18 super(env, flavor, kind, name, displayName, path);
31.19 }
31.20
31.21 @@ -63,7 +64,7 @@
31.22 return copy;
31.23 }
31.24
31.25 - public static GNUCCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
31.26 + public static GNUCCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
31.27 return new GNUCCCompiler(env, flavor, kind, name, displayName, path);
31.28 }
31.29
32.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCompiler.java Mon Feb 01 12:23:06 2010 +0100
32.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCompiler.java Mon Feb 01 12:24:26 2010 +0100
32.3 @@ -41,7 +41,8 @@
32.4
32.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
32.6
32.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
32.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
32.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
32.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
32.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
32.12
32.13 @@ -57,11 +58,11 @@
32.14 }
32.15
32.16 /** Creates a new instance of GNUCCompiler */
32.17 - protected GNUCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
32.18 + protected GNUCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
32.19 super(env, flavor, kind, name, displayName, path);
32.20 }
32.21
32.22 - public static GNUCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
32.23 + public static GNUCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
32.24 return new GNUCCompiler(env, flavor, kind, name, displayName, path);
32.25 }
32.26
33.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUDebuggerTool.java Mon Feb 01 12:23:06 2010 +0100
33.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUDebuggerTool.java Mon Feb 01 12:24:26 2010 +0100
33.3 @@ -41,15 +41,16 @@
33.4
33.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
33.6
33.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
33.8 import org.netbeans.modules.cnd.toolchain.api.Tool;
33.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
33.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
33.11 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.DebuggerDescriptor;
33.12 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
33.13
33.14 public class GNUDebuggerTool extends Tool {
33.15
33.16 private GNUDebuggerTool(ExecutionEnvironment env, CompilerFlavor flavor, String name, String displayName, String path) { // GRP - FIXME
33.17 - super(env, flavor, DebuggerTool, name, displayName, path); // NOI18N
33.18 + super(env, flavor, ToolKind.DebuggerTool, name, displayName, path); // NOI18N
33.19 }
33.20
33.21 @Override
34.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUFortranCompiler.java Mon Feb 01 12:23:06 2010 +0100
34.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUFortranCompiler.java Mon Feb 01 12:24:26 2010 +0100
34.3 @@ -41,13 +41,14 @@
34.4
34.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
34.6
34.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
34.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
34.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
34.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
34.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
34.12
34.13 public class GNUFortranCompiler extends BasicCompiler {
34.14 /** Creates a new instance of GNUCCompiler */
34.15 - private GNUFortranCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
34.16 + private GNUFortranCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
34.17 super(env, flavor, kind, name, displayName, path); // NOI18N
34.18 }
34.19
34.20 @@ -58,7 +59,7 @@
34.21 return copy;
34.22 }
34.23
34.24 - public static GNUFortranCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
34.25 + public static GNUFortranCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
34.26 return new GNUFortranCompiler(env, flavor, kind, name, displayName, path);
34.27 }
34.28
35.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUMaketool.java Mon Feb 01 12:23:06 2010 +0100
35.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUMaketool.java Mon Feb 01 12:24:26 2010 +0100
35.3 @@ -41,15 +41,16 @@
35.4
35.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
35.6
35.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
35.8 import org.netbeans.modules.cnd.toolchain.api.Tool;
35.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
35.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
35.11 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.MakeDescriptor;
35.12 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
35.13
35.14 public class GNUMaketool extends Tool {
35.15
35.16 private GNUMaketool(ExecutionEnvironment env, CompilerFlavor flavor, String name, String displayName, String path) { // GRP - FIXME
35.17 - super(env, flavor, MakeTool, name, displayName, path); // NOI18N
35.18 + super(env, flavor, ToolKind.MakeTool, name, displayName, path); // NOI18N
35.19 }
35.20
35.21 @Override
36.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GeneralTool.java Mon Feb 01 12:23:06 2010 +0100
36.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/GeneralTool.java Mon Feb 01 12:24:26 2010 +0100
36.3 @@ -39,8 +39,10 @@
36.4
36.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
36.6
36.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
36.8 import org.netbeans.modules.cnd.toolchain.api.Tool;
36.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
36.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
36.11 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
36.12 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolDescriptor;
36.13 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
36.14
36.15 @@ -49,7 +51,7 @@
36.16 * @author Alexander Simon
36.17 */
36.18 public class GeneralTool extends Tool {
36.19 - private GeneralTool(ExecutionEnvironment env, int kind, CompilerFlavor flavor, String name, String displayName, String path) {
36.20 + private GeneralTool(ExecutionEnvironment env, ToolKindBase kind, CompilerFlavor flavor, String name, String displayName, String path) {
36.21 super(env, flavor, kind, name, displayName, path); // NOI18N
36.22 }
36.23
36.24 @@ -60,17 +62,16 @@
36.25 return copy;
36.26 }
36.27
36.28 - public static GeneralTool create(ExecutionEnvironment env, int kind, CompilerFlavor flavor, String name, String displayName, String path) {
36.29 + public static GeneralTool create(ExecutionEnvironment env, ToolKindBase kind, CompilerFlavor flavor, String name, String displayName, String path) {
36.30 return new GeneralTool(env, kind, flavor, name, displayName, path);
36.31 }
36.32
36.33 @Override
36.34 public ToolDescriptor getDescriptor() {
36.35 - switch (getKind()) {
36.36 - case QMakeTool:
36.37 - return getFlavor().getToolchainDescriptor().getQMake();
36.38 - case CMakeTool:
36.39 - return getFlavor().getToolchainDescriptor().getCMake();
36.40 + if (getKind() == ToolKind.QMakeTool) {
36.41 + return getFlavor().getToolchainDescriptor().getQMake();
36.42 + } else if (getKind() == ToolKind.CMakeTool) {
36.43 + return getFlavor().getToolchainDescriptor().getCMake();
36.44 }
36.45 return null;
36.46 }
37.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/MakeProjectCompilerProvider.java Mon Feb 01 12:23:06 2010 +0100
37.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/MakeProjectCompilerProvider.java Mon Feb 01 12:24:26 2010 +0100
37.3 @@ -40,9 +40,11 @@
37.4 */
37.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
37.6
37.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerProvider;
37.8 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
37.9 import org.netbeans.modules.cnd.toolchain.api.Tool;
37.10 +import org.netbeans.modules.cnd.toolchain.spi.CompilerProvider;
37.11 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
37.12 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
37.13 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
37.14 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
37.15
37.16 /**
37.17 @@ -51,7 +53,7 @@
37.18 *
37.19 * @author gordonp
37.20 */
37.21 -@org.openide.util.lookup.ServiceProvider(service = org.netbeans.modules.cnd.toolchain.api.CompilerProvider.class, position=1000)
37.22 +@org.openide.util.lookup.ServiceProvider(service = org.netbeans.modules.cnd.toolchain.spi.CompilerProvider.class, position=1000)
37.23 public class MakeProjectCompilerProvider extends CompilerProvider {
37.24
37.25 /**
37.26 @@ -61,47 +63,48 @@
37.27 * this method. We can also add others, if desired. This was mainly a proof-of-concept that tool creation
37.28 * could be deferred to makeproject.
37.29 */
37.30 - public Tool createCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
37.31 + @Override
37.32 + public Tool createCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
37.33 if (flavor.isSunStudioCompiler()) {
37.34 - if (kind == Tool.CCompiler) {
37.35 + if (kind == ToolKind.CCompiler) {
37.36 return SunCCompiler.create(env, flavor, kind, name, displayName, path);
37.37 - } else if (kind == Tool.CCCompiler) {
37.38 + } else if (kind == ToolKind.CCCompiler) {
37.39 return SunCCCompiler.create(env, flavor, kind, name, displayName, path);
37.40 - } else if (kind == Tool.FortranCompiler) {
37.41 + } else if (kind == ToolKind.FortranCompiler) {
37.42 return SunFortranCompiler.create(env, flavor, kind, name, displayName, path);
37.43 - } else if (kind == Tool.MakeTool) {
37.44 + } else if (kind == ToolKind.MakeTool) {
37.45 return SunMaketool.create(env, flavor, name, displayName, path);
37.46 - } else if (kind == Tool.DebuggerTool) {
37.47 + } else if (kind == ToolKind.DebuggerTool) {
37.48 return SunDebuggerTool.create(env, flavor, name, displayName, path);
37.49 - } else if (kind == Tool.Assembler) {
37.50 + } else if (kind == ToolKind.Assembler) {
37.51 return Assembler.create(env, flavor, kind, name, displayName, path);
37.52 }
37.53 } else /* if (flavor.isGnuCompiler()) */ { // Assume GNU (makeproject system doesn't handle Unknown)
37.54 - if (kind == Tool.CCompiler) {
37.55 + if (kind == ToolKind.CCompiler) {
37.56 if ("MSVC".equals(flavor.toString())) { // NOI18N
37.57 return MsvcCompiler.create(env, flavor, kind, name, displayName, path);
37.58 } else {
37.59 return GNUCCompiler.create(env, flavor, kind, name, displayName, path);
37.60 }
37.61 - } else if (kind == Tool.CCCompiler) {
37.62 + } else if (kind == ToolKind.CCCompiler) {
37.63 if ("MSVC".equals(flavor.toString())) { // NOI18N
37.64 return new MsvcCompiler(env, flavor, kind, name, displayName, path);
37.65 } else {
37.66 return GNUCCCompiler.create(env, flavor, kind, name, displayName, path);
37.67 }
37.68 - } else if (kind == Tool.FortranCompiler) {
37.69 + } else if (kind == ToolKind.FortranCompiler) {
37.70 return GNUFortranCompiler.create(env, flavor, kind, name, displayName, path);
37.71 - } else if (kind == Tool.MakeTool) {
37.72 + } else if (kind == ToolKind.MakeTool) {
37.73 return GNUMaketool.create(env, flavor, name, displayName, path);
37.74 - } else if (kind == Tool.DebuggerTool) {
37.75 + } else if (kind == ToolKind.DebuggerTool) {
37.76 return GNUDebuggerTool.create(env, flavor, name, displayName, path);
37.77 - } else if (kind == Tool.Assembler) {
37.78 + } else if (kind == ToolKind.Assembler) {
37.79 return Assembler.create(env, flavor, kind, name, displayName, path);
37.80 }
37.81 }
37.82 - if (kind == Tool.CustomTool) {
37.83 + if (kind == ToolKind.CustomTool) {
37.84 return CustomTool.create(env);
37.85 - } else if (kind == Tool.QMakeTool || kind == Tool.CMakeTool) {
37.86 + } else if (kind == ToolKind.QMakeTool || kind == ToolKind.CMakeTool) {
37.87 return GeneralTool.create(env, kind, flavor, name, displayName, path);
37.88 }
37.89 return null;
38.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/MsvcCompiler.java Mon Feb 01 12:23:06 2010 +0100
38.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/MsvcCompiler.java Mon Feb 01 12:24:26 2010 +0100
38.3 @@ -41,8 +41,9 @@
38.4
38.5 import java.util.List;
38.6 import java.util.StringTokenizer;
38.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
38.8 -import org.netbeans.modules.cnd.toolchain.api.Tool;
38.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
38.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
38.11 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
38.12 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
38.13 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.PredefinedMacro;
38.14 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
38.15 @@ -53,7 +54,7 @@
38.16 */
38.17 public class MsvcCompiler extends GNUCCompiler {
38.18 /** Creates a new instance of GNUCCompiler */
38.19 - protected MsvcCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
38.20 + protected MsvcCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
38.21 super(env, flavor, kind, name, displayName, path);
38.22 }
38.23
38.24 @@ -68,13 +69,13 @@
38.25 return copy;
38.26 }
38.27
38.28 - public static MsvcCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
38.29 + public static MsvcCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
38.30 return new MsvcCompiler(env, flavor, kind, name, displayName, path);
38.31 }
38.32
38.33 @Override
38.34 public CompilerDescriptor getDescriptor() {
38.35 - if (getKind() == Tool.CCCompiler) {
38.36 + if (getKind() == ToolKind.CCCompiler) {
38.37 return getFlavor().getToolchainDescriptor().getCpp();
38.38 } else {
38.39 return getFlavor().getToolchainDescriptor().getC();
39.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCCCompiler.java Mon Feb 01 12:23:06 2010 +0100
39.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCCCompiler.java Mon Feb 01 12:24:26 2010 +0100
39.3 @@ -42,7 +42,8 @@
39.4 package org.netbeans.modules.cnd.makeproject.api.compilers;
39.5
39.6 import java.io.IOException;
39.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
39.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
39.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
39.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
39.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
39.12 import org.openide.DialogDisplayer;
39.13 @@ -51,7 +52,7 @@
39.14
39.15 public abstract class SunCCCCompiler extends CCCCompiler {
39.16
39.17 - protected SunCCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
39.18 + protected SunCCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
39.19 super(env, flavor, kind, name, displayName, path);
39.20 }
39.21
39.22 @@ -71,6 +72,7 @@
39.23 return null;
39.24 }
39.25
39.26 + @Override
39.27 protected Pair getFreshSystemIncludesAndDefines() {
39.28 Pair res = new Pair();
39.29 try {
40.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCCompiler.java Mon Feb 01 12:23:06 2010 +0100
40.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCCompiler.java Mon Feb 01 12:24:26 2010 +0100
40.3 @@ -43,7 +43,8 @@
40.4
40.5 import java.io.BufferedReader;
40.6 import java.io.IOException;
40.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
40.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
40.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
40.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
40.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
40.12 import org.openide.ErrorManager;
40.13 @@ -52,7 +53,7 @@
40.14 /**
40.15 * Creates a new instance of SunCCCompiler
40.16 */
40.17 - protected SunCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
40.18 + protected SunCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
40.19 super(env, flavor, kind, name, displayName, path);
40.20 }
40.21
40.22 @@ -67,7 +68,7 @@
40.23 return copy;
40.24 }
40.25
40.26 - public static SunCCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
40.27 + public static SunCCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
40.28 return new SunCCCompiler(env, flavor, kind, name, displayName, path);
40.29 }
40.30
40.31 @@ -86,7 +87,7 @@
40.32 int includeIndex = line.indexOf("-I"); // NOI18N
40.33 while (includeIndex > 0) {
40.34 String token;
40.35 - int spaceIndex = line.indexOf(" ", includeIndex + 1); // NOI18N
40.36 + int spaceIndex = line.indexOf(' ', includeIndex + 1); // NOI18N
40.37 if (spaceIndex > 0) {
40.38 token = line.substring(includeIndex+2, spaceIndex);
40.39 } else {
41.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCompiler.java Mon Feb 01 12:23:06 2010 +0100
41.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCompiler.java Mon Feb 01 12:24:26 2010 +0100
41.3 @@ -43,7 +43,8 @@
41.4
41.5 import java.io.BufferedReader;
41.6 import java.io.IOException;
41.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
41.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
41.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
41.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
41.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
41.12 import org.openide.ErrorManager;
41.13 @@ -53,7 +54,7 @@
41.14 * Creates a new instance of SunCCompiler
41.15 * private: use factory methods instead
41.16 */
41.17 - private SunCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
41.18 + private SunCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
41.19 super(env, flavor, kind, name, displayName, path);
41.20 }
41.21
41.22 @@ -68,7 +69,7 @@
41.23 return copy;
41.24 }
41.25
41.26 - public static SunCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
41.27 + public static SunCCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
41.28 return new SunCCompiler(env, flavor, kind, name, displayName, path);
41.29 }
41.30
41.31 @@ -86,7 +87,7 @@
41.32 int includeIndex = line.indexOf("-I"); // NOI18N
41.33 while (includeIndex > 0) {
41.34 String token;
41.35 - int spaceIndex = line.indexOf(" ", includeIndex + 1); // NOI18N
41.36 + int spaceIndex = line.indexOf(' ', includeIndex + 1); // NOI18N
41.37 if (spaceIndex > 0) {
41.38 token = line.substring(includeIndex+2, spaceIndex);
41.39 pair.systemIncludeDirectoriesList.addUnique(applyPathPrefix(token));
42.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunDebuggerTool.java Mon Feb 01 12:23:06 2010 +0100
42.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunDebuggerTool.java Mon Feb 01 12:24:26 2010 +0100
42.3 @@ -41,15 +41,16 @@
42.4
42.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
42.6
42.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
42.8 import org.netbeans.modules.cnd.toolchain.api.Tool;
42.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
42.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
42.11 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.DebuggerDescriptor;
42.12 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
42.13
42.14 public class SunDebuggerTool extends Tool {
42.15
42.16 private SunDebuggerTool(ExecutionEnvironment env, CompilerFlavor flavor, String name, String displayName, String path) { // GRP - FIXME
42.17 - super(env, flavor, DebuggerTool, name, displayName, path); // NOI18N
42.18 + super(env, flavor, ToolKind.DebuggerTool, name, displayName, path); // NOI18N
42.19 }
42.20
42.21 @Override
43.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunFortranCompiler.java Mon Feb 01 12:23:06 2010 +0100
43.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunFortranCompiler.java Mon Feb 01 12:24:26 2010 +0100
43.3 @@ -41,14 +41,15 @@
43.4
43.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
43.6
43.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
43.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
43.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
43.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
43.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
43.12
43.13 public class SunFortranCompiler extends BasicCompiler {
43.14
43.15 /** Creates a new instance of SunCCompiler */
43.16 - private SunFortranCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
43.17 + private SunFortranCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
43.18 super(env, flavor, kind, name, displayName, path);
43.19 }
43.20
43.21 @@ -67,7 +68,7 @@
43.22 return ""; // NOI18N
43.23 }
43.24
43.25 - public static SunFortranCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
43.26 + public static SunFortranCompiler create(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
43.27 return new SunFortranCompiler(env, flavor, kind, name, displayName, path);
43.28 }
43.29
44.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunMaketool.java Mon Feb 01 12:23:06 2010 +0100
44.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunMaketool.java Mon Feb 01 12:24:26 2010 +0100
44.3 @@ -41,15 +41,16 @@
44.4
44.5 package org.netbeans.modules.cnd.makeproject.api.compilers;
44.6
44.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
44.8 import org.netbeans.modules.cnd.toolchain.api.Tool;
44.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
44.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
44.11 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.MakeDescriptor;
44.12 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
44.13
44.14 public final class SunMaketool extends Tool {
44.15
44.16 private SunMaketool(ExecutionEnvironment env, CompilerFlavor flavor, String name, String displayName, String path) { // GRP - FIXME
44.17 - super(env, flavor, MakeTool, name, displayName, path); // NOI18N
44.18 + super(env, flavor, ToolKind.MakeTool, name, displayName, path); // NOI18N
44.19 }
44.20
44.21 @Override
45.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/AssemblerConfiguration.java Mon Feb 01 12:23:06 2010 +0100
45.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/AssemblerConfiguration.java Mon Feb 01 12:24:26 2010 +0100
45.3 @@ -45,7 +45,7 @@
45.4 import org.netbeans.modules.cnd.makeproject.configurations.CppUtils;
45.5 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
45.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
45.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
45.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
45.9 import org.openide.nodes.Sheet;
45.10 import org.openide.util.NbBundle;
45.11
45.12 @@ -125,7 +125,7 @@
45.13 public Sheet getGeneralSheet(MakeConfiguration conf) {
45.14 Sheet sheet = new Sheet();
45.15 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
45.16 - BasicCompiler assemblerCompiler = compilerSet == null ? null : (BasicCompiler) compilerSet.getTool(Tool.Assembler);
45.17 + BasicCompiler assemblerCompiler = compilerSet == null ? null : (BasicCompiler) compilerSet.getTool(ToolKind.Assembler);
45.18
45.19 Sheet.Set basicSet = getBasicSet();
45.20 basicSet.remove("StripSymbols"); // NOI18N
46.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/BasicCompilerConfiguration.java Mon Feb 01 12:23:06 2010 +0100
46.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/BasicCompilerConfiguration.java Mon Feb 01 12:24:26 2010 +0100
46.3 @@ -40,7 +40,6 @@
46.4 */
46.5 package org.netbeans.modules.cnd.makeproject.api.configurations;
46.6
46.7 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
46.8 import org.netbeans.modules.cnd.makeproject.configurations.ConfigurationMakefileWriter;
46.9 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.BooleanNodeProp;
46.10 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.IntNodeProp;
47.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CCCCompilerConfiguration.java Mon Feb 01 12:23:06 2010 +0100
47.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CCCCompilerConfiguration.java Mon Feb 01 12:24:26 2010 +0100
47.3 @@ -44,6 +44,7 @@
47.4 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
47.5 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
47.6 import org.netbeans.modules.cnd.api.utils.IpeUtils;
47.7 +import org.netbeans.modules.cnd.makeproject.configurations.CppUtils;
47.8 import org.netbeans.modules.cnd.makeproject.configurations.ui.StringListNodeProp;
47.9 import org.netbeans.modules.cnd.makeproject.configurations.ui.VectorNodeProp;
47.10 import org.openide.nodes.Sheet;
47.11 @@ -319,10 +320,11 @@
47.12 this.prepend = prepend;
47.13 }
47.14
47.15 + @Override
47.16 public String toString(String item) {
47.17 if (0 < item.length()) {
47.18 if (compilerSet != null) {
47.19 - item = compilerSet.normalizeDriveLetter(item);
47.20 + item = CppUtils.normalizeDriveLetter(compilerSet, item);
47.21 }
47.22 item = IpeUtils.escapeOddCharacters(item);
47.23 return prepend == null ? item : prepend + item;
48.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CCCompilerConfiguration.java Mon Feb 01 12:23:06 2010 +0100
48.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CCCompilerConfiguration.java Mon Feb 01 12:24:26 2010 +0100
48.3 @@ -41,7 +41,7 @@
48.4
48.5 package org.netbeans.modules.cnd.makeproject.api.configurations;
48.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
48.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
48.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
48.9 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
48.10 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.IntNodeProp;
48.11 import org.netbeans.modules.cnd.makeproject.configurations.ui.OptionsNodeProp;
48.12 @@ -211,12 +211,12 @@
48.13 public Sheet getSheet(MakeConfiguration conf, Folder folder) {
48.14 Sheet sheet = new Sheet();
48.15 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
48.16 - BasicCompiler ccCompiler = compilerSet == null ? null : (BasicCompiler)compilerSet.getTool(Tool.CCCompiler);
48.17 + BasicCompiler ccCompiler = compilerSet == null ? null : (BasicCompiler)compilerSet.getTool(ToolKind.CCCompiler);
48.18
48.19 sheet.put(getSet());
48.20 if (conf.isCompileConfiguration() && folder == null) {
48.21 sheet.put(getBasicSet());
48.22 - if (compilerSet !=null && compilerSet.isSunCompiler()) { // FIXUP: should be moved to SunCCompiler
48.23 + if (compilerSet !=null && compilerSet.getCompilerFlavor().isSunStudioCompiler()) { // FIXUP: should be moved to SunCCompiler
48.24 Sheet.Set set2 = new Sheet.Set();
48.25 set2.setName("OtherOptions"); // NOI18N
48.26 set2.setDisplayName(getString("OtherOptionsTxt"));
49.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CCompilerConfiguration.java Mon Feb 01 12:23:06 2010 +0100
49.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CCompilerConfiguration.java Mon Feb 01 12:24:26 2010 +0100
49.3 @@ -48,7 +48,7 @@
49.4 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
49.5 import org.netbeans.modules.cnd.makeproject.api.compilers.CCCCompiler;
49.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
49.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
49.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
49.9 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
49.10 import org.openide.nodes.Sheet;
49.11 import org.openide.util.NbBundle;
49.12 @@ -211,12 +211,12 @@
49.13 public Sheet getGeneralSheet(MakeConfiguration conf, Folder folder) {
49.14 Sheet sheet = new Sheet();
49.15 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
49.16 - BasicCompiler cCompiler = compilerSet == null ? null : (BasicCompiler)compilerSet.getTool(Tool.CCompiler);
49.17 + BasicCompiler cCompiler = compilerSet == null ? null : (BasicCompiler)compilerSet.getTool(ToolKind.CCompiler);
49.18
49.19 sheet.put(getSet());
49.20 if (conf.isCompileConfiguration() && folder == null) {
49.21 sheet.put(getBasicSet());
49.22 - if (compilerSet != null && compilerSet.isSunCompiler()) { // FIXUP: should be moved to SunCCompiler
49.23 + if (compilerSet != null && compilerSet.getCompilerFlavor().isSunStudioCompiler()) { // FIXUP: should be moved to SunCCompiler
49.24 Sheet.Set set2 = new Sheet.Set();
49.25 set2.setName("OtherOptions"); // NOI18N
49.26 set2.setDisplayName(getString("OtherOptionsTxt"));
50.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CompilerSet2Configuration.java Mon Feb 01 12:23:06 2010 +0100
50.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/CompilerSet2Configuration.java Mon Feb 01 12:24:26 2010 +0100
50.3 @@ -46,12 +46,12 @@
50.4 import java.util.HashMap;
50.5 import java.util.Map;
50.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
50.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
50.8 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
50.9 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
50.10 import org.netbeans.modules.cnd.api.remote.ServerList;
50.11 import org.netbeans.modules.cnd.api.remote.ServerRecord;
50.12 import org.netbeans.modules.cnd.makeproject.configurations.ui.CompilerSetNodeProp;
50.13 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
50.14 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
50.15 import org.openide.util.NbBundle;
50.16 import org.openide.util.RequestProcessor;
50.17 @@ -96,7 +96,7 @@
50.18
50.19 // we can't store CSM because it's dependent on devHostConfig name which is not persistent
50.20 public CompilerSetManager getCompilerSetManager() {
50.21 - return CompilerSetManager.getDefault(dhconf.getExecutionEnvironment());
50.22 + return CompilerSetManager.get(dhconf.getExecutionEnvironment());
50.23 }
50.24
50.25 //
50.26 @@ -132,7 +132,7 @@
50.27 public void setNameAndFlavor(String name, int version) {
50.28 String nm;
50.29 String fl;
50.30 - int index = name.indexOf("|"); // NOI18N
50.31 + int index = name.indexOf('|'); // NOI18N
50.32 if (index > 0) {
50.33 nm = name.substring(0, index);
50.34 fl = name.substring(index+1);
50.35 @@ -141,7 +141,7 @@
50.36 nm = name;
50.37 fl = name;
50.38 }
50.39 - setValue(CompilerFlavor.mapOldToNew(nm, version), CompilerFlavor.mapOldToNew(fl, version));
50.40 + setValue(CompilerFlavorAccessor.mapOldToNew(nm, version), CompilerFlavorAccessor.mapOldToNew(fl, version));
50.41 }
50.42
50.43 public void setValue(String name, String flavor) {
50.44 @@ -159,7 +159,7 @@
50.45 String s = getCompilerSetName().getValue();
50.46 if (s != null) {
50.47 int i = 0;
50.48 - for (String csname : CompilerSetManager.getDefault(dhconf.getExecutionEnvironment()).getCompilerSetNames()) {
50.49 + for (String csname : CompilerSetManager.get(dhconf.getExecutionEnvironment()).getCompilerSetNames()) {
50.50 if (s.equals(csname)) {
50.51 return i;
50.52 }
50.53 @@ -318,18 +318,19 @@
50.54 this.flavor = flavor;
50.55 }
50.56
50.57 + @Override
50.58 public void propertyChange(final PropertyChangeEvent evt) {
50.59 CompilerSet ocs = null;
50.60 String hkey = ((DevelopmentHostConfiguration) evt.getNewValue()).getHostKey();
50.61 final ExecutionEnvironment env = ExecutionEnvironmentFactory.fromUniqueID(hkey);
50.62 final String oldName = oldNameMap.get(hkey);
50.63 if (oldName != null) {
50.64 - ocs = CompilerSetManager.getDefault(env).getCompilerSet(oldName);
50.65 + ocs = CompilerSetManager.get(env).getCompilerSet(oldName);
50.66 } else {
50.67 - ocs = CompilerSetManager.getDefault(env).getDefaultCompilerSet();
50.68 + ocs = CompilerSetManager.get(env).getDefaultCompilerSet();
50.69 }
50.70 if (ocs == null) {
50.71 - ocs = CompilerSetManager.getDefault(env).getCompilerSet(0);
50.72 + ocs = CompilerSetManager.get(env).getCompilerSet(0);
50.73 }
50.74 if (ocs == null) {
50.75 return;
50.76 @@ -343,6 +344,7 @@
50.77 setValue(ocs.getName());
50.78 final CompilerSet focs = ocs;
50.79 RequestProcessor.getDefault().post(new Runnable() {
50.80 + @Override
50.81 public void run() {
50.82 ServerRecord record = ServerList.get(env);
50.83 if (record != null) {
51.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ConfigurationDescriptorProvider.java Mon Feb 01 12:23:06 2010 +0100
51.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ConfigurationDescriptorProvider.java Mon Feb 01 12:24:26 2010 +0100
51.3 @@ -50,7 +50,6 @@
51.4 import java.util.logging.LogRecord;
51.5 import java.util.logging.Logger;
51.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
51.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
51.8 import org.netbeans.modules.cnd.makeproject.MakeProject;
51.9 import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptor.State;
51.10 import org.netbeans.modules.cnd.makeproject.api.platforms.Platforms;
51.11 @@ -312,16 +311,16 @@
51.12 if (itemConfiguration != null && !itemConfiguration.getExcluded().getValue()) {
51.13 size++;
51.14 switch (itemConfiguration.getTool()) {
51.15 - case Tool.CCompiler:
51.16 + case CCompiler:
51.17 cLang = true;
51.18 break;
51.19 - case Tool.CCCompiler:
51.20 + case CCCompiler:
51.21 ccLang = true;
51.22 break;
51.23 - case Tool.FortranCompiler:
51.24 + case FortranCompiler:
51.25 fLang = true;
51.26 break;
51.27 - case Tool.Assembler:
51.28 + case Assembler:
51.29 aLang = true;
51.30 break;
51.31 }
51.32 @@ -389,26 +388,32 @@
51.33 }
51.34 }
51.35
51.36 + @Override
51.37 public void fileFolderCreated(FileEvent fe) {
51.38 resetConfiguration();
51.39 }
51.40
51.41 + @Override
51.42 public void fileDataCreated(FileEvent fe) {
51.43 resetConfiguration();
51.44 }
51.45
51.46 + @Override
51.47 public void fileChanged(FileEvent fe) {
51.48 resetConfiguration();
51.49 }
51.50
51.51 + @Override
51.52 public void fileDeleted(FileEvent fe) {
51.53 resetConfiguration();
51.54 }
51.55
51.56 + @Override
51.57 public void fileRenamed(FileRenameEvent fe) {
51.58 resetConfiguration();
51.59 }
51.60
51.61 + @Override
51.62 public void fileAttributeChanged(FileAttributeEvent fe) {
51.63 // Don't reset configuration on file attribute change.
51.64 }
52.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configurations.java Mon Feb 01 12:23:06 2010 +0100
52.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configurations.java Mon Feb 01 12:24:26 2010 +0100
52.3 @@ -48,7 +48,7 @@
52.4 import java.util.List;
52.5 import java.util.concurrent.locks.ReadWriteLock;
52.6 import java.util.concurrent.locks.ReentrantReadWriteLock;
52.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManagerEvents;
52.8 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetManagerEvents;
52.9
52.10 public final class Configurations {
52.11
53.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/DevelopmentHostConfiguration.java Mon Feb 01 12:23:06 2010 +0100
53.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/DevelopmentHostConfiguration.java Mon Feb 01 12:24:26 2010 +0100
53.3 @@ -42,13 +42,13 @@
53.4 import java.beans.PropertyChangeSupport;
53.5 import java.util.List;
53.6 import javax.swing.SwingUtilities;
53.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
53.8 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
53.9 import org.netbeans.modules.cnd.api.remote.ServerRecord;
53.10 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
53.11 import org.netbeans.modules.cnd.api.remote.ServerList;
53.12 import org.netbeans.modules.cnd.makeproject.api.platforms.Platform;
53.13 import org.netbeans.modules.cnd.makeproject.api.platforms.Platforms;
53.14 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
53.15 import org.netbeans.modules.cnd.utils.CndUtils;
53.16 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
53.17 import org.openide.util.NbBundle;
53.18 @@ -85,7 +85,7 @@
53.19 def = value;
53.20 pcs = new PropertyChangeSupport(this);
53.21
53.22 - int buildPlatform = CompilerSetManager.getDefault(execEnv).getPlatform();
53.23 + int buildPlatform = CompilerSetManager.get(execEnv).getPlatform();
53.24 if (buildPlatform == -1) {
53.25 // TODO: CompilerSet is not reliable about platform; it must be.
53.26 buildPlatform = PlatformTypes.PLATFORM_NONE;
53.27 @@ -129,7 +129,7 @@
53.28 public boolean isConfigured() {
53.29 // localhost is always STATE_COMPLETE so isLocalhost() is assumed
53.30 // keeping track of online status takes more efforts and can miss sometimes
53.31 - return !CompilerSetManager.getDefault(getExecutionEnvironment()).isUninitialized();
53.32 + return !CompilerSetManager.get(getExecutionEnvironment()).isUninitialized();
53.33 }
53.34
53.35 public int getValue() {
53.36 @@ -165,7 +165,7 @@
53.37 for (int i = 0; i < servers.size(); i++) {
53.38 if (servers.get(i).equals(execEnv)) {
53.39 value = i;
53.40 - setBuildPlatform(CompilerSetManager.getDefault(execEnv).getPlatform());
53.41 + setBuildPlatform(CompilerSetManager.get(execEnv).getPlatform());
53.42 if (getBuildPlatform() == -1) {
53.43 // TODO: CompilerSet is not reliable about platform; it must be.
53.44 setBuildPlatform(PlatformTypes.PLATFORM_NONE);
53.45 @@ -189,9 +189,10 @@
53.46 if (currRecord.getDisplayName().equals(v)) {
53.47 final int newValue = i;
53.48 final Runnable setter = new Runnable() {
53.49 + @Override
53.50 public void run() {
53.51 value = newValue;
53.52 - setBuildPlatform(CompilerSetManager.getDefault(currEnv).getPlatform());
53.53 + setBuildPlatform(CompilerSetManager.get(currEnv).getPlatform());
53.54 if (getBuildPlatform() == -1) {
53.55 // TODO: CompilerSet is not reliable about platform; it must be.
53.56 setBuildPlatform(PlatformTypes.PLATFORM_NONE);
53.57 @@ -207,6 +208,7 @@
53.58 setter.run();
53.59 } else {
53.60 SwingUtilities.invokeLater(new Runnable() {
53.61 + @Override
53.62 public void run() {
53.63 if (currRecord.setUp()) {
53.64 setter.run();
54.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/FortranCompilerConfiguration.java Mon Feb 01 12:23:06 2010 +0100
54.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/FortranCompilerConfiguration.java Mon Feb 01 12:24:26 2010 +0100
54.3 @@ -46,7 +46,7 @@
54.4 import org.netbeans.modules.cnd.makeproject.configurations.CppUtils;
54.5 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
54.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
54.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
54.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
54.9 import org.netbeans.modules.cnd.makeproject.api.compilers.SunFortranCompiler;
54.10 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.IntNodeProp;
54.11 import org.openide.nodes.Sheet;
54.12 @@ -136,13 +136,13 @@
54.13 public Sheet getGeneralSheet(MakeConfiguration conf) {
54.14 Sheet sheet = new Sheet();
54.15 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
54.16 - BasicCompiler fortranCompiler = compilerSet == null ? null : (BasicCompiler) compilerSet.getTool(Tool.FortranCompiler);
54.17 + BasicCompiler fortranCompiler = compilerSet == null ? null : (BasicCompiler) compilerSet.getTool(ToolKind.FortranCompiler);
54.18
54.19 sheet.put(getBasicSet());
54.20 if (getMaster() != null) {
54.21 sheet.put(getInputSet());
54.22 }
54.23 - if (compilerSet !=null && compilerSet.isSunCompiler()) { // FIXUP: should be moved to SunCCompiler
54.24 + if (compilerSet !=null && compilerSet.getCompilerFlavor().isSunStudioCompiler()) { // FIXUP: should be moved to SunCCompiler
54.25 Sheet.Set set2 = new Sheet.Set();
54.26 set2.setName("OtherOptions"); // NOI18N
54.27 set2.setDisplayName(getString("OtherOptionsTxt"));
55.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Item.java Mon Feb 01 12:23:06 2010 +0100
55.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Item.java Mon Feb 01 12:24:26 2010 +0100
55.3 @@ -55,7 +55,7 @@
55.4 import org.netbeans.modules.cnd.api.utils.IpeUtils;
55.5 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
55.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
55.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
55.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
55.9 import org.netbeans.modules.cnd.makeproject.spi.configurations.UserOptionsProvider;
55.10 import org.netbeans.modules.cnd.utils.MIMENames;
55.11 import org.netbeans.modules.cnd.utils.MIMESupport;
55.12 @@ -194,6 +194,7 @@
55.13 }
55.14 }
55.15
55.16 + @Override
55.17 public void propertyChange(PropertyChangeEvent evt) {
55.18 if (evt.getPropertyName().equals("name")) { // NOI18N
55.19 // File has been renamed
55.20 @@ -247,6 +248,7 @@
55.21 return file;
55.22 }
55.23
55.24 + @Override
55.25 public File getFile() {
55.26 // let's try to use normalized, not canonical paths
55.27 return getNormalizedFile();
55.28 @@ -380,21 +382,21 @@
55.29 return mimeType;
55.30 }
55.31
55.32 - public int getDefaultTool() {
55.33 - int tool;
55.34 + public ToolKind getDefaultTool() {
55.35 + ToolKind tool;
55.36 String mimeType = getMIMEType();
55.37 if (MIMENames.C_MIME_TYPE.equals(mimeType)) {
55.38 - tool = Tool.CCompiler;
55.39 + tool = ToolKind.CCompiler;
55.40 } else if (MIMENames.HEADER_MIME_TYPE.equals(mimeType)) {
55.41 - tool = Tool.CustomTool;
55.42 + tool = ToolKind.CustomTool;
55.43 } else if (MIMENames.CPLUSPLUS_MIME_TYPE.equals(mimeType)) {
55.44 - tool = Tool.CCCompiler;
55.45 + tool = ToolKind.CCCompiler;
55.46 } else if (MIMENames.FORTRAN_MIME_TYPE.equals(mimeType)) {
55.47 - tool = Tool.FortranCompiler;
55.48 + tool = ToolKind.FortranCompiler;
55.49 } else if (MIMENames.ASM_MIME_TYPE.equals(mimeType)) {
55.50 - tool = Tool.Assembler;
55.51 + tool = ToolKind.Assembler;
55.52 } else {
55.53 - tool = Tool.CustomTool;
55.54 + tool = ToolKind.CustomTool;
55.55 }
55.56 return tool;
55.57 }
55.58 @@ -414,6 +416,7 @@
55.59 return makeConfigurationDescriptor.getActiveConfiguration();
55.60 }
55.61
55.62 + @Override
55.63 public NativeProject getNativeProject() {
55.64 Folder curFolder = getFolder();
55.65 if (curFolder != null) {
55.66 @@ -425,6 +428,7 @@
55.67 return null;
55.68 }
55.69
55.70 + @Override
55.71 public List<String> getSystemIncludePaths() {
55.72 List<String> vec = new ArrayList<String>();
55.73 MakeConfiguration makeConfiguration = getMakeConfiguration();
55.74 @@ -448,6 +452,7 @@
55.75 return vec;
55.76 }
55.77
55.78 + @Override
55.79 public List<String> getUserIncludePaths() {
55.80 List<String> vec = new ArrayList<String>();
55.81 MakeConfiguration makeConfiguration = getMakeConfiguration();
55.82 @@ -488,6 +493,7 @@
55.83 return vec;
55.84 }
55.85
55.86 + @Override
55.87 public List<String> getSystemMacroDefinitions() {
55.88 List<String> vec = new ArrayList<String>();
55.89 MakeConfiguration makeConfiguration = getMakeConfiguration();
55.90 @@ -511,6 +517,7 @@
55.91 return vec;
55.92 }
55.93
55.94 + @Override
55.95 public List<String> getUserMacroDefinitions() {
55.96 List<String> vec = new ArrayList<String>();
55.97 MakeConfiguration makeConfiguration = getMakeConfiguration();
55.98 @@ -555,8 +562,9 @@
55.99 /**
55.100 * NativeFileItem interface
55.101 **/
55.102 + @Override
55.103 public Language getLanguage() {
55.104 - int tool;
55.105 + ToolKind tool;
55.106 Language language;
55.107 ItemConfiguration itemConfiguration = null;
55.108 MakeConfiguration makeConfiguration = getMakeConfiguration();
55.109 @@ -569,11 +577,11 @@
55.110 tool = getDefaultTool();
55.111 }
55.112
55.113 - if (tool == Tool.CCompiler) {
55.114 + if (tool == ToolKind.CCompiler) {
55.115 language = NativeFileItem.Language.C;
55.116 - } else if (tool == Tool.CCCompiler) {
55.117 + } else if (tool == ToolKind.CCCompiler) {
55.118 language = NativeFileItem.Language.CPP;
55.119 - } else if (tool == Tool.FortranCompiler) {
55.120 + } else if (tool == ToolKind.FortranCompiler) {
55.121 language = NativeFileItem.Language.FORTRAN;
55.122 } else if (hasHeaderOrSourceExtension(true, true)) {
55.123 language = NativeFileItem.Language.C_HEADER;
55.124 @@ -587,6 +595,7 @@
55.125 /**
55.126 * NativeFileItem interface
55.127 **/
55.128 + @Override
55.129 public LanguageFlavor getLanguageFlavor() {
55.130 return NativeFileItem.LanguageFlavor.GENERIC;
55.131 }
55.132 @@ -594,6 +603,7 @@
55.133 /**
55.134 * NativeFileItem interface
55.135 **/
55.136 + @Override
55.137 public boolean isExcluded() {
55.138 ItemConfiguration itemConfiguration = getItemConfiguration(getMakeConfiguration());
55.139 if (itemConfiguration != null) {
56.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ItemConfiguration.java Mon Feb 01 12:23:06 2010 +0100
56.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ItemConfiguration.java Mon Feb 01 12:24:26 2010 +0100
56.3 @@ -51,7 +51,7 @@
56.4 import org.netbeans.modules.cnd.api.utils.IpeUtils;
56.5 import org.netbeans.modules.cnd.api.xml.XMLDecoder;
56.6 import org.netbeans.modules.cnd.api.xml.XMLEncoder;
56.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
56.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
56.9 import org.openide.nodes.Node;
56.10 import org.openide.nodes.PropertySupport;
56.11 import org.openide.nodes.Sheet;
56.12 @@ -64,7 +64,7 @@
56.13 private Item item;
56.14 // General
56.15 private BooleanConfiguration excluded;
56.16 - private byte tool = -1;
56.17 + private ToolKind tool = ToolKind.UnknownTool;
56.18 // Tools
56.19 private ConfigurationBase lastConfiguration;
56.20
56.21 @@ -107,10 +107,10 @@
56.22
56.23 public boolean isCompilerToolConfiguration() {
56.24 switch (getTool()) {
56.25 - case Tool.Assembler:
56.26 - case Tool.CCCompiler:
56.27 - case Tool.CCompiler:
56.28 - case Tool.FortranCompiler:
56.29 + case Assembler:
56.30 + case CCCompiler:
56.31 + case CCompiler:
56.32 + case FortranCompiler:
56.33 return true;
56.34 }
56.35 return false;
56.36 @@ -118,13 +118,13 @@
56.37
56.38 public BasicCompilerConfiguration getCompilerConfiguration() {
56.39 switch (getTool()) {
56.40 - case Tool.Assembler:
56.41 + case Assembler:
56.42 return getAssemblerConfiguration();
56.43 - case Tool.CCCompiler:
56.44 + case CCCompiler:
56.45 return getCCCompilerConfiguration();
56.46 - case Tool.CCompiler:
56.47 + case CCompiler:
56.48 return getCCompilerConfiguration();
56.49 - case Tool.FortranCompiler:
56.50 + case FortranCompiler:
56.51 return getFortranCompilerConfiguration();
56.52 }
56.53 return null;
56.54 @@ -160,38 +160,25 @@
56.55 this.excluded = excluded;
56.56 needSave = true;
56.57 }
56.58 -
56.59 - // Tool
56.60 - public void setTool(String name) {
56.61 -// if (genericName != null) {
56.62 -// CompilerSet set = CompilerSetManager.getDefault(((MakeConfiguration)configuration).getDevelopmentHost().getName()).getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
56.63 -// tool = set.getToolKind(genericName);
56.64 -// }
56.65 - setTool(Tool.getTool(name));
56.66 - }
56.67 -
56.68 - public void setTool(int tool) {
56.69 +
56.70 + public void setTool(ToolKind tool) {
56.71 if (this.tool != tool){
56.72 lastConfiguration = null;
56.73 }
56.74 - this.tool = (byte)tool;
56.75 + this.tool = tool;
56.76 }
56.77
56.78 - public int getTool() {
56.79 - if (tool == -1) {
56.80 - tool = (byte)item.getDefaultTool();
56.81 + public ToolKind getTool() {
56.82 + if (tool == ToolKind.UnknownTool) {
56.83 + tool = item.getDefaultTool();
56.84 }
56.85 return tool;
56.86 }
56.87 -// protected String getToolName() {
56.88 -// CompilerSet set = CompilerSetManager.getDefault(((MakeConfiguration)configuration).getDevelopmentHost().getName()).getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
56.89 -// return set.getTool(getTool()).getName();
56.90 -// }
56.91
56.92 protected String[] getToolNames() {
56.93 -// CompilerSet set = CompilerSetManager.getDefault(((MakeConfiguration)configuration).getDevelopmentHost().getName()).getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
56.94 -// return set.getToolGenericNames();
56.95 - return Tool.getCompilerToolNames();
56.96 + return new String[]{ToolKind.CCompiler.getDisplayName(), ToolKind.CCCompiler.getDisplayName(),
56.97 + ToolKind.FortranCompiler.getDisplayName(), ToolKind.Assembler.getDisplayName(),
56.98 + ToolKind.CustomTool.getDisplayName()};
56.99 }
56.100
56.101 // Custom Tool
56.102 @@ -200,7 +187,7 @@
56.103 }
56.104
56.105 public synchronized CustomToolConfiguration getCustomToolConfiguration() {
56.106 - if (getTool() == Tool.CustomTool) {
56.107 + if (getTool() == ToolKind.CustomTool) {
56.108 if (lastConfiguration == null) {
56.109 lastConfiguration = new CustomToolConfiguration();
56.110 }
56.111 @@ -216,7 +203,7 @@
56.112 }
56.113
56.114 public synchronized CCompilerConfiguration getCCompilerConfiguration() {
56.115 - if (getTool() == Tool.CCompiler) {
56.116 + if (getTool() == ToolKind.CCompiler) {
56.117 if (lastConfiguration == null) {
56.118 FolderConfiguration folderConfiguration = item.getFolder().getFolderConfiguration(configuration);
56.119 if (folderConfiguration != null) {
56.120 @@ -237,7 +224,7 @@
56.121 }
56.122
56.123 public synchronized CCCompilerConfiguration getCCCompilerConfiguration() {
56.124 - if (getTool() == Tool.CCCompiler) {
56.125 + if (getTool() == ToolKind.CCCompiler) {
56.126 if (lastConfiguration == null) {
56.127 FolderConfiguration folderConfiguration = item.getFolder().getFolderConfiguration(configuration);
56.128 if (folderConfiguration != null) {
56.129 @@ -258,7 +245,7 @@
56.130 }
56.131
56.132 public synchronized FortranCompilerConfiguration getFortranCompilerConfiguration() {
56.133 - if (getTool() == Tool.FortranCompiler) {
56.134 + if (getTool() == ToolKind.FortranCompiler) {
56.135 if (lastConfiguration == null) {
56.136 lastConfiguration = new FortranCompilerConfiguration(((MakeConfiguration) configuration).getBaseDir(), ((MakeConfiguration) configuration).getFortranCompilerConfiguration());
56.137 }
56.138 @@ -274,7 +261,7 @@
56.139 }
56.140
56.141 public synchronized AssemblerConfiguration getAssemblerConfiguration() {
56.142 - if (getTool() == Tool.Assembler) {
56.143 + if (getTool() == ToolKind.Assembler) {
56.144 if (lastConfiguration == null) {
56.145 lastConfiguration = new AssemblerConfiguration(((MakeConfiguration) configuration).getBaseDir(), ((MakeConfiguration) configuration).getAssemblerConfiguration());
56.146 }
56.147 @@ -285,16 +272,19 @@
56.148 }
56.149
56.150 // interface ConfigurationAuxObject
56.151 + @Override
56.152 public boolean shared() {
56.153 return true;
56.154 }
56.155
56.156 // interface ConfigurationAuxObject
56.157 + @Override
56.158 public boolean hasChanged() {
56.159 return needSave;
56.160 }
56.161
56.162 // interface ProfileAuxObject
56.163 + @Override
56.164 public void clearChanged() {
56.165 needSave = false;
56.166 }
56.167 @@ -314,10 +304,12 @@
56.168 // static public String getId(String path) {
56.169 // return "item-" + path; // NOI18N
56.170 // }
56.171 + @Override
56.172 public String getId() {
56.173 return item.getId();
56.174 }
56.175
56.176 + @Override
56.177 public void assign(ConfigurationAuxObject profileAuxObject) {
56.178 if (!(profileAuxObject instanceof ItemConfiguration)) {
56.179 // FIXUP: exception ????
56.180 @@ -334,19 +326,19 @@
56.181 getExcluded().assign(i.getExcluded());
56.182 setTool(i.getTool());
56.183 switch (getTool()) {
56.184 - case Tool.Assembler:
56.185 + case Assembler:
56.186 getAssemblerConfiguration().assign(i.getAssemblerConfiguration());
56.187 break;
56.188 - case Tool.CCCompiler:
56.189 + case CCCompiler:
56.190 getCCCompilerConfiguration().assign(i.getCCCompilerConfiguration());
56.191 break;
56.192 - case Tool.CCompiler:
56.193 + case CCompiler:
56.194 getCCompilerConfiguration().assign(i.getCCompilerConfiguration());
56.195 break;
56.196 - case Tool.CustomTool:
56.197 + case CustomTool:
56.198 getCustomToolConfiguration().assign(i.getCustomToolConfiguration());
56.199 break;
56.200 - case Tool.FortranCompiler:
56.201 + case FortranCompiler:
56.202 getFortranCompilerConfiguration().assign(i.getFortranCompilerConfiguration());
56.203 break;
56.204 default:
56.205 @@ -364,19 +356,19 @@
56.206 getExcluded().assign(i.getExcluded());
56.207 setTool(i.getTool());
56.208 switch (getTool()) {
56.209 - case Tool.Assembler:
56.210 + case Assembler:
56.211 getAssemblerConfiguration().assign(i.getAssemblerConfiguration());
56.212 break;
56.213 - case Tool.CCCompiler:
56.214 + case CCCompiler:
56.215 getCCCompilerConfiguration().assign(i.getCCCompilerConfiguration());
56.216 break;
56.217 - case Tool.CCompiler:
56.218 + case CCompiler:
56.219 getCCompilerConfiguration().assign(i.getCCompilerConfiguration());
56.220 break;
56.221 - case Tool.CustomTool:
56.222 + case CustomTool:
56.223 getCustomToolConfiguration().assign(i.getCustomToolConfiguration());
56.224 break;
56.225 - case Tool.FortranCompiler:
56.226 + case FortranCompiler:
56.227 getFortranCompilerConfiguration().assign(i.getFortranCompilerConfiguration());
56.228 break;
56.229 default:
56.230 @@ -399,19 +391,19 @@
56.231 i.setExcluded(getExcluded().clone());
56.232 i.setTool(getTool());
56.233 switch (getTool()) {
56.234 - case Tool.Assembler:
56.235 + case Assembler:
56.236 i.setAssemblerConfiguration(getAssemblerConfiguration().clone());
56.237 break;
56.238 - case Tool.CCCompiler:
56.239 + case CCCompiler:
56.240 i.setCCCompilerConfiguration(getCCCompilerConfiguration().clone());
56.241 break;
56.242 - case Tool.CCompiler:
56.243 + case CCompiler:
56.244 i.setCCompilerConfiguration(getCCompilerConfiguration().clone());
56.245 break;
56.246 - case Tool.CustomTool:
56.247 + case CustomTool:
56.248 i.setCustomToolConfiguration(getCustomToolConfiguration().clone());
56.249 break;
56.250 - case Tool.FortranCompiler:
56.251 + case FortranCompiler:
56.252 i.setFortranCompilerConfiguration(getFortranCompilerConfiguration().clone());
56.253 break;
56.254 default:
56.255 @@ -422,14 +414,17 @@
56.256
56.257 //
56.258 // XML codec support
56.259 + @Override
56.260 public XMLDecoder getXMLDecoder() {
56.261 return new ItemXMLCodec(this);
56.262 }
56.263
56.264 + @Override
56.265 public XMLEncoder getXMLEncoder() {
56.266 return new ItemXMLCodec(this);
56.267 }
56.268
56.269 + @Override
56.270 public void initialize() {
56.271 // FIXUP: this doesn't make sense...
56.272 }
56.273 @@ -481,20 +476,24 @@
56.274 return getString("ToolTxt1");
56.275 }
56.276
56.277 + @Override
56.278 public Integer getValue() {
56.279 - return Integer.valueOf(getTool());
56.280 + return Integer.valueOf(getTool().ordinal());
56.281 }
56.282
56.283 + @Override
56.284 public void setValue(Integer v) {
56.285 // String newTool = (String) v;
56.286 // setTool(newTool);
56.287 - setTool(v);
56.288 + setTool(ToolKind.getTool(v));
56.289 }
56.290
56.291 + @Override
56.292 public boolean canWrite() {
56.293 return true;
56.294 }
56.295
56.296 + @Override
56.297 public boolean canRead() {
56.298 return true;
56.299 }
56.300 @@ -515,7 +514,7 @@
56.301 @Override
56.302 public String getAsText() {
56.303 int val = ((Integer) getValue()).intValue();
56.304 - return Tool.getName(val);
56.305 + return ToolKind.getTool(val).getDisplayName();
56.306 // CompilerSet set = CompilerSetManager.getDefault(((MakeConfiguration)configuration).getDevelopmentHost().getName()).getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
56.307 // return set.getTool(val).getGenericName();
56.308 }
56.309 @@ -523,7 +522,7 @@
56.310 @Override
56.311 public void setAsText(String text) throws java.lang.IllegalArgumentException {
56.312 // setValue(text);
56.313 - setValue(Tool.getTool(text));
56.314 + setValue(ToolKind.getTool(text));
56.315 }
56.316
56.317 @Override
56.318 @@ -534,17 +533,19 @@
56.319
56.320 private static class StringRONodeProp extends PropertySupport<String> {
56.321
56.322 - String value;
56.323 + private String value;
56.324
56.325 public StringRONodeProp(String name, String value) {
56.326 super(name, String.class, name, name, true, false);
56.327 this.value = value;
56.328 }
56.329
56.330 + @Override
56.331 public String getValue() {
56.332 return value;
56.333 }
56.334
56.335 + @Override
56.336 public void setValue(String v) {
56.337 }
56.338 }
57.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/LinkerConfiguration.java Mon Feb 01 12:23:06 2010 +0100
57.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/LinkerConfiguration.java Mon Feb 01 12:24:26 2010 +0100
57.3 @@ -43,7 +43,7 @@
57.4 import org.netbeans.api.project.Project;
57.5 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
57.6 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
57.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
57.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
57.9 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.LinkerDescriptor;
57.10 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.BooleanNodeProp;
57.11 import org.netbeans.modules.cnd.makeproject.configurations.ui.LibrariesNodeProp;
57.12 @@ -260,7 +260,7 @@
57.13 // FIXUP: should be move to Platform...
57.14 if (cs != null) {
57.15 options += cs.getCompilerFlavor().getToolchainDescriptor().getLinker().getDynamicLibraryBasicFlag();
57.16 - if (cs.isGnuCompiler() && getMakeConfiguration().getDevelopmentHost().getBuildPlatform() == PlatformTypes.PLATFORM_MACOSX) {
57.17 + if (cs.getCompilerFlavor().isGnuCompiler() && getMakeConfiguration().getDevelopmentHost().getBuildPlatform() == PlatformTypes.PLATFORM_MACOSX) {
57.18 options += libName + " "; // NOI18N
57.19 }
57.20 }
57.21 @@ -277,7 +277,7 @@
57.22 if (getPICOption().getValue()) {
57.23 options += getPICOption(cs);
57.24 }
57.25 - if (cs.isSunCompiler()) {
57.26 + if (cs.getCompilerFlavor().isSunStudioCompiler()) {
57.27 options += getNorunpathOption().getOption() + " "; // NOI18N
57.28 options += getNameassignOption(getNameassignOption().getValue()) + " "; // NOI18N
57.29 }
57.30 @@ -330,10 +330,10 @@
57.31 if (compilerSet != null) {
57.32 linker = compilerSet == null ? null : compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker();
57.33 if (conf.hasCPPFiles(configurationDescriptor)) {
57.34 - BasicCompiler ccCompiler = (BasicCompiler) compilerSet.getTool(Tool.CCCompiler);
57.35 + BasicCompiler ccCompiler = (BasicCompiler) compilerSet.getTool(ToolKind.CCCompiler);
57.36 linkDriver = ccCompiler.getName();
57.37 } else {
57.38 - BasicCompiler cCompiler = (BasicCompiler) compilerSet.getTool(Tool.CCompiler);
57.39 + BasicCompiler cCompiler = (BasicCompiler) compilerSet.getTool(ToolKind.CCompiler);
57.40 linkDriver = cCompiler.getName();
57.41 }
57.42 }
57.43 @@ -358,7 +358,7 @@
57.44 set2.put(new BooleanNodeProp(getStripOption(), true, "StripSymbols", getString("StripSymbolsTxt"), getString("StripSymbolsHint"))); // NOI18N
57.45 if (conf.getConfigurationType().getValue() == MakeConfiguration.TYPE_DYNAMIC_LIB) {
57.46 set2.put(new BooleanNodeProp(getPICOption(), true, "PositionIndependantCode", getString("PositionIndependantCodeTxt"), getString("PositionIndependantCodeHint"))); // NOI18N
57.47 - if (compilerSet != null && compilerSet.isSunCompiler()) {
57.48 + if (compilerSet != null && compilerSet.getCompilerFlavor().isSunStudioCompiler()) {
57.49 set2.put(new BooleanNodeProp(getNorunpathOption(), true, "NoRunPath", getString("NoRunPathTxt"), getString("NoRunPathHint"))); // NOI18N
57.50 set2.put(new BooleanNodeProp(getNameassignOption(), true, "AssignName", getString("AssignNameTxt"), getString("AssignNameHint"))); // NOI18N
57.51 }
57.52 @@ -402,7 +402,7 @@
57.53 return sheet;
57.54 }
57.55
57.56 - class AdditionalDependenciesOptions implements AllOptionsProvider {
57.57 + private final class AdditionalDependenciesOptions implements AllOptionsProvider {
57.58
57.59 @Override
57.60 public String getAllOptions(BasicCompiler compiler) {
58.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/MakeConfiguration.java Mon Feb 01 12:23:06 2010 +0100
58.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/MakeConfiguration.java Mon Feb 01 12:24:26 2010 +0100
58.3 @@ -50,8 +50,7 @@
58.4 import org.netbeans.api.project.Project;
58.5 import org.netbeans.api.project.ProjectManager;
58.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
58.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
58.8 -import org.netbeans.modules.cnd.toolchain.api.Tool;
58.9 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
58.10 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
58.11 import org.netbeans.modules.cnd.api.utils.IpeUtils;
58.12 import org.netbeans.modules.cnd.api.utils.PlatformInfo;
58.13 @@ -62,7 +61,7 @@
58.14 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.IntNodeProp;
58.15 import org.netbeans.modules.cnd.makeproject.api.platforms.Platforms;
58.16 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.BooleanNodeProp;
58.17 -import org.netbeans.modules.cnd.makeproject.configurations.ui.BuildPlatformNodeProp;
58.18 +import org.netbeans.modules.cnd.makeproject.configurations.CppUtils;
58.19 import org.netbeans.modules.cnd.makeproject.configurations.ui.CompilerSetNodeProp;
58.20 import org.netbeans.modules.cnd.makeproject.configurations.ui.DevelopmentHostNodeProp;
58.21 import org.netbeans.modules.cnd.makeproject.configurations.ui.RequiredProjectsNodeProp;
58.22 @@ -124,11 +123,11 @@
58.23
58.24 // Constructors
58.25 public MakeConfiguration(MakeConfigurationDescriptor makeConfigurationDescriptor, String name, int configurationTypeValue) {
58.26 - this(makeConfigurationDescriptor.getBaseDir(), name, configurationTypeValue, CompilerSetManager.getDefaultDevelopmentHost());
58.27 + this(makeConfigurationDescriptor.getBaseDir(), name, configurationTypeValue, CppUtils.getDefaultDevelopmentHost());
58.28 }
58.29
58.30 public MakeConfiguration(String baseDir, String name, int configurationTypeValue) {
58.31 - this(baseDir, name, configurationTypeValue, CompilerSetManager.getDefaultDevelopmentHost());
58.32 + this(baseDir, name, configurationTypeValue, CppUtils.getDefaultDevelopmentHost());
58.33 }
58.34
58.35 public MakeConfiguration(String baseDir, String name, int configurationTypeValue, String host) {
58.36 @@ -384,6 +383,7 @@
58.37 this.qmakeConfiguration = qmakeConfiguration;
58.38 }
58.39
58.40 + @Override
58.41 public void assign(Configuration conf) {
58.42 MakeConfiguration makeConf = (MakeConfiguration) conf;
58.43 setName(makeConf.getName());
58.44 @@ -425,6 +425,7 @@
58.45 }
58.46 }
58.47
58.48 + @Override
58.49 public Configuration cloneConf() {
58.50 return (Configuration) clone();
58.51 }
58.52 @@ -433,6 +434,7 @@
58.53 * Make a copy of configuration requested from Project Properties
58.54 * @return Copy of configuration
58.55 */
58.56 + @Override
58.57 public Configuration copy() {
58.58 MakeConfiguration copy = new MakeConfiguration(getBaseDir(), getName(), getConfigurationType().getValue());
58.59 copy.assign(this);
58.60 @@ -660,16 +662,16 @@
58.61 itemConfiguration.getExcluded().getValue()) {
58.62 continue;
58.63 }
58.64 - if (itemConfiguration.getTool() == Tool.CCompiler) {
58.65 + if (itemConfiguration.getTool() == ToolKind.CCompiler) {
58.66 hasCFiles = true;
58.67 }
58.68 - if (itemConfiguration.getTool() == Tool.CCCompiler) {
58.69 + if (itemConfiguration.getTool() == ToolKind.CCCompiler) {
58.70 hasCPPFiles = true;
58.71 }
58.72 - if (itemConfiguration.getTool() == Tool.FortranCompiler) {
58.73 + if (itemConfiguration.getTool() == ToolKind.FortranCompiler) {
58.74 hasFortranFiles = true;
58.75 }
58.76 - if (itemConfiguration.getTool() == Tool.Assembler) {
58.77 + if (itemConfiguration.getTool() == ToolKind.Assembler) {
58.78 hasAssemblerFiles = true;
58.79 }
58.80 // if (itemConfiguration.getTool() == Tool.AsmCompiler) {
58.81 @@ -849,7 +851,7 @@
58.82 * Special version of IntConfiguration
58.83 * Names are shifted one (because Makefile is not allowed as a choice anymore for managed projects)
58.84 */
58.85 - static class ManagedIntConfiguration extends IntConfiguration {
58.86 + private final static class ManagedIntConfiguration extends IntConfiguration {
58.87 public ManagedIntConfiguration(IntConfiguration master, int def, String[] names, String[] options) {
58.88 super(master, def, names, options);
58.89 }
59.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformGeneric.java Mon Feb 01 12:23:06 2010 +0100
59.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformGeneric.java Mon Feb 01 12:24:26 2010 +0100
59.3 @@ -58,15 +58,18 @@
59.4 super(NAME, NbBundle.getBundle(PlatformGeneric.class).getString("GenericName"), PlatformTypes.PLATFORM_GENERIC); // NOI18N
59.5 }
59.6
59.7 + @Override
59.8 public LibraryItem.StdLibItem[] getStandardLibraries() {
59.9 return standardLibrariesLinux;
59.10 }
59.11
59.12 + @Override
59.13 public String getLibraryName(String baseName) {
59.14 // Use Linux style
59.15 return "lib" + baseName + ".so"; // NOI18N
59.16 }
59.17
59.18 + @Override
59.19 public String getLibraryLinkOption(String libName, String libDir, String libPath, CompilerSet compilerSet) {
59.20 if (libName.endsWith(".so")) { // NOI18N
59.21 int i = libName.indexOf(".so"); // NOI18N
59.22 @@ -76,8 +79,10 @@
59.23 if (libName.startsWith("lib")) { // NOI18N
59.24 libName = libName.substring(3);
59.25 }
59.26 - return compilerSet.getLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir)
59.27 - + " " + compilerSet.getLibraryOption() + IpeUtils.escapeOddCharacters(libName); // NOI18N
59.28 + return compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibrarySearchFlag()
59.29 + + IpeUtils.escapeOddCharacters(libDir)
59.30 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibraryFlag() // NOI18N
59.31 + + IpeUtils.escapeOddCharacters(libName);
59.32 } else {
59.33 return IpeUtils.escapeOddCharacters(libPath);
59.34 }
60.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformLinux.java Mon Feb 01 12:23:06 2010 +0100
60.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformLinux.java Mon Feb 01 12:24:26 2010 +0100
60.3 @@ -62,14 +62,17 @@
60.4 super(NAME, "Linux x86", PlatformTypes.PLATFORM_LINUX); // NOI18N
60.5 }
60.6
60.7 + @Override
60.8 public LibraryItem.StdLibItem[] getStandardLibraries() {
60.9 return standardLibrariesLinux;
60.10 }
60.11
60.12 + @Override
60.13 public String getLibraryName(String baseName) {
60.14 return "lib" + baseName + ".so"; // NOI18N // NOI18N
60.15 }
60.16
60.17 + @Override
60.18 public String getLibraryLinkOption(String libName, String libDir, String libPath, CompilerSet compilerSet) {
60.19 if (libName.endsWith(".so")) { // NOI18N
60.20 int i = libName.indexOf(".so"); // NOI18N
60.21 @@ -79,9 +82,13 @@
60.22 if (libName.startsWith("lib")) { // NOI18N
60.23 libName = libName.substring(3);
60.24 }
60.25 - return compilerSet.getDynamicLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir)
60.26 - + " " + compilerSet.getLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir) // NOI18N
60.27 - + " " + compilerSet.getLibraryOption() + IpeUtils.escapeOddCharacters(libName); // NOI18N
60.28 +
60.29 + return compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getDynamicLibrarySearchFlag()
60.30 + + IpeUtils.escapeOddCharacters(libDir)
60.31 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibrarySearchFlag() // NOI18N
60.32 + + IpeUtils.escapeOddCharacters(libDir)
60.33 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibraryFlag() // NOI18N
60.34 + + IpeUtils.escapeOddCharacters(libName);
60.35 } else {
60.36 return IpeUtils.escapeOddCharacters(libPath);
60.37 }
61.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformMacOSX.java Mon Feb 01 12:23:06 2010 +0100
61.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformMacOSX.java Mon Feb 01 12:24:26 2010 +0100
61.3 @@ -63,14 +63,17 @@
61.4 super(NAME, "Mac OS X", PlatformTypes.PLATFORM_MACOSX); // NOI18N
61.5 }
61.6
61.7 + @Override
61.8 public LibraryItem.StdLibItem[] getStandardLibraries() {
61.9 return standardLibrariesLinux;
61.10 }
61.11
61.12 + @Override
61.13 public String getLibraryName(String baseName) {
61.14 return "lib" + baseName + "." + LIBRARY_SUFFIX; // NOI18N
61.15 }
61.16
61.17 + @Override
61.18 public String getLibraryLinkOption(String libName, String libDir, String libPath, CompilerSet compilerSet) {
61.19 if (libName.endsWith("." + LIBRARY_SUFFIX)) { // NOI18N
61.20 int i = libName.indexOf("." + LIBRARY_SUFFIX); // NOI18N
61.21 @@ -80,8 +83,10 @@
61.22 if (libName.startsWith("lib")) { // NOI18N
61.23 libName = libName.substring(3);
61.24 }
61.25 - return compilerSet.getLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir)
61.26 - + " " + compilerSet.getLibraryOption() + IpeUtils.escapeOddCharacters(libName); // NOI18N
61.27 + return compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibrarySearchFlag()
61.28 + + IpeUtils.escapeOddCharacters(libDir)
61.29 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibraryFlag() // NOI18N
61.30 + + IpeUtils.escapeOddCharacters(libName);
61.31 } else {
61.32 return IpeUtils.escapeOddCharacters(libPath);
61.33 }
62.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformNone.java Mon Feb 01 12:23:06 2010 +0100
62.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformNone.java Mon Feb 01 12:24:26 2010 +0100
62.3 @@ -58,15 +58,18 @@
62.4 super(NAME, NbBundle.getBundle(PlatformNone.class).getString("NoPlatform"), PlatformTypes.PLATFORM_NONE);
62.5 }
62.6
62.7 + @Override
62.8 public LibraryItem.StdLibItem[] getStandardLibraries() {
62.9 return standardLibrariesLinux;
62.10 }
62.11
62.12 + @Override
62.13 public String getLibraryName(String baseName) {
62.14 // Use Linux style
62.15 return "lib" + baseName + ".so"; // NOI18N
62.16 }
62.17
62.18 + @Override
62.19 public String getLibraryLinkOption(String libName, String libDir, String libPath, CompilerSet compilerSet) {
62.20 if (libName.endsWith(".so")) { // NOI18N
62.21 int i = libName.indexOf(".so"); // NOI18N
62.22 @@ -76,8 +79,10 @@
62.23 if (libName.startsWith("lib")) { // NOI18N
62.24 libName = libName.substring(3);
62.25 }
62.26 - return compilerSet.getLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir)
62.27 - + " " + compilerSet.getLibraryOption() + IpeUtils.escapeOddCharacters(libName); // NOI18N
62.28 + return compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibrarySearchFlag()
62.29 + + IpeUtils.escapeOddCharacters(libDir)
62.30 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibraryFlag() // NOI18N
62.31 + + IpeUtils.escapeOddCharacters(libName);
62.32 } else {
62.33 return IpeUtils.escapeOddCharacters(libPath);
62.34 }
63.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformSolaris.java Mon Feb 01 12:23:06 2010 +0100
63.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformSolaris.java Mon Feb 01 12:24:26 2010 +0100
63.3 @@ -64,14 +64,17 @@
63.4 super(name, displayName, id);
63.5 }
63.6
63.7 + @Override
63.8 public LibraryItem.StdLibItem[] getStandardLibraries() {
63.9 return standardLibrariesSolaris;
63.10 }
63.11
63.12 + @Override
63.13 public String getLibraryName(String baseName) {
63.14 return "lib" + baseName + ".so"; // NOI18N
63.15 }
63.16
63.17 + @Override
63.18 public String getLibraryLinkOption(String libName, String libDir, String libPath, CompilerSet compilerSet) {
63.19 if (libName.endsWith(".so")) { // NOI18N
63.20 int i = libName.indexOf(".so"); // NOI18N
63.21 @@ -81,9 +84,12 @@
63.22 if (libName.startsWith("lib")) { // NOI18N
63.23 libName = libName.substring(3);
63.24 }
63.25 - return compilerSet.getDynamicLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir)
63.26 - + " " + compilerSet.getLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir) // NOI18N
63.27 - + " " + compilerSet.getLibraryOption() + IpeUtils.escapeOddCharacters(libName); // NOI18N
63.28 + return compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getDynamicLibrarySearchFlag()
63.29 + + IpeUtils.escapeOddCharacters(libDir)
63.30 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibrarySearchFlag() // NOI18N
63.31 + + IpeUtils.escapeOddCharacters(libDir)
63.32 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibraryFlag() // NOI18N
63.33 + + IpeUtils.escapeOddCharacters(libName);
63.34 } else {
63.35 return IpeUtils.escapeOddCharacters(libPath);
63.36 }
64.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformWindows.java Mon Feb 01 12:23:06 2010 +0100
64.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/platforms/PlatformWindows.java Mon Feb 01 12:24:26 2010 +0100
64.3 @@ -59,10 +59,12 @@
64.4 super(NAME, "Windows", PlatformTypes.PLATFORM_WINDOWS); // NOI18N
64.5 }
64.6
64.7 + @Override
64.8 public LibraryItem.StdLibItem[] getStandardLibraries() {
64.9 return standardLibrariesWindows;
64.10 }
64.11
64.12 + @Override
64.13 public String getLibraryName(String baseName) {
64.14 return "lib" + baseName + ".dll"; // NOI18N
64.15 }
64.16 @@ -74,6 +76,7 @@
64.17 return baseName + majorVersion + ".dll"; // NOI18N
64.18 }
64.19
64.20 + @Override
64.21 public String getLibraryLinkOption(String libName, String libDir, String libPath, CompilerSet compilerSet) {
64.22 if (libName.endsWith(".dll")) { // NOI18N
64.23 int i = libName.indexOf(".dll"); // NOI18N
64.24 @@ -83,8 +86,10 @@
64.25 if (libName.startsWith("lib") || libName.startsWith("cyg")) { // NOI18N
64.26 libName = libName.substring(3);
64.27 }
64.28 - return compilerSet.getLibrarySearchOption() + IpeUtils.escapeOddCharacters(libDir)
64.29 - + " " + compilerSet.getLibraryOption() + IpeUtils.escapeOddCharacters(libName); // NOI18N
64.30 + return compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibrarySearchFlag()
64.31 + + IpeUtils.escapeOddCharacters(libDir)
64.32 + + " " + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibraryFlag() // NOI18N
64.33 + + IpeUtils.escapeOddCharacters(libName);
64.34 } else {
64.35 return IpeUtils.escapeOddCharacters(libPath);
64.36 }
65.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ConfigurationMakefileWriter.java Mon Feb 01 12:23:06 2010 +0100
65.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ConfigurationMakefileWriter.java Mon Feb 01 12:24:26 2010 +0100
65.3 @@ -70,9 +70,8 @@
65.4 import org.netbeans.modules.cnd.api.utils.IpeUtils;
65.5 import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
65.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
65.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
65.8 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
65.9 -import org.netbeans.modules.cnd.toolchain.api.Tool;
65.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
65.11 import org.netbeans.modules.cnd.makeproject.MakeOptions;
65.12 import org.netbeans.modules.cnd.makeproject.api.configurations.DefaultMakefileWriter;
65.13 import org.netbeans.modules.cnd.makeproject.spi.configurations.MakefileWriter;
65.14 @@ -83,6 +82,8 @@
65.15 import org.netbeans.modules.cnd.makeproject.api.platforms.Platforms;
65.16 import org.netbeans.modules.cnd.makeproject.api.remote.FilePathAdaptor;
65.17 import org.netbeans.modules.cnd.makeproject.packaging.DummyPackager;
65.18 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
65.19 +import org.netbeans.modules.cnd.toolchain.api.Tool;
65.20 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
65.21 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
65.22 import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
65.23 @@ -147,7 +148,7 @@
65.24 for (int i = 0; i < confs.length; i++) {
65.25 MakeConfiguration conf = (MakeConfiguration) confs[i];
65.26 if (conf.getDevelopmentHost().isLocalhost() &&
65.27 - CompilerSetManager.getDefault(conf.getDevelopmentHost().getExecutionEnvironment()).getPlatform() != conf.getDevelopmentHost().getBuildPlatformConfiguration().getValue()) {
65.28 + CompilerSetManager.get(conf.getDevelopmentHost().getExecutionEnvironment()).getPlatform() != conf.getDevelopmentHost().getBuildPlatformConfiguration().getValue()) {
65.29 // add configurations if local host and target platform are different (don't have the right compiler set on this platform)
65.30 wrongPlatform.add(conf);
65.31 }
65.32 @@ -161,11 +162,11 @@
65.33 }
65.34 if (!wrongPlatform.isEmpty() && showWarning && MakeOptions.getInstance().getShowConfigurationWarning()) {
65.35 ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.fromUniqueID(HostInfoUtils.LOCALHOST);
65.36 - int platformID = CompilerSetManager.getDefault(execEnv).getPlatform();
65.37 + int platformID = CompilerSetManager.get(execEnv).getPlatform();
65.38 Platform platform = Platforms.getPlatform(platformID);
65.39 - StringBuffer list = new StringBuffer();
65.40 + StringBuilder list = new StringBuilder();
65.41 for (MakeConfiguration c : wrongPlatform) {
65.42 - list.append(getString("CONF", c.getName(), c.getDevelopmentHost().getBuildPlatformConfiguration().getName()) + "\n"); // NOI18N
65.43 + list.append(getString("CONF", c.getName(), c.getDevelopmentHost().getBuildPlatformConfiguration().getName())).append("\n"); // NOI18N
65.44 }
65.45 final String msg = getString("TARGET_MISMATCH_TXT", platform.getDisplayName(), list.toString());
65.46 final String title = getString("TARGET_MISMATCH_DIALOG_TITLE.TXT");
65.47 @@ -327,23 +328,23 @@
65.48 }
65.49 }
65.50
65.51 - public static String getCompilerName(MakeConfiguration conf, int tool) {
65.52 + public static String getCompilerName(MakeConfiguration conf, ToolKind tool) {
65.53 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
65.54 if (compilerSet != null) {
65.55 Tool compiler = compilerSet.getTool(tool);
65.56 if (compiler != null) {
65.57 BasicCompilerConfiguration compilerConf = null;
65.58 switch (tool) {
65.59 - case Tool.CCompiler:
65.60 + case CCompiler:
65.61 compilerConf = conf.getCCompilerConfiguration();
65.62 break;
65.63 - case Tool.CCCompiler:
65.64 + case CCCompiler:
65.65 compilerConf = conf.getCCCompilerConfiguration();
65.66 break;
65.67 - case Tool.FortranCompiler:
65.68 + case FortranCompiler:
65.69 compilerConf = conf.getFortranCompilerConfiguration();
65.70 break;
65.71 - case Tool.Assembler:
65.72 + case Assembler:
65.73 compilerConf = conf.getAssemblerConfiguration();
65.74 break;
65.75 }
65.76 @@ -365,10 +366,10 @@
65.77 if (compilerSet == null) {
65.78 return;
65.79 }
65.80 - BasicCompiler cCompiler = (BasicCompiler) compilerSet.getTool(Tool.CCompiler);
65.81 - BasicCompiler ccCompiler = (BasicCompiler) compilerSet.getTool(Tool.CCCompiler);
65.82 - BasicCompiler fortranCompiler = (BasicCompiler) compilerSet.getTool(Tool.FortranCompiler);
65.83 - BasicCompiler assemblerCompiler = (BasicCompiler) compilerSet.getTool(Tool.Assembler);
65.84 + BasicCompiler cCompiler = (BasicCompiler) compilerSet.getTool(ToolKind.CCompiler);
65.85 + BasicCompiler ccCompiler = (BasicCompiler) compilerSet.getTool(ToolKind.CCCompiler);
65.86 + BasicCompiler fortranCompiler = (BasicCompiler) compilerSet.getTool(ToolKind.FortranCompiler);
65.87 + BasicCompiler assemblerCompiler = (BasicCompiler) compilerSet.getTool(ToolKind.Assembler);
65.88
65.89 bw.write("#\n"); // NOI18N
65.90 bw.write("# Generated Makefile - do not edit!\n"); // NOI18N
65.91 @@ -384,16 +385,16 @@
65.92 bw.write("CP=cp\n"); // NOI18N
65.93 bw.write("CCADMIN=CCadmin\n"); // NOI18N
65.94 bw.write("RANLIB=ranlib\n"); // NOI18N
65.95 - bw.write("CC=" + getCompilerName(conf, Tool.CCompiler) + "\n"); // NOI18N
65.96 - bw.write("CCC=" + getCompilerName(conf, Tool.CCCompiler) + "\n"); // NOI18N
65.97 - bw.write("CXX=" + getCompilerName(conf, Tool.CCCompiler) + "\n"); // NOI18N
65.98 - bw.write("FC=" + getCompilerName(conf, Tool.FortranCompiler) + "\n"); // NOI18N
65.99 - bw.write("AS=" + getCompilerName(conf, Tool.Assembler) + "\n"); // NOI18N
65.100 + bw.write("CC=" + getCompilerName(conf, ToolKind.CCompiler) + "\n"); // NOI18N
65.101 + bw.write("CCC=" + getCompilerName(conf, ToolKind.CCCompiler) + "\n"); // NOI18N
65.102 + bw.write("CXX=" + getCompilerName(conf, ToolKind.CCCompiler) + "\n"); // NOI18N
65.103 + bw.write("FC=" + getCompilerName(conf, ToolKind.FortranCompiler) + "\n"); // NOI18N
65.104 + bw.write("AS=" + getCompilerName(conf, ToolKind.Assembler) + "\n"); // NOI18N
65.105 if (conf.getArchiverConfiguration().getTool().getModified()) {
65.106 bw.write("AR=" + conf.getArchiverConfiguration().getTool().getValue() + "\n"); // NOI18N
65.107 }
65.108 if (conf.isQmakeConfiguration()) {
65.109 - bw.write("QMAKE=" + getCompilerName(conf, Tool.QMakeTool) + "\n"); // NOI18N
65.110 + bw.write("QMAKE=" + getCompilerName(conf, ToolKind.QMakeTool) + "\n"); // NOI18N
65.111 }
65.112 bw.write("\n"); // NOI18N
65.113
65.114 @@ -441,7 +442,7 @@
65.115 String qmakeSpec = conf.getQmakeConfiguration().getQmakeSpec().getValue();
65.116 if (qmakeSpec.length() == 0 && conf.getDevelopmentHost().getBuildPlatform() == PlatformTypes.PLATFORM_MACOSX) {
65.117 // on Mac we force spec to macx-g++, otherwise qmake generates xcode project
65.118 - qmakeSpec = compilerSet.getQmakeSpec(conf.getDevelopmentHost().getBuildPlatform());
65.119 + CppUtils.getQmakeSpec(compilerSet, conf.getDevelopmentHost().getBuildPlatform());
65.120 }
65.121 if (0 < qmakeSpec.length()) {
65.122 qmakeSpec = "-spec " + qmakeSpec + " "; // NOI18N
65.123 @@ -492,7 +493,7 @@
65.124
65.125 public static void writeQTTarget(MakeConfigurationDescriptor projectDescriptor, MakeConfiguration conf, Writer bw) throws IOException {
65.126 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
65.127 - String output = compilerSet.normalizeDriveLetter(getOutput(conf));
65.128 + String output = CppUtils.normalizeDriveLetter(compilerSet, getOutput(conf));
65.129 bw.write("# Build Targets\n"); // NOI18N
65.130 bw.write(".build-conf: ${BUILD_SUBPROJECTS} nbproject/qt-${CND_CONF}.mk\n"); // NOI18N
65.131 bw.write("\t${MAKE} -f nbproject/qt-${CND_CONF}.mk " + output + "\n"); // NOI18N
65.132 @@ -500,7 +501,7 @@
65.133
65.134 public static void writeBuildTarget(MakeConfigurationDescriptor projectDescriptor, MakeConfiguration conf, Writer bw) throws IOException {
65.135 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
65.136 - String output = compilerSet.normalizeDriveLetter(getOutput(conf));
65.137 + String output = CppUtils.normalizeDriveLetter(compilerSet, getOutput(conf));
65.138 bw.write("# Build Targets\n"); // NOI18N
65.139 bw.write(".build-conf: ${BUILD_SUBPROJECTS}\n"); // NOI18N
65.140 bw.write("\t${MAKE} " // NOI18N
65.141 @@ -510,10 +511,10 @@
65.142
65.143 public static void writeLinkTarget(MakeConfigurationDescriptor projectDescriptor, MakeConfiguration conf, Writer bw) throws IOException {
65.144 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
65.145 - String output = compilerSet.normalizeDriveLetter(getOutput(conf));
65.146 + String output = CppUtils.normalizeDriveLetter(compilerSet, getOutput(conf));
65.147 LinkerConfiguration linkerConfiguration = conf.getLinkerConfiguration();
65.148 CompilerSet cs = conf.getCompilerSet().getCompilerSet();
65.149 - output = cs.normalizeDriveLetter(output);
65.150 + output = CppUtils.normalizeDriveLetter(cs,output);
65.151 String command = ""; // NOI18N
65.152 if (linkerConfiguration.getTool().getModified()) {
65.153 command += linkerConfiguration.getTool().getValue() + " "; // NOI18N
65.154 @@ -536,7 +537,7 @@
65.155 for (LibraryItem lib : linkerConfiguration.getLibrariesConfiguration().getValue()) {
65.156 String libPath = lib.getPath();
65.157 if (libPath != null && libPath.length() > 0) {
65.158 - bw.write(output + ": " + IpeUtils.escapeOddCharacters(cs.normalizeDriveLetter(libPath)) + "\n\n"); // NOI18N
65.159 + bw.write(output + ": " + IpeUtils.escapeOddCharacters(CppUtils.normalizeDriveLetter(cs,libPath)) + "\n\n"); // NOI18N
65.160 }
65.161 }
65.162 bw.write(output + ": ${OBJECTFILES}\n"); // NOI18N
65.163 @@ -549,7 +550,7 @@
65.164
65.165 public static void writeArchiveTarget(MakeConfigurationDescriptor projectDescriptor, MakeConfiguration conf, Writer bw) throws IOException {
65.166 CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
65.167 - String output = compilerSet.normalizeDriveLetter(getOutput(conf));
65.168 + String output = CppUtils.normalizeDriveLetter(compilerSet, getOutput(conf));
65.169 ArchiverConfiguration archiverConfiguration = conf.getArchiverConfiguration();
65.170 String command = "${AR}" + " "; // NOI18N
65.171 command += archiverConfiguration.getOptions() + " "; // NOI18N
65.172 @@ -584,7 +585,7 @@
65.173 if (compilerSet == null) {
65.174 continue;
65.175 }
65.176 - file = IpeUtils.escapeOddCharacters(compilerSet.normalizeDriveLetter(items[i].getPath()));
65.177 + file = IpeUtils.escapeOddCharacters(CppUtils.normalizeDriveLetter(compilerSet,items[i].getPath()));
65.178 command = ""; // NOI18N
65.179 comment = null;
65.180 additionalDep = null;
65.181 @@ -614,10 +615,10 @@
65.182 } else {
65.183 command += compiler.getDescriptor().getOutputObjectFileFlags() + target + " "; // NOI18N
65.184 }
65.185 - command += IpeUtils.escapeOddCharacters(compilerSet.normalizeDriveLetter(items[i].getPath(true)));
65.186 + command += IpeUtils.escapeOddCharacters(CppUtils.normalizeDriveLetter(compilerSet,items[i].getPath(true)));
65.187 }
65.188 additionalDep = compilerConfiguration.getAdditionalDependencies().getValue();
65.189 - } else if (itemConfiguration.getTool() == Tool.CustomTool) {
65.190 + } else if (itemConfiguration.getTool() == ToolKind.CustomTool) {
65.191 CustomToolConfiguration customToolConfiguration = itemConfiguration.getCustomToolConfiguration();
65.192 if (customToolConfiguration.getModified()) {
65.193 target = customToolConfiguration.getOutputs().getValue(" + "); // NOI18N
65.194 @@ -734,7 +735,7 @@
65.195 bw.write("\t${RM} -r " + MakeConfiguration.BUILD_FOLDER + '/' + conf.getName() + "\n"); // UNIX path // NOI18N
65.196 bw.write("\t${RM} " + getOutput(conf) + "\n"); // NOI18N
65.197 if (conf.getCompilerSet().getCompilerSet() != null &&
65.198 - conf.getCompilerSet().getCompilerSet().isSunCompiler() &&
65.199 + conf.getCompilerSet().getCompilerSet().getCompilerFlavor().isSunStudioCompiler() &&
65.200 conf.hasCPPFiles(projectDescriptor)) {
65.201 bw.write("\t${CCADMIN} -clean" + "\n"); // NOI18N
65.202 }
65.203 @@ -749,7 +750,7 @@
65.204 if (itemConfiguration.getExcluded().getValue()) {
65.205 continue;
65.206 }
65.207 - if (itemConfiguration.getTool() == Tool.CustomTool && itemConfiguration.getCustomToolConfiguration().getModified()) {
65.208 + if (itemConfiguration.getTool() == ToolKind.CustomTool && itemConfiguration.getCustomToolConfiguration().getModified()) {
65.209 bw.write("\t${RM} " + itemConfiguration.getCustomToolConfiguration().getOutputs().getValue() + "\n"); // NOI18N
65.210 }
65.211 }
65.212 @@ -906,7 +907,7 @@
65.213 private void writePackagingScript(MakeConfiguration conf) {
65.214 String outputFileName = projectDescriptor.getBaseDir() + '/' + "nbproject" + '/' + "Package-" + conf.getName() + ".bash"; // UNIX path // NOI18N
65.215
65.216 - if (conf.getPackagingConfiguration().getFiles().getValue().size() == 0) {
65.217 + if (conf.getPackagingConfiguration().getFiles().getValue().isEmpty()) {
65.218 // Nothing to do
65.219 return;
65.220 }
66.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ConfigurationXMLCodec.java Mon Feb 01 12:23:06 2010 +0100
66.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ConfigurationXMLCodec.java Mon Feb 01 12:24:26 2010 +0100
66.3 @@ -47,7 +47,6 @@
66.4 import java.util.Stack;
66.5 import java.util.Vector;
66.6 import java.util.List;
66.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
66.8 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
66.9 import org.netbeans.modules.cnd.api.utils.IpeUtils;
66.10 import org.netbeans.modules.cnd.makeproject.api.MakeArtifact;
66.11 @@ -78,6 +77,7 @@
66.12 import org.netbeans.modules.cnd.makeproject.api.PackagerInfoElement;
66.13 import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationAuxObject;
66.14 import org.netbeans.modules.cnd.makeproject.api.configurations.QmakeConfiguration;
66.15 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
66.16 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
66.17 import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
66.18 import org.openide.filesystems.FileObject;
66.19 @@ -247,7 +247,7 @@
66.20 String excluded = atts.getValue(ItemXMLCodec.EXCLUDED_ATTR);
66.21 int tool = new Integer(atts.getValue(ItemXMLCodec.TOOL_ATTR)).intValue();
66.22 itemConfiguration.getExcluded().setValue(excluded.equals(TRUE_VALUE));
66.23 - itemConfiguration.setTool(tool);
66.24 + itemConfiguration.setTool(ToolKind.getTool(tool));
66.25 }
66.26 } else {
66.27 System.err.println("Not found item: " + path);
66.28 @@ -506,7 +506,7 @@
66.29 currentItemConfiguration.getExcluded().setValue(currentText.equals(TRUE_VALUE));
66.30 } else if (element.equals(ItemXMLCodec.ITEM_TOOL_ELEMENT) || element.equals(ItemXMLCodec.TOOL_ELEMENT)) {
66.31 int tool = new Integer(currentText).intValue();
66.32 - currentItemConfiguration.setTool(tool);
66.33 + currentItemConfiguration.setTool(ToolKind.getTool(tool));
66.34 } else if (element.equals(CONFORMANCE_LEVEL_ELEMENT)) { // FIXUP: <= 21
66.35 } else if (element.equals(COMPATIBILITY_MODE_ELEMENT)) { // FIXUP: <= 21
66.36 } else if (element.equals(LIBRARY_LEVEL_ELEMENT)) {
66.37 @@ -839,7 +839,7 @@
66.38 if (descriptorVersion < 46) {
66.39 host = HostInfoUtils.LOCALHOST;
66.40 } else {
66.41 - host = CompilerSetManager.getDefaultDevelopmentHost();
66.42 + host = CppUtils.getDefaultDevelopmentHost();
66.43 }
66.44 MakeConfiguration makeConfiguration = new MakeConfiguration(FileUtil.toFile(projectDirectory).getPath(), getString(value), confType, host);
66.45 return makeConfiguration;
67.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/CppUtils.java Mon Feb 01 12:23:06 2010 +0100
67.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/CppUtils.java Mon Feb 01 12:24:26 2010 +0100
67.3 @@ -42,6 +42,12 @@
67.4 package org.netbeans.modules.cnd.makeproject.configurations;
67.5
67.6 import java.util.ArrayList;
67.7 +import org.netbeans.modules.cnd.api.remote.ServerList;
67.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
67.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
67.10 +import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
67.11 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
67.12 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
67.13
67.14 /** Miscellaneous utility classes useful for the C/C++/Fortran module */
67.15 public class CppUtils {
67.16 @@ -124,4 +130,49 @@
67.17
67.18 return list;
67.19 }
67.20 +
67.21 + /**
67.22 + * Converts absolute Windows paths to paths without the ':'.
67.23 + * Example: C:/abc/def.c -> /cygdrive/c/def/c
67.24 + */
67.25 + public static String normalizeDriveLetter(CompilerSet cs, String path) {
67.26 + if (path.length() > 1 && path.charAt(1) == ':') { // NOI18N
67.27 + return cs.getCompilerFlavor().getToolchainDescriptor().getDriveLetterPrefix() + path.charAt(0) + path.substring(2); // NOI18N
67.28 + }
67.29 + return path;
67.30 + }
67.31 +
67.32 + public static String getQmakeSpec(CompilerSet cs, int platform) {
67.33 + CompilerFlavor flavor = cs.getCompilerFlavor();
67.34 + String qmakespec = flavor.getToolchainDescriptor().getQmakeSpec();
67.35 + if (qmakespec != null && 0 <= qmakespec.indexOf("${os}")) { // NOI18N
67.36 + String os = null;
67.37 + switch (platform) {
67.38 + case PlatformTypes.PLATFORM_LINUX:
67.39 + os = "linux"; // NOI18N
67.40 + break;
67.41 + case PlatformTypes.PLATFORM_MACOSX:
67.42 + os = "macx"; // NOI18N
67.43 + break;
67.44 + case PlatformTypes.PLATFORM_SOLARIS_INTEL:
67.45 + case PlatformTypes.PLATFORM_SOLARIS_SPARC:
67.46 + os = "solaris"; // NOI18N
67.47 + break;
67.48 + case PlatformTypes.PLATFORM_WINDOWS:
67.49 + os = "win32"; // NOI18N
67.50 + break;
67.51 + }
67.52 + if (os == null) {
67.53 + qmakespec = null;
67.54 + } else {
67.55 + qmakespec = qmakespec.replaceAll("\\$\\{os\\}", os); // NOI18N
67.56 + }
67.57 + }
67.58 + return qmakespec;
67.59 + }
67.60 +
67.61 + public static String getDefaultDevelopmentHost() {
67.62 + return ExecutionEnvironmentFactory.toUniqueID(ServerList.getDefaultRecord().getExecutionEnvironment());
67.63 + }
67.64 +
67.65 }
68.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/FolderXMLCodec.java Mon Feb 01 12:23:06 2010 +0100
68.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/FolderXMLCodec.java Mon Feb 01 12:24:26 2010 +0100
68.3 @@ -46,7 +46,7 @@
68.4 import org.netbeans.modules.cnd.api.xml.XMLDecoder;
68.5 import org.netbeans.modules.cnd.api.xml.XMLEncoder;
68.6 import org.netbeans.modules.cnd.api.xml.XMLEncoderStream;
68.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
68.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
68.9 import org.netbeans.modules.cnd.makeproject.api.configurations.FolderConfiguration;
68.10 import org.xml.sax.Attributes;
68.11
69.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ItemXMLCodec.java Mon Feb 01 12:23:06 2010 +0100
69.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ItemXMLCodec.java Mon Feb 01 12:24:26 2010 +0100
69.3 @@ -46,7 +46,7 @@
69.4 import org.netbeans.modules.cnd.api.xml.XMLDecoder;
69.5 import org.netbeans.modules.cnd.api.xml.XMLEncoder;
69.6 import org.netbeans.modules.cnd.api.xml.XMLEncoderStream;
69.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
69.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
69.9 import org.xml.sax.Attributes;
69.10
69.11 public class ItemXMLCodec extends XMLDecoder implements XMLEncoder {
69.12 @@ -69,11 +69,13 @@
69.13 }
69.14
69.15 // interface XMLDecoder
69.16 + @Override
69.17 public String tag() {
69.18 return item.getId();
69.19 }
69.20
69.21 // interface XMLDecoder
69.22 + @Override
69.23 public void start(Attributes atts) throws VersionException {
69.24 String what = "item"; // NOI18N
69.25 int maxVersion = 1;
69.26 @@ -81,18 +83,22 @@
69.27 }
69.28
69.29 // interface XMLDecoder
69.30 + @Override
69.31 public void end() {
69.32 }
69.33
69.34 // interface XMLDecoder
69.35 + @Override
69.36 public void startElement(String element, Attributes atts) {
69.37 }
69.38
69.39 // interface XMLDecoder
69.40 + @Override
69.41 public void endElement(String element, String currentText) {
69.42 }
69.43
69.44 // interface XMLEncoder
69.45 + @Override
69.46 public void encode(XMLEncoderStream xes) {
69.47 if (item.isDefaultConfiguration()) {
69.48 return;
69.49 @@ -101,19 +107,19 @@
69.50 xes.elementOpen(ITEM_ELEMENT, new AttrValuePair[]{
69.51 new AttrValuePair(PATH_ATTR, item.getItem().getPath()),
69.52 new AttrValuePair(EXCLUDED_ATTR, "" + item.getExcluded().getValue()),
69.53 - new AttrValuePair(TOOL_ATTR, "" + item.getTool()),
69.54 + new AttrValuePair(TOOL_ATTR, "" + item.getTool().ordinal()),
69.55 });
69.56 // if (item.getExcluded().getModified()) {
69.57 // xes.element(ITEM_EXCLUDED_ELEMENT, "" + item.getExcluded().getValue()); // NOI18N
69.58 // }
69.59 // xes.element(ITEM_TOOL_ELEMENT, "" + item.getTool()); // NOI18N
69.60 - if (item.getTool() == Tool.CCompiler) {
69.61 + if (item.getTool() == ToolKind.CCompiler) {
69.62 CommonConfigurationXMLCodec.writeCCompilerConfiguration(xes, item.getCCompilerConfiguration());
69.63 - } else if (item.getTool() == Tool.CCCompiler) {
69.64 + } else if (item.getTool() == ToolKind.CCCompiler) {
69.65 CommonConfigurationXMLCodec.writeCCCompilerConfiguration(xes, item.getCCCompilerConfiguration());
69.66 - } else if (item.getTool() == Tool.FortranCompiler) {
69.67 + } else if (item.getTool() == ToolKind.FortranCompiler) {
69.68 CommonConfigurationXMLCodec.writeFortranCompilerConfiguration(xes, item.getFortranCompilerConfiguration());
69.69 - } else if (item.getTool() == Tool.CustomTool) {
69.70 + } else if (item.getTool() == ToolKind.CustomTool) {
69.71 CommonConfigurationXMLCodec.writeCustomToolConfiguration(xes, item.getCustomToolConfiguration());
69.72 }
69.73 xes.elementClose(ITEM_ELEMENT);
70.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/QmakeProjectWriter.java Mon Feb 01 12:23:06 2010 +0100
70.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/QmakeProjectWriter.java Mon Feb 01 12:24:26 2010 +0100
70.3 @@ -46,7 +46,7 @@
70.4 import java.util.ArrayList;
70.5 import java.util.List;
70.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
70.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
70.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
70.9 import org.netbeans.modules.cnd.api.utils.IpeUtils;
70.10 import org.netbeans.modules.cnd.makeproject.api.configurations.CCCCompilerConfiguration.OptionToString;
70.11 import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
70.12 @@ -186,9 +186,9 @@
70.13 expandAndQuote(configuration.getQmakeConfiguration().getUiDir().getValue()));
70.14
70.15 write(bw, Variable.QMAKE_CC, Operation.SET,
70.16 - ConfigurationMakefileWriter.getCompilerName(configuration, Tool.CCompiler));
70.17 + ConfigurationMakefileWriter.getCompilerName(configuration, ToolKind.CCompiler));
70.18 write(bw, Variable.QMAKE_CXX, Operation.SET,
70.19 - ConfigurationMakefileWriter.getCompilerName(configuration, Tool.CCCompiler));
70.20 + ConfigurationMakefileWriter.getCompilerName(configuration, ToolKind.CCCompiler));
70.21
70.22 CompilerSet compilerSet = configuration.getCompilerSet().getCompilerSet();
70.23 OptionToString defineVisitor = new OptionToString(compilerSet, null);
70.24 @@ -282,7 +282,8 @@
70.25 if (0 < buf.length()) {
70.26 buf.append(' '); // NOI18N
70.27 }
70.28 - OptionToString dynamicSearchVisitor = new OptionToString(compilerSet, compilerSet.getDynamicLibrarySearchOption());
70.29 + OptionToString dynamicSearchVisitor = new OptionToString(compilerSet,
70.30 + compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getDynamicLibrarySearchFlag());
70.31 buf.append(configuration.getLinkerConfiguration().getDynamicSearch().toString(dynamicSearchVisitor));
70.32 }
70.33 return buf.toString();
70.34 @@ -300,6 +301,7 @@
70.35 this.compilerSet = compilerSet;
70.36 }
70.37
70.38 + @Override
70.39 public String toString(LibraryItem item) {
70.40 switch (item.getType()) {
70.41 case LibraryItem.PROJECT_ITEM:
70.42 @@ -317,7 +319,7 @@
70.43 private String libFileToOptionsString(String path) {
70.44 StringBuilder buf = new StringBuilder();
70.45 if (compilerSet != null && isDynamicLib(path)) {
70.46 - String searchOption = compilerSet.getDynamicLibrarySearchOption();
70.47 + String searchOption = compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getDynamicLibrarySearchFlag();
70.48 if (searchOption.length() == 0) {
70.49 // According to code in PlatformWindows and PlatformMacOSX,
70.50 // on Windows and MacOS the "-L" option is used
70.51 @@ -325,7 +327,7 @@
70.52 // Let's be consistent with that behavior. Detect this
70.53 // special case by empty dynamic_library_search
70.54 // and use the library_search option instead.
70.55 - searchOption = compilerSet.getLibrarySearchOption();
70.56 + searchOption = compilerSet.getCompilerFlavor().getToolchainDescriptor().getLinker().getLibrarySearchFlag();
70.57 }
70.58
70.59 buf.append(searchOption);
70.60 @@ -350,10 +352,11 @@
70.61 this.compilerSet = compilerSet;
70.62 }
70.63
70.64 + @Override
70.65 public String toString(String item) {
70.66 if (0 < item.length()) {
70.67 if (compilerSet != null) {
70.68 - item = compilerSet.normalizeDriveLetter(item);
70.69 + item = CppUtils.normalizeDriveLetter(compilerSet, item);
70.70 }
70.71 return IpeUtils.quoteIfNecessary(item);
70.72 } else {
71.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/MakeLogicalViewProvider.java Mon Feb 01 12:23:06 2010 +0100
71.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/MakeLogicalViewProvider.java Mon Feb 01 12:24:26 2010 +0100
71.3 @@ -73,7 +73,7 @@
71.4 import org.netbeans.api.project.ProjectInformation;
71.5 import org.netbeans.api.project.ProjectUtils;
71.6 import org.netbeans.api.queries.VisibilityQuery;
71.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
71.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
71.9 import org.netbeans.modules.cnd.api.project.NativeProject;
71.10 import org.netbeans.modules.cnd.api.utils.CndFileVisibilityQuery;
71.11 import org.netbeans.modules.cnd.api.utils.IpeUtils;
71.12 @@ -1819,12 +1819,12 @@
71.13 //Image original = Utilities.loadImage("org/openide/loaders/instanceObject.gif"); // NOI18N
71.14 //Image original = Utilities.loadImage("org/netbeans/modules/cnd/loaders/CCSrcIcon.gif"); // NOI18N
71.15 Image original;
71.16 - int tool = item.getDefaultTool();
71.17 - if (tool == Tool.CCompiler) {
71.18 + ToolKind tool = item.getDefaultTool();
71.19 + if (tool == ToolKind.CCompiler) {
71.20 original = ImageUtilities.loadImage("org/netbeans/modules/cnd/loaders/CSrcIcon.gif"); // NOI18N
71.21 - } else if (tool == Tool.CCCompiler) {
71.22 + } else if (tool == ToolKind.CCCompiler) {
71.23 original = ImageUtilities.loadImage("org/netbeans/modules/cnd/loaders/CCSrcIcon.gif"); // NOI18N
71.24 - } else if (tool == Tool.FortranCompiler) {
71.25 + } else if (tool == ToolKind.FortranCompiler) {
71.26 original = ImageUtilities.loadImage("org/netbeans/modules/cnd/loaders/FortranSrcIcon.gif"); // NOI18N
71.27 } else {
71.28 original = ImageUtilities.loadImage("org/netbeans/modules/cnd/loaders/unknown.gif"); // NOI18N
72.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/RemoteSyncActions.java Mon Feb 01 12:23:06 2010 +0100
72.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/RemoteSyncActions.java Mon Feb 01 12:24:26 2010 +0100
72.3 @@ -56,7 +56,6 @@
72.4 import org.netbeans.api.progress.ProgressHandle;
72.5 import org.netbeans.api.progress.ProgressHandleFactory;
72.6 import org.netbeans.api.project.Project;
72.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
72.8 import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
72.9 import org.netbeans.modules.cnd.api.remote.PathMap;
72.10 import org.netbeans.modules.cnd.api.remote.RemoteProject;
72.11 @@ -93,6 +92,7 @@
72.12
72.13 /** A task that activatedNodesCache */
72.14 private static final RequestProcessor.Task clearCacheTask = RequestProcessor.getDefault().create(new Runnable() {
72.15 + @Override
72.16 public void run() {
72.17 activatedNodesCache.set(null);
72.18 }
72.19 @@ -208,6 +208,7 @@
72.20 }
72.21 }
72.22
72.23 + @Override
72.24 public boolean cancel() {
72.25 cancelled = true;
72.26 Thread thread = workingThread;
72.27 @@ -264,6 +265,7 @@
72.28 protected Worker createWorker(final Project project, final ExecutionEnvironment execEnv) {
72.29 return new Worker() {
72.30 private final PathMap pathMap = HostInfoProvider.getMapper(execEnv);
72.31 + @Override
72.32 public void process(File file, Writer err) throws PathMapperException, InterruptedException, ExecutionException, IOException {
72.33 String remotePath = pathMap.getRemotePath(file.getAbsolutePath(), false);
72.34 if (remotePath == null) {
72.35 @@ -275,6 +277,7 @@
72.36 throw new IOException(NbBundle.getMessage(RemoteSyncActions.class, "ERR_RC", Integer.valueOf(rc)));
72.37 }
72.38 }
72.39 + @Override
72.40 public void close() {}
72.41 };
72.42 }
72.43 @@ -399,7 +402,7 @@
72.44 }
72.45
72.46 private static ExecutionEnvironment getEnv(Project project) {
72.47 - ExecutionEnvironment developmentHost = CompilerSetManager.getDefaultExecutionEnvironment();
72.48 + ExecutionEnvironment developmentHost = ServerList.getDefaultRecord().getExecutionEnvironment();
72.49 if (project != null) {
72.50 RemoteProject info = project.getLookup().lookup(RemoteProject.class);
72.51 if (info != null) {
73.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/customizer/MakeCustomizer.java Mon Feb 01 12:23:06 2010 +0100
73.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/customizer/MakeCustomizer.java Mon Feb 01 12:24:26 2010 +0100
73.3 @@ -79,9 +79,7 @@
73.4 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
73.5 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.CustomizerNode;
73.6 import org.netbeans.modules.cnd.makeproject.api.configurations.ui.CustomizerRootNodeProvider;
73.7 -import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
73.8 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
73.9 -import org.netbeans.modules.cnd.toolchain.api.Tool;
73.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
73.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
73.12 import org.netbeans.modules.cnd.makeproject.api.configurations.CCompilerConfiguration;
73.13 import org.netbeans.modules.cnd.makeproject.api.configurations.Folder;
73.14 @@ -91,6 +89,7 @@
73.15 import org.netbeans.modules.cnd.makeproject.configurations.ui.DebuggerChooserNodeProp;
73.16 import org.netbeans.modules.cnd.makeproject.ui.utils.ConfSelectorPanel;
73.17 import org.netbeans.modules.cnd.makeproject.ui.utils.ListEditorPanel;
73.18 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
73.19 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
73.20 import org.openide.DialogDescriptor;
73.21 import org.openide.DialogDisplayer;
73.22 @@ -393,6 +392,7 @@
73.23 // End of variables declaration//GEN-END:variables
73.24
73.25 // HelpCtx.Provider implementation -----------------------------------------
73.26 + @Override
73.27 public HelpCtx getHelpCtx() {
73.28 if (currentConfigurationNode != null) {
73.29 return HelpCtx.findHelp(currentConfigurationNode);
73.30 @@ -453,6 +453,7 @@
73.31 }
73.32 }
73.33
73.34 + @Override
73.35 public ExplorerManager getExplorerManager() {
73.36 return manager;
73.37 }
73.38 @@ -507,6 +508,7 @@
73.39 */
73.40 private class ManagerChangeListener implements PropertyChangeListener {
73.41
73.42 + @Override
73.43 public void propertyChange(PropertyChangeEvent evt) {
73.44 if (evt.getSource() != manager) {
73.45 return;
73.46 @@ -739,7 +741,7 @@
73.47 // advancedNodes.add(node);
73.48 // }
73.49 // }
73.50 - if (descriptions.size() == 0) {
73.51 + if (descriptions.isEmpty()) {
73.52 return null;
73.53 }
73.54 return new CustomizerNode(
73.55 @@ -755,7 +757,7 @@
73.56 private Node createRootNodeItem(Project project, Item item) {
73.57 CustomizerNode descriptions[];
73.58
73.59 - int tool = -1;
73.60 + ToolKind tool = ToolKind.UnknownTool;
73.61 int compilerSet = -1;
73.62 boolean isCompileConfiguration = ((MakeConfiguration) selectedConfigurations[0]).isCompileConfiguration();
73.63
73.64 @@ -766,39 +768,39 @@
73.65 if (itemConfiguration == null) {
73.66 continue;
73.67 }
73.68 - int tool2 = itemConfiguration.getTool();
73.69 - if (tool == -1 && compilerSet == -1) {
73.70 + ToolKind tool2 = itemConfiguration.getTool();
73.71 + if (tool == ToolKind.UnknownTool && compilerSet == -1) {
73.72 tool = tool2;
73.73 compilerSet = compilerSet2;
73.74 }
73.75 if (tool != tool2 || compilerSet != compilerSet2) {
73.76 - tool = -1;
73.77 + tool = ToolKind.UnknownTool;
73.78 break;
73.79 }
73.80
73.81 if ((isCompileConfiguration && !makeConfiguration.isCompileConfiguration()) || (!isCompileConfiguration && makeConfiguration.isCompileConfiguration())) {
73.82 - tool = -1;
73.83 + tool = ToolKind.UnknownTool;
73.84 break;
73.85 }
73.86 }
73.87
73.88 int count = 1;
73.89 - if (tool >= 0) {
73.90 + if (tool != ToolKind.UnknownTool) {
73.91 count++;
73.92 }
73.93 descriptions = new CustomizerNode[count];
73.94 int index = 0;
73.95 descriptions[index++] = createGeneralItemDescription(project, item);
73.96 - if (tool >= 0) {
73.97 - if (tool == Tool.CCompiler) {
73.98 + if (tool != ToolKind.UnknownTool) {
73.99 + if (tool == ToolKind.CCompiler) {
73.100 descriptions[index++] = createCCompilerDescription(project, compilerSet, item, folder, isCompileConfiguration);
73.101 - } else if (tool == Tool.CCCompiler) {
73.102 + } else if (tool == ToolKind.CCCompiler) {
73.103 descriptions[index++] = createCCCompilerDescription(project, compilerSet, item, folder, isCompileConfiguration);
73.104 - } else if (tool == Tool.FortranCompiler) {
73.105 + } else if (tool == ToolKind.FortranCompiler) {
73.106 descriptions[index++] = createFortranCompilerDescription(project, compilerSet, item, isCompileConfiguration);
73.107 - } else if (tool == Tool.Assembler) {
73.108 + } else if (tool == ToolKind.Assembler) {
73.109 descriptions[index++] = createAssemblerDescription(project, compilerSet, item, isCompileConfiguration);
73.110 - } else if (tool == Tool.CustomTool) {
73.111 + } else if (tool == ToolKind.CustomTool) {
73.112 descriptions[index++] = createCustomBuildItemDescription(project, item);
73.113 } else {
73.114 descriptions[index++] = createCustomBuildItemDescription(project, item); // FIXUP
73.115 @@ -1200,9 +1202,9 @@
73.116 private CustomizerNode createCCompilerDescription(Project project, int compilerSetIdx,
73.117 Item item, Folder folder, boolean isCompilerConfiguration) {
73.118 ExecutionEnvironment execEnv = getSelectedHost();
73.119 - CompilerSet csm = CompilerSetManager.getDefault(execEnv).getCompilerSet(compilerSetIdx);
73.120 - String compilerName = csm.getTool(BasicCompiler.CCompiler).getName();
73.121 - String compilerDisplayName = csm.getTool(BasicCompiler.CCompiler).getDisplayName();
73.122 + CompilerSet csm = CompilerSetManager.get(execEnv).getCompilerSet(compilerSetIdx);
73.123 + String compilerName = csm.getTool(ToolKind.CCompiler).getName();
73.124 + String compilerDisplayName = csm.getTool(ToolKind.CCompiler).getDisplayName();
73.125 CustomizerNode cCompilerCustomizerNode = new CCompilerCustomizerNode(
73.126 compilerName,
73.127 compilerDisplayName,
73.128 @@ -1270,8 +1272,8 @@
73.129 // CC Compiler Node
73.130 private CustomizerNode createCCCompilerDescription(Project project, int compilerSetIdx, Item item, Folder folder, boolean isCompilerConfiguration) {
73.131 ExecutionEnvironment execEnv = getSelectedHost();
73.132 - String compilerName = CompilerSetManager.getDefault(execEnv).getCompilerSet(compilerSetIdx).getTool(BasicCompiler.CCCompiler).getName();
73.133 - String compilerDisplayName = CompilerSetManager.getDefault(execEnv).getCompilerSet(compilerSetIdx).getTool(BasicCompiler.CCCompiler).getDisplayName();
73.134 + String compilerName = CompilerSetManager.get(execEnv).getCompilerSet(compilerSetIdx).getTool(ToolKind.CCCompiler).getName();
73.135 + String compilerDisplayName = CompilerSetManager.get(execEnv).getCompilerSet(compilerSetIdx).getTool(ToolKind.CCCompiler).getDisplayName();
73.136 CustomizerNode ccCompilerCustomizerNode = new CCCompilerCustomizerNode(
73.137 compilerName,
73.138 compilerDisplayName,
73.139 @@ -1316,8 +1318,8 @@
73.140 // Fortran Compiler Node
73.141 private CustomizerNode createFortranCompilerDescription(Project project, int compilerSetIdx, Item item, boolean isCompilerConfiguration) {
73.142 ExecutionEnvironment execEnv = getSelectedHost();
73.143 - String compilerName = CompilerSetManager.getDefault(execEnv).getCompilerSet(compilerSetIdx).getTool(BasicCompiler.FortranCompiler).getName();
73.144 - String compilerDisplayName = CompilerSetManager.getDefault(execEnv).getCompilerSet(compilerSetIdx).getTool(BasicCompiler.FortranCompiler).getDisplayName();
73.145 + String compilerName = CompilerSetManager.get(execEnv).getCompilerSet(compilerSetIdx).getTool(ToolKind.FortranCompiler).getName();
73.146 + String compilerDisplayName = CompilerSetManager.get(execEnv).getCompilerSet(compilerSetIdx).getTool(ToolKind.FortranCompiler).getDisplayName();
73.147 CustomizerNode fortranCompilerCustomizerNode = new FortranCompilerCustomizerNode(
73.148 compilerName,
73.149 compilerDisplayName,
73.150 @@ -1354,8 +1356,8 @@
73.151 // Assembler Compiler Node
73.152 private CustomizerNode createAssemblerDescription(Project project, int compilerSetIdx, Item item, boolean isCompilerConfiguration) {
73.153 ExecutionEnvironment execEnv = getSelectedHost();
73.154 - String compilerName = CompilerSetManager.getDefault(execEnv).getCompilerSet(compilerSetIdx).getTool(BasicCompiler.Assembler).getName();
73.155 - String compilerDisplayName = CompilerSetManager.getDefault(execEnv).getCompilerSet(compilerSetIdx).getTool(BasicCompiler.Assembler).getDisplayName();
73.156 + String compilerName = CompilerSetManager.get(execEnv).getCompilerSet(compilerSetIdx).getTool(ToolKind.Assembler).getName();
73.157 + String compilerDisplayName = CompilerSetManager.get(execEnv).getCompilerSet(compilerSetIdx).getTool(ToolKind.Assembler).getDisplayName();
73.158 CustomizerNode assemblerCustomizerNode = new AssemblerCustomizerNode(
73.159 compilerName,
73.160 compilerDisplayName,
73.161 @@ -1475,6 +1477,7 @@
73.162 setKeys(Collections.EMPTY_LIST);
73.163 }
73.164
73.165 + @Override
73.166 protected Node[] createNodes(CustomizerNode key) {
73.167 return new Node[]{new PropertyNode(key)};
73.168 }
73.169 @@ -1624,7 +1627,7 @@
73.170
73.171 @Override
73.172 public synchronized AssemblerConfiguration getAssemblerConfiguration() {
73.173 - if (getTool() == Tool.Assembler) {
73.174 + if (getTool() == ToolKind.Assembler) {
73.175 return super.getAssemblerConfiguration();
73.176 } else {
73.177 if (assemblerConfiguration == null) {
73.178 @@ -1637,7 +1640,7 @@
73.179
73.180 @Override
73.181 public synchronized CCCompilerConfiguration getCCCompilerConfiguration() {
73.182 - if (getTool() == Tool.CCCompiler) {
73.183 + if (getTool() == ToolKind.CCCompiler) {
73.184 return super.getCCCompilerConfiguration();
73.185 } else {
73.186 if (cCCompilerConfiguration == null) {
73.187 @@ -1654,7 +1657,7 @@
73.188
73.189 @Override
73.190 public CCompilerConfiguration getCCompilerConfiguration() {
73.191 - if (getTool() == Tool.CCompiler) {
73.192 + if (getTool() == ToolKind.CCompiler) {
73.193 return super.getCCompilerConfiguration();
73.194 } else {
73.195 FolderConfiguration folderConfiguration = getItem().getFolder().getFolderConfiguration(getConfiguration());
73.196 @@ -1669,7 +1672,7 @@
73.197
73.198 @Override
73.199 public synchronized FortranCompilerConfiguration getFortranCompilerConfiguration() {
73.200 - if (getTool() == Tool.FortranCompiler) {
73.201 + if (getTool() == ToolKind.FortranCompiler) {
73.202 return super.getFortranCompilerConfiguration();
73.203 } else {
73.204 if (fortranCompilerConfiguration == null) {
73.205 @@ -1681,7 +1684,7 @@
73.206
73.207 @Override
73.208 public synchronized CustomToolConfiguration getCustomToolConfiguration() {
73.209 - if (getTool() == Tool.CustomTool) {
73.210 + if (getTool() == ToolKind.CustomTool) {
73.211 return super.getCustomToolConfiguration();
73.212 } else {
73.213 if (customToolConfiguration == null) {
74.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/options/ParserSettingsPanel.form Mon Feb 01 12:23:06 2010 +0100
74.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/options/ParserSettingsPanel.form Mon Feb 01 12:24:26 2010 +0100
74.3 @@ -30,7 +30,7 @@
74.4 <Group type="103" groupAlignment="0" attributes="0">
74.5 <Group type="102" alignment="0" attributes="0">
74.6 <Component id="collectionPanel" min="-2" max="-2" attributes="0"/>
74.7 - <EmptySpace pref="272" max="32767" attributes="0"/>
74.8 + <EmptySpace pref="277" max="32767" attributes="0"/>
74.9 </Group>
74.10 <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
74.11 <Group type="102" attributes="0">
74.12 @@ -54,7 +54,7 @@
74.13 <Group type="102" attributes="0">
74.14 <Component id="compilerCollectionLabel" min="-2" max="-2" attributes="0"/>
74.15 <EmptySpace max="-2" attributes="0"/>
74.16 - <Component id="compilerCollectionComboBox" pref="313" max="32767" attributes="0"/>
74.17 + <Component id="compilerCollectionComboBox" pref="336" max="32767" attributes="0"/>
74.18 <EmptySpace max="-2" attributes="0"/>
74.19 </Group>
74.20 </Group>
75.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/options/ParserSettingsPanel.java Mon Feb 01 12:23:06 2010 +0100
75.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/options/ParserSettingsPanel.java Mon Feb 01 12:24:26 2010 +0100
75.3 @@ -43,7 +43,7 @@
75.4 import java.awt.Component;
75.5 import java.awt.event.ActionEvent;
75.6 import javax.swing.JList;
75.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
75.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
75.9 import org.netbeans.modules.cnd.makeproject.api.compilers.CCCCompiler;
75.10 import java.awt.event.ActionListener;
75.11 import java.util.ArrayList;
75.12 @@ -67,6 +67,7 @@
75.13 import org.netbeans.modules.cnd.api.remote.ServerList;
75.14 import org.netbeans.modules.cnd.api.remote.ServerRecord;
75.15 import org.netbeans.modules.cnd.makeproject.NativeProjectProvider;
75.16 +import org.netbeans.modules.cnd.toolchain.api.Tool;
75.17 import org.netbeans.modules.cnd.toolchain.ui.api.IsChangedListener;
75.18 import org.netbeans.modules.cnd.toolchain.ui.api.ToolsCacheManager;
75.19 import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelSupport;
75.20 @@ -225,11 +226,11 @@
75.21 }
75.22 // Show only the selected C and C++ compiler from the compiler collection
75.23 ArrayList<Tool> toolSet = new ArrayList<Tool>();
75.24 - Tool cCompiler = compilerCollection.getTool(Tool.CCompiler);
75.25 + Tool cCompiler = compilerCollection.getTool(ToolKind.CCompiler);
75.26 if (cCompiler != null && cCompiler.getPath().length() > 0) {
75.27 toolSet.add(cCompiler);
75.28 }
75.29 - Tool cppCompiler = compilerCollection.getTool(Tool.CCCompiler);
75.30 + Tool cppCompiler = compilerCollection.getTool(ToolKind.CCCompiler);
75.31 if (cppCompiler != null && cppCompiler.getPath().length() > 0) {
75.32 toolSet.add(cppCompiler);
75.33 }
76.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/wizards/ConfigureUtils.java Mon Feb 01 12:23:06 2010 +0100
76.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/wizards/ConfigureUtils.java Mon Feb 01 12:24:26 2010 +0100
76.3 @@ -41,12 +41,14 @@
76.4
76.5 import java.io.File;
76.6 import org.netbeans.modules.cnd.actions.AbstractExecutorRunAction;
76.7 +import org.netbeans.modules.cnd.api.remote.ServerList;
76.8 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
76.9 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
76.10 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
76.11 +import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
76.12 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
76.13 +import org.netbeans.modules.cnd.execution.ShellExecSupport;
76.14 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
76.15 -import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
76.16 import org.netbeans.modules.cnd.toolchain.api.Tool;
76.17 -import org.netbeans.modules.cnd.execution.ShellExecSupport;
76.18 import org.openide.filesystems.FileObject;
76.19 import org.openide.filesystems.FileUtil;
76.20 import org.openide.loaders.DataObject;
76.21 @@ -200,16 +202,16 @@
76.22 if (buf.length() > 0) {
76.23 buf.append(' '); // NOI18N
76.24 }
76.25 - buf.append(key + flag);
76.26 + buf.append(key).append(flag);
76.27 }
76.28 }
76.29
76.30 private static int getPlatform(){
76.31 - return CompilerSetManager.getDefault(CompilerSetManager.getDefaultExecutionEnvironment()).getPlatform();
76.32 + return CompilerSetManager.get(ServerList.getDefaultRecord().getExecutionEnvironment()).getPlatform();
76.33 }
76.34
76.35 private static boolean isSunStodio(){
76.36 - CompilerSet def = CompilerSetManager.getDefault(CompilerSetManager.getDefaultExecutionEnvironment()).getDefaultCompilerSet();
76.37 + CompilerSet def = CompilerSetManager.get(ServerList.getDefaultRecord().getExecutionEnvironment()).getDefaultCompilerSet();
76.38 if (def != null) {
76.39 CompilerFlavor flavor = def.getCompilerFlavor();
76.40 if (flavor.isSunStudioCompiler()) {
76.41 @@ -220,8 +222,8 @@
76.42 }
76.43
76.44 private static String getDefaultC(){
76.45 - CompilerSet def = CompilerSetManager.getDefault(CompilerSetManager.getDefaultExecutionEnvironment()).getDefaultCompilerSet();
76.46 - String cCompiler = getToolPath(def, Tool.CCompiler);
76.47 + CompilerSet def = CompilerSetManager.get(ServerList.getDefaultRecord().getExecutionEnvironment()).getDefaultCompilerSet();
76.48 + String cCompiler = getToolPath(def, ToolKind.CCompiler);
76.49 if (cCompiler != null) {
76.50 return cCompiler;
76.51 }
76.52 @@ -236,8 +238,8 @@
76.53 }
76.54
76.55 private static String getDefaultCpp(){
76.56 - CompilerSet def = CompilerSetManager.getDefault(CompilerSetManager.getDefaultExecutionEnvironment()).getDefaultCompilerSet();
76.57 - String cppCompiler = getToolPath(def, Tool.CCCompiler);
76.58 + CompilerSet def = CompilerSetManager.get(ServerList.getDefaultRecord().getExecutionEnvironment()).getDefaultCompilerSet();
76.59 + String cppCompiler = getToolPath(def, ToolKind.CCCompiler);
76.60 if (cppCompiler != null) {
76.61 return cppCompiler;
76.62 }
76.63 @@ -251,7 +253,7 @@
76.64 return cppCompiler;
76.65 }
76.66
76.67 - private static String getToolPath(CompilerSet compilerSet, int tool){
76.68 + private static String getToolPath(CompilerSet compilerSet, ToolKind tool){
76.69 if (compilerSet == null) {
76.70 return null;
76.71 }
76.72 @@ -270,7 +272,7 @@
76.73 }
76.74
76.75 private static String getCompilerFlags(){
76.76 - CompilerSet def = CompilerSetManager.getDefault(CompilerSetManager.getDefaultExecutionEnvironment()).getDefaultCompilerSet();
76.77 + CompilerSet def = CompilerSetManager.get(ServerList.getDefaultRecord().getExecutionEnvironment()).getDefaultCompilerSet();
76.78 if (def != null) {
76.79 CompilerFlavor flavor = def.getCompilerFlavor();
76.80 if (flavor.isSunStudioCompiler()) {
77.1 --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/wizards/MakeSampleProjectGenerator.java Mon Feb 01 12:23:06 2010 +0100
77.2 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/wizards/MakeSampleProjectGenerator.java Mon Feb 01 12:24:26 2010 +0100
77.3 @@ -61,6 +61,7 @@
77.4 import java.util.logging.Logger;
77.5 import java.util.zip.ZipEntry;
77.6 import java.util.zip.ZipInputStream;
77.7 +import org.netbeans.modules.cnd.api.remote.ServerList;
77.8 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
77.9 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
77.10 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
77.11 @@ -140,8 +141,8 @@
77.12 //changeXmlFileByTagName(doc, "folderPath", workingDir, "X-PROJECTDIR-X"); // NOI18N
77.13 changeXmlFileByTagName(doc, "defaultConf", systemOs, "X-DEFAULTCONF-X"); // NOI18N
77.14
77.15 - ExecutionEnvironment env = CompilerSetManager.getDefaultExecutionEnvironment();
77.16 - CompilerSetManager compilerSetManager = CompilerSetManager.getDefault(env);
77.17 + ExecutionEnvironment env = ServerList.getDefaultRecord().getExecutionEnvironment();
77.18 + CompilerSetManager compilerSetManager = CompilerSetManager.get(env);
77.19 int platform = compilerSetManager.getPlatform();
77.20 CompilerSet compilerSet = compilerSetManager.getDefaultCompilerSet();
77.21 String variant = null;
77.22 @@ -190,7 +191,7 @@
77.23 if (!logger.isLoggable(Level.INFO)) {
77.24 return;
77.25 }
77.26 - CompilerSetManager compilerSetManager = CompilerSetManager.getDefault(env);
77.27 + CompilerSetManager compilerSetManager = CompilerSetManager.get(env);
77.28 CompilerSet compilerSet = compilerSetManager.getDefaultCompilerSet();
77.29 LogRecord logRecord = new LogRecord(Level.INFO, ConfigurationDescriptorProvider.USG_PROJECT_CREATE_CND);
77.30 logRecord.setLoggerName(logger.getName());
78.1 --- a/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCCCompilerTest.java Mon Feb 01 12:23:06 2010 +0100
78.2 +++ b/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/api/compilers/GNUCCCCompilerTest.java Mon Feb 01 12:24:26 2010 +0100
78.3 @@ -49,10 +49,12 @@
78.4 import org.junit.Before;
78.5 import org.junit.BeforeClass;
78.6 import org.junit.Test;
78.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
78.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
78.9 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
78.10 -import org.netbeans.modules.cnd.toolchain.api.Tool;
78.11 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
78.12 import org.netbeans.modules.cnd.makeproject.api.compilers.CCCCompiler.Pair;
78.13 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
78.14 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
78.15 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
78.16 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
78.17
78.18 @@ -123,8 +125,8 @@
78.19 if (TRACE) {
78.20 System.out.println("Parse Compiler Output of GCC on Solaris");
78.21 }
78.22 - CompilerFlavor flavor = CompilerFlavor.toFlavor("GNU", PlatformTypes.PLATFORM_SOLARIS_INTEL);
78.23 - MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCCompiler, "GNU", "GNU", "/usr/sfw/bin");
78.24 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("GNU", PlatformTypes.PLATFORM_SOLARIS_INTEL);
78.25 + MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCCompiler, "GNU", "GNU", "/usr/sfw/bin");
78.26 instance.parseCompilerOutput(buf, instance.pair);
78.27 List<String> out = instance.pair.systemIncludeDirectoriesList;
78.28 Collections.<String>sort(out);
78.29 @@ -179,8 +181,8 @@
78.30 if (TRACE) {
78.31 System.out.println("Parse Compiler Output of GNU on Mac");
78.32 }
78.33 - CompilerFlavor flavor = CompilerFlavor.toFlavor("GNU", PlatformTypes.PLATFORM_MACOSX);
78.34 - MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCCompiler, "GNU", "GNU", "/usr/sfw/bin");
78.35 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("GNU", PlatformTypes.PLATFORM_MACOSX);
78.36 + MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCCompiler, "GNU", "GNU", "/usr/sfw/bin");
78.37 instance.parseCompilerOutput(buf, instance.pair);
78.38 List<String> out = instance.pair.systemIncludeDirectoriesList;
78.39 Collections.<String>sort(out);
78.40 @@ -242,8 +244,8 @@
78.41 if (TRACE) {
78.42 System.out.println("Parse Compiler Output of MinGW on Windows");
78.43 }
78.44 - CompilerFlavor flavor = CompilerFlavor.toFlavor("MinGW", PlatformTypes.PLATFORM_WINDOWS);
78.45 - MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCCompiler, "MinGW", "MinGW", "C:\\MinGW\\bin");
78.46 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("MinGW", PlatformTypes.PLATFORM_WINDOWS);
78.47 + MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCCompiler, "MinGW", "MinGW", "C:\\MinGW\\bin");
78.48 instance.parseCompilerOutput(buf, instance.pair);
78.49 List<String> out = instance.pair.systemIncludeDirectoriesList;
78.50 Collections.<String>sort(out);
78.51 @@ -312,8 +314,8 @@
78.52 if (TRACE) {
78.53 System.out.println("Parse Compiler Output of TDM MinGW on Windows");
78.54 }
78.55 - CompilerFlavor flavor = CompilerFlavor.toFlavor("MinGW_TDM", PlatformTypes.PLATFORM_WINDOWS);
78.56 - MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCCompiler, "MinGW_TDM", "MinGW_TDM", "D:\\tec\\mingw\\bin");
78.57 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("MinGW_TDM", PlatformTypes.PLATFORM_WINDOWS);
78.58 + MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCCompiler, "MinGW_TDM", "MinGW_TDM", "D:\\tec\\mingw\\bin");
78.59 instance.parseCompilerOutput(buf, instance.pair);
78.60 List<String> out = instance.pair.systemIncludeDirectoriesList;
78.61 Collections.<String>sort(out);
78.62 @@ -374,8 +376,8 @@
78.63 if (TRACE) {
78.64 System.out.println("Parse Compiler Output of Cygwin on Windows");
78.65 }
78.66 - CompilerFlavor flavor = CompilerFlavor.toFlavor("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
78.67 - MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCCompiler, "Cygwin", "Cygwin", "C:\\cygwin\\bin");
78.68 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
78.69 + MyGNUCCCompiler instance = new MyGNUCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCCompiler, "Cygwin", "Cygwin", "C:\\cygwin\\bin");
78.70 instance.parseCompilerOutput(buf, instance.pair);
78.71 List<String> out = instance.pair.systemIncludeDirectoriesList;
78.72 Collections.<String>sort(out);
78.73 @@ -404,7 +406,7 @@
78.74
78.75 private static final class MyGNUCCCompiler extends GNUCCCompiler {
78.76 Pair pair = new Pair();
78.77 - protected MyGNUCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
78.78 + protected MyGNUCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
78.79 super(env, flavor, kind, name, displayName, path);
78.80 }
78.81 @Override
79.1 --- a/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCCCompilerTest.java Mon Feb 01 12:23:06 2010 +0100
79.2 +++ b/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/api/compilers/SunCCCCompilerTest.java Mon Feb 01 12:24:26 2010 +0100
79.3 @@ -48,9 +48,11 @@
79.4 import org.junit.Before;
79.5 import org.junit.BeforeClass;
79.6 import org.junit.Test;
79.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
79.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
79.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
79.10 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
79.11 -import org.netbeans.modules.cnd.toolchain.api.Tool;
79.12 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
79.13 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
79.14 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
79.15 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
79.16
79.17 @@ -96,8 +98,8 @@
79.18 if (TRACE) {
79.19 System.out.println("Parse Compiler Output of SunStudio CC on Solaris");
79.20 }
79.21 - CompilerFlavor flavor = CompilerFlavor.toFlavor("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
79.22 - MySunCCCompiler instance = new MySunCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCCompiler, "SunStudio", "SunStudio", "/opt/SUNWspro/bin");
79.23 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
79.24 + MySunCCCompiler instance = new MySunCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCCompiler, "SunStudio", "SunStudio", "/opt/SUNWspro/bin");
79.25 instance.parseCompilerOutput(buf, instance.pair);
79.26 List<String> out = instance.pair.systemIncludeDirectoriesList;
79.27 Collections.<String>sort(out);
79.28 @@ -131,8 +133,8 @@
79.29 if (TRACE) {
79.30 System.out.println("Parse Compiler Output of SunStudio C on Solaris");
79.31 }
79.32 - CompilerFlavor flavor = CompilerFlavor.toFlavor("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
79.33 - MySunCCCompiler instance = new MySunCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCompiler, "SunStudio", "SunStudio", "/opt/SUNWspro/bin");
79.34 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
79.35 + MySunCCCompiler instance = new MySunCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCompiler, "SunStudio", "SunStudio", "/opt/SUNWspro/bin");
79.36 instance.parseCompilerOutput(buf, instance.pair);
79.37 List<String> out = instance.pair.systemIncludeDirectoriesList;
79.38 Collections.<String>sort(out);
79.39 @@ -169,8 +171,8 @@
79.40 if (TRACE) {
79.41 System.out.println("Parse Compiler Output of SunStudio C on Lunix");
79.42 }
79.43 - CompilerFlavor flavor = CompilerFlavor.toFlavor("SunStudio", PlatformTypes.PLATFORM_LINUX);
79.44 - MySunCCCompiler instance = new MySunCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, Tool.CCompiler, "SunStudio", "SunStudio", "/opt/SUNWspro/bin");
79.45 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor("SunStudio", PlatformTypes.PLATFORM_LINUX);
79.46 + MySunCCCompiler instance = new MySunCCCompiler(ExecutionEnvironmentFactory.getLocal(), flavor, ToolKind.CCompiler, "SunStudio", "SunStudio", "/opt/SUNWspro/bin");
79.47 instance.parseCompilerOutput(buf, instance.pair);
79.48 List<String> out = instance.pair.systemIncludeDirectoriesList;
79.49 Collections.<String>sort(out);
79.50 @@ -224,7 +226,7 @@
79.51 }
79.52 private static final class MySunCCCompiler extends SunCCCompiler {
79.53 Pair pair = new Pair();
79.54 - protected MySunCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
79.55 + protected MySunCCCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
79.56 super(env, flavor, kind, name, displayName, path);
79.57 }
79.58 @Override
80.1 --- a/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/configurations/ConfigurationMakefileWriterTest.java Mon Feb 01 12:23:06 2010 +0100
80.2 +++ b/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/configurations/ConfigurationMakefileWriterTest.java Mon Feb 01 12:24:26 2010 +0100
80.3 @@ -52,8 +52,7 @@
80.4 import java.util.logging.Logger;
80.5 import org.junit.Test;
80.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
80.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
80.8 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
80.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
80.10 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
80.11 import org.netbeans.modules.cnd.makeproject.api.MakeArtifact;
80.12 import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
80.13 @@ -61,6 +60,10 @@
80.14 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
80.15 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
80.16 import org.netbeans.modules.cnd.test.CndBaseTestCase;
80.17 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
80.18 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
80.19 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetFactory;
80.20 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
80.21 import org.openide.filesystems.FileUtil;
80.22 import org.openide.util.NbPreferences;
80.23
80.24 @@ -134,13 +137,13 @@
80.25 "dist/Debug/.../libhello3lib." + libsuffix));
80.26 conf.getLinkerConfiguration().getLibrariesConfiguration().add(projectItem);
80.27
80.28 - CompilerFlavor flavor = CompilerFlavor.toFlavor(flavorName, platform);
80.29 - CompilerSet compilerSet = CompilerSet.getCustomCompilerSet(folderBase.getAbsolutePath(), flavor, "MyCompilerSet");
80.30 - CompilerSet compilerSetold = CompilerSetManager.getDefault().getCompilerSet("MyCompilerSet");
80.31 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor(flavorName, platform);
80.32 + CompilerSet compilerSet = CompilerSetFactory.getCustomCompilerSet(folderBase.getAbsolutePath(), flavor, "MyCompilerSet");
80.33 + CompilerSet compilerSetold = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSet("MyCompilerSet");
80.34 if (compilerSetold != null) {
80.35 - CompilerSetManager.getDefault().remove(compilerSetold);
80.36 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).remove(compilerSetold);
80.37 }
80.38 - CompilerSetManager.getDefault().add(compilerSet);
80.39 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).add(compilerSet);
80.40 conf.getCompilerSet().setNameAndFlavor("MyCompilerSet|" + flavorName, 51);
80.41 conf.getDevelopmentHost().setBuildPlatform(platform);
80.42
80.43 @@ -176,7 +179,7 @@
80.44 rw.close();
80.45 break;
80.46 }
80.47 - result.append(line + "\n");
80.48 + result.append(line).append("\n");
80.49 }
80.50 } catch (IOException ioe) {
80.51 ioe.printStackTrace();
80.52 @@ -201,13 +204,13 @@
80.53 makeConfigurationDescriptor.init(conf);
80.54 makeConfigurationDescriptor.getLogicalFolders().addItem(new Item("test.cc"));
80.55
80.56 - CompilerFlavor flavor = CompilerFlavor.toFlavor(flavorName, platform);
80.57 - CompilerSet compilerSet = CompilerSet.getCustomCompilerSet(folderBase.getAbsolutePath(), flavor, "MyCompilerSet");
80.58 - CompilerSet compilerSetold = CompilerSetManager.getDefault().getCompilerSet("MyCompilerSet");
80.59 + CompilerFlavor flavor = CompilerFlavorAccessor.toFlavor(flavorName, platform);
80.60 + CompilerSet compilerSet = CompilerSetFactory.getCustomCompilerSet(folderBase.getAbsolutePath(), flavor, "MyCompilerSet");
80.61 + CompilerSet compilerSetold = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSet("MyCompilerSet");
80.62 if (compilerSetold != null) {
80.63 - CompilerSetManager.getDefault().remove(compilerSetold);
80.64 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).remove(compilerSetold);
80.65 }
80.66 - CompilerSetManager.getDefault().add(compilerSet);
80.67 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).add(compilerSet);
80.68 conf.getCompilerSet().setNameAndFlavor("MyCompilerSet|" + flavorName, 51);
80.69 conf.getDevelopmentHost().setBuildPlatform(platform);
80.70
80.71 @@ -243,7 +246,7 @@
80.72 rw.close();
80.73 break;
80.74 }
80.75 - result.append(line + "\n");
80.76 + result.append(line).append("\n");
80.77 }
80.78 } catch (IOException ioe) {
80.79 ioe.printStackTrace();
81.1 --- a/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/ui/wizards/MakeSampleProjectIteratorTest.java Mon Feb 01 12:23:06 2010 +0100
81.2 +++ b/cnd.makeproject/test/unit/src/org/netbeans/modules/cnd/makeproject/ui/wizards/MakeSampleProjectIteratorTest.java Mon Feb 01 12:24:26 2010 +0100
81.3 @@ -62,12 +62,13 @@
81.4 import org.junit.Test;
81.5 import org.netbeans.api.project.ProjectManager;
81.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
81.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
81.8 import org.netbeans.modules.cnd.makeproject.MakeActionProvider;
81.9 import org.netbeans.modules.cnd.makeproject.MakeOptions;
81.10 import org.netbeans.modules.cnd.makeproject.MakeProject;
81.11 import org.netbeans.modules.cnd.makeproject.MakeProjectType;
81.12 import org.netbeans.modules.cnd.test.CndTestIOProvider;
81.13 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
81.14 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
81.15 import org.openide.util.Utilities;
81.16 import org.openide.windows.IOProvider;
81.17
81.18 @@ -89,7 +90,7 @@
81.19 @Before @Override
81.20 public void setUp() throws Exception {
81.21 super.setUp();
81.22 - List<CompilerSet> sets = CompilerSetManager.getDefault().getCompilerSets();
81.23 + List<CompilerSet> sets = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSets();
81.24 for (CompilerSet set : sets) {
81.25 if (set.getName().equals("SunStudio")) {
81.26 SunStudioSet = set;
81.27 @@ -257,7 +258,7 @@
81.28 final CountDownLatch done = new CountDownLatch(1);
81.29 final AtomicInteger build_rc = new AtomicInteger(-1);
81.30
81.31 - CompilerSetManager.getDefault().setDefault(set);
81.32 + CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).setDefault(set);
81.33 MakeOptions.setDefaultMakeOptions(makeOptions);
81.34
81.35 File workDir = getWorkDir();//new File("/tmp");
82.1 --- a/cnd.model.services/src/org/netbeans/modules/cnd/api/model/services/CsmVirtualInfoQuery.java Mon Feb 01 12:23:06 2010 +0100
82.2 +++ b/cnd.model.services/src/org/netbeans/modules/cnd/api/model/services/CsmVirtualInfoQuery.java Mon Feb 01 12:24:26 2010 +0100
82.3 @@ -40,10 +40,10 @@
82.4 package org.netbeans.modules.cnd.api.model.services;
82.5
82.6 import java.util.Collection;
82.7 -import java.util.Collections;
82.8 import java.util.HashSet;
82.9 import java.util.Iterator;
82.10 import java.util.Set;
82.11 +import java.util.concurrent.atomic.AtomicReference;
82.12 import org.netbeans.modules.cnd.api.model.CsmClass;
82.13 import org.netbeans.modules.cnd.api.model.CsmInheritance;
82.14 import org.netbeans.modules.cnd.api.model.CsmMember;
82.15 @@ -52,6 +52,7 @@
82.16 import org.netbeans.modules.cnd.api.model.xref.CsmReference;
82.17 import org.netbeans.modules.cnd.api.model.xref.CsmTypeHierarchyResolver;
82.18 import org.netbeans.modules.cnd.modelutil.AntiLoop;
82.19 +import org.netbeans.modules.cnd.utils.CndUtils;
82.20 import org.netbeans.modules.cnd.utils.cache.CharSequenceKey;
82.21 import org.openide.util.Lookup;
82.22
82.23 @@ -61,7 +62,8 @@
82.24 */
82.25 public abstract class CsmVirtualInfoQuery {
82.26 public abstract boolean isVirtual(CsmMethod method);
82.27 - public abstract Collection<CsmMethod> getBaseDeclaration(CsmMethod method);
82.28 + public abstract Collection<CsmMethod> getTopmostBaseDeclarations(CsmMethod method);
82.29 + public abstract Collection<CsmMethod> getFirstBaseDeclarations(CsmMethod method);
82.30 public abstract Collection<CsmMethod> getOverridenMethods(CsmMethod method, boolean searchFromBase);
82.31 private static final CsmVirtualInfoQuery EMPTY = new Empty();
82.32
82.33 @@ -121,56 +123,79 @@
82.34 }
82.35 return false;
82.36 }
82.37 -
82.38 +
82.39 @Override
82.40 - public Collection<CsmMethod> getBaseDeclaration(CsmMethod method) {
82.41 + public Collection<CsmMethod> getTopmostBaseDeclarations(CsmMethod method) {
82.42 + return getBaseDeclaration(method, false);
82.43 + }
82.44 +
82.45 + @Override
82.46 + public Collection<CsmMethod> getFirstBaseDeclarations(CsmMethod method) {
82.47 + return getBaseDeclaration(method, true);
82.48 + }
82.49 +
82.50 + private Collection<CsmMethod> getBaseDeclaration(CsmMethod method, boolean first) {
82.51 Set<CharSequence> antilLoop = new HashSet<CharSequence>();
82.52 CharSequence sig = method.getSignature();
82.53 - CsmMethod met = processMethod(sig, method.getContainingClass(), antilLoop);
82.54 - if (met != null) {
82.55 - CsmMethod next = met;
82.56 - while(next != null) {
82.57 - met = next;
82.58 - CsmClass base = next.getContainingClass();
82.59 - next = null;
82.60 - if (base != null) {
82.61 - for(CsmInheritance inh : base.getBaseClasses()){
82.62 - CsmMethod m = processMethod(sig, CsmInheritanceUtilities.getCsmClass(inh), antilLoop);
82.63 - if (m != null) {
82.64 - next = m;
82.65 - break;
82.66 + Set<CsmMethod> result = new HashSet<CsmMethod>();
82.67 + for(CsmInheritance inh : method.getContainingClass().getBaseClasses()) {
82.68 + processMethod(sig, CsmInheritanceUtilities.getCsmClass(inh), antilLoop,
82.69 + new AtomicReference<CsmMethod>(), new AtomicReference<CsmMethod>(), result, first);
82.70 + }
82.71 + return result;
82.72 + }
82.73 +
82.74 + /**
82.75 + * Searches for method with the given signature in the given class and its ancestors.
82.76 + * @param sig signature to search
82.77 + * @param cls class to start with
82.78 + * @param antilLoop prevents infinite loops
82.79 + * @param result if a method with the given signature is found, it's stored in result - even if it is not virtual.
82.80 + * @param first if true, returns first found method, otherwise the topmost one
82.81 + * @return true if method found and it is virtual, otherwise false
82.82 + */
82.83 + private void processMethod(CharSequence sig, CsmClass cls, Set<CharSequence> antilLoop,
82.84 + AtomicReference<CsmMethod> firstFound, AtomicReference<CsmMethod> lastFound,
82.85 + Set<CsmMethod> result, boolean first) {
82.86 +
82.87 + boolean theLastInHierarchy;
82.88 + if (cls == null || antilLoop.contains(cls.getQualifiedName())) {
82.89 + theLastInHierarchy = true;
82.90 + } else {
82.91 +
82.92 + antilLoop.add(cls.getQualifiedName());
82.93 + for(CsmMember member : cls.getMembers()) {
82.94 + if (CsmKindUtilities.isMethod(member)) {
82.95 + CsmMethod method = (CsmMethod) member;
82.96 + if (CharSequenceKey.Comparator.compare(sig, method.getSignature()) == 0) {
82.97 + if (firstFound.get() == null) {
82.98 + firstFound.set(method);
82.99 + }
82.100 + lastFound.set(method);
82.101 + if (method.isVirtual()) {
82.102 + if (first) {
82.103 + result.add(firstFound.get());
82.104 + return;
82.105 + }
82.106 }
82.107 }
82.108 }
82.109 }
82.110 + theLastInHierarchy = cls.getBaseClasses().isEmpty();
82.111 + for(CsmInheritance inh : cls.getBaseClasses()) {
82.112 + AtomicReference<CsmMethod> firstFound2 = new AtomicReference<CsmMethod>(firstFound.get());
82.113 + AtomicReference<CsmMethod> lastFound2 = new AtomicReference<CsmMethod>(lastFound.get());
82.114 + processMethod(sig, CsmInheritanceUtilities.getCsmClass(inh), antilLoop, firstFound2, lastFound2, result, first);
82.115 + }
82.116 +
82.117 }
82.118 - if (met == null) {
82.119 - return Collections.<CsmMethod>emptyList();
82.120 - }
82.121 - return Collections.<CsmMethod>singleton(met);
82.122 - }
82.123 -
82.124 - private CsmMethod processMethod(CharSequence sig, CsmClass cls, Set<CharSequence> antilLoop){
82.125 - if (cls == null || antilLoop.contains(cls.getQualifiedName())) {
82.126 - return null;
82.127 - }
82.128 - antilLoop.add(cls.getQualifiedName());
82.129 - for(CsmMember m : cls.getMembers()){
82.130 - if (CsmKindUtilities.isMethod(m)) {
82.131 - CsmMethod met = (CsmMethod) m;
82.132 - if (CharSequenceKey.Comparator.compare(sig, met.getSignature())==0
82.133 - && met.isVirtual()){
82.134 - return met;
82.135 - }
82.136 + if (theLastInHierarchy) {
82.137 + CsmMethod m = lastFound.get();
82.138 + if (m != null && m.isVirtual()) {
82.139 + CndUtils.assertNotNull(firstFound.get(), "last found != null && first found == null ?!"); //NOI18N
82.140 + result.add(first ? firstFound.get() : m);
82.141 }
82.142 }
82.143 - for(CsmInheritance inh : cls.getBaseClasses()){
82.144 - CsmMethod met = processMethod(sig, CsmInheritanceUtilities.getCsmClass(inh), antilLoop);
82.145 - if (met != null) {
82.146 - return met;
82.147 - }
82.148 - }
82.149 - return null;
82.150 }
82.151
82.152 @Override
82.153 @@ -178,7 +203,7 @@
82.154 Set<CsmMethod> res = new HashSet<CsmMethod>();
82.155 CsmClass cls;
82.156 if (searchFromBase) {
82.157 - Iterator<CsmMethod> it = getBaseDeclaration(method).iterator();
82.158 + Iterator<CsmMethod> it = getTopmostBaseDeclarations(method).iterator();
82.159 if (it.hasNext()){
82.160 method = it.next();
82.161 }
83.1 --- a/cnd.modeldiscovery/src/org/netbeans/modules/cnd/modeldiscovery/provider/PkgConfigImpl.java Mon Feb 01 12:23:06 2010 +0100
83.2 +++ b/cnd.modeldiscovery/src/org/netbeans/modules/cnd/modeldiscovery/provider/PkgConfigImpl.java Mon Feb 01 12:24:26 2010 +0100
83.3 @@ -47,14 +47,11 @@
83.4 import java.util.Collections;
83.5 import java.util.HashMap;
83.6 import java.util.HashSet;
83.7 -import java.util.LinkedHashSet;
83.8 import java.util.List;
83.9 import java.util.Map;
83.10 import java.util.Set;
83.11 import java.util.StringTokenizer;
83.12 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
83.13 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
83.14 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
83.15 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
83.16 import org.netbeans.modules.cnd.api.remote.RemoteFile;
83.17 import org.netbeans.modules.nativeexecution.api.util.Path;
83.18 @@ -63,6 +60,9 @@
83.19 import org.netbeans.modules.cnd.discovery.api.PkgConfigManager.PkgConfig;
83.20 import org.netbeans.modules.cnd.discovery.api.PkgConfigManager.ResolvedPath;
83.21 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
83.22 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
83.23 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
83.24 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
83.25
83.26 /**
83.27 *
83.28 @@ -125,7 +125,7 @@
83.29 String baseDirectory = getPkgConfihPath();
83.30 if (baseDirectory == null) {
83.31 if (set == null) {
83.32 - set = CompilerSetManager.getDefault().getCompilerSet(CompilerFlavor.toFlavor("Cygwin", PlatformTypes.PLATFORM_WINDOWS)); // NOI18N
83.33 + set = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getCompilerSet(CompilerFlavorAccessor.toFlavor("Cygwin", PlatformTypes.PLATFORM_WINDOWS)); // NOI18N
83.34 }
83.35 if (set != null){
83.36 baseDirectory = set.getDirectory();
84.1 --- a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/TypedefImpl.java Mon Feb 01 12:23:06 2010 +0100
84.2 +++ b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/TypedefImpl.java Mon Feb 01 12:24:26 2010 +0100
84.3 @@ -275,13 +275,23 @@
84.4
84.5 ////////////////////////////////////////////////////////////////////////////
84.6 // impl of SelfPersistent
84.7 + private static final byte UNNAMED_TYPE_FLAG = 1;
84.8 + private static final byte UNNAMED_TYPEDEF_FLAG = 1 << 1;
84.9 @Override
84.10 public void write(DataOutput output) throws IOException {
84.11 super.write(output);
84.12 assert this.name != null;
84.13 PersistentUtils.writeUTF(name, output);
84.14 - output.writeBoolean(typeUnnamed);
84.15 + byte unnamedState = 0;
84.16 if (typeUnnamed) {
84.17 + unnamedState |= UNNAMED_TYPE_FLAG;
84.18 + }
84.19 + boolean unnamed = getName().length() == 0;
84.20 + if (unnamed) {
84.21 + unnamedState |= UNNAMED_TYPEDEF_FLAG;
84.22 + }
84.23 + output.writeByte(unnamedState);
84.24 + if (unnamed) {
84.25 super.writeUID(output);
84.26 }
84.27 assert this.type != null;
84.28 @@ -302,8 +312,16 @@
84.29 super(input);
84.30 this.name = PersistentUtils.readUTF(input, QualifiedNameCache.getManager());
84.31 assert this.name != null;
84.32 - typeUnnamed = input.readBoolean();
84.33 - if (typeUnnamed) {
84.34 + byte unnamedState = input.readByte();
84.35 + typeUnnamed = false;
84.36 + if ((unnamedState & UNNAMED_TYPE_FLAG) == UNNAMED_TYPE_FLAG) {
84.37 + typeUnnamed = true;
84.38 + }
84.39 + boolean unnamed = false;
84.40 + if ((unnamedState & UNNAMED_TYPEDEF_FLAG) == UNNAMED_TYPEDEF_FLAG) {
84.41 + unnamed = true;
84.42 + }
84.43 + if (unnamed) {
84.44 super.readUID(input);
84.45 }
84.46 this.type = PersistentUtils.readType(input);
85.1 --- a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/repository/RepositoryUtils.java Mon Feb 01 12:23:06 2010 +0100
85.2 +++ b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/repository/RepositoryUtils.java Mon Feb 01 12:24:26 2010 +0100
85.3 @@ -77,7 +77,7 @@
85.4 /**
85.5 * the version of the persistency mechanism
85.6 */
85.7 - private static int CURRENT_VERSION_OF_PERSISTENCY = 79;
85.8 + private static int CURRENT_VERSION_OF_PERSISTENCY = 80;
85.9
85.10 /** Creates a new instance of RepositoryUtils */
85.11 private RepositoryUtils() {
86.1 --- a/cnd.navigation/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
86.2 +++ b/cnd.navigation/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
86.3 @@ -229,6 +229,10 @@
86.4 <test/>
86.5 </test-dependency>
86.6 <test-dependency>
86.7 + <code-name-base>org.netbeans.modules.masterfs</code-name-base>
86.8 + <compile-dependency/>
86.9 + </test-dependency>
86.10 + <test-dependency>
86.11 <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
86.12 <recursive/>
86.13 <compile-dependency/>
87.1 --- a/cnd.navigation/src/org/netbeans/modules/cnd/navigation/overrides/ComputeAnnotations.java Mon Feb 01 12:23:06 2010 +0100
87.2 +++ b/cnd.navigation/src/org/netbeans/modules/cnd/navigation/overrides/ComputeAnnotations.java Mon Feb 01 12:24:26 2010 +0100
87.3 @@ -49,6 +49,7 @@
87.4 import org.netbeans.modules.cnd.api.model.CsmNamespaceDefinition;
87.5 import org.netbeans.modules.cnd.api.model.CsmOffsetableDeclaration;
87.6 import org.netbeans.modules.cnd.api.model.services.CsmVirtualInfoQuery;
87.7 +import org.netbeans.modules.cnd.api.model.util.CsmBaseUtilities;
87.8 import org.netbeans.modules.cnd.api.model.util.CsmKindUtilities;
87.9 import org.openide.loaders.DataObject;
87.10 import org.openide.util.NbBundle;
87.11 @@ -60,10 +61,16 @@
87.12 */
87.13 public class ComputeAnnotations {
87.14
87.15 + private static final ComputeAnnotations INSTANCE = new ComputeAnnotations();
87.16 +
87.17 private ComputeAnnotations() {
87.18 }
87.19
87.20 - public static void computeAnnotations(
87.21 + public static ComputeAnnotations getInstance() {
87.22 + return INSTANCE;
87.23 + }
87.24 +
87.25 + public void computeAnnotations(
87.26 Collection<? extends CsmOffsetableDeclaration> toProcess,
87.27 Collection<OverriddeAnnotation> toAdd, CsmFile file, StyledDocument doc, DataObject dobj) {
87.28
87.29 @@ -82,31 +89,43 @@
87.30 }
87.31 }
87.32
87.33 - private static OverriddeAnnotation computeAnnotation(CsmFunction func, StyledDocument doc) {
87.34 + private OverriddeAnnotation computeAnnotation(CsmFunction func, StyledDocument doc) {
87.35 if (CsmKindUtilities.isMethod(func)) {
87.36 - CsmMethod meth = (CsmMethod) func;
87.37 - final Collection<? extends CsmMethod> baseMethods = CsmVirtualInfoQuery.getDefault().getBaseDeclaration(meth);
87.38 + CsmMethod meth = (CsmMethod) CsmBaseUtilities.getFunctionDeclaration(func);
87.39 + final Collection<? extends CsmMethod> baseMethods = CsmVirtualInfoQuery.getDefault().getFirstBaseDeclarations(meth);
87.40 final Collection<? extends CsmMethod> overriddenMethods = CsmVirtualInfoQuery.getDefault().getOverridenMethods(meth, false);
87.41 if (OverriddeAnnotation.LOGGER.isLoggable(Level.FINEST)) {
87.42 - OverriddeAnnotation.LOGGER.log(Level.FINEST, "Found {0} base decls for {1}", new Object[]{baseMethods.size(), func});
87.43 + OverriddeAnnotation.LOGGER.log(Level.FINEST, "Found {0} base decls for {1}", new Object[]{baseMethods.size(), toString(func)});
87.44 for (CsmMethod baseMethod : baseMethods) {
87.45 - OverriddeAnnotation.LOGGER.log(Level.FINEST, " {0}", baseMethod);
87.46 + OverriddeAnnotation.LOGGER.log(Level.FINEST, " {0}", toString(baseMethod));
87.47 }
87.48 }
87.49 if (!baseMethods.isEmpty()) {
87.50 boolean itself = baseMethods.size() == 1 && baseMethods.iterator().next().equals(func);
87.51 if (!itself) {
87.52 CsmMethod m = baseMethods.iterator().next(); //TODO: XXX
87.53 - String desc = NbBundle.getMessage(OverridesTaskFactory.class, "LAB_Overrides", m.getQualifiedName().toString());
87.54 + String desc = NbBundle.getMessage(getClass(), "LAB_Overrides", m.getQualifiedName().toString());
87.55 return new OverriddeAnnotation(doc, func, OverriddeAnnotation.AnnotationType.OVERRIDES, desc, baseMethods);
87.56 }
87.57 }
87.58 if (!overriddenMethods.isEmpty()) {
87.59 - String desc = NbBundle.getMessage(OverridesTaskFactory.class, "LAB_IsOverriden");
87.60 + String desc = NbBundle.getMessage(getClass(), "LAB_IsOverriden");
87.61 return new OverriddeAnnotation(doc, func, OverriddeAnnotation.AnnotationType.IS_OVERRIDDEN, desc, overriddenMethods);
87.62 }
87.63 }
87.64 return null;
87.65 }
87.66
87.67 + private static CharSequence toString(CsmFunction func) {
87.68 + StringBuilder sb = new StringBuilder();
87.69 + sb.append(func.getClass().getSimpleName());
87.70 + sb.append(' ');
87.71 + sb.append(func.getQualifiedName());
87.72 + sb.append(" ["); // NOI18N
87.73 + sb.append(func.getContainingFile().getName());
87.74 + sb.append(':');
87.75 + sb.append(func.getStartPosition().getLine());
87.76 + sb.append(']');
87.77 + return sb;
87.78 + }
87.79 }
88.1 --- a/cnd.navigation/src/org/netbeans/modules/cnd/navigation/overrides/OverriddeAnnotation.java Mon Feb 01 12:23:06 2010 +0100
88.2 +++ b/cnd.navigation/src/org/netbeans/modules/cnd/navigation/overrides/OverriddeAnnotation.java Mon Feb 01 12:24:26 2010 +0100
88.3 @@ -50,6 +50,7 @@
88.4 import java.util.ArrayList;
88.5 import java.util.Collection;
88.6 import java.util.Collections;
88.7 +import java.util.Comparator;
88.8 import java.util.List;
88.9 import java.util.logging.Logger;
88.10 import javax.swing.BorderFactory;
88.11 @@ -134,20 +135,20 @@
88.12 public String toString() {
88.13 return "[IsOverriddenAnnotation: " + shortDescription + "]"; //NOI18N
88.14 }
88.15 -
88.16 +
88.17 public Position getPosition() {
88.18 return pos;
88.19 }
88.20
88.21 public String debugDump() {
88.22 - List<String> elementNames = new ArrayList<String>();
88.23 + List<String> elementNames = new ArrayList<String>();
88.24 for(CsmUID<CsmMethod> uid : methodUIDs) {
88.25 elementNames.add(uid.toString());
88.26 }
88.27 - Collections.sort(elementNames);
88.28 + Collections.sort(elementNames);
88.29 return "IsOverriddenAnnotation: type=" + type.name() + ", elements:" + elementNames.toString(); //NOI18N
88.30 }
88.31 -
88.32 +
88.33 void mouseClicked(JTextComponent c, Point p) {
88.34 Point position = new Point(p);
88.35 SwingUtilities.convertPointToScreen(position, c);
88.36 @@ -162,18 +163,37 @@
88.37 // return methods;
88.38 // }
88.39
88.40 - void performGoToAction(Point position) {
88.41 - if (methodUIDs.size() == 1) {
88.42 - CsmUtilities.openSource(methodUIDs.iterator().next().getObject());
88.43 + private void performGoToAction(Point position) {
88.44 + Collection<Element> elements = getElements();
88.45 + if (elements.size() == 1) {
88.46 + openSource(elements.iterator().next());
88.47 } else if (methodUIDs.size() > 1) {
88.48 -// CsmUtilities.openSource(methodUIDs.iterator().next().getObject()); //TODO: XXX
88.49 String caption = getShortDescription();
88.50 - PopupUtil.showPopup(new Popup(caption), caption, position.x, position.y, true, 0);
88.51 + PopupUtil.showPopup(new Popup(caption, elements), caption, position.x, position.y, true, 0);
88.52 } else {
88.53 throw new IllegalStateException("method list should not be empty"); // NOI18N
88.54 }
88.55 }
88.56
88.57 + private static void openSource(Element element) {
88.58 + CsmUtilities.openSource(element.method);
88.59 + }
88.60 +
88.61 +
88.62 + /**
88.63 + * Gets a SORTED elements list
88.64 + * @return
88.65 + */
88.66 + /*package-local for test purposes*/
88.67 + List<Element> getElements() {
88.68 + List<Element> elements = new ArrayList<Element>(methodUIDs.size());
88.69 + for (CsmUID<CsmMethod> uid : methodUIDs) {
88.70 + elements.add(new Element(uid.getObject()));
88.71 + }
88.72 + Collections.sort(elements);
88.73 + return elements;
88.74 + }
88.75 +
88.76 private static class DeclarationPosition implements Position {
88.77
88.78 private final int offset;
88.79 @@ -189,25 +209,37 @@
88.80
88.81 }
88.82
88.83 - static class Element {
88.84 + /*package-local for test purposes*/
88.85 + static class Element implements Comparable<Element> {
88.86 +
88.87 public final CsmMethod method;
88.88 +
88.89 public Element(CsmMethod method) {
88.90 this.method = method;
88.91 }
88.92 +
88.93 @Override
88.94 public String toString() {
88.95 return method.getQualifiedName().toString();
88.96 }
88.97 +
88.98 + @Override
88.99 + public int compareTo(Element o) {
88.100 + return (o == null) ? -1 : method.getQualifiedName().toString().compareTo(o.method.getQualifiedName().toString());
88.101 + }
88.102 +
88.103 }
88.104
88.105 - class Popup extends JPanel implements FocusListener {
88.106 + private static class Popup extends JPanel implements FocusListener {
88.107
88.108 private JLabel title;
88.109 private JList list;
88.110 private JScrollPane scrollPane;
88.111 + private final Collection<Element> elements;
88.112
88.113 - public Popup(String caption) {
88.114 + public Popup(String caption, Collection<Element> elements) {
88.115 super(new BorderLayout());
88.116 + this.elements = elements;
88.117
88.118 title = new JLabel(caption);
88.119 title.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
88.120 @@ -219,8 +251,8 @@
88.121 add(scrollPane, BorderLayout.CENTER);
88.122
88.123 DefaultListModel model = new DefaultListModel();
88.124 - for (CsmUID<CsmMethod> uid : methodUIDs) {
88.125 - model.addElement(new Element(uid.getObject()));
88.126 + for (Element element : elements) {
88.127 + model.addElement(element);
88.128 }
88.129 list.setModel(model);
88.130 list.setSelectedIndex(0);
88.131 @@ -250,7 +282,7 @@
88.132 private void openSelected() {
88.133 Element el = (Element) list.getSelectedValue();
88.134 if (el != null) {
88.135 - CsmUtilities.openSource(el.method);
88.136 + openSource(el);
88.137 }
88.138 PopupUtil.hidePopup();
88.139 }
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
89.2 +++ b/cnd.navigation/src/org/netbeans/modules/cnd/navigation/overrides/OverrideTaskFactory.java Mon Feb 01 12:24:26 2010 +0100
89.3 @@ -0,0 +1,173 @@
89.4 +/*
89.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
89.6 + *
89.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
89.8 + *
89.9 + * The contents of this file are subject to the terms of either the GNU
89.10 + * General Public License Version 2 only ("GPL") or the Common
89.11 + * Development and Distribution License("CDDL") (collectively, the
89.12 + * "License"). You may not use this file except in compliance with the
89.13 + * License. You can obtain a copy of the License at
89.14 + * http://www.netbeans.org/cddl-gplv2.html
89.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
89.16 + * specific language governing permissions and limitations under the
89.17 + * License. When distributing the software, include this License Header
89.18 + * Notice in each file and include the License file at
89.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
89.20 + * particular file as subject to the "Classpath" exception as provided
89.21 + * by Sun in the GPL Version 2 section of the License file that
89.22 + * accompanied this code. If applicable, add the following below the
89.23 + * License Header, with the fields enclosed by brackets [] replaced by
89.24 + * your own identifying information:
89.25 + * "Portions Copyrighted [year] [name of copyright owner]"
89.26 + *
89.27 + * If you wish your version of this file to be governed by only the CDDL
89.28 + * or only the GPL Version 2, indicate your decision by adding
89.29 + * "[Contributor] elects to include this software in this distribution
89.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
89.31 + * single choice of license, a recipient has the option to distribute
89.32 + * your version of this file under either the CDDL, the GPL Version 2 or
89.33 + * to extend the choice of license to its licensees as provided above.
89.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
89.35 + * Version 2 license, then the option applies only if the new code is
89.36 + * made subject to such option by the copyright holder.
89.37 + *
89.38 + * Contributor(s):
89.39 + *
89.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
89.41 + */
89.42 +
89.43 +package org.netbeans.modules.cnd.navigation.overrides;
89.44 +
89.45 +import java.lang.ref.WeakReference;
89.46 +import java.util.ArrayList;
89.47 +import java.util.Collection;
89.48 +import java.util.Collections;
89.49 +import java.util.logging.Level;
89.50 +import javax.swing.text.Document;
89.51 +import javax.swing.text.StyledDocument;
89.52 +import org.netbeans.modules.cnd.api.model.CsmFile;
89.53 +import org.netbeans.modules.cnd.model.tasks.CsmFileTaskFactory.PhaseRunner;
89.54 +import org.netbeans.modules.cnd.model.tasks.EditorAwareCsmFileTaskFactory;
89.55 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
89.56 +import org.openide.cookies.EditorCookie;
89.57 +import org.openide.filesystems.FileObject;
89.58 +import org.openide.loaders.DataObject;
89.59 +import org.openide.loaders.DataObjectNotFoundException;
89.60 +
89.61 +/**
89.62 + *
89.63 + * @author Vladimir Kvashin
89.64 + */
89.65 +@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.cnd.model.tasks.CsmFileTaskFactory.class, position=30)
89.66 +public class OverrideTaskFactory extends EditorAwareCsmFileTaskFactory {
89.67 +
89.68 + private static final int TASK_DELAY = getInt("cnd.overrides.delay", 500); // NOI18N
89.69 + private static final int RESCHEDULE_DELAY = getInt("cnd.overrides.reschedule.delay", 500); // NOI18N
89.70 +
89.71 + public OverrideTaskFactory() {
89.72 + }
89.73 +
89.74 + @Override
89.75 + protected PhaseRunner createTask(FileObject fo) {
89.76 + PhaseRunner pr = null;
89.77 + try {
89.78 + final DataObject dobj = DataObject.find(fo);
89.79 + EditorCookie ec = dobj.getCookie(EditorCookie.class);
89.80 + final CsmFile file = CsmUtilities.getCsmFile(dobj, false);
89.81 + final StyledDocument doc = ec.getDocument();
89.82 + if (doc != null && file != null) {
89.83 + pr = new PhaseRunnerImpl(dobj, file, doc);
89.84 + }
89.85 + } catch (DataObjectNotFoundException ex) {
89.86 + ex.printStackTrace();
89.87 + }
89.88 + return pr != null ? pr : lazyRunner();
89.89 + }
89.90 +
89.91 + @Override
89.92 + protected int taskDelay() {
89.93 + return TASK_DELAY;
89.94 + }
89.95 +
89.96 + @Override
89.97 + protected int rescheduleDelay() {
89.98 + return RESCHEDULE_DELAY;
89.99 + }
89.100 +
89.101 + private static int getInt(String name, int result){
89.102 + String text = System.getProperty(name);
89.103 + if( text != null ) {
89.104 + try {
89.105 + result = Integer.parseInt(text);
89.106 + } catch(NumberFormatException e){
89.107 + // default value
89.108 + }
89.109 + }
89.110 + return result;
89.111 + }
89.112 +
89.113 + private static class PhaseRunnerImpl implements PhaseRunner {
89.114 +
89.115 + private final DataObject dobj;
89.116 + private final CsmFile file;
89.117 + private final WeakReference<StyledDocument> weakDoc;
89.118 + private final Collection<OverriddeAnnotation> annotations = new ArrayList<OverriddeAnnotation>();
89.119 +
89.120 + private PhaseRunnerImpl(DataObject dobj,CsmFile file, Document doc){
89.121 + this.dobj = dobj;
89.122 + this.file = file;
89.123 + if (doc instanceof StyledDocument) {
89.124 + weakDoc = new WeakReference<StyledDocument>((StyledDocument) doc);
89.125 + } else {
89.126 + weakDoc = null;
89.127 + }
89.128 + }
89.129 +
89.130 + @Override
89.131 + public void run(Phase phase) {
89.132 + StyledDocument doc = getDocument();
89.133 + if (doc != null) {
89.134 + if (phase == Phase.PARSED || phase == Phase.INIT || phase == Phase.PROJECT_PARSED) {
89.135 + addAnnotations(file, doc, dobj);
89.136 + } else if (phase == Phase.CLEANUP) {
89.137 + clearAnnotations(doc, dobj);
89.138 + }
89.139 + }
89.140 + }
89.141 +
89.142 + protected StyledDocument getDocument() {
89.143 + return weakDoc != null ? weakDoc.get() : null;
89.144 + }
89.145 +
89.146 + private void addAnnotations(CsmFile file, StyledDocument doc, DataObject dobj) {
89.147 + final Collection<OverriddeAnnotation> toAdd = new ArrayList<OverriddeAnnotation>();
89.148 + OverriddeAnnotation.LOGGER.log(Level.FINE, ">> Computing annotations for {0}", file);
89.149 + long time = System.currentTimeMillis();
89.150 + ComputeAnnotations.getInstance().computeAnnotations(file.getDeclarations(), toAdd, file, doc, dobj);
89.151 + time = System.currentTimeMillis() - time;
89.152 + OverriddeAnnotation.LOGGER.log(Level.FINE, "<< Computed sannotations for {0} in {1} ms", new Object[] { file, time });
89.153 + final Collection<OverriddeAnnotation> toClear;
89.154 + AnnotationsHolder.get(dobj.getPrimaryFile()).setNewAnnotations(toAdd);
89.155 + }
89.156 +
89.157 + private void clearAnnotations(StyledDocument doc, DataObject dobj) {
89.158 + AnnotationsHolder.get(dobj.getPrimaryFile()).setNewAnnotations(Collections.<OverriddeAnnotation>emptyList());
89.159 + }
89.160 +
89.161 +
89.162 + @Override
89.163 + public boolean isValid() {
89.164 + return true;
89.165 + }
89.166 +
89.167 + @Override
89.168 + public void cancel() {
89.169 + }
89.170 +
89.171 + @Override
89.172 + public boolean isHighPriority() {
89.173 + return false;
89.174 + }
89.175 + }
89.176 +}
90.1 --- a/cnd.navigation/src/org/netbeans/modules/cnd/navigation/overrides/OverridesTaskFactory.java Mon Feb 01 12:23:06 2010 +0100
90.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
90.3 @@ -1,222 +0,0 @@
90.4 -/*
90.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
90.6 - *
90.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
90.8 - *
90.9 - * The contents of this file are subject to the terms of either the GNU
90.10 - * General Public License Version 2 only ("GPL") or the Common
90.11 - * Development and Distribution License("CDDL") (collectively, the
90.12 - * "License"). You may not use this file except in compliance with the
90.13 - * License. You can obtain a copy of the License at
90.14 - * http://www.netbeans.org/cddl-gplv2.html
90.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
90.16 - * specific language governing permissions and limitations under the
90.17 - * License. When distributing the software, include this License Header
90.18 - * Notice in each file and include the License file at
90.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
90.20 - * particular file as subject to the "Classpath" exception as provided
90.21 - * by Sun in the GPL Version 2 section of the License file that
90.22 - * accompanied this code. If applicable, add the following below the
90.23 - * License Header, with the fields enclosed by brackets [] replaced by
90.24 - * your own identifying information:
90.25 - * "Portions Copyrighted [year] [name of copyright owner]"
90.26 - *
90.27 - * If you wish your version of this file to be governed by only the CDDL
90.28 - * or only the GPL Version 2, indicate your decision by adding
90.29 - * "[Contributor] elects to include this software in this distribution
90.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
90.31 - * single choice of license, a recipient has the option to distribute
90.32 - * your version of this file under either the CDDL, the GPL Version 2 or
90.33 - * to extend the choice of license to its licensees as provided above.
90.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
90.35 - * Version 2 license, then the option applies only if the new code is
90.36 - * made subject to such option by the copyright holder.
90.37 - *
90.38 - * Contributor(s):
90.39 - *
90.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
90.41 - */
90.42 -
90.43 -package org.netbeans.modules.cnd.navigation.overrides;
90.44 -
90.45 -import java.lang.ref.WeakReference;
90.46 -import java.util.ArrayList;
90.47 -import java.util.Collection;
90.48 -import java.util.Collections;
90.49 -import java.util.logging.Level;
90.50 -import javax.swing.text.Document;
90.51 -import javax.swing.text.StyledDocument;
90.52 -import org.netbeans.modules.cnd.api.model.CsmClass;
90.53 -import org.netbeans.modules.cnd.api.model.CsmFile;
90.54 -import org.netbeans.modules.cnd.api.model.CsmFunction;
90.55 -import org.netbeans.modules.cnd.api.model.CsmMethod;
90.56 -import org.netbeans.modules.cnd.api.model.CsmNamespaceDefinition;
90.57 -import org.netbeans.modules.cnd.api.model.CsmOffsetableDeclaration;
90.58 -import org.netbeans.modules.cnd.api.model.services.CsmVirtualInfoQuery;
90.59 -import org.netbeans.modules.cnd.api.model.util.CsmKindUtilities;
90.60 -import org.netbeans.modules.cnd.model.tasks.CsmFileTaskFactory.PhaseRunner;
90.61 -import org.netbeans.modules.cnd.model.tasks.EditorAwareCsmFileTaskFactory;
90.62 -import org.netbeans.modules.cnd.modelutil.CsmUtilities;
90.63 -import org.openide.cookies.EditorCookie;
90.64 -import org.openide.filesystems.FileObject;
90.65 -import org.openide.loaders.DataObject;
90.66 -import org.openide.loaders.DataObjectNotFoundException;
90.67 -import org.openide.util.NbBundle;
90.68 -
90.69 -/**
90.70 - *
90.71 - * @author Vladimir Kvashin
90.72 - */
90.73 -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.cnd.model.tasks.CsmFileTaskFactory.class, position=30)
90.74 -public class OverridesTaskFactory extends EditorAwareCsmFileTaskFactory {
90.75 -
90.76 - private static final int TASK_DELAY = getInt("cnd.overrides.delay", 500); // NOI18N
90.77 - private static final int RESCHEDULE_DELAY = getInt("cnd.overrides.reschedule.delay", 500); // NOI18N
90.78 -
90.79 - public OverridesTaskFactory() {
90.80 - }
90.81 -
90.82 - @Override
90.83 - protected PhaseRunner createTask(FileObject fo) {
90.84 - PhaseRunner pr = null;
90.85 - try {
90.86 - final DataObject dobj = DataObject.find(fo);
90.87 - EditorCookie ec = dobj.getCookie(EditorCookie.class);
90.88 - final CsmFile file = CsmUtilities.getCsmFile(dobj, false);
90.89 - final StyledDocument doc = ec.getDocument();
90.90 - if (doc != null && file != null) {
90.91 - pr = new PhaseRunnerImpl(dobj, file, doc);
90.92 - }
90.93 - } catch (DataObjectNotFoundException ex) {
90.94 - ex.printStackTrace();
90.95 - }
90.96 - return pr != null ? pr : lazyRunner();
90.97 - }
90.98 -
90.99 - @Override
90.100 - protected int taskDelay() {
90.101 - return TASK_DELAY;
90.102 - }
90.103 -
90.104 - @Override
90.105 - protected int rescheduleDelay() {
90.106 - return RESCHEDULE_DELAY;
90.107 - }
90.108 -
90.109 - private static int getInt(String name, int result){
90.110 - String text = System.getProperty(name);
90.111 - if( text != null ) {
90.112 - try {
90.113 - result = Integer.parseInt(text);
90.114 - } catch(NumberFormatException e){
90.115 - // default value
90.116 - }
90.117 - }
90.118 - return result;
90.119 - }
90.120 -
90.121 - private static class PhaseRunnerImpl implements PhaseRunner {
90.122 -
90.123 - private final DataObject dobj;
90.124 - private final CsmFile file;
90.125 - private final WeakReference<StyledDocument> weakDoc;
90.126 - private final Collection<OverriddeAnnotation> annotations = new ArrayList<OverriddeAnnotation>();
90.127 -
90.128 - private PhaseRunnerImpl(DataObject dobj,CsmFile file, Document doc){
90.129 - this.dobj = dobj;
90.130 - this.file = file;
90.131 - if (doc instanceof StyledDocument) {
90.132 - weakDoc = new WeakReference<StyledDocument>((StyledDocument) doc);
90.133 - } else {
90.134 - weakDoc = null;
90.135 - }
90.136 - }
90.137 -
90.138 - @Override
90.139 - public void run(Phase phase) {
90.140 - StyledDocument doc = getDocument();
90.141 - if (doc != null) {
90.142 - if (phase == Phase.PARSED || phase == Phase.INIT || phase == Phase.PROJECT_PARSED) {
90.143 - addAnnotations(file, doc, dobj);
90.144 - } else if (phase == Phase.CLEANUP) {
90.145 - clearAnnotations(doc, dobj);
90.146 - }
90.147 - }
90.148 - }
90.149 -
90.150 - protected StyledDocument getDocument() {
90.151 - return weakDoc != null ? weakDoc.get() : null;
90.152 - }
90.153 -
90.154 - private void addAnnotations(CsmFile file, StyledDocument doc, DataObject dobj) {
90.155 - final Collection<OverriddeAnnotation> toAdd = new ArrayList<OverriddeAnnotation>();
90.156 - OverriddeAnnotation.LOGGER.log(Level.FINE, ">> Computing annotations for {0}", file);
90.157 - long time = System.currentTimeMillis();
90.158 - ComputeAnnotations.computeAnnotations(file.getDeclarations(), toAdd, file, doc, dobj);
90.159 - time = System.currentTimeMillis() - time;
90.160 - OverriddeAnnotation.LOGGER.log(Level.FINE, "<< Computed sannotations for {0} in {1} ms", new Object[] { file, time });
90.161 - final Collection<OverriddeAnnotation> toClear;
90.162 - AnnotationsHolder.get(dobj.getPrimaryFile()).setNewAnnotations(toAdd);
90.163 -// synchronized (annotations) {
90.164 -// toClear = new ArrayList<OverriddeAnnotation>(annotations);
90.165 -// annotations.clear();
90.166 -// annotations.addAll(toAdd);
90.167 -// }
90.168 -// Runnable r = new Runnable() {
90.169 -// @Override
90.170 -// public void run() {
90.171 -// for (OverriddeAnnotation anno : toClear) {
90.172 -// anno.detachImpl();
90.173 -// }
90.174 -// for (OverriddeAnnotation anno : toAdd) {
90.175 -// anno.attach();
90.176 -// }
90.177 -// }
90.178 -// };
90.179 -// if (SwingUtilities.isEventDispatchThread()) {
90.180 -// r.run();
90.181 -// } else {
90.182 -// SwingUtilities.invokeLater(r);
90.183 -// }
90.184 - }
90.185 -
90.186 - private void clearAnnotations(StyledDocument doc, DataObject dobj) {
90.187 - AnnotationsHolder.get(dobj.getPrimaryFile()).setNewAnnotations(Collections.<OverriddeAnnotation>emptyList());
90.188 -// final Collection<OverriddeAnnotation> toClear;
90.189 -// synchronized (annotations) {
90.190 -// toClear = new ArrayList<OverriddeAnnotation>(annotations);
90.191 -// annotations.clear();
90.192 -// }
90.193 -// if (!toClear.isEmpty()) {
90.194 -// Runnable r = new Runnable() {
90.195 -// @Override
90.196 -// public void run() {
90.197 -// for (OverriddeAnnotation anno : toClear) {
90.198 -// anno.detachImpl();
90.199 -// }
90.200 -// }
90.201 -// };
90.202 -// if (SwingUtilities.isEventDispatchThread()) {
90.203 -// r.run();
90.204 -// } else {
90.205 -// SwingUtilities.invokeLater(r);
90.206 -// }
90.207 -// }
90.208 - }
90.209 -
90.210 -
90.211 - @Override
90.212 - public boolean isValid() {
90.213 - return true;
90.214 - }
90.215 -
90.216 - @Override
90.217 - public void cancel() {
90.218 - }
90.219 -
90.220 - @Override
90.221 - public boolean isHighPriority() {
90.222 - return false;
90.223 - }
90.224 - }
90.225 -}
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
91.2 +++ b/cnd.navigation/test/unit/data/goldenfiles/org/netbeans/modules/cnd/navigation/overrides/OverrideTestCase/primitive.cc.ref Mon Feb 01 12:24:26 2010 +0100
91.3 @@ -0,0 +1,9 @@
91.4 +4:IS_OVERRIDDEN PrimitiveDescendant::v_func primitive.cc:15
91.5 +5:IS_OVERRIDDEN PrimitiveDescendant::v_inline_func primitive.cc:16
91.6 +7:IS_OVERRIDDEN PrimitiveDescendant::nv_func primitive.cc:18
91.7 +8:IS_OVERRIDDEN PrimitiveDescendant::nv_inline_func primitive.cc:19
91.8 +15:OVERRIDES PrimitiveAncestor::v_func primitive.cc:4
91.9 +16:OVERRIDES PrimitiveAncestor::v_inline_func primitive.cc:5
91.10 +26:IS_OVERRIDDEN PrimitiveDescendant::v_func primitive.cc:15
91.11 +29:IS_OVERRIDDEN PrimitiveDescendant::nv_func primitive.cc:18
91.12 +35:OVERRIDES PrimitiveAncestor::v_func primitive.cc:4
92.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
92.2 +++ b/cnd.navigation/test/unit/data/goldenfiles/org/netbeans/modules/cnd/navigation/overrides/OverrideTestCase/proper_parent_multy.cc.ref Mon Feb 01 12:24:26 2010 +0100
92.3 @@ -0,0 +1,2 @@
92.4 +35:OVERRIDES B1C1::v_foo proper_parent_multy.cc:25
92.5 +65:OVERRIDES B1::v_foo proper_parent_multy.cc:35,B2C2::v_foo proper_parent_multy.cc:42,B2C3::v_foo proper_parent_multy.cc:46
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
93.2 +++ b/cnd.navigation/test/unit/data/goldenfiles/org/netbeans/modules/cnd/navigation/overrides/OverrideTestCase/proper_parent_single.cc.ref Mon Feb 01 12:24:26 2010 +0100
93.3 @@ -0,0 +1,3 @@
93.4 +6:OVERRIDES Base::foo proper_parent_single.cc:2
93.5 +10:OVERRIDES DescA::foo proper_parent_single.cc:6
93.6 +14:OVERRIDES DescB::foo proper_parent_single.cc:10
93.7 \ No newline at end of file
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
94.2 +++ b/cnd.navigation/test/unit/data/org/netbeans/modules/cnd/navigation/overrides/OverrideTestCase/primitive.cc Mon Feb 01 12:24:26 2010 +0100
94.3 @@ -0,0 +1,39 @@
94.4 +struct PrimitiveAncestor {
94.5 + PrimitiveAncestor() {}
94.6 + PrimitiveAncestor(int);
94.7 + virtual void v_func();
94.8 + virtual void v_inline_func() {
94.9 + }
94.10 + void nv_func();
94.11 + void nv_inline_func() {
94.12 + }
94.13 +};
94.14 +
94.15 +class PrimitiveDescendant : PrimitiveAncestor {
94.16 + PrimitiveDescendant() {}
94.17 + PrimitiveDescendant(char);
94.18 + virtual void v_func();
94.19 + virtual void v_inline_func() {
94.20 + }
94.21 + void nv_func();
94.22 + void nv_inline_func() {
94.23 + }
94.24 +};
94.25 +
94.26 +PrimitiveAncestor::PrimitiveAncestor(int) {
94.27 +}
94.28 +
94.29 +void PrimitiveAncestor::v_func() {
94.30 +}
94.31 +
94.32 +void PrimitiveAncestor::nv_func() {
94.33 +}
94.34 +
94.35 +PrimitiveDescendant::PrimitiveDescendant(char) {
94.36 +}
94.37 +
94.38 +void PrimitiveDescendant::v_func() {
94.39 +}
94.40 +
94.41 +void PrimitiveDescendant::nv_func() {
94.42 +}
95.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
95.2 +++ b/cnd.navigation/test/unit/data/org/netbeans/modules/cnd/navigation/overrides/OverrideTestCase/proper_parent_multy.cc Mon Feb 01 12:24:26 2010 +0100
95.3 @@ -0,0 +1,66 @@
95.4 +/*
95.5 +
95.6 +Class hierarchy:
95.7 +
95.8 +Hierarchy v_foo presence
95.9 +--------- --------------
95.10 +A +
95.11 +|
95.12 ++-->B1 +
95.13 +| +-->B1C1 +
95.14 +| +-->B1C2
95.15 +| +-->B1C3
95.16 ++-->B2
95.17 +| +-->B2C1
95.18 +| +-->B2C2 +
95.19 +| +-->B2C3 +
95.20 ++-->B3
95.21 + +-->B3C1
95.22 + +-->B3C2
95.23 + +-->B3C3
95.24 +
95.25 +*/
95.26 +
95.27 +class B1C1 {
95.28 + virtual void v_foo();
95.29 +};
95.30 +
95.31 +class B1C2 {
95.32 +};
95.33 +
95.34 +class B1C3 {
95.35 +};
95.36 +
95.37 +class B1 : B1C1, B1C2, B1C3 {
95.38 + virtual void v_foo();
95.39 +};
95.40 +
95.41 +class B2C1 {
95.42 +};
95.43 +
95.44 +class B2C2 {
95.45 + virtual void v_foo();
95.46 +};
95.47 +
95.48 +class B2C3 {
95.49 + virtual void v_foo();
95.50 +};
95.51 +
95.52 +class B2: B2C1, B2C2, B2C3 {
95.53 +};
95.54 +
95.55 +class B3C1 {
95.56 +};
95.57 +
95.58 +class B3C2 {
95.59 +};
95.60 +
95.61 +class B3C3 {
95.62 +};
95.63 +
95.64 +class B3 : B3C1, B3C2, B3C3 {
95.65 +};
95.66 +
95.67 +class A : B1, B2, B3 {
95.68 + void v_foo();
95.69 +};
96.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
96.2 +++ b/cnd.navigation/test/unit/data/org/netbeans/modules/cnd/navigation/overrides/OverrideTestCase/proper_parent_single.cc Mon Feb 01 12:24:26 2010 +0100
96.3 @@ -0,0 +1,15 @@
96.4 +struct Base {
96.5 + virtual void foo();
96.6 +};
96.7 +
96.8 +struct DescA : protected Base {
96.9 + void foo();
96.10 +};
96.11 +
96.12 +struct DescB : protected DescA {
96.13 + void foo();
96.14 +};
96.15 +
96.16 +struct DescC : protected DescB {
96.17 + void foo();
96.18 +};
97.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
97.2 +++ b/cnd.navigation/test/unit/src/org/netbeans/modules/cnd/navigation/overrides/OverrideTestCase.java Mon Feb 01 12:24:26 2010 +0100
97.3 @@ -0,0 +1,156 @@
97.4 +/*
97.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
97.6 + *
97.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
97.8 + *
97.9 + * The contents of this file are subject to the terms of either the GNU
97.10 + * General Public License Version 2 only ("GPL") or the Common
97.11 + * Development and Distribution License("CDDL") (collectively, the
97.12 + * "License"). You may not use this file except in compliance with the
97.13 + * License. You can obtain a copy of the License at
97.14 + * http://www.netbeans.org/cddl-gplv2.html
97.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
97.16 + * specific language governing permissions and limitations under the
97.17 + * License. When distributing the software, include this License Header
97.18 + * Notice in each file and include the License file at
97.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
97.20 + * particular file as subject to the "Classpath" exception as provided
97.21 + * by Sun in the GPL Version 2 section of the License file that
97.22 + * accompanied this code. If applicable, add the following below the
97.23 + * License Header, with the fields enclosed by brackets [] replaced by
97.24 + * your own identifying information:
97.25 + * "Portions Copyrighted [year] [name of copyright owner]"
97.26 + *
97.27 + * If you wish your version of this file to be governed by only the CDDL
97.28 + * or only the GPL Version 2, indicate your decision by adding
97.29 + * "[Contributor] elects to include this software in this distribution
97.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
97.31 + * single choice of license, a recipient has the option to distribute
97.32 + * your version of this file under either the CDDL, the GPL Version 2 or
97.33 + * to extend the choice of license to its licensees as provided above.
97.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
97.35 + * Version 2 license, then the option applies only if the new code is
97.36 + * made subject to such option by the copyright holder.
97.37 + *
97.38 + * Contributor(s):
97.39 + *
97.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
97.41 + */
97.42 +
97.43 +package org.netbeans.modules.cnd.navigation.overrides;
97.44 +
97.45 +import java.io.File;
97.46 +import java.io.PrintStream;
97.47 +import java.util.ArrayList;
97.48 +import java.util.Collection;
97.49 +import java.util.Collections;
97.50 +import java.util.Comparator;
97.51 +import java.util.List;
97.52 +import java.util.regex.Pattern;
97.53 +import javax.swing.text.StyledDocument;
97.54 +import org.netbeans.modules.cnd.api.model.CsmFile;
97.55 +import org.netbeans.modules.cnd.modelimpl.test.ProjectBasedTestCase;
97.56 +import org.netbeans.modules.cnd.test.CndCoreTestUtils;
97.57 +import org.openide.filesystems.FileObject;
97.58 +import org.openide.filesystems.FileUtil;
97.59 +import org.openide.loaders.DataObject;
97.60 +import org.openide.text.NbDocument;
97.61 +
97.62 +/**
97.63 + *
97.64 + * @author Vladimir Kvashin
97.65 + */
97.66 +public class OverrideTestCase extends ProjectBasedTestCase {
97.67 +
97.68 + public OverrideTestCase(String testName) {
97.69 + super(testName);
97.70 + }
97.71 +
97.72 + public void testPrimitive() throws Exception {
97.73 + performTest("primitive.cc");
97.74 + }
97.75 +
97.76 + public void testProperParentSingle() throws Exception {
97.77 + performTest("proper_parent_single.cc", "\\d*:OVERRIDES .*");
97.78 + }
97.79 +
97.80 + public void testProperParentMulty() throws Exception {
97.81 + performTest("proper_parent_multy.cc", "\\d*:OVERRIDES .*");
97.82 + }
97.83 +
97.84 + private void performTest(String sourceFileName) throws Exception {
97.85 + performTest(sourceFileName, null);
97.86 + }
97.87 +
97.88 + private void performTest(String sourceFileName, String patternString) throws Exception {
97.89 + File testSourceFile = getDataFile(sourceFileName);
97.90 + assertNotNull(testSourceFile);
97.91 + StyledDocument doc = (StyledDocument) getBaseDocument(testSourceFile);
97.92 + assertNotNull(doc);
97.93 + FileObject fo = FileUtil.toFileObject(testSourceFile);
97.94 + assertNotNull(fo);
97.95 + DataObject dao = DataObject.find(fo);
97.96 + assertNotNull(dao);
97.97 + CsmFile csmFile = getCsmFile(testSourceFile);
97.98 + assertNotNull(csmFile);
97.99 + List<OverriddeAnnotation> annotations = new ArrayList<OverriddeAnnotation>();
97.100 + ComputeAnnotations.getInstance().computeAnnotations(csmFile.getDeclarations(), annotations, csmFile, doc, dao);
97.101 + Collections.sort(annotations, new Comparator<OverriddeAnnotation>() {
97.102 + @Override
97.103 + public int compare(OverriddeAnnotation o1, OverriddeAnnotation o2) {
97.104 + return o1.getPosition().getOffset() - o2.getPosition().getOffset();
97.105 + }
97.106 + });
97.107 +
97.108 + String goldenFileName = sourceFileName + ".ref";
97.109 + File workDir = getWorkDir();
97.110 + File output = new File(workDir, goldenFileName); //NOI18N
97.111 + PrintStream streamOut = new PrintStream(output);
97.112 + dumpAnnotations(annotations, doc, streamOut, patternString);
97.113 + streamOut.close();
97.114 +
97.115 + File goldenDataFile = getGoldenFile(goldenFileName);
97.116 + if (!goldenDataFile.exists()) {
97.117 + fail("No golden file " + goldenDataFile.getAbsolutePath() + "\n to check with output file " + output.getAbsolutePath());
97.118 + }
97.119 + if (CndCoreTestUtils.diff(output, goldenDataFile, null)) {
97.120 + System.err.printf("---------- Annotations dump for failed %s.%s ----------\n", getClass().getSimpleName(), getName());
97.121 + dumpAnnotations(annotations, doc, System.err, patternString);
97.122 + System.err.println();
97.123 + // copy golden
97.124 + File goldenCopyFile = new File(workDir, goldenFileName + ".golden");
97.125 + CndCoreTestUtils.copyToWorkDir(goldenDataFile, goldenCopyFile); // NOI18N
97.126 + fail("OUTPUT Difference between diff " + output + " " + goldenCopyFile); // NOI18N
97.127 + }
97.128 + }
97.129 +
97.130 + private void dumpAnnotations(Collection<OverriddeAnnotation> annotations, StyledDocument doc, PrintStream ps, String patternString) {
97.131 + Pattern pattern = (patternString == null) ? null : Pattern.compile(patternString);
97.132 + for (OverriddeAnnotation anno : annotations) {
97.133 + StringBuilder sb = new StringBuilder();
97.134 + int line = NbDocument.findLineNumber(doc, anno.getPosition().getOffset()) + 1; // convert to 1-based
97.135 + sb.append(line);
97.136 + sb.append(':');
97.137 + sb.append(anno.getType());
97.138 + sb.append(' ');
97.139 + boolean first = true;
97.140 + for (OverriddeAnnotation.Element element : anno.getElements()) {
97.141 + int gotoLine = element.method.getStartPosition().getLine();
97.142 + String gotoFile = element.method.getContainingFile().getName().toString();
97.143 + if (first) {
97.144 + first = false;
97.145 + } else {
97.146 + sb.append(',');
97.147 + }
97.148 + sb.append(element.method.getQualifiedName());
97.149 + sb.append(' ');
97.150 + sb.append(gotoFile);
97.151 + sb.append(':');
97.152 + sb.append(gotoLine);
97.153 + }
97.154 + if (pattern == null || pattern.matcher(sb).matches()) {
97.155 + ps.printf("%s\n", sb);
97.156 + }
97.157 + }
97.158 + }
97.159 +}
98.1 --- a/cnd.refactoring/src/org/netbeans/modules/cnd/refactoring/ui/WhereUsedPanel.java Mon Feb 01 12:23:06 2010 +0100
98.2 +++ b/cnd.refactoring/src/org/netbeans/modules/cnd/refactoring/ui/WhereUsedPanel.java Mon Feb 01 12:24:26 2010 +0100
98.3 @@ -238,7 +238,7 @@
98.4 labelText = getString("DSC_MethodUsages", functionDisplayName, displayClassName); // NOI18N
98.5 CsmVirtualInfoQuery query = CsmVirtualInfoQuery.getDefault();
98.6 if (query.isVirtual(method)) {
98.7 - Collection<CsmMethod> baseMethods = query.getBaseDeclaration(method);
98.8 + Collection<CsmMethod> baseMethods = query.getTopmostBaseDeclarations(method);
98.9 // use only the first for now
98.10 baseVirtualMethod = baseMethods.isEmpty() ? null : baseMethods.iterator().next();
98.11 assert baseVirtualMethod != null : "virtual method must have start virtual declaration";
99.1 --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/compilers/CompilerSetScriptManager.java Mon Feb 01 12:23:06 2010 +0100
99.2 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/compilers/CompilerSetScriptManager.java Mon Feb 01 12:24:26 2010 +0100
99.3 @@ -42,9 +42,9 @@
99.4 import java.util.ArrayList;
99.5 import java.util.List;
99.6 import java.util.logging.Level;
99.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
99.8 import org.netbeans.modules.cnd.remote.support.RemoteConnectionSupport;
99.9 import org.netbeans.modules.cnd.remote.support.RemoteUtil;
99.10 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainScriptGenerator;
99.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
99.12 import org.netbeans.modules.nativeexecution.api.HostInfo;
99.13 import org.netbeans.modules.nativeexecution.api.NativeProcessBuilder;
99.14 @@ -77,7 +77,7 @@
99.15 HostInfo hinfo = HostInfoUtils.getHostInfo(executionEnvironment);
99.16 pb.setExecutable(hinfo.getShell()).setArguments("-s"); // NOI18N
99.17 Process process = pb.call();
99.18 - process.getOutputStream().write(CompilerSetManager.getRemoteScript(null).getBytes());
99.19 + process.getOutputStream().write(ToolchainScriptGenerator.generateScript(null).getBytes());
99.20 process.getOutputStream().close();
99.21
99.22 List<String> lines = ProcessUtils.readProcessOutput(process);
99.23 @@ -90,24 +90,24 @@
99.24 }
99.25
99.26 if (status != 0) {
99.27 - RemoteUtil.LOGGER.warning("CSSM.runScript: FAILURE "+status); // NOI18N
99.28 + RemoteUtil.LOGGER.log(Level.WARNING, "CSSM.runScript: FAILURE {0}", status); // NOI18N
99.29 ProcessUtils.logError(Level.ALL, RemoteUtil.LOGGER, process);
99.30 } else {
99.31 int i = 0;
99.32 for (String s: lines) {
99.33 - RemoteUtil.LOGGER.fine("CSSM.runScript line: " + s); // NOI18N
99.34 + RemoteUtil.LOGGER.log(Level.FINE, "CSSM.runScript line: {0}", s); // NOI18N
99.35 if (i == 0) {
99.36 platform = s;
99.37 - RemoteUtil.LOGGER.fine(" platform [" + platform + "]"); // NOI18N
99.38 + RemoteUtil.LOGGER.log(Level.FINE, " platform [{0}]", platform); // NOI18N
99.39 } else {
99.40 - RemoteUtil.LOGGER.fine(" line [" + s + "]"); // NOI18N
99.41 + RemoteUtil.LOGGER.log(Level.FINE, " line [{0}]", s); // NOI18N
99.42 compilerSets.add(s);
99.43 }
99.44 i++;
99.45 }
99.46 }
99.47 } catch (IOException ex) {
99.48 - RemoteUtil.LOGGER.warning("CSSM.runScript: IOException [" + ex.getMessage() + "]"); // NOI18N
99.49 + RemoteUtil.LOGGER.log(Level.WARNING, "CSSM.runScript: IOException [{0}]", ex.getMessage()); // NOI18N
99.50 setFailed(ex.getMessage());
99.51 }
99.52 }
100.1 --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/compilers/RemoteCompilerSetProvider.java Mon Feb 01 12:23:06 2010 +0100
100.2 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/compilers/RemoteCompilerSetProvider.java Mon Feb 01 12:24:26 2010 +0100
100.3 @@ -43,10 +43,10 @@
100.4 import java.util.List;
100.5 import java.util.logging.Level;
100.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
100.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
100.8 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetProvider;
100.9 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProvider;
100.10 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
100.11 import org.netbeans.modules.cnd.remote.support.RemoteUtil;
100.12 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainScriptGenerator;
100.13 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
100.14 import org.netbeans.modules.nativeexecution.api.HostInfo;
100.15 import org.netbeans.modules.nativeexecution.api.NativeProcessBuilder;
100.16 @@ -75,6 +75,7 @@
100.17 manager.runScript();
100.18 }
100.19
100.20 + @Override
100.21 public int getPlatform() {
100.22 String platform = manager.getPlatform();
100.23 if (platform == null || platform.length() == 0) {
100.24 @@ -98,20 +99,25 @@
100.25 }
100.26 }
100.27
100.28 + @Override
100.29 public boolean hasMoreCompilerSets() {
100.30 return manager.hasMoreCompilerSets();
100.31 }
100.32
100.33 + @Override
100.34 public String getNextCompilerSetData() {
100.35 return manager.getNextCompilerSetData();
100.36 }
100.37
100.38 + @Override
100.39 public Runnable createCompilerSetDataLoader(List<CompilerSet> sets) {
100.40 return new Runnable() {
100.41 + @Override
100.42 public void run() {}
100.43 };
100.44 }
100.45
100.46 + @Override
100.47 public String[] getCompilerSetData(String path) {
100.48 //RemoteCommandSupport rcs = new RemoteCommandSupport(env,
100.49 // CompilerSetManager.getRemoteScriptFile() + " " + path); //NOI18N
100.50 @@ -124,7 +130,7 @@
100.51 HostInfo hinfo = HostInfoUtils.getHostInfo(env);
100.52 pb.setExecutable(hinfo.getShell()).setArguments("-s"); // NOI18N
100.53 Process process = pb.call();
100.54 - process.getOutputStream().write(CompilerSetManager.getRemoteScript(path).getBytes());
100.55 + process.getOutputStream().write(ToolchainScriptGenerator.generateScript(path).getBytes());
100.56 process.getOutputStream().close();
100.57
100.58 List<String> lines = ProcessUtils.readProcessOutput(process);
100.59 @@ -137,13 +143,13 @@
100.60 }
100.61
100.62 if (status != 0) {
100.63 - RemoteUtil.LOGGER.warning("CSSM.runScript: FAILURE "+status); // NOI18N
100.64 + RemoteUtil.LOGGER.log(Level.WARNING, "CSSM.runScript: FAILURE {0}", status); // NOI18N
100.65 ProcessUtils.logError(Level.ALL, RemoteUtil.LOGGER, process);
100.66 } else {
100.67 return lines.toArray(new String[lines.size()]);
100.68 }
100.69 } catch (IOException ex) {
100.70 - RemoteUtil.LOGGER.warning("CSSM.runScript: IOException [" + ex.getMessage() + "]"); // NOI18N
100.71 + RemoteUtil.LOGGER.log(Level.WARNING, "CSSM.runScript: IOException [{0}]", ex.getMessage()); // NOI18N
100.72 }
100.73 return null;
100.74 }
101.1 --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/compilers/RemoteCompilerSetProviderFactory.java Mon Feb 01 12:23:06 2010 +0100
101.2 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/compilers/RemoteCompilerSetProviderFactory.java Mon Feb 01 12:24:26 2010 +0100
101.3 @@ -39,16 +39,16 @@
101.4
101.5 package org.netbeans.modules.cnd.remote.compilers;
101.6
101.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetProvider;
101.8 -import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProviderFactoryImpl;
101.9 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProvider;
101.10 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProviderFactory;
101.11 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
101.12
101.13 /**
101.14 * CompilerSetProviderFactory implementation
101.15 * @author Vladimir Kvashin
101.16 */
101.17 -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.cnd.toolchain.spi.CompilerSetProviderFactoryImpl.class)
101.18 -public class RemoteCompilerSetProviderFactory implements CompilerSetProviderFactoryImpl {
101.19 +@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.cnd.toolchain.spi.CompilerSetProviderFactory.class)
101.20 +public class RemoteCompilerSetProviderFactory implements CompilerSetProviderFactory {
101.21
101.22 @Override
101.23 public CompilerSetProvider createNew(ExecutionEnvironment execEnv) {
102.1 --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerListUI.java Mon Feb 01 12:23:06 2010 +0100
102.2 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerListUI.java Mon Feb 01 12:24:26 2010 +0100
102.3 @@ -82,7 +82,7 @@
102.4 protected boolean showServerListDialogImpl(AtomicReference<ExecutionEnvironment> selectedEnv) {
102.5 ToolsCacheManager cacheManager = new ToolsCacheManager();
102.6 for (ServerRecord record : ServerList.getRecords()) {
102.7 - CompilerSetManager csm = CompilerSetManager.getDefault(record.getExecutionEnvironment());
102.8 + CompilerSetManager csm = CompilerSetManager.get(record.getExecutionEnvironment());
102.9 cacheManager.addCompilerSetManager(csm);
102.10 }
102.11 if (showServerListDialog(cacheManager, selectedEnv)) {
103.1 --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/EditServerListDialog.java Mon Feb 01 12:23:06 2010 +0100
103.2 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/EditServerListDialog.java Mon Feb 01 12:24:26 2010 +0100
103.3 @@ -205,7 +205,7 @@
103.4 record.init(pcs);
103.5 if (record.isOnline()) {
103.6 CompilerSetManager csm = cacheManager.getCompilerSetManagerCopy(record.getExecutionEnvironment(), false);
103.7 - csm.initialize(false, true);
103.8 + csm.initialize(false, true, null);
103.9 }
103.10 phandle.finish();
103.11 // back to EDT to work with Swing
104.1 --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/CreateHostVisualPanel3.java Mon Feb 01 12:23:06 2010 +0100
104.2 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/CreateHostVisualPanel3.java Mon Feb 01 12:24:26 2010 +0100
104.3 @@ -93,7 +93,7 @@
104.4 });
104.5 boolean selected = false;
104.6 for(CompilerSet cs : compilerSetManager.getCompilerSets()) {
104.7 - if (cs.isDefault()) {
104.8 + if (compilerSetManager.isDefaultCompilerSet(cs)) {
104.9 cbDefaultToolchain.setSelectedItem(cs);
104.10 selected = true;
104.11 break;
104.12 @@ -103,6 +103,7 @@
104.13 cbDefaultToolchain.setSelectedItem(0);
104.14 }
104.15 cbDefaultToolchain.addItemListener(new ItemListener() {
104.16 + @Override
104.17 public void itemStateChanged(ItemEvent e) {
104.18 compilerSetManager.setDefault((CompilerSet) cbDefaultToolchain.getSelectedItem());
104.19 }
105.1 --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/HostValidatorImpl.java Mon Feb 01 12:23:06 2010 +0100
105.2 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/HostValidatorImpl.java Mon Feb 01 12:24:26 2010 +0100
105.3 @@ -44,7 +44,6 @@
105.4 import java.io.Writer;
105.5 import java.util.concurrent.CancellationException;
105.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
105.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetReporter;
105.8 import org.netbeans.modules.cnd.api.remote.ServerList;
105.9 import org.netbeans.modules.cnd.remote.server.RemoteServerRecord;
105.10 import org.netbeans.modules.cnd.remote.support.RemoteCommandSupport;
105.11 @@ -113,7 +112,7 @@
105.12 record.init(null);
105.13 }
105.14 if (record.isOnline()) {
105.15 - CompilerSetReporter.setWriter(new Writer() {
105.16 + Writer reporter = new Writer() {
105.17
105.18 @Override
105.19 public void write(char[] cbuf, int off, int len) throws IOException {
105.20 @@ -128,9 +127,9 @@
105.21 @Override
105.22 public void close() throws IOException {
105.23 }
105.24 - });
105.25 + };
105.26 final CompilerSetManager csm = cacheManager.getCompilerSetManagerCopy(env, false);
105.27 - csm.initialize(false, false);
105.28 + csm.initialize(false, false, reporter);
105.29 runOnFinish = new Runnable() {
105.30 @Override
105.31 public void run() {
105.32 @@ -142,7 +141,6 @@
105.33 writer.write(NbBundle.getMessage(getClass(), "CreateHostVisualPanel2.ErrConn")
105.34 + '\n' + record.getReason()); //NOI18N
105.35 }
105.36 - CompilerSetReporter.setWriter(null);
105.37 if (alreadyOnline) {
105.38 writer.write('\n' + NbBundle.getMessage(getClass(), "CreateHostVisualPanel2.MsgAlreadyConnected2"));
105.39 }
106.1 --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/fs/RemoteFileSystemTest.java Mon Feb 01 12:23:06 2010 +0100
106.2 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/fs/RemoteFileSystemTest.java Mon Feb 01 12:24:26 2010 +0100
106.3 @@ -189,8 +189,8 @@
106.4 if (i == 0) {
106.5 firstTime = time;
106.6 } else if (time > 0) {
106.7 - assertTrue("Getting input stream for "+ getFileName(execEnv, absPath) + " took to long (" + time + ") ms",
106.8 - time < firstTime / 10);
106.9 + assertTrue("Getting input stream for "+ getFileName(execEnv, absPath) + " took too long (" + time + ") ms",
106.10 + time < firstTime / 8);
106.11 }
106.12 }
106.13 }
107.1 --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/project/RemoteBuildMakefileTest.java Mon Feb 01 12:23:06 2010 +0100
107.2 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/project/RemoteBuildMakefileTest.java Mon Feb 01 12:24:26 2010 +0100
107.3 @@ -45,9 +45,9 @@
107.4 import org.netbeans.modules.cnd.remote.RemoteDevelopmentTestSuite;
107.5 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
107.6 import org.netbeans.api.project.ProjectManager;
107.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
107.8 import org.netbeans.modules.cnd.api.remote.ServerList;
107.9 import org.netbeans.modules.cnd.makeproject.MakeProject;
107.10 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
107.11 import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
107.12 import org.netbeans.modules.nativeexecution.test.ForAllEnvironments;
107.13 import org.openide.filesystems.FileObject;
107.14 @@ -82,7 +82,7 @@
107.15
107.16 setDefaultCompilerSet(toolchain.ID);
107.17 assertEquals("Wrong tools collection", toolchain.ID,
107.18 - CompilerSetManager.getDefault(execEnv).getDefaultCompilerSet().getName());
107.19 + CompilerSetManager.get(execEnv).getDefaultCompilerSet().getName());
107.20
107.21 assertTrue(projectDirFile.exists());
107.22
108.1 --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/project/RemoteBuildSamplesTest.java Mon Feb 01 12:23:06 2010 +0100
108.2 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/project/RemoteBuildSamplesTest.java Mon Feb 01 12:24:26 2010 +0100
108.3 @@ -45,9 +45,9 @@
108.4 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
108.5 import org.openide.filesystems.FileObject;
108.6 import org.netbeans.api.project.ProjectManager;
108.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
108.8 import org.netbeans.modules.cnd.api.remote.ServerList;
108.9 import org.netbeans.modules.cnd.makeproject.MakeProject;
108.10 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
108.11 import org.netbeans.modules.nativeexecution.test.ForAllEnvironments;
108.12 /**
108.13 *
108.14 @@ -73,7 +73,7 @@
108.15
108.16 setDefaultCompilerSet(toolchain.ID);
108.17 assertEquals("Wrong tools collection", toolchain.ID,
108.18 - CompilerSetManager.getDefault(getTestExecutionEnvironment()).getDefaultCompilerSet().getName());
108.19 + CompilerSetManager.get(getTestExecutionEnvironment()).getDefaultCompilerSet().getName());
108.20
108.21 clearRemoteSyncRoot();
108.22 FileObject projectDirFO = prepareSampleProject(projectName, "Args_01");
109.1 --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/project/RemoteBuildTestBase.java Mon Feb 01 12:23:06 2010 +0100
109.2 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/project/RemoteBuildTestBase.java Mon Feb 01 12:24:26 2010 +0100
109.3 @@ -198,7 +198,7 @@
109.4 ExecutionEnvironment execEnv = getTestExecutionEnvironment();
109.5 ServerRecord record = ServerList.get(execEnv);
109.6 assertNotNull(record);
109.7 - final CompilerSetManager csm = CompilerSetManager.getDefault(execEnv);
109.8 + final CompilerSetManager csm = CompilerSetManager.get(execEnv);
109.9 for (CompilerSet cset : csm.getCompilerSets()) {
109.10 if (cset.getName().equals(name)) {
109.11 csm.setDefault(cset);
110.1 --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/support/RemoteTestBase.java Mon Feb 01 12:23:06 2010 +0100
110.2 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/support/RemoteTestBase.java Mon Feb 01 12:24:26 2010 +0100
110.3 @@ -43,9 +43,6 @@
110.4 import java.io.IOException;
110.5 import java.io.PrintWriter;
110.6 import java.text.ParseException;
110.7 -import java.util.ArrayList;
110.8 -import java.util.Collections;
110.9 -import java.util.List;
110.10 import java.util.concurrent.CountDownLatch;
110.11 import java.util.concurrent.TimeUnit;
110.12 import java.util.concurrent.atomic.AtomicInteger;
110.13 @@ -53,15 +50,9 @@
110.14 import java.util.logging.Level;
110.15 import java.util.logging.LogRecord;
110.16 import java.util.logging.Logger;
110.17 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
110.18 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
110.19 -import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
110.20 -import org.netbeans.modules.cnd.toolchain.api.Tool;
110.21 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
110.22 import org.netbeans.modules.cnd.makeproject.MakeActionProvider;
110.23 import org.netbeans.modules.cnd.makeproject.MakeProject;
110.24 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
110.25 -import org.netbeans.modules.cnd.makeproject.api.compilers.BasicCompiler;
110.26 import org.netbeans.modules.cnd.remote.RemoteDevelopmentTestSuite;
110.27 import org.netbeans.modules.cnd.remote.mapper.RemotePathMap;
110.28 import org.netbeans.modules.cnd.remote.ui.wizard.HostValidatorImpl;
110.29 @@ -323,41 +314,4 @@
110.30 System.setProperty(varName, value);
110.31 }
110.32 }
110.33 -
110.34 - public static class FakeCompilerSet extends CompilerSet {
110.35 -
110.36 - private List<Tool> tools = Collections.<Tool>singletonList(new FakeTool());
110.37 -
110.38 - public FakeCompilerSet() {
110.39 - super(PlatformTypes.getDefaultPlatform());
110.40 - }
110.41 -
110.42 - @Override
110.43 - public List<Tool> getTools() {
110.44 - return tools;
110.45 - }
110.46 -
110.47 - private static class FakeTool extends BasicCompiler {
110.48 -
110.49 - private List<String> fakeIncludes = new ArrayList<String>();
110.50 -
110.51 - private FakeTool() {
110.52 - super(ExecutionEnvironmentFactory.fromUniqueID("fake"), CompilerFlavor.getUnknown(PlatformTypes.getDefaultPlatform()), 0, "fakeTool", "fakeTool", "/usr/sfw/bin");
110.53 - fakeIncludes.add("/usr/include"); //NOI18N
110.54 - fakeIncludes.add("/usr/local/include"); //NOI18N
110.55 - fakeIncludes.add("/usr/sfw/include"); //NOI18N
110.56 - //fakeIncludes.add("/usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/include");
110.57 - }
110.58 -
110.59 - @Override
110.60 - public List<String> getSystemIncludeDirectories() {
110.61 - return fakeIncludes;
110.62 - }
110.63 -
110.64 - @Override
110.65 - public CompilerDescriptor getDescriptor() {
110.66 - return null;
110.67 - }
110.68 - }
110.69 - }
110.70 }
111.1 --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/ui/wizard/HostSetupTest.java Mon Feb 01 12:23:06 2010 +0100
111.2 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/ui/wizard/HostSetupTest.java Mon Feb 01 12:24:26 2010 +0100
111.3 @@ -65,7 +65,7 @@
111.4 public void testHostSetup() throws Exception {
111.5 ExecutionEnvironment execEnv = getTestExecutionEnvironment();
111.6 setupHost(execEnv);
111.7 - CompilerSetManager csm = CompilerSetManager.getDefault(execEnv);
111.8 + CompilerSetManager csm = CompilerSetManager.get(execEnv);
111.9 final List<CompilerSet> compilerSets = csm.getCompilerSets();
111.10 dumpCompilerSets(execEnv, compilerSets);
111.11
112.1 --- a/cnd.script/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
112.2 +++ b/cnd.script/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
112.3 @@ -77,6 +77,15 @@
112.4 </run-dependency>
112.5 </dependency>
112.6 <dependency>
112.7 + <code-name-base>org.netbeans.spi.navigator</code-name-base>
112.8 + <build-prerequisite/>
112.9 + <compile-dependency/>
112.10 + <run-dependency>
112.11 + <release-version>1</release-version>
112.12 + <specification-version>1.12</specification-version>
112.13 + </run-dependency>
112.14 + </dependency>
112.15 + <dependency>
112.16 <code-name-base>org.openide.actions</code-name-base>
112.17 <build-prerequisite/>
112.18 <compile-dependency/>
112.19 @@ -101,6 +110,14 @@
112.20 </run-dependency>
112.21 </dependency>
112.22 <dependency>
112.23 + <code-name-base>org.openide.explorer</code-name-base>
112.24 + <build-prerequisite/>
112.25 + <compile-dependency/>
112.26 + <run-dependency>
112.27 + <specification-version>6.26</specification-version>
112.28 + </run-dependency>
112.29 + </dependency>
112.30 + <dependency>
112.31 <code-name-base>org.openide.filesystems</code-name-base>
112.32 <build-prerequisite/>
112.33 <compile-dependency/>
112.34 @@ -182,6 +199,11 @@
112.35 <test/>
112.36 </test-dependency>
112.37 <test-dependency>
112.38 + <code-name-base>org.netbeans.modules.lexer.nbbridge</code-name-base>
112.39 + <recursive/>
112.40 + <compile-dependency/>
112.41 + </test-dependency>
112.42 + <test-dependency>
112.43 <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
112.44 <recursive/>
112.45 <compile-dependency/>
113.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/editor/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
113.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/editor/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
113.3 @@ -44,3 +44,4 @@
113.4 whitespace=Whitespace
113.5 tab=Tab
113.6 shell=Shell Command
113.7 +shell_modifier=Shell Command Modifier
114.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/lexer/MakefileLexer.java Mon Feb 01 12:23:06 2010 +0100
114.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/lexer/MakefileLexer.java Mon Feb 01 12:24:26 2010 +0100
114.3 @@ -87,9 +87,11 @@
114.4 "endif")); // NOI18N
114.5
114.6 private static enum State {
114.7 - NORMAL,
114.8 AT_LINE_START,
114.9 - AFTER_TAB
114.10 + AFTER_LINE_START,
114.11 + AFTER_TAB_OR_SEMICOLON,
114.12 + AFTER_EQUALS,
114.13 + AFTER_COLON
114.14 }
114.15
114.16 private final LexerRestartInfo<MakefileTokenId> info;
114.17 @@ -105,58 +107,123 @@
114.18 Token<MakefileTokenId> token;
114.19 switch (state) {
114.20
114.21 - case NORMAL:
114.22 - token = readToken(false);
114.23 - if (token != null) {
114.24 - switch (token.id()) {
114.25 - case NEW_LINE:
114.26 - state = State.AT_LINE_START;
114.27 - break;
114.28 - }
114.29 - }
114.30 - break;
114.31 -
114.32 case AT_LINE_START:
114.33 - token = readToken(true);
114.34 + token = readToken(true, true, true, false);
114.35 if (token != null) {
114.36 switch (token.id()) {
114.37 case NEW_LINE:
114.38 // remain in AT_LINE_START state
114.39 break;
114.40 case TAB:
114.41 - state = State.AFTER_TAB;
114.42 + state = State.AFTER_TAB_OR_SEMICOLON;
114.43 break;
114.44 + case EQUALS:
114.45 + case COLON_EQUALS:
114.46 + case PLUS_EQUALS:
114.47 + state = State.AFTER_EQUALS;
114.48 + break;
114.49 + case COLON:
114.50 + state = State.AFTER_COLON;
114.51 + break;
114.52 + case SEMICOLON:
114.53 + throw new IllegalStateException("Internal error"); // NOI18N
114.54 default:
114.55 - state = State.NORMAL;
114.56 + state = State.AFTER_LINE_START;
114.57 }
114.58 }
114.59 break;
114.60
114.61 - case AFTER_TAB:
114.62 - token = readShell();
114.63 + case AFTER_LINE_START:
114.64 + token = readToken(false, true, true, false);
114.65 + if (token != null) {
114.66 + switch (token.id()) {
114.67 + case NEW_LINE:
114.68 + state = State.AT_LINE_START;
114.69 + break;
114.70 + case EQUALS:
114.71 + case COLON_EQUALS:
114.72 + case PLUS_EQUALS:
114.73 + state = State.AFTER_EQUALS;
114.74 + break;
114.75 + case COLON:
114.76 + state = State.AFTER_COLON;
114.77 + break;
114.78 + case TAB:
114.79 + case SEMICOLON:
114.80 + throw new IllegalStateException("Internal error"); // NOI18N
114.81 + default:
114.82 + // remain in AFTER_LINE_START state
114.83 + }
114.84 + }
114.85 + break;
114.86 +
114.87 + case AFTER_TAB_OR_SEMICOLON:
114.88 + token = readWhitespaceOrModifierOrShell();
114.89 if (token == null) {
114.90 - token = readToken(false);
114.91 + token = readToken(false, false, false, false);
114.92 if (token != null) {
114.93 switch (token.id()) {
114.94 case NEW_LINE:
114.95 state = State.AT_LINE_START;
114.96 break;
114.97 default:
114.98 - state = State.NORMAL;
114.99 + throw new IllegalStateException("Internal error"); // NOI18N
114.100 }
114.101 }
114.102 }
114.103 break;
114.104
114.105 + case AFTER_EQUALS:
114.106 + token = readToken(false, false, false, false);
114.107 + if (token != null) {
114.108 + switch (token.id()) {
114.109 + case NEW_LINE:
114.110 + state = State.AT_LINE_START;
114.111 + break;
114.112 + case TAB:
114.113 + case COLON:
114.114 + case EQUALS:
114.115 + case COLON_EQUALS:
114.116 + case PLUS_EQUALS:
114.117 + case SEMICOLON:
114.118 + throw new IllegalStateException("Internal error"); // NOI18N
114.119 + default:
114.120 + // remain in AFTER_EQUALS state
114.121 + }
114.122 + }
114.123 + break;
114.124 +
114.125 + case AFTER_COLON:
114.126 + token = readToken(false, false, false, true);
114.127 + if (token != null) {
114.128 + switch (token.id()) {
114.129 + case NEW_LINE:
114.130 + state = State.AT_LINE_START;
114.131 + break;
114.132 + case SEMICOLON:
114.133 + state = State.AFTER_TAB_OR_SEMICOLON;
114.134 + break;
114.135 + case TAB:
114.136 + case COLON:
114.137 + case EQUALS:
114.138 + case COLON_EQUALS:
114.139 + case PLUS_EQUALS:
114.140 + throw new IllegalStateException("Internal error"); // NOI18N
114.141 + default:
114.142 + // remain in AFTER_EQUALS state
114.143 + }
114.144 + }
114.145 + break;
114.146 +
114.147 default:
114.148 - throw new IllegalStateException("Internal lexer error"); // NOI18N
114.149 + throw new IllegalStateException("Internal error"); // NOI18N
114.150 }
114.151 return token;
114.152 }
114.153
114.154 @Override
114.155 public Object state() {
114.156 - return state == State.AT_LINE_START? null : state.ordinal();
114.157 + return state == State.AT_LINE_START ? null : state.ordinal();
114.158 }
114.159
114.160 @Override
114.161 @@ -164,14 +231,17 @@
114.162 }
114.163
114.164
114.165 - private Token<MakefileTokenId> readToken(boolean atLineStart) {
114.166 + private Token<MakefileTokenId> readToken(boolean wantTab, boolean wantColon, boolean wantEquals, boolean wantSemicolon) {
114.167 LexerInput input = info.input();
114.168 TokenFactory<MakefileTokenId> factory = info.tokenFactory();
114.169
114.170 switch (input.read()) {
114.171
114.172 - case '\t': // tab has special meaning only at line start
114.173 - if (atLineStart) {
114.174 + case LexerInput.EOF:
114.175 + return null;
114.176 +
114.177 + case '\t':
114.178 + if (wantTab) {
114.179 return factory.createToken(MakefileTokenId.TAB);
114.180 } else {
114.181 consumeWhitespace(input);
114.182 @@ -183,7 +253,7 @@
114.183 return factory.createToken(MakefileTokenId.WHITESPACE);
114.184
114.185 case '#':
114.186 - consumeAnythingTillEndOfLine(input, false);
114.187 + consumeAnythingTillEndOfLine(input);
114.188 return factory.createToken(MakefileTokenId.COMMENT);
114.189
114.190 case '\r':
114.191 @@ -197,52 +267,181 @@
114.192 return readMacro(input, factory);
114.193
114.194 case ':':
114.195 - if (input.read() != '=') {
114.196 + if (input.read() == '=' && wantEquals) {
114.197 + return factory.createToken(MakefileTokenId.COLON_EQUALS);
114.198 + } else if (wantColon) {
114.199 input.backup(1);
114.200 + return factory.createToken(MakefileTokenId.COLON);
114.201 + } else {
114.202 + consumeBare(input, wantColon, wantEquals, wantSemicolon);
114.203 + return factory.createToken(MakefileTokenId.BARE);
114.204 }
114.205 - return factory.createToken(MakefileTokenId.SEPARATOR);
114.206 +
114.207 + case '+':
114.208 + if (input.read() == '=' && wantEquals) {
114.209 + return factory.createToken(MakefileTokenId.PLUS_EQUALS);
114.210 + } else {
114.211 + input.backup(1);
114.212 + consumeBare(input, wantColon, wantEquals, wantSemicolon);
114.213 + return factory.createToken(MakefileTokenId.BARE);
114.214 + }
114.215
114.216 case '=':
114.217 - return factory.createToken(MakefileTokenId.SEPARATOR);
114.218 + if (wantEquals) {
114.219 + return factory.createToken(MakefileTokenId.EQUALS);
114.220 + } else {
114.221 + consumeBare(input, wantColon, wantEquals, wantSemicolon);
114.222 + return factory.createToken(MakefileTokenId.BARE);
114.223 + }
114.224
114.225 - case LexerInput.EOF:
114.226 - return null;
114.227 + case ';':
114.228 + if (wantSemicolon) {
114.229 + return factory.createToken(MakefileTokenId.SEMICOLON);
114.230 + } else {
114.231 + consumeBare(input, wantColon, wantEquals, wantSemicolon);
114.232 + return factory.createToken(MakefileTokenId.BARE);
114.233 + }
114.234 +
114.235 + case '\\':
114.236 + if (0 < consumeNewline(input)) {
114.237 + return factory.createToken(MakefileTokenId.ESCAPED_NEW_LINE);
114.238 + } else {
114.239 + consumeEscape(input);
114.240 + consumeBare(input, wantColon, wantEquals, wantSemicolon);
114.241 + return factory.createToken(MakefileTokenId.BARE);
114.242 + }
114.243
114.244 default:
114.245 - input.backup(1);
114.246 - return readOther(input, factory);
114.247 + consumeBare(input, wantColon, wantEquals, wantSemicolon);
114.248 + return createBareOrKeyword(input.readText().toString(), factory);
114.249 }
114.250 }
114.251
114.252 - private Token<MakefileTokenId> readShell() {
114.253 - LexerInput input = info.input();
114.254 - if (consumeAnythingTillEndOfLine(input, true)) {
114.255 - return info.tokenFactory().createToken(MakefileTokenId.SHELL);
114.256 - } else {
114.257 - return null;
114.258 - }
114.259 - }
114.260 -
114.261 - private static void consumeWhitespace(LexerInput input) {
114.262 + private void consumeBare(LexerInput input, boolean wantColon, boolean wantEquals, boolean wantSemicolon) {
114.263 for (;;) {
114.264 switch (input.read()) {
114.265 + case ' ':
114.266 case '\t':
114.267 - case ' ':
114.268 - // proceed
114.269 + input.backup(1);
114.270 + return;
114.271 +
114.272 + case ':':
114.273 + if (wantColon) {
114.274 + input.backup(1);
114.275 + return;
114.276 + } else if (wantEquals && input.read() == '=') {
114.277 + input.backup(2);
114.278 + return;
114.279 + }
114.280 break;
114.281 - default:
114.282 +
114.283 + case '+':
114.284 + if (wantEquals && input.read() == '=') {
114.285 + input.backup(2);
114.286 + return;
114.287 + }
114.288 + break;
114.289 +
114.290 + case '=':
114.291 + if (wantEquals) {
114.292 + input.backup(1);
114.293 + return;
114.294 + }
114.295 + break;
114.296 +
114.297 + case ';':
114.298 + if (wantSemicolon) {
114.299 + input.backup(1);
114.300 + return;
114.301 + }
114.302 + break;
114.303 +
114.304 + case '\\':
114.305 + int consumed = consumeNewline(input);
114.306 + if (0 < consumed) {
114.307 + input.backup(1 + consumed);
114.308 + return;
114.309 + } else {
114.310 + consumeEscape(input);
114.311 + }
114.312 + break;
114.313 +
114.314 + case LexerInput.EOF:
114.315 + case '\r':
114.316 + case '\n':
114.317 + case '#':
114.318 + case '$':
114.319 input.backup(1);
114.320 return;
114.321 }
114.322 }
114.323 }
114.324
114.325 + private Token<MakefileTokenId> readWhitespaceOrModifierOrShell() {
114.326 + LexerInput input = info.input();
114.327 + TokenFactory<MakefileTokenId> factory = info.tokenFactory();
114.328 +
114.329 + switch (input.read()) {
114.330 + case '@':
114.331 + case '-':
114.332 + case '+':
114.333 + return factory.createToken(MakefileTokenId.SHELL_MODIFIER);
114.334 + case ' ':
114.335 + case '\t':
114.336 + consumeWhitespace(input);
114.337 + return factory.createToken(MakefileTokenId.WHITESPACE);
114.338 + default:
114.339 + input.backup(1);
114.340 + }
114.341 +
114.342 + if (consumeAnythingTillEndOfLine(input)) {
114.343 + return factory.createToken(MakefileTokenId.SHELL);
114.344 + } else {
114.345 + return null;
114.346 + }
114.347 + }
114.348 +
114.349 + private static void consumeEscape(LexerInput input) {
114.350 + switch (input.read()) {
114.351 + case ':':
114.352 + switch (input.read()) {
114.353 + case '=':
114.354 + input.backup(2);
114.355 + break;
114.356 + default:
114.357 + input.backup(1);
114.358 + }
114.359 + break;
114.360 +
114.361 + case ' ':
114.362 + case '\t':
114.363 + return;
114.364 +
114.365 + default:
114.366 + input.backup(1);
114.367 + }
114.368 + }
114.369 +
114.370 + private static boolean consumeWhitespace(LexerInput input) {
114.371 + int consumed = 0;
114.372 + for (;;) {
114.373 + switch (input.read()) {
114.374 + case '\t':
114.375 + case ' ':
114.376 + ++consumed;
114.377 + break;
114.378 + default:
114.379 + input.backup(1);
114.380 + return 0 < consumed;
114.381 + }
114.382 + }
114.383 + }
114.384 +
114.385 /**
114.386 * @param input
114.387 - * @param consumeEscapedNewlines
114.388 * @return <code>true</code> if consumed at least one character
114.389 */
114.390 - private static boolean consumeAnythingTillEndOfLine(LexerInput input, boolean consumeEscapedNewlines) {
114.391 + private static boolean consumeAnythingTillEndOfLine(LexerInput input) {
114.392 int consumed = 0;
114.393 for (;;) {
114.394 switch (input.read()) {
114.395 @@ -253,10 +452,7 @@
114.396 return 0 < consumed;
114.397
114.398 case '\\':
114.399 - ++consumed;
114.400 - if (consumeEscapedNewlines) {
114.401 - consumed += consumeNewline(input);
114.402 - }
114.403 + consumed += 1 + consumeNewline(input);
114.404 break;
114.405
114.406 default:
114.407 @@ -320,9 +516,7 @@
114.408 break;
114.409
114.410 case '\\':
114.411 - if (consumeNewline(input) == 0) {
114.412 - input.read(); // skip any character after backslash
114.413 - }
114.414 + consumeNewline(input);
114.415 break;
114.416
114.417 case LexerInput.EOF:
114.418 @@ -339,42 +533,7 @@
114.419 }
114.420 }
114.421
114.422 - private static Token<MakefileTokenId> readOther(LexerInput input, TokenFactory<MakefileTokenId> factory) {
114.423 - if (input.read() == '\\' && 0 < consumeNewline(input)) {
114.424 - return factory.createToken(MakefileTokenId.ESCAPED_NEW_LINE);
114.425 - } else {
114.426 -
114.427 - input.backup(1);
114.428 - for (;;) {
114.429 - int c = input.read();
114.430 - switch (c) {
114.431 - case '\\':
114.432 - int consumed = consumeNewline(input);
114.433 - if (0 < consumed) {
114.434 - input.backup(1 + consumed);
114.435 - return createToken(input.readText().toString(), factory);
114.436 - } else {
114.437 - input.read();
114.438 - }
114.439 - break;
114.440 -
114.441 - case LexerInput.EOF:
114.442 - case ' ':
114.443 - case '\t':
114.444 - case '\r':
114.445 - case '\n':
114.446 - case ':':
114.447 - case '=':
114.448 - case '$':
114.449 - case '#':
114.450 - input.backup(1);
114.451 - return createToken(input.readText().toString(), factory);
114.452 - }
114.453 - }
114.454 - }
114.455 - }
114.456 -
114.457 - private static Token<MakefileTokenId> createToken(String text, TokenFactory<MakefileTokenId> factory) {
114.458 + private static Token<MakefileTokenId> createBareOrKeyword(String text, TokenFactory<MakefileTokenId> factory) {
114.459 if (SPECIAL_TARGETS.contains(text)) {
114.460 return factory.createToken(MakefileTokenId.SPECIAL_TARGET);
114.461 } else if (KEYWORDS.contains(text)) {
115.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/lexer/MakefileTokenId.java Mon Feb 01 12:23:06 2010 +0100
115.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/lexer/MakefileTokenId.java Mon Feb 01 12:24:26 2010 +0100
115.3 @@ -54,7 +54,7 @@
115.4 public enum MakefileTokenId implements TokenId {
115.5
115.6 /**
115.7 - * Regular whitespace that does not have any special meaning.
115.8 + * Space or tab that does not have any special meaning.
115.9 */
115.10 WHITESPACE("whitespace"), // NOI18N
115.11
115.12 @@ -74,7 +74,12 @@
115.13 TAB("tab"), // NOI18N
115.14
115.15 /**
115.16 - * Unparsed shell command.
115.17 + * Shell command modifier: <code>@</code>, <code>-</code>, <code>+</code>
115.18 + */
115.19 + SHELL_MODIFIER("shell_modifier"), // NOI18N
115.20 +
115.21 + /**
115.22 + * Shell command, unlexed.
115.23 */
115.24 SHELL("shell"), // NOI18N
115.25
115.26 @@ -89,9 +94,29 @@
115.27 MACRO("macro"), // NOI18N
115.28
115.29 /**
115.30 - * Separator: <code>:</code>, <code>;</code>, <code>=</code>
115.31 + * Equals character: <code>=</code>
115.32 */
115.33 - SEPARATOR("separator"), // NOI18N
115.34 + EQUALS("separator"), // NOI18N
115.35 +
115.36 + /**
115.37 + * Colon character followed by equals character: <code>:=</code>
115.38 + */
115.39 + COLON_EQUALS("separator"), // NOI18N
115.40 +
115.41 + /**
115.42 + * Plus character followed by equals character: <code>+=</code>
115.43 + */
115.44 + PLUS_EQUALS("separator"), // NOI18N
115.45 +
115.46 + /**
115.47 + * Colon character: <code>:</code>
115.48 + */
115.49 + COLON("separator"), // NOI18N
115.50 +
115.51 + /**
115.52 + * Semicolon character: <code>;</code>
115.53 + */
115.54 + SEMICOLON("separator"), // NOI18N
115.55
115.56 /**
115.57 * Keyword: <code>include</code>, <code>ifdef</code>, <code>endif</code>
116.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/model/MakefileAssignment.java Mon Feb 01 12:23:06 2010 +0100
116.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/model/MakefileAssignment.java Mon Feb 01 12:24:26 2010 +0100
116.3 @@ -36,15 +36,38 @@
116.4 *
116.5 * Portions Copyrighted 2010 Sun Microsystems, Inc.
116.6 */
116.7 +
116.8 package org.netbeans.modules.cnd.makefile.model;
116.9
116.10 /**
116.11 *
116.12 * @author Alexey Vladykin
116.13 */
116.14 -public interface MakefileAssignment extends MakefileElement {
116.15 +public final class MakefileAssignment implements MakefileElement {
116.16
116.17 - String getMacroName();
116.18 + private final String name;
116.19 + private final String value;
116.20
116.21 - String getMacroValue();
116.22 + public MakefileAssignment(String name, String value) {
116.23 + this.name = name;
116.24 + this.value = value;
116.25 + }
116.26 +
116.27 + @Override
116.28 + public Kind getKind() {
116.29 + return Kind.ASSIGNMENT;
116.30 + }
116.31 +
116.32 + public String getMacroName() {
116.33 + return name;
116.34 + }
116.35 +
116.36 + public String getMacroValue() {
116.37 + return value;
116.38 + }
116.39 +
116.40 + @Override
116.41 + public String toString() {
116.42 + return name + " = " + value; // NOI18N
116.43 + }
116.44 }
117.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/model/MakefileElement.java Mon Feb 01 12:23:06 2010 +0100
117.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/model/MakefileElement.java Mon Feb 01 12:24:26 2010 +0100
117.3 @@ -44,5 +44,13 @@
117.4 */
117.5 public interface MakefileElement {
117.6
117.7 - MakefileElementKind getKind();
117.8 + public static enum Kind {
117.9 + RULE,
117.10 + ASSIGNMENT
117.11 + }
117.12 +
117.13 + /**
117.14 + * @return element kind
117.15 + */
117.16 + Kind getKind();
117.17 }
118.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/model/MakefileElementKind.java Mon Feb 01 12:23:06 2010 +0100
118.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
118.3 @@ -1,49 +0,0 @@
118.4 -/*
118.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
118.6 - *
118.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
118.8 - *
118.9 - * The contents of this file are subject to the terms of either the GNU
118.10 - * General Public License Version 2 only ("GPL") or the Common
118.11 - * Development and Distribution License("CDDL") (collectively, the
118.12 - * "License"). You may not use this file except in compliance with the
118.13 - * License. You can obtain a copy of the License at
118.14 - * http://www.netbeans.org/cddl-gplv2.html
118.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
118.16 - * specific language governing permissions and limitations under the
118.17 - * License. When distributing the software, include this License Header
118.18 - * Notice in each file and include the License file at
118.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
118.20 - * particular file as subject to the "Classpath" exception as provided
118.21 - * by Sun in the GPL Version 2 section of the License file that
118.22 - * accompanied this code. If applicable, add the following below the
118.23 - * License Header, with the fields enclosed by brackets [] replaced by
118.24 - * your own identifying information:
118.25 - * "Portions Copyrighted [year] [name of copyright owner]"
118.26 - *
118.27 - * If you wish your version of this file to be governed by only the CDDL
118.28 - * or only the GPL Version 2, indicate your decision by adding
118.29 - * "[Contributor] elects to include this software in this distribution
118.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
118.31 - * single choice of license, a recipient has the option to distribute
118.32 - * your version of this file under either the CDDL, the GPL Version 2 or
118.33 - * to extend the choice of license to its licensees as provided above.
118.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
118.35 - * Version 2 license, then the option applies only if the new code is
118.36 - * made subject to such option by the copyright holder.
118.37 - *
118.38 - * Contributor(s):
118.39 - *
118.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
118.41 - */
118.42 -
118.43 -package org.netbeans.modules.cnd.makefile.model;
118.44 -
118.45 -/**
118.46 - * @author Alexey Vladykin
118.47 - */
118.48 -public enum MakefileElementKind {
118.49 - RULE,
118.50 - ASSIGNMENT,
118.51 -// INCLUDE
118.52 -}
119.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/model/MakefileRule.java Mon Feb 01 12:23:06 2010 +0100
119.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/model/MakefileRule.java Mon Feb 01 12:24:26 2010 +0100
119.3 @@ -36,19 +36,48 @@
119.4 *
119.5 * Portions Copyrighted 2010 Sun Microsystems, Inc.
119.6 */
119.7 -
119.8 package org.netbeans.modules.cnd.makefile.model;
119.9
119.10 +import java.util.Collections;
119.11 import java.util.List;
119.12
119.13 /**
119.14 + *
119.15 * @author Alexey Vladykin
119.16 */
119.17 -public interface MakefileRule extends MakefileElement {
119.18 +public final class MakefileRule implements MakefileElement {
119.19
119.20 - List<String> getTargets();
119.21 + private final List<String> targets;
119.22 + private final List<String> prereqs;
119.23
119.24 - List<String> getPrerequisites();
119.25 + public MakefileRule(List<String> targets, List<String> prereqs) {
119.26 + this.targets = Collections.unmodifiableList(targets);
119.27 + this.prereqs = Collections.unmodifiableList(prereqs);
119.28 + }
119.29
119.30 -// List<String> getCommands();
119.31 + @Override
119.32 + public Kind getKind() {
119.33 + return Kind.RULE;
119.34 + }
119.35 +
119.36 + public List<String> getTargets() {
119.37 + return targets;
119.38 + }
119.39 +
119.40 + public List<String> getPrerequisites() {
119.41 + return prereqs;
119.42 + }
119.43 +
119.44 + @Override
119.45 + public String toString() {
119.46 + StringBuilder buf = new StringBuilder();
119.47 + for (String target : targets) {
119.48 + buf.append(target).append(' ');
119.49 + }
119.50 + buf.append(':');
119.51 + for (String prereq : prereqs) {
119.52 + buf.append(' ').append(prereq);
119.53 + }
119.54 + return buf.toString();
119.55 + }
119.56 }
120.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
120.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/navigator/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
120.3 @@ -0,0 +1,39 @@
120.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
120.5 +#
120.6 +# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
120.7 +#
120.8 +# The contents of this file are subject to the terms of either the GNU
120.9 +# General Public License Version 2 only ("GPL") or the Common
120.10 +# Development and Distribution License("CDDL") (collectively, the
120.11 +# "License"). You may not use this file except in compliance with the
120.12 +# License. You can obtain a copy of the License at
120.13 +# http://www.netbeans.org/cddl-gplv2.html
120.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
120.15 +# specific language governing permissions and limitations under the
120.16 +# License. When distributing the software, include this License Header
120.17 +# Notice in each file and include the License file at
120.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
120.19 +# particular file as subject to the "Classpath" exception as provided
120.20 +# by Sun in the GPL Version 2 section of the License file that
120.21 +# accompanied this code. If applicable, add the following below the
120.22 +# License Header, with the fields enclosed by brackets [] replaced by
120.23 +# your own identifying information:
120.24 +# "Portions Copyrighted [year] [name of copyright owner]"
120.25 +#
120.26 +# If you wish your version of this file to be governed by only the CDDL
120.27 +# or only the GPL Version 2, indicate your decision by adding
120.28 +# "[Contributor] elects to include this software in this distribution
120.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
120.30 +# single choice of license, a recipient has the option to distribute
120.31 +# your version of this file under either the CDDL, the GPL Version 2 or
120.32 +# to extend the choice of license to its licensees as provided above.
120.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
120.34 +# Version 2 license, then the option applies only if the new code is
120.35 +# made subject to such option by the copyright holder.
120.36 +#
120.37 +# Contributor(s):
120.38 +#
120.39 +# Portions Copyrighted 2010 Sun Microsystems, Inc.
120.40 +
120.41 +navigator.title = Makefile Elements
120.42 +navigator.hint = Shows elements of the makefile
121.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
121.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/navigator/MakefileNavigatorPanel.java Mon Feb 01 12:24:26 2010 +0100
121.3 @@ -0,0 +1,168 @@
121.4 +/*
121.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
121.6 + *
121.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
121.8 + *
121.9 + * The contents of this file are subject to the terms of either the GNU
121.10 + * General Public License Version 2 only ("GPL") or the Common
121.11 + * Development and Distribution License("CDDL") (collectively, the
121.12 + * "License"). You may not use this file except in compliance with the
121.13 + * License. You can obtain a copy of the License at
121.14 + * http://www.netbeans.org/cddl-gplv2.html
121.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
121.16 + * specific language governing permissions and limitations under the
121.17 + * License. When distributing the software, include this License Header
121.18 + * Notice in each file and include the License file at
121.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
121.20 + * particular file as subject to the "Classpath" exception as provided
121.21 + * by Sun in the GPL Version 2 section of the License file that
121.22 + * accompanied this code. If applicable, add the following below the
121.23 + * License Header, with the fields enclosed by brackets [] replaced by
121.24 + * your own identifying information:
121.25 + * "Portions Copyrighted [year] [name of copyright owner]"
121.26 + *
121.27 + * If you wish your version of this file to be governed by only the CDDL
121.28 + * or only the GPL Version 2, indicate your decision by adding
121.29 + * "[Contributor] elects to include this software in this distribution
121.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
121.31 + * single choice of license, a recipient has the option to distribute
121.32 + * your version of this file under either the CDDL, the GPL Version 2 or
121.33 + * to extend the choice of license to its licensees as provided above.
121.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
121.35 + * Version 2 license, then the option applies only if the new code is
121.36 + * made subject to such option by the copyright holder.
121.37 + *
121.38 + * Contributor(s):
121.39 + *
121.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
121.41 + */
121.42 +package org.netbeans.modules.cnd.makefile.navigator;
121.43 +
121.44 +import java.util.Collections;
121.45 +import javax.swing.JComponent;
121.46 +import javax.swing.SwingUtilities;
121.47 +import org.netbeans.modules.cnd.makefile.parser.MakefileModel;
121.48 +import org.netbeans.modules.cnd.utils.MIMENames;
121.49 +import org.netbeans.modules.parsing.api.ParserManager;
121.50 +import org.netbeans.modules.parsing.api.ResultIterator;
121.51 +import org.netbeans.modules.parsing.api.Source;
121.52 +import org.netbeans.modules.parsing.api.UserTask;
121.53 +import org.netbeans.modules.parsing.spi.ParseException;
121.54 +import org.netbeans.modules.parsing.spi.Parser.Result;
121.55 +import org.netbeans.spi.navigator.NavigatorPanel;
121.56 +import org.openide.filesystems.FileObject;
121.57 +import org.openide.util.Lookup;
121.58 +import org.openide.util.LookupEvent;
121.59 +import org.openide.util.LookupListener;
121.60 +import org.openide.util.NbBundle;
121.61 +import org.openide.util.RequestProcessor;
121.62 +
121.63 +/**
121.64 + * @author Alexey Vladykin
121.65 + */
121.66 +public class MakefileNavigatorPanel implements NavigatorPanel, LookupListener {
121.67 +
121.68 + private Lookup.Result<FileObject> lookupResult;
121.69 + private MakefileNavigatorPanelUI panel;
121.70 + private final UpdaterTask updaterTask;
121.71 +
121.72 + public MakefileNavigatorPanel() {
121.73 + updaterTask = new UpdaterTask();
121.74 + }
121.75 +
121.76 + @Override
121.77 + public String getDisplayName() {
121.78 + return getMessage("navigator.title"); // NOI18N
121.79 + }
121.80 +
121.81 + @Override
121.82 + public String getDisplayHint() {
121.83 + return getMessage("navigator.hint"); // NOI18N
121.84 + }
121.85 +
121.86 + @Override
121.87 + public JComponent getComponent() {
121.88 + if (panel == null) {
121.89 + panel = new MakefileNavigatorPanelUI();
121.90 + }
121.91 + return panel;
121.92 + }
121.93 +
121.94 + @Override
121.95 + public void panelActivated(Lookup context) {
121.96 + lookupResult = context.lookupResult(FileObject.class);
121.97 + lookupResult.addLookupListener(this);
121.98 + scheduleUpdate(findMakefile(lookupResult));
121.99 + }
121.100 +
121.101 + @Override
121.102 + public void panelDeactivated() {
121.103 + lookupResult.removeLookupListener(this);
121.104 + scheduleUpdate(null);
121.105 + }
121.106 +
121.107 + @Override
121.108 + public Lookup getLookup() {
121.109 + return null;
121.110 + }
121.111 +
121.112 + @Override
121.113 + public void resultChanged(LookupEvent ev) {
121.114 + scheduleUpdate(findMakefile(lookupResult));
121.115 + }
121.116 +
121.117 + private void scheduleUpdate(final FileObject makefile) {
121.118 + if (makefile != null) {
121.119 + uiSetWaiting();
121.120 + RequestProcessor.getDefault().post(new Runnable() {
121.121 + public void run() {
121.122 + Source source = Source.create(makefile);
121.123 + try {
121.124 + ParserManager.parse(Collections.singletonList(source), updaterTask);
121.125 + } catch (ParseException ex) {
121.126 + ex.printStackTrace();
121.127 + }
121.128 + }
121.129 + });
121.130 + } else {
121.131 + uiSetModel(null);
121.132 + }
121.133 + }
121.134 +
121.135 + private void uiSetWaiting() {
121.136 + SwingUtilities.invokeLater(new Runnable() {
121.137 + public void run() {
121.138 + panel.setWaiting();
121.139 + }
121.140 + });
121.141 + }
121.142 +
121.143 + private void uiSetModel(final MakefileModel model) {
121.144 + SwingUtilities.invokeLater(new Runnable() {
121.145 + public void run() {
121.146 + panel.setModel(model);
121.147 + }
121.148 + });
121.149 + }
121.150 +
121.151 + private FileObject findMakefile(Lookup.Result<FileObject> result) {
121.152 + for (FileObject file : result.allInstances()) {
121.153 + if (file.getMIMEType().equals(MIMENames.MAKEFILE_MIME_TYPE)) {
121.154 + return file;
121.155 + }
121.156 + }
121.157 + return null;
121.158 + }
121.159 +
121.160 + private static String getMessage(String key) {
121.161 + return NbBundle.getMessage(MakefileNavigatorPanel.class, key);
121.162 + }
121.163 +
121.164 + private class UpdaterTask extends UserTask {
121.165 + @Override
121.166 + public void run(ResultIterator resultIterator) throws ParseException {
121.167 + Result r = resultIterator.getParserResult();
121.168 + uiSetModel((MakefileModel) r);
121.169 + }
121.170 + }
121.171 +}
122.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
122.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/navigator/MakefileNavigatorPanelUI.java Mon Feb 01 12:24:26 2010 +0100
122.3 @@ -0,0 +1,115 @@
122.4 +/*
122.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
122.6 + *
122.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
122.8 + *
122.9 + * The contents of this file are subject to the terms of either the GNU
122.10 + * General Public License Version 2 only ("GPL") or the Common
122.11 + * Development and Distribution License("CDDL") (collectively, the
122.12 + * "License"). You may not use this file except in compliance with the
122.13 + * License. You can obtain a copy of the License at
122.14 + * http://www.netbeans.org/cddl-gplv2.html
122.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
122.16 + * specific language governing permissions and limitations under the
122.17 + * License. When distributing the software, include this License Header
122.18 + * Notice in each file and include the License file at
122.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
122.20 + * particular file as subject to the "Classpath" exception as provided
122.21 + * by Sun in the GPL Version 2 section of the License file that
122.22 + * accompanied this code. If applicable, add the following below the
122.23 + * License Header, with the fields enclosed by brackets [] replaced by
122.24 + * your own identifying information:
122.25 + * "Portions Copyrighted [year] [name of copyright owner]"
122.26 + *
122.27 + * If you wish your version of this file to be governed by only the CDDL
122.28 + * or only the GPL Version 2, indicate your decision by adding
122.29 + * "[Contributor] elects to include this software in this distribution
122.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
122.31 + * single choice of license, a recipient has the option to distribute
122.32 + * your version of this file under either the CDDL, the GPL Version 2 or
122.33 + * to extend the choice of license to its licensees as provided above.
122.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
122.35 + * Version 2 license, then the option applies only if the new code is
122.36 + * made subject to such option by the copyright holder.
122.37 + *
122.38 + * Contributor(s):
122.39 + *
122.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
122.41 + */
122.42 +
122.43 +package org.netbeans.modules.cnd.makefile.navigator;
122.44 +
122.45 +import java.awt.BorderLayout;
122.46 +import java.util.ArrayList;
122.47 +import java.util.Collections;
122.48 +import java.util.List;
122.49 +import javax.swing.JPanel;
122.50 +import org.netbeans.modules.cnd.makefile.model.MakefileAssignment;
122.51 +import org.netbeans.modules.cnd.makefile.model.MakefileElement;
122.52 +import org.netbeans.modules.cnd.makefile.model.MakefileRule;
122.53 +import org.netbeans.modules.cnd.makefile.parser.MakefileModel;
122.54 +import org.openide.explorer.ExplorerManager;
122.55 +import org.openide.explorer.view.ListView;
122.56 +import org.openide.nodes.AbstractNode;
122.57 +import org.openide.nodes.Children;
122.58 +import org.openide.nodes.Node;
122.59 +
122.60 +/**
122.61 + * @author Alexey Vladykin
122.62 + */
122.63 +public class MakefileNavigatorPanelUI extends JPanel implements ExplorerManager.Provider {
122.64 +
122.65 + private final ExplorerManager manager;
122.66 + private final ListView view;
122.67 +
122.68 + public MakefileNavigatorPanelUI() {
122.69 + super(new BorderLayout());
122.70 +
122.71 + manager = new ExplorerManager();
122.72 + view = new ListView();
122.73 + add(view, BorderLayout.CENTER);
122.74 + }
122.75 +
122.76 + @Override
122.77 + public ExplorerManager getExplorerManager() {
122.78 + return manager;
122.79 + }
122.80 +
122.81 + public void setWaiting() {
122.82 + // TODO: manager.setRootContext(new AbstractNode(new WaitingChildren()));
122.83 + }
122.84 +
122.85 + public void setModel(MakefileModel model) {
122.86 + manager.setRootContext(new AbstractNode(new MakefileElementChildren(model)));
122.87 + }
122.88 +
122.89 + private static class MakefileElementChildren extends Children.Keys<MakefileElement> {
122.90 +
122.91 + public MakefileElementChildren(MakefileModel model) {
122.92 + setKeys(model == null ? Collections.<MakefileElement>emptyList() : model.getElements());
122.93 + }
122.94 +
122.95 + @Override
122.96 + protected Node[] createNodes(MakefileElement key) {
122.97 + if (key.getKind() == MakefileElement.Kind.RULE) {
122.98 + List<Node> list = new ArrayList<Node>();
122.99 + MakefileRule rule = (MakefileRule) key;
122.100 + for (String target : rule.getTargets()) {
122.101 + if (0 < target.length()) {
122.102 + AbstractNode node = new AbstractNode(Children.LEAF);
122.103 + node.setName(target);
122.104 + list.add(node);
122.105 + }
122.106 + }
122.107 + return list.toArray(new Node[list.size()]);
122.108 + } else if (key.getKind() == MakefileElement.Kind.ASSIGNMENT) {
122.109 + MakefileAssignment assign = (MakefileAssignment) key;
122.110 + AbstractNode node = new AbstractNode(Children.LEAF);
122.111 + node.setName(assign.getMacroName());
122.112 + return new Node[]{node};
122.113 + } else {
122.114 + return new Node[] {};
122.115 + }
122.116 + }
122.117 + }
122.118 +}
123.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/navigator/NavigatorUpdaterTask.java Mon Feb 01 12:23:06 2010 +0100
123.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/navigator/NavigatorUpdaterTask.java Mon Feb 01 12:24:26 2010 +0100
123.3 @@ -52,10 +52,10 @@
123.4
123.5 @Override
123.6 public void run(MakefileModel result, SchedulerEvent event) {
123.7 - System.out.println(result.getSnapshot().getSource().getFileObject());
123.8 - for (MakefileElement e : result.getElements()) {
123.9 - System.out.println(e);
123.10 - }
123.11 +// System.out.println(result.getSnapshot().getSource().getFileObject());
123.12 +// for (MakefileElement e : result.getElements()) {
123.13 +// System.out.println(e);
123.14 +// }
123.15 }
123.16
123.17 @Override
124.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/parser/AssignmentImpl.java Mon Feb 01 12:23:06 2010 +0100
124.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
124.3 @@ -1,78 +0,0 @@
124.4 -/*
124.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
124.6 - *
124.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
124.8 - *
124.9 - * The contents of this file are subject to the terms of either the GNU
124.10 - * General Public License Version 2 only ("GPL") or the Common
124.11 - * Development and Distribution License("CDDL") (collectively, the
124.12 - * "License"). You may not use this file except in compliance with the
124.13 - * License. You can obtain a copy of the License at
124.14 - * http://www.netbeans.org/cddl-gplv2.html
124.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
124.16 - * specific language governing permissions and limitations under the
124.17 - * License. When distributing the software, include this License Header
124.18 - * Notice in each file and include the License file at
124.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
124.20 - * particular file as subject to the "Classpath" exception as provided
124.21 - * by Sun in the GPL Version 2 section of the License file that
124.22 - * accompanied this code. If applicable, add the following below the
124.23 - * License Header, with the fields enclosed by brackets [] replaced by
124.24 - * your own identifying information:
124.25 - * "Portions Copyrighted [year] [name of copyright owner]"
124.26 - *
124.27 - * If you wish your version of this file to be governed by only the CDDL
124.28 - * or only the GPL Version 2, indicate your decision by adding
124.29 - * "[Contributor] elects to include this software in this distribution
124.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
124.31 - * single choice of license, a recipient has the option to distribute
124.32 - * your version of this file under either the CDDL, the GPL Version 2 or
124.33 - * to extend the choice of license to its licensees as provided above.
124.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
124.35 - * Version 2 license, then the option applies only if the new code is
124.36 - * made subject to such option by the copyright holder.
124.37 - *
124.38 - * Contributor(s):
124.39 - *
124.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
124.41 - */
124.42 -
124.43 -package org.netbeans.modules.cnd.makefile.parser;
124.44 -
124.45 -import org.netbeans.modules.cnd.makefile.model.MakefileAssignment;
124.46 -import org.netbeans.modules.cnd.makefile.model.MakefileElementKind;
124.47 -
124.48 -/**
124.49 - *
124.50 - * @author Alexey Vladykin
124.51 - */
124.52 -public class AssignmentImpl implements MakefileAssignment {
124.53 -
124.54 - private final String name;
124.55 - private final String value;
124.56 -
124.57 - public AssignmentImpl(String name, String value) {
124.58 - this.name = name;
124.59 - this.value = value;
124.60 - }
124.61 -
124.62 - @Override
124.63 - public MakefileElementKind getKind() {
124.64 - return MakefileElementKind.ASSIGNMENT;
124.65 - }
124.66 -
124.67 - @Override
124.68 - public String getMacroName() {
124.69 - return name;
124.70 - }
124.71 -
124.72 - @Override
124.73 - public String getMacroValue() {
124.74 - return value;
124.75 - }
124.76 -
124.77 - @Override
124.78 - public String toString() {
124.79 - return name + " = " + value; // NOI18N
124.80 - }
124.81 -}
125.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/parser/MakefileParser.java Mon Feb 01 12:23:06 2010 +0100
125.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/makefile/parser/MakefileParser.java Mon Feb 01 12:24:26 2010 +0100
125.3 @@ -38,10 +38,16 @@
125.4 */
125.5 package org.netbeans.modules.cnd.makefile.parser;
125.6
125.7 -import java.util.Arrays;
125.8 +import org.netbeans.modules.cnd.makefile.model.MakefileRule;
125.9 +import org.netbeans.modules.cnd.makefile.model.MakefileAssignment;
125.10 +import java.util.ArrayList;
125.11 +import java.util.List;
125.12 +import java.util.concurrent.atomic.AtomicBoolean;
125.13 import javax.swing.event.ChangeListener;
125.14 +import org.netbeans.api.lexer.Token;
125.15 import org.netbeans.api.lexer.TokenSequence;
125.16 import org.netbeans.modules.cnd.makefile.lexer.MakefileTokenId;
125.17 +import org.netbeans.modules.cnd.makefile.model.MakefileElement;
125.18 import org.netbeans.modules.parsing.api.Snapshot;
125.19 import org.netbeans.modules.parsing.api.Task;
125.20 import org.netbeans.modules.parsing.spi.ParseException;
125.21 @@ -53,28 +59,28 @@
125.22 */
125.23 public class MakefileParser extends Parser {
125.24
125.25 - private volatile boolean cancelled;
125.26 + private final AtomicBoolean cancelled;
125.27 private MakefileModel result;
125.28
125.29 /*package*/ MakefileParser() {
125.30 + cancelled = new AtomicBoolean();
125.31 }
125.32
125.33 @Override
125.34 public void parse(Snapshot snapshot, Task task, SourceModificationEvent event) throws ParseException {
125.35 - TokenSequence<MakefileTokenId> ts = snapshot.getTokenHierarchy().tokenSequence(MakefileTokenId.language());
125.36 - if (ts != null) {
125.37 - parse(snapshot, ts);
125.38 - }
125.39 + result = null;
125.40 + cancelled.set(false);
125.41 + result = parse(snapshot, cancelled);
125.42 }
125.43
125.44 @Override
125.45 - public Result getResult(Task task) throws ParseException {
125.46 - return cancelled? null : result;
125.47 + public MakefileModel getResult(Task task) throws ParseException {
125.48 + return result;
125.49 }
125.50
125.51 @Override
125.52 public void cancel() {
125.53 - this.cancelled = true;
125.54 + cancelled.set(true);
125.55 }
125.56
125.57 @Override
125.58 @@ -87,9 +93,120 @@
125.59 // nothing to listen to => no reason to register listeners
125.60 }
125.61
125.62 - private void parse(Snapshot snapshot, TokenSequence<MakefileTokenId> ts) throws ParseException {
125.63 - result = new MakefileModel(snapshot, Arrays.asList(
125.64 - new AssignmentImpl("a", "b"), // NOI18N
125.65 - new RuleImpl(Arrays.asList("sample"), Arrays.asList("sample")))); // NOI18N
125.66 +
125.67 + private static MakefileModel parse(Snapshot snapshot, AtomicBoolean cancelled) {
125.68 + TokenSequence<MakefileTokenId> tokenSequence =
125.69 + snapshot.getTokenHierarchy().tokenSequence(MakefileTokenId.language());
125.70 +
125.71 + if (tokenSequence == null) {
125.72 + return null;
125.73 + }
125.74 +
125.75 + List<MakefileElement> makefileElements = new ArrayList<MakefileElement>();
125.76 +
125.77 + int startIndex = 0;
125.78 + while (tokenSequence.moveNext() && !cancelled.get()) {
125.79 + Token<MakefileTokenId> token = tokenSequence.token();
125.80 +
125.81 + switch (token.id()) {
125.82 + case EQUALS:
125.83 + case COLON_EQUALS:
125.84 + tokenSequence.moveIndex(startIndex);
125.85 + makefileElements.add(createAssignment(tokenSequence));
125.86 + startIndex = tokenSequence.index();
125.87 + break;
125.88 +
125.89 + case COLON:
125.90 + tokenSequence.moveIndex(startIndex);
125.91 + makefileElements.add(createRule(tokenSequence));
125.92 + startIndex = tokenSequence.index();
125.93 + break;
125.94 +
125.95 + case COMMENT:
125.96 + case NEW_LINE:
125.97 + startIndex = tokenSequence.index() + 1;
125.98 + }
125.99 + }
125.100 +
125.101 + return cancelled.get()? null : new MakefileModel(snapshot, makefileElements);
125.102 + }
125.103 +
125.104 + private static MakefileAssignment createAssignment(TokenSequence<MakefileTokenId> tokenSequence) {
125.105 + StringBuilder nameBuilder = new StringBuilder();
125.106 + NAME_LOOP: while (tokenSequence.moveNext()) {
125.107 + Token<MakefileTokenId> token = tokenSequence.token();
125.108 + switch (token.id()) {
125.109 + case EQUALS:
125.110 + case COLON_EQUALS:
125.111 + break NAME_LOOP;
125.112 + default:
125.113 + nameBuilder.append(token.text());
125.114 + }
125.115 + }
125.116 +
125.117 + StringBuilder valueBuilder = new StringBuilder();
125.118 + VALUE_LOOP: while (tokenSequence.moveNext()) {
125.119 + Token<MakefileTokenId> token = tokenSequence.token();
125.120 + switch (token.id()) {
125.121 + case COMMENT:
125.122 + case NEW_LINE:
125.123 + break VALUE_LOOP;
125.124 + default:
125.125 + valueBuilder.append(token.text());
125.126 + }
125.127 + }
125.128 +
125.129 + return new MakefileAssignment(nameBuilder.toString().trim(), valueBuilder.toString());
125.130 + }
125.131 +
125.132 + private static MakefileRule createRule(TokenSequence<MakefileTokenId> tokenSequence) {
125.133 + StringBuilder nameBuilder = new StringBuilder();
125.134 +
125.135 + List<String> targets = new ArrayList<String>();
125.136 + TARGETS_LOOP: while (tokenSequence.moveNext()) {
125.137 + Token<MakefileTokenId> token = tokenSequence.token();
125.138 + switch (token.id()) {
125.139 + case COLON:
125.140 + if (0 < nameBuilder.length()) {
125.141 + targets.add(nameBuilder.toString());
125.142 + nameBuilder.setLength(0);
125.143 + }
125.144 + break TARGETS_LOOP;
125.145 + case WHITESPACE:
125.146 + case ESCAPED_NEW_LINE:
125.147 + if (0 < nameBuilder.length()) {
125.148 + targets.add(nameBuilder.toString());
125.149 + nameBuilder.setLength(0);
125.150 + }
125.151 + break;
125.152 + default:
125.153 + nameBuilder.append(token.text());
125.154 + }
125.155 + }
125.156 +
125.157 + List<String> prereqs = new ArrayList<String>();
125.158 + PREREQS_LOOP: while (tokenSequence.moveNext()) {
125.159 + Token<MakefileTokenId> token = tokenSequence.token();
125.160 + switch (token.id()) {
125.161 + case WHITESPACE:
125.162 + case ESCAPED_NEW_LINE:
125.163 + if (0 < nameBuilder.length()) {
125.164 + prereqs.add(nameBuilder.toString());
125.165 + nameBuilder.setLength(0);
125.166 + }
125.167 + break;
125.168 + case COMMENT:
125.169 + case NEW_LINE:
125.170 + if (0 < nameBuilder.length()) {
125.171 + prereqs.add(nameBuilder.toString());
125.172 + nameBuilder.setLength(0);
125.173 + }
125.174 + break PREREQS_LOOP;
125.175 + default:
125.176 + nameBuilder.append(token.text());
125.177 + }
125.178 + }
125.179 +
125.180 + return new MakefileRule(targets, prereqs);
125.181 }
125.182 }
126.1 --- a/cnd.script/src/org/netbeans/modules/cnd/makefile/parser/RuleImpl.java Mon Feb 01 12:23:06 2010 +0100
126.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
126.3 @@ -1,87 +0,0 @@
126.4 -/*
126.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
126.6 - *
126.7 - * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
126.8 - *
126.9 - * The contents of this file are subject to the terms of either the GNU
126.10 - * General Public License Version 2 only ("GPL") or the Common
126.11 - * Development and Distribution License("CDDL") (collectively, the
126.12 - * "License"). You may not use this file except in compliance with the
126.13 - * License. You can obtain a copy of the License at
126.14 - * http://www.netbeans.org/cddl-gplv2.html
126.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
126.16 - * specific language governing permissions and limitations under the
126.17 - * License. When distributing the software, include this License Header
126.18 - * Notice in each file and include the License file at
126.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
126.20 - * particular file as subject to the "Classpath" exception as provided
126.21 - * by Sun in the GPL Version 2 section of the License file that
126.22 - * accompanied this code. If applicable, add the following below the
126.23 - * License Header, with the fields enclosed by brackets [] replaced by
126.24 - * your own identifying information:
126.25 - * "Portions Copyrighted [year] [name of copyright owner]"
126.26 - *
126.27 - * If you wish your version of this file to be governed by only the CDDL
126.28 - * or only the GPL Version 2, indicate your decision by adding
126.29 - * "[Contributor] elects to include this software in this distribution
126.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
126.31 - * single choice of license, a recipient has the option to distribute
126.32 - * your version of this file under either the CDDL, the GPL Version 2 or
126.33 - * to extend the choice of license to its licensees as provided above.
126.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
126.35 - * Version 2 license, then the option applies only if the new code is
126.36 - * made subject to such option by the copyright holder.
126.37 - *
126.38 - * Contributor(s):
126.39 - *
126.40 - * Portions Copyrighted 2010 Sun Microsystems, Inc.
126.41 - */
126.42 -package org.netbeans.modules.cnd.makefile.parser;
126.43 -
126.44 -import java.util.Collections;
126.45 -import java.util.List;
126.46 -import org.netbeans.modules.cnd.makefile.model.MakefileElementKind;
126.47 -import org.netbeans.modules.cnd.makefile.model.MakefileRule;
126.48 -
126.49 -/**
126.50 - *
126.51 - * @author Alexey Vladykin
126.52 - */
126.53 -public class RuleImpl implements MakefileRule {
126.54 -
126.55 - private final List<String> targets;
126.56 - private final List<String> prereqs;
126.57 -
126.58 - public RuleImpl(List<String> targets, List<String> prereqs) {
126.59 - this.targets = Collections.unmodifiableList(targets);
126.60 - this.prereqs = Collections.unmodifiableList(prereqs);
126.61 - }
126.62 -
126.63 - @Override
126.64 - public MakefileElementKind getKind() {
126.65 - return MakefileElementKind.RULE;
126.66 - }
126.67 -
126.68 - @Override
126.69 - public List<String> getTargets() {
126.70 - return targets;
126.71 - }
126.72 -
126.73 - @Override
126.74 - public List<String> getPrerequisites() {
126.75 - return prereqs;
126.76 - }
126.77 -
126.78 - @Override
126.79 - public String toString() {
126.80 - StringBuilder buf = new StringBuilder();
126.81 - for (String target : targets) {
126.82 - buf.append(target).append(' ');
126.83 - }
126.84 - buf.append(':');
126.85 - for (String prereq : prereqs) {
126.86 - buf.append(' ').append(prereq);
126.87 - }
126.88 - return buf.toString();
126.89 - }
126.90 -}
127.1 --- a/cnd.script/src/org/netbeans/modules/cnd/script/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
127.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/script/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
127.3 @@ -427,4 +427,17 @@
127.4 </folder>
127.5 </folder>
127.6
127.7 + <folder name="Navigator">
127.8 + <folder name="Panels">
127.9 + <folder name="text">
127.10 + <folder name="x-make">
127.11 + <file name="NavigatorPanel.instance">
127.12 + <attr name="instanceClass" stringvalue="org.netbeans.modules.cnd.makefile.navigator.MakefileNavigatorPanel"/>
127.13 + <attr name="instanceOf" stringvalue="org.netbeans.spi.navigator.NavigatorPanel"/>
127.14 + </file>
127.15 + </folder>
127.16 + </folder>
127.17 + </folder>
127.18 + </folder>
127.19 +
127.20 </filesystem>
128.1 --- a/cnd.script/src/org/netbeans/modules/cnd/script/resources/makefileFontsColors.xml Mon Feb 01 12:23:06 2010 +0100
128.2 +++ b/cnd.script/src/org/netbeans/modules/cnd/script/resources/makefileFontsColors.xml Mon Feb 01 12:24:26 2010 +0100
128.3 @@ -57,5 +57,6 @@
128.4 <font style="bold"/>
128.5 </fontcolor>
128.6 <fontcolor name="shell" default="identifier"/>
128.7 + <fontcolor name="shell_modifier" default="identifier"/>
128.8
128.9 </fontscolors>
129.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
129.2 +++ b/cnd.script/test/unit/data/Makefile1 Mon Feb 01 12:24:26 2010 +0100
129.3 @@ -0,0 +1,17 @@
129.4 +# Environment
129.5 +RM=rm
129.6 +CC=gcc
129.7 +
129.8 +# Include project Makefile
129.9 +include Makefile
129.10 +
129.11 +# Build Targets
129.12 +.build-conf: $(BUILD_SUBPROJECTS) dist/Debug/GNU-Solaris-x86/quote_1
129.13 +
129.14 +# Clean Targets
129.15 +.clean-conf:
129.16 + -$(RM) -r build/Debug
129.17 + -$(RM) -r dist/Debug/GNU-Solaris-x86
129.18 +
129.19 +.DONE:
129.20 + echo "Done"
130.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
130.2 +++ b/cnd.script/test/unit/src/org/netbeans/modules/cnd/makefile/editor/MakefileIndentTest.java Mon Feb 01 12:24:26 2010 +0100
130.3 @@ -0,0 +1,142 @@
130.4 +/*
130.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
130.6 + *
130.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
130.8 + *
130.9 + * The contents of this file are subject to the terms of either the GNU
130.10 + * General Public License Version 2 only ("GPL") or the Common
130.11 + * Development and Distribution License("CDDL") (collectively, the
130.12 + * "License"). You may not use this file except in compliance with the
130.13 + * License. You can obtain a copy of the License at
130.14 + * http://www.netbeans.org/cddl-gplv2.html
130.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
130.16 + * specific language governing permissions and limitations under the
130.17 + * License. When distributing the software, include this License Header
130.18 + * Notice in each file and include the License file at
130.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
130.20 + * particular file as subject to the "Classpath" exception as provided
130.21 + * by Sun in the GPL Version 2 section of the License file that
130.22 + * accompanied this code. If applicable, add the following below the
130.23 + * License Header, with the fields enclosed by brackets [] replaced by
130.24 + * your own identifying information:
130.25 + * "Portions Copyrighted [year] [name of copyright owner]"
130.26 + *
130.27 + * If you wish your version of this file to be governed by only the CDDL
130.28 + * or only the GPL Version 2, indicate your decision by adding
130.29 + * "[Contributor] elects to include this software in this distribution
130.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
130.31 + * single choice of license, a recipient has the option to distribute
130.32 + * your version of this file under either the CDDL, the GPL Version 2 or
130.33 + * to extend the choice of license to its licensees as provided above.
130.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
130.35 + * Version 2 license, then the option applies only if the new code is
130.36 + * made subject to such option by the copyright holder.
130.37 + *
130.38 + * Contributor(s):
130.39 + *
130.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
130.41 + */
130.42 +
130.43 +package org.netbeans.modules.cnd.makefile.editor;
130.44 +
130.45 +import org.netbeans.modules.cnd.makefile.editor.MakefileIndentTaskFactory;
130.46 +import javax.swing.text.BadLocationException;
130.47 +import org.netbeans.api.editor.mimelookup.MimePath;
130.48 +import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
130.49 +import org.netbeans.editor.BaseDocument;
130.50 +import org.netbeans.junit.MockServices;
130.51 +import org.netbeans.junit.NbTestCase;
130.52 +import org.netbeans.modules.cnd.utils.MIMENames;
130.53 +import org.netbeans.modules.editor.NbEditorDocument;
130.54 +import org.netbeans.modules.editor.indent.api.Indent;
130.55 +
130.56 +/**
130.57 + * @author Alexey Vladykin
130.58 + */
130.59 +public class MakefileIndentTest extends NbTestCase {
130.60 +
130.61 + private static final String MIME_TYPE = MIMENames.MAKEFILE_MIME_TYPE;
130.62 + private MimePath mimePath;
130.63 +
130.64 + public MakefileIndentTest(String name) {
130.65 + super(name);
130.66 + }
130.67 +
130.68 + @Override
130.69 + public void setUp() throws Exception {
130.70 + super.setUp();
130.71 + MakefileIndentTaskFactory factory = new MakefileIndentTaskFactory();
130.72 + MockServices.setServices(MockMimeLookup.class);
130.73 + mimePath = MimePath.parse(MIME_TYPE);
130.74 + MockMimeLookup.setInstances(mimePath, factory);
130.75 + }
130.76 +
130.77 + @Override
130.78 + protected int timeOut() {
130.79 + return 500000;
130.80 + }
130.81 +
130.82 + public void testRuleIndent1() throws BadLocationException {
130.83 + createDocument("build: myapp|");
130.84 + indentNewLine();
130.85 + assertText("build: myapp\n\t");
130.86 + }
130.87 +
130.88 + public void testRuleIndent2() throws BadLocationException {
130.89 + createDocument("build: myapp|\nclean:\n");
130.90 + indentNewLine();
130.91 + assertText("build: myapp\n\t\nclean:\n");
130.92 + }
130.93 +
130.94 + public void testRuleIndent3() throws BadLocationException {
130.95 + createDocument("build: myapp| #comment");
130.96 + indentNewLine();
130.97 + assertText("build: myapp\n\t#comment");
130.98 + }
130.99 +
130.100 + public void testRuleIndent4() throws BadLocationException {
130.101 + createDocument("build:\n\tcc -o a.o a.c|cc -o b.o b.c\n");
130.102 + indentNewLine();
130.103 + createDocument("build:\n\tcc -o a.o a.c\n\tcc -o b.o b.c\n");
130.104 + }
130.105 +
130.106 + public void testCommentIndent() throws BadLocationException {
130.107 + createDocument("#build: myapp|");
130.108 + indentNewLine();
130.109 + assertText("#build: myapp\n");
130.110 + }
130.111 +
130.112 +
130.113 + private BaseDocument doc;
130.114 + private int caretOffset = -1;
130.115 +
130.116 + private void createDocument(String text) throws BadLocationException {
130.117 + doc = new NbEditorDocument(MIME_TYPE);
130.118 + setText(text);
130.119 + }
130.120 +
130.121 + private void setText(String text) throws BadLocationException {
130.122 + doc.remove(0, doc.getLength());
130.123 + caretOffset = text.indexOf('|');
130.124 + if (0 <= caretOffset) {
130.125 + text = text.substring(0, caretOffset) + text.substring(caretOffset + 1);
130.126 + }
130.127 + doc.insertString(0, text, null);
130.128 + }
130.129 +
130.130 + private void indentNewLine() throws BadLocationException {
130.131 + doc.insertString(caretOffset, "\n", null);
130.132 + Indent indent = Indent.get(doc);
130.133 + indent.lock();
130.134 + try {
130.135 + indent.reindent(caretOffset + 1);
130.136 + } finally {
130.137 + indent.unlock();
130.138 + }
130.139 + }
130.140 +
130.141 + private void assertText(String text) throws BadLocationException {
130.142 + assertEquals(text, doc.getText(0, doc.getLength()));
130.143 + }
130.144 +
130.145 +}
131.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
131.2 +++ b/cnd.script/test/unit/src/org/netbeans/modules/cnd/makefile/lexer/MakefileLexerTest.java Mon Feb 01 12:24:26 2010 +0100
131.3 @@ -0,0 +1,255 @@
131.4 +/*
131.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
131.6 + *
131.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
131.8 + *
131.9 + * The contents of this file are subject to the terms of either the GNU
131.10 + * General Public License Version 2 only ("GPL") or the Common
131.11 + * Development and Distribution License("CDDL") (collectively, the
131.12 + * "License"). You may not use this file except in compliance with the
131.13 + * License. You can obtain a copy of the License at
131.14 + * http://www.netbeans.org/cddl-gplv2.html
131.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
131.16 + * specific language governing permissions and limitations under the
131.17 + * License. When distributing the software, include this License Header
131.18 + * Notice in each file and include the License file at
131.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
131.20 + * particular file as subject to the "Classpath" exception as provided
131.21 + * by Sun in the GPL Version 2 section of the License file that
131.22 + * accompanied this code. If applicable, add the following below the
131.23 + * License Header, with the fields enclosed by brackets [] replaced by
131.24 + * your own identifying information:
131.25 + * "Portions Copyrighted [year] [name of copyright owner]"
131.26 + *
131.27 + * If you wish your version of this file to be governed by only the CDDL
131.28 + * or only the GPL Version 2, indicate your decision by adding
131.29 + * "[Contributor] elects to include this software in this distribution
131.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
131.31 + * single choice of license, a recipient has the option to distribute
131.32 + * your version of this file under either the CDDL, the GPL Version 2 or
131.33 + * to extend the choice of license to its licensees as provided above.
131.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
131.35 + * Version 2 license, then the option applies only if the new code is
131.36 + * made subject to such option by the copyright holder.
131.37 + *
131.38 + * Contributor(s):
131.39 + *
131.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
131.41 + */
131.42 +
131.43 +package org.netbeans.modules.cnd.makefile.lexer;
131.44 +
131.45 +import org.netbeans.api.lexer.TokenHierarchy;
131.46 +import org.netbeans.api.lexer.TokenSequence;
131.47 +import org.netbeans.junit.NbTestCase;
131.48 +import org.netbeans.lib.lexer.test.LexerTestUtilities;
131.49 +import static org.netbeans.lib.lexer.test.LexerTestUtilities.assertNextTokenEquals;
131.50 +
131.51 +/**
131.52 + * @author Alexey Vladykin
131.53 + */
131.54 +public class MakefileLexerTest extends NbTestCase {
131.55 +
131.56 + public MakefileLexerTest(String testName) {
131.57 + super(testName);
131.58 + }
131.59 +
131.60 + @Override
131.61 + protected void setUp() throws Exception {
131.62 + LexerTestUtilities.setTesting(true);
131.63 + }
131.64 +
131.65 + @Override
131.66 + protected int timeOut() {
131.67 + return 500000;
131.68 + }
131.69 +
131.70 + public void testSimple() {
131.71 + String text = "# Environment\n" +
131.72 + "MKDIR=mkdir\n" +
131.73 + "BUILDDIR=build/${CONF}\n" +
131.74 + "OS := $(shell uname | grep -i Darwin)\n\n" +
131.75 + "build:\n" +
131.76 + "\t$(COMPILE.cc) source.cpp -o source.o\n\n" +
131.77 + ".PHONY: build\n" +
131.78 + "include foo.mk\n";
131.79 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.80 + TokenSequence<?> ts = hi.tokenSequence();
131.81 +
131.82 + assertNextTokenEquals(ts, MakefileTokenId.COMMENT, "# Environment");
131.83 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.84 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "MKDIR");
131.85 + assertNextTokenEquals(ts, MakefileTokenId.EQUALS, "=");
131.86 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "mkdir");
131.87 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.88 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "BUILDDIR");
131.89 + assertNextTokenEquals(ts, MakefileTokenId.EQUALS, "=");
131.90 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "build/");
131.91 + assertNextTokenEquals(ts, MakefileTokenId.MACRO, "${CONF}");
131.92 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.93 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "OS");
131.94 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.95 + assertNextTokenEquals(ts, MakefileTokenId.COLON_EQUALS, ":=");
131.96 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.97 + assertNextTokenEquals(ts, MakefileTokenId.MACRO, "$(shell uname | grep -i Darwin)");
131.98 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.99 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.100 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "build");
131.101 + assertNextTokenEquals(ts, MakefileTokenId.COLON, ":");
131.102 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.103 + assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
131.104 + assertNextTokenEquals(ts, MakefileTokenId.SHELL, "$(COMPILE.cc) source.cpp -o source.o");
131.105 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.106 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.107 + assertNextTokenEquals(ts, MakefileTokenId.SPECIAL_TARGET, ".PHONY");
131.108 + assertNextTokenEquals(ts, MakefileTokenId.COLON, ":");
131.109 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.110 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "build");
131.111 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.112 + assertNextTokenEquals(ts, MakefileTokenId.KEYWORD, "include");
131.113 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.114 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "foo.mk");
131.115 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.116 +
131.117 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.118 + }
131.119 +
131.120 + public void testBare() {
131.121 + String text = "a\\ b := a\\:b a:b a\\ b\na\\ b:";
131.122 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.123 + TokenSequence<?> ts = hi.tokenSequence();
131.124 +
131.125 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "a\\ b");
131.126 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.127 + assertNextTokenEquals(ts, MakefileTokenId.COLON_EQUALS, ":=");
131.128 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.129 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "a\\:b");
131.130 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.131 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "a:b");
131.132 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.133 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "a\\ b");
131.134 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.135 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "a\\ b");
131.136 + assertNextTokenEquals(ts, MakefileTokenId.COLON, ":");
131.137 +
131.138 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.139 + }
131.140 +
131.141 + public void testTabs() {
131.142 + String text = "\tfoo\n\t\tbar\n \tbaz";
131.143 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.144 + TokenSequence<?> ts = hi.tokenSequence();
131.145 +
131.146 + assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
131.147 + assertNextTokenEquals(ts, MakefileTokenId.SHELL, "foo");
131.148 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.149 + assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
131.150 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, "\t");
131.151 + assertNextTokenEquals(ts, MakefileTokenId.SHELL, "bar");
131.152 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.153 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " \t");
131.154 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "baz");
131.155 +
131.156 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.157 + }
131.158 +
131.159 + public void testNewline() {
131.160 + String text = "var = foo\\\n\\\r\n\tbar\n";
131.161 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.162 + TokenSequence<?> ts = hi.tokenSequence();
131.163 +
131.164 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "var");
131.165 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.166 + assertNextTokenEquals(ts, MakefileTokenId.EQUALS, "=");
131.167 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.168 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "foo");
131.169 + assertNextTokenEquals(ts, MakefileTokenId.ESCAPED_NEW_LINE, "\\\n");
131.170 + assertNextTokenEquals(ts, MakefileTokenId.ESCAPED_NEW_LINE, "\\\r\n");
131.171 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, "\t");
131.172 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "bar");
131.173 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.174 +
131.175 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.176 + }
131.177 +
131.178 + public void testShell() {
131.179 + String text = "\t@+-echo foo\\\nbar\\\n\tbaz\nfoo: ; -bar\n";
131.180 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.181 + TokenSequence<?> ts = hi.tokenSequence();
131.182 +
131.183 + assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
131.184 + assertNextTokenEquals(ts, MakefileTokenId.SHELL_MODIFIER, "@");
131.185 + assertNextTokenEquals(ts, MakefileTokenId.SHELL_MODIFIER, "+");
131.186 + assertNextTokenEquals(ts, MakefileTokenId.SHELL_MODIFIER, "-");
131.187 + assertNextTokenEquals(ts, MakefileTokenId.SHELL, "echo foo\\\nbar\\\n\tbaz");
131.188 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.189 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "foo");
131.190 + assertNextTokenEquals(ts, MakefileTokenId.COLON, ":");
131.191 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.192 + assertNextTokenEquals(ts, MakefileTokenId.SEMICOLON, ";");
131.193 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.194 + assertNextTokenEquals(ts, MakefileTokenId.SHELL_MODIFIER, "-");
131.195 + assertNextTokenEquals(ts, MakefileTokenId.SHELL, "bar");
131.196 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.197 +
131.198 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.199 + }
131.200 +
131.201 + public void testMacro() {
131.202 + String text = "ab=$(a\nb)\ncd=$(c\\\nd";
131.203 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.204 + TokenSequence<?> ts = hi.tokenSequence();
131.205 +
131.206 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "ab");
131.207 + assertNextTokenEquals(ts, MakefileTokenId.EQUALS, "=");
131.208 + assertNextTokenEquals(ts, MakefileTokenId.MACRO, "$(a");
131.209 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.210 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "b)");
131.211 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.212 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "cd");
131.213 + assertNextTokenEquals(ts, MakefileTokenId.EQUALS, "=");
131.214 + assertNextTokenEquals(ts, MakefileTokenId.MACRO, "$(c\\\nd");
131.215 +
131.216 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.217 + }
131.218 +
131.219 + public void testComment() {
131.220 + String text = "A=B #\\\nA=B";
131.221 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.222 + TokenSequence<?> ts = hi.tokenSequence();
131.223 +
131.224 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "A");
131.225 + assertNextTokenEquals(ts, MakefileTokenId.EQUALS, "=");
131.226 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "B");
131.227 + assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
131.228 + assertNextTokenEquals(ts, MakefileTokenId.COMMENT, "#\\\nA=B");
131.229 +
131.230 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.231 + }
131.232 +
131.233 + public void testEscapes() {
131.234 + String text = "a\\:=b\nc\\=d\ne\\+=f\n\\:all\\::\n\techo $(a\\) $(c\\) $(e\\)";
131.235 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
131.236 + TokenSequence<?> ts = hi.tokenSequence();
131.237 +
131.238 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "a\\");
131.239 + assertNextTokenEquals(ts, MakefileTokenId.COLON_EQUALS, ":=");
131.240 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "b");
131.241 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.242 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "c\\");
131.243 + assertNextTokenEquals(ts, MakefileTokenId.EQUALS, "=");
131.244 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "d");
131.245 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.246 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "e\\");
131.247 + assertNextTokenEquals(ts, MakefileTokenId.PLUS_EQUALS, "+=");
131.248 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "f");
131.249 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.250 + assertNextTokenEquals(ts, MakefileTokenId.BARE, "\\:all\\:");
131.251 + assertNextTokenEquals(ts, MakefileTokenId.COLON, ":");
131.252 + assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
131.253 + assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
131.254 + assertNextTokenEquals(ts, MakefileTokenId.SHELL, "echo $(a\\) $(c\\) $(e\\)");
131.255 +
131.256 + assertFalse("Unexpected tokens remaining", ts.moveNext());
131.257 + }
131.258 +}
132.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
132.2 +++ b/cnd.script/test/unit/src/org/netbeans/modules/cnd/makefile/parser/MakefileParserTest.java Mon Feb 01 12:24:26 2010 +0100
132.3 @@ -0,0 +1,116 @@
132.4 +/*
132.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
132.6 + *
132.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
132.8 + *
132.9 + * The contents of this file are subject to the terms of either the GNU
132.10 + * General Public License Version 2 only ("GPL") or the Common
132.11 + * Development and Distribution License("CDDL") (collectively, the
132.12 + * "License"). You may not use this file except in compliance with the
132.13 + * License. You can obtain a copy of the License at
132.14 + * http://www.netbeans.org/cddl-gplv2.html
132.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
132.16 + * specific language governing permissions and limitations under the
132.17 + * License. When distributing the software, include this License Header
132.18 + * Notice in each file and include the License file at
132.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
132.20 + * particular file as subject to the "Classpath" exception as provided
132.21 + * by Sun in the GPL Version 2 section of the License file that
132.22 + * accompanied this code. If applicable, add the following below the
132.23 + * License Header, with the fields enclosed by brackets [] replaced by
132.24 + * your own identifying information:
132.25 + * "Portions Copyrighted [year] [name of copyright owner]"
132.26 + *
132.27 + * If you wish your version of this file to be governed by only the CDDL
132.28 + * or only the GPL Version 2, indicate your decision by adding
132.29 + * "[Contributor] elects to include this software in this distribution
132.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
132.31 + * single choice of license, a recipient has the option to distribute
132.32 + * your version of this file under either the CDDL, the GPL Version 2 or
132.33 + * to extend the choice of license to its licensees as provided above.
132.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
132.35 + * Version 2 license, then the option applies only if the new code is
132.36 + * made subject to such option by the copyright holder.
132.37 + *
132.38 + * Contributor(s):
132.39 + *
132.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
132.41 + */
132.42 +package org.netbeans.modules.cnd.makefile.parser;
132.43 +
132.44 +import java.io.File;
132.45 +import java.util.Arrays;
132.46 +import java.util.Collections;
132.47 +import java.util.List;
132.48 +import org.netbeans.api.editor.mimelookup.MimePath;
132.49 +import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
132.50 +import org.netbeans.junit.NbTestCase;
132.51 +import org.netbeans.modules.cnd.makefile.lexer.MakefileTokenId;
132.52 +import org.netbeans.modules.cnd.makefile.model.MakefileAssignment;
132.53 +import org.netbeans.modules.cnd.makefile.model.MakefileElement;
132.54 +import org.netbeans.modules.cnd.makefile.model.MakefileRule;
132.55 +import org.netbeans.modules.cnd.utils.MIMENames;
132.56 +import org.netbeans.modules.parsing.api.Source;
132.57 +import org.netbeans.modules.parsing.spi.ParseException;
132.58 +import org.openide.filesystems.FileObject;
132.59 +import org.openide.filesystems.FileUtil;
132.60 +import static org.junit.Assert.*;
132.61 +
132.62 +/**
132.63 + *
132.64 + * @author Alexey Vladykin
132.65 + */
132.66 +public class MakefileParserTest extends NbTestCase {
132.67 +
132.68 + public MakefileParserTest(String name) {
132.69 + super(name);
132.70 + }
132.71 +
132.72 + @Override
132.73 + public void setUp() throws Exception {
132.74 + super.setUp();
132.75 + MimePath mimePath = MimePath.parse(MIMENames.MAKEFILE_MIME_TYPE);
132.76 + MockMimeLookup.setInstances(mimePath, MakefileTokenId.language());
132.77 + }
132.78 +
132.79 + public void testSample() throws Exception {
132.80 + MakefileModel result = parseFile(new File(getDataDir(), "Makefile1"));
132.81 + assertNotNull(result);
132.82 + List<MakefileElement> elements = result.getElements();
132.83 + assertNotNull(elements);
132.84 +
132.85 + MakefileAssignment rm = (MakefileAssignment) elements.get(0);
132.86 + assertEquals(MakefileElement.Kind.ASSIGNMENT, rm.getKind());
132.87 + assertEquals("RM", rm.getMacroName());
132.88 + assertEquals("rm", rm.getMacroValue());
132.89 +
132.90 + MakefileAssignment cc = (MakefileAssignment) elements.get(1);
132.91 + assertEquals(MakefileElement.Kind.ASSIGNMENT, cc.getKind());
132.92 + assertEquals("CC", cc.getMacroName());
132.93 + assertEquals("gcc", cc.getMacroValue());
132.94 +
132.95 + MakefileRule buildConf = (MakefileRule) elements.get(2);
132.96 + assertEquals(MakefileElement.Kind.RULE, buildConf.getKind());
132.97 + assertEquals(Collections.singletonList(".build-conf"), buildConf.getTargets());
132.98 + assertEquals(Arrays.asList("$(BUILD_SUBPROJECTS)", "dist/Debug/GNU-Solaris-x86/quote_1"), buildConf.getPrerequisites());
132.99 +
132.100 + MakefileRule cleanConf = (MakefileRule) elements.get(3);
132.101 + assertEquals(MakefileElement.Kind.RULE, cleanConf.getKind());
132.102 + assertEquals(Collections.singletonList(".clean-conf"), cleanConf.getTargets());
132.103 + assertEquals(Collections.emptyList(), cleanConf.getPrerequisites());
132.104 +
132.105 + MakefileRule done = (MakefileRule) elements.get(4);
132.106 + assertEquals(MakefileElement.Kind.RULE, done.getKind());
132.107 + assertEquals(Collections.singletonList(".DONE"), done.getTargets());
132.108 + assertEquals(Collections.emptyList(), done.getPrerequisites());
132.109 +
132.110 + assertEquals(5, elements.size());
132.111 + }
132.112 +
132.113 + private MakefileModel parseFile(File file) throws ParseException {
132.114 + FileObject fobj = FileUtil.toFileObject(file);
132.115 + MakefileParser parser = new MakefileParser();
132.116 + parser.parse(Source.create(fobj).createSnapshot(), null, null);
132.117 + return parser.getResult(null);
132.118 + }
132.119 +}
133.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
133.2 +++ b/cnd.script/test/unit/src/org/netbeans/modules/cnd/script/lexer/ShLexerTest.java Mon Feb 01 12:24:26 2010 +0100
133.3 @@ -0,0 +1,139 @@
133.4 +/*
133.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
133.6 + *
133.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
133.8 + *
133.9 + * The contents of this file are subject to the terms of either the GNU
133.10 + * General Public License Version 2 only ("GPL") or the Common
133.11 + * Development and Distribution License("CDDL") (collectively, the
133.12 + * "License"). You may not use this file except in compliance with the
133.13 + * License. You can obtain a copy of the License at
133.14 + * http://www.netbeans.org/cddl-gplv2.html
133.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
133.16 + * specific language governing permissions and limitations under the
133.17 + * License. When distributing the software, include this License Header
133.18 + * Notice in each file and include the License file at
133.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
133.20 + * particular file as subject to the "Classpath" exception as provided
133.21 + * by Sun in the GPL Version 2 section of the License file that
133.22 + * accompanied this code. If applicable, add the following below the
133.23 + * License Header, with the fields enclosed by brackets [] replaced by
133.24 + * your own identifying information:
133.25 + * "Portions Copyrighted [year] [name of copyright owner]"
133.26 + *
133.27 + * If you wish your version of this file to be governed by only the CDDL
133.28 + * or only the GPL Version 2, indicate your decision by adding
133.29 + * "[Contributor] elects to include this software in this distribution
133.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
133.31 + * single choice of license, a recipient has the option to distribute
133.32 + * your version of this file under either the CDDL, the GPL Version 2 or
133.33 + * to extend the choice of license to its licensees as provided above.
133.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
133.35 + * Version 2 license, then the option applies only if the new code is
133.36 + * made subject to such option by the copyright holder.
133.37 + *
133.38 + * Contributor(s):
133.39 + *
133.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
133.41 + */
133.42 +
133.43 +package org.netbeans.modules.cnd.script.lexer;
133.44 +
133.45 +import org.netbeans.modules.cnd.script.lexer.ShLanguageHierarchy;
133.46 +import org.netbeans.api.lexer.TokenHierarchy;
133.47 +import org.netbeans.api.lexer.TokenSequence;
133.48 +import org.netbeans.junit.NbTestCase;
133.49 +import org.netbeans.lib.lexer.test.LexerTestUtilities;
133.50 +import static org.netbeans.modules.cnd.script.lexer.ShTokenId.*;
133.51 +import static org.netbeans.lib.lexer.test.LexerTestUtilities.assertNextTokenEquals;
133.52 +
133.53 +/**
133.54 + * @author Alexey Vladykin
133.55 + */
133.56 +public class ShLexerTest extends NbTestCase {
133.57 +
133.58 + public ShLexerTest(String testName) {
133.59 + super(testName);
133.60 + }
133.61 +
133.62 + @Override
133.63 + protected void setUp() throws Exception {
133.64 + LexerTestUtilities.setTesting(true);
133.65 + }
133.66 +
133.67 + @Override
133.68 + protected int timeOut() {
133.69 + return 500000;
133.70 + }
133.71 +
133.72 + public void testSimple() {
133.73 + String text = "#!/bin/sh\n\n" +
133.74 + "for f in foo.tar foo.bar; do\n" +
133.75 + "\techo if for do $f \\\"asd\\\" \"fasdf\" >/dev/null 2>&1\n" +
133.76 + "done\n\n" +
133.77 + "tar xf foo.tar\n";
133.78 +
133.79 + TokenHierarchy<?> hi = TokenHierarchy.create(text, new ShLanguageHierarchy().language());
133.80 + TokenSequence<?> ts = hi.tokenSequence();
133.81 +
133.82 + assertNextTokenEquals(ts, COMMENT, "#!/bin/sh\n");
133.83 + assertNextTokenEquals(ts, WHITESPACE, "\n");
133.84 + assertNextTokenEquals(ts, KEYWORD, "for");
133.85 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.86 + assertNextTokenEquals(ts, IDENTIFIER, "f");
133.87 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.88 + assertNextTokenEquals(ts, IDENTIFIER, "in");
133.89 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.90 + assertNextTokenEquals(ts, IDENTIFIER, "foo");
133.91 + assertNextTokenEquals(ts, OPERATOR, ".");
133.92 + assertNextTokenEquals(ts, IDENTIFIER, "tar");
133.93 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.94 + assertNextTokenEquals(ts, IDENTIFIER, "foo");
133.95 + assertNextTokenEquals(ts, OPERATOR, ".");
133.96 + assertNextTokenEquals(ts, IDENTIFIER, "bar");
133.97 + assertNextTokenEquals(ts, OPERATOR, ";");
133.98 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.99 + assertNextTokenEquals(ts, KEYWORD, "do");
133.100 + assertNextTokenEquals(ts, WHITESPACE, "\n\t");
133.101 + assertNextTokenEquals(ts, COMMAND, "echo");
133.102 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.103 + assertNextTokenEquals(ts, IDENTIFIER, "if");
133.104 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.105 + assertNextTokenEquals(ts, IDENTIFIER, "for");
133.106 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.107 + assertNextTokenEquals(ts, IDENTIFIER, "do");
133.108 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.109 + assertNextTokenEquals(ts, OPERATOR, "$");
133.110 + assertNextTokenEquals(ts, IDENTIFIER, "f");
133.111 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.112 + assertNextTokenEquals(ts, OPERATOR, "\\\"");
133.113 + assertNextTokenEquals(ts, IDENTIFIER, "asd");
133.114 + assertNextTokenEquals(ts, OPERATOR, "\\\"");
133.115 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.116 + assertNextTokenEquals(ts, STRING, "\"fasdf\"");
133.117 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.118 + assertNextTokenEquals(ts, OPERATOR, ">");
133.119 + assertNextTokenEquals(ts, OPERATOR, "/");
133.120 + assertNextTokenEquals(ts, IDENTIFIER, "dev");
133.121 + assertNextTokenEquals(ts, OPERATOR, "/");
133.122 + assertNextTokenEquals(ts, IDENTIFIER, "null");
133.123 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.124 + assertNextTokenEquals(ts, NUMBER, "2");
133.125 + assertNextTokenEquals(ts, OPERATOR, ">");
133.126 + assertNextTokenEquals(ts, OPERATOR, "&");
133.127 + assertNextTokenEquals(ts, NUMBER, "1");
133.128 + assertNextTokenEquals(ts, WHITESPACE, "\n");
133.129 + assertNextTokenEquals(ts, KEYWORD, "done");
133.130 + assertNextTokenEquals(ts, WHITESPACE, "\n\n");
133.131 + assertNextTokenEquals(ts, COMMAND, "tar");
133.132 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.133 + assertNextTokenEquals(ts, IDENTIFIER, "xf");
133.134 + assertNextTokenEquals(ts, WHITESPACE, " ");
133.135 + assertNextTokenEquals(ts, IDENTIFIER, "foo");
133.136 + assertNextTokenEquals(ts, OPERATOR, ".");
133.137 + assertNextTokenEquals(ts, IDENTIFIER, "tar");
133.138 + assertNextTokenEquals(ts, WHITESPACE, "\n");
133.139 +
133.140 + assertFalse("No more tokens", ts.moveNext());
133.141 + }
133.142 +}
134.1 --- a/cnd.script/test/unit/src/org/netbeans/modules/makefile/editor/MakefileIndentTest.java Mon Feb 01 12:23:06 2010 +0100
134.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
134.3 @@ -1,142 +0,0 @@
134.4 -/*
134.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
134.6 - *
134.7 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
134.8 - *
134.9 - * The contents of this file are subject to the terms of either the GNU
134.10 - * General Public License Version 2 only ("GPL") or the Common
134.11 - * Development and Distribution License("CDDL") (collectively, the
134.12 - * "License"). You may not use this file except in compliance with the
134.13 - * License. You can obtain a copy of the License at
134.14 - * http://www.netbeans.org/cddl-gplv2.html
134.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
134.16 - * specific language governing permissions and limitations under the
134.17 - * License. When distributing the software, include this License Header
134.18 - * Notice in each file and include the License file at
134.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
134.20 - * particular file as subject to the "Classpath" exception as provided
134.21 - * by Sun in the GPL Version 2 section of the License file that
134.22 - * accompanied this code. If applicable, add the following below the
134.23 - * License Header, with the fields enclosed by brackets [] replaced by
134.24 - * your own identifying information:
134.25 - * "Portions Copyrighted [year] [name of copyright owner]"
134.26 - *
134.27 - * If you wish your version of this file to be governed by only the CDDL
134.28 - * or only the GPL Version 2, indicate your decision by adding
134.29 - * "[Contributor] elects to include this software in this distribution
134.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
134.31 - * single choice of license, a recipient has the option to distribute
134.32 - * your version of this file under either the CDDL, the GPL Version 2 or
134.33 - * to extend the choice of license to its licensees as provided above.
134.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
134.35 - * Version 2 license, then the option applies only if the new code is
134.36 - * made subject to such option by the copyright holder.
134.37 - *
134.38 - * Contributor(s):
134.39 - *
134.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
134.41 - */
134.42 -
134.43 -package org.netbeans.modules.makefile.editor;
134.44 -
134.45 -import org.netbeans.modules.cnd.makefile.editor.MakefileIndentTaskFactory;
134.46 -import javax.swing.text.BadLocationException;
134.47 -import org.netbeans.api.editor.mimelookup.MimePath;
134.48 -import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
134.49 -import org.netbeans.editor.BaseDocument;
134.50 -import org.netbeans.junit.MockServices;
134.51 -import org.netbeans.junit.NbTestCase;
134.52 -import org.netbeans.modules.cnd.utils.MIMENames;
134.53 -import org.netbeans.modules.editor.NbEditorDocument;
134.54 -import org.netbeans.modules.editor.indent.api.Indent;
134.55 -
134.56 -/**
134.57 - * @author Alexey Vladykin
134.58 - */
134.59 -public class MakefileIndentTest extends NbTestCase {
134.60 -
134.61 - private static final String MIME_TYPE = MIMENames.MAKEFILE_MIME_TYPE;
134.62 - private MimePath mimePath;
134.63 -
134.64 - public MakefileIndentTest(String name) {
134.65 - super(name);
134.66 - }
134.67 -
134.68 - @Override
134.69 - public void setUp() throws Exception {
134.70 - super.setUp();
134.71 - MakefileIndentTaskFactory factory = new MakefileIndentTaskFactory();
134.72 - MockServices.setServices(MockMimeLookup.class);
134.73 - mimePath = MimePath.parse(MIME_TYPE);
134.74 - MockMimeLookup.setInstances(mimePath, factory);
134.75 - }
134.76 -
134.77 - @Override
134.78 - protected int timeOut() {
134.79 - return 500000;
134.80 - }
134.81 -
134.82 - public void testRuleIndent1() throws BadLocationException {
134.83 - createDocument("build: myapp|");
134.84 - indentNewLine();
134.85 - assertText("build: myapp\n\t");
134.86 - }
134.87 -
134.88 - public void testRuleIndent2() throws BadLocationException {
134.89 - createDocument("build: myapp|\nclean:\n");
134.90 - indentNewLine();
134.91 - assertText("build: myapp\n\t\nclean:\n");
134.92 - }
134.93 -
134.94 - public void testRuleIndent3() throws BadLocationException {
134.95 - createDocument("build: myapp| #comment");
134.96 - indentNewLine();
134.97 - assertText("build: myapp\n\t#comment");
134.98 - }
134.99 -
134.100 - public void testRuleIndent4() throws BadLocationException {
134.101 - createDocument("build:\n\tcc -o a.o a.c|cc -o b.o b.c\n");
134.102 - indentNewLine();
134.103 - createDocument("build:\n\tcc -o a.o a.c\n\tcc -o b.o b.c\n");
134.104 - }
134.105 -
134.106 - public void testCommentIndent() throws BadLocationException {
134.107 - createDocument("#build: myapp|");
134.108 - indentNewLine();
134.109 - assertText("#build: myapp\n");
134.110 - }
134.111 -
134.112 -
134.113 - private BaseDocument doc;
134.114 - private int caretOffset = -1;
134.115 -
134.116 - private void createDocument(String text) throws BadLocationException {
134.117 - doc = new NbEditorDocument(MIME_TYPE);
134.118 - setText(text);
134.119 - }
134.120 -
134.121 - private void setText(String text) throws BadLocationException {
134.122 - doc.remove(0, doc.getLength());
134.123 - caretOffset = text.indexOf('|');
134.124 - if (0 <= caretOffset) {
134.125 - text = text.substring(0, caretOffset) + text.substring(caretOffset + 1);
134.126 - }
134.127 - doc.insertString(0, text, null);
134.128 - }
134.129 -
134.130 - private void indentNewLine() throws BadLocationException {
134.131 - doc.insertString(caretOffset, "\n", null);
134.132 - Indent indent = Indent.get(doc);
134.133 - indent.lock();
134.134 - try {
134.135 - indent.reindent(caretOffset + 1);
134.136 - } finally {
134.137 - indent.unlock();
134.138 - }
134.139 - }
134.140 -
134.141 - private void assertText(String text) throws BadLocationException {
134.142 - assertEquals(text, doc.getText(0, doc.getLength()));
134.143 - }
134.144 -
134.145 -}
135.1 --- a/cnd.script/test/unit/src/org/netbeans/modules/makefile/lexer/MakefileLexerTest.java Mon Feb 01 12:23:06 2010 +0100
135.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
135.3 @@ -1,198 +0,0 @@
135.4 -/*
135.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
135.6 - *
135.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
135.8 - *
135.9 - * The contents of this file are subject to the terms of either the GNU
135.10 - * General Public License Version 2 only ("GPL") or the Common
135.11 - * Development and Distribution License("CDDL") (collectively, the
135.12 - * "License"). You may not use this file except in compliance with the
135.13 - * License. You can obtain a copy of the License at
135.14 - * http://www.netbeans.org/cddl-gplv2.html
135.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
135.16 - * specific language governing permissions and limitations under the
135.17 - * License. When distributing the software, include this License Header
135.18 - * Notice in each file and include the License file at
135.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
135.20 - * particular file as subject to the "Classpath" exception as provided
135.21 - * by Sun in the GPL Version 2 section of the License file that
135.22 - * accompanied this code. If applicable, add the following below the
135.23 - * License Header, with the fields enclosed by brackets [] replaced by
135.24 - * your own identifying information:
135.25 - * "Portions Copyrighted [year] [name of copyright owner]"
135.26 - *
135.27 - * If you wish your version of this file to be governed by only the CDDL
135.28 - * or only the GPL Version 2, indicate your decision by adding
135.29 - * "[Contributor] elects to include this software in this distribution
135.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
135.31 - * single choice of license, a recipient has the option to distribute
135.32 - * your version of this file under either the CDDL, the GPL Version 2 or
135.33 - * to extend the choice of license to its licensees as provided above.
135.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
135.35 - * Version 2 license, then the option applies only if the new code is
135.36 - * made subject to such option by the copyright holder.
135.37 - *
135.38 - * Contributor(s):
135.39 - *
135.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
135.41 - */
135.42 -
135.43 -package org.netbeans.modules.makefile.lexer;
135.44 -
135.45 -import org.netbeans.modules.cnd.makefile.lexer.MakefileLanguageHierarchy;
135.46 -import org.netbeans.api.lexer.TokenHierarchy;
135.47 -import org.netbeans.api.lexer.TokenSequence;
135.48 -import org.netbeans.modules.cnd.makefile.lexer.MakefileTokenId;
135.49 -import org.netbeans.junit.NbTestCase;
135.50 -import org.netbeans.lib.lexer.test.LexerTestUtilities;
135.51 -import static org.netbeans.lib.lexer.test.LexerTestUtilities.assertNextTokenEquals;
135.52 -
135.53 -/**
135.54 - * @author Alexey Vladykin
135.55 - */
135.56 -public class MakefileLexerTest extends NbTestCase {
135.57 -
135.58 - public MakefileLexerTest(String testName) {
135.59 - super(testName);
135.60 - }
135.61 -
135.62 - @Override
135.63 - protected void setUp() throws Exception {
135.64 - LexerTestUtilities.setTesting(true);
135.65 - }
135.66 -
135.67 - @Override
135.68 - protected int timeOut() {
135.69 - return 500000;
135.70 - }
135.71 -
135.72 - public void testSimple() {
135.73 - String text = "# Environment\n" +
135.74 - "MKDIR=mkdir\n" +
135.75 - "BUILDDIR=build/${CONF}\n" +
135.76 - "OS := $(shell uname | grep -i Darwin)\n\n" +
135.77 - "build:\n" +
135.78 - "\t$(COMPILE.cc) source.cpp -o source.o\n\n" +
135.79 - ".PHONY: build\n" +
135.80 - "include foo.mk\n";
135.81 - TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
135.82 - TokenSequence<?> ts = hi.tokenSequence();
135.83 -
135.84 - assertNextTokenEquals(ts, MakefileTokenId.COMMENT, "# Environment");
135.85 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.86 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "MKDIR");
135.87 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, "=");
135.88 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "mkdir");
135.89 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.90 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "BUILDDIR");
135.91 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, "=");
135.92 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "build/");
135.93 - assertNextTokenEquals(ts, MakefileTokenId.MACRO, "${CONF}");
135.94 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.95 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "OS");
135.96 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.97 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, ":=");
135.98 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.99 - assertNextTokenEquals(ts, MakefileTokenId.MACRO, "$(shell uname | grep -i Darwin)");
135.100 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.101 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.102 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "build");
135.103 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, ":");
135.104 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.105 - assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
135.106 - assertNextTokenEquals(ts, MakefileTokenId.SHELL, "$(COMPILE.cc) source.cpp -o source.o");
135.107 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.108 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.109 - assertNextTokenEquals(ts, MakefileTokenId.SPECIAL_TARGET, ".PHONY");
135.110 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, ":");
135.111 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.112 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "build");
135.113 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.114 - assertNextTokenEquals(ts, MakefileTokenId.KEYWORD, "include");
135.115 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.116 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "foo.mk");
135.117 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.118 -
135.119 - assertFalse("Unexpected tokens remaining", ts.moveNext());
135.120 - }
135.121 -
135.122 - public void testBare() {
135.123 - String text = "a\\ b := a\\:b\n";
135.124 - TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
135.125 - TokenSequence<?> ts = hi.tokenSequence();
135.126 -
135.127 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "a\\ b");
135.128 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.129 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, ":=");
135.130 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.131 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "a\\:b");
135.132 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.133 -
135.134 - assertFalse("Unexpected tokens remaining", ts.moveNext());
135.135 - }
135.136 -
135.137 - public void testTabs() {
135.138 - String text = "\tfoo\n\t\tbar\n \tbaz";
135.139 - TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
135.140 - TokenSequence<?> ts = hi.tokenSequence();
135.141 -
135.142 - assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
135.143 - assertNextTokenEquals(ts, MakefileTokenId.SHELL, "foo");
135.144 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.145 - assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
135.146 - assertNextTokenEquals(ts, MakefileTokenId.SHELL, "\tbar");
135.147 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.148 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " \t");
135.149 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "baz");
135.150 -
135.151 - assertFalse("Unexpected tokens remaining", ts.moveNext());
135.152 - }
135.153 -
135.154 - public void testNewline() {
135.155 - String text = "var = foo\\\n\\\r\n\tbar\n";
135.156 - TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
135.157 - TokenSequence<?> ts = hi.tokenSequence();
135.158 -
135.159 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "var");
135.160 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.161 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, "=");
135.162 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, " ");
135.163 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "foo");
135.164 - assertNextTokenEquals(ts, MakefileTokenId.ESCAPED_NEW_LINE, "\\\n");
135.165 - assertNextTokenEquals(ts, MakefileTokenId.ESCAPED_NEW_LINE, "\\\r\n");
135.166 - assertNextTokenEquals(ts, MakefileTokenId.WHITESPACE, "\t");
135.167 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "bar");
135.168 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.169 -
135.170 - assertFalse("Unexpected tokens remaining", ts.moveNext());
135.171 - }
135.172 -
135.173 - public void testShell() {
135.174 - String text = "\techo foo\\\nbar\\\n\tbaz";
135.175 - TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
135.176 - TokenSequence<?> ts = hi.tokenSequence();
135.177 -
135.178 - assertNextTokenEquals(ts, MakefileTokenId.TAB, "\t");
135.179 - assertNextTokenEquals(ts, MakefileTokenId.SHELL, "echo foo\\\nbar\\\n\tbaz");
135.180 -
135.181 - assertFalse("Unexpected tokens remaining", ts.moveNext());
135.182 - }
135.183 -
135.184 - public void testMacro() {
135.185 - String text = "ab=$(a\nb)\ncd=$(c\\\nd)";
135.186 - TokenHierarchy<?> hi = TokenHierarchy.create(text, new MakefileLanguageHierarchy().language());
135.187 - TokenSequence<?> ts = hi.tokenSequence();
135.188 -
135.189 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "ab");
135.190 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, "=");
135.191 - assertNextTokenEquals(ts, MakefileTokenId.MACRO, "$(a");
135.192 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.193 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "b)");
135.194 - assertNextTokenEquals(ts, MakefileTokenId.NEW_LINE, "\n");
135.195 - assertNextTokenEquals(ts, MakefileTokenId.BARE, "cd");
135.196 - assertNextTokenEquals(ts, MakefileTokenId.SEPARATOR, "=");
135.197 - assertNextTokenEquals(ts, MakefileTokenId.MACRO, "$(c\\\nd)");
135.198 -
135.199 - assertFalse("Unexpected tokens remaining", ts.moveNext());
135.200 - }
135.201 -}
136.1 --- a/cnd.script/test/unit/src/org/netbeans/modules/script/lexer/ShLexerTest.java Mon Feb 01 12:23:06 2010 +0100
136.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
136.3 @@ -1,139 +0,0 @@
136.4 -/*
136.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
136.6 - *
136.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
136.8 - *
136.9 - * The contents of this file are subject to the terms of either the GNU
136.10 - * General Public License Version 2 only ("GPL") or the Common
136.11 - * Development and Distribution License("CDDL") (collectively, the
136.12 - * "License"). You may not use this file except in compliance with the
136.13 - * License. You can obtain a copy of the License at
136.14 - * http://www.netbeans.org/cddl-gplv2.html
136.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
136.16 - * specific language governing permissions and limitations under the
136.17 - * License. When distributing the software, include this License Header
136.18 - * Notice in each file and include the License file at
136.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
136.20 - * particular file as subject to the "Classpath" exception as provided
136.21 - * by Sun in the GPL Version 2 section of the License file that
136.22 - * accompanied this code. If applicable, add the following below the
136.23 - * License Header, with the fields enclosed by brackets [] replaced by
136.24 - * your own identifying information:
136.25 - * "Portions Copyrighted [year] [name of copyright owner]"
136.26 - *
136.27 - * If you wish your version of this file to be governed by only the CDDL
136.28 - * or only the GPL Version 2, indicate your decision by adding
136.29 - * "[Contributor] elects to include this software in this distribution
136.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
136.31 - * single choice of license, a recipient has the option to distribute
136.32 - * your version of this file under either the CDDL, the GPL Version 2 or
136.33 - * to extend the choice of license to its licensees as provided above.
136.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
136.35 - * Version 2 license, then the option applies only if the new code is
136.36 - * made subject to such option by the copyright holder.
136.37 - *
136.38 - * Contributor(s):
136.39 - *
136.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
136.41 - */
136.42 -
136.43 -package org.netbeans.modules.script.lexer;
136.44 -
136.45 -import org.netbeans.modules.cnd.script.lexer.ShLanguageHierarchy;
136.46 -import org.netbeans.api.lexer.TokenHierarchy;
136.47 -import org.netbeans.api.lexer.TokenSequence;
136.48 -import org.netbeans.junit.NbTestCase;
136.49 -import org.netbeans.lib.lexer.test.LexerTestUtilities;
136.50 -import static org.netbeans.modules.cnd.script.lexer.ShTokenId.*;
136.51 -import static org.netbeans.lib.lexer.test.LexerTestUtilities.assertNextTokenEquals;
136.52 -
136.53 -/**
136.54 - * @author Alexey Vladykin
136.55 - */
136.56 -public class ShLexerTest extends NbTestCase {
136.57 -
136.58 - public ShLexerTest(String testName) {
136.59 - super(testName);
136.60 - }
136.61 -
136.62 - @Override
136.63 - protected void setUp() throws Exception {
136.64 - LexerTestUtilities.setTesting(true);
136.65 - }
136.66 -
136.67 - @Override
136.68 - protected int timeOut() {
136.69 - return 500000;
136.70 - }
136.71 -
136.72 - public void testSimple() {
136.73 - String text = "#!/bin/sh\n\n" +
136.74 - "for f in foo.tar foo.bar; do\n" +
136.75 - "\techo if for do $f \\\"asd\\\" \"fasdf\" >/dev/null 2>&1\n" +
136.76 - "done\n\n" +
136.77 - "tar xf foo.tar\n";
136.78 -
136.79 - TokenHierarchy<?> hi = TokenHierarchy.create(text, new ShLanguageHierarchy().language());
136.80 - TokenSequence<?> ts = hi.tokenSequence();
136.81 -
136.82 - assertNextTokenEquals(ts, COMMENT, "#!/bin/sh\n");
136.83 - assertNextTokenEquals(ts, WHITESPACE, "\n");
136.84 - assertNextTokenEquals(ts, KEYWORD, "for");
136.85 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.86 - assertNextTokenEquals(ts, IDENTIFIER, "f");
136.87 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.88 - assertNextTokenEquals(ts, IDENTIFIER, "in");
136.89 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.90 - assertNextTokenEquals(ts, IDENTIFIER, "foo");
136.91 - assertNextTokenEquals(ts, OPERATOR, ".");
136.92 - assertNextTokenEquals(ts, IDENTIFIER, "tar");
136.93 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.94 - assertNextTokenEquals(ts, IDENTIFIER, "foo");
136.95 - assertNextTokenEquals(ts, OPERATOR, ".");
136.96 - assertNextTokenEquals(ts, IDENTIFIER, "bar");
136.97 - assertNextTokenEquals(ts, OPERATOR, ";");
136.98 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.99 - assertNextTokenEquals(ts, KEYWORD, "do");
136.100 - assertNextTokenEquals(ts, WHITESPACE, "\n\t");
136.101 - assertNextTokenEquals(ts, COMMAND, "echo");
136.102 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.103 - assertNextTokenEquals(ts, IDENTIFIER, "if");
136.104 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.105 - assertNextTokenEquals(ts, IDENTIFIER, "for");
136.106 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.107 - assertNextTokenEquals(ts, IDENTIFIER, "do");
136.108 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.109 - assertNextTokenEquals(ts, OPERATOR, "$");
136.110 - assertNextTokenEquals(ts, IDENTIFIER, "f");
136.111 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.112 - assertNextTokenEquals(ts, OPERATOR, "\\\"");
136.113 - assertNextTokenEquals(ts, IDENTIFIER, "asd");
136.114 - assertNextTokenEquals(ts, OPERATOR, "\\\"");
136.115 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.116 - assertNextTokenEquals(ts, STRING, "\"fasdf\"");
136.117 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.118 - assertNextTokenEquals(ts, OPERATOR, ">");
136.119 - assertNextTokenEquals(ts, OPERATOR, "/");
136.120 - assertNextTokenEquals(ts, IDENTIFIER, "dev");
136.121 - assertNextTokenEquals(ts, OPERATOR, "/");
136.122 - assertNextTokenEquals(ts, IDENTIFIER, "null");
136.123 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.124 - assertNextTokenEquals(ts, NUMBER, "2");
136.125 - assertNextTokenEquals(ts, OPERATOR, ">");
136.126 - assertNextTokenEquals(ts, OPERATOR, "&");
136.127 - assertNextTokenEquals(ts, NUMBER, "1");
136.128 - assertNextTokenEquals(ts, WHITESPACE, "\n");
136.129 - assertNextTokenEquals(ts, KEYWORD, "done");
136.130 - assertNextTokenEquals(ts, WHITESPACE, "\n\n");
136.131 - assertNextTokenEquals(ts, COMMAND, "tar");
136.132 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.133 - assertNextTokenEquals(ts, IDENTIFIER, "xf");
136.134 - assertNextTokenEquals(ts, WHITESPACE, " ");
136.135 - assertNextTokenEquals(ts, IDENTIFIER, "foo");
136.136 - assertNextTokenEquals(ts, OPERATOR, ".");
136.137 - assertNextTokenEquals(ts, IDENTIFIER, "tar");
136.138 - assertNextTokenEquals(ts, WHITESPACE, "\n");
136.139 -
136.140 - assertFalse("No more tokens", ts.moveNext());
136.141 - }
136.142 -}
137.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/actions/BuildToolsAction.java Mon Feb 01 12:23:06 2010 +0100
137.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
137.3 @@ -1,179 +0,0 @@
137.4 -/*
137.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
137.6 - *
137.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
137.8 - *
137.9 - * The contents of this file are subject to the terms of either the GNU
137.10 - * General Public License Version 2 only ("GPL") or the Common
137.11 - * Development and Distribution License("CDDL") (collectively, the
137.12 - * "License"). You may not use this file except in compliance with the
137.13 - * License. You can obtain a copy of the License at
137.14 - * http://www.netbeans.org/cddl-gplv2.html
137.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
137.16 - * specific language governing permissions and limitations under the
137.17 - * License. When distributing the software, include this License Header
137.18 - * Notice in each file and include the License file at
137.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
137.20 - * particular file as subject to the "Classpath" exception as provided
137.21 - * by Sun in the GPL Version 2 section of the License file that
137.22 - * accompanied this code. If applicable, add the following below the
137.23 - * License Header, with the fields enclosed by brackets [] replaced by
137.24 - * your own identifying information:
137.25 - * "Portions Copyrighted [year] [name of copyright owner]"
137.26 - *
137.27 - * Contributor(s):
137.28 - *
137.29 - * The Original Software is NetBeans. The Initial Developer of the Original
137.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
137.31 - * Microsystems, Inc. All Rights Reserved.
137.32 - *
137.33 - * If you wish your version of this file to be governed by only the CDDL
137.34 - * or only the GPL Version 2, indicate your decision by adding
137.35 - * "[Contributor] elects to include this software in this distribution
137.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
137.37 - * single choice of license, a recipient has the option to distribute
137.38 - * your version of this file under either the CDDL, the GPL Version 2 or
137.39 - * to extend the choice of license to its licensees as provided above.
137.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
137.41 - * Version 2 license, then the option applies only if the new code is
137.42 - * made subject to such option by the copyright holder.
137.43 - */
137.44 -
137.45 -package org.netbeans.modules.cnd.toolchain.actions;
137.46 -
137.47 -import java.awt.Dialog;
137.48 -import java.awt.Dimension;
137.49 -import java.awt.event.ActionEvent;
137.50 -import java.beans.PropertyChangeEvent;
137.51 -import java.beans.PropertyChangeListener;
137.52 -import java.util.ArrayList;
137.53 -import javax.swing.JButton;
137.54 -import javax.swing.JPanel;
137.55 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
137.56 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
137.57 -import org.netbeans.modules.cnd.toolchain.ui.options.DownloadUtils;
137.58 -import org.netbeans.modules.cnd.toolchain.ui.api.LocalToolsPanelModel;
137.59 -import org.netbeans.modules.cnd.toolchain.ui.options.ToolsPanel;
137.60 -import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelModel;
137.61 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
137.62 -import org.openide.DialogDescriptor;
137.63 -import org.openide.DialogDisplayer;
137.64 -import org.openide.util.HelpCtx;
137.65 -import org.openide.util.NbBundle;
137.66 -import org.openide.util.actions.CallableSystemAction;
137.67 -
137.68 -/**
137.69 - * Post the ToolsPanel as a standalone dialog.
137.70 - *
137.71 - * @author gordonp
137.72 - */
137.73 -public class BuildToolsAction extends CallableSystemAction implements PropertyChangeListener {
137.74 -
137.75 - private String title;
137.76 - private String name;
137.77 - private JButton jOK = null;
137.78 - private ToolsPanel tp;
137.79 - private ToolsPanelModel model;
137.80 -
137.81 - public BuildToolsAction() {
137.82 - name = NbBundle.getMessage(BuildToolsAction.class, "LBL_BuildToolsName"); // NOI18N
137.83 - title = NbBundle.getMessage(BuildToolsAction.class, "LBL_BuildToolsTitle"); // NOI18N
137.84 - }
137.85 -
137.86 - @Override
137.87 - public String getName() {
137.88 - return name;
137.89 - }
137.90 -
137.91 - public void setName(String name) {
137.92 - this.name = name;
137.93 - }
137.94 -
137.95 - public String getTitle() {
137.96 - return title;
137.97 - }
137.98 -
137.99 - public void setTitle(String title) {
137.100 - this.title = title;
137.101 - }
137.102 -
137.103 - @Override
137.104 - public void performAction() {
137.105 - initBuildTools(new LocalToolsPanelModel(), new ArrayList<String>(), null);
137.106 - }
137.107 -
137.108 - @Override
137.109 - public void propertyChange(PropertyChangeEvent ev) {
137.110 - if (ev.getPropertyName().equals(ToolsPanel.PROP_VALID) &&
137.111 - ev.getSource() instanceof ToolsPanel) {
137.112 - jOK.setEnabled(((Boolean) ev.getNewValue()).booleanValue());
137.113 - }
137.114 - }
137.115 -
137.116 - public ToolsPanelModel getModel() {
137.117 - return model;
137.118 - }
137.119 -
137.120 - /**
137.121 - * Initialize the build tools
137.122 - *
137.123 - * @returns true if the user pressed OK, false if Cancel
137.124 - */
137.125 - public boolean initBuildTools(ToolsPanelModel model, ArrayList<String> errs, CompilerSet cs) {
137.126 - if (downloadIfNeed(model, cs)){
137.127 - return true;
137.128 - }
137.129 - tp = new ToolsPanel(model);
137.130 - tp.addPropertyChangeListener(this);
137.131 - jOK = new JButton(NbBundle.getMessage(BuildToolsAction.class, "BTN_OK")); // NOI18N
137.132 - tp.setPreferredSize(new Dimension(900, 550));
137.133 - tp.update(errs);
137.134 - DialogDescriptor dd = new DialogDescriptor((Object) constructOuterPanel(tp), getTitle(), true,
137.135 - new Object[] { jOK, DialogDescriptor.CANCEL_OPTION},
137.136 - DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, null, null);
137.137 - Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
137.138 - dialog.setVisible(true);
137.139 - if (dd.getValue() == jOK) {
137.140 - tp.applyChanges(true);
137.141 - return true;
137.142 - }
137.143 - return false;
137.144 - }
137.145 -
137.146 - private boolean downloadIfNeed(ToolsPanelModel model, CompilerSet cs){
137.147 - ExecutionEnvironment env = model.getSelectedDevelopmentHost();
137.148 - if (env.isLocal()){
137.149 - if (cs == null) {
137.150 - cs = CompilerSetManager.getDefault().getDefaultCompilerSet();
137.151 - }
137.152 - if (cs != null) {
137.153 - if (cs.isUrlPointer()){
137.154 - // Can be downloaded
137.155 - return DownloadUtils.showDownloadConfirmation(cs);
137.156 - }
137.157 - }
137.158 - }
137.159 - return false;
137.160 - }
137.161 -
137.162 - private JPanel constructOuterPanel(JPanel innerPanel) {
137.163 - JPanel panel = new JPanel();
137.164 - panel.setLayout(new java.awt.GridBagLayout());
137.165 - java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
137.166 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
137.167 - gridBagConstraints.weightx = 1.0;
137.168 - gridBagConstraints.weighty = 1.0;
137.169 - gridBagConstraints.insets = new java.awt.Insets(16, 16, 16, 16);
137.170 - panel.add(innerPanel, gridBagConstraints);
137.171 - return panel;
137.172 - }
137.173 -
137.174 - @Override
137.175 - public void actionPerformed(ActionEvent ev) {
137.176 - performAction();
137.177 - }
137.178 -
137.179 - public HelpCtx getHelpCtx() {
137.180 - return null;
137.181 - }
137.182 -}
138.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/actions/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
138.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
138.3 @@ -1,47 +0,0 @@
138.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
138.5 -#
138.6 -# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
138.7 -#
138.8 -# The contents of this file are subject to the terms of either the GNU
138.9 -# General Public License Version 2 only ("GPL") or the Common
138.10 -# Development and Distribution License("CDDL") (collectively, the
138.11 -# "License"). You may not use this file except in compliance with the
138.12 -# License. You can obtain a copy of the License at
138.13 -# http://www.netbeans.org/cddl-gplv2.html
138.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
138.15 -# specific language governing permissions and limitations under the
138.16 -# License. When distributing the software, include this License Header
138.17 -# Notice in each file and include the License file at
138.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
138.19 -# particular file as subject to the "Classpath" exception as provided
138.20 -# by Sun in the GPL Version 2 section of the License file that
138.21 -# accompanied this code. If applicable, add the following below the
138.22 -# License Header, with the fields enclosed by brackets [] replaced by
138.23 -# your own identifying information:
138.24 -# "Portions Copyrighted [year] [name of copyright owner]"
138.25 -#
138.26 -# Contributor(s):
138.27 -#
138.28 -# The Original Software is NetBeans. The Initial Developer of the Original
138.29 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
138.30 -# Microsystems, Inc. All Rights Reserved.
138.31 -#
138.32 -# If you wish your version of this file to be governed by only the CDDL
138.33 -# or only the GPL Version 2, indicate your decision by adding
138.34 -# "[Contributor] elects to include this software in this distribution
138.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
138.36 -# single choice of license, a recipient has the option to distribute
138.37 -# your version of this file under either the CDDL, the GPL Version 2 or
138.38 -# to extend the choice of license to its licensees as provided above.
138.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
138.40 -# Version 2 license, then the option applies only if the new code is
138.41 -# made subject to such option by the copyright holder.
138.42 -
138.43 -BTN_OK=OK
138.44 -
138.45 -# BuildToolsAction
138.46 -LBL_BuildToolsName=Native Build Tools...
138.47 -LBL_BuildToolsTitle=Native Build Tools Setup
138.48 -LBL_InitializeBuildSystem_Title=Initialize Native Build Tools
138.49 -LBL_ResolveMissingTools_Title=Resolve Missing Native Build Tools
138.50 -LBL_ResolveMissingCompilerSets_Title=Resolve Missing Compiler Collections
139.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
139.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
139.3 @@ -31,216 +31,14 @@
139.4 # Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
139.5 # Microsystems, Inc. All Rights Reserved.
139.6
139.7 -# Compiler Collection names for the 1st of each flavor
139.8 -LBL_CygwinCompilerSet_0=GNU Compiler Collection from Cygwin
139.9 -LBL_MinGWCompilerSet_0=GNU Compiler Collection from MinGW
139.10 -LBL_InterixCompilerSet_0=GNU Compiler Collection from Interix/Microsoft
139.11 -LBL_DJGPPCompilerSet_0=GNU Compiler Collection from DJGPP
139.12 -LBL_SunStudio_13CompilerSet_0=Sun Studio 13 Compiler Collection
139.13 -LBL_SunStudio_12CompilerSet_0=Sun Studio 12 Compiler Collection
139.14 -LBL_SunStudio_11CompilerSet_0=Sun Studio 11 Compiler Collection
139.15 -LBL_SunStudio_10CompilerSet_0=Sun Studio 10 Compiler Collection
139.16 -LBL_SunStudio_9CompilerSet_0=Sun Studio 9 Compiler Collection
139.17 -LBL_SunStudio_8CompilerSet_0=Sun Studio 8 Compiler Collection
139.18 -LBL_SunStudioCompilerSet_0=Sun Studio Compiler Collection
139.19 -LBL_SunUCBCompilerSet_0=Sun UCB Compatible C Compiler
139.20 -LBL_GNUCompilerSet_0=GNU Compiler Collection
139.21 -LBL_UnknownCompilerSet_0=Generic Compiler Collection
139.22 -
139.23 -# Compiler Collection names for subsequent instances of each flavor
139.24 -#LBL_CygwinCompilerSet_X=GNU Compiler Collection from Cygwin [{0}]
139.25 -#LBL_MinGWCompilerSet_X=GNU Compiler Collection from MinGW [{0}]
139.26 -#LBL_InterixCompilerSet_X=GNU Compiler Collection from Interix/Microsoft [{0}]
139.27 -#LBL_DJGPPCompilerSet_X=GNU Compiler Collection from DJGPP [{0}]
139.28 -#LBL_SunStudio_12CompilerSet_X=Sun Studio 12 Compiler Collection [{0}]
139.29 -#LBL_SunStudio_11CompilerSet_X=Sun Studio 11 Compiler Collection [{0}]
139.30 -#LBL_SunStudio_10CompilerSet_X=Sun Studio 10 Compiler Collection [{0}]
139.31 -#LBL_SunStudio_9CompilerSet_X=Sun Studio 9 Compiler Collection [{0}]
139.32 -#LBL_SunStudio_8CompilerSet_X=Sun Studio 8 Compiler Collection [{0}]
139.33 -#LBL_SunStudioCompilerSet_X=Sun Studio Compiler Collection [{0}]
139.34 -#LBL_SunUCBCompilerSet_X=Sun UCB Compatible C Compiler [{0}]
139.35 -#LBL_GNUCompilerSet_X=GNU Compiler Collection [{0}]
139.36 -#LBL_UnknownCompilerSet_X=Generic Compiler Collection [{0}]
139.37 -
139.38 -# Compiler Collection names for missing compilers
139.39 -#LBL_CygwinCompilerSet_Missing=GNU Compiler Collection from Cygwin [Missing Compilers]
139.40 -#LBL_MinGWCompilerSet_Missing=GNU Compiler Collection from MinGW [Missing Compilers]
139.41 -#LBL_InterixCompilerSet_Missing=GNU Compiler Collection from Interix/Microsoft [Missing Compilers]
139.42 -#LBL_DJGPPCompilerSet_Missing=GNU Compiler Collection from DJGPP [Missing Compilers]
139.43 -#LBL_SunStudio_12CompilerSet_Missing=Sun Studio 12 Compiler Collection [Missing Compilers]
139.44 -#LBL_SunStudio_11CompilerSet_Missing=Sun Studio 11 Compiler Collection [Missing Compilers]
139.45 -#LBL_SunStudio_10CompilerSet_Missing=Sun Studio 10 Compiler Collection [Missing Compilers]
139.46 -#LBL_SunStudio_9CompilerSet_Missing=Sun Studio 9 Compiler Collection [Missing Compilers]
139.47 -#LBL_SunStudio_8CompilerSet_Missing=Sun Studio 8 Compiler Collection [Missing Compilers]
139.48 -#LBL_SunStudioCompilerSet_Missing=Sun Studio Compiler Collection [Missing Compilers]
139.49 -#LBL_SunUCBCompilerSet_Missing=Sun UCB Compatible C Compiler [Missing Compilers]
139.50 -#LBL_GNUCompilerSet_Missing=GNU Compiler Collection [Missing Compilers]
139.51 -#LBL_UnknownCompilerSet_Missing=Generic Compiler Collection [Missing Compilers]
139.52 -
139.53 -LBL_EmptyCompilerSetName=None
139.54 -LBL_EmptyCompilerSetDisplayName=No Compilers Found
139.55 -
139.56 CCompiler=C Compiler
139.57 CCCompiler=C++ Compiler
139.58 FortranCompiler=Fortran Compiler
139.59 -CustomBuildTool=Custom Build Tool
139.60 +CustomTool=Custom Build Tool
139.61 Assembler=Assembler
139.62 MakeTool=Make Tool
139.63 DebuggerTool=Debugger
139.64 QMakeTool=QMake Tool
139.65 CMakeTool=CMake Tool
139.66 +UnknownTool=Unknown Tool
139.67
139.68 -# Missing compiler display names
139.69 -#LBL_NoCCompiler=No C Compiler Found
139.70 -#LBL_NoCppCompiler=No C++ Compiler Found
139.71 -#LBL_NoFortranCompiler=No Fortran Compiler Found
139.72 -#LBL_NoCustomBuildTool=No Custom Build Tool Found
139.73 -#LBL_NoAssembler=No Assembler Found
139.74 -#LBL_NoMakeTool=No Make Tool Found
139.75 -#LBL_NoDebuggerTool=No Debugger Found
139.76 -
139.77 -# CompilerSetManager
139.78 -NO_COMPILERS_FOUND_TITLE=No Compilers Found
139.79 -NO_COMPILERS_FOUND_MSG=\
139.80 -No suitable compilers were found on your system. The IDE needs a suitable set of compilers and other build tools in order to work correctly.\n\n\
139.81 -If you already have compilers on your system but they were not found, do one of the following:\n\n\
139.82 -1) Exit the IDE, add your compilers to your PATH environment variable, and restart the IDE.\n\n\
139.83 -2) Open the Build Tool dialog in Tools | Options | C/C++ | Build Tools and add your compiler(s) to the setup.\n\n\
139.84 -If you do not already have compilers on your system, do:\n\n\
139.85 -3) Download and install a suitable set of compilers and restart the IDE.\n\n\
139.86 -Visit http://www.netbeans.org/community/releases/65/cpp-setup-instructions.html for further assistance in installing and configuring a build environment.
139.87 -
139.88 -# CSM_ stands for CompilerSetManager
139.89 -CSM_Conn=Connecting to {0}...
139.90 -CSM_Done= done.
139.91 -CSM_ValPlatf=Validating platform... found {0}
139.92 -CSM_LFTC=Looking for tool collections:
139.93 -CSM_Found= Found {0} at {1}.
139.94 -CSM_Err= Error creating compiler set {0}
139.95 -CSM_Done_NF=Done. No tool collections were found in default locations.\nYou can configure them manually later using\n Tools > Options > C/C++ > Build Tools dialog.
139.96 -CSM_Done_OK=Done. Found {0} tool collection(s).
139.97 -CSM_Conigured=Your host was successfully configured.
139.98 -CSM_Fail=...failed. Hostname is wrong or host is offline.
139.99 -CSM_Initializing_Tool=Checking {0} ...
139.100 -
139.101 -PROGRESS_TEXT=Initializing compiler sets on {0}
139.102 -
139.103 -DetectHostInfo=\
139.104 -PLATFORM_SOLARIS_SPARC=0\n\
139.105 -PLATFORM_SOLARIS_INTEL=1\n\
139.106 -PLATFORM_LINUX=2\n\
139.107 -PLATFORM_WINDOWS=3\n\
139.108 -PLATFORM_MACOSX=4\n\
139.109 -PLATFORM_GENERIC=5\n\
139.110 -PLATFORM_NONE=6\n\
139.111 -detectHostInfo() {\n\
139.112 - PLATFORM=$PLATFORM_NONE\n\
139.113 - OPATH=$PATH\n\
139.114 - PATH=/usr/bin:/bin:$PATH\n\
139.115 - OS=`uname -s`\n\
139.116 - ARCH=`uname -m`\n\
139.117 - PATH=$OPATH\n\
139.118 - if [ "$OS" = "SunOS" ]; then\n\
139.119 - if [ "$ARCH" = "i86pc" ]; then\n\
139.120 - PLATFORM=$PLATFORM_SOLARIS_INTEL\n\
139.121 - else\n\
139.122 - PLATFORM=$PLATFORM_SOLARIS_SPARC\n\
139.123 - fi\n\
139.124 - else\n\
139.125 - if [ "$OS" = "Linux" ]; then\n\
139.126 - PLATFORM=$PLATFORM_LINUX\n\
139.127 - else\n\
139.128 - if [ "$OS" = "Darwin" ]; then\n\
139.129 - PLATFORM=$PLATFORM_MACOSX\n\
139.130 - else\n\
139.131 - echo ${OS} | grep _NT- >/dev/null\n\
139.132 - status=$?\n\
139.133 - if [ status -eq 0 ]; then\n\
139.134 - PLATFORM=$PLATFORM_WINDOWS\n\
139.135 - else\n\
139.136 - PLATFORM=$PLATFORM_NONE\n\
139.137 - fi\n\
139.138 - fi\n\
139.139 - fi\n\
139.140 - fi\n\
139.141 - echo $PLATFORM\n\
139.142 -}\n\
139.143 -PLATFORM=`detectHostInfo`\n\
139.144 -PLATFORM_NAME=\n\
139.145 -if [ "$PLATFORM" = "$PLATFORM_SOLARIS_SPARC" ]; then\n\
139.146 - PLATFORM_NAME="PLATFORM_SOLARIS_SPARC"\n\
139.147 -fi\n\
139.148 -if [ "$PLATFORM" = "$PLATFORM_SOLARIS_INTEL" ]; then\n\
139.149 - PLATFORM_NAME="PLATFORM_SOLARIS_INTEL"\n\
139.150 -fi\n\
139.151 -if [ "$PLATFORM" = "$PLATFORM_LINUX" ]; then\n\
139.152 - PLATFORM_NAME="PLATFORM_LINUX"\n\
139.153 -fi\n\
139.154 -if [ "$PLATFORM" = "$PLATFORM_WINDOWS" ]; then\n\
139.155 - PLATFORM_NAME="PLATFORM_WINDOWS"\n\
139.156 -fi\n\
139.157 -if [ "$PLATFORM" = "$PLATFORM_MACOSX" ]; then\n\
139.158 - PLATFORM_NAME="PLATFORM_MACOSX"\n\
139.159 -fi\n\
139.160 -if [ "$PLATFORM" = "$PLATFORM_NONE" ]; then\n\
139.161 - PLATFORM_NAME="PLATFORM_NONE"\n\
139.162 -fi\n\
139.163 -findInPath() {\n\
139.164 - for f1 in $PATHSLIST; do\n\
139.165 - pathStatus=\n\
139.166 - echo $f1 | egrep -e "^/" >/dev/null\n\
139.167 - if [ "$?" != "0" ]; then\n\
139.168 - continue # skip relative directories\n\
139.169 - fi\n\
139.170 - echo $f1 | egrep -e "^/usr/ucb" >/dev/null\n\
139.171 - if [ "$?" = "0" ]; then\n\
139.172 - continue # skip /usr/ucb (IZ #142780)\n\
139.173 - fi\n\
139.174 - for f2 in $1; do\n\
139.175 - if [ -x "$f1/$f2" ]; then\n\
139.176 - pathStatus="$f1/$f2"\n\
139.177 - else\n\
139.178 - if [ "$PLATFORM" = "$PLATFORM_WINDOWS" ]; then\n\
139.179 - if [ -x "$f1/$f2.exe" ]; then\n\
139.180 - pathStatus="$f1/$f2.exe"\n\
139.181 - fi\n\
139.182 - fi\n\
139.183 - if [ -n "$pathStatus" ]; then\n\
139.184 - break\n\
139.185 - fi\n\
139.186 - fi\n\
139.187 - done\n\
139.188 - if [ -n "$pathStatus" ]; then\n\
139.189 - break\n\
139.190 - fi\n\
139.191 - done\n\
139.192 - if [ -n "$pathStatus" ]; then\n\
139.193 - echo $pathStatus\n\
139.194 - fi\n\
139.195 -}\n\
139.196 -addNewToolChain() {\n\
139.197 - if [ -n "$line" ]; then\n\
139.198 - echo $foundFlavors | egrep -e ";${flavor}" >/dev/null\n\
139.199 - if [ ! "$?" = "0" ]; then\n\
139.200 - echo $line\n\
139.201 - foundFlavors=$foundFlavors$flavor\n\
139.202 - fi\n\
139.203 - fi\n\
139.204 -}\n\
139.205 -findCompiler() {\n\
139.206 - status=\n\
139.207 - for f3 in $1; do\n\
139.208 - if [ ! -n "$status" ]; then\n\
139.209 - if [ -x "$f/$f3" ]; then\n\
139.210 - line="$line;$2=$f/$f3"\n\
139.211 - status=1\n\
139.212 - fi\n\
139.213 - fi\n\
139.214 - done\n\
139.215 - if [ ! -n "$status" ]; then\n\
139.216 - status=`findInPath "$1"`\n\
139.217 - if [ -n "$status" ]; then\n\
139.218 - line="$line;$2(PATH)=$status"\n\
139.219 - fi\n\
139.220 - fi\n\
139.221 -}
140.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
140.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerFlavor.java Mon Feb 01 12:24:26 2010 +0100
140.3 @@ -0,0 +1,62 @@
140.4 +/*
140.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
140.6 + *
140.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
140.8 + *
140.9 + * The contents of this file are subject to the terms of either the GNU
140.10 + * General Public License Version 2 only ("GPL") or the Common
140.11 + * Development and Distribution License("CDDL") (collectively, the
140.12 + * "License"). You may not use this file except in compliance with the
140.13 + * License. You can obtain a copy of the License at
140.14 + * http://www.netbeans.org/cddl-gplv2.html
140.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
140.16 + * specific language governing permissions and limitations under the
140.17 + * License. When distributing the software, include this License Header
140.18 + * Notice in each file and include the License file at
140.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
140.20 + * particular file as subject to the "Classpath" exception as provided
140.21 + * by Sun in the GPL Version 2 section of the License file that
140.22 + * accompanied this code. If applicable, add the following below the
140.23 + * License Header, with the fields enclosed by brackets [] replaced by
140.24 + * your own identifying information:
140.25 + * "Portions Copyrighted [year] [name of copyright owner]"
140.26 + *
140.27 + * If you wish your version of this file to be governed by only the CDDL
140.28 + * or only the GPL Version 2, indicate your decision by adding
140.29 + * "[Contributor] elects to include this software in this distribution
140.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
140.31 + * single choice of license, a recipient has the option to distribute
140.32 + * your version of this file under either the CDDL, the GPL Version 2 or
140.33 + * to extend the choice of license to its licensees as provided above.
140.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
140.35 + * Version 2 license, then the option applies only if the new code is
140.36 + * made subject to such option by the copyright holder.
140.37 + *
140.38 + * Contributor(s):
140.39 + *
140.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
140.41 + */
140.42 +
140.43 +package org.netbeans.modules.cnd.toolchain.api;
140.44 +
140.45 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
140.46 +
140.47 +/**
140.48 + *
140.49 + * @author Alexander Simon
140.50 + */
140.51 +public interface CompilerFlavor {
140.52 +
140.53 + String getCommandFolder(int platform);
140.54 +
140.55 + ToolchainDescriptor getToolchainDescriptor();
140.56 +
140.57 + boolean isCygwinCompiler();
140.58 +
140.59 + boolean isGnuCompiler();
140.60 +
140.61 + boolean isMinGWCompiler();
140.62 +
140.63 + boolean isSunStudioCompiler();
140.64 +
140.65 +}
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
141.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerFlavorAccessor.java Mon Feb 01 12:24:26 2010 +0100
141.3 @@ -0,0 +1,92 @@
141.4 +/*
141.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
141.6 + *
141.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
141.8 + *
141.9 + * The contents of this file are subject to the terms of either the GNU
141.10 + * General Public License Version 2 only ("GPL") or the Common
141.11 + * Development and Distribution License("CDDL") (collectively, the
141.12 + * "License"). You may not use this file except in compliance with the
141.13 + * License. You can obtain a copy of the License at
141.14 + * http://www.netbeans.org/cddl-gplv2.html
141.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
141.16 + * specific language governing permissions and limitations under the
141.17 + * License. When distributing the software, include this License Header
141.18 + * Notice in each file and include the License file at
141.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
141.20 + * particular file as subject to the "Classpath" exception as provided
141.21 + * by Sun in the GPL Version 2 section of the License file that
141.22 + * accompanied this code. If applicable, add the following below the
141.23 + * License Header, with the fields enclosed by brackets [] replaced by
141.24 + * your own identifying information:
141.25 + * "Portions Copyrighted [year] [name of copyright owner]"
141.26 + *
141.27 + * If you wish your version of this file to be governed by only the CDDL
141.28 + * or only the GPL Version 2, indicate your decision by adding
141.29 + * "[Contributor] elects to include this software in this distribution
141.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
141.31 + * single choice of license, a recipient has the option to distribute
141.32 + * your version of this file under either the CDDL, the GPL Version 2 or
141.33 + * to extend the choice of license to its licensees as provided above.
141.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
141.35 + * Version 2 license, then the option applies only if the new code is
141.36 + * made subject to such option by the copyright holder.
141.37 + *
141.38 + * Contributor(s):
141.39 + *
141.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
141.41 + */
141.42 +
141.43 +package org.netbeans.modules.cnd.toolchain.api;
141.44 +
141.45 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetImpl;
141.46 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerFlavorImpl;
141.47 +import java.util.List;
141.48 +
141.49 +/**
141.50 + *
141.51 + * @author Alexander Simon
141.52 + */
141.53 +public class CompilerFlavorAccessor {
141.54 + private CompilerFlavorAccessor() {
141.55 + }
141.56 +
141.57 + public static CompilerFlavor getUnknown(int platform) {
141.58 + return CompilerFlavorImpl.getUnknown(platform);
141.59 + }
141.60 +
141.61 + public static List<CompilerFlavor> getFlavors(int platform) {
141.62 + return CompilerFlavorImpl.getFlavors(platform);
141.63 + }
141.64 +
141.65 + public static CompilerFlavor toFlavor(String name, int platform) {
141.66 + return CompilerFlavorImpl.toFlavor(name, platform);
141.67 + }
141.68 +
141.69 + public static String mapOldToNew(String flavor, int version) {
141.70 + if (version <= 43) {
141.71 + if (flavor.equals("Sun")) { // NOI18N
141.72 + return "SunStudio"; // NOI18N
141.73 + } else if (flavor.equals("SunExpress")) { // NOI18N
141.74 + return "SunStudioExpress"; // NOI18N
141.75 + } else if (flavor.equals("Sun12")) { // NOI18N
141.76 + return "SunStudio_12"; // NOI18N
141.77 + } else if (flavor.equals("Sun11")) { // NOI18N
141.78 + return "SunStudio_11"; // NOI18N
141.79 + } else if (flavor.equals("Sun10")) { // NOI18N
141.80 + return "SunStudio_10"; // NOI18N
141.81 + } else if (flavor.equals("Sun9")) { // NOI18N
141.82 + return "SunStudio_9"; // NOI18N
141.83 + } else if (flavor.equals("Sun8")) { // NOI18N
141.84 + return "SunStudio_8"; // NOI18N
141.85 + } else if (flavor.equals("DJGPP")) { // NOI18N
141.86 + return "GNU"; // NOI18N
141.87 + } else if (flavor.equals("Interix")) { // NOI18N
141.88 + return "GNU"; // NOI18N
141.89 + } else if (flavor.equals(CompilerSetImpl.UNKNOWN)) {
141.90 + return "GNU"; // NOI18N
141.91 + }
141.92 + }
141.93 + return flavor;
141.94 + }
141.95 +}
142.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerProvider.java Mon Feb 01 12:23:06 2010 +0100
142.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
142.3 @@ -1,88 +0,0 @@
142.4 -/*
142.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
142.6 - *
142.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
142.8 - *
142.9 - * The contents of this file are subject to the terms of either the GNU
142.10 - * General Public License Version 2 only ("GPL") or the Common
142.11 - * Development and Distribution License("CDDL") (collectively, the
142.12 - * "License"). You may not use this file except in compliance with the
142.13 - * License. You can obtain a copy of the License at
142.14 - * http://www.netbeans.org/cddl-gplv2.html
142.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
142.16 - * specific language governing permissions and limitations under the
142.17 - * License. When distributing the software, include this License Header
142.18 - * Notice in each file and include the License file at
142.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
142.20 - * particular file as subject to the "Classpath" exception as provided
142.21 - * by Sun in the GPL Version 2 section of the License file that
142.22 - * accompanied this code. If applicable, add the following below the
142.23 - * License Header, with the fields enclosed by brackets [] replaced by
142.24 - * your own identifying information:
142.25 - * "Portions Copyrighted [year] [name of copyright owner]"
142.26 - *
142.27 - * Contributor(s):
142.28 - *
142.29 - * The Original Software is NetBeans. The Initial Developer of the Original
142.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
142.31 - * Microsystems, Inc. All Rights Reserved.
142.32 - *
142.33 - * If you wish your version of this file to be governed by only the CDDL
142.34 - * or only the GPL Version 2, indicate your decision by adding
142.35 - * "[Contributor] elects to include this software in this distribution
142.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
142.37 - * single choice of license, a recipient has the option to distribute
142.38 - * your version of this file under either the CDDL, the GPL Version 2 or
142.39 - * to extend the choice of license to its licensees as provided above.
142.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
142.41 - * Version 2 license, then the option applies only if the new code is
142.42 - * made subject to such option by the copyright holder.
142.43 - */
142.44 -
142.45 -package org.netbeans.modules.cnd.toolchain.api;
142.46 -
142.47 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
142.48 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
142.49 -import org.openide.util.Lookup;
142.50 -
142.51 -/**
142.52 - *
142.53 - * @author gordonp
142.54 - */
142.55 -public abstract class CompilerProvider {
142.56 - private static final CompilerProvider INSTANCE = new Default();
142.57 -
142.58 - public abstract Tool createCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path);
142.59 -
142.60 - protected CompilerProvider() {
142.61 - }
142.62 -
142.63 - /**
142.64 - * Static method to obtain the provider.
142.65 - * @return the provider
142.66 - */
142.67 - public static CompilerProvider getInstance() {
142.68 - return INSTANCE;
142.69 - }
142.70 -
142.71 - //
142.72 - // Implementation of the default provider
142.73 - //
142.74 - private static final class Default extends CompilerProvider {
142.75 - private final Lookup.Result<CompilerProvider> res;
142.76 -
142.77 - private Default() {
142.78 - res = Lookup.getDefault().lookupResult(CompilerProvider.class);
142.79 - }
142.80 -
142.81 - public Tool createCompiler(ExecutionEnvironment env, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
142.82 - for (CompilerProvider resolver : res.allInstances()) {
142.83 - Tool out = resolver.createCompiler(env, flavor, kind, name, displayName, path);
142.84 - if (out != null) {
142.85 - return out;
142.86 - }
142.87 - }
142.88 - return Tool.createTool(env, flavor, kind, name, displayName, path);
142.89 - }
142.90 - }
142.91 -}
143.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSet.java Mon Feb 01 12:23:06 2010 +0100
143.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSet.java Mon Feb 01 12:24:26 2010 +0100
143.3 @@ -1,7 +1,7 @@
143.4 /*
143.5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
143.6 *
143.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
143.8 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
143.9 *
143.10 * The contents of this file are subject to the terms of either the GNU
143.11 * General Public License Version 2 only ("GPL") or the Common
143.12 @@ -21,12 +21,6 @@
143.13 * your own identifying information:
143.14 * "Portions Copyrighted [year] [name of copyright owner]"
143.15 *
143.16 - * Contributor(s):
143.17 - *
143.18 - * The Original Software is NetBeans. The Initial Developer of the Original
143.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
143.20 - * Microsystems, Inc. All Rights Reserved.
143.21 - *
143.22 * If you wish your version of this file to be governed by only the CDDL
143.23 * or only the GPL Version 2, indicate your decision by adding
143.24 * "[Contributor] elects to include this software in this distribution
143.25 @@ -37,676 +31,52 @@
143.26 * However, if you add GPL Version 2 code and therefore, elected the GPL
143.27 * Version 2 license, then the option applies only if the new code is
143.28 * made subject to such option by the copyright holder.
143.29 + *
143.30 + * Contributor(s):
143.31 + *
143.32 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
143.33 */
143.34
143.35 package org.netbeans.modules.cnd.toolchain.api;
143.36
143.37 -import java.io.File;
143.38 -import java.util.ArrayList;
143.39 -import java.util.Collections;
143.40 -import java.util.HashMap;
143.41 import java.util.List;
143.42 -import java.util.Map;
143.43 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.BaseFolder;
143.44 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CMakeDescriptor;
143.45 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
143.46 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.DebuggerDescriptor;
143.47 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.LinkerDescriptor;
143.48 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.MakeDescriptor;
143.49 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.QMakeDescriptor;
143.50 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerDescriptor;
143.51 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
143.52 -import org.netbeans.modules.cnd.utils.CndUtils;
143.53 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
143.54 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
143.55 -import org.openide.util.NbBundle;
143.56
143.57 /**
143.58 - * A container for information about a set of related compilers, typicaly from a vendor or
143.59 - * redistributor.
143.60 + *
143.61 + * @author Alexander Simon
143.62 */
143.63 -public class CompilerSet {
143.64 +public interface CompilerSet {
143.65 + public static final String None = "None"; // NOI18N
143.66 + public static final String UNKNOWN = "Unknown"; // NOI18N
143.67
143.68 - private static final String UNKNOWN = "Unknown"; // NOI18N
143.69 -
143.70 - public boolean isAutoGenerated() {
143.71 - return autoGenerated;
143.72 - }
143.73 -
143.74 - public void setAutoGenerated(boolean autoGenerated) {
143.75 - this.autoGenerated = autoGenerated;
143.76 - }
143.77 -
143.78 - public boolean isDefault() {
143.79 - return isDefault;
143.80 - }
143.81 -
143.82 - public boolean isUrlPointer(){
143.83 - if (getDirectory() == null || getDirectory().length() == 0){
143.84 - return flavor.descriptor.getUpdateCenterUrl() != null && flavor.descriptor.getModuleID() != null;
143.85 - }
143.86 - return false;
143.87 - }
143.88 -
143.89 - void setAsDefault(boolean isDefault) {
143.90 - this.isDefault = isDefault;
143.91 - }
143.92 -
143.93 - public void unsetDefault() {
143.94 - this.isDefault = false; // to set to true use CompilerSetManager.setDefault()
143.95 - }
143.96 -
143.97 - /** Recognized (and prioritized) types of compiler sets */
143.98 - public static final class CompilerFlavor {
143.99 - private static final List<CompilerFlavor> flavors = new ArrayList<CompilerFlavor>();
143.100 - private static final Map<Integer, CompilerFlavor> unknown = new HashMap<Integer, CompilerFlavor>();
143.101 - static {
143.102 - for(ToolchainDescriptor descriptor : ToolchainManager.getImpl().getAllToolchains()){
143.103 - flavors.add(new CompilerFlavor(descriptor.getName(), descriptor));
143.104 - }
143.105 - }
143.106 -
143.107 - private String sval;
143.108 - private ToolchainDescriptor descriptor;
143.109 -
143.110 - CompilerFlavor(String sval, ToolchainDescriptor descriptor) {
143.111 - this.sval = sval;
143.112 - this.descriptor = descriptor;
143.113 - }
143.114 -
143.115 - public ToolchainDescriptor getToolchainDescriptor(){
143.116 - return descriptor;
143.117 - }
143.118 -
143.119 - public boolean isGnuCompiler() {
143.120 - ToolchainDescriptor d = getToolchainDescriptor();
143.121 - if (d != null) {
143.122 - for(String f : d.getFamily()){
143.123 - if ("GNU".equals(f)) { // NOI18N
143.124 - return true;
143.125 - }
143.126 - }
143.127 - }
143.128 - return false;
143.129 - }
143.130 -
143.131 - public boolean isSunStudioCompiler() {
143.132 - ToolchainDescriptor d = getToolchainDescriptor();
143.133 - if (d != null) {
143.134 - for(String f : d.getFamily()){
143.135 - if ("SunStudio".equals(f)) { // NOI18N
143.136 - return true;
143.137 - }
143.138 - }
143.139 - }
143.140 - return false;
143.141 - }
143.142 -
143.143 - public boolean isMinGWCompiler(){
143.144 - return "MinGW".equals(sval); // NOI18N
143.145 - }
143.146 -
143.147 - public boolean isCygwinCompiler(){
143.148 - return "Cygwin".equals(sval); // NOI18N
143.149 - }
143.150 -
143.151 - public String getCommandFolder(int platform){
143.152 - ToolchainDescriptor d = getToolchainDescriptor();
143.153 - if (d != null) {
143.154 - return ToolchainManager.getImpl().getCommandFolder(d, platform);
143.155 - }
143.156 - return null;
143.157 - }
143.158 -
143.159 - public static CompilerFlavor getUnknown(int platform){
143.160 - CompilerFlavor unknownFlavor = unknown.get(platform);
143.161 - if (unknownFlavor == null) {
143.162 - unknownFlavor = _getUnknown(platform);
143.163 - }
143.164 - return unknownFlavor;
143.165 - }
143.166 -
143.167 - private static CompilerFlavor _getUnknown(int platform){
143.168 - CompilerFlavor unknownFlavor = null;
143.169 - synchronized(unknown) {
143.170 - unknownFlavor = unknown.get(platform);
143.171 - if (unknownFlavor == null) {
143.172 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("GNU", platform); // NOI18N
143.173 - if (d == null) {
143.174 - List<ToolchainDescriptor> list = ToolchainManager.getImpl().getToolchains(platform);
143.175 - if (list.size()>0){
143.176 - d = list.get(0);
143.177 - }
143.178 - }
143.179 - if (d == null) {
143.180 - d = new UnknownToolchainDescriptor();
143.181 - }
143.182 - unknownFlavor = new CompilerFlavor(UNKNOWN, d);
143.183 - unknown.put(platform, unknownFlavor);
143.184 - }
143.185 - }
143.186 - return unknownFlavor;
143.187 - }
143.188 -
143.189 - public static CompilerFlavor toFlavor(String name, int platform) {
143.190 - if (UNKNOWN.equals(name)) {
143.191 - return getUnknown(platform);
143.192 - }
143.193 - for (CompilerFlavor flavor : flavors) {
143.194 - if (name.equals(flavor.sval) && ToolchainManager.getImpl().isPlatforSupported(platform, flavor.getToolchainDescriptor())) {
143.195 - return flavor;
143.196 - }
143.197 - }
143.198 - return null;
143.199 - }
143.200 -
143.201 - public static String mapOldToNew(String flavor, int version) {
143.202 - if (version <=43) {
143.203 - if (flavor.equals("Sun")) { // NOI18N
143.204 - return "SunStudio"; // NOI18N
143.205 - }
143.206 - else if (flavor.equals("SunExpress")) { // NOI18N
143.207 - return "SunStudioExpress"; // NOI18N
143.208 - }
143.209 - else if (flavor.equals("Sun12")) { // NOI18N
143.210 - return "SunStudio_12"; // NOI18N
143.211 - }
143.212 - else if (flavor.equals("Sun11")) { // NOI18N
143.213 - return "SunStudio_11"; // NOI18N
143.214 - }
143.215 - else if (flavor.equals("Sun10")) { // NOI18N
143.216 - return "SunStudio_10"; // NOI18N
143.217 - }
143.218 - else if (flavor.equals("Sun9")) { // NOI18N
143.219 - return "SunStudio_9"; // NOI18N
143.220 - }
143.221 - else if (flavor.equals("Sun8")) { // NOI18N
143.222 - return "SunStudio_8"; // NOI18N
143.223 - }
143.224 - else if (flavor.equals("DJGPP")) { // NOI18N
143.225 - return "GNU"; // NOI18N
143.226 - }
143.227 - else if (flavor.equals("Interix")) { // NOI18N
143.228 - return "GNU"; // NOI18N
143.229 - }
143.230 - else if (flavor.equals(UNKNOWN)) {
143.231 - return "GNU"; // NOI18N
143.232 - }
143.233 - }
143.234 - return flavor;
143.235 - }
143.236 -
143.237 - private static boolean isPlatforSupported(CompilerFlavor flavor, int platform){
143.238 - ToolchainDescriptor d = flavor.getToolchainDescriptor();
143.239 - if (d != null){
143.240 - return ToolchainManager.getImpl().isPlatforSupported(platform, d);
143.241 - }
143.242 - return true;
143.243 - }
143.244 -
143.245 - public static List<CompilerFlavor> getFlavors(int platform) {
143.246 - ArrayList<CompilerFlavor> list = new ArrayList<CompilerFlavor>();
143.247 - for (CompilerFlavor flavor : flavors){
143.248 - if (isPlatforSupported(flavor, platform)) {
143.249 - list.add(flavor);
143.250 - }
143.251 - }
143.252 - return list;
143.253 - }
143.254 -
143.255 - @Override
143.256 - public String toString() {
143.257 - return sval;
143.258 - }
143.259 - }
143.260 -
143.261 - public static final String None = "None"; // NOI18N
143.262 -
143.263 - private CompilerFlavor flavor;
143.264 - private String name;
143.265 - private String displayName;
143.266 - private boolean autoGenerated;
143.267 - private boolean isDefault;
143.268 - private StringBuilder directory = new StringBuilder(256);
143.269 - private final ArrayList<Tool> tools = new ArrayList<Tool>();
143.270 - private String librarySearchOption;
143.271 - private String dynamicLibrarySearchOption;
143.272 - private String libraryOption;
143.273 - private CompilerProvider compilerProvider;
143.274 - private String driveLetterPrefix = "/"; // NOI18N
143.275 - private Map<Integer,String> pathSearch;
143.276 - private boolean isSunStudioDefault;
143.277 -
143.278 - /** Creates a new instance of CompilerSet */
143.279 - protected CompilerSet(CompilerFlavor flavor, String directory, String name) {
143.280 - addDirectory(directory);
143.281 -
143.282 - compilerProvider = CompilerProvider.getInstance();
143.283 - driveLetterPrefix = flavor.getToolchainDescriptor().getDriveLetterPrefix();
143.284 -
143.285 - if (name != null) {
143.286 - this.name = name;
143.287 - } else {
143.288 - this.name = flavor.toString();
143.289 - }
143.290 - //displayName = mapNameToDisplayName(flavor);
143.291 - displayName = flavor.getToolchainDescriptor().getDisplayName();
143.292 - librarySearchOption = flavor.getToolchainDescriptor().getLinker().getLibrarySearchFlag();
143.293 - dynamicLibrarySearchOption = flavor.getToolchainDescriptor().getLinker().getDynamicLibrarySearchFlag();
143.294 - libraryOption = flavor.getToolchainDescriptor().getLinker().getLibraryFlag();
143.295 - this.flavor = flavor;
143.296 - setAutoGenerated(true);
143.297 - setAsDefault(false);
143.298 - }
143.299 -
143.300 - protected CompilerSet(int platform) {
143.301 - this.name = None;
143.302 - this.flavor = CompilerFlavor.getUnknown(platform);
143.303 - this.displayName = NbBundle.getMessage(CompilerSet.class, "LBL_EmptyCompilerSetDisplayName"); // NOI18N
143.304 -
143.305 - compilerProvider = CompilerProvider.getInstance();
143.306 - setAutoGenerated(true);
143.307 - setAsDefault(false);
143.308 - }
143.309 -
143.310 - public CompilerSet createCopy() {
143.311 - CompilerSet copy = new CompilerSet(flavor, getDirectory(), name);
143.312 - copy.setAutoGenerated(isAutoGenerated());
143.313 - copy.setAsDefault(isDefault());
143.314 -
143.315 - for (Tool tool : getTools()) {
143.316 - copy.addTool(tool.createCopy());
143.317 - }
143.318 -
143.319 - return copy;
143.320 - }
143.321 -
143.322 - /**
143.323 - * Get an existing compiler set. If it doesn't exist, get an empty one based on the requested name.
143.324 - *
143.325 - * @param name The name of the compiler set we want
143.326 - * @returns The best fitting compiler set (may be an empty CompilerSet)
143.327 - */
143.328 - public static CompilerSet getCompilerSet(ExecutionEnvironment env, String name, int platform) {
143.329 - CompilerSet cs = CompilerSetManager.getDefault(env).getCompilerSet(CompilerFlavor.toFlavor(name, platform));
143.330 - if (cs == null) {
143.331 - CompilerFlavor flavor = CompilerFlavor.toFlavor(name, platform);
143.332 - flavor = flavor == null ? CompilerFlavor.getUnknown(platform) : flavor;
143.333 - cs = new CompilerSet(flavor, "", null); // NOI18N
143.334 - }
143.335 - return cs;
143.336 - }
143.337 -
143.338 - public static List<CompilerFlavor> getCompilerSetFlavor(String directory, int platform) {
143.339 - List<CompilerFlavor> list = new ArrayList<CompilerFlavor>();
143.340 - for(ToolchainDescriptor d : ToolchainManager.getImpl().getToolchains(platform)) {
143.341 - if (d.isAbstract()) {
143.342 - continue;
143.343 - }
143.344 - if (ToolchainManager.getImpl().isMyFolder(directory, d, platform, false)){
143.345 - CompilerFlavor f = CompilerFlavor.toFlavor(d.getName(), platform);
143.346 - if (f != null) {
143.347 - list.add(f);
143.348 - }
143.349 - }
143.350 - }
143.351 - return list;
143.352 - }
143.353 -
143.354 - public static CompilerSet getCustomCompilerSet(String directory, CompilerFlavor flavor, String name) {
143.355 - CompilerSet cs = new CompilerSet(flavor, directory, name);
143.356 - cs.setAutoGenerated(false);
143.357 - return cs;
143.358 - }
143.359 -
143.360 - /**
143.361 - * If no compilers are found an empty compiler set is created so we don't have an empty list.
143.362 - * Too many places in CND expect a non-empty list and throw NPEs if it is empty!
143.363 - */
143.364 - protected static CompilerSet createEmptyCompilerSet(int platform) {
143.365 - return new CompilerSet(platform);
143.366 - }
143.367 -
143.368 - public boolean isGnuCompiler() {
143.369 - return flavor.isGnuCompiler();
143.370 - }
143.371 -
143.372 - public boolean isSunCompiler() {
143.373 - return flavor.isSunStudioCompiler();
143.374 - }
143.375 -
143.376 - public CompilerFlavor getCompilerFlavor() {
143.377 - return flavor;
143.378 - }
143.379 -
143.380 - /*package-local*/ void setFlavor(CompilerFlavor flavor) {
143.381 - this.flavor = flavor;
143.382 - }
143.383 -
143.384 - private void addDirectory(String path) {
143.385 - if (path != null) {
143.386 - if (directory.length() == 0) {
143.387 - directory.append(path);
143.388 - } else {
143.389 - directory.append(File.pathSeparator);
143.390 - directory.append(path);
143.391 - }
143.392 - }
143.393 - }
143.394 -
143.395 - public String getDirectory() {
143.396 - return directory.toString();
143.397 - }
143.398 -
143.399 - public String getName() {
143.400 - return name;
143.401 - }
143.402 -
143.403 - public void setName(String name) {
143.404 - this.name = name;
143.405 - }
143.406 -
143.407 - public String getDisplayName() {
143.408 - // TODO: this thing is never used although it's being set to informative values by personality
143.409 - return displayName;
143.410 - }
143.411 -
143.412 - /*package-local*/ Tool addTool(ExecutionEnvironment env, String name, String path, int kind) {
143.413 - if (findTool(kind) != null) {
143.414 - return null;
143.415 - }
143.416 - Tool tool = compilerProvider.createCompiler(env, flavor, kind, name, Tool.getToolDisplayName(kind), path);
143.417 - if (!tools.contains(tool)) {
143.418 - tools.add(tool);
143.419 - }
143.420 - tool.setCompilerSet(this);
143.421 - return tool;
143.422 - }
143.423 -
143.424 - /*package-local*/ void addTool(Tool tool) {
143.425 - tools.add(tool);
143.426 - tool.setCompilerSet(this);
143.427 - }
143.428 -
143.429 - /*package-local*/ Tool addNewTool(ExecutionEnvironment env, String name, String path, int kind) {
143.430 - Tool tool = compilerProvider.createCompiler(env, flavor, kind, name, Tool.getToolDisplayName(kind), path);
143.431 - tools.add(tool);
143.432 - tool.setCompilerSet(this);
143.433 - return tool;
143.434 - }
143.435 -
143.436 /**
143.437 * Get the first tool of its kind.
143.438 *
143.439 * @param kind The type of tool to get
143.440 * @return The Tool or null
143.441 */
143.442 - public Tool getTool(int kind) {
143.443 - for (Tool tool : tools) {
143.444 - if (tool.getKind() == kind) {
143.445 - return tool;
143.446 - }
143.447 - }
143.448 - CndUtils.assertFalse(true, "Should not be here, cuz we should create empty tools in CompilerSetManager"); //NOI18N
143.449 - //TODO: remove this code, empty tools should be created in CompilerSetManager
143.450 - Tool t;
143.451 - // Fixup: all tools should go here ....
143.452 - t = compilerProvider.createCompiler(ExecutionEnvironmentFactory.getLocal(),
143.453 - getCompilerFlavor(), kind, "", Tool.getToolDisplayName(kind), ""); // NOI18N
143.454 - t.setCompilerSet(this);
143.455 - synchronized( tools ) { // synchronize this only unpredictable tools modification
143.456 - tools.add(t);
143.457 - }
143.458 - return t;
143.459 - }
143.460 -
143.461 -
143.462 + Tool findTool(ToolKindBase kind);
143.463 +
143.464 + CompilerFlavor getCompilerFlavor();
143.465 +
143.466 + String getDirectory();
143.467 +
143.468 + String getDisplayName();
143.469 +
143.470 + String getName();
143.471 +
143.472 /**
143.473 * Get the first tool of its kind.
143.474 *
143.475 * @param kind The type of tool to get
143.476 * @return The Tool or null
143.477 */
143.478 - public Tool findTool(int kind) {
143.479 - for (Tool tool : tools) {
143.480 - if (tool.getKind() == kind) {
143.481 - return tool;
143.482 - }
143.483 - }
143.484 - return null;
143.485 - }
143.486 + Tool getTool(ToolKindBase kind);
143.487
143.488 - @SuppressWarnings("unchecked")
143.489 - public List<Tool> getTools() {
143.490 - synchronized (tools) {
143.491 - return (List<Tool>)tools.clone();
143.492 - }
143.493 - }
143.494 -
143.495 - public String getDynamicLibrarySearchOption() {
143.496 - return dynamicLibrarySearchOption;
143.497 - }
143.498 + List<Tool> getTools();
143.499
143.500 - public String getLibrarySearchOption() {
143.501 - return librarySearchOption;
143.502 - }
143.503 + boolean isAutoGenerated();
143.504
143.505 - public String getLibraryOption() {
143.506 - return libraryOption;
143.507 - }
143.508 + boolean isUrlPointer();
143.509
143.510 - private String getDriveLetterPrefix() {
143.511 - return driveLetterPrefix;
143.512 - }
143.513 -
143.514 - public String getQmakeSpec(int platform) {
143.515 - String qmakespec = flavor.getToolchainDescriptor().getQmakeSpec();
143.516 - if (qmakespec != null && 0 <= qmakespec.indexOf("${os}")) { // NOI18N
143.517 - String os = null;
143.518 - switch (platform) {
143.519 - case PlatformTypes.PLATFORM_LINUX:
143.520 - os = "linux"; // NOI18N
143.521 - break;
143.522 - case PlatformTypes.PLATFORM_MACOSX:
143.523 - os = "macx"; // NOI18N
143.524 - break;
143.525 - case PlatformTypes.PLATFORM_SOLARIS_INTEL:
143.526 - case PlatformTypes.PLATFORM_SOLARIS_SPARC:
143.527 - os = "solaris"; // NOI18N
143.528 - break;
143.529 - case PlatformTypes.PLATFORM_WINDOWS:
143.530 - os = "win32"; // NOI18N
143.531 - break;
143.532 - }
143.533 - if (os == null) {
143.534 - qmakespec = null;
143.535 - } else {
143.536 - qmakespec = qmakespec.replaceAll("\\$\\{os\\}", os); // NOI18N
143.537 - }
143.538 - }
143.539 - return qmakespec;
143.540 - }
143.541 -
143.542 - /**
143.543 - * Converts absolute Windows paths to paths without the ':'.
143.544 - * Example: C:/abc/def.c -> /cygdrive/c/def/c
143.545 - */
143.546 - public String normalizeDriveLetter(String path) {
143.547 - if (path.length() > 1 && path.charAt(1) == ':') { // NOI18N
143.548 - return getDriveLetterPrefix() + path.charAt(0) + path.substring(2); // NOI18N
143.549 - }
143.550 - return path;
143.551 - }
143.552 -
143.553 - /*package-local*/ void addPathCandidate(int tool, String path) {
143.554 - if (pathSearch == null){
143.555 - pathSearch = new HashMap<Integer, String>();
143.556 - }
143.557 - pathSearch.put(tool, path);
143.558 - }
143.559 -
143.560 - /*package-local*/String getPathCandidate(int tool){
143.561 - if (pathSearch == null){
143.562 - return null;
143.563 - }
143.564 - return pathSearch.get(tool);
143.565 - }
143.566 -
143.567 - /*package-local*/void setSunStudioDefault(boolean isSunStudioDefault){
143.568 - this.isSunStudioDefault = isSunStudioDefault;
143.569 - }
143.570 -
143.571 - /*package-local*/boolean isSunStudioDefault(){
143.572 - return isSunStudioDefault;
143.573 - }
143.574 -
143.575 - @Override
143.576 - public String toString() {
143.577 - return name;
143.578 - }
143.579 -
143.580 - private static class UnknownToolchainDescriptor implements ToolchainDescriptor {
143.581 -
143.582 - public String getFileName() {
143.583 - return ""; // NOI18N
143.584 - }
143.585 -
143.586 - public String getName() {
143.587 - return ""; // NOI18N
143.588 - }
143.589 -
143.590 - public String getDisplayName() {
143.591 - return ""; // NOI18N
143.592 - }
143.593 -
143.594 - public String[] getFamily() {
143.595 - return new String[]{};
143.596 - }
143.597 -
143.598 - public String[] getPlatforms() {
143.599 - return new String[]{};
143.600 - }
143.601 -
143.602 - public String getUpdateCenterUrl() {
143.603 - return null;
143.604 - }
143.605 -
143.606 - public String getUpdateCenterDisplayName() {
143.607 - return null;
143.608 - }
143.609 -
143.610 - public String getUpgradeUrl() {
143.611 - return null;
143.612 - }
143.613 -
143.614 - public String getModuleID() {
143.615 - return null;
143.616 - }
143.617 -
143.618 - public boolean isAbstract() {
143.619 - return true;
143.620 - }
143.621 -
143.622 - public String getDriveLetterPrefix() {
143.623 - return ""; // NOI18N
143.624 - }
143.625 -
143.626 - public List<BaseFolder> getBaseFolders() {
143.627 - return Collections.<BaseFolder>emptyList();
143.628 - }
143.629 -
143.630 - public List<BaseFolder> getCommandFolders() {
143.631 - return Collections.<BaseFolder>emptyList();
143.632 - }
143.633 -
143.634 - public String getQmakeSpec() {
143.635 - return ""; // NOI18N
143.636 - }
143.637 -
143.638 - public CompilerDescriptor getC() {
143.639 - return null;
143.640 - }
143.641 -
143.642 - public CompilerDescriptor getCpp() {
143.643 - return null;
143.644 - }
143.645 -
143.646 - public CompilerDescriptor getFortran() {
143.647 - return null;
143.648 - }
143.649 -
143.650 - public CompilerDescriptor getAssembler() {
143.651 - return null;
143.652 - }
143.653 -
143.654 - public ScannerDescriptor getScanner() {
143.655 - return null;
143.656 - }
143.657 -
143.658 - public LinkerDescriptor getLinker() {
143.659 - return new LinkerDescriptor(){
143.660 -
143.661 - public String getLibraryPrefix() {
143.662 - return ""; // NOI18N
143.663 - }
143.664 -
143.665 - public String getLibrarySearchFlag() {
143.666 - return ""; // NOI18N
143.667 - }
143.668 -
143.669 - public String getDynamicLibrarySearchFlag() {
143.670 - return ""; // NOI18N
143.671 - }
143.672 -
143.673 - public String getLibraryFlag() {
143.674 - return ""; // NOI18N
143.675 - }
143.676 -
143.677 - public String getPICFlag() {
143.678 - return ""; // NOI18N
143.679 - }
143.680 -
143.681 - public String getStaticLibraryFlag() {
143.682 - return ""; // NOI18N
143.683 - }
143.684 -
143.685 - public String getDynamicLibraryFlag() {
143.686 - return ""; // NOI18N
143.687 - }
143.688 -
143.689 - public String getDynamicLibraryBasicFlag() {
143.690 - return ""; // NOI18N
143.691 - }
143.692 -
143.693 - public String getOutputFileFlag() {
143.694 - return ""; // NOI18N
143.695 - }
143.696 - };
143.697 - }
143.698 -
143.699 - public MakeDescriptor getMake() {
143.700 - return null;
143.701 - }
143.702 -
143.703 - public Map<String, List<String>> getDefaultLocations() {
143.704 - return Collections.<String, List<String>>emptyMap();
143.705 - }
143.706 -
143.707 - public DebuggerDescriptor getDebugger() {
143.708 - return null;
143.709 - }
143.710 -
143.711 - public String getMakefileWriter() {
143.712 - return null;
143.713 - }
143.714 -
143.715 - public QMakeDescriptor getQMake() {
143.716 - return null;
143.717 - }
143.718 -
143.719 - public CMakeDescriptor getCMake() {
143.720 - return null;
143.721 - }
143.722 -
143.723 - }
143.724 }
144.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetChangeListener.java Mon Feb 01 12:23:06 2010 +0100
144.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
144.3 @@ -1,54 +0,0 @@
144.4 -/*
144.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
144.6 - *
144.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
144.8 - *
144.9 - * The contents of this file are subject to the terms of either the GNU
144.10 - * General Public License Version 2 only ("GPL") or the Common
144.11 - * Development and Distribution License("CDDL") (collectively, the
144.12 - * "License"). You may not use this file except in compliance with the
144.13 - * License. You can obtain a copy of the License at
144.14 - * http://www.netbeans.org/cddl-gplv2.html
144.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
144.16 - * specific language governing permissions and limitations under the
144.17 - * License. When distributing the software, include this License Header
144.18 - * Notice in each file and include the License file at
144.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
144.20 - * particular file as subject to the "Classpath" exception as provided
144.21 - * by Sun in the GPL Version 2 section of the License file that
144.22 - * accompanied this code. If applicable, add the following below the
144.23 - * License Header, with the fields enclosed by brackets [] replaced by
144.24 - * your own identifying information:
144.25 - * "Portions Copyrighted [year] [name of copyright owner]"
144.26 - *
144.27 - * Contributor(s):
144.28 - *
144.29 - * The Original Software is NetBeans. The Initial Developer of the Original
144.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
144.31 - * Microsystems, Inc. All Rights Reserved.
144.32 - *
144.33 - * If you wish your version of this file to be governed by only the CDDL
144.34 - * or only the GPL Version 2, indicate your decision by adding
144.35 - * "[Contributor] elects to include this software in this distribution
144.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
144.37 - * single choice of license, a recipient has the option to distribute
144.38 - * your version of this file under either the CDDL, the GPL Version 2 or
144.39 - * to extend the choice of license to its licensees as provided above.
144.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
144.41 - * Version 2 license, then the option applies only if the new code is
144.42 - * made subject to such option by the copyright holder.
144.43 - */
144.44 -
144.45 -package org.netbeans.modules.cnd.toolchain.api;
144.46 -
144.47 -import java.util.EventListener;
144.48 -
144.49 -/**
144.50 - *
144.51 - * @author gordonp
144.52 - */
144.53 -public interface CompilerSetChangeListener extends EventListener {
144.54 -
144.55 - public void compilerSetChange(CompilerSetEvent e);
144.56 -
144.57 -}
145.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetEvent.java Mon Feb 01 12:23:06 2010 +0100
145.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
145.3 @@ -1,58 +0,0 @@
145.4 -/*
145.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
145.6 - *
145.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
145.8 - *
145.9 - * The contents of this file are subject to the terms of either the GNU
145.10 - * General Public License Version 2 only ("GPL") or the Common
145.11 - * Development and Distribution License("CDDL") (collectively, the
145.12 - * "License"). You may not use this file except in compliance with the
145.13 - * License. You can obtain a copy of the License at
145.14 - * http://www.netbeans.org/cddl-gplv2.html
145.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
145.16 - * specific language governing permissions and limitations under the
145.17 - * License. When distributing the software, include this License Header
145.18 - * Notice in each file and include the License file at
145.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
145.20 - * particular file as subject to the "Classpath" exception as provided
145.21 - * by Sun in the GPL Version 2 section of the License file that
145.22 - * accompanied this code. If applicable, add the following below the
145.23 - * License Header, with the fields enclosed by brackets [] replaced by
145.24 - * your own identifying information:
145.25 - * "Portions Copyrighted [year] [name of copyright owner]"
145.26 - *
145.27 - * Contributor(s):
145.28 - *
145.29 - * The Original Software is NetBeans. The Initial Developer of the Original
145.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
145.31 - * Microsystems, Inc. All Rights Reserved.
145.32 - *
145.33 - * If you wish your version of this file to be governed by only the CDDL
145.34 - * or only the GPL Version 2, indicate your decision by adding
145.35 - * "[Contributor] elects to include this software in this distribution
145.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
145.37 - * single choice of license, a recipient has the option to distribute
145.38 - * your version of this file under either the CDDL, the GPL Version 2 or
145.39 - * to extend the choice of license to its licensees as provided above.
145.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
145.41 - * Version 2 license, then the option applies only if the new code is
145.42 - * made subject to such option by the copyright holder.
145.43 - */
145.44 -
145.45 -package org.netbeans.modules.cnd.toolchain.api;
145.46 -
145.47 -import java.util.EventObject;
145.48 -
145.49 -/**
145.50 - * Track changes in compiler sets. Mostly used by CompilerSetConfigurations, so they don't
145.51 - * contain removed compiler set references.
145.52 - *
145.53 - * @author gordonp
145.54 - */
145.55 -public class CompilerSetEvent extends EventObject {
145.56 -
145.57 - /** Creates a new instance of CompilerSetEvent */
145.58 - public CompilerSetEvent(Object source) {
145.59 - super(source);
145.60 - }
145.61 -}
146.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetManager.java Mon Feb 01 12:23:06 2010 +0100
146.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetManager.java Mon Feb 01 12:24:26 2010 +0100
146.3 @@ -1,7 +1,7 @@
146.4 /*
146.5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
146.6 *
146.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
146.8 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
146.9 *
146.10 * The contents of this file are subject to the terms of either the GNU
146.11 * General Public License Version 2 only ("GPL") or the Common
146.12 @@ -21,12 +21,6 @@
146.13 * your own identifying information:
146.14 * "Portions Copyrighted [year] [name of copyright owner]"
146.15 *
146.16 - * Contributor(s):
146.17 - *
146.18 - * The Original Software is NetBeans. The Initial Developer of the Original
146.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
146.20 - * Microsystems, Inc. All Rights Reserved.
146.21 - *
146.22 * If you wish your version of this file to be governed by only the CDDL
146.23 * or only the GPL Version 2, indicate your decision by adding
146.24 * "[Contributor] elects to include this software in this distribution
146.25 @@ -37,68 +31,25 @@
146.26 * However, if you add GPL Version 2 code and therefore, elected the GPL
146.27 * Version 2 license, then the option applies only if the new code is
146.28 * made subject to such option by the copyright holder.
146.29 + *
146.30 + * Contributor(s):
146.31 + *
146.32 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
146.33 */
146.34 +
146.35 package org.netbeans.modules.cnd.toolchain.api;
146.36
146.37 -import java.io.File;
146.38 -import java.util.ArrayList;
146.39 -import java.util.Collection;
146.40 -import java.util.Collections;
146.41 -import java.util.Comparator;
146.42 -import java.util.HashMap;
146.43 -import java.util.HashSet;
146.44 -import java.util.LinkedHashSet;
146.45 +import java.io.Writer;
146.46 import java.util.List;
146.47 -import java.util.Map;
146.48 -import java.util.NoSuchElementException;
146.49 -import java.util.Set;
146.50 -import java.util.StringTokenizer;
146.51 -import java.util.concurrent.atomic.AtomicReference;
146.52 -import java.util.logging.Level;
146.53 -import java.util.logging.Logger;
146.54 -import javax.swing.SwingUtilities;
146.55 -import org.netbeans.api.progress.ProgressHandle;
146.56 -import org.netbeans.api.progress.ProgressHandleFactory;
146.57 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
146.58 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.AlternativePath;
146.59 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
146.60 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
146.61 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolDescriptor;
146.62 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
146.63 -import org.netbeans.modules.cnd.api.remote.ServerList;
146.64 -import org.netbeans.modules.cnd.api.remote.ServerRecord;
146.65 -import org.netbeans.modules.cnd.utils.CndUtils;
146.66 -import org.netbeans.modules.cnd.utils.NamedRunnable;
146.67 -import org.netbeans.modules.cnd.utils.cache.CndFileUtils;
146.68 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerAccessorImpl;
146.69 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerImpl;
146.70 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
146.71 -import org.netbeans.modules.nativeexecution.api.util.Path;
146.72 -import org.openide.DialogDescriptor;
146.73 -import org.openide.DialogDisplayer;
146.74 -import org.openide.util.Cancellable;
146.75 -import org.openide.util.NbBundle;
146.76 -import org.openide.util.RequestProcessor;
146.77 -import org.openide.util.RequestProcessor.Task;
146.78 -import org.openide.util.TaskListener;
146.79
146.80 /**
146.81 - * Manage a set of CompilerSets. The CompilerSets are dynamically created based on which compilers
146.82 - * are found in the user's $PATH variable.
146.83 + *
146.84 + * @author Alexander Simon
146.85 */
146.86 -public final class CompilerSetManager {
146.87 -
146.88 - private static final Logger log = Logger.getLogger("cnd.remote.logger"); // NOI18N
146.89 -
146.90 - private static final HashMap<ExecutionEnvironment, CompilerSetManager> managers = new HashMap<ExecutionEnvironment, CompilerSetManager>();
146.91 - private static final Object MASTER_LOCK = new Object();
146.92 -
146.93 - // CopyOnWriteArrayList because of IZ#175647
146.94 - private List<CompilerSet> sets = new ArrayList<CompilerSet>();
146.95 -
146.96 - private final ExecutionEnvironment executionEnvironment;
146.97 - private volatile State state;
146.98 - private int platform = -1;
146.99 - private Task initializationTask;
146.100 -
146.101 +public abstract class CompilerSetManager {
146.102 /**
146.103 * Find or create a default CompilerSetManager for the given key. A default
146.104 * CSM is one which is active in the system. A non-default is one which gets
146.105 @@ -111,990 +62,50 @@
146.106 * @param env specifies execution environment
146.107 * @return A default CompilerSetManager for the given key
146.108 */
146.109 - public static CompilerSetManager getDefault(ExecutionEnvironment env) {
146.110 - return getDefaultImpl(env, true);
146.111 + public static CompilerSetManager get(ExecutionEnvironment env) {
146.112 + return CompilerSetManagerAccessorImpl.getDefault(env);
146.113 }
146.114 -
146.115 - private static CompilerSetManager getDefaultImpl(ExecutionEnvironment env, boolean initialize) {
146.116 - CompilerSetManager csm = null;
146.117 - boolean no_compilers = false;
146.118 -
146.119 - synchronized (MASTER_LOCK) {
146.120 - csm = managers.get(env);
146.121 - if (csm == null) {
146.122 - csm = CompilerSetPreferences.restoreFromDisk(env);
146.123 - if (csm != null && csm.getDefaultCompilerSet() == null) {
146.124 - CompilerSetPreferences.saveToDisk(csm);
146.125 - }
146.126 - }
146.127 - if (csm == null) {
146.128 - csm = new CompilerSetManager(env, initialize);
146.129 - if (csm.isValid()) {
146.130 - CompilerSetPreferences.saveToDisk(csm);
146.131 - } else if (!csm.isPending() && !csm.isUninitialized()) {
146.132 - no_compilers = true;
146.133 - }
146.134 - }
146.135 - if (csm != null) {
146.136 - managers.put(env, csm);
146.137 - }
146.138 - }
146.139 -
146.140 - if (no_compilers) {
146.141 - // workaround to fix IZ#164028: Full IDE freeze when opening GizmoDemo project on Linux
146.142 - // we postpone dialog displayer until EDT is free to process
146.143 - SwingUtilities.invokeLater(new Runnable() {
146.144 - public void run() {
146.145 - DialogDescriptor dialogDescriptor = new DialogDescriptor(
146.146 - new NoCompilersPanel(),
146.147 - getString("NO_COMPILERS_FOUND_TITLE"),
146.148 - true,
146.149 - new Object[]{DialogDescriptor.OK_OPTION},
146.150 - DialogDescriptor.OK_OPTION,
146.151 - DialogDescriptor.BOTTOM_ALIGN,
146.152 - null,
146.153 - null);
146.154 - DialogDisplayer.getDefault().notify(dialogDescriptor);
146.155 - }
146.156 - });
146.157 - }
146.158 - return csm;
146.159 - }
146.160 -
146.161 - public static CompilerSetManager getDefault() {
146.162 - return getDefault(ExecutionEnvironmentFactory.getLocal());
146.163 - }
146.164 -
146.165 - /** Create a CompilerSetManager which may be registered at a later time via CompilerSetManager.setDefault() */
146.166 - public static CompilerSetManager create(ExecutionEnvironment env) {
146.167 - CompilerSetManager newCsm = new CompilerSetManager(env);
146.168 - if (newCsm.getCompilerSets().size() == 1 && newCsm.getCompilerSets().get(0).getName().equals(CompilerSet.None)) {
146.169 - newCsm.remove(newCsm.getCompilerSets().get(0));
146.170 - }
146.171 - return newCsm;
146.172 - }
146.173 -
146.174 - /** Replace the default CompilerSetManager. Let registered listeners know its been updated */
146.175 - public static void setManagers(Collection<CompilerSetManager> csms) {
146.176 - synchronized (MASTER_LOCK) {
146.177 - CompilerSetPreferences.clearPersistence();
146.178 - managers.clear();
146.179 - for (CompilerSetManager csm : csms) {
146.180 - csm.completeCompilerSets();
146.181 - CompilerSetPreferences.saveToDisk(csm);
146.182 - managers.put(csm.executionEnvironment, csm);
146.183 - }
146.184 - }
146.185 - }
146.186 -
146.187 - private CompilerSetManager(ExecutionEnvironment env) {
146.188 - this(env, true);
146.189 - }
146.190 -
146.191 - private CompilerSetManager(ExecutionEnvironment env, final boolean initialize) {
146.192 - //if (log.isLoggable(Level.FINEST)) {
146.193 - // log.log(Level.FINEST, "CompilerSetManager CTOR A @" + System.identityHashCode(this) + ' ' + env + ' ' + initialize, new Exception()); //NOI18N
146.194 - //}
146.195 - executionEnvironment = env;
146.196 - if (initialize) {
146.197 - state = State.STATE_PENDING;
146.198 - } else {
146.199 - state = State.STATE_UNINITIALIZED;
146.200 - return;
146.201 - }
146.202 - if (executionEnvironment.isLocal()) {
146.203 - platform = CompilerSetUtils.computeLocalPlatform();
146.204 - initCompilerSets(Path.getPath());
146.205 - } else {
146.206 - final AtomicReference<Thread> threadRef = new AtomicReference<Thread>();
146.207 - final String progressMessage = NbBundle.getMessage(getClass(), "PROGRESS_TEXT", env.getDisplayName());
146.208 - final ProgressHandle progressHandle = ProgressHandleFactory.createHandle(
146.209 - progressMessage,
146.210 - new Cancellable() {
146.211 - public boolean cancel() {
146.212 - Thread thread = threadRef.get();
146.213 - if (thread != null) {
146.214 - thread.interrupt();
146.215 - }
146.216 - return true;
146.217 - }
146.218 -
146.219 - });
146.220 - log.fine("CSM.init: initializing remote compiler set @" + System.identityHashCode(this) + " for: " + toString());
146.221 - progressHandle.start();
146.222 - RequestProcessor.getDefault().post(new NamedRunnable(progressMessage) {
146.223 - protected @Override void runImpl() {
146.224 - threadRef.set(Thread.currentThread());
146.225 - try {
146.226 - initRemoteCompilerSets(false, initialize);
146.227 - } finally {
146.228 - progressHandle.finish();
146.229 - }
146.230 - }
146.231 - });
146.232 - }
146.233 - }
146.234 -
146.235 - CompilerSetManager(ExecutionEnvironment env, List<CompilerSet> sets, int platform) {
146.236 - //if (log.isLoggable(Level.FINEST)) {
146.237 - // log.log(Level.FINEST, "CompilerSetManager CTOR B @" + System.identityHashCode(this) + ' ' + sets + ' ' + platform, new Exception()); //NOI18N
146.238 - //}
146.239 - this.executionEnvironment = env;
146.240 - this.sets = sets;
146.241 - this.platform = platform;
146.242 - completeCompilerSets();
146.243 - if(env.isRemote() && isEmpty()) {
146.244 - this.state = State.STATE_UNINITIALIZED;
146.245 - log.fine("CSM restoring from pref: Adding empty CS to host " + toString());
146.246 - } else {
146.247 - this.state = State.STATE_COMPLETE;
146.248 - }
146.249 - }
146.250 -
146.251 - public static final String getRemoteScript(String path) {
146.252 - return ToolchainScriptGenerator.generateScript(path);
146.253 - }
146.254 -
146.255 - private boolean isValid() {
146.256 - return sets.size() > 0 && !sets.get(0).getName().equals(CompilerSet.None);
146.257 - }
146.258 -
146.259 - public boolean isPending() {
146.260 - return state == State.STATE_PENDING;
146.261 - }
146.262 -
146.263 - public boolean isUninitialized() {
146.264 - return state == State.STATE_UNINITIALIZED;
146.265 - }
146.266 -
146.267 - /*package-local*/ boolean isComplete() {
146.268 - return state == State.STATE_COMPLETE;
146.269 - }
146.270 -
146.271 - /** CAUTION: this is a slow method. It should NOT be called from the EDT thread */
146.272 - public synchronized void initialize(boolean save, boolean runCompilerSetDataLoader) {
146.273 - CndUtils.assertNonUiThread();
146.274 - if (isUninitialized()) {
146.275 - log.fine("CSM.getDefault: Doing remote setup from EDT?" + SwingUtilities.isEventDispatchThread());
146.276 - this.sets.clear();
146.277 - initRemoteCompilerSets(true, runCompilerSetDataLoader);
146.278 - if (initializationTask != null) {
146.279 - initializationTask.waitFinished();
146.280 - initializationTask = null;
146.281 - }
146.282 - }
146.283 - if (save) {
146.284 - synchronized (MASTER_LOCK) {
146.285 - CompilerSetPreferences.saveToDisk(this);
146.286 - }
146.287 - }
146.288 - }
146.289 -
146.290 - public int getPlatform() {
146.291 - if (platform < 0) {
146.292 - if (executionEnvironment.isLocal()) {
146.293 - platform = CompilerSetUtils.computeLocalPlatform();
146.294 - } else {
146.295 - if (isPending()) {
146.296 - log.warning("calling getPlatform() on uninitializad " + getClass().getSimpleName());
146.297 - }
146.298 - }
146.299 - }
146.300 - return platform == -1 ? PlatformTypes.PLATFORM_NONE : platform;
146.301 - }
146.302 -
146.303 - public static CompilerSetManager getDeepCopy(ExecutionEnvironment execEnv, boolean initialize) {
146.304 - return getDefaultImpl(execEnv, initialize).deepCopy();
146.305 - }
146.306 -
146.307 - private CompilerSetManager deepCopy() {
146.308 - if (isPending()) {
146.309 - log.warning("calling deepCopy() on uninitializad " + getClass().getSimpleName());
146.310 - }
146.311 - List<CompilerSet> setsCopy = new ArrayList<CompilerSet>();
146.312 - for (CompilerSet set : getCompilerSets()) {
146.313 - setsCopy.add(set.createCopy());
146.314 - }
146.315 - CompilerSetManager copy = new CompilerSetManager(executionEnvironment, setsCopy, this.platform);
146.316 - return copy;
146.317 - }
146.318 -
146.319 - public String getUniqueCompilerSetName(String baseName) {
146.320 - int n = 0;
146.321 - String suggestedName = baseName;
146.322 - while (true) {
146.323 - suggestedName = baseName + (n > 0 ? ("_" + n) : ""); // NOI18N
146.324 - if (getCompilerSet(suggestedName) != null) {
146.325 - n++;
146.326 - } else {
146.327 - break;
146.328 - }
146.329 - }
146.330 - return suggestedName;
146.331 - }
146.332 -
146.333 - private Collection<FolderDescriptor> getPaths(ToolchainDescriptor d, CompilerFlavor flavor, ArrayList<String> dirlist) {
146.334 - LinkedHashSet<FolderDescriptor> dirs = new LinkedHashSet<FolderDescriptor>();
146.335 - // path from regestry
146.336 - String base = ToolchainManager.getImpl().getBaseFolder(d, getPlatform());
146.337 - if (base != null) {
146.338 - dirs.add(new FolderDescriptor(base, true));
146.339 - }
146.340 - // path from env
146.341 - for (String p : dirlist) {
146.342 - dirs.add(new FolderDescriptor(p, false));
146.343 - }
146.344 - // path from default location
146.345 - Map<String, List<String>> map = d.getDefaultLocations();
146.346 - if (map != null) {
146.347 - List<String> list = map.get(CompilerSetUtils.getPlatformName(getPlatform()));
146.348 - if (list != null) {
146.349 - for (String p : list) {
146.350 - dirs.add(new FolderDescriptor(p, true));
146.351 - }
146.352 - }
146.353 - }
146.354 - // path from plugins
146.355 - String path = ToolChainPathProvider.getDefault().getPath(flavor);
146.356 - if (path != null) {
146.357 - dirs.add(new FolderDescriptor(path, true));
146.358 - }
146.359 - return dirs;
146.360 - }
146.361 -
146.362 - /** Search $PATH for all desired compiler sets and initialize cbCompilerSet and spCompilerSets */
146.363 - private synchronized void initCompilerSets(final ArrayList<String> dirlist) {
146.364 - // NB: function itself is synchronized!
146.365 - if (state == State.STATE_COMPLETE) {
146.366 - return;
146.367 - }
146.368 - if (initializationTask != null) {
146.369 - return;
146.370 - }
146.371 - String progressMessage = NbBundle.getMessage(getClass(), "PROGRESS_TEXT", executionEnvironment.getDisplayName()); // NOI18N
146.372 - ProgressHandle progressHandle = ProgressHandleFactory.createHandle(progressMessage);
146.373 - progressHandle.start();
146.374 - initializationTask = RequestProcessor.getDefault().post(new Runnable() {
146.375 - public void run() {
146.376 - initCompilerSetsImpl(dirlist);
146.377 - }
146.378 - });
146.379 - initializationTask.waitFinished();
146.380 - initializationTask = null;
146.381 - progressHandle.finish();
146.382 - }
146.383 -
146.384 - /** Search $PATH for all desired compiler sets and initialize cbCompilerSet and spCompilerSets */
146.385 - private void initCompilerSetsImpl(ArrayList<String> dirlist) {
146.386 - Set<CompilerFlavor> flavors = new HashSet<CompilerFlavor>();
146.387 - String SunStudioPath = System.getProperty("spro.bin"); // NB: function itself is synchronized!
146.388 -
146.389 - if (SunStudioPath != null) {
146.390 - File folder = new File(SunStudioPath);
146.391 - if (folder.isDirectory()) {
146.392 - for(ToolchainDescriptor d : ToolchainManager.getImpl().getToolchains(getPlatform())) {
146.393 - if (d.isAbstract()) {
146.394 - continue;
146.395 - }
146.396 - CompilerFlavor flavor = CompilerFlavor.toFlavor(d.getName(), getPlatform());
146.397 - if (flavor == null) {
146.398 - continue;
146.399 - }
146.400 - if (flavors.contains(flavor)) {
146.401 - continue;
146.402 - }
146.403 - CompilerSet cs = CompilerSet.getCustomCompilerSet(folder.getAbsolutePath(), flavor, flavor.toString());
146.404 - cs.setAutoGenerated(true);
146.405 - if (initCompilerSet(SunStudioPath, cs, true)){
146.406 - flavors.add(flavor);
146.407 - addUnsafe(cs);
146.408 - cs.setSunStudioDefault(true);
146.409 - }
146.410 - }
146.411 - }
146.412 - }
146.413 - Loop:for(ToolchainDescriptor d : ToolchainManager.getImpl().getToolchains(getPlatform())) {
146.414 - if (d.isAbstract()) {
146.415 - continue;
146.416 - }
146.417 - CompilerFlavor flavor = CompilerFlavor.toFlavor(d.getName(), getPlatform());
146.418 - if (flavor == null) {
146.419 - continue;
146.420 - }
146.421 - if (flavors.contains(flavor)) {
146.422 - continue;
146.423 - }
146.424 - for (FolderDescriptor folderDescriptor : getPaths(d, flavor, dirlist)) {
146.425 - String path = folderDescriptor.path;
146.426 - if (path.equals("/usr/ucb")) { // NOI18N
146.427 - // Don't look here.
146.428 - continue;
146.429 - }
146.430 - if (!CompilerSetUtils.isPathAbsolute(path)) {
146.431 - path = CndFileUtils.normalizeAbsolutePath(new File(path).getAbsolutePath());
146.432 - }
146.433 - File dir = new File(path);
146.434 - if (dir.isDirectory()) {
146.435 - if (ToolchainManager.getImpl().isMyFolder(dir.getAbsolutePath(), d, getPlatform(), folderDescriptor.knownFolder)){
146.436 - if (d.getModuleID() == null && !d.isAbstract()) {
146.437 - CompilerSet cs = CompilerSet.getCustomCompilerSet(dir.getAbsolutePath(), flavor, flavor.toString());
146.438 - cs.setAutoGenerated(true);
146.439 - if (initCompilerSet(path, cs, folderDescriptor.knownFolder)){
146.440 - flavors.add(flavor);
146.441 - addUnsafe(cs);
146.442 - continue Loop;
146.443 - }
146.444 - }
146.445 - }
146.446 - }
146.447 - }
146.448 - }
146.449 - addFakeCompilerSets();
146.450 - completeCompilerSets();
146.451 - state = State.STATE_COMPLETE;
146.452 - }
146.453 -
146.454 - /**
146.455 - * Since many toolchains have default locations, append them to the path (on a per-platform basis)
146.456 - * if they aren't already in the list.
146.457 - *
146.458 - * @param platform The platform we're running on
146.459 - * @param dirlist An ArrayList of the current PATH
146.460 - * @return A possibly modified ArrayList
146.461 - */
146.462 - static ArrayList<String> appendDefaultLocations(int platform, ArrayList<String> dirlist) {
146.463 - for (ToolchainDescriptor d : ToolchainManager.getImpl().getToolchains(platform)) {
146.464 - if (d.isAbstract()) {
146.465 - continue;
146.466 - }
146.467 - Map<String, List<String>> map = d.getDefaultLocations();
146.468 - if (map != null) {
146.469 - String pname = CompilerSetUtils.getPlatformName(platform);
146.470 - List<String> list = map.get(pname);
146.471 - if (list != null ) {
146.472 - for (String dir : list){
146.473 - if (!dirlist.contains(dir)){
146.474 - dirlist.add(dir);
146.475 - }
146.476 - }
146.477 - }
146.478 - }
146.479 - }
146.480 - return dirlist;
146.481 - }
146.482 -
146.483 - private void setDefaltCompilerSet() {
146.484 - for (CompilerSet cs : sets) {
146.485 - if (cs.isDefault()) {
146.486 - return;
146.487 - }
146.488 - }
146.489 - CompilerSet bestCandidate = null;
146.490 - for (CompilerSet cs : sets) {
146.491 - if (cs.isSunCompiler()) {
146.492 - if ("SunStudio".equals(cs.getName())) { // NOI18N
146.493 - setDefault(cs);
146.494 - return;
146.495 - }
146.496 - if (bestCandidate == null) {
146.497 - bestCandidate = cs;
146.498 - }
146.499 - }
146.500 - }
146.501 - if (bestCandidate != null) {
146.502 - setDefault(bestCandidate);
146.503 - return;
146.504 - }
146.505 - if (!sets.isEmpty()) {
146.506 - setDefault(sets.get(0));
146.507 - }
146.508 - }
146.509 -
146.510 - public List<CompilerSet> findRemoteCompilerSets(String path) {
146.511 - ServerRecord record = ServerList.get(executionEnvironment);
146.512 - assert record != null;
146.513 - record.validate(true);
146.514 - if (!record.isOnline()) {
146.515 - return Collections.<CompilerSet>emptyList();
146.516 - }
146.517 - final CompilerSetProvider provider = CompilerSetProviderFactory.createNew(executionEnvironment);
146.518 - String[] arData = provider.getCompilerSetData(path);
146.519 - List<CompilerSet> css = new ArrayList<CompilerSet>();
146.520 - if (arData != null) {
146.521 - for (String data : arData) {
146.522 - if (data != null && data.length() > 0) {
146.523 - CompilerSet cs = parseCompilerSetString(platform, data);
146.524 - if (cs != null) {
146.525 - css.add(cs);
146.526 - }
146.527 - }
146.528 - }
146.529 - }
146.530 - for(CompilerSet cs : css) {
146.531 - completeCompilerSet(executionEnvironment, cs, css);
146.532 - }
146.533 - return css;
146.534 - }
146.535 -
146.536 - private CompilerSet parseCompilerSetString(int platform, String data) {
146.537 - log.fine("CSM.initRemoteCompileSets: line = [" + data + "]"); // NOI18N
146.538 - String flavor;
146.539 - String path;
146.540 - StringTokenizer st = new StringTokenizer(data, ";"); // NOI18N
146.541 - try {
146.542 - flavor = st.nextToken();
146.543 - path = st.nextToken();
146.544 - } catch (NoSuchElementException ex) {
146.545 - log.warning("Malformed compilerSetString: " + data); // NOI18N
146.546 - return null;
146.547 - }
146.548 - CompilerFlavor compilerFlavor = CompilerFlavor.toFlavor(flavor, platform);
146.549 - if (compilerFlavor == null) { // #158084
146.550 - log.warning("NULL compiler flavor for " + flavor + " on platform " + platform); // NOI18N
146.551 - return null;
146.552 - }
146.553 - CompilerSet cs = new CompilerSet(compilerFlavor, path, flavor);
146.554 - while (st.hasMoreTokens()) {
146.555 - String name = st.nextToken();
146.556 - int i = name.indexOf('='); // NOI18N
146.557 - if (i < 0) {
146.558 - continue;
146.559 - }
146.560 - String tool = name.substring(0,i);
146.561 - String p = name.substring(i + 1);
146.562 - i = name.lastIndexOf('/');
146.563 - if (i < 0) {
146.564 - i = name.lastIndexOf('\\');
146.565 - }
146.566 - if (i > 0) {
146.567 - name = name.substring(i+1);
146.568 - }
146.569 - int kind = -1;
146.570 - if (tool.equals("c")){ // NOI18N
146.571 - kind = Tool.CCompiler;
146.572 - } else if (tool.equals("cpp")){ // NOI18N
146.573 - kind = Tool.CCCompiler;
146.574 - } else if (tool.equals("fortran")){ // NOI18N
146.575 - kind = Tool.FortranCompiler;
146.576 - } else if (tool.equals("assembler")){ // NOI18N
146.577 - kind = Tool.Assembler;
146.578 - } else if (tool.equals("make")){ // NOI18N
146.579 - kind = Tool.MakeTool;
146.580 - } else if (tool.equals("debugger")){ // NOI18N
146.581 - kind = Tool.DebuggerTool;
146.582 - } else if (tool.equals("cmake")){ // NOI18N
146.583 - kind = Tool.CMakeTool;
146.584 - } else if (tool.equals("qmake")){ // NOI18N
146.585 - kind = Tool.QMakeTool;
146.586 - } else if (tool.equals("c(PATH)")){ // NOI18N
146.587 - cs.addPathCandidate(Tool.CCompiler, p);
146.588 - } else if (tool.equals("cpp(PATH)")){ // NOI18N
146.589 - cs.addPathCandidate(Tool.CCCompiler, p);
146.590 - } else if (tool.equals("fortran(PATH)")){ // NOI18N
146.591 - cs.addPathCandidate(Tool.FortranCompiler, p);
146.592 - } else if (tool.equals("assembler(PATH)")){ // NOI18N
146.593 - cs.addPathCandidate(Tool.Assembler, p);
146.594 - } else if (tool.equals("make(PATH)")){ // NOI18N
146.595 - cs.addPathCandidate(Tool.MakeTool, p);
146.596 - } else if (tool.equals("debugger(PATH)")){ // NOI18N
146.597 - cs.addPathCandidate(Tool.DebuggerTool, p);
146.598 - } else if (tool.equals("cmake(PATH)")){ // NOI18N
146.599 - cs.addPathCandidate(Tool.CMakeTool, p);
146.600 - } else if (tool.equals("qmake(PATH)")){ // NOI18N
146.601 - cs.addPathCandidate(Tool.QMakeTool, p);
146.602 - }
146.603 - if (kind != -1) {
146.604 - cs.addTool(executionEnvironment, name, p, kind);
146.605 - }
146.606 - }
146.607 - return cs;
146.608 - }
146.609 -
146.610 - /** Initialize remote CompilerSets */
146.611 - private synchronized void initRemoteCompilerSets(boolean connect, final boolean runCompilerSetDataLoader) {
146.612 -
146.613 - //if (log.isLoggable(Level.FINEST)) {
146.614 - // String text = String.format("\n\n---------- IRCS @%d remoteInitialization=%s state=%s writer=%b\n", //NOI18N
146.615 - // System.identityHashCode(this), remoteInitialization, state, CompilerSetReporter.canReport());
146.616 - // new Exception(text).printStackTrace();
146.617 - //}
146.618 -
146.619 - // NB: function itself is synchronized!
146.620 - if (state == State.STATE_COMPLETE) {
146.621 - return;
146.622 - }
146.623 - if (initializationTask != null) {
146.624 - return;
146.625 - }
146.626 - ServerRecord record = ServerList.get(executionEnvironment);
146.627 - assert record != null;
146.628 -
146.629 - log.fine("CSM.initRemoteCompilerSets for " + executionEnvironment + " [" + state + "]"); // NOI18N
146.630 - final boolean wasOffline = record.isOffline();
146.631 - if (wasOffline) {
146.632 - CompilerSetReporter.report("CSM_Conn", false, executionEnvironment.getHost()); //NOI18N
146.633 - }
146.634 - record.validate(connect);
146.635 - if (record.isOnline()) {
146.636 - if (wasOffline) {
146.637 - CompilerSetReporter.report("CSM_Done"); //NOI18N
146.638 - }
146.639 - // NB: function itself is synchronized!
146.640 - initializationTask = RequestProcessor.getDefault().post(new Runnable() {
146.641 -
146.642 - @SuppressWarnings("unchecked")
146.643 - public void run() {
146.644 - //if (log.isLoggable(Level.FINEST)) {
146.645 - // System.err.printf("\n\n###########\n###### %b @%d #######\n############\n\n",
146.646 - // CompilerSetReporter.canReport(),System.identityHashCode(CompilerSetManager.this));
146.647 - //}
146.648 - try {
146.649 - final CompilerSetProvider provider = CompilerSetProviderFactory.createNew(executionEnvironment);
146.650 - assert provider != null;
146.651 - provider.init();
146.652 - platform = provider.getPlatform();
146.653 - CompilerSetReporter.report("CSM_ValPlatf", true, PlatformTypes.toString(platform)); //NOI18N
146.654 - CompilerSetReporter.report("CSM_LFTC"); //NOI18N
146.655 - log.fine("CSM.initRemoteCompileSets: platform = " + platform); // NOI18N
146.656 - CompilerSetPreferences.putEnv(executionEnvironment, platform);
146.657 - while (provider.hasMoreCompilerSets()) {
146.658 - String data = provider.getNextCompilerSetData();
146.659 - CompilerSet cs = parseCompilerSetString(platform, data);
146.660 - if (cs != null) {
146.661 - CompilerSetReporter.report("CSM_Found", true, cs.getDisplayName(), cs.getDirectory()); //NOI18N
146.662 - addUnsafe(cs);
146.663 - for (Tool tool : cs.getTools()) {
146.664 - if (! tool.isReady()) {
146.665 - CompilerSetReporter.report("CSM_Initializing_Tool", false, tool.getDisplayName()); //NOI18N
146.666 - tool.waitReady(true);
146.667 - CompilerSetReporter.report("CSM_Done"); //NOI18N
146.668 - }
146.669 - }
146.670 - } else if(CompilerSetReporter.canReport()) {
146.671 - CompilerSetReporter.report("CSM_Err", true, data);//NOI18N
146.672 - }
146.673 - }
146.674 - completeCompilerSets();
146.675 -
146.676 - log.fine("CSM.initRemoteCompilerSets: Found " + sets.size() + " compiler sets"); // NOI18N
146.677 - if (sets.size() == 0) {
146.678 - CompilerSetReporter.report("CSM_Done_NF"); //NOI18N
146.679 - } else {
146.680 - CompilerSetReporter.report("CSM_Done_OK", true, sets.size());//NOI18N
146.681 - }
146.682 - // NB: function itself is synchronized!
146.683 - state = State.STATE_COMPLETE;
146.684 - CompilerSetReporter.report("CSM_Conigured");//NOI18N
146.685 - if (runCompilerSetDataLoader) {
146.686 - finishInitialization();
146.687 - }
146.688 - } catch (Throwable thr) {
146.689 - // otherwise STATE_PENDING hangs forever - see #158088
146.690 - // NB: function itself is synchronized!
146.691 - state = State.STATE_UNINITIALIZED; //STATE_ERROR;
146.692 - log.log(Level.FINE, "Error initiaizing compiler set @" + hashCode() + //NOI18N
146.693 - " on " + executionEnvironment, thr); //NOI18N
146.694 - CompilerSetReporter.report("CSM_Fail"); //NOI18N
146.695 - completeCompilerSets();
146.696 - }
146.697 - }
146.698 -
146.699 - });
146.700 - } else {
146.701 - CompilerSetReporter.report("CSM_Fail");//NOI18N
146.702 - // create empty CSM
146.703 - log.fine("CSM.initRemoteCompilerSets: Adding empty CS to OFFLINE host " + executionEnvironment);
146.704 - completeCompilerSets();
146.705 - // NB: function itself is synchronized!
146.706 - state = State.STATE_UNINITIALIZED; //STATE_ERROR;
146.707 - }
146.708 - }
146.709 -
146.710 - public void finishInitialization() {
146.711 - CompilerSetProvider provider = CompilerSetProviderFactory.createNew(executionEnvironment);
146.712 - List<CompilerSet> setsCopy = new ArrayList<CompilerSet>(sets);
146.713 - Runnable compilerSetDataLoader = provider.createCompilerSetDataLoader(setsCopy);
146.714 - CndUtils.assertFalse(compilerSetDataLoader == null);
146.715 - if (compilerSetDataLoader != null) {
146.716 - RequestProcessor.Task task = RequestProcessor.getDefault().create(compilerSetDataLoader);
146.717 - task.addTaskListener(new TaskListener() {
146.718 - public void taskFinished(org.openide.util.Task task) {
146.719 - log.fine("Code Model Ready for " + CompilerSetManager.this.toString());
146.720 - // FIXUP: this server has been probably deleted; TODO: provide return statis from loader
146.721 - if (!ServerList.get(executionEnvironment).isDeleted()) {
146.722 - CompilerSetManagerEvents.get(executionEnvironment).runTasks();
146.723 - }
146.724 - }
146.725 - });
146.726 - task.schedule(0);
146.727 - }
146.728 - }
146.729 -
146.730 - public void initCompilerSet(CompilerSet cs) {
146.731 - initCompilerSet(cs.getDirectory(), cs, false);
146.732 - completeCompilerSet(executionEnvironment, cs, sets);
146.733 - }
146.734 -
146.735 - private boolean initCompilerSet(String path, CompilerSet cs, boolean known) {
146.736 - CompilerFlavor flavor = cs.getCompilerFlavor();
146.737 - ToolchainDescriptor d = flavor.getToolchainDescriptor();
146.738 - if (d != null && ToolchainManager.getImpl().isMyFolder(path, d, getPlatform(), known)) {
146.739 - CompilerDescriptor compiler = d.getC();
146.740 - if (compiler != null && !compiler.skipSearch()) {
146.741 - initCompiler(Tool.CCompiler, path, cs, compiler.getNames());
146.742 - }
146.743 - compiler = d.getCpp();
146.744 - if (compiler != null && !compiler.skipSearch()) {
146.745 - initCompiler(Tool.CCCompiler, path, cs, compiler.getNames());
146.746 - }
146.747 - compiler = d.getFortran();
146.748 - if (compiler != null && !compiler.skipSearch()) {
146.749 - initCompiler(Tool.FortranCompiler, path, cs, compiler.getNames());
146.750 - }
146.751 - compiler = d.getAssembler();
146.752 - if (compiler != null && !compiler.skipSearch()) {
146.753 - initCompiler(Tool.Assembler, path, cs, compiler.getNames());
146.754 - }
146.755 - if (d.getMake() != null && !d.getMake().skipSearch()){
146.756 - initCompiler(Tool.MakeTool, path, cs, d.getMake().getNames());
146.757 - }
146.758 - if (d.getDebugger() != null && !d.getDebugger().skipSearch()){
146.759 - initCompiler(Tool.DebuggerTool, path, cs, d.getDebugger().getNames());
146.760 - }
146.761 - if (d.getQMake() != null && !d.getQMake().skipSearch()){
146.762 - initCompiler(Tool.QMakeTool, path, cs, d.getQMake().getNames());
146.763 - }
146.764 - if (d.getCMake() != null && !d.getCMake().skipSearch()){
146.765 - initCompiler(Tool.CMakeTool, path, cs, d.getCMake().getNames());
146.766 - }
146.767 - return true;
146.768 - }
146.769 - return false;
146.770 - }
146.771 -
146.772 - private void initCompiler(int kind, String path, CompilerSet cs, String[] names) {
146.773 - File dir = new File(path);
146.774 - if (cs.findTool(kind) != null) {
146.775 - // Only one tool of each kind in a cs
146.776 - return;
146.777 - }
146.778 - for (String name : names) {
146.779 - File file = new File(dir, name);
146.780 - if (file.exists() && !file.isDirectory()) {
146.781 - cs.addTool(executionEnvironment, name, file.getAbsolutePath(), kind);
146.782 - return;
146.783 - }
146.784 - file = new File(dir, name + ".exe"); // NOI18N
146.785 - if (file.exists() && !file.isDirectory()) {
146.786 - cs.addTool(executionEnvironment, name, file.getAbsolutePath(), kind);
146.787 - return;
146.788 - }
146.789 - File file2 = new File(dir, name + ".exe.lnk"); // NOI18N
146.790 - if (file2.exists() && !file2.isDirectory()) {
146.791 - cs.addTool(executionEnvironment, name, file.getAbsolutePath(), kind);
146.792 - return;
146.793 - }
146.794 - }
146.795 - }
146.796 -
146.797 - private void addFakeCompilerSets() {
146.798 - for (CompilerFlavor flavor : CompilerFlavor.getFlavors(getPlatform())) {
146.799 - ToolchainDescriptor descriptor = flavor.getToolchainDescriptor();
146.800 - if (descriptor.getUpdateCenterUrl() != null && descriptor.getModuleID() != null) {
146.801 - boolean found = false;
146.802 - mainLoop:for (CompilerSet cs : sets) {
146.803 - for(String family : cs.getCompilerFlavor().getToolchainDescriptor().getFamily()){
146.804 - for(String f : flavor.getToolchainDescriptor().getFamily()){
146.805 - if (family.equals(f)) {
146.806 - found = true;
146.807 - break mainLoop;
146.808 - }
146.809 - }
146.810 - }
146.811 - }
146.812 - if (!found) {
146.813 - CompilerSet fake = CompilerSet.getCustomCompilerSet(null, flavor, null);
146.814 - fake.setAutoGenerated(true);
146.815 - addUnsafe(fake);
146.816 - }
146.817 - }
146.818 - }
146.819 - }
146.820 -
146.821 - /**
146.822 - * If a compiler set doesn't have one of each compiler types, add a "No compiler"
146.823 - * tool. If selected, this will tell the build validation things are OK.
146.824 - */
146.825 - private void completeCompilerSets() {
146.826 - if (sets.size() == 0) { // No compilers found
146.827 - addUnsafe(CompilerSet.createEmptyCompilerSet(PlatformTypes.PLATFORM_NONE));
146.828 - }
146.829 - for (CompilerSet cs : sets) {
146.830 - completeCompilerSet(executionEnvironment, cs, sets);
146.831 - }
146.832 - completeSunStudioCompilerSet(getPlatform());
146.833 - setDefaltCompilerSet();
146.834 - Collections.<CompilerSet>sort(sets, new Comparator<CompilerSet>(){
146.835 - public int compare(CompilerSet o1, CompilerSet o2) {
146.836 - return o1.getCompilerFlavor().getToolchainDescriptor().getName().compareTo(o2.getCompilerFlavor().getToolchainDescriptor().getName());
146.837 - }
146.838 - });
146.839 - completeCompilerSetsSettings(false);
146.840 - }
146.841 -
146.842 - private void completeCompilerSetsSettings(boolean reset) {
146.843 - for (CompilerSet cs : sets) {
146.844 - for (Tool tool : cs.getTools()) {
146.845 - if (!tool.isReady()) {
146.846 - tool.waitReady(reset);
146.847 - }
146.848 - }
146.849 - }
146.850 - }
146.851 -
146.852 - private void completeSunStudioCompilerSet(int platform) {
146.853 - CompilerSet bestCandidate = null;
146.854 - for(CompilerSet cs : sets) {
146.855 - if (cs.isSunStudioDefault()){
146.856 - bestCandidate = cs;
146.857 - break;
146.858 - }
146.859 - }
146.860 - // find 'best' Sun set and copy it
146.861 - CompilerSet sun = getCompilerSet("SunStudio"); // NOI18N
146.862 - if (sun != null) {
146.863 - return;
146.864 - }
146.865 - if (bestCandidate == null) {
146.866 - bestCandidate = getCompilerSet("SunStudio_12.2"); // NOI18N
146.867 - }
146.868 - if (bestCandidate == null) {
146.869 - bestCandidate = getCompilerSet("SunStudioExpress"); // NOI18N
146.870 - if (bestCandidate != null && bestCandidate.getCompilerFlavor().getToolchainDescriptor().getDisplayName().indexOf("Aten") < 0) { // NOI18N
146.871 - bestCandidate = null;
146.872 - }
146.873 - }
146.874 - if (bestCandidate == null) {
146.875 - bestCandidate = getCompilerSet("SunStudio_12.1"); // NOI18N
146.876 - }
146.877 - if (bestCandidate == null) {
146.878 - bestCandidate = getCompilerSet("SunStudioExpress"); // NOI18N
146.879 - }
146.880 - if (bestCandidate == null) {
146.881 - bestCandidate = getCompilerSet("SunStudioLite"); // NOI18N
146.882 - }
146.883 - if (bestCandidate == null) {
146.884 - bestCandidate = getCompilerSet("SunStudio_12"); // NOI18N
146.885 - }
146.886 - if (bestCandidate == null) {
146.887 - bestCandidate = getCompilerSet("SunStudio_11"); // NOI18N
146.888 - }
146.889 - if (bestCandidate == null) {
146.890 - bestCandidate = getCompilerSet("SunStudio_10"); // NOI18N
146.891 - }
146.892 - if (bestCandidate == null) {
146.893 - bestCandidate = getCompilerSet("SunStudio_9"); // NOI18N
146.894 - }
146.895 - if (bestCandidate == null) {
146.896 - bestCandidate = getCompilerSet("SunStudio_8"); // NOI18N
146.897 - }
146.898 - if (bestCandidate == null) {
146.899 - return;
146.900 - }
146.901 - if (bestCandidate.isUrlPointer()) {
146.902 - return;
146.903 - }
146.904 - CompilerSet bestCandidateCopy = bestCandidate.createCopy();
146.905 - bestCandidateCopy.setName("SunStudio"); // NOI18N
146.906 - CompilerFlavor flavor = CompilerFlavor.toFlavor("SunStudio", platform); // NOI18N
146.907 - if (flavor != null) { // #158084 NPE
146.908 - bestCandidateCopy.setFlavor(flavor);
146.909 - bestCandidateCopy.setAutoGenerated(true);
146.910 - addUnsafe(bestCandidateCopy);
146.911 - if (bestCandidate.isDefault()) {
146.912 - bestCandidateCopy.setAsDefault(false);
146.913 - }
146.914 - }
146.915 - }
146.916 -
146.917 - private static Tool autoComplete(ExecutionEnvironment env, CompilerSet cs, List<CompilerSet> sets, ToolDescriptor descriptor, int tool){
146.918 - if (descriptor != null && !cs.isUrlPointer()) {
146.919 - AlternativePath[] paths = descriptor.getAlternativePath();
146.920 - if (paths != null && paths.length > 0) {
146.921 - for(AlternativePath p : paths){
146.922 - switch(p.getKind()){
146.923 - case PATH:
146.924 - {
146.925 - StringTokenizer st = new StringTokenizer(p.getPath(),";,"); // NOI18N
146.926 - while(st.hasMoreTokens()){
146.927 - String method = st.nextToken();
146.928 - if ("$PATH".equals(method)){ // NOI18N
146.929 - if (env.isLocal()) {
146.930 - for(String name : descriptor.getNames()){
146.931 - String path = CompilerSetUtils.findCommand(name);
146.932 - if (path != null) {
146.933 - if (notSkipedName(cs, descriptor, path, name)) {
146.934 - return cs.addNewTool(env, CompilerSetUtils.getBaseName(path), path, tool);
146.935 - }
146.936 - }
146.937 - }
146.938 - } else {
146.939 - String path = cs.getPathCandidate(tool);
146.940 - if (path != null) {
146.941 - String name = CompilerSetUtils.getBaseName(path);
146.942 - if (notSkipedName(cs, descriptor, path, name)) {
146.943 - return cs.addNewTool(env, name, path, tool);
146.944 - }
146.945 - }
146.946 - }
146.947 - } else if ("$MSYS".equals(method)){ // NOI18N
146.948 - if (env.isLocal()) {
146.949 - for(String name : descriptor.getNames()){
146.950 - String dir = CompilerSetUtils.getCommandFolder(cs.getCompilerFlavor().getToolchainDescriptor());
146.951 - if (dir != null) {
146.952 - String path = CompilerSetUtils.findCommand(name, dir); // NOI18N
146.953 - if (path != null) {
146.954 - if (notSkipedName(cs, descriptor, path, name)) {
146.955 - return cs.addNewTool(env, CompilerSetUtils.getBaseName(path), path, tool);
146.956 - }
146.957 - }
146.958 - }
146.959 - }
146.960 - } else {
146.961 - // TODO
146.962 - }
146.963 - } else {
146.964 - if (env.isLocal()) {
146.965 - for(String name : descriptor.getNames()){
146.966 - String path = CompilerSetUtils.findCommand(name, method);
146.967 - if (path != null) {
146.968 - return cs.addNewTool(env, CompilerSetUtils.getBaseName(path), path, tool);
146.969 - }
146.970 - }
146.971 - } else {
146.972 - // TODO
146.973 - }
146.974 - }
146.975 - }
146.976 - break;
146.977 - }
146.978 - case TOOL_FAMILY:
146.979 - {
146.980 - StringTokenizer st = new StringTokenizer(p.getPath(),";,"); // NOI18N
146.981 - while(st.hasMoreTokens()){
146.982 - String method = st.nextToken();
146.983 - for(CompilerSet s : sets){
146.984 - if (s != cs) {
146.985 - for(String family : s.getCompilerFlavor().getToolchainDescriptor().getFamily()){
146.986 - if (family.equals(method)){
146.987 - Tool other = s.findTool(tool);
146.988 - if (other != null){
146.989 - return cs.addNewTool(env, other.getName(), other.getPath(), tool);
146.990 - }
146.991 - }
146.992 - }
146.993 - }
146.994 - }
146.995 - }
146.996 - break;
146.997 - }
146.998 - case TOOL_NAME:
146.999 - {
146.1000 - StringTokenizer st = new StringTokenizer(p.getPath(),";,"); // NOI18N
146.1001 - while(st.hasMoreTokens()){
146.1002 - String method = st.nextToken();
146.1003 - for(CompilerSet s : sets){
146.1004 - if (s != cs) {
146.1005 - String name = s.getCompilerFlavor().getToolchainDescriptor().getName();
146.1006 - if (name.equals(method) || "*".equals(method)){ // NOI18N
146.1007 - Tool other = s.findTool(tool);
146.1008 - if (other != null){
146.1009 - return cs.addNewTool(env, other.getName(), other.getPath(), tool);
146.1010 - }
146.1011 - }
146.1012 - }
146.1013 - }
146.1014 - }
146.1015 - break;
146.1016 - }
146.1017 - }
146.1018 - }
146.1019 - }
146.1020 - }
146.1021 - return cs.addTool(env, "", "", tool); // NOI18N
146.1022 - }
146.1023 -
146.1024 - private static boolean notSkipedName(CompilerSet cs, ToolDescriptor descriptor, String path, String name){
146.1025 - if (!descriptor.skipSearch()) {
146.1026 - return true;
146.1027 - }
146.1028 - String s = cs.getDirectory()+"/"+name; // NOI18N
146.1029 - s = s.replaceAll("\\\\", "/"); // NOI18N
146.1030 - path = path.replaceAll("\\\\", "/"); // NOI18N
146.1031 - return !path.startsWith(s);
146.1032 - }
146.1033 -
146.1034 - /*package-local*/ static void completeCompilerSet(ExecutionEnvironment env, CompilerSet cs, List<CompilerSet> sets) {
146.1035 - //if (cs.findTool(Tool.CCompiler) == null && cs.findTool(Tool.CCCompiler) == null) {
146.1036 - // // do not complete empty tool
146.1037 - // return;
146.1038 - //}
146.1039 - if (cs.findTool(Tool.CCompiler) == null) {
146.1040 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getC(), Tool.CCompiler);
146.1041 - }
146.1042 - if (cs.findTool(Tool.CCCompiler) == null) {
146.1043 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getCpp(), Tool.CCCompiler);
146.1044 - }
146.1045 - if (cs.findTool(Tool.FortranCompiler) == null) {
146.1046 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getFortran(), Tool.FortranCompiler);
146.1047 - }
146.1048 - if (cs.findTool(Tool.Assembler) == null) {
146.1049 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getAssembler(), Tool.Assembler);
146.1050 - }
146.1051 - if (cs.findTool(Tool.MakeTool) == null) {
146.1052 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getMake(), Tool.MakeTool);
146.1053 - }
146.1054 - if (cs.findTool(Tool.DebuggerTool) == null) {
146.1055 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getDebugger(), Tool.DebuggerTool);
146.1056 - }
146.1057 - if (cs.findTool(Tool.QMakeTool) == null) {
146.1058 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getQMake(), Tool.QMakeTool);
146.1059 - }
146.1060 - if (cs.findTool(Tool.CMakeTool) == null) {
146.1061 - autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getCMake(), Tool.CMakeTool);
146.1062 - }
146.1063 - }
146.1064 -
146.1065 /**
146.1066 * Add a CompilerSet to this CompilerSetManager. Make sure it doesn't get added multiple times.
146.1067 *
146.1068 * @param cs The CompilerSet to (possibly) add
146.1069 */
146.1070 - public void add(CompilerSet cs) {
146.1071 - if (sets.size() == 1 && sets.get(0).getName().equals(CompilerSet.None)) {
146.1072 - sets.remove(0);
146.1073 - }
146.1074 - sets.add(cs);
146.1075 - if (sets.size() == 1) {
146.1076 - setDefault(cs);
146.1077 - }
146.1078 - completeCompilerSets();
146.1079 - }
146.1080 + public abstract void add(CompilerSet cs);
146.1081
146.1082 - private void addUnsafe(CompilerSet cs) {
146.1083 - if (sets.size() == 1 && sets.get(0).getName().equals(CompilerSet.None)) {
146.1084 - sets.remove(0);
146.1085 - }
146.1086 - sets.add(cs);
146.1087 - }
146.1088 + public abstract List<CompilerSet> findRemoteCompilerSets(String path);
146.1089
146.1090 - public final boolean isEmpty() {
146.1091 - if ((sets.size() == 0) ||
146.1092 - (sets.size() == 1 && sets.get(0).getName().equals(CompilerSet.None))) {
146.1093 - return true;
146.1094 - }
146.1095 - return false;
146.1096 - }
146.1097 + public abstract void finishInitialization();
146.1098 +
146.1099 + public abstract CompilerSet getCompilerSet(CompilerFlavor flavor);
146.1100 +
146.1101 + public abstract CompilerSet getCompilerSet(String name);
146.1102 +
146.1103 + public abstract CompilerSet getCompilerSet(int idx);
146.1104 +
146.1105 + public abstract List<String> getCompilerSetNames();
146.1106 +
146.1107 + public abstract List<CompilerSet> getCompilerSets();
146.1108 +
146.1109 + public abstract CompilerSet getDefaultCompilerSet();
146.1110 +
146.1111 + public abstract boolean isDefaultCompilerSet(CompilerSet cs);
146.1112 +
146.1113 + public abstract ExecutionEnvironment getExecutionEnvironment();
146.1114 +
146.1115 + public abstract int getPlatform();
146.1116 +
146.1117 + public abstract String getUniqueCompilerSetName(String baseName);
146.1118 +
146.1119 + /**
146.1120 + * CAUTION: this is a slow method. It should NOT be called from the EDT thread
146.1121 + */
146.1122 + public abstract void initialize(boolean save, boolean runCompilerSetDataLoader, Writer reporter);
146.1123 +
146.1124 + public abstract boolean isEmpty();
146.1125 +
146.1126 + public abstract boolean isPending();
146.1127 +
146.1128 + public abstract boolean isUninitialized();
146.1129
146.1130 /**
146.1131 * Remove a CompilerSet from this CompilerSetManager. Use caution with this method. Its primary
146.1132 @@ -1103,129 +114,14 @@
146.1133 *
146.1134 * @param cs The CompilerSet to (possibly) remove
146.1135 */
146.1136 - public void remove(CompilerSet cs) {
146.1137 - int idx = sets.indexOf(cs);
146.1138 - if (idx >= 0) {
146.1139 - sets.remove(idx);
146.1140 + public abstract void remove(CompilerSet cs);
146.1141 +
146.1142 + public abstract void setDefault(CompilerSet newDefault);
146.1143 +
146.1144 + protected CompilerSetManager() {
146.1145 + if (!getClass().equals(CompilerSetManagerImpl.class)) {
146.1146 + throw new UnsupportedOperationException("this class can not be overriden by clients"); // NOI18N
146.1147 }
146.1148 }
146.1149
146.1150 - public CompilerSet getCompilerSet(CompilerFlavor flavor) {
146.1151 - return getCompilerSet(flavor.toString());
146.1152 - }
146.1153 -
146.1154 - public CompilerSet getCompilerSet(String name) {
146.1155 - for (CompilerSet cs : sets) {
146.1156 - if (cs.getName().equals(name)) {
146.1157 - return cs;
146.1158 - }
146.1159 - }
146.1160 - return null;
146.1161 - }
146.1162 -
146.1163 - public CompilerSet getCompilerSet(int idx) {
146.1164 - //waitForCompletion();
146.1165 - if (isPending()) {
146.1166 - log.warning("calling getCompilerSet() on uninitializad " + getClass().getSimpleName());
146.1167 - }
146.1168 - if (idx >= 0 && idx < sets.size()) {
146.1169 - return sets.get(idx);
146.1170 - }
146.1171 - return null;
146.1172 - }
146.1173 -
146.1174 - public List<CompilerSet> getCompilerSets() {
146.1175 - return new ArrayList<CompilerSet>(sets);
146.1176 - }
146.1177 -
146.1178 - public List<String> getCompilerSetNames() {
146.1179 - List<String> names = new ArrayList<String>();
146.1180 - for (CompilerSet cs : getCompilerSets()) {
146.1181 - names.add(cs.getName());
146.1182 - }
146.1183 - return names;
146.1184 - }
146.1185 -
146.1186 - public void setDefault(CompilerSet newDefault) {
146.1187 - boolean set = false;
146.1188 - for (CompilerSet cs : getCompilerSets()) {
146.1189 - cs.setAsDefault(false);
146.1190 - if (cs == newDefault) {
146.1191 - newDefault.setAsDefault(true);
146.1192 - set = true;
146.1193 - }
146.1194 - }
146.1195 - if (!set && sets.size() > 0) {
146.1196 - getCompilerSet(0).setAsDefault(true);
146.1197 - }
146.1198 - }
146.1199 -
146.1200 - public CompilerSet getDefaultCompilerSet() {
146.1201 - for (CompilerSet cs : getCompilerSets()) {
146.1202 - if (cs.isDefault()) {
146.1203 - return cs;
146.1204 - }
146.1205 - }
146.1206 - return null;
146.1207 - }
146.1208 -
146.1209 - /** TODO: deprecate and remove */
146.1210 - public static String getDefaultDevelopmentHost() {
146.1211 - return ExecutionEnvironmentFactory.toUniqueID(getDefaultExecutionEnvironment());
146.1212 - }
146.1213 -
146.1214 - public static ExecutionEnvironment getDefaultExecutionEnvironment() {
146.1215 - return ServerList.getDefaultRecord().getExecutionEnvironment();
146.1216 - }
146.1217 -
146.1218 - /** Look up i18n strings here */
146.1219 - private static String getString(String s) {
146.1220 - return NbBundle.getMessage(CompilerSetManager.class, s);
146.1221 - }
146.1222 -
146.1223 - @Override
146.1224 - public String toString() {
146.1225 - StringBuilder out = new StringBuilder();
146.1226 - out.append("CSM for ").append(executionEnvironment.toString()); // NOI18N
146.1227 - out.append(" with toolchains:["); // NOI18N
146.1228 - for (CompilerSet compilerSet : sets) {
146.1229 - out.append(compilerSet.getName()).append(" "); // NOI18N
146.1230 - }
146.1231 - out.append("]"); // NOI18N
146.1232 - out.append(" platform:").append(PlatformTypes.toString(platform)); // NOI18N
146.1233 - out.append(" in state ").append(state.toString()); // NOI18N
146.1234 - return out.toString();
146.1235 - }
146.1236 -
146.1237 - public ExecutionEnvironment getExecutionEnvironment() {
146.1238 - return executionEnvironment;
146.1239 - }
146.1240 -
146.1241 - private static enum State {
146.1242 - STATE_PENDING,
146.1243 - STATE_COMPLETE,
146.1244 - STATE_UNINITIALIZED
146.1245 - }
146.1246 -
146.1247 - private static final class FolderDescriptor {
146.1248 - private final String path;
146.1249 - private final boolean knownFolder;
146.1250 - private FolderDescriptor(String path, boolean knownFolder){
146.1251 - this.path = path;
146.1252 - this.knownFolder = knownFolder;
146.1253 - }
146.1254 -
146.1255 - @Override
146.1256 - public int hashCode() {
146.1257 - return path.hashCode();
146.1258 - }
146.1259 -
146.1260 - @Override
146.1261 - public boolean equals(Object obj) {
146.1262 - if (obj instanceof FolderDescriptor) {
146.1263 - return path.equals(((FolderDescriptor)obj).path);
146.1264 - }
146.1265 - return false;
146.1266 - }
146.1267 - }
146.1268 }
147.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetManagerEvents.java Mon Feb 01 12:23:06 2010 +0100
147.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
147.3 @@ -1,97 +0,0 @@
147.4 -/*
147.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
147.6 - *
147.7 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
147.8 - *
147.9 - * The contents of this file are subject to the terms of either the GNU
147.10 - * General Public License Version 2 only ("GPL") or the Common
147.11 - * Development and Distribution License("CDDL") (collectively, the
147.12 - * "License"). You may not use this file except in compliance with the
147.13 - * License. You can obtain a copy of the License at
147.14 - * http://www.netbeans.org/cddl-gplv2.html
147.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
147.16 - * specific language governing permissions and limitations under the
147.17 - * License. When distributing the software, include this License Header
147.18 - * Notice in each file and include the License file at
147.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
147.20 - * particular file as subject to the "Classpath" exception as provided
147.21 - * by Sun in the GPL Version 2 section of the License file that
147.22 - * accompanied this code. If applicable, add the following below the
147.23 - * License Header, with the fields enclosed by brackets [] replaced by
147.24 - * your own identifying information:
147.25 - * "Portions Copyrighted [year] [name of copyright owner]"
147.26 - *
147.27 - * If you wish your version of this file to be governed by only the CDDL
147.28 - * or only the GPL Version 2, indicate your decision by adding
147.29 - * "[Contributor] elects to include this software in this distribution
147.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
147.31 - * single choice of license, a recipient has the option to distribute
147.32 - * your version of this file under either the CDDL, the GPL Version 2 or
147.33 - * to extend the choice of license to its licensees as provided above.
147.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
147.35 - * Version 2 license, then the option applies only if the new code is
147.36 - * made subject to such option by the copyright holder.
147.37 - *
147.38 - * Contributor(s):
147.39 - *
147.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
147.41 - */
147.42 -package org.netbeans.modules.cnd.toolchain.api;
147.43 -
147.44 -import java.util.ArrayList;
147.45 -import java.util.HashMap;
147.46 -import java.util.List;
147.47 -import java.util.Map;
147.48 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
147.49 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
147.50 -
147.51 -/**
147.52 - * CompilerSetManagerEvents handles tasks which depends on CompilerSetManager activity and
147.53 - * have to survive CompilerSetManager.deepCopy()
147.54 - *
147.55 - * There is only one (and I hope there would be only one) such event -- Code Model Readiness
147.56 - *
147.57 - * @author Sergey Grinev
147.58 - */
147.59 -public class CompilerSetManagerEvents {
147.60 -
147.61 - private static final Map<ExecutionEnvironment, CompilerSetManagerEvents> map =
147.62 - new HashMap<ExecutionEnvironment, CompilerSetManagerEvents>();
147.63 -
147.64 - public static synchronized CompilerSetManagerEvents get(ExecutionEnvironment env) {
147.65 - CompilerSetManagerEvents instance = map.get(env);
147.66 - if (instance == null) {
147.67 - instance = new CompilerSetManagerEvents(env);
147.68 - map.put(env, instance);
147.69 - }
147.70 - return instance;
147.71 - }
147.72 -
147.73 - public CompilerSetManagerEvents(ExecutionEnvironment env) {
147.74 - this.executionEnvironment = env;
147.75 - this.isCodeModelInfoReady = CompilerSetManager.getDefault(executionEnvironment).isComplete();
147.76 - }
147.77 -
147.78 - private final ExecutionEnvironment executionEnvironment;
147.79 -
147.80 - private boolean isCodeModelInfoReady;
147.81 - private List<Runnable> tasks = new ArrayList<Runnable>();
147.82 -
147.83 - public void runOnCodeModelReadiness(Runnable task) {
147.84 - if (executionEnvironment.isLocal() || isCodeModelInfoReady) {
147.85 - task.run();
147.86 - } else {
147.87 - tasks.add(task);
147.88 - }
147.89 - }
147.90 -
147.91 - /* package */ void runTasks() {
147.92 - isCodeModelInfoReady = true;
147.93 - if (tasks != null) {
147.94 - for (Runnable task : tasks) {
147.95 - task.run();
147.96 - }
147.97 - }
147.98 - tasks = null;
147.99 - }
147.100 -}
148.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetPreferences.java Mon Feb 01 12:23:06 2010 +0100
148.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
148.3 @@ -1,247 +0,0 @@
148.4 -/*
148.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
148.6 - *
148.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
148.8 - *
148.9 - * The contents of this file are subject to the terms of either the GNU
148.10 - * General Public License Version 2 only ("GPL") or the Common
148.11 - * Development and Distribution License("CDDL") (collectively, the
148.12 - * "License"). You may not use this file except in compliance with the
148.13 - * License. You can obtain a copy of the License at
148.14 - * http://www.netbeans.org/cddl-gplv2.html
148.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
148.16 - * specific language governing permissions and limitations under the
148.17 - * License. When distributing the software, include this License Header
148.18 - * Notice in each file and include the License file at
148.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
148.20 - * particular file as subject to the "Classpath" exception as provided
148.21 - * by Sun in the GPL Version 2 section of the License file that
148.22 - * accompanied this code. If applicable, add the following below the
148.23 - * License Header, with the fields enclosed by brackets [] replaced by
148.24 - * your own identifying information:
148.25 - * "Portions Copyrighted [year] [name of copyright owner]"
148.26 - *
148.27 - * If you wish your version of this file to be governed by only the CDDL
148.28 - * or only the GPL Version 2, indicate your decision by adding
148.29 - * "[Contributor] elects to include this software in this distribution
148.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
148.31 - * single choice of license, a recipient has the option to distribute
148.32 - * your version of this file under either the CDDL, the GPL Version 2 or
148.33 - * to extend the choice of license to its licensees as provided above.
148.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
148.35 - * Version 2 license, then the option applies only if the new code is
148.36 - * made subject to such option by the copyright holder.
148.37 - *
148.38 - * Contributor(s):
148.39 - *
148.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
148.41 - */
148.42 -
148.43 -package org.netbeans.modules.cnd.toolchain.api;
148.44 -
148.45 -import java.util.ArrayList;
148.46 -import java.util.List;
148.47 -import java.util.prefs.BackingStoreException;
148.48 -import java.util.prefs.Preferences;
148.49 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
148.50 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
148.51 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
148.52 -import org.openide.util.Exceptions;
148.53 -import org.openide.util.NbPreferences;
148.54 -
148.55 -/**
148.56 - *
148.57 - * @author Alexander Simon
148.58 - */
148.59 -final class CompilerSetPreferences {
148.60 - /* Persistance information */
148.61 - private static final double csm_version = 1.1;
148.62 - private static final String CSM = "csm."; // NOI18N
148.63 - private static final String VERSION = "version"; // NOI18N
148.64 - private static final String NO_SETS = ".noOfSets"; // NOI18N
148.65 - private static final String SET_NAME = ".setName."; // NOI18N
148.66 - private static final String SET_FLAVOR = ".setFlavor."; // NOI18N
148.67 - private static final String SET_DIRECTORY = ".setDirectory."; // NOI18N
148.68 - private static final String SET_AUTO = ".autoGenerated."; // NOI18N
148.69 - private static final String SET_DEFAULT = ".defaultSet"; // NOI18N
148.70 - private static final String SET_PLATFORM = ".setPlatform."; // NOI18N
148.71 - private static final String NO_TOOLS = ".noOfTools."; // NOI18N
148.72 - private static final String TOOL_NAME = ".toolName."; // NOI18N
148.73 - private static final String TOOL_DISPLAYNAME = ".toolDisplayName."; // NOI18N
148.74 - private static final String TOOL_KIND = ".toolKind."; // NOI18N
148.75 - private static final String TOOL_PATH = ".toolPath."; // NOI18N
148.76 - private static final String TOOL_FLAVOR = ".toolFlavor."; // NOI18N
148.77 -
148.78 - private static CompilerProvider compilerProvider = null;
148.79 -
148.80 - private CompilerSetPreferences() {
148.81 - }
148.82 -
148.83 - /*
148.84 - * Persistence ...
148.85 - */
148.86 - static Preferences getPreferences() {
148.87 - return NbPreferences.forModule(CompilerSetPreferences.class);
148.88 - }
148.89 -
148.90 - static void putEnv(ExecutionEnvironment executionEnvironment, int platform){
148.91 - getPreferences().putInt(CSM + ExecutionEnvironmentFactory.toUniqueID(executionEnvironment) + SET_PLATFORM, platform);
148.92 - }
148.93 -
148.94 - static void clearPersistence() {
148.95 - try {
148.96 - getPreferences().clear();
148.97 - } catch (BackingStoreException ex) {
148.98 - Exceptions.printStackTrace(ex);
148.99 - }
148.100 - }
148.101 -
148.102 - static void saveToDisk(CompilerSetManager manager) {
148.103 - if (!manager.getCompilerSets().isEmpty()) {
148.104 - getPreferences().putDouble(CSM + VERSION, csm_version);
148.105 - String executionEnvironmentKey = ExecutionEnvironmentFactory.toUniqueID(manager.getExecutionEnvironment());
148.106 - getPreferences().putInt(CSM + executionEnvironmentKey + NO_SETS, manager.getCompilerSets().size());
148.107 - getPreferences().putInt(CSM + executionEnvironmentKey + SET_PLATFORM, manager.getPlatform());
148.108 - int setCount = 0;
148.109 - for (CompilerSet cs : manager.getCompilerSets()) {
148.110 - getPreferences().put(CSM + executionEnvironmentKey + SET_NAME + setCount, cs.getName());
148.111 - getPreferences().put(CSM + executionEnvironmentKey + SET_FLAVOR + setCount, cs.getCompilerFlavor().toString());
148.112 - getPreferences().put(CSM + executionEnvironmentKey + SET_DIRECTORY + setCount, cs.getDirectory());
148.113 - getPreferences().putBoolean(CSM + executionEnvironmentKey + SET_AUTO + setCount, cs.isAutoGenerated());
148.114 - getPreferences().putBoolean(CSM + executionEnvironmentKey + SET_DEFAULT + setCount, cs.isDefault());
148.115 - List<Tool> tools = cs.getTools();
148.116 - getPreferences().putInt(CSM + executionEnvironmentKey + NO_TOOLS + setCount, tools.size());
148.117 - int toolCount = 0;
148.118 - for (Tool tool : tools) {
148.119 - getPreferences().put(CSM + executionEnvironmentKey + TOOL_NAME + setCount + '.' + toolCount, tool.getName());
148.120 - getPreferences().put(CSM + executionEnvironmentKey + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount, tool.getDisplayName());
148.121 - getPreferences().putInt(CSM + executionEnvironmentKey + TOOL_KIND + setCount + '.' + toolCount, tool.getKind());
148.122 - getPreferences().put(CSM + executionEnvironmentKey + TOOL_PATH + setCount + '.' + toolCount, tool.getPath());
148.123 - getPreferences().put(CSM + executionEnvironmentKey + TOOL_FLAVOR + setCount + '.' + toolCount, tool.getFlavor().toString());
148.124 - toolCount++;
148.125 - }
148.126 - setCount++;
148.127 - }
148.128 - }
148.129 - }
148.130 -
148.131 - static CompilerSetManager restoreFromDisk(ExecutionEnvironment env) {
148.132 - double version = getPreferences().getDouble(CSM + VERSION, 1.0);
148.133 - if (version == 1.0 && env.isLocal()) {
148.134 - return restoreFromDisk10();
148.135 - }
148.136 - String executionEnvironmentKey = ExecutionEnvironmentFactory.toUniqueID(env);
148.137 - int noSets = getPreferences().getInt(CSM + executionEnvironmentKey + NO_SETS, -1);
148.138 - if (noSets < 0) {
148.139 - return null;
148.140 - }
148.141 - int pform = getPreferences().getInt(CSM + executionEnvironmentKey + SET_PLATFORM, -1);
148.142 - if (pform < 0) {
148.143 - if (env.isLocal()) {
148.144 - pform = CompilerSetUtils.computeLocalPlatform();
148.145 - }
148.146 - }
148.147 -
148.148 - ArrayList<CompilerSet> css = new ArrayList<CompilerSet>();
148.149 - for (int setCount = 0; setCount < noSets; setCount++) {
148.150 - String setName = getPreferences().get(CSM + executionEnvironmentKey + SET_NAME + setCount, null);
148.151 - String setFlavorName = getPreferences().get(CSM + executionEnvironmentKey + SET_FLAVOR + setCount, null);
148.152 - CompilerFlavor flavor = null;
148.153 - if (setFlavorName != null) {
148.154 - flavor = CompilerFlavor.toFlavor(setFlavorName, pform);
148.155 - }
148.156 - String setDirectory = getPreferences().get(CSM + executionEnvironmentKey + SET_DIRECTORY + setCount, null);
148.157 - if (setName == null || setFlavorName == null || flavor == null) {
148.158 - // FIXUP: error
148.159 - continue;
148.160 - }
148.161 - Boolean auto = getPreferences().getBoolean(CSM + executionEnvironmentKey + SET_AUTO + setCount, false);
148.162 - Boolean isDefault = getPreferences().getBoolean(CSM + executionEnvironmentKey + SET_DEFAULT + setCount, false);
148.163 - CompilerSet cs = new CompilerSet(flavor, setDirectory, setName);
148.164 - cs.setAutoGenerated(auto);
148.165 - cs.setAsDefault(isDefault);
148.166 - int noTools = getPreferences().getInt(CSM + executionEnvironmentKey + NO_TOOLS + setCount, -1);
148.167 - for (int toolCount = 0; toolCount < noTools; toolCount++) {
148.168 - String toolName = getPreferences().get(CSM + executionEnvironmentKey + TOOL_NAME + setCount + '.' + toolCount, null);
148.169 - String toolDisplayName = getPreferences().get(CSM + executionEnvironmentKey + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount, null);
148.170 - int toolKind = getPreferences().getInt(CSM + executionEnvironmentKey + TOOL_KIND + setCount + '.' + toolCount, -1);
148.171 - String toolPath = getPreferences().get(CSM + executionEnvironmentKey + TOOL_PATH + setCount + '.' + toolCount, null);
148.172 - String toolFlavorName = getPreferences().get(CSM + executionEnvironmentKey + TOOL_FLAVOR + setCount + '.' + toolCount, null);
148.173 - CompilerFlavor toolFlavor = null;
148.174 - if (toolFlavorName != null) {
148.175 - toolFlavor = CompilerFlavor.toFlavor(toolFlavorName, pform);
148.176 - }
148.177 - Tool tool = CompilerSetPreferences.getCompilerProvider().createCompiler(env, toolFlavor, toolKind, "", toolDisplayName, toolPath);
148.178 - tool.setName(toolName);
148.179 - cs.addTool(tool);
148.180 - }
148.181 - css.add(cs);
148.182 - }
148.183 -
148.184 - CompilerSetManager csm = new CompilerSetManager(env, css, pform);
148.185 - return csm;
148.186 - }
148.187 -
148.188 - private static CompilerSetManager restoreFromDisk10() {
148.189 - int noSets = getPreferences().getInt(CSM + NO_SETS, -1);
148.190 - if (noSets < 0) {
148.191 - return null;
148.192 - }
148.193 -
148.194 - ArrayList<CompilerSet> css = new ArrayList<CompilerSet>();
148.195 - getPreferences().remove(CSM + NO_SETS);
148.196 - for (int setCount = 0; setCount < noSets; setCount++) {
148.197 - String setName = getPreferences().get(CSM + SET_NAME + setCount, null);
148.198 - getPreferences().remove(CSM + SET_NAME + setCount);
148.199 - String setFlavorName = getPreferences().get(CSM + SET_FLAVOR + setCount, null);
148.200 - getPreferences().remove(CSM + SET_FLAVOR + setCount);
148.201 - CompilerFlavor flavor = null;
148.202 - if (setFlavorName != null) {
148.203 - flavor = CompilerFlavor.toFlavor(setFlavorName, PlatformTypes.getDefaultPlatform());
148.204 - }
148.205 - String setDirectory = getPreferences().get(CSM + SET_DIRECTORY + setCount, null);
148.206 - getPreferences().remove(CSM + SET_DIRECTORY + setCount);
148.207 - if (setName == null || setFlavorName == null || flavor == null) {
148.208 - // FIXUP: error
148.209 - continue;
148.210 - }
148.211 - Boolean auto = getPreferences().getBoolean(CSM + SET_AUTO + setCount, false);
148.212 - getPreferences().remove(CSM + SET_AUTO + setCount);
148.213 - CompilerSet cs = new CompilerSet(flavor, setDirectory, setName);
148.214 - cs.setAutoGenerated(auto);
148.215 - int noTools = getPreferences().getInt(CSM + NO_TOOLS + setCount, -1);
148.216 - getPreferences().remove(CSM + NO_TOOLS + setCount);
148.217 - for (int toolCount = 0; toolCount < noTools; toolCount++) {
148.218 - String toolName = getPreferences().get(CSM + TOOL_NAME + setCount + '.' + toolCount, null);
148.219 - String toolDisplayName = getPreferences().get(CSM + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount, null);
148.220 - int toolKind = getPreferences().getInt(CSM + TOOL_KIND + setCount + '.' + toolCount, -1);
148.221 - String toolPath = getPreferences().get(CSM + TOOL_PATH + setCount + '.' + toolCount, null);
148.222 - String toolFlavorName = getPreferences().get(CSM + TOOL_FLAVOR + setCount + '.' + toolCount, null);
148.223 - getPreferences().remove(CSM + TOOL_NAME + setCount + '.' + toolCount);
148.224 - getPreferences().remove(CSM + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount);
148.225 - getPreferences().remove(CSM + TOOL_KIND + setCount + '.' + toolCount);
148.226 - getPreferences().remove(CSM + TOOL_PATH + setCount + '.' + toolCount);
148.227 - getPreferences().remove(CSM + TOOL_FLAVOR + setCount + '.' + toolCount);
148.228 - CompilerFlavor toolFlavor = null;
148.229 - if (toolFlavorName != null) {
148.230 - toolFlavor = CompilerFlavor.toFlavor(toolFlavorName, PlatformTypes.getDefaultPlatform());
148.231 - }
148.232 - Tool tool = CompilerSetPreferences.getCompilerProvider().createCompiler(ExecutionEnvironmentFactory.getLocal(),
148.233 - toolFlavor, toolKind, "", toolDisplayName, toolPath); //NOI18N
148.234 - tool.setName(toolName);
148.235 - cs.addTool(tool);
148.236 - }
148.237 - CompilerSetManager.completeCompilerSet(ExecutionEnvironmentFactory.getLocal(), cs, css);
148.238 - css.add(cs);
148.239 - }
148.240 - CompilerSetManager csm = new CompilerSetManager(ExecutionEnvironmentFactory.getLocal(), css, CompilerSetUtils.computeLocalPlatform());
148.241 - return csm;
148.242 - }
148.243 -
148.244 - static CompilerProvider getCompilerProvider() {
148.245 - if (compilerProvider == null) {
148.246 - compilerProvider = CompilerProvider.getInstance();
148.247 - }
148.248 - return compilerProvider;
148.249 - }
148.250 -}
149.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetProvider.java Mon Feb 01 12:23:06 2010 +0100
149.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
149.3 @@ -1,61 +0,0 @@
149.4 -/*
149.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
149.6 - *
149.7 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
149.8 - *
149.9 - * The contents of this file are subject to the terms of either the GNU
149.10 - * General Public License Version 2 only ("GPL") or the Common
149.11 - * Development and Distribution License("CDDL") (collectively, the
149.12 - * "License"). You may not use this file except in compliance with the
149.13 - * License. You can obtain a copy of the License at
149.14 - * http://www.netbeans.org/cddl-gplv2.html
149.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
149.16 - * specific language governing permissions and limitations under the
149.17 - * License. When distributing the software, include this License Header
149.18 - * Notice in each file and include the License file at
149.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
149.20 - * particular file as subject to the "Classpath" exception as provided
149.21 - * by Sun in the GPL Version 2 section of the License file that
149.22 - * accompanied this code. If applicable, add the following below the
149.23 - * License Header, with the fields enclosed by brackets [] replaced by
149.24 - * your own identifying information:
149.25 - * "Portions Copyrighted [year] [name of copyright owner]"
149.26 - *
149.27 - * If you wish your version of this file to be governed by only the CDDL
149.28 - * or only the GPL Version 2, indicate your decision by adding
149.29 - * "[Contributor] elects to include this software in this distribution
149.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
149.31 - * single choice of license, a recipient has the option to distribute
149.32 - * your version of this file under either the CDDL, the GPL Version 2 or
149.33 - * to extend the choice of license to its licensees as provided above.
149.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
149.35 - * Version 2 license, then the option applies only if the new code is
149.36 - * made subject to such option by the copyright holder.
149.37 - *
149.38 - * Contributor(s):
149.39 - *
149.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
149.41 - */
149.42 -
149.43 -package org.netbeans.modules.cnd.toolchain.api;
149.44 -
149.45 -import java.util.List;
149.46 -
149.47 -/**
149.48 - * @author gordonp
149.49 - * @author vkvashin
149.50 - */
149.51 -public interface CompilerSetProvider {
149.52 -
149.53 - int getPlatform();
149.54 -
149.55 - void init();
149.56 -
149.57 - boolean hasMoreCompilerSets();
149.58 -
149.59 - String getNextCompilerSetData();
149.60 -
149.61 - String[] getCompilerSetData(String path);
149.62 -
149.63 - Runnable createCompilerSetDataLoader(List<CompilerSet> sets);
149.64 -}
150.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetProviderFactory.java Mon Feb 01 12:23:06 2010 +0100
150.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
150.3 @@ -1,67 +0,0 @@
150.4 -/*
150.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
150.6 - *
150.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
150.8 - *
150.9 - * The contents of this file are subject to the terms of either the GNU
150.10 - * General Public License Version 2 only ("GPL") or the Common
150.11 - * Development and Distribution License("CDDL") (collectively, the
150.12 - * "License"). You may not use this file except in compliance with the
150.13 - * License. You can obtain a copy of the License at
150.14 - * http://www.netbeans.org/cddl-gplv2.html
150.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
150.16 - * specific language governing permissions and limitations under the
150.17 - * License. When distributing the software, include this License Header
150.18 - * Notice in each file and include the License file at
150.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
150.20 - * particular file as subject to the "Classpath" exception as provided
150.21 - * by Sun in the GPL Version 2 section of the License file that
150.22 - * accompanied this code. If applicable, add the following below the
150.23 - * License Header, with the fields enclosed by brackets [] replaced by
150.24 - * your own identifying information:
150.25 - * "Portions Copyrighted [year] [name of copyright owner]"
150.26 - *
150.27 - * If you wish your version of this file to be governed by only the CDDL
150.28 - * or only the GPL Version 2, indicate your decision by adding
150.29 - * "[Contributor] elects to include this software in this distribution
150.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
150.31 - * single choice of license, a recipient has the option to distribute
150.32 - * your version of this file under either the CDDL, the GPL Version 2 or
150.33 - * to extend the choice of license to its licensees as provided above.
150.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
150.35 - * Version 2 license, then the option applies only if the new code is
150.36 - * made subject to such option by the copyright holder.
150.37 - *
150.38 - * Contributor(s):
150.39 - *
150.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
150.41 - */
150.42 -
150.43 -package org.netbeans.modules.cnd.toolchain.api;
150.44 -
150.45 -import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProviderFactoryImpl;
150.46 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
150.47 -import org.openide.util.Lookup;
150.48 -
150.49 -/**
150.50 - * An factory for creation CompilerSetProvider instances
150.51 - * @author Vladimir Kvashin
150.52 - */
150.53 -public class CompilerSetProviderFactory {
150.54 - /**
150.55 - * Creates a new instance of CompilerSetProvider
150.56 - * for the given execution environment
150.57 - * @param execEnv execution environment to create CompilerSetProvider for
150.58 - * @return new CompilerSetProvider instance
150.59 - */
150.60 - public static CompilerSetProvider createNew(ExecutionEnvironment execEnv) {
150.61 - CompilerSetProviderFactoryImpl factory = Lookup.getDefault().lookup(CompilerSetProviderFactoryImpl.class);
150.62 - if (factory == null) {
150.63 - throw new IllegalStateException(CompilerSetProviderFactoryImpl.class.getName() +" not found in lookup"); //NOI18N
150.64 - }
150.65 - return factory.createNew(execEnv);
150.66 - }
150.67 -
150.68 - private CompilerSetProviderFactory() {
150.69 - }
150.70 -}
151.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetReporter.java Mon Feb 01 12:23:06 2010 +0100
151.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
151.3 @@ -1,87 +0,0 @@
151.4 -/*
151.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
151.6 - *
151.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
151.8 - *
151.9 - * The contents of this file are subject to the terms of either the GNU
151.10 - * General Public License Version 2 only ("GPL") or the Common
151.11 - * Development and Distribution License("CDDL") (collectively, the
151.12 - * "License"). You may not use this file except in compliance with the
151.13 - * License. You can obtain a copy of the License at
151.14 - * http://www.netbeans.org/cddl-gplv2.html
151.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
151.16 - * specific language governing permissions and limitations under the
151.17 - * License. When distributing the software, include this License Header
151.18 - * Notice in each file and include the License file at
151.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
151.20 - * particular file as subject to the "Classpath" exception as provided
151.21 - * by Sun in the GPL Version 2 section of the License file that
151.22 - * accompanied this code. If applicable, add the following below the
151.23 - * License Header, with the fields enclosed by brackets [] replaced by
151.24 - * your own identifying information:
151.25 - * "Portions Copyrighted [year] [name of copyright owner]"
151.26 - *
151.27 - * If you wish your version of this file to be governed by only the CDDL
151.28 - * or only the GPL Version 2, indicate your decision by adding
151.29 - * "[Contributor] elects to include this software in this distribution
151.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
151.31 - * single choice of license, a recipient has the option to distribute
151.32 - * your version of this file under either the CDDL, the GPL Version 2 or
151.33 - * to extend the choice of license to its licensees as provided above.
151.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
151.35 - * Version 2 license, then the option applies only if the new code is
151.36 - * made subject to such option by the copyright holder.
151.37 - *
151.38 - * Contributor(s):
151.39 - *
151.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
151.41 - */
151.42 -
151.43 -package org.netbeans.modules.cnd.toolchain.api;
151.44 -
151.45 -import java.io.IOException;
151.46 -import java.io.Writer;
151.47 -import org.openide.util.NbBundle;
151.48 -
151.49 -/**
151.50 - * Sometimes we need to make process of setting up compiler set verbose.
151.51 - * This class allows to plug in a writer to report the process of
151.52 - * compiler set setup to
151.53 - * @author Vladimir Kvashin
151.54 - */
151.55 -public class CompilerSetReporter {
151.56 -
151.57 - private static Writer writer;
151.58 -
151.59 - /**
151.60 - * Sets a writer to report the process of compiler set setup to
151.61 - * @param writer if null, no reporting occurs
151.62 - */
151.63 - public static synchronized void setWriter(Writer writer) {
151.64 - CompilerSetReporter.writer = writer;
151.65 - }
151.66 -
151.67 - /* package-local */
151.68 - static void report(String msgKey) {
151.69 - report(msgKey, true);
151.70 - }
151.71 -
151.72 - /* package-local */
151.73 - static synchronized void report(String msgKey, boolean addLineFeed, Object... params) {
151.74 - if (writer != null) {
151.75 - try {
151.76 - writer.write(NbBundle.getMessage(CompilerSetReporter.class, msgKey, params));
151.77 - if (addLineFeed) {
151.78 - writer.write('\n');
151.79 - }
151.80 - writer.flush();
151.81 - } catch (IOException ex) {
151.82 - }
151.83 - }
151.84 - }
151.85 -
151.86 - /* package-local */
151.87 - static boolean canReport() {
151.88 - return writer != null;
151.89 - }
151.90 -}
152.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetUtils.java Mon Feb 01 12:23:06 2010 +0100
152.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/CompilerSetUtils.java Mon Feb 01 12:24:26 2010 +0100
152.3 @@ -39,7 +39,6 @@
152.4
152.5 package org.netbeans.modules.cnd.toolchain.api;
152.6
152.7 -import java.io.File;
152.8 import java.util.HashMap;
152.9 import java.util.Map;
152.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
152.11 @@ -63,7 +62,7 @@
152.12 */
152.13 public static String getCygwinBase() {
152.14 if (cygwinBase == null) {
152.15 - ToolchainManagerImpl tcm = ToolchainManager.getImpl();
152.16 + ToolchainManagerImpl tcm = ToolchainManagerImpl.getImpl();
152.17 ToolchainDescriptor td = tcm.getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS); // NOI18N
152.18 if (td != null) {
152.19 String cygwinBin = tcm.getBaseFolder(td, PlatformTypes.PLATFORM_WINDOWS);
152.20 @@ -103,7 +102,7 @@
152.21 if (res != null) {
152.22 return res;
152.23 }
152.24 - ToolchainManagerImpl tcm = ToolchainManager.getImpl();
152.25 + ToolchainManagerImpl tcm = ToolchainManagerImpl.getImpl();
152.26 for(ToolchainDescriptor td : tcm.getToolchains(PlatformTypes.PLATFORM_WINDOWS)){
152.27 if (td != null) {
152.28 res = getCommandDir(td);
152.29 @@ -125,7 +124,7 @@
152.30 if (td != null) {
152.31 String dir = commandsFolders.get(td);
152.32 if (dir == null) {
152.33 - ToolchainManagerImpl tcm = ToolchainManager.getImpl();
152.34 + ToolchainManagerImpl tcm = ToolchainManagerImpl.getImpl();
152.35 String msysBin = tcm.getCommandFolder(td, PlatformTypes.PLATFORM_WINDOWS);
152.36 if (msysBin != null) {
152.37 dir = msysBin.replace("\\", "/"); // NOI18N
152.38 @@ -141,126 +140,4 @@
152.39 return null;
152.40 }
152.41
152.42 - static String getPlatformName(int platform) {
152.43 - switch (platform) {
152.44 - case PlatformTypes.PLATFORM_LINUX:
152.45 - return "linux"; // NOI18N
152.46 - case PlatformTypes.PLATFORM_SOLARIS_SPARC:
152.47 - return "sun_sparc"; // NOI18N
152.48 - case PlatformTypes.PLATFORM_SOLARIS_INTEL:
152.49 - return "sun_intel"; // NOI18N
152.50 - case PlatformTypes.PLATFORM_WINDOWS:
152.51 - return "windows"; // NOI18N
152.52 - case PlatformTypes.PLATFORM_MACOSX:
152.53 - return "mac"; // NOI18N
152.54 - default:
152.55 - return "none"; // NOI18N
152.56 - }
152.57 - }
152.58 -
152.59 - public static int computeLocalPlatform() {
152.60 - String os = System.getProperty("os.name"); // NOI18N
152.61 -
152.62 - if (os.equals("SunOS")) { // NOI18N
152.63 - return System.getProperty("os.arch").equals("x86") ? PlatformTypes.PLATFORM_SOLARIS_INTEL : PlatformTypes.PLATFORM_SOLARIS_SPARC; // NOI18N
152.64 - } else if (os.startsWith("Windows ")) { // NOI18N
152.65 - return PlatformTypes.PLATFORM_WINDOWS;
152.66 - } else if (os.toLowerCase().contains("linux")) { // NOI18N
152.67 - return PlatformTypes.PLATFORM_LINUX;
152.68 - } else if (os.toLowerCase().contains("mac") || os.startsWith("Darwin")) { // NOI18N
152.69 - return PlatformTypes.PLATFORM_MACOSX;
152.70 - } else {
152.71 - return PlatformTypes.PLATFORM_GENERIC;
152.72 - }
152.73 - }
152.74 -
152.75 - static String findCommand(String name) {
152.76 - String path = Path.findCommand(name);
152.77 - if (path == null) {
152.78 - String dir = CompilerSetUtils.getCommandFolder(null);
152.79 - if (dir != null) {
152.80 - path = findCommand(name, dir); // NOI18N
152.81 - }
152.82 - }
152.83 - return path;
152.84 - }
152.85 -
152.86 - static String findCommand(String cmd, String dir) {
152.87 - File file;
152.88 - String cmd2 = null;
152.89 - if (cmd.length() > 0) {
152.90 - if (Utilities.isWindows() && !cmd.endsWith(".exe")) { // NOI18N
152.91 - cmd2 = cmd + ".exe"; // NOI18N
152.92 - }
152.93 -
152.94 - file = new File(dir, cmd);
152.95 - if (file.exists()) {
152.96 - return file.getAbsolutePath();
152.97 - } else {
152.98 - if (Utilities.isWindows() && cmd.endsWith(".exe")){// NOI18N
152.99 - File file2 = new File(dir, cmd+".lnk");// NOI18N
152.100 - if (file2.exists()) {
152.101 - return file.getAbsolutePath();
152.102 - }
152.103 - }
152.104 - }
152.105 - if (cmd2 != null) {
152.106 - file = new File(dir, cmd2);
152.107 - if (file.exists()) {
152.108 - return file.getAbsolutePath();
152.109 - }
152.110 - File file2 = new File(dir, cmd2+".lnk");// NOI18N
152.111 - if (file2.exists()) {
152.112 - return file.getAbsolutePath();
152.113 - }
152.114 - }
152.115 - }
152.116 - return null;
152.117 - }
152.118 -
152.119 - /** Same as the C library basename function: given a path, return
152.120 - * its filename.
152.121 - */
152.122 - public static final String getBaseName(String path) {
152.123 - int sep = path.lastIndexOf('/');
152.124 - if (sep == -1) {
152.125 - sep = path.lastIndexOf('\\');
152.126 - }
152.127 - if (sep != -1) {
152.128 - return path.substring(sep + 1);
152.129 - }
152.130 - return path;
152.131 - }
152.132 -
152.133 - public static boolean isPathAbsolute(String path) {
152.134 - if (path == null || path.length() == 0) {
152.135 - return false;
152.136 - } else if (path.charAt(0) == '/') {
152.137 - return true;
152.138 - } else if (path.charAt(0) == '\\') {
152.139 - return true;
152.140 - } else if (path.indexOf(':') > 0) {
152.141 - return true;
152.142 - } else {
152.143 - return false;
152.144 - }
152.145 - }
152.146 -
152.147 - public static String replaceOddCharacters(String s, char replaceChar) {
152.148 - int n = s.length();
152.149 - StringBuilder ret = new StringBuilder(n);
152.150 - for (int i = 0; i < n; i++) {
152.151 - char c = s.charAt(i);
152.152 - if ((c == ' ') || (c == '\t') ||
152.153 - (c == ':') || (c == '\'') ||
152.154 - (c == '*') || (c == '\"') ||
152.155 - (c == '[') || (c == ']') ||
152.156 - (c == '(') || (c == ')')) {
152.157 - ret.append(replaceChar);
152.158 - } else {
152.159 - ret.append(c);
152.160 - }
152.161 - }
152.162 - return ret.toString();
152.163 - }
152.164 }
153.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/NoCompilersPanel.form Mon Feb 01 12:23:06 2010 +0100
153.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
153.3 @@ -1,53 +0,0 @@
153.4 -<?xml version="1.0" encoding="UTF-8" ?>
153.5 -
153.6 -<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
153.7 - <AuxValues>
153.8 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
153.9 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
153.10 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
153.11 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
153.12 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
153.13 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
153.14 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
153.15 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
153.16 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
153.17 - </AuxValues>
153.18 -
153.19 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
153.20 - <SubComponents>
153.21 - <Container class="javax.swing.JScrollPane" name="jScrollPane1">
153.22 - <Properties>
153.23 - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
153.24 - <Border info="null"/>
153.25 - </Property>
153.26 - </Properties>
153.27 - <AuxValues>
153.28 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
153.29 - </AuxValues>
153.30 - <Constraints>
153.31 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
153.32 - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="20" insetsLeft="20" insetsBottom="20" insetsRight="20" anchor="10" weightX="1.0" weightY="1.0"/>
153.33 - </Constraint>
153.34 - </Constraints>
153.35 -
153.36 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
153.37 - <SubComponents>
153.38 - <Component class="javax.swing.JTextArea" name="textArea">
153.39 - <Properties>
153.40 - <Property name="columns" type="int" value="20"/>
153.41 - <Property name="editable" type="boolean" value="false"/>
153.42 - <Property name="lineWrap" type="boolean" value="true"/>
153.43 - <Property name="rows" type="int" value="5"/>
153.44 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
153.45 - <ResourceString bundle="org/netbeans/modules/cnd/toolchain/api/Bundle.properties" key="NO_COMPILERS_FOUND_MSG" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
153.46 - </Property>
153.47 - <Property name="wrapStyleWord" type="boolean" value="true"/>
153.48 - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
153.49 - <Border info="null"/>
153.50 - </Property>
153.51 - </Properties>
153.52 - </Component>
153.53 - </SubComponents>
153.54 - </Container>
153.55 - </SubComponents>
153.56 -</Form>
154.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/NoCompilersPanel.java Mon Feb 01 12:23:06 2010 +0100
154.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
154.3 @@ -1,99 +0,0 @@
154.4 -/*
154.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
154.6 - *
154.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
154.8 - *
154.9 - * The contents of this file are subject to the terms of either the GNU
154.10 - * General Public License Version 2 only ("GPL") or the Common
154.11 - * Development and Distribution License("CDDL") (collectively, the
154.12 - * "License"). You may not use this file except in compliance with the
154.13 - * License. You can obtain a copy of the License at
154.14 - * http://www.netbeans.org/cddl-gplv2.html
154.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
154.16 - * specific language governing permissions and limitations under the
154.17 - * License. When distributing the software, include this License Header
154.18 - * Notice in each file and include the License file at
154.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
154.20 - * particular file as subject to the "Classpath" exception as provided
154.21 - * by Sun in the GPL Version 2 section of the License file that
154.22 - * accompanied this code. If applicable, add the following below the
154.23 - * License Header, with the fields enclosed by brackets [] replaced by
154.24 - * your own identifying information:
154.25 - * "Portions Copyrighted [year] [name of copyright owner]"
154.26 - *
154.27 - * Contributor(s):
154.28 - *
154.29 - * The Original Software is NetBeans. The Initial Developer of the Original
154.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
154.31 - * Microsystems, Inc. All Rights Reserved.
154.32 - *
154.33 - * If you wish your version of this file to be governed by only the CDDL
154.34 - * or only the GPL Version 2, indicate your decision by adding
154.35 - * "[Contributor] elects to include this software in this distribution
154.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
154.37 - * single choice of license, a recipient has the option to distribute
154.38 - * your version of this file under either the CDDL, the GPL Version 2 or
154.39 - * to extend the choice of license to its licensees as provided above.
154.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
154.41 - * Version 2 license, then the option applies only if the new code is
154.42 - * made subject to such option by the copyright holder.
154.43 - */
154.44 -
154.45 -package org.netbeans.modules.cnd.toolchain.api;
154.46 -
154.47 -import java.awt.Dimension;
154.48 -
154.49 -/**
154.50 - *
154.51 - * @author thp
154.52 - */
154.53 -public class NoCompilersPanel extends javax.swing.JPanel {
154.54 -
154.55 - /** Creates new form NoCompilersPanel */
154.56 - public NoCompilersPanel() {
154.57 - initComponents();
154.58 - textArea.setBackground(getBackground());
154.59 - setPreferredSize(new Dimension(700, 320));
154.60 - }
154.61 -
154.62 - /** This method is called from within the constructor to
154.63 - * initialize the form.
154.64 - * WARNING: Do NOT modify this code. The content of this method is
154.65 - * always regenerated by the Form Editor.
154.66 - */
154.67 - @SuppressWarnings("unchecked")
154.68 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
154.69 - private void initComponents() {
154.70 - java.awt.GridBagConstraints gridBagConstraints;
154.71 -
154.72 - jScrollPane1 = new javax.swing.JScrollPane();
154.73 - textArea = new javax.swing.JTextArea();
154.74 -
154.75 - setLayout(new java.awt.GridBagLayout());
154.76 -
154.77 - jScrollPane1.setBorder(null);
154.78 -
154.79 - textArea.setColumns(20);
154.80 - textArea.setEditable(false);
154.81 - textArea.setLineWrap(true);
154.82 - textArea.setRows(5);
154.83 - textArea.setText(org.openide.util.NbBundle.getMessage(NoCompilersPanel.class, "NO_COMPILERS_FOUND_MSG")); // NOI18N
154.84 - textArea.setWrapStyleWord(true);
154.85 - textArea.setBorder(null);
154.86 - jScrollPane1.setViewportView(textArea);
154.87 -
154.88 - gridBagConstraints = new java.awt.GridBagConstraints();
154.89 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
154.90 - gridBagConstraints.weightx = 1.0;
154.91 - gridBagConstraints.weighty = 1.0;
154.92 - gridBagConstraints.insets = new java.awt.Insets(20, 20, 20, 20);
154.93 - add(jScrollPane1, gridBagConstraints);
154.94 - }// </editor-fold>//GEN-END:initComponents
154.95 -
154.96 -
154.97 - // Variables declaration - do not modify//GEN-BEGIN:variables
154.98 - private javax.swing.JScrollPane jScrollPane1;
154.99 - private javax.swing.JTextArea textArea;
154.100 - // End of variables declaration//GEN-END:variables
154.101 -
154.102 -}
155.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/Tool.java Mon Feb 01 12:23:06 2010 +0100
155.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/Tool.java Mon Feb 01 12:24:26 2010 +0100
155.3 @@ -1,7 +1,7 @@
155.4 /*
155.5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
155.6 *
155.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
155.8 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
155.9 *
155.10 * The contents of this file are subject to the terms of either the GNU
155.11 * General Public License Version 2 only ("GPL") or the Common
155.12 @@ -21,12 +21,6 @@
155.13 * your own identifying information:
155.14 * "Portions Copyrighted [year] [name of copyright owner]"
155.15 *
155.16 - * Contributor(s):
155.17 - *
155.18 - * The Original Software is NetBeans. The Initial Developer of the Original
155.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
155.20 - * Microsystems, Inc. All Rights Reserved.
155.21 - *
155.22 * If you wish your version of this file to be governed by only the CDDL
155.23 * or only the GPL Version 2, indicate your decision by adding
155.24 * "[Contributor] elects to include this software in this distribution
155.25 @@ -37,56 +31,40 @@
155.26 * However, if you add GPL Version 2 code and therefore, elected the GPL
155.27 * Version 2 license, then the option applies only if the new code is
155.28 * made subject to such option by the copyright holder.
155.29 + *
155.30 + * Contributor(s):
155.31 + *
155.32 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
155.33 */
155.34 +
155.35 package org.netbeans.modules.cnd.toolchain.api;
155.36
155.37 -import java.util.ResourceBundle;
155.38 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
155.39 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolDescriptor;
155.40 +import org.netbeans.modules.cnd.toolchain.compilers.impl.APIAccessor;
155.41 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolUtils;
155.42 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
155.43 -import org.openide.util.NbBundle;
155.44 import org.openide.util.Utilities;
155.45
155.46 +/**
155.47 + *
155.48 + * @author Alexander Simon
155.49 + */
155.50 public class Tool {
155.51
155.52 - // Compiler types
155.53 - public static final int CCompiler = 0;
155.54 - public static final int CCCompiler = 1;
155.55 - public static final int FortranCompiler = 2;
155.56 - public static final int CustomTool = 3;
155.57 - public static final int Assembler = 4;
155.58 - public static final int MakeTool = 5;
155.59 - public static final int DebuggerTool = 6;
155.60 - public static final int QMakeTool = 7;
155.61 - public static final int CMakeTool = 8;
155.62 - private static final String[] TOOL_NAMES = {
155.63 - getString("CCompiler"), // NOI18N
155.64 - getString("CCCompiler"), // NOI18N
155.65 - getString("FortranCompiler"), // NOI18N
155.66 - getString("CustomBuildTool"), // NOI18N
155.67 - getString("Assembler"), // NOI18N
155.68 - getString("MakeTool"), // NOI18N
155.69 - getString("DebuggerTool"), // NOI18N
155.70 - getString("QMakeTool"), // NOI18N
155.71 - getString("CMakeTool"), // NOI18N
155.72 - };
155.73 - private static final String[] COMPILER_TOOL_NAMES = {
155.74 - getString("CCompiler"), // NOI18N
155.75 - getString("CCCompiler"), // NOI18N
155.76 - getString("FortranCompiler"), // NOI18N
155.77 - getString("Assembler"), // NOI18N // Noy yet
155.78 - getString("CustomBuildTool"), // NOI18N
155.79 - };
155.80 + static {
155.81 + APIAccessor.register(new APIAccessorImpl());
155.82 + }
155.83 +
155.84 private final ExecutionEnvironment executionEnvironment;
155.85 private CompilerFlavor flavor;
155.86 - private int kind;
155.87 + private ToolKindBase kind;
155.88 private String name;
155.89 private String displayName;
155.90 private String path;
155.91 private CompilerSet compilerSet = null;
155.92
155.93 /** Creates a new instance of GenericCompiler */
155.94 - protected Tool(ExecutionEnvironment executionEnvironment, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
155.95 + protected Tool(ExecutionEnvironment executionEnvironment, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
155.96 this.executionEnvironment = executionEnvironment;
155.97 this.flavor = flavor;
155.98 this.kind = kind;
155.99 @@ -106,18 +84,10 @@
155.100 return copy;
155.101 }
155.102
155.103 - public static Tool createTool(ExecutionEnvironment executionEnvironment, CompilerFlavor flavor, int kind, String name, String displayName, String path) {
155.104 + static Tool createTool(ExecutionEnvironment executionEnvironment, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
155.105 return new Tool(executionEnvironment, flavor, kind, name, displayName, path);
155.106 }
155.107
155.108 -// public String getHostKey() {
155.109 -// if (executionEnvironment.isLocal()) {
155.110 -// return CompilerSetManager.LOCALHOST; // executionEnvironment.getHost();
155.111 -// } else {
155.112 -// return executionEnvironment.getUser() + '@' + executionEnvironment.getHost();
155.113 -// }
155.114 -// }
155.115 -
155.116 public ExecutionEnvironment getExecutionEnvironment() {
155.117 return executionEnvironment;
155.118 }
155.119 @@ -152,7 +122,7 @@
155.120 public void waitReady(boolean reset) {
155.121 }
155.122
155.123 - public int getKind() {
155.124 + public ToolKindBase getKind() {
155.125 return kind;
155.126 }
155.127
155.128 @@ -172,28 +142,7 @@
155.129 if (p == null) {
155.130 } else {
155.131 path = p;
155.132 - name = CompilerSetUtils.getBaseName(path);
155.133 - }
155.134 - }
155.135 -
155.136 - public static String[] getCompilerToolNames() {
155.137 - return COMPILER_TOOL_NAMES;
155.138 - }
155.139 -
155.140 - public static int getTool(String name) {
155.141 - for (int i = 0; i < TOOL_NAMES.length; i++) {
155.142 - if (TOOL_NAMES[i].equals(name)) {
155.143 - return i;
155.144 - }
155.145 - }
155.146 - return 0; // ????
155.147 - }
155.148 -
155.149 - public static String getName(int kind) {
155.150 - if (kind >= 0 && kind <= TOOL_NAMES.length) {
155.151 - return TOOL_NAMES[kind];
155.152 - } else {
155.153 - return null;
155.154 + name = ToolUtils.getBaseName(path);
155.155 }
155.156 }
155.157
155.158 @@ -201,10 +150,6 @@
155.159 return displayName;
155.160 }
155.161
155.162 - public static String getToolDisplayName(int kind) {
155.163 - return TOOL_NAMES[kind];
155.164 - }
155.165 -
155.166 @Override
155.167 public String toString() {
155.168 String n = getName();
155.169 @@ -222,15 +167,6 @@
155.170 throw new UnsupportedOperationException();
155.171 }
155.172
155.173 - private static ResourceBundle bundle = null;
155.174 -
155.175 - protected static String getString(String s) {
155.176 - if (bundle == null) {
155.177 - bundle = NbBundle.getBundle(Tool.class);
155.178 - }
155.179 - return bundle.getString(s);
155.180 - }
155.181 -
155.182 public CompilerSet getCompilerSet() {
155.183 return compilerSet;
155.184 }
155.185 @@ -238,4 +174,13 @@
155.186 public void setCompilerSet(CompilerSet compilerSet) {
155.187 this.compilerSet = compilerSet;
155.188 }
155.189 +
155.190 + private static final class APIAccessorImpl extends APIAccessor {
155.191 +
155.192 + @Override
155.193 + public Tool createTool(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
155.194 + return Tool.createTool(env, flavor, kind, name, displayName, path);
155.195 + }
155.196 +
155.197 + }
155.198 }
156.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/ToolChainPathProvider.java Mon Feb 01 12:23:06 2010 +0100
156.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
156.3 @@ -1,75 +0,0 @@
156.4 -/*
156.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
156.6 - *
156.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
156.8 - *
156.9 - * The contents of this file are subject to the terms of either the GNU
156.10 - * General Public License Version 2 only ("GPL") or the Common
156.11 - * Development and Distribution License("CDDL") (collectively, the
156.12 - * "License"). You may not use this file except in compliance with the
156.13 - * License. You can obtain a copy of the License at
156.14 - * http://www.netbeans.org/cddl-gplv2.html
156.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
156.16 - * specific language governing permissions and limitations under the
156.17 - * License. When distributing the software, include this License Header
156.18 - * Notice in each file and include the License file at
156.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
156.20 - * particular file as subject to the "Classpath" exception as provided
156.21 - * by Sun in the GPL Version 2 section of the License file that
156.22 - * accompanied this code. If applicable, add the following below the
156.23 - * License Header, with the fields enclosed by brackets [] replaced by
156.24 - * your own identifying information:
156.25 - * "Portions Copyrighted [year] [name of copyright owner]"
156.26 - *
156.27 - * If you wish your version of this file to be governed by only the CDDL
156.28 - * or only the GPL Version 2, indicate your decision by adding
156.29 - * "[Contributor] elects to include this software in this distribution
156.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
156.31 - * single choice of license, a recipient has the option to distribute
156.32 - * your version of this file under either the CDDL, the GPL Version 2 or
156.33 - * to extend the choice of license to its licensees as provided above.
156.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
156.35 - * Version 2 license, then the option applies only if the new code is
156.36 - * made subject to such option by the copyright holder.
156.37 - *
156.38 - * Contributor(s):
156.39 - *
156.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
156.41 - */
156.42 -
156.43 -package org.netbeans.modules.cnd.toolchain.api;
156.44 -
156.45 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
156.46 -import org.openide.util.Lookup;
156.47 -
156.48 -/**
156.49 - *
156.50 - * @author Alexander Simon
156.51 - */
156.52 -public abstract class ToolChainPathProvider {
156.53 - private static final ToolChainPathProvider DEFAULT = new DefaultToolChainPathProvider();
156.54 -
156.55 - public static ToolChainPathProvider getDefault() {
156.56 - return DEFAULT;
156.57 - }
156.58 -
156.59 - public abstract String getPath(CompilerFlavor flavor);
156.60 -
156.61 - private static final class DefaultToolChainPathProvider extends ToolChainPathProvider {
156.62 - private final Lookup.Result<ToolChainPathProvider> res;
156.63 - DefaultToolChainPathProvider() {
156.64 - res = Lookup.getDefault().lookupResult(ToolChainPathProvider.class);
156.65 - }
156.66 -
156.67 - @Override
156.68 - public String getPath(CompilerFlavor flavor) {
156.69 - for (ToolChainPathProvider service : res.allInstances()) {
156.70 - String path = service.getPath(flavor);
156.71 - if (path != null) {
156.72 - return path;
156.73 - }
156.74 - }
156.75 - return null;
156.76 - }
156.77 - }
156.78 -}
157.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
157.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/ToolKind.java Mon Feb 01 12:24:26 2010 +0100
157.3 @@ -0,0 +1,80 @@
157.4 +/*
157.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
157.6 + *
157.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
157.8 + *
157.9 + * The contents of this file are subject to the terms of either the GNU
157.10 + * General Public License Version 2 only ("GPL") or the Common
157.11 + * Development and Distribution License("CDDL") (collectively, the
157.12 + * "License"). You may not use this file except in compliance with the
157.13 + * License. You can obtain a copy of the License at
157.14 + * http://www.netbeans.org/cddl-gplv2.html
157.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
157.16 + * specific language governing permissions and limitations under the
157.17 + * License. When distributing the software, include this License Header
157.18 + * Notice in each file and include the License file at
157.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
157.20 + * particular file as subject to the "Classpath" exception as provided
157.21 + * by Sun in the GPL Version 2 section of the License file that
157.22 + * accompanied this code. If applicable, add the following below the
157.23 + * License Header, with the fields enclosed by brackets [] replaced by
157.24 + * your own identifying information:
157.25 + * "Portions Copyrighted [year] [name of copyright owner]"
157.26 + *
157.27 + * Contributor(s):
157.28 + *
157.29 + * The Original Software is NetBeans. The Initial Developer of the Original
157.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
157.31 + * Microsystems, Inc. All Rights Reserved.
157.32 + *
157.33 + * If you wish your version of this file to be governed by only the CDDL
157.34 + * or only the GPL Version 2, indicate your decision by adding
157.35 + * "[Contributor] elects to include this software in this distribution
157.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
157.37 + * single choice of license, a recipient has the option to distribute
157.38 + * your version of this file under either the CDDL, the GPL Version 2 or
157.39 + * to extend the choice of license to its licensees as provided above.
157.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
157.41 + * Version 2 license, then the option applies only if the new code is
157.42 + * made subject to such option by the copyright holder.
157.43 + */
157.44 +package org.netbeans.modules.cnd.toolchain.api;
157.45 +
157.46 +import org.openide.util.NbBundle;
157.47 +
157.48 +public enum ToolKind implements ToolKindBase {
157.49 + CCompiler, //0
157.50 + CCCompiler, //1
157.51 + FortranCompiler, //2
157.52 + CustomTool, //3
157.53 + Assembler, //4
157.54 + MakeTool, //5
157.55 + DebuggerTool, //6
157.56 + QMakeTool, //7
157.57 + CMakeTool, //8
157.58 + UnknownTool; //9
157.59 +
157.60 + @Override
157.61 + public String getDisplayName(){
157.62 + return NbBundle.getBundle(ToolKind.class).getString(name());
157.63 + }
157.64 +
157.65 + public static ToolKind getTool(int ordinal){
157.66 + for (ToolKind tool : ToolKind.values()){
157.67 + if (tool.ordinal() == ordinal) {
157.68 + return tool;
157.69 + }
157.70 + }
157.71 + return UnknownTool;
157.72 + }
157.73 +
157.74 + public static ToolKind getTool(String name){
157.75 + for (ToolKind tool : ToolKind.values()){
157.76 + if (tool.getDisplayName().equals(name)) {
157.77 + return tool;
157.78 + }
157.79 + }
157.80 + return UnknownTool;
157.81 + }
157.82 +
157.83 +}
158.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
158.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/ToolKindBase.java Mon Feb 01 12:24:26 2010 +0100
158.3 @@ -0,0 +1,52 @@
158.4 +/*
158.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
158.6 + *
158.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
158.8 + *
158.9 + * The contents of this file are subject to the terms of either the GNU
158.10 + * General Public License Version 2 only ("GPL") or the Common
158.11 + * Development and Distribution License("CDDL") (collectively, the
158.12 + * "License"). You may not use this file except in compliance with the
158.13 + * License. You can obtain a copy of the License at
158.14 + * http://www.netbeans.org/cddl-gplv2.html
158.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
158.16 + * specific language governing permissions and limitations under the
158.17 + * License. When distributing the software, include this License Header
158.18 + * Notice in each file and include the License file at
158.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
158.20 + * particular file as subject to the "Classpath" exception as provided
158.21 + * by Sun in the GPL Version 2 section of the License file that
158.22 + * accompanied this code. If applicable, add the following below the
158.23 + * License Header, with the fields enclosed by brackets [] replaced by
158.24 + * your own identifying information:
158.25 + * "Portions Copyrighted [year] [name of copyright owner]"
158.26 + *
158.27 + * If you wish your version of this file to be governed by only the CDDL
158.28 + * or only the GPL Version 2, indicate your decision by adding
158.29 + * "[Contributor] elects to include this software in this distribution
158.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
158.31 + * single choice of license, a recipient has the option to distribute
158.32 + * your version of this file under either the CDDL, the GPL Version 2 or
158.33 + * to extend the choice of license to its licensees as provided above.
158.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
158.35 + * Version 2 license, then the option applies only if the new code is
158.36 + * made subject to such option by the copyright holder.
158.37 + *
158.38 + * Contributor(s):
158.39 + *
158.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
158.41 + */
158.42 +
158.43 +package org.netbeans.modules.cnd.toolchain.api;
158.44 +
158.45 +/**
158.46 + *
158.47 + * @author Alexander Simon
158.48 + */
158.49 +public interface ToolKindBase {
158.50 + int ordinal();
158.51 +
158.52 + String name();
158.53 +
158.54 + String getDisplayName();
158.55 +}
159.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/ToolchainManager.java Mon Feb 01 12:23:06 2010 +0100
159.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/ToolchainManager.java Mon Feb 01 12:24:26 2010 +0100
159.3 @@ -40,22 +40,12 @@
159.4
159.5 import java.util.List;
159.6 import java.util.Map;
159.7 -import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolchainManagerImpl;
159.8
159.9 /**
159.10 *
159.11 * @author Alexander Simon
159.12 */
159.13 public final class ToolchainManager {
159.14 - private static final ToolchainManagerImpl manager = new ToolchainManagerImpl();
159.15 -
159.16 - /*package-local*/ static final ToolchainManagerImpl getImpl() {
159.17 - return manager;
159.18 - }
159.19 -
159.20 - private ToolchainManager() {
159.21 - }
159.22 -
159.23 public interface ToolchainDescriptor {
159.24
159.25 String getFileName();
160.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/ToolchainProject.java Mon Feb 01 12:23:06 2010 +0100
160.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
160.3 @@ -1,54 +0,0 @@
160.4 -/*
160.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
160.6 - *
160.7 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
160.8 - *
160.9 - * The contents of this file are subject to the terms of either the GNU
160.10 - * General Public License Version 2 only ("GPL") or the Common
160.11 - * Development and Distribution License("CDDL") (collectively, the
160.12 - * "License"). You may not use this file except in compliance with the
160.13 - * License. You can obtain a copy of the License at
160.14 - * http://www.netbeans.org/cddl-gplv2.html
160.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
160.16 - * specific language governing permissions and limitations under the
160.17 - * License. When distributing the software, include this License Header
160.18 - * Notice in each file and include the License file at
160.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
160.20 - * particular file as subject to the "Classpath" exception as provided
160.21 - * by Sun in the GPL Version 2 section of the License file that
160.22 - * accompanied this code. If applicable, add the following below the
160.23 - * License Header, with the fields enclosed by brackets [] replaced by
160.24 - * your own identifying information:
160.25 - * "Portions Copyrighted [year] [name of copyright owner]"
160.26 - *
160.27 - * If you wish your version of this file to be governed by only the CDDL
160.28 - * or only the GPL Version 2, indicate your decision by adding
160.29 - * "[Contributor] elects to include this software in this distribution
160.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
160.31 - * single choice of license, a recipient has the option to distribute
160.32 - * your version of this file under either the CDDL, the GPL Version 2 or
160.33 - * to extend the choice of license to its licensees as provided above.
160.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
160.35 - * Version 2 license, then the option applies only if the new code is
160.36 - * made subject to such option by the copyright holder.
160.37 - *
160.38 - * Contributor(s):
160.39 - *
160.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
160.41 - */
160.42 -
160.43 -package org.netbeans.modules.cnd.toolchain.api;
160.44 -
160.45 -/**
160.46 - * Interface is returned by project lookup.
160.47 - *
160.48 - * @author Alexander Simon
160.49 - */
160.50 -public interface ToolchainProject {
160.51 -
160.52 - /**
160.53 - *
160.54 - * @return toolchain for active project configuration
160.55 - */
160.56 - CompilerSet getCompilerSet();
160.57 -}
161.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/api/ToolchainScriptGenerator.java Mon Feb 01 12:23:06 2010 +0100
161.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
161.3 @@ -1,258 +0,0 @@
161.4 -/*
161.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
161.6 - *
161.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
161.8 - *
161.9 - * The contents of this file are subject to the terms of either the GNU
161.10 - * General Public License Version 2 only ("GPL") or the Common
161.11 - * Development and Distribution License("CDDL") (collectively, the
161.12 - * "License"). You may not use this file except in compliance with the
161.13 - * License. You can obtain a copy of the License at
161.14 - * http://www.netbeans.org/cddl-gplv2.html
161.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
161.16 - * specific language governing permissions and limitations under the
161.17 - * License. When distributing the software, include this License Header
161.18 - * Notice in each file and include the License file at
161.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
161.20 - * particular file as subject to the "Classpath" exception as provided
161.21 - * by Sun in the GPL Version 2 section of the License file that
161.22 - * accompanied this code. If applicable, add the following below the
161.23 - * License Header, with the fields enclosed by brackets [] replaced by
161.24 - * your own identifying information:
161.25 - * "Portions Copyrighted [year] [name of copyright owner]"
161.26 - *
161.27 - * If you wish your version of this file to be governed by only the CDDL
161.28 - * or only the GPL Version 2, indicate your decision by adding
161.29 - * "[Contributor] elects to include this software in this distribution
161.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
161.31 - * single choice of license, a recipient has the option to distribute
161.32 - * your version of this file under either the CDDL, the GPL Version 2 or
161.33 - * to extend the choice of license to its licensees as provided above.
161.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
161.35 - * Version 2 license, then the option applies only if the new code is
161.36 - * made subject to such option by the copyright holder.
161.37 - *
161.38 - * Contributor(s):
161.39 - *
161.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
161.41 - */
161.42 -
161.43 -package org.netbeans.modules.cnd.toolchain.api;
161.44 -
161.45 -
161.46 -import java.util.ArrayList;
161.47 -import java.util.StringTokenizer;
161.48 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
161.49 -import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
161.50 -import org.openide.util.NbBundle;
161.51 -
161.52 -/**
161.53 - *
161.54 - * @author Alexander Simon
161.55 - */
161.56 -final class ToolchainScriptGenerator {
161.57 - private static final boolean TRACE = true;
161.58 - private static final String[] platforms = new String[]{
161.59 - "PLATFORM_SOLARIS_SPARC", // NOI18N
161.60 - "PLATFORM_SOLARIS_INTEL", // NOI18N
161.61 - "PLATFORM_LINUX", // NOI18N
161.62 - //"PLATFORM_WINDOWS", // NOI18N // not supported yet
161.63 - "PLATFORM_MACOSX", // NOI18N
161.64 - "PLATFORM_NONE" // NOI18N
161.65 - };
161.66 - private static final int[] platformsID = new int[]{
161.67 - PlatformTypes.PLATFORM_SOLARIS_SPARC,
161.68 - PlatformTypes.PLATFORM_SOLARIS_INTEL,
161.69 - PlatformTypes.PLATFORM_LINUX,
161.70 - //PlatformTypes.PLATFORM_WINDOWS, // not supported yet
161.71 - PlatformTypes.PLATFORM_MACOSX,
161.72 - PlatformTypes.PLATFORM_NONE
161.73 - };
161.74 - private final StringBuilder buf = new StringBuilder();
161.75 -
161.76 - private ToolchainScriptGenerator(){
161.77 - }
161.78 -
161.79 - static final String generateScript(String path){
161.80 - ToolchainScriptGenerator generator = new ToolchainScriptGenerator();
161.81 - generator.prefix(path);
161.82 - generator.scanPaths();
161.83 - return generator.buf.toString();
161.84 - }
161.85 -
161.86 - private void prefix(String path){
161.87 - line("#!/bin/sh"); // NOI18N
161.88 - lines(NbBundle.getMessage(ToolchainScriptGenerator.class, "DetectHostInfo")); // NOI18N
161.89 - if (path != null) {
161.90 - line("PATHSLIST=\""+path+"\""); // NOI18N
161.91 - } else {
161.92 - line("echo $PLATFORM_NAME"); // NOI18N
161.93 - for(int i = 0; i < platforms.length; i++) {
161.94 - line("if [ \"$PLATFORM\" = \"$"+platforms[i]+"\" ]; then"); // NOI18N
161.95 - if (platformsID[i] == PlatformTypes.PLATFORM_WINDOWS) {
161.96 - line("PATH=$PATH;C:/WINDOWS/System32;C:/WINDOWS;C:/WINDOWS/System32/WBem"); // NOI18N
161.97 - } else if (platformsID[i] != PlatformTypes.PLATFORM_NONE) {
161.98 - line("PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin"); // NOI18N
161.99 - } else {
161.100 - line("PATH=$PATH"); // NOI18N
161.101 - }
161.102 - ArrayList<String> dirlist = new ArrayList<String>();
161.103 - CompilerSetManager.appendDefaultLocations(platformsID[i], dirlist);
161.104 - for(String s : dirlist) {
161.105 - line("PATH=$PATH:"+s); // NOI18N
161.106 - }
161.107 - line("fi"); // NOI18N
161.108 - }
161.109 - line("PATHSLIST=$PATH"); // NOI18N
161.110 - }
161.111 - line("if [ \"$PLATFORM\" = \"$PLATFORM_WINDOWS\" ]; then"); // NOI18N
161.112 - line(" IFS=;"); // NOI18N
161.113 - line("else"); // NOI18N
161.114 - line(" IFS=:"); // NOI18N
161.115 - line("fi"); // NOI18N
161.116 - line("foundFlavors=\";\""); // NOI18N
161.117 - }
161.118 -
161.119 - private void scanPaths(){
161.120 - line("for f in $PATHSLIST; do"); // NOI18N
161.121 - line(" line="); // NOI18N
161.122 - line(" flavor="); // NOI18N
161.123 - line(" echo $f | egrep -e \"^/\" >/dev/null"); // NOI18N
161.124 - line(" if [ \"$?\" != \"0\" ]; then"); // NOI18N
161.125 - line(" continue # skip relative directories"); // NOI18N
161.126 - line(" fi"); // NOI18N
161.127 - line(" echo $f | egrep -e \"^/usr/ucb\" >/dev/null"); // NOI18N
161.128 - line(" if [ \"$?\" = \"0\" ]; then"); // NOI18N
161.129 - line(" continue # skip /usr/ucb (IZ #142780)"); // NOI18N
161.130 - line(" fi"); // NOI18N
161.131 - scanPath();
161.132 - line("done"); // NOI18N
161.133 - }
161.134 - private void scanPath(){
161.135 - for(int i = 0; i < platforms.length; i++) {
161.136 - line("if [ \"$PLATFORM\" = \"$"+platforms[i]+"\" ]; then"); // NOI18N
161.137 - platformPath(platformsID[i]);
161.138 - line("fi"); // NOI18N
161.139 - }
161.140 - }
161.141 - private void platformPath(int platform){
161.142 - for (ToolchainDescriptor d : ToolchainManager.getImpl().getToolchains(platform)) {
161.143 - if (d.isAbstract()) {
161.144 - continue;
161.145 - }
161.146 - if (d.getModuleID() != null) {
161.147 - continue;
161.148 - }
161.149 - CompilerDescriptor c = d.getC();
161.150 - if (c == null || c.getNames().length == 0) {
161.151 - continue;
161.152 - }
161.153 - line("status="); // NOI18N
161.154 - line("while [ ! -n \"$status\" ]; do"); // NOI18N
161.155 - if (c.getPathPattern() != null) {
161.156 - // todo windows use case insensitive regexp
161.157 - line(" echo $f | egrep -e \""+c.getPathPattern()+"\" >/dev/null"); // NOI18N
161.158 - line(" status=$?"); // NOI18N
161.159 - line(" if [ ! \"$status\" = \"0\" ]; then"); // NOI18N
161.160 - if (c.getExistFolder() == null) {
161.161 - line(" break"); // NOI18N
161.162 - } else {
161.163 - line(" if [ ! -d \"$f/"+c.getExistFolder()+"\" ]; then"); // NOI18N
161.164 - line(" break"); // NOI18N
161.165 - line(" fi"); // NOI18N
161.166 - }
161.167 - line(" fi"); // NOI18N
161.168 - }
161.169 - line(" file=\"$f/"+c.getNames()[0]+"\""); // NOI18N
161.170 - line(" if [ ! -x \"$file\" ]; then"); // NOI18N
161.171 - if (platform == PlatformTypes.PLATFORM_WINDOWS) {
161.172 - line(" file=\"$f/"+c.getNames()[0]+".exe\""); // NOI18N
161.173 - line(" if [ ! -x \"$f/"+c.getNames()[0]+".exe\" ]; then"); // NOI18N
161.174 - line(" break"); // NOI18N
161.175 - line(" fi"); // NOI18N
161.176 - } else {
161.177 - line(" break"); // NOI18N
161.178 - }
161.179 - line(" fi"); // NOI18N
161.180 - if (c.getVersionFlags() != null && c.getVersionPattern() != null){
161.181 - line(" $file "+c.getVersionFlags()+" 2>&1 | egrep -e \""+c.getVersionPattern()+"\" >/dev/null"); // NOI18N
161.182 - line(" status=$?"); // NOI18N
161.183 - line(" if [ ! \"$status\" = \"0\" ]; then"); // NOI18N
161.184 - line(" break"); // NOI18N
161.185 - line(" fi"); // NOI18N
161.186 - }
161.187 - //Found compiler set
161.188 - line(" line=\""+d.getName()+";$f\""); // NOI18N
161.189 - line(" flavor=\""+d.getName()+";\""); // NOI18N
161.190 - addTool("c", d.getC().getNames(), platform); // NOI18N
161.191 - if (d.getCpp() != null) {
161.192 - addTool("cpp", d.getCpp().getNames(), platform); // NOI18N
161.193 - }
161.194 - if (d.getFortran() != null) {
161.195 - addTool("fortran", d.getFortran().getNames(), platform); // NOI18N
161.196 - }
161.197 - if (d.getAssembler() != null) {
161.198 - addTool("assembler", d.getAssembler().getNames(), platform); // NOI18N
161.199 - }
161.200 - if (d.getMake() != null) {
161.201 - addTool("make", d.getMake().getNames(), platform); // NOI18N
161.202 - }
161.203 - if (d.getDebugger() != null) {
161.204 - addTool("debugger", d.getDebugger().getNames(), platform); // NOI18N
161.205 - }
161.206 - if (d.getCMake() != null) {
161.207 - addTool("cmake", d.getCMake().getNames(), platform); // NOI18N
161.208 - }
161.209 - if (d.getQMake() != null) {
161.210 - addTool("qmake", d.getQMake().getNames(), platform); // NOI18N
161.211 - }
161.212 - line(" addNewToolChain"); // NOI18N
161.213 - line(" break"); // NOI18N
161.214 - line("done"); // NOI18N
161.215 - }
161.216 - }
161.217 -
161.218 - private void addTool(String kind, String[] names, int platform){
161.219 - if (names != null) {
161.220 - StringBuilder list = new StringBuilder();
161.221 - for(String name : names) {
161.222 - if (list.length()>0) {
161.223 - if (platform == PlatformTypes.PLATFORM_WINDOWS) {
161.224 - list.append(';'); // NOI18N
161.225 - } else {
161.226 - list.append(':'); // NOI18N
161.227 - }
161.228 - }
161.229 - list.append(name);
161.230 - }
161.231 - line("findCompiler \""+list.toString()+"\" \""+kind+"\""); // NOI18N
161.232 - }
161.233 - }
161.234 -
161.235 - private void lines(String lines){
161.236 - StringTokenizer st = new StringTokenizer(lines,"\n"); // NOI18N
161.237 - while(st.hasMoreTokens()) {
161.238 - line(st.nextToken());
161.239 - }
161.240 - }
161.241 -
161.242 - int level = 0;
161.243 - private void line(String line){
161.244 - String l = line.trim();
161.245 - if (TRACE) {
161.246 - if (l.equals("fi") || l.equals("done") || l.equals("else") || l.equals("}")){ // NOI18N
161.247 - level--;
161.248 - }
161.249 - if (level >= 0) {
161.250 - for(int i = 0; i < level; i++){
161.251 - buf.append(' ');
161.252 - buf.append(' ');
161.253 - }
161.254 - }
161.255 - if (l.startsWith("while ") || l.startsWith("if ") || l.startsWith("for ") || l.equals("else") || l.endsWith("{")){ // NOI18N
161.256 - level++;
161.257 - }
161.258 - }
161.259 - buf.append(l).append('\n'); // NOI18N
161.260 - }
161.261 -}
162.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
162.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/APIAccessor.java Mon Feb 01 12:24:26 2010 +0100
162.3 @@ -0,0 +1,82 @@
162.4 +/*
162.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
162.6 + *
162.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
162.8 + *
162.9 + * The contents of this file are subject to the terms of either the GNU
162.10 + * General Public License Version 2 only ("GPL") or the Common
162.11 + * Development and Distribution License("CDDL") (collectively, the
162.12 + * "License"). You may not use this file except in compliance with the
162.13 + * License. You can obtain a copy of the License at
162.14 + * http://www.netbeans.org/cddl-gplv2.html
162.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
162.16 + * specific language governing permissions and limitations under the
162.17 + * License. When distributing the software, include this License Header
162.18 + * Notice in each file and include the License file at
162.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
162.20 + * particular file as subject to the "Classpath" exception as provided
162.21 + * by Sun in the GPL Version 2 section of the License file that
162.22 + * accompanied this code. If applicable, add the following below the
162.23 + * License Header, with the fields enclosed by brackets [] replaced by
162.24 + * your own identifying information:
162.25 + * "Portions Copyrighted [year] [name of copyright owner]"
162.26 + *
162.27 + * If you wish your version of this file to be governed by only the CDDL
162.28 + * or only the GPL Version 2, indicate your decision by adding
162.29 + * "[Contributor] elects to include this software in this distribution
162.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
162.31 + * single choice of license, a recipient has the option to distribute
162.32 + * your version of this file under either the CDDL, the GPL Version 2 or
162.33 + * to extend the choice of license to its licensees as provided above.
162.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
162.35 + * Version 2 license, then the option applies only if the new code is
162.36 + * made subject to such option by the copyright holder.
162.37 + *
162.38 + * Contributor(s):
162.39 + *
162.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
162.41 + */
162.42 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
162.43 +
162.44 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
162.45 +import org.netbeans.modules.cnd.toolchain.api.Tool;
162.46 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
162.47 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
162.48 +
162.49 +/**
162.50 + *
162.51 + * @author as204739
162.52 + */
162.53 +public abstract class APIAccessor {
162.54 +
162.55 + private static APIAccessor INSTANCE;
162.56 +
162.57 + public static synchronized APIAccessor get() {
162.58 + if (INSTANCE == null) {
162.59 + Class<?> c = Tool.class;
162.60 + try {
162.61 + Class.forName(c.getName(), true, c.getClassLoader());
162.62 + } catch (ClassNotFoundException e) {
162.63 + // ignore
162.64 + }
162.65 + }
162.66 +
162.67 + assert INSTANCE != null : "There is no API package accessor available!"; //NOI18N
162.68 + return INSTANCE;
162.69 + }
162.70 +
162.71 + /**
162.72 + * Register the accessor. The method can only be called once
162.73 + * - othewise it throws IllegalStateException.
162.74 + *
162.75 + * @param accessor instance.
162.76 + */
162.77 + public static void register(APIAccessor accessor) {
162.78 + if (INSTANCE != null) {
162.79 + throw new IllegalStateException("Already registered"); // NOI18N
162.80 + }
162.81 + INSTANCE = accessor;
162.82 + }
162.83 +
162.84 + public abstract Tool createTool(ExecutionEnvironment executionEnvironment, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path);
162.85 +}
163.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
163.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
163.3 @@ -0,0 +1,88 @@
163.4 +# This module is part of NetBeans and is open-source.
163.5 +# You can see http://www.netbeans.org/about/legal/index.html for details.
163.6 +#
163.7 +# You may use the binary however you like. The source file license is:
163.8 +#
163.9 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
163.10 +#
163.11 +# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
163.12 +#
163.13 +# The contents of this file are subject to the terms of either the GNU
163.14 +# General Public License Version 2 only ("GPL") or the Common
163.15 +# Development and Distribution License("CDDL") (collectively, the
163.16 +# "License"). You may not use this file except in compliance with the
163.17 +# License. You can obtain a copy of the License at
163.18 +# http://www.netbeans.org/cddl-gplv2.html
163.19 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
163.20 +# specific language governing permissions and limitations under the
163.21 +# License. When distributing the software, include this License Header
163.22 +# Notice in each file and include the License file at
163.23 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
163.24 +# particular file as subject to the "Classpath" exception as provided
163.25 +# by Sun in the GPL Version 2 section of the License file that
163.26 +# accompanied this code. If applicable, add the following below the
163.27 +# License Header, with the fields enclosed by brackets [] replaced by
163.28 +# your own identifying information:
163.29 +# "Portions Copyrighted [year] [name of copyright owner]"
163.30 +#
163.31 +# Contributor(s):
163.32 +#
163.33 +# The Original Software is NetBeans. The Initial Developer of the Original
163.34 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
163.35 +# Microsystems, Inc. All Rights Reserved.
163.36 +
163.37 +# Compiler Collection names for the 1st of each flavor
163.38 +LBL_CygwinCompilerSet_0=GNU Compiler Collection from Cygwin
163.39 +LBL_MinGWCompilerSet_0=GNU Compiler Collection from MinGW
163.40 +LBL_InterixCompilerSet_0=GNU Compiler Collection from Interix/Microsoft
163.41 +LBL_DJGPPCompilerSet_0=GNU Compiler Collection from DJGPP
163.42 +LBL_SunStudio_13CompilerSet_0=Sun Studio 13 Compiler Collection
163.43 +LBL_SunStudio_12CompilerSet_0=Sun Studio 12 Compiler Collection
163.44 +LBL_SunStudio_11CompilerSet_0=Sun Studio 11 Compiler Collection
163.45 +LBL_SunStudio_10CompilerSet_0=Sun Studio 10 Compiler Collection
163.46 +LBL_SunStudio_9CompilerSet_0=Sun Studio 9 Compiler Collection
163.47 +LBL_SunStudio_8CompilerSet_0=Sun Studio 8 Compiler Collection
163.48 +LBL_SunStudioCompilerSet_0=Sun Studio Compiler Collection
163.49 +LBL_SunUCBCompilerSet_0=Sun UCB Compatible C Compiler
163.50 +LBL_GNUCompilerSet_0=GNU Compiler Collection
163.51 +LBL_UnknownCompilerSet_0=Generic Compiler Collection
163.52 +
163.53 +LBL_EmptyCompilerSetName=None
163.54 +LBL_EmptyCompilerSetDisplayName=No Compilers Found
163.55 +
163.56 +CCompiler=C Compiler
163.57 +CCCompiler=C++ Compiler
163.58 +FortranCompiler=Fortran Compiler
163.59 +CustomBuildTool=Custom Build Tool
163.60 +Assembler=Assembler
163.61 +MakeTool=Make Tool
163.62 +DebuggerTool=Debugger
163.63 +QMakeTool=QMake Tool
163.64 +CMakeTool=CMake Tool
163.65 +
163.66 +# CompilerSetManager
163.67 +NO_COMPILERS_FOUND_TITLE=No Compilers Found
163.68 +NO_COMPILERS_FOUND_MSG=\
163.69 +No suitable compilers were found on your system. The IDE needs a suitable set of compilers and other build tools in order to work correctly.\n\n\
163.70 +If you already have compilers on your system but they were not found, do one of the following:\n\n\
163.71 +1) Exit the IDE, add your compilers to your PATH environment variable, and restart the IDE.\n\n\
163.72 +2) Open the Build Tool dialog in Tools | Options | C/C++ | Build Tools and add your compiler(s) to the setup.\n\n\
163.73 +If you do not already have compilers on your system, do:\n\n\
163.74 +3) Download and install a suitable set of compilers and restart the IDE.\n\n\
163.75 +Visit http://www.netbeans.org/community/releases/65/cpp-setup-instructions.html for further assistance in installing and configuring a build environment.
163.76 +
163.77 +# CSM_ stands for CompilerSetManager
163.78 +CSM_Conn=Connecting to {0}...
163.79 +CSM_Done= done.
163.80 +CSM_ValPlatf=Validating platform... found {0}
163.81 +CSM_LFTC=Looking for tool collections:
163.82 +CSM_Found= Found {0} at {1}.
163.83 +CSM_Err= Error creating compiler set {0}
163.84 +CSM_Done_NF=Done. No tool collections were found in default locations.\nYou can configure them manually later using\n Tools > Options > C/C++ > Build Tools dialog.
163.85 +CSM_Done_OK=Done. Found {0} tool collection(s).
163.86 +CSM_Conigured=Your host was successfully configured.
163.87 +CSM_Fail=...failed. Hostname is wrong or host is offline.
163.88 +CSM_Initializing_Tool=Checking {0} ...
163.89 +
163.90 +PROGRESS_TEXT=Initializing compiler sets on {0}
163.91 +
164.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
164.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/CompilerFlavorImpl.java Mon Feb 01 12:24:26 2010 +0100
164.3 @@ -0,0 +1,210 @@
164.4 +/*
164.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
164.6 + *
164.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
164.8 + *
164.9 + * The contents of this file are subject to the terms of either the GNU
164.10 + * General Public License Version 2 only ("GPL") or the Common
164.11 + * Development and Distribution License("CDDL") (collectively, the
164.12 + * "License"). You may not use this file except in compliance with the
164.13 + * License. You can obtain a copy of the License at
164.14 + * http://www.netbeans.org/cddl-gplv2.html
164.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
164.16 + * specific language governing permissions and limitations under the
164.17 + * License. When distributing the software, include this License Header
164.18 + * Notice in each file and include the License file at
164.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
164.20 + * particular file as subject to the "Classpath" exception as provided
164.21 + * by Sun in the GPL Version 2 section of the License file that
164.22 + * accompanied this code. If applicable, add the following below the
164.23 + * License Header, with the fields enclosed by brackets [] replaced by
164.24 + * your own identifying information:
164.25 + * "Portions Copyrighted [year] [name of copyright owner]"
164.26 + *
164.27 + * If you wish your version of this file to be governed by only the CDDL
164.28 + * or only the GPL Version 2, indicate your decision by adding
164.29 + * "[Contributor] elects to include this software in this distribution
164.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
164.31 + * single choice of license, a recipient has the option to distribute
164.32 + * your version of this file under either the CDDL, the GPL Version 2 or
164.33 + * to extend the choice of license to its licensees as provided above.
164.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
164.35 + * Version 2 license, then the option applies only if the new code is
164.36 + * made subject to such option by the copyright holder.
164.37 + *
164.38 + * Contributor(s):
164.39 + *
164.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
164.41 + */
164.42 +
164.43 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
164.44 +
164.45 +import java.util.ArrayList;
164.46 +import java.util.HashMap;
164.47 +import java.util.List;
164.48 +import java.util.Map;
164.49 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
164.50 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
164.51 +
164.52 +/**
164.53 + * Recognized (and prioritized) types of compiler sets
164.54 + */
164.55 +public final class CompilerFlavorImpl implements CompilerFlavor {
164.56 +
164.57 + private static final List<CompilerFlavorImpl> flavors = new ArrayList<CompilerFlavorImpl>();
164.58 + private static final Map<Integer, CompilerFlavorImpl> unknown = new HashMap<Integer, CompilerFlavorImpl>();
164.59 + static {
164.60 + for (ToolchainDescriptor descriptor : ToolchainManagerImpl.getImpl().getAllToolchains()) {
164.61 + flavors.add(new CompilerFlavorImpl(descriptor.getName(), descriptor));
164.62 + }
164.63 + }
164.64 + private String sval;
164.65 + private ToolchainDescriptor descriptor;
164.66 +
164.67 + CompilerFlavorImpl(String sval, ToolchainDescriptor descriptor) {
164.68 + this.sval = sval;
164.69 + this.descriptor = descriptor;
164.70 + }
164.71 +
164.72 + @Override
164.73 + public ToolchainDescriptor getToolchainDescriptor() {
164.74 + return descriptor;
164.75 + }
164.76 +
164.77 + @Override
164.78 + public boolean isGnuCompiler() {
164.79 + ToolchainDescriptor d = getToolchainDescriptor();
164.80 + if (d != null) {
164.81 + for (String f : d.getFamily()) {
164.82 + if ("GNU".equals(f)) { // NOI18N
164.83 + return true;
164.84 + }
164.85 + }
164.86 + }
164.87 + return false;
164.88 + }
164.89 +
164.90 + @Override
164.91 + public boolean isSunStudioCompiler() {
164.92 + ToolchainDescriptor d = getToolchainDescriptor();
164.93 + if (d != null) {
164.94 + for (String f : d.getFamily()) {
164.95 + if ("SunStudio".equals(f)) { // NOI18N
164.96 + return true;
164.97 + }
164.98 + }
164.99 + }
164.100 + return false;
164.101 + }
164.102 +
164.103 + @Override
164.104 + public boolean isMinGWCompiler() {
164.105 + return "MinGW".equals(sval); // NOI18N
164.106 + }
164.107 +
164.108 + @Override
164.109 + public boolean isCygwinCompiler() {
164.110 + return "Cygwin".equals(sval); // NOI18N
164.111 + }
164.112 +
164.113 + @Override
164.114 + public String getCommandFolder(int platform) {
164.115 + ToolchainDescriptor d = getToolchainDescriptor();
164.116 + if (d != null) {
164.117 + return ToolchainManagerImpl.getImpl().getCommandFolder(d, platform);
164.118 + }
164.119 + return null;
164.120 + }
164.121 +
164.122 + public static CompilerFlavor getUnknown(int platform) {
164.123 + CompilerFlavor unknownFlavor = unknown.get(platform);
164.124 + if (unknownFlavor == null) {
164.125 + unknownFlavor = _getUnknown(platform);
164.126 + }
164.127 + return unknownFlavor;
164.128 + }
164.129 +
164.130 + private static CompilerFlavor _getUnknown(int platform) {
164.131 + CompilerFlavorImpl unknownFlavor = null;
164.132 + synchronized (unknown) {
164.133 + unknownFlavor = unknown.get(platform);
164.134 + if (unknownFlavor == null) {
164.135 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("GNU", platform); // NOI18N
164.136 + if (d == null) {
164.137 + List<ToolchainDescriptor> list = ToolchainManagerImpl.getImpl().getToolchains(platform);
164.138 + if (list.size() > 0) {
164.139 + d = list.get(0);
164.140 + }
164.141 + }
164.142 + if (d == null) {
164.143 + d = new CompilerSetImpl.UnknownToolchainDescriptor();
164.144 + }
164.145 + unknownFlavor = new CompilerFlavorImpl(CompilerSetImpl.UNKNOWN, d);
164.146 + unknown.put(platform, unknownFlavor);
164.147 + }
164.148 + }
164.149 + return unknownFlavor;
164.150 + }
164.151 +
164.152 + public static CompilerFlavor toFlavor(String name, int platform) {
164.153 + if (CompilerSetImpl.UNKNOWN.equals(name)) {
164.154 + return getUnknown(platform);
164.155 + }
164.156 + for (CompilerFlavorImpl flavor : flavors) {
164.157 + if (name.equals(flavor.sval) && ToolchainManagerImpl.getImpl().isPlatforSupported(platform, flavor.getToolchainDescriptor())) {
164.158 + return flavor;
164.159 + }
164.160 + }
164.161 + return null;
164.162 + }
164.163 +
164.164 + public static String mapOldToNew(String flavor, int version) {
164.165 + if (version <= 43) {
164.166 + if (flavor.equals("Sun")) { // NOI18N
164.167 + return "SunStudio"; // NOI18N
164.168 + } else if (flavor.equals("SunExpress")) { // NOI18N
164.169 + return "SunStudioExpress"; // NOI18N
164.170 + } else if (flavor.equals("Sun12")) { // NOI18N
164.171 + return "SunStudio_12"; // NOI18N
164.172 + } else if (flavor.equals("Sun11")) { // NOI18N
164.173 + return "SunStudio_11"; // NOI18N
164.174 + } else if (flavor.equals("Sun10")) { // NOI18N
164.175 + return "SunStudio_10"; // NOI18N
164.176 + } else if (flavor.equals("Sun9")) { // NOI18N
164.177 + return "SunStudio_9"; // NOI18N
164.178 + } else if (flavor.equals("Sun8")) { // NOI18N
164.179 + return "SunStudio_8"; // NOI18N
164.180 + } else if (flavor.equals("DJGPP")) { // NOI18N
164.181 + return "GNU"; // NOI18N
164.182 + } else if (flavor.equals("Interix")) { // NOI18N
164.183 + return "GNU"; // NOI18N
164.184 + } else if (flavor.equals(CompilerSetImpl.UNKNOWN)) {
164.185 + return "GNU"; // NOI18N
164.186 + }
164.187 + }
164.188 + return flavor;
164.189 + }
164.190 +
164.191 + private static boolean isPlatforSupported(CompilerFlavor flavor, int platform) {
164.192 + ToolchainDescriptor d = flavor.getToolchainDescriptor();
164.193 + if (d != null) {
164.194 + return ToolchainManagerImpl.getImpl().isPlatforSupported(platform, d);
164.195 + }
164.196 + return true;
164.197 + }
164.198 +
164.199 + public static List<CompilerFlavor> getFlavors(int platform) {
164.200 + ArrayList<CompilerFlavor> list = new ArrayList<CompilerFlavor>();
164.201 + for (CompilerFlavor flavor : flavors) {
164.202 + if (isPlatforSupported(flavor, platform)) {
164.203 + list.add(flavor);
164.204 + }
164.205 + }
164.206 + return list;
164.207 + }
164.208 +
164.209 + @Override
164.210 + public String toString() {
164.211 + return sval;
164.212 + }
164.213 +}
165.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
165.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/CompilerSetImpl.java Mon Feb 01 12:24:26 2010 +0100
165.3 @@ -0,0 +1,496 @@
165.4 +/*
165.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
165.6 + *
165.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
165.8 + *
165.9 + * The contents of this file are subject to the terms of either the GNU
165.10 + * General Public License Version 2 only ("GPL") or the Common
165.11 + * Development and Distribution License("CDDL") (collectively, the
165.12 + * "License"). You may not use this file except in compliance with the
165.13 + * License. You can obtain a copy of the License at
165.14 + * http://www.netbeans.org/cddl-gplv2.html
165.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
165.16 + * specific language governing permissions and limitations under the
165.17 + * License. When distributing the software, include this License Header
165.18 + * Notice in each file and include the License file at
165.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
165.20 + * particular file as subject to the "Classpath" exception as provided
165.21 + * by Sun in the GPL Version 2 section of the License file that
165.22 + * accompanied this code. If applicable, add the following below the
165.23 + * License Header, with the fields enclosed by brackets [] replaced by
165.24 + * your own identifying information:
165.25 + * "Portions Copyrighted [year] [name of copyright owner]"
165.26 + *
165.27 + * Contributor(s):
165.28 + *
165.29 + * The Original Software is NetBeans. The Initial Developer of the Original
165.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
165.31 + * Microsystems, Inc. All Rights Reserved.
165.32 + *
165.33 + * If you wish your version of this file to be governed by only the CDDL
165.34 + * or only the GPL Version 2, indicate your decision by adding
165.35 + * "[Contributor] elects to include this software in this distribution
165.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
165.37 + * single choice of license, a recipient has the option to distribute
165.38 + * your version of this file under either the CDDL, the GPL Version 2 or
165.39 + * to extend the choice of license to its licensees as provided above.
165.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
165.41 + * Version 2 license, then the option applies only if the new code is
165.42 + * made subject to such option by the copyright holder.
165.43 + */
165.44 +
165.45 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
165.46 +
165.47 +import java.io.File;
165.48 +import java.util.ArrayList;
165.49 +import java.util.Collections;
165.50 +import java.util.HashMap;
165.51 +import java.util.List;
165.52 +import java.util.Map;
165.53 +import org.netbeans.modules.cnd.toolchain.api.Tool;
165.54 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
165.55 +import org.netbeans.modules.cnd.toolchain.spi.CompilerProvider;
165.56 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
165.57 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
165.58 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.BaseFolder;
165.59 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CMakeDescriptor;
165.60 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
165.61 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.DebuggerDescriptor;
165.62 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.LinkerDescriptor;
165.63 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.MakeDescriptor;
165.64 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.QMakeDescriptor;
165.65 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerDescriptor;
165.66 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
165.67 +import org.netbeans.modules.cnd.utils.CndUtils;
165.68 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
165.69 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
165.70 +import org.openide.util.NbBundle;
165.71 +
165.72 +/**
165.73 + * A container for information about a set of related compilers, typicaly from a vendor or
165.74 + * redistributor.
165.75 + */
165.76 +public class CompilerSetImpl implements CompilerSet {
165.77 +
165.78 + @Override
165.79 + public boolean isAutoGenerated() {
165.80 + return autoGenerated;
165.81 + }
165.82 +
165.83 + public void setAutoGenerated(boolean autoGenerated) {
165.84 + this.autoGenerated = autoGenerated;
165.85 + }
165.86 +
165.87 + public boolean isDefault() {
165.88 + return isDefault;
165.89 + }
165.90 +
165.91 + @Override
165.92 + public boolean isUrlPointer(){
165.93 + if (getDirectory() == null || getDirectory().length() == 0){
165.94 + return flavor.getToolchainDescriptor().getUpdateCenterUrl() != null && flavor.getToolchainDescriptor().getModuleID() != null;
165.95 + }
165.96 + return false;
165.97 + }
165.98 +
165.99 + void setAsDefault(boolean isDefault) {
165.100 + this.isDefault = isDefault;
165.101 + }
165.102 +
165.103 + public void unsetDefault() {
165.104 + this.isDefault = false; // to set to true use CompilerSetManager.setDefault()
165.105 + }
165.106 +
165.107 + private final CompilerFlavor flavor;
165.108 + private String name;
165.109 + private final String displayName;
165.110 + private boolean autoGenerated;
165.111 + private boolean isDefault;
165.112 + private StringBuilder directory = new StringBuilder(256);
165.113 + private final ArrayList<Tool> tools = new ArrayList<Tool>();
165.114 + private CompilerProvider compilerProvider;
165.115 + private Map<ToolKindBase,String> pathSearch;
165.116 + private boolean isSunStudioDefault;
165.117 +
165.118 + /** Creates a new instance of CompilerSet */
165.119 + public CompilerSetImpl(CompilerFlavor flavor, String directory, String name) {
165.120 + addDirectory(directory);
165.121 +
165.122 + compilerProvider = CompilerProvider.getInstance();
165.123 +
165.124 + if (name != null) {
165.125 + this.name = name;
165.126 + } else {
165.127 + this.name = flavor.toString();
165.128 + }
165.129 + //displayName = mapNameToDisplayName(flavor);
165.130 + displayName = flavor.getToolchainDescriptor().getDisplayName();
165.131 + this.flavor = flavor;
165.132 + this.autoGenerated = true;
165.133 + this.isDefault = false;
165.134 + }
165.135 +
165.136 + public CompilerSetImpl(int platform) {
165.137 + this.name = None;
165.138 + this.flavor = CompilerFlavorImpl.getUnknown(platform);
165.139 + this.displayName = NbBundle.getMessage(CompilerSetImpl.class, "LBL_EmptyCompilerSetDisplayName"); // NOI18N
165.140 +
165.141 + compilerProvider = CompilerProvider.getInstance();
165.142 + this.autoGenerated = true;
165.143 + this.isDefault = false;
165.144 + }
165.145 +
165.146 + public CompilerSetImpl createCopy() {
165.147 + return createCopy(this.flavor, getDirectory(), name, isAutoGenerated());
165.148 + }
165.149 +
165.150 + /**
165.151 + * if null is passed as param value => "this" object value is used instead
165.152 + * @param flavor
165.153 + * @param directory
165.154 + * @param name
165.155 + * @param autoGenerated
165.156 + * @param def
165.157 + * @return
165.158 + */
165.159 + public CompilerSetImpl createCopy(CompilerFlavor flavor, String directory, String name, Boolean autoGenerated) {
165.160 + flavor = (flavor == null) ? this.flavor : flavor;
165.161 + directory = (directory == null) ? getDirectory() : directory;
165.162 + name = (name == null) ? this.name : name;
165.163 + CompilerSetImpl copy = new CompilerSetImpl(flavor, directory, name);
165.164 + autoGenerated = (autoGenerated == null) ? isAutoGenerated() : autoGenerated;
165.165 + copy.setAutoGenerated(autoGenerated);
165.166 +
165.167 + for (Tool tool : getTools()) {
165.168 + copy.addTool(tool.createCopy());
165.169 + }
165.170 +
165.171 + return copy;
165.172 + }
165.173 +
165.174 + /**
165.175 + * If no compilers are found an empty compiler set is created so we don't have an empty list.
165.176 + * Too many places in CND expect a non-empty list and throw NPEs if it is empty!
165.177 + */
165.178 + protected static CompilerSet createEmptyCompilerSet(int platform) {
165.179 + return new CompilerSetImpl(platform);
165.180 + }
165.181 +
165.182 + @Override
165.183 + public CompilerFlavor getCompilerFlavor() {
165.184 + return flavor;
165.185 + }
165.186 +
165.187 + private void addDirectory(String path) {
165.188 + if (path != null) {
165.189 + if (directory.length() == 0) {
165.190 + directory.append(path);
165.191 + } else {
165.192 + directory.append(File.pathSeparator);
165.193 + directory.append(path);
165.194 + }
165.195 + }
165.196 + }
165.197 +
165.198 + @Override
165.199 + public String getDirectory() {
165.200 + return directory.toString();
165.201 + }
165.202 +
165.203 + @Override
165.204 + public String getName() {
165.205 + return name;
165.206 + }
165.207 +
165.208 + public void setName(String name) {
165.209 + this.name = name;
165.210 + }
165.211 +
165.212 + @Override
165.213 + public String getDisplayName() {
165.214 + // TODO: this thing is never used although it's being set to informative values by personality
165.215 + return displayName;
165.216 + }
165.217 +
165.218 + /*package-local*/ Tool addTool(ExecutionEnvironment env, String name, String path, ToolKindBase kind) {
165.219 + if (findTool(kind) != null) {
165.220 + return null;
165.221 + }
165.222 + Tool tool = compilerProvider.createCompiler(env, flavor, kind, name, kind.getDisplayName(), path);
165.223 + if (!tools.contains(tool)) {
165.224 + tools.add(tool);
165.225 + }
165.226 + tool.setCompilerSet(this);
165.227 + return tool;
165.228 + }
165.229 +
165.230 + /*package-local*/ void addTool(Tool tool) {
165.231 + tools.add(tool);
165.232 + tool.setCompilerSet(this);
165.233 + }
165.234 +
165.235 + /*package-local*/ Tool addNewTool(ExecutionEnvironment env, String name, String path, ToolKindBase kind) {
165.236 + Tool tool = compilerProvider.createCompiler(env, flavor, kind, name, kind.getDisplayName(), path);
165.237 + tools.add(tool);
165.238 + tool.setCompilerSet(this);
165.239 + return tool;
165.240 + }
165.241 +
165.242 + /**
165.243 + * Get the first tool of its kind.
165.244 + *
165.245 + * @param kind The type of tool to get
165.246 + * @return The Tool or null
165.247 + */
165.248 + @Override
165.249 + public Tool getTool(ToolKindBase kind) {
165.250 + for (Tool tool : tools) {
165.251 + if (tool.getKind() == kind) {
165.252 + return tool;
165.253 + }
165.254 + }
165.255 + CndUtils.assertFalse(true, "Should not be here, cuz we should create empty tools in CompilerSetManager"); //NOI18N
165.256 + //TODO: remove this code, empty tools should be created in CompilerSetManager
165.257 + Tool t;
165.258 + // Fixup: all tools should go here ....
165.259 + t = compilerProvider.createCompiler(ExecutionEnvironmentFactory.getLocal(),
165.260 + getCompilerFlavor(), kind, "", kind.getDisplayName(), ""); // NOI18N
165.261 + t.setCompilerSet(this);
165.262 + synchronized( tools ) { // synchronize this only unpredictable tools modification
165.263 + tools.add(t);
165.264 + }
165.265 + return t;
165.266 + }
165.267 +
165.268 +
165.269 + /**
165.270 + * Get the first tool of its kind.
165.271 + *
165.272 + * @param kind The type of tool to get
165.273 + * @return The Tool or null
165.274 + */
165.275 + @Override
165.276 + public Tool findTool(ToolKindBase kind) {
165.277 + for (Tool tool : tools) {
165.278 + if (tool.getKind() == kind) {
165.279 + return tool;
165.280 + }
165.281 + }
165.282 + return null;
165.283 + }
165.284 +
165.285 + @SuppressWarnings("unchecked")
165.286 + @Override
165.287 + public List<Tool> getTools() {
165.288 + synchronized (tools) {
165.289 + return (List<Tool>)tools.clone();
165.290 + }
165.291 + }
165.292 +
165.293 + /*package-local*/ void addPathCandidate(ToolKindBase tool, String path) {
165.294 + if (pathSearch == null){
165.295 + pathSearch = new HashMap<ToolKindBase, String>();
165.296 + }
165.297 + pathSearch.put(tool, path);
165.298 + }
165.299 +
165.300 + /*package-local*/String getPathCandidate(ToolKindBase tool){
165.301 + if (pathSearch == null){
165.302 + return null;
165.303 + }
165.304 + return pathSearch.get(tool);
165.305 + }
165.306 +
165.307 + /*package-local*/void setSunStudioDefault(boolean isSunStudioDefault){
165.308 + this.isSunStudioDefault = isSunStudioDefault;
165.309 + }
165.310 +
165.311 + /*package-local*/boolean isSunStudioDefault(){
165.312 + return isSunStudioDefault;
165.313 + }
165.314 +
165.315 + @Override
165.316 + public String toString() {
165.317 + return name;
165.318 + }
165.319 +
165.320 + public static class UnknownToolchainDescriptor implements ToolchainDescriptor {
165.321 +
165.322 + @Override
165.323 + public String getFileName() {
165.324 + return ""; // NOI18N
165.325 + }
165.326 +
165.327 + @Override
165.328 + public String getName() {
165.329 + return ""; // NOI18N
165.330 + }
165.331 +
165.332 + @Override
165.333 + public String getDisplayName() {
165.334 + return ""; // NOI18N
165.335 + }
165.336 +
165.337 + @Override
165.338 + public String[] getFamily() {
165.339 + return new String[]{};
165.340 + }
165.341 +
165.342 + @Override
165.343 + public String[] getPlatforms() {
165.344 + return new String[]{};
165.345 + }
165.346 +
165.347 + @Override
165.348 + public String getUpdateCenterUrl() {
165.349 + return null;
165.350 + }
165.351 +
165.352 + @Override
165.353 + public String getUpdateCenterDisplayName() {
165.354 + return null;
165.355 + }
165.356 +
165.357 + @Override
165.358 + public String getUpgradeUrl() {
165.359 + return null;
165.360 + }
165.361 +
165.362 + @Override
165.363 + public String getModuleID() {
165.364 + return null;
165.365 + }
165.366 +
165.367 + @Override
165.368 + public boolean isAbstract() {
165.369 + return true;
165.370 + }
165.371 +
165.372 + @Override
165.373 + public String getDriveLetterPrefix() {
165.374 + return "/"; // NOI18N
165.375 + }
165.376 +
165.377 + @Override
165.378 + public List<BaseFolder> getBaseFolders() {
165.379 + return Collections.<BaseFolder>emptyList();
165.380 + }
165.381 +
165.382 + @Override
165.383 + public List<BaseFolder> getCommandFolders() {
165.384 + return Collections.<BaseFolder>emptyList();
165.385 + }
165.386 +
165.387 + @Override
165.388 + public String getQmakeSpec() {
165.389 + return ""; // NOI18N
165.390 + }
165.391 +
165.392 + @Override
165.393 + public CompilerDescriptor getC() {
165.394 + return null;
165.395 + }
165.396 +
165.397 + @Override
165.398 + public CompilerDescriptor getCpp() {
165.399 + return null;
165.400 + }
165.401 +
165.402 + @Override
165.403 + public CompilerDescriptor getFortran() {
165.404 + return null;
165.405 + }
165.406 +
165.407 + @Override
165.408 + public CompilerDescriptor getAssembler() {
165.409 + return null;
165.410 + }
165.411 +
165.412 + @Override
165.413 + public ScannerDescriptor getScanner() {
165.414 + return null;
165.415 + }
165.416 +
165.417 + @Override
165.418 + public LinkerDescriptor getLinker() {
165.419 + return new LinkerDescriptor(){
165.420 +
165.421 + @Override
165.422 + public String getLibraryPrefix() {
165.423 + return ""; // NOI18N
165.424 + }
165.425 +
165.426 + @Override
165.427 + public String getLibrarySearchFlag() {
165.428 + return ""; // NOI18N
165.429 + }
165.430 +
165.431 + @Override
165.432 + public String getDynamicLibrarySearchFlag() {
165.433 + return ""; // NOI18N
165.434 + }
165.435 +
165.436 + @Override
165.437 + public String getLibraryFlag() {
165.438 + return ""; // NOI18N
165.439 + }
165.440 +
165.441 + @Override
165.442 + public String getPICFlag() {
165.443 + return ""; // NOI18N
165.444 + }
165.445 +
165.446 + @Override
165.447 + public String getStaticLibraryFlag() {
165.448 + return ""; // NOI18N
165.449 + }
165.450 +
165.451 + @Override
165.452 + public String getDynamicLibraryFlag() {
165.453 + return ""; // NOI18N
165.454 + }
165.455 +
165.456 + @Override
165.457 + public String getDynamicLibraryBasicFlag() {
165.458 + return ""; // NOI18N
165.459 + }
165.460 +
165.461 + @Override
165.462 + public String getOutputFileFlag() {
165.463 + return ""; // NOI18N
165.464 + }
165.465 + };
165.466 + }
165.467 +
165.468 + @Override
165.469 + public MakeDescriptor getMake() {
165.470 + return null;
165.471 + }
165.472 +
165.473 + @Override
165.474 + public Map<String, List<String>> getDefaultLocations() {
165.475 + return Collections.<String, List<String>>emptyMap();
165.476 + }
165.477 +
165.478 + @Override
165.479 + public DebuggerDescriptor getDebugger() {
165.480 + return null;
165.481 + }
165.482 +
165.483 + @Override
165.484 + public String getMakefileWriter() {
165.485 + return null;
165.486 + }
165.487 +
165.488 + @Override
165.489 + public QMakeDescriptor getQMake() {
165.490 + return null;
165.491 + }
165.492 +
165.493 + @Override
165.494 + public CMakeDescriptor getCMake() {
165.495 + return null;
165.496 + }
165.497 +
165.498 + }
165.499 +}
166.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
166.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/CompilerSetManagerAccessorImpl.java Mon Feb 01 12:24:26 2010 +0100
166.3 @@ -0,0 +1,168 @@
166.4 +/*
166.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
166.6 + *
166.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
166.8 + *
166.9 + * The contents of this file are subject to the terms of either the GNU
166.10 + * General Public License Version 2 only ("GPL") or the Common
166.11 + * Development and Distribution License("CDDL") (collectively, the
166.12 + * "License"). You may not use this file except in compliance with the
166.13 + * License. You can obtain a copy of the License at
166.14 + * http://www.netbeans.org/cddl-gplv2.html
166.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
166.16 + * specific language governing permissions and limitations under the
166.17 + * License. When distributing the software, include this License Header
166.18 + * Notice in each file and include the License file at
166.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
166.20 + * particular file as subject to the "Classpath" exception as provided
166.21 + * by Sun in the GPL Version 2 section of the License file that
166.22 + * accompanied this code. If applicable, add the following below the
166.23 + * License Header, with the fields enclosed by brackets [] replaced by
166.24 + * your own identifying information:
166.25 + * "Portions Copyrighted [year] [name of copyright owner]"
166.26 + *
166.27 + * If you wish your version of this file to be governed by only the CDDL
166.28 + * or only the GPL Version 2, indicate your decision by adding
166.29 + * "[Contributor] elects to include this software in this distribution
166.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
166.31 + * single choice of license, a recipient has the option to distribute
166.32 + * your version of this file under either the CDDL, the GPL Version 2 or
166.33 + * to extend the choice of license to its licensees as provided above.
166.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
166.35 + * Version 2 license, then the option applies only if the new code is
166.36 + * made subject to such option by the copyright holder.
166.37 + *
166.38 + * Contributor(s):
166.39 + *
166.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
166.41 + */
166.42 +
166.43 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
166.44 +
166.45 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainScriptGenerator;
166.46 +import java.util.Collection;
166.47 +import java.util.HashMap;
166.48 +import javax.swing.SwingUtilities;
166.49 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
166.50 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
166.51 +import org.openide.DialogDescriptor;
166.52 +import org.openide.DialogDisplayer;
166.53 +import org.openide.util.NbBundle;
166.54 +
166.55 +/**
166.56 + *
166.57 + * @author Alexander Simon
166.58 + */
166.59 +public class CompilerSetManagerAccessorImpl {
166.60 +
166.61 + private static final HashMap<ExecutionEnvironment, CompilerSetManagerImpl> managers = new HashMap<ExecutionEnvironment, CompilerSetManagerImpl>();
166.62 + private static final Object MASTER_LOCK = new Object();
166.63 +
166.64 + private CompilerSetManagerAccessorImpl() {
166.65 + }
166.66 +
166.67 + /**
166.68 + * Find or create a default CompilerSetManager for the given key. A default
166.69 + * CSM is one which is active in the system. A non-default is one which gets
166.70 + * created but has no affect unless its made default.
166.71 + *
166.72 + * For instance, the Build Tools tab (on C/C++ Tools->Options) creates a non-Default
166.73 + * CSM and only makes it default if the OK button is pressed. If Cancel is pressed,
166.74 + * it never becomes default.
166.75 + *
166.76 + * @param env specifies execution environment
166.77 + * @return A default CompilerSetManager for the given key
166.78 + */
166.79 + public static CompilerSetManager getDefault(ExecutionEnvironment env) {
166.80 + return getDefaultImpl(env, true);
166.81 + }
166.82 +
166.83 + /** Create a CompilerSetManager which may be registered at a later time via CompilerSetManager.setDefault() */
166.84 + public static CompilerSetManagerImpl create(ExecutionEnvironment env) {
166.85 + CompilerSetManagerImpl newCsm = new CompilerSetManagerImpl(env);
166.86 + if (newCsm.getCompilerSets().size() == 1 && newCsm.getCompilerSets().get(0).getName().equals(CompilerSetImpl.None)) {
166.87 + newCsm.remove(newCsm.getCompilerSets().get(0));
166.88 + }
166.89 + return newCsm;
166.90 + }
166.91 +
166.92 + /** Replace the default CompilerSetManager. Let registered listeners know its been updated */
166.93 + public static void setManagers(Collection<CompilerSetManager> csms) {
166.94 + synchronized (MASTER_LOCK) {
166.95 + CompilerSetPreferences.clearPersistence();
166.96 + managers.clear();
166.97 + for (CompilerSetManager csm : csms) {
166.98 + CompilerSetManagerImpl impl = (CompilerSetManagerImpl) csm;
166.99 + impl.completeCompilerSets();
166.100 + CompilerSetPreferences.saveToDisk(impl);
166.101 + managers.put(impl.getExecutionEnvironment(), impl);
166.102 + }
166.103 + }
166.104 + }
166.105 +
166.106 + public static String getRemoteScript(String path) {
166.107 + return ToolchainScriptGenerator.generateScript(path);
166.108 + }
166.109 +
166.110 + public static void save(CompilerSetManager csm) {
166.111 + synchronized (MASTER_LOCK) {
166.112 + CompilerSetPreferences.saveToDisk(csm);
166.113 + }
166.114 + }
166.115 +
166.116 + public static CompilerSetManager getDeepCopy(ExecutionEnvironment execEnv, boolean initialize) {
166.117 + return ((CompilerSetManagerImpl)getDefaultImpl(execEnv, initialize)).deepCopy();
166.118 + }
166.119 +
166.120 + private static CompilerSetManager getDefaultImpl(ExecutionEnvironment env, boolean initialize) {
166.121 + CompilerSetManagerImpl csm = null;
166.122 + boolean no_compilers = false;
166.123 +
166.124 + synchronized (MASTER_LOCK) {
166.125 + csm = managers.get(env);
166.126 + if (csm == null) {
166.127 + csm = CompilerSetPreferences.restoreFromDisk(env);
166.128 + if (csm != null && csm.getDefaultCompilerSet() == null) {
166.129 + CompilerSetPreferences.saveToDisk(csm);
166.130 + }
166.131 + }
166.132 + if (csm == null) {
166.133 + csm = new CompilerSetManagerImpl(env, initialize);
166.134 + if (csm.isValid()) {
166.135 + CompilerSetPreferences.saveToDisk(csm);
166.136 + } else if (!csm.isPending() && !csm.isUninitialized()) {
166.137 + no_compilers = true;
166.138 + }
166.139 + }
166.140 + if (csm != null) {
166.141 + managers.put(env, csm);
166.142 + }
166.143 + }
166.144 +
166.145 + if (no_compilers) {
166.146 + // workaround to fix IZ#164028: Full IDE freeze when opening GizmoDemo project on Linux
166.147 + // we postpone dialog displayer until EDT is free to process
166.148 + SwingUtilities.invokeLater(new Runnable() {
166.149 + @Override
166.150 + public void run() {
166.151 + DialogDescriptor dialogDescriptor = new DialogDescriptor(
166.152 + new NoCompilersPanel(),
166.153 + getString("NO_COMPILERS_FOUND_TITLE"),
166.154 + true,
166.155 + new Object[]{DialogDescriptor.OK_OPTION},
166.156 + DialogDescriptor.OK_OPTION,
166.157 + DialogDescriptor.BOTTOM_ALIGN,
166.158 + null,
166.159 + null);
166.160 + DialogDisplayer.getDefault().notify(dialogDescriptor);
166.161 + }
166.162 + });
166.163 + }
166.164 + return csm;
166.165 + }
166.166 +
166.167 + /** Look up i18n strings here */
166.168 + private static String getString(String s) {
166.169 + return NbBundle.getMessage(CompilerSetManagerAccessorImpl.class, s);
166.170 + }
166.171 +}
167.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
167.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/CompilerSetManagerImpl.java Mon Feb 01 12:24:26 2010 +0100
167.3 @@ -0,0 +1,1171 @@
167.4 +/*
167.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
167.6 + *
167.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
167.8 + *
167.9 + * The contents of this file are subject to the terms of either the GNU
167.10 + * General Public License Version 2 only ("GPL") or the Common
167.11 + * Development and Distribution License("CDDL") (collectively, the
167.12 + * "License"). You may not use this file except in compliance with the
167.13 + * License. You can obtain a copy of the License at
167.14 + * http://www.netbeans.org/cddl-gplv2.html
167.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
167.16 + * specific language governing permissions and limitations under the
167.17 + * License. When distributing the software, include this License Header
167.18 + * Notice in each file and include the License file at
167.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
167.20 + * particular file as subject to the "Classpath" exception as provided
167.21 + * by Sun in the GPL Version 2 section of the License file that
167.22 + * accompanied this code. If applicable, add the following below the
167.23 + * License Header, with the fields enclosed by brackets [] replaced by
167.24 + * your own identifying information:
167.25 + * "Portions Copyrighted [year] [name of copyright owner]"
167.26 + *
167.27 + * Contributor(s):
167.28 + *
167.29 + * The Original Software is NetBeans. The Initial Developer of the Original
167.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
167.31 + * Microsystems, Inc. All Rights Reserved.
167.32 + *
167.33 + * If you wish your version of this file to be governed by only the CDDL
167.34 + * or only the GPL Version 2, indicate your decision by adding
167.35 + * "[Contributor] elects to include this software in this distribution
167.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
167.37 + * single choice of license, a recipient has the option to distribute
167.38 + * your version of this file under either the CDDL, the GPL Version 2 or
167.39 + * to extend the choice of license to its licensees as provided above.
167.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
167.41 + * Version 2 license, then the option applies only if the new code is
167.42 + * made subject to such option by the copyright holder.
167.43 + */
167.44 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
167.45 +
167.46 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainScriptGenerator;
167.47 +import java.io.File;
167.48 +import java.io.Writer;
167.49 +import java.util.ArrayList;
167.50 +import java.util.Collection;
167.51 +import java.util.Collections;
167.52 +import java.util.Comparator;
167.53 +import java.util.HashSet;
167.54 +import java.util.LinkedHashSet;
167.55 +import java.util.List;
167.56 +import java.util.Map;
167.57 +import java.util.NoSuchElementException;
167.58 +import java.util.Set;
167.59 +import java.util.StringTokenizer;
167.60 +import java.util.concurrent.atomic.AtomicReference;
167.61 +import java.util.logging.Level;
167.62 +import java.util.logging.Logger;
167.63 +import javax.swing.SwingUtilities;
167.64 +import org.netbeans.api.progress.ProgressHandle;
167.65 +import org.netbeans.api.progress.ProgressHandleFactory;
167.66 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.AlternativePath;
167.67 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
167.68 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
167.69 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolDescriptor;
167.70 +import org.netbeans.modules.cnd.api.remote.ServerList;
167.71 +import org.netbeans.modules.cnd.api.remote.ServerRecord;
167.72 +import org.netbeans.modules.cnd.toolchain.api.Tool;
167.73 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
167.74 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
167.75 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetFactory;
167.76 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
167.77 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetManagerEvents;
167.78 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProvider;
167.79 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
167.80 +import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
167.81 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
167.82 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
167.83 +import org.netbeans.modules.cnd.toolchain.spi.ToolChainPathProvider;
167.84 +import org.netbeans.modules.cnd.utils.CndUtils;
167.85 +import org.netbeans.modules.cnd.utils.NamedRunnable;
167.86 +import org.netbeans.modules.cnd.utils.cache.CndFileUtils;
167.87 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
167.88 +import org.netbeans.modules.nativeexecution.api.util.Path;
167.89 +import org.openide.util.Cancellable;
167.90 +import org.openide.util.NbBundle;
167.91 +import org.openide.util.RequestProcessor;
167.92 +import org.openide.util.RequestProcessor.Task;
167.93 +import org.openide.util.TaskListener;
167.94 +
167.95 +/**
167.96 + * Manage a set of CompilerSets. The CompilerSets are dynamically created based on which compilers
167.97 + * are found in the user's $PATH variable.
167.98 + */
167.99 +public final class CompilerSetManagerImpl extends CompilerSetManager {
167.100 +
167.101 + private static final Logger log = Logger.getLogger("cnd.remote.logger"); // NOI18N
167.102 +
167.103 + //private static final HashMap<ExecutionEnvironment, CompilerSetManagerImpl> managers = new HashMap<ExecutionEnvironment, CompilerSetManagerImpl>();
167.104 + //private static final Object MASTER_LOCK = new Object();
167.105 +
167.106 + // CopyOnWriteArrayList because of IZ#175647
167.107 + private List<CompilerSet> sets = new ArrayList<CompilerSet>();
167.108 +
167.109 + private final ExecutionEnvironment executionEnvironment;
167.110 + private volatile State state;
167.111 + private int platform = -1;
167.112 + private Task initializationTask;
167.113 +
167.114 +
167.115 + public CompilerSetManagerImpl(ExecutionEnvironment env) {
167.116 + this(env, true);
167.117 + }
167.118 +
167.119 + public CompilerSetManagerImpl(ExecutionEnvironment env, final boolean initialize) {
167.120 + //if (log.isLoggable(Level.FINEST)) {
167.121 + // log.log(Level.FINEST, "CompilerSetManager CTOR A @" + System.identityHashCode(this) + ' ' + env + ' ' + initialize, new Exception()); //NOI18N
167.122 + //}
167.123 + executionEnvironment = env;
167.124 + if (initialize) {
167.125 + state = State.STATE_PENDING;
167.126 + } else {
167.127 + state = State.STATE_UNINITIALIZED;
167.128 + return;
167.129 + }
167.130 + if (executionEnvironment.isLocal()) {
167.131 + platform = ToolUtils.computeLocalPlatform();
167.132 + initCompilerSets(Path.getPath());
167.133 + } else {
167.134 + final AtomicReference<Thread> threadRef = new AtomicReference<Thread>();
167.135 + final String progressMessage = NbBundle.getMessage(getClass(), "PROGRESS_TEXT", env.getDisplayName());
167.136 + final ProgressHandle progressHandle = ProgressHandleFactory.createHandle(
167.137 + progressMessage,
167.138 + new Cancellable() {
167.139 + @Override
167.140 + public boolean cancel() {
167.141 + Thread thread = threadRef.get();
167.142 + if (thread != null) {
167.143 + thread.interrupt();
167.144 + }
167.145 + return true;
167.146 + }
167.147 +
167.148 + });
167.149 + log.log(Level.FINE, "CSM.init: initializing remote compiler set @{0} for: {1}", new Object[]{System.identityHashCode(CompilerSetManagerImpl.this), toString()});
167.150 + progressHandle.start();
167.151 + RequestProcessor.getDefault().post(new NamedRunnable(progressMessage) {
167.152 + protected @Override void runImpl() {
167.153 + threadRef.set(Thread.currentThread());
167.154 + try {
167.155 + initRemoteCompilerSets(false, initialize);
167.156 + } finally {
167.157 + progressHandle.finish();
167.158 + }
167.159 + }
167.160 + });
167.161 + }
167.162 + }
167.163 +
167.164 + CompilerSetManagerImpl(ExecutionEnvironment env, List<CompilerSet> sets, int platform) {
167.165 + //if (log.isLoggable(Level.FINEST)) {
167.166 + // log.log(Level.FINEST, "CompilerSetManager CTOR B @" + System.identityHashCode(this) + ' ' + sets + ' ' + platform, new Exception()); //NOI18N
167.167 + //}
167.168 + this.executionEnvironment = env;
167.169 + this.sets = sets;
167.170 + this.platform = platform;
167.171 + completeCompilerSets();
167.172 + if(env.isRemote() && isEmpty()) {
167.173 + this.state = State.STATE_UNINITIALIZED;
167.174 + log.log(Level.FINE, "CSM restoring from pref: Adding empty CS to host {0}", toString());
167.175 + } else {
167.176 + this.state = State.STATE_COMPLETE;
167.177 + }
167.178 + }
167.179 +
167.180 + public static String getRemoteScript(String path) {
167.181 + return ToolchainScriptGenerator.generateScript(path);
167.182 + }
167.183 +
167.184 + public boolean isValid() {
167.185 + return sets.size() > 0 && !sets.get(0).getName().equals(CompilerSetImpl.None);
167.186 + }
167.187 +
167.188 + @Override
167.189 + public boolean isPending() {
167.190 + return state == State.STATE_PENDING;
167.191 + }
167.192 +
167.193 + @Override
167.194 + public boolean isUninitialized() {
167.195 + return state == State.STATE_UNINITIALIZED;
167.196 + }
167.197 +
167.198 + public boolean isComplete() {
167.199 + return state == State.STATE_COMPLETE;
167.200 + }
167.201 +
167.202 + /** CAUTION: this is a slow method. It should NOT be called from the EDT thread */
167.203 + @Override
167.204 + public synchronized void initialize(boolean save, boolean runCompilerSetDataLoader, Writer reporter) {
167.205 + CompilerSetReporter.setWriter(reporter);
167.206 + try {
167.207 + CndUtils.assertNonUiThread();
167.208 + if (isUninitialized()) {
167.209 + log.log(Level.FINE, "CSM.getDefault: Doing remote setup from EDT?{0}", SwingUtilities.isEventDispatchThread());
167.210 + this.sets.clear();
167.211 + initRemoteCompilerSets(true, runCompilerSetDataLoader);
167.212 + if (initializationTask != null) {
167.213 + initializationTask.waitFinished();
167.214 + initializationTask = null;
167.215 + }
167.216 + }
167.217 + if (save) {
167.218 + CompilerSetManagerAccessorImpl.save(this);
167.219 + }
167.220 + } finally {
167.221 + CompilerSetReporter.setWriter(null);
167.222 + }
167.223 + }
167.224 +
167.225 + @Override
167.226 + public int getPlatform() {
167.227 + if (platform < 0) {
167.228 + if (executionEnvironment.isLocal()) {
167.229 + platform = ToolUtils.computeLocalPlatform();
167.230 + } else {
167.231 + if (isPending()) {
167.232 + log.log(Level.WARNING, "calling getPlatform() on uninitializad {0}", getClass().getSimpleName());
167.233 + }
167.234 + }
167.235 + }
167.236 + return platform == -1 ? PlatformTypes.PLATFORM_NONE : platform;
167.237 + }
167.238 +
167.239 + public CompilerSetManagerImpl deepCopy() {
167.240 + if (isPending()) {
167.241 + log.log(Level.WARNING, "calling deepCopy() on uninitializad {0}", getClass().getSimpleName());
167.242 + }
167.243 + List<CompilerSet> setsCopy = new ArrayList<CompilerSet>();
167.244 + CompilerSet copyOfDefaultCompilerSet = null;
167.245 + for (CompilerSet set : getCompilerSets()) {
167.246 + final CompilerSetImpl copy = ((CompilerSetImpl) set).createCopy();
167.247 + setsCopy.add(copy);
167.248 + if (isDefaultCompilerSet(set)) {
167.249 + copyOfDefaultCompilerSet = copy;
167.250 + }
167.251 + }
167.252 + CompilerSetManagerImpl copy = new CompilerSetManagerImpl(executionEnvironment, setsCopy, this.platform);
167.253 + copy.setDefault(copyOfDefaultCompilerSet);
167.254 + return copy;
167.255 + }
167.256 +
167.257 + @Override
167.258 + public String getUniqueCompilerSetName(String baseName) {
167.259 + int n = 0;
167.260 + String suggestedName = baseName;
167.261 + while (true) {
167.262 + suggestedName = baseName + (n > 0 ? ("_" + n) : ""); // NOI18N
167.263 + if (getCompilerSet(suggestedName) != null) {
167.264 + n++;
167.265 + } else {
167.266 + break;
167.267 + }
167.268 + }
167.269 + return suggestedName;
167.270 + }
167.271 +
167.272 + private Collection<FolderDescriptor> getPaths(ToolchainDescriptor d, CompilerFlavor flavor, ArrayList<String> dirlist) {
167.273 + LinkedHashSet<FolderDescriptor> dirs = new LinkedHashSet<FolderDescriptor>();
167.274 + // path from regestry
167.275 + String base = ToolchainManagerImpl.getImpl().getBaseFolder(d, getPlatform());
167.276 + if (base != null) {
167.277 + dirs.add(new FolderDescriptor(base, true));
167.278 + }
167.279 + // path from env
167.280 + for (String p : dirlist) {
167.281 + dirs.add(new FolderDescriptor(p, false));
167.282 + }
167.283 + // path from default location
167.284 + Map<String, List<String>> map = d.getDefaultLocations();
167.285 + if (map != null) {
167.286 + List<String> list = map.get(ToolUtils.getPlatformName(getPlatform()));
167.287 + if (list != null) {
167.288 + for (String p : list) {
167.289 + dirs.add(new FolderDescriptor(p, true));
167.290 + }
167.291 + }
167.292 + }
167.293 + // path from plugins
167.294 + String path = ToolChainPathProvider.getDefault().getPath(flavor);
167.295 + if (path != null) {
167.296 + dirs.add(new FolderDescriptor(path, true));
167.297 + }
167.298 + return dirs;
167.299 + }
167.300 +
167.301 + /** Search $PATH for all desired compiler sets and initialize cbCompilerSet and spCompilerSets */
167.302 + private synchronized void initCompilerSets(final ArrayList<String> dirlist) {
167.303 + // NB: function itself is synchronized!
167.304 + if (state == State.STATE_COMPLETE) {
167.305 + return;
167.306 + }
167.307 + if (initializationTask != null) {
167.308 + return;
167.309 + }
167.310 + String progressMessage = NbBundle.getMessage(getClass(), "PROGRESS_TEXT", executionEnvironment.getDisplayName()); // NOI18N
167.311 + ProgressHandle progressHandle = ProgressHandleFactory.createHandle(progressMessage);
167.312 + progressHandle.start();
167.313 + initializationTask = RequestProcessor.getDefault().post(new Runnable() {
167.314 + @Override
167.315 + public void run() {
167.316 + initCompilerSetsImpl(dirlist);
167.317 + }
167.318 + });
167.319 + initializationTask.waitFinished();
167.320 + initializationTask = null;
167.321 + progressHandle.finish();
167.322 + }
167.323 +
167.324 + /** Search $PATH for all desired compiler sets and initialize cbCompilerSet and spCompilerSets */
167.325 + private void initCompilerSetsImpl(ArrayList<String> dirlist) {
167.326 + Set<CompilerFlavor> flavors = new HashSet<CompilerFlavor>();
167.327 + String SunStudioPath = System.getProperty("spro.bin"); // NB: function itself is synchronized!
167.328 +
167.329 + if (SunStudioPath != null) {
167.330 + File folder = new File(SunStudioPath);
167.331 + if (folder.isDirectory()) {
167.332 + for(ToolchainDescriptor d : ToolchainManagerImpl.getImpl().getToolchains(getPlatform())) {
167.333 + if (d.isAbstract()) {
167.334 + continue;
167.335 + }
167.336 + CompilerFlavor flavor = CompilerFlavorImpl.toFlavor(d.getName(), getPlatform());
167.337 + if (flavor == null) {
167.338 + continue;
167.339 + }
167.340 + if (flavors.contains(flavor)) {
167.341 + continue;
167.342 + }
167.343 + CompilerSetImpl cs = (CompilerSetImpl) CompilerSetFactory.getCustomCompilerSet(folder.getAbsolutePath(), flavor, flavor.toString());
167.344 + cs.setAutoGenerated(true);
167.345 + if (initCompilerSet(SunStudioPath, cs, true)){
167.346 + flavors.add(flavor);
167.347 + addUnsafe(cs);
167.348 + cs.setSunStudioDefault(true);
167.349 + }
167.350 + }
167.351 + }
167.352 + }
167.353 + Loop:for(ToolchainDescriptor d : ToolchainManagerImpl.getImpl().getToolchains(getPlatform())) {
167.354 + if (d.isAbstract()) {
167.355 + continue;
167.356 + }
167.357 + CompilerFlavor flavor = CompilerFlavorImpl.toFlavor(d.getName(), getPlatform());
167.358 + if (flavor == null) {
167.359 + continue;
167.360 + }
167.361 + if (flavors.contains(flavor)) {
167.362 + continue;
167.363 + }
167.364 + for (FolderDescriptor folderDescriptor : getPaths(d, flavor, dirlist)) {
167.365 + String path = folderDescriptor.path;
167.366 + if (path.equals("/usr/ucb")) { // NOI18N
167.367 + // Don't look here.
167.368 + continue;
167.369 + }
167.370 + if (!ToolUtils.isPathAbsolute(path)) {
167.371 + path = CndFileUtils.normalizeAbsolutePath(new File(path).getAbsolutePath());
167.372 + }
167.373 + File dir = new File(path);
167.374 + if (dir.isDirectory()) {
167.375 + if (ToolchainManagerImpl.getImpl().isMyFolder(dir.getAbsolutePath(), d, getPlatform(), folderDescriptor.knownFolder)){
167.376 + if (d.getModuleID() == null && !d.isAbstract()) {
167.377 + CompilerSetImpl cs = (CompilerSetImpl) CompilerSetFactory.getCustomCompilerSet(dir.getAbsolutePath(), flavor, flavor.toString());
167.378 + cs.setAutoGenerated(true);
167.379 + if (initCompilerSet(path, cs, folderDescriptor.knownFolder)){
167.380 + flavors.add(flavor);
167.381 + addUnsafe(cs);
167.382 + continue Loop;
167.383 + }
167.384 + }
167.385 + }
167.386 + }
167.387 + }
167.388 + }
167.389 + addFakeCompilerSets();
167.390 + completeCompilerSets();
167.391 + state = State.STATE_COMPLETE;
167.392 + }
167.393 +
167.394 + /**
167.395 + * Since many toolchains have default locations, append them to the path (on a per-platform basis)
167.396 + * if they aren't already in the list.
167.397 + *
167.398 + * @param platform The platform we're running on
167.399 + * @param dirlist An ArrayList of the current PATH
167.400 + * @return A possibly modified ArrayList
167.401 + */
167.402 + public static ArrayList<String> appendDefaultLocations(int platform, ArrayList<String> dirlist) {
167.403 + for (ToolchainDescriptor d : ToolchainManagerImpl.getImpl().getToolchains(platform)) {
167.404 + if (d.isAbstract()) {
167.405 + continue;
167.406 + }
167.407 + Map<String, List<String>> map = d.getDefaultLocations();
167.408 + if (map != null) {
167.409 + String pname = ToolUtils.getPlatformName(platform);
167.410 + List<String> list = map.get(pname);
167.411 + if (list != null ) {
167.412 + for (String dir : list){
167.413 + if (!dirlist.contains(dir)){
167.414 + dirlist.add(dir);
167.415 + }
167.416 + }
167.417 + }
167.418 + }
167.419 + }
167.420 + return dirlist;
167.421 + }
167.422 +
167.423 + private void setDefaltCompilerSet() {
167.424 + for (CompilerSet cs : sets) {
167.425 + if (((CompilerSetImpl)cs).isDefault()) {
167.426 + return;
167.427 + }
167.428 + }
167.429 + CompilerSet bestCandidate = null;
167.430 + for (CompilerSet cs : sets) {
167.431 + if (cs.getCompilerFlavor().isSunStudioCompiler()) {
167.432 + if ("SunStudio".equals(cs.getName())) { // NOI18N
167.433 + setDefault(cs);
167.434 + return;
167.435 + }
167.436 + if (bestCandidate == null) {
167.437 + bestCandidate = cs;
167.438 + }
167.439 + }
167.440 + }
167.441 + if (bestCandidate != null) {
167.442 + setDefault(bestCandidate);
167.443 + return;
167.444 + }
167.445 + if (!sets.isEmpty()) {
167.446 + setDefault(sets.get(0));
167.447 + }
167.448 + }
167.449 +
167.450 + @Override
167.451 + public List<CompilerSet> findRemoteCompilerSets(String path) {
167.452 + ServerRecord record = ServerList.get(executionEnvironment);
167.453 + assert record != null;
167.454 + record.validate(true);
167.455 + if (!record.isOnline()) {
167.456 + return Collections.<CompilerSet>emptyList();
167.457 + }
167.458 + final CompilerSetProvider provider = CompilerSetProviderFactoryImpl.createNew(executionEnvironment);
167.459 + String[] arData = provider.getCompilerSetData(path);
167.460 + List<CompilerSet> css = new ArrayList<CompilerSet>();
167.461 + if (arData != null) {
167.462 + for (String data : arData) {
167.463 + if (data != null && data.length() > 0) {
167.464 + CompilerSetImpl cs = parseCompilerSetString(platform, data);
167.465 + if (cs != null) {
167.466 + css.add(cs);
167.467 + }
167.468 + }
167.469 + }
167.470 + }
167.471 + for(CompilerSet cs : css) {
167.472 + completeCompilerSet(executionEnvironment, (CompilerSetImpl)cs, css);
167.473 + }
167.474 + return css;
167.475 + }
167.476 +
167.477 + private CompilerSetImpl parseCompilerSetString(int platform, String data) {
167.478 + log.log(Level.FINE, "CSM.initRemoteCompileSets: line = [{0}]", data); // NOI18N
167.479 + String flavor;
167.480 + String path;
167.481 + StringTokenizer st = new StringTokenizer(data, ";"); // NOI18N
167.482 + try {
167.483 + flavor = st.nextToken();
167.484 + path = st.nextToken();
167.485 + } catch (NoSuchElementException ex) {
167.486 + log.log(Level.WARNING, "Malformed compilerSetString: {0}", data); // NOI18N
167.487 + return null;
167.488 + }
167.489 + CompilerFlavor compilerFlavor = CompilerFlavorImpl.toFlavor(flavor, platform);
167.490 + if (compilerFlavor == null) { // #158084
167.491 + log.log(Level.WARNING, "NULL compiler flavor for {0} on platform {1}", new Object[]{flavor, platform}); // NOI18N
167.492 + return null;
167.493 + }
167.494 + CompilerSetImpl cs = new CompilerSetImpl(compilerFlavor, path, flavor);
167.495 + while (st.hasMoreTokens()) {
167.496 + String name = st.nextToken();
167.497 + int i = name.indexOf('='); // NOI18N
167.498 + if (i < 0) {
167.499 + continue;
167.500 + }
167.501 + String tool = name.substring(0,i);
167.502 + String p = name.substring(i + 1);
167.503 + i = name.lastIndexOf('/');
167.504 + if (i < 0) {
167.505 + i = name.lastIndexOf('\\');
167.506 + }
167.507 + if (i > 0) {
167.508 + name = name.substring(i+1);
167.509 + }
167.510 + ToolKind kind = ToolKind.UnknownTool;
167.511 + if (tool.equals("c")){ // NOI18N
167.512 + kind = ToolKind.CCompiler;
167.513 + } else if (tool.equals("cpp")){ // NOI18N
167.514 + kind = ToolKind.CCCompiler;
167.515 + } else if (tool.equals("fortran")){ // NOI18N
167.516 + kind = ToolKind.FortranCompiler;
167.517 + } else if (tool.equals("assembler")){ // NOI18N
167.518 + kind = ToolKind.Assembler;
167.519 + } else if (tool.equals("make")){ // NOI18N
167.520 + kind = ToolKind.MakeTool;
167.521 + } else if (tool.equals("debugger")){ // NOI18N
167.522 + kind = ToolKind.DebuggerTool;
167.523 + } else if (tool.equals("cmake")){ // NOI18N
167.524 + kind = ToolKind.CMakeTool;
167.525 + } else if (tool.equals("qmake")){ // NOI18N
167.526 + kind = ToolKind.QMakeTool;
167.527 + } else if (tool.equals("c(PATH)")){ // NOI18N
167.528 + cs.addPathCandidate(ToolKind.CCompiler, p);
167.529 + } else if (tool.equals("cpp(PATH)")){ // NOI18N
167.530 + cs.addPathCandidate(ToolKind.CCCompiler, p);
167.531 + } else if (tool.equals("fortran(PATH)")){ // NOI18N
167.532 + cs.addPathCandidate(ToolKind.FortranCompiler, p);
167.533 + } else if (tool.equals("assembler(PATH)")){ // NOI18N
167.534 + cs.addPathCandidate(ToolKind.Assembler, p);
167.535 + } else if (tool.equals("make(PATH)")){ // NOI18N
167.536 + cs.addPathCandidate(ToolKind.MakeTool, p);
167.537 + } else if (tool.equals("debugger(PATH)")){ // NOI18N
167.538 + cs.addPathCandidate(ToolKind.DebuggerTool, p);
167.539 + } else if (tool.equals("cmake(PATH)")){ // NOI18N
167.540 + cs.addPathCandidate(ToolKind.CMakeTool, p);
167.541 + } else if (tool.equals("qmake(PATH)")){ // NOI18N
167.542 + cs.addPathCandidate(ToolKind.QMakeTool, p);
167.543 + }
167.544 + if (kind != ToolKind.UnknownTool) {
167.545 + cs.addTool(executionEnvironment, name, p, kind);
167.546 + }
167.547 + }
167.548 + return cs;
167.549 + }
167.550 +
167.551 + /** Initialize remote CompilerSets */
167.552 + private synchronized void initRemoteCompilerSets(boolean connect, final boolean runCompilerSetDataLoader) {
167.553 +
167.554 + //if (log.isLoggable(Level.FINEST)) {
167.555 + // String text = String.format("\n\n---------- IRCS @%d remoteInitialization=%s state=%s writer=%b\n", //NOI18N
167.556 + // System.identityHashCode(this), remoteInitialization, state, CompilerSetReporter.canReport());
167.557 + // new Exception(text).printStackTrace();
167.558 + //}
167.559 +
167.560 + // NB: function itself is synchronized!
167.561 + if (state == State.STATE_COMPLETE) {
167.562 + return;
167.563 + }
167.564 + if (initializationTask != null) {
167.565 + return;
167.566 + }
167.567 + ServerRecord record = ServerList.get(executionEnvironment);
167.568 + assert record != null;
167.569 +
167.570 + log.log(Level.FINE, "CSM.initRemoteCompilerSets for {0} [{1}]", new Object[]{executionEnvironment, state}); // NOI18N
167.571 + final boolean wasOffline = record.isOffline();
167.572 + if (wasOffline) {
167.573 + CompilerSetReporter.report("CSM_Conn", false, executionEnvironment.getHost()); //NOI18N
167.574 + }
167.575 + record.validate(connect);
167.576 + if (record.isOnline()) {
167.577 + if (wasOffline) {
167.578 + CompilerSetReporter.report("CSM_Done"); //NOI18N
167.579 + }
167.580 + // NB: function itself is synchronized!
167.581 + initializationTask = RequestProcessor.getDefault().post(new Runnable() {
167.582 +
167.583 + @SuppressWarnings("unchecked")
167.584 + @Override
167.585 + public void run() {
167.586 + //if (log.isLoggable(Level.FINEST)) {
167.587 + // System.err.printf("\n\n###########\n###### %b @%d #######\n############\n\n",
167.588 + // CompilerSetReporter.canReport(),System.identityHashCode(CompilerSetManager.this));
167.589 + //}
167.590 + try {
167.591 + final CompilerSetProvider provider = CompilerSetProviderFactoryImpl.createNew(executionEnvironment);
167.592 + assert provider != null;
167.593 + provider.init();
167.594 + platform = provider.getPlatform();
167.595 + CompilerSetReporter.report("CSM_ValPlatf", true, PlatformTypes.toString(platform)); //NOI18N
167.596 + CompilerSetReporter.report("CSM_LFTC"); //NOI18N
167.597 + log.log(Level.FINE, "CSM.initRemoteCompileSets: platform = {0}", platform); // NOI18N
167.598 + CompilerSetPreferences.putEnv(executionEnvironment, platform);
167.599 + while (provider.hasMoreCompilerSets()) {
167.600 + String data = provider.getNextCompilerSetData();
167.601 + CompilerSet cs = parseCompilerSetString(platform, data);
167.602 + if (cs != null) {
167.603 + CompilerSetReporter.report("CSM_Found", true, cs.getDisplayName(), cs.getDirectory()); //NOI18N
167.604 + addUnsafe(cs);
167.605 + for (Tool tool : cs.getTools()) {
167.606 + if (! tool.isReady()) {
167.607 + CompilerSetReporter.report("CSM_Initializing_Tool", false, tool.getDisplayName()); //NOI18N
167.608 + tool.waitReady(true);
167.609 + CompilerSetReporter.report("CSM_Done"); //NOI18N
167.610 + }
167.611 + }
167.612 + } else if(CompilerSetReporter.canReport()) {
167.613 + CompilerSetReporter.report("CSM_Err", true, data);//NOI18N
167.614 + }
167.615 + }
167.616 + completeCompilerSets();
167.617 +
167.618 + log.log(Level.FINE, "CSM.initRemoteCompilerSets: Found {0} compiler sets", sets.size()); // NOI18N
167.619 + if (sets.isEmpty()) {
167.620 + CompilerSetReporter.report("CSM_Done_NF"); //NOI18N
167.621 + } else {
167.622 + CompilerSetReporter.report("CSM_Done_OK", true, sets.size());//NOI18N
167.623 + }
167.624 + // NB: function itself is synchronized!
167.625 + state = State.STATE_COMPLETE;
167.626 + CompilerSetReporter.report("CSM_Conigured");//NOI18N
167.627 + if (runCompilerSetDataLoader) {
167.628 + finishInitialization();
167.629 + }
167.630 + } catch (Throwable thr) {
167.631 + // otherwise STATE_PENDING hangs forever - see #158088
167.632 + // NB: function itself is synchronized!
167.633 + state = State.STATE_UNINITIALIZED; //STATE_ERROR;
167.634 + log.log(Level.FINE, "Error initiaizing compiler set @" + hashCode() + //NOI18N
167.635 + " on " + executionEnvironment, thr); //NOI18N
167.636 + CompilerSetReporter.report("CSM_Fail"); //NOI18N
167.637 + completeCompilerSets();
167.638 + }
167.639 + }
167.640 +
167.641 + });
167.642 + } else {
167.643 + CompilerSetReporter.report("CSM_Fail");//NOI18N
167.644 + // create empty CSM
167.645 + log.log(Level.FINE, "CSM.initRemoteCompilerSets: Adding empty CS to OFFLINE host {0}", executionEnvironment);
167.646 + completeCompilerSets();
167.647 + // NB: function itself is synchronized!
167.648 + state = State.STATE_UNINITIALIZED; //STATE_ERROR;
167.649 + }
167.650 + }
167.651 +
167.652 + @Override
167.653 + public void finishInitialization() {
167.654 + CompilerSetProvider provider = CompilerSetProviderFactoryImpl.createNew(executionEnvironment);
167.655 + List<CompilerSet> setsCopy = new ArrayList<CompilerSet>(sets);
167.656 + Runnable compilerSetDataLoader = provider.createCompilerSetDataLoader(setsCopy);
167.657 + CndUtils.assertFalse(compilerSetDataLoader == null);
167.658 + if (compilerSetDataLoader != null) {
167.659 + RequestProcessor.Task task = RequestProcessor.getDefault().create(compilerSetDataLoader);
167.660 + task.addTaskListener(new TaskListener() {
167.661 + @Override
167.662 + public void taskFinished(org.openide.util.Task task) {
167.663 + log.log(Level.FINE, "Code Model Ready for {0}", CompilerSetManagerImpl.this.toString());
167.664 + // FIXUP: this server has been probably deleted; TODO: provide return statis from loader
167.665 + if (!ServerList.get(executionEnvironment).isDeleted()) {
167.666 + CompilerSetManagerEvents.get(executionEnvironment).runTasks();
167.667 + }
167.668 + }
167.669 + });
167.670 + task.schedule(0);
167.671 + }
167.672 + }
167.673 +
167.674 + public void initCompilerSet(CompilerSet cs) {
167.675 + CompilerSetImpl impl = (CompilerSetImpl) cs;
167.676 + initCompilerSet(impl.getDirectory(), impl, false);
167.677 + completeCompilerSet(executionEnvironment, impl, sets);
167.678 + }
167.679 +
167.680 + private boolean initCompilerSet(String path, CompilerSetImpl cs, boolean known) {
167.681 + CompilerFlavor flavor = cs.getCompilerFlavor();
167.682 + ToolchainDescriptor d = flavor.getToolchainDescriptor();
167.683 + if (d != null && ToolchainManagerImpl.getImpl().isMyFolder(path, d, getPlatform(), known)) {
167.684 + CompilerDescriptor compiler = d.getC();
167.685 + if (compiler != null && !compiler.skipSearch()) {
167.686 + initCompiler(ToolKind.CCompiler, path, cs, compiler.getNames());
167.687 + }
167.688 + compiler = d.getCpp();
167.689 + if (compiler != null && !compiler.skipSearch()) {
167.690 + initCompiler(ToolKind.CCCompiler, path, cs, compiler.getNames());
167.691 + }
167.692 + compiler = d.getFortran();
167.693 + if (compiler != null && !compiler.skipSearch()) {
167.694 + initCompiler(ToolKind.FortranCompiler, path, cs, compiler.getNames());
167.695 + }
167.696 + compiler = d.getAssembler();
167.697 + if (compiler != null && !compiler.skipSearch()) {
167.698 + initCompiler(ToolKind.Assembler, path, cs, compiler.getNames());
167.699 + }
167.700 + if (d.getMake() != null && !d.getMake().skipSearch()){
167.701 + initCompiler(ToolKind.MakeTool, path, cs, d.getMake().getNames());
167.702 + }
167.703 + if (d.getDebugger() != null && !d.getDebugger().skipSearch()){
167.704 + initCompiler(ToolKind.DebuggerTool, path, cs, d.getDebugger().getNames());
167.705 + }
167.706 + if (d.getQMake() != null && !d.getQMake().skipSearch()){
167.707 + initCompiler(ToolKind.QMakeTool, path, cs, d.getQMake().getNames());
167.708 + }
167.709 + if (d.getCMake() != null && !d.getCMake().skipSearch()){
167.710 + initCompiler(ToolKind.CMakeTool, path, cs, d.getCMake().getNames());
167.711 + }
167.712 + return true;
167.713 + }
167.714 + return false;
167.715 + }
167.716 +
167.717 + private void initCompiler(ToolKindBase kind, String path, CompilerSetImpl cs, String[] names) {
167.718 + File dir = new File(path);
167.719 + if (cs.findTool(kind) != null) {
167.720 + // Only one tool of each kind in a cs
167.721 + return;
167.722 + }
167.723 + for (String name : names) {
167.724 + File file = new File(dir, name);
167.725 + if (file.exists() && !file.isDirectory()) {
167.726 + cs.addTool(executionEnvironment, name, file.getAbsolutePath(), kind);
167.727 + return;
167.728 + }
167.729 + file = new File(dir, name + ".exe"); // NOI18N
167.730 + if (file.exists() && !file.isDirectory()) {
167.731 + cs.addTool(executionEnvironment, name, file.getAbsolutePath(), kind);
167.732 + return;
167.733 + }
167.734 + File file2 = new File(dir, name + ".exe.lnk"); // NOI18N
167.735 + if (file2.exists() && !file2.isDirectory()) {
167.736 + cs.addTool(executionEnvironment, name, file.getAbsolutePath(), kind);
167.737 + return;
167.738 + }
167.739 + }
167.740 + }
167.741 +
167.742 + private void addFakeCompilerSets() {
167.743 + for (CompilerFlavor flavor : CompilerFlavorImpl.getFlavors(getPlatform())) {
167.744 + ToolchainDescriptor descriptor = flavor.getToolchainDescriptor();
167.745 + if (descriptor.getUpdateCenterUrl() != null && descriptor.getModuleID() != null) {
167.746 + boolean found = false;
167.747 + mainLoop:for (CompilerSet cs : sets) {
167.748 + for(String family : cs.getCompilerFlavor().getToolchainDescriptor().getFamily()){
167.749 + for(String f : flavor.getToolchainDescriptor().getFamily()){
167.750 + if (family.equals(f)) {
167.751 + found = true;
167.752 + break mainLoop;
167.753 + }
167.754 + }
167.755 + }
167.756 + }
167.757 + if (!found) {
167.758 + CompilerSetImpl fake = (CompilerSetImpl) CompilerSetFactory.getCustomCompilerSet(null, flavor, null);
167.759 + fake.setAutoGenerated(true);
167.760 + addUnsafe(fake);
167.761 + }
167.762 + }
167.763 + }
167.764 + }
167.765 +
167.766 + /**
167.767 + * If a compiler set doesn't have one of each compiler types, add a "No compiler"
167.768 + * tool. If selected, this will tell the build validation things are OK.
167.769 + */
167.770 + public void completeCompilerSets() {
167.771 + if (sets.isEmpty()) { // No compilers found
167.772 + addUnsafe(CompilerSetImpl.createEmptyCompilerSet(PlatformTypes.PLATFORM_NONE));
167.773 + }
167.774 + for (CompilerSet cs : sets) {
167.775 + completeCompilerSet(executionEnvironment, (CompilerSetImpl)cs, sets);
167.776 + }
167.777 + completeSunStudioCompilerSet(getPlatform());
167.778 + setDefaltCompilerSet();
167.779 + Collections.<CompilerSet>sort(sets, new Comparator<CompilerSet>(){
167.780 + @Override
167.781 + public int compare(CompilerSet o1, CompilerSet o2) {
167.782 + return o1.getCompilerFlavor().getToolchainDescriptor().getName().compareTo(o2.getCompilerFlavor().getToolchainDescriptor().getName());
167.783 + }
167.784 + });
167.785 + completeCompilerSetsSettings(false);
167.786 + }
167.787 +
167.788 + private void completeCompilerSetsSettings(boolean reset) {
167.789 + for (CompilerSet cs : sets) {
167.790 + for (Tool tool : cs.getTools()) {
167.791 + if (!tool.isReady()) {
167.792 + tool.waitReady(reset);
167.793 + }
167.794 + }
167.795 + }
167.796 + }
167.797 +
167.798 + private void completeSunStudioCompilerSet(int platform) {
167.799 + CompilerSetImpl bestCandidate = null;
167.800 + for(CompilerSet cs : sets) {
167.801 + if (((CompilerSetImpl)cs).isSunStudioDefault()){
167.802 + bestCandidate = (CompilerSetImpl) cs;
167.803 + break;
167.804 + }
167.805 + }
167.806 + // find 'best' Sun set and copy it
167.807 + CompilerSet sun = getCompilerSet("SunStudio"); // NOI18N
167.808 + if (sun != null) {
167.809 + return;
167.810 + }
167.811 + if (bestCandidate == null) {
167.812 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudio_12.2"); // NOI18N
167.813 + }
167.814 + if (bestCandidate == null) {
167.815 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudioExpress"); // NOI18N
167.816 + if (bestCandidate != null && bestCandidate.getCompilerFlavor().getToolchainDescriptor().getDisplayName().indexOf("Aten") < 0) { // NOI18N
167.817 + bestCandidate = null;
167.818 + }
167.819 + }
167.820 + if (bestCandidate == null) {
167.821 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudio_12.1"); // NOI18N
167.822 + }
167.823 + if (bestCandidate == null) {
167.824 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudioExpress"); // NOI18N
167.825 + }
167.826 + if (bestCandidate == null) {
167.827 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudioLite"); // NOI18N
167.828 + }
167.829 + if (bestCandidate == null) {
167.830 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudio_12"); // NOI18N
167.831 + }
167.832 + if (bestCandidate == null) {
167.833 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudio_11"); // NOI18N
167.834 + }
167.835 + if (bestCandidate == null) {
167.836 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudio_10"); // NOI18N
167.837 + }
167.838 + if (bestCandidate == null) {
167.839 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudio_9"); // NOI18N
167.840 + }
167.841 + if (bestCandidate == null) {
167.842 + bestCandidate = (CompilerSetImpl) getCompilerSet("SunStudio_8"); // NOI18N
167.843 + }
167.844 + if (bestCandidate == null) {
167.845 + return;
167.846 + }
167.847 + if (bestCandidate.isUrlPointer()) {
167.848 + return;
167.849 + }
167.850 + CompilerFlavor flavor = CompilerFlavorImpl.toFlavor("SunStudio", platform); // NOI18N
167.851 + if (flavor != null) { // #158084 NPE
167.852 + CompilerSetImpl bestCandidateCopy = bestCandidate.createCopy(
167.853 + flavor, bestCandidate.getDirectory(), "SunStudio", true); // NOI18N
167.854 + addUnsafe(bestCandidateCopy);
167.855 + }
167.856 + }
167.857 +
167.858 + private static Tool autoComplete(ExecutionEnvironment env, CompilerSetImpl cs, List<CompilerSet> sets, ToolDescriptor descriptor, ToolKindBase tool){
167.859 + if (descriptor != null && !cs.isUrlPointer()) {
167.860 + AlternativePath[] paths = descriptor.getAlternativePath();
167.861 + if (paths != null && paths.length > 0) {
167.862 + for(AlternativePath p : paths){
167.863 + switch(p.getKind()){
167.864 + case PATH:
167.865 + {
167.866 + StringTokenizer st = new StringTokenizer(p.getPath(),";,"); // NOI18N
167.867 + while(st.hasMoreTokens()){
167.868 + String method = st.nextToken();
167.869 + if ("$PATH".equals(method)){ // NOI18N
167.870 + if (env.isLocal()) {
167.871 + for(String name : descriptor.getNames()){
167.872 + String path = ToolUtils.findCommand(name);
167.873 + if (path != null) {
167.874 + if (notSkipedName(cs, descriptor, path, name)) {
167.875 + return cs.addNewTool(env, ToolUtils.getBaseName(path), path, tool);
167.876 + }
167.877 + }
167.878 + }
167.879 + } else {
167.880 + String path = cs.getPathCandidate(tool);
167.881 + if (path != null) {
167.882 + String name = ToolUtils.getBaseName(path);
167.883 + if (notSkipedName(cs, descriptor, path, name)) {
167.884 + return cs.addNewTool(env, name, path, tool);
167.885 + }
167.886 + }
167.887 + }
167.888 + } else if ("$MSYS".equals(method)){ // NOI18N
167.889 + if (env.isLocal()) {
167.890 + for(String name : descriptor.getNames()){
167.891 + String dir = CompilerSetUtils.getCommandFolder(cs.getCompilerFlavor().getToolchainDescriptor());
167.892 + if (dir != null) {
167.893 + String path = ToolUtils.findCommand(name, dir); // NOI18N
167.894 + if (path != null) {
167.895 + if (notSkipedName(cs, descriptor, path, name)) {
167.896 + return cs.addNewTool(env, ToolUtils.getBaseName(path), path, tool);
167.897 + }
167.898 + }
167.899 + }
167.900 + }
167.901 + } else {
167.902 + // TODO
167.903 + }
167.904 + } else {
167.905 + if (env.isLocal()) {
167.906 + for(String name : descriptor.getNames()){
167.907 + String path = ToolUtils.findCommand(name, method);
167.908 + if (path != null) {
167.909 + return cs.addNewTool(env, ToolUtils.getBaseName(path), path, tool);
167.910 + }
167.911 + }
167.912 + } else {
167.913 + // TODO
167.914 + }
167.915 + }
167.916 + }
167.917 + break;
167.918 + }
167.919 + case TOOL_FAMILY:
167.920 + {
167.921 + StringTokenizer st = new StringTokenizer(p.getPath(),";,"); // NOI18N
167.922 + while(st.hasMoreTokens()){
167.923 + String method = st.nextToken();
167.924 + for(CompilerSet s : sets){
167.925 + if (s != cs) {
167.926 + for(String family : s.getCompilerFlavor().getToolchainDescriptor().getFamily()){
167.927 + if (family.equals(method)){
167.928 + Tool other = s.findTool(tool);
167.929 + if (other != null){
167.930 + return cs.addNewTool(env, other.getName(), other.getPath(), tool);
167.931 + }
167.932 + }
167.933 + }
167.934 + }
167.935 + }
167.936 + }
167.937 + break;
167.938 + }
167.939 + case TOOL_NAME:
167.940 + {
167.941 + StringTokenizer st = new StringTokenizer(p.getPath(),";,"); // NOI18N
167.942 + while(st.hasMoreTokens()){
167.943 + String method = st.nextToken();
167.944 + for(CompilerSet s : sets){
167.945 + if (s != cs) {
167.946 + String name = s.getCompilerFlavor().getToolchainDescriptor().getName();
167.947 + if (name.equals(method) || "*".equals(method)){ // NOI18N
167.948 + Tool other = s.findTool(tool);
167.949 + if (other != null){
167.950 + return cs.addNewTool(env, other.getName(), other.getPath(), tool);
167.951 + }
167.952 + }
167.953 + }
167.954 + }
167.955 + }
167.956 + break;
167.957 + }
167.958 + }
167.959 + }
167.960 + }
167.961 + }
167.962 + return cs.addTool(env, "", "", tool); // NOI18N
167.963 + }
167.964 +
167.965 + private static boolean notSkipedName(CompilerSet cs, ToolDescriptor descriptor, String path, String name){
167.966 + if (!descriptor.skipSearch()) {
167.967 + return true;
167.968 + }
167.969 + String s = cs.getDirectory()+"/"+name; // NOI18N
167.970 + s = s.replaceAll("\\\\", "/"); // NOI18N
167.971 + path = path.replaceAll("\\\\", "/"); // NOI18N
167.972 + return !path.startsWith(s);
167.973 + }
167.974 +
167.975 + /*package-local*/ static void completeCompilerSet(ExecutionEnvironment env, CompilerSetImpl cs, List<CompilerSet> sets) {
167.976 + //if (cs.findTool(Tool.CCompiler) == null && cs.findTool(Tool.CCCompiler) == null) {
167.977 + // // do not complete empty tool
167.978 + // return;
167.979 + //}
167.980 + if (cs.findTool(ToolKind.CCompiler) == null) {
167.981 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getC(), ToolKind.CCompiler);
167.982 + }
167.983 + if (cs.findTool(ToolKind.CCCompiler) == null) {
167.984 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getCpp(), ToolKind.CCCompiler);
167.985 + }
167.986 + if (cs.findTool(ToolKind.FortranCompiler) == null) {
167.987 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getFortran(), ToolKind.FortranCompiler);
167.988 + }
167.989 + if (cs.findTool(ToolKind.Assembler) == null) {
167.990 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getAssembler(), ToolKind.Assembler);
167.991 + }
167.992 + if (cs.findTool(ToolKind.MakeTool) == null) {
167.993 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getMake(), ToolKind.MakeTool);
167.994 + }
167.995 + if (cs.findTool(ToolKind.DebuggerTool) == null) {
167.996 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getDebugger(), ToolKind.DebuggerTool);
167.997 + }
167.998 + if (cs.findTool(ToolKind.QMakeTool) == null) {
167.999 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getQMake(), ToolKind.QMakeTool);
167.1000 + }
167.1001 + if (cs.findTool(ToolKind.CMakeTool) == null) {
167.1002 + autoComplete(env, cs, sets, cs.getCompilerFlavor().getToolchainDescriptor().getCMake(), ToolKind.CMakeTool);
167.1003 + }
167.1004 + }
167.1005 +
167.1006 + /**
167.1007 + * Add a CompilerSet to this CompilerSetManager. Make sure it doesn't get added multiple times.
167.1008 + *
167.1009 + * @param cs The CompilerSet to (possibly) add
167.1010 + */
167.1011 + @Override
167.1012 + public void add(CompilerSet cs) {
167.1013 + if (sets.size() == 1 && sets.get(0).getName().equals(CompilerSetImpl.None)) {
167.1014 + sets.remove(0);
167.1015 + }
167.1016 + sets.add(cs);
167.1017 + if (sets.size() == 1) {
167.1018 + setDefault(cs);
167.1019 + }
167.1020 + completeCompilerSets();
167.1021 + }
167.1022 +
167.1023 + private void addUnsafe(CompilerSet cs) {
167.1024 + if (sets.size() == 1 && sets.get(0).getName().equals(CompilerSetImpl.None)) {
167.1025 + sets.remove(0);
167.1026 + }
167.1027 + sets.add(cs);
167.1028 + }
167.1029 +
167.1030 + @Override
167.1031 + public final boolean isEmpty() {
167.1032 + if ((sets.isEmpty()) ||
167.1033 + (sets.size() == 1 && sets.get(0).getName().equals(CompilerSetImpl.None))) {
167.1034 + return true;
167.1035 + }
167.1036 + return false;
167.1037 + }
167.1038 +
167.1039 + /**
167.1040 + * Remove a CompilerSet from this CompilerSetManager. Use caution with this method. Its primary
167.1041 + * use is to remove temporary CompilerSets which were added to represent missing compiler sets. In
167.1042 + * that context, they're removed immediately after showing the ToolsPanel after project open.
167.1043 + *
167.1044 + * @param cs The CompilerSet to (possibly) remove
167.1045 + */
167.1046 + @Override
167.1047 + public void remove(CompilerSet cs) {
167.1048 + int idx = sets.indexOf(cs);
167.1049 + if (idx >= 0) {
167.1050 + sets.remove(idx);
167.1051 + }
167.1052 + }
167.1053 +
167.1054 + @Override
167.1055 + public CompilerSet getCompilerSet(CompilerFlavor flavor) {
167.1056 + return getCompilerSet(flavor.toString());
167.1057 + }
167.1058 +
167.1059 + @Override
167.1060 + public CompilerSet getCompilerSet(String name) {
167.1061 + for (CompilerSet cs : sets) {
167.1062 + if (cs.getName().equals(name)) {
167.1063 + return cs;
167.1064 + }
167.1065 + }
167.1066 + return null;
167.1067 + }
167.1068 +
167.1069 + @Override
167.1070 + public CompilerSet getCompilerSet(int idx) {
167.1071 + //waitForCompletion();
167.1072 + if (isPending()) {
167.1073 + log.log(Level.WARNING, "calling getCompilerSet() on uninitializad {0}", getClass().getSimpleName());
167.1074 + }
167.1075 + if (idx >= 0 && idx < sets.size()) {
167.1076 + return sets.get(idx);
167.1077 + }
167.1078 + return null;
167.1079 + }
167.1080 +
167.1081 + @Override
167.1082 + public List<CompilerSet> getCompilerSets() {
167.1083 + return new ArrayList<CompilerSet>(sets);
167.1084 + }
167.1085 +
167.1086 + @Override
167.1087 + public List<String> getCompilerSetNames() {
167.1088 + List<String> names = new ArrayList<String>();
167.1089 + for (CompilerSet cs : getCompilerSets()) {
167.1090 + names.add(cs.getName());
167.1091 + }
167.1092 + return names;
167.1093 + }
167.1094 +
167.1095 + @Override
167.1096 + public void setDefault(CompilerSet newDefault) {
167.1097 + boolean set = false;
167.1098 + for (CompilerSet cs : getCompilerSets()) {
167.1099 + ((CompilerSetImpl)cs).setAsDefault(false);
167.1100 + if (cs == newDefault) {
167.1101 + ((CompilerSetImpl)newDefault).setAsDefault(true);
167.1102 + set = true;
167.1103 + }
167.1104 + }
167.1105 + if (!set && sets.size() > 0) {
167.1106 + ((CompilerSetImpl)getCompilerSet(0)).setAsDefault(true);
167.1107 + }
167.1108 + }
167.1109 +
167.1110 + @Override
167.1111 + public CompilerSet getDefaultCompilerSet() {
167.1112 + for (CompilerSet cs : getCompilerSets()) {
167.1113 + if (((CompilerSetImpl)cs).isDefault()) {
167.1114 + return cs;
167.1115 + }
167.1116 + }
167.1117 + return null;
167.1118 + }
167.1119 +
167.1120 + @Override
167.1121 + public boolean isDefaultCompilerSet(CompilerSet cs) {
167.1122 + if (cs == null) {
167.1123 + return false;
167.1124 + }
167.1125 + return ((CompilerSetImpl)cs).isDefault();
167.1126 + }
167.1127 +
167.1128 + @Override
167.1129 + public String toString() {
167.1130 + StringBuilder out = new StringBuilder();
167.1131 + out.append("CSM for ").append(executionEnvironment.toString()); // NOI18N
167.1132 + out.append(" with toolchains:["); // NOI18N
167.1133 + for (CompilerSet compilerSet : sets) {
167.1134 + out.append(compilerSet.getName()).append(" "); // NOI18N
167.1135 + }
167.1136 + out.append("]"); // NOI18N
167.1137 + out.append(" platform:").append(PlatformTypes.toString(platform)); // NOI18N
167.1138 + out.append(" in state ").append(state.toString()); // NOI18N
167.1139 + return out.toString();
167.1140 + }
167.1141 +
167.1142 + @Override
167.1143 + public ExecutionEnvironment getExecutionEnvironment() {
167.1144 + return executionEnvironment;
167.1145 + }
167.1146 +
167.1147 + private static enum State {
167.1148 + STATE_PENDING,
167.1149 + STATE_COMPLETE,
167.1150 + STATE_UNINITIALIZED
167.1151 + }
167.1152 +
167.1153 + private static final class FolderDescriptor {
167.1154 + private final String path;
167.1155 + private final boolean knownFolder;
167.1156 + private FolderDescriptor(String path, boolean knownFolder){
167.1157 + this.path = path;
167.1158 + this.knownFolder = knownFolder;
167.1159 + }
167.1160 +
167.1161 + @Override
167.1162 + public int hashCode() {
167.1163 + return path.hashCode();
167.1164 + }
167.1165 +
167.1166 + @Override
167.1167 + public boolean equals(Object obj) {
167.1168 + if (obj instanceof FolderDescriptor) {
167.1169 + return path.equals(((FolderDescriptor)obj).path);
167.1170 + }
167.1171 + return false;
167.1172 + }
167.1173 + }
167.1174 +}
168.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
168.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/CompilerSetPreferences.java Mon Feb 01 12:24:26 2010 +0100
168.3 @@ -0,0 +1,253 @@
168.4 +/*
168.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
168.6 + *
168.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
168.8 + *
168.9 + * The contents of this file are subject to the terms of either the GNU
168.10 + * General Public License Version 2 only ("GPL") or the Common
168.11 + * Development and Distribution License("CDDL") (collectively, the
168.12 + * "License"). You may not use this file except in compliance with the
168.13 + * License. You can obtain a copy of the License at
168.14 + * http://www.netbeans.org/cddl-gplv2.html
168.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
168.16 + * specific language governing permissions and limitations under the
168.17 + * License. When distributing the software, include this License Header
168.18 + * Notice in each file and include the License file at
168.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
168.20 + * particular file as subject to the "Classpath" exception as provided
168.21 + * by Sun in the GPL Version 2 section of the License file that
168.22 + * accompanied this code. If applicable, add the following below the
168.23 + * License Header, with the fields enclosed by brackets [] replaced by
168.24 + * your own identifying information:
168.25 + * "Portions Copyrighted [year] [name of copyright owner]"
168.26 + *
168.27 + * If you wish your version of this file to be governed by only the CDDL
168.28 + * or only the GPL Version 2, indicate your decision by adding
168.29 + * "[Contributor] elects to include this software in this distribution
168.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
168.31 + * single choice of license, a recipient has the option to distribute
168.32 + * your version of this file under either the CDDL, the GPL Version 2 or
168.33 + * to extend the choice of license to its licensees as provided above.
168.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
168.35 + * Version 2 license, then the option applies only if the new code is
168.36 + * made subject to such option by the copyright holder.
168.37 + *
168.38 + * Contributor(s):
168.39 + *
168.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
168.41 + */
168.42 +
168.43 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
168.44 +
168.45 +import java.util.ArrayList;
168.46 +import java.util.List;
168.47 +import java.util.prefs.BackingStoreException;
168.48 +import java.util.prefs.Preferences;
168.49 +import org.netbeans.modules.cnd.toolchain.api.Tool;
168.50 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
168.51 +import org.netbeans.modules.cnd.toolchain.spi.CompilerProvider;
168.52 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
168.53 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
168.54 +import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
168.55 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
168.56 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
168.57 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
168.58 +import org.openide.util.Exceptions;
168.59 +import org.openide.util.NbPreferences;
168.60 +
168.61 +/**
168.62 + *
168.63 + * @author Alexander Simon
168.64 + */
168.65 +public final class CompilerSetPreferences {
168.66 + /* Persistance information */
168.67 + private static final double csm_version = 1.1;
168.68 + private static final String CSM = "csm."; // NOI18N
168.69 + private static final String VERSION = "version"; // NOI18N
168.70 + private static final String NO_SETS = ".noOfSets"; // NOI18N
168.71 + private static final String SET_NAME = ".setName."; // NOI18N
168.72 + private static final String SET_FLAVOR = ".setFlavor."; // NOI18N
168.73 + private static final String SET_DIRECTORY = ".setDirectory."; // NOI18N
168.74 + private static final String SET_AUTO = ".autoGenerated."; // NOI18N
168.75 + private static final String SET_DEFAULT = ".defaultSet"; // NOI18N
168.76 + private static final String SET_PLATFORM = ".setPlatform."; // NOI18N
168.77 + private static final String NO_TOOLS = ".noOfTools."; // NOI18N
168.78 + private static final String TOOL_NAME = ".toolName."; // NOI18N
168.79 + private static final String TOOL_DISPLAYNAME = ".toolDisplayName."; // NOI18N
168.80 + private static final String TOOL_KIND = ".toolKind."; // NOI18N
168.81 + private static final String TOOL_PATH = ".toolPath."; // NOI18N
168.82 + private static final String TOOL_FLAVOR = ".toolFlavor."; // NOI18N
168.83 +
168.84 + private static CompilerProvider compilerProvider = null;
168.85 +
168.86 + private CompilerSetPreferences() {
168.87 + }
168.88 +
168.89 + /*
168.90 + * Persistence ...
168.91 + */
168.92 + public static Preferences getPreferences() {
168.93 + return NbPreferences.forModule(CompilerSetPreferences.class);
168.94 + }
168.95 +
168.96 + public static void putEnv(ExecutionEnvironment executionEnvironment, int platform){
168.97 + getPreferences().putInt(CSM + ExecutionEnvironmentFactory.toUniqueID(executionEnvironment) + SET_PLATFORM, platform);
168.98 + }
168.99 +
168.100 + public static void clearPersistence() {
168.101 + try {
168.102 + getPreferences().clear();
168.103 + } catch (BackingStoreException ex) {
168.104 + Exceptions.printStackTrace(ex);
168.105 + }
168.106 + }
168.107 +
168.108 + public static void saveToDisk(CompilerSetManager manager) {
168.109 + if (!manager.getCompilerSets().isEmpty()) {
168.110 + getPreferences().putDouble(CSM + VERSION, csm_version);
168.111 + String executionEnvironmentKey = ExecutionEnvironmentFactory.toUniqueID(manager.getExecutionEnvironment());
168.112 + getPreferences().putInt(CSM + executionEnvironmentKey + NO_SETS, manager.getCompilerSets().size());
168.113 + getPreferences().putInt(CSM + executionEnvironmentKey + SET_PLATFORM, manager.getPlatform());
168.114 + int setCount = 0;
168.115 + for (CompilerSet cs : manager.getCompilerSets()) {
168.116 + getPreferences().put(CSM + executionEnvironmentKey + SET_NAME + setCount, cs.getName());
168.117 + getPreferences().put(CSM + executionEnvironmentKey + SET_FLAVOR + setCount, cs.getCompilerFlavor().toString());
168.118 + getPreferences().put(CSM + executionEnvironmentKey + SET_DIRECTORY + setCount, cs.getDirectory());
168.119 + getPreferences().putBoolean(CSM + executionEnvironmentKey + SET_AUTO + setCount, cs.isAutoGenerated());
168.120 + getPreferences().putBoolean(CSM + executionEnvironmentKey + SET_DEFAULT + setCount, manager.isDefaultCompilerSet(cs));
168.121 + List<Tool> tools = cs.getTools();
168.122 + getPreferences().putInt(CSM + executionEnvironmentKey + NO_TOOLS + setCount, tools.size());
168.123 + int toolCount = 0;
168.124 + for (Tool tool : tools) {
168.125 + getPreferences().put(CSM + executionEnvironmentKey + TOOL_NAME + setCount + '.' + toolCount, tool.getName());
168.126 + getPreferences().put(CSM + executionEnvironmentKey + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount, tool.getDisplayName());
168.127 + getPreferences().putInt(CSM + executionEnvironmentKey + TOOL_KIND + setCount + '.' + toolCount, tool.getKind().ordinal());
168.128 + getPreferences().put(CSM + executionEnvironmentKey + TOOL_PATH + setCount + '.' + toolCount, tool.getPath());
168.129 + getPreferences().put(CSM + executionEnvironmentKey + TOOL_FLAVOR + setCount + '.' + toolCount, tool.getFlavor().toString());
168.130 + toolCount++;
168.131 + }
168.132 + setCount++;
168.133 + }
168.134 + }
168.135 + }
168.136 +
168.137 + public static CompilerSetManagerImpl restoreFromDisk(ExecutionEnvironment env) {
168.138 + double version = getPreferences().getDouble(CSM + VERSION, 1.0);
168.139 + if (version == 1.0 && env.isLocal()) {
168.140 + return restoreFromDisk10();
168.141 + }
168.142 + String executionEnvironmentKey = ExecutionEnvironmentFactory.toUniqueID(env);
168.143 + int noSets = getPreferences().getInt(CSM + executionEnvironmentKey + NO_SETS, -1);
168.144 + if (noSets < 0) {
168.145 + return null;
168.146 + }
168.147 + int pform = getPreferences().getInt(CSM + executionEnvironmentKey + SET_PLATFORM, -1);
168.148 + if (pform < 0) {
168.149 + if (env.isLocal()) {
168.150 + pform = ToolUtils.computeLocalPlatform();
168.151 + }
168.152 + }
168.153 +
168.154 + ArrayList<CompilerSet> css = new ArrayList<CompilerSet>();
168.155 + for (int setCount = 0; setCount < noSets; setCount++) {
168.156 + String setName = getPreferences().get(CSM + executionEnvironmentKey + SET_NAME + setCount, null);
168.157 + String setFlavorName = getPreferences().get(CSM + executionEnvironmentKey + SET_FLAVOR + setCount, null);
168.158 + CompilerFlavor flavor = null;
168.159 + if (setFlavorName != null) {
168.160 + flavor = CompilerFlavorImpl.toFlavor(setFlavorName, pform);
168.161 + }
168.162 + String setDirectory = getPreferences().get(CSM + executionEnvironmentKey + SET_DIRECTORY + setCount, null);
168.163 + if (setName == null || setFlavorName == null || flavor == null) {
168.164 + // FIXUP: error
168.165 + continue;
168.166 + }
168.167 + Boolean auto = getPreferences().getBoolean(CSM + executionEnvironmentKey + SET_AUTO + setCount, false);
168.168 + Boolean isDefault = getPreferences().getBoolean(CSM + executionEnvironmentKey + SET_DEFAULT + setCount, false);
168.169 + CompilerSetImpl cs = new CompilerSetImpl(flavor, setDirectory, setName);
168.170 + cs.setAutoGenerated(auto);
168.171 + cs.setAsDefault(isDefault);
168.172 + int noTools = getPreferences().getInt(CSM + executionEnvironmentKey + NO_TOOLS + setCount, -1);
168.173 + for (int toolCount = 0; toolCount < noTools; toolCount++) {
168.174 + String toolName = getPreferences().get(CSM + executionEnvironmentKey + TOOL_NAME + setCount + '.' + toolCount, null);
168.175 + String toolDisplayName = getPreferences().get(CSM + executionEnvironmentKey + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount, null);
168.176 + int toolKind = getPreferences().getInt(CSM + executionEnvironmentKey + TOOL_KIND + setCount + '.' + toolCount, -1);
168.177 + String toolPath = getPreferences().get(CSM + executionEnvironmentKey + TOOL_PATH + setCount + '.' + toolCount, null);
168.178 + String toolFlavorName = getPreferences().get(CSM + executionEnvironmentKey + TOOL_FLAVOR + setCount + '.' + toolCount, null);
168.179 + CompilerFlavor toolFlavor = null;
168.180 + if (toolFlavorName != null) {
168.181 + toolFlavor = CompilerFlavorImpl.toFlavor(toolFlavorName, pform);
168.182 + }
168.183 + Tool tool = CompilerSetPreferences.getCompilerProvider().createCompiler(env, toolFlavor, ToolKind.getTool(toolKind), "", toolDisplayName, toolPath);
168.184 + tool.setName(toolName);
168.185 + cs.addTool(tool);
168.186 + }
168.187 + css.add(cs);
168.188 + }
168.189 +
168.190 + CompilerSetManagerImpl csm = new CompilerSetManagerImpl(env, css, pform);
168.191 + return csm;
168.192 + }
168.193 +
168.194 + private static CompilerSetManagerImpl restoreFromDisk10() {
168.195 + int noSets = getPreferences().getInt(CSM + NO_SETS, -1);
168.196 + if (noSets < 0) {
168.197 + return null;
168.198 + }
168.199 +
168.200 + ArrayList<CompilerSet> css = new ArrayList<CompilerSet>();
168.201 + getPreferences().remove(CSM + NO_SETS);
168.202 + for (int setCount = 0; setCount < noSets; setCount++) {
168.203 + String setName = getPreferences().get(CSM + SET_NAME + setCount, null);
168.204 + getPreferences().remove(CSM + SET_NAME + setCount);
168.205 + String setFlavorName = getPreferences().get(CSM + SET_FLAVOR + setCount, null);
168.206 + getPreferences().remove(CSM + SET_FLAVOR + setCount);
168.207 + CompilerFlavor flavor = null;
168.208 + if (setFlavorName != null) {
168.209 + flavor = CompilerFlavorImpl.toFlavor(setFlavorName, PlatformTypes.getDefaultPlatform());
168.210 + }
168.211 + String setDirectory = getPreferences().get(CSM + SET_DIRECTORY + setCount, null);
168.212 + getPreferences().remove(CSM + SET_DIRECTORY + setCount);
168.213 + if (setName == null || setFlavorName == null || flavor == null) {
168.214 + // FIXUP: error
168.215 + continue;
168.216 + }
168.217 + Boolean auto = getPreferences().getBoolean(CSM + SET_AUTO + setCount, false);
168.218 + getPreferences().remove(CSM + SET_AUTO + setCount);
168.219 + CompilerSetImpl cs = new CompilerSetImpl(flavor, setDirectory, setName);
168.220 + cs.setAutoGenerated(auto);
168.221 + int noTools = getPreferences().getInt(CSM + NO_TOOLS + setCount, -1);
168.222 + getPreferences().remove(CSM + NO_TOOLS + setCount);
168.223 + for (int toolCount = 0; toolCount < noTools; toolCount++) {
168.224 + String toolName = getPreferences().get(CSM + TOOL_NAME + setCount + '.' + toolCount, null);
168.225 + String toolDisplayName = getPreferences().get(CSM + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount, null);
168.226 + int toolKind = getPreferences().getInt(CSM + TOOL_KIND + setCount + '.' + toolCount, -1);
168.227 + String toolPath = getPreferences().get(CSM + TOOL_PATH + setCount + '.' + toolCount, null);
168.228 + String toolFlavorName = getPreferences().get(CSM + TOOL_FLAVOR + setCount + '.' + toolCount, null);
168.229 + getPreferences().remove(CSM + TOOL_NAME + setCount + '.' + toolCount);
168.230 + getPreferences().remove(CSM + TOOL_DISPLAYNAME + '-' + setCount + '.' + toolCount);
168.231 + getPreferences().remove(CSM + TOOL_KIND + setCount + '.' + toolCount);
168.232 + getPreferences().remove(CSM + TOOL_PATH + setCount + '.' + toolCount);
168.233 + getPreferences().remove(CSM + TOOL_FLAVOR + setCount + '.' + toolCount);
168.234 + CompilerFlavor toolFlavor = null;
168.235 + if (toolFlavorName != null) {
168.236 + toolFlavor = CompilerFlavorImpl.toFlavor(toolFlavorName, PlatformTypes.getDefaultPlatform());
168.237 + }
168.238 + Tool tool = CompilerSetPreferences.getCompilerProvider().createCompiler(ExecutionEnvironmentFactory.getLocal(),
168.239 + toolFlavor, ToolKind.getTool(toolKind), "", toolDisplayName, toolPath); //NOI18N
168.240 + tool.setName(toolName);
168.241 + (cs).addTool(tool);
168.242 + }
168.243 + CompilerSetManagerImpl.completeCompilerSet(ExecutionEnvironmentFactory.getLocal(), cs, css);
168.244 + css.add(cs);
168.245 + }
168.246 + CompilerSetManagerImpl csm = new CompilerSetManagerImpl(ExecutionEnvironmentFactory.getLocal(), css, ToolUtils.computeLocalPlatform());
168.247 + return csm;
168.248 + }
168.249 +
168.250 + public static CompilerProvider getCompilerProvider() {
168.251 + if (compilerProvider == null) {
168.252 + compilerProvider = CompilerProvider.getInstance();
168.253 + }
168.254 + return compilerProvider;
168.255 + }
168.256 +}
169.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
169.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/CompilerSetProviderFactoryImpl.java Mon Feb 01 12:24:26 2010 +0100
169.3 @@ -0,0 +1,68 @@
169.4 +/*
169.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
169.6 + *
169.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
169.8 + *
169.9 + * The contents of this file are subject to the terms of either the GNU
169.10 + * General Public License Version 2 only ("GPL") or the Common
169.11 + * Development and Distribution License("CDDL") (collectively, the
169.12 + * "License"). You may not use this file except in compliance with the
169.13 + * License. You can obtain a copy of the License at
169.14 + * http://www.netbeans.org/cddl-gplv2.html
169.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
169.16 + * specific language governing permissions and limitations under the
169.17 + * License. When distributing the software, include this License Header
169.18 + * Notice in each file and include the License file at
169.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
169.20 + * particular file as subject to the "Classpath" exception as provided
169.21 + * by Sun in the GPL Version 2 section of the License file that
169.22 + * accompanied this code. If applicable, add the following below the
169.23 + * License Header, with the fields enclosed by brackets [] replaced by
169.24 + * your own identifying information:
169.25 + * "Portions Copyrighted [year] [name of copyright owner]"
169.26 + *
169.27 + * If you wish your version of this file to be governed by only the CDDL
169.28 + * or only the GPL Version 2, indicate your decision by adding
169.29 + * "[Contributor] elects to include this software in this distribution
169.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
169.31 + * single choice of license, a recipient has the option to distribute
169.32 + * your version of this file under either the CDDL, the GPL Version 2 or
169.33 + * to extend the choice of license to its licensees as provided above.
169.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
169.35 + * Version 2 license, then the option applies only if the new code is
169.36 + * made subject to such option by the copyright holder.
169.37 + *
169.38 + * Contributor(s):
169.39 + *
169.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
169.41 + */
169.42 +
169.43 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
169.44 +
169.45 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProvider;
169.46 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetProviderFactory;
169.47 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
169.48 +import org.openide.util.Lookup;
169.49 +
169.50 +/**
169.51 + * An factory for creation CompilerSetProvider instances
169.52 + * @author Vladimir Kvashin
169.53 + */
169.54 +public class CompilerSetProviderFactoryImpl {
169.55 + /**
169.56 + * Creates a new instance of CompilerSetProvider
169.57 + * for the given execution environment
169.58 + * @param execEnv execution environment to create CompilerSetProvider for
169.59 + * @return new CompilerSetProvider instance
169.60 + */
169.61 + public static CompilerSetProvider createNew(ExecutionEnvironment execEnv) {
169.62 + CompilerSetProviderFactory factory = Lookup.getDefault().lookup(CompilerSetProviderFactory.class);
169.63 + if (factory == null) {
169.64 + throw new IllegalStateException(CompilerSetProviderFactory.class.getName() +" not found in lookup"); //NOI18N
169.65 + }
169.66 + return factory.createNew(execEnv);
169.67 + }
169.68 +
169.69 + private CompilerSetProviderFactoryImpl() {
169.70 + }
169.71 +}
170.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
170.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/CompilerSetReporter.java Mon Feb 01 12:24:26 2010 +0100
170.3 @@ -0,0 +1,91 @@
170.4 +/*
170.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
170.6 + *
170.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
170.8 + *
170.9 + * The contents of this file are subject to the terms of either the GNU
170.10 + * General Public License Version 2 only ("GPL") or the Common
170.11 + * Development and Distribution License("CDDL") (collectively, the
170.12 + * "License"). You may not use this file except in compliance with the
170.13 + * License. You can obtain a copy of the License at
170.14 + * http://www.netbeans.org/cddl-gplv2.html
170.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
170.16 + * specific language governing permissions and limitations under the
170.17 + * License. When distributing the software, include this License Header
170.18 + * Notice in each file and include the License file at
170.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
170.20 + * particular file as subject to the "Classpath" exception as provided
170.21 + * by Sun in the GPL Version 2 section of the License file that
170.22 + * accompanied this code. If applicable, add the following below the
170.23 + * License Header, with the fields enclosed by brackets [] replaced by
170.24 + * your own identifying information:
170.25 + * "Portions Copyrighted [year] [name of copyright owner]"
170.26 + *
170.27 + * If you wish your version of this file to be governed by only the CDDL
170.28 + * or only the GPL Version 2, indicate your decision by adding
170.29 + * "[Contributor] elects to include this software in this distribution
170.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
170.31 + * single choice of license, a recipient has the option to distribute
170.32 + * your version of this file under either the CDDL, the GPL Version 2 or
170.33 + * to extend the choice of license to its licensees as provided above.
170.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
170.35 + * Version 2 license, then the option applies only if the new code is
170.36 + * made subject to such option by the copyright holder.
170.37 + *
170.38 + * Contributor(s):
170.39 + *
170.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
170.41 + */
170.42 +
170.43 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
170.44 +
170.45 +import java.io.IOException;
170.46 +import java.io.Writer;
170.47 +import org.openide.util.NbBundle;
170.48 +
170.49 +/**
170.50 + * Sometimes we need to make process of setting up compiler set verbose.
170.51 + * This class allows to plug in a writer to report the process of
170.52 + * compiler set setup to
170.53 + * @author Vladimir Kvashin
170.54 + */
170.55 +public class CompilerSetReporter {
170.56 +
170.57 + private static Writer writer;
170.58 +
170.59 + private CompilerSetReporter() {
170.60 + }
170.61 +
170.62 + /**
170.63 + * Sets a writer to report the process of compiler set setup to
170.64 + * @param writer if null, no reporting occurs
170.65 + */
170.66 + public static synchronized void setWriter(Writer writer) {
170.67 + CompilerSetReporter.writer = writer;
170.68 + }
170.69 +
170.70 + /* package-local */
170.71 + public static void report(String msgKey) {
170.72 + report(msgKey, true);
170.73 + }
170.74 +
170.75 + /* package-local */
170.76 + public static synchronized void report(String msgKey, boolean addLineFeed, Object... params) {
170.77 + if (writer != null) {
170.78 + try {
170.79 + writer.write(NbBundle.getMessage(CompilerSetReporter.class, msgKey, params));
170.80 + if (addLineFeed) {
170.81 + writer.write('\n');
170.82 + }
170.83 + writer.flush();
170.84 + } catch (IOException ex) {
170.85 + }
170.86 + }
170.87 + }
170.88 +
170.89 + /* package-local */
170.90 + public static boolean canReport() {
170.91 + return writer != null;
170.92 + }
170.93 +
170.94 +}
171.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
171.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/NoCompilersPanel.form Mon Feb 01 12:24:26 2010 +0100
171.3 @@ -0,0 +1,53 @@
171.4 +<?xml version="1.0" encoding="UTF-8" ?>
171.5 +
171.6 +<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
171.7 + <AuxValues>
171.8 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
171.9 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
171.10 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
171.11 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
171.12 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
171.13 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
171.14 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
171.15 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
171.16 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
171.17 + </AuxValues>
171.18 +
171.19 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
171.20 + <SubComponents>
171.21 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
171.22 + <Properties>
171.23 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
171.24 + <Border info="null"/>
171.25 + </Property>
171.26 + </Properties>
171.27 + <AuxValues>
171.28 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
171.29 + </AuxValues>
171.30 + <Constraints>
171.31 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
171.32 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="20" insetsLeft="20" insetsBottom="20" insetsRight="20" anchor="10" weightX="1.0" weightY="1.0"/>
171.33 + </Constraint>
171.34 + </Constraints>
171.35 +
171.36 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
171.37 + <SubComponents>
171.38 + <Component class="javax.swing.JTextArea" name="textArea">
171.39 + <Properties>
171.40 + <Property name="columns" type="int" value="20"/>
171.41 + <Property name="editable" type="boolean" value="false"/>
171.42 + <Property name="lineWrap" type="boolean" value="true"/>
171.43 + <Property name="rows" type="int" value="5"/>
171.44 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
171.45 + <ResourceString bundle="org/netbeans/modules/cnd/toolchain/api/Bundle.properties" key="NO_COMPILERS_FOUND_MSG" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
171.46 + </Property>
171.47 + <Property name="wrapStyleWord" type="boolean" value="true"/>
171.48 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
171.49 + <Border info="null"/>
171.50 + </Property>
171.51 + </Properties>
171.52 + </Component>
171.53 + </SubComponents>
171.54 + </Container>
171.55 + </SubComponents>
171.56 +</Form>
172.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
172.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/NoCompilersPanel.java Mon Feb 01 12:24:26 2010 +0100
172.3 @@ -0,0 +1,99 @@
172.4 +/*
172.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
172.6 + *
172.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
172.8 + *
172.9 + * The contents of this file are subject to the terms of either the GNU
172.10 + * General Public License Version 2 only ("GPL") or the Common
172.11 + * Development and Distribution License("CDDL") (collectively, the
172.12 + * "License"). You may not use this file except in compliance with the
172.13 + * License. You can obtain a copy of the License at
172.14 + * http://www.netbeans.org/cddl-gplv2.html
172.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
172.16 + * specific language governing permissions and limitations under the
172.17 + * License. When distributing the software, include this License Header
172.18 + * Notice in each file and include the License file at
172.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
172.20 + * particular file as subject to the "Classpath" exception as provided
172.21 + * by Sun in the GPL Version 2 section of the License file that
172.22 + * accompanied this code. If applicable, add the following below the
172.23 + * License Header, with the fields enclosed by brackets [] replaced by
172.24 + * your own identifying information:
172.25 + * "Portions Copyrighted [year] [name of copyright owner]"
172.26 + *
172.27 + * Contributor(s):
172.28 + *
172.29 + * The Original Software is NetBeans. The Initial Developer of the Original
172.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
172.31 + * Microsystems, Inc. All Rights Reserved.
172.32 + *
172.33 + * If you wish your version of this file to be governed by only the CDDL
172.34 + * or only the GPL Version 2, indicate your decision by adding
172.35 + * "[Contributor] elects to include this software in this distribution
172.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
172.37 + * single choice of license, a recipient has the option to distribute
172.38 + * your version of this file under either the CDDL, the GPL Version 2 or
172.39 + * to extend the choice of license to its licensees as provided above.
172.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
172.41 + * Version 2 license, then the option applies only if the new code is
172.42 + * made subject to such option by the copyright holder.
172.43 + */
172.44 +
172.45 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
172.46 +
172.47 +import java.awt.Dimension;
172.48 +
172.49 +/**
172.50 + *
172.51 + * @author thp
172.52 + */
172.53 +public class NoCompilersPanel extends javax.swing.JPanel {
172.54 +
172.55 + /** Creates new form NoCompilersPanel */
172.56 + public NoCompilersPanel() {
172.57 + initComponents();
172.58 + textArea.setBackground(getBackground());
172.59 + setPreferredSize(new Dimension(700, 320));
172.60 + }
172.61 +
172.62 + /** This method is called from within the constructor to
172.63 + * initialize the form.
172.64 + * WARNING: Do NOT modify this code. The content of this method is
172.65 + * always regenerated by the Form Editor.
172.66 + */
172.67 + @SuppressWarnings("unchecked")
172.68 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
172.69 + private void initComponents() {
172.70 + java.awt.GridBagConstraints gridBagConstraints;
172.71 +
172.72 + jScrollPane1 = new javax.swing.JScrollPane();
172.73 + textArea = new javax.swing.JTextArea();
172.74 +
172.75 + setLayout(new java.awt.GridBagLayout());
172.76 +
172.77 + jScrollPane1.setBorder(null);
172.78 +
172.79 + textArea.setColumns(20);
172.80 + textArea.setEditable(false);
172.81 + textArea.setLineWrap(true);
172.82 + textArea.setRows(5);
172.83 + textArea.setText(org.openide.util.NbBundle.getMessage(NoCompilersPanel.class, "NO_COMPILERS_FOUND_MSG")); // NOI18N
172.84 + textArea.setWrapStyleWord(true);
172.85 + textArea.setBorder(null);
172.86 + jScrollPane1.setViewportView(textArea);
172.87 +
172.88 + gridBagConstraints = new java.awt.GridBagConstraints();
172.89 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
172.90 + gridBagConstraints.weightx = 1.0;
172.91 + gridBagConstraints.weighty = 1.0;
172.92 + gridBagConstraints.insets = new java.awt.Insets(20, 20, 20, 20);
172.93 + add(jScrollPane1, gridBagConstraints);
172.94 + }// </editor-fold>//GEN-END:initComponents
172.95 +
172.96 +
172.97 + // Variables declaration - do not modify//GEN-BEGIN:variables
172.98 + private javax.swing.JScrollPane jScrollPane1;
172.99 + private javax.swing.JTextArea textArea;
172.100 + // End of variables declaration//GEN-END:variables
172.101 +
172.102 +}
173.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
173.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/ToolUtils.java Mon Feb 01 12:24:26 2010 +0100
173.3 @@ -0,0 +1,267 @@
173.4 +/*
173.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
173.6 + *
173.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
173.8 + *
173.9 + * The contents of this file are subject to the terms of either the GNU
173.10 + * General Public License Version 2 only ("GPL") or the Common
173.11 + * Development and Distribution License("CDDL") (collectively, the
173.12 + * "License"). You may not use this file except in compliance with the
173.13 + * License. You can obtain a copy of the License at
173.14 + * http://www.netbeans.org/cddl-gplv2.html
173.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
173.16 + * specific language governing permissions and limitations under the
173.17 + * License. When distributing the software, include this License Header
173.18 + * Notice in each file and include the License file at
173.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
173.20 + * particular file as subject to the "Classpath" exception as provided
173.21 + * by Sun in the GPL Version 2 section of the License file that
173.22 + * accompanied this code. If applicable, add the following below the
173.23 + * License Header, with the fields enclosed by brackets [] replaced by
173.24 + * your own identifying information:
173.25 + * "Portions Copyrighted [year] [name of copyright owner]"
173.26 + *
173.27 + * If you wish your version of this file to be governed by only the CDDL
173.28 + * or only the GPL Version 2, indicate your decision by adding
173.29 + * "[Contributor] elects to include this software in this distribution
173.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
173.31 + * single choice of license, a recipient has the option to distribute
173.32 + * your version of this file under either the CDDL, the GPL Version 2 or
173.33 + * to extend the choice of license to its licensees as provided above.
173.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
173.35 + * Version 2 license, then the option applies only if the new code is
173.36 + * made subject to such option by the copyright holder.
173.37 + *
173.38 + * Contributor(s):
173.39 + *
173.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
173.41 + */
173.42 +
173.43 +package org.netbeans.modules.cnd.toolchain.compilers.impl;
173.44 +
173.45 +import org.netbeans.modules.cnd.toolchain.api.*;
173.46 +import java.io.File;
173.47 +import java.util.HashMap;
173.48 +import java.util.Map;
173.49 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
173.50 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolchainManagerImpl;
173.51 +import org.netbeans.modules.nativeexecution.api.util.Path;
173.52 +import org.openide.util.Utilities;
173.53 +
173.54 +/**
173.55 + *
173.56 + * @author Alexander Simon
173.57 + */
173.58 +public final class ToolUtils {
173.59 + private static String cygwinBase;
173.60 + private static Map<ToolchainDescriptor, String> commandsFolders = new HashMap<ToolchainDescriptor, String>(8);
173.61 +
173.62 + private ToolUtils() {
173.63 + }
173.64 +
173.65 + /**
173.66 + * Get the Cygwin base directory from Cygwin.xml (toolchain definition, which users the Windows registry) or the user's path
173.67 + */
173.68 + public static String getCygwinBase() {
173.69 + if (cygwinBase == null) {
173.70 + ToolchainManagerImpl tcm = ToolchainManagerImpl.getImpl();
173.71 + ToolchainDescriptor td = tcm.getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS); // NOI18N
173.72 + if (td != null) {
173.73 + String cygwinBin = tcm.getBaseFolder(td, PlatformTypes.PLATFORM_WINDOWS);
173.74 + if (cygwinBin != null) {
173.75 + cygwinBase = cygwinBin.substring(0, cygwinBin.length() - 4).replace("\\", "/"); // NOI18N
173.76 + }
173.77 + }
173.78 + if (cygwinBase == null) {
173.79 + for (String dir : Path.getPath()) {
173.80 + dir = dir.toLowerCase().replace("\\", "/"); // NOI18N
173.81 + if (dir.contains("cygwin")) { // NOI18N
173.82 + if (dir.endsWith("/")) { // NOI18N
173.83 + dir = dir.substring(0, dir.length() - 1);
173.84 + }
173.85 + if (dir.toLowerCase().endsWith("/usr/bin")) { // NOI18N
173.86 + cygwinBase = dir.substring(0, dir.length() - 8);
173.87 + break;
173.88 + } else if (dir.toLowerCase().endsWith("/bin")) { // NOI18N
173.89 + cygwinBase = dir.substring(0, dir.length() - 4);
173.90 + break;
173.91 + }
173.92 + }
173.93 + }
173.94 + }
173.95 + }
173.96 + return cygwinBase;
173.97 + }
173.98 +
173.99 + /**
173.100 + * Get the command folder (toolchain definition, which users the Windows registry) or the user's path
173.101 + */
173.102 + public static String getCommandFolder(ToolchainDescriptor descriptor) {
173.103 + if (!Utilities.isWindows()) {
173.104 + return null;
173.105 + }
173.106 + String res = getCommandDir(descriptor);
173.107 + if (res != null) {
173.108 + return res;
173.109 + }
173.110 + ToolchainManagerImpl tcm = ToolchainManagerImpl.getImpl();
173.111 + for(ToolchainDescriptor td : tcm.getToolchains(PlatformTypes.PLATFORM_WINDOWS)){
173.112 + if (td != null) {
173.113 + res = getCommandDir(td);
173.114 + if (res != null) {
173.115 + return res;
173.116 + }
173.117 + }
173.118 + }
173.119 + for (String dir : Path.getPath()) {
173.120 + dir = dir.toLowerCase().replace("\\", "/"); // NOI18N
173.121 + if (dir.contains("/msys/1.0") && dir.contains("/bin")) { // NOI18N
173.122 + return dir;
173.123 + }
173.124 + }
173.125 + return null;
173.126 + }
173.127 +
173.128 + private static String getCommandDir(ToolchainDescriptor td) {
173.129 + if (td != null) {
173.130 + String dir = commandsFolders.get(td);
173.131 + if (dir == null) {
173.132 + ToolchainManagerImpl tcm = ToolchainManagerImpl.getImpl();
173.133 + String msysBin = tcm.getCommandFolder(td, PlatformTypes.PLATFORM_WINDOWS);
173.134 + if (msysBin != null) {
173.135 + dir = msysBin.replace("\\", "/"); // NOI18N
173.136 + } else {
173.137 + dir = ""; // NOI18N
173.138 + }
173.139 + commandsFolders.put(td, dir);
173.140 + }
173.141 + if (dir.length() > 0) {
173.142 + return dir;
173.143 + }
173.144 + }
173.145 + return null;
173.146 + }
173.147 +
173.148 + public static String getPlatformName(int platform) {
173.149 + switch (platform) {
173.150 + case PlatformTypes.PLATFORM_LINUX:
173.151 + return "linux"; // NOI18N
173.152 + case PlatformTypes.PLATFORM_SOLARIS_SPARC:
173.153 + return "sun_sparc"; // NOI18N
173.154 + case PlatformTypes.PLATFORM_SOLARIS_INTEL:
173.155 + return "sun_intel"; // NOI18N
173.156 + case PlatformTypes.PLATFORM_WINDOWS:
173.157 + return "windows"; // NOI18N
173.158 + case PlatformTypes.PLATFORM_MACOSX:
173.159 + return "mac"; // NOI18N
173.160 + default:
173.161 + return "none"; // NOI18N
173.162 + }
173.163 + }
173.164 +
173.165 + public static int computeLocalPlatform() {
173.166 + String os = System.getProperty("os.name"); // NOI18N
173.167 +
173.168 + if (os.equals("SunOS")) { // NOI18N
173.169 + return System.getProperty("os.arch").equals("x86") ? PlatformTypes.PLATFORM_SOLARIS_INTEL : PlatformTypes.PLATFORM_SOLARIS_SPARC; // NOI18N
173.170 + } else if (os.startsWith("Windows ")) { // NOI18N
173.171 + return PlatformTypes.PLATFORM_WINDOWS;
173.172 + } else if (os.toLowerCase().contains("linux")) { // NOI18N
173.173 + return PlatformTypes.PLATFORM_LINUX;
173.174 + } else if (os.toLowerCase().contains("mac") || os.startsWith("Darwin")) { // NOI18N
173.175 + return PlatformTypes.PLATFORM_MACOSX;
173.176 + } else {
173.177 + return PlatformTypes.PLATFORM_GENERIC;
173.178 + }
173.179 + }
173.180 +
173.181 + public static String findCommand(String name) {
173.182 + String path = Path.findCommand(name);
173.183 + if (path == null) {
173.184 + String dir = ToolUtils.getCommandFolder(null);
173.185 + if (dir != null) {
173.186 + path = findCommand(name, dir); // NOI18N
173.187 + }
173.188 + }
173.189 + return path;
173.190 + }
173.191 +
173.192 + public static String findCommand(String cmd, String dir) {
173.193 + File file;
173.194 + String cmd2 = null;
173.195 + if (cmd.length() > 0) {
173.196 + if (Utilities.isWindows() && !cmd.endsWith(".exe")) { // NOI18N
173.197 + cmd2 = cmd + ".exe"; // NOI18N
173.198 + }
173.199 +
173.200 + file = new File(dir, cmd);
173.201 + if (file.exists()) {
173.202 + return file.getAbsolutePath();
173.203 + } else {
173.204 + if (Utilities.isWindows() && cmd.endsWith(".exe")){// NOI18N
173.205 + File file2 = new File(dir, cmd+".lnk");// NOI18N
173.206 + if (file2.exists()) {
173.207 + return file.getAbsolutePath();
173.208 + }
173.209 + }
173.210 + }
173.211 + if (cmd2 != null) {
173.212 + file = new File(dir, cmd2);
173.213 + if (file.exists()) {
173.214 + return file.getAbsolutePath();
173.215 + }
173.216 + File file2 = new File(dir, cmd2+".lnk");// NOI18N
173.217 + if (file2.exists()) {
173.218 + return file.getAbsolutePath();
173.219 + }
173.220 + }
173.221 + }
173.222 + return null;
173.223 + }
173.224 +
173.225 + /** Same as the C library basename function: given a path, return
173.226 + * its filename.
173.227 + */
173.228 + public static String getBaseName(String path) {
173.229 + int sep = path.lastIndexOf('/');
173.230 + if (sep == -1) {
173.231 + sep = path.lastIndexOf('\\');
173.232 + }
173.233 + if (sep != -1) {
173.234 + return path.substring(sep + 1);
173.235 + }
173.236 + return path;
173.237 + }
173.238 +
173.239 + public static boolean isPathAbsolute(String path) {
173.240 + if (path == null || path.length() == 0) {
173.241 + return false;
173.242 + } else if (path.charAt(0) == '/') {
173.243 + return true;
173.244 + } else if (path.charAt(0) == '\\') {
173.245 + return true;
173.246 + } else if (path.indexOf(':') > 0) {
173.247 + return true;
173.248 + } else {
173.249 + return false;
173.250 + }
173.251 + }
173.252 +
173.253 + public static String replaceOddCharacters(String s, char replaceChar) {
173.254 + int n = s.length();
173.255 + StringBuilder ret = new StringBuilder(n);
173.256 + for (int i = 0; i < n; i++) {
173.257 + char c = s.charAt(i);
173.258 + if ((c == ' ') || (c == '\t') ||
173.259 + (c == ':') || (c == '\'') ||
173.260 + (c == '*') || (c == '\"') ||
173.261 + (c == '[') || (c == ']') ||
173.262 + (c == '(') || (c == ')')) {
173.263 + ret.append(replaceChar);
173.264 + } else {
173.265 + ret.append(c);
173.266 + }
173.267 + }
173.268 + return ret.toString();
173.269 + }
173.270 +}
174.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/ToolchainManagerImpl.java Mon Feb 01 12:23:06 2010 +0100
174.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilers/impl/ToolchainManagerImpl.java Mon Feb 01 12:24:26 2010 +0100
174.3 @@ -83,10 +83,15 @@
174.4 private static final boolean TRACE = Boolean.getBoolean("cnd.toolchain.personality.trace"); // NOI18N
174.5 private static final boolean CREATE_SHADOW = Boolean.getBoolean("cnd.toolchain.personality.create_shadow"); // NOI18N
174.6 public static final String CONFIG_FOLDER = "CND/ToolChain"; // NOI18N
174.7 + private static final ToolchainManagerImpl manager = new ToolchainManagerImpl();
174.8 private List<ToolchainDescriptor> descriptors = new ArrayList<ToolchainDescriptor>();
174.9 - private Logger log = Logger.getLogger("cnd.toolchain.logger"); // NOI18N
174.10 + private static final Logger log = Logger.getLogger("cnd.toolchain.logger"); // NOI18N
174.11
174.12 - public ToolchainManagerImpl() {
174.13 + public static final ToolchainManagerImpl getImpl() {
174.14 + return manager;
174.15 + }
174.16 +
174.17 + private ToolchainManagerImpl() {
174.18 initToolchainManager();
174.19 }
174.20
175.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/ErrorParser.java Mon Feb 01 12:23:06 2010 +0100
175.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/ErrorParser.java Mon Feb 01 12:24:26 2010 +0100
175.3 @@ -43,10 +43,11 @@
175.4 import java.util.List;
175.5 import java.util.StringTokenizer;
175.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
175.7 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
175.8 +import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
175.9 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
175.10 import org.netbeans.modules.cnd.toolchain.api.Tool;
175.11 -import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
175.12 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
175.13 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolUtils;
175.14 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider;
175.15 import org.netbeans.modules.cnd.utils.cache.CndFileUtils;
175.16 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
175.17 @@ -89,7 +90,7 @@
175.18 }
175.19
175.20 protected FileObject resolveRelativePath(FileObject relativeDir, String relativePath) {
175.21 - if (CompilerSetUtils.isPathAbsolute(relativePath)) {
175.22 + if (ToolUtils.isPathAbsolute(relativePath)) {
175.23 // NOI18N
175.24 if (execEnv.isRemote() || Utilities.isWindows()) {
175.25 // See IZ 106841 for details.
175.26 @@ -107,9 +108,9 @@
175.27 if (absPath1.startsWith("/usr/lib")) { // NOI18N
175.28 absPath2 = absPath1.substring(4);
175.29 }
175.30 - List<CompilerSet> compilerSets = CompilerSetManager.getDefault(execEnv).getCompilerSets();
175.31 + List<CompilerSet> compilerSets = CompilerSetManager.get(execEnv).getCompilerSets();
175.32 for (CompilerSet set : compilerSets) {
175.33 - Tool cCompiler = set.getTool(Tool.CCompiler);
175.34 + Tool cCompiler = set.getTool(ToolKind.CCompiler);
175.35 if (cCompiler != null) {
175.36 String includePrefix = cCompiler.getIncludeFilePathPrefix();
175.37 File file = new File(includePrefix + absPath1);
176.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/GCCErrorParser.java Mon Feb 01 12:23:06 2010 +0100
176.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/GCCErrorParser.java Mon Feb 01 12:24:26 2010 +0100
176.3 @@ -47,10 +47,10 @@
176.4 import java.util.Stack;
176.5 import java.util.regex.Matcher;
176.6 import java.util.regex.Pattern;
176.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
176.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
176.9 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerDescriptor;
176.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerPattern;
176.11 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
176.12 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolUtils;
176.13 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider;
176.14 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider.Result;
176.15 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider.Results;
176.16 @@ -155,7 +155,7 @@
176.17 popLevel();
176.18 }
176.19 if (isEntered) {
176.20 - if (!CompilerSetUtils.isPathAbsolute(directory)) {
176.21 + if (!ToolUtils.isPathAbsolute(directory)) {
176.22 if (relativeTo != null) {
176.23 if (relativeTo.isFolder()) {
176.24 directory = relativeTo.getURL().getPath() + File.separator + directory;
176.25 @@ -174,7 +174,7 @@
176.26 }
176.27 if (m.pattern() == GCC_DIRECTORY_CD) {
176.28 String directory = m.group(1);
176.29 - if (!CompilerSetUtils.isPathAbsolute(directory)) {
176.30 + if (!ToolUtils.isPathAbsolute(directory)) {
176.31 if (relativeTo != null) {
176.32 if (relativeTo.isFolder()) {
176.33 directory = relativeTo.getURL().getPath() + File.separator + directory;
176.34 @@ -190,7 +190,7 @@
176.35 if (m.pattern() == GCC_DIRECTORY_MAKE_ALL) {
176.36 FileObject relativeDir = relativesTo.peek();
176.37 String directory = m.group(1);
176.38 - if (!CompilerSetUtils.isPathAbsolute(directory)) {
176.39 + if (!ToolUtils.isPathAbsolute(directory)) {
176.40 if (relativeDir != null) {
176.41 if (relativeDir.isFolder()) {
176.42 directory = relativeDir.getURL().getPath() + File.separator + directory;
177.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/GCCErrorParserProvider.java Mon Feb 01 12:23:06 2010 +0100
177.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/GCCErrorParserProvider.java Mon Feb 01 12:24:26 2010 +0100
177.3 @@ -39,7 +39,7 @@
177.4
177.5 package org.netbeans.modules.cnd.toolchain.execution.impl;
177.6
177.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
177.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
177.9 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider;
177.10 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
177.11 import org.openide.filesystems.FileObject;
178.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/SUNErrorParser.java Mon Feb 01 12:23:06 2010 +0100
178.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/SUNErrorParser.java Mon Feb 01 12:24:26 2010 +0100
178.3 @@ -44,7 +44,7 @@
178.4 import java.util.List;
178.5 import java.util.regex.Matcher;
178.6 import java.util.regex.Pattern;
178.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
178.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
178.9 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerDescriptor;
178.10 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerPattern;
178.11 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider;
179.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/SUNErrorParserProvider.java Mon Feb 01 12:23:06 2010 +0100
179.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/execution/impl/SUNErrorParserProvider.java Mon Feb 01 12:24:26 2010 +0100
179.3 @@ -39,7 +39,7 @@
179.4
179.5 package org.netbeans.modules.cnd.toolchain.execution.impl;
179.6
179.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
179.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
179.9 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider;
179.10 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
179.11 import org.openide.filesystems.FileObject;
180.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/layer.xml Mon Feb 01 12:23:06 2010 +0100
180.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/layer.xml Mon Feb 01 12:24:26 2010 +0100
180.3 @@ -121,11 +121,4 @@
180.4 </file>
180.5 </folder>
180.6 </folder>
180.7 - <folder name="Actions">
180.8 - <folder name="Build">
180.9 - <file name="org-netbeans-modules-cnd-toolchain-actions-BuildToolsAction.instance">
180.10 - <attr name="instanceClass" stringvalue="org.netbeans.modules.cnd.toolchain.actions.BuildToolsAction"/>
180.11 - </file>
180.12 - </folder>
180.13 - </folder> <!-- Actions -->
180.14 </filesystem>
181.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
181.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
181.3 @@ -0,0 +1,152 @@
181.4 +# This module is part of NetBeans and is open-source.
181.5 +# You can see http://www.netbeans.org/about/legal/index.html for details.
181.6 +#
181.7 +# You may use the binary however you like. The source file license is:
181.8 +#
181.9 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
181.10 +#
181.11 +# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
181.12 +#
181.13 +# The contents of this file are subject to the terms of either the GNU
181.14 +# General Public License Version 2 only ("GPL") or the Common
181.15 +# Development and Distribution License("CDDL") (collectively, the
181.16 +# "License"). You may not use this file except in compliance with the
181.17 +# License. You can obtain a copy of the License at
181.18 +# http://www.netbeans.org/cddl-gplv2.html
181.19 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
181.20 +# specific language governing permissions and limitations under the
181.21 +# License. When distributing the software, include this License Header
181.22 +# Notice in each file and include the License file at
181.23 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
181.24 +# particular file as subject to the "Classpath" exception as provided
181.25 +# by Sun in the GPL Version 2 section of the License file that
181.26 +# accompanied this code. If applicable, add the following below the
181.27 +# License Header, with the fields enclosed by brackets [] replaced by
181.28 +# your own identifying information:
181.29 +# "Portions Copyrighted [year] [name of copyright owner]"
181.30 +#
181.31 +# Contributor(s):
181.32 +#
181.33 +# The Original Software is NetBeans. The Initial Developer of the Original
181.34 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
181.35 +# Microsystems, Inc. All Rights Reserved.
181.36 +
181.37 +DetectHostInfo=\
181.38 +PLATFORM_SOLARIS_SPARC=0\n\
181.39 +PLATFORM_SOLARIS_INTEL=1\n\
181.40 +PLATFORM_LINUX=2\n\
181.41 +PLATFORM_WINDOWS=3\n\
181.42 +PLATFORM_MACOSX=4\n\
181.43 +PLATFORM_GENERIC=5\n\
181.44 +PLATFORM_NONE=6\n\
181.45 +detectHostInfo() {\n\
181.46 + PLATFORM=$PLATFORM_NONE\n\
181.47 + OPATH=$PATH\n\
181.48 + PATH=/usr/bin:/bin:$PATH\n\
181.49 + OS=`uname -s`\n\
181.50 + ARCH=`uname -m`\n\
181.51 + PATH=$OPATH\n\
181.52 + if [ "$OS" = "SunOS" ]; then\n\
181.53 + if [ "$ARCH" = "i86pc" ]; then\n\
181.54 + PLATFORM=$PLATFORM_SOLARIS_INTEL\n\
181.55 + else\n\
181.56 + PLATFORM=$PLATFORM_SOLARIS_SPARC\n\
181.57 + fi\n\
181.58 + else\n\
181.59 + if [ "$OS" = "Linux" ]; then\n\
181.60 + PLATFORM=$PLATFORM_LINUX\n\
181.61 + else\n\
181.62 + if [ "$OS" = "Darwin" ]; then\n\
181.63 + PLATFORM=$PLATFORM_MACOSX\n\
181.64 + else\n\
181.65 + echo ${OS} | grep _NT- >/dev/null\n\
181.66 + status=$?\n\
181.67 + if [ status -eq 0 ]; then\n\
181.68 + PLATFORM=$PLATFORM_WINDOWS\n\
181.69 + else\n\
181.70 + PLATFORM=$PLATFORM_NONE\n\
181.71 + fi\n\
181.72 + fi\n\
181.73 + fi\n\
181.74 + fi\n\
181.75 + echo $PLATFORM\n\
181.76 +}\n\
181.77 +PLATFORM=`detectHostInfo`\n\
181.78 +PLATFORM_NAME=\n\
181.79 +if [ "$PLATFORM" = "$PLATFORM_SOLARIS_SPARC" ]; then\n\
181.80 + PLATFORM_NAME="PLATFORM_SOLARIS_SPARC"\n\
181.81 +fi\n\
181.82 +if [ "$PLATFORM" = "$PLATFORM_SOLARIS_INTEL" ]; then\n\
181.83 + PLATFORM_NAME="PLATFORM_SOLARIS_INTEL"\n\
181.84 +fi\n\
181.85 +if [ "$PLATFORM" = "$PLATFORM_LINUX" ]; then\n\
181.86 + PLATFORM_NAME="PLATFORM_LINUX"\n\
181.87 +fi\n\
181.88 +if [ "$PLATFORM" = "$PLATFORM_WINDOWS" ]; then\n\
181.89 + PLATFORM_NAME="PLATFORM_WINDOWS"\n\
181.90 +fi\n\
181.91 +if [ "$PLATFORM" = "$PLATFORM_MACOSX" ]; then\n\
181.92 + PLATFORM_NAME="PLATFORM_MACOSX"\n\
181.93 +fi\n\
181.94 +if [ "$PLATFORM" = "$PLATFORM_NONE" ]; then\n\
181.95 + PLATFORM_NAME="PLATFORM_NONE"\n\
181.96 +fi\n\
181.97 +findInPath() {\n\
181.98 + for f1 in $PATHSLIST; do\n\
181.99 + pathStatus=\n\
181.100 + echo $f1 | egrep -e "^/" >/dev/null\n\
181.101 + if [ "$?" != "0" ]; then\n\
181.102 + continue # skip relative directories\n\
181.103 + fi\n\
181.104 + echo $f1 | egrep -e "^/usr/ucb" >/dev/null\n\
181.105 + if [ "$?" = "0" ]; then\n\
181.106 + continue # skip /usr/ucb (IZ #142780)\n\
181.107 + fi\n\
181.108 + for f2 in $1; do\n\
181.109 + if [ -x "$f1/$f2" ]; then\n\
181.110 + pathStatus="$f1/$f2"\n\
181.111 + else\n\
181.112 + if [ "$PLATFORM" = "$PLATFORM_WINDOWS" ]; then\n\
181.113 + if [ -x "$f1/$f2.exe" ]; then\n\
181.114 + pathStatus="$f1/$f2.exe"\n\
181.115 + fi\n\
181.116 + fi\n\
181.117 + if [ -n "$pathStatus" ]; then\n\
181.118 + break\n\
181.119 + fi\n\
181.120 + fi\n\
181.121 + done\n\
181.122 + if [ -n "$pathStatus" ]; then\n\
181.123 + break\n\
181.124 + fi\n\
181.125 + done\n\
181.126 + if [ -n "$pathStatus" ]; then\n\
181.127 + echo $pathStatus\n\
181.128 + fi\n\
181.129 +}\n\
181.130 +addNewToolChain() {\n\
181.131 + if [ -n "$line" ]; then\n\
181.132 + echo $foundFlavors | egrep -e ";${flavor}" >/dev/null\n\
181.133 + if [ ! "$?" = "0" ]; then\n\
181.134 + echo $line\n\
181.135 + foundFlavors=$foundFlavors$flavor\n\
181.136 + fi\n\
181.137 + fi\n\
181.138 +}\n\
181.139 +findCompiler() {\n\
181.140 + status=\n\
181.141 + for f3 in $1; do\n\
181.142 + if [ ! -n "$status" ]; then\n\
181.143 + if [ -x "$f/$f3" ]; then\n\
181.144 + line="$line;$2=$f/$f3"\n\
181.145 + status=1\n\
181.146 + fi\n\
181.147 + fi\n\
181.148 + done\n\
181.149 + if [ ! -n "$status" ]; then\n\
181.150 + status=`findInPath "$1"`\n\
181.151 + if [ -n "$status" ]; then\n\
181.152 + line="$line;$2(PATH)=$status"\n\
181.153 + fi\n\
181.154 + fi\n\
181.155 +}
182.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerLineConvertor.java Mon Feb 01 12:23:06 2010 +0100
182.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerLineConvertor.java Mon Feb 01 12:24:26 2010 +0100
182.3 @@ -47,7 +47,8 @@
182.4 import org.netbeans.api.extexecution.print.ConvertedLine;
182.5 import org.netbeans.api.extexecution.print.LineConvertor;
182.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
182.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
182.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
182.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
182.10 import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
182.11 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerDescriptor;
182.12 import org.netbeans.modules.cnd.toolchain.spi.ErrorParserProvider.ErrorParser;
182.13 @@ -138,7 +139,7 @@
182.14 }
182.15 List<CompilerFlavor> flavors = new ArrayList<CompilerFlavor>();
182.16 flavors.add(set.getCompilerFlavor());
182.17 - for(CompilerFlavor flavor : CompilerFlavor.getFlavors(platform)) {
182.18 + for(CompilerFlavor flavor : CompilerFlavorAccessor.getFlavors(platform)) {
182.19 if (!flavors.contains(flavor)){
182.20 boolean found = false;
182.21 for(CompilerFlavor f : flavors) {
183.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
183.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerProvider.java Mon Feb 01 12:24:26 2010 +0100
183.3 @@ -0,0 +1,92 @@
183.4 +/*
183.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
183.6 + *
183.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
183.8 + *
183.9 + * The contents of this file are subject to the terms of either the GNU
183.10 + * General Public License Version 2 only ("GPL") or the Common
183.11 + * Development and Distribution License("CDDL") (collectively, the
183.12 + * "License"). You may not use this file except in compliance with the
183.13 + * License. You can obtain a copy of the License at
183.14 + * http://www.netbeans.org/cddl-gplv2.html
183.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
183.16 + * specific language governing permissions and limitations under the
183.17 + * License. When distributing the software, include this License Header
183.18 + * Notice in each file and include the License file at
183.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
183.20 + * particular file as subject to the "Classpath" exception as provided
183.21 + * by Sun in the GPL Version 2 section of the License file that
183.22 + * accompanied this code. If applicable, add the following below the
183.23 + * License Header, with the fields enclosed by brackets [] replaced by
183.24 + * your own identifying information:
183.25 + * "Portions Copyrighted [year] [name of copyright owner]"
183.26 + *
183.27 + * Contributor(s):
183.28 + *
183.29 + * The Original Software is NetBeans. The Initial Developer of the Original
183.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
183.31 + * Microsystems, Inc. All Rights Reserved.
183.32 + *
183.33 + * If you wish your version of this file to be governed by only the CDDL
183.34 + * or only the GPL Version 2, indicate your decision by adding
183.35 + * "[Contributor] elects to include this software in this distribution
183.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
183.37 + * single choice of license, a recipient has the option to distribute
183.38 + * your version of this file under either the CDDL, the GPL Version 2 or
183.39 + * to extend the choice of license to its licensees as provided above.
183.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
183.41 + * Version 2 license, then the option applies only if the new code is
183.42 + * made subject to such option by the copyright holder.
183.43 + */
183.44 +
183.45 +package org.netbeans.modules.cnd.toolchain.spi;
183.46 +
183.47 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
183.48 +import org.netbeans.modules.cnd.toolchain.api.Tool;
183.49 +import org.netbeans.modules.cnd.toolchain.api.ToolKindBase;
183.50 +import org.netbeans.modules.cnd.toolchain.compilers.impl.APIAccessor;
183.51 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
183.52 +import org.openide.util.Lookup;
183.53 +
183.54 +/**
183.55 + *
183.56 + * @author gordonp
183.57 + */
183.58 +public abstract class CompilerProvider {
183.59 + private static final CompilerProvider INSTANCE = new Default();
183.60 +
183.61 + public abstract Tool createCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path);
183.62 +
183.63 + protected CompilerProvider() {
183.64 + }
183.65 +
183.66 + /**
183.67 + * Static method to obtain the provider.
183.68 + * @return the provider
183.69 + */
183.70 + public static CompilerProvider getInstance() {
183.71 + return INSTANCE;
183.72 + }
183.73 +
183.74 + //
183.75 + // Implementation of the default provider
183.76 + //
183.77 + private static final class Default extends CompilerProvider {
183.78 + private final Lookup.Result<CompilerProvider> res;
183.79 +
183.80 + private Default() {
183.81 + res = Lookup.getDefault().lookupResult(CompilerProvider.class);
183.82 + }
183.83 +
183.84 + @Override
183.85 + public Tool createCompiler(ExecutionEnvironment env, CompilerFlavor flavor, ToolKindBase kind, String name, String displayName, String path) {
183.86 + for (CompilerProvider resolver : res.allInstances()) {
183.87 + Tool out = resolver.createCompiler(env, flavor, kind, name, displayName, path);
183.88 + if (out != null) {
183.89 + return out;
183.90 + }
183.91 + }
183.92 + return APIAccessor.get().createTool(env, flavor, kind, name, displayName, path);
183.93 + }
183.94 + }
183.95 +}
184.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
184.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerSetFactory.java Mon Feb 01 12:24:26 2010 +0100
184.3 @@ -0,0 +1,100 @@
184.4 +/*
184.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
184.6 + *
184.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
184.8 + *
184.9 + * The contents of this file are subject to the terms of either the GNU
184.10 + * General Public License Version 2 only ("GPL") or the Common
184.11 + * Development and Distribution License("CDDL") (collectively, the
184.12 + * "License"). You may not use this file except in compliance with the
184.13 + * License. You can obtain a copy of the License at
184.14 + * http://www.netbeans.org/cddl-gplv2.html
184.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
184.16 + * specific language governing permissions and limitations under the
184.17 + * License. When distributing the software, include this License Header
184.18 + * Notice in each file and include the License file at
184.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
184.20 + * particular file as subject to the "Classpath" exception as provided
184.21 + * by Sun in the GPL Version 2 section of the License file that
184.22 + * accompanied this code. If applicable, add the following below the
184.23 + * License Header, with the fields enclosed by brackets [] replaced by
184.24 + * your own identifying information:
184.25 + * "Portions Copyrighted [year] [name of copyright owner]"
184.26 + *
184.27 + * If you wish your version of this file to be governed by only the CDDL
184.28 + * or only the GPL Version 2, indicate your decision by adding
184.29 + * "[Contributor] elects to include this software in this distribution
184.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
184.31 + * single choice of license, a recipient has the option to distribute
184.32 + * your version of this file under either the CDDL, the GPL Version 2 or
184.33 + * to extend the choice of license to its licensees as provided above.
184.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
184.35 + * Version 2 license, then the option applies only if the new code is
184.36 + * made subject to such option by the copyright holder.
184.37 + *
184.38 + * Contributor(s):
184.39 + *
184.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
184.41 + */
184.42 +
184.43 +package org.netbeans.modules.cnd.toolchain.spi;
184.44 +
184.45 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetImpl;
184.46 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerFlavorImpl;
184.47 +import java.util.ArrayList;
184.48 +import java.util.List;
184.49 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
184.50 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
184.51 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
184.52 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
184.53 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolchainManagerImpl;
184.54 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
184.55 +
184.56 +/**
184.57 + *
184.58 + * @author Alexander Simon
184.59 + */
184.60 +public class CompilerSetFactory {
184.61 +
184.62 + private CompilerSetFactory() {
184.63 + }
184.64 +
184.65 + /**
184.66 + * Get an existing compiler set. If it doesn't exist, get an empty one based on the requested name.
184.67 + *
184.68 + * @param name The name of the compiler set we want
184.69 + * @returns The best fitting compiler set (may be an empty CompilerSet)
184.70 + */
184.71 + public static CompilerSet getCompilerSet(ExecutionEnvironment env, String name, int platform) {
184.72 + CompilerSet cs = CompilerSetManager.get(env).getCompilerSet(CompilerFlavorImpl.toFlavor(name, platform));
184.73 + if (cs == null) {
184.74 + CompilerFlavor flavor = CompilerFlavorImpl.toFlavor(name, platform);
184.75 + flavor = flavor == null ? CompilerFlavorImpl.getUnknown(platform) : flavor;
184.76 + cs = new CompilerSetImpl(flavor, "", null); // NOI18N
184.77 + }
184.78 + return cs;
184.79 + }
184.80 +
184.81 + public static List<CompilerFlavor> getCompilerSetFlavor(String directory, int platform) {
184.82 + List<CompilerFlavor> list = new ArrayList<CompilerFlavor>();
184.83 + for(ToolchainDescriptor d : ToolchainManagerImpl.getImpl().getToolchains(platform)) {
184.84 + if (d.isAbstract()) {
184.85 + continue;
184.86 + }
184.87 + if (ToolchainManagerImpl.getImpl().isMyFolder(directory, d, platform, false)){
184.88 + CompilerFlavor f = CompilerFlavorImpl.toFlavor(d.getName(), platform);
184.89 + if (f != null) {
184.90 + list.add(f);
184.91 + }
184.92 + }
184.93 + }
184.94 + return list;
184.95 + }
184.96 +
184.97 + public static CompilerSet getCustomCompilerSet(String directory, CompilerFlavor flavor, String name) {
184.98 + CompilerSetImpl cs = new CompilerSetImpl(flavor, directory, name);
184.99 + cs.setAutoGenerated(false);
184.100 + return cs;
184.101 + }
184.102 +
184.103 +}
185.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
185.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerSetManagerEvents.java Mon Feb 01 12:24:26 2010 +0100
185.3 @@ -0,0 +1,98 @@
185.4 +/*
185.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
185.6 + *
185.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
185.8 + *
185.9 + * The contents of this file are subject to the terms of either the GNU
185.10 + * General Public License Version 2 only ("GPL") or the Common
185.11 + * Development and Distribution License("CDDL") (collectively, the
185.12 + * "License"). You may not use this file except in compliance with the
185.13 + * License. You can obtain a copy of the License at
185.14 + * http://www.netbeans.org/cddl-gplv2.html
185.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
185.16 + * specific language governing permissions and limitations under the
185.17 + * License. When distributing the software, include this License Header
185.18 + * Notice in each file and include the License file at
185.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
185.20 + * particular file as subject to the "Classpath" exception as provided
185.21 + * by Sun in the GPL Version 2 section of the License file that
185.22 + * accompanied this code. If applicable, add the following below the
185.23 + * License Header, with the fields enclosed by brackets [] replaced by
185.24 + * your own identifying information:
185.25 + * "Portions Copyrighted [year] [name of copyright owner]"
185.26 + *
185.27 + * If you wish your version of this file to be governed by only the CDDL
185.28 + * or only the GPL Version 2, indicate your decision by adding
185.29 + * "[Contributor] elects to include this software in this distribution
185.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
185.31 + * single choice of license, a recipient has the option to distribute
185.32 + * your version of this file under either the CDDL, the GPL Version 2 or
185.33 + * to extend the choice of license to its licensees as provided above.
185.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
185.35 + * Version 2 license, then the option applies only if the new code is
185.36 + * made subject to such option by the copyright holder.
185.37 + *
185.38 + * Contributor(s):
185.39 + *
185.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
185.41 + */
185.42 +package org.netbeans.modules.cnd.toolchain.spi;
185.43 +
185.44 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerImpl;
185.45 +import java.util.ArrayList;
185.46 +import java.util.HashMap;
185.47 +import java.util.List;
185.48 +import java.util.Map;
185.49 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
185.50 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
185.51 +
185.52 +/**
185.53 + * CompilerSetManagerEvents handles tasks which depends on CompilerSetManager activity and
185.54 + * have to survive CompilerSetManager.deepCopy()
185.55 + *
185.56 + * There is only one (and I hope there would be only one) such event -- Code Model Readiness
185.57 + *
185.58 + * @author Sergey Grinev
185.59 + */
185.60 +public class CompilerSetManagerEvents {
185.61 +
185.62 + private static final Map<ExecutionEnvironment, CompilerSetManagerEvents> map =
185.63 + new HashMap<ExecutionEnvironment, CompilerSetManagerEvents>();
185.64 +
185.65 + public static synchronized CompilerSetManagerEvents get(ExecutionEnvironment env) {
185.66 + CompilerSetManagerEvents instance = map.get(env);
185.67 + if (instance == null) {
185.68 + instance = new CompilerSetManagerEvents(env);
185.69 + map.put(env, instance);
185.70 + }
185.71 + return instance;
185.72 + }
185.73 +
185.74 + public CompilerSetManagerEvents(ExecutionEnvironment env) {
185.75 + this.executionEnvironment = env;
185.76 + this.isCodeModelInfoReady = ((CompilerSetManagerImpl)CompilerSetManager.get(executionEnvironment)).isComplete();
185.77 + }
185.78 +
185.79 + private final ExecutionEnvironment executionEnvironment;
185.80 +
185.81 + private boolean isCodeModelInfoReady;
185.82 + private List<Runnable> tasks = new ArrayList<Runnable>();
185.83 +
185.84 + public void runOnCodeModelReadiness(Runnable task) {
185.85 + if (executionEnvironment.isLocal() || isCodeModelInfoReady) {
185.86 + task.run();
185.87 + } else {
185.88 + tasks.add(task);
185.89 + }
185.90 + }
185.91 +
185.92 + public void runTasks() {
185.93 + isCodeModelInfoReady = true;
185.94 + if (tasks != null) {
185.95 + for (Runnable task : tasks) {
185.96 + task.run();
185.97 + }
185.98 + }
185.99 + tasks = null;
185.100 + }
185.101 +}
186.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
186.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerSetProvider.java Mon Feb 01 12:24:26 2010 +0100
186.3 @@ -0,0 +1,62 @@
186.4 +/*
186.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
186.6 + *
186.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
186.8 + *
186.9 + * The contents of this file are subject to the terms of either the GNU
186.10 + * General Public License Version 2 only ("GPL") or the Common
186.11 + * Development and Distribution License("CDDL") (collectively, the
186.12 + * "License"). You may not use this file except in compliance with the
186.13 + * License. You can obtain a copy of the License at
186.14 + * http://www.netbeans.org/cddl-gplv2.html
186.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
186.16 + * specific language governing permissions and limitations under the
186.17 + * License. When distributing the software, include this License Header
186.18 + * Notice in each file and include the License file at
186.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
186.20 + * particular file as subject to the "Classpath" exception as provided
186.21 + * by Sun in the GPL Version 2 section of the License file that
186.22 + * accompanied this code. If applicable, add the following below the
186.23 + * License Header, with the fields enclosed by brackets [] replaced by
186.24 + * your own identifying information:
186.25 + * "Portions Copyrighted [year] [name of copyright owner]"
186.26 + *
186.27 + * If you wish your version of this file to be governed by only the CDDL
186.28 + * or only the GPL Version 2, indicate your decision by adding
186.29 + * "[Contributor] elects to include this software in this distribution
186.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
186.31 + * single choice of license, a recipient has the option to distribute
186.32 + * your version of this file under either the CDDL, the GPL Version 2 or
186.33 + * to extend the choice of license to its licensees as provided above.
186.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
186.35 + * Version 2 license, then the option applies only if the new code is
186.36 + * made subject to such option by the copyright holder.
186.37 + *
186.38 + * Contributor(s):
186.39 + *
186.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
186.41 + */
186.42 +
186.43 +package org.netbeans.modules.cnd.toolchain.spi;
186.44 +
186.45 +import java.util.List;
186.46 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
186.47 +
186.48 +/**
186.49 + * @author gordonp
186.50 + * @author vkvashin
186.51 + */
186.52 +public interface CompilerSetProvider {
186.53 +
186.54 + int getPlatform();
186.55 +
186.56 + void init();
186.57 +
186.58 + boolean hasMoreCompilerSets();
186.59 +
186.60 + String getNextCompilerSetData();
186.61 +
186.62 + String[] getCompilerSetData(String path);
186.63 +
186.64 + Runnable createCompilerSetDataLoader(List<CompilerSet> sets);
186.65 +}
187.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
187.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerSetProviderFactory.java Mon Feb 01 12:24:26 2010 +0100
187.3 @@ -0,0 +1,56 @@
187.4 +/*
187.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
187.6 + *
187.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
187.8 + *
187.9 + * The contents of this file are subject to the terms of either the GNU
187.10 + * General Public License Version 2 only ("GPL") or the Common
187.11 + * Development and Distribution License("CDDL") (collectively, the
187.12 + * "License"). You may not use this file except in compliance with the
187.13 + * License. You can obtain a copy of the License at
187.14 + * http://www.netbeans.org/cddl-gplv2.html
187.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
187.16 + * specific language governing permissions and limitations under the
187.17 + * License. When distributing the software, include this License Header
187.18 + * Notice in each file and include the License file at
187.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
187.20 + * particular file as subject to the "Classpath" exception as provided
187.21 + * by Sun in the GPL Version 2 section of the License file that
187.22 + * accompanied this code. If applicable, add the following below the
187.23 + * License Header, with the fields enclosed by brackets [] replaced by
187.24 + * your own identifying information:
187.25 + * "Portions Copyrighted [year] [name of copyright owner]"
187.26 + *
187.27 + * If you wish your version of this file to be governed by only the CDDL
187.28 + * or only the GPL Version 2, indicate your decision by adding
187.29 + * "[Contributor] elects to include this software in this distribution
187.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
187.31 + * single choice of license, a recipient has the option to distribute
187.32 + * your version of this file under either the CDDL, the GPL Version 2 or
187.33 + * to extend the choice of license to its licensees as provided above.
187.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
187.35 + * Version 2 license, then the option applies only if the new code is
187.36 + * made subject to such option by the copyright holder.
187.37 + *
187.38 + * Contributor(s):
187.39 + *
187.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
187.41 + */
187.42 +
187.43 +package org.netbeans.modules.cnd.toolchain.spi;
187.44 +
187.45 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
187.46 +
187.47 +/**
187.48 + * An SPI for creation CompilerSetProvider instances
187.49 + * @author Vladimir Kvashin
187.50 + */
187.51 +public interface CompilerSetProviderFactory {
187.52 + /**
187.53 + * Creates a new instance of CompilerSetProvider
187.54 + * for the given execution environment
187.55 + * @param execEnv execution environment to create CompilerSetProvider for
187.56 + * @return new CompilerSetProvider instance
187.57 + */
187.58 + public CompilerSetProvider createNew(ExecutionEnvironment execEnv);
187.59 +}
188.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/CompilerSetProviderFactoryImpl.java Mon Feb 01 12:23:06 2010 +0100
188.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
188.3 @@ -1,57 +0,0 @@
188.4 -/*
188.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
188.6 - *
188.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
188.8 - *
188.9 - * The contents of this file are subject to the terms of either the GNU
188.10 - * General Public License Version 2 only ("GPL") or the Common
188.11 - * Development and Distribution License("CDDL") (collectively, the
188.12 - * "License"). You may not use this file except in compliance with the
188.13 - * License. You can obtain a copy of the License at
188.14 - * http://www.netbeans.org/cddl-gplv2.html
188.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
188.16 - * specific language governing permissions and limitations under the
188.17 - * License. When distributing the software, include this License Header
188.18 - * Notice in each file and include the License file at
188.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
188.20 - * particular file as subject to the "Classpath" exception as provided
188.21 - * by Sun in the GPL Version 2 section of the License file that
188.22 - * accompanied this code. If applicable, add the following below the
188.23 - * License Header, with the fields enclosed by brackets [] replaced by
188.24 - * your own identifying information:
188.25 - * "Portions Copyrighted [year] [name of copyright owner]"
188.26 - *
188.27 - * If you wish your version of this file to be governed by only the CDDL
188.28 - * or only the GPL Version 2, indicate your decision by adding
188.29 - * "[Contributor] elects to include this software in this distribution
188.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
188.31 - * single choice of license, a recipient has the option to distribute
188.32 - * your version of this file under either the CDDL, the GPL Version 2 or
188.33 - * to extend the choice of license to its licensees as provided above.
188.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
188.35 - * Version 2 license, then the option applies only if the new code is
188.36 - * made subject to such option by the copyright holder.
188.37 - *
188.38 - * Contributor(s):
188.39 - *
188.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
188.41 - */
188.42 -
188.43 -package org.netbeans.modules.cnd.toolchain.spi;
188.44 -
188.45 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetProvider;
188.46 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
188.47 -
188.48 -/**
188.49 - * An SPI for creation CompilerSetProvider instances
188.50 - * @author Vladimir Kvashin
188.51 - */
188.52 -public interface CompilerSetProviderFactoryImpl {
188.53 - /**
188.54 - * Creates a new instance of CompilerSetProvider
188.55 - * for the given execution environment
188.56 - * @param execEnv execution environment to create CompilerSetProvider for
188.57 - * @return new CompilerSetProvider instance
188.58 - */
188.59 - public CompilerSetProvider createNew(ExecutionEnvironment execEnv);
188.60 -}
189.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/ErrorParserProvider.java Mon Feb 01 12:23:06 2010 +0100
189.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/ErrorParserProvider.java Mon Feb 01 12:24:26 2010 +0100
189.3 @@ -44,7 +44,7 @@
189.4 import java.util.Collections;
189.5 import java.util.List;
189.6 import org.netbeans.api.extexecution.print.ConvertedLine;
189.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
189.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
189.9 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
189.10 import org.openide.filesystems.FileObject;
189.11 import org.openide.util.Lookup;
190.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
190.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/ToolChainPathProvider.java Mon Feb 01 12:24:26 2010 +0100
190.3 @@ -0,0 +1,75 @@
190.4 +/*
190.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
190.6 + *
190.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
190.8 + *
190.9 + * The contents of this file are subject to the terms of either the GNU
190.10 + * General Public License Version 2 only ("GPL") or the Common
190.11 + * Development and Distribution License("CDDL") (collectively, the
190.12 + * "License"). You may not use this file except in compliance with the
190.13 + * License. You can obtain a copy of the License at
190.14 + * http://www.netbeans.org/cddl-gplv2.html
190.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
190.16 + * specific language governing permissions and limitations under the
190.17 + * License. When distributing the software, include this License Header
190.18 + * Notice in each file and include the License file at
190.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
190.20 + * particular file as subject to the "Classpath" exception as provided
190.21 + * by Sun in the GPL Version 2 section of the License file that
190.22 + * accompanied this code. If applicable, add the following below the
190.23 + * License Header, with the fields enclosed by brackets [] replaced by
190.24 + * your own identifying information:
190.25 + * "Portions Copyrighted [year] [name of copyright owner]"
190.26 + *
190.27 + * If you wish your version of this file to be governed by only the CDDL
190.28 + * or only the GPL Version 2, indicate your decision by adding
190.29 + * "[Contributor] elects to include this software in this distribution
190.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
190.31 + * single choice of license, a recipient has the option to distribute
190.32 + * your version of this file under either the CDDL, the GPL Version 2 or
190.33 + * to extend the choice of license to its licensees as provided above.
190.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
190.35 + * Version 2 license, then the option applies only if the new code is
190.36 + * made subject to such option by the copyright holder.
190.37 + *
190.38 + * Contributor(s):
190.39 + *
190.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
190.41 + */
190.42 +
190.43 +package org.netbeans.modules.cnd.toolchain.spi;
190.44 +
190.45 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
190.46 +import org.openide.util.Lookup;
190.47 +
190.48 +/**
190.49 + *
190.50 + * @author Alexander Simon
190.51 + */
190.52 +public abstract class ToolChainPathProvider {
190.53 + private static final ToolChainPathProvider DEFAULT = new DefaultToolChainPathProvider();
190.54 +
190.55 + public static ToolChainPathProvider getDefault() {
190.56 + return DEFAULT;
190.57 + }
190.58 +
190.59 + public abstract String getPath(CompilerFlavor flavor);
190.60 +
190.61 + private static final class DefaultToolChainPathProvider extends ToolChainPathProvider {
190.62 + private final Lookup.Result<ToolChainPathProvider> res;
190.63 + DefaultToolChainPathProvider() {
190.64 + res = Lookup.getDefault().lookupResult(ToolChainPathProvider.class);
190.65 + }
190.66 +
190.67 + @Override
190.68 + public String getPath(CompilerFlavor flavor) {
190.69 + for (ToolChainPathProvider service : res.allInstances()) {
190.70 + String path = service.getPath(flavor);
190.71 + if (path != null) {
190.72 + return path;
190.73 + }
190.74 + }
190.75 + return null;
190.76 + }
190.77 + }
190.78 +}
191.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
191.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/ToolchainProject.java Mon Feb 01 12:24:26 2010 +0100
191.3 @@ -0,0 +1,56 @@
191.4 +/*
191.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
191.6 + *
191.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
191.8 + *
191.9 + * The contents of this file are subject to the terms of either the GNU
191.10 + * General Public License Version 2 only ("GPL") or the Common
191.11 + * Development and Distribution License("CDDL") (collectively, the
191.12 + * "License"). You may not use this file except in compliance with the
191.13 + * License. You can obtain a copy of the License at
191.14 + * http://www.netbeans.org/cddl-gplv2.html
191.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
191.16 + * specific language governing permissions and limitations under the
191.17 + * License. When distributing the software, include this License Header
191.18 + * Notice in each file and include the License file at
191.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
191.20 + * particular file as subject to the "Classpath" exception as provided
191.21 + * by Sun in the GPL Version 2 section of the License file that
191.22 + * accompanied this code. If applicable, add the following below the
191.23 + * License Header, with the fields enclosed by brackets [] replaced by
191.24 + * your own identifying information:
191.25 + * "Portions Copyrighted [year] [name of copyright owner]"
191.26 + *
191.27 + * If you wish your version of this file to be governed by only the CDDL
191.28 + * or only the GPL Version 2, indicate your decision by adding
191.29 + * "[Contributor] elects to include this software in this distribution
191.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
191.31 + * single choice of license, a recipient has the option to distribute
191.32 + * your version of this file under either the CDDL, the GPL Version 2 or
191.33 + * to extend the choice of license to its licensees as provided above.
191.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
191.35 + * Version 2 license, then the option applies only if the new code is
191.36 + * made subject to such option by the copyright holder.
191.37 + *
191.38 + * Contributor(s):
191.39 + *
191.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
191.41 + */
191.42 +
191.43 +package org.netbeans.modules.cnd.toolchain.spi;
191.44 +
191.45 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
191.46 +
191.47 +/**
191.48 + * Interface is returned by project lookup.
191.49 + *
191.50 + * @author Alexander Simon
191.51 + */
191.52 +public interface ToolchainProject {
191.53 +
191.54 + /**
191.55 + *
191.56 + * @return toolchain for active project configuration
191.57 + */
191.58 + CompilerSet getCompilerSet();
191.59 +}
192.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
192.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/spi/ToolchainScriptGenerator.java Mon Feb 01 12:24:26 2010 +0100
192.3 @@ -0,0 +1,261 @@
192.4 +/*
192.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
192.6 + *
192.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
192.8 + *
192.9 + * The contents of this file are subject to the terms of either the GNU
192.10 + * General Public License Version 2 only ("GPL") or the Common
192.11 + * Development and Distribution License("CDDL") (collectively, the
192.12 + * "License"). You may not use this file except in compliance with the
192.13 + * License. You can obtain a copy of the License at
192.14 + * http://www.netbeans.org/cddl-gplv2.html
192.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
192.16 + * specific language governing permissions and limitations under the
192.17 + * License. When distributing the software, include this License Header
192.18 + * Notice in each file and include the License file at
192.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
192.20 + * particular file as subject to the "Classpath" exception as provided
192.21 + * by Sun in the GPL Version 2 section of the License file that
192.22 + * accompanied this code. If applicable, add the following below the
192.23 + * License Header, with the fields enclosed by brackets [] replaced by
192.24 + * your own identifying information:
192.25 + * "Portions Copyrighted [year] [name of copyright owner]"
192.26 + *
192.27 + * If you wish your version of this file to be governed by only the CDDL
192.28 + * or only the GPL Version 2, indicate your decision by adding
192.29 + * "[Contributor] elects to include this software in this distribution
192.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
192.31 + * single choice of license, a recipient has the option to distribute
192.32 + * your version of this file under either the CDDL, the GPL Version 2 or
192.33 + * to extend the choice of license to its licensees as provided above.
192.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
192.35 + * Version 2 license, then the option applies only if the new code is
192.36 + * made subject to such option by the copyright holder.
192.37 + *
192.38 + * Contributor(s):
192.39 + *
192.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
192.41 + */
192.42 +
192.43 +package org.netbeans.modules.cnd.toolchain.spi;
192.44 +
192.45 +
192.46 +import java.util.ArrayList;
192.47 +import java.util.StringTokenizer;
192.48 +import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
192.49 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
192.50 +import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
192.51 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerImpl;
192.52 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolchainManagerImpl;
192.53 +import org.openide.util.NbBundle;
192.54 +
192.55 +/**
192.56 + *
192.57 + * @author Alexander Simon
192.58 + */
192.59 +public final class ToolchainScriptGenerator {
192.60 + private static final boolean TRACE = true;
192.61 + private static final String[] platforms = new String[]{
192.62 + "PLATFORM_SOLARIS_SPARC", // NOI18N
192.63 + "PLATFORM_SOLARIS_INTEL", // NOI18N
192.64 + "PLATFORM_LINUX", // NOI18N
192.65 + //"PLATFORM_WINDOWS", // NOI18N // not supported yet
192.66 + "PLATFORM_MACOSX", // NOI18N
192.67 + "PLATFORM_NONE" // NOI18N
192.68 + };
192.69 + private static final int[] platformsID = new int[]{
192.70 + PlatformTypes.PLATFORM_SOLARIS_SPARC,
192.71 + PlatformTypes.PLATFORM_SOLARIS_INTEL,
192.72 + PlatformTypes.PLATFORM_LINUX,
192.73 + //PlatformTypes.PLATFORM_WINDOWS, // not supported yet
192.74 + PlatformTypes.PLATFORM_MACOSX,
192.75 + PlatformTypes.PLATFORM_NONE
192.76 + };
192.77 + private final StringBuilder buf = new StringBuilder();
192.78 +
192.79 + private ToolchainScriptGenerator(){
192.80 + }
192.81 +
192.82 + public static String generateScript(String path){
192.83 + ToolchainScriptGenerator generator = new ToolchainScriptGenerator();
192.84 + generator.prefix(path);
192.85 + generator.scanPaths();
192.86 + return generator.buf.toString();
192.87 + }
192.88 +
192.89 + private void prefix(String path){
192.90 + line("#!/bin/sh"); // NOI18N
192.91 + lines(NbBundle.getMessage(ToolchainScriptGenerator.class, "DetectHostInfo")); // NOI18N
192.92 + if (path != null) {
192.93 + line("PATHSLIST=\""+path+"\""); // NOI18N
192.94 + } else {
192.95 + line("echo $PLATFORM_NAME"); // NOI18N
192.96 + for(int i = 0; i < platforms.length; i++) {
192.97 + line("if [ \"$PLATFORM\" = \"$"+platforms[i]+"\" ]; then"); // NOI18N
192.98 + if (platformsID[i] == PlatformTypes.PLATFORM_WINDOWS) {
192.99 + line("PATH=$PATH;C:/WINDOWS/System32;C:/WINDOWS;C:/WINDOWS/System32/WBem"); // NOI18N
192.100 + } else if (platformsID[i] != PlatformTypes.PLATFORM_NONE) {
192.101 + line("PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin"); // NOI18N
192.102 + } else {
192.103 + line("PATH=$PATH"); // NOI18N
192.104 + }
192.105 + ArrayList<String> dirlist = new ArrayList<String>();
192.106 + CompilerSetManagerImpl.appendDefaultLocations(platformsID[i], dirlist);
192.107 + for(String s : dirlist) {
192.108 + line("PATH=$PATH:"+s); // NOI18N
192.109 + }
192.110 + line("fi"); // NOI18N
192.111 + }
192.112 + line("PATHSLIST=$PATH"); // NOI18N
192.113 + }
192.114 + line("if [ \"$PLATFORM\" = \"$PLATFORM_WINDOWS\" ]; then"); // NOI18N
192.115 + line(" IFS=;"); // NOI18N
192.116 + line("else"); // NOI18N
192.117 + line(" IFS=:"); // NOI18N
192.118 + line("fi"); // NOI18N
192.119 + line("foundFlavors=\";\""); // NOI18N
192.120 + }
192.121 +
192.122 + private void scanPaths(){
192.123 + line("for f in $PATHSLIST; do"); // NOI18N
192.124 + line(" line="); // NOI18N
192.125 + line(" flavor="); // NOI18N
192.126 + line(" echo $f | egrep -e \"^/\" >/dev/null"); // NOI18N
192.127 + line(" if [ \"$?\" != \"0\" ]; then"); // NOI18N
192.128 + line(" continue # skip relative directories"); // NOI18N
192.129 + line(" fi"); // NOI18N
192.130 + line(" echo $f | egrep -e \"^/usr/ucb\" >/dev/null"); // NOI18N
192.131 + line(" if [ \"$?\" = \"0\" ]; then"); // NOI18N
192.132 + line(" continue # skip /usr/ucb (IZ #142780)"); // NOI18N
192.133 + line(" fi"); // NOI18N
192.134 + scanPath();
192.135 + line("done"); // NOI18N
192.136 + }
192.137 + private void scanPath(){
192.138 + for(int i = 0; i < platforms.length; i++) {
192.139 + line("if [ \"$PLATFORM\" = \"$"+platforms[i]+"\" ]; then"); // NOI18N
192.140 + platformPath(platformsID[i]);
192.141 + line("fi"); // NOI18N
192.142 + }
192.143 + }
192.144 + private void platformPath(int platform){
192.145 + for (ToolchainDescriptor d : ToolchainManagerImpl.getImpl().getToolchains(platform)) {
192.146 + if (d.isAbstract()) {
192.147 + continue;
192.148 + }
192.149 + if (d.getModuleID() != null) {
192.150 + continue;
192.151 + }
192.152 + CompilerDescriptor c = d.getC();
192.153 + if (c == null || c.getNames().length == 0) {
192.154 + continue;
192.155 + }
192.156 + line("status="); // NOI18N
192.157 + line("while [ ! -n \"$status\" ]; do"); // NOI18N
192.158 + if (c.getPathPattern() != null) {
192.159 + // todo windows use case insensitive regexp
192.160 + line(" echo $f | egrep -e \""+c.getPathPattern()+"\" >/dev/null"); // NOI18N
192.161 + line(" status=$?"); // NOI18N
192.162 + line(" if [ ! \"$status\" = \"0\" ]; then"); // NOI18N
192.163 + if (c.getExistFolder() == null) {
192.164 + line(" break"); // NOI18N
192.165 + } else {
192.166 + line(" if [ ! -d \"$f/"+c.getExistFolder()+"\" ]; then"); // NOI18N
192.167 + line(" break"); // NOI18N
192.168 + line(" fi"); // NOI18N
192.169 + }
192.170 + line(" fi"); // NOI18N
192.171 + }
192.172 + line(" file=\"$f/"+c.getNames()[0]+"\""); // NOI18N
192.173 + line(" if [ ! -x \"$file\" ]; then"); // NOI18N
192.174 + if (platform == PlatformTypes.PLATFORM_WINDOWS) {
192.175 + line(" file=\"$f/"+c.getNames()[0]+".exe\""); // NOI18N
192.176 + line(" if [ ! -x \"$f/"+c.getNames()[0]+".exe\" ]; then"); // NOI18N
192.177 + line(" break"); // NOI18N
192.178 + line(" fi"); // NOI18N
192.179 + } else {
192.180 + line(" break"); // NOI18N
192.181 + }
192.182 + line(" fi"); // NOI18N
192.183 + if (c.getVersionFlags() != null && c.getVersionPattern() != null){
192.184 + line(" $file "+c.getVersionFlags()+" 2>&1 | egrep -e \""+c.getVersionPattern()+"\" >/dev/null"); // NOI18N
192.185 + line(" status=$?"); // NOI18N
192.186 + line(" if [ ! \"$status\" = \"0\" ]; then"); // NOI18N
192.187 + line(" break"); // NOI18N
192.188 + line(" fi"); // NOI18N
192.189 + }
192.190 + //Found compiler set
192.191 + line(" line=\""+d.getName()+";$f\""); // NOI18N
192.192 + line(" flavor=\""+d.getName()+";\""); // NOI18N
192.193 + addTool("c", d.getC().getNames(), platform); // NOI18N
192.194 + if (d.getCpp() != null) {
192.195 + addTool("cpp", d.getCpp().getNames(), platform); // NOI18N
192.196 + }
192.197 + if (d.getFortran() != null) {
192.198 + addTool("fortran", d.getFortran().getNames(), platform); // NOI18N
192.199 + }
192.200 + if (d.getAssembler() != null) {
192.201 + addTool("assembler", d.getAssembler().getNames(), platform); // NOI18N
192.202 + }
192.203 + if (d.getMake() != null) {
192.204 + addTool("make", d.getMake().getNames(), platform); // NOI18N
192.205 + }
192.206 + if (d.getDebugger() != null) {
192.207 + addTool("debugger", d.getDebugger().getNames(), platform); // NOI18N
192.208 + }
192.209 + if (d.getCMake() != null) {
192.210 + addTool("cmake", d.getCMake().getNames(), platform); // NOI18N
192.211 + }
192.212 + if (d.getQMake() != null) {
192.213 + addTool("qmake", d.getQMake().getNames(), platform); // NOI18N
192.214 + }
192.215 + line(" addNewToolChain"); // NOI18N
192.216 + line(" break"); // NOI18N
192.217 + line("done"); // NOI18N
192.218 + }
192.219 + }
192.220 +
192.221 + private void addTool(String kind, String[] names, int platform){
192.222 + if (names != null) {
192.223 + StringBuilder list = new StringBuilder();
192.224 + for(String name : names) {
192.225 + if (list.length()>0) {
192.226 + if (platform == PlatformTypes.PLATFORM_WINDOWS) {
192.227 + list.append(';'); // NOI18N
192.228 + } else {
192.229 + list.append(':'); // NOI18N
192.230 + }
192.231 + }
192.232 + list.append(name);
192.233 + }
192.234 + line("findCompiler \""+list.toString()+"\" \""+kind+"\""); // NOI18N
192.235 + }
192.236 + }
192.237 +
192.238 + private void lines(String lines){
192.239 + StringTokenizer st = new StringTokenizer(lines,"\n"); // NOI18N
192.240 + while(st.hasMoreTokens()) {
192.241 + line(st.nextToken());
192.242 + }
192.243 + }
192.244 +
192.245 + int level = 0;
192.246 + private void line(String line){
192.247 + String l = line.trim();
192.248 + if (TRACE) {
192.249 + if (l.equals("fi") || l.equals("done") || l.equals("else") || l.equals("}")){ // NOI18N
192.250 + level--;
192.251 + }
192.252 + if (level >= 0) {
192.253 + for(int i = 0; i < level; i++){
192.254 + buf.append(' ');
192.255 + buf.append(' ');
192.256 + }
192.257 + }
192.258 + if (l.startsWith("while ") || l.startsWith("if ") || l.startsWith("for ") || l.equals("else") || l.endsWith("{")){ // NOI18N
192.259 + level++;
192.260 + }
192.261 + }
192.262 + buf.append(l).append('\n'); // NOI18N
192.263 + }
192.264 +}
193.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
193.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/api/BuildToolsAction.java Mon Feb 01 12:24:26 2010 +0100
193.3 @@ -0,0 +1,181 @@
193.4 +/*
193.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
193.6 + *
193.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
193.8 + *
193.9 + * The contents of this file are subject to the terms of either the GNU
193.10 + * General Public License Version 2 only ("GPL") or the Common
193.11 + * Development and Distribution License("CDDL") (collectively, the
193.12 + * "License"). You may not use this file except in compliance with the
193.13 + * License. You can obtain a copy of the License at
193.14 + * http://www.netbeans.org/cddl-gplv2.html
193.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
193.16 + * specific language governing permissions and limitations under the
193.17 + * License. When distributing the software, include this License Header
193.18 + * Notice in each file and include the License file at
193.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
193.20 + * particular file as subject to the "Classpath" exception as provided
193.21 + * by Sun in the GPL Version 2 section of the License file that
193.22 + * accompanied this code. If applicable, add the following below the
193.23 + * License Header, with the fields enclosed by brackets [] replaced by
193.24 + * your own identifying information:
193.25 + * "Portions Copyrighted [year] [name of copyright owner]"
193.26 + *
193.27 + * Contributor(s):
193.28 + *
193.29 + * The Original Software is NetBeans. The Initial Developer of the Original
193.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
193.31 + * Microsystems, Inc. All Rights Reserved.
193.32 + *
193.33 + * If you wish your version of this file to be governed by only the CDDL
193.34 + * or only the GPL Version 2, indicate your decision by adding
193.35 + * "[Contributor] elects to include this software in this distribution
193.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
193.37 + * single choice of license, a recipient has the option to distribute
193.38 + * your version of this file under either the CDDL, the GPL Version 2 or
193.39 + * to extend the choice of license to its licensees as provided above.
193.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
193.41 + * Version 2 license, then the option applies only if the new code is
193.42 + * made subject to such option by the copyright holder.
193.43 + */
193.44 +
193.45 +package org.netbeans.modules.cnd.toolchain.ui.api;
193.46 +
193.47 +import java.awt.Dialog;
193.48 +import java.awt.Dimension;
193.49 +import java.awt.event.ActionEvent;
193.50 +import java.beans.PropertyChangeEvent;
193.51 +import java.beans.PropertyChangeListener;
193.52 +import java.util.ArrayList;
193.53 +import javax.swing.JButton;
193.54 +import javax.swing.JPanel;
193.55 +import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
193.56 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
193.57 +import org.netbeans.modules.cnd.toolchain.ui.options.DownloadUtils;
193.58 +import org.netbeans.modules.cnd.toolchain.ui.api.LocalToolsPanelModel;
193.59 +import org.netbeans.modules.cnd.toolchain.ui.options.ToolsPanel;
193.60 +import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelModel;
193.61 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
193.62 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
193.63 +import org.openide.DialogDescriptor;
193.64 +import org.openide.DialogDisplayer;
193.65 +import org.openide.util.HelpCtx;
193.66 +import org.openide.util.NbBundle;
193.67 +import org.openide.util.actions.CallableSystemAction;
193.68 +
193.69 +/**
193.70 + * Post the ToolsPanel as a standalone dialog.
193.71 + *
193.72 + * @author gordonp
193.73 + */
193.74 +public class BuildToolsAction extends CallableSystemAction implements PropertyChangeListener {
193.75 +
193.76 + private String title;
193.77 + private String name;
193.78 + private JButton jOK = null;
193.79 + private ToolsPanel tp;
193.80 + private ToolsPanelModel model;
193.81 +
193.82 + public BuildToolsAction() {
193.83 + name = NbBundle.getMessage(BuildToolsAction.class, "LBL_BuildToolsName"); // NOI18N
193.84 + title = NbBundle.getMessage(BuildToolsAction.class, "LBL_BuildToolsTitle"); // NOI18N
193.85 + }
193.86 +
193.87 + @Override
193.88 + public String getName() {
193.89 + return name;
193.90 + }
193.91 +
193.92 + public void setName(String name) {
193.93 + this.name = name;
193.94 + }
193.95 +
193.96 + public String getTitle() {
193.97 + return title;
193.98 + }
193.99 +
193.100 + public void setTitle(String title) {
193.101 + this.title = title;
193.102 + }
193.103 +
193.104 + @Override
193.105 + public void performAction() {
193.106 + initBuildTools(new LocalToolsPanelModel(), new ArrayList<String>(), null);
193.107 + }
193.108 +
193.109 + @Override
193.110 + public void propertyChange(PropertyChangeEvent ev) {
193.111 + if (ev.getPropertyName().equals(ToolsPanel.PROP_VALID) &&
193.112 + ev.getSource() instanceof ToolsPanel) {
193.113 + jOK.setEnabled(((Boolean) ev.getNewValue()).booleanValue());
193.114 + }
193.115 + }
193.116 +
193.117 + public ToolsPanelModel getModel() {
193.118 + return model;
193.119 + }
193.120 +
193.121 + /**
193.122 + * Initialize the build tools
193.123 + *
193.124 + * @returns true if the user pressed OK, false if Cancel
193.125 + */
193.126 + public boolean initBuildTools(ToolsPanelModel model, ArrayList<String> errs, CompilerSet cs) {
193.127 + if (downloadIfNeed(model, cs)){
193.128 + return true;
193.129 + }
193.130 + tp = new ToolsPanel(model);
193.131 + tp.addPropertyChangeListener(this);
193.132 + jOK = new JButton(NbBundle.getMessage(BuildToolsAction.class, "BTN_OK")); // NOI18N
193.133 + tp.setPreferredSize(new Dimension(900, 550));
193.134 + tp.update(errs);
193.135 + DialogDescriptor dd = new DialogDescriptor((Object) constructOuterPanel(tp), getTitle(), true,
193.136 + new Object[] { jOK, DialogDescriptor.CANCEL_OPTION},
193.137 + DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, null, null);
193.138 + Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
193.139 + dialog.setVisible(true);
193.140 + if (dd.getValue() == jOK) {
193.141 + tp.applyChanges(true);
193.142 + return true;
193.143 + }
193.144 + return false;
193.145 + }
193.146 +
193.147 + private boolean downloadIfNeed(ToolsPanelModel model, CompilerSet cs){
193.148 + ExecutionEnvironment env = model.getSelectedDevelopmentHost();
193.149 + if (env.isLocal()){
193.150 + if (cs == null) {
193.151 + cs = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
193.152 + }
193.153 + if (cs != null) {
193.154 + if (cs.isUrlPointer()){
193.155 + // Can be downloaded
193.156 + return DownloadUtils.showDownloadConfirmation(cs);
193.157 + }
193.158 + }
193.159 + }
193.160 + return false;
193.161 + }
193.162 +
193.163 + private JPanel constructOuterPanel(JPanel innerPanel) {
193.164 + JPanel panel = new JPanel();
193.165 + panel.setLayout(new java.awt.GridBagLayout());
193.166 + java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
193.167 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
193.168 + gridBagConstraints.weightx = 1.0;
193.169 + gridBagConstraints.weighty = 1.0;
193.170 + gridBagConstraints.insets = new java.awt.Insets(16, 16, 16, 16);
193.171 + panel.add(innerPanel, gridBagConstraints);
193.172 + return panel;
193.173 + }
193.174 +
193.175 + @Override
193.176 + public void actionPerformed(ActionEvent ev) {
193.177 + performAction();
193.178 + }
193.179 +
193.180 + @Override
193.181 + public HelpCtx getHelpCtx() {
193.182 + return null;
193.183 + }
193.184 +}
194.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
194.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/api/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
194.3 @@ -0,0 +1,47 @@
194.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
194.5 +#
194.6 +# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
194.7 +#
194.8 +# The contents of this file are subject to the terms of either the GNU
194.9 +# General Public License Version 2 only ("GPL") or the Common
194.10 +# Development and Distribution License("CDDL") (collectively, the
194.11 +# "License"). You may not use this file except in compliance with the
194.12 +# License. You can obtain a copy of the License at
194.13 +# http://www.netbeans.org/cddl-gplv2.html
194.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
194.15 +# specific language governing permissions and limitations under the
194.16 +# License. When distributing the software, include this License Header
194.17 +# Notice in each file and include the License file at
194.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
194.19 +# particular file as subject to the "Classpath" exception as provided
194.20 +# by Sun in the GPL Version 2 section of the License file that
194.21 +# accompanied this code. If applicable, add the following below the
194.22 +# License Header, with the fields enclosed by brackets [] replaced by
194.23 +# your own identifying information:
194.24 +# "Portions Copyrighted [year] [name of copyright owner]"
194.25 +#
194.26 +# Contributor(s):
194.27 +#
194.28 +# The Original Software is NetBeans. The Initial Developer of the Original
194.29 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
194.30 +# Microsystems, Inc. All Rights Reserved.
194.31 +#
194.32 +# If you wish your version of this file to be governed by only the CDDL
194.33 +# or only the GPL Version 2, indicate your decision by adding
194.34 +# "[Contributor] elects to include this software in this distribution
194.35 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
194.36 +# single choice of license, a recipient has the option to distribute
194.37 +# your version of this file under either the CDDL, the GPL Version 2 or
194.38 +# to extend the choice of license to its licensees as provided above.
194.39 +# However, if you add GPL Version 2 code and therefore, elected the GPL
194.40 +# Version 2 license, then the option applies only if the new code is
194.41 +# made subject to such option by the copyright holder.
194.42 +
194.43 +BTN_OK=OK
194.44 +
194.45 +# BuildToolsAction
194.46 +LBL_BuildToolsName=Native Build Tools...
194.47 +LBL_BuildToolsTitle=Native Build Tools Setup
194.48 +LBL_InitializeBuildSystem_Title=Initialize Native Build Tools
194.49 +LBL_ResolveMissingTools_Title=Resolve Missing Native Build Tools
194.50 +LBL_ResolveMissingCompilerSets_Title=Resolve Missing Compiler Collections
195.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/api/ToolsCacheManager.java Mon Feb 01 12:23:06 2010 +0100
195.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/api/ToolsCacheManager.java Mon Feb 01 12:24:26 2010 +0100
195.3 @@ -42,11 +42,12 @@
195.4 import java.util.Collection;
195.5 import java.util.HashMap;
195.6 import java.util.List;
195.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
195.8 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
195.9 import org.netbeans.modules.cnd.api.remote.ServerList;
195.10 import org.netbeans.modules.cnd.api.remote.ServerRecord;
195.11 import org.netbeans.modules.cnd.api.remote.ServerUpdateCache;
195.12 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetImpl;
195.13 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerAccessorImpl;
195.14 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
195.15 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
195.16
195.17 @@ -107,7 +108,7 @@
195.18 allCSMs.add(copiedManagers.get(copiedServer));
195.19 }
195.20 }
195.21 - CompilerSetManager.setManagers(allCSMs);
195.22 + CompilerSetManagerAccessorImpl.setManagers(allCSMs);
195.23 copiedManagers.clear();
195.24 }
195.25
195.26 @@ -165,8 +166,8 @@
195.27 public synchronized CompilerSetManager getCompilerSetManagerCopy(ExecutionEnvironment env, boolean initialize) {
195.28 CompilerSetManager out = copiedManagers.get(env);
195.29 if (out == null) {
195.30 - out = CompilerSetManager.getDeepCopy(env, initialize);
195.31 - if (out.getCompilerSets().size() == 1 && out.getCompilerSets().get(0).getName().equals(CompilerSet.None)) {
195.32 + out = CompilerSetManagerAccessorImpl.getDeepCopy(env, initialize);
195.33 + if (out.getCompilerSets().size() == 1 && out.getCompilerSets().get(0).getName().equals(CompilerSetImpl.None)) {
195.34 out.remove(out.getCompilerSets().get(0));
195.35 }
195.36 copiedManagers.put(env, out);
196.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/api/ToolsPanelSupport.java Mon Feb 01 12:23:06 2010 +0100
196.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/api/ToolsPanelSupport.java Mon Feb 01 12:24:26 2010 +0100
196.3 @@ -42,7 +42,7 @@
196.4 import javax.swing.event.ChangeEvent;
196.5 import javax.swing.event.ChangeListener;
196.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
196.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
196.8 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolUtils;
196.9 import org.openide.util.WeakSet;
196.10
196.11 /**
196.12 @@ -58,7 +58,7 @@
196.13 }
196.14
196.15 public static boolean supportedMake(String name) {
196.16 - name = CompilerSetUtils.getBaseName(name);
196.17 + name = ToolUtils.getBaseName(name);
196.18 return !name.toLowerCase().equals("mingw32-make.exe"); // NOI18N
196.19 }
196.20
197.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/AddCompilerSetPanel.java Mon Feb 01 12:23:06 2010 +0100
197.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/AddCompilerSetPanel.java Mon Feb 01 12:24:26 2010 +0100
197.3 @@ -54,10 +54,15 @@
197.4 import javax.swing.event.DocumentEvent;
197.5 import javax.swing.event.DocumentListener;
197.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
197.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
197.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
197.9 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
197.10 +import org.netbeans.modules.cnd.toolchain.spi.CompilerSetFactory;
197.11 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetImpl;
197.12 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
197.13 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
197.14 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerImpl;
197.15 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolUtils;
197.16 import org.netbeans.modules.cnd.utils.ui.FileChooser;
197.17 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
197.18 import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
197.19 import org.openide.DialogDescriptor;
197.20 import org.openide.util.Exceptions;
197.21 @@ -88,19 +93,19 @@
197.22 btBaseDirectory.setMnemonic(0);
197.23 }
197.24
197.25 - List<CompilerFlavor> list = CompilerFlavor.getFlavors(csm.getPlatform());
197.26 + List<CompilerFlavor> list = CompilerFlavorAccessor.getFlavors(csm.getPlatform());
197.27 for (CompilerFlavor cf : list) {
197.28 cbFamily.addItem(cf);
197.29 }
197.30 // add unknown as well
197.31 - cbFamily.addItem(CompilerFlavor.getUnknown(csm.getPlatform()));
197.32 + cbFamily.addItem(CompilerFlavorAccessor.getUnknown(csm.getPlatform()));
197.33 tfName.setText(""); // NOI18N
197.34 validateData();
197.35
197.36 setPreferredSize(new Dimension(800, 300));
197.37
197.38 - tfBaseDirectory.getDocument().addDocumentListener(this);
197.39 - tfName.getDocument().addDocumentListener(this);
197.40 + tfBaseDirectory.getDocument().addDocumentListener(AddCompilerSetPanel.this);
197.41 + tfName.getDocument().addDocumentListener(AddCompilerSetPanel.this);
197.42 }
197.43
197.44 @Override
197.45 @@ -133,11 +138,11 @@
197.46 if (local) {
197.47 //This will be invoked in UI thread
197.48 File dirFile = new File(tfBaseDirectory.getText());
197.49 - List<CompilerFlavor> flavors = CompilerSet.getCompilerSetFlavor(dirFile.getAbsolutePath(), csm.getPlatform());
197.50 + List<CompilerFlavor> flavors = CompilerSetFactory.getCompilerSetFlavor(dirFile.getAbsolutePath(), csm.getPlatform());
197.51 if (flavors.size() > 0) {
197.52 cbFamily.setSelectedItem(flavors.get(0));
197.53 } else {
197.54 - cbFamily.setSelectedItem(CompilerFlavor.getUnknown(csm.getPlatform()));
197.55 + cbFamily.setSelectedItem(CompilerFlavorAccessor.getUnknown(csm.getPlatform()));
197.56 }
197.57 updateDataFamily();
197.58 if (!dialogDescriptor.isValid()) {
197.59 @@ -230,7 +235,7 @@
197.60 }
197.61
197.62 private void updateDataFamily() {
197.63 - CompilerSet.CompilerFlavor flavor = (CompilerSet.CompilerFlavor) cbFamily.getSelectedItem();
197.64 + CompilerFlavor flavor = (CompilerFlavor) cbFamily.getSelectedItem();
197.65 int n = 0;
197.66 String suggestedName = null;
197.67 while (true) {
197.68 @@ -252,7 +257,7 @@
197.69
197.70 if (local) {
197.71 File dirFile = new File(tfBaseDirectory.getText());
197.72 - if (valid && !dirFile.exists() || !dirFile.isDirectory() || !CompilerSetUtils.isPathAbsolute(dirFile.getPath())) {
197.73 + if (valid && !dirFile.exists() || !dirFile.isDirectory() || !ToolUtils.isPathAbsolute(dirFile.getPath())) {
197.74 valid = false;
197.75 lbError.setText(getString("BASE_INVALID"));
197.76 }
197.77 @@ -268,7 +273,7 @@
197.78 cbFamily.setEnabled(valid);
197.79 tfName.setEnabled(valid);
197.80
197.81 - String compilerSetName = CompilerSetUtils.replaceOddCharacters(tfName.getText().trim(), '_');
197.82 + String compilerSetName = ToolUtils.replaceOddCharacters(tfName.getText().trim(), '_');
197.83 if (valid && compilerSetName.length() == 0 || compilerSetName.contains("|")) { // NOI18N
197.84 valid = false;
197.85 lbError.setText(getString("NAME_INVALID"));
197.86 @@ -313,27 +318,26 @@
197.87 return tfBaseDirectory.getText();
197.88 }
197.89
197.90 - private CompilerSet.CompilerFlavor getFamily() {
197.91 - return (CompilerSet.CompilerFlavor) cbFamily.getSelectedItem();
197.92 + private CompilerFlavor getFamily() {
197.93 + return (CompilerFlavor) cbFamily.getSelectedItem();
197.94 }
197.95
197.96 private String getCompilerSetName() {
197.97 - return CompilerSetUtils.replaceOddCharacters(tfName.getText().trim(), '_');
197.98 + return ToolUtils.replaceOddCharacters(tfName.getText().trim(), '_');
197.99 }
197.100
197.101 public CompilerSet getCompilerSet() {
197.102 String compilerSetName = getCompilerSetName().trim();
197.103 if (local) {
197.104 String baseDirectory = getBaseDirectory();
197.105 - CompilerSet.CompilerFlavor flavor = getFamily();
197.106 -
197.107 - CompilerSet cs = CompilerSet.getCustomCompilerSet(new File(baseDirectory).getAbsolutePath(), flavor, compilerSetName);
197.108 - CompilerSetManager.getDefault().initCompilerSet(cs);
197.109 + CompilerFlavor flavor = getFamily();
197.110 + CompilerSet cs = CompilerSetFactory.getCustomCompilerSet(new File(baseDirectory).getAbsolutePath(), flavor, compilerSetName);
197.111 + ((CompilerSetManagerImpl)CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal())).initCompilerSet(cs);
197.112 return cs;
197.113 } else {
197.114 synchronized (lock) {
197.115 if (lastFoundRemoteCompilerSet != null){
197.116 - lastFoundRemoteCompilerSet.setName(compilerSetName);
197.117 + ((CompilerSetImpl)lastFoundRemoteCompilerSet).setName(compilerSetName);
197.118 return lastFoundRemoteCompilerSet;
197.119 }else{
197.120 return lastFoundRemoteCompilerSet;
198.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/AddRemoveListModel.java Mon Feb 01 12:23:06 2010 +0100
198.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
198.3 @@ -1,99 +0,0 @@
198.4 -/*
198.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
198.6 - *
198.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
198.8 - *
198.9 - * The contents of this file are subject to the terms of either the GNU
198.10 - * General Public License Version 2 only ("GPL") or the Common
198.11 - * Development and Distribution License("CDDL") (collectively, the
198.12 - * "License"). You may not use this file except in compliance with the
198.13 - * License. You can obtain a copy of the License at
198.14 - * http://www.netbeans.org/cddl-gplv2.html
198.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
198.16 - * specific language governing permissions and limitations under the
198.17 - * License. When distributing the software, include this License Header
198.18 - * Notice in each file and include the License file at
198.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
198.20 - * particular file as subject to the "Classpath" exception as provided
198.21 - * by Sun in the GPL Version 2 section of the License file that
198.22 - * accompanied this code. If applicable, add the following below the
198.23 - * License Header, with the fields enclosed by brackets [] replaced by
198.24 - * your own identifying information:
198.25 - * "Portions Copyrighted [year] [name of copyright owner]"
198.26 - *
198.27 - * Contributor(s):
198.28 - *
198.29 - * The Original Software is NetBeans. The Initial Developer of the Original
198.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
198.31 - * Microsystems, Inc. All Rights Reserved.
198.32 - *
198.33 - * If you wish your version of this file to be governed by only the CDDL
198.34 - * or only the GPL Version 2, indicate your decision by adding
198.35 - * "[Contributor] elects to include this software in this distribution
198.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
198.37 - * single choice of license, a recipient has the option to distribute
198.38 - * your version of this file under either the CDDL, the GPL Version 2 or
198.39 - * to extend the choice of license to its licensees as provided above.
198.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
198.41 - * Version 2 license, then the option applies only if the new code is
198.42 - * made subject to such option by the copyright holder.
198.43 - */
198.44 -
198.45 -package org.netbeans.modules.cnd.toolchain.ui.options;
198.46 -
198.47 -import java.util.ArrayList;
198.48 -import java.util.List;
198.49 -import javax.swing.DefaultListModel;
198.50 -import org.netbeans.modules.cnd.toolchain.api.Tool;
198.51 -
198.52 -/**
198.53 - * Manage a JList with both add and remove lists.
198.54 - *
198.55 - * @author gordon
198.56 - */
198.57 -/*package-local*/ final class AddRemoveListModel extends DefaultListModel {
198.58 -
198.59 - private ArrayList<String> addList;
198.60 - private ArrayList<Object> removeList;
198.61 -
198.62 - /** Creates a new instance of AddRemoveListModel */
198.63 - public AddRemoveListModel() {
198.64 - addList = new ArrayList<String>();
198.65 - removeList = new ArrayList<Object>();
198.66 - }
198.67 -
198.68 - public void addAddElement(String s) {
198.69 - if (!contains(s)) {
198.70 - for (int i = 0; i < getSize(); i++) {
198.71 - Object o = elementAt(i);
198.72 - if (o instanceof Tool) {
198.73 - Tool tool = (Tool) o;
198.74 - if (tool.getName().equals(s)) {
198.75 - return;
198.76 - }
198.77 - }
198.78 - }
198.79 - addList.add(s);
198.80 - addElement(s);
198.81 - }
198.82 - }
198.83 -
198.84 - @Override
198.85 - public Object remove(int idx) {
198.86 - Object o = super.remove(idx);
198.87 - if (addList.contains(o)) {
198.88 - addList.remove(o);
198.89 - } else {
198.90 - removeList.add(o);
198.91 - }
198.92 - return o;
198.93 - }
198.94 -
198.95 - public List<String> getAddList() {
198.96 - return addList;
198.97 - }
198.98 -
198.99 - public List getRemoveList() {
198.100 - return removeList;
198.101 - }
198.102 -}
199.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/DuplicateCompilerSetPanel.java Mon Feb 01 12:23:06 2010 +0100
199.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/DuplicateCompilerSetPanel.java Mon Feb 01 12:24:26 2010 +0100
199.3 @@ -45,9 +45,10 @@
199.4 import javax.swing.event.DocumentEvent;
199.5 import javax.swing.event.DocumentListener;
199.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
199.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
199.8 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavor;
199.9 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
199.10 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
199.11 +import org.netbeans.modules.cnd.toolchain.api.CompilerFlavorAccessor;
199.12 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolUtils;
199.13 import org.openide.DialogDescriptor;
199.14 import org.openide.util.NbBundle;
199.15
199.16 @@ -64,7 +65,7 @@
199.17 initComponents();
199.18 this.csm = csm;
199.19
199.20 - List<CompilerFlavor> list = CompilerFlavor.getFlavors(csm.getPlatform());
199.21 + List<CompilerFlavor> list = CompilerFlavorAccessor.getFlavors(csm.getPlatform());
199.22 for (CompilerFlavor cf : list) {
199.23 cbFamily.addItem(cf);
199.24 }
199.25 @@ -91,7 +92,7 @@
199.26 }
199.27
199.28 private void updateDataFamily() {
199.29 - CompilerSet.CompilerFlavor flavor = (CompilerSet.CompilerFlavor)cbFamily.getSelectedItem();
199.30 + CompilerFlavor flavor = (CompilerFlavor)cbFamily.getSelectedItem();
199.31 String suggestedName = csm.getUniqueCompilerSetName(flavor.toString());
199.32 tfName.setText(suggestedName);
199.33 updateDataName();
199.34 @@ -105,7 +106,7 @@
199.35 boolean valid = true;
199.36 lbError.setText(""); // NOI18N
199.37
199.38 - String compilerSetName = CompilerSetUtils.replaceOddCharacters(tfName.getText().trim(), '_');
199.39 + String compilerSetName = ToolUtils.replaceOddCharacters(tfName.getText().trim(), '_');
199.40 if (valid && compilerSetName.length() == 0 || compilerSetName.contains("|")) { // NOI18N
199.41 valid = false;
199.42 lbError.setText(getString("NAME_INVALID"));
199.43 @@ -144,12 +145,12 @@
199.44 return tfBaseDirectory.getText();
199.45 }
199.46
199.47 - public CompilerSet.CompilerFlavor getFamily() {
199.48 - return (CompilerSet.CompilerFlavor)cbFamily.getSelectedItem();
199.49 + public CompilerFlavor getFamily() {
199.50 + return (CompilerFlavor)cbFamily.getSelectedItem();
199.51 }
199.52
199.53 public String getCompilerSetName() {
199.54 - return CompilerSetUtils.replaceOddCharacters(tfName.getText().trim(), '_');
199.55 + return ToolUtils.replaceOddCharacters(tfName.getText().trim(), '_');
199.56 }
199.57
199.58 /** This method is called from within the constructor to
200.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolCollectionPanel.java Mon Feb 01 12:23:06 2010 +0100
200.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolCollectionPanel.java Mon Feb 01 12:24:26 2010 +0100
200.3 @@ -59,9 +59,10 @@
200.4 import javax.swing.text.Document;
200.5 import org.netbeans.api.progress.ProgressHandle;
200.6 import org.netbeans.api.progress.ProgressHandleFactory;
200.7 +import org.netbeans.modules.cnd.toolchain.api.Tool;
200.8 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
200.9 -import org.netbeans.modules.cnd.toolchain.api.Tool;
200.10 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetUtils;
200.11 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
200.12 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolUtils;
200.13 import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelSupport;
200.14 import org.netbeans.modules.cnd.utils.ui.FileChooser;
200.15 import org.netbeans.modules.nativeexecution.api.util.Path;
200.16 @@ -171,23 +172,23 @@
200.17 return;
200.18 }
200.19 if (force) {
200.20 - cs.getTool(Tool.CCompiler).setPath(tfCPath.getText());
200.21 - cs.getTool(Tool.CCCompiler).setPath(tfCppPath.getText());
200.22 - cs.getTool(Tool.FortranCompiler).setPath(tfFortranPath.getText());
200.23 - cs.getTool(Tool.Assembler).setPath(tfAsPath.getText());
200.24 - cs.getTool(Tool.MakeTool).setPath(tfMakePath.getText());
200.25 - cs.getTool(Tool.DebuggerTool).setPath(tfDebuggerPath.getText());
200.26 - cs.getTool(Tool.QMakeTool).setPath(tfQMakePath.getText());
200.27 - cs.getTool(Tool.CMakeTool).setPath(tfCMakePath.getText());
200.28 + cs.getTool(ToolKind.CCompiler).setPath(tfCPath.getText());
200.29 + cs.getTool(ToolKind.CCCompiler).setPath(tfCppPath.getText());
200.30 + cs.getTool(ToolKind.FortranCompiler).setPath(tfFortranPath.getText());
200.31 + cs.getTool(ToolKind.Assembler).setPath(tfAsPath.getText());
200.32 + cs.getTool(ToolKind.MakeTool).setPath(tfMakePath.getText());
200.33 + cs.getTool(ToolKind.DebuggerTool).setPath(tfDebuggerPath.getText());
200.34 + cs.getTool(ToolKind.QMakeTool).setPath(tfQMakePath.getText());
200.35 + cs.getTool(ToolKind.CMakeTool).setPath(tfCMakePath.getText());
200.36 } else {
200.37 - cs.findTool(Tool.CCompiler).setPath(tfCPath.getText());
200.38 - cs.findTool(Tool.CCCompiler).setPath(tfCppPath.getText());
200.39 - cs.findTool(Tool.FortranCompiler).setPath(tfFortranPath.getText());
200.40 - cs.findTool(Tool.Assembler).setPath(tfAsPath.getText());
200.41 - cs.findTool(Tool.MakeTool).setPath(tfMakePath.getText());
200.42 - cs.findTool(Tool.DebuggerTool).setPath(tfDebuggerPath.getText());
200.43 - cs.findTool(Tool.QMakeTool).setPath(tfQMakePath.getText());
200.44 - cs.findTool(Tool.CMakeTool).setPath(tfCMakePath.getText());
200.45 + cs.findTool(ToolKind.CCompiler).setPath(tfCPath.getText());
200.46 + cs.findTool(ToolKind.CCCompiler).setPath(tfCppPath.getText());
200.47 + cs.findTool(ToolKind.FortranCompiler).setPath(tfFortranPath.getText());
200.48 + cs.findTool(ToolKind.Assembler).setPath(tfAsPath.getText());
200.49 + cs.findTool(ToolKind.MakeTool).setPath(tfMakePath.getText());
200.50 + cs.findTool(ToolKind.DebuggerTool).setPath(tfDebuggerPath.getText());
200.51 + cs.findTool(ToolKind.QMakeTool).setPath(tfQMakePath.getText());
200.52 + cs.findTool(ToolKind.CMakeTool).setPath(tfCMakePath.getText());
200.53 }
200.54 }
200.55
200.56 @@ -279,14 +280,14 @@
200.57 Tool qmakeToolSelection = null;
200.58 Tool cmakeToolSelection = null;
200.59 if (!cs.isUrlPointer()) {
200.60 - cSelection = cs.getTool(Tool.CCompiler);
200.61 - cppSelection = cs.getTool(Tool.CCCompiler);
200.62 - fortranSelection = cs.getTool(Tool.FortranCompiler);
200.63 - asSelection = cs.getTool(Tool.Assembler);
200.64 - makeToolSelection = cs.getTool(Tool.MakeTool);
200.65 - debuggerToolSelection = cs.getTool(Tool.DebuggerTool);
200.66 - qmakeToolSelection = cs.getTool(Tool.QMakeTool);
200.67 - cmakeToolSelection = cs.getTool(Tool.CMakeTool);
200.68 + cSelection = cs.getTool(ToolKind.CCompiler);
200.69 + cppSelection = cs.getTool(ToolKind.CCCompiler);
200.70 + fortranSelection = cs.getTool(ToolKind.FortranCompiler);
200.71 + asSelection = cs.getTool(ToolKind.Assembler);
200.72 + makeToolSelection = cs.getTool(ToolKind.MakeTool);
200.73 + debuggerToolSelection = cs.getTool(ToolKind.DebuggerTool);
200.74 + qmakeToolSelection = cs.getTool(ToolKind.QMakeTool);
200.75 + cmakeToolSelection = cs.getTool(ToolKind.CMakeTool);
200.76 }
200.77 if (cSelection != null) {
200.78 setCPathField(cSelection.getPath());
200.79 @@ -583,42 +584,42 @@
200.80 }
200.81 Document doc = ev.getDocument();
200.82 String title = (String) doc.getProperty(Document.TitleProperty);
200.83 - int toolKind = -1;
200.84 + ToolKind toolKind = ToolKind.UnknownTool;
200.85 String toolPath = null;
200.86 if (title.equals(MAKE_NAME)) {
200.87 validateMakePathField();
200.88 - toolKind = Tool.MakeTool;
200.89 + toolKind = ToolKind.MakeTool;
200.90 toolPath = tfMakePath.getText();
200.91 } else if (title.equals(DEBUGGER_NAME)) {
200.92 validateGdbPathField();
200.93 - toolKind = Tool.DebuggerTool;
200.94 + toolKind = ToolKind.DebuggerTool;
200.95 toolPath = tfDebuggerPath.getText();
200.96 } else if (title.equals(C_NAME)) {
200.97 validateCPathField();
200.98 - toolKind = Tool.CCompiler;
200.99 + toolKind = ToolKind.CCompiler;
200.100 toolPath = tfCPath.getText();
200.101 } else if (title.equals(CPP_NAME)) {
200.102 validateCppPathField();
200.103 - toolKind = Tool.CCCompiler;
200.104 + toolKind = ToolKind.CCCompiler;
200.105 toolPath = tfCppPath.getText();
200.106 } else if (title.equals(FORTRAN_NAME)) {
200.107 validateFortranPathField();
200.108 - toolKind = Tool.FortranCompiler;
200.109 + toolKind = ToolKind.FortranCompiler;
200.110 toolPath = tfFortranPath.getText();
200.111 } else if (title.equals(ASSEMBLER_NAME)) {
200.112 validateAsPathField();
200.113 - toolKind = Tool.Assembler;
200.114 + toolKind = ToolKind.Assembler;
200.115 toolPath = tfAsPath.getText();
200.116 } else if (title.equals(QMAKE_NAME)) {
200.117 validateQMakePathField();
200.118 - toolKind = Tool.QMakeTool;
200.119 + toolKind = ToolKind.QMakeTool;
200.120 toolPath = tfQMakePath.getText();
200.121 } else if (title.equals(CMAKE_NAME)) {
200.122 validateCMakePathField();
200.123 - toolKind = Tool.CMakeTool;
200.124 + toolKind = ToolKind.CMakeTool;
200.125 toolPath = tfCMakePath.getText();
200.126 }
200.127 - if (userChange && 0 <= toolKind) {
200.128 + if (userChange && toolKind != ToolKind.UnknownTool) {
200.129 manager.getCurrentCompilerSet().getTool(toolKind).setPath(toolPath);
200.130 manager.fireCompilerSetChange();
200.131 manager.fireCompilerSetModified();
200.132 @@ -645,7 +646,7 @@
200.133 version.append(tool.getDisplayName()).append(": "); // NOI18N
200.134 if (isPathFieldValid(tf)) {
200.135 String path = tf.getText();
200.136 - if (!CompilerSetUtils.isPathAbsolute(path)) {
200.137 + if (!ToolUtils.isPathAbsolute(path)) {
200.138 path = Path.findCommand(path);
200.139 }
200.140 String v = postVersionInfo(tool, path);
200.141 @@ -680,23 +681,23 @@
200.142 StringBuilder versions = new StringBuilder();
200.143 int i = 0;
200.144 versions.append('\n'); // NOI18N
200.145 - versions.append(getToolVersion(cs.findTool(Tool.CCompiler), tfCPath)).append('\n'); // NOI18N
200.146 + versions.append(getToolVersion(cs.findTool(ToolKind.CCompiler), tfCPath)).append('\n'); // NOI18N
200.147 handle.progress(++i);
200.148 - versions.append(getToolVersion(cs.findTool(Tool.CCCompiler), tfCppPath)).append('\n'); // NOI18N
200.149 + versions.append(getToolVersion(cs.findTool(ToolKind.CCCompiler), tfCppPath)).append('\n'); // NOI18N
200.150 handle.progress(++i);
200.151 - versions.append(getToolVersion(cs.findTool(Tool.FortranCompiler), tfFortranPath)).append('\n'); // NOI18N
200.152 + versions.append(getToolVersion(cs.findTool(ToolKind.FortranCompiler), tfFortranPath)).append('\n'); // NOI18N
200.153 handle.progress(++i);
200.154 - versions.append(getToolVersion(cs.findTool(Tool.Assembler), tfAsPath)).append('\n'); // NOI18N
200.155 + versions.append(getToolVersion(cs.findTool(ToolKind.Assembler), tfAsPath)).append('\n'); // NOI18N
200.156 handle.progress(++i);
200.157 - versions.append(getToolVersion(cs.findTool(Tool.MakeTool), tfMakePath)).append('\n'); // NOI18N
200.158 + versions.append(getToolVersion(cs.findTool(ToolKind.MakeTool), tfMakePath)).append('\n'); // NOI18N
200.159 if (manager.isCustomizableDebugger()) {
200.160 handle.progress(++i);
200.161 - versions.append(getToolVersion(cs.findTool(Tool.DebuggerTool), tfDebuggerPath)).append('\n'); // NOI18N
200.162 + versions.append(getToolVersion(cs.findTool(ToolKind.DebuggerTool), tfDebuggerPath)).append('\n'); // NOI18N
200.163 }
200.164 handle.progress(++i);
200.165 - versions.append(getToolVersion(cs.findTool(Tool.QMakeTool), tfQMakePath)).append('\n'); // NOI18N
200.166 + versions.append(getToolVersion(cs.findTool(ToolKind.QMakeTool), tfQMakePath)).append('\n'); // NOI18N
200.167 handle.progress(++i);
200.168 - versions.append(getToolVersion(cs.findTool(Tool.CMakeTool), tfCMakePath)).append('\n'); // NOI18N
200.169 + versions.append(getToolVersion(cs.findTool(ToolKind.CMakeTool), tfCMakePath)).append('\n'); // NOI18N
200.170 handle.finish();
200.171 String upgradeUrl = cs.getCompilerFlavor().getToolchainDescriptor().getUpgradeUrl();
200.172 if (upgradeUrl != null) {
201.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolsPanel.java Mon Feb 01 12:23:06 2010 +0100
201.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolsPanel.java Mon Feb 01 12:24:26 2010 +0100
201.3 @@ -70,6 +70,9 @@
201.4 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
201.5 import org.netbeans.modules.cnd.api.remote.ServerList;
201.6 import org.netbeans.modules.cnd.api.remote.ServerRecord;
201.7 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetImpl;
201.8 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerAccessorImpl;
201.9 +import org.netbeans.modules.cnd.toolchain.compilers.impl.CompilerSetManagerImpl;
201.10 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
201.11 import org.netbeans.modules.cnd.toolchain.ui.api.ToolsPanelSupport;
201.12 import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg;
201.13 @@ -116,7 +119,7 @@
201.14 initComponents();
201.15 setName("TAB_ToolsTab"); // NOI18N (used as a pattern...)
201.16 changed = false;
201.17 - instance = this;
201.18 + instance = ToolsPanel.this;
201.19 currentCompilerSet = null;
201.20 if (ToolsPanelSupport.getToolsCacheManager().isRemoteAvailable()) {
201.21 execEnv = ToolsPanelSupport.getToolsCacheManager().getDefaultHostEnvironment();
201.22 @@ -132,7 +135,7 @@
201.23 setOpaque(false);
201.24 }
201.25
201.26 - HelpCtx.setHelpIDString(this, "ResolveBuildTools"); // NOI18N
201.27 + HelpCtx.setHelpIDString(ToolsPanel.this, "ResolveBuildTools"); // NOI18N
201.28 }
201.29
201.30 public ToolsPanel(ToolsPanelModel model) {
201.31 @@ -250,10 +253,8 @@
201.32 return;
201.33 }
201.34 String compilerSetName = panel.getCompilerSetName().trim();
201.35 - CompilerSet cs = selectedCompilerSet.createCopy();
201.36 - cs.setName(compilerSetName);
201.37 - cs.unsetDefault();
201.38 - cs.setAutoGenerated(false);
201.39 + CompilerSetImpl cs = ((CompilerSetImpl) selectedCompilerSet).createCopy(
201.40 + selectedCompilerSet.getCompilerFlavor(), selectedCompilerSet.getDirectory(), compilerSetName, false);
201.41 csm.add(cs);
201.42 changed = true;
201.43 update(false, cs, null);
201.44 @@ -270,7 +271,7 @@
201.45 btAdd.setEnabled(isHostValidForEditing());
201.46 btRemove.setEnabled(cbRemoveEnabled && isHostValidForEditing());
201.47 btDuplicate.setEnabled(lstDirlist.getSelectedIndex() >= 0 && isHostValidForEditing());
201.48 - btDefault.setEnabled(lstDirlist.getSelectedIndex() >= 0 && !((CompilerSet) lstDirlist.getSelectedValue()).isDefault());
201.49 + btDefault.setEnabled(lstDirlist.getSelectedIndex() >= 0 && !((CompilerSetImpl) lstDirlist.getSelectedValue()).isDefault());
201.50 }
201.51
201.52 private void onNewDevHostSelected() {
201.53 @@ -294,11 +295,12 @@
201.54 }
201.55
201.56 private void removeCompilerSet() {
201.57 - CompilerSet cs = (CompilerSet) lstDirlist.getSelectedValue();
201.58 + CompilerSetImpl cs = (CompilerSetImpl) lstDirlist.getSelectedValue();
201.59 if (cs != null) {
201.60 int index = csm.getCompilerSets().indexOf(cs);
201.61 + boolean wasDefault = csm.isDefaultCompilerSet(cs);
201.62 csm.remove(cs);
201.63 - if (cs.isDefault()) {
201.64 + if (wasDefault) {
201.65 if (csm.getCompilerSets().size() > 0) {
201.66 csm.setDefault(csm.getCompilerSet(0));
201.67 }
201.68 @@ -951,7 +953,7 @@
201.69 @Override
201.70 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
201.71 Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
201.72 - CompilerSet cs = (CompilerSet) value;
201.73 + CompilerSetImpl cs = (CompilerSetImpl) value;
201.74 if (cs != null && cs.isDefault()) {
201.75 comp.setFont(comp.getFont().deriveFont(Font.BOLD));
201.76 }
201.77 @@ -1011,8 +1013,8 @@
201.78 // cancelled.set(true);
201.79 // return;
201.80 // }
201.81 - CompilerSetManager newCsm = CompilerSetManager.create(execEnv);
201.82 - newCsm.initialize(false, true);
201.83 + CompilerSetManagerImpl newCsm = CompilerSetManagerAccessorImpl.create(execEnv);
201.84 + newCsm.initialize(false, true, null);
201.85 while (newCsm.isPending()) {
201.86 log.finest("\twaiting for compiler manager to initialize...");
201.87 try {
201.88 @@ -1031,7 +1033,7 @@
201.89 String newName = newCsm.getUniqueCompilerSetName(name);
201.90 if (!name.equals(newName)) {
201.91 // FIXUP: show a dialog with renamed custom sets. Can't do now because of UI freeze.
201.92 - cs.setName(newName);
201.93 + ((CompilerSetImpl)cs).setName(newName);
201.94 }
201.95 newCsm.add(cs);
201.96 }
202.1 --- a/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/ReadRegistryTestCase.java Mon Feb 01 12:23:06 2010 +0100
202.2 +++ b/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/ReadRegistryTestCase.java Mon Feb 01 12:24:26 2010 +0100
202.3 @@ -40,15 +40,14 @@
202.4 */
202.5 package org.netbeans.modules.cnd.toolchain.api;
202.6
202.7 -import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
202.8 import java.util.List;
202.9 import java.util.regex.Matcher;
202.10 import java.util.regex.Pattern;
202.11 import org.netbeans.junit.NbTestCase;
202.12 -import org.netbeans.modules.cnd.toolchain.api.CompilerSet.CompilerFlavor;
202.13 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.BaseFolder;
202.14 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.CompilerDescriptor;
202.15 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
202.16 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolchainManagerImpl;
202.17
202.18 /**
202.19 *
202.20 @@ -78,7 +77,7 @@
202.21 }
202.22
202.23 public void testCygwin() throws Exception {
202.24 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
202.25 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
202.26 assertNotNull(d);
202.27 assertTrue("Cygwin".equals(d.getName()));
202.28 List<BaseFolder> list = d.getBaseFolders();
202.29 @@ -112,7 +111,7 @@
202.30 }
202.31
202.32 public void testCygwin17() throws Exception {
202.33 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
202.34 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
202.35 assertNotNull(d);
202.36 assertTrue("Cygwin".equals(d.getName()));
202.37 List<BaseFolder> list = d.getBaseFolders();
202.38 @@ -146,7 +145,7 @@
202.39 }
202.40
202.41 public void testMinGW() throws Exception {
202.42 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("MinGW", PlatformTypes.PLATFORM_WINDOWS);
202.43 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("MinGW", PlatformTypes.PLATFORM_WINDOWS);
202.44 assertNotNull(d);
202.45 assertTrue("MinGW".equals(d.getName()));
202.46 List<BaseFolder> list = d.getBaseFolders();
202.47 @@ -246,7 +245,7 @@
202.48 "-Wall", // More Warnings // NOI18N
202.49 "-Werror", // Convert Warnings to Errors // NOI18N
202.50 };
202.51 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
202.52 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
202.53 assertNotNull(d);
202.54 assertTrue("GNU".equals(d.getName()));
202.55 CompilerDescriptor c = d.getC();
202.56 @@ -296,7 +295,7 @@
202.57 "", // Default // NOI18N
202.58 "", // All // NOI18N
202.59 };
202.60 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.61 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.62 assertNotNull(d);
202.63 assertTrue("SunStudio".equals(d.getName()));
202.64 CompilerDescriptor c = d.getC();
202.65 @@ -348,7 +347,7 @@
202.66 "", // Default // NOI18N
202.67 "-features=extensions,tmplrefstatic,iddollar", // All // NOI18N
202.68 };
202.69 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.70 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.71 assertNotNull(d);
202.72 assertTrue("SunStudio".equals(d.getName()));
202.73 CompilerDescriptor c = d.getCpp();
202.74 @@ -376,7 +375,7 @@
202.75 "-w2", // More Warnings // NOI18N
202.76 "-errwarn", // Convert Warnings to Errors // NOI18N
202.77 };
202.78 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.79 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.80 assertNotNull(d);
202.81 CompilerDescriptor c = d.getFortran();
202.82 assertNotNull(c);
202.83 @@ -386,54 +385,54 @@
202.84
202.85 public void testUnknownService() throws Exception {
202.86 ToolchainDescriptor d;
202.87 - d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_SOLARIS_SPARC);
202.88 + d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_SOLARIS_SPARC);
202.89 assertNotNull(d);
202.90 assertTrue("GNU".equals(d.getName()));
202.91 - d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.92 + d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.93 assertNotNull(d);
202.94 assertTrue("GNU".equals(d.getName()));
202.95 - d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
202.96 + d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
202.97 assertNotNull(d);
202.98 assertTrue("GNU".equals(d.getName()));
202.99 - d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_WINDOWS);
202.100 + d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_WINDOWS);
202.101 assertNotNull(d);
202.102 assertTrue("GNU".equals(d.getName()));
202.103 - d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_MACOSX);
202.104 + d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_MACOSX);
202.105 assertNotNull(d);
202.106 assertTrue("GNU".equals(d.getName()));
202.107 - d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_GENERIC);
202.108 + d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_GENERIC);
202.109 assertNotNull(d);
202.110 assertTrue("GNU".equals(d.getName()));
202.111 - d = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_NONE);
202.112 + d = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_NONE);
202.113 assertNotNull(d);
202.114 assertTrue("GNU".equals(d.getName()));
202.115
202.116 CompilerFlavor f;
202.117 - f = CompilerFlavor.getUnknown(PlatformTypes.PLATFORM_SOLARIS_SPARC);
202.118 + f = CompilerFlavorAccessor.getUnknown(PlatformTypes.PLATFORM_SOLARIS_SPARC);
202.119 assertNotNull(f);
202.120 assertTrue("Unknown".equals(f.toString()));
202.121 assertTrue(f.isGnuCompiler());
202.122 - f = CompilerFlavor.getUnknown(PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.123 + f = CompilerFlavorAccessor.getUnknown(PlatformTypes.PLATFORM_SOLARIS_INTEL);
202.124 assertNotNull(f);
202.125 assertTrue("Unknown".equals(f.toString()));
202.126 assertTrue(f.isGnuCompiler());
202.127 - f = CompilerFlavor.getUnknown(PlatformTypes.PLATFORM_LINUX);
202.128 + f = CompilerFlavorAccessor.getUnknown(PlatformTypes.PLATFORM_LINUX);
202.129 assertNotNull(f);
202.130 assertTrue("Unknown".equals(f.toString()));
202.131 assertTrue(f.isGnuCompiler());
202.132 - f = CompilerFlavor.getUnknown(PlatformTypes.PLATFORM_WINDOWS);
202.133 + f = CompilerFlavorAccessor.getUnknown(PlatformTypes.PLATFORM_WINDOWS);
202.134 assertNotNull(f);
202.135 assertTrue("Unknown".equals(f.toString()));
202.136 assertTrue(f.isGnuCompiler());
202.137 - f = CompilerFlavor.getUnknown(PlatformTypes.PLATFORM_MACOSX);
202.138 + f = CompilerFlavorAccessor.getUnknown(PlatformTypes.PLATFORM_MACOSX);
202.139 assertNotNull(f);
202.140 assertTrue("Unknown".equals(f.toString()));
202.141 assertTrue(f.isGnuCompiler());
202.142 - f = CompilerFlavor.getUnknown(PlatformTypes.PLATFORM_GENERIC);
202.143 + f = CompilerFlavorAccessor.getUnknown(PlatformTypes.PLATFORM_GENERIC);
202.144 assertNotNull(f);
202.145 assertTrue("Unknown".equals(f.toString()));
202.146 assertTrue(f.isGnuCompiler());
202.147 - f = CompilerFlavor.getUnknown(PlatformTypes.PLATFORM_NONE);
202.148 + f = CompilerFlavorAccessor.getUnknown(PlatformTypes.PLATFORM_NONE);
202.149 assertNotNull(f);
202.150 assertTrue("Unknown".equals(f.toString()));
202.151 assertTrue(f.isGnuCompiler());
202.152 @@ -460,7 +459,7 @@
202.153 //Copyright (C) 2008 Free Software Foundation, Inc.
202.154 //This is free software; see the source for copying conditions. There is NO
202.155 //warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
202.156 - ToolchainDescriptor d = ToolchainManager.getImpl().getToolchain("Cygwin_4.x", PlatformTypes.PLATFORM_WINDOWS);
202.157 + ToolchainDescriptor d = ToolchainManagerImpl.getImpl().getToolchain("Cygwin_4.x", PlatformTypes.PLATFORM_WINDOWS);
202.158 assertNotNull(d);
202.159 String s = d.getC().getVersionPattern();
202.160 //.*\\(GCC\\) 4\\.[3-9]
203.1 --- a/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/ScannerTestCase.java Mon Feb 01 12:23:06 2010 +0100
203.2 +++ b/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/ScannerTestCase.java Mon Feb 01 12:24:26 2010 +0100
203.3 @@ -38,7 +38,6 @@
203.4 */
203.5 package org.netbeans.modules.cnd.toolchain.api;
203.6
203.7 -import org.netbeans.modules.cnd.toolchain.api.PlatformTypes;
203.8 import java.io.BufferedReader;
203.9 import java.io.File;
203.10 import java.io.FileReader;
203.11 @@ -51,6 +50,7 @@
203.12 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerDescriptor;
203.13 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ScannerPattern;
203.14 import org.netbeans.modules.cnd.toolchain.api.ToolchainManager.ToolchainDescriptor;
203.15 +import org.netbeans.modules.cnd.toolchain.compilers.impl.ToolchainManagerImpl;
203.16
203.17 /**
203.18 * @author Alexey Vladykin
203.19 @@ -67,7 +67,7 @@
203.20 }
203.21
203.22 public void testGNUpatterns() throws Exception {
203.23 - ToolchainDescriptor toolchain = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
203.24 + ToolchainDescriptor toolchain = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
203.25 String[] GCC_ERROR_SCANNER = new String[]{"^([a-zA-Z]:[^:$]*|[^:$]*):([0-9]+)[\\.:]([^:$]*):([^$]*)", // NOI18N
203.26 "^([^:$]*):([0-9]+): ([a-zA-Z]*):*.*", // NOI18N
203.27 "^([^\\($]*)\\(([0-9]+)\\): ([^:$]*): ([^$]*)"}; // NOI18N
203.28 @@ -90,7 +90,7 @@
203.29 }
203.30
203.31 public void testSUNpatterns() throws Exception {
203.32 - ToolchainDescriptor toolchain = ToolchainManager.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
203.33 + ToolchainDescriptor toolchain = ToolchainManagerImpl.getImpl().getToolchain("SunStudio", PlatformTypes.PLATFORM_SOLARIS_INTEL);
203.34 String[] SUN_ERROR_SCANNER = new String[]{"^\"(.*)\", line ([0-9]+):", // NOI18N
203.35 "^\"(.*)\", line ([0-9]+): Error:", // NOI18N
203.36 "^\"(.*)\", Line = ([0-9]+),", // NOI18N
203.37 @@ -125,22 +125,22 @@
203.38 }
203.39
203.40 public void testCygwinLogs() throws Exception {
203.41 - ToolchainDescriptor toolchain = ToolchainManager.getImpl().getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
203.42 + ToolchainDescriptor toolchain = ToolchainManagerImpl.getImpl().getToolchain("Cygwin", PlatformTypes.PLATFORM_WINDOWS);
203.43 doTest(getLogs(), toolchain.getScanner(), getRef());
203.44 }
203.45
203.46 public void testDJGPPLogs() throws Exception {
203.47 - ToolchainDescriptor toolchain = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_WINDOWS);
203.48 + ToolchainDescriptor toolchain = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_WINDOWS);
203.49 doTest(getLogs(), toolchain.getScanner(), getRef());
203.50 }
203.51
203.52 public void testGnuFortranLogs() throws Exception {
203.53 - ToolchainDescriptor toolchain = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
203.54 + ToolchainDescriptor toolchain = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
203.55 doTest(getLogs(), toolchain.getScanner(), getRef());
203.56 }
203.57
203.58 public void testGnuCluceneLogs() throws Exception {
203.59 - ToolchainDescriptor toolchain = ToolchainManager.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
203.60 + ToolchainDescriptor toolchain = ToolchainManagerImpl.getImpl().getToolchain("GNU", PlatformTypes.PLATFORM_LINUX);
203.61 doTest(getLogs(), toolchain.getScanner(), getRef());
203.62 }
203.63
204.1 --- a/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/ScriptGeneratorTestCase.java Mon Feb 01 12:23:06 2010 +0100
204.2 +++ b/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/ScriptGeneratorTestCase.java Mon Feb 01 12:24:26 2010 +0100
204.3 @@ -39,6 +39,7 @@
204.4
204.5 package org.netbeans.modules.cnd.toolchain.api;
204.6
204.7 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainScriptGenerator;
204.8 import org.netbeans.junit.NbTestCase;
204.9
204.10 /**
205.1 --- a/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/WriteRegistryTestCase.java Mon Feb 01 12:23:06 2010 +0100
205.2 +++ b/cnd.toolchain/test/unit/src/org/netbeans/modules/cnd/toolchain/api/WriteRegistryTestCase.java Mon Feb 01 12:24:26 2010 +0100
205.3 @@ -78,10 +78,10 @@
205.4 }
205.5
205.6 public void testWrtiteDescriptor() throws Exception {
205.7 - List<ToolchainDescriptor> original = ToolchainManager.getImpl().getAllToolchains();
205.8 - ToolchainManager.getImpl().writeToolchains();
205.9 - ToolchainManager.getImpl().reinitToolchainManager();
205.10 - List<ToolchainDescriptor> restored = ToolchainManager.getImpl().getAllToolchains();
205.11 + List<ToolchainDescriptor> original = ToolchainManagerImpl.getImpl().getAllToolchains();
205.12 + ToolchainManagerImpl.getImpl().writeToolchains();
205.13 + ToolchainManagerImpl.getImpl().reinitToolchainManager();
205.14 + List<ToolchainDescriptor> restored = ToolchainManagerImpl.getImpl().getAllToolchains();
205.15 for(int i = 0; i < original.size(); i++) {
205.16 assertTrue("Tool chain "+original.get(i)+" not equals "+restored.get(i), deepObjectComparing(original.get(i),restored.get(i)));
205.17 }
206.1 --- a/cnd/src/org/netbeans/modules/cnd/actions/AbstractExecutorRunAction.java Mon Feb 01 12:23:06 2010 +0100
206.2 +++ b/cnd/src/org/netbeans/modules/cnd/actions/AbstractExecutorRunAction.java Mon Feb 01 12:24:26 2010 +0100
206.3 @@ -60,9 +60,8 @@
206.4 import org.netbeans.api.project.Project;
206.5 import org.netbeans.api.project.ui.OpenProjects;
206.6 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
206.7 -import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
206.8 -import org.netbeans.modules.cnd.toolchain.api.Tool;
206.9 -import org.netbeans.modules.cnd.toolchain.api.ToolchainProject;
206.10 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
206.11 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainProject;
206.12 import org.netbeans.modules.nativeexecution.api.ExecutionListener;
206.13 import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
206.14 import org.netbeans.modules.cnd.api.remote.RemoteProject;
206.15 @@ -76,8 +75,11 @@
206.16 import org.netbeans.modules.cnd.builds.MakeExecSupport;
206.17 import org.netbeans.modules.cnd.builds.QMakeExecSupport;
206.18 import org.netbeans.modules.cnd.execution41.org.openide.loaders.ExecutionSupport;
206.19 +import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
206.20 +import org.netbeans.modules.cnd.toolchain.api.Tool;
206.21 import org.netbeans.modules.cnd.utils.cache.CndFileUtils;
206.22 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
206.23 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
206.24 import org.netbeans.modules.nativeexecution.api.NativeProcess;
206.25 import org.netbeans.modules.nativeexecution.api.NativeProcessChangeEvent;
206.26 import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
206.27 @@ -143,7 +145,7 @@
206.28 if (project == null) {
206.29 project = findInOpenedProject(fileObject);
206.30 }
206.31 - ExecutionEnvironment developmentHost = CompilerSetManager.getDefaultExecutionEnvironment();
206.32 + ExecutionEnvironment developmentHost = ServerList.getDefaultRecord().getExecutionEnvironment();
206.33 if (project != null) {
206.34 RemoteProject info = project.getLookup().lookup(RemoteProject.class);
206.35 if (info != null) {
206.36 @@ -207,12 +209,12 @@
206.37 }
206.38 }
206.39 if (set == null) {
206.40 - set = CompilerSetManager.getDefault().getDefaultCompilerSet();
206.41 + set = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
206.42 }
206.43 if (set == null) {
206.44 return false;
206.45 }
206.46 - return set.isSunCompiler();
206.47 + return set.getCompilerFlavor().isSunStudioCompiler();
206.48 }
206.49
206.50 protected static CompilerSet getCompilerSet(Node node ){
206.51 @@ -231,12 +233,12 @@
206.52 }
206.53 }
206.54 if (set == null) {
206.55 - set = CompilerSetManager.getDefault().getDefaultCompilerSet();
206.56 + set = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
206.57 }
206.58 return set;
206.59 }
206.60
206.61 - protected static String getCommand(Node node, Project project, int tool, String defaultName){
206.62 + protected static String getCommand(Node node, Project project, ToolKind tool, String defaultName){
206.63 DataObject dataObject = node.getCookie(DataObject.class);
206.64 FileObject fileObject = dataObject.getPrimaryFile();
206.65 if (project == null) {
206.66 @@ -253,7 +255,7 @@
206.67 }
206.68 }
206.69 if (set == null) {
206.70 - set = CompilerSetManager.getDefault().getDefaultCompilerSet();
206.71 + set = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
206.72 }
206.73 String command = null;
206.74 if (set != null) {
206.75 @@ -263,17 +265,17 @@
206.76 }
206.77 }
206.78 if (command == null || command.length()==0) {
206.79 - if (tool == Tool.MakeTool) {
206.80 + if (tool == ToolKind.MakeTool) {
206.81 MakeExecSupport mes = node.getCookie(MakeExecSupport.class);
206.82 if (mes != null) {
206.83 command = mes.getMakeCommand();
206.84 }
206.85 - } else if (tool == Tool.QMakeTool) {
206.86 + } else if (tool == ToolKind.QMakeTool) {
206.87 QMakeExecSupport mes = node.getCookie(QMakeExecSupport.class);
206.88 if (mes != null) {
206.89 command = mes.getQMakeCommand();
206.90 }
206.91 - } else if (tool == Tool.CMakeTool) {
206.92 + } else if (tool == ToolKind.CMakeTool) {
206.93 CMakeExecSupport mes = node.getCookie(CMakeExecSupport.class);
206.94 if (mes != null) {
206.95 command = mes.getCMakeCommand();
206.96 @@ -286,23 +288,23 @@
206.97 return command;
206.98 }
206.99
206.100 - protected static String getBuildDirectory(Node node,int tool){
206.101 + protected static String getBuildDirectory(Node node, ToolKind tool){
206.102 DataObject dataObject = node.getCookie(DataObject.class);
206.103 FileObject fileObject = dataObject.getPrimaryFile();
206.104 File makefile = FileUtil.toFile(fileObject);
206.105 // Build directory
206.106 String bdir = null;
206.107 - if (tool == Tool.MakeTool) {
206.108 + if (tool == ToolKind.MakeTool) {
206.109 MakeExecSupport mes = node.getCookie(MakeExecSupport.class);
206.110 if (mes != null) {
206.111 bdir = mes.getBuildDirectory();
206.112 }
206.113 - } else if (tool == Tool.QMakeTool) {
206.114 + } else if (tool == ToolKind.QMakeTool) {
206.115 QMakeExecSupport mes = node.getCookie(QMakeExecSupport.class);
206.116 if (mes != null) {
206.117 bdir = mes.getRunDirectory();
206.118 }
206.119 - } else if (tool == Tool.CMakeTool) {
206.120 + } else if (tool == ToolKind.CMakeTool) {
206.121 CMakeExecSupport mes = node.getCookie(CMakeExecSupport.class);
206.122 if (mes != null) {
206.123 bdir = mes.getRunDirectory();
206.124 @@ -315,14 +317,14 @@
206.125 return buildDir.getAbsolutePath();
206.126 }
206.127
206.128 - protected static String[] getArguments(Node node, int tool) {
206.129 + protected static String[] getArguments(Node node, ToolKind tool) {
206.130 String[] args = null;
206.131 - if (tool == Tool.QMakeTool) {
206.132 + if (tool == ToolKind.QMakeTool) {
206.133 QMakeExecSupport mes = node.getCookie(QMakeExecSupport.class);
206.134 if (mes != null) {
206.135 args = mes.getArguments();
206.136 }
206.137 - } else if (tool == Tool.CMakeTool) {
206.138 + } else if (tool == ToolKind.CMakeTool) {
206.139 CMakeExecSupport mes = node.getCookie(CMakeExecSupport.class);
206.140 if (mes != null) {
206.141 args = mes.getArguments();
206.142 @@ -406,11 +408,11 @@
206.143 return HelpCtx.DEFAULT_HELP; // FIXUP ???
206.144 }
206.145
206.146 - protected final static String getString(String key) {
206.147 + protected static String getString(String key) {
206.148 return NbBundle.getBundle(AbstractExecutorRunAction.class).getString(key);
206.149 }
206.150
206.151 - protected final static String getString(String key, String ... a1) {
206.152 + protected static String getString(String key, String ... a1) {
206.153 return NbBundle.getMessage(AbstractExecutorRunAction.class, key, a1);
206.154 }
206.155
207.1 --- a/cnd/src/org/netbeans/modules/cnd/actions/CMakeAction.java Mon Feb 01 12:23:06 2010 +0100
207.2 +++ b/cnd/src/org/netbeans/modules/cnd/actions/CMakeAction.java Mon Feb 01 12:24:26 2010 +0100
207.3 @@ -49,7 +49,7 @@
207.4 import org.netbeans.api.extexecution.ExecutionDescriptor;
207.5 import org.netbeans.api.extexecution.ExecutionService;
207.6 import org.netbeans.api.project.Project;
207.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
207.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
207.9 import org.netbeans.modules.nativeexecution.api.ExecutionListener;
207.10 import org.netbeans.modules.cnd.api.remote.RemoteSyncSupport;
207.11 import org.netbeans.modules.cnd.api.remote.RemoteSyncWorker;
207.12 @@ -126,12 +126,12 @@
207.13 DataObject dataObject = node.getCookie(DataObject.class);
207.14 FileObject fileObject = dataObject.getPrimaryFile();
207.15 // Build directory
207.16 - String buildDir = getBuildDirectory(node,Tool.CMakeTool);
207.17 + String buildDir = getBuildDirectory(node,ToolKind.CMakeTool);
207.18 // Executable
207.19 - String executable = getCommand(node, project, Tool.CMakeTool, "cmake"); // NOI18N
207.20 + String executable = getCommand(node, project, ToolKind.CMakeTool, "cmake"); // NOI18N
207.21 // Arguments
207.22 //String arguments = proFile.getName();
207.23 - String[] arguments = getArguments(node, Tool.CMakeTool); // NOI18N
207.24 + String[] arguments = getArguments(node, ToolKind.CMakeTool); // NOI18N
207.25 ExecutionEnvironment execEnv = getExecutionEnvironment(fileObject, project);
207.26 buildDir = convertToRemoteIfNeeded(execEnv, buildDir);
207.27 if (buildDir == null) {
208.1 --- a/cnd/src/org/netbeans/modules/cnd/actions/MakeBaseAction.java Mon Feb 01 12:23:06 2010 +0100
208.2 +++ b/cnd/src/org/netbeans/modules/cnd/actions/MakeBaseAction.java Mon Feb 01 12:24:26 2010 +0100
208.3 @@ -52,7 +52,7 @@
208.4 import org.netbeans.api.extexecution.ExecutionDescriptor;
208.5 import org.netbeans.api.extexecution.ExecutionService;
208.6 import org.netbeans.api.project.Project;
208.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
208.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
208.9 import org.netbeans.modules.nativeexecution.api.ExecutionListener;
208.10 import org.netbeans.modules.cnd.api.remote.RemoteSyncSupport;
208.11 import org.netbeans.modules.cnd.api.remote.RemoteSyncWorker;
208.12 @@ -61,9 +61,10 @@
208.13 import org.netbeans.modules.cnd.settings.MakeSettings;
208.14 import org.netbeans.modules.cnd.toolchain.api.CompilerSet;
208.15 import org.netbeans.modules.cnd.toolchain.api.CompilerSetManager;
208.16 -import org.netbeans.modules.cnd.toolchain.api.ToolchainProject;
208.17 +import org.netbeans.modules.cnd.toolchain.spi.ToolchainProject;
208.18 import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg;
208.19 import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
208.20 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
208.21 import org.netbeans.modules.nativeexecution.api.NativeProcessBuilder;
208.22 import org.openide.LifecycleManager;
208.23 import org.openide.filesystems.FileObject;
208.24 @@ -133,9 +134,9 @@
208.25 final FileObject fileObject = dataObject.getPrimaryFile();
208.26 File makefile = FileUtil.toFile(fileObject);
208.27 // Build directory
208.28 - String buildDir = getBuildDirectory(node,Tool.MakeTool);
208.29 + String buildDir = getBuildDirectory(node,ToolKind.MakeTool);
208.30 // Executable
208.31 - String executable = getCommand(node, project, Tool.MakeTool, "make"); // NOI18N
208.32 + String executable = getCommand(node, project, ToolKind.MakeTool, "make"); // NOI18N
208.33 // Arguments
208.34 String[] args;
208.35 if (target.length() == 0) {
208.36 @@ -208,7 +209,7 @@
208.37 }
208.38 }
208.39 if (set == null) {
208.40 - set = CompilerSetManager.getDefault().getDefaultCompilerSet();
208.41 + set = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
208.42 }
208.43 return set;
208.44 }
209.1 --- a/cnd/src/org/netbeans/modules/cnd/actions/QMakeAction.java Mon Feb 01 12:23:06 2010 +0100
209.2 +++ b/cnd/src/org/netbeans/modules/cnd/actions/QMakeAction.java Mon Feb 01 12:24:26 2010 +0100
209.3 @@ -50,7 +50,7 @@
209.4 import org.netbeans.api.extexecution.ExecutionDescriptor;
209.5 import org.netbeans.api.extexecution.ExecutionService;
209.6 import org.netbeans.api.project.Project;
209.7 -import org.netbeans.modules.cnd.toolchain.api.Tool;
209.8 +import org.netbeans.modules.cnd.toolchain.api.ToolKind;
209.9 import org.netbeans.modules.nativeexecution.api.ExecutionListener;
209.10 import org.netbeans.modules.cnd.api.remote.RemoteSyncSupport;
209.11 import org.netbeans.modules.cnd.api.remote.RemoteSyncWorker;
209.12 @@ -129,12 +129,12 @@
209.13 FileObject fileObject = dataObject.getPrimaryFile();
209.14 File proFile = FileUtil.toFile(fileObject);
209.15 // Build directory
209.16 - String buildDir = getBuildDirectory(node,Tool.QMakeTool);
209.17 + String buildDir = getBuildDirectory(node,ToolKind.QMakeTool);
209.18 // Executable
209.19 - String executable = getCommand(node, project, Tool.QMakeTool, "qmake"); // NOI18N
209.20 + String executable = getCommand(node, project, ToolKind.QMakeTool, "qmake"); // NOI18N
209.21 // Arguments
209.22 String arguments = proFile.getName();// + " " + getArguments(node, Tool.QMakeTool); // NOI18N
209.23 - String[] args = getArguments(node, Tool.QMakeTool); // NOI18N
209.24 + String[] args = getArguments(node, ToolKind.QMakeTool); // NOI18N
209.25
209.26 ExecutionEnvironment execEnv = getExecutionEnvironment(fileObject, project);
209.27 buildDir = convertToRemoteIfNeeded(execEnv, buildDir);
210.1 --- a/cnd/src/org/netbeans/modules/cnd/actions/ShellRunAction.java Mon Feb 01 12:23:06 2010 +0100
210.2 +++ b/cnd/src/org/netbeans/modules/cnd/actions/ShellRunAction.java Mon Feb 01 12:24:26 2010 +0100
210.3 @@ -254,7 +254,7 @@
210.4 if (set != null) {
210.5 list.add(set);
210.6 }
210.7 - CompilerSetManager csm = CompilerSetManager.getDefault(execEnv);
210.8 + CompilerSetManager csm = CompilerSetManager.get(execEnv);
210.9 if (csm != null) {
210.10 set = csm.getDefaultCompilerSet();
210.11 if (set != null && !list.contains(set)) {
211.1 --- a/core.netigso/manifest.mf Mon Feb 01 12:23:06 2010 +0100
211.2 +++ b/core.netigso/manifest.mf Mon Feb 01 12:24:26 2010 +0100
211.3 @@ -5,5 +5,5 @@
211.4 OpenIDE-Module-Specification-Version: 1.1
211.5 OpenIDE-Module-Needs: org.osgi.framework.launch.FrameworkFactory
211.6 AutoUpdate-Essential-Module: true
211.7 +X-Comment: various OSGi headers are set by the MakeOSGi task
211.8
211.9 -
212.1 --- a/core.netigso/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
212.2 +++ b/core.netigso/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
212.3 @@ -73,6 +73,14 @@
212.4 </run-dependency>
212.5 </dependency>
212.6 <dependency>
212.7 + <code-name-base>org.openide.filesystems</code-name-base>
212.8 + <build-prerequisite/>
212.9 + <compile-dependency/>
212.10 + <run-dependency>
212.11 + <specification-version>7.33</specification-version>
212.12 + </run-dependency>
212.13 + </dependency>
212.14 + <dependency>
212.15 <code-name-base>org.openide.modules</code-name-base>
212.16 <build-prerequisite/>
212.17 <compile-dependency/>
213.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
213.2 +++ b/core.netigso/src/org/netbeans/core/osgi/Activator.java Mon Feb 01 12:24:26 2010 +0100
213.3 @@ -0,0 +1,229 @@
213.4 +/*
213.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
213.6 + *
213.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
213.8 + *
213.9 + * The contents of this file are subject to the terms of either the GNU
213.10 + * General Public License Version 2 only ("GPL") or the Common
213.11 + * Development and Distribution License("CDDL") (collectively, the
213.12 + * "License"). You may not use this file except in compliance with the
213.13 + * License. You can obtain a copy of the License at
213.14 + * http://www.netbeans.org/cddl-gplv2.html
213.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
213.16 + * specific language governing permissions and limitations under the
213.17 + * License. When distributing the software, include this License Header
213.18 + * Notice in each file and include the License file at
213.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
213.20 + * particular file as subject to the "Classpath" exception as provided
213.21 + * by Sun in the GPL Version 2 section of the License file that
213.22 + * accompanied this code. If applicable, add the following below the
213.23 + * License Header, with the fields enclosed by brackets [] replaced by
213.24 + * your own identifying information:
213.25 + * "Portions Copyrighted [year] [name of copyright owner]"
213.26 + *
213.27 + * If you wish your version of this file to be governed by only the CDDL
213.28 + * or only the GPL Version 2, indicate your decision by adding
213.29 + * "[Contributor] elects to include this software in this distribution
213.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
213.31 + * single choice of license, a recipient has the option to distribute
213.32 + * your version of this file under either the CDDL, the GPL Version 2 or
213.33 + * to extend the choice of license to its licensees as provided above.
213.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
213.35 + * Version 2 license, then the option applies only if the new code is
213.36 + * made subject to such option by the copyright holder.
213.37 + *
213.38 + * Contributor(s):
213.39 + *
213.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
213.41 + */
213.42 +
213.43 +package org.netbeans.core.osgi;
213.44 +
213.45 +import java.io.BufferedReader;
213.46 +import java.io.IOException;
213.47 +import java.io.InputStream;
213.48 +import java.io.InputStreamReader;
213.49 +import java.lang.reflect.Method;
213.50 +import java.net.URL;
213.51 +import java.net.URLConnection;
213.52 +import java.net.URLStreamHandler;
213.53 +import java.util.ArrayList;
213.54 +import java.util.Enumeration;
213.55 +import java.util.List;
213.56 +import java.util.Properties;
213.57 +import java.util.logging.Level;
213.58 +import java.util.logging.Logger;
213.59 +import org.openide.modules.ModuleInstall;
213.60 +import org.openide.util.NbCollections;
213.61 +import org.openide.util.SharedClassObject;
213.62 +import org.osgi.framework.Bundle;
213.63 +import org.osgi.framework.BundleActivator;
213.64 +import org.osgi.framework.BundleContext;
213.65 +import org.osgi.framework.BundleEvent;
213.66 +import org.osgi.framework.BundleListener;
213.67 +import org.osgi.framework.Constants;
213.68 +import org.osgi.framework.FrameworkEvent;
213.69 +import org.osgi.framework.FrameworkListener;
213.70 +import org.osgi.service.url.AbstractURLStreamHandlerService;
213.71 +import org.osgi.service.url.URLConstants;
213.72 +import org.osgi.service.url.URLStreamHandlerService;
213.73 +
213.74 +/**
213.75 + * Initializes critical NetBeans infrastructure inside an OSGi container.
213.76 + */
213.77 +public class Activator implements BundleActivator, BundleListener, FrameworkListener {
213.78 +
213.79 + private static final Logger LOG = Logger.getLogger(Activator.class.getName());
213.80 +
213.81 + public Activator() {}
213.82 +
213.83 + public @Override void start(BundleContext context) throws Exception {
213.84 + if (System.getProperty("netbeans.home") != null) {
213.85 + throw new IllegalStateException("Should not be run from inside regular NetBeans module system");
213.86 + }
213.87 + String storage = context.getProperty(Constants.FRAMEWORK_STORAGE);
213.88 + if (storage != null) {
213.89 + System.setProperty("netbeans.user", storage);
213.90 + }
213.91 + // XXX set netbeans.buildnumber to OpenIDE-Module-Implementation-Version of org.netbeans.bootstrap
213.92 + OSGiMainLookup.initialize(context);
213.93 + context.addFrameworkListener(this);
213.94 + context.addBundleListener(this);
213.95 +// System.err.println("processing already loaded bundles...");
213.96 + for (Bundle b : context.getBundles()) {
213.97 + switch (b.getState()) {
213.98 + case Bundle.ACTIVE:
213.99 + // XXX coalesce these layer events
213.100 + bundleChanged(new BundleEvent(BundleEvent.RESOLVED, b));
213.101 + // XXX should resolve all first, then start all:
213.102 + bundleChanged(new BundleEvent(BundleEvent.STARTED, b));
213.103 + break;
213.104 + case Bundle.RESOLVED:
213.105 + case Bundle.STARTING:
213.106 + case Bundle.STOPPING:
213.107 + bundleChanged(new BundleEvent(BundleEvent.RESOLVED, b));
213.108 + break;
213.109 + }
213.110 + }
213.111 +// System.err.println("done processing already loaded bundles.");
213.112 + // XXX if GUI mode: Main.initUICustomizations(); add "org.netbeans.beaninfo" to Introspector.beanInfoSearchPath; GuiRunLevel.run
213.113 + }
213.114 +
213.115 + public @Override void stop(BundleContext context) throws Exception {}
213.116 +
213.117 + public @Override void bundleChanged(BundleEvent event) {
213.118 + Bundle bundle = event.getBundle();
213.119 + switch (event.getType()) {
213.120 + case BundleEvent.RESOLVED:
213.121 +// System.err.println("resolved " + bundle.getSymbolicName());
213.122 + OSGiMainLookup.bundleResolved(bundle);
213.123 + OSGiRepository.DEFAULT.addLayers(layersFor(bundle));
213.124 + break;
213.125 + case BundleEvent.UNRESOLVED:
213.126 +// System.err.println("unresolved " + bundle.getSymbolicName());
213.127 + OSGiMainLookup.bundleUnresolved(bundle);
213.128 + OSGiRepository.DEFAULT.removeLayers(layersFor(bundle));
213.129 + break;
213.130 + case BundleEvent.STARTED:
213.131 +// System.err.println("started " + bundle.getSymbolicName());
213.132 + registerUrlProtocolHandlers(bundle); // must be active
213.133 + ModuleInstall mi = installerFor(bundle);
213.134 + if (mi != null) {
213.135 +// System.err.println("running " + mi.getClass().getName() + ".restored()");
213.136 + mi.restored();
213.137 + }
213.138 + // XXX if o.n.core (or o.n.m.settings?) tell OSGiMainLookup to use CoreBridge.getDefault().lookupCacheLoad()
213.139 + break;
213.140 + case BundleEvent.STOPPED:
213.141 +// System.err.println("stopped " + bundle.getSymbolicName());
213.142 + mi = installerFor(bundle);
213.143 + if (mi != null) {
213.144 +// System.err.println("running " + mi.getClass().getName() + ".uninstalled()");
213.145 + mi.uninstalled();
213.146 + }
213.147 + break;
213.148 + }
213.149 + }
213.150 +
213.151 + public @Override void frameworkEvent(FrameworkEvent event) {
213.152 +// System.err.println("XXX framework event " + event.getType() + " on " + event.getBundle().getSymbolicName());
213.153 + // XXX perhaps defer processing various things until the framework is started
213.154 + }
213.155 +
213.156 + private static URL[] layersFor(Bundle b) {
213.157 + List<URL> layers = new ArrayList<URL>(2);
213.158 + String explicit = (String) b.getHeaders().get("OpenIDE-Module-Layer");
213.159 + if (explicit != null) {
213.160 + layers.add(b.getResource(explicit));
213.161 + // XXX could also add localized/branded variants
213.162 + }
213.163 + URL generated = b.getResource("META-INF/generated-layer.xml");
213.164 + if (generated != null) {
213.165 + layers.add(generated);
213.166 + }
213.167 + return layers.toArray(new URL[layers.size()]);
213.168 + }
213.169 +
213.170 + private static ModuleInstall installerFor(Bundle b) {
213.171 + String respath = (String) b.getHeaders().get("OpenIDE-Module-Install");
213.172 + if (respath != null) {
213.173 + String fqn = respath.replaceFirst("[.]class$", "").replace('/', '.');
213.174 + try {
213.175 + return SharedClassObject.findObject(((Class<?>) b.loadClass(fqn)).asSubclass(ModuleInstall.class), true);
213.176 + } catch (Exception x) { // CNFE, CCE, ...
213.177 + LOG.log(Level.WARNING, "Could not load " + fqn, x);
213.178 + return null;
213.179 + }
213.180 + }
213.181 + return null;
213.182 + }
213.183 +
213.184 + private void registerUrlProtocolHandlers(final Bundle bundle) {
213.185 + Enumeration e = bundle.getEntryPaths("META-INF/namedservices/URLStreamHandler/");
213.186 + if (e != null) {
213.187 + for (String path : NbCollections.iterable(NbCollections.checkedEnumerationByFilter(e, String.class, true))) {
213.188 + URL entry = bundle.getEntry(path + "java.net.URLStreamHandler");
213.189 + if (entry != null) {
213.190 + String protocol = path.replaceAll("^META-INF/namedservices/URLStreamHandler/|/$", "");
213.191 + try {
213.192 + InputStream is = entry.openStream();
213.193 + try {
213.194 + BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
213.195 + String line;
213.196 + while ((line = r.readLine()) != null) {
213.197 + if (!line.isEmpty() && !line.startsWith("#")) {
213.198 + final String fqn = line;
213.199 + Properties props = new Properties();
213.200 + props.put(URLConstants.URL_HANDLER_PROTOCOL, protocol);
213.201 + class Svc extends AbstractURLStreamHandlerService {
213.202 + public @Override URLConnection openConnection(final URL u) throws IOException {
213.203 + try {
213.204 + URLStreamHandler handler = (URLStreamHandler) bundle.loadClass(fqn).newInstance();
213.205 + Method openConnection = URLStreamHandler.class.getDeclaredMethod("openConnection", URL.class);
213.206 + openConnection.setAccessible(true);
213.207 + return (URLConnection) openConnection.invoke(handler, u);
213.208 + } catch (Exception x) {
213.209 + throw (IOException) new IOException(x.toString()).initCause(x);
213.210 + }
213.211 + }
213.212 + }
213.213 + BundleContext context = bundle.getBundleContext();
213.214 + if (context != null) {
213.215 + context.registerService(URLStreamHandlerService.class.getName(), new Svc(), props);
213.216 + } else {
213.217 + LOG.log(Level.WARNING, "no context for {0} in state {1}", new Object[] {bundle.getSymbolicName(), bundle.getState()});
213.218 + }
213.219 + }
213.220 + }
213.221 + } finally {
213.222 + is.close();
213.223 + }
213.224 + } catch (Exception x) {
213.225 + LOG.log(Level.WARNING, "Could not load protocol handler for " + protocol + " from " + bundle.getSymbolicName(), x);
213.226 + }
213.227 + }
213.228 + }
213.229 + }
213.230 + }
213.231 +
213.232 +}
214.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
214.2 +++ b/core.netigso/src/org/netbeans/core/osgi/OSGiClassLoader.java Mon Feb 01 12:24:26 2010 +0100
214.3 @@ -0,0 +1,110 @@
214.4 +/*
214.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
214.6 + *
214.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
214.8 + *
214.9 + * The contents of this file are subject to the terms of either the GNU
214.10 + * General Public License Version 2 only ("GPL") or the Common
214.11 + * Development and Distribution License("CDDL") (collectively, the
214.12 + * "License"). You may not use this file except in compliance with the
214.13 + * License. You can obtain a copy of the License at
214.14 + * http://www.netbeans.org/cddl-gplv2.html
214.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
214.16 + * specific language governing permissions and limitations under the
214.17 + * License. When distributing the software, include this License Header
214.18 + * Notice in each file and include the License file at
214.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
214.20 + * particular file as subject to the "Classpath" exception as provided
214.21 + * by Sun in the GPL Version 2 section of the License file that
214.22 + * accompanied this code. If applicable, add the following below the
214.23 + * License Header, with the fields enclosed by brackets [] replaced by
214.24 + * your own identifying information:
214.25 + * "Portions Copyrighted [year] [name of copyright owner]"
214.26 + *
214.27 + * If you wish your version of this file to be governed by only the CDDL
214.28 + * or only the GPL Version 2, indicate your decision by adding
214.29 + * "[Contributor] elects to include this software in this distribution
214.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
214.31 + * single choice of license, a recipient has the option to distribute
214.32 + * your version of this file under either the CDDL, the GPL Version 2 or
214.33 + * to extend the choice of license to its licensees as provided above.
214.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
214.35 + * Version 2 license, then the option applies only if the new code is
214.36 + * made subject to such option by the copyright holder.
214.37 + *
214.38 + * Contributor(s):
214.39 + *
214.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
214.41 + */
214.42 +
214.43 +package org.netbeans.core.osgi;
214.44 +
214.45 +import java.io.IOException;
214.46 +import java.net.URL;
214.47 +import java.util.ArrayList;
214.48 +import java.util.Collections;
214.49 +import java.util.Enumeration;
214.50 +import java.util.List;
214.51 +import org.openide.util.Enumerations;
214.52 +import org.openide.util.NbCollections;
214.53 +import org.osgi.framework.Bundle;
214.54 +import org.osgi.framework.BundleContext;
214.55 +
214.56 +/**
214.57 + * Delegates to all loaded bundles.
214.58 + */
214.59 +class OSGiClassLoader extends ClassLoader {
214.60 +
214.61 + private final BundleContext context;
214.62 +
214.63 + public OSGiClassLoader(BundleContext context) {
214.64 + this.context = context;
214.65 + }
214.66 +
214.67 + protected @Override Class<?> findClass(String name) throws ClassNotFoundException {
214.68 + for (Bundle b : context.getBundles()) {
214.69 + if (b.getState() == Bundle.INSTALLED) {
214.70 + continue;
214.71 + }
214.72 + try {
214.73 + return b.loadClass(name);
214.74 + } catch (ClassNotFoundException x) {
214.75 + // normal, try next one
214.76 + }
214.77 + }
214.78 + return super.findClass(name);
214.79 + }
214.80 +
214.81 + protected @Override URL findResource(String name) {
214.82 + for (Bundle b : context.getBundles()) {
214.83 + if (b.getState() == Bundle.INSTALLED) {
214.84 + continue;
214.85 + }
214.86 + URL resource = b.getResource(name);
214.87 + if (resource != null) {
214.88 + return resource;
214.89 + }
214.90 + }
214.91 + return super.findResource(name);
214.92 + }
214.93 +
214.94 + protected @Override Enumeration<URL> findResources(String name) throws IOException {
214.95 + List<Enumeration<URL>> resourcess = new ArrayList<Enumeration<URL>>();
214.96 + for (Bundle b : context.getBundles()) {
214.97 + if (b.getState() == Bundle.INSTALLED) {
214.98 + continue;
214.99 + }
214.100 + Enumeration resourcesRaw = b.getResources(name);
214.101 + if (resourcesRaw == null) {
214.102 + // Oddly, this is permitted.
214.103 + continue;
214.104 + }
214.105 + Enumeration<URL> resources = NbCollections.checkedEnumerationByFilter(resourcesRaw, URL.class, true);
214.106 + if (resources != null) {
214.107 + resourcess.add(resources);
214.108 + }
214.109 + }
214.110 + return Enumerations.concat(Collections.enumeration(resourcess));
214.111 + }
214.112 +
214.113 +}
215.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
215.2 +++ b/core.netigso/src/org/netbeans/core/osgi/OSGiLifecycleManager.java Mon Feb 01 12:24:26 2010 +0100
215.3 @@ -0,0 +1,74 @@
215.4 +/*
215.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
215.6 + *
215.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
215.8 + *
215.9 + * The contents of this file are subject to the terms of either the GNU
215.10 + * General Public License Version 2 only ("GPL") or the Common
215.11 + * Development and Distribution License("CDDL") (collectively, the
215.12 + * "License"). You may not use this file except in compliance with the
215.13 + * License. You can obtain a copy of the License at
215.14 + * http://www.netbeans.org/cddl-gplv2.html
215.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
215.16 + * specific language governing permissions and limitations under the
215.17 + * License. When distributing the software, include this License Header
215.18 + * Notice in each file and include the License file at
215.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
215.20 + * particular file as subject to the "Classpath" exception as provided
215.21 + * by Sun in the GPL Version 2 section of the License file that
215.22 + * accompanied this code. If applicable, add the following below the
215.23 + * License Header, with the fields enclosed by brackets [] replaced by
215.24 + * your own identifying information:
215.25 + * "Portions Copyrighted [year] [name of copyright owner]"
215.26 + *
215.27 + * If you wish your version of this file to be governed by only the CDDL
215.28 + * or only the GPL Version 2, indicate your decision by adding
215.29 + * "[Contributor] elects to include this software in this distribution
215.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
215.31 + * single choice of license, a recipient has the option to distribute
215.32 + * your version of this file under either the CDDL, the GPL Version 2 or
215.33 + * to extend the choice of license to its licensees as provided above.
215.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
215.35 + * Version 2 license, then the option applies only if the new code is
215.36 + * made subject to such option by the copyright holder.
215.37 + *
215.38 + * Contributor(s):
215.39 + *
215.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
215.41 + */
215.42 +
215.43 +package org.netbeans.core.osgi;
215.44 +
215.45 +import java.util.logging.Level;
215.46 +import java.util.logging.Logger;
215.47 +import org.openide.LifecycleManager;
215.48 +import org.osgi.framework.Bundle;
215.49 +import org.osgi.framework.BundleContext;
215.50 +import org.osgi.framework.BundleException;
215.51 +import org.osgi.framework.launch.Framework;
215.52 +
215.53 +class OSGiLifecycleManager extends LifecycleManager {
215.54 +
215.55 + private final BundleContext context;
215.56 +
215.57 + OSGiLifecycleManager(BundleContext context) {
215.58 + this.context = context;
215.59 + }
215.60 +
215.61 + public @Override void saveAll() {
215.62 + // XXX should delegate to impl in o.n.core
215.63 + }
215.64 +
215.65 + public @Override void exit() {
215.66 + // XXX is there any better way to get the framework?
215.67 + Bundle system = context.getBundle(0);
215.68 + if (system instanceof Framework) {
215.69 + try {
215.70 + ((Framework) system).stop();
215.71 + } catch (BundleException x) {
215.72 + Logger.getLogger(OSGiLifecycleManager.class.getName()).log(Level.WARNING, "Could not stop OSGi framework", x);
215.73 + }
215.74 + }
215.75 + }
215.76 +
215.77 +}
216.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
216.2 +++ b/core.netigso/src/org/netbeans/core/osgi/OSGiMainLookup.java Mon Feb 01 12:24:26 2010 +0100
216.3 @@ -0,0 +1,111 @@
216.4 +/*
216.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
216.6 + *
216.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
216.8 + *
216.9 + * The contents of this file are subject to the terms of either the GNU
216.10 + * General Public License Version 2 only ("GPL") or the Common
216.11 + * Development and Distribution License("CDDL") (collectively, the
216.12 + * "License"). You may not use this file except in compliance with the
216.13 + * License. You can obtain a copy of the License at
216.14 + * http://www.netbeans.org/cddl-gplv2.html
216.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
216.16 + * specific language governing permissions and limitations under the
216.17 + * License. When distributing the software, include this License Header
216.18 + * Notice in each file and include the License file at
216.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
216.20 + * particular file as subject to the "Classpath" exception as provided
216.21 + * by Sun in the GPL Version 2 section of the License file that
216.22 + * accompanied this code. If applicable, add the following below the
216.23 + * License Header, with the fields enclosed by brackets [] replaced by
216.24 + * your own identifying information:
216.25 + * "Portions Copyrighted [year] [name of copyright owner]"
216.26 + *
216.27 + * If you wish your version of this file to be governed by only the CDDL
216.28 + * or only the GPL Version 2, indicate your decision by adding
216.29 + * "[Contributor] elects to include this software in this distribution
216.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
216.31 + * single choice of license, a recipient has the option to distribute
216.32 + * your version of this file under either the CDDL, the GPL Version 2 or
216.33 + * to extend the choice of license to its licensees as provided above.
216.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
216.35 + * Version 2 license, then the option applies only if the new code is
216.36 + * made subject to such option by the copyright holder.
216.37 + *
216.38 + * Contributor(s):
216.39 + *
216.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
216.41 + */
216.42 +
216.43 +package org.netbeans.core.osgi;
216.44 +
216.45 +import java.util.ArrayList;
216.46 +import java.util.List;
216.47 +import org.openide.util.Lookup;
216.48 +import org.openide.util.lookup.Lookups;
216.49 +import org.openide.util.lookup.ProxyLookup;
216.50 +import org.osgi.framework.Bundle;
216.51 +import org.osgi.framework.BundleContext;
216.52 +
216.53 +/**
216.54 + * Default lookup when running inside an OSGi container.
216.55 + */
216.56 +public class OSGiMainLookup extends ProxyLookup {
216.57 +
216.58 + private static BundleContext context;
216.59 +
216.60 + private static OSGiMainLookup get() {
216.61 + return (OSGiMainLookup) Lookup.getDefault();
216.62 + }
216.63 +
216.64 + public static void initialize(BundleContext _context) throws Exception {
216.65 + System.setProperty(Lookup.class.getName(), OSGiMainLookup.class.getName());
216.66 + context = _context;
216.67 + OSGiMainLookup lkp;
216.68 + ClassLoader oldCCL = Thread.currentThread().getContextClassLoader();
216.69 + Thread.currentThread().setContextClassLoader(OSGiMainLookup.class.getClassLoader());
216.70 + try {
216.71 + lkp = get();
216.72 + } finally {
216.73 + Thread.currentThread().setContextClassLoader(oldCCL);
216.74 + }
216.75 + lkp.postInit();
216.76 + }
216.77 +
216.78 + static void bundleResolved(Bundle bundle) {
216.79 + // XXX extend existing classLoader
216.80 + get().setClassLoader();
216.81 + }
216.82 +
216.83 + static void bundleUnresolved(Bundle bundle) {
216.84 + get().setClassLoader();
216.85 + }
216.86 +
216.87 + private ClassLoader classLoader;
216.88 + private final List<Lookup> nonClassLoaderDelegates = new ArrayList<Lookup>();
216.89 +
216.90 + public OSGiMainLookup() {}
216.91 +
216.92 + private void postInit() {
216.93 + nonClassLoaderDelegates.add(Lookups.fixed(OSGiRepository.DEFAULT, new OSGiLifecycleManager(context)));
216.94 + nonClassLoaderDelegates.add(Lookups.forPath("Services/"));
216.95 + // XXX add ModuleInfo objects corresponding to bundles
216.96 + // XXX InstalledFileLocator impl for OSGI-INF/files/*
216.97 + setClassLoader();
216.98 + }
216.99 +
216.100 + private void setClassLoader() {
216.101 + classLoader = new OSGiClassLoader(context);
216.102 + // XXX should it be set as thread CCL? would help some NB APIs, but might break OSGi conventions
216.103 + setDelegates();
216.104 + }
216.105 +
216.106 + private void setDelegates() {
216.107 + Lookup[] delegates = new Lookup[nonClassLoaderDelegates.size() + 2];
216.108 + nonClassLoaderDelegates.toArray(delegates);
216.109 + delegates[delegates.length - 2] = Lookups.metaInfServices(classLoader);
216.110 + delegates[delegates.length - 1] = Lookups.singleton(classLoader);
216.111 + setLookups(delegates);
216.112 + }
216.113 +
216.114 +}
217.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
217.2 +++ b/core.netigso/src/org/netbeans/core/osgi/OSGiRepository.java Mon Feb 01 12:24:26 2010 +0100
217.3 @@ -0,0 +1,144 @@
217.4 +/*
217.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
217.6 + *
217.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
217.8 + *
217.9 + * The contents of this file are subject to the terms of either the GNU
217.10 + * General Public License Version 2 only ("GPL") or the Common
217.11 + * Development and Distribution License("CDDL") (collectively, the
217.12 + * "License"). You may not use this file except in compliance with the
217.13 + * License. You can obtain a copy of the License at
217.14 + * http://www.netbeans.org/cddl-gplv2.html
217.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
217.16 + * specific language governing permissions and limitations under the
217.17 + * License. When distributing the software, include this License Header
217.18 + * Notice in each file and include the License file at
217.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
217.20 + * particular file as subject to the "Classpath" exception as provided
217.21 + * by Sun in the GPL Version 2 section of the License file that
217.22 + * accompanied this code. If applicable, add the following below the
217.23 + * License Header, with the fields enclosed by brackets [] replaced by
217.24 + * your own identifying information:
217.25 + * "Portions Copyrighted [year] [name of copyright owner]"
217.26 + *
217.27 + * If you wish your version of this file to be governed by only the CDDL
217.28 + * or only the GPL Version 2, indicate your decision by adding
217.29 + * "[Contributor] elects to include this software in this distribution
217.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
217.31 + * single choice of license, a recipient has the option to distribute
217.32 + * your version of this file under either the CDDL, the GPL Version 2 or
217.33 + * to extend the choice of license to its licensees as provided above.
217.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
217.35 + * Version 2 license, then the option applies only if the new code is
217.36 + * made subject to such option by the copyright holder.
217.37 + *
217.38 + * Contributor(s):
217.39 + *
217.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
217.41 + */
217.42 +
217.43 +package org.netbeans.core.osgi;
217.44 +
217.45 +import java.io.File;
217.46 +import java.net.URL;
217.47 +import java.util.ArrayList;
217.48 +import java.util.Arrays;
217.49 +import java.util.HashMap;
217.50 +import java.util.List;
217.51 +import java.util.Map;
217.52 +import java.util.logging.Level;
217.53 +import java.util.logging.Logger;
217.54 +import org.openide.filesystems.FileSystem;
217.55 +import org.openide.filesystems.FileUtil;
217.56 +import org.openide.filesystems.LocalFileSystem;
217.57 +import org.openide.filesystems.MultiFileSystem;
217.58 +import org.openide.filesystems.Repository;
217.59 +import org.openide.filesystems.XMLFileSystem;
217.60 +import org.xml.sax.SAXException;
217.61 +
217.62 +/**
217.63 + * Default repository to which layers can be added or removed.
217.64 + */
217.65 +class OSGiRepository extends Repository {
217.66 +
217.67 + private static final Logger LOG = Logger.getLogger(OSGiRepository.class.getName());
217.68 + public static final OSGiRepository DEFAULT = new OSGiRepository();
217.69 +
217.70 + private final LayerFS fs;
217.71 +
217.72 + private OSGiRepository() {
217.73 + this(new LayerFS());
217.74 + }
217.75 +
217.76 + private OSGiRepository(LayerFS fs) {
217.77 + super(fs);
217.78 + this.fs = fs;
217.79 + }
217.80 +
217.81 + public void addLayers(URL... resources) {
217.82 + if (resources.length > 0) {
217.83 +// System.err.println("adding layers: " + Arrays.toString(resources));
217.84 + fs.addLayers(resources);
217.85 + }
217.86 + }
217.87 +
217.88 + public void removeLayers(URL... resources) {
217.89 + if (resources.length > 0) {
217.90 +// System.err.println("removing layers: " + Arrays.toString(resources));
217.91 + fs.removeLayers(resources);
217.92 + }
217.93 + }
217.94 +
217.95 + private static final class LayerFS extends MultiFileSystem {
217.96 +
217.97 + private final Map<URL,FileSystem> fss = new HashMap<URL,FileSystem>();
217.98 + private final FileSystem userdir;
217.99 +
217.100 + LayerFS() {
217.101 + reset();
217.102 + File config = null;
217.103 + String netbeansUser = System.getProperty("netbeans.user");
217.104 + if (netbeansUser != null) {
217.105 + config = new File(netbeansUser, "config");
217.106 + }
217.107 + if (config != null && (config.isDirectory() || config.mkdirs())) {
217.108 + LocalFileSystem lfs = new LocalFileSystem();
217.109 + try {
217.110 + lfs.setRootDirectory(config);
217.111 + } catch (Exception x) {
217.112 + LOG.log(Level.WARNING, "Could not set userdir: " + config, x);
217.113 + }
217.114 + userdir = lfs;
217.115 + } else {
217.116 + // no persisted configuration
217.117 + userdir = FileUtil.createMemoryFileSystem();
217.118 + }
217.119 + }
217.120 +
217.121 + private synchronized void addLayers(URL... resources) {
217.122 + for (URL resource : resources) {
217.123 + try {
217.124 + fss.put(resource, new XMLFileSystem(resource));
217.125 + } catch (SAXException x) {
217.126 + LOG.log(Level.WARNING, "Could not parse layer: " + resource, x);
217.127 + }
217.128 + }
217.129 + reset();
217.130 + }
217.131 +
217.132 + private synchronized void removeLayers(URL... resources) {
217.133 + fss.keySet().removeAll(Arrays.asList(resources));
217.134 + reset();
217.135 + }
217.136 +
217.137 + private void reset() {
217.138 + List<FileSystem> delegates = new ArrayList<FileSystem>(fss.size() + 1);
217.139 + delegates.add(userdir);
217.140 + delegates.addAll(fss.values());
217.141 + setDelegates(delegates.toArray(new FileSystem[delegates.size()]));
217.142 + // XXX also include FileSystem's from lookup
217.143 + }
217.144 +
217.145 + }
217.146 +
217.147 +}
218.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
218.2 +++ b/core.netigso/src/org/netbeans/core/osgi/package-info.java Mon Feb 01 12:24:26 2010 +0100
218.3 @@ -0,0 +1,44 @@
218.4 +/*
218.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
218.6 + *
218.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
218.8 + *
218.9 + * The contents of this file are subject to the terms of either the GNU
218.10 + * General Public License Version 2 only ("GPL") or the Common
218.11 + * Development and Distribution License("CDDL") (collectively, the
218.12 + * "License"). You may not use this file except in compliance with the
218.13 + * License. You can obtain a copy of the License at
218.14 + * http://www.netbeans.org/cddl-gplv2.html
218.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
218.16 + * specific language governing permissions and limitations under the
218.17 + * License. When distributing the software, include this License Header
218.18 + * Notice in each file and include the License file at
218.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
218.20 + * particular file as subject to the "Classpath" exception as provided
218.21 + * by Sun in the GPL Version 2 section of the License file that
218.22 + * accompanied this code. If applicable, add the following below the
218.23 + * License Header, with the fields enclosed by brackets [] replaced by
218.24 + * your own identifying information:
218.25 + * "Portions Copyrighted [year] [name of copyright owner]"
218.26 + *
218.27 + * If you wish your version of this file to be governed by only the CDDL
218.28 + * or only the GPL Version 2, indicate your decision by adding
218.29 + * "[Contributor] elects to include this software in this distribution
218.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
218.31 + * single choice of license, a recipient has the option to distribute
218.32 + * your version of this file under either the CDDL, the GPL Version 2 or
218.33 + * to extend the choice of license to its licensees as provided above.
218.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
218.35 + * Version 2 license, then the option applies only if the new code is
218.36 + * made subject to such option by the copyright holder.
218.37 + *
218.38 + * Contributor(s):
218.39 + *
218.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
218.41 + */
218.42 +
218.43 +/**
218.44 + * Runtime services for use by NetBeans modules translated to bundles
218.45 + * running inside an OSGi container.
218.46 + */
218.47 +package org.netbeans.core.osgi;
219.1 --- a/csl.api/apichanges.xml Mon Feb 01 12:23:06 2010 +0100
219.2 +++ b/csl.api/apichanges.xml Mon Feb 01 12:24:26 2010 +0100
219.3 @@ -46,6 +46,24 @@
219.4 <apidef name="csl.api">Common Scripting Language API</apidef>
219.5 </apidefs>
219.6 <changes>
219.7 + <change id="api-cleanup">
219.8 + <api name="csl.api"/>
219.9 + <summary>Removing o.n.m.csl.core and o.n.m.csl.editor from public API</summary>
219.10 + <version major="2" minor="1"/>
219.11 + <date day="28" month="1" year="2010"/>
219.12 + <author login="vstejskal"/>
219.13 + <compatibility addition="no" deletion="yes" modification="yes" binary="incompatible" source="incompatible"/>
219.14 + <description>
219.15 + <p>
219.16 + The packages <code>o.n.m.csl.core</code> and <code>o.n.m.csl.editor</code> were removed
219.17 + from the public API. They contained implementation classes and should never have been
219.18 + made public in the first place. The only classes in these packages that were needed
219.19 + by language plugins are several editor actions. They were moved to <code>o.n.m.csl.api</code>
219.20 + package.
219.21 + </p>
219.22 + </description>
219.23 + <issue number="169991"/>
219.24 + </change>
219.25 <change id="LanguageRegistration-annotation">
219.26 <api name="csl.api"/>
219.27 <summary>Adding @LanguageRegistration annotation</summary>
220.1 --- a/csl.api/manifest.mf Mon Feb 01 12:23:06 2010 +0100
220.2 +++ b/csl.api/manifest.mf Mon Feb 01 12:24:26 2010 +0100
220.3 @@ -1,6 +1,6 @@
220.4 Manifest-Version: 1.0
220.5 -OpenIDE-Module: org.netbeans.modules.csl.api/1
220.6 -OpenIDE-Module-Implementation-Version: 1
220.7 +OpenIDE-Module: org.netbeans.modules.csl.api/2
220.8 +OpenIDE-Module-Implementation-Version: 2
220.9 OpenIDE-Module-Layer: org/netbeans/modules/csl/core/layer.xml
220.10 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/csl/api/Bundle.properties
220.11 AutoUpdate-Show-In-Client: false
221.1 --- a/csl.api/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
221.2 +++ b/csl.api/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
221.3 @@ -37,7 +37,7 @@
221.4 # Version 2 license, then the option applies only if the new code is
221.5 # made subject to such option by the copyright holder.
221.6
221.7 -spec.version.base=1.19.0
221.8 +spec.version.base=2.1
221.9 is.autoload=true
221.10 javac.source=1.6
221.11
222.1 --- a/csl.api/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
222.2 +++ b/csl.api/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
222.3 @@ -393,8 +393,6 @@
222.4 </test-dependencies>
222.5 <public-packages>
222.6 <package>org.netbeans.modules.csl.api</package>
222.7 - <package>org.netbeans.modules.csl.core</package>
222.8 - <package>org.netbeans.modules.csl.editor</package>
222.9 <package>org.netbeans.modules.csl.spi</package>
222.10 <package>org.netbeans.modules.csl.spi.support</package>
222.11 </public-packages>
223.1 --- a/csl.api/src/META-INF/services/org.netbeans.spi.editor.mimelookup.MimeLookupInitializer Mon Feb 01 12:23:06 2010 +0100
223.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
223.3 @@ -1,1 +0,0 @@
223.4 -org.netbeans.modules.csl.core.MimeLookupInitializerImpl
224.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
224.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/AbstractCamelCasePosition.java Mon Feb 01 12:24:26 2010 +0100
224.3 @@ -0,0 +1,131 @@
224.4 +/*
224.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
224.6 + *
224.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
224.8 + *
224.9 + * The contents of this file are subject to the terms of either the GNU
224.10 + * General Public License Version 2 only ("GPL") or the Common
224.11 + * Development and Distribution License("CDDL") (collectively, the
224.12 + * "License"). You may not use this file except in compliance with the
224.13 + * License. You can obtain a copy of the License at
224.14 + * http://www.netbeans.org/cddl-gplv2.html
224.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
224.16 + * specific language governing permissions and limitations under the
224.17 + * License. When distributing the software, include this License Header
224.18 + * Notice in each file and include the License file at
224.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
224.20 + * particular file as subject to the "Classpath" exception as provided
224.21 + * by Sun in the GPL Version 2 section of the License file that
224.22 + * accompanied this code. If applicable, add the following below the
224.23 + * License Header, with the fields enclosed by brackets [] replaced by
224.24 + * your own identifying information:
224.25 + * "Portions Copyrighted [year] [name of copyright owner]"
224.26 + *
224.27 + * Contributor(s):
224.28 + *
224.29 + * The Original Software is NetBeans. The Initial Developer of the Original
224.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
224.31 + * Microsystems, Inc. All Rights Reserved.
224.32 + *
224.33 + * If you wish your version of this file to be governed by only the CDDL
224.34 + * or only the GPL Version 2, indicate your decision by adding
224.35 + * "[Contributor] elects to include this software in this distribution
224.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
224.37 + * single choice of license, a recipient has the option to distribute
224.38 + * your version of this file under either the CDDL, the GPL Version 2 or
224.39 + * to extend the choice of license to its licensees as provided above.
224.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
224.41 + * Version 2 license, then the option applies only if the new code is
224.42 + * made subject to such option by the copyright holder.
224.43 + */
224.44 +package org.netbeans.modules.csl.api;
224.45 +
224.46 +import java.awt.event.ActionEvent;
224.47 +import java.util.MissingResourceException;
224.48 +import javax.swing.Action;
224.49 +import javax.swing.text.BadLocationException;
224.50 +import javax.swing.text.JTextComponent;
224.51 +import org.netbeans.editor.BaseAction;
224.52 +import org.netbeans.editor.BaseDocument;
224.53 +import org.netbeans.lib.editor.util.swing.DocumentUtilities;
224.54 +import org.openide.util.NbBundle;
224.55 +
224.56 +/**
224.57 + *
224.58 + * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
224.59 + */
224.60 +public abstract class AbstractCamelCasePosition extends BaseAction {
224.61 +
224.62 + private Action originalAction;
224.63 +
224.64 + public AbstractCamelCasePosition(String name, Action originalAction) {
224.65 + super(name, MAGIC_POSITION_RESET);
224.66 +
224.67 + if (originalAction != null) {
224.68 + Object nameObj = originalAction.getValue(Action.NAME);
224.69 + if (nameObj instanceof String) {
224.70 + // We will be wrapping around the original action, use its name
224.71 + putValue(NAME, nameObj);
224.72 + this.originalAction = originalAction;
224.73 + }
224.74 + }
224.75 +
224.76 + String desc = getShortDescription();
224.77 + if (desc != null) {
224.78 + putValue(SHORT_DESCRIPTION, desc);
224.79 + }
224.80 + }
224.81 +
224.82 + public final void actionPerformed(ActionEvent evt, final JTextComponent target) {
224.83 + if (target != null) {
224.84 + if (originalAction != null && !isUsingCamelCase()) {
224.85 + if (originalAction instanceof BaseAction) {
224.86 + ((BaseAction) originalAction).actionPerformed(evt, target);
224.87 + } else {
224.88 + originalAction.actionPerformed(evt);
224.89 + }
224.90 + } else {
224.91 + final BaseDocument bdoc = org.netbeans.editor.Utilities.getDocument(target);
224.92 + if (bdoc != null) {
224.93 + bdoc.runAtomic(new Runnable() {
224.94 + public void run() {
224.95 + DocumentUtilities.setTypingModification(bdoc, true);
224.96 + try {
224.97 + int offset = newOffset(target);
224.98 + if (offset != -1) {
224.99 + moveToNewOffset(target, offset);
224.100 + }
224.101 + } catch (BadLocationException ble) {
224.102 + target.getToolkit().beep();
224.103 + } finally {
224.104 + DocumentUtilities.setTypingModification(bdoc, false);
224.105 + }
224.106 + }
224.107 + });
224.108 + } else {
224.109 + target.getToolkit().beep();
224.110 + }
224.111 + }
224.112 + }
224.113 + }
224.114 +
224.115 + protected abstract int newOffset(JTextComponent textComponent) throws BadLocationException;
224.116 + protected abstract void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException;
224.117 +
224.118 + public String getShortDescription(){
224.119 + String name = (String)getValue(Action.NAME);
224.120 + if (name == null) return null;
224.121 + String shortDesc;
224.122 + try {
224.123 + shortDesc = NbBundle.getBundle(AbstractCamelCasePosition.class).getString(name); // NOI18N
224.124 + }catch (MissingResourceException mre){
224.125 + shortDesc = name;
224.126 + }
224.127 + return shortDesc;
224.128 + }
224.129 +
224.130 + private boolean isUsingCamelCase() {
224.131 + return !Boolean.getBoolean("no-ruby-camel-case-style-navigation");
224.132 + }
224.133 +}
224.134 +
225.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
225.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/CamelCaseOperations.java Mon Feb 01 12:24:26 2010 +0100
225.3 @@ -0,0 +1,143 @@
225.4 +/*
225.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
225.6 + *
225.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
225.8 + *
225.9 + * The contents of this file are subject to the terms of either the GNU
225.10 + * General Public License Version 2 only ("GPL") or the Common
225.11 + * Development and Distribution License("CDDL") (collectively, the
225.12 + * "License"). You may not use this file except in compliance with the
225.13 + * License. You can obtain a copy of the License at
225.14 + * http://www.netbeans.org/cddl-gplv2.html
225.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
225.16 + * specific language governing permissions and limitations under the
225.17 + * License. When distributing the software, include this License Header
225.18 + * Notice in each file and include the License file at
225.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
225.20 + * particular file as subject to the "Classpath" exception as provided
225.21 + * by Sun in the GPL Version 2 section of the License file that
225.22 + * accompanied this code. If applicable, add the following below the
225.23 + * License Header, with the fields enclosed by brackets [] replaced by
225.24 + * your own identifying information:
225.25 + * "Portions Copyrighted [year] [name of copyright owner]"
225.26 + *
225.27 + * Contributor(s):
225.28 + *
225.29 + * The Original Software is NetBeans. The Initial Developer of the Original
225.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
225.31 + * Microsystems, Inc. All Rights Reserved.
225.32 + *
225.33 + * If you wish your version of this file to be governed by only the CDDL
225.34 + * or only the GPL Version 2, indicate your decision by adding
225.35 + * "[Contributor] elects to include this software in this distribution
225.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
225.37 + * single choice of license, a recipient has the option to distribute
225.38 + * your version of this file under either the CDDL, the GPL Version 2 or
225.39 + * to extend the choice of license to its licensees as provided above.
225.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
225.41 + * Version 2 license, then the option applies only if the new code is
225.42 + * made subject to such option by the copyright holder.
225.43 + */
225.44 +
225.45 +package org.netbeans.modules.csl.api;
225.46 +
225.47 +import javax.swing.text.BadLocationException;
225.48 +import javax.swing.text.Document;
225.49 +import javax.swing.text.JTextComponent;
225.50 +import org.netbeans.editor.BaseDocument;
225.51 +import org.netbeans.editor.Utilities;
225.52 +import org.openide.ErrorManager;
225.53 +
225.54 +/**
225.55 + * CamelCase operations - based on Java ones but rewritten to delegate all logic
225.56 + * to language plugins
225.57 + *
225.58 + * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
225.59 + * @author Tor Norbye
225.60 + */
225.61 +/* package */ class CamelCaseOperations {
225.62 +
225.63 + static int nextCamelCasePosition(JTextComponent textComponent) {
225.64 + int offset = textComponent.getCaretPosition();
225.65 + Document doc = textComponent.getDocument();
225.66 +
225.67 + // Are we at the end of the document?
225.68 + if (offset == doc.getLength()) {
225.69 + return -1;
225.70 + }
225.71 +
225.72 + KeystrokeHandler bc = UiUtils.getBracketCompletion(doc, offset);
225.73 + if (bc != null) {
225.74 + int nextOffset = bc.getNextWordOffset(doc, offset, false);
225.75 + if (nextOffset != -1) {
225.76 + return nextOffset;
225.77 + }
225.78 + }
225.79 +
225.80 + try {
225.81 + return Utilities.getNextWord(textComponent, offset);
225.82 + } catch (BadLocationException ble) {
225.83 + // something went wrong :(
225.84 + ErrorManager.getDefault().notify(ble);
225.85 + }
225.86 + return -1;
225.87 + }
225.88 +
225.89 + static int previousCamelCasePosition(JTextComponent textComponent) {
225.90 + int offset = textComponent.getCaretPosition();
225.91 +
225.92 + // Are we at the beginning of the document?
225.93 + if (offset == 0) {
225.94 + return -1;
225.95 + }
225.96 +
225.97 + final Document doc = textComponent.getDocument();
225.98 +
225.99 + KeystrokeHandler bc = UiUtils.getBracketCompletion(doc, offset);
225.100 + if (bc != null) {
225.101 + int nextOffset = bc.getNextWordOffset(
225.102 + doc, offset, true);
225.103 + if (nextOffset != -1) {
225.104 + return nextOffset;
225.105 + }
225.106 + }
225.107 +
225.108 + try {
225.109 + return Utilities.getPreviousWord(textComponent, offset);
225.110 + } catch (BadLocationException ble) {
225.111 + ErrorManager.getDefault().notify(ble);
225.112 + }
225.113 + return -1;
225.114 + }
225.115 +
225.116 + static void replaceChar(JTextComponent textComponent, int offset, char c) {
225.117 + if (!textComponent.isEditable()) {
225.118 + return;
225.119 + }
225.120 + replaceText(textComponent, offset, 1, String.valueOf(c));
225.121 + }
225.122 +
225.123 + static void replaceText(JTextComponent textComponent, final int offset, final int length, final String text) {
225.124 + if (!textComponent.isEditable()) {
225.125 + return;
225.126 + }
225.127 + final Document document = textComponent.getDocument();
225.128 + Runnable r = new Runnable() {
225.129 + public @Override void run() {
225.130 + try {
225.131 + if (length > 0) {
225.132 + document.remove(offset, length);
225.133 + }
225.134 + document.insertString(offset, text, null);
225.135 + } catch (BadLocationException ble) {
225.136 + ErrorManager.getDefault().notify(ble);
225.137 + }
225.138 + }
225.139 + };
225.140 + if (document instanceof BaseDocument) {
225.141 + ((BaseDocument)document).runAtomic(r);
225.142 + } else {
225.143 + r.run();
225.144 + }
225.145 + }
225.146 +}
226.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
226.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/DeleteToNextCamelCasePosition.java Mon Feb 01 12:24:26 2010 +0100
226.3 @@ -0,0 +1,45 @@
226.4 +/*
226.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
226.6 + *
226.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
226.8 + *
226.9 + * The contents of this file are subject to the terms of either the GNU
226.10 + * General Public License Version 2 only ("GPL") or the Common
226.11 + * Development and Distribution License("CDDL") (collectively, the
226.12 + * "License"). You may not use this file except in compliance with the
226.13 + * License. You can obtain a copy of the License at
226.14 + * http://www.netbeans.org/cddl-gplv2.html
226.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
226.16 + * specific language governing permissions and limitations under the
226.17 + * License. When distributing the software, include this License Header
226.18 + * Notice in each file and include the License file at
226.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
226.20 + * particular file as subject to the "Classpath" exception as provided
226.21 + * by Sun in the GPL Version 2 section of the License file that
226.22 + * accompanied this code. If applicable, add the following below the
226.23 + * License Header, with the fields enclosed by brackets [] replaced by
226.24 + * your own identifying information:
226.25 + * "Portions Copyrighted [year] [name of copyright owner]"
226.26 + *
226.27 + * Contributor(s):
226.28 + *
226.29 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
226.30 + */
226.31 +package org.netbeans.modules.csl.api;
226.32 +
226.33 +import javax.swing.Action;
226.34 +import javax.swing.text.BadLocationException;
226.35 +import javax.swing.text.JTextComponent;
226.36 +
226.37 +/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
226.38 +public final class DeleteToNextCamelCasePosition extends SelectNextCamelCasePosition {
226.39 + public static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
226.40 +
226.41 + public DeleteToNextCamelCasePosition(Action originalAction) {
226.42 + super(deleteNextCamelCasePosition, originalAction);
226.43 + }
226.44 +
226.45 + protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
226.46 + textComponent.getDocument().remove(textComponent.getCaretPosition(), offset - textComponent.getCaretPosition());
226.47 + }
226.48 +}
227.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
227.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/DeleteToPreviousCamelCasePosition.java Mon Feb 01 12:24:26 2010 +0100
227.3 @@ -0,0 +1,60 @@
227.4 +/*
227.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
227.6 + *
227.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
227.8 + *
227.9 + * The contents of this file are subject to the terms of either the GNU
227.10 + * General Public License Version 2 only ("GPL") or the Common
227.11 + * Development and Distribution License("CDDL") (collectively, the
227.12 + * "License"). You may not use this file except in compliance with the
227.13 + * License. You can obtain a copy of the License at
227.14 + * http://www.netbeans.org/cddl-gplv2.html
227.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
227.16 + * specific language governing permissions and limitations under the
227.17 + * License. When distributing the software, include this License Header
227.18 + * Notice in each file and include the License file at
227.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
227.20 + * particular file as subject to the "Classpath" exception as provided
227.21 + * by Sun in the GPL Version 2 section of the License file that
227.22 + * accompanied this code. If applicable, add the following below the
227.23 + * License Header, with the fields enclosed by brackets [] replaced by
227.24 + * your own identifying information:
227.25 + * "Portions Copyrighted [year] [name of copyright owner]"
227.26 + *
227.27 + * Contributor(s):
227.28 + *
227.29 + * The Original Software is NetBeans. The Initial Developer of the Original
227.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
227.31 + * Microsystems, Inc. All Rights Reserved.
227.32 + *
227.33 + * If you wish your version of this file to be governed by only the CDDL
227.34 + * or only the GPL Version 2, indicate your decision by adding
227.35 + * "[Contributor] elects to include this software in this distribution
227.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
227.37 + * single choice of license, a recipient has the option to distribute
227.38 + * your version of this file under either the CDDL, the GPL Version 2 or
227.39 + * to extend the choice of license to its licensees as provided above.
227.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
227.41 + * Version 2 license, then the option applies only if the new code is
227.42 + * made subject to such option by the copyright holder.
227.43 + */
227.44 +package org.netbeans.modules.csl.api;
227.45 +
227.46 +import javax.swing.Action;
227.47 +import javax.swing.text.BadLocationException;
227.48 +import javax.swing.text.JTextComponent;
227.49 +
227.50 +/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
227.51 +public final class DeleteToPreviousCamelCasePosition extends SelectPreviousCamelCasePosition {
227.52 + public static final String deletePreviousCamelCasePosition = "delete-previous-camel-case-position"; //NOI18N
227.53 +
227.54 + public DeleteToPreviousCamelCasePosition(Action originalAction) {
227.55 + // XXX Why does this get called so many times?
227.56 + super(deletePreviousCamelCasePosition, originalAction);
227.57 + }
227.58 + protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
227.59 + textComponent.getDocument().remove(offset, textComponent.getCaretPosition() - offset);
227.60 + }
227.61 +}
227.62 +
227.63 +
228.1 --- a/csl.api/src/org/netbeans/modules/csl/api/GsfLanguage.java Mon Feb 01 12:23:06 2010 +0100
228.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/GsfLanguage.java Mon Feb 01 12:24:26 2010 +0100
228.3 @@ -45,6 +45,7 @@
228.4 import org.netbeans.api.annotations.common.CheckForNull;
228.5 import org.netbeans.api.annotations.common.NonNull;
228.6 import org.netbeans.api.lexer.Language;
228.7 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
228.8
228.9
228.10 /**
228.11 @@ -121,6 +122,7 @@
228.12 * <b>no</b> source classpath.
228.13 *
228.14 * @return The set of source classpath IDs, can be empty or even <code>null</code>.
228.15 + * @deprecated Use {@link PathRecognizerRegistration} instead.
228.16 */
228.17 Set<String> getSourcePathIds();
228.18
228.19 @@ -131,6 +133,7 @@
228.20 *
228.21 * @return The set of library classpath IDs, can be empty or even <code>null</code>.
228.22 * Please see {@link #getSourcePathIds()} for the exact meaning of those values.
228.23 + * @deprecated Use {@link PathRecognizerRegistration} instead.
228.24 */
228.25 Set<String> getLibraryPathIds();
228.26
228.27 @@ -145,6 +148,7 @@
228.28 *
228.29 * @return The set of binary library classpath IDs, can be empty or even <code>null</code>.
228.30 * Please see {@link #getLibraryPathIds()} for the exact meaning of those values.
228.31 + * @deprecated Use {@link PathRecognizerRegistration} instead.
228.32 */
228.33 Set<String> getBinaryLibraryPathIds();
228.34 }
229.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
229.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/InstantRenameAction.java Mon Feb 01 12:24:26 2010 +0100
229.3 @@ -0,0 +1,208 @@
229.4 +/*
229.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
229.6 + *
229.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
229.8 + *
229.9 + * The contents of this file are subject to the terms of either the GNU
229.10 + * General Public License Version 2 only ("GPL") or the Common
229.11 + * Development and Distribution License("CDDL") (collectively, the
229.12 + * "License"). You may not use this file except in compliance with the
229.13 + * License. You can obtain a copy of the License at
229.14 + * http://www.netbeans.org/cddl-gplv2.html
229.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
229.16 + * specific language governing permissions and limitations under the
229.17 + * License. When distributing the software, include this License Header
229.18 + * Notice in each file and include the License file at
229.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
229.20 + * particular file as subject to the "Classpath" exception as provided
229.21 + * by Sun in the GPL Version 2 section of the License file that
229.22 + * accompanied this code. If applicable, add the following below the
229.23 + * License Header, with the fields enclosed by brackets [] replaced by
229.24 + * your own identifying information:
229.25 + * "Portions Copyrighted [year] [name of copyright owner]"
229.26 + *
229.27 + * Contributor(s):
229.28 + *
229.29 + * The Original Software is NetBeans. The Initial Developer of the Original
229.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
229.31 + * Microsystems, Inc. All Rights Reserved.
229.32 + *
229.33 + * If you wish your version of this file to be governed by only the CDDL
229.34 + * or only the GPL Version 2, indicate your decision by adding
229.35 + * "[Contributor] elects to include this software in this distribution
229.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
229.37 + * single choice of license, a recipient has the option to distribute
229.38 + * your version of this file under either the CDDL, the GPL Version 2 or
229.39 + * to extend the choice of license to its licensees as provided above.
229.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
229.41 + * Version 2 license, then the option applies only if the new code is
229.42 + * made subject to such option by the copyright holder.
229.43 + */
229.44 +package org.netbeans.modules.csl.api;
229.45 +
229.46 +import java.awt.event.ActionEvent;
229.47 +import java.io.IOException;
229.48 +import java.util.Collections;
229.49 +import java.util.List;
229.50 +import java.util.Set;
229.51 +import javax.swing.Action;
229.52 +
229.53 +import javax.swing.text.BadLocationException;
229.54 +import javax.swing.text.Document;
229.55 +import javax.swing.text.JTextComponent;
229.56 +
229.57 +import org.netbeans.modules.parsing.api.Source;
229.58 +import org.netbeans.modules.parsing.api.UserTask;
229.59 +import org.netbeans.modules.parsing.spi.ParseException;
229.60 +import org.netbeans.editor.BaseAction;
229.61 +import org.netbeans.editor.BaseDocument;
229.62 +import org.netbeans.editor.Utilities;
229.63 +import org.netbeans.modules.csl.core.Language;
229.64 +import org.netbeans.modules.csl.core.LanguageRegistry;
229.65 +import org.netbeans.modules.csl.editor.InstantRenamePerformer;
229.66 +import org.netbeans.modules.csl.spi.ParserResult;
229.67 +import org.netbeans.modules.parsing.api.ParserManager;
229.68 +import org.netbeans.modules.parsing.api.ResultIterator;
229.69 +import org.netbeans.modules.parsing.api.indexing.IndexingManager;
229.70 +import org.netbeans.modules.parsing.spi.Parser;
229.71 +import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory;
229.72 +import org.openide.ErrorManager;
229.73 +import org.openide.cookies.EditorCookie;
229.74 +import org.openide.nodes.Node;
229.75 +import org.openide.util.Lookup;
229.76 +import org.openide.util.NbBundle;
229.77 +import org.openide.util.lookup.AbstractLookup;
229.78 +import org.openide.util.lookup.InstanceContent;
229.79 +
229.80 +
229.81 +/**
229.82 + * This file is originally from Retouche, the Java Support
229.83 + * infrastructure in NetBeans. I have modified the file as little
229.84 + * as possible to make merging Retouche fixes back as simple as
229.85 + * possible.
229.86 + *
229.87 + *
229.88 + * @author Jan Lahoda
229.89 + * @author Tor Norbye
229.90 + */
229.91 +public class InstantRenameAction extends BaseAction {
229.92 + /** Creates a new instance of InstantRenameAction */
229.93 + public InstantRenameAction() {
229.94 + super("in-place-refactoring", MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
229.95 + }
229.96 +
229.97 + public @Override void actionPerformed(ActionEvent evt, final JTextComponent target) {
229.98 + try {
229.99 + final int caret = target.getCaretPosition();
229.100 + String ident = Utilities.getIdentifier(Utilities.getDocument(target), caret);
229.101 +
229.102 + if (ident == null) {
229.103 + Utilities.setStatusBoldText(target, NbBundle.getMessage(InstantRenameAction.class, "InstantRenameDenied"));
229.104 + return;
229.105 + }
229.106 +
229.107 + if (IndexingManager.getDefault().isIndexing()) {
229.108 + Utilities.setStatusBoldText(target, NbBundle.getMessage(InstantRenameAction.class, "scanning-in-progress"));
229.109 + return;
229.110 + }
229.111 +
229.112 + Source js = Source.create (DataLoadersBridge.getDefault().getFileObject(target));
229.113 + if (js == null) {
229.114 + return;
229.115 + }
229.116 +
229.117 + final boolean[] wasResolved = new boolean[1];
229.118 + final String[] message = new String[1];
229.119 + final Set<OffsetRange>[] changePoints = new Set[1];
229.120 +
229.121 + ParserManager.parse (
229.122 + Collections.<Source> singleton (js),
229.123 + new UserTask () {
229.124 + public @Override void run (ResultIterator resultIterator) throws Exception {
229.125 + Parser.Result result = resultIterator.getParserResult (target.getCaretPosition ());
229.126 + if(!(result instanceof ParserResult)) {
229.127 + return ;
229.128 + }
229.129 + ParserResult parserResult = (ParserResult)result;
229.130 + Document doc = target.getDocument();
229.131 + BaseDocument baseDoc = (BaseDocument)doc;
229.132 + List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, caret);
229.133 + Language language = null;
229.134 + for (Language l : list) {
229.135 + if (l.getInstantRenamer() != null) {
229.136 + language = l;
229.137 + break;
229.138 + }
229.139 + }
229.140 +
229.141 + if (language != null) {
229.142 + InstantRenamer renamer = language.getInstantRenamer();
229.143 + assert renamer != null;
229.144 +
229.145 + String[] descRetValue = new String[1];
229.146 +
229.147 + if ((renamer == null) ||
229.148 + !renamer.isRenameAllowed(parserResult, caret, descRetValue)) {
229.149 + wasResolved[0] = false;
229.150 + message[0] = descRetValue[0];
229.151 +
229.152 + return;
229.153 + }
229.154 +
229.155 + wasResolved[0] = true;
229.156 +
229.157 + Set<OffsetRange> regions = renamer.getRenameRegions(parserResult, caret);
229.158 +
229.159 + if ((regions != null) && (regions.size() > 0)) {
229.160 + changePoints[0] = regions;
229.161 + }
229.162 + }
229.163 + }
229.164 + }
229.165 + );
229.166 +
229.167 + if (wasResolved[0]) {
229.168 + if (changePoints[0] != null) {
229.169 + doInstantRename(changePoints[0], target, caret, ident);
229.170 + } else {
229.171 + doFullRename((EditorCookie)DataLoadersBridge.getDefault().getCookie(target,EditorCookie.class), DataLoadersBridge.getDefault().getNodeDelegate(target));
229.172 + }
229.173 + } else {
229.174 + if (message[0] == null) {
229.175 + message[0] = NbBundle.getMessage(InstantRenameAction.class,
229.176 + "InstantRenameDenied");
229.177 + }
229.178 +
229.179 + Utilities.setStatusBoldText(target, message[0]);
229.180 + }
229.181 + } catch (BadLocationException e) {
229.182 + ErrorManager.getDefault().notify(e);
229.183 + } catch (IOException ioe) {
229.184 + ErrorManager.getDefault().notify(ioe);
229.185 + } catch (ParseException ioe) {
229.186 + ErrorManager.getDefault().notify(ioe);
229.187 + }
229.188 + }
229.189 +
229.190 + @Override
229.191 + protected Class getShortDescriptionBundleClass() {
229.192 + return InstantRenameAction.class;
229.193 + }
229.194 +
229.195 + private void doInstantRename(Set<OffsetRange> changePoints, JTextComponent target, int caret,
229.196 + String ident) throws BadLocationException {
229.197 + InstantRenamePerformer.performInstantRename(target, changePoints, caret);
229.198 + }
229.199 +
229.200 + private void doFullRename(EditorCookie ec, Node n) {
229.201 + InstanceContent ic = new InstanceContent();
229.202 + ic.add(ec);
229.203 + ic.add(n);
229.204 +
229.205 + Lookup actionContext = new AbstractLookup(ic);
229.206 +
229.207 + Action a =
229.208 + RefactoringActionsFactory.renameAction().createContextAwareInstance(actionContext);
229.209 + a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
229.210 + }
229.211 +}
230.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
230.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/NextCamelCasePosition.java Mon Feb 01 12:24:26 2010 +0100
230.3 @@ -0,0 +1,53 @@
230.4 +/*
230.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
230.6 + *
230.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
230.8 + *
230.9 + * The contents of this file are subject to the terms of either the GNU
230.10 + * General Public License Version 2 only ("GPL") or the Common
230.11 + * Development and Distribution License("CDDL") (collectively, the
230.12 + * "License"). You may not use this file except in compliance with the
230.13 + * License. You can obtain a copy of the License at
230.14 + * http://www.netbeans.org/cddl-gplv2.html
230.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
230.16 + * specific language governing permissions and limitations under the
230.17 + * License. When distributing the software, include this License Header
230.18 + * Notice in each file and include the License file at
230.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
230.20 + * particular file as subject to the "Classpath" exception as provided
230.21 + * by Sun in the GPL Version 2 section of the License file that
230.22 + * accompanied this code. If applicable, add the following below the
230.23 + * License Header, with the fields enclosed by brackets [] replaced by
230.24 + * your own identifying information:
230.25 + * "Portions Copyrighted [year] [name of copyright owner]"
230.26 + *
230.27 + * Contributor(s):
230.28 + *
230.29 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
230.30 + */
230.31 +package org.netbeans.modules.csl.api;
230.32 +
230.33 +import javax.swing.Action;
230.34 +import javax.swing.text.BadLocationException;
230.35 +import javax.swing.text.JTextComponent;
230.36 +
230.37 +/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
230.38 +public class NextCamelCasePosition extends AbstractCamelCasePosition {
230.39 + public static final String nextCamelCasePosition = "next-camel-case-position"; //NOI18N
230.40 +
230.41 + public NextCamelCasePosition(Action originalAction) {
230.42 + this(nextCamelCasePosition, originalAction);
230.43 + }
230.44 +
230.45 + protected NextCamelCasePosition(String name, Action originalAction) {
230.46 + super(name, originalAction);
230.47 + }
230.48 +
230.49 + protected int newOffset(JTextComponent textComponent) throws BadLocationException {
230.50 + return CamelCaseOperations.nextCamelCasePosition(textComponent);
230.51 + }
230.52 +
230.53 + protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
230.54 + textComponent.setCaretPosition(offset);
230.55 + }
230.56 +}
231.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
231.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/PreviousCamelCasePosition.java Mon Feb 01 12:24:26 2010 +0100
231.3 @@ -0,0 +1,67 @@
231.4 +/*
231.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
231.6 + *
231.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
231.8 + *
231.9 + * The contents of this file are subject to the terms of either the GNU
231.10 + * General Public License Version 2 only ("GPL") or the Common
231.11 + * Development and Distribution License("CDDL") (collectively, the
231.12 + * "License"). You may not use this file except in compliance with the
231.13 + * License. You can obtain a copy of the License at
231.14 + * http://www.netbeans.org/cddl-gplv2.html
231.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
231.16 + * specific language governing permissions and limitations under the
231.17 + * License. When distributing the software, include this License Header
231.18 + * Notice in each file and include the License file at
231.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
231.20 + * particular file as subject to the "Classpath" exception as provided
231.21 + * by Sun in the GPL Version 2 section of the License file that
231.22 + * accompanied this code. If applicable, add the following below the
231.23 + * License Header, with the fields enclosed by brackets [] replaced by
231.24 + * your own identifying information:
231.25 + * "Portions Copyrighted [year] [name of copyright owner]"
231.26 + *
231.27 + * Contributor(s):
231.28 + *
231.29 + * The Original Software is NetBeans. The Initial Developer of the Original
231.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
231.31 + * Microsystems, Inc. All Rights Reserved.
231.32 + *
231.33 + * If you wish your version of this file to be governed by only the CDDL
231.34 + * or only the GPL Version 2, indicate your decision by adding
231.35 + * "[Contributor] elects to include this software in this distribution
231.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
231.37 + * single choice of license, a recipient has the option to distribute
231.38 + * your version of this file under either the CDDL, the GPL Version 2 or
231.39 + * to extend the choice of license to its licensees as provided above.
231.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
231.41 + * Version 2 license, then the option applies only if the new code is
231.42 + * made subject to such option by the copyright holder.
231.43 + */
231.44 +package org.netbeans.modules.csl.api;
231.45 +
231.46 +import javax.swing.Action;
231.47 +import javax.swing.text.BadLocationException;
231.48 +import javax.swing.text.JTextComponent;
231.49 +
231.50 +/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
231.51 +public class PreviousCamelCasePosition extends AbstractCamelCasePosition {
231.52 + public static final String previousCamelCasePosition = "previous-camel-case-position"; //NOI18N
231.53 +
231.54 + public PreviousCamelCasePosition(Action originalAction) {
231.55 + this(previousCamelCasePosition, originalAction);
231.56 + }
231.57 +
231.58 + protected PreviousCamelCasePosition(String name, Action originalAction) {
231.59 + super(name, originalAction);
231.60 + }
231.61 +
231.62 + protected int newOffset(JTextComponent textComponent) throws BadLocationException {
231.63 + return CamelCaseOperations.previousCamelCasePosition(textComponent);
231.64 + }
231.65 +
231.66 + protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
231.67 + textComponent.setCaretPosition(offset);
231.68 + }
231.69 +}
231.70 +
232.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
232.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/SelectCodeElementAction.java Mon Feb 01 12:24:26 2010 +0100
232.3 @@ -0,0 +1,291 @@
232.4 +/*
232.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
232.6 + *
232.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
232.8 + *
232.9 + * The contents of this file are subject to the terms of either the GNU
232.10 + * General Public License Version 2 only ("GPL") or the Common
232.11 + * Development and Distribution License("CDDL") (collectively, the
232.12 + * "License"). You may not use this file except in compliance with the
232.13 + * License. You can obtain a copy of the License at
232.14 + * http://www.netbeans.org/cddl-gplv2.html
232.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
232.16 + * specific language governing permissions and limitations under the
232.17 + * License. When distributing the software, include this License Header
232.18 + * Notice in each file and include the License file at
232.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
232.20 + * particular file as subject to the "Classpath" exception as provided
232.21 + * by Sun in the GPL Version 2 section of the License file that
232.22 + * accompanied this code. If applicable, add the following below the
232.23 + * License Header, with the fields enclosed by brackets [] replaced by
232.24 + * your own identifying information:
232.25 + * "Portions Copyrighted [year] [name of copyright owner]"
232.26 + *
232.27 + * Contributor(s):
232.28 + *
232.29 + * The Original Software is NetBeans. The Initial Developer of the Original
232.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
232.31 + * Microsystems, Inc. All Rights Reserved.
232.32 + *
232.33 + * If you wish your version of this file to be governed by only the CDDL
232.34 + * or only the GPL Version 2, indicate your decision by adding
232.35 + * "[Contributor] elects to include this software in this distribution
232.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
232.37 + * single choice of license, a recipient has the option to distribute
232.38 + * your version of this file under either the CDDL, the GPL Version 2 or
232.39 + * to extend the choice of license to its licensees as provided above.
232.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
232.41 + * Version 2 license, then the option applies only if the new code is
232.42 + * made subject to such option by the copyright holder.
232.43 + */
232.44 +
232.45 +package org.netbeans.modules.csl.api;
232.46 +
232.47 +import java.awt.event.ActionEvent;
232.48 +import java.util.Collections;
232.49 +import java.util.List;
232.50 +import java.util.MissingResourceException;
232.51 +import javax.swing.Action;
232.52 +import javax.swing.event.CaretEvent;
232.53 +import javax.swing.event.CaretListener;
232.54 +import javax.swing.text.Caret;
232.55 +import javax.swing.text.Document;
232.56 +import javax.swing.text.JTextComponent;
232.57 +
232.58 +import org.netbeans.editor.BaseAction;
232.59 +import org.netbeans.editor.BaseDocument;
232.60 +import org.netbeans.modules.csl.core.Language;
232.61 +import org.netbeans.modules.csl.core.LanguageRegistry;
232.62 +import org.netbeans.modules.csl.spi.ParserResult;
232.63 +import org.netbeans.modules.parsing.api.ParserManager;
232.64 +import org.netbeans.modules.parsing.api.ResultIterator;
232.65 +import org.netbeans.modules.parsing.api.Source;
232.66 +import org.netbeans.modules.parsing.api.UserTask;
232.67 +import org.netbeans.modules.parsing.spi.ParseException;
232.68 +import org.netbeans.modules.parsing.spi.Parser;
232.69 +import org.openide.ErrorManager;
232.70 +import org.openide.util.NbBundle;
232.71 +
232.72 +/**
232.73 + * Code selection according to syntax tree.
232.74 + *
232.75 + * TODO: javadoc selection
232.76 + *
232.77 + * @author Miloslav Metelka, Jan Pokorsky
232.78 + */
232.79 +public final class SelectCodeElementAction extends BaseAction {
232.80 + public static final String selectNextElementAction = "select-element-next"; //NOI18N
232.81 + public static final String selectPreviousElementAction = "select-element-previous"; //NOI18N
232.82 +
232.83 + private boolean selectNext;
232.84 +
232.85 + /**
232.86 + * Construct new action that selects next/previous code elements
232.87 + * according to the language model.
232.88 + * <br>
232.89 + *
232.90 + * @param name name of the action (should be one of
232.91 + * <br>
232.92 + * <code>JavaKit.selectNextElementAction</code>
232.93 + * <code>JavaKit.selectPreviousElementAction</code>
232.94 + * @param selectNext <code>true</code> if the next element should be selected.
232.95 + * <code>False</code> if the previous element should be selected.
232.96 + */
232.97 + public SelectCodeElementAction(String name, boolean selectNext) {
232.98 + super(name);
232.99 + this.selectNext = selectNext;
232.100 + String desc = getShortDescription();
232.101 + if (desc != null) {
232.102 + putValue(SHORT_DESCRIPTION, desc);
232.103 + }
232.104 + }
232.105 +
232.106 + public String getShortDescription(){
232.107 + String name = (String)getValue(Action.NAME);
232.108 + if (name == null) return null;
232.109 + String shortDesc;
232.110 + try {
232.111 + shortDesc = NbBundle.getBundle(SelectCodeElementAction.class).getString(name); // NOI18N
232.112 + }catch (MissingResourceException mre){
232.113 + shortDesc = name;
232.114 + }
232.115 + return shortDesc;
232.116 + }
232.117 +
232.118 + public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
232.119 + if (target != null) {
232.120 + int selectionStartOffset = target.getSelectionStart();
232.121 + int selectionEndOffset = target.getSelectionEnd();
232.122 + if (selectionEndOffset > selectionStartOffset || selectNext) {
232.123 + SelectionHandler handler = (SelectionHandler)target.getClientProperty(SelectionHandler.class);
232.124 + if (handler == null) {
232.125 + handler = new SelectionHandler(target);
232.126 + target.addCaretListener(handler);
232.127 + // No need to remove the listener above as the handler
232.128 + // is stored is the client-property of the component itself
232.129 + target.putClientProperty(SelectionHandler.class, handler);
232.130 + }
232.131 +
232.132 + if (selectNext) { // select next element
232.133 + handler.selectNext();
232.134 + } else { // select previous
232.135 + handler.selectPrevious();
232.136 + }
232.137 + }
232.138 + }
232.139 + }
232.140 +
232.141 + private static final class SelectionHandler extends UserTask implements CaretListener, Runnable {
232.142 +
232.143 + private JTextComponent target;
232.144 + private SelectionInfo[] selectionInfos;
232.145 + private int selIndex = -1;
232.146 + private boolean ignoreNextCaretUpdate;
232.147 +
232.148 + SelectionHandler(JTextComponent target) {
232.149 + this.target = target;
232.150 + }
232.151 +
232.152 + public void selectNext() {
232.153 + if (selectionInfos == null) {
232.154 + Source source = Source.create (target.getDocument());
232.155 + try {
232.156 + ParserManager.parse (Collections.<Source> singleton (source), this);
232.157 + } catch (ParseException ex) {
232.158 + ErrorManager.getDefault().notify(ex);
232.159 + }
232.160 + }
232.161 +
232.162 + run();
232.163 + }
232.164 +
232.165 + public synchronized void selectPrevious() {
232.166 + if (selIndex == -1) {
232.167 + // Try to figure out the selected AST index based on the editor selection
232.168 + selIndex = computeSelIndex(false);
232.169 + }
232.170 + if (selIndex > 0) {
232.171 + select(selectionInfos[--selIndex]);
232.172 + }
232.173 + }
232.174 +
232.175 + private void select(SelectionInfo selectionInfo) {
232.176 + Caret caret = target.getCaret();
232.177 + markIgnoreNextCaretUpdate();
232.178 + caret.setDot(selectionInfo.getStartOffset());
232.179 + markIgnoreNextCaretUpdate();
232.180 + caret.moveDot(selectionInfo.getEndOffset());
232.181 + }
232.182 +
232.183 + private void markIgnoreNextCaretUpdate() {
232.184 + ignoreNextCaretUpdate = true;
232.185 + }
232.186 +
232.187 + public @Override void caretUpdate(CaretEvent e) {
232.188 + if (!ignoreNextCaretUpdate) {
232.189 + synchronized (this) {
232.190 + selectionInfos = null;
232.191 + selIndex = -1;
232.192 + }
232.193 + }
232.194 + ignoreNextCaretUpdate = false;
232.195 + }
232.196 +
232.197 + public void cancel() {
232.198 + }
232.199 +
232.200 + public @Override void run (ResultIterator resultIterator) throws ParseException {
232.201 + Parser.Result parserResult = resultIterator.getParserResult (target.getCaretPosition ());
232.202 + if(!(parserResult instanceof ParserResult)) {
232.203 + return ;
232.204 + }
232.205 + selectionInfos = initSelectionPath(target, (ParserResult)parserResult);
232.206 + }
232.207 +
232.208 + private KeystrokeHandler getBracketCompletion(Document doc, int offset) {
232.209 + BaseDocument baseDoc = (BaseDocument)doc;
232.210 + List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset);
232.211 + for (Language l : list) {
232.212 + if (l.getBracketCompletion() != null) {
232.213 + return l.getBracketCompletion();
232.214 + }
232.215 + }
232.216 +
232.217 + return null;
232.218 + }
232.219 +
232.220 + private SelectionInfo[] initSelectionPath(JTextComponent target, ParserResult parserResult) {
232.221 + KeystrokeHandler bc = getBracketCompletion(target.getDocument(), target.getCaretPosition());
232.222 + if (bc != null) {
232.223 + List<OffsetRange> ranges = bc.findLogicalRanges(parserResult, target.getCaretPosition());
232.224 + SelectionInfo[] result = new SelectionInfo[ranges.size()];
232.225 + for (int i = 0; i < ranges.size(); i++) {
232.226 + OffsetRange range = ranges.get(i);
232.227 + result[i] = new SelectionInfo(range.getStart(), range.getEnd());
232.228 + }
232.229 + return result;
232.230 + } else {
232.231 + return new SelectionInfo[0];
232.232 + }
232.233 + }
232.234 +
232.235 + private int computeSelIndex(boolean inner) {
232.236 + Caret caret = target.getCaret();
232.237 + if (selectionInfos != null && caret != null && caret.getDot() != caret.getMark()) {
232.238 + int dot = caret.getDot();
232.239 + int mark = caret.getMark();
232.240 + int start = Math.min(dot,mark);
232.241 + //int end = Math.max(dot,mark);
232.242 + for (int i = 0; i < selectionInfos.length; i++) {
232.243 + if (selectionInfos[i].getStartOffset() == start) {
232.244 + // TODO - check end offset too
232.245 + return i;
232.246 + }
232.247 + }
232.248 + // No exact match - look at the editor selection and find the range
232.249 + // that most closely surround the selection (if inner is true, go
232.250 + // for the inner one, otherwise the outer)
232.251 + for (int i = selectionInfos.length-2; i >= 0; i--) {
232.252 + if (selectionInfos[i].getStartOffset() > start &&
232.253 + selectionInfos[i+1].getStartOffset() < start) {
232.254 + return inner ? i : i-1;
232.255 + }
232.256 + }
232.257 + }
232.258 +
232.259 + return selIndex;
232.260 + }
232.261 +
232.262 + public @Override void run() {
232.263 + if (selIndex == -1) {
232.264 + // Try to figure out the selected AST index based on the editor selection
232.265 + selIndex = computeSelIndex(true);
232.266 + }
232.267 + if (selIndex < selectionInfos.length - 1) {
232.268 + select(selectionInfos[++selIndex]);
232.269 + }
232.270 + }
232.271 +
232.272 + }
232.273 +
232.274 + // This looks a lot like an OffsetRange! Just reuse my own OffsetRange class?
232.275 + private static final class SelectionInfo {
232.276 +
232.277 + private int startOffset;
232.278 + private int endOffset;
232.279 +
232.280 + SelectionInfo(int startOffset, int endOffset) {
232.281 + this.startOffset = startOffset;
232.282 + this.endOffset = endOffset;
232.283 + }
232.284 +
232.285 + public int getStartOffset() {
232.286 + return startOffset;
232.287 + }
232.288 +
232.289 + public int getEndOffset() {
232.290 + return endOffset;
232.291 + }
232.292 +
232.293 + }
232.294 +}
233.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
233.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/SelectNextCamelCasePosition.java Mon Feb 01 12:24:26 2010 +0100
233.3 @@ -0,0 +1,49 @@
233.4 +/*
233.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
233.6 + *
233.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
233.8 + *
233.9 + * The contents of this file are subject to the terms of either the GNU
233.10 + * General Public License Version 2 only ("GPL") or the Common
233.11 + * Development and Distribution License("CDDL") (collectively, the
233.12 + * "License"). You may not use this file except in compliance with the
233.13 + * License. You can obtain a copy of the License at
233.14 + * http://www.netbeans.org/cddl-gplv2.html
233.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
233.16 + * specific language governing permissions and limitations under the
233.17 + * License. When distributing the software, include this License Header
233.18 + * Notice in each file and include the License file at
233.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
233.20 + * particular file as subject to the "Classpath" exception as provided
233.21 + * by Sun in the GPL Version 2 section of the License file that
233.22 + * accompanied this code. If applicable, add the following below the
233.23 + * License Header, with the fields enclosed by brackets [] replaced by
233.24 + * your own identifying information:
233.25 + * "Portions Copyrighted [year] [name of copyright owner]"
233.26 + *
233.27 + * Contributor(s):
233.28 + *
233.29 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
233.30 + */
233.31 +package org.netbeans.modules.csl.api;
233.32 +
233.33 +import javax.swing.Action;
233.34 +import javax.swing.text.BadLocationException;
233.35 +import javax.swing.text.JTextComponent;
233.36 +
233.37 +/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
233.38 +public class SelectNextCamelCasePosition extends NextCamelCasePosition {
233.39 + public static final String selectNextCamelCasePosition = "select-next-camel-case-position"; //NOI18N
233.40 +
233.41 + public SelectNextCamelCasePosition(Action originalAction) {
233.42 + this(selectNextCamelCasePosition, originalAction);
233.43 + }
233.44 +
233.45 + protected SelectNextCamelCasePosition(String name, Action originalAction) {
233.46 + super(name, originalAction);
233.47 + }
233.48 +
233.49 + protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
233.50 + textComponent.getCaret().moveDot(offset);
233.51 + }
233.52 +}
234.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
234.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/SelectPreviousCamelCasePosition.java Mon Feb 01 12:24:26 2010 +0100
234.3 @@ -0,0 +1,62 @@
234.4 +/*
234.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
234.6 + *
234.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
234.8 + *
234.9 + * The contents of this file are subject to the terms of either the GNU
234.10 + * General Public License Version 2 only ("GPL") or the Common
234.11 + * Development and Distribution License("CDDL") (collectively, the
234.12 + * "License"). You may not use this file except in compliance with the
234.13 + * License. You can obtain a copy of the License at
234.14 + * http://www.netbeans.org/cddl-gplv2.html
234.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
234.16 + * specific language governing permissions and limitations under the
234.17 + * License. When distributing the software, include this License Header
234.18 + * Notice in each file and include the License file at
234.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
234.20 + * particular file as subject to the "Classpath" exception as provided
234.21 + * by Sun in the GPL Version 2 section of the License file that
234.22 + * accompanied this code. If applicable, add the following below the
234.23 + * License Header, with the fields enclosed by brackets [] replaced by
234.24 + * your own identifying information:
234.25 + * "Portions Copyrighted [year] [name of copyright owner]"
234.26 + *
234.27 + * Contributor(s):
234.28 + *
234.29 + * The Original Software is NetBeans. The Initial Developer of the Original
234.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
234.31 + * Microsystems, Inc. All Rights Reserved.
234.32 + *
234.33 + * If you wish your version of this file to be governed by only the CDDL
234.34 + * or only the GPL Version 2, indicate your decision by adding
234.35 + * "[Contributor] elects to include this software in this distribution
234.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
234.37 + * single choice of license, a recipient has the option to distribute
234.38 + * your version of this file under either the CDDL, the GPL Version 2 or
234.39 + * to extend the choice of license to its licensees as provided above.
234.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
234.41 + * Version 2 license, then the option applies only if the new code is
234.42 + * made subject to such option by the copyright holder.
234.43 + */
234.44 +package org.netbeans.modules.csl.api;
234.45 +
234.46 +import javax.swing.Action;
234.47 +import javax.swing.text.BadLocationException;
234.48 +import javax.swing.text.JTextComponent;
234.49 +
234.50 +/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
234.51 +public class SelectPreviousCamelCasePosition extends PreviousCamelCasePosition {
234.52 + public static final String selectPreviousCamelCasePosition = "select-previous-camel-case-position"; //NOI18N
234.53 +
234.54 + public SelectPreviousCamelCasePosition(Action originalAction) {
234.55 + this(selectPreviousCamelCasePosition, originalAction);
234.56 + }
234.57 +
234.58 + protected SelectPreviousCamelCasePosition(String name, Action originalAction) {
234.59 + super(name, originalAction);
234.60 + }
234.61 +
234.62 + protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
234.63 + textComponent.getCaret().moveDot(offset);
234.64 + }
234.65 +}
235.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
235.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/ToggleBlockCommentAction.java Mon Feb 01 12:24:26 2010 +0100
235.3 @@ -0,0 +1,304 @@
235.4 +/*
235.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
235.6 + *
235.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
235.8 + *
235.9 + * The contents of this file are subject to the terms of either the GNU
235.10 + * General Public License Version 2 only ("GPL") or the Common
235.11 + * Development and Distribution License("CDDL") (collectively, the
235.12 + * "License"). You may not use this file except in compliance with the
235.13 + * License. You can obtain a copy of the License at
235.14 + * http://www.netbeans.org/cddl-gplv2.html
235.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
235.16 + * specific language governing permissions and limitations under the
235.17 + * License. When distributing the software, include this License Header
235.18 + * Notice in each file and include the License file at
235.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
235.20 + * particular file as subject to the "Classpath" exception as provided
235.21 + * by Sun in the GPL Version 2 section of the License file that
235.22 + * accompanied this code. If applicable, add the following below the
235.23 + * License Header, with the fields enclosed by brackets [] replaced by
235.24 + * your own identifying information:
235.25 + * "Portions Copyrighted [year] [name of copyright owner]"
235.26 + *
235.27 + * If you wish your version of this file to be governed by only the CDDL
235.28 + * or only the GPL Version 2, indicate your decision by adding
235.29 + * "[Contributor] elects to include this software in this distribution
235.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
235.31 + * single choice of license, a recipient has the option to distribute
235.32 + * your version of this file under either the CDDL, the GPL Version 2 or
235.33 + * to extend the choice of license to its licensees as provided above.
235.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
235.35 + * Version 2 license, then the option applies only if the new code is
235.36 + * made subject to such option by the copyright holder.
235.37 + *
235.38 + * Contributor(s):
235.39 + *
235.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
235.41 + */
235.42 +package org.netbeans.modules.csl.api;
235.43 +
235.44 +import java.awt.event.ActionEvent;
235.45 +import javax.swing.text.BadLocationException;
235.46 +import javax.swing.text.Caret;
235.47 +import javax.swing.text.Document;
235.48 +import javax.swing.text.JTextComponent;
235.49 +import org.netbeans.editor.BaseDocument;
235.50 +import org.netbeans.editor.Utilities;
235.51 +import org.netbeans.editor.ext.ExtKit;
235.52 +import org.netbeans.lib.editor.util.CharSequenceUtilities;
235.53 +import org.netbeans.lib.editor.util.swing.DocumentUtilities;
235.54 +import org.netbeans.modules.csl.spi.CommentHandler;
235.55 +import org.openide.util.Exceptions;
235.56 +
235.57 +public class ToggleBlockCommentAction extends ExtKit.ToggleCommentAction {
235.58 +
235.59 + static final long serialVersionUID = -1L;
235.60 + private final CommentHandler commentHandler;
235.61 + private final int COMMENT_START_LENGTH;
235.62 + private final int COMMENT_END_LENGTH;
235.63 +
235.64 + public ToggleBlockCommentAction(CommentHandler commentHandler) {
235.65 + super("");
235.66 + this.COMMENT_START_LENGTH = commentHandler.getCommentStartDelimiter().length();
235.67 + this.COMMENT_END_LENGTH = commentHandler.getCommentEndDelimiter().length();
235.68 + this.commentHandler = commentHandler;
235.69 + }
235.70 +
235.71 + @Override
235.72 + public void actionPerformed(ActionEvent evt, final JTextComponent target) {
235.73 + if (target != null) {
235.74 + if (!target.isEditable() || !target.isEnabled()) {
235.75 + target.getToolkit().beep();
235.76 + return;
235.77 + }
235.78 +
235.79 + final Caret caret = target.getCaret();
235.80 + final BaseDocument doc = (BaseDocument) target.getDocument();
235.81 +
235.82 + int from = Utilities.isSelectionShowing(caret) ? target.getSelectionStart() : caret.getDot();
235.83 + int to = Utilities.isSelectionShowing(caret) ? target.getSelectionEnd() : caret.getDot();
235.84 +
235.85 + boolean lineSelection = false;
235.86 + boolean inComment = isInComment(doc, from);
235.87 + if (from == to) {
235.88 + //no selection
235.89 + if (!inComment) {
235.90 + try {
235.91 + //check for commenting empty line
235.92 + if (Utilities.isRowEmpty(doc, from) || Utilities.isRowWhite(doc, from)) {
235.93 + return;
235.94 + }
235.95 +
235.96 + //extend the range to the whole line
235.97 + from = Utilities.getFirstNonWhiteFwd(doc, Utilities.getRowStart(doc, from));
235.98 + to = Utilities.getFirstNonWhiteBwd(doc, Utilities.getRowEnd(doc, to)) + 1;
235.99 + lineSelection = true;
235.100 + } catch (BadLocationException ex) {
235.101 + Exceptions.printStackTrace(ex);
235.102 + }
235.103 + }
235.104 + }
235.105 +
235.106 + if(!inComment && from == to) {
235.107 + return ; //no-op
235.108 + }
235.109 +
235.110 + int[] adjustedRange = commentHandler.getAdjustedBlocks(doc, from, to);
235.111 + if(adjustedRange.length == 0) {
235.112 + return; //no-op
235.113 + }
235.114 +
235.115 + from = adjustedRange[0];
235.116 + to = adjustedRange[1];
235.117 +
235.118 + if(!inComment && from == to) {
235.119 + return ; //no-op
235.120 + }
235.121 +
235.122 + final int comments[] = commentHandler.getCommentBlocks(doc, from, to);
235.123 +
235.124 + assert comments != null;
235.125 +
235.126 +// debug(doc, comments, from, to);
235.127 +
235.128 + check(comments, from, to);
235.129 +
235.130 + final int _from = from;
235.131 + final int _to = to;
235.132 + final boolean _lineSelection = lineSelection;
235.133 +
235.134 + doc.runAtomic(new Runnable() {
235.135 +
235.136 + public void run() {
235.137 + try {
235.138 + int[] commentRange = getCommentRange(comments, _from);
235.139 + if (commentRange == null) {
235.140 + //comment
235.141 + comment(target, doc, comments, _from, _to, _lineSelection);
235.142 + } else if (comments.length > 0) {
235.143 + //uncomment
235.144 + uncomment(target, doc, comments, _from, _to, _lineSelection);
235.145 + }
235.146 + } catch (BadLocationException e) {
235.147 + Exceptions.printStackTrace(e);
235.148 + }
235.149 + }
235.150 + });
235.151 +
235.152 +
235.153 + }
235.154 +
235.155 + }
235.156 +
235.157 + private void comment(JTextComponent target, BaseDocument doc, int[] comments, int from, int to, boolean lineSelection) throws BadLocationException {
235.158 +// System.out.println("comment");
235.159 +
235.160 + int diff = 0;
235.161 +
235.162 + //put the comment start
235.163 + diff += insert(doc, from, commentHandler.getCommentStartDelimiter());
235.164 +
235.165 + for (int i = 0; i < comments.length; i += 2) {
235.166 + int commentStart = comments[i];
235.167 + int commentEnd = comments[i + 1];
235.168 +
235.169 + diff += remove(doc, commentStart + diff, COMMENT_START_LENGTH);
235.170 +
235.171 + if (commentEnd <= to) {
235.172 + diff += remove(doc, commentEnd + diff - COMMENT_END_LENGTH, COMMENT_END_LENGTH);
235.173 + }
235.174 +
235.175 + }
235.176 +
235.177 + //add closing comment if the last comment doesn't contain the 'to' offset
235.178 + if (comments.length == 0 || comments[comments.length - 1] <= to) {
235.179 + diff += insert(doc, to + diff, commentHandler.getCommentEndDelimiter());
235.180 + }
235.181 +
235.182 + if (!lineSelection) {
235.183 + //update the selection range, we always add the starting delimiter out of the selection
235.184 + target.setSelectionStart(from);
235.185 + target.setSelectionEnd(to + diff);
235.186 + }
235.187 +
235.188 + }
235.189 +
235.190 + private void uncomment(JTextComponent target, BaseDocument doc, int[] comments, int from, int to, boolean lineSelection) throws BadLocationException {
235.191 +// System.out.println("uncomment");
235.192 +
235.193 + int diff = 0;
235.194 +
235.195 + //no selection handling
235.196 + if (from == to) {
235.197 + //extend the range to the only possible comment
235.198 + assert comments.length == 2;
235.199 +
235.200 + from = comments[0];
235.201 + to = comments[1];
235.202 +
235.203 + lineSelection = true;
235.204 + }
235.205 +
235.206 + if (comments[0] < from) {
235.207 + //we need to end the existing comment
235.208 + diff += insert(doc, from, commentHandler.getCommentEndDelimiter());
235.209 + }
235.210 +
235.211 + int selectionStart = from + diff;
235.212 +
235.213 + for (int i = 0; i < comments.length; i += 2) {
235.214 + int commentStart = comments[i];
235.215 + int commentEnd = comments[i + 1];
235.216 +
235.217 + if (commentStart >= from) {
235.218 + diff += remove(doc, commentStart + diff, COMMENT_START_LENGTH);
235.219 + }
235.220 +
235.221 + if (commentEnd <= to) {
235.222 + diff += remove(doc, commentEnd + diff - COMMENT_END_LENGTH, COMMENT_END_LENGTH);
235.223 + }
235.224 +
235.225 + }
235.226 +
235.227 + int selectionEnd = to + diff;
235.228 + //add opening comment if the last comment doesn't contain the 'to' offset
235.229 + if (comments[comments.length - 1] > to) {
235.230 + diff += insert(doc, to + diff, commentHandler.getCommentStartDelimiter());
235.231 + }
235.232 +
235.233 + if (!lineSelection) {
235.234 + //update the selection range, we always add the starting delimiter out of the selection
235.235 + target.setSelectionStart(selectionStart);
235.236 + target.setSelectionEnd(selectionEnd);
235.237 + }
235.238 +
235.239 + }
235.240 +
235.241 + private int insert(Document doc, int offset, String text) throws BadLocationException {
235.242 + doc.insertString(offset, text, null);
235.243 + return text.length();
235.244 + }
235.245 +
235.246 + private int remove(Document doc, int offset, int length) throws BadLocationException {
235.247 + doc.remove(offset, length);
235.248 + return -length;
235.249 + }
235.250 +
235.251 + private int[] getCommentRange(int[] comments, int offset) {
235.252 + //linear search
235.253 + for (int i = 0; i < comments.length; i++) {
235.254 + int from = comments[i];
235.255 + int to = comments[++i];
235.256 +
235.257 + if (from <= offset && to > offset) { //end offset exclusive
235.258 + return new int[]{from, to};
235.259 + }
235.260 + }
235.261 +
235.262 + return null; //not comment offset
235.263 +
235.264 + }
235.265 +
235.266 + private boolean isInComment(Document doc, int offset) {
235.267 + CharSequence text = DocumentUtilities.getText(doc); //shared instance, low cost
235.268 + int lastCommentStartIndex = CharSequenceUtilities.lastIndexOf(text, commentHandler.getCommentStartDelimiter(), offset);
235.269 + int lastCommentEndIndex = CharSequenceUtilities.lastIndexOf(text, commentHandler.getCommentEndDelimiter(), offset);
235.270 +
235.271 + return lastCommentStartIndex > -1 && (lastCommentStartIndex > lastCommentEndIndex || lastCommentEndIndex == -1);
235.272 +
235.273 + }
235.274 +
235.275 + private void debug(Document doc, int[] comments, int start, int end) {
235.276 + System.out.println("TOGGLE_COMENT [" + start + "-" + end + "]");
235.277 + for (int i = 0; i < comments.length; i++) {
235.278 + try {
235.279 + int from = comments[i];
235.280 + int to = comments[++i];
235.281 + if (from <= start && to > end) {
235.282 + System.out.print("*");
235.283 + }
235.284 + System.out.print("[" + from + " - " + to + "]");
235.285 + System.out.println(doc.getText(from, to - from));
235.286 + } catch (BadLocationException ex) {
235.287 + Exceptions.printStackTrace(ex);
235.288 + }
235.289 + }
235.290 + System.out.println("----------------");
235.291 + }
235.292 +
235.293 + private void check(int[] comments, int from, int to) {
235.294 + if (comments.length % 2 != 0) {
235.295 + throw new IllegalArgumentException("Comments array size must be even, e.g. contain just pairs.");
235.296 + }
235.297 +
235.298 + for (int i = 0; i < comments.length; i++) {
235.299 + int cfrom = comments[i];
235.300 + int cto = comments[++i];
235.301 + if (cfrom < from && cto < from || cto > to && cfrom > to) {
235.302 + throw new IllegalArgumentException("Comment [" + cfrom + " - " + cto + " is out of the range [" + from + " - " + to + "]!");
235.303 + }
235.304 + }
235.305 + }
235.306 +}
235.307 +
236.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
236.2 +++ b/csl.api/src/org/netbeans/modules/csl/api/UiUtils.java Mon Feb 01 12:24:26 2010 +0100
236.3 @@ -0,0 +1,226 @@
236.4 +/*
236.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
236.6 + *
236.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
236.8 + *
236.9 + * The contents of this file are subject to the terms of either the GNU
236.10 + * General Public License Version 2 only ("GPL") or the Common
236.11 + * Development and Distribution License("CDDL") (collectively, the
236.12 + * "License"). You may not use this file except in compliance with the
236.13 + * License. You can obtain a copy of the License at
236.14 + * http://www.netbeans.org/cddl-gplv2.html
236.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
236.16 + * specific language governing permissions and limitations under the
236.17 + * License. When distributing the software, include this License Header
236.18 + * Notice in each file and include the License file at
236.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
236.20 + * particular file as subject to the "Classpath" exception as provided
236.21 + * by Sun in the GPL Version 2 section of the License file that
236.22 + * accompanied this code. If applicable, add the following below the
236.23 + * License Header, with the fields enclosed by brackets [] replaced by
236.24 + * your own identifying information:
236.25 + * "Portions Copyrighted [year] [name of copyright owner]"
236.26 + *
236.27 + * Contributor(s):
236.28 + *
236.29 + * The Original Software is NetBeans. The Initial Developer of the Original
236.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
236.31 + * Microsystems, Inc. All Rights Reserved.
236.32 + *
236.33 + * If you wish your version of this file to be governed by only the CDDL
236.34 + * or only the GPL Version 2, indicate your decision by adding
236.35 + * "[Contributor] elects to include this software in this distribution
236.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
236.37 + * single choice of license, a recipient has the option to distribute
236.38 + * your version of this file under either the CDDL, the GPL Version 2 or
236.39 + * to extend the choice of license to its licensees as provided above.
236.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
236.41 + * Version 2 license, then the option applies only if the new code is
236.42 + * made subject to such option by the copyright holder.
236.43 + */
236.44 +package org.netbeans.modules.csl.api;
236.45 +
236.46 +import java.io.IOException;
236.47 +import java.util.Collection;
236.48 +import java.util.Collections;
236.49 +import java.util.List;
236.50 +import java.util.concurrent.Future;
236.51 +import java.util.logging.Level;
236.52 +import java.util.logging.Logger;
236.53 +import javax.swing.ImageIcon;
236.54 +import javax.swing.SwingUtilities;
236.55 +import javax.swing.text.Document;
236.56 +import javax.swing.text.StyledDocument;
236.57 +import org.netbeans.editor.BaseDocument;
236.58 +import org.netbeans.modules.csl.api.DeclarationFinder.DeclarationLocation;
236.59 +import org.netbeans.modules.csl.core.Language;
236.60 +import org.netbeans.modules.csl.core.LanguageRegistry;
236.61 +import org.netbeans.modules.csl.navigation.Icons;
236.62 +import org.netbeans.modules.csl.spi.ParserResult;
236.63 +import org.netbeans.modules.parsing.api.Embedding;
236.64 +import org.netbeans.modules.parsing.api.ParserManager;
236.65 +import org.netbeans.modules.parsing.api.ResultIterator;
236.66 +import org.netbeans.modules.parsing.api.Source;
236.67 +import org.netbeans.modules.parsing.api.UserTask;
236.68 +import org.netbeans.modules.parsing.spi.ParseException;
236.69 +import org.netbeans.modules.parsing.spi.Parser;
236.70 +import org.openide.cookies.EditorCookie;
236.71 +import org.openide.cookies.LineCookie;
236.72 +import org.openide.cookies.OpenCookie;
236.73 +import org.openide.filesystems.FileObject;
236.74 +import org.openide.text.Line;
236.75 +import org.openide.text.NbDocument;
236.76 +
236.77 +
236.78 +/**
236.79 + * This file is originally from Retouche, the Java Support
236.80 + * infrastructure in NetBeans. I have modified the file as little
236.81 + * as possible to make merging Retouche fixes back as simple as
236.82 + * possible.
236.83 + *
236.84 + * This class contains various methods bound to visualization of Java model
236.85 + * elements. It was formerly included under SourceUtils
236.86 + *
236.87 + * XXX - needs cleanup
236.88 + *
236.89 + * @author Jan Lahoda
236.90 + * @author Tor Norbye
236.91 + */
236.92 +public final class UiUtils {
236.93 +
236.94 + public static boolean open(Source source, ElementHandle handle) {
236.95 + assert source != null;
236.96 + assert handle != null; // Only one should be set
236.97 +
236.98 + DeclarationLocation location = getElementLocation(source, handle);
236.99 +
236.100 + if (location != DeclarationLocation.NONE) {
236.101 + return doOpen(location.getFileObject(), location.getOffset());
236.102 + }
236.103 +
236.104 + return false;
236.105 + }
236.106 +
236.107 + public static boolean open(final FileObject fo, final int offset) {
236.108 + assert fo != null;
236.109 +
236.110 + if (!SwingUtilities.isEventDispatchThread()) {
236.111 + SwingUtilities.invokeLater(new Runnable() {
236.112 + public @Override void run() {
236.113 + doOpen(fo, offset);
236.114 + }
236.115 + });
236.116 + return true; // not exactly accurate, but....
236.117 + }
236.118 +
236.119 + return doOpen(fo, offset);
236.120 + }
236.121 +
236.122 + public static ImageIcon getElementIcon( ElementKind elementKind, Collection<Modifier> modifiers ) {
236.123 + return Icons.getElementIcon(elementKind, modifiers);
236.124 + }
236.125 +
236.126 + public static KeystrokeHandler getBracketCompletion(Document doc, int offset) {
236.127 + BaseDocument baseDoc = (BaseDocument)doc;
236.128 + List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset);
236.129 + for (Language l : list) {
236.130 + if (l.getBracketCompletion() != null) {
236.131 + return l.getBracketCompletion();
236.132 + }
236.133 + }
236.134 +
236.135 + return null;
236.136 + }
236.137 +
236.138 + // Private methods ---------------------------------------------------------
236.139 +
236.140 + private static final Logger LOG = Logger.getLogger(UiUtils.class.getName());
236.141 +
236.142 + private UiUtils() {
236.143 + }
236.144 +
236.145 + private static boolean doOpen(FileObject fo, int offset) {
236.146 + try {
236.147 + EditorCookie ec = DataLoadersBridge.getDefault().getCookie(fo, EditorCookie.class);
236.148 + LineCookie lc = DataLoadersBridge.getDefault().getCookie(fo, LineCookie.class);
236.149 +
236.150 + if ((ec != null) && (lc != null) && (offset != -1)) {
236.151 + StyledDocument doc = ec.openDocument();
236.152 +
236.153 + if (doc != null) {
236.154 + int line = NbDocument.findLineNumber(doc, offset);
236.155 + int lineOffset = NbDocument.findLineOffset(doc, line);
236.156 + int column = offset - lineOffset;
236.157 +
236.158 + if (line != -1) {
236.159 + Line l = lc.getLineSet().getCurrent(line);
236.160 +
236.161 + if (l != null) {
236.162 + l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column);
236.163 + return true;
236.164 + }
236.165 + }
236.166 + }
236.167 + }
236.168 +
236.169 + OpenCookie oc = DataLoadersBridge.getDefault().getCookie(fo, OpenCookie.class);
236.170 +
236.171 + if (oc != null) {
236.172 + oc.open();
236.173 + return true;
236.174 + }
236.175 + } catch (IOException ioe) {
236.176 + LOG.log(Level.WARNING, null, ioe);
236.177 + }
236.178 +
236.179 + return false;
236.180 + }
236.181 +
236.182 + private static DeclarationLocation getElementLocation(Source source, final ElementHandle handle) {
236.183 + if (source.getFileObject() == null) {
236.184 + return DeclarationLocation.NONE;
236.185 + }
236.186 +
236.187 + FileObject fileObject = handle.getFileObject();
236.188 + if (fileObject != null && fileObject != source.getFileObject()) {
236.189 + // The element is not in the parse tree for this parse job; it is
236.190 + // probably something like an indexed element
236.191 + return new DeclarationLocation(fileObject, -1);
236.192 + }
236.193 +
236.194 + final DeclarationLocation[] result = new DeclarationLocation[] { null };
236.195 + try {
236.196 + Future<Void> f = ParserManager.parseWhenScanFinished(Collections.singleton(source), new UserTask() {
236.197 + public @Override void run(ResultIterator resultIterator) throws ParseException {
236.198 + if (resultIterator.getSnapshot().getMimeType().equals(handle.getMimeType())) {
236.199 + Parser.Result r = resultIterator.getParserResult();
236.200 + if (r instanceof ParserResult) {
236.201 + ParserResult info = (ParserResult) r;
236.202 + OffsetRange range = handle.getOffsetRange(info);
236.203 + if (range != OffsetRange.NONE && range != null) {
236.204 + result[0] = new DeclarationLocation(info.getSnapshot().getSource().getFileObject(), range.getStart());
236.205 + return;
236.206 + }
236.207 + }
236.208 + }
236.209 +
236.210 + for(Embedding e : resultIterator.getEmbeddings()) {
236.211 + run(resultIterator.getResultIterator(e));
236.212 + if (result[0] != null) {
236.213 + break;
236.214 + }
236.215 + }
236.216 + }
236.217 + });
236.218 + //#169806: Do not block when parsing is in progress
236.219 + if (!f.isDone()) {
236.220 + f.cancel(true);
236.221 + return new DeclarationLocation(source.getFileObject(), -1);
236.222 + }
236.223 + } catch (ParseException e) {
236.224 + LOG.log(Level.WARNING, null, e);
236.225 + }
236.226 +
236.227 + return result[0] == null ? DeclarationLocation.NONE : result[0];
236.228 + }
236.229 +}
237.1 --- a/csl.api/src/org/netbeans/modules/csl/core/AbstractCamelCasePosition.java Mon Feb 01 12:23:06 2010 +0100
237.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
237.3 @@ -1,131 +0,0 @@
237.4 -/*
237.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
237.6 - *
237.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
237.8 - *
237.9 - * The contents of this file are subject to the terms of either the GNU
237.10 - * General Public License Version 2 only ("GPL") or the Common
237.11 - * Development and Distribution License("CDDL") (collectively, the
237.12 - * "License"). You may not use this file except in compliance with the
237.13 - * License. You can obtain a copy of the License at
237.14 - * http://www.netbeans.org/cddl-gplv2.html
237.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
237.16 - * specific language governing permissions and limitations under the
237.17 - * License. When distributing the software, include this License Header
237.18 - * Notice in each file and include the License file at
237.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
237.20 - * particular file as subject to the "Classpath" exception as provided
237.21 - * by Sun in the GPL Version 2 section of the License file that
237.22 - * accompanied this code. If applicable, add the following below the
237.23 - * License Header, with the fields enclosed by brackets [] replaced by
237.24 - * your own identifying information:
237.25 - * "Portions Copyrighted [year] [name of copyright owner]"
237.26 - *
237.27 - * Contributor(s):
237.28 - *
237.29 - * The Original Software is NetBeans. The Initial Developer of the Original
237.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
237.31 - * Microsystems, Inc. All Rights Reserved.
237.32 - *
237.33 - * If you wish your version of this file to be governed by only the CDDL
237.34 - * or only the GPL Version 2, indicate your decision by adding
237.35 - * "[Contributor] elects to include this software in this distribution
237.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
237.37 - * single choice of license, a recipient has the option to distribute
237.38 - * your version of this file under either the CDDL, the GPL Version 2 or
237.39 - * to extend the choice of license to its licensees as provided above.
237.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
237.41 - * Version 2 license, then the option applies only if the new code is
237.42 - * made subject to such option by the copyright holder.
237.43 - */
237.44 -package org.netbeans.modules.csl.core;
237.45 -
237.46 -import java.awt.event.ActionEvent;
237.47 -import java.util.MissingResourceException;
237.48 -import javax.swing.Action;
237.49 -import javax.swing.text.BadLocationException;
237.50 -import javax.swing.text.JTextComponent;
237.51 -import org.netbeans.editor.BaseAction;
237.52 -import org.netbeans.editor.BaseDocument;
237.53 -import org.netbeans.lib.editor.util.swing.DocumentUtilities;
237.54 -import org.openide.util.NbBundle;
237.55 -
237.56 -/**
237.57 - *
237.58 - * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
237.59 - */
237.60 -public abstract class AbstractCamelCasePosition extends BaseAction {
237.61 -
237.62 - private Action originalAction;
237.63 -
237.64 - public AbstractCamelCasePosition(String name, Action originalAction) {
237.65 - super(name, MAGIC_POSITION_RESET);
237.66 -
237.67 - if (originalAction != null) {
237.68 - Object nameObj = originalAction.getValue(Action.NAME);
237.69 - if (nameObj instanceof String) {
237.70 - // We will be wrapping around the original action, use its name
237.71 - putValue(NAME, nameObj);
237.72 - this.originalAction = originalAction;
237.73 - }
237.74 - }
237.75 -
237.76 - String desc = getShortDescription();
237.77 - if (desc != null) {
237.78 - putValue(SHORT_DESCRIPTION, desc);
237.79 - }
237.80 - }
237.81 -
237.82 - public final void actionPerformed(ActionEvent evt, final JTextComponent target) {
237.83 - if (target != null) {
237.84 - if (originalAction != null && !isUsingCamelCase()) {
237.85 - if (originalAction instanceof BaseAction) {
237.86 - ((BaseAction) originalAction).actionPerformed(evt, target);
237.87 - } else {
237.88 - originalAction.actionPerformed(evt);
237.89 - }
237.90 - } else {
237.91 - final BaseDocument bdoc = org.netbeans.editor.Utilities.getDocument(target);
237.92 - if (bdoc != null) {
237.93 - bdoc.runAtomic(new Runnable() {
237.94 - public void run() {
237.95 - DocumentUtilities.setTypingModification(bdoc, true);
237.96 - try {
237.97 - int offset = newOffset(target);
237.98 - if (offset != -1) {
237.99 - moveToNewOffset(target, offset);
237.100 - }
237.101 - } catch (BadLocationException ble) {
237.102 - target.getToolkit().beep();
237.103 - } finally {
237.104 - DocumentUtilities.setTypingModification(bdoc, false);
237.105 - }
237.106 - }
237.107 - });
237.108 - } else {
237.109 - target.getToolkit().beep();
237.110 - }
237.111 - }
237.112 - }
237.113 - }
237.114 -
237.115 - protected abstract int newOffset(JTextComponent textComponent) throws BadLocationException;
237.116 - protected abstract void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException;
237.117 -
237.118 - public String getShortDescription(){
237.119 - String name = (String)getValue(Action.NAME);
237.120 - if (name == null) return null;
237.121 - String shortDesc;
237.122 - try {
237.123 - shortDesc = NbBundle.getBundle(GsfEditorKitFactory.class).getString(name); // NOI18N
237.124 - }catch (MissingResourceException mre){
237.125 - shortDesc = name;
237.126 - }
237.127 - return shortDesc;
237.128 - }
237.129 -
237.130 - private boolean isUsingCamelCase() {
237.131 - return !Boolean.getBoolean("no-ruby-camel-case-style-navigation");
237.132 - }
237.133 -}
237.134 -
238.1 --- a/csl.api/src/org/netbeans/modules/csl/core/CamelCaseOperations.java Mon Feb 01 12:23:06 2010 +0100
238.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
238.3 @@ -1,144 +0,0 @@
238.4 -/*
238.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
238.6 - *
238.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
238.8 - *
238.9 - * The contents of this file are subject to the terms of either the GNU
238.10 - * General Public License Version 2 only ("GPL") or the Common
238.11 - * Development and Distribution License("CDDL") (collectively, the
238.12 - * "License"). You may not use this file except in compliance with the
238.13 - * License. You can obtain a copy of the License at
238.14 - * http://www.netbeans.org/cddl-gplv2.html
238.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
238.16 - * specific language governing permissions and limitations under the
238.17 - * License. When distributing the software, include this License Header
238.18 - * Notice in each file and include the License file at
238.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
238.20 - * particular file as subject to the "Classpath" exception as provided
238.21 - * by Sun in the GPL Version 2 section of the License file that
238.22 - * accompanied this code. If applicable, add the following below the
238.23 - * License Header, with the fields enclosed by brackets [] replaced by
238.24 - * your own identifying information:
238.25 - * "Portions Copyrighted [year] [name of copyright owner]"
238.26 - *
238.27 - * Contributor(s):
238.28 - *
238.29 - * The Original Software is NetBeans. The Initial Developer of the Original
238.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
238.31 - * Microsystems, Inc. All Rights Reserved.
238.32 - *
238.33 - * If you wish your version of this file to be governed by only the CDDL
238.34 - * or only the GPL Version 2, indicate your decision by adding
238.35 - * "[Contributor] elects to include this software in this distribution
238.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
238.37 - * single choice of license, a recipient has the option to distribute
238.38 - * your version of this file under either the CDDL, the GPL Version 2 or
238.39 - * to extend the choice of license to its licensees as provided above.
238.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
238.41 - * Version 2 license, then the option applies only if the new code is
238.42 - * made subject to such option by the copyright holder.
238.43 - */
238.44 -
238.45 -package org.netbeans.modules.csl.core;
238.46 -
238.47 -import javax.swing.text.BadLocationException;
238.48 -import javax.swing.text.Document;
238.49 -import javax.swing.text.JTextComponent;
238.50 -import org.netbeans.modules.csl.api.KeystrokeHandler;
238.51 -import org.netbeans.editor.BaseDocument;
238.52 -import org.netbeans.editor.Utilities;
238.53 -import org.openide.ErrorManager;
238.54 -
238.55 -/**
238.56 - * CamelCase operations - based on Java ones but rewritten to delegate all logic
238.57 - * to language plugins
238.58 - *
238.59 - * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
238.60 - * @author Tor Norbye
238.61 - */
238.62 -/* package */ class CamelCaseOperations {
238.63 -
238.64 - static int nextCamelCasePosition(JTextComponent textComponent) {
238.65 - int offset = textComponent.getCaretPosition();
238.66 - Document doc = textComponent.getDocument();
238.67 -
238.68 - // Are we at the end of the document?
238.69 - if (offset == doc.getLength()) {
238.70 - return -1;
238.71 - }
238.72 -
238.73 - KeystrokeHandler bc = GsfEditorKitFactory.getBracketCompletion(doc, offset);
238.74 - if (bc != null) {
238.75 - int nextOffset = bc.getNextWordOffset(doc, offset, false);
238.76 - if (nextOffset != -1) {
238.77 - return nextOffset;
238.78 - }
238.79 - }
238.80 -
238.81 - try {
238.82 - return Utilities.getNextWord(textComponent, offset);
238.83 - } catch (BadLocationException ble) {
238.84 - // something went wrong :(
238.85 - ErrorManager.getDefault().notify(ble);
238.86 - }
238.87 - return -1;
238.88 - }
238.89 -
238.90 - static int previousCamelCasePosition(JTextComponent textComponent) {
238.91 - int offset = textComponent.getCaretPosition();
238.92 -
238.93 - // Are we at the beginning of the document?
238.94 - if (offset == 0) {
238.95 - return -1;
238.96 - }
238.97 -
238.98 - final Document doc = textComponent.getDocument();
238.99 -
238.100 - KeystrokeHandler bc = GsfEditorKitFactory.getBracketCompletion(doc, offset);
238.101 - if (bc != null) {
238.102 - int nextOffset = bc.getNextWordOffset(
238.103 - doc, offset, true);
238.104 - if (nextOffset != -1) {
238.105 - return nextOffset;
238.106 - }
238.107 - }
238.108 -
238.109 - try {
238.110 - return Utilities.getPreviousWord(textComponent, offset);
238.111 - } catch (BadLocationException ble) {
238.112 - ErrorManager.getDefault().notify(ble);
238.113 - }
238.114 - return -1;
238.115 - }
238.116 -
238.117 - static void replaceChar(JTextComponent textComponent, int offset, char c) {
238.118 - if (!textComponent.isEditable()) {
238.119 - return;
238.120 - }
238.121 - replaceText(textComponent, offset, 1, String.valueOf(c));
238.122 - }
238.123 -
238.124 - static void replaceText(JTextComponent textComponent, final int offset, final int length, final String text) {
238.125 - if (!textComponent.isEditable()) {
238.126 - return;
238.127 - }
238.128 - final Document document = textComponent.getDocument();
238.129 - Runnable r = new Runnable() {
238.130 - public void run() {
238.131 - try {
238.132 - if (length > 0) {
238.133 - document.remove(offset, length);
238.134 - }
238.135 - document.insertString(offset, text, null);
238.136 - } catch (BadLocationException ble) {
238.137 - ErrorManager.getDefault().notify(ble);
238.138 - }
238.139 - }
238.140 - };
238.141 - if (document instanceof BaseDocument) {
238.142 - ((BaseDocument)document).runAtomic(r);
238.143 - } else {
238.144 - r.run();
238.145 - }
238.146 - }
238.147 -}
239.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
239.2 +++ b/csl.api/src/org/netbeans/modules/csl/core/CslEditorKit.java Mon Feb 01 12:24:26 2010 +0100
239.3 @@ -0,0 +1,514 @@
239.4 +/*
239.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
239.6 + *
239.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
239.8 + *
239.9 + * The contents of this file are subject to the terms of either the GNU
239.10 + * General Public License Version 2 only ("GPL") or the Common
239.11 + * Development and Distribution License("CDDL") (collectively, the
239.12 + * "License"). You may not use this file except in compliance with the
239.13 + * License. You can obtain a copy of the License at
239.14 + * http://www.netbeans.org/cddl-gplv2.html
239.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
239.16 + * specific language governing permissions and limitations under the
239.17 + * License. When distributing the software, include this License Header
239.18 + * Notice in each file and include the License file at
239.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
239.20 + * particular file as subject to the "Classpath" exception as provided
239.21 + * by Sun in the GPL Version 2 section of the License file that
239.22 + * accompanied this code. If applicable, add the following below the
239.23 + * License Header, with the fields enclosed by brackets [] replaced by
239.24 + * your own identifying information:
239.25 + * "Portions Copyrighted [year] [name of copyright owner]"
239.26 + *
239.27 + * If you wish your version of this file to be governed by only the CDDL
239.28 + * or only the GPL Version 2, indicate your decision by adding
239.29 + * "[Contributor] elects to include this software in this distribution
239.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
239.31 + * single choice of license, a recipient has the option to distribute
239.32 + * your version of this file under either the CDDL, the GPL Version 2 or
239.33 + * to extend the choice of license to its licensees as provided above.
239.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
239.35 + * Version 2 license, then the option applies only if the new code is
239.36 + * made subject to such option by the copyright holder.
239.37 + *
239.38 + * Contributor(s):
239.39 + *
239.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
239.41 + */
239.42 +
239.43 +package org.netbeans.modules.csl.core;
239.44 +
239.45 +import java.awt.event.ActionEvent;
239.46 +import java.util.ArrayList;
239.47 +import javax.swing.Action;
239.48 +import javax.swing.JMenu;
239.49 +import javax.swing.JMenuItem;
239.50 +import javax.swing.KeyStroke;
239.51 +import javax.swing.text.BadLocationException;
239.52 +import javax.swing.text.Caret;
239.53 +import javax.swing.text.Document;
239.54 +import javax.swing.text.EditorKit;
239.55 +import javax.swing.text.JTextComponent;
239.56 +import javax.swing.text.Keymap;
239.57 +import javax.swing.text.TextAction;
239.58 +import org.netbeans.api.editor.mimelookup.MimePath;
239.59 +import org.netbeans.editor.BaseAction;
239.60 +import org.netbeans.editor.BaseDocument;
239.61 +import org.netbeans.editor.BaseKit;
239.62 +import org.netbeans.editor.SyntaxSupport;
239.63 +import org.netbeans.editor.Utilities;
239.64 +import org.netbeans.editor.ext.ExtKit;
239.65 +import org.netbeans.editor.ext.ExtSyntaxSupport;
239.66 +import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
239.67 +import org.netbeans.modules.csl.api.DeleteToNextCamelCasePosition;
239.68 +import org.netbeans.modules.csl.api.DeleteToPreviousCamelCasePosition;
239.69 +import org.netbeans.modules.csl.api.GsfLanguage;
239.70 +import org.netbeans.modules.csl.api.InstantRenameAction;
239.71 +import org.netbeans.modules.csl.api.KeystrokeHandler;
239.72 +import org.netbeans.modules.csl.api.NextCamelCasePosition;
239.73 +import org.netbeans.modules.csl.api.OffsetRange;
239.74 +import org.netbeans.modules.csl.api.PreviousCamelCasePosition;
239.75 +import org.netbeans.modules.csl.api.SelectCodeElementAction;
239.76 +import org.netbeans.modules.csl.api.SelectNextCamelCasePosition;
239.77 +import org.netbeans.modules.csl.api.SelectPreviousCamelCasePosition;
239.78 +import org.netbeans.modules.csl.api.ToggleBlockCommentAction;
239.79 +import org.netbeans.modules.csl.api.UiUtils;
239.80 +import org.netbeans.modules.csl.editor.hyperlink.GoToSupport;
239.81 +import org.netbeans.modules.csl.editor.semantic.GoToMarkOccurrencesAction;
239.82 +import org.netbeans.modules.csl.spi.CommentHandler;
239.83 +import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
239.84 +import org.netbeans.modules.editor.NbEditorKit;
239.85 +import org.openide.awt.Mnemonics;
239.86 +import org.openide.filesystems.FileObject;
239.87 +import org.openide.util.Exceptions;
239.88 +import org.openide.util.NbBundle;
239.89 +
239.90 +/**
239.91 + *
239.92 + * @author vita
239.93 + */
239.94 +public final class CslEditorKit extends NbEditorKit {
239.95 +
239.96 + public static EditorKit createEditorKitInstance(FileObject f) {
239.97 + String mimeType = detectMimeType(f);
239.98 + return mimeType != null ? new CslEditorKit(mimeType) : null;
239.99 + }
239.100 +
239.101 + public static org.netbeans.api.lexer.Language createLexerLanguageInstance(FileObject f) {
239.102 + String mimeType = detectMimeType(f);
239.103 + if (mimeType != null) {
239.104 + Language l = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
239.105 + if (l != null) {
239.106 + return l.getGsfLanguage().getLexerLanguage();
239.107 + }
239.108 + }
239.109 + return null;
239.110 + }
239.111 +
239.112 + // this is public only because of tests
239.113 + public CslEditorKit(String mimeType) {
239.114 + this.mimeType = mimeType;
239.115 + }
239.116 +
239.117 + // -----------------------------------------------------------------------
239.118 + // NbEditorKit implementation
239.119 + // -----------------------------------------------------------------------
239.120 +
239.121 + @Override
239.122 + public String getContentType() {
239.123 + return mimeType;
239.124 + }
239.125 +
239.126 + @Override
239.127 + public Document createDefaultDocument() {
239.128 + return new GsfDocument(mimeType);
239.129 + }
239.130 +
239.131 + @Override
239.132 + public SyntaxSupport createSyntaxSupport(final BaseDocument doc) {
239.133 + return new ExtSyntaxSupport(doc) {
239.134 + @Override
239.135 + public int[] findMatchingBlock(int offset, boolean simpleSearch)
239.136 + throws BadLocationException {
239.137 + // Do parenthesis matching, if applicable
239.138 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, offset);
239.139 + if (bracketCompletion != null) {
239.140 + OffsetRange range = bracketCompletion.findMatching(getDocument(), offset/*, simpleSearch*/);
239.141 + if (range == OffsetRange.NONE) {
239.142 + return null;
239.143 + } else {
239.144 + return new int[] { range.getStart(), range.getEnd() };
239.145 + }
239.146 + }
239.147 +
239.148 + return null;
239.149 + }
239.150 + };
239.151 + }
239.152 +
239.153 + @Override
239.154 + protected void initDocument(BaseDocument doc) {
239.155 + // XXX This appears in JavaKit, not sure why, but doing it just in case.
239.156 + //do not ask why, fire bug in the IZ:
239.157 + CodeTemplateManager.get(doc);
239.158 + }
239.159 +
239.160 + @Override
239.161 + protected Action[] createActions() {
239.162 + Action[] superActions = super.createActions();
239.163 + Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
239.164 + GsfLanguage gsfLanguage = language.getGsfLanguage();
239.165 +
239.166 + ArrayList<Action> actions = new ArrayList<Action>(30);
239.167 +
239.168 + actions.add(new GsfDefaultKeyTypedAction());
239.169 + actions.add(new GsfInsertBreakAction());
239.170 + actions.add(new GsfDeleteCharAction(deletePrevCharAction, false));
239.171 +
239.172 + String lineCommentPrefix = (gsfLanguage != null) ? gsfLanguage.getLineCommentPrefix() : null;
239.173 + if (lineCommentPrefix != null) {
239.174 + actions.add(new CommentAction(lineCommentPrefix));
239.175 + actions.add(new UncommentAction(lineCommentPrefix));
239.176 + actions.add(new ToggleCommentAction(lineCommentPrefix));
239.177 + }
239.178 +
239.179 + if(gsfLanguage instanceof DefaultLanguageConfig) {
239.180 + CommentHandler ch = ((DefaultLanguageConfig)gsfLanguage).getCommentHandler();
239.181 + if(ch != null) {
239.182 + actions.add(new ToggleBlockCommentAction(ch));
239.183 + }
239.184 +
239.185 + }
239.186 +
239.187 + actions.add(new InstantRenameAction());
239.188 + actions.add(new GenericGoToDeclarationAction());
239.189 + actions.add(new GenericGenerateGoToPopupAction());
239.190 + actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
239.191 + actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));
239.192 + //actions.add(new ExpandAllCodeBlockFolds());
239.193 + //actions.add(new CollapseAllCodeBlockFolds());
239.194 + actions.add(new NextCamelCasePosition(findAction(superActions, nextWordAction)));
239.195 + actions.add(new PreviousCamelCasePosition(findAction(superActions, previousWordAction)));
239.196 + actions.add(new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)));
239.197 + actions.add(new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)));
239.198 + actions.add(new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)));
239.199 + actions.add(new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)));
239.200 +
239.201 + if (language.hasOccurrencesFinder()) {
239.202 + actions.add(new GoToMarkOccurrencesAction(false));
239.203 + actions.add(new GoToMarkOccurrencesAction(true));
239.204 + }
239.205 +
239.206 + return TextAction.augmentList(superActions,
239.207 + actions.toArray(new Action[actions.size()]));
239.208 + }
239.209 +
239.210 + // -----------------------------------------------------------------------
239.211 + // Private implementation
239.212 + // -----------------------------------------------------------------------
239.213 +
239.214 + private final String mimeType;
239.215 +
239.216 + private static String detectMimeType(FileObject f) {
239.217 + String mimeType = f.getParent().getPath().substring("Editors/".length()); //NOI18N
239.218 + return MimePath.validate(mimeType) && mimeType.length() > 0 ? mimeType : null;
239.219 + }
239.220 +
239.221 + private static Action findAction(Action [] actions, String name) {
239.222 + for(Action a : actions) {
239.223 + Object nameObj = a.getValue(Action.NAME);
239.224 + if (nameObj instanceof String && name.equals(nameObj)) {
239.225 + return a;
239.226 + }
239.227 + }
239.228 + return null;
239.229 + }
239.230 +
239.231 + /**
239.232 + * Returns true if bracket completion is enabled in options.
239.233 + */
239.234 + private static boolean completionSettingEnabled() {
239.235 + //return ((Boolean)Settings.getValue(GsfEditorKit.class, JavaSettingsNames.PAIR_CHARACTERS_COMPLETION)).booleanValue();
239.236 + return true;
239.237 + }
239.238 +
239.239 + private final class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
239.240 + private JTextComponent currentTarget;
239.241 +
239.242 + @Override
239.243 + public void actionPerformed(ActionEvent evt, JTextComponent target) {
239.244 + currentTarget = target;
239.245 + super.actionPerformed(evt, target);
239.246 + currentTarget = null;
239.247 + }
239.248 +
239.249 + @Override
239.250 + protected void insertString(BaseDocument doc, int dotPos, Caret caret, String str,
239.251 + boolean overwrite) throws BadLocationException {
239.252 + if (completionSettingEnabled()) {
239.253 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
239.254 +
239.255 + if (bracketCompletion != null) {
239.256 + // TODO - check if we're in a comment etc. and if so, do nothing
239.257 + boolean handled =
239.258 + bracketCompletion.beforeCharInserted(doc, dotPos, currentTarget,
239.259 + str.charAt(0));
239.260 +
239.261 + if (!handled) {
239.262 + super.insertString(doc, dotPos, caret, str, overwrite);
239.263 + handled = bracketCompletion.afterCharInserted(doc, dotPos, currentTarget,
239.264 + str.charAt(0));
239.265 + }
239.266 +
239.267 + return;
239.268 + }
239.269 + }
239.270 +
239.271 + super.insertString(doc, dotPos, caret, str, overwrite);
239.272 + }
239.273 +
239.274 + @Override
239.275 + protected void replaceSelection(JTextComponent target, int dotPos, Caret caret,
239.276 + String str, boolean overwrite) throws BadLocationException {
239.277 + char insertedChar = str.charAt(0);
239.278 + Document document = target.getDocument();
239.279 +
239.280 + if (document instanceof BaseDocument) {
239.281 + BaseDocument doc = (BaseDocument)document;
239.282 +
239.283 + if (completionSettingEnabled()) {
239.284 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
239.285 +
239.286 + if (bracketCompletion != null) {
239.287 + try {
239.288 + int caretPosition = caret.getDot();
239.289 +
239.290 + boolean handled =
239.291 + bracketCompletion.beforeCharInserted(doc, caretPosition,
239.292 + target, insertedChar);
239.293 +
239.294 + int p0 = Math.min(caret.getDot(), caret.getMark());
239.295 + int p1 = Math.max(caret.getDot(), caret.getMark());
239.296 +
239.297 + if (p0 != p1) {
239.298 + doc.remove(p0, p1 - p0);
239.299 + }
239.300 +
239.301 + if (!handled) {
239.302 + if ((str != null) && (str.length() > 0)) {
239.303 + doc.insertString(p0, str, null);
239.304 + }
239.305 +
239.306 + bracketCompletion.afterCharInserted(doc, caret.getDot() - 1,
239.307 + target, insertedChar);
239.308 + }
239.309 + } catch (BadLocationException e) {
239.310 + e.printStackTrace();
239.311 + }
239.312 +
239.313 + return;
239.314 + }
239.315 + }
239.316 + }
239.317 +
239.318 + super.replaceSelection(target, dotPos, caret, str, overwrite);
239.319 + }
239.320 + }
239.321 +
239.322 + private final class GsfInsertBreakAction extends InsertBreakAction {
239.323 + static final long serialVersionUID = -1506173310438326380L;
239.324 +
239.325 + @Override
239.326 + protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) {
239.327 + if (completionSettingEnabled()) {
239.328 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, caret.getDot());
239.329 +
239.330 + if (bracketCompletion != null) {
239.331 + try {
239.332 + int newOffset = bracketCompletion.beforeBreak(doc, caret.getDot(), target);
239.333 +
239.334 + if (newOffset >= 0) {
239.335 + return new Integer(newOffset);
239.336 + }
239.337 + } catch (BadLocationException ble) {
239.338 + Exceptions.printStackTrace(ble);
239.339 + }
239.340 + }
239.341 + }
239.342 +
239.343 + // return Boolean.TRUE;
239.344 + return null;
239.345 + }
239.346 +
239.347 + @Override
239.348 + protected void afterBreak(JTextComponent target, BaseDocument doc, Caret caret,
239.349 + Object cookie) {
239.350 + if (completionSettingEnabled()) {
239.351 + if (cookie != null) {
239.352 + if (cookie instanceof Integer) {
239.353 + // integer
239.354 + int dotPos = ((Integer)cookie).intValue();
239.355 + if (dotPos != -1) {
239.356 + caret.setDot(dotPos);
239.357 + } else {
239.358 + int nowDotPos = caret.getDot();
239.359 + caret.setDot(nowDotPos + 1);
239.360 + }
239.361 + }
239.362 + }
239.363 + }
239.364 + }
239.365 + }
239.366 +
239.367 + private final class GsfDeleteCharAction extends ExtDeleteCharAction {
239.368 + private JTextComponent currentTarget;
239.369 +
239.370 + public GsfDeleteCharAction(String nm, boolean nextChar) {
239.371 + super(nm, nextChar);
239.372 + }
239.373 +
239.374 + @Override
239.375 + public void actionPerformed(ActionEvent evt, JTextComponent target) {
239.376 + currentTarget = target;
239.377 + super.actionPerformed(evt, target);
239.378 + currentTarget = null;
239.379 + }
239.380 +
239.381 + @Override
239.382 + protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch)
239.383 + throws BadLocationException {
239.384 + if (completionSettingEnabled()) {
239.385 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
239.386 +
239.387 + if (bracketCompletion != null) {
239.388 + boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch);
239.389 + return;
239.390 + }
239.391 + }
239.392 + super.charBackspaced(doc, dotPos, caret, ch);
239.393 + }
239.394 + }
239.395 +
239.396 + private final class GenericGoToDeclarationAction extends GotoDeclarationAction {
239.397 + @Override
239.398 + public boolean gotoDeclaration(JTextComponent target) {
239.399 + GoToSupport.performGoTo((BaseDocument)target.getDocument(),
239.400 + target.getCaretPosition());
239.401 +
239.402 + return true;
239.403 + }
239.404 + }
239.405 +
239.406 + private final class GenericGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
239.407 + @Override
239.408 + public void actionPerformed(ActionEvent evt, JTextComponent target) {
239.409 + }
239.410 +
239.411 + private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
239.412 + // Try to get the accelerator
239.413 + Keymap km = target.getKeymap();
239.414 +
239.415 + if (km != null) {
239.416 + KeyStroke[] keys = km.getKeyStrokesForAction(a);
239.417 +
239.418 + if ((keys != null) && (keys.length > 0)) {
239.419 + item.setAccelerator(keys[0]);
239.420 + } else if (a != null) {
239.421 + KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
239.422 +
239.423 + if (ks != null) {
239.424 + item.setAccelerator(ks);
239.425 + }
239.426 + }
239.427 + }
239.428 + }
239.429 +
239.430 + private void addAction(JTextComponent target, JMenu menu, Action a) {
239.431 + if (a != null) {
239.432 + String actionName = (String)a.getValue(Action.NAME);
239.433 + JMenuItem item = null;
239.434 +
239.435 + if (a instanceof BaseAction) {
239.436 + item = ((BaseAction)a).getPopupMenuItem(target);
239.437 + }
239.438 +
239.439 + if (item == null) {
239.440 + // gets trimmed text that doesn' contain "go to"
239.441 + String itemText = (String)a.getValue(ExtKit.TRIMMED_TEXT);
239.442 +
239.443 + if (itemText == null) {
239.444 + itemText = getItemText(target, actionName, a);
239.445 + }
239.446 +
239.447 + if (itemText != null) {
239.448 + item = new JMenuItem(itemText);
239.449 + Mnemonics.setLocalizedText(item, itemText);
239.450 + item.addActionListener(a);
239.451 + addAcceleretors(a, item, target);
239.452 + item.setEnabled(a.isEnabled());
239.453 +
239.454 + Object helpID = a.getValue("helpID"); // NOI18N
239.455 +
239.456 + if ((helpID != null) && (helpID instanceof String)) {
239.457 + item.putClientProperty("HelpID", helpID); // NOI18N
239.458 + }
239.459 + } else {
239.460 + if (ExtKit.gotoSourceAction.equals(actionName)) {
239.461 + item = new JMenuItem(NbBundle.getBundle(CslEditorKit.class)
239.462 + .getString("goto_source_open_source_not_formatted")); //NOI18N
239.463 + addAcceleretors(a, item, target);
239.464 + item.setEnabled(false);
239.465 + }
239.466 + }
239.467 + }
239.468 +
239.469 + if (item != null) {
239.470 + menu.add(item);
239.471 + }
239.472 + }
239.473 + }
239.474 +
239.475 + private void addAction(JTextComponent target, JMenu menu, String actionName) {
239.476 + BaseKit kit = Utilities.getKit(target);
239.477 +
239.478 + if (kit == null) {
239.479 + return;
239.480 + }
239.481 +
239.482 + Action a = kit.getActionByName(actionName);
239.483 +
239.484 + if (a != null) {
239.485 + addAction(target, menu, a);
239.486 + } else { // action-name is null, add the separator
239.487 + menu.addSeparator();
239.488 + }
239.489 + }
239.490 +
239.491 + private String getItemText(JTextComponent target, String actionName, Action a) {
239.492 + String itemText;
239.493 +
239.494 + if (a instanceof BaseAction) {
239.495 + itemText = ((BaseAction)a).getPopupMenuText(target);
239.496 + } else {
239.497 + itemText = actionName;
239.498 + }
239.499 +
239.500 + return itemText;
239.501 + }
239.502 +
239.503 + @Override
239.504 + public JMenuItem getPopupMenuItem(final JTextComponent target) {
239.505 + String menuText =
239.506 + NbBundle.getBundle(CslEditorKit.class).getString("generate-goto-popup"); //NOI18N
239.507 + JMenu jm = new JMenu(menuText);
239.508 + //addAction(target, jm, ExtKit.gotoSourceAction);
239.509 + addAction(target, jm, ExtKit.gotoDeclarationAction);
239.510 + //addAction(target, jm, gotoSuperImplementationAction);
239.511 + //addAction(target, jm, ExtKit.gotoAction);
239.512 + return jm;
239.513 + }
239.514 + }
239.515 +
239.516 +
239.517 +}
240.1 --- a/csl.api/src/org/netbeans/modules/csl/core/DeleteToNextCamelCasePosition.java Mon Feb 01 12:23:06 2010 +0100
240.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
240.3 @@ -1,45 +0,0 @@
240.4 -/*
240.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
240.6 - *
240.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
240.8 - *
240.9 - * The contents of this file are subject to the terms of either the GNU
240.10 - * General Public License Version 2 only ("GPL") or the Common
240.11 - * Development and Distribution License("CDDL") (collectively, the
240.12 - * "License"). You may not use this file except in compliance with the
240.13 - * License. You can obtain a copy of the License at
240.14 - * http://www.netbeans.org/cddl-gplv2.html
240.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
240.16 - * specific language governing permissions and limitations under the
240.17 - * License. When distributing the software, include this License Header
240.18 - * Notice in each file and include the License file at
240.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
240.20 - * particular file as subject to the "Classpath" exception as provided
240.21 - * by Sun in the GPL Version 2 section of the License file that
240.22 - * accompanied this code. If applicable, add the following below the
240.23 - * License Header, with the fields enclosed by brackets [] replaced by
240.24 - * your own identifying information:
240.25 - * "Portions Copyrighted [year] [name of copyright owner]"
240.26 - *
240.27 - * Contributor(s):
240.28 - *
240.29 - * Portions Copyrighted 2007 Sun Microsystems, Inc.
240.30 - */
240.31 -package org.netbeans.modules.csl.core;
240.32 -
240.33 -import javax.swing.Action;
240.34 -import javax.swing.text.BadLocationException;
240.35 -import javax.swing.text.JTextComponent;
240.36 -
240.37 -/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
240.38 -public final class DeleteToNextCamelCasePosition extends SelectNextCamelCasePosition {
240.39 - public static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
240.40 -
240.41 - public DeleteToNextCamelCasePosition(Action originalAction) {
240.42 - super(deleteNextCamelCasePosition, originalAction);
240.43 - }
240.44 -
240.45 - protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
240.46 - textComponent.getDocument().remove(textComponent.getCaretPosition(), offset - textComponent.getCaretPosition());
240.47 - }
240.48 -}
241.1 --- a/csl.api/src/org/netbeans/modules/csl/core/DeleteToPreviousCamelCasePosition.java Mon Feb 01 12:23:06 2010 +0100
241.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
241.3 @@ -1,60 +0,0 @@
241.4 -/*
241.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
241.6 - *
241.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
241.8 - *
241.9 - * The contents of this file are subject to the terms of either the GNU
241.10 - * General Public License Version 2 only ("GPL") or the Common
241.11 - * Development and Distribution License("CDDL") (collectively, the
241.12 - * "License"). You may not use this file except in compliance with the
241.13 - * License. You can obtain a copy of the License at
241.14 - * http://www.netbeans.org/cddl-gplv2.html
241.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
241.16 - * specific language governing permissions and limitations under the
241.17 - * License. When distributing the software, include this License Header
241.18 - * Notice in each file and include the License file at
241.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
241.20 - * particular file as subject to the "Classpath" exception as provided
241.21 - * by Sun in the GPL Version 2 section of the License file that
241.22 - * accompanied this code. If applicable, add the following below the
241.23 - * License Header, with the fields enclosed by brackets [] replaced by
241.24 - * your own identifying information:
241.25 - * "Portions Copyrighted [year] [name of copyright owner]"
241.26 - *
241.27 - * Contributor(s):
241.28 - *
241.29 - * The Original Software is NetBeans. The Initial Developer of the Original
241.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
241.31 - * Microsystems, Inc. All Rights Reserved.
241.32 - *
241.33 - * If you wish your version of this file to be governed by only the CDDL
241.34 - * or only the GPL Version 2, indicate your decision by adding
241.35 - * "[Contributor] elects to include this software in this distribution
241.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
241.37 - * single choice of license, a recipient has the option to distribute
241.38 - * your version of this file under either the CDDL, the GPL Version 2 or
241.39 - * to extend the choice of license to its licensees as provided above.
241.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
241.41 - * Version 2 license, then the option applies only if the new code is
241.42 - * made subject to such option by the copyright holder.
241.43 - */
241.44 -package org.netbeans.modules.csl.core;
241.45 -
241.46 -import javax.swing.Action;
241.47 -import javax.swing.text.BadLocationException;
241.48 -import javax.swing.text.JTextComponent;
241.49 -
241.50 -/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
241.51 -public final class DeleteToPreviousCamelCasePosition extends SelectPreviousCamelCasePosition {
241.52 - public static final String deletePreviousCamelCasePosition = "delete-previous-camel-case-position"; //NOI18N
241.53 -
241.54 - public DeleteToPreviousCamelCasePosition(Action originalAction) {
241.55 - // XXX Why does this get called so many times?
241.56 - super(deletePreviousCamelCasePosition, originalAction);
241.57 - }
241.58 - protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
241.59 - textComponent.getDocument().remove(offset, textComponent.getCaretPosition() - offset);
241.60 - }
241.61 -}
241.62 -
241.63 -
242.1 --- a/csl.api/src/org/netbeans/modules/csl/core/GsfDocument.java Mon Feb 01 12:23:06 2010 +0100
242.2 +++ b/csl.api/src/org/netbeans/modules/csl/core/GsfDocument.java Mon Feb 01 12:24:26 2010 +0100
242.3 @@ -50,24 +50,22 @@
242.4 * @author Tor Norbye
242.5 */
242.6 public class GsfDocument extends NbEditorDocument {
242.7 - private Language language;
242.8 +
242.9 + private GsfLanguage language = null;
242.10
242.11 - public GsfDocument(Language language) {
242.12 - super(language.getMimeType());
242.13 - if (language.getGsfLanguage() != null) {
242.14 - putProperty(org.netbeans.api.lexer.Language.class, language.getGsfLanguage().getLexerLanguage());
242.15 - }
242.16 -
242.17 - this.language = language;
242.18 + public GsfDocument(String mimeType) {
242.19 + super(mimeType);
242.20 }
242.21
242.22 @Override
242.23 public boolean isIdentifierPart(char ch) {
242.24 - GsfLanguage gsfLanguage = language.getGsfLanguage();
242.25 - if (gsfLanguage != null) {
242.26 - return gsfLanguage.isIdentifierChar(ch);
242.27 + if (language == null) {
242.28 + Language l = LanguageRegistry.getInstance().getLanguageByMimeType((String) getProperty("mimeType")); //NOI18N
242.29 + if (l != null) {
242.30 + language = l.getGsfLanguage();
242.31 + }
242.32 }
242.33 -
242.34 - return super.isIdentifierPart(ch);
242.35 +
242.36 + return language != null ? language.isIdentifierChar(ch) : super.isIdentifierPart(ch);
242.37 }
242.38 }
243.1 --- a/csl.api/src/org/netbeans/modules/csl/core/GsfEditorKitFactory.java Mon Feb 01 12:23:06 2010 +0100
243.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
243.3 @@ -1,561 +0,0 @@
243.4 -/*
243.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
243.6 - *
243.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
243.8 - *
243.9 - * The contents of this file are subject to the terms of either the GNU
243.10 - * General Public License Version 2 only ("GPL") or the Common
243.11 - * Development and Distribution License("CDDL") (collectively, the
243.12 - * "License"). You may not use this file except in compliance with the
243.13 - * License. You can obtain a copy of the License at
243.14 - * http://www.netbeans.org/cddl-gplv2.html
243.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
243.16 - * specific language governing permissions and limitations under the
243.17 - * License. When distributing the software, include this License Header
243.18 - * Notice in each file and include the License file at
243.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
243.20 - * particular file as subject to the "Classpath" exception as provided
243.21 - * by Sun in the GPL Version 2 section of the License file that
243.22 - * accompanied this code. If applicable, add the following below the
243.23 - * License Header, with the fields enclosed by brackets [] replaced by
243.24 - * your own identifying information:
243.25 - * "Portions Copyrighted [year] [name of copyright owner]"
243.26 - *
243.27 - * Contributor(s):
243.28 - *
243.29 - * The Original Software is NetBeans. The Initial Developer of the Original
243.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
243.31 - * Microsystems, Inc. All Rights Reserved.
243.32 - *
243.33 - * If you wish your version of this file to be governed by only the CDDL
243.34 - * or only the GPL Version 2, indicate your decision by adding
243.35 - * "[Contributor] elects to include this software in this distribution
243.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
243.37 - * single choice of license, a recipient has the option to distribute
243.38 - * your version of this file under either the CDDL, the GPL Version 2 or
243.39 - * to extend the choice of license to its licensees as provided above.
243.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
243.41 - * Version 2 license, then the option applies only if the new code is
243.42 - * made subject to such option by the copyright holder.
243.43 - */
243.44 -package org.netbeans.modules.csl.core;
243.45 -
243.46 -import java.awt.event.ActionEvent;
243.47 -import java.util.ArrayList;
243.48 -import java.util.List;
243.49 -import javax.swing.Action;
243.50 -import javax.swing.JMenu;
243.51 -import javax.swing.JMenuItem;
243.52 -import javax.swing.KeyStroke;
243.53 -import javax.swing.text.BadLocationException;
243.54 -import javax.swing.text.Caret;
243.55 -import javax.swing.text.Document;
243.56 -import javax.swing.text.JTextComponent;
243.57 -import javax.swing.text.Keymap;
243.58 -import javax.swing.text.TextAction;
243.59 -import org.netbeans.api.editor.fold.FoldHierarchy;
243.60 -import org.netbeans.api.editor.fold.FoldUtilities;
243.61 -import org.netbeans.modules.csl.api.KeystrokeHandler;
243.62 -import org.netbeans.modules.csl.api.GsfLanguage;
243.63 -import org.netbeans.modules.csl.api.OffsetRange;
243.64 -import org.netbeans.editor.BaseAction;
243.65 -import org.netbeans.editor.BaseDocument;
243.66 -import org.netbeans.editor.BaseKit;
243.67 -import org.netbeans.editor.BaseKit.InsertBreakAction;
243.68 -import org.netbeans.editor.SyntaxSupport;
243.69 -import org.netbeans.editor.Utilities;
243.70 -import org.netbeans.editor.ext.ExtKit;
243.71 -import org.netbeans.editor.ext.ExtKit.ToggleCommentAction;
243.72 -import org.netbeans.editor.ext.ExtSyntaxSupport;
243.73 -import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
243.74 -import org.netbeans.modules.csl.spi.CommentHandler;
243.75 -import org.netbeans.modules.editor.NbEditorKit;
243.76 -import org.netbeans.modules.csl.editor.InstantRenameAction;
243.77 -import org.netbeans.modules.csl.editor.ToggleBlockCommentAction;
243.78 -import org.netbeans.modules.csl.editor.fold.GsfFoldManager;
243.79 -import org.netbeans.modules.csl.editor.hyperlink.GoToSupport;
243.80 -import org.netbeans.modules.csl.editor.semantic.GoToMarkOccurrencesAction;
243.81 -import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
243.82 -import org.openide.awt.Mnemonics;
243.83 -import org.openide.util.Exceptions;
243.84 -import org.openide.util.NbBundle;
243.85 -
243.86 -
243.87 -/**
243.88 - * This class represents a generic Editor Kit which is shared by a number of different
243.89 - * languages. The EditorKit is an innerclass, because its superclass (BaseKit) calls
243.90 - * getContentType() as part of its constructor. Our getContentType implementation
243.91 - * relies on accessing one of the fields passed in to our constructor; but when the
243.92 - * super constructor is calling getContentType(), our own constructor has not yet been
243.93 - * called. This is worked around by having an outer class which holds the field
243.94 - * we need at constructor time (langauge).
243.95 - *
243.96 - * @author Tor Norbye
243.97 - * @author Jan Jancura
243.98 - */
243.99 -public class GsfEditorKitFactory {
243.100 - public static final String expandAllCodeBlockFolds = "expand-all-code-block-folds"; //NOI18N
243.101 - public static final String collapseAllCodeBlockFolds = "collapse-all-code-block-folds"; //NOI18N
243.102 -
243.103 - Language language;
243.104 - String mimeType;
243.105 -
243.106 - public GsfEditorKitFactory(Language language) {
243.107 - assert language != null;
243.108 - this.language = language;
243.109 - this.mimeType = language.getMimeType();
243.110 - }
243.111 -
243.112 - /**
243.113 - * Return the actual kit. This is necessary because NbEditorKit's constructor
243.114 - * winds up calling getContentType(), before we've actually had a chance to
243.115 - * construct our own editor kit (where getContentType() depends on construction
243.116 - * of the object. The trick is to use an outer class, construct that first, and
243.117 - *
243.118 - */
243.119 - public GsfEditorKit kit() {
243.120 - return new GsfEditorKit();
243.121 - }
243.122 -
243.123 - public static Action findAction(Action [] actions, String name) {
243.124 - for(Action a : actions) {
243.125 - Object nameObj = a.getValue(Action.NAME);
243.126 - if (nameObj instanceof String && name.equals(nameObj)) {
243.127 - return a;
243.128 - }
243.129 - }
243.130 - return null;
243.131 - }
243.132 -
243.133 - static KeystrokeHandler getBracketCompletion(Document doc, int offset) {
243.134 - BaseDocument baseDoc = (BaseDocument)doc;
243.135 - List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset);
243.136 - for (Language l : list) {
243.137 - if (l.getBracketCompletion() != null) {
243.138 - return l.getBracketCompletion();
243.139 - }
243.140 - }
243.141 -
243.142 - return null;
243.143 - }
243.144 -
243.145 - /**
243.146 - * Returns true if bracket completion is enabled in options.
243.147 - */
243.148 - private static boolean completionSettingEnabled() {
243.149 - //return ((Boolean)Settings.getValue(GsfEditorKit.class, JavaSettingsNames.PAIR_CHARACTERS_COMPLETION)).booleanValue();
243.150 - return true;
243.151 - }
243.152 -
243.153 - public class GsfEditorKit extends NbEditorKit {
243.154 -
243.155 - public GsfEditorKit() {
243.156 - }
243.157 -
243.158 - @Override
243.159 - public String getContentType() {
243.160 - return language.getMimeType();
243.161 - }
243.162 -
243.163 - @Override
243.164 - public Document createDefaultDocument() {
243.165 - Document doc = new GsfDocument(language);
243.166 - doc.putProperty("mimeType", getContentType()); //NOI18N
243.167 - return doc;
243.168 - }
243.169 -
243.170 - @Override
243.171 - public SyntaxSupport createSyntaxSupport(final BaseDocument doc) {
243.172 - return new ExtSyntaxSupport(doc) {
243.173 - @Override
243.174 - public int[] findMatchingBlock(int offset, boolean simpleSearch)
243.175 - throws BadLocationException {
243.176 - // Do parenthesis matching, if applicable
243.177 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, offset);
243.178 - if (bracketCompletion != null) {
243.179 - OffsetRange range = bracketCompletion.findMatching(getDocument(), offset/*, simpleSearch*/);
243.180 - if (range == OffsetRange.NONE) {
243.181 - return null;
243.182 - } else {
243.183 - return new int[] { range.getStart(), range.getEnd() };
243.184 - }
243.185 - }
243.186 -
243.187 - return null;
243.188 - }
243.189 - };
243.190 - }
243.191 -
243.192 - @Override
243.193 - protected void initDocument(BaseDocument doc) {
243.194 - // XXX This appears in JavaKit, not sure why, but doing it just in case.
243.195 - //do not ask why, fire bug in the IZ:
243.196 - CodeTemplateManager.get(doc);
243.197 - }
243.198 -
243.199 - @Override
243.200 - public Object clone() {
243.201 - return new GsfEditorKit();
243.202 - }
243.203 -
243.204 - @Override
243.205 - protected Action[] createActions() {
243.206 - Action[] superActions = super.createActions();
243.207 - GsfLanguage gsfLanguage = language.getGsfLanguage();
243.208 -
243.209 - ArrayList<Action> actions = new ArrayList<Action>(30);
243.210 -
243.211 - actions.add(new GsfDefaultKeyTypedAction());
243.212 - actions.add(new GsfInsertBreakAction());
243.213 - actions.add(new GsfDeleteCharAction(deletePrevCharAction, false));
243.214 -
243.215 - String lineCommentPrefix = (gsfLanguage != null) ? gsfLanguage.getLineCommentPrefix() : null;
243.216 - if (lineCommentPrefix != null) {
243.217 - actions.add(new CommentAction(lineCommentPrefix));
243.218 - actions.add(new UncommentAction(lineCommentPrefix));
243.219 - actions.add(new ToggleCommentAction(lineCommentPrefix));
243.220 - }
243.221 -
243.222 - if(gsfLanguage instanceof DefaultLanguageConfig) {
243.223 - CommentHandler ch = ((DefaultLanguageConfig)gsfLanguage).getCommentHandler();
243.224 - if(ch != null) {
243.225 - actions.add(new ToggleBlockCommentAction(ch));
243.226 - }
243.227 -
243.228 - }
243.229 -
243.230 - actions.add(new InstantRenameAction());
243.231 - actions.add(new GenericGoToDeclarationAction());
243.232 - actions.add(new GenericGenerateGoToPopupAction());
243.233 - actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
243.234 - actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));
243.235 - //actions.add(new ExpandAllCodeBlockFolds());
243.236 - //actions.add(new CollapseAllCodeBlockFolds());
243.237 - actions.add(new NextCamelCasePosition(findAction(superActions, nextWordAction)));
243.238 - actions.add(new PreviousCamelCasePosition(findAction(superActions, previousWordAction)));
243.239 - actions.add(new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)));
243.240 - actions.add(new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)));
243.241 - actions.add(new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)));
243.242 - actions.add(new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)));
243.243 -
243.244 - if (language.hasOccurrencesFinder()) {
243.245 - actions.add(new GoToMarkOccurrencesAction(false));
243.246 - actions.add(new GoToMarkOccurrencesAction(true));
243.247 - }
243.248 -
243.249 - return TextAction.augmentList(superActions,
243.250 - actions.toArray(new Action[actions.size()]));
243.251 - }
243.252 -
243.253 - public class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
243.254 - private JTextComponent currentTarget;
243.255 -
243.256 - @Override
243.257 - public void actionPerformed(ActionEvent evt, JTextComponent target) {
243.258 - currentTarget = target;
243.259 - super.actionPerformed(evt, target);
243.260 - currentTarget = null;
243.261 - }
243.262 -
243.263 - @Override
243.264 - protected void insertString(BaseDocument doc, int dotPos, Caret caret, String str,
243.265 - boolean overwrite) throws BadLocationException {
243.266 - if (completionSettingEnabled()) {
243.267 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
243.268 -
243.269 - if (bracketCompletion != null) {
243.270 - // TODO - check if we're in a comment etc. and if so, do nothing
243.271 - boolean handled =
243.272 - bracketCompletion.beforeCharInserted(doc, dotPos, currentTarget,
243.273 - str.charAt(0));
243.274 -
243.275 - if (!handled) {
243.276 - super.insertString(doc, dotPos, caret, str, overwrite);
243.277 - handled = bracketCompletion.afterCharInserted(doc, dotPos, currentTarget,
243.278 - str.charAt(0));
243.279 - }
243.280 -
243.281 - return;
243.282 - }
243.283 - }
243.284 -
243.285 - super.insertString(doc, dotPos, caret, str, overwrite);
243.286 - }
243.287 -
243.288 - @Override
243.289 - protected void replaceSelection(JTextComponent target, int dotPos, Caret caret,
243.290 - String str, boolean overwrite) throws BadLocationException {
243.291 - char insertedChar = str.charAt(0);
243.292 - Document document = target.getDocument();
243.293 -
243.294 - if (document instanceof BaseDocument) {
243.295 - BaseDocument doc = (BaseDocument)document;
243.296 -
243.297 - if (completionSettingEnabled()) {
243.298 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
243.299 -
243.300 - if (bracketCompletion != null) {
243.301 - try {
243.302 - int caretPosition = caret.getDot();
243.303 -
243.304 - boolean handled =
243.305 - bracketCompletion.beforeCharInserted(doc, caretPosition,
243.306 - target, insertedChar);
243.307 -
243.308 - int p0 = Math.min(caret.getDot(), caret.getMark());
243.309 - int p1 = Math.max(caret.getDot(), caret.getMark());
243.310 -
243.311 - if (p0 != p1) {
243.312 - doc.remove(p0, p1 - p0);
243.313 - }
243.314 -
243.315 - if (!handled) {
243.316 - if ((str != null) && (str.length() > 0)) {
243.317 - doc.insertString(p0, str, null);
243.318 - }
243.319 -
243.320 - bracketCompletion.afterCharInserted(doc, caret.getDot() - 1,
243.321 - target, insertedChar);
243.322 - }
243.323 - } catch (BadLocationException e) {
243.324 - e.printStackTrace();
243.325 - }
243.326 -
243.327 - return;
243.328 - }
243.329 - }
243.330 - }
243.331 -
243.332 - super.replaceSelection(target, dotPos, caret, str, overwrite);
243.333 - }
243.334 - }
243.335 -
243.336 - public class GsfInsertBreakAction extends InsertBreakAction {
243.337 - static final long serialVersionUID = -1506173310438326380L;
243.338 -
243.339 - @Override
243.340 - protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) {
243.341 - if (completionSettingEnabled()) {
243.342 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, caret.getDot());
243.343 -
243.344 - if (bracketCompletion != null) {
243.345 - try {
243.346 - int newOffset = bracketCompletion.beforeBreak(doc, caret.getDot(), target);
243.347 -
243.348 - if (newOffset >= 0) {
243.349 - return new Integer(newOffset);
243.350 - }
243.351 - } catch (BadLocationException ble) {
243.352 - Exceptions.printStackTrace(ble);
243.353 - }
243.354 - }
243.355 - }
243.356 -
243.357 - // return Boolean.TRUE;
243.358 - return null;
243.359 - }
243.360 -
243.361 - @Override
243.362 - protected void afterBreak(JTextComponent target, BaseDocument doc, Caret caret,
243.363 - Object cookie) {
243.364 - if (completionSettingEnabled()) {
243.365 - if (cookie != null) {
243.366 - if (cookie instanceof Integer) {
243.367 - // integer
243.368 - int dotPos = ((Integer)cookie).intValue();
243.369 - if (dotPos != -1) {
243.370 - caret.setDot(dotPos);
243.371 - } else {
243.372 - int nowDotPos = caret.getDot();
243.373 - caret.setDot(nowDotPos + 1);
243.374 - }
243.375 - }
243.376 - }
243.377 - }
243.378 - }
243.379 - }
243.380 -
243.381 - public class GsfDeleteCharAction extends ExtDeleteCharAction {
243.382 - private JTextComponent currentTarget;
243.383 -
243.384 - public GsfDeleteCharAction(String nm, boolean nextChar) {
243.385 - super(nm, nextChar);
243.386 - }
243.387 -
243.388 - @Override
243.389 - public void actionPerformed(ActionEvent evt, JTextComponent target) {
243.390 - currentTarget = target;
243.391 - super.actionPerformed(evt, target);
243.392 - currentTarget = null;
243.393 - }
243.394 -
243.395 - @Override
243.396 - protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch)
243.397 - throws BadLocationException {
243.398 - if (completionSettingEnabled()) {
243.399 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
243.400 -
243.401 - if (bracketCompletion != null) {
243.402 - boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch);
243.403 - return;
243.404 - }
243.405 - }
243.406 - super.charBackspaced(doc, dotPos, caret, ch);
243.407 - }
243.408 - }
243.409 -
243.410 - private class GenericGoToDeclarationAction extends GotoDeclarationAction {
243.411 - @Override
243.412 - public boolean gotoDeclaration(JTextComponent target) {
243.413 - GoToSupport.performGoTo((BaseDocument)target.getDocument(),
243.414 - target.getCaretPosition());
243.415 -
243.416 - return true;
243.417 - }
243.418 - }
243.419 -
243.420 - private class GenericGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
243.421 - @Override
243.422 - public void actionPerformed(ActionEvent evt, JTextComponent target) {
243.423 - }
243.424 -
243.425 - private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
243.426 - // Try to get the accelerator
243.427 - Keymap km = target.getKeymap();
243.428 -
243.429 - if (km != null) {
243.430 - KeyStroke[] keys = km.getKeyStrokesForAction(a);
243.431 -
243.432 - if ((keys != null) && (keys.length > 0)) {
243.433 - item.setAccelerator(keys[0]);
243.434 - } else if (a != null) {
243.435 - KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
243.436 -
243.437 - if (ks != null) {
243.438 - item.setAccelerator(ks);
243.439 - }
243.440 - }
243.441 - }
243.442 - }
243.443 -
243.444 - private void addAction(JTextComponent target, JMenu menu, Action a) {
243.445 - if (a != null) {
243.446 - String actionName = (String)a.getValue(Action.NAME);
243.447 - JMenuItem item = null;
243.448 -
243.449 - if (a instanceof BaseAction) {
243.450 - item = ((BaseAction)a).getPopupMenuItem(target);
243.451 - }
243.452 -
243.453 - if (item == null) {
243.454 - // gets trimmed text that doesn' contain "go to"
243.455 - String itemText = (String)a.getValue(ExtKit.TRIMMED_TEXT);
243.456 -
243.457 - if (itemText == null) {
243.458 - itemText = getItemText(target, actionName, a);
243.459 - }
243.460 -
243.461 - if (itemText != null) {
243.462 - item = new JMenuItem(itemText);
243.463 - Mnemonics.setLocalizedText(item, itemText);
243.464 - item.addActionListener(a);
243.465 - addAcceleretors(a, item, target);
243.466 - item.setEnabled(a.isEnabled());
243.467 -
243.468 - Object helpID = a.getValue("helpID"); // NOI18N
243.469 -
243.470 - if ((helpID != null) && (helpID instanceof String)) {
243.471 - item.putClientProperty("HelpID", helpID); // NOI18N
243.472 - }
243.473 - } else {
243.474 - if (ExtKit.gotoSourceAction.equals(actionName)) {
243.475 - item = new JMenuItem(NbBundle.getBundle(GsfEditorKit.class)
243.476 - .getString("goto_source_open_source_not_formatted")); //NOI18N
243.477 - addAcceleretors(a, item, target);
243.478 - item.setEnabled(false);
243.479 - }
243.480 - }
243.481 - }
243.482 -
243.483 - if (item != null) {
243.484 - menu.add(item);
243.485 - }
243.486 - }
243.487 - }
243.488 -
243.489 - private void addAction(JTextComponent target, JMenu menu, String actionName) {
243.490 - BaseKit kit = Utilities.getKit(target);
243.491 -
243.492 - if (kit == null) {
243.493 - return;
243.494 - }
243.495 -
243.496 - Action a = kit.getActionByName(actionName);
243.497 -
243.498 - if (a != null) {
243.499 - addAction(target, menu, a);
243.500 - } else { // action-name is null, add the separator
243.501 - menu.addSeparator();
243.502 - }
243.503 - }
243.504 -
243.505 - private String getItemText(JTextComponent target, String actionName, Action a) {
243.506 - String itemText;
243.507 -
243.508 - if (a instanceof BaseAction) {
243.509 - itemText = ((BaseAction)a).getPopupMenuText(target);
243.510 - } else {
243.511 - itemText = actionName;
243.512 - }
243.513 -
243.514 - return itemText;
243.515 - }
243.516 -
243.517 - @Override
243.518 - public JMenuItem getPopupMenuItem(final JTextComponent target) {
243.519 - String menuText =
243.520 - NbBundle.getBundle(GsfEditorKit.class).getString("generate-goto-popup"); //NOI18N
243.521 - JMenu jm = new JMenu(menuText);
243.522 - //addAction(target, jm, ExtKit.gotoSourceAction);
243.523 - addAction(target, jm, ExtKit.gotoDeclarationAction);
243.524 - //addAction(target, jm, gotoSuperImplementationAction);
243.525 - //addAction(target, jm, ExtKit.gotoAction);
243.526 - return jm;
243.527 - }
243.528 - }
243.529 - }
243.530 -
243.531 - public static class ExpandAllCodeBlockFolds extends BaseAction{
243.532 - public ExpandAllCodeBlockFolds(){
243.533 - super(expandAllCodeBlockFolds);
243.534 - putValue(SHORT_DESCRIPTION, NbBundle.getBundle(GsfEditorKitFactory.class).getString("expand-all-code-block-folds"));
243.535 - putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(GsfEditorKitFactory.class).getString("popup-expand-all-code-block-folds"));
243.536 - }
243.537 -
243.538 - public void actionPerformed(ActionEvent evt, JTextComponent target) {
243.539 - FoldHierarchy hierarchy = FoldHierarchy.get(target);
243.540 - // Hierarchy locking done in the utility method
243.541 - List types = new ArrayList();
243.542 - types.add(GsfFoldManager.CODE_BLOCK_FOLD_TYPE);
243.543 - //types.add(GsfFoldManager.IMPORTS_FOLD_TYPE);
243.544 - FoldUtilities.expand(hierarchy, types);
243.545 - }
243.546 - }
243.547 -
243.548 - public static class CollapseAllCodeBlockFolds extends BaseAction{
243.549 - public CollapseAllCodeBlockFolds(){
243.550 - super(collapseAllCodeBlockFolds);
243.551 - putValue(SHORT_DESCRIPTION, NbBundle.getBundle(GsfEditorKitFactory.class).getString("collapse-all-code-block-folds"));
243.552 - putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(GsfEditorKitFactory.class).getString("popup-collapse-all-code-block-folds"));
243.553 - }
243.554 -
243.555 - public void actionPerformed(ActionEvent evt, JTextComponent target) {
243.556 - FoldHierarchy hierarchy = FoldHierarchy.get(target);
243.557 - // Hierarchy locking done in the utility method
243.558 - List types = new ArrayList();
243.559 - types.add(GsfFoldManager.CODE_BLOCK_FOLD_TYPE);
243.560 - ///types.add(GsfFoldManager.IMPORTS_FOLD_TYPE);
243.561 - FoldUtilities.collapse(hierarchy, types);
243.562 - }
243.563 - }
243.564 -}
244.1 --- a/csl.api/src/org/netbeans/modules/csl/core/LanguageRegistrationProcessor.java Mon Feb 01 12:23:06 2010 +0100
244.2 +++ b/csl.api/src/org/netbeans/modules/csl/core/LanguageRegistrationProcessor.java Mon Feb 01 12:24:26 2010 +0100
244.3 @@ -48,12 +48,15 @@
244.4 import javax.annotation.processing.SupportedAnnotationTypes;
244.5 import javax.annotation.processing.SupportedSourceVersion;
244.6 import javax.lang.model.SourceVersion;
244.7 +import javax.lang.model.element.AnnotationMirror;
244.8 import javax.lang.model.element.Element;
244.9 import javax.lang.model.element.ExecutableElement;
244.10 import javax.lang.model.element.TypeElement;
244.11 import javax.lang.model.util.ElementFilter;
244.12 import javax.swing.JSeparator;
244.13 +import javax.swing.text.EditorKit;
244.14 import org.netbeans.api.editor.mimelookup.MimePath;
244.15 +import org.netbeans.api.lexer.Language;
244.16 import org.netbeans.lib.editor.codetemplates.CodeTemplateCompletionProvider;
244.17 import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt;
244.18 import org.netbeans.modules.csl.editor.GsfCodeFoldingSideBarFactory;
244.19 @@ -68,6 +71,8 @@
244.20 import org.netbeans.modules.csl.navigation.ClassMemberPanel;
244.21 import org.netbeans.modules.csl.spi.LanguageRegistration;
244.22 import org.netbeans.modules.editor.errorstripe.privatespi.MarkProviderCreator;
244.23 +import org.netbeans.modules.editor.indent.spi.IndentTask;
244.24 +import org.netbeans.modules.editor.indent.spi.ReformatTask;
244.25 import org.netbeans.modules.parsing.spi.ParserFactory;
244.26 import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
244.27 import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
244.28 @@ -107,6 +112,15 @@
244.29 throw new LayerGenerationException("Class " + cls + " is not subclass of " + dlc, e); //NOI18N
244.30 }
244.31
244.32 + boolean isAnnotatedByPathRecognizerRegistration = false;
244.33 + TypeElement prr = processingEnv.getElementUtils().getTypeElement("org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration"); //NOI18N
244.34 + for(AnnotationMirror am : cls.getAnnotationMirrors()) {
244.35 + if (am.getAnnotationType().asElement().equals(prr)) {
244.36 + isAnnotatedByPathRecognizerRegistration = true;
244.37 + break;
244.38 + }
244.39 + }
244.40 +
244.41 List<ExecutableElement> methodsList = ElementFilter.methodsIn(cls.getEnclosedElements());
244.42 Map<String, ExecutableElement> methods = new HashMap<String, ExecutableElement>(methodsList.size());
244.43 for(ExecutableElement m : methodsList) {
244.44 @@ -126,10 +140,20 @@
244.45 }
244.46
244.47 if (!languageRegistration.useCustomEditorKit()) {
244.48 + registerEditorKit(lb, mimeType);
244.49 registerLoader(lb, mimeType);
244.50 - registerPathRecognizer(lb, mimeType);
244.51 - registerParser(lb, mimeType);
244.52 - registerIndexer(lb, mimeType);
244.53 + if (methods.containsKey("getLexerLanguage")) { //NOI18N
244.54 + registerLexer(lb, mimeType);
244.55 + }
244.56 + if (methods.containsKey("getParser")) { //NOI18N
244.57 + registerParser(lb, mimeType);
244.58 + }
244.59 + if (methods.containsKey("getIndexerFactory")) { //NOI18N
244.60 + registerIndexer(lb, mimeType);
244.61 + if (!isAnnotatedByPathRecognizerRegistration) {
244.62 + registerPathRecognizer(lb, mimeType);
244.63 + }
244.64 + }
244.65 registerCodeCompletion(lb, mimeType);
244.66 registerCodeFolding(lb, mimeType);
244.67 registerCodeTemplates(lb, mimeType);
244.68 @@ -140,6 +164,9 @@
244.69 registerUpToDateStatus(lb, mimeType);
244.70 registerContextMenu(lb, mimeType, methods);
244.71 registerCommentUncommentToolbarButtons(lb, mimeType);
244.72 + if (methods.containsKey("getFormatter")) { //NOI18N
244.73 + registerFormatterIndenter(lb, mimeType);
244.74 + }
244.75 }
244.76 }
244.77 }
244.78 @@ -431,6 +458,19 @@
244.79 // }
244.80 }
244.81
244.82 + private static void registerEditorKit(LayerBuilder b, String mimeType) {
244.83 + instanceFile(b, "Editors/" + mimeType, null, CslEditorKit.class, "createEditorKitInstance", EditorKit.class).write(); //NOI18N
244.84 + }
244.85 +
244.86 + private static void registerLexer(LayerBuilder b, String mimeType) {
244.87 + instanceFile(b, "Editors/" + mimeType, null, CslEditorKit.class, "createLexerLanguageInstance", Language.class).write(); //NOI18N
244.88 + }
244.89 +
244.90 + private static void registerFormatterIndenter(LayerBuilder b, String mimeType) {
244.91 + instanceFile(b, "Editors/" + mimeType, null, GsfReformatTaskFactory.class, null, ReformatTask.class).write(); //NOI18N
244.92 + instanceFile(b, "Editors/" + mimeType, null, GsfIndentTaskFactory.class, null, IndentTask.class).write(); //NOI18N
244.93 + }
244.94 +
244.95 private static String makeFilesystemName(String s) {
244.96 StringBuilder sb = new StringBuilder(s.length());
244.97 for(int i = 0; i < s.length(); i++) {
245.1 --- a/csl.api/src/org/netbeans/modules/csl/core/MimeLookupInitializerImpl.java Mon Feb 01 12:23:06 2010 +0100
245.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
245.3 @@ -1,189 +0,0 @@
245.4 -/*
245.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
245.6 - *
245.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
245.8 - *
245.9 - * The contents of this file are subject to the terms of either the GNU
245.10 - * General Public License Version 2 only ("GPL") or the Common
245.11 - * Development and Distribution License("CDDL") (collectively, the
245.12 - * "License"). You may not use this file except in compliance with the
245.13 - * License. You can obtain a copy of the License at
245.14 - * http://www.netbeans.org/cddl-gplv2.html
245.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
245.16 - * specific language governing permissions and limitations under the
245.17 - * License. When distributing the software, include this License Header
245.18 - * Notice in each file and include the License file at
245.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
245.20 - * particular file as subject to the "Classpath" exception as provided
245.21 - * by Sun in the GPL Version 2 section of the License file that
245.22 - * accompanied this code. If applicable, add the following below the
245.23 - * License Header, with the fields enclosed by brackets [] replaced by
245.24 - * your own identifying information:
245.25 - * "Portions Copyrighted [year] [name of copyright owner]"
245.26 - *
245.27 - * Contributor(s):
245.28 - *
245.29 - * The Original Software is NetBeans. The Initial Developer of the Original
245.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
245.31 - * Microsystems, Inc. All Rights Reserved.
245.32 - *
245.33 - * If you wish your version of this file to be governed by only the CDDL
245.34 - * or only the GPL Version 2, indicate your decision by adding
245.35 - * "[Contributor] elects to include this software in this distribution
245.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
245.37 - * single choice of license, a recipient has the option to distribute
245.38 - * your version of this file under either the CDDL, the GPL Version 2 or
245.39 - * to extend the choice of license to its licensees as provided above.
245.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
245.41 - * Version 2 license, then the option applies only if the new code is
245.42 - * made subject to such option by the copyright holder.
245.43 - */
245.44 -package org.netbeans.modules.csl.core;
245.45 -
245.46 -import java.util.HashMap;
245.47 -import java.util.Map;
245.48 -import org.netbeans.modules.csl.core.GsfIndentTaskFactory;
245.49 -import org.netbeans.spi.editor.mimelookup.MimeLookupInitializer;
245.50 -import org.openide.util.Lookup;
245.51 -import org.openide.util.lookup.InstanceContent;
245.52 -import org.openide.util.lookup.Lookups;
245.53 -
245.54 -
245.55 -/**
245.56 - * Listen for editor lookup requests for a particular mime type, and lazily
245.57 - * initialize language support and construct an editor kit for the given
245.58 - * mime type.
245.59 - *
245.60 - * Based on MimeLookupInitializer in the Schliemann prototype by Jan Jancura.
245.61 - *
245.62 - * @author Jan Jancura
245.63 - * @author Tor Norbye
245.64 - */
245.65 -public class MimeLookupInitializerImpl implements MimeLookupInitializer {
245.66 -
245.67 - private static final int EDITOR_KIT_ID = 1;
245.68 - private static final int INDENT_ID = 2;
245.69 - private static final int FORMAT_ID = 3;
245.70 - private static final int BRACES_ID = 4;
245.71 -
245.72 - private String[] mimeTypes;
245.73 - private Map<String, Lookup.Result> children = new HashMap<String,Lookup.Result>(); //<mimetype, child Lookup.Result>
245.74 - private Lookup lookup;
245.75 -
245.76 - public MimeLookupInitializerImpl() {
245.77 - this(new String[0]);
245.78 - }
245.79 -
245.80 - public MimeLookupInitializerImpl(String[] mimeTypes) {
245.81 - this.mimeTypes = mimeTypes;
245.82 - }
245.83 -
245.84 - /**
245.85 - * Retrieves a Lookup.Result of MimeLookupInitializers for the given sub-mimeType.
245.86 - *
245.87 - * @param mimeType mime-type string representation e.g. "text/x-java"
245.88 - * @return non-null lookup result of MimeLookupInitializer(s).
245.89 - * <br/>
245.90 - * Typically there should be just one child initializer although if there
245.91 - * will be more than one all of them will be taken into consideration.
245.92 - * <br/>
245.93 - * If there will be no specific initializers for the particular mime-type
245.94 - * then an empty result should be returned.
245.95 - */
245.96 - public Lookup.Result child(String mimeType) {
245.97 - synchronized (children) {
245.98 - String[] newMimeType = new String[mimeTypes.length + 1];
245.99 - System.arraycopy(mimeTypes, 0, newMimeType, 0, mimeTypes.length);
245.100 - newMimeType[mimeTypes.length] = mimeType;
245.101 -
245.102 - Lookup.Result child = children.get(mimeType);
245.103 -
245.104 - if (child == null) {
245.105 - child = Lookups.fixed(new Object[]{new MimeLookupInitializerImpl(newMimeType)}).lookup(new Lookup.Template(MimeLookupInitializerImpl.class));
245.106 - children.put(mimeType, child);
245.107 - }
245.108 -
245.109 - return child;
245.110 - }
245.111 - }
245.112 -
245.113 - /**
245.114 - * Lookup providing mime-type sensitive or global-level data
245.115 - * depending on which level this initializer is defined.
245.116 - *
245.117 - * @return Lookup or null, if there are no lookup-able objects for mime or global level.
245.118 - */
245.119 - public Lookup lookup() {
245.120 - if (lookup == null) {
245.121 - if (mimeTypes.length != 1) {
245.122 - lookup = Lookup.EMPTY;
245.123 -
245.124 - return lookup;
245.125 - }
245.126 -
245.127 - if (LanguageRegistry.getInstance().isSupported(mimeTypes[0])) {
245.128 - final Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeTypes[0]);
245.129 - assert language != null;
245.130 -
245.131 - if (language.useCustomEditorKit()) {
245.132 - return null;
245.133 - }
245.134 -
245.135 - Integer[] supportedOps = null;
245.136 - if (language.hasFormatter()) {
245.137 - supportedOps = new Integer[]{Integer.valueOf(EDITOR_KIT_ID), Integer.valueOf(INDENT_ID), Integer.valueOf(FORMAT_ID) };
245.138 - } else {
245.139 - supportedOps = new Integer[]{Integer.valueOf(EDITOR_KIT_ID), Integer.valueOf(INDENT_ID) };
245.140 - }
245.141 -
245.142 - lookup = Lookups.fixed(supportedOps, new InstanceContent.Convertor<Integer, Object>() {
245.143 -
245.144 - public Object convert(Integer i) {
245.145 - switch (i.intValue()) {
245.146 - case EDITOR_KIT_ID: {
245.147 - GsfEditorKitFactory outer = new GsfEditorKitFactory(language);
245.148 -
245.149 - return outer.kit();
245.150 - }
245.151 - //case BRACES_ID: {
245.152 - // return new BraceHighlighting(mimeTypes[0]);
245.153 - //}
245.154 - case FORMAT_ID:
245.155 - return new GsfReformatTaskFactory();
245.156 - case INDENT_ID:
245.157 - return new GsfIndentTaskFactory();
245.158 - }
245.159 -
245.160 - return null;
245.161 - }
245.162 -
245.163 - public Class<? extends Object> type(Integer i) {
245.164 - switch (i.intValue()) {
245.165 - case EDITOR_KIT_ID:
245.166 - return GsfEditorKitFactory.GsfEditorKit.class;
245.167 - case FORMAT_ID:
245.168 - return GsfReformatTaskFactory.class;
245.169 - case INDENT_ID:
245.170 - return GsfIndentTaskFactory.class;
245.171 - //case BRACES_ID:
245.172 - // return BracesMatcherFactory.class;
245.173 - }
245.174 -
245.175 -
245.176 - return null;
245.177 - }
245.178 -
245.179 - public String id(Integer i) {
245.180 - return i.toString();
245.181 - }
245.182 -
245.183 - public String displayName(Integer i) {
245.184 - return i.toString();
245.185 - }
245.186 - });
245.187 - }
245.188 - }
245.189 -
245.190 - return lookup;
245.191 - }
245.192 -}
246.1 --- a/csl.api/src/org/netbeans/modules/csl/core/NextCamelCasePosition.java Mon Feb 01 12:23:06 2010 +0100
246.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
246.3 @@ -1,53 +0,0 @@
246.4 -/*
246.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
246.6 - *
246.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
246.8 - *
246.9 - * The contents of this file are subject to the terms of either the GNU
246.10 - * General Public License Version 2 only ("GPL") or the Common
246.11 - * Development and Distribution License("CDDL") (collectively, the
246.12 - * "License"). You may not use this file except in compliance with the
246.13 - * License. You can obtain a copy of the License at
246.14 - * http://www.netbeans.org/cddl-gplv2.html
246.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
246.16 - * specific language governing permissions and limitations under the
246.17 - * License. When distributing the software, include this License Header
246.18 - * Notice in each file and include the License file at
246.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
246.20 - * particular file as subject to the "Classpath" exception as provided
246.21 - * by Sun in the GPL Version 2 section of the License file that
246.22 - * accompanied this code. If applicable, add the following below the
246.23 - * License Header, with the fields enclosed by brackets [] replaced by
246.24 - * your own identifying information:
246.25 - * "Portions Copyrighted [year] [name of copyright owner]"
246.26 - *
246.27 - * Contributor(s):
246.28 - *
246.29 - * Portions Copyrighted 2007 Sun Microsystems, Inc.
246.30 - */
246.31 -package org.netbeans.modules.csl.core;
246.32 -
246.33 -import javax.swing.Action;
246.34 -import javax.swing.text.BadLocationException;
246.35 -import javax.swing.text.JTextComponent;
246.36 -
246.37 -/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
246.38 -public class NextCamelCasePosition extends AbstractCamelCasePosition {
246.39 - public static final String nextCamelCasePosition = "next-camel-case-position"; //NOI18N
246.40 -
246.41 - public NextCamelCasePosition(Action originalAction) {
246.42 - this(nextCamelCasePosition, originalAction);
246.43 - }
246.44 -
246.45 - protected NextCamelCasePosition(String name, Action originalAction) {
246.46 - super(name, originalAction);
246.47 - }
246.48 -
246.49 - protected int newOffset(JTextComponent textComponent) throws BadLocationException {
246.50 - return CamelCaseOperations.nextCamelCasePosition(textComponent);
246.51 - }
246.52 -
246.53 - protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
246.54 - textComponent.setCaretPosition(offset);
246.55 - }
246.56 -}
247.1 --- a/csl.api/src/org/netbeans/modules/csl/core/PreviousCamelCasePosition.java Mon Feb 01 12:23:06 2010 +0100
247.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
247.3 @@ -1,67 +0,0 @@
247.4 -/*
247.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
247.6 - *
247.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
247.8 - *
247.9 - * The contents of this file are subject to the terms of either the GNU
247.10 - * General Public License Version 2 only ("GPL") or the Common
247.11 - * Development and Distribution License("CDDL") (collectively, the
247.12 - * "License"). You may not use this file except in compliance with the
247.13 - * License. You can obtain a copy of the License at
247.14 - * http://www.netbeans.org/cddl-gplv2.html
247.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
247.16 - * specific language governing permissions and limitations under the
247.17 - * License. When distributing the software, include this License Header
247.18 - * Notice in each file and include the License file at
247.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
247.20 - * particular file as subject to the "Classpath" exception as provided
247.21 - * by Sun in the GPL Version 2 section of the License file that
247.22 - * accompanied this code. If applicable, add the following below the
247.23 - * License Header, with the fields enclosed by brackets [] replaced by
247.24 - * your own identifying information:
247.25 - * "Portions Copyrighted [year] [name of copyright owner]"
247.26 - *
247.27 - * Contributor(s):
247.28 - *
247.29 - * The Original Software is NetBeans. The Initial Developer of the Original
247.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
247.31 - * Microsystems, Inc. All Rights Reserved.
247.32 - *
247.33 - * If you wish your version of this file to be governed by only the CDDL
247.34 - * or only the GPL Version 2, indicate your decision by adding
247.35 - * "[Contributor] elects to include this software in this distribution
247.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
247.37 - * single choice of license, a recipient has the option to distribute
247.38 - * your version of this file under either the CDDL, the GPL Version 2 or
247.39 - * to extend the choice of license to its licensees as provided above.
247.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
247.41 - * Version 2 license, then the option applies only if the new code is
247.42 - * made subject to such option by the copyright holder.
247.43 - */
247.44 -package org.netbeans.modules.csl.core;
247.45 -
247.46 -import javax.swing.Action;
247.47 -import javax.swing.text.BadLocationException;
247.48 -import javax.swing.text.JTextComponent;
247.49 -
247.50 -/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
247.51 -public class PreviousCamelCasePosition extends AbstractCamelCasePosition {
247.52 - public static final String previousCamelCasePosition = "previous-camel-case-position"; //NOI18N
247.53 -
247.54 - public PreviousCamelCasePosition(Action originalAction) {
247.55 - this(previousCamelCasePosition, originalAction);
247.56 - }
247.57 -
247.58 - protected PreviousCamelCasePosition(String name, Action originalAction) {
247.59 - super(name, originalAction);
247.60 - }
247.61 -
247.62 - protected int newOffset(JTextComponent textComponent) throws BadLocationException {
247.63 - return CamelCaseOperations.previousCamelCasePosition(textComponent);
247.64 - }
247.65 -
247.66 - protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
247.67 - textComponent.setCaretPosition(offset);
247.68 - }
247.69 -}
247.70 -
248.1 --- a/csl.api/src/org/netbeans/modules/csl/core/SelectCodeElementAction.java Mon Feb 01 12:23:06 2010 +0100
248.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
248.3 @@ -1,291 +0,0 @@
248.4 -/*
248.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
248.6 - *
248.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
248.8 - *
248.9 - * The contents of this file are subject to the terms of either the GNU
248.10 - * General Public License Version 2 only ("GPL") or the Common
248.11 - * Development and Distribution License("CDDL") (collectively, the
248.12 - * "License"). You may not use this file except in compliance with the
248.13 - * License. You can obtain a copy of the License at
248.14 - * http://www.netbeans.org/cddl-gplv2.html
248.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
248.16 - * specific language governing permissions and limitations under the
248.17 - * License. When distributing the software, include this License Header
248.18 - * Notice in each file and include the License file at
248.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
248.20 - * particular file as subject to the "Classpath" exception as provided
248.21 - * by Sun in the GPL Version 2 section of the License file that
248.22 - * accompanied this code. If applicable, add the following below the
248.23 - * License Header, with the fields enclosed by brackets [] replaced by
248.24 - * your own identifying information:
248.25 - * "Portions Copyrighted [year] [name of copyright owner]"
248.26 - *
248.27 - * Contributor(s):
248.28 - *
248.29 - * The Original Software is NetBeans. The Initial Developer of the Original
248.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
248.31 - * Microsystems, Inc. All Rights Reserved.
248.32 - *
248.33 - * If you wish your version of this file to be governed by only the CDDL
248.34 - * or only the GPL Version 2, indicate your decision by adding
248.35 - * "[Contributor] elects to include this software in this distribution
248.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
248.37 - * single choice of license, a recipient has the option to distribute
248.38 - * your version of this file under either the CDDL, the GPL Version 2 or
248.39 - * to extend the choice of license to its licensees as provided above.
248.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
248.41 - * Version 2 license, then the option applies only if the new code is
248.42 - * made subject to such option by the copyright holder.
248.43 - */
248.44 -
248.45 -package org.netbeans.modules.csl.core;
248.46 -
248.47 -import java.awt.event.ActionEvent;
248.48 -import java.util.Collections;
248.49 -import java.util.List;
248.50 -import java.util.MissingResourceException;
248.51 -import javax.swing.Action;
248.52 -import javax.swing.event.CaretEvent;
248.53 -import javax.swing.event.CaretListener;
248.54 -import javax.swing.text.Caret;
248.55 -import javax.swing.text.Document;
248.56 -import javax.swing.text.JTextComponent;
248.57 -
248.58 -import org.netbeans.modules.csl.api.OffsetRange;
248.59 -import org.netbeans.editor.BaseAction;
248.60 -import org.netbeans.editor.BaseDocument;
248.61 -import org.netbeans.modules.csl.api.KeystrokeHandler;
248.62 -import org.netbeans.modules.csl.spi.ParserResult;
248.63 -import org.netbeans.modules.parsing.api.ParserManager;
248.64 -import org.netbeans.modules.parsing.api.ResultIterator;
248.65 -import org.netbeans.modules.parsing.api.Source;
248.66 -import org.netbeans.modules.parsing.api.UserTask;
248.67 -import org.netbeans.modules.parsing.spi.ParseException;
248.68 -import org.netbeans.modules.parsing.spi.Parser;
248.69 -import org.openide.ErrorManager;
248.70 -import org.openide.util.NbBundle;
248.71 -
248.72 -/**
248.73 - * Code selection according to syntax tree.
248.74 - *
248.75 - * TODO: javadoc selection
248.76 - *
248.77 - * @author Miloslav Metelka, Jan Pokorsky
248.78 - */
248.79 -public final class SelectCodeElementAction extends BaseAction {
248.80 - public static final String selectNextElementAction = "select-element-next"; //NOI18N
248.81 - public static final String selectPreviousElementAction = "select-element-previous"; //NOI18N
248.82 -
248.83 - private boolean selectNext;
248.84 -
248.85 - /**
248.86 - * Construct new action that selects next/previous code elements
248.87 - * according to the language model.
248.88 - * <br>
248.89 - *
248.90 - * @param name name of the action (should be one of
248.91 - * <br>
248.92 - * <code>JavaKit.selectNextElementAction</code>
248.93 - * <code>JavaKit.selectPreviousElementAction</code>
248.94 - * @param selectNext <code>true</code> if the next element should be selected.
248.95 - * <code>False</code> if the previous element should be selected.
248.96 - */
248.97 - public SelectCodeElementAction(String name, boolean selectNext) {
248.98 - super(name);
248.99 - this.selectNext = selectNext;
248.100 - String desc = getShortDescription();
248.101 - if (desc != null) {
248.102 - putValue(SHORT_DESCRIPTION, desc);
248.103 - }
248.104 - }
248.105 -
248.106 - public String getShortDescription(){
248.107 - String name = (String)getValue(Action.NAME);
248.108 - if (name == null) return null;
248.109 - String shortDesc;
248.110 - try {
248.111 - shortDesc = NbBundle.getBundle(GsfEditorKitFactory.class).getString(name); // NOI18N
248.112 - }catch (MissingResourceException mre){
248.113 - shortDesc = name;
248.114 - }
248.115 - return shortDesc;
248.116 - }
248.117 -
248.118 - public void actionPerformed(ActionEvent evt, JTextComponent target) {
248.119 - if (target != null) {
248.120 - int selectionStartOffset = target.getSelectionStart();
248.121 - int selectionEndOffset = target.getSelectionEnd();
248.122 - if (selectionEndOffset > selectionStartOffset || selectNext) {
248.123 - SelectionHandler handler = (SelectionHandler)target.getClientProperty(SelectionHandler.class);
248.124 - if (handler == null) {
248.125 - handler = new SelectionHandler(target);
248.126 - target.addCaretListener(handler);
248.127 - // No need to remove the listener above as the handler
248.128 - // is stored is the client-property of the component itself
248.129 - target.putClientProperty(SelectionHandler.class, handler);
248.130 - }
248.131 -
248.132 - if (selectNext) { // select next element
248.133 - handler.selectNext();
248.134 - } else { // select previous
248.135 - handler.selectPrevious();
248.136 - }
248.137 - }
248.138 - }
248.139 - }
248.140 -
248.141 - private static final class SelectionHandler extends UserTask implements CaretListener, Runnable {
248.142 -
248.143 - private JTextComponent target;
248.144 - private SelectionInfo[] selectionInfos;
248.145 - private int selIndex = -1;
248.146 - private boolean ignoreNextCaretUpdate;
248.147 -
248.148 - SelectionHandler(JTextComponent target) {
248.149 - this.target = target;
248.150 - }
248.151 -
248.152 - public void selectNext() {
248.153 - if (selectionInfos == null) {
248.154 - Source source = Source.create (target.getDocument());
248.155 - try {
248.156 - ParserManager.parse (Collections.<Source> singleton (source), this);
248.157 - } catch (ParseException ex) {
248.158 - ErrorManager.getDefault().notify(ex);
248.159 - }
248.160 - }
248.161 -
248.162 - run();
248.163 - }
248.164 -
248.165 - public synchronized void selectPrevious() {
248.166 - if (selIndex == -1) {
248.167 - // Try to figure out the selected AST index based on the editor selection
248.168 - selIndex = computeSelIndex(false);
248.169 - }
248.170 - if (selIndex > 0) {
248.171 - select(selectionInfos[--selIndex]);
248.172 - }
248.173 - }
248.174 -
248.175 - private void select(SelectionInfo selectionInfo) {
248.176 - Caret caret = target.getCaret();
248.177 - markIgnoreNextCaretUpdate();
248.178 - caret.setDot(selectionInfo.getStartOffset());
248.179 - markIgnoreNextCaretUpdate();
248.180 - caret.moveDot(selectionInfo.getEndOffset());
248.181 - }
248.182 -
248.183 - private void markIgnoreNextCaretUpdate() {
248.184 - ignoreNextCaretUpdate = true;
248.185 - }
248.186 -
248.187 - public void caretUpdate(CaretEvent e) {
248.188 - if (!ignoreNextCaretUpdate) {
248.189 - synchronized (this) {
248.190 - selectionInfos = null;
248.191 - selIndex = -1;
248.192 - }
248.193 - }
248.194 - ignoreNextCaretUpdate = false;
248.195 - }
248.196 -
248.197 - public void cancel() {
248.198 - }
248.199 -
248.200 - public void run (ResultIterator resultIterator) throws ParseException {
248.201 - Parser.Result parserResult = resultIterator.getParserResult (target.getCaretPosition ());
248.202 - if(!(parserResult instanceof ParserResult)) {
248.203 - return ;
248.204 - }
248.205 - selectionInfos = initSelectionPath(target, (ParserResult)parserResult);
248.206 - }
248.207 -
248.208 - private KeystrokeHandler getBracketCompletion(Document doc, int offset) {
248.209 - BaseDocument baseDoc = (BaseDocument)doc;
248.210 - List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset);
248.211 - for (Language l : list) {
248.212 - if (l.getBracketCompletion() != null) {
248.213 - return l.getBracketCompletion();
248.214 - }
248.215 - }
248.216 -
248.217 - return null;
248.218 - }
248.219 -
248.220 - private SelectionInfo[] initSelectionPath(JTextComponent target, ParserResult parserResult) {
248.221 - KeystrokeHandler bc = getBracketCompletion(target.getDocument(), target.getCaretPosition());
248.222 - if (bc != null) {
248.223 - List<OffsetRange> ranges = bc.findLogicalRanges(parserResult, target.getCaretPosition());
248.224 - SelectionInfo[] result = new SelectionInfo[ranges.size()];
248.225 - for (int i = 0; i < ranges.size(); i++) {
248.226 - OffsetRange range = ranges.get(i);
248.227 - result[i] = new SelectionInfo(range.getStart(), range.getEnd());
248.228 - }
248.229 - return result;
248.230 - } else {
248.231 - return new SelectionInfo[0];
248.232 - }
248.233 - }
248.234 -
248.235 - private int computeSelIndex(boolean inner) {
248.236 - Caret caret = target.getCaret();
248.237 - if (selectionInfos != null && caret != null && caret.getDot() != caret.getMark()) {
248.238 - int dot = caret.getDot();
248.239 - int mark = caret.getMark();
248.240 - int start = Math.min(dot,mark);
248.241 - //int end = Math.max(dot,mark);
248.242 - for (int i = 0; i < selectionInfos.length; i++) {
248.243 - if (selectionInfos[i].getStartOffset() == start) {
248.244 - // TODO - check end offset too
248.245 - return i;
248.246 - }
248.247 - }
248.248 - // No exact match - look at the editor selection and find the range
248.249 - // that most closely surround the selection (if inner is true, go
248.250 - // for the inner one, otherwise the outer)
248.251 - for (int i = selectionInfos.length-2; i >= 0; i--) {
248.252 - if (selectionInfos[i].getStartOffset() > start &&
248.253 - selectionInfos[i+1].getStartOffset() < start) {
248.254 - return inner ? i : i-1;
248.255 - }
248.256 - }
248.257 - }
248.258 -
248.259 - return selIndex;
248.260 - }
248.261 -
248.262 - public void run() {
248.263 - if (selIndex == -1) {
248.264 - // Try to figure out the selected AST index based on the editor selection
248.265 - selIndex = computeSelIndex(true);
248.266 - }
248.267 - if (selIndex < selectionInfos.length - 1) {
248.268 - select(selectionInfos[++selIndex]);
248.269 - }
248.270 - }
248.271 -
248.272 - }
248.273 -
248.274 - // This looks a lot like an OffsetRange! Just reuse my own OffsetRange class?
248.275 - private static final class SelectionInfo {
248.276 -
248.277 - private int startOffset;
248.278 - private int endOffset;
248.279 -
248.280 - SelectionInfo(int startOffset, int endOffset) {
248.281 - this.startOffset = startOffset;
248.282 - this.endOffset = endOffset;
248.283 - }
248.284 -
248.285 - public int getStartOffset() {
248.286 - return startOffset;
248.287 - }
248.288 -
248.289 - public int getEndOffset() {
248.290 - return endOffset;
248.291 - }
248.292 -
248.293 - }
248.294 -}
249.1 --- a/csl.api/src/org/netbeans/modules/csl/core/SelectNextCamelCasePosition.java Mon Feb 01 12:23:06 2010 +0100
249.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
249.3 @@ -1,49 +0,0 @@
249.4 -/*
249.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
249.6 - *
249.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
249.8 - *
249.9 - * The contents of this file are subject to the terms of either the GNU
249.10 - * General Public License Version 2 only ("GPL") or the Common
249.11 - * Development and Distribution License("CDDL") (collectively, the
249.12 - * "License"). You may not use this file except in compliance with the
249.13 - * License. You can obtain a copy of the License at
249.14 - * http://www.netbeans.org/cddl-gplv2.html
249.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
249.16 - * specific language governing permissions and limitations under the
249.17 - * License. When distributing the software, include this License Header
249.18 - * Notice in each file and include the License file at
249.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
249.20 - * particular file as subject to the "Classpath" exception as provided
249.21 - * by Sun in the GPL Version 2 section of the License file that
249.22 - * accompanied this code. If applicable, add the following below the
249.23 - * License Header, with the fields enclosed by brackets [] replaced by
249.24 - * your own identifying information:
249.25 - * "Portions Copyrighted [year] [name of copyright owner]"
249.26 - *
249.27 - * Contributor(s):
249.28 - *
249.29 - * Portions Copyrighted 2007 Sun Microsystems, Inc.
249.30 - */
249.31 -package org.netbeans.modules.csl.core;
249.32 -
249.33 -import javax.swing.Action;
249.34 -import javax.swing.text.BadLocationException;
249.35 -import javax.swing.text.JTextComponent;
249.36 -
249.37 -/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
249.38 -public class SelectNextCamelCasePosition extends NextCamelCasePosition {
249.39 - public static final String selectNextCamelCasePosition = "select-next-camel-case-position"; //NOI18N
249.40 -
249.41 - public SelectNextCamelCasePosition(Action originalAction) {
249.42 - this(selectNextCamelCasePosition, originalAction);
249.43 - }
249.44 -
249.45 - protected SelectNextCamelCasePosition(String name, Action originalAction) {
249.46 - super(name, originalAction);
249.47 - }
249.48 -
249.49 - protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
249.50 - textComponent.getCaret().moveDot(offset);
249.51 - }
249.52 -}
250.1 --- a/csl.api/src/org/netbeans/modules/csl/core/SelectPreviousCamelCasePosition.java Mon Feb 01 12:23:06 2010 +0100
250.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
250.3 @@ -1,62 +0,0 @@
250.4 -/*
250.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
250.6 - *
250.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
250.8 - *
250.9 - * The contents of this file are subject to the terms of either the GNU
250.10 - * General Public License Version 2 only ("GPL") or the Common
250.11 - * Development and Distribution License("CDDL") (collectively, the
250.12 - * "License"). You may not use this file except in compliance with the
250.13 - * License. You can obtain a copy of the License at
250.14 - * http://www.netbeans.org/cddl-gplv2.html
250.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
250.16 - * specific language governing permissions and limitations under the
250.17 - * License. When distributing the software, include this License Header
250.18 - * Notice in each file and include the License file at
250.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
250.20 - * particular file as subject to the "Classpath" exception as provided
250.21 - * by Sun in the GPL Version 2 section of the License file that
250.22 - * accompanied this code. If applicable, add the following below the
250.23 - * License Header, with the fields enclosed by brackets [] replaced by
250.24 - * your own identifying information:
250.25 - * "Portions Copyrighted [year] [name of copyright owner]"
250.26 - *
250.27 - * Contributor(s):
250.28 - *
250.29 - * The Original Software is NetBeans. The Initial Developer of the Original
250.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
250.31 - * Microsystems, Inc. All Rights Reserved.
250.32 - *
250.33 - * If you wish your version of this file to be governed by only the CDDL
250.34 - * or only the GPL Version 2, indicate your decision by adding
250.35 - * "[Contributor] elects to include this software in this distribution
250.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
250.37 - * single choice of license, a recipient has the option to distribute
250.38 - * your version of this file under either the CDDL, the GPL Version 2 or
250.39 - * to extend the choice of license to its licensees as provided above.
250.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
250.41 - * Version 2 license, then the option applies only if the new code is
250.42 - * made subject to such option by the copyright holder.
250.43 - */
250.44 -package org.netbeans.modules.csl.core;
250.45 -
250.46 -import javax.swing.Action;
250.47 -import javax.swing.text.BadLocationException;
250.48 -import javax.swing.text.JTextComponent;
250.49 -
250.50 -/** @author Sandip V. Chitale (Sandip.Chitale@Sun.Com) */
250.51 -public class SelectPreviousCamelCasePosition extends PreviousCamelCasePosition {
250.52 - public static final String selectPreviousCamelCasePosition = "select-previous-camel-case-position"; //NOI18N
250.53 -
250.54 - public SelectPreviousCamelCasePosition(Action originalAction) {
250.55 - this(selectPreviousCamelCasePosition, originalAction);
250.56 - }
250.57 -
250.58 - protected SelectPreviousCamelCasePosition(String name, Action originalAction) {
250.59 - super(name, originalAction);
250.60 - }
250.61 -
250.62 - protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
250.63 - textComponent.getCaret().moveDot(offset);
250.64 - }
250.65 -}
251.1 --- a/csl.api/src/org/netbeans/modules/csl/core/TypeAndSymbolProvider.java Mon Feb 01 12:23:06 2010 +0100
251.2 +++ b/csl.api/src/org/netbeans/modules/csl/core/TypeAndSymbolProvider.java Mon Feb 01 12:24:26 2010 +0100
251.3 @@ -47,6 +47,7 @@
251.4 import org.netbeans.api.project.Project;
251.5 import org.netbeans.modules.csl.api.ElementHandle;
251.6 import org.netbeans.modules.csl.api.IndexSearcher;
251.7 +import org.netbeans.modules.csl.api.UiUtils;
251.8 import org.netbeans.modules.csl.navigation.Icons;
251.9 import org.netbeans.modules.parsing.api.Source;
251.10 import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
252.1 --- a/csl.api/src/org/netbeans/modules/csl/core/UiUtils.java Mon Feb 01 12:23:06 2010 +0100
252.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
252.3 @@ -1,214 +0,0 @@
252.4 -/*
252.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
252.6 - *
252.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
252.8 - *
252.9 - * The contents of this file are subject to the terms of either the GNU
252.10 - * General Public License Version 2 only ("GPL") or the Common
252.11 - * Development and Distribution License("CDDL") (collectively, the
252.12 - * "License"). You may not use this file except in compliance with the
252.13 - * License. You can obtain a copy of the License at
252.14 - * http://www.netbeans.org/cddl-gplv2.html
252.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
252.16 - * specific language governing permissions and limitations under the
252.17 - * License. When distributing the software, include this License Header
252.18 - * Notice in each file and include the License file at
252.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
252.20 - * particular file as subject to the "Classpath" exception as provided
252.21 - * by Sun in the GPL Version 2 section of the License file that
252.22 - * accompanied this code. If applicable, add the following below the
252.23 - * License Header, with the fields enclosed by brackets [] replaced by
252.24 - * your own identifying information:
252.25 - * "Portions Copyrighted [year] [name of copyright owner]"
252.26 - *
252.27 - * Contributor(s):
252.28 - *
252.29 - * The Original Software is NetBeans. The Initial Developer of the Original
252.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
252.31 - * Microsystems, Inc. All Rights Reserved.
252.32 - *
252.33 - * If you wish your version of this file to be governed by only the CDDL
252.34 - * or only the GPL Version 2, indicate your decision by adding
252.35 - * "[Contributor] elects to include this software in this distribution
252.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
252.37 - * single choice of license, a recipient has the option to distribute
252.38 - * your version of this file under either the CDDL, the GPL Version 2 or
252.39 - * to extend the choice of license to its licensees as provided above.
252.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
252.41 - * Version 2 license, then the option applies only if the new code is
252.42 - * made subject to such option by the copyright holder.
252.43 - */
252.44 -package org.netbeans.modules.csl.core;
252.45 -
252.46 -import java.io.IOException;
252.47 -import java.util.Collection;
252.48 -import java.util.Collections;
252.49 -import java.util.concurrent.Future;
252.50 -import java.util.logging.Level;
252.51 -import java.util.logging.Logger;
252.52 -import javax.swing.ImageIcon;
252.53 -import javax.swing.SwingUtilities;
252.54 -import javax.swing.text.StyledDocument;
252.55 -import org.netbeans.modules.csl.api.DataLoadersBridge;
252.56 -import org.netbeans.modules.csl.api.DeclarationFinder.DeclarationLocation;
252.57 -import org.netbeans.modules.csl.api.ElementHandle;
252.58 -import org.netbeans.modules.csl.api.ElementKind;
252.59 -import org.netbeans.modules.csl.api.Modifier;
252.60 -import org.netbeans.modules.csl.api.OffsetRange;
252.61 -import org.netbeans.modules.csl.navigation.Icons;
252.62 -import org.netbeans.modules.csl.spi.ParserResult;
252.63 -import org.netbeans.modules.parsing.api.Embedding;
252.64 -import org.netbeans.modules.parsing.api.ParserManager;
252.65 -import org.netbeans.modules.parsing.api.ResultIterator;
252.66 -import org.netbeans.modules.parsing.api.Source;
252.67 -import org.netbeans.modules.parsing.api.UserTask;
252.68 -import org.netbeans.modules.parsing.spi.ParseException;
252.69 -import org.netbeans.modules.parsing.spi.Parser;
252.70 -import org.openide.cookies.EditorCookie;
252.71 -import org.openide.cookies.LineCookie;
252.72 -import org.openide.cookies.OpenCookie;
252.73 -import org.openide.filesystems.FileObject;
252.74 -import org.openide.text.Line;
252.75 -import org.openide.text.NbDocument;
252.76 -
252.77 -
252.78 -/**
252.79 - * This file is originally from Retouche, the Java Support
252.80 - * infrastructure in NetBeans. I have modified the file as little
252.81 - * as possible to make merging Retouche fixes back as simple as
252.82 - * possible.
252.83 - *
252.84 - * This class contains various methods bound to visualization of Java model
252.85 - * elements. It was formerly included under SourceUtils
252.86 - *
252.87 - * XXX - needs cleanup
252.88 - *
252.89 - * @author Jan Lahoda
252.90 - * @author Tor Norbye
252.91 - */
252.92 -public final class UiUtils {
252.93 -
252.94 - public static boolean open(Source source, ElementHandle handle) {
252.95 - assert source != null;
252.96 - assert handle != null; // Only one should be set
252.97 -
252.98 - DeclarationLocation location = getElementLocation(source, handle);
252.99 -
252.100 - if (location != DeclarationLocation.NONE) {
252.101 - return doOpen(location.getFileObject(), location.getOffset());
252.102 - }
252.103 -
252.104 - return false;
252.105 - }
252.106 -
252.107 - public static boolean open(final FileObject fo, final int offset) {
252.108 - assert fo != null;
252.109 -
252.110 - if (!SwingUtilities.isEventDispatchThread()) {
252.111 - SwingUtilities.invokeLater(new Runnable() {
252.112 - public void run() {
252.113 - doOpen(fo, offset);
252.114 - }
252.115 - });
252.116 - return true; // not exactly accurate, but....
252.117 - }
252.118 -
252.119 - return doOpen(fo, offset);
252.120 - }
252.121 -
252.122 - public static ImageIcon getElementIcon( ElementKind elementKind, Collection<Modifier> modifiers ) {
252.123 - return Icons.getElementIcon(elementKind, modifiers);
252.124 - }
252.125 -
252.126 - // Private methods ---------------------------------------------------------
252.127 -
252.128 - private static final Logger LOG = Logger.getLogger(UiUtils.class.getName());
252.129 -
252.130 - private UiUtils() {
252.131 - }
252.132 -
252.133 - private static boolean doOpen(FileObject fo, int offset) {
252.134 - try {
252.135 - EditorCookie ec = DataLoadersBridge.getDefault().getCookie(fo, EditorCookie.class);
252.136 - LineCookie lc = DataLoadersBridge.getDefault().getCookie(fo, LineCookie.class);
252.137 -
252.138 - if ((ec != null) && (lc != null) && (offset != -1)) {
252.139 - StyledDocument doc = ec.openDocument();
252.140 -
252.141 - if (doc != null) {
252.142 - int line = NbDocument.findLineNumber(doc, offset);
252.143 - int lineOffset = NbDocument.findLineOffset(doc, line);
252.144 - int column = offset - lineOffset;
252.145 -
252.146 - if (line != -1) {
252.147 - Line l = lc.getLineSet().getCurrent(line);
252.148 -
252.149 - if (l != null) {
252.150 - l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column);
252.151 - return true;
252.152 - }
252.153 - }
252.154 - }
252.155 - }
252.156 -
252.157 - OpenCookie oc = DataLoadersBridge.getDefault().getCookie(fo, OpenCookie.class);
252.158 -
252.159 - if (oc != null) {
252.160 - oc.open();
252.161 - return true;
252.162 - }
252.163 - } catch (IOException ioe) {
252.164 - LOG.log(Level.WARNING, null, ioe);
252.165 - }
252.166 -
252.167 - return false;
252.168 - }
252.169 -
252.170 - private static DeclarationLocation getElementLocation(Source source, final ElementHandle handle) {
252.171 - if (source.getFileObject() == null) {
252.172 - return DeclarationLocation.NONE;
252.173 - }
252.174 -
252.175 - FileObject fileObject = handle.getFileObject();
252.176 - if (fileObject != null && fileObject != source.getFileObject()) {
252.177 - // The element is not in the parse tree for this parse job; it is
252.178 - // probably something like an indexed element
252.179 - return new DeclarationLocation(fileObject, -1);
252.180 - }
252.181 -
252.182 - final DeclarationLocation[] result = new DeclarationLocation[] { null };
252.183 - try {
252.184 - Future<Void> f = ParserManager.parseWhenScanFinished(Collections.singleton(source), new UserTask() {
252.185 - public void run(ResultIterator resultIterator) throws ParseException {
252.186 - if (resultIterator.getSnapshot().getMimeType().equals(handle.getMimeType())) {
252.187 - Parser.Result r = resultIterator.getParserResult();
252.188 - if (r instanceof ParserResult) {
252.189 - ParserResult info = (ParserResult) r;
252.190 - OffsetRange range = handle.getOffsetRange(info);
252.191 - if (range != OffsetRange.NONE && range != null) {
252.192 - result[0] = new DeclarationLocation(info.getSnapshot().getSource().getFileObject(), range.getStart());
252.193 - return;
252.194 - }
252.195 - }
252.196 - }
252.197 -
252.198 - for(Embedding e : resultIterator.getEmbeddings()) {
252.199 - run(resultIterator.getResultIterator(e));
252.200 - if (result[0] != null) {
252.201 - break;
252.202 - }
252.203 - }
252.204 - }
252.205 - });
252.206 - //#169806: Do not block when parsing is in progress
252.207 - if (!f.isDone()) {
252.208 - f.cancel(true);
252.209 - return new DeclarationLocation(source.getFileObject(), -1);
252.210 - }
252.211 - } catch (ParseException e) {
252.212 - LOG.log(Level.WARNING, null, e);
252.213 - }
252.214 -
252.215 - return result[0] == null ? DeclarationLocation.NONE : result[0];
252.216 - }
252.217 -}
253.1 --- a/csl.api/src/org/netbeans/modules/csl/editor/InstantRenameAction.java Mon Feb 01 12:23:06 2010 +0100
253.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
253.3 @@ -1,210 +0,0 @@
253.4 -/*
253.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
253.6 - *
253.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
253.8 - *
253.9 - * The contents of this file are subject to the terms of either the GNU
253.10 - * General Public License Version 2 only ("GPL") or the Common
253.11 - * Development and Distribution License("CDDL") (collectively, the
253.12 - * "License"). You may not use this file except in compliance with the
253.13 - * License. You can obtain a copy of the License at
253.14 - * http://www.netbeans.org/cddl-gplv2.html
253.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
253.16 - * specific language governing permissions and limitations under the
253.17 - * License. When distributing the software, include this License Header
253.18 - * Notice in each file and include the License file at
253.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
253.20 - * particular file as subject to the "Classpath" exception as provided
253.21 - * by Sun in the GPL Version 2 section of the License file that
253.22 - * accompanied this code. If applicable, add the following below the
253.23 - * License Header, with the fields enclosed by brackets [] replaced by
253.24 - * your own identifying information:
253.25 - * "Portions Copyrighted [year] [name of copyright owner]"
253.26 - *
253.27 - * Contributor(s):
253.28 - *
253.29 - * The Original Software is NetBeans. The Initial Developer of the Original
253.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
253.31 - * Microsystems, Inc. All Rights Reserved.
253.32 - *
253.33 - * If you wish your version of this file to be governed by only the CDDL
253.34 - * or only the GPL Version 2, indicate your decision by adding
253.35 - * "[Contributor] elects to include this software in this distribution
253.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
253.37 - * single choice of license, a recipient has the option to distribute
253.38 - * your version of this file under either the CDDL, the GPL Version 2 or
253.39 - * to extend the choice of license to its licensees as provided above.
253.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
253.41 - * Version 2 license, then the option applies only if the new code is
253.42 - * made subject to such option by the copyright holder.
253.43 - */
253.44 -package org.netbeans.modules.csl.editor;
253.45 -
253.46 -import java.awt.event.ActionEvent;
253.47 -import java.io.IOException;
253.48 -import java.util.Collections;
253.49 -import java.util.List;
253.50 -import java.util.Set;
253.51 -import javax.swing.Action;
253.52 -
253.53 -import javax.swing.text.BadLocationException;
253.54 -import javax.swing.text.Document;
253.55 -import javax.swing.text.JTextComponent;
253.56 -
253.57 -import org.netbeans.modules.csl.api.InstantRenamer;
253.58 -import org.netbeans.modules.csl.api.OffsetRange;
253.59 -import org.netbeans.modules.parsing.api.Source;
253.60 -import org.netbeans.modules.parsing.api.UserTask;
253.61 -import org.netbeans.modules.parsing.spi.ParseException;
253.62 -import org.netbeans.editor.BaseAction;
253.63 -import org.netbeans.editor.BaseDocument;
253.64 -import org.netbeans.editor.Utilities;
253.65 -import org.netbeans.modules.csl.core.Language;
253.66 -import org.netbeans.modules.csl.core.LanguageRegistry;
253.67 -import org.netbeans.modules.csl.api.DataLoadersBridge;
253.68 -import org.netbeans.modules.csl.spi.ParserResult;
253.69 -import org.netbeans.modules.parsing.api.ParserManager;
253.70 -import org.netbeans.modules.parsing.api.ResultIterator;
253.71 -import org.netbeans.modules.parsing.api.indexing.IndexingManager;
253.72 -import org.netbeans.modules.parsing.spi.Parser;
253.73 -import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory;
253.74 -import org.openide.ErrorManager;
253.75 -import org.openide.cookies.EditorCookie;
253.76 -import org.openide.nodes.Node;
253.77 -import org.openide.util.Lookup;
253.78 -import org.openide.util.NbBundle;
253.79 -import org.openide.util.lookup.AbstractLookup;
253.80 -import org.openide.util.lookup.InstanceContent;
253.81 -
253.82 -
253.83 -/**
253.84 - * This file is originally from Retouche, the Java Support
253.85 - * infrastructure in NetBeans. I have modified the file as little
253.86 - * as possible to make merging Retouche fixes back as simple as
253.87 - * possible.
253.88 - *
253.89 - *
253.90 - * @author Jan Lahoda
253.91 - * @author Tor Norbye
253.92 - */
253.93 -public class InstantRenameAction extends BaseAction {
253.94 - /** Creates a new instance of InstantRenameAction */
253.95 - public InstantRenameAction() {
253.96 - super("in-place-refactoring", MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
253.97 - }
253.98 -
253.99 - public void actionPerformed(ActionEvent evt, final JTextComponent target) {
253.100 - try {
253.101 - final int caret = target.getCaretPosition();
253.102 - String ident = Utilities.getIdentifier(Utilities.getDocument(target), caret);
253.103 -
253.104 - if (ident == null) {
253.105 - Utilities.setStatusBoldText(target, NbBundle.getMessage(InstantRenameAction.class, "InstantRenameDenied"));
253.106 - return;
253.107 - }
253.108 -
253.109 - if (IndexingManager.getDefault().isIndexing()) {
253.110 - Utilities.setStatusBoldText(target, NbBundle.getMessage(InstantRenameAction.class, "scanning-in-progress"));
253.111 - return;
253.112 - }
253.113 -
253.114 - Source js = Source.create (DataLoadersBridge.getDefault().getFileObject(target));
253.115 - if (js == null) {
253.116 - return;
253.117 - }
253.118 -
253.119 - final boolean[] wasResolved = new boolean[1];
253.120 - final String[] message = new String[1];
253.121 - final Set<OffsetRange>[] changePoints = new Set[1];
253.122 -
253.123 - ParserManager.parse (
253.124 - Collections.<Source> singleton (js),
253.125 - new UserTask () {
253.126 - public void run (ResultIterator resultIterator) throws Exception {
253.127 - Parser.Result result = resultIterator.getParserResult (target.getCaretPosition ());
253.128 - if(!(result instanceof ParserResult)) {
253.129 - return ;
253.130 - }
253.131 - ParserResult parserResult = (ParserResult)result;
253.132 - Document doc = target.getDocument();
253.133 - BaseDocument baseDoc = (BaseDocument)doc;
253.134 - List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, caret);
253.135 - Language language = null;
253.136 - for (Language l : list) {
253.137 - if (l.getInstantRenamer() != null) {
253.138 - language = l;
253.139 - break;
253.140 - }
253.141 - }
253.142 -
253.143 - if (language != null) {
253.144 - InstantRenamer renamer = language.getInstantRenamer();
253.145 - assert renamer != null;
253.146 -
253.147 - String[] descRetValue = new String[1];
253.148 -
253.149 - if ((renamer == null) ||
253.150 - !renamer.isRenameAllowed(parserResult, caret, descRetValue)) {
253.151 - wasResolved[0] = false;
253.152 - message[0] = descRetValue[0];
253.153 -
253.154 - return;
253.155 - }
253.156 -
253.157 - wasResolved[0] = true;
253.158 -
253.159 - Set<OffsetRange> regions = renamer.getRenameRegions(parserResult, caret);
253.160 -
253.161 - if ((regions != null) && (regions.size() > 0)) {
253.162 - changePoints[0] = regions;
253.163 - }
253.164 - }
253.165 - }
253.166 - }
253.167 - );
253.168 -
253.169 - if (wasResolved[0]) {
253.170 - if (changePoints[0] != null) {
253.171 - doInstantRename(changePoints[0], target, caret, ident);
253.172 - } else {
253.173 - doFullRename((EditorCookie)DataLoadersBridge.getDefault().getCookie(target,EditorCookie.class), DataLoadersBridge.getDefault().getNodeDelegate(target));
253.174 - }
253.175 - } else {
253.176 - if (message[0] == null) {
253.177 - message[0] = NbBundle.getMessage(InstantRenameAction.class,
253.178 - "InstantRenameDenied");
253.179 - }
253.180 -
253.181 - Utilities.setStatusBoldText(target, message[0]);
253.182 - }
253.183 - } catch (BadLocationException e) {
253.184 - ErrorManager.getDefault().notify(e);
253.185 - } catch (IOException ioe) {
253.186 - ErrorManager.getDefault().notify(ioe);
253.187 - } catch (ParseException ioe) {
253.188 - ErrorManager.getDefault().notify(ioe);
253.189 - }
253.190 - }
253.191 -
253.192 - @Override
253.193 - protected Class getShortDescriptionBundleClass() {
253.194 - return InstantRenameAction.class;
253.195 - }
253.196 -
253.197 - private void doInstantRename(Set<OffsetRange> changePoints, JTextComponent target, int caret,
253.198 - String ident) throws BadLocationException {
253.199 - InstantRenamePerformer.performInstantRename(target, changePoints, caret);
253.200 - }
253.201 -
253.202 - private void doFullRename(EditorCookie ec, Node n) {
253.203 - InstanceContent ic = new InstanceContent();
253.204 - ic.add(ec);
253.205 - ic.add(n);
253.206 -
253.207 - Lookup actionContext = new AbstractLookup(ic);
253.208 -
253.209 - Action a =
253.210 - RefactoringActionsFactory.renameAction().createContextAwareInstance(actionContext);
253.211 - a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
253.212 - }
253.213 -}
254.1 --- a/csl.api/src/org/netbeans/modules/csl/editor/ToggleBlockCommentAction.java Mon Feb 01 12:23:06 2010 +0100
254.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
254.3 @@ -1,304 +0,0 @@
254.4 -/*
254.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
254.6 - *
254.7 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
254.8 - *
254.9 - * The contents of this file are subject to the terms of either the GNU
254.10 - * General Public License Version 2 only ("GPL") or the Common
254.11 - * Development and Distribution License("CDDL") (collectively, the
254.12 - * "License"). You may not use this file except in compliance with the
254.13 - * License. You can obtain a copy of the License at
254.14 - * http://www.netbeans.org/cddl-gplv2.html
254.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
254.16 - * specific language governing permissions and limitations under the
254.17 - * License. When distributing the software, include this License Header
254.18 - * Notice in each file and include the License file at
254.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
254.20 - * particular file as subject to the "Classpath" exception as provided
254.21 - * by Sun in the GPL Version 2 section of the License file that
254.22 - * accompanied this code. If applicable, add the following below the
254.23 - * License Header, with the fields enclosed by brackets [] replaced by
254.24 - * your own identifying information:
254.25 - * "Portions Copyrighted [year] [name of copyright owner]"
254.26 - *
254.27 - * If you wish your version of this file to be governed by only the CDDL
254.28 - * or only the GPL Version 2, indicate your decision by adding
254.29 - * "[Contributor] elects to include this software in this distribution
254.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
254.31 - * single choice of license, a recipient has the option to distribute
254.32 - * your version of this file under either the CDDL, the GPL Version 2 or
254.33 - * to extend the choice of license to its licensees as provided above.
254.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
254.35 - * Version 2 license, then the option applies only if the new code is
254.36 - * made subject to such option by the copyright holder.
254.37 - *
254.38 - * Contributor(s):
254.39 - *
254.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
254.41 - */
254.42 -package org.netbeans.modules.csl.editor;
254.43 -
254.44 -import java.awt.event.ActionEvent;
254.45 -import javax.swing.text.BadLocationException;
254.46 -import javax.swing.text.Caret;
254.47 -import javax.swing.text.Document;
254.48 -import javax.swing.text.JTextComponent;
254.49 -import org.netbeans.editor.BaseDocument;
254.50 -import org.netbeans.editor.Utilities;
254.51 -import org.netbeans.editor.ext.ExtKit;
254.52 -import org.netbeans.lib.editor.util.CharSequenceUtilities;
254.53 -import org.netbeans.lib.editor.util.swing.DocumentUtilities;
254.54 -import org.netbeans.modules.csl.spi.CommentHandler;
254.55 -import org.openide.util.Exceptions;
254.56 -
254.57 -public class ToggleBlockCommentAction extends ExtKit.ToggleCommentAction {
254.58 -
254.59 - static final long serialVersionUID = -1L;
254.60 - private final CommentHandler commentHandler;
254.61 - private final int COMMENT_START_LENGTH;
254.62 - private final int COMMENT_END_LENGTH;
254.63 -
254.64 - public ToggleBlockCommentAction(CommentHandler commentHandler) {
254.65 - super("");
254.66 - this.COMMENT_START_LENGTH = commentHandler.getCommentStartDelimiter().length();
254.67 - this.COMMENT_END_LENGTH = commentHandler.getCommentEndDelimiter().length();
254.68 - this.commentHandler = commentHandler;
254.69 - }
254.70 -
254.71 - @Override
254.72 - public void actionPerformed(ActionEvent evt, final JTextComponent target) {
254.73 - if (target != null) {
254.74 - if (!target.isEditable() || !target.isEnabled()) {
254.75 - target.getToolkit().beep();
254.76 - return;
254.77 - }
254.78 -
254.79 - final Caret caret = target.getCaret();
254.80 - final BaseDocument doc = (BaseDocument) target.getDocument();
254.81 -
254.82 - int from = Utilities.isSelectionShowing(caret) ? target.getSelectionStart() : caret.getDot();
254.83 - int to = Utilities.isSelectionShowing(caret) ? target.getSelectionEnd() : caret.getDot();
254.84 -
254.85 - boolean lineSelection = false;
254.86 - boolean inComment = isInComment(doc, from);
254.87 - if (from == to) {
254.88 - //no selection
254.89 - if (!inComment) {
254.90 - try {
254.91 - //check for commenting empty line
254.92 - if (Utilities.isRowEmpty(doc, from) || Utilities.isRowWhite(doc, from)) {
254.93 - return;
254.94 - }
254.95 -
254.96 - //extend the range to the whole line
254.97 - from = Utilities.getFirstNonWhiteFwd(doc, Utilities.getRowStart(doc, from));
254.98 - to = Utilities.getFirstNonWhiteBwd(doc, Utilities.getRowEnd(doc, to)) + 1;
254.99 - lineSelection = true;
254.100 - } catch (BadLocationException ex) {
254.101 - Exceptions.printStackTrace(ex);
254.102 - }
254.103 - }
254.104 - }
254.105 -
254.106 - if(!inComment && from == to) {
254.107 - return ; //no-op
254.108 - }
254.109 -
254.110 - int[] adjustedRange = commentHandler.getAdjustedBlocks(doc, from, to);
254.111 - if(adjustedRange.length == 0) {
254.112 - return; //no-op
254.113 - }
254.114 -
254.115 - from = adjustedRange[0];
254.116 - to = adjustedRange[1];
254.117 -
254.118 - if(!inComment && from == to) {
254.119 - return ; //no-op
254.120 - }
254.121 -
254.122 - final int comments[] = commentHandler.getCommentBlocks(doc, from, to);
254.123 -
254.124 - assert comments != null;
254.125 -
254.126 -// debug(doc, comments, from, to);
254.127 -
254.128 - check(comments, from, to);
254.129 -
254.130 - final int _from = from;
254.131 - final int _to = to;
254.132 - final boolean _lineSelection = lineSelection;
254.133 -
254.134 - doc.runAtomic(new Runnable() {
254.135 -
254.136 - public void run() {
254.137 - try {
254.138 - int[] commentRange = getCommentRange(comments, _from);
254.139 - if (commentRange == null) {
254.140 - //comment
254.141 - comment(target, doc, comments, _from, _to, _lineSelection);
254.142 - } else if (comments.length > 0) {
254.143 - //uncomment
254.144 - uncomment(target, doc, comments, _from, _to, _lineSelection);
254.145 - }
254.146 - } catch (BadLocationException e) {
254.147 - Exceptions.printStackTrace(e);
254.148 - }
254.149 - }
254.150 - });
254.151 -
254.152 -
254.153 - }
254.154 -
254.155 - }
254.156 -
254.157 - private void comment(JTextComponent target, BaseDocument doc, int[] comments, int from, int to, boolean lineSelection) throws BadLocationException {
254.158 -// System.out.println("comment");
254.159 -
254.160 - int diff = 0;
254.161 -
254.162 - //put the comment start
254.163 - diff += insert(doc, from, commentHandler.getCommentStartDelimiter());
254.164 -
254.165 - for (int i = 0; i < comments.length; i += 2) {
254.166 - int commentStart = comments[i];
254.167 - int commentEnd = comments[i + 1];
254.168 -
254.169 - diff += remove(doc, commentStart + diff, COMMENT_START_LENGTH);
254.170 -
254.171 - if (commentEnd <= to) {
254.172 - diff += remove(doc, commentEnd + diff - COMMENT_END_LENGTH, COMMENT_END_LENGTH);
254.173 - }
254.174 -
254.175 - }
254.176 -
254.177 - //add closing comment if the last comment doesn't contain the 'to' offset
254.178 - if (comments.length == 0 || comments[comments.length - 1] <= to) {
254.179 - diff += insert(doc, to + diff, commentHandler.getCommentEndDelimiter());
254.180 - }
254.181 -
254.182 - if (!lineSelection) {
254.183 - //update the selection range, we always add the starting delimiter out of the selection
254.184 - target.setSelectionStart(from);
254.185 - target.setSelectionEnd(to + diff);
254.186 - }
254.187 -
254.188 - }
254.189 -
254.190 - private void uncomment(JTextComponent target, BaseDocument doc, int[] comments, int from, int to, boolean lineSelection) throws BadLocationException {
254.191 -// System.out.println("uncomment");
254.192 -
254.193 - int diff = 0;
254.194 -
254.195 - //no selection handling
254.196 - if (from == to) {
254.197 - //extend the range to the only possible comment
254.198 - assert comments.length == 2;
254.199 -
254.200 - from = comments[0];
254.201 - to = comments[1];
254.202 -
254.203 - lineSelection = true;
254.204 - }
254.205 -
254.206 - if (comments[0] < from) {
254.207 - //we need to end the existing comment
254.208 - diff += insert(doc, from, commentHandler.getCommentEndDelimiter());
254.209 - }
254.210 -
254.211 - int selectionStart = from + diff;
254.212 -
254.213 - for (int i = 0; i < comments.length; i += 2) {
254.214 - int commentStart = comments[i];
254.215 - int commentEnd = comments[i + 1];
254.216 -
254.217 - if (commentStart >= from) {
254.218 - diff += remove(doc, commentStart + diff, COMMENT_START_LENGTH);
254.219 - }
254.220 -
254.221 - if (commentEnd <= to) {
254.222 - diff += remove(doc, commentEnd + diff - COMMENT_END_LENGTH, COMMENT_END_LENGTH);
254.223 - }
254.224 -
254.225 - }
254.226 -
254.227 - int selectionEnd = to + diff;
254.228 - //add opening comment if the last comment doesn't contain the 'to' offset
254.229 - if (comments[comments.length - 1] > to) {
254.230 - diff += insert(doc, to + diff, commentHandler.getCommentStartDelimiter());
254.231 - }
254.232 -
254.233 - if (!lineSelection) {
254.234 - //update the selection range, we always add the starting delimiter out of the selection
254.235 - target.setSelectionStart(selectionStart);
254.236 - target.setSelectionEnd(selectionEnd);
254.237 - }
254.238 -
254.239 - }
254.240 -
254.241 - private int insert(Document doc, int offset, String text) throws BadLocationException {
254.242 - doc.insertString(offset, text, null);
254.243 - return text.length();
254.244 - }
254.245 -
254.246 - private int remove(Document doc, int offset, int length) throws BadLocationException {
254.247 - doc.remove(offset, length);
254.248 - return -length;
254.249 - }
254.250 -
254.251 - private int[] getCommentRange(int[] comments, int offset) {
254.252 - //linear search
254.253 - for (int i = 0; i < comments.length; i++) {
254.254 - int from = comments[i];
254.255 - int to = comments[++i];
254.256 -
254.257 - if (from <= offset && to > offset) { //end offset exclusive
254.258 - return new int[]{from, to};
254.259 - }
254.260 - }
254.261 -
254.262 - return null; //not comment offset
254.263 -
254.264 - }
254.265 -
254.266 - private boolean isInComment(Document doc, int offset) {
254.267 - CharSequence text = DocumentUtilities.getText(doc); //shared instance, low cost
254.268 - int lastCommentStartIndex = CharSequenceUtilities.lastIndexOf(text, commentHandler.getCommentStartDelimiter(), offset);
254.269 - int lastCommentEndIndex = CharSequenceUtilities.lastIndexOf(text, commentHandler.getCommentEndDelimiter(), offset);
254.270 -
254.271 - return lastCommentStartIndex > -1 && (lastCommentStartIndex > lastCommentEndIndex || lastCommentEndIndex == -1);
254.272 -
254.273 - }
254.274 -
254.275 - private void debug(Document doc, int[] comments, int start, int end) {
254.276 - System.out.println("TOGGLE_COMENT [" + start + "-" + end + "]");
254.277 - for (int i = 0; i < comments.length; i++) {
254.278 - try {
254.279 - int from = comments[i];
254.280 - int to = comments[++i];
254.281 - if (from <= start && to > end) {
254.282 - System.out.print("*");
254.283 - }
254.284 - System.out.print("[" + from + " - " + to + "]");
254.285 - System.out.println(doc.getText(from, to - from));
254.286 - } catch (BadLocationException ex) {
254.287 - Exceptions.printStackTrace(ex);
254.288 - }
254.289 - }
254.290 - System.out.println("----------------");
254.291 - }
254.292 -
254.293 - private void check(int[] comments, int from, int to) {
254.294 - if (comments.length % 2 != 0) {
254.295 - throw new IllegalArgumentException("Comments array size must be even, e.g. contain just pairs.");
254.296 - }
254.297 -
254.298 - for (int i = 0; i < comments.length; i++) {
254.299 - int cfrom = comments[i];
254.300 - int cto = comments[++i];
254.301 - if (cfrom < from && cto < from || cto > to && cfrom > to) {
254.302 - throw new IllegalArgumentException("Comment [" + cfrom + " - " + cto + " is out of the range [" + from + " - " + to + "]!");
254.303 - }
254.304 - }
254.305 - }
254.306 -}
254.307 -
255.1 --- a/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionDoc.java Mon Feb 01 12:23:06 2010 +0100
255.2 +++ b/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionDoc.java Mon Feb 01 12:24:26 2010 +0100
255.3 @@ -52,10 +52,10 @@
255.4 import org.netbeans.api.editor.completion.Completion;
255.5 import org.netbeans.modules.csl.api.CodeCompletionHandler;
255.6 import org.netbeans.modules.csl.api.ElementHandle;
255.7 +import org.netbeans.modules.csl.api.UiUtils;
255.8 import org.netbeans.modules.csl.core.LanguageRegistry;
255.9 import org.netbeans.modules.csl.spi.ParserResult;
255.10 import org.netbeans.modules.csl.core.Language;
255.11 -import org.netbeans.modules.csl.core.UiUtils;
255.12 import org.netbeans.spi.editor.completion.CompletionDocumentation;
255.13 import org.openide.awt.HtmlBrowser;
255.14 import org.openide.util.Exceptions;
256.1 --- a/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/DeclarationPopup.java Mon Feb 01 12:23:06 2010 +0100
256.2 +++ b/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/DeclarationPopup.java Mon Feb 01 12:24:26 2010 +0100
256.3 @@ -57,8 +57,8 @@
256.4 import org.netbeans.modules.csl.api.DeclarationFinder.AlternativeLocation;
256.5 import org.netbeans.modules.csl.api.DeclarationFinder.DeclarationLocation;
256.6 import org.netbeans.modules.csl.api.ElementHandle;
256.7 +import org.netbeans.modules.csl.api.UiUtils;
256.8 import org.netbeans.modules.csl.core.GsfHtmlFormatter;
256.9 -import org.netbeans.modules.csl.core.UiUtils;
256.10 import org.netbeans.modules.csl.navigation.Icons;
256.11 import org.openide.awt.StatusDisplayer;
256.12 import org.openide.filesystems.FileObject;
257.1 --- a/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/GoToSupport.java Mon Feb 01 12:23:06 2010 +0100
257.2 +++ b/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/GoToSupport.java Mon Feb 01 12:24:26 2010 +0100
257.3 @@ -64,10 +64,10 @@
257.4 import org.netbeans.modules.csl.api.OffsetRange;
257.5 import org.netbeans.modules.csl.api.CodeCompletionHandler;
257.6 import org.netbeans.modules.csl.api.ElementHandle;
257.7 +import org.netbeans.modules.csl.api.UiUtils;
257.8 import org.netbeans.modules.csl.core.GsfHtmlFormatter;
257.9 import org.netbeans.modules.csl.core.Language;
257.10 import org.netbeans.modules.csl.core.LanguageRegistry;
257.11 -import org.netbeans.modules.csl.core.UiUtils;
257.12 import org.netbeans.modules.csl.spi.ParserResult;
257.13 import org.netbeans.modules.parsing.api.ParserManager;
257.14 import org.netbeans.modules.parsing.api.ResultIterator;
258.1 --- a/csl.api/src/org/netbeans/modules/csl/navigation/actions/OpenAction.java Mon Feb 01 12:23:06 2010 +0100
258.2 +++ b/csl.api/src/org/netbeans/modules/csl/navigation/actions/OpenAction.java Mon Feb 01 12:24:26 2010 +0100
258.3 @@ -47,7 +47,7 @@
258.4 import java.awt.event.*;
258.5 import org.netbeans.modules.csl.api.DataLoadersBridge;
258.6 import org.netbeans.modules.csl.api.ElementHandle;
258.7 -import org.netbeans.modules.csl.core.UiUtils;
258.8 +import org.netbeans.modules.csl.api.UiUtils;
258.9 import org.netbeans.modules.parsing.api.Source;
258.10
258.11 /**
259.1 --- a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java Mon Feb 01 12:23:06 2010 +0100
259.2 +++ b/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java Mon Feb 01 12:24:26 2010 +0100
259.3 @@ -160,7 +160,7 @@
259.4 import org.netbeans.modules.csl.api.OffsetRange;
259.5 import org.netbeans.modules.csl.api.PreviewableFix;
259.6 import org.netbeans.modules.csl.api.Severity;
259.7 -import org.netbeans.modules.csl.core.GsfEditorKitFactory;
259.8 +import org.netbeans.modules.csl.core.CslEditorKit;
259.9 import org.netbeans.modules.csl.core.GsfIndentTaskFactory;
259.10 import org.netbeans.modules.csl.core.GsfReformatTaskFactory;
259.11 import org.netbeans.modules.csl.core.LanguageRegistry;
259.12 @@ -2068,8 +2068,7 @@
259.13 org.netbeans.modules.csl.core.Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
259.14 assertNotNull(language);
259.15 if (!language.useCustomEditorKit()) {
259.16 - GsfEditorKitFactory factory = new GsfEditorKitFactory(language);
259.17 - return factory.kit();
259.18 + return new CslEditorKit(mimeType);
259.19 }
259.20 fail("Must override getEditorKit() for useCustomEditorKit languages");
259.21 return null;
259.22 @@ -3993,6 +3992,49 @@
259.23 assertDescriptionMatches(relFilePath, fixed, true, ".fixed");
259.24 }
259.25
259.26 + @SuppressWarnings("unchecked")
259.27 + protected final void ensureRegistered(AstRule hint) throws Exception {
259.28 + org.netbeans.modules.csl.core.Language language = LanguageRegistry.getInstance().getLanguageByMimeType(getPreferredMimeType());
259.29 + assertNotNull(language.getHintsProvider());
259.30 + GsfHintsManager hintsManager = language.getHintsManager();
259.31 + Map<?, List<? extends AstRule>> hints = (Map<?, List<? extends AstRule>>)hintsManager.getHints();
259.32 + Set<?> kinds = hint.getKinds();
259.33 + for (Object nodeType : kinds) {
259.34 + List<? extends AstRule> rules = hints.get(nodeType);
259.35 + assertNotNull(rules);
259.36 + boolean found = false;
259.37 + for (AstRule rule : rules) {
259.38 + if (rule.getClass() == hint.getClass()) {
259.39 + found = true;
259.40 + break;
259.41 + }
259.42 + }
259.43 +
259.44 + assertTrue(found);
259.45 + }
259.46 + }
259.47 +
259.48 + @SuppressWarnings("unchecked")
259.49 + protected final void ensureRegistered(ErrorRule hint) throws Exception {
259.50 + org.netbeans.modules.csl.core.Language language = LanguageRegistry.getInstance().getLanguageByMimeType(getPreferredMimeType());
259.51 + assertNotNull(language.getHintsProvider());
259.52 + GsfHintsManager hintsManager = language.getHintsManager();
259.53 + Map<?, List<? extends ErrorRule>> hints = (Map<?, List<? extends ErrorRule>>)hintsManager.getErrors();
259.54 + Set<?> kinds = hint.getCodes();
259.55 + for (Object codes : kinds) {
259.56 + List<? extends ErrorRule> rules = hints.get(codes);
259.57 + assertNotNull(rules);
259.58 + boolean found = false;
259.59 + for (ErrorRule rule : rules) {
259.60 + if (rule.getClass() == hint.getClass()) {
259.61 + found = true;
259.62 + break;
259.63 + }
259.64 + }
259.65 +
259.66 + assertTrue(found);
259.67 + }
259.68 + }
259.69 // public void ensureRegistered(AstRule hint) throws Exception {
259.70 // Map<Integer, List<AstRule>> hints = JsRulesManager.getInstance().getHints();
259.71 // Set<Integer> kinds = hint.getKinds();
260.1 --- a/css.editor/manifest.mf Mon Feb 01 12:23:06 2010 +0100
260.2 +++ b/css.editor/manifest.mf Mon Feb 01 12:24:26 2010 +0100
260.3 @@ -2,5 +2,5 @@
260.4 OpenIDE-Module: org.netbeans.modules.css.editor/1
260.5 OpenIDE-Module-Layer: org/netbeans/modules/css/resources/layer.xml
260.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/css/resources/Bundle.properties
260.7 -OpenIDE-Module-Specification-Version: 1.9
260.8 +OpenIDE-Module-Specification-Version: 1.10
260.9 AutoUpdate-Show-In-Client: false
261.1 --- a/css.editor/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
261.2 +++ b/css.editor/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
261.3 @@ -19,8 +19,8 @@
261.4 <build-prerequisite/>
261.5 <compile-dependency/>
261.6 <run-dependency>
261.7 - <release-version>1</release-version>
261.8 - <specification-version>1.19</specification-version>
261.9 + <release-version>2</release-version>
261.10 + <specification-version>2.1</specification-version>
261.11 </run-dependency>
261.12 </dependency>
261.13 <dependency>
262.1 --- a/css.editor/src/org/netbeans/modules/css/editor/Css.java Mon Feb 01 12:23:06 2010 +0100
262.2 +++ b/css.editor/src/org/netbeans/modules/css/editor/Css.java Mon Feb 01 12:24:26 2010 +0100
262.3 @@ -91,5 +91,5 @@
262.4 }
262.5 return null;
262.6 }
262.7 -
262.8 +
262.9 }
263.1 --- a/css.editor/src/org/netbeans/modules/css/editor/CssProjectSupport.java Mon Feb 01 12:23:06 2010 +0100
263.2 +++ b/css.editor/src/org/netbeans/modules/css/editor/CssProjectSupport.java Mon Feb 01 12:24:26 2010 +0100
263.3 @@ -77,7 +77,7 @@
263.4 if (p == null) {
263.5 return null;
263.6 }
263.7 - ClassPath classPath = ClassPath.getClassPath(p.getProjectDirectory(), ClassPath.SOURCE);
263.8 + ClassPath classPath = ClassPath.getClassPath(fo, ClassPath.SOURCE);
263.9 if (classPath == null) {
263.10 return null;
263.11 }
263.12 @@ -86,8 +86,8 @@
263.13 if (instance == null) {
263.14 instance = new CssProjectSupport(p, classPath);
263.15 INSTANCIES.put(p, instance);
263.16 - return instance;
263.17 }
263.18 + return instance;
263.19 }
263.20 } catch (IOException ex) {
263.21 Exceptions.printStackTrace(ex);
264.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
264.2 +++ b/css.editor/src/org/netbeans/modules/css/indexing/CssFileModel.java Mon Feb 01 12:24:26 2010 +0100
264.3 @@ -0,0 +1,286 @@
264.4 +/*
264.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
264.6 + *
264.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
264.8 + *
264.9 + * The contents of this file are subject to the terms of either the GNU
264.10 + * General Public License Version 2 only ("GPL") or the Common
264.11 + * Development and Distribution License("CDDL") (collectively, the
264.12 + * "License"). You may not use this file except in compliance with the
264.13 + * License. You can obtain a copy of the License at
264.14 + * http://www.netbeans.org/cddl-gplv2.html
264.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
264.16 + * specific language governing permissions and limitations under the
264.17 + * License. When distributing the software, include this License Header
264.18 + * Notice in each file and include the License file at
264.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
264.20 + * particular file as subject to the "Classpath" exception as provided
264.21 + * by Sun in the GPL Version 2 section of the License file that
264.22 + * accompanied this code. If applicable, add the following below the
264.23 + * License Header, with the fields enclosed by brackets [] replaced by
264.24 + * your own identifying information:
264.25 + * "Portions Copyrighted [year] [name of copyright owner]"
264.26 + *
264.27 + * If you wish your version of this file to be governed by only the CDDL
264.28 + * or only the GPL Version 2, indicate your decision by adding
264.29 + * "[Contributor] elects to include this software in this distribution
264.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
264.31 + * single choice of license, a recipient has the option to distribute
264.32 + * your version of this file under either the CDDL, the GPL Version 2 or
264.33 + * to extend the choice of license to its licensees as provided above.
264.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
264.35 + * Version 2 license, then the option applies only if the new code is
264.36 + * made subject to such option by the copyright holder.
264.37 + *
264.38 + * Contributor(s):
264.39 + *
264.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
264.41 + */
264.42 +package org.netbeans.modules.css.indexing;
264.43 +
264.44 +import java.util.ArrayList;
264.45 +import java.util.Collection;
264.46 +import java.util.Collections;
264.47 +import java.util.logging.Level;
264.48 +import java.util.logging.Logger;
264.49 +import java.util.regex.Matcher;
264.50 +import java.util.regex.Pattern;
264.51 +import org.netbeans.modules.csl.api.OffsetRange;
264.52 +import org.netbeans.modules.css.editor.Css;
264.53 +import org.netbeans.modules.css.gsf.api.CssParserResult;
264.54 +import org.netbeans.modules.css.parser.CssParserConstants;
264.55 +import org.netbeans.modules.css.parser.CssParserTreeConstants;
264.56 +import org.netbeans.modules.css.parser.NodeVisitor;
264.57 +import org.netbeans.modules.css.parser.SimpleNode;
264.58 +import org.netbeans.modules.css.parser.SimpleNodeUtil;
264.59 +import org.netbeans.modules.css.parser.Token;
264.60 +import org.netbeans.modules.parsing.api.ParserManager;
264.61 +import org.netbeans.modules.parsing.api.ResultIterator;
264.62 +import org.netbeans.modules.parsing.api.Snapshot;
264.63 +import org.netbeans.modules.parsing.api.Source;
264.64 +import org.netbeans.modules.parsing.api.UserTask;
264.65 +import org.netbeans.modules.parsing.spi.ParseException;
264.66 +import org.openide.filesystems.FileObject;
264.67 +
264.68 +/**
264.69 + *
264.70 + * @author marekfukala
264.71 + */
264.72 +public class CssFileModel {
264.73 +
264.74 + private static final Logger LOGGER = Logger.getLogger(CssIndex.class.getSimpleName());
264.75 + private static final boolean LOG = LOGGER.isLoggable(Level.FINE);
264.76 +
264.77 + private static final Pattern URI_PATTERN = Pattern.compile("url\\(\\s*(.*)\\s*\\)");
264.78 +
264.79 + private Collection<Entry> classes, ids, htmlElements, imports;
264.80 + private boolean isParserBased;
264.81 + private FileObject fileObject;
264.82 + private Snapshot snapshot;
264.83 +
264.84 + public CssFileModel(Source source) throws ParseException {
264.85 + this.fileObject = source.getFileObject();
264.86 + isParserBased = true;
264.87 + ParserManager.parse(Collections.singletonList(source), new UserTask() {
264.88 + @Override
264.89 + public void run(ResultIterator resultIterator) throws Exception {
264.90 + ResultIterator cssRi = Css.getResultIterator(resultIterator, Css.CSS_MIME_TYPE);
264.91 + if(cssRi != null) {
264.92 + snapshot = cssRi.getSnapshot();
264.93 + init((CssParserResult)cssRi.getParserResult());
264.94 + }
264.95 + }
264.96 + });
264.97 + }
264.98 +
264.99 + public CssFileModel(CssParserResult parserResult) {
264.100 + fileObject = parserResult.getSnapshot().getSource().getFileObject();
264.101 + snapshot = parserResult.getSnapshot();
264.102 + isParserBased = true;
264.103 + init(parserResult);
264.104 + }
264.105 +
264.106 + public boolean isParserBased() {
264.107 + return isParserBased;
264.108 + }
264.109 +
264.110 + public Collection<Entry> getClasses() {
264.111 + return classes == null ? Collections.<Entry>emptyList() : classes;
264.112 + }
264.113 +
264.114 + public Collection<Entry> getIds() {
264.115 + return ids == null ? Collections.<Entry>emptyList() : ids;
264.116 + }
264.117 +
264.118 + public Collection<Entry> getHtmlElements() {
264.119 + return htmlElements == null ? Collections.<Entry>emptyList() : htmlElements;
264.120 + }
264.121 +
264.122 + public Collection<Entry> getImports() {
264.123 + return imports == null ? Collections.<Entry>emptyList() : imports;
264.124 + }
264.125 +
264.126 + /**
264.127 + *
264.128 + * @return true if the model is empty - nothing interesting found in the page.
264.129 + */
264.130 + public boolean isEmpty() {
264.131 + return null == classes && null == ids && null == htmlElements && null == imports;
264.132 + }
264.133 +
264.134 + //single threaded - called from constructor only, no need for synch
264.135 + private Collection<Entry> getClassesCollectionInstance() {
264.136 + if(classes == null) {
264.137 + classes = new ArrayList<Entry>();
264.138 + }
264.139 + return classes;
264.140 + }
264.141 +
264.142 + private Collection<Entry> getIdsCollectionInstance() {
264.143 + if(ids == null) {
264.144 + ids = new ArrayList<Entry>();
264.145 + }
264.146 + return ids;
264.147 + }
264.148 +
264.149 + private Collection<Entry> getHtmlElementsCollectionInstance() {
264.150 + if(htmlElements == null) {
264.151 + htmlElements = new ArrayList<Entry>();
264.152 + }
264.153 + return htmlElements;
264.154 + }
264.155 +
264.156 + private Collection<Entry> getImportsCollectionInstance() {
264.157 + if(imports == null) {
264.158 + imports = new ArrayList<Entry>();
264.159 + }
264.160 + return imports;
264.161 + }
264.162 +
264.163 + private void init(CssParserResult parserResult) {
264.164 + SimpleNodeUtil.visitChildren(parserResult.root(), new AstVisitor());
264.165 + }
264.166 +
264.167 + @Override
264.168 + public String toString() {
264.169 + StringBuffer buf = new StringBuffer(super.toString());
264.170 + buf.append(":");
264.171 + for (Entry c : getImports()) {
264.172 + buf.append(" imports=");
264.173 + buf.append(c);
264.174 + buf.append(',');
264.175 + }
264.176 + for (Entry c : getClasses()) {
264.177 + buf.append(c);
264.178 + buf.append(',');
264.179 + }
264.180 + for (Entry c : getIds()) {
264.181 + buf.append(c);
264.182 + buf.append(',');
264.183 + }
264.184 + for (Entry c : getHtmlElements()) {
264.185 + buf.append(c);
264.186 + buf.append(',');
264.187 + }
264.188 +
264.189 + return buf.toString();
264.190 + }
264.191 +
264.192 + private class AstVisitor implements NodeVisitor {
264.193 +
264.194 + @Override
264.195 + public void visit(SimpleNode node) {
264.196 + if (node.kind() == CssParserTreeConstants.JJTIMPORTRULE) {
264.197 + Entry entry = getImportedEntry(node);
264.198 + if(entry != null) {
264.199 + getImportsCollectionInstance().add(entry);
264.200 + }
264.201 + } else if (node.kind() == CssParserTreeConstants.JJT_CLASS) {
264.202 + Entry e = createEntry(node.image(), new OffsetRange(node.startOffset(), node.endOffset()));
264.203 + getClassesCollectionInstance().add(e);
264.204 + } else if (node.kind() == CssParserTreeConstants.JJTHASH) {
264.205 + Entry e = createEntry(node.image(), new OffsetRange(node.startOffset(), node.endOffset()));
264.206 + getIdsCollectionInstance().add(e);
264.207 + } else if (node.kind() == CssParserTreeConstants.JJTELEMENTNAME) {
264.208 + Entry e = createEntry(node.image(), new OffsetRange(node.startOffset(), node.endOffset()));
264.209 + getHtmlElementsCollectionInstance().add(e);
264.210 + }
264.211 +
264.212 + }
264.213 +
264.214 + private Entry getImportedEntry(SimpleNode node) {
264.215 + //@import "resources/global.css";
264.216 + Token token = SimpleNodeUtil.getNodeToken(node, CssParserConstants.STRING);
264.217 + if(token != null) {
264.218 + String image = token.image;
264.219 + boolean quoted = SimpleNodeUtil.isValueQuoted(image);
264.220 + return createEntry(SimpleNodeUtil.unquotedValue(image),
264.221 + new OffsetRange(token.offset + (quoted ? 1 : 0),
264.222 + token.offset + image.length() - (quoted ? 1 : 0)));
264.223 + }
264.224 +
264.225 + //@import url("another.css");
264.226 + token = SimpleNodeUtil.getNodeToken(node, CssParserConstants.URI);
264.227 + if(token != null) {
264.228 + Matcher m = URI_PATTERN.matcher(token.image);
264.229 + if(m.matches()) {
264.230 + int groupIndex = 1;
264.231 + String content = m.group(groupIndex);
264.232 + boolean quoted = SimpleNodeUtil.isValueQuoted(content);
264.233 + int from = m.start(groupIndex);
264.234 + int to = m.end(groupIndex);
264.235 + return createEntry(SimpleNodeUtil.unquotedValue(content),
264.236 + new OffsetRange(from + (quoted ? 1 : 0), to - (quoted ? 1 : 0)));
264.237 + }
264.238 + }
264.239 +
264.240 + return null;
264.241 + }
264.242 + }
264.243 +
264.244 + public Entry createEntry(String name, OffsetRange range) {
264.245 + int documentFrom = snapshot.getOriginalOffset(range.getStart());
264.246 + int documentTo = snapshot.getOriginalOffset(range.getEnd());
264.247 +
264.248 + if(documentFrom == -1 || documentTo == -1) {
264.249 + LOGGER.info("Ast offset range " + range.toString() +
264.250 + " cannot be properly mapped to source offset range: ["
264.251 + + documentFrom + "," + documentTo + "] in file " +
264.252 + CssFileModel.this.fileObject.getPath()); //NOI18N
264.253 + return null;
264.254 + }
264.255 + return new Entry(name, range, new OffsetRange(documentFrom, documentTo));
264.256 + }
264.257 +
264.258 + public class Entry {
264.259 + private String name;
264.260 + private OffsetRange astRange;
264.261 + private OffsetRange documentRange;
264.262 +
264.263 + private Entry(String name, OffsetRange astRange, OffsetRange documentRange) {
264.264 + this.name = name;
264.265 + this.astRange = astRange;
264.266 + this.documentRange = documentRange;
264.267 + }
264.268 +
264.269 + public String getName() {
264.270 + return name;
264.271 + }
264.272 +
264.273 + public OffsetRange getDocumentRange() {
264.274 + return documentRange;
264.275 + }
264.276 +
264.277 + public OffsetRange getRange() {
264.278 + return astRange;
264.279 + }
264.280 +
264.281 + @Override
264.282 + public String toString() {
264.283 + return "Entry[" + getName() + "; " + getRange().getStart() + " - " + getRange().getEnd() + "]";
264.284 + }
264.285 +
264.286 +
264.287 + }
264.288 +
264.289 +}
265.1 --- a/css.editor/src/org/netbeans/modules/css/indexing/CssIndex.java Mon Feb 01 12:23:06 2010 +0100
265.2 +++ b/css.editor/src/org/netbeans/modules/css/indexing/CssIndex.java Mon Feb 01 12:24:26 2010 +0100
265.3 @@ -38,9 +38,23 @@
265.4 */
265.5 package org.netbeans.modules.css.indexing;
265.6
265.7 +import java.io.File;
265.8 import java.io.IOException;
265.9 +import java.net.URI;
265.10 +import java.util.ArrayList;
265.11 +import java.util.Collection;
265.12 +import java.util.Collections;
265.13 +import java.util.HashMap;
265.14 +import java.util.LinkedList;
265.15 +import java.util.Map;
265.16 +import java.util.StringTokenizer;
265.17 +import java.util.logging.Level;
265.18 +import java.util.logging.Logger;
265.19 +import org.netbeans.modules.css.indexing.DependenciesGraph.Node;
265.20 +import org.netbeans.modules.parsing.spi.indexing.support.IndexResult;
265.21 import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport;
265.22 import org.openide.filesystems.FileObject;
265.23 +import org.openide.util.Exceptions;
265.24
265.25 /**
265.26 * An instance of the indexer which can be held until the source roots are valid.
265.27 @@ -49,20 +63,188 @@
265.28 */
265.29 public class CssIndex {
265.30
265.31 + private static final Logger LOGGER = Logger.getLogger(CssIndex.class.getSimpleName());
265.32 + private static final boolean LOG = LOGGER.isLoggable(Level.FINE);
265.33 +
265.34 public static CssIndex create(FileObject[] sourceRoots) throws IOException {
265.35 return new CssIndex(sourceRoots);
265.36 }
265.37 -
265.38 - private final FileObject[] sourceRoots;
265.39 private final QuerySupport querySupport;
265.40
265.41 /** Creates a new instance of JsfIndex */
265.42 private CssIndex(FileObject[] sourceRoots) throws IOException {
265.43 - this.sourceRoots = sourceRoots;
265.44 - //QuerySupport now refreshes the roots indexes so it can held until
265.45 - //the source roots are valid
265.46 - this.querySupport = QuerySupport.forRoots(CssIndexer.Factory.NAME, CssIndexer.Factory.VERSION, sourceRoots);
265.47 + //QuerySupport now refreshes the roots indexes so it can held until
265.48 + //the source roots are valid
265.49 + this.querySupport = QuerySupport.forRoots(CssIndexer.Factory.NAME, CssIndexer.Factory.VERSION, sourceRoots);
265.50 }
265.51
265.52 -
265.53 + public Collection<FileObject> findIds(String id) {
265.54 + return find(CssIndexer.IDS_KEY, id);
265.55 + }
265.56 +
265.57 + public Collection<FileObject> findClasses(String clazz) {
265.58 + return find(CssIndexer.CLASSES_KEY, clazz);
265.59 + }
265.60 +
265.61 + public Collection<FileObject> findHtmlElement(String htmlElement) {
265.62 + return find(CssIndexer.HTML_ELEMENTS_KEY, htmlElement);
265.63 + }
265.64 +
265.65 + /**
265.66 + *
265.67 + * @param keyName
265.68 + * @param value
265.69 + * @return returns a collection of files which contains the keyName key and the
265.70 + * value matches the value regular expression
265.71 + */
265.72 + public Collection<FileObject> find(String keyName, String value) {
265.73 + try {
265.74 + String searchExpression = ".*(" + value + ")[,;].*";
265.75 + Collection<FileObject> matchedFiles = new LinkedList<FileObject>();
265.76 + Collection<? extends IndexResult> results = querySupport.query(keyName, searchExpression, QuerySupport.Kind.REGEXP, keyName);
265.77 + for (IndexResult result : results) {
265.78 + matchedFiles.add(result.getFile());
265.79 + }
265.80 + return matchedFiles;
265.81 + } catch (IOException ex) {
265.82 + Exceptions.printStackTrace(ex);
265.83 + }
265.84 +
265.85 + return Collections.emptyList();
265.86 + }
265.87 +
265.88 + /**
265.89 + * Gets all 'related' files to the given css file object.
265.90 + *
265.91 + * @param cssFile
265.92 + * @return a collection of all files which either imports or are imported
265.93 + * by the given cssFile both directly and indirectly (transitive relation)
265.94 + */
265.95 + public DependenciesGraph getDependencies(FileObject cssFile) {
265.96 + try {
265.97 + DependenciesGraph deps = new DependenciesGraph(cssFile);
265.98 + Collection<? extends IndexResult> results = querySupport.query(CssIndexer.IMPORTS_KEY, "", QuerySupport.Kind.PREFIX, CssIndexer.IMPORTS_KEY);
265.99 +
265.100 + //create the refering part of the graph (imported files)
265.101 + //map of FileObject to list of imported files
265.102 + Map<FileObject, Collection<String>> files2imports = new HashMap<FileObject, Collection<String>>();
265.103 + for (IndexResult result : results) {
265.104 + String importsValue = result.getValue(CssIndexer.IMPORTS_KEY);
265.105 + FileObject file = result.getFile();
265.106 + files2imports.put(file, decodeListValue(importsValue));
265.107 + }
265.108 + resolveImports(deps.getSourceNode(), files2imports);
265.109 +
265.110 + //resolve importing files
265.111 + //TODO the recursive algrithm uses linear search - this deserves
265.112 + //fixing even if the number of css files is typically quite small
265.113 +
265.114 + //reversed map of imports to files
265.115 + Map<String, FileObject> imports2files = new HashMap<String, FileObject>();
265.116 + for (FileObject file : files2imports.keySet()) {
265.117 + for (String imp : files2imports.get(file)) {
265.118 + imports2files.put(imp, file);
265.119 + }
265.120 + }
265.121 + resolveImporting(deps.getSourceNode(), imports2files);
265.122 +
265.123 + return deps;
265.124 +
265.125 + } catch (IOException ex) {
265.126 + Exceptions.printStackTrace(ex);
265.127 + }
265.128 +
265.129 + return null;
265.130 + }
265.131 +
265.132 + private void resolveImporting(Node sourceNode, Map<String, FileObject> imports2files) {
265.133 + FileObject source = sourceNode.getFile();
265.134 + //a. find all entries which may possibly be references to our base file
265.135 + String baseFileName = source.getNameExt();
265.136 + //hmm, linear search :-(, wouldn't it be faster to uset the index instead?
265.137 + Collection<String> possiblyValidImports = new LinkedList<String>();
265.138 + for (String imp : imports2files.keySet()) {
265.139 + if (imp.indexOf(baseFileName) != -1) {
265.140 + //might possibly import the base file
265.141 + possiblyValidImports.add(imp);
265.142 + }
265.143 + }
265.144 +
265.145 + //b.now check if the possible imports do really import our base file
265.146 + for (String possibleImport : possiblyValidImports) {
265.147 + FileObject base = imports2files.get(possibleImport);
265.148 + FileObject resolved = resolve(base, possibleImport);
265.149 + if (resolved != null && resolved.equals(source)) {
265.150 + //gotcha!
265.151 + Node node = sourceNode.getDependencyGraph().getNode(base);
265.152 + sourceNode.addReferingNode(node);
265.153 + resolveImporting(node, imports2files);
265.154 + }
265.155 + }
265.156 + }
265.157 +
265.158 + private void resolveImports(Node base, Map<FileObject, Collection<String>> file2imports) {
265.159 + FileObject source = base.getFile();
265.160 + Collection<String> imports = file2imports.get(source);
265.161 + if (imports == null) {
265.162 + return;
265.163 + }
265.164 +
265.165 + for (String importedFileName : imports) {
265.166 + //resolve the file
265.167 + FileObject resolvedFileObject = resolve(source, importedFileName);
265.168 + if (resolvedFileObject != null) {
265.169 + Node node = base.getDependencyGraph().getNode(resolvedFileObject);
265.170 + base.addReferedNode(node);
265.171 + resolveImports(node, file2imports);
265.172 + }
265.173 + }
265.174 +
265.175 + }
265.176 +
265.177 + private FileObject resolve(FileObject source, String importedFileName) {
265.178 + URI u = URI.create(importedFileName);
265.179 + File file = null;
265.180 +
265.181 + if (u.isAbsolute()) {
265.182 + //do refactor only file resources
265.183 + if ("file".equals(u.getScheme())) { //NOI18N
265.184 + try {
265.185 + //the IAE is thrown for invalid URIs quite frequently
265.186 + file = new File(u);
265.187 + } catch (IllegalArgumentException iae) {
265.188 + //no-op
265.189 + }
265.190 + }
265.191 + } else {
265.192 + //no schema specified
265.193 + file = new File(importedFileName);
265.194 + }
265.195 +
265.196 + if (file != null && !file.isAbsolute()) {
265.197 + //relative to the current file's folder - let's resolve
265.198 + FileObject resolvedFileObject = source.getParent().getFileObject(importedFileName);
265.199 + if (resolvedFileObject != null && resolvedFileObject.isValid()) {
265.200 + return resolvedFileObject;
265.201 + }
265.202 + } else {
265.203 + //absolute - TO THE DEPLOYMENT ROOT!!!
265.204 + //todo implement!!!
265.205 + if(LOG) {
265.206 + LOGGER.fine("Cannot resolve import '" + importedFileName + "' from file " + source.getPath()); //NOI18N
265.207 + }
265.208 + }
265.209 + return null;
265.210 + }
265.211 +
265.212 + //each list value is terminated by semicolon
265.213 + private Collection<String> decodeListValue(String value) {
265.214 + assert value.charAt(value.length() - 1) == ';';
265.215 + Collection<String> list = new ArrayList<String>();
265.216 + StringTokenizer st = new StringTokenizer(value.substring(0, value.length() - 1), ",");
265.217 + while (st.hasMoreTokens()) {
265.218 + list.add(st.nextToken());
265.219 + }
265.220 + return list;
265.221 + }
265.222 }
266.1 --- a/css.editor/src/org/netbeans/modules/css/indexing/CssIndexer.java Mon Feb 01 12:23:06 2010 +0100
266.2 +++ b/css.editor/src/org/netbeans/modules/css/indexing/CssIndexer.java Mon Feb 01 12:24:26 2010 +0100
266.3 @@ -39,14 +39,13 @@
266.4 package org.netbeans.modules.css.indexing;
266.5
266.6 import java.io.IOException;
266.7 -import java.util.Arrays;
266.8 -import java.util.HashSet;
266.9 -import java.util.LinkedList;
266.10 -import java.util.List;
266.11 -import java.util.Set;
266.12 +import java.util.Collection;
266.13 +import java.util.Iterator;
266.14 import java.util.logging.Level;
266.15 import java.util.logging.Logger;
266.16 import org.netbeans.modules.css.editor.Css;
266.17 +import org.netbeans.modules.css.gsf.api.CssParserResult;
266.18 +import org.netbeans.modules.css.indexing.CssFileModel.Entry;
266.19 import org.netbeans.modules.parsing.api.Snapshot;
266.20 import org.netbeans.modules.parsing.spi.Parser.Result;
266.21 import org.netbeans.modules.parsing.spi.indexing.Context;
266.22 @@ -65,75 +64,93 @@
266.23 */
266.24 public class CssIndexer extends EmbeddingIndexer {
266.25
266.26 - private static final Logger LOG = Logger.getLogger(CssIndexer.class.getSimpleName());
266.27 + private static final Logger LOGGER = Logger.getLogger(CssIndexer.class.getSimpleName());
266.28 + private static final boolean LOG = LOGGER.isLoggable(Level.FINE);
266.29
266.30 - static {
266.31 -// LOG.setLevel(Level.ALL); //DEBUG, DELETE!!!!!!!!!!!!!!!!
266.32 + static final String IMPORTS_KEY = "imports"; //NOI18N
266.33 + static final String IDS_KEY = "ids"; //NOI18N
266.34 + static final String CLASSES_KEY = "classes"; //NOI18N
266.35 + static final String HTML_ELEMENTS_KEY = "htmlElements"; //NOI18N
266.36 +
266.37 +// static {
266.38 +// LOG.setLevel(Level.ALL);
266.39 +// }
266.40 + @Override
266.41 + protected void index(Indexable indexable, Result parserResult, Context context) {
266.42 + try {
266.43 + if(LOG) {
266.44 + FileObject fo = parserResult.getSnapshot().getSource().getFileObject();
266.45 + LOGGER.log(Level.FINE, "indexing " + fo.getPath()); //NOI18N
266.46 + }
266.47 +
266.48 + CssFileModel model = new CssFileModel((CssParserResult) parserResult);
266.49 + if (!model.isEmpty()) {
266.50 + IndexingSupport support = IndexingSupport.getInstance(context);
266.51 + IndexDocument document = support.createDocument(indexable);
266.52 +
266.53 + storeEntries(model.getIds(), document, IDS_KEY);
266.54 + storeEntries(model.getClasses(), document, CLASSES_KEY);
266.55 + storeEntries(model.getHtmlElements(), document, HTML_ELEMENTS_KEY);
266.56 + storeEntries(model.getImports(), document, IMPORTS_KEY);
266.57 +
266.58 + support.addDocument(document);
266.59 + }
266.60 +
266.61 + } catch (IOException ex) {
266.62 + Exceptions.printStackTrace(ex);
266.63 + }
266.64 }
266.65
266.66 - @Override
266.67 - protected void index(Indexable indexable, Result parserResult, Context context) {
266.68 - try {
266.69 - FileObject fo = parserResult.getSnapshot().getSource().getFileObject();
266.70 - LOG.log(Level.FINE, "indexing " + fo.getPath()); //NOI18N
266.71 - List<IndexDocument> documents = new LinkedList<IndexDocument>();
266.72 - IndexingSupport support = IndexingSupport.getInstance(context);
266.73 -
266.74 -// //get JSF models and index them
266.75 -// Collection<JsfPageModel> models = JsfPageModelFactory.getModels((HtmlParserResult) parserResult);
266.76 -// for (JsfPageModel model : models) {
266.77 -// IndexDocument document = support.createDocument(indexable);
266.78 -// modifications.add(model.storeToIndex(document));
266.79 -// documents.add(document);
266.80 -// }
266.81 -
266.82 - //add the documents to the index
266.83 - for (IndexDocument d : documents) {
266.84 - support.addDocument(d);
266.85 - }
266.86 -
266.87 - } catch (IOException ex) {
266.88 - Exceptions.printStackTrace(ex);
266.89 - }
266.90 + private void storeEntries(Collection<Entry> entries, IndexDocument doc, String key) {
266.91 + if (!entries.isEmpty()) {
266.92 + StringBuffer sb = new StringBuffer();
266.93 + Iterator<Entry> i = entries.iterator();
266.94 + while (i.hasNext()) {
266.95 + sb.append(i.next().getName());
266.96 + if (i.hasNext()) {
266.97 + sb.append(','); //NOI18N
266.98 + }
266.99 + }
266.100 + sb.append(';'); //end of string
266.101 + doc.addPair(key, sb.toString(), true, true);
266.102 + }
266.103 }
266.104
266.105 public static class Factory extends EmbeddingIndexerFactory {
266.106
266.107 - static final String NAME = "css"; //NOI18N
266.108 - static final int VERSION = 1;
266.109 + static final String NAME = "css"; //NOI18N
266.110 + static final int VERSION = 1;
266.111
266.112 - @Override
266.113 - public EmbeddingIndexer createIndexer(Indexable indexable, Snapshot snapshot) {
266.114 - if (isIndexable(snapshot)) {
266.115 - return new CssIndexer();
266.116 - } else {
266.117 - return null;
266.118 - }
266.119 - }
266.120 + @Override
266.121 + public EmbeddingIndexer createIndexer(Indexable indexable, Snapshot snapshot) {
266.122 + if (isIndexable(snapshot)) {
266.123 + return new CssIndexer();
266.124 + } else {
266.125 + return null;
266.126 + }
266.127 + }
266.128
266.129 - @Override
266.130 - public void filesDeleted(Iterable<? extends Indexable> deleted, Context context) {
266.131 - }
266.132 + @Override
266.133 + public void filesDeleted(Iterable<? extends Indexable> deleted, Context context) {
266.134 + }
266.135
266.136 - @Override
266.137 - public void filesDirty(Iterable<? extends Indexable> dirty, Context context) {
266.138 - }
266.139 + @Override
266.140 + public void filesDirty(Iterable<? extends Indexable> dirty, Context context) {
266.141 + }
266.142
266.143 - @Override
266.144 - public String getIndexerName() {
266.145 - return NAME;
266.146 - }
266.147 + @Override
266.148 + public String getIndexerName() {
266.149 + return NAME;
266.150 + }
266.151
266.152 - @Override
266.153 - public int getIndexVersion() {
266.154 - return VERSION;
266.155 - }
266.156 + @Override
266.157 + public int getIndexVersion() {
266.158 + return VERSION;
266.159 + }
266.160
266.161 - private boolean isIndexable(Snapshot snapshot) {
266.162 - //index all files possibly containing css
266.163 - FileObject fo = snapshot.getSource().getFileObject();
266.164 - String sourceFileMimeType = fo.getMIMEType();
266.165 - return Css.CSS_MIME_TYPE.equals(sourceFileMimeType);
266.166 - }
266.167 - } //end of Factory class
266.168 + private boolean isIndexable(Snapshot snapshot) {
266.169 + //index all files possibly containing css
266.170 + return Css.CSS_MIME_TYPE.equals(snapshot.getMimeType());
266.171 + }
266.172 + }
266.173 }
267.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
267.2 +++ b/css.editor/src/org/netbeans/modules/css/indexing/DependenciesGraph.java Mon Feb 01 12:24:26 2010 +0100
267.3 @@ -0,0 +1,221 @@
267.4 +/*
267.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
267.6 + *
267.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
267.8 + *
267.9 + * The contents of this file are subject to the terms of either the GNU
267.10 + * General Public License Version 2 only ("GPL") or the Common
267.11 + * Development and Distribution License("CDDL") (collectively, the
267.12 + * "License"). You may not use this file except in compliance with the
267.13 + * License. You can obtain a copy of the License at
267.14 + * http://www.netbeans.org/cddl-gplv2.html
267.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
267.16 + * specific language governing permissions and limitations under the
267.17 + * License. When distributing the software, include this License Header
267.18 + * Notice in each file and include the License file at
267.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
267.20 + * particular file as subject to the "Classpath" exception as provided
267.21 + * by Sun in the GPL Version 2 section of the License file that
267.22 + * accompanied this code. If applicable, add the following below the
267.23 + * License Header, with the fields enclosed by brackets [] replaced by
267.24 + * your own identifying information:
267.25 + * "Portions Copyrighted [year] [name of copyright owner]"
267.26 + *
267.27 + * If you wish your version of this file to be governed by only the CDDL
267.28 + * or only the GPL Version 2, indicate your decision by adding
267.29 + * "[Contributor] elects to include this software in this distribution
267.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
267.31 + * single choice of license, a recipient has the option to distribute
267.32 + * your version of this file under either the CDDL, the GPL Version 2 or
267.33 + * to extend the choice of license to its licensees as provided above.
267.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
267.35 + * Version 2 license, then the option applies only if the new code is
267.36 + * made subject to such option by the copyright holder.
267.37 + *
267.38 + * Contributor(s):
267.39 + *
267.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
267.41 + */
267.42 +
267.43 +package org.netbeans.modules.css.indexing;
267.44 +
267.45 +import java.util.Collection;
267.46 +import java.util.Collections;
267.47 +import java.util.HashMap;
267.48 +import java.util.HashSet;
267.49 +import java.util.LinkedList;
267.50 +import java.util.Map;
267.51 +import org.openide.filesystems.FileObject;
267.52 +
267.53 +/**
267.54 + * bidirectional dependencies graph
267.55 + *
267.56 + * The aim of the class is to store a map of dependencies among css file
267.57 + * originaly created based on index information which can be later corrected
267.58 + * based on the parse results from opened files (if the structural information
267.59 + * from the parser result differs from the stored index data (file unsaved))
267.60 + *
267.61 + * @author marekfukala
267.62 + */
267.63 +public class DependenciesGraph {
267.64 +
267.65 + private static final String INDENT = " "; //NOI18N
267.66 +
267.67 + private Map<FileObject, Node> file2node = new HashMap<FileObject, Node>();
267.68 + private Node sourceNode;
267.69 +
267.70 + DependenciesGraph(FileObject source) {
267.71 + this.sourceNode = new Node(source);
267.72 + }
267.73 +
267.74 + public Node getNode(FileObject source) {
267.75 + Node node = file2node.get(source);
267.76 + if(node == null) {
267.77 + node = new Node(source);
267.78 + }
267.79 + return node;
267.80 + }
267.81 +
267.82 + public Node getSourceNode() {
267.83 + return sourceNode;
267.84 + }
267.85 +
267.86 + /**
267.87 + *
267.88 + * @return a collection a files which are either imported or importing the
267.89 + * base source file for this dependencies graph
267.90 + */
267.91 + public Collection<FileObject> getAllRelatedFiles() {
267.92 + Collection<FileObject> files = new HashSet<FileObject>();
267.93 + addReferingFiles(files, sourceNode);
267.94 + addReferedFiles(files, sourceNode);
267.95 +
267.96 + return files;
267.97 + }
267.98 +
267.99 + private void addReferingFiles(Collection<FileObject> files, Node base) {
267.100 + files.add(base.getFile());
267.101 + for(Node node : base.refering) {
267.102 + addReferingFiles(files, node);
267.103 + }
267.104 + }
267.105 +
267.106 + private void addReferedFiles(Collection<FileObject> files, Node base) {
267.107 + files.add(base.getFile());
267.108 + for(Node node : base.refered) {
267.109 + addReferedFiles(files, node);
267.110 + }
267.111 + }
267.112 +
267.113 + @Override
267.114 + public String toString() {
267.115 + StringBuilder builder = new StringBuilder();
267.116 + dumpNodes(builder, 0, sourceNode, false); //refering
267.117 + dumpNodes(builder, 0, sourceNode, true); //refered
267.118 + return builder.toString();
267.119 + }
267.120 +
267.121 + private void dumpNodes(StringBuilder b, int level, Node node, boolean refered) {
267.122 + for(int i = 0; i < level; i++) {
267.123 + b.append(INDENT);
267.124 + }
267.125 + b.append(refered ? "->" : "<-");
267.126 + b.append(node);
267.127 + b.append('\n');
267.128 + for(Node n : refered ? node.getReferedNodes() : node.getReferingNodes()) {
267.129 + dumpNodes(b, level + 1, n, refered);
267.130 + }
267.131 +
267.132 + }
267.133 +
267.134 +
267.135 +
267.136 + public class Node {
267.137 +
267.138 + private FileObject source;
267.139 + private Collection<Node> refering = new LinkedList<Node>();
267.140 + private Collection<Node> refered = new LinkedList<Node>();
267.141 +
267.142 + private Node(FileObject source) {
267.143 + this.source = source;
267.144 + }
267.145 +
267.146 + public DependenciesGraph getDependencyGraph() {
267.147 + return DependenciesGraph.this;
267.148 + }
267.149 +
267.150 + public FileObject getFile() {
267.151 + return source;
267.152 + }
267.153 +
267.154 + public void addReferedNode(Node node) {
267.155 + if(refered.add(node)) {
267.156 + node.refering.add(this);
267.157 + }
267.158 + }
267.159 +
267.160 + public void removeReferedNode(Node node) {
267.161 + if(refered.remove(node)) {
267.162 + node.refering.remove(this);
267.163 + }
267.164 + }
267.165 +
267.166 + public void addReferingNode(Node node) {
267.167 + if(refering.add(node)) {
267.168 + node.refered.add(this);
267.169 + }
267.170 + }
267.171 +
267.172 + public void removeReferingNode(Node node) {
267.173 + if(refering.remove(node)) {
267.174 + node.refered.remove(this);
267.175 + }
267.176 + }
267.177 +
267.178 + /**
267.179 + *
267.180 + * @return unmodifiable collection of nodes which refers to (imports) this node
267.181 + */
267.182 + public Collection<Node> getReferingNodes() {
267.183 + return Collections.unmodifiableCollection(refering);
267.184 + }
267.185 +
267.186 + /**
267.187 + *
267.188 + * @return unmodifiable collection of nodes which this node refers to (imports)
267.189 + */
267.190 + public Collection<Node> getReferedNodes() {
267.191 + return Collections.unmodifiableCollection(refered);
267.192 + }
267.193 +
267.194 + @Override
267.195 + public boolean equals(Object obj) {
267.196 + if (obj == null) {
267.197 + return false;
267.198 + }
267.199 + if (getClass() != obj.getClass()) {
267.200 + return false;
267.201 + }
267.202 + final Node other = (Node) obj;
267.203 + if (this.source != other.source && (this.source == null || !this.source.equals(other.source))) {
267.204 + return false;
267.205 + }
267.206 + return true;
267.207 + }
267.208 +
267.209 + @Override
267.210 + public int hashCode() {
267.211 + int hash = 5;
267.212 + hash = 41 * hash + (this.source != null ? this.source.hashCode() : 0);
267.213 + return hash;
267.214 + }
267.215 +
267.216 + @Override
267.217 + public String toString() {
267.218 + return "Node[" + source.getPath() + "]";
267.219 + }
267.220 +
267.221 +
267.222 +
267.223 + }
267.224 +}
268.1 --- a/css.editor/src/org/netbeans/modules/css/refactoring/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
268.2 +++ b/css.editor/src/org/netbeans/modules/css/refactoring/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
268.3 @@ -42,7 +42,7 @@
268.4
268.5 LBL_NewName=&New Name:
268.6 LBL_RenameComments=Apply Rename on &Comments
268.7 -LBL_NonAccurateRefactoringWarning=Css refactoring is approximate. Review all changes.
268.8 +LBL_NonAccurateRefactoringWarning=Please review all changes before refactoring.
268.9 LBL_RenameWithoutRefactoring=&Rename Without Refactoring
268.10
268.11 ERR_CannotRenameLoc=Cannot rename here
268.12 @@ -50,3 +50,5 @@
268.13 ACSD_nameField=Type new name
268.14
268.15 MSG_CreateCssRule=Css Rule
268.16 +
268.17 +MSG_Rename_Selector=Selector rename
268.18 \ No newline at end of file
269.1 --- a/css.editor/src/org/netbeans/modules/css/refactoring/CssElementContext.java Mon Feb 01 12:23:06 2010 +0100
269.2 +++ b/css.editor/src/org/netbeans/modules/css/refactoring/CssElementContext.java Mon Feb 01 12:24:26 2010 +0100
269.3 @@ -39,6 +39,7 @@
269.4 package org.netbeans.modules.css.refactoring;
269.5
269.6 import java.util.Collection;
269.7 +import javax.swing.text.Document;
269.8 import org.netbeans.modules.css.gsf.api.CssParserResult;
269.9 import org.netbeans.modules.css.parser.CssParserTreeConstants;
269.10 import org.netbeans.modules.css.parser.SimpleNode;
269.11 @@ -132,6 +133,10 @@
269.12 return SimpleNodeUtil.findDescendant(root, astOffset);
269.13 }
269.14
269.15 + public Document getDocument() {
269.16 + return result.getSnapshot().getSource().getDocument(false);
269.17 + }
269.18 +
269.19 public CssParserResult getParserResult() {
269.20 return result;
269.21 }
269.22 @@ -157,6 +162,10 @@
269.23 return element;
269.24 }
269.25
269.26 + public SimpleNode getSimpleSelectorElement() {
269.27 + return SimpleNodeUtil.getAncestorByType(getElement(), CssParserTreeConstants.JJTSIMPLESELECTOR);
269.28 + }
269.29 +
269.30 @Override
269.31 public String getElementName() {
269.32 return getElement().image();
269.33 @@ -164,7 +173,7 @@
269.34
269.35 @Override
269.36 public boolean isRefactoringAllowed() {
269.37 - return null != SimpleNodeUtil.getAncestorByType(getElement(), CssParserTreeConstants.JJTSIMPLESELECTOR);
269.38 + return null != getSimpleSelectorElement();
269.39 }
269.40 }
269.41 }
270.1 --- a/css.editor/src/org/netbeans/modules/css/refactoring/CssRenameRefactoringPlugin.java Mon Feb 01 12:23:06 2010 +0100
270.2 +++ b/css.editor/src/org/netbeans/modules/css/refactoring/CssRenameRefactoringPlugin.java Mon Feb 01 12:24:26 2010 +0100
270.3 @@ -38,20 +38,35 @@
270.4 */
270.5 package org.netbeans.modules.css.refactoring;
270.6
270.7 +import java.util.ArrayList;
270.8 +import java.util.Collection;
270.9 import java.util.Collections;
270.10 +import java.util.LinkedList;
270.11 +import java.util.List;
270.12 +import java.util.logging.Level;
270.13 +import java.util.logging.Logger;
270.14 import javax.swing.text.Position.Bias;
270.15 import org.netbeans.modules.csl.spi.support.ModificationResult;
270.16 import org.netbeans.modules.csl.spi.support.ModificationResult.Difference;
270.17 import org.netbeans.modules.css.editor.Css;
270.18 -import org.netbeans.modules.css.parser.NodeVisitor;
270.19 +import org.netbeans.modules.css.editor.CssProjectSupport;
270.20 +import org.netbeans.modules.css.indexing.CssFileModel;
270.21 +import org.netbeans.modules.css.indexing.CssFileModel.Entry;
270.22 +import org.netbeans.modules.css.indexing.CssIndex;
270.23 +import org.netbeans.modules.css.indexing.DependenciesGraph;
270.24 +import org.netbeans.modules.css.parser.CssParserTreeConstants;
270.25 import org.netbeans.modules.css.parser.SimpleNode;
270.26 -import org.netbeans.modules.css.parser.SimpleNodeUtil;
270.27 +import org.netbeans.modules.parsing.api.Source;
270.28 +import org.netbeans.modules.parsing.spi.ParseException;
270.29 import org.netbeans.modules.refactoring.api.Problem;
270.30 import org.netbeans.modules.refactoring.api.RenameRefactoring;
270.31 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
270.32 import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
270.33 +import org.openide.filesystems.FileObject;
270.34 import org.openide.text.CloneableEditorSupport;
270.35 +import org.openide.util.Exceptions;
270.36 import org.openide.util.Lookup;
270.37 +import org.openide.util.NbBundle;
270.38
270.39 /**
270.40 *
270.41 @@ -59,77 +74,164 @@
270.42 */
270.43 public class CssRenameRefactoringPlugin implements RefactoringPlugin {
270.44
270.45 + private static final Logger LOGGER = Logger.getLogger(CssRenameRefactoringPlugin.class.getSimpleName());
270.46 + private static final boolean LOG = LOGGER.isLoggable(Level.FINE);
270.47 private RenameRefactoring refactoring;
270.48
270.49 public CssRenameRefactoringPlugin(RenameRefactoring refactoring) {
270.50 - this.refactoring = refactoring;
270.51 + this.refactoring = refactoring;
270.52 }
270.53
270.54 + @Override
270.55 public Problem preCheck() {
270.56 - return null;
270.57 + return null;
270.58 }
270.59
270.60 + @Override
270.61 public Problem checkParameters() {
270.62 - return null;
270.63 + return null;
270.64 }
270.65
270.66 + @Override
270.67 public Problem fastCheckParameters() {
270.68 - return null;
270.69 + return null;
270.70 }
270.71
270.72 + @Override
270.73 public void cancelRequest() {
270.74 - //no-op
270.75 + //no-op
270.76 }
270.77
270.78 + @Override
270.79 public Problem prepare(final RefactoringElementsBag refactoringElements) {
270.80 - Lookup lookup = refactoring.getRefactoringSource();
270.81 - CssElementContext context = lookup.lookup(CssElementContext.class);
270.82 + Lookup lookup = refactoring.getRefactoringSource();
270.83 + CssElementContext context = lookup.lookup(CssElementContext.class);
270.84
270.85 - if (context instanceof CssElementContext.Editor) {
270.86 - //find all occurances of selected element in (and only in) THIS file.
270.87 - final CssElementContext.Editor econtext = (CssElementContext.Editor) context;
270.88 + if (context instanceof CssElementContext.Editor) {
270.89 + //find all occurances of selected element in (and only in) THIS file.
270.90 + CssElementContext.Editor econtext = (CssElementContext.Editor) context;
270.91 + //get selected element in the editor
270.92 + SimpleNode element = econtext.getElement();
270.93 + String elementImage = element.image();
270.94
270.95 - final SimpleNode element = econtext.getElement();
270.96 - SimpleNode root = econtext.getParserResult().root();
270.97 + CssProjectSupport sup = CssProjectSupport.findFor(context.getFileObject());
270.98 + if (sup == null) {
270.99 + return null;
270.100 + }
270.101 + CssIndex index = sup.getIndex();
270.102 + ModificationResult modificationResult = new ModificationResult();
270.103
270.104 - final CloneableEditorSupport ces = Css.findCloneableEditorSupport(context.getFileObject());
270.105 - final ModificationResult mr = new ModificationResult(); //per file???
270.106 + if (element.kind() == CssParserTreeConstants.JJT_CLASS
270.107 + || element.kind() == CssParserTreeConstants.JJTHASH) {
270.108 + //class or id refactoring
270.109
270.110 - //add the differences to the modificationResults
270.111 - SimpleNodeUtil.visitChildren(root, new NodeVisitor() {
270.112 + String elementName = element.image();
270.113 + Collection<FileObject> files = element.kind() == CssParserTreeConstants.JJT_CLASS
270.114 + ? index.findClasses(elementName)
270.115 + : index.findIds(elementName);
270.116
270.117 - public void visit(SimpleNode node) {
270.118 - if (node.kind() == element.kind() && node.image().equals(element.image())) {
270.119 - int astFrom = econtext.getParserResult().getSnapshot().getOriginalOffset(node.startOffset());
270.120 - int astTo = econtext.getParserResult().getSnapshot().getOriginalOffset(node.endOffset());
270.121 - Difference diff = new Difference(Difference.Kind.CHANGE,
270.122 - ces.createPositionRef(astFrom, Bias.Forward),
270.123 - ces.createPositionRef(astTo, Bias.Backward),
270.124 - node.image(),
270.125 - refactoring.getNewName(),
270.126 - "Rename selector name");
270.127 - mr.addDifferences(econtext.getFileObject(), Collections.singletonList(diff));
270.128 + DependenciesGraph deps = index.getDependencies(context.getFileObject());
270.129
270.130 - }
270.131 - }
270.132 - });
270.133 + //TODO: correct the dependecies graph if any of the involved files
270.134 + //is opened in editor and marked as modified. There could be
270.135 + //an unsaved change modifying the dependencies
270.136
270.137 - refactoringElements.registerTransaction(new RetoucheCommit(Collections.singletonList(mr)));
270.138 + //filter out those files which have no relation with the current file.
270.139 + //note: the list of involved files also contains the currently edited file.
270.140 + List<FileObject> involvedFiles = new LinkedList<FileObject>(files);
270.141 + involvedFiles.retainAll(deps.getAllRelatedFiles());
270.142
270.143 - for (Difference diff : mr.getDifferences(context.getFileObject())) {
270.144 - refactoringElements.add(refactoring, DiffElement.create(diff, context.getFileObject(), mr));
270.145 + //now we have a list of files which contain the given class or id and are
270.146 + //related to the base file
270.147 + if (LOG) {
270.148 + LOGGER.fine("Refactoring element " + elementName + " in file " + context.getFileObject().getPath()); //NOI18N
270.149 + LOGGER.fine("Dependencies graph:\n"); //NOI18N
270.150 + LOGGER.fine(deps.toString() + "\n"); //NOI18N
270.151
270.152 - }
270.153 - } else if (context instanceof CssElementContext.File) {
270.154 - //refactor a file in explorer
270.155 - CssElementContext.File fileContext = (CssElementContext.File)context;
270.156 - System.out.println("refactor file " + fileContext.getFileObject().getPath() );
270.157 - } else if (context instanceof CssElementContext.Folder) {
270.158 - //refactor a folder in explorer
270.159 - CssElementContext.Folder fileContext = (CssElementContext.Folder)context;
270.160 - System.out.println("refactor folder " + fileContext.getFileObject().getPath() );
270.161 - }
270.162 + LOGGER.fine("Involved files declaring the element " + elementName + ":"); //NOI18N
270.163 + for (FileObject fo : involvedFiles) {
270.164 + LOGGER.fine(fo.getPath() + "\n"); //NOI18N
270.165 + }
270.166 + }
270.167
270.168 - return null;
270.169 + //make css simple models for all involved files
270.170 + //where we already have the result
270.171 + for (FileObject file : involvedFiles) {
270.172 + try {
270.173 + Source source;
270.174 + CloneableEditorSupport editor = Css.findCloneableEditorSupport(file);
270.175 + //prefer using editor
270.176 + //XXX this approach doesn't match the dependencies graph
270.177 + //which is made strictly upon the index data
270.178 + if (editor != null && editor.isModified()) {
270.179 + source = Source.create(editor.getDocument());
270.180 + } else {
270.181 + source = Source.create(file);
270.182 + }
270.183 +
270.184 + CssFileModel model = new CssFileModel(source);
270.185 + Collection<Entry> entries = element.kind() == CssParserTreeConstants.JJT_CLASS
270.186 + ? model.getClasses() : model.getIds();
270.187 +
270.188 + List<Difference> diffs = new ArrayList<Difference>();
270.189 + for (Entry entry : entries) {
270.190 + if (elementImage.equals(entry.getName())) {
270.191 + diffs.add(new Difference(Difference.Kind.CHANGE,
270.192 + editor.createPositionRef(entry.getDocumentRange().getStart(), Bias.Forward),
270.193 + editor.createPositionRef(entry.getDocumentRange().getEnd(), Bias.Backward),
270.194 + entry.getName(),
270.195 + refactoring.getNewName(),
270.196 + NbBundle.getMessage(CssRenameRefactoringPlugin.class, "MSG_Rename_Selector"))); //NOI18N
270.197 + }
270.198 + }
270.199 + modificationResult.addDifferences(file, diffs);
270.200 +
270.201 + } catch (ParseException ex) {
270.202 + Exceptions.printStackTrace(ex);
270.203 + }
270.204 + }
270.205 +
270.206 + } else if (element.kind() == CssParserTreeConstants.JJTELEMENTNAME) {
270.207 + //type selector: div
270.208 + //we do refactor only elements in the current css file, and even this is questionable if makes much sense
270.209 + CssFileModel model = new CssFileModel(econtext.getParserResult());
270.210 + List<Difference> diffs = new ArrayList<Difference>();
270.211 + CloneableEditorSupport editor = Css.findCloneableEditorSupport(context.getFileObject());
270.212 + for(Entry entry : model.getHtmlElements()) {
270.213 + if(elementImage.equals(entry.getName())) {
270.214 + diffs.add(new Difference(Difference.Kind.CHANGE,
270.215 + editor.createPositionRef(entry.getDocumentRange().getStart(), Bias.Forward),
270.216 + editor.createPositionRef(entry.getDocumentRange().getEnd(), Bias.Backward),
270.217 + entry.getName(),
270.218 + refactoring.getNewName(),
270.219 + NbBundle.getMessage(CssRenameRefactoringPlugin.class, "MSG_Rename_Selector"))); //NOI18N
270.220 + }
270.221 + }
270.222 + modificationResult.addDifferences(context.getFileObject(), diffs);
270.223 +
270.224 + } else {
270.225 + //other nodes which may appear under the simple selector node
270.226 + //we do not refactor them
270.227 + }
270.228 +
270.229 + refactoringElements.registerTransaction(new RetoucheCommit(Collections.singletonList(modificationResult)));
270.230 +
270.231 + for (FileObject fo : modificationResult.getModifiedFileObjects()) {
270.232 + for (Difference diff : modificationResult.getDifferences(fo)) {
270.233 + refactoringElements.add(refactoring, DiffElement.create(diff, fo, modificationResult));
270.234 +
270.235 + }
270.236 + }
270.237 + } else if (context instanceof CssElementContext.File) {
270.238 + //refactor a file in explorer
270.239 + CssElementContext.File fileContext = (CssElementContext.File) context;
270.240 + LOGGER.info("refactor file " + fileContext.getFileObject().getPath()); //NOI18N
270.241 + } else if (context instanceof CssElementContext.Folder) {
270.242 + //refactor a folder in explorer
270.243 + CssElementContext.Folder fileContext = (CssElementContext.Folder) context;
270.244 + LOGGER.info("refactor folder " + fileContext.getFileObject().getPath()); //NOI18N
270.245 + }
270.246 +
270.247 + return null;
270.248 }
270.249 }
271.1 --- a/css.editor/src/org/netbeans/modules/css/refactoring/RenamePanel.form Mon Feb 01 12:23:06 2010 +0100
271.2 +++ b/css.editor/src/org/netbeans/modules/css/refactoring/RenamePanel.form Mon Feb 01 12:24:26 2010 +0100
271.3 @@ -131,6 +131,7 @@
271.4 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
271.5 <ResourceString bundle="org/netbeans/modules/css/refactoring/Bundle.properties" key="LBL_RenameWithoutRefactoring" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString("{key}")"/>
271.6 </Property>
271.7 + <Property name="enabled" type="boolean" value="false"/>
271.8 <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
271.9 <Insets value="[2, 2, 0, 2]"/>
271.10 </Property>
272.1 --- a/css.editor/src/org/netbeans/modules/css/refactoring/RenamePanel.java Mon Feb 01 12:23:06 2010 +0100
272.2 +++ b/css.editor/src/org/netbeans/modules/css/refactoring/RenamePanel.java Mon Feb 01 12:24:26 2010 +0100
272.3 @@ -165,6 +165,7 @@
272.4 textCheckBox.getAccessibleContext().setAccessibleDescription(textCheckBox.getText());
272.5
272.6 org.openide.awt.Mnemonics.setLocalizedText(updateReferencesCheckBox, org.openide.util.NbBundle.getBundle(RenamePanel.class).getString("LBL_RenameWithoutRefactoring")); // NOI18N
272.7 + updateReferencesCheckBox.setEnabled(false);
272.8 updateReferencesCheckBox.setMargin(new java.awt.Insets(2, 2, 0, 2));
272.9 updateReferencesCheckBox.addActionListener(new java.awt.event.ActionListener() {
272.10 public void actionPerformed(java.awt.event.ActionEvent evt) {
273.1 --- a/css.editor/src/org/netbeans/modules/css/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
273.2 +++ b/css.editor/src/org/netbeans/modules/css/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
273.3 @@ -38,7 +38,9 @@
273.4 <attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/>
273.5 </file>
273.6
273.7 - <file name="org-netbeans-modules-css-editor-indent-CssIndentTaskFactory.instance"/>
273.8 + <file name="org-netbeans-modules-css-editor-indent-CssIndentTaskFactory.instance">
273.9 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
273.10 + </file>
273.11
273.12 <folder name="BracesMatchers">
273.13 <file name="org-netbeans-modules-css-editor-CssBracesMatcherFactory.instance">
274.1 --- a/css.visual/manifest.mf Mon Feb 01 12:23:06 2010 +0100
274.2 +++ b/css.visual/manifest.mf Mon Feb 01 12:24:26 2010 +0100
274.3 @@ -5,4 +5,4 @@
274.4 OpenIDE-Module-Install: org/netbeans/modules/css/CssModuleInstall.class
274.5 OpenIDE-Module-Requires: org.openide.windows.IOProvider
274.6 AutoUpdate-Show-In-Client: false
274.7 -OpenIDE-Module-Specification-Version: 2.10
274.8 +OpenIDE-Module-Specification-Version: 2.11
275.1 --- a/css.visual/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
275.2 +++ b/css.visual/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
275.3 @@ -69,8 +69,8 @@
275.4 <build-prerequisite/>
275.5 <compile-dependency/>
275.6 <run-dependency>
275.7 - <release-version>1</release-version>
275.8 - <specification-version>1.8</specification-version>
275.9 + <release-version>2</release-version>
275.10 + <specification-version>2.1</specification-version>
275.11 </run-dependency>
275.12 </dependency>
275.13 <dependency>
276.1 --- a/groovy.editor/manifest.mf Mon Feb 01 12:23:06 2010 +0100
276.2 +++ b/groovy.editor/manifest.mf Mon Feb 01 12:24:26 2010 +0100
276.3 @@ -3,4 +3,4 @@
276.4 OpenIDE-Module: org.netbeans.modules.groovy.editor/2
276.5 OpenIDE-Module-Layer: org/netbeans/modules/groovy/editor/resources/layer.xml
276.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/groovy/editor/Bundle.properties
276.7 -OpenIDE-Module-Specification-Version: 1.18
276.8 +OpenIDE-Module-Specification-Version: 1.19
277.1 --- a/groovy.editor/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
277.2 +++ b/groovy.editor/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
277.3 @@ -54,8 +54,8 @@
277.4 <build-prerequisite/>
277.5 <compile-dependency/>
277.6 <run-dependency>
277.7 - <release-version>0-1</release-version>
277.8 - <specification-version>1.19</specification-version>
277.9 + <release-version>2</release-version>
277.10 + <specification-version>2.1</specification-version>
277.11 </run-dependency>
277.12 </dependency>
277.13 <dependency>
278.1 --- a/groovy.editor/src/org/netbeans/modules/groovy/editor/api/parser/GroovyLanguage.java Mon Feb 01 12:23:06 2010 +0100
278.2 +++ b/groovy.editor/src/org/netbeans/modules/groovy/editor/api/parser/GroovyLanguage.java Mon Feb 01 12:24:26 2010 +0100
278.3 @@ -48,7 +48,6 @@
278.4 import org.netbeans.modules.csl.api.CodeCompletionHandler;
278.5 import org.netbeans.modules.csl.api.DeclarationFinder;
278.6 import org.netbeans.modules.csl.api.Formatter;
278.7 -import org.netbeans.modules.csl.api.HintsProvider;
278.8 import org.netbeans.modules.csl.api.IndexSearcher;
278.9 import org.netbeans.modules.csl.api.InstantRenamer;
278.10 import org.netbeans.modules.csl.api.KeystrokeHandler;
278.11 @@ -65,10 +64,10 @@
278.12 import org.netbeans.modules.groovy.editor.api.GroovyUtils;
278.13 import org.netbeans.modules.groovy.editor.api.StructureAnalyzer;
278.14 import org.netbeans.modules.groovy.editor.api.completion.CompletionHandler;
278.15 -import org.netbeans.modules.groovy.editor.hints.infrastructure.GroovyHintsProvider;
278.16 import org.netbeans.modules.groovy.editor.api.lexer.GroovyTokenId;
278.17 import org.netbeans.modules.parsing.spi.Parser;
278.18 import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
278.19 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
278.20
278.21 /**
278.22 * Language/lexing configuration for Groovy
278.23 @@ -77,6 +76,7 @@
278.24 * @author Martin Adamek
278.25 */
278.26 @LanguageRegistration(mimeType="text/x-groovy")
278.27 +@PathRecognizerRegistration(mimeTypes="text/x-groovy", sourcePathIds=ClassPath.SOURCE, libraryPathIds={}, binaryLibraryPathIds={}) //NOI18N
278.28 public class GroovyLanguage extends DefaultLanguageConfig {
278.29
278.30 public GroovyLanguage() {
279.1 --- a/groovy.grailsproject/manifest.mf Mon Feb 01 12:23:06 2010 +0100
279.2 +++ b/groovy.grailsproject/manifest.mf Mon Feb 01 12:24:26 2010 +0100
279.3 @@ -3,5 +3,5 @@
279.4 OpenIDE-Module: org.netbeans.modules.groovy.grailsproject
279.5 OpenIDE-Module-Layer: org/netbeans/modules/groovy/grailsproject/resources/layer.xml
279.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/groovy/grailsproject/resources/Bundle.properties
279.7 -OpenIDE-Module-Specification-Version: 1.21
279.8 +OpenIDE-Module-Specification-Version: 1.22
279.9
280.1 --- a/groovy.grailsproject/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
280.2 +++ b/groovy.grailsproject/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
280.3 @@ -55,8 +55,8 @@
280.4 <build-prerequisite/>
280.5 <compile-dependency/>
280.6 <run-dependency>
280.7 - <release-version>1</release-version>
280.8 - <specification-version>1.8</specification-version>
280.9 + <release-version>2</release-version>
280.10 + <specification-version>2.1</specification-version>
280.11 </run-dependency>
280.12 </dependency>
280.13 <dependency>
281.1 --- a/groovy.gsp/manifest.mf Mon Feb 01 12:23:06 2010 +0100
281.2 +++ b/groovy.gsp/manifest.mf Mon Feb 01 12:24:26 2010 +0100
281.3 @@ -3,4 +3,4 @@
281.4 OpenIDE-Module: org.netbeans.modules.groovy.gsp
281.5 OpenIDE-Module-Layer: org/netbeans/modules/groovy/gsp/resources/layer.xml
281.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/groovy/gsp/resources/Bundle.properties
281.7 -OpenIDE-Module-Specification-Version: 1.12
281.8 +OpenIDE-Module-Specification-Version: 1.13
282.1 --- a/groovy.gsp/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
282.2 +++ b/groovy.gsp/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
282.3 @@ -90,8 +90,8 @@
282.4 <build-prerequisite/>
282.5 <compile-dependency/>
282.6 <run-dependency>
282.7 - <release-version>0-1</release-version>
282.8 - <specification-version>1.19</specification-version>
282.9 + <release-version>2</release-version>
282.10 + <specification-version>2.1</specification-version>
282.11 </run-dependency>
282.12 </dependency>
282.13 <dependency>
283.1 --- a/groovy.gsp/src/org/netbeans/modules/groovy/gsp/GspLanguage.java Mon Feb 01 12:23:06 2010 +0100
283.2 +++ b/groovy.gsp/src/org/netbeans/modules/groovy/gsp/GspLanguage.java Mon Feb 01 12:24:26 2010 +0100
283.3 @@ -42,18 +42,10 @@
283.4 package org.netbeans.modules.groovy.gsp;
283.5
283.6 import org.netbeans.api.lexer.Language;
283.7 -import org.netbeans.modules.csl.api.CodeCompletionHandler;
283.8 -import org.netbeans.modules.csl.api.DeclarationFinder;
283.9 -import org.netbeans.modules.csl.api.Formatter;
283.10 -import org.netbeans.modules.csl.api.HintsProvider;
283.11 -import org.netbeans.modules.csl.api.InstantRenamer;
283.12 -import org.netbeans.modules.csl.api.KeystrokeHandler;
283.13 -import org.netbeans.modules.csl.api.OccurrencesFinder;
283.14 import org.netbeans.modules.csl.api.SemanticAnalyzer;
283.15 import org.netbeans.modules.csl.api.StructureScanner;
283.16 import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
283.17 import org.netbeans.modules.csl.spi.LanguageRegistration;
283.18 -import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
283.19 import org.netbeans.modules.groovy.editor.api.GroovyUtils;
283.20 import org.netbeans.modules.groovy.gsp.lexer.GspTokenId;
283.21 import org.netbeans.modules.parsing.spi.Parser;
283.22 @@ -97,52 +89,6 @@
283.23 }
283.24
283.25 @Override
283.26 - public CodeCompletionHandler getCompletionHandler() {
283.27 - return null;
283.28 - }
283.29 -
283.30 - @Override
283.31 - public DeclarationFinder getDeclarationFinder() {
283.32 - return null;
283.33 - }
283.34 -
283.35 - @Override
283.36 - public boolean hasFormatter() {
283.37 - return false;
283.38 - }
283.39 -
283.40 - @Override
283.41 - public Formatter getFormatter() {
283.42 - return null;
283.43 - }
283.44 -
283.45 - @Override
283.46 - public EmbeddingIndexerFactory getIndexerFactory() {
283.47 - return null;
283.48 - }
283.49 -
283.50 -
283.51 - @Override
283.52 - public InstantRenamer getInstantRenamer() {
283.53 - return null;
283.54 - }
283.55 -
283.56 - @Override
283.57 - public KeystrokeHandler getKeystrokeHandler() {
283.58 - return null;
283.59 - }
283.60 -
283.61 - @Override
283.62 - public boolean hasOccurrencesFinder() {
283.63 - return false;
283.64 - }
283.65 -
283.66 - @Override
283.67 - public OccurrencesFinder getOccurrencesFinder() {
283.68 - return null;
283.69 - }
283.70 -
283.71 - @Override
283.72 public Parser getParser() {
283.73 return new GspParser();
283.74 }
283.75 @@ -162,13 +108,4 @@
283.76 return new GspStructureScanner();
283.77 }
283.78
283.79 - @Override
283.80 - public boolean hasHintsProvider() {
283.81 - return false;
283.82 - }
283.83 -
283.84 - @Override
283.85 - public HintsProvider getHintsProvider() {
283.86 - return null;
283.87 - }
283.88 }
284.1 --- a/groovy.gsp/src/org/netbeans/modules/groovy/gsp/editor/GspKit.java Mon Feb 01 12:23:06 2010 +0100
284.2 +++ b/groovy.gsp/src/org/netbeans/modules/groovy/gsp/editor/GspKit.java Mon Feb 01 12:24:26 2010 +0100
284.3 @@ -56,15 +56,14 @@
284.4 import org.netbeans.lib.editor.util.swing.DocumentUtilities;
284.5 import org.netbeans.editor.Utilities;
284.6 import org.netbeans.editor.ext.ExtKit.ExtDefaultKeyTypedAction;
284.7 -import org.netbeans.modules.csl.core.DeleteToNextCamelCasePosition;
284.8 -import org.netbeans.modules.csl.core.DeleteToPreviousCamelCasePosition;
284.9 -import org.netbeans.modules.csl.core.GsfEditorKitFactory;
284.10 -import org.netbeans.modules.csl.core.NextCamelCasePosition;
284.11 -import org.netbeans.modules.csl.core.PreviousCamelCasePosition;
284.12 -import org.netbeans.modules.csl.core.SelectCodeElementAction;
284.13 -import org.netbeans.modules.csl.core.SelectNextCamelCasePosition;
284.14 -import org.netbeans.modules.csl.core.SelectPreviousCamelCasePosition;
284.15 -import org.netbeans.modules.csl.editor.InstantRenameAction;
284.16 +import org.netbeans.modules.csl.api.DeleteToNextCamelCasePosition;
284.17 +import org.netbeans.modules.csl.api.DeleteToPreviousCamelCasePosition;
284.18 +import org.netbeans.modules.csl.api.InstantRenameAction;
284.19 +import org.netbeans.modules.csl.api.NextCamelCasePosition;
284.20 +import org.netbeans.modules.csl.api.PreviousCamelCasePosition;
284.21 +import org.netbeans.modules.csl.api.SelectCodeElementAction;
284.22 +import org.netbeans.modules.csl.api.SelectNextCamelCasePosition;
284.23 +import org.netbeans.modules.csl.api.SelectPreviousCamelCasePosition;
284.24 import org.netbeans.modules.html.editor.api.HtmlKit;
284.25 import org.netbeans.modules.groovy.gsp.lexer.GspTokenId;
284.26 import org.openide.util.Exceptions;
284.27 @@ -116,16 +115,25 @@
284.28 // new GspToggleCommentAction(),
284.29 new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true),
284.30 new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false),
284.31 - new NextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, nextWordAction)),
284.32 - new PreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, previousWordAction)),
284.33 - new SelectNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionNextWordAction)),
284.34 - new SelectPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionPreviousWordAction)),
284.35 - new DeleteToNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removeNextWordAction)),
284.36 - new DeleteToPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removePreviousWordAction)),
284.37 + new NextCamelCasePosition(findAction(superActions, nextWordAction)),
284.38 + new PreviousCamelCasePosition(findAction(superActions, previousWordAction)),
284.39 + new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)),
284.40 + new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)),
284.41 + new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)),
284.42 + new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)),
284.43 new InstantRenameAction(),
284.44 });
284.45 }
284.46
284.47 + private static Action findAction(Action [] actions, String name) {
284.48 + for(Action a : actions) {
284.49 + Object nameObj = a.getValue(Action.NAME);
284.50 + if (nameObj instanceof String && name.equals(nameObj)) {
284.51 + return a;
284.52 + }
284.53 + }
284.54 + return null;
284.55 + }
284.56 private boolean handleDeletion(BaseDocument doc, int dotPos) {
284.57 if (dotPos > 0) {
284.58 try {
285.1 --- a/groovy.gsp/src/org/netbeans/modules/groovy/gsp/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
285.2 +++ b/groovy.gsp/src/org/netbeans/modules/groovy/gsp/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
285.3 @@ -97,12 +97,22 @@
285.4 <file name="org-netbeans-modules-groovy-gsp-editor-embedding-GroovyEmbeddingProvider$Factory.instance">
285.5 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
285.6 </file>
285.7 - <file name="org-netbeans-modules-groovy-gsp-editor-embedding-HtmlEmbeddingProvider$Factory.instance"/>
285.8 + <file name="org-netbeans-modules-groovy-gsp-editor-embedding-HtmlEmbeddingProvider$Factory.instance">
285.9 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
285.10 + </file>
285.11
285.12 - <file name="org-netbeans-modules-groovy-gsp-GspIndentTaskFactory.instance"/>
285.13 - <file name="org-netbeans-modules-groovy-gsp-EmbeddedSectionsHighlighting$Factory.instance"/>
285.14 - <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
285.15 - <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
285.16 + <file name="org-netbeans-modules-groovy-gsp-GspIndentTaskFactory.instance">
285.17 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
285.18 + </file>
285.19 + <file name="org-netbeans-modules-groovy-gsp-EmbeddedSectionsHighlighting$Factory.instance">
285.20 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
285.21 + </file>
285.22 + <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
285.23 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
285.24 + </file>
285.25 + <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
285.26 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
285.27 + </file>
285.28 <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
285.29 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
285.30 <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
286.1 --- a/groovy.refactoring/manifest.mf Mon Feb 01 12:23:06 2010 +0100
286.2 +++ b/groovy.refactoring/manifest.mf Mon Feb 01 12:24:26 2010 +0100
286.3 @@ -3,5 +3,5 @@
286.4 OpenIDE-Module: org.netbeans.modules.groovy.refactoring
286.5 OpenIDE-Module-Layer: org/netbeans/modules/groovy/refactoring/resources/layer.xml
286.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/groovy/refactoring/resources/Bundle.properties
286.7 -OpenIDE-Module-Specification-Version: 1.11
286.8 +OpenIDE-Module-Specification-Version: 1.12
286.9
287.1 --- a/groovy.refactoring/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
287.2 +++ b/groovy.refactoring/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
287.3 @@ -27,8 +27,8 @@
287.4 <build-prerequisite/>
287.5 <compile-dependency/>
287.6 <run-dependency>
287.7 - <release-version>0-1</release-version>
287.8 - <specification-version>1.8</specification-version>
287.9 + <release-version>2</release-version>
287.10 + <specification-version>2.1</specification-version>
287.11 </run-dependency>
287.12 </dependency>
287.13 <dependency>
288.1 --- a/gsf.codecoverage/manifest.mf Mon Feb 01 12:23:06 2010 +0100
288.2 +++ b/gsf.codecoverage/manifest.mf Mon Feb 01 12:24:26 2010 +0100
288.3 @@ -2,6 +2,6 @@
288.4 OpenIDE-Module: org.netbeans.modules.gsf.codecoverage
288.5 OpenIDE-Module-Layer: org/netbeans/modules/gsf/codecoverage/layer.xml
288.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gsf/codecoverage/Bundle.properties
288.7 -OpenIDE-Module-Specification-Version: 1.6
288.8 +OpenIDE-Module-Specification-Version: 1.7
288.9 AutoUpdate-Show-In-Client: false
288.10
289.1 --- a/gsf.codecoverage/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
289.2 +++ b/gsf.codecoverage/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
289.3 @@ -19,8 +19,8 @@
289.4 <build-prerequisite/>
289.5 <compile-dependency/>
289.6 <run-dependency>
289.7 - <release-version>1</release-version>
289.8 - <specification-version>1.8</specification-version>
289.9 + <release-version>2</release-version>
289.10 + <specification-version>2.1</specification-version>
289.11 </run-dependency>
289.12 </dependency>
289.13 <dependency>
290.1 --- a/html.editor/manifest.mf Mon Feb 01 12:23:06 2010 +0100
290.2 +++ b/html.editor/manifest.mf Mon Feb 01 12:24:26 2010 +0100
290.3 @@ -2,5 +2,5 @@
290.4 OpenIDE-Module: org.netbeans.modules.html.editor/1
290.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/html/editor/resources/Bundle.properties
290.6 OpenIDE-Module-Layer: org/netbeans/modules/html/editor/resources/layer.xml
290.7 -OpenIDE-Module-Specification-Version: 1.19
290.8 +OpenIDE-Module-Specification-Version: 1.20
290.9 AutoUpdate-Show-In-Client: false
291.1 --- a/html.editor/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
291.2 +++ b/html.editor/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
291.3 @@ -51,8 +51,8 @@
291.4 <build-prerequisite/>
291.5 <compile-dependency/>
291.6 <run-dependency>
291.7 - <release-version>1</release-version>
291.8 - <specification-version>1.19</specification-version>
291.9 + <release-version>2</release-version>
291.10 + <specification-version>2.1</specification-version>
291.11 </run-dependency>
291.12 </dependency>
291.13 <dependency>
292.1 --- a/html.editor/src/org/netbeans/modules/html/editor/api/HtmlKit.java Mon Feb 01 12:23:06 2010 +0100
292.2 +++ b/html.editor/src/org/netbeans/modules/html/editor/api/HtmlKit.java Mon Feb 01 12:24:26 2010 +0100
292.3 @@ -51,7 +51,6 @@
292.4 import java.io.Reader;
292.5 import java.io.StringReader;
292.6 import java.io.StringWriter;
292.7 -import java.util.List;
292.8 import javax.swing.Action;
292.9 import javax.swing.JComponent;
292.10 import javax.swing.JEditorPane;
292.11 @@ -69,12 +68,11 @@
292.12 import org.netbeans.editor.BaseKit.DeleteCharAction;
292.13 import org.netbeans.editor.ext.ExtKit;
292.14 import org.netbeans.editor.ext.ExtKit.ExtDefaultKeyTypedAction;
292.15 +import org.netbeans.modules.csl.api.InstantRenameAction;
292.16 import org.netbeans.modules.csl.api.KeystrokeHandler;
292.17 -import org.netbeans.modules.csl.core.Language;
292.18 -import org.netbeans.modules.csl.core.LanguageRegistry;
292.19 -import org.netbeans.modules.csl.core.SelectCodeElementAction;
292.20 -import org.netbeans.modules.csl.editor.InstantRenameAction;
292.21 -import org.netbeans.modules.csl.editor.ToggleBlockCommentAction;
292.22 +import org.netbeans.modules.csl.api.SelectCodeElementAction;
292.23 +import org.netbeans.modules.csl.api.ToggleBlockCommentAction;
292.24 +import org.netbeans.modules.csl.api.UiUtils;
292.25 import org.netbeans.modules.editor.NbEditorKit;
292.26 import org.netbeans.modules.html.editor.gsf.HtmlCommentHandler;
292.27 import org.openide.util.Exceptions;
292.28 @@ -87,7 +85,7 @@
292.29 */
292.30 public class HtmlKit extends NbEditorKit implements org.openide.util.HelpCtx.Provider {
292.31
292.32 - public org.openide.util.HelpCtx getHelpCtx() {
292.33 + public @Override org.openide.util.HelpCtx getHelpCtx() {
292.34 return new org.openide.util.HelpCtx(HtmlKit.class);
292.35 }
292.36 static final long serialVersionUID = -1381945567613910297L;
292.37 @@ -147,18 +145,6 @@
292.38 return TextAction.augmentList(super.createActions(), HtmlActions);
292.39 }
292.40
292.41 - static KeystrokeHandler getBracketCompletion(Document doc, int offset) {
292.42 - BaseDocument baseDoc = (BaseDocument) doc;
292.43 - List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset);
292.44 - for (Language l : list) {
292.45 - if (l.getBracketCompletion() != null) {
292.46 - return l.getBracketCompletion();
292.47 - }
292.48 - }
292.49 -
292.50 - return null;
292.51 - }
292.52 -
292.53 /**
292.54 * Returns true if bracket completion is enabled in options.
292.55 */
292.56 @@ -174,7 +160,7 @@
292.57 @Override
292.58 protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) {
292.59 if (completionSettingEnabled()) {
292.60 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, caret.getDot());
292.61 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, caret.getDot());
292.62
292.63 if (bracketCompletion != null) {
292.64 try {
292.65 @@ -230,7 +216,7 @@
292.66 boolean overwrite) throws BadLocationException {
292.67
292.68 if (completionSettingEnabled()) {
292.69 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
292.70 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
292.71
292.72 if (bracketCompletion != null) {
292.73 // TODO - check if we're in a comment etc. and if so, do nothing
292.74 @@ -262,7 +248,7 @@
292.75 BaseDocument doc = (BaseDocument) document;
292.76
292.77 if (completionSettingEnabled()) {
292.78 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
292.79 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
292.80
292.81 if (bracketCompletion != null) {
292.82 try {
292.83 @@ -323,7 +309,7 @@
292.84 @Override
292.85 protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch) throws BadLocationException {
292.86 if (completionSettingEnabled()) {
292.87 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
292.88 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
292.89
292.90 if (bracketCompletion != null) {
292.91 boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch);
293.1 --- a/html.editor/src/org/netbeans/modules/html/editor/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
293.2 +++ b/html.editor/src/org/netbeans/modules/html/editor/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
293.3 @@ -95,7 +95,9 @@
293.4 <attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/>
293.5 </file>
293.6
293.7 - <file name="org-netbeans-modules-html-editor-xhtml-XhtmlElEmbeddingProvider$Factory.instance"/>
293.8 + <file name="org-netbeans-modules-html-editor-xhtml-XhtmlElEmbeddingProvider$Factory.instance">
293.9 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
293.10 + </file>
293.11
293.12 <file name="org-netbeans-modules-html-editor-HtmlCaretAwareSourceTask$Factory.instance">
293.13 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
293.14 @@ -105,9 +107,15 @@
293.15 <file name="org-netbeans-modules-html-editor-preferences.xml" url="Preferences.xml"/>
293.16 </folder>
293.17
293.18 - <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
293.19 - <file name="org-netbeans-modules-html-editor-xhtml.XhtmlElHighlighting$Factory.instance"/>
293.20 - <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
293.21 + <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
293.22 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
293.23 + </file>
293.24 + <file name="org-netbeans-modules-html-editor-xhtml.XhtmlElHighlighting$Factory.instance">
293.25 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
293.26 + </file>
293.27 + <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
293.28 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
293.29 + </file>
293.30 <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
293.31 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
293.32 <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
293.33 @@ -208,8 +216,12 @@
293.34 <file name="org-netbeans-modules-html-editor-preferences.xml" url="Preferences.xml"/>
293.35 </folder>
293.36
293.37 - <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
293.38 - <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
293.39 + <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
293.40 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
293.41 + </file>
293.42 + <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
293.43 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
293.44 + </file>
293.45 <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
293.46 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
293.47 <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
293.48 @@ -235,7 +247,9 @@
293.49 </file>
293.50 </folder>
293.51
293.52 - <file name="org-netbeans-modules-html-editor-indent-HtmlIndentTaskFactory.instance"/>
293.53 + <file name="org-netbeans-modules-html-editor-indent-HtmlIndentTaskFactory.instance">
293.54 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
293.55 + </file>
293.56
293.57 <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.html.editor.resources.Bundle"/>
293.58 <folder name="FontsColors">
294.1 --- a/html/manifest.mf Mon Feb 01 12:23:06 2010 +0100
294.2 +++ b/html/manifest.mf Mon Feb 01 12:24:26 2010 +0100
294.3 @@ -2,6 +2,6 @@
294.4 OpenIDE-Module: org.netbeans.modules.html/1
294.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/html/Bundle.properties
294.6 OpenIDE-Module-Layer: org/netbeans/modules/html/mf-layer.xml
294.7 -OpenIDE-Module-Specification-Version: 1.30
294.8 +OpenIDE-Module-Specification-Version: 1.31
294.9 OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
294.10 AutoUpdate-Show-In-Client: false
295.1 --- a/html/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
295.2 +++ b/html/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
295.3 @@ -60,8 +60,8 @@
295.4 <build-prerequisite/>
295.5 <compile-dependency/>
295.6 <run-dependency>
295.7 - <release-version>1</release-version>
295.8 - <specification-version>1.11</specification-version>
295.9 + <release-version>2</release-version>
295.10 + <specification-version>2.1</specification-version>
295.11 </run-dependency>
295.12 </dependency>
295.13 <dependency>
296.1 --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/jpa/dao/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
296.2 +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/jpa/dao/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
296.3 @@ -40,6 +40,7 @@
296.4 Templates/Persistence/ejbFacade=Session Beans For Entity Classes
296.5 Templates/J2EE/ejbFacade=Session Beans For Entity Classes
296.6 LBL_SpecifyLocation=Specify the location of new Session Bean classes
296.7 +LBL_PersistenceUnitSetup=Persistence Unit Provider and Database
296.8
296.9 LBL_Project=Project\:
296.10
297.1 --- a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/jpa/dao/EjbFacadeWizardIterator.java Mon Feb 01 12:23:06 2010 +0100
297.2 +++ b/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/jpa/dao/EjbFacadeWizardIterator.java Mon Feb 01 12:24:26 2010 +0100
297.3 @@ -49,10 +49,13 @@
297.4 import com.sun.source.tree.Tree;
297.5 import com.sun.source.tree.TypeParameterTree;
297.6 import com.sun.source.tree.VariableTree;
297.7 +import com.sun.source.util.TreePath;
297.8 import java.awt.Component;
297.9 import java.io.IOException;
297.10 +import java.util.ArrayList;
297.11 import java.util.Arrays;
297.12 import java.util.Collections;
297.13 +import java.util.EnumSet;
297.14 import java.util.HashMap;
297.15 import java.util.HashSet;
297.16 import java.util.List;
297.17 @@ -65,6 +68,7 @@
297.18 import java.util.logging.Logger;
297.19 import javax.lang.model.element.Modifier;
297.20 import javax.lang.model.element.TypeElement;
297.21 +import javax.lang.model.type.TypeKind;
297.22 import javax.swing.JComponent;
297.23 import javax.swing.event.ChangeListener;
297.24 import org.netbeans.api.java.source.JavaSource;
297.25 @@ -94,7 +98,10 @@
297.26 import org.netbeans.modules.j2ee.persistence.spi.entitymanagergenerator.ContainerManagedJTAInjectableInEJB;
297.27 import org.netbeans.modules.j2ee.persistence.spi.entitymanagergenerator.EntityManagerGenerationStrategy;
297.28 import org.netbeans.modules.j2ee.persistence.wizard.PersistenceClientEntitySelection;
297.29 +import org.netbeans.modules.j2ee.persistence.wizard.Util;
297.30 import org.netbeans.modules.j2ee.persistence.wizard.WizardProperties;
297.31 +import org.netbeans.modules.j2ee.persistence.wizard.unit.PersistenceUnitWizardDescriptor;
297.32 +import org.netbeans.modules.j2ee.persistence.wizard.unit.PersistenceUnitWizardPanel.TableGeneration;
297.33 import org.netbeans.spi.project.ui.templates.support.Templates;
297.34 import org.openide.WizardDescriptor;
297.35 import org.openide.filesystems.FileObject;
297.36 @@ -105,13 +112,14 @@
297.37
297.38 /**
297.39 * Generates EJB facades for entity classes.
297.40 - *
297.41 + *
297.42 * @author Martin Adamek, Erno Mononen
297.43 - */
297.44 + */
297.45 public final class EjbFacadeWizardIterator implements WizardDescriptor.ProgressInstantiatingIterator {
297.46 -
297.47 +
297.48 private static final String WIZARD_PANEL_CONTENT_DATA = WizardDescriptor.PROP_CONTENT_DATA; // NOI18N
297.49
297.50 + private static final String FACADE_ABSTRACT = "AbstractFacade"; //NOI18N
297.51 private static final String FACADE_SUFFIX = "Facade"; //NOI18N
297.52 private static final String FACADE_REMOTE_SUFFIX = FACADE_SUFFIX + "Remote"; //NOI18N
297.53 private static final String FACADE_LOCAL_SUFFIX = FACADE_SUFFIX + "Local"; //NOI18N
297.54 @@ -126,22 +134,24 @@
297.55 private int stepsStartPos;
297.56 private Project project;
297.57 /**
297.58 - * Contains the names of the entities. Key the FQN class name,
297.59 + * Contains the names of the entities. Key the FQN class name,
297.60 * value the name of the entity.
297.61 - */
297.62 + */
297.63 private final Map<String, String> entityNames = new HashMap<String, String>();
297.64 -
297.65 +
297.66 private static final String EJB30_STATELESS_EJBCLASS = "Templates/J2EE/EJB30/StatelessEjbClass.java"; // NOI18N
297.67 -
297.68 +
297.69 private WizardDescriptor.Panel[] getPanels() {
297.70 return panels;
297.71 }
297.72 -
297.73 +
297.74 + @Override
297.75 public Set instantiate() throws IOException {
297.76 assert true : "should never be called, instantiate(ProgressHandle) should be called instead";
297.77 return null;
297.78 }
297.79
297.80 + @Override
297.81 public Set instantiate(ProgressHandle handle) throws IOException {
297.82 try {
297.83 return instantiateWProgress(handle);
297.84 @@ -160,23 +170,30 @@
297.85 final Set<FileObject> createdFiles = new HashSet<FileObject>();
297.86 final EjbFacadeWizardPanel2 panel = (EjbFacadeWizardPanel2) panels[1];
297.87 String pkg = panel.getPackage();
297.88 -
297.89 - PersistenceUnit persistenceUnit = (PersistenceUnit) wizard.getProperty(WizardProperties.PERSISTENCE_UNIT);
297.90 - int stepsCount = entities.size() + (persistenceUnit!=null ? 1 : 0);
297.91 +
297.92 + boolean createPersistenceUnit = (Boolean) wizard.getProperty(WizardProperties.CREATE_PERSISTENCE_UNIT);
297.93 + int stepsCount = entities.size() + (createPersistenceUnit ? 1 : 0);
297.94 int step = 0;
297.95 handle.start(stepsCount);
297.96
297.97 - if (persistenceUnit != null) {
297.98 - try {
297.99 - handle.progress(NbBundle.getMessage(EjbFacadeWizardIterator.class, "MSG_AddPU"), step++);
297.100 - ProviderUtil.addPersistenceUnit(persistenceUnit, project);
297.101 - } catch (InvalidPersistenceXmlException ipx) {
297.102 - // just log for debugging purposes, at this point the user has
297.103 - // already been warned about an invalid persistence.xml
297.104 - Logger.getLogger(EjbFacadeWizardIterator.class.getName()).log(Level.FINE, "Invalid persistence.xml: " + ipx.getPath(), ipx); //NOI18N
297.105 + if (createPersistenceUnit) {
297.106 + PersistenceUnitWizardDescriptor puPanel = (PersistenceUnitWizardDescriptor) (panels[panels.length - 1] instanceof PersistenceUnitWizardDescriptor ? panels[panels.length - 1] : null);
297.107 + if(puPanel!=null){
297.108 + try {
297.109 + handle.progress(NbBundle.getMessage(EjbFacadeWizardIterator.class, "MSG_AddPU"), step++);
297.110 + PersistenceUnit punit = Util.buildPersistenceUnitUsingData(project, puPanel.getPersistenceUnitName(), puPanel.getPersistenceConnection()!=null ? puPanel.getPersistenceConnection().getName() : puPanel.getDatasource(), TableGeneration.NONE, puPanel.getSelectedProvider());
297.111 + ProviderUtil.setTableGeneration(punit, puPanel.getTableGeneration(), puPanel.getSelectedProvider());
297.112 + if (punit != null){
297.113 + ProviderUtil.addPersistenceUnit(punit, project);
297.114 + }
297.115 + } catch (InvalidPersistenceXmlException ipx) {
297.116 + // just log for debugging purposes, at this point the user has
297.117 + // already been warned about an invalid persistence.xml
297.118 + Logger.getLogger(EjbFacadeWizardIterator.class.getName()).log(Level.FINE, "Invalid persistence.xml: " + ipx.getPath(), ipx); //NOI18N
297.119 + }
297.120 }
297.121 }
297.122 -
297.123 +
297.124 for (String entity : entities) {
297.125 handle.progress(NbBundle.getMessage(EjbFacadeWizardIterator.class, "MSG_GenSessionBean", entity), step++);
297.126 createdFiles.addAll(generate(targetFolder, entity, pkg, panel.isRemote(), panel.isLocal(), false));
297.127 @@ -186,7 +203,7 @@
297.128
297.129 return createdFiles;
297.130 }
297.131 -
297.132 +
297.133 /**
297.134 * Generates the facade and the loca/remote interface(s) for the given
297.135 * entity class.
297.136 @@ -195,14 +212,14 @@
297.137 * @param pkg the package prefix for the generated facede.
297.138 * @param hasRemote specifies whether a remote interface is generated.
297.139 * @param hasLocal specifies whether a local interface is generated.
297.140 - *
297.141 + *
297.142 * @return a set containing the generated files.
297.143 - */
297.144 + */
297.145 private Set<FileObject> generate(final FileObject targetFolder, final String entityClass, String pkg, final boolean hasRemote, final boolean hasLocal, boolean overrideExisting) throws IOException {
297.146 return generate(targetFolder, entityClass, pkg, hasRemote, hasLocal, ContainerManagedJTAInjectableInEJB.class, overrideExisting);
297.147 }
297.148 -
297.149 -
297.150 +
297.151 +
297.152 /**
297.153 * Generates the facade and the loca/remote interface(s) for thhe given
297.154 * entity class.
297.155 @@ -212,19 +229,98 @@
297.156 * @param pkg the package prefix for the generated facede.
297.157 * @param hasRemote specifies whether a remote interface is generated.
297.158 * @param hasLocal specifies whether a local interface is generated.
297.159 - * @param strategyClass the entity manager lookup strategy.
297.160 - *
297.161 + * @param strategyClass the entity manager lookup strategy.
297.162 + *
297.163 * @return a set containing the generated files.
297.164 - */
297.165 - Set<FileObject> generate(final FileObject targetFolder, final String entityFQN,
297.166 - String pkg, final boolean hasRemote, final boolean hasLocal,
297.167 + */
297.168 + Set<FileObject> generate(final FileObject targetFolder, final String entityFQN,
297.169 + String pkg, final boolean hasRemote, final boolean hasLocal,
297.170 final Class<? extends EntityManagerGenerationStrategy> strategyClass,
297.171 boolean overrideExisting) throws IOException {
297.172 -
297.173 +
297.174 final Set<FileObject> createdFiles = new HashSet<FileObject>();
297.175 final String entitySimpleName = JavaIdentifiers.unqualify(entityFQN);
297.176 final String variableName = entitySimpleName.toLowerCase().charAt(0) + entitySimpleName.substring(1);
297.177 -
297.178 +
297.179 + //create the abstract facade class
297.180 + final String afName = pkg + "." + FACADE_ABSTRACT;
297.181 + FileObject afFO = targetFolder.getFileObject(FACADE_ABSTRACT, "java");
297.182 + if (afFO == null){
297.183 + afFO = GenerationUtils.createClass(targetFolder, FACADE_ABSTRACT, null);
297.184 + createdFiles.add(afFO);
297.185 +
297.186 + JavaSource source = JavaSource.forFileObject(afFO);
297.187 + source.runModificationTask(new Task<WorkingCopy>(){
297.188 + public void run(WorkingCopy workingCopy) throws Exception {
297.189 + workingCopy.toPhase(Phase.RESOLVED);
297.190 + ClassTree classTree = SourceUtils.getPublicTopLevelTree(workingCopy);
297.191 + assert classTree != null;
297.192 + TreeMaker maker = workingCopy.getTreeMaker();
297.193 + GenerationUtils genUtils = GenerationUtils.newInstance(workingCopy);
297.194 + TreePath classTreePath = workingCopy.getTrees().getPath(workingCopy.getCompilationUnit(), classTree);
297.195 + TypeElement classElement = (TypeElement)workingCopy.getTrees().getElement(classTreePath);
297.196 +
297.197 + String genericsTypeName = "T"; //NOI18N
297.198 + List<GenerationOptions> methodOptions = getAbstractFacadeMethodOptions(genericsTypeName, "entity"); //NOI18N
297.199 + List<Tree> members = new ArrayList();
297.200 + String entityClassVar = "entityClass"; //NOI18N
297.201 + Tree classObjectTree = genUtils.createType("java.lang.Class<" + genericsTypeName + ">", classElement); //NOI18N
297.202 + members.add(maker.Variable(genUtils.createModifiers(Modifier.PRIVATE),entityClassVar,classObjectTree,null));
297.203 + members.add(maker.Constructor(
297.204 + genUtils.createModifiers(Modifier.PUBLIC),
297.205 + Collections.EMPTY_LIST,
297.206 + Arrays.asList(new VariableTree[]{genUtils.createVariable(entityClassVar,classObjectTree)}),
297.207 + Collections.EMPTY_LIST,
297.208 + "{this." + entityClassVar + " = " + entityClassVar + ";}")); //NOI18N
297.209 + for(GenerationOptions option: methodOptions){
297.210 + Tree returnType = (option.getReturnType() == null || option.getReturnType().equals("void"))? //NOI18N
297.211 + maker.PrimitiveType(TypeKind.VOID):
297.212 + genUtils.createType(option.getReturnType(), classElement);
297.213 + List<VariableTree> vars = option.getParameterName() == null ? Collections.EMPTY_LIST :
297.214 + Arrays.asList(new VariableTree[]{
297.215 + genUtils.createVariable(
297.216 + option.getParameterName(),
297.217 + genUtils.createType(option.getParameterType(), classElement)
297.218 + )
297.219 + });
297.220 +
297.221 + if (option.getOperation() == null){
297.222 + members.add(maker.Method(
297.223 + maker.Modifiers(EnumSet.of(Modifier.PUBLIC, Modifier.ABSTRACT)),
297.224 + option.getMethodName(),
297.225 + returnType,
297.226 + Collections.EMPTY_LIST,
297.227 + vars,
297.228 + (List<ExpressionTree>)Collections.EMPTY_LIST,
297.229 + (BlockTree)null,
297.230 + null));
297.231 + } else {
297.232 + members.add(maker.Method(
297.233 + genUtils.createModifiers(Modifier.PUBLIC),
297.234 + option.getMethodName(),
297.235 + returnType,
297.236 + (List<TypeParameterTree>)Collections.EMPTY_LIST,
297.237 + vars,
297.238 + (List<ExpressionTree>)Collections.EMPTY_LIST,
297.239 + "{" + option.getCallLines("getEntityManager()", entityClassVar) + "}", //NOI18N
297.240 + null));
297.241 + }
297.242 + }
297.243 +
297.244 + ClassTree newClassTree = maker.Class(
297.245 + maker.Modifiers(EnumSet.of(Modifier.PUBLIC, Modifier.ABSTRACT)),
297.246 + classTree.getSimpleName(),
297.247 + Arrays.asList(maker.TypeParameter(genericsTypeName, Collections.EMPTY_LIST)),
297.248 + null,
297.249 + Collections.EMPTY_LIST,
297.250 + members);
297.251 +
297.252 + workingCopy.rewrite(classTree, newClassTree);
297.253 + }
297.254 + }).commit();
297.255 +
297.256 + }
297.257 +
297.258 // create the facade
297.259 FileObject existingFO = targetFolder.getFileObject(entitySimpleName + FACADE_SUFFIX, "java");
297.260 if (existingFO != null) {
297.261 @@ -236,7 +332,7 @@
297.262 }
297.263 final FileObject facade = GenerationUtils.createClass(targetFolder, entitySimpleName + FACADE_SUFFIX, null);
297.264 createdFiles.add(facade);
297.265 - // add the @stateless annotation
297.266 + // add the @stateless annotation
297.267 JavaSource source = JavaSource.forFileObject(facade);
297.268 source.runModificationTask(new Task<WorkingCopy>(){
297.269 public void run(WorkingCopy parameter) throws Exception {
297.270 @@ -271,7 +367,7 @@
297.271 createdFiles.add(remote);
297.272 }
297.273
297.274 - // add implements clauses to the facade
297.275 + // add implements and extends clauses to the facade
297.276 source.runModificationTask(new Task<WorkingCopy>() {
297.277
297.278 public void run(WorkingCopy parameter) throws Exception {
297.279 @@ -279,6 +375,7 @@
297.280 ClassTree classTree = SourceUtils.getPublicTopLevelTree(parameter);
297.281 assert classTree != null;
297.282 GenerationUtils genUtils = GenerationUtils.newInstance(parameter);
297.283 + TreeMaker maker = parameter.getTreeMaker();
297.284 ClassTree newClassTree = classTree;
297.285 if (hasLocal){
297.286 newClassTree = genUtils.addImplementsClause(newClassTree, localInterfaceFQN);
297.287 @@ -286,19 +383,46 @@
297.288 if (hasRemote){
297.289 newClassTree = genUtils.addImplementsClause(newClassTree, remoteInterfaceFQN);
297.290 }
297.291 + newClassTree = maker.setExtends(newClassTree, (ExpressionTree)genUtils.createType(
297.292 + afName + "<" + entityFQN + ">",
297.293 + SourceUtils.getPublicTopLevelElement(parameter)
297.294 + ));
297.295 + MethodTree constructor = maker.Constructor(
297.296 + genUtils.createModifiers(Modifier.PUBLIC),
297.297 + Collections.EMPTY_LIST,
297.298 + Collections.EMPTY_LIST,
297.299 + Collections.EMPTY_LIST,
297.300 + "{super(" + entitySimpleName + ".class);}"); //NOI18N
297.301 + newClassTree = maker.addClassMember(newClassTree, constructor);
297.302 parameter.rewrite(classTree, newClassTree);
297.303 }
297.304 }).commit();
297.305 -
297.306 +
297.307 return createdFiles;
297.308 }
297.309 -
297.310 +
297.311 /**
297.312 * @return the options representing the methods for a facade, i.e. create/edit/
297.313 * find/remove/findAll.
297.314 - */
297.315 + */
297.316 private List<GenerationOptions> getMethodOptions(String entityFQN, String variableName){
297.317
297.318 + GenerationOptions getEMOptions = new GenerationOptions();
297.319 + getEMOptions.setMethodName("getEntityManager"); //NOI18N
297.320 + getEMOptions.setOperation(GenerationOptions.Operation.GET_EM);
297.321 + getEMOptions.setReturnType("javax.persistence.EntityManager");//NOI18N
297.322 +
297.323 + return Arrays.<GenerationOptions>asList(getEMOptions);
297.324 + }
297.325 +
297.326 + private List<GenerationOptions> getAbstractFacadeMethodOptions(String entityFQN, String variableName){
297.327 + //abstract methods
297.328 +
297.329 + GenerationOptions getEMOptions = new GenerationOptions();
297.330 + getEMOptions.setMethodName("getEntityManager"); //NOI18N
297.331 + getEMOptions.setReturnType("javax.persistence.EntityManager");//NOI18N
297.332 +
297.333 + //implemented methods
297.334 GenerationOptions createOptions = new GenerationOptions();
297.335 createOptions.setMethodName("create"); //NOI18N
297.336 createOptions.setOperation(GenerationOptions.Operation.PERSIST);
297.337 @@ -347,20 +471,20 @@
297.338 countOptions.setReturnType("int");//NOI18N
297.339 countOptions.setQueryAttribute(getEntityName(entityFQN));
297.340
297.341 - return Arrays.<GenerationOptions>asList(createOptions, editOptions, destroyOptions, findOptions, findAllOptions, findSubOptions, countOptions);
297.342 + return Arrays.<GenerationOptions>asList(getEMOptions, createOptions, editOptions, destroyOptions, findOptions, findAllOptions, findSubOptions, countOptions);
297.343 }
297.344
297.345 /**
297.346 *@return the name for the given <code>entityFQN</code>.
297.347 - */
297.348 + */
297.349 private String getEntityName(String entityFQN){
297.350 String result = entityNames.get(entityFQN);
297.351 return result != null ? result : JavaIdentifiers.unqualify(entityFQN);
297.352 }
297.353 -
297.354 +
297.355 /**
297.356 * Initializes the {@link #entityNames} map.
297.357 - */
297.358 + */
297.359 private void initEntityNames() throws IOException{
297.360 if (project == null){
297.361 // just to facilitate testing, avoids the need to provide a project (together with the getEntityName method)
297.362 @@ -372,6 +496,7 @@
297.363 MetadataModel<EntityMappingsMetadata> entityMappingsModel = entityClassScope.getEntityMappingsModel(true);
297.364 Future<Void> result = entityMappingsModel.runReadActionWhenReady(new MetadataModelAction<EntityMappingsMetadata, Void>() {
297.365
297.366 + @Override
297.367 public Void run(EntityMappingsMetadata metadata) throws Exception {
297.368 for (Entity entity : metadata.getRoot().getEntity()) {
297.369 entityNames.put(entity.getClass2(), entity.getName());
297.370 @@ -386,26 +511,27 @@
297.371 Exceptions.printStackTrace(ex);
297.372 }
297.373 }
297.374 -
297.375 +
297.376 String getUniqueClassName(String candidateName, FileObject targetFolder){
297.377 return FileUtil.findFreeFileName(targetFolder, candidateName, "java"); //NOI18N
297.378 }
297.379 -
297.380 +
297.381 /**
297.382 * Creates an interface with the given <code>name</code>, annotated with an annotation
297.383 * of the given <code>annotationType</code>. <i>Package private visibility just because of tests</i>.
297.384 - *
297.385 + *
297.386 * @param name the name for the interface
297.387 * @param annotationType the FQN of the annotation
297.388 * @param targetFolder the folder to which the interface is generated
297.389 - *
297.390 + *
297.391 * @return the generated interface.
297.392 */
297.393 FileObject createInterface(String name, final String annotationType, FileObject targetFolder) throws IOException {
297.394 FileObject sourceFile = GenerationUtils.createInterface(targetFolder, name, null);
297.395 JavaSource source = JavaSource.forFileObject(sourceFile);
297.396 ModificationResult result = source.runModificationTask(new Task<WorkingCopy>() {
297.397 -
297.398 +
297.399 + @Override
297.400 public void run(WorkingCopy workingCopy) throws Exception {
297.401 workingCopy.toPhase(Phase.RESOLVED);
297.402 ClassTree clazz = SourceUtils.getPublicTopLevelTree(workingCopy);
297.403 @@ -421,21 +547,22 @@
297.404 result.commit();
297.405 return source.getFileObjects().iterator().next();
297.406 }
297.407 -
297.408 +
297.409 /**
297.410 * Adds a method to the given interface.
297.411 - *
297.412 + *
297.413 * @param name the name of the method.
297.414 * @param returnType the return type of the method.
297.415 * @param parameterName the name of the parameter for the method.
297.416 * @param parameterType the FQN type of the parameter.
297.417 * @param target the target interface.
297.418 - */
297.419 + */
297.420 void addMethodToInterface(final List<GenerationOptions> options, final FileObject target) throws IOException {
297.421 -
297.422 +
297.423 JavaSource source = JavaSource.forFileObject(target);
297.424 ModificationResult result = source.runModificationTask(new Task<WorkingCopy>() {
297.425 -
297.426 +
297.427 + @Override
297.428 public void run(WorkingCopy copy) throws Exception {
297.429 copy.toPhase(Phase.RESOLVED);
297.430 GenerationUtils utils = GenerationUtils.newInstance(copy);
297.431 @@ -445,8 +572,8 @@
297.432 ClassTree modifiedClass = original;
297.433 TreeMaker make = copy.getTreeMaker();
297.434 for (GenerationOptions each : options) {
297.435 - MethodTree method = make.Method(make.Modifiers(Collections.<Modifier>emptySet()),
297.436 - each.getMethodName(), utils.createType(each.getReturnType(), typeElement),
297.437 + MethodTree method = make.Method(make.Modifiers(Collections.<Modifier>emptySet()),
297.438 + each.getMethodName(), utils.createType(each.getReturnType(), typeElement),
297.439 Collections.<TypeParameterTree>emptyList(), getParameterList(each, make, utils, typeElement),
297.440 Collections.<ExpressionTree>emptyList(), (BlockTree) null, null);
297.441 modifiedClass = make.addClassMember(modifiedClass, method);
297.442 @@ -456,30 +583,46 @@
297.443 });
297.444 result.commit();
297.445 }
297.446 -
297.447 +
297.448 private List<VariableTree> getParameterList(GenerationOptions options, TreeMaker make, GenerationUtils utils, TypeElement scope){
297.449 if (options.getParameterName() == null){
297.450 return Collections.<VariableTree>emptyList();
297.451 }
297.452 - VariableTree vt = make.Variable(make.Modifiers(Collections.<Modifier>emptySet()),
297.453 + VariableTree vt = make.Variable(make.Modifiers(Collections.<Modifier>emptySet()),
297.454 options.getParameterName(), utils.createType(options.getParameterType(), scope), null);
297.455 return Collections.<VariableTree>singletonList(vt);
297.456 }
297.457 -
297.458 +
297.459 + @Override
297.460 public void initialize(WizardDescriptor wizard) {
297.461 this.wizard = wizard;
297.462 wizard.putProperty("NewFileWizard_Title", NbBundle.getMessage(EjbFacadeWizardIterator.class, "Templates/Persistence/ejbFacade"));
297.463 Project project = Templates.getProject(wizard);
297.464 -
297.465 +
297.466 // http://www.netbeans.org/issues/show_bug.cgi?id=126642
297.467 //if (Templates.getTargetFolder(wizard) == null) {
297.468 // Templates.setTargetFolder(wizard, project.getProjectDirectory());
297.469 //}
297.470 -
297.471 +
297.472 if (panels == null) {
297.473 - panels = new WizardDescriptor.Panel[]{new PersistenceClientEntitySelection(NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_EntityClasses"), new HelpCtx(EjbFacadeWizardIterator.class.getName() + "$PersistenceClientEntitySelection"), wizard), new EjbFacadeWizardPanel2(project, wizard)};
297.474 + boolean noPuNeeded = true;
297.475 + try {
297.476 + noPuNeeded = ProviderUtil.persistenceExists(project) || !ProviderUtil.isValidServerInstanceOrNone(project);
297.477 + } catch (InvalidPersistenceXmlException ex) {
297.478 + Logger.getLogger(EjbFacadeWizardIterator.class.getName()).log(Level.FINE, "Invalid persistence.xml: "+ ex.getPath()); //NOI18N
297.479 + }
297.480 + String names[]=null;
297.481 + if(noPuNeeded){
297.482 + panels = new WizardDescriptor.Panel[]{new PersistenceClientEntitySelection(NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_EntityClasses"), new HelpCtx(EjbFacadeWizardIterator.class.getName() + "$PersistenceClientEntitySelection"), wizard), new EjbFacadeWizardPanel2(project, wizard)};
297.483 + names = new String[]{NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_EntityClasses"), NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_GeneratedSessionBeans")};
297.484 + } else {
297.485 + panels = new WizardDescriptor.Panel[]{new PersistenceClientEntitySelection(NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_EntityClasses"), new HelpCtx(EjbFacadeWizardIterator.class.getName() + "$PersistenceClientEntitySelection"), wizard), new EjbFacadeWizardPanel2(project, wizard), new PersistenceUnitWizardDescriptor(project)};
297.486 + names = new String[]{NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_EntityClasses"), NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_GeneratedSessionBeans"), NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_PersistenceUnitSetup")};
297.487 + }
297.488 +
297.489 +
297.490 if (steps == null) {
297.491 - mergeSteps(new String[]{NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_EntityClasses"), NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_GeneratedSessionBeans")});
297.492 + mergeSteps(names);
297.493 }
297.494 for (int i = 0; i < panels.length; i++) {
297.495 Component c = panels[i].getComponent();
297.496 @@ -502,49 +645,58 @@
297.497 }
297.498 }
297.499 }
297.500 -
297.501 +
297.502 + @Override
297.503 public void uninitialize(WizardDescriptor wizard) {
297.504 panels = null;
297.505 }
297.506 -
297.507 +
297.508 + @Override
297.509 public WizardDescriptor.Panel current() {
297.510 return getPanels()[index];
297.511 }
297.512 -
297.513 +
297.514 + @Override
297.515 public String name() {
297.516 return NbBundle.getMessage(EjbFacadeWizardIterator.class, "LBL_FacadeWizardTitle");
297.517 }
297.518 -
297.519 +
297.520 + @Override
297.521 public boolean hasNext() {
297.522 return index < getPanels().length - 1;
297.523 }
297.524 -
297.525 +
297.526 + @Override
297.527 public boolean hasPrevious() {
297.528 return index > 0;
297.529 }
297.530 -
297.531 +
297.532 + @Override
297.533 public void nextPanel() {
297.534 if (!hasNext()) {
297.535 throw new NoSuchElementException();
297.536 }
297.537 index++;
297.538 }
297.539 -
297.540 +
297.541 + @Override
297.542 public void previousPanel() {
297.543 if (!hasPrevious()) {
297.544 throw new NoSuchElementException();
297.545 }
297.546 index--;
297.547 }
297.548 -
297.549 +
297.550 // If nothing unusual changes in the middle of the wizard, simply:
297.551 + @Override
297.552 public void addChangeListener(ChangeListener l) {}
297.553 + @Override
297.554 public void removeChangeListener(ChangeListener l) {}
297.555 -
297.556 +
297.557 private void mergeSteps(String[] thisSteps) {
297.558 Object prop = wizard.getProperty(WIZARD_PANEL_CONTENT_DATA);
297.559 String[] beforeSteps;
297.560 -
297.561 +
297.562 if (prop instanceof String[]) {
297.563 beforeSteps = (String[]) prop;
297.564 stepsStartPos = beforeSteps.length;
297.565 @@ -555,7 +707,7 @@
297.566 beforeSteps = null;
297.567 stepsStartPos = 0;
297.568 }
297.569 -
297.570 +
297.571 steps = new String[stepsStartPos + thisSteps.length];
297.572 System.arraycopy(beforeSteps, 0, steps, 0, stepsStartPos);
297.573 System.arraycopy(thisSteps, 0, steps, stepsStartPos, thisSteps.length);
297.574 @@ -564,7 +716,7 @@
297.575 public static FileObject[] generateSessionBeans(ProgressContributor progressContributor, ProgressPanel progressPanel, List<String> entities, Project project, String jpaControllerPackage, FileObject jpaControllerPackageFileObject, boolean local, boolean remote) throws IOException {
297.576 return generateSessionBeans(progressContributor, progressPanel, entities, project, jpaControllerPackage, jpaControllerPackageFileObject, local, remote, false);
297.577 }
297.578 -
297.579 +
297.580 public static FileObject[] generateSessionBeans(ProgressContributor progressContributor, ProgressPanel progressPanel, List<String> entities, Project project, String jpaControllerPackage, FileObject jpaControllerPackageFileObject, boolean local, boolean remote, boolean overrideExisting) throws IOException {
297.581 int progressIndex = 0;
297.582 String progressMsg = NbBundle.getMessage(EjbFacadeWizardIterator.class, "MSG_Progress_SessionBean_Pre"); //NOI18N;
297.583 @@ -586,7 +738,7 @@
297.584 }
297.585
297.586 PersistenceUtils.logUsage(EjbFacadeWizardIterator.class, "USG_PERSISTENCE_SESSIONBEAN", new Integer[]{entities.size()});
297.587 -
297.588 +
297.589 return sbFileObjects;
297.590 }
297.591
298.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/action/GenerationOptions.java Mon Feb 01 12:23:06 2010 +0100
298.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/action/GenerationOptions.java Mon Feb 01 12:24:26 2010 +0100
298.3 @@ -41,6 +41,7 @@
298.4
298.5 package org.netbeans.modules.j2ee.persistence.action;
298.6
298.7 +import java.text.MessageFormat;
298.8 import org.netbeans.modules.j2ee.persistence.dd.common.Persistence;
298.9
298.10 /**
298.11 @@ -52,28 +53,30 @@
298.12 public final class GenerationOptions {
298.13
298.14 public enum Operation {
298.15 - // {0} the name of the entity manager instance
298.16 + // {0} the Classname of the entity Class object
298.17 // {1} the name of the given parameter, i.e. <code>parameterName</code>.
298.18 // {2} the class of the given parameter, i.e. <code>parameterType</code>.
298.19 // {3} the return type of the method, i.e. <code>returnType</code>.
298.20 // {4} a query attribute for the query, i.e. <code>queryAttribute</code>.
298.21 + // {5} the java.lang.Class object of the entity class
298.22 PERSIST("{0}.persist({1});"),
298.23 MERGE("{0}.merge({1});"),
298.24 REMOVE("{0}.remove({0}.merge({1}));"),
298.25 - FIND("return {0}.find({3}.class, {1});"),
298.26 + FIND("return {0}.find({5}, {1});"),
298.27 // here the query attribute represents the name of the entity class
298.28 FIND_ALL(
298.29 - "return {0}.createQuery(\"select object(o) from {4} as o\").getResultList();",
298.30 - "javax.persistence.criteria.CriteriaQuery cq = {0}.getCriteriaBuilder().createQuery();cq.select(cq.from({4}.class));return {0}.createQuery(cq).getResultList();"
298.31 + "return {0}.createQuery(\"select object(o) from \" + {5}.getSimpleName() + \" as o\").getResultList();",
298.32 + "javax.persistence.criteria.CriteriaQuery cq = {0}.getCriteriaBuilder().createQuery();cq.select(cq.from({5}));return {0}.createQuery(cq).getResultList();"
298.33 ),
298.34 //querry to get only items starting from {1}[0] up to {1}[1]-1
298.35 FIND_SUBSET(
298.36 - "javax.persistence.Query q = {0}.createQuery(\"select object(o) from {4} as o\");\nq.setMaxResults({1}[1]-{1}[0]);\nq.setFirstResult({1}[0]);\nreturn q.getResultList();",
298.37 - "javax.persistence.criteria.CriteriaQuery cq = {0}.getCriteriaBuilder().createQuery();cq.select(cq.from({4}.class));javax.persistence.Query q = {0}.createQuery(cq);q.setMaxResults({1}[1]-{1}[0]);q.setFirstResult({1}[0]);return q.getResultList();"),
298.38 + "javax.persistence.Query q = {0}.createQuery(\"select object(o) from \" + {5}.getSimpleName() + \" as o\");\nq.setMaxResults({1}[1]-{1}[0]);\nq.setFirstResult({1}[0]);\nreturn q.getResultList();",
298.39 + "javax.persistence.criteria.CriteriaQuery cq = {0}.getCriteriaBuilder().createQuery();cq.select(cq.from({5}));javax.persistence.Query q = {0}.createQuery(cq);q.setMaxResults({1}[1]-{1}[0]);q.setFirstResult({1}[0]);return q.getResultList();"),
298.40 //qurrry to get count(*) on a table
298.41 COUNT(
298.42 - "return ((Long) {0}.createQuery(\"select count(o) from {4} as o\").getSingleResult()).intValue();",
298.43 - "javax.persistence.criteria.CriteriaQuery cq = {0}.getCriteriaBuilder().createQuery();javax.persistence.criteria.Root<{4}> rt = cq.from({4}.class);cq.select({0}.getCriteriaBuilder().count(rt));javax.persistence.Query q = {0}.createQuery(cq);return ((Long) q.getSingleResult()).intValue();");
298.44 + "return ((Long) {0}.createQuery(\"select count(o) from \" + {5}.getSimpleName() + \" as o\").getSingleResult()).intValue();",
298.45 + "javax.persistence.criteria.CriteriaQuery cq = {0}.getCriteriaBuilder().createQuery();javax.persistence.criteria.Root<{4}> rt = cq.from({5});cq.select({0}.getCriteriaBuilder().count(rt));javax.persistence.Query q = {0}.createQuery(cq);return ((Long) q.getSingleResult()).intValue();"),
298.46 + GET_EM("return {0};");
298.47
298.48 private String body;
298.49 private String body2_0;
298.50 @@ -148,7 +151,25 @@
298.51 public String getReturnType() {
298.52 return returnType;
298.53 }
298.54 -
298.55 +
298.56 + public String getCallLines(){
298.57 + return getCallLines(null, null);
298.58 + }
298.59 +
298.60 + public String getCallLines(String emName, String ecName){
298.61 + return getCallLines(emName, ecName, Persistence.VERSION_1_0);
298.62 + }
298.63 +
298.64 + public String getCallLines(String emName, String ecName, String version){
298.65 + return operation == null ? null : MessageFormat.format(operation.getBody(version), new Object[] {
298.66 + emName,
298.67 + getParameterName(),
298.68 + getParameterType(),
298.69 + getReturnType(),
298.70 + getQueryAttribute(),
298.71 + ecName});
298.72 + }
298.73 +
298.74 public void setMethodName(String methodName) {
298.75 this.methodName = methodName;
298.76 }
299.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
299.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
299.3 @@ -60,7 +60,7 @@
299.4 ERR_NoPersistenceUnit=The project does not have a persistence unit. You need a persistence unit to persist entity classes.
299.5 ERR_NoPersistenceProvider=The project does not have a persistence provider on the classpath.
299.6
299.7 -LBL_CreatePersistenceUnit=Create Persistence Unit...
299.8 +LBL_CreatePersistenceUnit=Create Persistence &Unit...
299.9 LBL_Project=Project\:
299.10 LBL_SrcLocation=&Location\:
299.11 LBL_Package=Package\:
300.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/PersistenceClientEntitySelection.java Mon Feb 01 12:23:06 2010 +0100
300.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/PersistenceClientEntitySelection.java Mon Feb 01 12:24:26 2010 +0100
300.3 @@ -68,10 +68,12 @@
300.4 this.wizardDescriptor = wizardDescriptor;
300.5 }
300.6
300.7 + @Override
300.8 public boolean isFinishPanel() {
300.9 return false;
300.10 }
300.11
300.12 + @Override
300.13 public Component getComponent() {
300.14 if (component == null) {
300.15 component = new PersistenceClientEntitySelectionVisual(panelName, wizardDescriptor);
300.16 @@ -80,10 +82,12 @@
300.17 return component;
300.18 }
300.19
300.20 + @Override
300.21 public HelpCtx getHelp() {
300.22 return helpCtx;
300.23 }
300.24
300.25 + @Override
300.26 public boolean isValid() {
300.27 getComponent();
300.28 return component.valid(wizardDescriptor);
300.29 @@ -91,9 +95,11 @@
300.30
300.31 private final ChangeSupport changeSupport = new ChangeSupport(this);
300.32
300.33 + @Override
300.34 public final void addChangeListener(ChangeListener l) {
300.35 changeSupport.addChangeListener(l);
300.36 }
300.37 + @Override
300.38 public final void removeChangeListener(ChangeListener l) {
300.39 changeSupport.removeChangeListener(l);
300.40 }
300.41 @@ -101,6 +107,7 @@
300.42 changeSupport.fireChange();
300.43 }
300.44
300.45 + @Override
300.46 public void readSettings(Object settings) {
300.47 wizardDescriptor = (WizardDescriptor) settings;
300.48 component.read(wizardDescriptor);
300.49 @@ -113,13 +120,15 @@
300.50 }
300.51 }
300.52
300.53 + @Override
300.54 public void storeSettings(Object settings) {
300.55 WizardDescriptor d = (WizardDescriptor) settings;
300.56 component.store(d);
300.57 - d.putProperty(WizardProperties.PERSISTENCE_UNIT, component.getPersistenceUnit());
300.58 + d.putProperty(WizardProperties.CREATE_PERSISTENCE_UNIT, component.getCreatePersistenceUnit());
300.59 ((WizardDescriptor) d).putProperty("NewProjectWizard_Title", null); // NOI18N
300.60 }
300.61
300.62 + @Override
300.63 public void stateChanged(ChangeEvent e) {
300.64 fireChangeEvent(e);
300.65 }
301.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/PersistenceClientEntitySelectionVisual.form Mon Feb 01 12:23:06 2010 +0100
301.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/PersistenceClientEntitySelectionVisual.form Mon Feb 01 12:24:26 2010 +0100
301.3 @@ -4,6 +4,7 @@
301.4 <AuxValues>
301.5 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
301.6 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
301.7 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
301.8 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
301.9 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
301.10 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
301.11 @@ -20,21 +21,21 @@
301.12 <Group type="102" attributes="0">
301.13 <Group type="103" groupAlignment="0" attributes="0">
301.14 <Component id="labelAvailableEntities" min="-2" max="-2" attributes="0"/>
301.15 - <Component id="jScrollPane1" pref="206" max="32767" attributes="0"/>
301.16 + <Component id="jScrollPane1" pref="306" max="32767" attributes="0"/>
301.17 </Group>
301.18 <EmptySpace max="-2" attributes="0"/>
301.19 <Component id="panelButtons" min="-2" max="-2" attributes="0"/>
301.20 <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
301.21 </Group>
301.22 <Group type="102" attributes="0">
301.23 - <Component id="createPUButton" min="-2" max="-2" attributes="0"/>
301.24 + <Component id="createPUCheckbox" min="-2" max="-2" attributes="0"/>
301.25 <EmptySpace max="-2" attributes="0"/>
301.26 </Group>
301.27 </Group>
301.28 <Group type="103" groupAlignment="0" attributes="0">
301.29 <Component id="cbAddRelated" alignment="0" min="-2" max="-2" attributes="1"/>
301.30 <Component id="labelSelectedEntities" alignment="0" min="-2" max="-2" attributes="0"/>
301.31 - <Component id="jScrollPane2" pref="198" max="32767" attributes="0"/>
301.32 + <Component id="jScrollPane2" pref="196" max="32767" attributes="0"/>
301.33 </Group>
301.34 <EmptySpace max="-2" attributes="0"/>
301.35 </Group>
301.36 @@ -50,21 +51,16 @@
301.37 </Group>
301.38 <EmptySpace min="-2" max="-2" attributes="0"/>
301.39 <Group type="103" groupAlignment="0" attributes="0">
301.40 - <Component id="jScrollPane2" pref="302" max="32767" attributes="2"/>
301.41 + <Component id="jScrollPane2" pref="318" max="32767" attributes="2"/>
301.42 <Component id="panelButtons" alignment="0" max="32767" attributes="2"/>
301.43 - <Component id="jScrollPane1" alignment="0" pref="302" max="32767" attributes="2"/>
301.44 + <Component id="jScrollPane1" alignment="0" pref="318" max="32767" attributes="2"/>
301.45 </Group>
301.46 <EmptySpace max="-2" attributes="0"/>
301.47 - <Group type="103" groupAlignment="1" attributes="0">
301.48 - <Group type="102" attributes="0">
301.49 - <Component id="cbAddRelated" min="-2" max="-2" attributes="0"/>
301.50 - <EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
301.51 - </Group>
301.52 - <Group type="102" alignment="1" attributes="0">
301.53 - <Component id="createPUButton" min="-2" max="-2" attributes="0"/>
301.54 - <EmptySpace max="-2" attributes="0"/>
301.55 - </Group>
301.56 + <Group type="103" groupAlignment="3" attributes="0">
301.57 + <Component id="cbAddRelated" alignment="3" min="-2" max="-2" attributes="0"/>
301.58 + <Component id="createPUCheckbox" alignment="3" min="-2" max="-2" attributes="0"/>
301.59 </Group>
301.60 + <EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
301.61 </Group>
301.62 </Group>
301.63 </DimensionLayout>
301.64 @@ -138,9 +134,6 @@
301.65 <EmptyBorder bottom="0" left="0" right="0" top="0"/>
301.66 </Border>
301.67 </Property>
301.68 - <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
301.69 - <Insets value="[0, 0, 0, 0]"/>
301.70 - </Property>
301.71 </Properties>
301.72 <AccessibilityProperties>
301.73 <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
301.74 @@ -292,26 +285,25 @@
301.75 </Property>
301.76 </Properties>
301.77 </Component>
301.78 - <Component class="javax.swing.JButton" name="createPUButton">
301.79 + <Component class="javax.swing.JCheckBox" name="createPUCheckbox">
301.80 <Properties>
301.81 - <Property name="mnemonic" type="int" editor="org.netbeans.modules.i18n.form.FormI18nMnemonicEditor">
301.82 - <ResourceString bundle="org/netbeans/modules/j2ee/persistence/wizard/Bundle.properties" key="MNE_CreatePersistenceUnit" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
301.83 - </Property>
301.84 + <Property name="selected" type="boolean" value="true"/>
301.85 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
301.86 <ResourceString bundle="org/netbeans/modules/j2ee/persistence/wizard/Bundle.properties" key="LBL_CreatePersistenceUnit" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
301.87 </Property>
301.88 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
301.89 + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
301.90 + <EmptyBorder/>
301.91 + </Border>
301.92 + </Property>
301.93 + <Property name="enabled" type="boolean" value="false"/>
301.94 </Properties>
301.95 - <AccessibilityProperties>
301.96 - <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
301.97 - <ResourceString bundle="org/netbeans/modules/j2ee/persistence/wizard/Bundle.properties" key="LBL_CreatePersistenceUnitButton" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
301.98 - </Property>
301.99 - <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
301.100 - <ResourceString bundle="org/netbeans/modules/j2ee/persistence/wizard/Bundle.properties" key="ACSD_CreatePersistenceUnitButton" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
301.101 - </Property>
301.102 - </AccessibilityProperties>
301.103 <Events>
301.104 - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createPUButtonActionPerformed"/>
301.105 + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="createPUCheckboxItemStateChanged"/>
301.106 </Events>
301.107 + <AuxValues>
301.108 + <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
301.109 + </AuxValues>
301.110 </Component>
301.111 </SubComponents>
301.112 </Form>
302.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/PersistenceClientEntitySelectionVisual.java Mon Feb 01 12:23:06 2010 +0100
302.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/PersistenceClientEntitySelectionVisual.java Mon Feb 01 12:24:26 2010 +0100
302.3 @@ -92,7 +92,8 @@
302.4 private Project project;
302.5 boolean waitingForScan;
302.6 boolean waitingForEntities;
302.7 - private PersistenceUnit persistenceUnit;
302.8 + //private PersistenceUnit persistenceUnit;
302.9 + private boolean createPU = true;//right now this panel is used in wizards with required pu
302.10
302.11 private EntityClosure entityClosure;
302.12
302.13 @@ -104,6 +105,7 @@
302.14 initComponents();
302.15 ListSelectionListener selectionListener = new ListSelectionListener() {
302.16
302.17 + @Override
302.18 public void valueChanged(ListSelectionEvent e) {
302.19 updateButtons();
302.20 }
302.21 @@ -113,12 +115,10 @@
302.22 }
302.23
302.24 /**
302.25 - * @return PersistenceUnit that was created by invoking the PU wizard from
302.26 - * this wizard or <code>null</code> if there was already a persistence unit, i.e.
302.27 - * there was no reason to create a new persistence unit from this wizard.
302.28 + * @return if wizard have selected option to create new pu.
302.29 */
302.30 - public PersistenceUnit getPersistenceUnit() {
302.31 - return persistenceUnit;
302.32 + public boolean getCreatePersistenceUnit() {
302.33 + return createPU;
302.34 }
302.35
302.36 private Set<String> getSelectedEntities(JList list) {
302.37 @@ -143,7 +143,7 @@
302.38 buttonAddAll = new javax.swing.JButton();
302.39 buttonRemoveAll = new javax.swing.JButton();
302.40 labelSelectedEntities = new javax.swing.JLabel();
302.41 - createPUButton = new javax.swing.JButton();
302.42 + createPUCheckbox = new javax.swing.JCheckBox();
302.43
302.44 listAvailable.setCellRenderer(ENTITY_LIST_RENDERER);
302.45 jScrollPane1.setViewportView(listAvailable);
302.46 @@ -159,7 +159,6 @@
302.47 cbAddRelated.setSelected(true);
302.48 cbAddRelated.setText(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "LBL_IncludeReferenced")); // NOI18N
302.49 cbAddRelated.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
302.50 - cbAddRelated.setMargin(new java.awt.Insets(0, 0, 0, 0));
302.51 cbAddRelated.addActionListener(new java.awt.event.ActionListener() {
302.52 public void actionPerformed(java.awt.event.ActionEvent evt) {
302.53 cbAddRelatedActionPerformed(evt);
302.54 @@ -242,11 +241,13 @@
302.55 labelSelectedEntities.setLabelFor(listSelected);
302.56 labelSelectedEntities.setText(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "LBL_SelectedEntities")); // NOI18N
302.57
302.58 - createPUButton.setMnemonic(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "MNE_CreatePersistenceUnit").charAt(0));
302.59 - createPUButton.setText(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "LBL_CreatePersistenceUnit")); // NOI18N
302.60 - createPUButton.addActionListener(new java.awt.event.ActionListener() {
302.61 - public void actionPerformed(java.awt.event.ActionEvent evt) {
302.62 - createPUButtonActionPerformed(evt);
302.63 + createPUCheckbox.setSelected(true);
302.64 + org.openide.awt.Mnemonics.setLocalizedText(createPUCheckbox, org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "LBL_CreatePersistenceUnit")); // NOI18N
302.65 + createPUCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
302.66 + createPUCheckbox.setEnabled(false);
302.67 + createPUCheckbox.addItemListener(new java.awt.event.ItemListener() {
302.68 + public void itemStateChanged(java.awt.event.ItemEvent evt) {
302.69 + createPUCheckboxItemStateChanged(evt);
302.70 }
302.71 });
302.72
302.73 @@ -259,17 +260,17 @@
302.74 .add(layout.createSequentialGroup()
302.75 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
302.76 .add(labelAvailableEntities)
302.77 - .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE))
302.78 + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE))
302.79 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
302.80 .add(panelButtons, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
302.81 .add(0, 0, 0))
302.82 .add(layout.createSequentialGroup()
302.83 - .add(createPUButton)
302.84 + .add(createPUCheckbox)
302.85 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
302.86 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
302.87 .add(cbAddRelated)
302.88 .add(labelSelectedEntities)
302.89 - .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE))
302.90 + .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE))
302.91 .addContainerGap())
302.92 );
302.93 layout.setVerticalGroup(
302.94 @@ -281,23 +282,18 @@
302.95 .add(labelAvailableEntities))
302.96 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
302.97 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
302.98 - .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
302.99 + .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
302.100 .add(panelButtons, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
302.101 - .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE))
302.102 + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE))
302.103 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
302.104 - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
302.105 - .add(layout.createSequentialGroup()
302.106 - .add(cbAddRelated)
302.107 - .add(31, 31, 31))
302.108 - .add(layout.createSequentialGroup()
302.109 - .add(createPUButton)
302.110 - .addContainerGap())))
302.111 + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
302.112 + .add(cbAddRelated)
302.113 + .add(createPUCheckbox))
302.114 + .add(31, 31, 31))
302.115 );
302.116
302.117 cbAddRelated.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "LBL_IncludeReferencedCheckbox")); // NOI18N
302.118 cbAddRelated.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "ACSD_IncludeReferencedCheckbox")); // NOI18N
302.119 - createPUButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "LBL_CreatePersistenceUnitButton")); // NOI18N
302.120 - createPUButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "ACSD_CreatePersistenceUnitButton")); // NOI18N
302.121 }// </editor-fold>//GEN-END:initComponents
302.122
302.123 private void cbAddRelatedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAddRelatedActionPerformed
302.124 @@ -308,14 +304,6 @@
302.125 changeSupport.fireChange();
302.126 }//GEN-LAST:event_cbAddRelatedActionPerformed
302.127
302.128 - private void createPUButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createPUButtonActionPerformed
302.129 - persistenceUnit = Util.buildPersistenceUnitUsingWizard(project, null, TableGeneration.CREATE);
302.130 - if (persistenceUnit != null) {
302.131 - updatePersistenceUnitButton();
302.132 - changeSupport.fireChange();
302.133 - }
302.134 - }//GEN-LAST:event_createPUButtonActionPerformed
302.135 -
302.136 private void buttonRemoveAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRemoveAllActionPerformed
302.137 entityClosure.removeAllEntities();
302.138 listSelected.clearSelection();
302.139 @@ -346,6 +334,11 @@
302.140 changeSupport.fireChange();
302.141 }//GEN-LAST:event_buttonAddActionPerformed
302.142
302.143 + private void createPUCheckboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_createPUCheckboxItemStateChanged
302.144 + createPU = createPUCheckbox.isVisible() && createPUCheckbox.isSelected();
302.145 +
302.146 + }//GEN-LAST:event_createPUCheckboxItemStateChanged
302.147 +
302.148
302.149 // Variables declaration - do not modify//GEN-BEGIN:variables
302.150 private javax.swing.JButton buttonAdd;
302.151 @@ -353,7 +346,7 @@
302.152 private javax.swing.JButton buttonRemove;
302.153 private javax.swing.JButton buttonRemoveAll;
302.154 private javax.swing.JCheckBox cbAddRelated;
302.155 - private javax.swing.JButton createPUButton;
302.156 + private javax.swing.JCheckBox createPUCheckbox;
302.157 private javax.swing.JScrollPane jScrollPane1;
302.158 private javax.swing.JScrollPane jScrollPane2;
302.159 private javax.swing.JLabel labelAvailableEntities;
302.160 @@ -368,10 +361,10 @@
302.161
302.162 boolean valid(WizardDescriptor wizard) {
302.163 // check PU - not just warning, required
302.164 - if (createPUButton.isVisible()) {
302.165 - wizard.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "ERR_NoPersistenceUnit"));
302.166 - return false;
302.167 - }
302.168 +// if (createPUButton.isVisible()) {
302.169 +// wizard.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(PersistenceClientEntitySelectionVisual.class, "ERR_NoPersistenceUnit"));
302.170 +// return false;
302.171 +// }
302.172
302.173 SourceGroup[] groups = SourceGroups.getJavaSourceGroups(project);
302.174 if (groups.length > 0) {
302.175 @@ -385,6 +378,7 @@
302.176 if (!entityClosure.isModelReady()) {
302.177 RequestProcessor.Task task = RequestProcessor.getDefault().create(new Runnable() {
302.178
302.179 + @Override
302.180 public void run() {
302.181 entityClosure.waitModelIsReady();
302.182 changeSupport.fireChange();
302.183 @@ -412,6 +406,7 @@
302.184
302.185 entityClosure = EntityClosure.create(entityClassScope, project);
302.186 entityClosure.addChangeListener(new ChangeListener() {
302.187 + @Override
302.188 public void stateChanged(ChangeEvent e) {
302.189 updateAddAllButton();
302.190 }
302.191 @@ -449,7 +444,7 @@
302.192 }
302.193
302.194 public void updatePersistenceUnitButton() {
302.195 - boolean visible = getPersistenceUnit() == null;
302.196 + boolean visible = true;
302.197 if (ProviderUtil.isValidServerInstanceOrNone(project) && visible) {
302.198 PersistenceScope[] scopes = PersistenceUtils.getPersistenceScopes(project);
302.199 for (int i = 0; i < scopes.length; i++) {
302.200 @@ -468,7 +463,7 @@
302.201 }
302.202 }
302.203 }
302.204 - createPUButton.setVisible(visible);
302.205 + createPUCheckbox.setVisible(visible);
302.206 }
302.207
302.208 private final ListCellRenderer ENTITY_LIST_RENDERER = new EntityListCellRenderer();
302.209 @@ -486,10 +481,12 @@
302.210 refresh();
302.211 }
302.212
302.213 + @Override
302.214 public int getSize() {
302.215 return entities.size();
302.216 }
302.217
302.218 + @Override
302.219 public Object getElementAt(int index) {
302.220 return entities.get(index);
302.221 }
302.222 @@ -501,6 +498,7 @@
302.223 return entities;
302.224 }
302.225
302.226 + @Override
302.227 public void stateChanged(ChangeEvent e) {
302.228 refresh();
302.229 }
302.230 @@ -519,6 +517,7 @@
302.231 setOpaque(true);
302.232 }
302.233
302.234 + @Override
302.235 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
302.236 String text = null;
302.237 if (value instanceof Entity) {
303.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/WizardProperties.java Mon Feb 01 12:23:06 2010 +0100
303.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/WizardProperties.java Mon Feb 01 12:24:26 2010 +0100
303.3 @@ -46,6 +46,6 @@
303.4 /**
303.5 * Key used for the created persistence unit.
303.6 */
303.7 - public static final String PERSISTENCE_UNIT = "PersistenceUnit"; //NOI18N
303.8 -
303.9 + //public static final String PERSISTENCE_UNIT = "PersistenceUnit"; //NOI18N
303.10 + public static final String CREATE_PERSISTENCE_UNIT = "CreatePersistenceUnit"; //NOI18N
303.11 }
304.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/DatabaseTablesPanel.java Mon Feb 01 12:23:06 2010 +0100
304.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/DatabaseTablesPanel.java Mon Feb 01 12:24:26 2010 +0100
304.3 @@ -65,10 +65,13 @@
304.4 import org.netbeans.api.project.SourceGroup;
304.5 import org.netbeans.modules.dbschema.SchemaElement;
304.6 import org.netbeans.modules.j2ee.core.api.support.SourceGroups;
304.7 +import org.netbeans.modules.j2ee.persistence.dd.common.PersistenceUnit;
304.8 +import org.netbeans.modules.j2ee.persistence.provider.InvalidPersistenceXmlException;
304.9 import org.netbeans.modules.j2ee.persistence.provider.ProviderUtil;
304.10 import org.netbeans.modules.j2ee.persistence.spi.datasource.JPADataSource;
304.11 import org.netbeans.modules.j2ee.persistence.spi.datasource.JPADataSourcePopulator;
304.12 import org.netbeans.modules.j2ee.persistence.spi.datasource.JPADataSourceProvider;
304.13 +import org.netbeans.modules.j2ee.persistence.unit.PUDataObject;
304.14 import org.netbeans.modules.j2ee.persistence.util.SourceLevelChecker;
304.15 import org.netbeans.modules.j2ee.persistence.wizard.Util;
304.16 import org.netbeans.spi.project.ui.templates.support.Templates;
304.17 @@ -78,6 +81,7 @@
304.18 import org.openide.filesystems.FileObject;
304.19 import org.openide.filesystems.FileUtil;
304.20 import org.openide.util.ChangeSupport;
304.21 +import org.openide.util.Exceptions;
304.22 import org.openide.util.HelpCtx;
304.23 import org.openide.util.NbBundle;
304.24 import org.openide.util.RequestProcessor;
304.25 @@ -236,6 +240,44 @@
304.26 break;
304.27 }
304.28 }
304.29 +
304.30 + //try to find pu for the project
304.31 + //nothing is selected based on previos selection, try to select based on persistence.xml
304.32 + boolean puExists = false;
304.33 + try {
304.34 + puExists = ProviderUtil.persistenceExists(project);
304.35 + } catch (InvalidPersistenceXmlException ex) {
304.36 + }
304.37 +
304.38 + if(puExists){
304.39 + PUDataObject pud = null;
304.40 + try {
304.41 + pud = ProviderUtil.getPUDataObject(project);
304.42 + } catch (InvalidPersistenceXmlException ex) {
304.43 + Exceptions.printStackTrace(ex);
304.44 + }
304.45 + PersistenceUnit pu = (pud !=null && pud.getPersistence().getPersistenceUnit().length==1) ? pud.getPersistence().getPersistenceUnit()[0] : null;
304.46 + if(pu !=null ){
304.47 + if(withDatasources){
304.48 + String jtaDs = pu.getJtaDataSource();
304.49 + if(jtaDs !=null ){
304.50 + selectDatasource(jtaDs);
304.51 + }
304.52 + else {
304.53 + String nJtaDs = pu.getNonJtaDataSource();
304.54 + if(nJtaDs != null) {
304.55 + selectDatasource(nJtaDs);
304.56 + }
304.57 + }
304.58 + } else {
304.59 + //try to find jdbc connection
304.60 + DatabaseConnection cn = ProviderUtil.getConnection(pu);
304.61 + if(cn != null){
304.62 + datasourceComboBox.setSelectedItem(cn);
304.63 + }
304.64 + }
304.65 + }
304.66 + }
304.67
304.68 // nothing got selected so far, so select the data source / connection
304.69 // radio button, but don't select an actual data source or connection
304.70 @@ -317,12 +359,12 @@
304.71 * Tries to select the given connection and returns true if successful.
304.72 */
304.73 private boolean selectDbConnection(String name) {
304.74 - DatabaseConnection dbconn = ConnectionManager.getDefault().getConnection(name);
304.75 - if (dbconn == null || dbconn.getJDBCConnection() == null) {
304.76 + DatabaseConnection dbcon = ConnectionManager.getDefault().getConnection(name);
304.77 + if (dbcon == null || dbcon.getJDBCConnection() == null) {
304.78 return false;
304.79 }
304.80 - datasourceComboBox.setSelectedItem(dbconn);
304.81 - if (!dbconn.equals(datasourceComboBox.getSelectedItem())) {
304.82 + datasourceComboBox.setSelectedItem(dbcon);
304.83 + if (!dbcon.equals(datasourceComboBox.getSelectedItem())) {
304.84 return false;
304.85 }
304.86 datasourceRadioButton.setSelected(true);
305.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/jpacontroller/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
305.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/jpacontroller/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
305.3 @@ -43,6 +43,7 @@
305.4
305.5 LBL_WizardTitle_FromEntity=JPA Controller Classes from Entity Classes
305.6 LBL_JpaControllerClasses=Generate JPA Controller Classes
305.7 +LBL_PersistenceUnitSetup=Persistence Unit Provider and Database
305.8
305.9 # Sample ResourceBundle properties file
305.10 TITLE_x_of_y={0} of {1}
306.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/jpacontroller/JpaControllerIterator.java Mon Feb 01 12:23:06 2010 +0100
306.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/jpacontroller/JpaControllerIterator.java Mon Feb 01 12:24:26 2010 +0100
306.3 @@ -38,7 +38,6 @@
306.4 * Version 2 license, then the option applies only if the new code is
306.5 * made subject to such option by the copyright holder.
306.6 */
306.7 -
306.8 package org.netbeans.modules.j2ee.persistence.wizard.jpacontroller;
306.9
306.10 import java.io.IOException;
306.11 @@ -51,14 +50,10 @@
306.12 import javax.swing.JComponent;
306.13 import javax.swing.SwingUtilities;
306.14 import javax.swing.event.ChangeListener;
306.15 -import org.netbeans.api.java.project.JavaProjectConstants;
306.16 import org.netbeans.api.progress.aggregate.AggregateProgressFactory;
306.17 import org.netbeans.api.progress.aggregate.AggregateProgressHandle;
306.18 import org.netbeans.api.progress.aggregate.ProgressContributor;
306.19 import org.netbeans.api.project.Project;
306.20 -import org.netbeans.api.project.ProjectUtils;
306.21 -import org.netbeans.api.project.SourceGroup;
306.22 -import org.netbeans.api.project.Sources;
306.23 import org.netbeans.modules.j2ee.core.api.support.java.GenerationUtils;
306.24 import org.netbeans.modules.j2ee.core.api.support.wizard.DelegatingWizardDescriptorPanel;
306.25 import org.netbeans.modules.j2ee.core.api.support.wizard.Wizards;
306.26 @@ -77,54 +72,61 @@
306.27 import org.openide.util.HelpCtx;
306.28 import org.openide.util.NbBundle;
306.29 import org.netbeans.modules.j2ee.persistence.wizard.fromdb.ProgressPanel;
306.30 +import org.netbeans.modules.j2ee.persistence.wizard.unit.PersistenceUnitWizardDescriptor;
306.31 +import org.netbeans.modules.j2ee.persistence.wizard.unit.PersistenceUnitWizardPanel.TableGeneration;
306.32 import org.openide.DialogDisplayer;
306.33 import org.openide.NotifyDescriptor;
306.34 import org.openide.util.RequestProcessor;
306.35 +
306.36 /**
306.37 *
306.38 * @author Pavel Buzek
306.39 */
306.40 public class JpaControllerIterator implements TemplateWizard.Iterator {
306.41 -
306.42 +
306.43 private int index;
306.44 private transient WizardDescriptor.Panel[] panels;
306.45 + private PersistenceUnitWizardDescriptor puPanel;
306.46 private static final String[] EXCEPTION_CLASS_NAMES = {"IllegalOrphanException", "NonexistentEntityException", "PreexistingEntityException", "RollbackFailureException"};
306.47 public static final String EXCEPTION_FOLDER_NAME = "exceptions"; //NOI18N
306.48 private static String RESOURCE_FOLDER = "org/netbeans/modules/j2ee/persistence/wizard/jpacontroller/resources/"; //NOI18N
306.49 -
306.50 - public Set instantiate(TemplateWizard wizard) throws IOException
306.51 - {
306.52 +
306.53 + @Override
306.54 + public Set instantiate(TemplateWizard wizard) throws IOException {
306.55 final List<String> entities = (List<String>) wizard.getProperty(WizardProperties.ENTITY_CLASS);
306.56 final Project project = Templates.getProject(wizard);
306.57 final FileObject jpaControllerPackageFileObject = Templates.getTargetFolder(wizard);
306.58 final String jpaControllerPackage = (String) wizard.getProperty(WizardProperties.JPA_CONTROLLER_PACKAGE);
306.59 -
306.60 - PersistenceUnit persistenceUnit =
306.61 - (PersistenceUnit) wizard.getProperty(org.netbeans.modules.j2ee.persistence.wizard.WizardProperties.PERSISTENCE_UNIT);
306.62
306.63 - if (persistenceUnit != null){
306.64 + boolean createPersistenceUnit = (Boolean) wizard.getProperty(org.netbeans.modules.j2ee.persistence.wizard.WizardProperties.CREATE_PERSISTENCE_UNIT);
306.65 +
306.66 + if (createPersistenceUnit) {
306.67 try {
306.68 - ProviderUtil.addPersistenceUnit(persistenceUnit, Templates.getProject(wizard));
306.69 - }
306.70 - catch (InvalidPersistenceXmlException e) {
306.71 + PersistenceUnit punit = Util.buildPersistenceUnitUsingData(project, puPanel.getPersistenceUnitName(), puPanel.getPersistenceConnection()!=null ? puPanel.getPersistenceConnection().getName() : puPanel.getDatasource(), TableGeneration.NONE, puPanel.getSelectedProvider());
306.72 + ProviderUtil.setTableGeneration(punit, puPanel.getTableGeneration(), puPanel.getSelectedProvider());
306.73 + if (punit != null){
306.74 + ProviderUtil.addPersistenceUnit(punit, project);
306.75 + }
306.76 + } catch (InvalidPersistenceXmlException e) {
306.77 throw new IOException(e.toString());
306.78 }
306.79 }
306.80 -
306.81 +
306.82 final String title = NbBundle.getMessage(JpaControllerIterator.class, "TITLE_Progress_Jpa_Controller"); //NOI18N
306.83 final ProgressContributor progressContributor = AggregateProgressFactory.createProgressContributor(title);
306.84 - final AggregateProgressHandle handle =
306.85 + final AggregateProgressHandle handle =
306.86 AggregateProgressFactory.createHandle(title, new ProgressContributor[]{progressContributor}, null, null);
306.87 final ProgressPanel progressPanel = new ProgressPanel();
306.88 final JComponent progressComponent = AggregateProgressFactory.createProgressComponent(handle);
306.89 -
306.90 +
306.91 final Runnable r = new Runnable() {
306.92
306.93 + @Override
306.94 public void run() {
306.95 try {
306.96 handle.start();
306.97 int progressStepCount = getProgressStepCount(entities.size());
306.98 - progressContributor.start(progressStepCount);
306.99 + progressContributor.start(progressStepCount);
306.100 generateJpaControllers(progressContributor, progressPanel, entities, project, jpaControllerPackage, jpaControllerPackageFileObject, null, false, true);
306.101 progressContributor.progress(progressStepCount);
306.102 } catch (IOException ioe) {
306.103 @@ -134,6 +136,8 @@
306.104 } finally {
306.105 progressContributor.finish();
306.106 SwingUtilities.invokeLater(new Runnable() {
306.107 +
306.108 + @Override
306.109 public void run() {
306.110 progressPanel.close();
306.111 }
306.112 @@ -142,7 +146,7 @@
306.113 }
306.114 }
306.115 };
306.116 -
306.117 +
306.118 // Ugly hack ensuring the progress dialog opens after the wizard closes. Needed because:
306.119 // 1) the wizard is not closed in the AWT event in which instantiate() is called.
306.120 // Instead it is closed in an event scheduled by SwingUtilities.invokeLater().
306.121 @@ -155,9 +159,12 @@
306.122 // - the first invocation event of our runnable
306.123 // - the invocation event which closes the wizard
306.124 // - the second invocation event of our runnable
306.125 -
306.126 +
306.127 SwingUtilities.invokeLater(new Runnable() {
306.128 +
306.129 private boolean first = true;
306.130 +
306.131 + @Override
306.132 public void run() {
306.133 if (!first) {
306.134 RequestProcessor.getDefault().post(r);
306.135 @@ -168,19 +175,19 @@
306.136 }
306.137 }
306.138 });
306.139 -
306.140 +
306.141 return Collections.singleton(DataFolder.findFolder(jpaControllerPackageFileObject));
306.142 }
306.143 -
306.144 +
306.145 public static int getProgressStepCount(int entityCount) {
306.146 return EXCEPTION_CLASS_NAMES.length + entityCount + 2;
306.147 }
306.148 -
306.149 +
306.150 public static FileObject[] generateJpaControllers(ProgressContributor progressContributor, ProgressPanel progressPanel, List<String> entities, Project project, String jpaControllerPackage, FileObject jpaControllerPackageFileObject, JpaControllerUtil.EmbeddedPkSupport embeddedPkSupport, boolean managed, boolean evenIfExists) throws IOException {
306.151 int progressIndex = 0;
306.152 String progressMsg = NbBundle.getMessage(JpaControllerIterator.class, "MSG_Progress_Jpa_Exception_Pre"); //NOI18N
306.153 progressContributor.progress(progressMsg, progressIndex++);
306.154 - progressPanel.setText(progressMsg);
306.155 + progressPanel.setText(progressMsg);
306.156
306.157 FileObject exceptionFolder = jpaControllerPackageFileObject.getFileObject(EXCEPTION_FOLDER_NAME);
306.158 if (exceptionFolder == null) {
306.159 @@ -190,7 +197,7 @@
306.160 String exceptionPackage = jpaControllerPackage == null || jpaControllerPackage.length() == 0 ? EXCEPTION_FOLDER_NAME : jpaControllerPackage + "." + EXCEPTION_FOLDER_NAME;
306.161
306.162 int exceptionClassCount = Util.isContainerManaged(project) ? EXCEPTION_CLASS_NAMES.length : EXCEPTION_CLASS_NAMES.length - 1;
306.163 - for (int i = 0; i < exceptionClassCount; i++){
306.164 + for (int i = 0; i < exceptionClassCount; i++) {
306.165 if (exceptionFolder.getFileObject(EXCEPTION_CLASS_NAMES[i], "java") == null) {
306.166 progressMsg = NbBundle.getMessage(JpaControllerIterator.class, "MSG_Progress_Jpa_Now_Generating", EXCEPTION_CLASS_NAMES[i] + ".java");//NOI18N
306.167 progressContributor.progress(progressMsg, progressIndex++);
306.168 @@ -200,12 +207,11 @@
306.169 FileObject target = FileUtil.createData(exceptionFolder, EXCEPTION_CLASS_NAMES[i] + ".java");//NOI18N
306.170 String projectEncoding = JpaControllerUtil.getProjectEncodingAsString(project, target);
306.171 JpaControllerUtil.createFile(target, content, projectEncoding); //NOI18N
306.172 - }
306.173 - else {
306.174 + } else {
306.175 progressContributor.progress(progressIndex++);
306.176 }
306.177 }
306.178 -
306.179 +
306.180 progressMsg = NbBundle.getMessage(JpaControllerIterator.class, "MSG_Progress_Jpa_Controller_Pre"); //NOI18N;
306.181 progressContributor.progress(progressMsg, progressIndex++);
306.182 progressPanel.setText(progressMsg);
306.183 @@ -253,115 +259,102 @@
306.184 return controllerFileObjects;
306.185 }
306.186
306.187 - /**
306.188 - * Convenience method to obtain the source root folder.
306.189 - * @param project the Project object
306.190 - * @return the FileObject of the source root folder
306.191 - */
306.192 - private static FileObject getSourceRoot(Project project) {
306.193 - if (project == null) {
306.194 - return null;
306.195 - }
306.196
306.197 - // Search the ${src.dir} Source Package Folder first, use the first source group if failed.
306.198 - Sources src = ProjectUtils.getSources(project);
306.199 - SourceGroup[] grp = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
306.200 - for (int i = 0; i < grp.length; i++) {
306.201 - if ("${src.dir}".equals(grp[i].getName())) { // NOI18N
306.202 - return grp[i].getRootFolder();
306.203 - }
306.204 - }
306.205 - if (grp.length != 0) {
306.206 - return grp[0].getRootFolder();
306.207 - }
306.208 -
306.209 - return null;
306.210 - }
306.211 -
306.212 + @Override
306.213 public void initialize(TemplateWizard wizard) {
306.214 index = 0;
306.215 // obtaining target folder
306.216 - Project project = Templates.getProject( wizard );
306.217 - DataFolder targetFolder=null;
306.218 + Project project = Templates.getProject(wizard);
306.219 + DataFolder targetFolder = null;
306.220 try {
306.221 targetFolder = wizard.getTargetFolder();
306.222 } catch (IOException ex) {
306.223 targetFolder = DataFolder.findFolder(project.getProjectDirectory());
306.224 }
306.225 -
306.226 - SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
306.227 -
306.228 +
306.229 WizardDescriptor.Panel secondPanel = new ValidationPanel(
306.230 new PersistenceClientEntitySelection(NbBundle.getMessage(JpaControllerIterator.class, "LBL_EntityClasses"),
306.231 - new HelpCtx("org.netbeans.modules.j2ee.persistence.wizard.jpacontroller"), wizard)); // NOI18N
306.232 + new HelpCtx("org.netbeans.modules.j2ee.persistence.wizard.jpacontroller"), wizard)); // NOI18N
306.233 WizardDescriptor.Panel thirdPanel = new JpaControllerSetupPanel(project, wizard);
306.234 -// WizardDescriptor.Panel javaPanel = JavaTemplates.createPackageChooser(project, sourceGroups, secondPanel);
306.235 -// panels = new WizardDescriptor.Panel[] { javaPanel };
306.236 - panels = new WizardDescriptor.Panel[] { secondPanel, thirdPanel };
306.237 - String names[] = new String[] {
306.238 - NbBundle.getMessage(JpaControllerIterator.class, "LBL_EntityClasses"),
306.239 - NbBundle.getMessage(JpaControllerIterator.class, "LBL_JpaControllerClasses")
306.240 -
306.241 - };
306.242 - wizard.putProperty("NewFileWizard_Title",
306.243 - NbBundle.getMessage(JpaControllerIterator.class, "Templates/Persistence/JpaControllersFromEntities"));
306.244 + String names[] = null;
306.245 + //
306.246 + boolean noPuNeeded = true;
306.247 + try {
306.248 + noPuNeeded = ProviderUtil.persistenceExists(project) || !ProviderUtil.isValidServerInstanceOrNone(project);
306.249 + } catch (InvalidPersistenceXmlException ex) {
306.250 + Logger.getLogger(JpaControllerIterator.class.getName()).log(Level.FINE, "Invalid persistence.xml: "+ ex.getPath()); //NOI18N
306.251 + }
306.252 + if (!noPuNeeded) {
306.253 + puPanel = new PersistenceUnitWizardDescriptor(project);
306.254 + panels = new WizardDescriptor.Panel[]{secondPanel, thirdPanel, puPanel};
306.255 + names = new String[]{
306.256 + NbBundle.getMessage(JpaControllerIterator.class, "LBL_EntityClasses"),
306.257 + NbBundle.getMessage(JpaControllerIterator.class, "LBL_JpaControllerClasses"),
306.258 + NbBundle.getMessage(JpaControllerIterator.class, "LBL_PersistenceUnitSetup")
306.259 + };
306.260 + } else {
306.261 +
306.262 + panels = new WizardDescriptor.Panel[]{secondPanel, thirdPanel};
306.263 + names = new String[]{
306.264 + NbBundle.getMessage(JpaControllerIterator.class, "LBL_EntityClasses"),
306.265 + NbBundle.getMessage(JpaControllerIterator.class, "LBL_JpaControllerClasses")
306.266 + };
306.267 + }
306.268 +
306.269 + wizard.putProperty("NewFileWizard_Title",
306.270 + NbBundle.getMessage(JpaControllerIterator.class, "Templates/Persistence/JpaControllersFromEntities"));
306.271 Wizards.mergeSteps(wizard, panels, names);
306.272 }
306.273
306.274 - private String[] createSteps(String[] before, WizardDescriptor.Panel[] panels) {
306.275 - int diff = 0;
306.276 - if (before == null) {
306.277 - before = new String[0];
306.278 - } else if (before.length > 0) {
306.279 - diff = ("...".equals (before[before.length - 1])) ? 1 : 0; // NOI18N
306.280 - }
306.281 - String[] res = new String[ (before.length - diff) + panels.length];
306.282 - for (int i = 0; i < res.length; i++) {
306.283 - if (i < (before.length - diff)) {
306.284 - res[i] = before[i];
306.285 - } else {
306.286 - res[i] = panels[i - before.length + diff].getComponent ().getName ();
306.287 - }
306.288 - }
306.289 - return res;
306.290 - }
306.291 -
306.292 + @Override
306.293 public void uninitialize(TemplateWizard wiz) {
306.294 panels = null;
306.295 }
306.296
306.297 + @Override
306.298 public WizardDescriptor.Panel current() {
306.299 return panels[index];
306.300 }
306.301
306.302 + @Override
306.303 public String name() {
306.304 - return NbBundle.getMessage (JpaControllerIterator.class, "LBL_WizardTitle_FromEntity");
306.305 + return NbBundle.getMessage(JpaControllerIterator.class, "LBL_WizardTitle_FromEntity");
306.306 }
306.307
306.308 + @Override
306.309 public boolean hasNext() {
306.310 return index < panels.length - 1;
306.311 }
306.312
306.313 + @Override
306.314 public boolean hasPrevious() {
306.315 return index > 0;
306.316 }
306.317
306.318 + @Override
306.319 public void nextPanel() {
306.320 - if (! hasNext ()) throw new NoSuchElementException ();
306.321 + if (!hasNext()) {
306.322 + throw new NoSuchElementException();
306.323 + }
306.324 index++;
306.325 }
306.326
306.327 + @Override
306.328 public void previousPanel() {
306.329 - if (! hasPrevious ()) throw new NoSuchElementException ();
306.330 + if (!hasPrevious()) {
306.331 + throw new NoSuchElementException();
306.332 + }
306.333 index--;
306.334 }
306.335
306.336 + @Override
306.337 public void addChangeListener(ChangeListener l) {
306.338 }
306.339
306.340 + @Override
306.341 public void removeChangeListener(ChangeListener l) {
306.342 }
306.343 -
306.344 +
306.345 /**
306.346 * A panel which checks that the target project has a valid server set
306.347 * otherwise it delegates to the real panel.
306.348 @@ -371,7 +364,6 @@
306.349 private ValidationPanel(WizardDescriptor.Panel delegate) {
306.350 super(delegate);
306.351 }
306.352 -
306.353 // public boolean isValid() {
306.354 // Project project = getProject();
306.355 // WizardDescriptor wizardDescriptor = getWizardDescriptor();
307.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/unit/PersistenceUnitWizardDescriptor.java Mon Feb 01 12:23:06 2010 +0100
307.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/unit/PersistenceUnitWizardDescriptor.java Mon Feb 01 12:24:26 2010 +0100
307.3 @@ -176,6 +176,10 @@
307.4 public String getDatasource() {
307.5 return datasourcePanel == null ? null : datasourcePanel.getDatasource();
307.6 }
307.7 +
307.8 + public String getDBResourceSelection() {
307.9 + return getPersistenceConnection()!=null ? getPersistenceConnection().getName() : getDatasource();
307.10 + }
307.11
307.12 public boolean isContainerManaged() {
307.13 return isContainerManaged;
308.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/unit/PersistenceUnitWizardPanelDS.form Mon Feb 01 12:23:06 2010 +0100
308.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/unit/PersistenceUnitWizardPanelDS.form Mon Feb 01 12:24:26 2010 +0100
308.3 @@ -14,6 +14,8 @@
308.4 </Properties>
308.5 <AuxValues>
308.6 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
308.7 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
308.8 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
308.9 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
308.10 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
308.11 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
309.1 --- a/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/unit/PersistenceUnitWizardPanelDS.java Mon Feb 01 12:23:06 2010 +0100
309.2 +++ b/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/unit/PersistenceUnitWizardPanelDS.java Mon Feb 01 12:24:26 2010 +0100
309.3 @@ -112,6 +112,7 @@
309.4 dsPopulator.connect(dsCombo);
309.5
309.6 dsCombo.addActionListener(new ActionListener() {
309.7 + @Override
309.8 public void actionPerformed(ActionEvent e) {
309.9 checkValidity();
309.10 }
309.11 @@ -119,12 +120,15 @@
309.12
309.13 ((JTextComponent)dsCombo.getEditor().getEditorComponent()).
309.14 getDocument().addDocumentListener(new DocumentListener() {
309.15 + @Override
309.16 public void changedUpdate(DocumentEvent e) {
309.17 checkValidity();
309.18 }
309.19 + @Override
309.20 public void insertUpdate(DocumentEvent e) {
309.21 checkValidity();
309.22 }
309.23 + @Override
309.24 public void removeUpdate(DocumentEvent e) {
309.25 checkValidity();
309.26 }
309.27 @@ -144,6 +148,7 @@
309.28 }
309.29 }
309.30
309.31 + @Override
309.32 public String getPersistenceUnitName() {
309.33 return unitNameTextField.getText();
309.34 }
309.35 @@ -152,6 +157,7 @@
309.36 return ((JTextComponent)dsCombo.getEditor().getEditorComponent()).getText();
309.37 }
309.38
309.39 + @Override
309.40 public void setPreselectedDB(String db) {
309.41 boolean hasItem = false;
309.42 for (int i = 0; i < dsCombo.getItemCount(); i++) {
309.43 @@ -181,6 +187,7 @@
309.44 }
309.45
309.46
309.47 + @Override
309.48 public String getTableGeneration() {
309.49 if (ddlCreate.isSelected()) {
309.50 return Provider.TABLE_GENERATION_CREATE;
309.51 @@ -191,6 +198,7 @@
309.52 }
309.53 }
309.54
309.55 + @Override
309.56 public boolean isValidPanel() {
309.57 try{
309.58 if (!isNameValid()){
309.59 @@ -211,6 +219,7 @@
309.60 return Strings.isEmpty(getPersistenceUnitName()) ? false : isNameUnique();
309.61 }
309.62
309.63 + @Override
309.64 public Provider getSelectedProvider() {
309.65 return (Provider) providerCombo.getSelectedItem();
309.66 }
310.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java Mon Feb 01 12:23:06 2010 +0100
310.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java Mon Feb 01 12:24:26 2010 +0100
310.3 @@ -159,6 +159,11 @@
310.4
310.5 TreePath columnIndex = ctx.getVariables().get("$columnIndex");
310.6 Number value = ArithmeticUtilities.compute(ctx.getInfo(), columnIndex, true);
310.7 +
310.8 + if (value == null) {
310.9 + return null;
310.10 + }
310.11 +
310.12 int intValue = value.intValue();
310.13
310.14 if (intValue > 0) {
311.1 --- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/TinyTest.java Mon Feb 01 12:23:06 2010 +0100
311.2 +++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/TinyTest.java Mon Feb 01 12:24:26 2010 +0100
311.3 @@ -166,6 +166,21 @@
311.4 "3:30-3:31:verifier:ERR_ResultSetZero");
311.5 }
311.6
311.7 + public void testResultSet180027() throws Exception {
311.8 + performAnalysisTest("test/Test.java",
311.9 + "package test;\n" +
311.10 + "public class Test {\n" +
311.11 + " public Object test(R set, int i) {\n" +
311.12 + " set.getBoolean(0);\n" +
311.13 + " return set.getBoolean(i + 1);\n" +
311.14 + " }" +
311.15 + " private interface R extends java.sql.ResultSet {" +
311.16 + " public boolean getBoolean(int i);" +
311.17 + " }\n" +
311.18 + "}\n",
311.19 + "3:23-3:24:verifier:ERR_ResultSetZero");
311.20 + }
311.21 +
311.22 @Override
311.23 protected String toDebugString(CompilationInfo info, Fix f) {
311.24 return f.getText();
312.1 --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/J2SEProjectGeneratorTest.java Mon Feb 01 12:23:06 2010 +0100
312.2 +++ b/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/J2SEProjectGeneratorTest.java Mon Feb 01 12:24:26 2010 +0100
312.3 @@ -42,8 +42,6 @@
312.4 package org.netbeans.modules.java.j2seproject;
312.5
312.6 import java.io.File;
312.7 -import java.util.ArrayList;
312.8 -import java.util.List;
312.9 import org.netbeans.api.project.FileOwnerQuery;
312.10 import org.netbeans.api.project.Project;
312.11 import org.netbeans.junit.NbTestCase;
312.12 @@ -83,94 +81,6 @@
312.13 // "nbproject/private/private.properties", no private.properties are created when project and source roots are collocated
312.14 };
312.15
312.16 - private static final String[] createdProperties = {
312.17 - "build.classes.dir",
312.18 - "build.classes.excludes",
312.19 - "build.dir",
312.20 - "build.generated.dir",
312.21 - "build.generated.sources.dir",
312.22 - "build.sysclasspath",
312.23 - "build.test.classes.dir",
312.24 - "build.test.results.dir",
312.25 - "debug.classpath",
312.26 - "debug.test.classpath",
312.27 - "dist.dir",
312.28 - "dist.jar",
312.29 - "dist.javadoc.dir",
312.30 - "jar.compress",
312.31 - "javac.classpath",
312.32 - "javac.compilerargs",
312.33 - "javac.deprecation",
312.34 - "javac.source",
312.35 - "javac.target",
312.36 - "javac.test.classpath",
312.37 - "javadoc.author",
312.38 - "javadoc.encoding",
312.39 - "javadoc.noindex",
312.40 - "javadoc.nonavbar",
312.41 - "javadoc.notree",
312.42 - "javadoc.private",
312.43 - "javadoc.splitindex",
312.44 - "javadoc.use",
312.45 - "javadoc.version",
312.46 - "javadoc.windowtitle",
312.47 - "javadoc.additionalparam",
312.48 - "main.class",
312.49 - "manifest.file",
312.50 - "meta.inf.dir",
312.51 - "platform.active",
312.52 - "source.encoding",
312.53 - "run.classpath",
312.54 - "run.jvmargs",
312.55 - "run.test.classpath",
312.56 - "src.dir",
312.57 - "test.src.dir",
312.58 - };
312.59 -
312.60 - private static final String[] createdPropertiesExtSources = {
312.61 - "build.classes.dir",
312.62 - "build.classes.excludes",
312.63 - "build.dir",
312.64 - "build.generated.dir",
312.65 - "build.generated.sources.dir",
312.66 - "build.sysclasspath",
312.67 - "build.test.classes.dir",
312.68 - "build.test.results.dir",
312.69 - "debug.classpath",
312.70 - "debug.test.classpath",
312.71 - "dist.dir",
312.72 - "dist.jar",
312.73 - "dist.javadoc.dir",
312.74 - "jar.compress",
312.75 - "javac.classpath",
312.76 - "javac.compilerargs",
312.77 - "javac.deprecation",
312.78 - "javac.source",
312.79 - "javac.target",
312.80 - "javac.test.classpath",
312.81 - "javadoc.author",
312.82 - "javadoc.encoding",
312.83 - "javadoc.noindex",
312.84 - "javadoc.nonavbar",
312.85 - "javadoc.notree",
312.86 - "javadoc.private",
312.87 - "javadoc.splitindex",
312.88 - "javadoc.use",
312.89 - "javadoc.version",
312.90 - "javadoc.windowtitle",
312.91 - "javadoc.additionalparam",
312.92 - "main.class",
312.93 - "manifest.file",
312.94 - "meta.inf.dir",
312.95 - "platform.active",
312.96 - "source.encoding",
312.97 - "run.classpath",
312.98 - "run.jvmargs",
312.99 - "run.test.classpath",
312.100 - "src.dir",
312.101 - "test.src.dir",
312.102 - };
312.103 -
312.104 public void testCreateProject() throws Exception {
312.105 MockLookup.setLayersAndInstances();
312.106 File proj = getWorkDir();
312.107 @@ -183,13 +93,6 @@
312.108 for (int i=0; i<createdFiles.length; i++) {
312.109 assertNotNull(createdFiles[i]+" file/folder cannot be found", fo.getFileObject(createdFiles[i]));
312.110 }
312.111 - EditableProperties props = aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
312.112 - List<String> l = new ArrayList<String>(props.keySet());
312.113 - for (String p : createdProperties) {
312.114 - assertNotNull(p + " property cannot be found in project.properties", props.getProperty(p));
312.115 - l.remove(p);
312.116 - }
312.117 - assertEquals("Found unexpected property: "+l,createdProperties.length, props.keySet().size());
312.118 }
312.119
312.120 public void testCreateProjectFromExtSources () throws Exception {
312.121 @@ -210,39 +113,16 @@
312.122 assertNotNull(createdFilesExtSources[i]+" file/folder cannot be found", fo.getFileObject(createdFilesExtSources[i]));
312.123 }
312.124 EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
312.125 - List<String> l = new ArrayList<String>(props.keySet());
312.126 - int extFileRefCount = 0;
312.127 - for (String propName : createdPropertiesExtSources) {
312.128 + for (String propName : new String[] {"src.dir", "test.src.dir"}) {
312.129 String propValue = props.getProperty(propName);
312.130 assertNotNull(propName+" property cannot be found in project.properties", propValue);
312.131 - l.remove(propName);
312.132 - if ("manifest.file".equals (propName)) {
312.133 - assertEquals("Invalid value of manifest.file property.", "manifest.mf", propValue);
312.134 - }
312.135 - else if ("src.dir".equals (propName)) {
312.136 - PropertyEvaluator eval = helper.getStandardPropertyEvaluator();
312.137 - //Remove the file.reference to the source.dir, it is implementation detail
312.138 - //depending on the presence of the AlwaysRelativeCollocationQuery
312.139 - assertTrue("Value of the external source dir should be file reference",propValue.startsWith("${file.reference."));
312.140 - if (l.remove (propValue.subSequence(2,propValue.length()-1))) {
312.141 - extFileRefCount++;
312.142 - }
312.143 - File file = helper.resolveFile(eval.evaluate(propValue));
312.144 - assertEquals("Invalid value of src.dir property.", srcRoot, file);
312.145 - }
312.146 - else if ("test.src.dir".equals(propName)) {
312.147 - PropertyEvaluator eval = helper.getStandardPropertyEvaluator();
312.148 - //Remove the file.reference to the source.dir, it is implementation detail
312.149 - //depending on the presence of the AlwaysRelativeCollocationQuery
312.150 - assertTrue("Value of the external test dir should be file reference",propValue.startsWith("${file.reference."));
312.151 - if (l.remove (propValue.subSequence(2,propValue.length()-1))) {
312.152 - extFileRefCount++;
312.153 - }
312.154 - File file = helper.resolveFile(eval.evaluate(propValue));
312.155 - assertEquals("Invalid value of test.src.dir property.", testRoot, file);
312.156 - }
312.157 + PropertyEvaluator eval = helper.getStandardPropertyEvaluator();
312.158 + //Remove the file.reference to the source.dir, it is implementation detail
312.159 + //depending on the presence of the AlwaysRelativeCollocationQuery
312.160 + assertTrue("Value of " + propName + " should be file reference", propValue.startsWith("${file.reference."));
312.161 + File file = helper.resolveFile(eval.evaluate(propValue));
312.162 + assertEquals("Invalid value of " + propName + " property", propName.equals("src.dir") ? srcRoot : testRoot, file);
312.163 }
312.164 - assertEquals("Found unexpected property: "+l,createdPropertiesExtSources.length, props.keySet().size() - extFileRefCount);
312.165 }
312.166
312.167 //Tests issue: #147128:J2SESources does not register new external roots immediately
313.1 --- a/java.navigation/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
313.2 +++ b/java.navigation/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
313.3 @@ -56,6 +56,14 @@
313.4 </run-dependency>
313.5 </dependency>
313.6 <dependency>
313.7 + <code-name-base>org.openide.text</code-name-base>
313.8 + <build-prerequisite/>
313.9 + <compile-dependency/>
313.10 + <run-dependency>
313.11 + <specification-version>6.16</specification-version>
313.12 + </run-dependency>
313.13 + </dependency>
313.14 + <dependency>
313.15 <code-name-base>org.netbeans.api.java</code-name-base>
313.16 <build-prerequisite/>
313.17 <compile-dependency/>
314.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
314.2 +++ b/java.navigation/src/org/netbeans/modules/java/navigation/resources/AnalyzeStackTopComponentSettings.xml Mon Feb 01 12:24:26 2010 +0100
314.3 @@ -0,0 +1,49 @@
314.4 +<?xml version="1.0" encoding="UTF-8"?>
314.5 +<!--
314.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
314.7 +
314.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
314.9 +
314.10 +
314.11 +The contents of this file are subject to the terms of either the GNU
314.12 +General Public License Version 2 only ("GPL") or the Common
314.13 +Development and Distribution License("CDDL") (collectively, the
314.14 +"License"). You may not use this file except in compliance with the
314.15 +License. You can obtain a copy of the License at
314.16 +http://www.netbeans.org/cddl-gplv2.html
314.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
314.18 +specific language governing permissions and limitations under the
314.19 +License. When distributing the software, include this License Header
314.20 +Notice in each file and include the License file at
314.21 +nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
314.22 +particular file as subject to the "Classpath" exception as provided
314.23 +by Sun in the GPL Version 2 section of the License file that
314.24 +accompanied this code. If applicable, add the following below the
314.25 +License Header, with the fields enclosed by brackets [] replaced by
314.26 +your own identifying information:
314.27 +"Portions Copyrighted [year] [name of copyright owner]"
314.28 +
314.29 +Contributor(s):
314.30 +
314.31 +The Original Software is NetBeans. The Initial Developer of the Original
314.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
314.33 +Microsystems, Inc. All Rights Reserved.
314.34 +
314.35 +If you wish your version of this file to be governed by only the CDDL
314.36 +or only the GPL Version 2, indicate your decision by adding
314.37 +"[Contributor] elects to include this software in this distribution
314.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
314.39 +single choice of license, a recipient has the option to distribute
314.40 +your version of this file under either the CDDL, the GPL Version 2 or
314.41 +to extend the choice of license to its licensees as provided above.
314.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
314.43 +Version 2 license, then the option applies only if the new code is
314.44 +made subject to such option by the copyright holder.
314.45 +-->
314.46 +<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
314.47 +<settings version="1.0">
314.48 + <module name="org.netbeans.modules.java.navigation" spec="1.4"/>
314.49 + <instanceof class="org.openide.windows.TopComponent"/>
314.50 + <instanceof class="org.netbeans.modules.java.stackanalyzer.AnalyzeStackTopComponent"/>
314.51 + <instance class="org.netbeans.modules.java.stackanalyzer.AnalyzeStackTopComponent" method="getDefault"/>
314.52 +</settings>
315.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
315.2 +++ b/java.navigation/src/org/netbeans/modules/java/navigation/resources/AnalyzeStackTopComponentWstcref.xml Mon Feb 01 12:24:26 2010 +0100
315.3 @@ -0,0 +1,49 @@
315.4 +<?xml version="1.0" encoding="UTF-8"?>
315.5 +<!--
315.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
315.7 +
315.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
315.9 +
315.10 +
315.11 +The contents of this file are subject to the terms of either the GNU
315.12 +General Public License Version 2 only ("GPL") or the Common
315.13 +Development and Distribution License("CDDL") (collectively, the
315.14 +"License"). You may not use this file except in compliance with the
315.15 +License. You can obtain a copy of the License at
315.16 +http://www.netbeans.org/cddl-gplv2.html
315.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
315.18 +specific language governing permissions and limitations under the
315.19 +License. When distributing the software, include this License Header
315.20 +Notice in each file and include the License file at
315.21 +nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
315.22 +particular file as subject to the "Classpath" exception as provided
315.23 +by Sun in the GPL Version 2 section of the License file that
315.24 +accompanied this code. If applicable, add the following below the
315.25 +License Header, with the fields enclosed by brackets [] replaced by
315.26 +your own identifying information:
315.27 +"Portions Copyrighted [year] [name of copyright owner]"
315.28 +
315.29 +Contributor(s):
315.30 +
315.31 +The Original Software is NetBeans. The Initial Developer of the Original
315.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
315.33 +Microsystems, Inc. All Rights Reserved.
315.34 +
315.35 +If you wish your version of this file to be governed by only the CDDL
315.36 +or only the GPL Version 2, indicate your decision by adding
315.37 +"[Contributor] elects to include this software in this distribution
315.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
315.39 +single choice of license, a recipient has the option to distribute
315.40 +your version of this file under either the CDDL, the GPL Version 2 or
315.41 +to extend the choice of license to its licensees as provided above.
315.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
315.43 +Version 2 license, then the option applies only if the new code is
315.44 +made subject to such option by the copyright holder.
315.45 +-->
315.46 +
315.47 +<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
315.48 +<tc-ref version="2.0" >
315.49 + <module name="org.netbeans.modules.java.navigation" spec="1.4"/>
315.50 + <tc-id id="AnalyzeStackTopComponent"/>
315.51 + <state opened="false"/>
315.52 +</tc-ref>
316.1 --- a/java.navigation/src/org/netbeans/modules/java/navigation/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
316.2 +++ b/java.navigation/src/org/netbeans/modules/java/navigation/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
316.3 @@ -116,6 +116,7 @@
316.4 <folder name="Window">
316.5 <file name="org-netbeans-modules-java-navigation-actions-DeclarationAction.instance"/>
316.6 <file name="org-netbeans-modules-java-navigation-actions-JavadocAction.instance"/>
316.7 + <file name="org-netbeans-modules-java-stackanalyzer-AnalyzeStackAction.instance"/>
316.8 </folder>
316.9 </folder>
316.10
316.11 @@ -163,14 +164,19 @@
316.12 <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-java-navigation-actions-JavadocAction.instance"/>
316.13 <attr name="position" intvalue="500"/>
316.14 </file>
316.15 + <file name="AnalyzeStackAction.shadow">
316.16 + <attr name="position" intvalue="1000"/>
316.17 + <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-java-stackanalyzer-AnalyzeStackAction.instance"/>
316.18 + </file>
316.19 </folder>
316.20 - </folder>
316.21 + </folder>
316.22 </folder>
316.23
316.24 <folder name="Windows2">
316.25 <folder name="Components">
316.26 <file name="DeclarationTopComponent.settings" url="DeclarationTopComponentSettings.xml"/>
316.27 <file name="JavadocTopComponent.settings" url="JavadocTopComponentSettings.xml"/>
316.28 + <file name="AnalyzeStackTopComponent.settings" url="AnalyzeStackTopComponentSettings.xml"/>
316.29 </folder>
316.30 <folder name="Modes">
316.31 <folder name="output">
316.32 @@ -181,6 +187,9 @@
316.33 <attr name="position" intvalue="2500"/>
316.34 </file>
316.35 </folder>
316.36 + <folder name="properties">
316.37 + <file name="AnalyzeStackTopComponent.wstcref" url="AnalyzeStackTopComponentWstcref.xml"/>
316.38 + </folder>
316.39 </folder>
316.40 </folder>
316.41
317.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
317.2 +++ b/java.navigation/src/org/netbeans/modules/java/stackanalyzer/AnalyzeStackAction.java Mon Feb 01 12:24:26 2010 +0100
317.3 @@ -0,0 +1,64 @@
317.4 +/*
317.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
317.6 + *
317.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
317.8 + *
317.9 + * The contents of this file are subject to the terms of either the GNU
317.10 + * General Public License Version 2 only ("GPL") or the Common
317.11 + * Development and Distribution License("CDDL") (collectively, the
317.12 + * "License"). You may not use this file except in compliance with the
317.13 + * License. You can obtain a copy of the License at
317.14 + * http://www.netbeans.org/cddl-gplv2.html
317.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
317.16 + * specific language governing permissions and limitations under the
317.17 + * License. When distributing the software, include this License Header
317.18 + * Notice in each file and include the License file at
317.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
317.20 + * particular file as subject to the "Classpath" exception as provided
317.21 + * by Sun in the GPL Version 2 section of the License file that
317.22 + * accompanied this code. If applicable, add the following below the
317.23 + * License Header, with the fields enclosed by brackets [] replaced by
317.24 + * your own identifying information:
317.25 + * "Portions Copyrighted [year] [name of copyright owner]"
317.26 + *
317.27 + * Contributor(s):
317.28 + *
317.29 + * The Original Software is NetBeans. The Initial Developer of the Original
317.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
317.31 + * Microsystems, Inc. All Rights Reserved.
317.32 + *
317.33 + * If you wish your version of this file to be governed by only the CDDL
317.34 + * or only the GPL Version 2, indicate your decision by adding
317.35 + * "[Contributor] elects to include this software in this distribution
317.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
317.37 + * single choice of license, a recipient has the option to distribute
317.38 + * your version of this file under either the CDDL, the GPL Version 2 or
317.39 + * to extend the choice of license to its licensees as provided above.
317.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
317.41 + * Version 2 license, then the option applies only if the new code is
317.42 + * made subject to such option by the copyright holder.
317.43 + */
317.44 +package org.netbeans.modules.java.stackanalyzer;
317.45 +
317.46 +import java.awt.event.ActionEvent;
317.47 +import javax.swing.AbstractAction;
317.48 +import org.openide.util.NbBundle;
317.49 +import org.openide.windows.TopComponent;
317.50 +
317.51 +/**
317.52 + * Action which shows AnalyzeStack component.
317.53 + * @author Jan Becicka
317.54 + */
317.55 +public class AnalyzeStackAction extends AbstractAction {
317.56 +
317.57 + public AnalyzeStackAction() {
317.58 + super(NbBundle.getMessage(AnalyzeStackAction.class, "CTL_AnalyzeStackAction"));
317.59 +// putValue(SMALL_ICON, new ImageIcon(Utilities.loadImage(AnalyzeStackTopComponent.ICON_PATH, true)));
317.60 + }
317.61 +
317.62 + public void actionPerformed(ActionEvent evt) {
317.63 + TopComponent win = AnalyzeStackTopComponent.findInstance();
317.64 + win.open();
317.65 + win.requestActive();
317.66 + }
317.67 +}
318.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
318.2 +++ b/java.navigation/src/org/netbeans/modules/java/stackanalyzer/AnalyzeStackTopComponent.form Mon Feb 01 12:24:26 2010 +0100
318.3 @@ -0,0 +1,91 @@
318.4 +<?xml version="1.0" encoding="UTF-8" ?>
318.5 +
318.6 +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
318.7 + <Properties>
318.8 + <Property name="name" type="java.lang.String" value="Form" noResource="true"/>
318.9 + </Properties>
318.10 + <AccessibilityProperties>
318.11 + <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
318.12 + <ResourceString bundle="org/netbeans/modules/stackanalyzer/Bundle.properties" key="AnalyzeStackTopComponent.AccessibleContext.accessibleName" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
318.13 + </Property>
318.14 + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
318.15 + <ResourceString bundle="org/netbeans/modules/stackanalyzer/Bundle.properties" key="AnalyzeStackTopComponent.AccessibleContext.accessibleDescription" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
318.16 + </Property>
318.17 + </AccessibilityProperties>
318.18 + <AuxValues>
318.19 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
318.20 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
318.21 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
318.22 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
318.23 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
318.24 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
318.25 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
318.26 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
318.27 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
318.28 + </AuxValues>
318.29 +
318.30 + <Layout>
318.31 + <DimensionLayout dim="0">
318.32 + <Group type="103" groupAlignment="0" attributes="0">
318.33 + <Group type="102" alignment="0" attributes="0">
318.34 + <EmptySpace max="-2" attributes="0"/>
318.35 + <Group type="103" groupAlignment="0" attributes="0">
318.36 + <Component id="analyzeScroll" alignment="0" pref="393" max="32767" attributes="0"/>
318.37 + <Component id="insertButton" alignment="0" min="-2" max="-2" attributes="0"/>
318.38 + </Group>
318.39 + <EmptySpace max="-2" attributes="0"/>
318.40 + </Group>
318.41 + </Group>
318.42 + </DimensionLayout>
318.43 + <DimensionLayout dim="1">
318.44 + <Group type="103" groupAlignment="0" attributes="0">
318.45 + <Group type="102" alignment="0" attributes="0">
318.46 + <EmptySpace max="-2" attributes="0"/>
318.47 + <Component id="insertButton" min="-2" max="-2" attributes="0"/>
318.48 + <EmptySpace max="-2" attributes="0"/>
318.49 + <Component id="analyzeScroll" pref="367" max="32767" attributes="0"/>
318.50 + <EmptySpace max="-2" attributes="0"/>
318.51 + </Group>
318.52 + </Group>
318.53 + </DimensionLayout>
318.54 + </Layout>
318.55 + <SubComponents>
318.56 + <Component class="javax.swing.JButton" name="insertButton">
318.57 + <Properties>
318.58 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
318.59 + <ResourceString bundle="org/netbeans/modules/stackanalyzer/Bundle.properties" key="AnalyzeStackTopComponent.insertButton.text" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString("{key}")"/>
318.60 + </Property>
318.61 + <Property name="name" type="java.lang.String" value="insertButton" noResource="true"/>
318.62 + </Properties>
318.63 + <AccessibilityProperties>
318.64 + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
318.65 + <ResourceString bundle="org/netbeans/modules/stackanalyzer/Bundle.properties" key="AnalyzeStackTopComponent.insertButton.AccessibleContext.accessibleDescription" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
318.66 + </Property>
318.67 + </AccessibilityProperties>
318.68 + <Events>
318.69 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="insertButtonActionPerformed"/>
318.70 + </Events>
318.71 + </Component>
318.72 + <Container class="javax.swing.JScrollPane" name="analyzeScroll">
318.73 + <Properties>
318.74 + <Property name="name" type="java.lang.String" value="analyzeScroll" noResource="true"/>
318.75 + </Properties>
318.76 + <AuxValues>
318.77 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
318.78 + </AuxValues>
318.79 +
318.80 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
318.81 + <SubComponents>
318.82 + <Component class="javax.swing.JList" name="analyzePane">
318.83 + <Properties>
318.84 + <Property name="selectionMode" type="int" value="0"/>
318.85 + <Property name="name" type="java.lang.String" value="analyzePane" noResource="true"/>
318.86 + </Properties>
318.87 + <Events>
318.88 + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="analyzePaneValueChanged"/>
318.89 + </Events>
318.90 + </Component>
318.91 + </SubComponents>
318.92 + </Container>
318.93 + </SubComponents>
318.94 +</Form>
319.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
319.2 +++ b/java.navigation/src/org/netbeans/modules/java/stackanalyzer/AnalyzeStackTopComponent.java Mon Feb 01 12:24:26 2010 +0100
319.3 @@ -0,0 +1,333 @@
319.4 +/*
319.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
319.6 + *
319.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
319.8 + *
319.9 + * The contents of this file are subject to the terms of either the GNU
319.10 + * General Public License Version 2 only ("GPL") or the Common
319.11 + * Development and Distribution License("CDDL") (collectively, the
319.12 + * "License"). You may not use this file except in compliance with the
319.13 + * License. You can obtain a copy of the License at
319.14 + * http://www.netbeans.org/cddl-gplv2.html
319.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
319.16 + * specific language governing permissions and limitations under the
319.17 + * License. When distributing the software, include this License Header
319.18 + * Notice in each file and include the License file at
319.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
319.20 + * particular file as subject to the "Classpath" exception as provided
319.21 + * by Sun in the GPL Version 2 section of the License file that
319.22 + * accompanied this code. If applicable, add the following below the
319.23 + * License Header, with the fields enclosed by brackets [] replaced by
319.24 + * your own identifying information:
319.25 + * "Portions Copyrighted [year] [name of copyright owner]"
319.26 + *
319.27 + * Contributor(s):
319.28 + *
319.29 + * The Original Software is NetBeans. The Initial Developer of the Original
319.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
319.31 + * Microsystems, Inc. All Rights Reserved.
319.32 + *
319.33 + * If you wish your version of this file to be governed by only the CDDL
319.34 + * or only the GPL Version 2, indicate your decision by adding
319.35 + * "[Contributor] elects to include this software in this distribution
319.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
319.37 + * single choice of license, a recipient has the option to distribute
319.38 + * your version of this file under either the CDDL, the GPL Version 2 or
319.39 + * to extend the choice of license to its licensees as provided above.
319.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
319.41 + * Version 2 license, then the option applies only if the new code is
319.42 + * made subject to such option by the copyright holder.
319.43 + */
319.44 +
319.45 +package org.netbeans.modules.java.stackanalyzer;
319.46 +
319.47 +import java.awt.Toolkit;
319.48 +import java.awt.datatransfer.Clipboard;
319.49 +import java.awt.datatransfer.DataFlavor;
319.50 +import java.awt.datatransfer.UnsupportedFlavorException;
319.51 +import java.awt.event.ActionEvent;
319.52 +import java.io.IOException;
319.53 +import java.io.Reader;
319.54 +import java.io.Serializable;
319.55 +import java.util.logging.Logger;
319.56 +import java.util.regex.Matcher;
319.57 +import java.util.regex.Pattern;
319.58 +import javax.swing.AbstractAction;
319.59 +import javax.swing.text.DefaultEditorKit;
319.60 +import javax.swing.text.StyledDocument;
319.61 +import org.netbeans.api.java.classpath.ClassPath;
319.62 +import org.netbeans.api.java.classpath.GlobalPathRegistry;
319.63 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
319.64 +import org.openide.ErrorManager;
319.65 +import org.openide.cookies.EditorCookie;
319.66 +import org.openide.cookies.LineCookie;
319.67 +import org.openide.cookies.OpenCookie;
319.68 +import org.openide.filesystems.FileObject;
319.69 +import org.openide.loaders.DataObject;
319.70 +import org.openide.text.Line;
319.71 +import org.openide.util.Exceptions;
319.72 +import org.openide.util.NbBundle;
319.73 +import org.openide.windows.TopComponent;
319.74 +import org.openide.windows.WindowManager;
319.75 +//import org.openide.util.Utilities;
319.76 +
319.77 +/**
319.78 + * Top component which displays something.
319.79 + * @author Jan Becicka
319.80 + */
319.81 +final class AnalyzeStackTopComponent extends TopComponent {
319.82 +
319.83 + private static AnalyzeStackTopComponent instance;
319.84 + /** path to the icon used by the component and its open action */
319.85 +// static final String ICON_PATH = "SET/PATH/TO/ICON/HERE";
319.86 +
319.87 + private static final String PREFERRED_ID = "AnalyzeStackTopComponent";
319.88 +
319.89 + private AnalyzeStackTopComponent() {
319.90 + initComponents();
319.91 + setName(NbBundle.getMessage(AnalyzeStackTopComponent.class, "CTL_AnalyzeStackTopComponent"));
319.92 + setToolTipText(NbBundle.getMessage(AnalyzeStackTopComponent.class, "HINT_AnalyzeStackTopComponent"));
319.93 + getActionMap().put(DefaultEditorKit.pasteAction, new AbstractActionImpl());
319.94 + insertButton.getActionMap().put(DefaultEditorKit.pasteAction, new AbstractActionImpl());
319.95 + analyzeScroll.getActionMap().put(DefaultEditorKit.pasteAction, new AbstractActionImpl());
319.96 + analyzePane.getActionMap().put(DefaultEditorKit.pasteAction, new AbstractActionImpl());
319.97 +// setIcon(Utilities.loadImage(ICON_PATH, true));
319.98 + }
319.99 +
319.100 +
319.101 +
319.102 + private void fillIn(Reader stackTrace) {
319.103 + analyzePane.setModel(new StackListModel(stackTrace));
319.104 + }
319.105 +
319.106 + /** This method is called from within the constructor to
319.107 + * initialize the form.
319.108 + * WARNING: Do NOT modify this code. The content of this method is
319.109 + * always regenerated by the Form Editor.
319.110 + */
319.111 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
319.112 + private void initComponents() {
319.113 +
319.114 + insertButton = new javax.swing.JButton();
319.115 + analyzeScroll = new javax.swing.JScrollPane();
319.116 + analyzePane = new javax.swing.JList();
319.117 +
319.118 + setName("Form"); // NOI18N
319.119 +
319.120 + org.openide.awt.Mnemonics.setLocalizedText(insertButton, org.openide.util.NbBundle.getBundle(AnalyzeStackTopComponent.class).getString("AnalyzeStackTopComponent.insertButton.text")); // NOI18N
319.121 + insertButton.setName("insertButton"); // NOI18N
319.122 + insertButton.addActionListener(new java.awt.event.ActionListener() {
319.123 + public void actionPerformed(java.awt.event.ActionEvent evt) {
319.124 + insertButtonActionPerformed(evt);
319.125 + }
319.126 + });
319.127 +
319.128 + analyzeScroll.setName("analyzeScroll"); // NOI18N
319.129 +
319.130 + analyzePane.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
319.131 + analyzePane.setName("analyzePane"); // NOI18N
319.132 + analyzePane.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
319.133 + public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
319.134 + analyzePaneValueChanged(evt);
319.135 + }
319.136 + });
319.137 + analyzeScroll.setViewportView(analyzePane);
319.138 +
319.139 + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
319.140 + this.setLayout(layout);
319.141 + layout.setHorizontalGroup(
319.142 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
319.143 + .add(layout.createSequentialGroup()
319.144 + .addContainerGap()
319.145 + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
319.146 + .add(analyzeScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
319.147 + .add(insertButton))
319.148 + .addContainerGap())
319.149 + );
319.150 + layout.setVerticalGroup(
319.151 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
319.152 + .add(layout.createSequentialGroup()
319.153 + .addContainerGap()
319.154 + .add(insertButton)
319.155 + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
319.156 + .add(analyzeScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
319.157 + .addContainerGap())
319.158 + );
319.159 +
319.160 + insertButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AnalyzeStackTopComponent.class, "AnalyzeStackTopComponent.insertButton.AccessibleContext.accessibleDescription")); // NOI18N
319.161 +
319.162 + getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AnalyzeStackTopComponent.class, "AnalyzeStackTopComponent.AccessibleContext.accessibleName")); // NOI18N
319.163 + getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AnalyzeStackTopComponent.class, "AnalyzeStackTopComponent.AccessibleContext.accessibleDescription")); // NOI18N
319.164 + }// </editor-fold>//GEN-END:initComponents
319.165 +
319.166 + private void insertButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertButtonActionPerformed
319.167 + try {
319.168 + Clipboard clipBoard = Toolkit.getDefaultToolkit().getSystemClipboard();
319.169 + Reader stackTrace = DataFlavor.stringFlavor.getReaderForText(clipBoard.getContents(this));//GEN-LAST:event_insertButtonActionPerformed
319.170 + fillIn(stackTrace);
319.171 + } catch (UnsupportedFlavorException ex) {
319.172 + Exceptions.printStackTrace(ex);
319.173 + } catch (IOException ex) {
319.174 + Exceptions.printStackTrace(ex);
319.175 + }
319.176 +}
319.177 +
319.178 + private void analyzePaneValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_analyzePaneValueChanged
319.179 + String line = (String) analyzePane.getSelectedValue();
319.180 + if (line!=null)
319.181 + select(line);
319.182 + }//GEN-LAST:event_analyzePaneValueChanged
319.183 +
319.184 + // Variables declaration - do not modify//GEN-BEGIN:variables
319.185 + private javax.swing.JList analyzePane;
319.186 + private javax.swing.JScrollPane analyzeScroll;
319.187 + private javax.swing.JButton insertButton;
319.188 + // End of variables declaration//GEN-END:variables
319.189 + /**
319.190 + * Gets default instance. Do not use directly: reserved for *.settings files only,
319.191 + * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
319.192 + * To obtain the singleton instance, use {@link findInstance}.
319.193 + */
319.194 + public static synchronized AnalyzeStackTopComponent getDefault() {
319.195 + if (instance == null) {
319.196 + instance = new AnalyzeStackTopComponent();
319.197 + }
319.198 + return instance;
319.199 + }
319.200 +
319.201 + /**
319.202 + * Obtain the AnalyzeStackTopComponent instance. Never call {@link #getDefault} directly!
319.203 + */
319.204 + public static synchronized AnalyzeStackTopComponent findInstance() {
319.205 + TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
319.206 + if (win == null) {
319.207 + Logger.getLogger(AnalyzeStackTopComponent.class.getName()).warning(
319.208 + "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
319.209 + return getDefault();
319.210 + }
319.211 + if (win instanceof AnalyzeStackTopComponent) {
319.212 + return (AnalyzeStackTopComponent) win;
319.213 + }
319.214 + Logger.getLogger(AnalyzeStackTopComponent.class.getName()).warning(
319.215 + "There seem to be multiple components with the '" + PREFERRED_ID +
319.216 + "' ID. That is a potential source of errors and unexpected behavior.");
319.217 + return getDefault();
319.218 + }
319.219 +
319.220 + @Override
319.221 + public int getPersistenceType() {
319.222 + return TopComponent.PERSISTENCE_ALWAYS;
319.223 + }
319.224 +
319.225 + @Override
319.226 + public void componentOpened() {
319.227 + // TODO add custom code on component opening
319.228 + }
319.229 +
319.230 + @Override
319.231 + public void componentClosed() {
319.232 + // TODO add custom code on component closing
319.233 + }
319.234 +
319.235 + /** replaces this in object stream */
319.236 + @Override
319.237 + public Object writeReplace() {
319.238 + return new ResolvableHelper();
319.239 + }
319.240 +
319.241 + @Override
319.242 + protected String preferredID() {
319.243 + return PREFERRED_ID;
319.244 + }
319.245 +
319.246 + final static class ResolvableHelper implements Serializable {
319.247 +
319.248 + private static final long serialVersionUID = 1L;
319.249 +
319.250 + public Object readResolve() {
319.251 + return AnalyzeStackTopComponent.getDefault();
319.252 + }
319.253 + }
319.254 +
319.255 + /**
319.256 + * Regexp matching one line (not the first) of a stack trace.
319.257 + * Captured groups:
319.258 + * <ol>
319.259 + * <li>package
319.260 + * <li>filename
319.261 + * <li>line number
319.262 + * </ol>
319.263 + */
319.264 + static final Pattern STACK_TRACE = Pattern.compile(
319.265 + "(\\s)+(|catch )at ((?:[a-zA-Z_$][a-zA-Z0-9_$]*\\.)*)[a-zA-Z_$][a-zA-Z0-9_$]*\\.[a-zA-Z_$<][a-zA-Z0-9_$>]*\\(([a-zA-Z_$][a-zA-Z0-9_$]*\\.java):([0-9]+)\\)"); // NOI18N
319.266 +
319.267 + /**
319.268 + * Regexp matching the first line of a stack trace, with the exception message.
319.269 + * Captured groups:
319.270 + * <ol>
319.271 + * <li>unqualified name of exception class plus possible message
319.272 + * </ol>
319.273 + */
319.274 + static final Pattern EXCEPTION_MESSAGE = Pattern.compile(
319.275 + // #42894: JRockit uses "Main Thread" not "main"
319.276 + "(?:Exception in thread \"(?:main|Main Thread)\" )?(?:(?:[a-zA-Z_$][a-zA-Z0-9_$]*\\.)+)([a-zA-Z_$][a-zA-Z0-9_$]*(?:: .+)?)"); // NOI18N
319.277 +
319.278 + private void select(String line) {
319.279 + Matcher m = STACK_TRACE.matcher(line);
319.280 + if (m.matches()) {
319.281 + String pkg = m.group(3);
319.282 + String filename = m.group(4);
319.283 + String resource = pkg.replace('.', '/') + filename;
319.284 + int lineNumber = Integer.parseInt(m.group(5));
319.285 + ClassPath cp = ClassPathSupport.createClassPath(GlobalPathRegistry.getDefault().getSourceRoots().toArray(new FileObject[0]));
319.286 + FileObject source = cp.findResource(resource);
319.287 + if (source != null) {
319.288 + doOpen(source, lineNumber);
319.289 + }
319.290 + }
319.291 + }
319.292 +
319.293 + private static boolean doOpen(FileObject fo, int line) {
319.294 + try {
319.295 + DataObject od = DataObject.find(fo);
319.296 + EditorCookie ec = (EditorCookie) od.getCookie(EditorCookie.class);
319.297 + LineCookie lc = (LineCookie) od.getCookie(LineCookie.class);
319.298 +
319.299 + if (ec != null && lc != null && line != -1) {
319.300 + StyledDocument doc = ec.openDocument();
319.301 + if (doc != null) {
319.302 + if (line != -1) {
319.303 + Line l = lc.getLineSet().getCurrent(line-1);
319.304 +
319.305 + if (l != null) {
319.306 + l.show(Line.SHOW_GOTO);
319.307 + return true;
319.308 + }
319.309 + }
319.310 + }
319.311 + }
319.312 +
319.313 + OpenCookie oc = (OpenCookie) od.getCookie(OpenCookie.class);
319.314 +
319.315 + if (oc != null) {
319.316 + oc.open();
319.317 + return true;
319.318 + }
319.319 + } catch (IOException e) {
319.320 + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
319.321 + }
319.322 +
319.323 + return false;
319.324 + }
319.325 +
319.326 + private class AbstractActionImpl extends AbstractAction {
319.327 +
319.328 + public AbstractActionImpl() {
319.329 + }
319.330 +
319.331 + public void actionPerformed(ActionEvent e) {
319.332 + insertButtonActionPerformed(null);
319.333 + }
319.334 + }
319.335 +
319.336 +}
320.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
320.2 +++ b/java.navigation/src/org/netbeans/modules/java/stackanalyzer/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
320.3 @@ -0,0 +1,50 @@
320.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
320.5 +#
320.6 +# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
320.7 +#
320.8 +# The contents of this file are subject to the terms of either the GNU
320.9 +# General Public License Version 2 only ("GPL") or the Common
320.10 +# Development and Distribution License("CDDL") (collectively, the
320.11 +# "License"). You may not use this file except in compliance with the
320.12 +# License. You can obtain a copy of the License at
320.13 +# http://www.netbeans.org/cddl-gplv2.html
320.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
320.15 +# specific language governing permissions and limitations under the
320.16 +# License. When distributing the software, include this License Header
320.17 +# Notice in each file and include the License file at
320.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
320.19 +# particular file as subject to the "Classpath" exception as provided
320.20 +# by Sun in the GPL Version 2 section of the License file that
320.21 +# accompanied this code. If applicable, add the following below the
320.22 +# License Header, with the fields enclosed by brackets [] replaced by
320.23 +# your own identifying information:
320.24 +# "Portions Copyrighted [year] [name of copyright owner]"
320.25 +#
320.26 +# Contributor(s):
320.27 +#
320.28 +# The Original Software is NetBeans. The Initial Developer of the Original
320.29 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
320.30 +# Microsystems, Inc. All Rights Reserved.
320.31 +#
320.32 +# If you wish your version of this file to be governed by only the CDDL
320.33 +# or only the GPL Version 2, indicate your decision by adding
320.34 +# "[Contributor] elects to include this software in this distribution
320.35 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
320.36 +# single choice of license, a recipient has the option to distribute
320.37 +# your version of this file under either the CDDL, the GPL Version 2 or
320.38 +# to extend the choice of license to its licensees as provided above.
320.39 +# However, if you add GPL Version 2 code and therefore, elected the GPL
320.40 +# Version 2 license, then the option applies only if the new code is
320.41 +# made subject to such option by the copyright holder.
320.42 +CTL_AnalyzeStackAction=Analyze Stack
320.43 +CTL_AnalyzeStackTopComponent=Analyze Stack Window
320.44 +HINT_AnalyzeStackTopComponent=This is a Analyze Stack window
320.45 +OpenIDE-Module-Display-Category=Experimental
320.46 +OpenIDE-Module-Long-Description=\
320.47 + Easy navigation from external stack trace to source code.
320.48 +OpenIDE-Module-Name=Stack Analyzer
320.49 +AnalyzeStackTopComponent.insertButton.text=Insert StackTrace From Clipboard
320.50 +OpenIDE-Module-Short-Description=Easy navigation from external stack trace to source code.
320.51 +AnalyzeStackTopComponent.insertButton.AccessibleContext.accessibleDescription=Insert StackTrace From Clipboard
320.52 +AnalyzeStackTopComponent.AccessibleContext.accessibleName=Analyze Stack
320.53 +AnalyzeStackTopComponent.AccessibleContext.accessibleDescription=Analyze Stack
321.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
321.2 +++ b/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackListModel.java Mon Feb 01 12:24:26 2010 +0100
321.3 @@ -0,0 +1,86 @@
321.4 +/*
321.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
321.6 + *
321.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
321.8 + *
321.9 + * The contents of this file are subject to the terms of either the GNU
321.10 + * General Public License Version 2 only ("GPL") or the Common
321.11 + * Development and Distribution License("CDDL") (collectively, the
321.12 + * "License"). You may not use this file except in compliance with the
321.13 + * License. You can obtain a copy of the License at
321.14 + * http://www.netbeans.org/cddl-gplv2.html
321.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
321.16 + * specific language governing permissions and limitations under the
321.17 + * License. When distributing the software, include this License Header
321.18 + * Notice in each file and include the License file at
321.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
321.20 + * particular file as subject to the "Classpath" exception as provided
321.21 + * by Sun in the GPL Version 2 section of the License file that
321.22 + * accompanied this code. If applicable, add the following below the
321.23 + * License Header, with the fields enclosed by brackets [] replaced by
321.24 + * your own identifying information:
321.25 + * "Portions Copyrighted [year] [name of copyright owner]"
321.26 + *
321.27 + * Contributor(s):
321.28 + *
321.29 + * The Original Software is NetBeans. The Initial Developer of the Original
321.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
321.31 + * Microsystems, Inc. All Rights Reserved.
321.32 + *
321.33 + * If you wish your version of this file to be governed by only the CDDL
321.34 + * or only the GPL Version 2, indicate your decision by adding
321.35 + * "[Contributor] elects to include this software in this distribution
321.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
321.37 + * single choice of license, a recipient has the option to distribute
321.38 + * your version of this file under either the CDDL, the GPL Version 2 or
321.39 + * to extend the choice of license to its licensees as provided above.
321.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
321.41 + * Version 2 license, then the option applies only if the new code is
321.42 + * made subject to such option by the copyright holder.
321.43 + */
321.44 +
321.45 +package org.netbeans.modules.java.stackanalyzer;
321.46 +
321.47 +import java.io.BufferedReader;
321.48 +import java.io.IOException;
321.49 +import java.io.Reader;
321.50 +import java.util.ArrayList;
321.51 +import java.util.regex.Matcher;
321.52 +import javax.swing.AbstractListModel;
321.53 +import org.openide.util.Exceptions;
321.54 +/**
321.55 + * @author Jan Becicka
321.56 + */
321.57 +class StackListModel extends AbstractListModel {
321.58 + private ArrayList<String> lines = new ArrayList();
321.59 +
321.60 + public StackListModel(Reader stack) {
321.61 + BufferedReader r = new BufferedReader(stack);
321.62 + String currentLine = null;
321.63 + do {
321.64 + try {
321.65 + currentLine = r.readLine();
321.66 + if (currentLine != null) {
321.67 + Matcher m = AnalyzeStackTopComponent.STACK_TRACE.matcher(currentLine);
321.68 + if (m.matches()) {
321.69 + lines.add(currentLine);
321.70 + }
321.71 + m = AnalyzeStackTopComponent.EXCEPTION_MESSAGE.matcher(currentLine);
321.72 + if (m.matches()) {
321.73 + lines.add(currentLine);
321.74 + }
321.75 + }
321.76 + } catch (IOException ex) {
321.77 + Exceptions.printStackTrace(ex);
321.78 + }
321.79 + } while (currentLine!=null);
321.80 + }
321.81 +
321.82 + public int getSize() {
321.83 + return lines.size();
321.84 + }
321.85 +
321.86 + public Object getElementAt(int index) {
321.87 + return lines.get(index);
321.88 + }
321.89 +}
322.1 --- a/java.source/src/org/netbeans/modules/java/source/classpath/CacheSourceForBinaryQueryImpl.java Mon Feb 01 12:23:06 2010 +0100
322.2 +++ b/java.source/src/org/netbeans/modules/java/source/classpath/CacheSourceForBinaryQueryImpl.java Mon Feb 01 12:24:26 2010 +0100
322.3 @@ -45,6 +45,7 @@
322.4 import java.net.URL;
322.5 import javax.swing.event.ChangeListener;
322.6 import org.netbeans.api.java.classpath.GlobalPathRegistry;
322.7 +import org.netbeans.api.java.queries.AnnotationProcessingQuery;
322.8 import org.netbeans.api.java.queries.SourceForBinaryQuery;
322.9 import org.netbeans.modules.java.source.indexing.JavaIndex;
322.10 import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
322.11 @@ -129,10 +130,15 @@
322.12 result = new FileObject[0];
322.13 }
322.14 else {
322.15 - FileObject aptRoot = resolveAptSourceCache(sourceRoot);
322.16 - result = aptRoot != null ?
322.17 - new FileObject[] {this.sourceRoot, aptRoot} :
322.18 - new FileObject[] {this.sourceRoot};
322.19 + final FileObject[] aptRoots = resolveAptSourceCache(sourceRoot);
322.20 + if (aptRoots.length == 0) {
322.21 + result = new FileObject[] {this.sourceRoot};
322.22 + }
322.23 + else {
322.24 + result = new FileObject[1+aptRoots.length];
322.25 + result[0] = this.sourceRoot;
322.26 + System.arraycopy(aptRoots, 0, result, 1, aptRoots.length);
322.27 + }
322.28 }
322.29 }
322.30 return result;
322.31 @@ -142,9 +148,19 @@
322.32 * Resolves the APT sources cache root
322.33 * Depends on the JavaIndex rather than on AptCacheForSourceQuery due to performance reasons
322.34 */
322.35 - private static FileObject resolveAptSourceCache(final FileObject sourceRoot) {
322.36 + private static FileObject[] resolveAptSourceCache(final FileObject sourceRoot) {
322.37 try {
322.38 - return FileUtil.toFileObject(JavaIndex.getAptFolder(sourceRoot.getURL(), false));
322.39 + final AnnotationProcessingQuery.Result result = AnnotationProcessingQuery.getAnnotationProcessingOptions(sourceRoot);
322.40 + final URL annotationOutputURL = result.sourceOutputDirectory();
322.41 + final FileObject userAnnotationOutput = annotationOutputURL == null ? null : URLMapper.findFileObject(annotationOutputURL);
322.42 + final FileObject cacheAnnoationOutput = FileUtil.toFileObject(JavaIndex.getAptFolder(sourceRoot.getURL(), false));
322.43 + return userAnnotationOutput == null ?
322.44 + cacheAnnoationOutput == null ?
322.45 + new FileObject[0] :
322.46 + new FileObject[] {cacheAnnoationOutput}
322.47 + : cacheAnnoationOutput == null ?
322.48 + new FileObject[] {userAnnotationOutput} :
322.49 + new FileObject[] {userAnnotationOutput, cacheAnnoationOutput};
322.50 } catch (IOException ex) {
322.51 Exceptions.printStackTrace(ex);
322.52 return null;
323.1 --- a/java.source/src/org/netbeans/modules/java/source/parsing/AptSourceFileManager.java Mon Feb 01 12:23:06 2010 +0100
323.2 +++ b/java.source/src/org/netbeans/modules/java/source/parsing/AptSourceFileManager.java Mon Feb 01 12:24:26 2010 +0100
323.3 @@ -146,7 +146,7 @@
323.4 throw new IllegalArgumentException("Invalid path argument: " + ownerRootURL); //NOI18N
323.5 }
323.6 }
323.7 - return true;
323.8 + return false; //Pass the option to all FileManagers
323.9 }
323.10 else {
323.11 return super.handleOption(head, tail);
324.1 --- a/java.source/src/org/netbeans/modules/java/source/parsing/FileObjects.java Mon Feb 01 12:23:06 2010 +0100
324.2 +++ b/java.source/src/org/netbeans/modules/java/source/parsing/FileObjects.java Mon Feb 01 12:24:26 2010 +0100
324.3 @@ -529,6 +529,7 @@
324.4 public static String getRelativePath (final String packageName, final String relativeName) {
324.5 StringBuilder relativePath = new StringBuilder ();
324.6 relativePath.append(packageName.replace('.','/'));
324.7 + relativePath.append('/');
324.8 relativePath.append(relativeName);
324.9 return relativePath.toString();
324.10 }
325.1 --- a/java.source/src/org/netbeans/modules/java/source/parsing/OutputFileManager.java Mon Feb 01 12:23:06 2010 +0100
325.2 +++ b/java.source/src/org/netbeans/modules/java/source/parsing/OutputFileManager.java Mon Feb 01 12:24:26 2010 +0100
325.3 @@ -70,12 +70,12 @@
325.4 public class OutputFileManager extends CachingFileManager {
325.5
325.6 private static final ClassPath EMPTY_PATH = ClassPathSupport.createClassPath(new URL[0]);
325.7 -
325.8 + private static final String ORIGIN_FILE = "apt-origin"; //NOI18N
325.9 + private static final String OUTPUT_ROOT = "output-root"; //NOI18N
325.10 /**
325.11 * Exception used to signal that the sourcepath is broken (project is deleted)
325.12 */
325.13 public class InvalidSourcePath extends IllegalStateException {
325.14 -
325.15 }
325.16
325.17 private ClassPath scp;
325.18 @@ -83,7 +83,8 @@
325.19 private final Set<File> filteredFiles = new HashSet<File>();
325.20 private boolean filtered;
325.21 private String outputRoot;
325.22 -
325.23 + private URL explicitSibling;
325.24 +
325.25 /** Creates a new instance of CachingFileManager */
325.26 public OutputFileManager(final CachingArchiveProvider provider,
325.27 final ClassPath outputClassPath,
325.28 @@ -95,18 +96,18 @@
325.29 this.scp = sourcePath;
325.30 this.apt = aptPath == null ? EMPTY_PATH : aptPath;
325.31 }
325.32 -
325.33 +
325.34 public final boolean isFiltered () {
325.35 return this.filtered;
325.36 }
325.37 -
325.38 +
325.39 public final synchronized void setFilteredFiles (final Set<File> files) {
325.40 assert files != null;
325.41 this.filteredFiles.clear();
325.42 this.filteredFiles.addAll(files);
325.43 this.filtered = true;
325.44 }
325.45 -
325.46 +
325.47 public final synchronized void clearFilteredFiles () {
325.48 this.filteredFiles.clear();
325.49 this.filtered = false;
325.50 @@ -124,19 +125,19 @@
325.51 File f = ((FileObjects.FileBase)o).f;
325.52 return filteredFiles.contains(f) ? 0 : -1;
325.53 }
325.54 - });
325.55 + });
325.56 return res;
325.57 }
325.58 }
325.59 -
325.60 +
325.61 public @Override JavaFileObject getJavaFileForOutput( Location l, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling )
325.62 throws IOException, UnsupportedOperationException, IllegalArgumentException {
325.63 -
325.64 -
325.65 +
325.66 +
325.67 if (kind != JavaFileObject.Kind.CLASS) {
325.68 throw new IllegalArgumentException ();
325.69 }
325.70 - else {
325.71 + else {
325.72 File activeRoot = null;
325.73 if (outputRoot != null) {
325.74 activeRoot = new File(outputRoot);
325.75 @@ -161,27 +162,28 @@
325.76 }
325.77 String baseName = className.replace('.', File.separatorChar); //NOI18N
325.78 String nameStr = baseName + '.' + FileObjects.SIG;
325.79 - int nameComponentIndex = nameStr.lastIndexOf(File.separatorChar);
325.80 + int nameComponentIndex = nameStr.lastIndexOf(File.separatorChar);
325.81 if (nameComponentIndex != -1) {
325.82 String pathComponent = nameStr.substring(0, nameComponentIndex);
325.83 new File (activeRoot, pathComponent).mkdirs();
325.84 }
325.85 else {
325.86 activeRoot.mkdirs();
325.87 - }
325.88 + }
325.89 File f = FileUtil.normalizeFile(new File (activeRoot, nameStr));
325.90 return OutputFileObject.create (activeRoot, f);
325.91 }
325.92 - }
325.93 -
325.94 + }
325.95 +
325.96 public @Override javax.tools.FileObject getFileForOutput( Location l, String pkgName, String relativeName, javax.tools.FileObject sibling )
325.97 throws IOException, UnsupportedOperationException, IllegalArgumentException {
325.98 assert pkgName != null;
325.99 assert relativeName != null;
325.100 - if (sibling == null) {
325.101 + URL siblingURL = explicitSibling != null ? explicitSibling : sibling == null ? null : sibling.toUri().toURL();
325.102 + if (siblingURL == null) {
325.103 throw new IllegalArgumentException ("sibling == null");
325.104 - }
325.105 - final int index = getActiveRootImpl (sibling);
325.106 + }
325.107 + final int index = getActiveRootImpl (siblingURL);
325.108 if (index == -1) {
325.109 //Deleted project
325.110 throw new InvalidSourcePath ();
325.111 @@ -203,18 +205,18 @@
325.112 File file = FileUtil.normalizeFile(new File (folder,relativeName));
325.113 return OutputFileObject.create (activeRoot,file);
325.114 }
325.115 -
325.116 +
325.117
325.118 private int getActiveRoot (final javax.tools.FileObject sibling, final String baseName) throws IOException {
325.119 - return sibling == null ? getActiveRootImpl(baseName) : getActiveRootImpl(sibling);
325.120 + return sibling == null ? getActiveRootImpl(baseName) : getActiveRootImpl(sibling.toUri().toURL());
325.121 }
325.122 -
325.123 - private int getActiveRootImpl (final javax.tools.FileObject file) throws IOException {
325.124 +
325.125 + private int getActiveRootImpl (final URL sibling) throws IOException {
325.126 List<ClassPath.Entry> entries = this.scp.entries();
325.127 int eSize = entries.size();
325.128 if ( eSize == 1) {
325.129 return 0;
325.130 - }
325.131 + }
325.132 if (eSize == 0) {
325.133 return -1;
325.134 }
325.135 @@ -223,20 +225,18 @@
325.136 try {
325.137 for (int i = 0; it.hasNext(); i++) {
325.138 URL rootUrl = it.next().getURL();
325.139 - if (FileObjects.isParentOf(rootUrl, file.toUri().toURL())) {
325.140 + if (FileObjects.isParentOf(rootUrl, sibling)) {
325.141 return i;
325.142 }
325.143 }
325.144 } catch (IllegalArgumentException e) {
325.145 //Logging for issue #151416
325.146 - String message = String.format("file: %s class: %s uri: %s", file.toString(), file.getClass().toString(), file.toUri().toString());
325.147 + String message = String.format("uri: %s", sibling.toString());
325.148 throw Exceptions.attachMessage(e, message);
325.149 }
325.150 return -2;
325.151 }
325.152 -
325.153 -
325.154 -
325.155 +
325.156 private int getActiveRootImpl (String baseName) {
325.157 List<ClassPath.Entry> entries = this.scp.entries();
325.158 int eSize = entries.size();
325.159 @@ -248,7 +248,7 @@
325.160 }
325.161 final String[] parentName = splitParentName(baseName);
325.162 Iterator<ClassPath.Entry> it = entries.iterator();
325.163 - for (int i=0; it.hasNext(); i++) {
325.164 + for (int i=0; it.hasNext(); i++) {
325.165 FileObject root = it.next().getRoot();
325.166 if (root != null) {
325.167 FileObject parentFile = root.getFileObject(parentName[0]);
325.168 @@ -258,7 +258,7 @@
325.169 }
325.170 }
325.171 }
325.172 - }
325.173 + }
325.174 return -2;
325.175 }
325.176
325.177 @@ -327,18 +327,35 @@
325.178 }
325.179 return new String[] {parent, name};
325.180 }
325.181 -
325.182 +
325.183 @Override
325.184 public boolean handleOption(String head, Iterator<String> tail) {
325.185 - if ("output-root".equals(head)) { //NOI18N
325.186 + if (OUTPUT_ROOT.equals(head)) { //NOI18N
325.187 if (!tail.hasNext())
325.188 throw new IllegalArgumentException();
325.189 outputRoot = tail.next();
325.190 if (outputRoot.length() <= 0)
325.191 outputRoot = null;
325.192 return true;
325.193 + } if (ORIGIN_FILE.equals(head)) {
325.194 + if (!tail.hasNext()) {
325.195 + throw new IllegalArgumentException("The apt-origin requires folder."); //NOI18N
325.196 + }
325.197 + final String aptOrigin = tail.next();
325.198 + if (aptOrigin.length() == 0) {
325.199 + explicitSibling = null;
325.200 + }
325.201 + else {
325.202 + try {
325.203 + explicitSibling = new URL(aptOrigin);
325.204 + } catch (MalformedURLException ex) {
325.205 + throw new IllegalArgumentException("Invalid path argument: " + aptOrigin); //NOI18N
325.206 + }
325.207 + }
325.208 + return false; //Pass the option to all FileManagers
325.209 }
325.210 - return super.handleOption(head, tail);
325.211 + else {
325.212 + return super.handleOption(head, tail);
325.213 + }
325.214 }
325.215 -
325.216 }
326.1 --- a/java.source/src/org/netbeans/modules/java/source/parsing/ProxyFileManager.java Mon Feb 01 12:23:06 2010 +0100
326.2 +++ b/java.source/src/org/netbeans/modules/java/source/parsing/ProxyFileManager.java Mon Feb 01 12:24:26 2010 +0100
326.3 @@ -43,6 +43,7 @@
326.4
326.5 import java.io.IOException;
326.6 import java.util.ArrayList;
326.7 +import java.util.Collections;
326.8 import java.util.Iterator;
326.9 import java.util.LinkedList;
326.10 import java.util.List;
326.11 @@ -62,11 +63,22 @@
326.12 public class ProxyFileManager implements JavaFileManager {
326.13
326.14 private static final Location ALL = new Location () {
326.15 - public String getName() { return "ALL";} //NOI18N
326.16 + public String getName() { return "ALL";} //NOI18N
326.17
326.18 public boolean isOutputLocation() { return false; }
326.19 };
326.20 -
326.21 +
326.22 + /**
326.23 + * Workaround to allow Filer ask for getFileForOutput for StandardLocation.SOURCE_PATH
326.24 + * which is not allowed but Filer does not allow write anyway => safe to do it.
326.25 + */
326.26 + private static final Location SOURCE_PATH_WRITE = new Location () {
326.27 + @Override
326.28 + public String getName() { return "SOURCE_PATH_WRITE"; } //NOI18N
326.29 + @Override
326.30 + public boolean isOutputLocation() { return false;}
326.31 + };
326.32 +
326.33 private final JavaFileManager bootPath;
326.34 private final JavaFileManager classPath;
326.35 private final JavaFileManager sourcePath;
326.36 @@ -137,6 +149,9 @@
326.37 else if (location == StandardLocation.SOURCE_OUTPUT && this.aptSources != null) {
326.38 return new JavaFileManager[] {this.aptSources};
326.39 }
326.40 + else if (location == SOURCE_PATH_WRITE) {
326.41 + return new JavaFileManager[] {this.sourcePath};
326.42 + }
326.43 else if (location == ALL) {
326.44 return getAllFileManagers();
326.45 }
326.46 @@ -193,7 +208,9 @@
326.47
326.48 public FileObject getFileForOutput(Location l, String packageName, String relativeName, FileObject sibling)
326.49 throws IOException, UnsupportedOperationException, IllegalArgumentException {
326.50 - JavaFileManager[] fms = getFileManager (l);
326.51 + JavaFileManager[] fms = getFileManager(
326.52 + l == StandardLocation.SOURCE_PATH ?
326.53 + SOURCE_PATH_WRITE : l);
326.54 assert fms.length <=1;
326.55 if (fms.length == 0) {
326.56 return null;
326.57 @@ -226,15 +243,27 @@
326.58 }
326.59
326.60 public boolean handleOption (String current, Iterator<String> remains) {
326.61 + final Iterable<String> defensiveCopy = copy(remains);
326.62 for (JavaFileManager m : getFileManager(ALL)) {
326.63 - if (m.handleOption(current, remains)) {
326.64 + if (m.handleOption(current, defensiveCopy.iterator())) {
326.65 return true;
326.66 }
326.67 }
326.68 -
326.69 return false;
326.70 }
326.71
326.72 + private static Iterable<String> copy(final Iterator<String> from) {
326.73 + if (!from.hasNext()) {
326.74 + return Collections.<String>emptyList();
326.75 + } else {
326.76 + final LinkedList<String> result = new LinkedList<String>();
326.77 + while (from.hasNext()) {
326.78 + result.add(from.next());
326.79 + }
326.80 + return result;
326.81 + }
326.82 + }
326.83 +
326.84 public boolean hasLocation(JavaFileManager.Location location) {
326.85 return location == StandardLocation.CLASS_PATH ||
326.86 location == StandardLocation.PLATFORM_CLASS_PATH ||
327.1 --- a/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileManager.java Mon Feb 01 12:23:06 2010 +0100
327.2 +++ b/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileManager.java Mon Feb 01 12:24:26 2010 +0100
327.3 @@ -41,6 +41,7 @@
327.4
327.5 package org.netbeans.modules.java.source.parsing;
327.6
327.7 +import java.io.File;
327.8 import java.io.IOException;
327.9 import java.net.MalformedURLException;
327.10 import java.util.ArrayList;
327.11 @@ -53,6 +54,7 @@
327.12 import javax.tools.JavaFileManager;
327.13 import javax.tools.JavaFileManager.Location;
327.14 import javax.tools.JavaFileObject;
327.15 +import javax.tools.StandardLocation;
327.16 import org.netbeans.api.java.classpath.ClassPath;
327.17 import org.openide.filesystems.FileObject;
327.18 import org.openide.filesystems.FileUtil;
327.19 @@ -118,21 +120,11 @@
327.20 }
327.21
327.22 public javax.tools.FileObject getFileForInput (final Location l, final String pkgName, final String relativeName) {
327.23 - String rp = FileObjects.getRelativePath (pkgName, relativeName);
327.24 - for (ClassPath.Entry entry : this.sourceRoots.entries()) {
327.25 - if (ignoreExcludes || entry.includes(rp)) {
327.26 - FileObject root = entry.getRoot();
327.27 - if (root != null) {
327.28 - FileObject file = root.getFileObject(rp);
327.29 - if (file != null) {
327.30 - return SourceFileObject.create (file, root);
327.31 - }
327.32 - }
327.33 - }
327.34 - }
327.35 - return null;
327.36 + final String rp = FileObjects.getRelativePath (pkgName, relativeName);
327.37 + final FileObject[] fileRootPair = findFile(rp);
327.38 + return fileRootPair == null ? null : SourceFileObject.create (fileRootPair[0], fileRootPair[1]);
327.39 }
327.40 -
327.41 +
327.42 public JavaFileObject getJavaFileForInput (Location l, final String className, JavaFileObject.Kind kind) {
327.43 String[] namePair = FileObjects.getParentRelativePathAndName (className);
327.44 if (namePair == null) {
327.45 @@ -156,9 +148,27 @@
327.46 return null;
327.47 }
327.48
327.49 - public javax.tools.FileObject getFileForOutput(Location l, String pkgName, String relativeName, javax.tools.FileObject sibling)
327.50 + public javax.tools.FileObject getFileForOutput(final Location l, final String pkgName, final String relativeName, final javax.tools.FileObject sibling)
327.51 throws IOException, UnsupportedOperationException, IllegalArgumentException {
327.52 - throw new UnsupportedOperationException ("The SourceFileManager does not support write operations."); // NOI18N
327.53 + if (StandardLocation.SOURCE_PATH != l) {
327.54 + throw new UnsupportedOperationException("Only StandardLocation.SOURCE_PATH is supported."); // NOI18N
327.55 + }
327.56 + final String rp = FileObjects.getRelativePath (pkgName, relativeName);
327.57 + final FileObject[] fileRootPair = findFile(rp);
327.58 + if (fileRootPair == null) {
327.59 + final FileObject[] roots = this.sourceRoots.getRoots();
327.60 + if (roots.length == 0) {
327.61 + return null;
327.62 + }
327.63 + final File rootFile = FileUtil.toFile(roots[0]);
327.64 + if (rootFile == null) {
327.65 + return null;
327.66 + }
327.67 + return FileObjects.nbFileObject(new File(rootFile,FileObjects.convertFolder2Package(rp, File.separatorChar)).toURI().toURL(), roots[0]); //Todo: wrap to protect from write
327.68 + }
327.69 + else {
327.70 + return SourceFileObject.create (fileRootPair[0], fileRootPair[1]); //Todo: wrap to protect from write
327.71 + }
327.72 }
327.73
327.74 public JavaFileObject getJavaFileForOutput (Location l, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling)
327.75 @@ -229,4 +239,19 @@
327.76 ((SourceFileObject)fileObject).handle.file != null &&
327.77 ((SourceFileObject)fileObject).handle.file == ((SourceFileObject)fileObject0).handle.file;
327.78 }
327.79 +
327.80 + private FileObject[] findFile (final String relativePath) {
327.81 + for (ClassPath.Entry entry : this.sourceRoots.entries()) {
327.82 + if (ignoreExcludes || entry.includes(relativePath)) {
327.83 + FileObject root = entry.getRoot();
327.84 + if (root != null) {
327.85 + FileObject file = root.getFileObject(relativePath);
327.86 + if (file != null) {
327.87 + return new FileObject[] {file, root};
327.88 + }
327.89 + }
327.90 + }
327.91 + }
327.92 + return null;
327.93 + }
327.94 }
328.1 --- a/javascript.editing/manifest.mf Mon Feb 01 12:23:06 2010 +0100
328.2 +++ b/javascript.editing/manifest.mf Mon Feb 01 12:24:26 2010 +0100
328.3 @@ -3,6 +3,6 @@
328.4 OpenIDE-Module-Install: org/netbeans/modules/javascript/editing/Installer.class
328.5 OpenIDE-Module-Layer: org/netbeans/modules/javascript/editing/layer.xml
328.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javascript/editing/Bundle.properties
328.7 -OpenIDE-Module-Specification-Version: 0.93
328.8 +OpenIDE-Module-Specification-Version: 0.94
328.9 AutoUpdate-Show-In-Client: false
328.10
329.1 --- a/javascript.editing/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
329.2 +++ b/javascript.editing/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
329.3 @@ -55,8 +55,8 @@
329.4 <build-prerequisite/>
329.5 <compile-dependency/>
329.6 <run-dependency>
329.7 - <release-version>1</release-version>
329.8 - <specification-version>1.19</specification-version>
329.9 + <release-version>2</release-version>
329.10 + <specification-version>2.1</specification-version>
329.11 </run-dependency>
329.12 </dependency>
329.13 <dependency>
330.1 --- a/javascript.editing/src/org/netbeans/modules/javascript/editing/JsLanguage.java Mon Feb 01 12:23:06 2010 +0100
330.2 +++ b/javascript.editing/src/org/netbeans/modules/javascript/editing/JsLanguage.java Mon Feb 01 12:24:26 2010 +0100
330.3 @@ -60,6 +60,7 @@
330.4 import org.netbeans.modules.javascript.editing.lexer.JsTokenId;
330.5 import org.netbeans.modules.parsing.spi.Parser;
330.6 import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
330.7 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
330.8
330.9
330.10 /*
330.11 @@ -68,6 +69,7 @@
330.12 * @author Tor Norbye
330.13 */
330.14 @LanguageRegistration(mimeType="text/javascript") //NOI18N
330.15 +@PathRecognizerRegistration(mimeTypes="text/javascript", libraryPathIds=JsClassPathProvider.BOOT_CP, binaryLibraryPathIds={})
330.16 public class JsLanguage extends DefaultLanguageConfig {
330.17
330.18 private static boolean jsClassPathRegistered = false;
331.1 --- a/javascript.editing/src/org/netbeans/modules/javascript/editing/JsonLanguage.java Mon Feb 01 12:23:06 2010 +0100
331.2 +++ b/javascript.editing/src/org/netbeans/modules/javascript/editing/JsonLanguage.java Mon Feb 01 12:24:26 2010 +0100
331.3 @@ -53,6 +53,7 @@
331.4 import org.netbeans.modules.csl.spi.LanguageRegistration;
331.5 import org.netbeans.modules.javascript.editing.lexer.JsTokenId;
331.6 import org.netbeans.modules.parsing.spi.Parser;
331.7 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
331.8
331.9 /**
331.10 * Configuration for JSON
331.11 @@ -60,6 +61,7 @@
331.12 * @author Tor Norbye
331.13 */
331.14 @LanguageRegistration(mimeType="text/x-json") //NOI18N
331.15 +@PathRecognizerRegistration(mimeTypes="text/x-json", libraryPathIds=JsClassPathProvider.BOOT_CP, binaryLibraryPathIds={})
331.16 public class JsonLanguage extends DefaultLanguageConfig {
331.17
331.18 public JsonLanguage() {
332.1 --- a/javascript.hints/manifest.mf Mon Feb 01 12:23:06 2010 +0100
332.2 +++ b/javascript.hints/manifest.mf Mon Feb 01 12:24:26 2010 +0100
332.3 @@ -1,6 +1,6 @@
332.4 Manifest-Version: 1.0
332.5 OpenIDE-Module: org.netbeans.modules.javascript.hints/1
332.6 -OpenIDE-Module-Specification-Version: 0.43
332.7 +OpenIDE-Module-Specification-Version: 0.44
332.8 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javascript/hints/Bundle.properties
332.9 OpenIDE-Module-Layer: org/netbeans/modules/javascript/hints/layer.xml
332.10 AutoUpdate-Show-In-Client: false
333.1 --- a/javascript.hints/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
333.2 +++ b/javascript.hints/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
333.3 @@ -28,8 +28,8 @@
333.4 <build-prerequisite/>
333.5 <compile-dependency/>
333.6 <run-dependency>
333.7 - <release-version>1</release-version>
333.8 - <specification-version>1.0</specification-version>
333.9 + <release-version>2</release-version>
333.10 + <specification-version>2.1</specification-version>
333.11 </run-dependency>
333.12 </dependency>
333.13 <dependency>
333.14 @@ -206,6 +206,10 @@
333.15 <compile-dependency/>
333.16 </test-dependency>
333.17 <test-dependency>
333.18 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
333.19 + <compile-dependency/>
333.20 + </test-dependency>
333.21 + <test-dependency>
333.22 <code-name-base>org.netbeans.modules.csl.api</code-name-base>
333.23 <recursive/>
333.24 <compile-dependency/>
333.25 @@ -233,10 +237,6 @@
333.26 <test/>
333.27 </test-dependency>
333.28 <test-dependency>
333.29 - <code-name-base>org.netbeans.modules.lexer.nbbridge</code-name-base>
333.30 - <compile-dependency/>
333.31 - </test-dependency>
333.32 - <test-dependency>
333.33 <code-name-base>org.netbeans.modules.editor.settings.storage</code-name-base>
333.34 </test-dependency>
333.35 <test-dependency>
333.36 @@ -273,10 +273,19 @@
333.37 <test/>
333.38 </test-dependency>
333.39 <test-dependency>
333.40 + <code-name-base>org.netbeans.modules.lexer.nbbridge</code-name-base>
333.41 + <compile-dependency/>
333.42 + </test-dependency>
333.43 + <test-dependency>
333.44 <code-name-base>org.netbeans.modules.masterfs</code-name-base>
333.45 <recursive/>
333.46 </test-dependency>
333.47 <test-dependency>
333.48 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
333.49 + <recursive/>
333.50 + <compile-dependency/>
333.51 + </test-dependency>
333.52 + <test-dependency>
333.53 <code-name-base>org.netbeans.modules.progress.ui</code-name-base>
333.54 <recursive/>
333.55 </test-dependency>
334.1 --- a/javascript.hints/test/unit/src/org/netbeans/modules/javascript/hints/HintTestBase.java Mon Feb 01 12:23:06 2010 +0100
334.2 +++ b/javascript.hints/test/unit/src/org/netbeans/modules/javascript/hints/HintTestBase.java Mon Feb 01 12:24:26 2010 +0100
334.3 @@ -27,17 +27,8 @@
334.4 */
334.5 package org.netbeans.modules.javascript.hints;
334.6
334.7 -import java.util.List;
334.8 -import java.util.Map;
334.9 -import java.util.Set;
334.10 -import org.netbeans.modules.csl.core.Language;
334.11 -import org.netbeans.modules.csl.core.LanguageRegistry;
334.12 import org.netbeans.modules.csl.api.HintsProvider;
334.13 -import org.netbeans.modules.csl.hints.infrastructure.GsfHintsManager;
334.14 import org.netbeans.modules.javascript.editing.JsTestBase;
334.15 -import org.netbeans.modules.javascript.editing.lexer.JsTokenId;
334.16 -import org.netbeans.modules.javascript.hints.infrastructure.JsAstRule;
334.17 -import org.netbeans.modules.javascript.hints.infrastructure.JsErrorRule;
334.18 import org.netbeans.modules.javascript.hints.infrastructure.JsHintsProvider;
334.19
334.20 /**
334.21 @@ -56,47 +47,4 @@
334.22 return new JsHintsProvider();
334.23 }
334.24
334.25 - @SuppressWarnings("unchecked")
334.26 - public void ensureRegistered(JsAstRule hint) throws Exception {
334.27 - Language language = LanguageRegistry.getInstance().getLanguageByMimeType(JsTokenId.JAVASCRIPT_MIME_TYPE);
334.28 - assertNotNull(language.getHintsProvider());
334.29 - GsfHintsManager hintsManager = language.getHintsManager();
334.30 - Map<Integer, List<JsAstRule>> hints = (Map)hintsManager.getHints();
334.31 - Set<Integer> kinds = hint.getKinds();
334.32 - for (Integer nodeType : kinds) {
334.33 - List<JsAstRule> rules = hints.get(nodeType);
334.34 - assertNotNull(rules);
334.35 - boolean found = false;
334.36 - for (JsAstRule rule : rules) {
334.37 - if (rule.getClass() == hint.getClass()) {
334.38 - found = true;
334.39 - break;
334.40 - }
334.41 - }
334.42 -
334.43 - assertTrue(found);
334.44 - }
334.45 - }
334.46 -
334.47 - @SuppressWarnings("unchecked")
334.48 - public void ensureRegistered(JsErrorRule hint) throws Exception {
334.49 - Language language = LanguageRegistry.getInstance().getLanguageByMimeType(JsTokenId.JAVASCRIPT_MIME_TYPE);
334.50 - assertNotNull(language.getHintsProvider());
334.51 - GsfHintsManager hintsManager = language.getHintsManager();
334.52 - Map<Integer, List<JsErrorRule>> hints = (Map)hintsManager.getErrors();
334.53 - Set<String> kinds = hint.getCodes();
334.54 - for (String codes : kinds) {
334.55 - List<JsErrorRule> rules = hints.get(codes);
334.56 - assertNotNull(rules);
334.57 - boolean found = false;
334.58 - for (JsErrorRule rule : rules) {
334.59 - if (rule.getClass() == hint.getClass()) {
334.60 - found = true;
334.61 - break;
334.62 - }
334.63 - }
334.64 -
334.65 - assertTrue(found);
334.66 - }
334.67 - }
334.68 }
335.1 --- a/javascript.kit/manifest.mf Mon Feb 01 12:23:06 2010 +0100
335.2 +++ b/javascript.kit/manifest.mf Mon Feb 01 12:24:26 2010 +0100
335.3 @@ -1,6 +1,6 @@
335.4 Manifest-Version: 1.0
335.5 OpenIDE-Module: org.netbeans.modules.javascript.kit/1
335.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javascript/kit/Bundle.properties
335.7 -OpenIDE-Module-Specification-Version: 0.109
335.8 +OpenIDE-Module-Specification-Version: 0.110
335.9 AutoUpdate-Show-In-Client: false
335.10
336.1 --- a/javascript.kit/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
336.2 +++ b/javascript.kit/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
336.3 @@ -19,8 +19,8 @@
336.4 <build-prerequisite/>
336.5 <compile-dependency/>
336.6 <run-dependency>
336.7 - <release-version>1</release-version>
336.8 - <specification-version>1.8</specification-version>
336.9 + <release-version>2</release-version>
336.10 + <specification-version>2.1</specification-version>
336.11 </run-dependency>
336.12 </dependency>
336.13 <dependency>
337.1 --- a/javascript.refactoring/manifest.mf Mon Feb 01 12:23:06 2010 +0100
337.2 +++ b/javascript.refactoring/manifest.mf Mon Feb 01 12:24:26 2010 +0100
337.3 @@ -3,4 +3,4 @@
337.4 OpenIDE-Module-Layer: org/netbeans/modules/refactoring/javascript/resources/mf-layer.xml
337.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/refactoring/javascript/resources/Bundle.properties
337.6 AutoUpdate-Show-In-Client: false
337.7 -OpenIDE-Module-Specification-Version: 0.68
337.8 +OpenIDE-Module-Specification-Version: 0.69
338.1 --- a/javascript.refactoring/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
338.2 +++ b/javascript.refactoring/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
338.3 @@ -37,8 +37,8 @@
338.4 <build-prerequisite/>
338.5 <compile-dependency/>
338.6 <run-dependency>
338.7 - <release-version>1</release-version>
338.8 - <specification-version>1.0</specification-version>
338.9 + <release-version>2</release-version>
338.10 + <specification-version>2.1</specification-version>
338.11 </run-dependency>
338.12 </dependency>
338.13 <dependency>
339.1 --- a/javascript.refactoring/src/org/netbeans/modules/refactoring/javascript/WhereUsedElement.java Mon Feb 01 12:23:06 2010 +0100
339.2 +++ b/javascript.refactoring/src/org/netbeans/modules/refactoring/javascript/WhereUsedElement.java Mon Feb 01 12:24:26 2010 +0100
339.3 @@ -50,7 +50,7 @@
339.4 import org.netbeans.modules.csl.api.OffsetRange;
339.5 import org.netbeans.editor.BaseDocument;
339.6 import org.netbeans.editor.Utilities;
339.7 -import org.netbeans.modules.csl.core.UiUtils;
339.8 +import org.netbeans.modules.csl.api.UiUtils;
339.9 import org.netbeans.modules.csl.spi.GsfUtilities;
339.10 import org.netbeans.modules.refactoring.javascript.ui.tree.ElementGripFactory;
339.11 import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImplementation;
340.1 --- a/javascript.refactoring/src/org/netbeans/modules/refactoring/javascript/plugins/JsWhereUsedQueryPlugin.java Mon Feb 01 12:23:06 2010 +0100
340.2 +++ b/javascript.refactoring/src/org/netbeans/modules/refactoring/javascript/plugins/JsWhereUsedQueryPlugin.java Mon Feb 01 12:24:26 2010 +0100
340.3 @@ -59,7 +59,7 @@
340.4 import org.netbeans.api.lexer.TokenSequence;
340.5 import org.netbeans.api.lexer.TokenUtilities;
340.6 import org.netbeans.editor.BaseDocument;
340.7 -import org.netbeans.modules.csl.core.UiUtils;
340.8 +import org.netbeans.modules.csl.api.UiUtils;
340.9 import org.netbeans.modules.csl.spi.GsfUtilities;
340.10 import org.netbeans.modules.csl.spi.support.ModificationResult;
340.11 import org.netbeans.modules.javascript.editing.JsParseResult;
341.1 --- a/javascript.refactoring/src/org/netbeans/modules/refactoring/javascript/ui/tree/FolderTreeElement.java Mon Feb 01 12:23:06 2010 +0100
341.2 +++ b/javascript.refactoring/src/org/netbeans/modules/refactoring/javascript/ui/tree/FolderTreeElement.java Mon Feb 01 12:24:26 2010 +0100
341.3 @@ -49,7 +49,7 @@
341.4 import org.netbeans.api.project.ProjectUtils;
341.5 import org.netbeans.api.project.SourceGroup;
341.6 import org.netbeans.api.project.Sources;
341.7 -import org.netbeans.modules.csl.core.UiUtils;
341.8 +import org.netbeans.modules.csl.api.UiUtils;
341.9 import org.netbeans.modules.refactoring.spi.ui.*;
341.10 import org.openide.filesystems.FileObject;
341.11 import org.openide.filesystems.FileUtil;
342.1 --- a/javawebstart/AntTasks/nbproject/build-impl.xml Mon Feb 01 12:23:06 2010 +0100
342.2 +++ b/javawebstart/AntTasks/nbproject/build-impl.xml Mon Feb 01 12:24:26 2010 +0100
342.3 @@ -55,21 +55,52 @@
342.4 </target>
342.5 <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
342.6 <available file="${manifest.file}" property="manifest.available"/>
342.7 - <condition property="manifest.available+main.class">
342.8 + <condition property="main.class.available">
342.9 <and>
342.10 - <isset property="manifest.available"/>
342.11 <isset property="main.class"/>
342.12 <not>
342.13 <equals arg1="${main.class}" arg2="" trim="true"/>
342.14 </not>
342.15 </and>
342.16 </condition>
342.17 + <condition property="manifest.available+main.class">
342.18 + <and>
342.19 + <isset property="manifest.available"/>
342.20 + <isset property="main.class.available"/>
342.21 + </and>
342.22 + </condition>
342.23 + <condition property="do.mkdist">
342.24 + <and>
342.25 + <isset property="libs.CopyLibs.classpath"/>
342.26 + <not>
342.27 + <istrue value="${mkdist.disabled}"/>
342.28 + </not>
342.29 + </and>
342.30 + </condition>
342.31 <condition property="manifest.available+main.class+mkdist.available">
342.32 <and>
342.33 <istrue value="${manifest.available+main.class}"/>
342.34 - <isset property="libs.CopyLibs.classpath"/>
342.35 + <isset property="do.mkdist"/>
342.36 </and>
342.37 </condition>
342.38 + <condition property="manifest.available+mkdist.available">
342.39 + <and>
342.40 + <istrue value="${manifest.available}"/>
342.41 + <isset property="do.mkdist"/>
342.42 + </and>
342.43 + </condition>
342.44 + <condition property="manifest.available-mkdist.available">
342.45 + <or>
342.46 + <istrue value="${manifest.available}"/>
342.47 + <isset property="do.mkdist"/>
342.48 + </or>
342.49 + </condition>
342.50 + <condition property="manifest.available+main.class-mkdist.available">
342.51 + <or>
342.52 + <istrue value="${manifest.available+main.class}"/>
342.53 + <isset property="do.mkdist"/>
342.54 + </or>
342.55 + </condition>
342.56 <condition property="have.tests">
342.57 <or>
342.58 <available file="${test.src.dir}"/>
342.59 @@ -104,6 +135,7 @@
342.60 <property name="javadoc.preview" value="true"/>
342.61 <property name="application.args" value=""/>
342.62 <property name="source.encoding" value="${file.encoding}"/>
342.63 + <property name="runtime.encoding" value="${source.encoding}"/>
342.64 <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
342.65 <and>
342.66 <isset property="javadoc.encoding"/>
342.67 @@ -119,12 +151,11 @@
342.68 <condition property="do.depend.true">
342.69 <istrue value="${do.depend}"/>
342.70 </condition>
342.71 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
342.72 - <and>
342.73 - <isset property="jaxws.endorsed.dir"/>
342.74 - <available file="nbproject/jaxws-build.xml"/>
342.75 - </and>
342.76 + <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
342.77 + <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
342.78 + <length length="0" string="${endorsed.classpath}" when="greater"/>
342.79 </condition>
342.80 + <property name="javac.fork" value="false"/>
342.81 </target>
342.82 <target name="-post-init">
342.83 <!-- Empty placeholder for easier customization. -->
342.84 @@ -165,7 +196,7 @@
342.85 <sequential>
342.86 <property location="${build.dir}/empty" name="empty.dir"/>
342.87 <mkdir dir="${empty.dir}"/>
342.88 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
342.89 + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
342.90 <src>
342.91 <dirset dir="@{gensrcdir}" erroronmissingdir="false">
342.92 <include name="*"/>
342.93 @@ -174,7 +205,8 @@
342.94 <classpath>
342.95 <path path="@{classpath}"/>
342.96 </classpath>
342.97 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
342.98 + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
342.99 + <compilerarg line="${javac.compilerargs}"/>
342.100 <customize/>
342.101 </javac>
342.102 </sequential>
342.103 @@ -213,7 +245,7 @@
342.104 <attribute default="${excludes}" name="excludes"/>
342.105 <attribute default="**" name="testincludes"/>
342.106 <sequential>
342.107 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
342.108 + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
342.109 <batchtest todir="${build.test.results.dir}">
342.110 <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
342.111 <filename name="@{testincludes}"/>
342.112 @@ -228,6 +260,7 @@
342.113 </syspropertyset>
342.114 <formatter type="brief" usefile="false"/>
342.115 <formatter type="xml"/>
342.116 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
342.117 <jvmarg line="${run.jvmargs}"/>
342.118 </junit>
342.119 </sequential>
342.120 @@ -284,10 +317,11 @@
342.121 <element name="customize" optional="true"/>
342.122 <sequential>
342.123 <java classname="@{classname}" dir="${work.dir}" fork="true">
342.124 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
342.125 <jvmarg line="${debug-args-line}"/>
342.126 <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
342.127 - <jvmarg value="-Dfile.encoding=${source.encoding}"/>
342.128 - <redirector errorencoding="${source.encoding}" inputencoding="${source.encoding}" outputencoding="${source.encoding}"/>
342.129 + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
342.130 + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
342.131 <jvmarg line="${run.jvmargs}"/>
342.132 <classpath>
342.133 <path path="@{classpath}"/>
342.134 @@ -308,8 +342,9 @@
342.135 <element name="customize" optional="true"/>
342.136 <sequential>
342.137 <java classname="@{classname}" dir="${work.dir}" fork="true">
342.138 - <jvmarg value="-Dfile.encoding=${source.encoding}"/>
342.139 - <redirector errorencoding="${source.encoding}" inputencoding="${source.encoding}" outputencoding="${source.encoding}"/>
342.140 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
342.141 + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
342.142 + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
342.143 <jvmarg line="${run.jvmargs}"/>
342.144 <classpath>
342.145 <path path="@{classpath}"/>
342.146 @@ -336,7 +371,22 @@
342.147 COMPILATION SECTION
342.148 ===================
342.149 -->
342.150 - <target depends="init" name="deps-jar" unless="no.deps"/>
342.151 + <target name="-deps-jar-init" unless="built-jar.properties">
342.152 + <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
342.153 + <delete file="${built-jar.properties}" quiet="true"/>
342.154 + </target>
342.155 + <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
342.156 + <echo level="warn" message="Cycle detected: AntTasks was already built"/>
342.157 + </target>
342.158 + <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
342.159 + <mkdir dir="${build.dir}"/>
342.160 + <touch file="${built-jar.properties}" verbose="false"/>
342.161 + <property file="${built-jar.properties}" prefix="already.built.jar."/>
342.162 + <antcall target="-warn-already-built-jar"/>
342.163 + <propertyfile file="${built-jar.properties}">
342.164 + <entry key="${basedir}" value=""/>
342.165 + </propertyfile>
342.166 + </target>
342.167 <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
342.168 <target depends="init" name="-check-automatic-build">
342.169 <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
342.170 @@ -397,10 +447,10 @@
342.171 <!-- Empty placeholder for easier customization. -->
342.172 <!-- You can override this target in the ../build.xml file. -->
342.173 </target>
342.174 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
342.175 + <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
342.176 <j2seproject1:jar/>
342.177 </target>
342.178 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
342.179 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
342.180 <j2seproject1:jar manifest="${manifest.file}"/>
342.181 </target>
342.182 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
342.183 @@ -443,7 +493,28 @@
342.184 <property location="${dist.jar}" name="dist.jar.resolved"/>
342.185 <echo>java -jar "${dist.jar.resolved}"</echo>
342.186 </target>
342.187 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="libs.CopyLibs.classpath" name="-do-jar-with-libraries-without-manifest" unless="manifest.available+main.class">
342.188 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">
342.189 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
342.190 + <pathconvert property="run.classpath.without.build.classes.dir">
342.191 + <path path="${run.classpath}"/>
342.192 + <map from="${build.classes.dir.resolved}" to=""/>
342.193 + </pathconvert>
342.194 + <pathconvert pathsep=" " property="jar.classpath">
342.195 + <path path="${run.classpath.without.build.classes.dir}"/>
342.196 + <chainedmapper>
342.197 + <flattenmapper/>
342.198 + <globmapper from="*" to="lib/*"/>
342.199 + </chainedmapper>
342.200 + </pathconvert>
342.201 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
342.202 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
342.203 + <fileset dir="${build.classes.dir}"/>
342.204 + <manifest>
342.205 + <attribute name="Class-Path" value="${jar.classpath}"/>
342.206 + </manifest>
342.207 + </copylibs>
342.208 + </target>
342.209 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.mkdist" name="-do-jar-with-libraries-without-manifest" unless="manifest.available">
342.210 <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
342.211 <pathconvert property="run.classpath.without.build.classes.dir">
342.212 <path path="${run.classpath}"/>
342.213 @@ -459,13 +530,16 @@
342.214 <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
342.215 <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
342.216 <fileset dir="${build.classes.dir}"/>
342.217 + <manifest>
342.218 + <attribute name="Class-Path" value="${jar.classpath}"/>
342.219 + </manifest>
342.220 </copylibs>
342.221 </target>
342.222 <target name="-post-jar">
342.223 <!-- Empty placeholder for easier customization. -->
342.224 <!-- You can override this target in the ../build.xml file. -->
342.225 </target>
342.226 - <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
342.227 + <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-do-jar-with-libraries-without-mainclass,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
342.228 <!--
342.229 =================
342.230 EXECUTION SECTION
342.231 @@ -481,11 +555,11 @@
342.232 <target name="-do-not-recompile">
342.233 <property name="javac.includes.binary" value=""/>
342.234 </target>
342.235 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
342.236 + <target depends="init,compile-single" name="run-single">
342.237 <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
342.238 <j2seproject1:java classname="${run.class}"/>
342.239 </target>
342.240 - <target depends="init,-do-not-recompile,compile-test-single" name="run-test-with-main">
342.241 + <target depends="init,compile-test-single" name="run-test-with-main">
342.242 <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
342.243 <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
342.244 </target>
342.245 @@ -516,12 +590,12 @@
342.246 <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
342.247 <j2seproject3:debug classname="${debug.class}"/>
342.248 </target>
342.249 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
342.250 + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
342.251 <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
342.252 <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
342.253 <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
342.254 </target>
342.255 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
342.256 + <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
342.257 <target depends="init" name="-pre-debug-fix">
342.258 <fail unless="fix.includes">Must set fix.includes</fail>
342.259 <property name="javac.includes" value="${fix.includes}.java"/>
342.260 @@ -623,7 +697,7 @@
342.261 <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
342.262 <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
342.263 </target>
342.264 - <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
342.265 + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
342.266 <!--
342.267 =======================
342.268 JUNIT DEBUGGING SECTION
342.269 @@ -650,7 +724,7 @@
342.270 <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
342.271 <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
342.272 </target>
342.273 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
342.274 + <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
342.275 <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
342.276 <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
342.277 </target>
342.278 @@ -687,14 +761,45 @@
342.279 CLEANUP SECTION
342.280 ===============
342.281 -->
342.282 - <target depends="init" name="deps-clean" unless="no.deps"/>
342.283 + <target name="-deps-clean-init" unless="built-clean.properties">
342.284 + <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
342.285 + <delete file="${built-clean.properties}" quiet="true"/>
342.286 + </target>
342.287 + <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
342.288 + <echo level="warn" message="Cycle detected: AntTasks was already built"/>
342.289 + </target>
342.290 + <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
342.291 + <mkdir dir="${build.dir}"/>
342.292 + <touch file="${built-clean.properties}" verbose="false"/>
342.293 + <property file="${built-clean.properties}" prefix="already.built.clean."/>
342.294 + <antcall target="-warn-already-built-clean"/>
342.295 + <propertyfile file="${built-clean.properties}">
342.296 + <entry key="${basedir}" value=""/>
342.297 + </propertyfile>
342.298 + </target>
342.299 <target depends="init" name="-do-clean">
342.300 <delete dir="${build.dir}"/>
342.301 - <delete dir="${dist.dir}"/>
342.302 + <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
342.303 </target>
342.304 <target name="-post-clean">
342.305 <!-- Empty placeholder for easier customization. -->
342.306 <!-- You can override this target in the ../build.xml file. -->
342.307 </target>
342.308 <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
342.309 + <target name="-check-call-dep">
342.310 + <property file="${call.built.properties}" prefix="already.built."/>
342.311 + <condition property="should.call.dep">
342.312 + <not>
342.313 + <isset property="already.built.${call.subproject}"/>
342.314 + </not>
342.315 + </condition>
342.316 + </target>
342.317 + <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
342.318 + <ant antfile="${call.script}" inheritall="false" target="${call.target}">
342.319 + <propertyset>
342.320 + <propertyref prefix="transfer."/>
342.321 + <mapper from="transfer.*" to="*" type="glob"/>
342.322 + </propertyset>
342.323 + </ant>
342.324 + </target>
342.325 </project>
343.1 --- a/javawebstart/AntTasks/nbproject/genfiles.properties Mon Feb 01 12:23:06 2010 +0100
343.2 +++ b/javawebstart/AntTasks/nbproject/genfiles.properties Mon Feb 01 12:24:26 2010 +0100
343.3 @@ -4,5 +4,5 @@
343.4 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
343.5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
343.6 nbproject/build-impl.xml.data.CRC32=59bdc239
343.7 -nbproject/build-impl.xml.script.CRC32=5936736c
343.8 -nbproject/build-impl.xml.stylesheet.CRC32=5c621a33@1.26.1.45
343.9 +nbproject/build-impl.xml.script.CRC32=59be7b2e
343.10 +nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45
344.1 --- a/javawebstart/AntTasks/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
344.2 +++ b/javawebstart/AntTasks/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
344.3 @@ -45,6 +45,7 @@
344.4 javadoc.use=true
344.5 javadoc.version=false
344.6 javadoc.windowtitle=
344.7 +jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
344.8 main.class=
344.9 manifest.file=manifest.mf
344.10 meta.inf.dir=${src.dir}/META-INF
345.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
345.2 +++ b/javawebstart/AntTasks/src/org/netbeans/modules/javawebstart/anttasks/CopyTemplatePageTask.java Mon Feb 01 12:24:26 2010 +0100
345.3 @@ -0,0 +1,196 @@
345.4 +/*
345.5 + * To change this template, choose Tools | Templates
345.6 + * and open the template in the editor.
345.7 + */
345.8 +
345.9 +package org.netbeans.modules.javawebstart.anttasks;
345.10 +
345.11 +import java.io.BufferedReader;
345.12 +import java.io.File;
345.13 +import java.io.FileReader;
345.14 +import java.io.FileWriter;
345.15 +import java.io.IOException;
345.16 +import java.io.PrintWriter;
345.17 +import java.util.HashMap;
345.18 +import java.util.Hashtable;
345.19 +import java.util.Map;
345.20 +import java.util.concurrent.Callable;
345.21 +import java.util.regex.Matcher;
345.22 +import java.util.regex.Pattern;
345.23 +import org.apache.tools.ant.BuildException;
345.24 +import org.apache.tools.ant.Project;
345.25 +import org.apache.tools.ant.Task;
345.26 +
345.27 +/**
345.28 + *
345.29 + * @author Tomas Zezula
345.30 + */
345.31 +public class CopyTemplatePageTask extends Task {
345.32 +
345.33 + private static final String JNLP_FILE = "${JNLP.FILE}"; //NOI18N
345.34 + private static final String JNLP_APPLET_WIDTH = "${JNLP.APPLET.WIDTH}"; //NOI18N
345.35 + private static final String JNLP_APPLET_HEIGHT = "${JNLP.APPLET.HEIGHT}"; //NOI18N
345.36 + private static final String JNLP_RESOURCES_MAIN_JAR="${JNLP.RESOURCES.MAIN.JAR}"; //NOI18N
345.37 + private static final String JNLP_APPLET_CLASS="${JNLP.APPLET.CLASS}"; //NOI18N
345.38 + private static final String JNLP_VM_VERSION="${JNLP_VM_VERSION}"; //NOI18N
345.39 + private static final String JNLP_APPLET_PARAMS = "${JNLP.APPLET.PARAMS}"; //NOI18N
345.40 +
345.41 + //todo: Use ANTLR SringTemplateGroup
345.42 + private final Map<String,Callable<String>> toReplace = new HashMap<String, Callable<String>>() {
345.43 + {
345.44 + put (JNLP_FILE, new BaseNamePropertyValue("jnlp.file", "launch.jnlp")); //NOI18N
345.45 + put (JNLP_APPLET_WIDTH, new PropertyValue("jnlp.applet.width","300"));//NOI18N
345.46 + put (JNLP_APPLET_HEIGHT, new PropertyValue("jnlp.applet.height","300"));//NOI18N
345.47 + put (JNLP_RESOURCES_MAIN_JAR, new BaseNamePropertyValue("dist.jar", "")); //NOI18N
345.48 + put (JNLP_APPLET_CLASS, new PropertyValue("jnlp.applet.class", ""));//NOI18N
345.49 + put (JNLP_VM_VERSION, new PropertyValue("javac.target", "1.6")); //NOI18N
345.50 + put (JNLP_VM_VERSION, new PropertyValue("javac.target", "1.6")); //NOI18N
345.51 + put (JNLP_APPLET_PARAMS, new PropertyMap("jnlp.applet.param","name","value")); //NOI18N
345.52 + }
345.53 + };
345.54 +
345.55 + private File destFile;
345.56 + private File destDir;
345.57 + private File template;
345.58 +
345.59 + public void setDestfile(File file) {
345.60 + this.destFile = file;
345.61 + }
345.62 +
345.63 + public void setDestDir(File dir) {
345.64 + this.destDir = dir;
345.65 + }
345.66 +
345.67 + public void setTemplate(File file) {
345.68 + this.template = file;
345.69 + }
345.70 +
345.71 + @Override
345.72 + public void execute() throws BuildException {
345.73 + checkParameters();
345.74 + try {
345.75 + final BufferedReader in = new BufferedReader(new FileReader(template)); //todo: encoding
345.76 + try {
345.77 + final PrintWriter out = new PrintWriter (new FileWriter(destFile)); //todo: encoding
345.78 + try {
345.79 + copy (in,out);
345.80 + } finally {
345.81 + out.close();
345.82 + }
345.83 + } finally {
345.84 + in.close();
345.85 + }
345.86 + } catch (IOException ioe) {
345.87 + throw new BuildException(ioe, getLocation());
345.88 + }
345.89 + }
345.90 +
345.91 + private void checkParameters() {
345.92 + if (destFile == null) {
345.93 + throw new BuildException("Destination file is not set, template page cannot be copied.");
345.94 + }
345.95 + if (destDir == null) {
345.96 + throw new BuildException("Destination directory is not set, template page cannot be copied.");
345.97 + }
345.98 + if (template == null) {
345.99 + throw new BuildException("Template file is not set, template page cannot be copied.");
345.100 + }
345.101 + }
345.102 +
345.103 + private void copy(final BufferedReader in, final PrintWriter out) throws IOException {
345.104 + String line;
345.105 + while ((line=in.readLine())!=null) {
345.106 + out.println(map(line));
345.107 + }
345.108 + }
345.109 +
345.110 + private String getProperty(String propName, String defaultVal) {
345.111 + String propVal = getProject().getProperty(propName);
345.112 + if (propVal == null) {
345.113 + log("Property " + propName + " is not defined, using default value: " + defaultVal, Project.MSG_VERBOSE);
345.114 + return defaultVal;
345.115 + }
345.116 + return propVal.trim();
345.117 + }
345.118 +
345.119 + private String map(String line) {
345.120 + for (Map.Entry<String,Callable<String>> mapper : toReplace.entrySet()) {
345.121 + try {
345.122 + if (line.contains(mapper.getKey())) {
345.123 + line = line.replaceAll(Pattern.quote(mapper.getKey()), mapper.getValue().call());
345.124 + }
345.125 + } catch (Exception ex) {
345.126 + throw new BuildException(ex, getLocation());
345.127 + }
345.128 + }
345.129 + return line;
345.130 + }
345.131 +
345.132 + private static String stripFilename(String path) {
345.133 + int sepIndex = path.lastIndexOf('/') == -1 ? path.lastIndexOf('\\') : path.lastIndexOf('/');
345.134 + return path.substring(sepIndex + 1);
345.135 + }
345.136 +
345.137 + private class PropertyValue implements Callable<String> {
345.138 + private final String propName;
345.139 + private final String defaultValue;
345.140 +
345.141 + public PropertyValue(final String propName, final String defaultValue) {
345.142 + this.propName = propName;
345.143 + this.defaultValue = defaultValue;
345.144 + }
345.145 +
345.146 + public String call() throws Exception {
345.147 + return getProperty(propName, defaultValue);
345.148 + }
345.149 + }
345.150 +
345.151 + private class BaseNamePropertyValue extends PropertyValue {
345.152 +
345.153 + public BaseNamePropertyValue(final String propName, final String defaultValue) {
345.154 + super(propName, defaultValue);
345.155 + }
345.156 +
345.157 + public String call() throws Exception {
345.158 + return stripFilename(super.call());
345.159 + }
345.160 + }
345.161 +
345.162 + private class PropertyMap implements Callable<String> {
345.163 +
345.164 + private final String prefix;
345.165 + private final String key;
345.166 + private final String value;
345.167 +
345.168 + public PropertyMap(final String prefix, final String key, final String value) {
345.169 + this.prefix = prefix;
345.170 + this.key = key;
345.171 + this.value = value;
345.172 + }
345.173 +
345.174 + public String call() throws Exception {
345.175 + final StringBuilder sb = new StringBuilder();
345.176 + final Pattern p = Pattern.compile(Pattern.quote(prefix) + "\\.(\\d+)\\." + Pattern.quote(key)); //NOI18N
345.177 +
345.178 + final Hashtable<String,String> props = getProject().getProperties();
345.179 + for (Map.Entry<String,String> entry : props.entrySet()) {
345.180 + Matcher m = p.matcher(entry.getKey());
345.181 + if (m.matches()) {
345.182 + final String kv = entry.getValue();
345.183 + final String valueKey = prefix + '.'+ m.group(1) +'.' + value; //NOI18N
345.184 + final String vv = getProperty(valueKey, ""); //NOI18N
345.185 + if (sb.length() > 0) {
345.186 + sb.append(", "); //NOI18N
345.187 + }
345.188 + sb.append(kv);
345.189 + sb.append(':'); //NOI18N
345.190 + sb.append('"');
345.191 + sb.append(vv);
345.192 + sb.append('"');
345.193 + }
345.194 + }
345.195 + return sb.toString();
345.196 + }
345.197 +
345.198 + }
345.199 +}
346.1 --- a/javawebstart/AntTasks/src/org/netbeans/modules/javawebstart/anttasks/GenerateJnlpFileTask.java Mon Feb 01 12:23:06 2010 +0100
346.2 +++ b/javawebstart/AntTasks/src/org/netbeans/modules/javawebstart/anttasks/GenerateJnlpFileTask.java Mon Feb 01 12:24:26 2010 +0100
346.3 @@ -67,6 +67,7 @@
346.4 private static final String DEFAULT_APPLICATION_DESC_SHORT = "${APPLICATION.DESC.SHORT}";
346.5 private static final String DEFAULT_JNLP_ICON = "${JNLP.ICONS}";
346.6 private static final String DEFAULT_JNLP_OFFLINE = "${JNLP.OFFLINE.ALLOWED}";
346.7 + private static final String JNLP_UPDATE = "${JNLP.UPDATE}";
346.8 private static final String DEFAULT_JNLP_SECURITY = "${JNLP.SECURITY}";
346.9 private static final String DEFAULT_JNLP_RESOURCES_RUNTIME = "${JNLP.RESOURCES.RUNTIME}";
346.10 private static final String DEFAULT_JNLP_RESOURCES_MAIN_JAR = "${JNLP.RESOURCES.MAIN.JAR}";
346.11 @@ -203,6 +204,7 @@
346.12 }
346.13
346.14 processInformationElem(docDom);
346.15 + processBackgroundElem(docDom, jnlpElem);
346.16 processSecurityElem(docDom, jnlpElem);
346.17 processResourcesElem(docDom);
346.18 processDescriptorElem(docDom);
346.19 @@ -282,6 +284,7 @@
346.20 informationElem.appendChild(createIconElement(docDom, fileName, "default"));
346.21 }
346.22 } else if (nodeValue.equals(DEFAULT_JNLP_OFFLINE)) {
346.23 + //Has to be here to keep compatibility with NB 6.8
346.24 informationElem.removeChild(node);
346.25 String offlineProp = getProperty("jnlp.offline-allowed", null); // property in project.properties
346.26 if (offlineProp.equalsIgnoreCase("true")) {
346.27 @@ -297,7 +300,28 @@
346.28 }
346.29 }
346.30 }
346.31 -
346.32 +
346.33 + private void processBackgroundElem(final Document docDom, final Node parent) {
346.34 + assert docDom != null;
346.35 + assert parent != null;
346.36 + NodeList childNodes = parent.getChildNodes();
346.37 + int len = childNodes.getLength();
346.38 + for (int i = 0; i < len; i++) {
346.39 + Node node = childNodes.item(i);
346.40 + if (node != null && node.getNodeType() == Node.COMMENT_NODE) { // node might be null (don't know why)
346.41 + if (node.getNodeValue().equals(JNLP_UPDATE)) {
346.42 + String offlineProp = getProperty("jnlp.offline-allowed", null); // property in project.properties
346.43 + final Element updateElm = docDom.createElement("update");
346.44 + final String updateVal = offlineProp.equalsIgnoreCase("true") ? //NOI18N
346.45 + "background" : //NOI18N
346.46 + "always"; //NOI18N
346.47 + updateElm.setAttribute("check", updateVal); //NOI18N
346.48 + parent.replaceChild(updateElm, node);
346.49 + }
346.50 + }
346.51 + }
346.52 + }
346.53 +
346.54 private Element createIconElement(Document doc, String href, String kind) {
346.55 Element iconElem = doc.createElement("icon");
346.56 iconElem.setAttribute("href", href);
347.1 --- a/javawebstart/AntTasks/src/org/netbeans/modules/javawebstart/anttasks/antlib.xml Mon Feb 01 12:23:06 2010 +0100
347.2 +++ b/javawebstart/AntTasks/src/org/netbeans/modules/javawebstart/anttasks/antlib.xml Mon Feb 01 12:24:26 2010 +0100
347.3 @@ -2,4 +2,5 @@
347.4 <antlib>
347.5 <taskdef name="jnlpsignjars" classname="org.netbeans.modules.javawebstart.signtask.SignJarsTask"/>
347.6 <taskdef name="jnlpgenerate" classname="org.netbeans.modules.javawebstart.signtask.GenerateJnlpFileTask"/>
347.7 + <taskdef name="jnlpgenerate" classname="org.netbeans.modules.javawebstart.signtask.CopyTemplatePageTask"/>
347.8 </antlib>
348.1 --- a/javawebstart/src/org/netbeans/modules/javawebstart/resources/jnlp-impl.xml_ Mon Feb 01 12:23:06 2010 +0100
348.2 +++ b/javawebstart/src/org/netbeans/modules/javawebstart/resources/jnlp-impl.xml_ Mon Feb 01 12:24:26 2010 +0100
348.3 @@ -286,13 +286,9 @@
348.4 </target>
348.5
348.6 <target name="generate-html-preview" depends="-check-html-preview" if="generate.html.preview">
348.7 - <copy file="preview-${jnlp.descriptor}.html" tofile="${jnlp.dest.dir}/launch.html" overwrite="true" encoding="UTF-8">
348.8 - <filterchain>
348.9 - <replacestring from="${JNLP.FILE}" to="${jnlp.file}"/>
348.10 - <replacestring from="${JNLP.APPLET.WIDTH}" to="${jnlp.applet.width}"/>
348.11 - <replacestring from="${JNLP.APPLET.HEIGHT}" to="${jnlp.applet.height}"/>
348.12 - </filterchain>
348.13 - </copy>
348.14 + <taskdef name="copy-template-page" classname="org.netbeans.modules.javawebstart.anttasks.CopyTemplatePageTask"
348.15 + classpath="${libs.JWSAntTasks.classpath}"/>
348.16 + <copy-template-page destfile="${jnlp.dest.dir}/launch.html" template="preview-${jnlp.descriptor}.html" destdir="${jnlp.dest.dir}"/>
348.17 </target>
348.18
348.19 </project>
349.1 --- a/javawebstart/src/org/netbeans/modules/javawebstart/ui/customizer/JWSCompositeCategoryProvider.java Mon Feb 01 12:23:06 2010 +0100
349.2 +++ b/javawebstart/src/org/netbeans/modules/javawebstart/ui/customizer/JWSCompositeCategoryProvider.java Mon Feb 01 12:24:26 2010 +0100
349.3 @@ -184,7 +184,7 @@
349.4 try {
349.5 OutputStream os = masterFile.getOutputStream(lock);
349.6 PrintWriter writer = new PrintWriter(os);
349.7 - writer.println("<jnlp spec=\"1.0+\" codebase=\"${jnlp.codebase}\" href=\"launch.jnlp\">");
349.8 + writer.println("<jnlp spec=\"1.0+\" href=\"launch.jnlp\">");
349.9 writer.println(" <information>");
349.10 writer.println(" <title>${APPLICATION.TITLE}</title>");
349.11 writer.println(" <vendor>${APPLICATION.VENDOR}</vendor>");
349.12 @@ -192,8 +192,8 @@
349.13 writer.println(" <description>${APPLICATION.DESC}</description>");
349.14 writer.println(" <description kind=\"short\">${APPLICATION.DESC.SHORT}</description>");
349.15 writer.println("<!--${JNLP.ICONS}-->");
349.16 - writer.println("<!--${JNLP.OFFLINE.ALLOWED}-->");
349.17 writer.println(" </information>");
349.18 + writer.println("<!--${JNLP.UPDATE}-->");
349.19 writer.println("<!--${JNLP.SECURITY}-->");
349.20 writer.println(" <resources>");
349.21 writer.println("<!--${JNLP.RESOURCES.RUNTIME}-->");
349.22 @@ -246,37 +246,34 @@
349.23 writer.println(" <body>");
349.24 if (JWSProjectProperties.DescType.applet.equals(descType)) {
349.25 writer.println(" <h3>Test page for launching the applet via JNLP</h3>");
349.26 + writer.println(" <script src=\"http://java.com/js/deployJava.js\"></script>");
349.27 + writer.println(" <script>");
349.28 + writer.println(" var attributes = {");
349.29 + writer.println(" code: \"${JNLP.APPLET.CLASS}\",");
349.30 + writer.println(" archive: \"${JNLP.RESOURCES.MAIN.JAR}\",");
349.31 + writer.println(" width: ${JNLP.APPLET.WIDTH},");
349.32 + writer.println(" height: ${JNLP.APPLET.HEIGHT}");
349.33 + writer.println(" };");
349.34 + writer.println(" var parameters = {${JNLP.APPLET.PARAMS}}; <!-- Applet Parameters -->");
349.35 + writer.println(" var version = \"${JNLP_VM_VERSION}\"; <!-- Required Java Version -->");
349.36 + writer.println(" deployJava.runApplet(attributes, parameters, version);");
349.37 + writer.println(" </script>");
349.38 + writer.println(" <!-- Or use the following applet element to launch the applet using jnlp_href -->");
349.39 + writer.println(" <!--");
349.40 writer.println(" <applet width=\"${JNLP.APPLET.WIDTH}\" height=\"${JNLP.APPLET.HEIGHT}\">");
349.41 writer.println(" <param name=\"jnlp_href\" value=\"${JNLP.FILE}\"/>");
349.42 writer.println(" </applet>");
349.43 - writer.println(" <!-- Or use the following script element to launch with the Deployment Toolkit -->");
349.44 - writer.println(" <!-- Open the deployJava.js script to view its documentation -->");
349.45 - writer.println(" <!--");
349.46 + writer.println(" -->");
349.47 +
349.48 + } else if (JWSProjectProperties.DescType.application.equals(descType)) {
349.49 + writer.println(" <h3>Test page for launching the application via JNLP</h3>");
349.50 writer.println(" <script src=\"http://java.com/js/deployJava.js\"></script>");
349.51 writer.println(" <script>");
349.52 - writer.println(" var attributes = {");
349.53 - writer.println(" codebase: [applet codebase],");
349.54 - writer.println(" code: [class to launch],");
349.55 - writer.println(" archive: [JAR file with the applet],");
349.56 - writer.println(" width: [applet width],");
349.57 - writer.println(" height: [applet height]");
349.58 - writer.println(" };");
349.59 - writer.println(" var parameters = { [applet parameters] };");
349.60 - writer.println(" var version = [JDK version];");
349.61 - writer.println(" deployJava.runApplet(attributes, parameters, version);");
349.62 + writer.println(" deployJava.createWebStartLaunchButton(\"${JNLP.FILE}\")");
349.63 writer.println(" </script>");
349.64 - writer.println(" -->");
349.65 - } else if (JWSProjectProperties.DescType.application.equals(descType)) {
349.66 - writer.println(" <h3>Test page for launching the application via JNLP</h3>");
349.67 + writer.println(" <!-- Or use the following link element to launch with the application -->");
349.68 + writer.println(" <!--");
349.69 writer.println(" <a href=\"${JNLP.FILE}\">Launch the application</a>");
349.70 - writer.println(" <!-- Or use the following script element to launch with the Deployment Toolkit -->");
349.71 - writer.println(" <!-- Open the deployJava.js script to view its documentation -->");
349.72 - writer.println(" <!--");
349.73 - writer.println(" <script src=\"http://java.com/js/deployJava.js\"></script>");
349.74 - writer.println(" <script>");
349.75 - writer.println(" var url=\"http://[fill in your URL]/${JNLP.FILE}\"");
349.76 - writer.println(" deployJava.createWebStartLaunchButton(url, \"1.6\")");
349.77 - writer.println(" </script>");
349.78 writer.println(" -->");
349.79 }
349.80 writer.println(" </body>");
350.1 --- a/languages.yaml/manifest.mf Mon Feb 01 12:23:06 2010 +0100
350.2 +++ b/languages.yaml/manifest.mf Mon Feb 01 12:24:26 2010 +0100
350.3 @@ -2,5 +2,5 @@
350.4 OpenIDE-Module: org.netbeans.modules.languages.yaml
350.5 OpenIDE-Module-Layer: org/netbeans/modules/languages/yaml/layer.xml
350.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/languages/yaml/Bundle.properties
350.7 -OpenIDE-Module-Specification-Version: 2.7
350.8 +OpenIDE-Module-Specification-Version: 2.8
350.9 AutoUpdate-Show-In-Client: false
351.1 --- a/languages.yaml/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
351.2 +++ b/languages.yaml/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
351.3 @@ -73,8 +73,8 @@
351.4 <build-prerequisite/>
351.5 <compile-dependency/>
351.6 <run-dependency>
351.7 - <release-version>0-1</release-version>
351.8 - <specification-version>1.19</specification-version>
351.9 + <release-version>2</release-version>
351.10 + <specification-version>2.1</specification-version>
351.11 </run-dependency>
351.12 </dependency>
351.13 <dependency>
352.1 --- a/languages.yaml/src/org/netbeans/modules/languages/yaml/layer.xml Mon Feb 01 12:23:06 2010 +0100
352.2 +++ b/languages.yaml/src/org/netbeans/modules/languages/yaml/layer.xml Mon Feb 01 12:24:26 2010 +0100
352.3 @@ -64,7 +64,9 @@
352.4 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
352.5 </file>
352.6
352.7 - <file name="org-netbeans-modules-languages-yaml-EmbeddedSectionsHighlighting$Factory.instance"/>
352.8 + <file name="org-netbeans-modules-languages-yaml-EmbeddedSectionsHighlighting$Factory.instance">
352.9 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
352.10 + </file>
352.11
352.12 <folder name="FontsColors">
352.13 <folder name="NetBeans">
353.1 --- a/libs.felix/external/binaries-list Mon Feb 01 12:23:06 2010 +0100
353.2 +++ b/libs.felix/external/binaries-list Mon Feb 01 12:24:26 2010 +0100
353.3 @@ -1,1 +1,2 @@
353.4 8F69CD29825A30B6AA774BD79576C909AEC07668 felix-2.0.3.jar
353.5 +BD5615C6A15497B60A0AAA9A04D4F05E2BC42D07 felix-main-2.0.2.jar
354.1 --- a/libs.felix/external/felix-2.0.3-license.txt Mon Feb 01 12:23:06 2010 +0100
354.2 +++ b/libs.felix/external/felix-2.0.3-license.txt Mon Feb 01 12:24:26 2010 +0100
354.3 @@ -3,6 +3,7 @@
354.4 Description: Apache Felix OSGi container (minus org.osgi.** packages).
354.5 License: Apache-2.0
354.6 OSR: 13360
354.7 +Files: felix-2.0.3.jar felix-main-2.0.2.jar
354.8 Origin: http://archive.apache.org/dist/felix/
354.9
354.10 Apache License
355.1 --- a/libs.felix/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
355.2 +++ b/libs.felix/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
355.3 @@ -38,6 +38,7 @@
355.4 # made subject to such option by the copyright holder.
355.5
355.6 release.external/felix-2.0.3.jar=modules/ext/felix-2.0.3.jar
355.7 -
355.8 +release.external/felix-main-2.0.2.jar=modules/ext/felix-main-2.0.2.jar
355.9 +jnlp.verify.excludes=modules/ext/felix-main-2.0.2.jar
355.10 javac.source=1.6
355.11 javac.compilerargs=-Xlint -Xlint:-serial
356.1 --- a/libs.jsr223/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
356.2 +++ b/libs.jsr223/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
356.3 @@ -46,7 +46,9 @@
356.4 <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
356.5 <code-name-base>org.netbeans.libs.jsr223</code-name-base>
356.6 <module-dependencies/>
356.7 - <public-packages/>
356.8 + <public-packages>
356.9 + <package>org.netbeans.libs.jsr223</package>
356.10 + </public-packages>
356.11 </data>
356.12 </configuration>
356.13 </project>
357.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
357.2 +++ b/libs.jsr223/src/org/netbeans/libs/jsr223/Dummy.java Mon Feb 01 12:24:26 2010 +0100
357.3 @@ -0,0 +1,47 @@
357.4 +/*
357.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
357.6 + *
357.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
357.8 + *
357.9 + * The contents of this file are subject to the terms of either the GNU
357.10 + * General Public License Version 2 only ("GPL") or the Common
357.11 + * Development and Distribution License("CDDL") (collectively, the
357.12 + * "License"). You may not use this file except in compliance with the
357.13 + * License. You can obtain a copy of the License at
357.14 + * http://www.netbeans.org/cddl-gplv2.html
357.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
357.16 + * specific language governing permissions and limitations under the
357.17 + * License. When distributing the software, include this License Header
357.18 + * Notice in each file and include the License file at
357.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
357.20 + * particular file as subject to the "Classpath" exception as provided
357.21 + * by Sun in the GPL Version 2 section of the License file that
357.22 + * accompanied this code. If applicable, add the following below the
357.23 + * License Header, with the fields enclosed by brackets [] replaced by
357.24 + * your own identifying information:
357.25 + * "Portions Copyrighted [year] [name of copyright owner]"
357.26 + *
357.27 + * If you wish your version of this file to be governed by only the CDDL
357.28 + * or only the GPL Version 2, indicate your decision by adding
357.29 + * "[Contributor] elects to include this software in this distribution
357.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
357.31 + * single choice of license, a recipient has the option to distribute
357.32 + * your version of this file under either the CDDL, the GPL Version 2 or
357.33 + * to extend the choice of license to its licensees as provided above.
357.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
357.35 + * Version 2 license, then the option applies only if the new code is
357.36 + * made subject to such option by the copyright holder.
357.37 + *
357.38 + * Contributor(s):
357.39 + *
357.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
357.41 + */
357.42 +
357.43 +package org.netbeans.libs.jsr223;
357.44 +
357.45 +/**
357.46 + * Not used for anything, and not accessible anyway.
357.47 + * Just exists to prevent "ZIP file must have at least one entry"
357.48 + * from ParseProjectXml.createPublicPackageJar.
357.49 + */
357.50 +interface Dummy {}
358.1 --- a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
358.2 +++ b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
358.3 @@ -41,10 +41,6 @@
358.4 LBL_important_files=Important Files
358.5 LBL_module.xml=Module Descriptor
358.6 LBL_module_manifest=Module Manifest
358.7 -TIT_NBM_Archetype=Maven NetBeans Module Archetype
358.8 -DESC_NBM_Archetype=Archetype for creation of NetBeans module projects.
358.9 -TIT_Platform_Application_Archetype=Maven NetBeans Platform Application Archetype
358.10 -DESC_Platform_Application_Archetype=Archetype for creating NetBeans platform based applications.
358.11 Projects/org-netbeans-modules-maven/Repositories/netbeans=NetBeans Repository
358.12 ACT_NBM_Reload=Install/Reload in Development IDE
358.13
359.1 --- a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/layer.xml Mon Feb 01 12:23:06 2010 +0100
359.2 +++ b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/layer.xml Mon Feb 01 12:24:26 2010 +0100
359.3 @@ -62,28 +62,6 @@
359.4 <attr name="misplaced.action.allowed" boolvalue="true"/>
359.5 </file>
359.6 </folder>
359.7 - <folder name="Archetypes">
359.8 - <file name="nbm-archetype">
359.9 - <attr name="position" intvalue="200"/>
359.10 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.maven.apisupport.Bundle"/>
359.11 - <attr name="groupId" stringvalue="org.codehaus.mojo.archetypes"/>
359.12 - <attr name="artifactId" stringvalue="nbm-archetype"/>
359.13 - <attr name="version" stringvalue="1.2"/>
359.14 - <!--attr name="repository" stringvalue=""/-->
359.15 - <attr name="nameBundleKey" stringvalue="TIT_NBM_Archetype"/>
359.16 - <attr name="descriptionBundleKey" stringvalue="DESC_NBM_Archetype"/>
359.17 - </file>
359.18 - <file name="netbeans-platform-app-archetype">
359.19 - <attr name="position" intvalue="205"/>
359.20 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.maven.apisupport.Bundle"/>
359.21 - <attr name="groupId" stringvalue="org.codehaus.mojo.archetypes"/>
359.22 - <attr name="artifactId" stringvalue="netbeans-platform-app-archetype"/>
359.23 - <attr name="version" stringvalue="1.3-SNAPSHOT"/>
359.24 - <attr name="repository" stringvalue="http://snapshots.repository.codehaus.org/"/>
359.25 - <attr name="nameBundleKey" stringvalue="TIT_Platform_Application_Archetype"/>
359.26 - <attr name="descriptionBundleKey" stringvalue="DESC_Platform_Application_Archetype"/>
359.27 - </file>
359.28 - </folder>
359.29 </folder>
359.30 </folder>
359.31 <folder name="Templates">
360.1 --- a/maven.osgi/src/org/netbeans/modules/maven/osgi/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
360.2 +++ b/maven.osgi/src/org/netbeans/modules/maven/osgi/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
360.3 @@ -2,6 +2,4 @@
360.4 OpenIDE-Module-Name=Maven OSGI module
360.5 Templates/OSGI=OSGI
360.6 Templates/OSGI/Activator.java=Bundle Activator
360.7 -TIT_OSGI_Archetype=OSGi Archetype
360.8 -DESC_OSGI_Archetype=OSGi project template based on Apache Felix maven-bundle-plugin.
360.9 TITLE_x_of_y=${0} of ${1}
361.1 --- a/maven.osgi/src/org/netbeans/modules/maven/osgi/customizer/PackagesPanelProvider.java Mon Feb 01 12:23:06 2010 +0100
361.2 +++ b/maven.osgi/src/org/netbeans/modules/maven/osgi/customizer/PackagesPanelProvider.java Mon Feb 01 12:24:26 2010 +0100
361.3 @@ -41,6 +41,7 @@
361.4
361.5 import javax.swing.JComponent;
361.6 import org.netbeans.api.project.Project;
361.7 +import org.netbeans.modules.maven.api.NbMavenProject;
361.8 import org.netbeans.modules.maven.api.customizer.ModelHandle;
361.9 import org.netbeans.spi.project.ui.support.ProjectCustomizer;
361.10 import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
361.11 @@ -53,13 +54,20 @@
361.12 @ProjectCustomizer.CompositeCategoryProvider.Registration(projectType="org-netbeans-modules-maven", position=350)
361.13 public class PackagesPanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
361.14
361.15 + @Override
361.16 public Category createCategory(Lookup context) {
361.17 - return ProjectCustomizer.Category.create(
361.18 - ModelHandle.PANEL_COMPILE,
361.19 - org.openide.util.NbBundle.getMessage(PackagesPanelProvider.class, "TIT_Packages"),
361.20 - null);
361.21 + Project project = context.lookup(Project.class);
361.22 + NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class);
361.23 + if (NbMavenProject.TYPE_OSGI.equalsIgnoreCase(watcher.getPackagingType())) {
361.24 + return ProjectCustomizer.Category.create(
361.25 + ModelHandle.PANEL_COMPILE,
361.26 + org.openide.util.NbBundle.getMessage(PackagesPanelProvider.class, "TIT_Packages"),
361.27 + null);
361.28 + }
361.29 + return null;
361.30 }
361.31
361.32 + @Override
361.33 public JComponent createComponent(Category category, Lookup context) {
361.34 ModelHandle handle = context.lookup(ModelHandle.class);
361.35 Project prj = context.lookup(Project.class);
362.1 --- a/maven.osgi/src/org/netbeans/modules/maven/osgi/layer.xml Mon Feb 01 12:23:06 2010 +0100
362.2 +++ b/maven.osgi/src/org/netbeans/modules/maven/osgi/layer.xml Mon Feb 01 12:24:26 2010 +0100
362.3 @@ -28,20 +28,4 @@
362.4 </folder>
362.5 </folder>
362.6 </folder>
362.7 - <folder name="Projects">
362.8 - <folder name="org-netbeans-modules-maven">
362.9 - <folder name="Archetypes">
362.10 - <file name="osgi-archetype">
362.11 - <attr name="position" intvalue="329"/>
362.12 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.maven.osgi.Bundle"/>
362.13 - <attr name="groupId" stringvalue="org.codehaus.mojo.archetypes"/>
362.14 - <attr name="artifactId" stringvalue="osgi-archetype"/>
362.15 - <attr name="version" stringvalue="1.0-SNAPSHOT"/>
362.16 - <attr name="repository" stringvalue="http://snapshots.repository.codehaus.org"/>
362.17 - <attr name="nameBundleKey" stringvalue="TIT_OSGI_Archetype"/>
362.18 - <attr name="descriptionBundleKey" stringvalue="DESC_OSGI_Archetype"/>
362.19 - </file>
362.20 - </folder>
362.21 - </folder>
362.22 - </folder>
362.23 </filesystem>
363.1 Binary file mercurial/src/org/netbeans/modules/mercurial/resources/icons/load_template.png has changed
364.1 --- a/mercurial/src/org/netbeans/modules/mercurial/ui/commit/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
364.2 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/commit/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
364.3 @@ -62,14 +62,18 @@
364.4 MSG_CommitForm_ErrorConflicts=You cannot commit Files with Conflicts. Edit Files and resolve Conflicts first.
364.5 MSG_CommitForm_ErrorMultipleBranches = Warning: Committing to multiple Branches, see Branch column.
364.6 MSG_CommitForm_InfoBranch = Committing to "{0}" Branch
364.7 -CTL_CommitForm_FilesToCommit=By clicking on a Field in the 'Commit Action' Column you may specify some additional Actions.
364.8 +CTL_CommitForm_FilesToCommit=&By right-clicking on a row you may specify some additional Actions.
364.9
364.10 ACSD_CommitTable = Lists files to commit along with their commit options which you can change.
364.11 +CTL_CommitTable_Column_Commit = Commit
364.12 +CTL_CommitTable_Column_Description = Include/Exclude from commit
364.13 CTL_CommitTable_Column_File = File
364.14 CTL_CommitTable_Column_Branch = Branch
364.15 CTL_CommitTable_Column_Status = Status
364.16 CTL_CommitTable_Column_Action = Commit Action
364.17 CTL_CommitTable_Column_Folder = Repository Path
364.18 +CTL_CommitTable_IncludeAction = &Include In Commit
364.19 +CTL_CommitTable_ExcludeAction = &Exclude From Commit
364.20
364.21 CTL_CommitOption_Commit = Commit
364.22 CTL_CommitOption_CommitRemove = Remove
364.23 @@ -88,6 +92,8 @@
364.24 CTL_CommitForm_RecentPrompt = Recent Commit &Messages:
364.25
364.26 CTL_CommitForm_RecentMessages=Recent Messages
364.27 +CTL_CommitForm_LoadTemplate=Load Template
364.28 +
364.29 ACSN_CommitDialog=Commit Dialog
364.30 ACSD_CommitDialog=This dialog lets you review list files to commit, exclude or include individual files and write commit message describing your changes.
364.31 ACSN_CommitForm_Message=Commit Message
365.1 --- a/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Mon Feb 01 12:23:06 2010 +0100
365.2 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Mon Feb 01 12:24:26 2010 +0100
365.3 @@ -322,10 +322,10 @@
365.4 }
365.5
365.6 if (stickyTags.size() > 1) {
365.7 - table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_BRANCH, CommitTableModel.COLUMN_NAME_STATUS,
365.8 + table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_COMMIT, CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_BRANCH, CommitTableModel.COLUMN_NAME_STATUS,
365.9 CommitTableModel.COLUMN_NAME_ACTION, CommitTableModel.COLUMN_NAME_PATH });
365.10 } else {
365.11 - table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_STATUS,
365.12 + table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_COMMIT, CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_STATUS,
365.13 CommitTableModel.COLUMN_NAME_ACTION, CommitTableModel.COLUMN_NAME_PATH });
365.14 }
365.15
366.1 --- a/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java Mon Feb 01 12:23:06 2010 +0100
366.2 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java Mon Feb 01 12:24:26 2010 +0100
366.3 @@ -41,6 +41,7 @@
366.4
366.5 package org.netbeans.modules.mercurial.ui.commit;
366.6
366.7 +import org.netbeans.modules.versioning.util.TemplateSelector;
366.8 import java.awt.Component;
366.9 import java.awt.Container;
366.10 import javax.swing.Box;
366.11 @@ -117,6 +118,7 @@
366.12 private final JScrollPane jScrollPane1 = new JScrollPane();
366.13 private final JTextArea messageTextArea = new JTextArea();
366.14 private final JLabel recentLink = new JLabel();
366.15 + private final JLabel templateLink = new JLabel();
366.16 private Icon expandedIcon, collapsedIcon;
366.17
366.18 private CommitTable commitTable;
366.19 @@ -145,11 +147,16 @@
366.20 commitTable.getTableModel().addTableModelListener(this);
366.21 listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
366.22
366.23 - final List<String> messages = Utils.getStringList(HgModuleConfig.getDefault().getPreferences(), CommitAction.RECENT_COMMIT_MESSAGES);
366.24 SwingUtilities.invokeLater(new Runnable() {
366.25 public void run() {
366.26 - if (messages.size() > 0) {
366.27 - messageTextArea.setText(messages.get(0));
366.28 + TemplateSelector ts = new TemplateSelector(HgModuleConfig.getDefault().getPreferences());
366.29 + if(ts.isAutofill()) {
366.30 + messageTextArea.setText(ts.getTemplate());
366.31 + } else {
366.32 + List<String> messages = Utils.getStringList(HgModuleConfig.getDefault().getPreferences(), CommitAction.RECENT_COMMIT_MESSAGES);
366.33 + if (messages.size() > 0) {
366.34 + messageTextArea.setText(messages.get(0));
366.35 + }
366.36 }
366.37 messageTextArea.selectAll();
366.38 }
366.39 @@ -286,7 +293,14 @@
366.40 messageTextArea.replaceSelection(message);
366.41 }
366.42 }
366.43 -
366.44 +
366.45 + private void onTemplate() {
366.46 + TemplateSelector ts = new TemplateSelector(HgModuleConfig.getDefault().getPreferences());
366.47 + if(ts.show()) {
366.48 + messageTextArea.setText(ts.getTemplate());
366.49 + }
366.50 + }
366.51 +
366.52 public void preferenceChange(PreferenceChangeEvent evt) {
366.53 if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
366.54 Runnable inAWT = new Runnable() {
366.55 @@ -320,6 +334,9 @@
366.56 recentLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/mercurial/resources/icons/recent_messages.png"))); // NOI18N
366.57 recentLink.setToolTipText(getMessage("CTL_CommitForm_RecentMessages")); // NOI18N
366.58
366.59 + templateLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/mercurial/resources/icons/load_template.png"))); // NOI18N
366.60 + templateLink.setToolTipText(getMessage("CTL_CommitForm_LoadTemplate")); // NOI18N
366.61 +
366.62 messageTextArea.setColumns(60); //this determines the preferred width of the whole dialog
366.63 messageTextArea.setLineWrap(true);
366.64 messageTextArea.setRows(4);
366.65 @@ -342,8 +359,11 @@
366.66 topPanel.add(jLabel1);
366.67 topPanel.add(Box.createHorizontalGlue());
366.68 topPanel.add(recentLink);
366.69 + topPanel.add(makeHorizontalStrut(recentLink, templateLink, RELATED));
366.70 + topPanel.add(templateLink);
366.71 jLabel1.setAlignmentY(BOTTOM_ALIGNMENT);
366.72 recentLink.setAlignmentY(BOTTOM_ALIGNMENT);
366.73 + templateLink.setAlignmentY(BOTTOM_ALIGNMENT);
366.74
366.75 JPanel bottomPanel = new VerticallyNonResizingPanel();
366.76 bottomPanel.setLayout(new BoxLayout(bottomPanel, X_AXIS));
366.77 @@ -392,6 +412,13 @@
366.78 onBrowseRecentMessages();
366.79 }
366.80 });
366.81 + templateLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
366.82 + templateLink.addMouseListener(new MouseAdapter() {
366.83 + @Override
366.84 + public void mouseClicked(MouseEvent e) {
366.85 + onTemplate();
366.86 + }
366.87 + });
366.88 }
366.89
366.90 private Component makeVerticalStrut(JComponent compA,
366.91 @@ -406,6 +433,18 @@
366.92 return Box.createVerticalStrut(height);
366.93 }
366.94
366.95 + private Component makeHorizontalStrut(JComponent compA,
366.96 + JComponent compB,
366.97 + int relatedUnrelated) {
366.98 + int width = LayoutStyle.getSharedInstance().getPreferredGap(
366.99 + compA,
366.100 + compB,
366.101 + relatedUnrelated,
366.102 + WEST,
366.103 + this);
366.104 + return Box.createHorizontalStrut(width);
366.105 + }
366.106 +
366.107 private Component makeFlexibleHorizontalStrut(int minWidth,
366.108 int prefWidth,
366.109 int maxWidth) {
367.1 --- a/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitTable.java Mon Feb 01 12:23:06 2010 +0100
367.2 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitTable.java Mon Feb 01 12:24:26 2010 +0100
367.3 @@ -46,7 +46,6 @@
367.4 import org.netbeans.modules.versioning.util.TableSorter;
367.5 import org.netbeans.modules.mercurial.util.HgUtils;
367.6 import org.netbeans.modules.mercurial.HgFileNode;
367.7 -import org.netbeans.modules.mercurial.FileInformation;
367.8 import org.netbeans.modules.mercurial.Mercurial;
367.9 import org.openide.util.NbBundle;
367.10
367.11 @@ -59,28 +58,29 @@
367.12 import javax.swing.table.TableModel;
367.13 import javax.swing.table.TableColumnModel;
367.14 import java.awt.Component;
367.15 -import java.lang.String;
367.16 +import java.awt.Point;
367.17 +import java.awt.event.ActionEvent;
367.18 +import java.awt.event.KeyEvent;
367.19 +import java.awt.event.MouseEvent;
367.20 +import java.awt.event.MouseListener;
367.21 import java.util.*;
367.22 +import javax.swing.table.TableCellRenderer;
367.23 +import org.openide.awt.Mnemonics;
367.24
367.25 /**
367.26 * {@link #getComponent Table} that displays nodes in the commit dialog.
367.27 *
367.28 * @author Maros Sandor
367.29 */
367.30 -public class CommitTable implements AncestorListener, TableModelListener {
367.31 +public class CommitTable implements AncestorListener, TableModelListener, MouseListener {
367.32
367.33 public static String [] COMMIT_COLUMNS = new String [] {
367.34 + CommitTableModel.COLUMN_NAME_COMMIT,
367.35 CommitTableModel.COLUMN_NAME_NAME,
367.36 CommitTableModel.COLUMN_NAME_STATUS,
367.37 CommitTableModel.COLUMN_NAME_ACTION,
367.38 CommitTableModel.COLUMN_NAME_PATH
367.39 };
367.40 -
367.41 - public static String [] IMPORT_COLUMNS = new String [] {
367.42 - CommitTableModel.COLUMN_NAME_NAME,
367.43 - CommitTableModel.COLUMN_NAME_ACTION,
367.44 - CommitTableModel.COLUMN_NAME_PATH
367.45 - };
367.46
367.47 private CommitTableModel tableModel;
367.48 private JTable table;
367.49 @@ -107,20 +107,31 @@
367.50 if(sorter == null) {
367.51 sorter = new TableSorter(tableModel);
367.52 }
367.53 - this.sorter = sorter;
367.54 + this.sorter = sorter;
367.55 table = new SortedTable(this.sorter);
367.56 table.getTableHeader().setReorderingAllowed(false);
367.57 table.setDefaultRenderer(String.class, new CommitStringsCellRenderer());
367.58 - table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
367.59 + table.setDefaultRenderer(Boolean.class, new CheckboxCellRenderer());
367.60 + table.setDefaultEditor(Boolean.class, new CheckboxCellEditor());
367.61 table.getTableHeader().setReorderingAllowed(true);
367.62 table.setRowHeight(table.getRowHeight() * 6 / 5);
367.63 table.addAncestorListener(this);
367.64 component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
367.65 label.setLabelFor(table);
367.66 table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CommitTable.class, "ACSD_CommitTable")); // NOI18N
367.67 + table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
367.68 + KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK ), "org.openide.actions.PopupAction"); // NOI18N
367.69 + table.getActionMap().put("org.openide.actions.PopupAction", new AbstractAction() { // NOI18N
367.70 + @Override
367.71 + public void actionPerformed(ActionEvent e) {
367.72 + showPopup(org.netbeans.modules.versioning.util.Utils.getPositionForPopup(table));
367.73 + }
367.74 + });
367.75 + table.addMouseListener(this);
367.76 setColumns(columns);
367.77 }
367.78
367.79 + @Override
367.80 public void ancestorAdded(AncestorEvent event) {
367.81 setDefaultColumnSizes();
367.82 }
367.83 @@ -133,11 +144,14 @@
367.84 TableColumnModel columnModel = table.getColumnModel();
367.85 if (columns == null || columnModel == null) return; // unsure when this methed will be called (component realization)
367.86 if (columnModel.getColumnCount() != columns.length) return;
367.87 - if (columns.length == 3) {
367.88 + if (columns.length == 4) {
367.89 for (int i = 0; i < columns.length; i++) {
367.90 String col = columns[i];
367.91 sorter.setColumnComparator(i, null);
367.92 - if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
367.93 + if (col.equals(CommitTableModel.COLUMN_NAME_COMMIT)) {
367.94 + columnModel.getColumn(i).setMinWidth(new JCheckBox().getMinimumSize().width);
367.95 + columnModel.getColumn(i).setPreferredWidth(new JCheckBox().getPreferredSize().width);
367.96 + } else if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
367.97 sorter.setColumnComparator(i, new FileNameComparator());
367.98 columnModel.getColumn(i).setPreferredWidth(width * 30 / 100);
367.99 } else if (col.equals(CommitTableModel.COLUMN_NAME_ACTION)) {
367.100 @@ -146,11 +160,14 @@
367.101 columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
367.102 }
367.103 }
367.104 - } else if (columns.length == 4) {
367.105 + } else if (columns.length == 5) {
367.106 for (int i = 0; i < columns.length; i++) {
367.107 String col = columns[i];
367.108 sorter.setColumnComparator(i, null);
367.109 - if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
367.110 + if (col.equals(CommitTableModel.COLUMN_NAME_COMMIT)) {
367.111 + columnModel.getColumn(i).setMinWidth(new JCheckBox().getMinimumSize().width);
367.112 + columnModel.getColumn(i).setPreferredWidth(new JCheckBox().getPreferredSize().width);
367.113 + } else if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
367.114 sorter.setColumnComparator(i, new FileNameComparator());
367.115 columnModel.getColumn(i).setPreferredWidth(width * 25 / 100);
367.116 } else if (col.equals(CommitTableModel.COLUMN_NAME_STATUS)) {
367.117 @@ -162,11 +179,14 @@
367.118 columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
367.119 }
367.120 }
367.121 - } else if (columns.length == 5) {
367.122 + } else if (columns.length == 6) {
367.123 for (int i = 0; i < columns.length; i++) {
367.124 String col = columns[i];
367.125 sorter.setColumnComparator(i, null);
367.126 - if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
367.127 + if (col.equals(CommitTableModel.COLUMN_NAME_COMMIT)) {
367.128 + columnModel.getColumn(i).setMinWidth(new JCheckBox().getMinimumSize().width);
367.129 + columnModel.getColumn(i).setPreferredWidth(new JCheckBox().getPreferredSize().width);
367.130 + } else if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
367.131 sorter.setColumnComparator(i, new FileNameComparator());
367.132 columnModel.getColumn(i).setPreferredWidth(width * 25 / 100);
367.133 } else if (col.equals(CommitTableModel.COLUMN_NAME_STATUS)) {
367.134 @@ -199,9 +219,11 @@
367.135 return sorter;
367.136 }
367.137
367.138 + @Override
367.139 public void ancestorMoved(AncestorEvent event) {
367.140 }
367.141
367.142 + @Override
367.143 public void ancestorRemoved(AncestorEvent event) {
367.144 }
367.145
367.146 @@ -240,6 +262,7 @@
367.147 return tableModel;
367.148 }
367.149
367.150 + @Override
367.151 public void tableChanged(TableModelEvent e) {
367.152 // change in commit options may alter name rendering (strikethrough)
367.153 table.repaint();
367.154 @@ -248,58 +271,120 @@
367.155 public void setRootFile(String repositoryPath, String rootLocalPath) {
367.156 tableModel.setRootFile(repositoryPath, rootLocalPath);
367.157 }
367.158 +
367.159 + private void showPopup(final MouseEvent e) {
367.160 + int row = table.rowAtPoint(e.getPoint());
367.161 + int col = table.columnAtPoint(e.getPoint());
367.162 + if (row != -1) {
367.163 + boolean makeRowSelected = true;
367.164 + int [] selectedrows = table.getSelectedRows();
367.165 + for (int i = 0; i < selectedrows.length; i++) {
367.166 + if (row == selectedrows[i]) {
367.167 + makeRowSelected = false;
367.168 + break;
367.169 + }
367.170 + }
367.171 + if (makeRowSelected) {
367.172 + table.getSelectionModel().setSelectionInterval(row, row);
367.173 + }
367.174 + }
367.175 + if (col != -1) {
367.176 + boolean makeColSelected = true;
367.177 + int [] selectedcols = table.getSelectedColumns();
367.178 + for (int i = 0; i < selectedcols.length; i++) {
367.179 + if (col == selectedcols[i]) {
367.180 + makeColSelected = false;
367.181 + break;
367.182 + }
367.183 + }
367.184 + if (makeColSelected) {
367.185 + table.getColumnModel().getSelectionModel().setSelectionInterval(col, col);
367.186 + }
367.187 + }
367.188 + SwingUtilities.invokeLater(new Runnable() {
367.189 + @Override
367.190 + public void run() {
367.191 + // invoke later so the selection on the table will be set first
367.192 + JPopupMenu menu = getPopup();
367.193 + menu.show(table, e.getX(), e.getY());
367.194 + }
367.195 + });
367.196 + }
367.197 +
367.198 + private void showPopup (Point p) {
367.199 + JPopupMenu menu = getPopup();
367.200 + menu.show(table, p.x, p.y);
367.201 + }
367.202
367.203 - private class CommitOptionsCellEditor extends DefaultCellEditor {
367.204 + private JPopupMenu getPopup() {
367.205
367.206 - private final Object[] dirAddOptions = new Object [] {
367.207 - CommitOptions.COMMIT,
367.208 - CommitOptions.EXCLUDE
367.209 - };
367.210 -
367.211 - private final Object[] addOptions = new Object [] {
367.212 - CommitOptions.COMMIT,
367.213 - CommitOptions.EXCLUDE
367.214 - };
367.215 - private final Object[] commitOptions = new Object [] {
367.216 - CommitOptions.COMMIT,
367.217 - CommitOptions.EXCLUDE
367.218 - };
367.219 + JPopupMenu menu = new JPopupMenu();
367.220 + JMenuItem item;
367.221
367.222 - private final Object[] removeOptions = new Object [] {
367.223 - CommitOptions.COMMIT_REMOVE,
367.224 - CommitOptions.EXCLUDE
367.225 - };
367.226 + boolean onlyIncluded = true;
367.227 + for (int rowIndex : table.getSelectedRows()) {
367.228 + if (CommitOptions.EXCLUDE.equals(tableModel.getOptions(sorter.modelIndex(rowIndex)))) {
367.229 + onlyIncluded = false;
367.230 + break;
367.231 + }
367.232 + }
367.233 + final boolean include = !onlyIncluded;
367.234 + item = menu.add(new AbstractAction(NbBundle.getMessage(CommitTable.class, include ? "CTL_CommitTable_IncludeAction" : "CTL_CommitTable_ExcludeAction")) { // NOI18N
367.235 + @Override
367.236 + public void actionPerformed(ActionEvent e) {
367.237 + int[] rows = table.getSelectedRows();
367.238 + int rowCount = table.getRowCount();
367.239 + for (int i = 0; i < rows.length; ++i) {
367.240 + rows[i] = sorter.modelIndex(rows[i]);
367.241 + }
367.242 + tableModel.setIncluded(rows, include);
367.243 + // WA for table sorter, keep the selection
367.244 + if (rowCount == table.getRowCount()) {
367.245 + for (int i = 0; i < rows.length; ++i) {
367.246 + table.getSelectionModel().addSelectionInterval(sorter.viewIndex(rows[i]), sorter.viewIndex(rows[i]));
367.247 + }
367.248 + }
367.249 + }
367.250 + });
367.251 + Mnemonics.setLocalizedText(item, item.getText());
367.252 + return menu;
367.253 + }
367.254
367.255 - public CommitOptionsCellEditor() {
367.256 - super(new JComboBox());
367.257 + @Override
367.258 + public void mouseEntered(MouseEvent e) {
367.259 + }
367.260 +
367.261 + @Override
367.262 + public void mouseExited(MouseEvent e) {
367.263 + }
367.264 +
367.265 + @Override
367.266 + public void mousePressed(MouseEvent e) {
367.267 + if (e.isPopupTrigger()) {
367.268 + showPopup(e);
367.269 }
367.270 + }
367.271
367.272 - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
367.273 - FileInformation info = tableModel.getNode(sorter.modelIndex(row)).getInformation();
367.274 - int fileStatus = info.getStatus();
367.275 - JComboBox combo = (JComboBox) editorComponent;
367.276 - if (fileStatus == FileInformation.STATUS_VERSIONED_DELETEDLOCALLY || fileStatus == FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY) {
367.277 - combo.setModel(new DefaultComboBoxModel(removeOptions));
367.278 - } else if ((fileStatus & FileInformation.STATUS_IN_REPOSITORY) == 0) {
367.279 - if (info.isDirectory()) {
367.280 - combo.setModel(new DefaultComboBoxModel(dirAddOptions));
367.281 - } else {
367.282 - combo.setModel(new DefaultComboBoxModel(addOptions));
367.283 - }
367.284 - } else {
367.285 - combo.setModel(new DefaultComboBoxModel(commitOptions));
367.286 - }
367.287 - return super.getTableCellEditorComponent(table, value, isSelected, row, column);
367.288 + @Override
367.289 + public void mouseReleased(MouseEvent e) {
367.290 + if (e.isPopupTrigger()) {
367.291 + showPopup(e);
367.292 }
367.293 }
367.294
367.295 + @Override
367.296 + public void mouseClicked(MouseEvent e) {
367.297 + // not interested
367.298 + }
367.299 +
367.300 private class CommitStringsCellRenderer extends DefaultTableCellRenderer {
367.301
367.302 private FilePathCellRenderer pathRenderer = new FilePathCellRenderer();
367.303
367.304 + @Override
367.305 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
367.306 int col = table.convertColumnIndexToModel(column);
367.307 - if (columns[col] == CommitTableModel.COLUMN_NAME_NAME) {
367.308 + if (CommitTableModel.COLUMN_NAME_NAME.equals(columns[col])) {
367.309 TableSorter sorter = (TableSorter) table.getModel();
367.310 CommitTableModel model = (CommitTableModel) sorter.getTableModel();
367.311 HgFileNode node = model.getNode(sorter.modelIndex(row));
367.312 @@ -312,13 +397,43 @@
367.313 value = "<html><s>" + value + "</s></html>"; // NOI18N
367.314 }
367.315 return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
367.316 - } else if (columns[col] == CommitTableModel.COLUMN_NAME_PATH) {
367.317 + } else if (CommitTableModel.COLUMN_NAME_PATH.equals(columns[col])) {
367.318 return pathRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
367.319 } else {
367.320 return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
367.321 }
367.322 }
367.323 }
367.324 +
367.325 + private class CheckboxCellRenderer extends JCheckBox implements TableCellRenderer {
367.326 +
367.327 + public CheckboxCellRenderer() {
367.328 + setToolTipText(NbBundle.getMessage(CommitTable.class, "CTL_CommitTable_Column_Description")); //NOI18N
367.329 + }
367.330 +
367.331 + @Override
367.332 + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
367.333 + setSelected(value == null ? false : (Boolean) value);
367.334 + setBackground(hasFocus || isSelected ? table.getSelectionBackground() : table.getBackground());
367.335 + setHorizontalAlignment(SwingConstants.LEFT);
367.336 + return this;
367.337 + }
367.338 + }
367.339 +
367.340 + private class CheckboxCellEditor extends DefaultCellEditor {
367.341 +
367.342 + public CheckboxCellEditor() {
367.343 + super(new JCheckBox());
367.344 + }
367.345 +
367.346 + @Override
367.347 + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
367.348 + JCheckBox checkbox = (JCheckBox) editorComponent;
367.349 + checkbox.setSelected(value == null ? false : (Boolean) value);
367.350 + checkbox.setHorizontalAlignment(SwingConstants.LEFT);
367.351 + return super.getTableCellEditorComponent(table, value, isSelected, row, column);
367.352 + }
367.353 + }
367.354
367.355 private class StatusComparator extends HgUtils.ByImportanceComparator {
367.356 public int compare(Object o1, Object o2) {
367.357 @@ -330,6 +445,7 @@
367.358 }
367.359
367.360 private class FileNameComparator implements Comparator {
367.361 + @Override
367.362 public int compare(Object o1, Object o2) {
367.363 Integer row1 = (Integer) o1;
367.364 Integer row2 = (Integer) o2;
368.1 --- a/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitTableModel.java Mon Feb 01 12:23:06 2010 +0100
368.2 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitTableModel.java Mon Feb 01 12:24:26 2010 +0100
368.3 @@ -58,6 +58,7 @@
368.4 */
368.5 public class CommitTableModel extends AbstractTableModel {
368.6
368.7 + public static final String COLUMN_NAME_COMMIT = "commit"; // NOI18N
368.8 public static final String COLUMN_NAME_NAME = "name"; // NOI18N
368.9 public static final String COLUMN_NAME_STATUS = "status"; // NOI18N
368.10 public static final String COLUMN_NAME_ACTION = "action"; // NOI18N
368.11 @@ -78,6 +79,9 @@
368.12
368.13 {
368.14 ResourceBundle loc = NbBundle.getBundle(CommitTableModel.class);
368.15 + columnLabels.put(COLUMN_NAME_COMMIT, new String [] {
368.16 + loc.getString("CTL_CommitTable_Column_Commit"), // NOI18N
368.17 + loc.getString("CTL_CommitTable_Column_Description")}); // NOI18N
368.18 columnLabels.put(COLUMN_NAME_NAME, new String [] {
368.19 loc.getString("CTL_CommitTable_Column_File"), // NOI18N
368.20 loc.getString("CTL_CommitTable_Column_File")}); // NOI18N
368.21 @@ -132,35 +136,46 @@
368.22 return ret;
368.23 }
368.24
368.25 + @Override
368.26 public String getColumnName(int column) {
368.27 return columnLabels.get(columns[column])[0];
368.28 }
368.29
368.30 + @Override
368.31 public int getColumnCount() {
368.32 return columns.length;
368.33 }
368.34
368.35 + @Override
368.36 public int getRowCount() {
368.37 return nodes.length;
368.38 }
368.39
368.40 + @Override
368.41 public Class getColumnClass(int columnIndex) {
368.42 String col = columns[columnIndex];
368.43 - if (col.equals(COLUMN_NAME_ACTION)) {
368.44 + if (col.equals(COLUMN_NAME_COMMIT)) {
368.45 + return Boolean.class;
368.46 + } else if (col.equals(COLUMN_NAME_ACTION)) {
368.47 return CommitOptions.class;
368.48 + } else {
368.49 + return String.class;
368.50 }
368.51 - return String.class;
368.52 }
368.53
368.54 + @Override
368.55 public boolean isCellEditable(int rowIndex, int columnIndex) {
368.56 String col = columns[columnIndex];
368.57 - return col.equals(COLUMN_NAME_ACTION);
368.58 + return col.equals(COLUMN_NAME_COMMIT);
368.59 }
368.60
368.61 + @Override
368.62 public Object getValueAt(int rowIndex, int columnIndex) {
368.63 HgFileNode node;
368.64 String col = columns[columnIndex];
368.65 - if (col.equals(COLUMN_NAME_NAME)) {
368.66 + if (col.equals(COLUMN_NAME_COMMIT)) {
368.67 + return commitOptions[rowIndex] != CommitOptions.EXCLUDE;
368.68 + } else if (col.equals(COLUMN_NAME_NAME)) {
368.69 return nodes[rowIndex].getName();
368.70 // TODO deal with branch?
368.71 //} else if (col.equals(COLUMN_NAME_BRANCH)) {
368.72 @@ -169,8 +184,6 @@
368.73 } else if (col.equals(COLUMN_NAME_STATUS)) {
368.74 node = nodes[rowIndex];
368.75 FileInformation finfo = node.getInformation();
368.76 - //TODO what should we do with this?
368.77 - //finfo.getEntry(node.getFile()); // HACK returned value is not interesting, point is side effect, it loads ISVNStatus structure
368.78 return finfo.getStatusText();
368.79 } else if (col.equals(COLUMN_NAME_ACTION)) {
368.80 return commitOptions[rowIndex];
368.81 @@ -192,14 +205,17 @@
368.82 throw new IllegalArgumentException("Column index out of range: " + columnIndex); // NOI18N
368.83 }
368.84
368.85 + @Override
368.86 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
368.87 String col = columns[columnIndex];
368.88 if (col.equals(COLUMN_NAME_ACTION)) {
368.89 commitOptions[rowIndex] = (CommitOptions) aValue;
368.90 - fireTableCellUpdated(rowIndex, columnIndex);
368.91 + } else if (col.equals(COLUMN_NAME_COMMIT)) {
368.92 + commitOptions[rowIndex] = ((Boolean) aValue) ? getCommitOptions(rowIndex) : CommitOptions.EXCLUDE;
368.93 } else {
368.94 throw new IllegalArgumentException("Column index out of range: " + columnIndex); // NOI18N
368.95 }
368.96 + fireTableRowsUpdated(rowIndex, rowIndex);
368.97 }
368.98
368.99 public HgFileNode getNode(int row) {
368.100 @@ -216,4 +232,18 @@
368.101 rootFile.rootLocalPath = rootLocalPath;
368.102 }
368.103
368.104 + void setIncluded (int[] rows, boolean include) {
368.105 + for (int rowIndex : rows) {
368.106 + commitOptions[rowIndex] = include ? getCommitOptions(rowIndex) : CommitOptions.EXCLUDE;
368.107 + }
368.108 + fireTableRowsUpdated(0, getRowCount() - 1);
368.109 + }
368.110 +
368.111 + private CommitOptions getCommitOptions (int rowIndex) {
368.112 + HgFileNode node = nodes[rowIndex];
368.113 + FileInformation finfo = node.getInformation();
368.114 + return (finfo.getStatus() & (FileInformation.STATUS_VERSIONED_DELETEDLOCALLY | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) == 0
368.115 + ? CommitOptions.COMMIT
368.116 + : CommitOptions.COMMIT_REMOVE;
368.117 + }
368.118 }
369.1 --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java Mon Feb 01 12:23:06 2010 +0100
369.2 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java Mon Feb 01 12:24:26 2010 +0100
369.3 @@ -349,11 +349,6 @@
369.4 nextAction.setEnabled(false);
369.5 }
369.6 prevAction.setEnabled(currentIndex > 0 || currentDifferenceIndex > 0);
369.7 -
369.8 - if (splitPane != null) {
369.9 - dividerSet = false;
369.10 - updateSplitLocation();
369.11 - }
369.12 }
369.13
369.14 @Override
369.15 @@ -377,6 +372,7 @@
369.16 updateSplitLocation();
369.17 }
369.18 });
369.19 + return;
369.20 }
369.21 dividerSet = true;
369.22 JTable jt = fileTable.getTable();
369.23 @@ -729,6 +725,10 @@
369.24 if (currentModelIndex == fi) {
369.25 setDiffIndex(currentIndex, 0);
369.26 }
369.27 + if (splitPane != null) {
369.28 + dividerSet = false;
369.29 + updateSplitLocation();
369.30 + }
369.31 }
369.32 });
369.33 } catch (IOException e) {
370.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
370.2 +++ b/nbbuild/antsrc/org/netbeans/nbbuild/MakeOSGi.java Mon Feb 01 12:24:26 2010 +0100
370.3 @@ -0,0 +1,378 @@
370.4 +/*
370.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
370.6 + *
370.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
370.8 + *
370.9 + * The contents of this file are subject to the terms of either the GNU
370.10 + * General Public License Version 2 only ("GPL") or the Common
370.11 + * Development and Distribution License("CDDL") (collectively, the
370.12 + * "License"). You may not use this file except in compliance with the
370.13 + * License. You can obtain a copy of the License at
370.14 + * http://www.netbeans.org/cddl-gplv2.html
370.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
370.16 + * specific language governing permissions and limitations under the
370.17 + * License. When distributing the software, include this License Header
370.18 + * Notice in each file and include the License file at
370.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
370.20 + * particular file as subject to the "Classpath" exception as provided
370.21 + * by Sun in the GPL Version 2 section of the License file that
370.22 + * accompanied this code. If applicable, add the following below the
370.23 + * License Header, with the fields enclosed by brackets [] replaced by
370.24 + * your own identifying information:
370.25 + * "Portions Copyrighted [year] [name of copyright owner]"
370.26 + *
370.27 + * If you wish your version of this file to be governed by only the CDDL
370.28 + * or only the GPL Version 2, indicate your decision by adding
370.29 + * "[Contributor] elects to include this software in this distribution
370.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
370.31 + * single choice of license, a recipient has the option to distribute
370.32 + * your version of this file under either the CDDL, the GPL Version 2 or
370.33 + * to extend the choice of license to its licensees as provided above.
370.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
370.35 + * Version 2 license, then the option applies only if the new code is
370.36 + * made subject to such option by the copyright holder.
370.37 + *
370.38 + * Contributor(s):
370.39 + *
370.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
370.41 + */
370.42 +
370.43 +package org.netbeans.nbbuild;
370.44 +
370.45 +import java.io.ByteArrayOutputStream;
370.46 +import java.io.File;
370.47 +import java.io.FileInputStream;
370.48 +import java.io.FileOutputStream;
370.49 +import java.io.IOException;
370.50 +import java.io.InputStream;
370.51 +import java.io.OutputStream;
370.52 +import java.net.URI;
370.53 +import java.util.ArrayList;
370.54 +import java.util.Enumeration;
370.55 +import java.util.HashMap;
370.56 +import java.util.HashSet;
370.57 +import java.util.Iterator;
370.58 +import java.util.List;
370.59 +import java.util.Map;
370.60 +import java.util.Properties;
370.61 +import java.util.Set;
370.62 +import java.util.jar.Attributes;
370.63 +import java.util.jar.JarFile;
370.64 +import java.util.jar.JarOutputStream;
370.65 +import java.util.jar.Manifest;
370.66 +import java.util.regex.Matcher;
370.67 +import java.util.regex.Pattern;
370.68 +import java.util.zip.CRC32;
370.69 +import java.util.zip.ZipEntry;
370.70 +import java.util.zip.ZipOutputStream;
370.71 +import org.apache.tools.ant.BuildException;
370.72 +import org.apache.tools.ant.Project;
370.73 +import org.apache.tools.ant.Task;
370.74 +import org.apache.tools.ant.types.ResourceCollection;
370.75 +import org.apache.tools.ant.types.resources.FileResource;
370.76 +import org.w3c.dom.Document;
370.77 +import org.w3c.dom.Element;
370.78 +import org.w3c.dom.NodeList;
370.79 +import org.xml.sax.InputSource;
370.80 +
370.81 +/**
370.82 + * Converts a set of NetBeans modules into OSGi bundles.
370.83 + */
370.84 +public class MakeOSGi extends Task {
370.85 +
370.86 + private File destdir;
370.87 + private List<ResourceCollection> modules = new ArrayList<ResourceCollection>();
370.88 +
370.89 + /**
370.90 + * Mandatory destination directory. Bundles will be created here.
370.91 + */
370.92 + public void setDestdir(File destdir) {
370.93 + this.destdir = destdir;
370.94 + }
370.95 +
370.96 + /**
370.97 + * Adds a set of module JARs.
370.98 + * It is permitted for them to be JARs anywhere on disk,
370.99 + * but it is best if they are in a cluster structure
370.100 + * with ../update_tracking/*.xml present
370.101 + * so that associated files can be included in the bundle.
370.102 + */
370.103 + public void add(ResourceCollection modules) {
370.104 + this.modules.add(modules);
370.105 + }
370.106 +
370.107 + public @Override void execute() throws BuildException {
370.108 + if (destdir == null) {
370.109 + throw new BuildException("missing destdir");
370.110 + }
370.111 + for (ResourceCollection rc : modules) {
370.112 + Iterator it = rc.iterator();
370.113 + while (it.hasNext()) {
370.114 + File jar = ((FileResource) it.next()).getFile();
370.115 + try {
370.116 + process(jar);
370.117 + } catch (Exception x) {
370.118 + throw new BuildException("Could not process " + jar + ": " + x, x, getLocation());
370.119 + }
370.120 + }
370.121 + }
370.122 + }
370.123 +
370.124 + private void process(File module) throws Exception {
370.125 + JarFile jar = new JarFile(module);
370.126 + try {
370.127 + Manifest netbeans = jar.getManifest();
370.128 + Manifest osgi = new Manifest();
370.129 + if (netbeans.getMainAttributes().getValue("Bundle-SymbolicName") != null) {
370.130 + // XXX copy it as is!
370.131 + }
370.132 + osgi.getMainAttributes().putValue("Manifest-Version", "1.0"); // workaround for JDK bug
370.133 + osgi.getMainAttributes().putValue("Bundle-ManifestVersion", "2");
370.134 + String codename = netbeans.getMainAttributes().getValue("OpenIDE-Module");
370.135 + String cnb = codename.replaceFirst("/\\d+$", "");
370.136 + if (cnb.equals("org.netbeans.core.netigso")) {
370.137 + // special handling...
370.138 + netbeans.getMainAttributes().remove(new Attributes.Name("OpenIDE-Module-Install"));
370.139 + netbeans.getMainAttributes().remove(new Attributes.Name("Class-Path"));
370.140 + osgi.getMainAttributes().putValue("Bundle-Activator", "org.netbeans.core.osgi.Activator");
370.141 + osgi.getMainAttributes().putValue("Import-Package", "org.osgi.framework, org.osgi.framework.launch, org.osgi.service.url");
370.142 + }
370.143 + osgi.getMainAttributes().putValue("Bundle-SymbolicName", cnb);
370.144 + String spec = netbeans.getMainAttributes().getValue("OpenIDE-Module-Specification-Version");
370.145 + String bundleVersion = null;
370.146 + if (spec != null) {
370.147 + bundleVersion = threeDotsWithMajor(spec, codename);
370.148 + String buildVersion = netbeans.getMainAttributes().getValue("OpenIDE-Module-Build-Version");
370.149 + if (buildVersion == null) {
370.150 + buildVersion = netbeans.getMainAttributes().getValue("OpenIDE-Module-Implementation-Version");
370.151 + }
370.152 + if (buildVersion != null) {
370.153 + bundleVersion += "." + buildVersion.replaceAll("[^a-zA-Z0-9_-]", "_");
370.154 + }
370.155 + osgi.getMainAttributes().putValue("Bundle-Version", bundleVersion);
370.156 + }
370.157 + File bundleFile = new File(destdir, cnb + (bundleVersion != null ? "-" + bundleVersion : "") + ".jar");
370.158 + if (bundleFile.lastModified() > module.lastModified()) {
370.159 + log("Skipping " + module + " since " + bundleFile + " is newer", Project.MSG_VERBOSE);
370.160 + return;
370.161 + }
370.162 + log("Processing " + module + " into " + bundleFile);
370.163 + String pp = netbeans.getMainAttributes().getValue("OpenIDE-Module-Public-Packages");
370.164 + if (pp != null && !pp.equals("-")) {
370.165 + // XXX handle .** (subpackages)
370.166 + // XXX if have an integer OpenIDE-Module-Specification-Version, export all packages
370.167 + osgi.getMainAttributes().putValue("Export-Package", pp.replaceAll("\\.\\*", ""));
370.168 + // OpenIDE-Module-Friends is ignored since OSGi has no apparent equivalent
370.169 + }
370.170 + for (String attrToCopy : new String[] {"OpenIDE-Module-Layer", "OpenIDE-Module-Install"}) {
370.171 + String val = netbeans.getMainAttributes().getValue(attrToCopy);
370.172 + if (val != null) {
370.173 + osgi.getMainAttributes().putValue(attrToCopy, val);
370.174 + }
370.175 + }
370.176 + StringBuilder requireBundles = new StringBuilder();
370.177 + /* XXX does not work, perhaps because of cyclic dependencies:
370.178 + // do not need to import any API, just need it to be started:
370.179 + requireBundles.append("org.netbeans.core.netigso");
370.180 + */
370.181 + String dependencies = netbeans.getMainAttributes().getValue("OpenIDE-Module-Module-Dependencies");
370.182 + if (dependencies != null) {
370.183 + for (String dependency : dependencies.split(" *, *")) {
370.184 + if (requireBundles.length() > 0) {
370.185 + requireBundles.append(", ");
370.186 + }
370.187 + translateDependency(requireBundles, dependency);
370.188 + }
370.189 + }
370.190 + if (requireBundles.length() > 0) {
370.191 + osgi.getMainAttributes().putValue("Require-Bundle", requireBundles.toString());
370.192 + }
370.193 + // XXX OpenIDE-Module-Java-Dependencies => Bundle-RequiredExecutionEnvironment: JavaSE-1.6
370.194 + // XXX OpenIDE-Module-Package-Dependencies => Import-Package
370.195 + // OpenIDE-Module-{Provides,Requires,Needs} are ignored since OSGi has no apparent equivalent
370.196 + // (achievable by exposing generic provide/require mechanisms of Felix and/or Equinox,
370.197 + // but this would not be part of the OSGi R4.1 spec, but could be raised as an issue for R5 since it was discussed for R4)
370.198 + // autoload, eager status are ignored since OSGi has no apparent equivalent
370.199 + Properties localizedStrings = new Properties();
370.200 + String locbundle = netbeans.getMainAttributes().getValue("OpenIDE-Module-Localizing-Bundle");
370.201 + if (locbundle != null) {
370.202 + InputStream is = jar.getInputStream(jar.getEntry(locbundle));
370.203 + try {
370.204 + localizedStrings.load(is);
370.205 + } finally {
370.206 + is.close();
370.207 + }
370.208 + osgi.getMainAttributes().putValue("Bundle-Localization", locbundle.replaceFirst("[.]properties$", ""));
370.209 + }
370.210 + handleDisplayAttribute(localizedStrings, netbeans.getMainAttributes(), osgi.getMainAttributes(),
370.211 + "OpenIDE-Module-Name", "Bundle-Name");
370.212 + handleDisplayAttribute(localizedStrings, netbeans.getMainAttributes(), osgi.getMainAttributes(),
370.213 + "OpenIDE-Module-Display-Category", "Bundle-Category");
370.214 + handleDisplayAttribute(localizedStrings, netbeans.getMainAttributes(), osgi.getMainAttributes(),
370.215 + "OpenIDE-Module-Short-Description", "Bundle-Description");
370.216 + Map<String,File> bundledFiles = findBundledFiles(module, cnb);
370.217 + // XXX any use for OpenIDE-Module-Long-Description?
370.218 + String classPath = netbeans.getMainAttributes().getValue("Class-Path");
370.219 + if (classPath != null) {
370.220 + StringBuilder bundleCP = new StringBuilder();
370.221 + for (String entry : classPath.split("[, ]+")) {
370.222 + String clusterPath = new URI(module.getParentFile().getName() + "/" + entry).normalize().toString();
370.223 + if (bundledFiles.containsKey(clusterPath)) {
370.224 + bundleCP.append("/OSGI-INF/files/").append(clusterPath).append(",");
370.225 + } else {
370.226 + log("Class-Path entry " + entry + " from " + module + " does not correspond to any apparent cluster file", Project.MSG_WARN);
370.227 + }
370.228 + }
370.229 + osgi.getMainAttributes().putValue("Bundle-Classpath", bundleCP + ".");
370.230 + }
370.231 + // XXX modules/lib/*.dll/so => Bundle-NativeCode (but syntax is rather complex)
370.232 + OutputStream bundle = new FileOutputStream(bundleFile);
370.233 + try {
370.234 + ZipOutputStream zos = new JarOutputStream(bundle, osgi);
370.235 + Set<String> parents = new HashSet<String>();
370.236 + Enumeration<? extends ZipEntry> entries = jar.entries();
370.237 + while (entries.hasMoreElements()) {
370.238 + ZipEntry entry = entries.nextElement();
370.239 + String path = entry.getName();
370.240 + if (path.endsWith("/") || path.equals("META-INF/MANIFEST.MF")) {
370.241 + continue;
370.242 + }
370.243 + InputStream is = jar.getInputStream(entry);
370.244 + try {
370.245 + writeEntry(zos, path, is, parents);
370.246 + } finally {
370.247 + is.close();
370.248 + }
370.249 + }
370.250 + for (Map.Entry<String,File> bundledFile : bundledFiles.entrySet()) {
370.251 + InputStream is = new FileInputStream(bundledFile.getValue());
370.252 + try {
370.253 + // XXX need matching IFL impl in netigso
370.254 + writeEntry(zos, "OSGI-INF/files/" + bundledFile.getKey(), is, parents);
370.255 + } finally {
370.256 + is.close();
370.257 + }
370.258 + }
370.259 + zos.finish();
370.260 + zos.close();
370.261 + } finally {
370.262 + bundle.close();
370.263 + }
370.264 + } finally {
370.265 + jar.close();
370.266 + }
370.267 + }
370.268 +
370.269 + private static void writeEntry(ZipOutputStream zos, String path, InputStream data, Set<String> parents) throws IOException {
370.270 + int size = Math.max(data.available(), 100);
370.271 + ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
370.272 + byte[] buf = new byte[size];
370.273 + int read;
370.274 + while ((read = data.read(buf)) != -1) {
370.275 + baos.write(buf, 0, read);
370.276 + }
370.277 + writeEntry(zos, path, baos.toByteArray(), parents);
370.278 + }
370.279 + private static void writeEntry(ZipOutputStream zos, String path, byte[] data, Set<String> parents) throws IOException {
370.280 + assert path.length() > 0 && !path.endsWith("/") && !path.startsWith("/") && path.indexOf("//") == -1 : path;
370.281 + for (int i = 0; i < path.length(); i++) {
370.282 + if (path.charAt(i) == '/') {
370.283 + String parent = path.substring(0, i + 1);
370.284 + if (parents.add(parent)) {
370.285 + ZipEntry ze = new ZipEntry(parent);
370.286 + ze.setMethod(ZipEntry.STORED);
370.287 + ze.setSize(0);
370.288 + ze.setCrc(0);
370.289 + zos.putNextEntry(ze);
370.290 + zos.closeEntry();
370.291 + }
370.292 + }
370.293 + }
370.294 + ZipEntry ze = new ZipEntry(path);
370.295 + ze.setMethod(ZipEntry.STORED);
370.296 + ze.setSize(data.length);
370.297 + CRC32 crc = new CRC32();
370.298 + crc.update(data);
370.299 + ze.setCrc(crc.getValue());
370.300 + zos.putNextEntry(ze);
370.301 + zos.write(data, 0, data.length);
370.302 + zos.closeEntry();
370.303 + }
370.304 +
370.305 + // copied from NetigsoModuleFactory
370.306 + private static String threeDotsWithMajor(String version, String withMajor) {
370.307 + int indx = withMajor.indexOf('/');
370.308 + int major = 0;
370.309 + if (indx > 0) {
370.310 + major = Integer.parseInt(withMajor.substring(indx + 1));
370.311 + }
370.312 + String[] segments = (version + ".0.0.0").split("\\.");
370.313 + assert segments.length >= 3 && segments[0].length() > 0;
370.314 + return (Integer.parseInt(segments[0]) + major * 100) + "." + segments[1] + "." + segments[2];
370.315 + }
370.316 +
370.317 + static void translateDependency(StringBuilder b, String dependency) throws IOException {
370.318 + Matcher m = Pattern.compile("([^/ >=]+)(?:/(\\d+)(?:-(\\d+))?)? *(?:(=|>) *(.+))?").matcher(dependency);
370.319 + if (!m.matches()) {
370.320 + throw new IOException("bad dep: " + dependency);
370.321 + }
370.322 + String depCnb = m.group(1);
370.323 + String depMajLo = m.group(2);
370.324 + String depMajHi = m.group(3);
370.325 + String comparison = m.group(4);
370.326 + String version = m.group(5);
370.327 + b.append(depCnb);
370.328 + if (!"=".equals(comparison)) {
370.329 + if (version == null) {
370.330 + version = "0";
370.331 + }
370.332 + String targetVersion = threeDotsWithMajor(version, depMajLo == null ? "" : "x/" + depMajLo);
370.333 + b.append(";bundle-version=\"[").append(targetVersion).append(",");
370.334 + b.append(100 * (Integer.parseInt(targetVersion.replaceFirst("[.].+", "")) / 100 + 1));
370.335 + b.append(")\"");
370.336 + }
370.337 + }
370.338 +
370.339 + private void handleDisplayAttribute(Properties props, Attributes netbeans, Attributes osgi, String netbeansHeader, String osgiHeader) throws IOException {
370.340 + String val = netbeans.getValue(netbeansHeader);
370.341 + if (val != null) {
370.342 + osgi.putValue(osgiHeader, val);
370.343 + } else if (props.containsKey(netbeansHeader)) {
370.344 + osgi.putValue(osgiHeader, "%" + netbeansHeader);
370.345 + }
370.346 + }
370.347 +
370.348 + private Map<String,File> findBundledFiles(File module, String cnb) throws Exception {
370.349 + Map<String,File> result = new HashMap<String,File>();
370.350 + if (module.getParentFile().getName().matches("modules|core|lib")) {
370.351 + File cluster = module.getParentFile().getParentFile();
370.352 + File updateTracking = new File(new File(cluster, "update_tracking"), cnb.replace('.', '-') + ".xml");
370.353 + if (updateTracking.isFile()) {
370.354 + Document doc = XMLUtil.parse(new InputSource(updateTracking.toURI().toString()), false, false, null, null);
370.355 + NodeList nl = doc.getElementsByTagName("file");
370.356 + for (int i = 0; i < nl.getLength(); i++) {
370.357 + String path = ((Element) nl.item(i)).getAttribute("name");
370.358 + if (path.matches("config/Modules/.+[.]xml")) {
370.359 + continue;
370.360 + }
370.361 + File f = new File(cluster, path);
370.362 + if (f.equals(module)) {
370.363 + continue;
370.364 + }
370.365 + // XXX exclude lib/nbexec{,.dll,.exe}, core/*felix*.jar
370.366 + if (f.isFile()) {
370.367 + result.put(path, f);
370.368 + } else {
370.369 + log("did not find " + f + " specified in " + updateTracking, Project.MSG_WARN);
370.370 + }
370.371 + }
370.372 + } else {
370.373 + log("did not find expected " + updateTracking, Project.MSG_WARN);
370.374 + }
370.375 + } else {
370.376 + log("JAR " + module + " not found in expected cluster layout", Project.MSG_WARN);
370.377 + }
370.378 + return result;
370.379 + }
370.380 +
370.381 +}
371.1 --- a/nbbuild/cluster.properties Mon Feb 01 12:23:06 2010 +0100
371.2 +++ b/nbbuild/cluster.properties Mon Feb 01 12:24:26 2010 +0100
371.3 @@ -1250,7 +1250,6 @@
371.4 contrib/spellchecker.dictionary_en,\
371.5 contrib/spellchecker.kit,\
371.6 contrib/spi.actions.support,\
371.7 - contrib/stackanalyzer,\
371.8 contrib/suggestions_framework,\
371.9 contrib/sysprops,\
371.10 contrib/tasklist.bugs,\
372.1 --- a/nbbuild/sierra/build.pro Mon Feb 01 12:23:06 2010 +0100
372.2 +++ b/nbbuild/sierra/build.pro Mon Feb 01 12:24:26 2010 +0100
372.3 @@ -43,7 +43,7 @@
372.4 <property environment="env"/>
372.5
372.6 <property name="netbeans.prox" value="false"/>
372.7 - <property name="netbeans.type" value="java"/>
372.8 + <property name="netbeans.type" value="javase"/>
372.9
372.10 <!-- NetBeans latest nightly -->
372.11 <!-- property name="netbeans.host" value="http://bits.netbeans.org"/ -->
373.1 --- a/nbbuild/sierra/build.xml Mon Feb 01 12:23:06 2010 +0100
373.2 +++ b/nbbuild/sierra/build.xml Mon Feb 01 12:24:26 2010 +0100
373.3 @@ -99,15 +99,12 @@
373.4 <zip destfile="${cache}/latest/${sierra.build}_${env.BUILD_NUMBER}_${time.stamp}.zip">
373.5 <zipfileset dir="${home}/nbbuild">
373.6 <include name="netbeans/bin/**"/>
373.7 - <include name="netbeans/enterprise/**"/>
373.8 <include name="netbeans/etc/**"/>
373.9 <include name="netbeans/harness/**"/>
373.10 <include name="netbeans/ide/**"/>
373.11 <include name="netbeans/java/**"/>
373.12 <include name="netbeans/nb/**"/>
373.13 <include name="netbeans/platform/**"/>
373.14 - <include name="netbeans/soa/**"/>
373.15 - <include name="netbeans/websvccommon/**"/>
373.16 <include name="netbeans/xml/**"/>
373.17 <exclude name="netbeans/**/.lastModified"/>
373.18 </zipfileset>
374.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
374.2 +++ b/nbbuild/test/unit/src/org/netbeans/nbbuild/MakeOSGiTest.java Mon Feb 01 12:24:26 2010 +0100
374.3 @@ -0,0 +1,64 @@
374.4 +/*
374.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
374.6 + *
374.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
374.8 + *
374.9 + * The contents of this file are subject to the terms of either the GNU
374.10 + * General Public License Version 2 only ("GPL") or the Common
374.11 + * Development and Distribution License("CDDL") (collectively, the
374.12 + * "License"). You may not use this file except in compliance with the
374.13 + * License. You can obtain a copy of the License at
374.14 + * http://www.netbeans.org/cddl-gplv2.html
374.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
374.16 + * specific language governing permissions and limitations under the
374.17 + * License. When distributing the software, include this License Header
374.18 + * Notice in each file and include the License file at
374.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
374.20 + * particular file as subject to the "Classpath" exception as provided
374.21 + * by Sun in the GPL Version 2 section of the License file that
374.22 + * accompanied this code. If applicable, add the following below the
374.23 + * License Header, with the fields enclosed by brackets [] replaced by
374.24 + * your own identifying information:
374.25 + * "Portions Copyrighted [year] [name of copyright owner]"
374.26 + *
374.27 + * If you wish your version of this file to be governed by only the CDDL
374.28 + * or only the GPL Version 2, indicate your decision by adding
374.29 + * "[Contributor] elects to include this software in this distribution
374.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
374.31 + * single choice of license, a recipient has the option to distribute
374.32 + * your version of this file under either the CDDL, the GPL Version 2 or
374.33 + * to extend the choice of license to its licensees as provided above.
374.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
374.35 + * Version 2 license, then the option applies only if the new code is
374.36 + * made subject to such option by the copyright holder.
374.37 + *
374.38 + * Contributor(s):
374.39 + *
374.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
374.41 + */
374.42 +
374.43 +package org.netbeans.nbbuild;
374.44 +
374.45 +import org.netbeans.junit.NbTestCase;
374.46 +
374.47 +public class MakeOSGiTest extends NbTestCase {
374.48 +
374.49 + public MakeOSGiTest(String n) {
374.50 + super(n);
374.51 + }
374.52 +
374.53 + public void testTranslateDependency() throws Exception {
374.54 + assertTranslateDependency("org.openide.util;bundle-version=\"[8.0.0,100)\"", "org.openide.util > 8.0");
374.55 + assertTranslateDependency("org.netbeans.modules.lexer;bundle-version=\"[201.4.0,300)\"", "org.netbeans.modules.lexer/2 > 1.4");
374.56 + assertTranslateDependency("what.ever;bundle-version=\"[0.0.0,100)\"", "what.ever");
374.57 + assertTranslateDependency("org.netbeans.modules.java.sourceui", "org.netbeans.modules.java.sourceui = 15");
374.58 + // XXX interpret depMajHi, e.g. /0-1 > 1.7 => [1.7.0,200)
374.59 + // XXX 3 or more items in sequence
374.60 + }
374.61 + private void assertTranslateDependency(String expected, String dependency) throws Exception {
374.62 + StringBuilder b = new StringBuilder();
374.63 + MakeOSGi.translateDependency(b, dependency);
374.64 + assertEquals(expected, b.toString());
374.65 + }
374.66 +
374.67 +}
375.1 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/Utils.java Mon Feb 01 12:23:06 2010 +0100
375.2 +++ b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/Utils.java Mon Feb 01 12:24:26 2010 +0100
375.3 @@ -835,13 +835,93 @@
375.4
375.5 return handleProcess(process);
375.6 }
375.7 +
375.8 + private static int getPermissionsAnalized(final File file) {
375.9 + if (file.isDirectory()) {
375.10 + return getIntegerValue(DEFAULT_PERMISSION_DIR_PROP, DEFAULT_PERMISSION_DIR);
375.11 +
375.12 + } else {
375.13 + return isExecutableAnalized(file) ?
375.14 + getIntegerValue(DEFAULT_EXECUTABLE_PERMISSION_FILE_PROP, DEFAULT_EXECUTABLE_PERMISSION_FILE) :
375.15 + getIntegerValue(DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE_PROP, DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE);
375.16 + }
375.17 + }
375.18 + private static final int getIntegerValue(String prop, int defaultValue) {
375.19 + int result = defaultValue;
375.20 + String value = project.getProperty(prop);
375.21 + if (value != null && !value.equals("")) {
375.22 + try {
375.23 + result = Integer.parseInt(value);
375.24 + } catch (NumberFormatException e) {
375.25 + if (project != null) {
375.26 + project.log("Error while parsing property " + prop
375.27 + + " which value is [" + value + "]"
375.28 + + " but should be integer", e, Project.MSG_WARN);
375.29 + }
375.30 + }
375.31 + }
375.32 + return result;
375.33 + }
375.34 +
375.35 + private static final boolean isExecutableAnalized(File file) {
375.36 + int index = file.getName().lastIndexOf(".");
375.37 + String ext = (index != -1) ? file.getName().substring(index + 1) : "";
375.38 +
375.39 + for (String e : EXECUTABLE_EXTENSIONS) {
375.40 + if (ext.equals(e)) {
375.41 + return true;
375.42 + }
375.43 + }
375.44 + for (String e : NOT_EXECUTABLE_EXTENSIONS) {
375.45 + if (ext.equals(e)) {
375.46 + return false;
375.47 + }
375.48 + }
375.49 +
375.50 + FileInputStream fis = null;
375.51 + try {
375.52 + fis = new FileInputStream(file);
375.53 + byte[] bytes = new byte[64];
375.54 +
375.55 + int c;
375.56 + c = fis.read(bytes);
375.57 + if (c >= 4) { // length of ELF header and min length of "#!/X" string
375.58 + if (bytes[0] == '\177'
375.59 + && bytes[1] == 'E'
375.60 + && bytes[2] == 'L'
375.61 + && bytes[3] == 'F') {
375.62 + return true;
375.63 + } else if (bytes[0] == '#' && bytes[1] == '!') {
375.64 + String s = new String(bytes, 0, c);
375.65 + String[] array = s.split("(?:\r\n|\n|\r)");
375.66 +
375.67 + if (array.length > 0) {
375.68 + //read the first line only
375.69 + //allow lines like "#! /bin/sh"
375.70 + if (array[0].replaceAll("#!(\\s)+/", "#!/").startsWith("#!/")) {
375.71 + return true;
375.72 + }
375.73 + }
375.74 + }
375.75 + }
375.76 + } catch (IOException e) {
375.77 + if(fis!=null) {
375.78 + try {
375.79 + fis.close();
375.80 + } catch (IOException ex) {
375.81 + }
375.82 + }
375.83 + }
375.84 +
375.85 + return false;
375.86 + }
375.87
375.88 public static int getPermissions(final File file) {
375.89 try {
375.90 final String lsExec = getLsExecutable();
375.91 if (lsExec == null) {
375.92 //no ls found
375.93 - return 777;
375.94 + return getPermissionsAnalized(file);
375.95 }
375.96 final Results results = run(file.getParentFile(), lsExec, "-ld", file.getName());
375.97
375.98 @@ -1426,10 +1506,27 @@
375.99 "jarsigner.executable";
375.100 public static final String VERIFICATION_JAVA_EXECUTABLE_PROPERTY =
375.101 "verification.java.executable";
375.102 +
375.103 + public static final String DEFAULT_EXECUTABLE_PERMISSION_FILE_PROP =
375.104 + "default.file.executable.permissions";
375.105 + public static final String DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE_PROP =
375.106 + "default.file.not.executable.permissions";
375.107 + public static final String DEFAULT_PERMISSION_DIR_PROP =
375.108 + "default.dir.permissions";
375.109
375.110 private static final String JARSIGNER_EXECUTABLE = JAVA_HOME_VALUE +
375.111 ((IS_WINDOWS) ? "\\..\\bin\\jarsigner.exe" : "/../bin/jarsigner");//NOI18N
375.112 private static final String LS_EXECUTABLE =
375.113 (IS_WINDOWS) ? "ls.exe" : "ls";//NOI18N
375.114 public static final String LINE_SEPARATOR = System.getProperty("line.separator");
375.115 +
375.116 + public static final String [] EXECUTABLE_EXTENSIONS =
375.117 + {"so", "a", "jnilib", "dylib", "sl",
375.118 + "sh", "pl", "rb", "py", "command"};
375.119 + public static final String [] NOT_EXECUTABLE_EXTENSIONS =
375.120 + {"jar", "zip", "gz", "bzip2", "tgz", "txt", "xml",
375.121 + "html", "htm", "pdf", "conf", "css", "java"};
375.122 + public static final int DEFAULT_EXECUTABLE_PERMISSION_FILE = 755;//rwx r-x r-x
375.123 + public static final int DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE = 644;//rwx r-- r--
375.124 + public static final int DEFAULT_PERMISSION_DIR = 755; //rwx r-x r-x
375.125 }
376.1 --- a/openide.explorer/src/org/openide/explorer/propertysheet/BaseTable.java Mon Feb 01 12:23:06 2010 +0100
376.2 +++ b/openide.explorer/src/org/openide/explorer/propertysheet/BaseTable.java Mon Feb 01 12:24:26 2010 +0100
376.3 @@ -54,6 +54,7 @@
376.4 import java.awt.Font;
376.5 import java.awt.FontMetrics;
376.6 import java.awt.Graphics;
376.7 +import java.awt.GraphicsEnvironment;
376.8 import java.awt.Insets;
376.9 import java.awt.KeyboardFocusManager;
376.10 import java.awt.Point;
376.11 @@ -229,6 +230,7 @@
376.12 InputMap imp = getInputMap();
376.13 ActionMap am = getActionMap();
376.14
376.15 + if (!GraphicsEnvironment.isHeadless()) {
376.16 //Issue 37919, reinstate support for up/down cycle focus transfer.
376.17 //being focus cycle root mangles this in some dialogs
376.18 imp.put(
376.19 @@ -240,6 +242,7 @@
376.20 KeyStroke.getKeyStroke(KeyEvent.VK_TAB, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false),
376.21 ACTION_FOCUS_NEXT
376.22 );
376.23 + }
376.24
376.25 Action ctrlTab = new CTRLTabAction();
376.26 am.put(ACTION_FOCUS_NEXT, ctrlTab);
377.1 --- a/parsing.api/apichanges.xml Mon Feb 01 12:23:06 2010 +0100
377.2 +++ b/parsing.api/apichanges.xml Mon Feb 01 12:24:26 2010 +0100
377.3 @@ -107,6 +107,21 @@
377.4 <!-- ACTUAL CHANGES BEGIN HERE: -->
377.5
377.6 <changes>
377.7 + <change id="adding-PathRecognizerRegistration-annotation">
377.8 + <api name="ParsingAPI"/>
377.9 + <summary>Adding PathRecognizerRegistration annotation</summary>
377.10 + <version major="1" minor="32"/>
377.11 + <date day="26" month="1" year="2010"/>
377.12 + <author login="vstejskal"/>
377.13 + <compatibility source="compatible" binary="compatible" semantic="compatible" deletion="no" addition="yes" modification="no"/>
377.14 + <description>
377.15 + <p>
377.16 + Added <code>PathRecognizerRegistration</code> annotation that simplyfies registering <code>PathRecognizer</code>s.
377.17 + </p>
377.18 + </description>
377.19 + <class package="org.netbeans.modules.parsing.spi.indexing" name="PathRecognizerRegistration"/>
377.20 + <issue number="169991"/>
377.21 + </change>
377.22 <change id="errors-cache">
377.23 <api name="ParsingAPI"/>
377.24 <summary>Adding ErrorsCache</summary>
378.1 --- a/parsing.api/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
378.2 +++ b/parsing.api/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
378.3 @@ -2,4 +2,4 @@
378.4 javac.source=1.6
378.5 javadoc.apichanges=${basedir}/apichanges.xml
378.6 javadoc.arch=${basedir}/arch.xml
378.7 -spec.version.base=1.31.0
378.8 +spec.version.base=1.32.0
379.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
379.2 +++ b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/DefaultPathRecognizer.java Mon Feb 01 12:24:26 2010 +0100
379.3 @@ -0,0 +1,165 @@
379.4 +/*
379.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
379.6 + *
379.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
379.8 + *
379.9 + * The contents of this file are subject to the terms of either the GNU
379.10 + * General Public License Version 2 only ("GPL") or the Common
379.11 + * Development and Distribution License("CDDL") (collectively, the
379.12 + * "License"). You may not use this file except in compliance with the
379.13 + * License. You can obtain a copy of the License at
379.14 + * http://www.netbeans.org/cddl-gplv2.html
379.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
379.16 + * specific language governing permissions and limitations under the
379.17 + * License. When distributing the software, include this License Header
379.18 + * Notice in each file and include the License file at
379.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
379.20 + * particular file as subject to the "Classpath" exception as provided
379.21 + * by Sun in the GPL Version 2 section of the License file that
379.22 + * accompanied this code. If applicable, add the following below the
379.23 + * License Header, with the fields enclosed by brackets [] replaced by
379.24 + * your own identifying information:
379.25 + * "Portions Copyrighted [year] [name of copyright owner]"
379.26 + *
379.27 + * If you wish your version of this file to be governed by only the CDDL
379.28 + * or only the GPL Version 2, indicate your decision by adding
379.29 + * "[Contributor] elects to include this software in this distribution
379.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
379.31 + * single choice of license, a recipient has the option to distribute
379.32 + * your version of this file under either the CDDL, the GPL Version 2 or
379.33 + * to extend the choice of license to its licensees as provided above.
379.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
379.35 + * Version 2 license, then the option applies only if the new code is
379.36 + * made subject to such option by the copyright holder.
379.37 + *
379.38 + * Contributor(s):
379.39 + *
379.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
379.41 + */
379.42 +
379.43 +package org.netbeans.modules.parsing.impl.indexing;
379.44 +
379.45 +import java.util.Collections;
379.46 +import java.util.HashSet;
379.47 +import java.util.Map;
379.48 +import java.util.Set;
379.49 +import java.util.logging.Level;
379.50 +import java.util.logging.Logger;
379.51 +import org.netbeans.api.editor.mimelookup.MimePath;
379.52 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
379.53 +
379.54 +/**
379.55 + *
379.56 + * @author vita
379.57 + */
379.58 +public final class DefaultPathRecognizer extends PathRecognizer {
379.59 +
379.60 + // ------------------------------------------------------------------------
379.61 + // PathRecognizer implementation
379.62 + // ------------------------------------------------------------------------
379.63 +
379.64 + @Override
379.65 + public Set<String> getSourcePathIds() {
379.66 + return sourcePathIds;
379.67 + }
379.68 +
379.69 + @Override
379.70 + public Set<String> getBinaryLibraryPathIds() {
379.71 + return binaryLibraryPathIds;
379.72 + }
379.73 +
379.74 + @Override
379.75 + public Set<String> getLibraryPathIds() {
379.76 + return libraryPathIds;
379.77 + }
379.78 +
379.79 + @Override
379.80 + public Set<String> getMimeTypes() {
379.81 + return mimeTypes;
379.82 + }
379.83 +
379.84 + // ------------------------------------------------------------------------
379.85 + // Public implementation
379.86 + // ------------------------------------------------------------------------
379.87 +
379.88 + public static PathRecognizer createInstance(Map fileAttributes) {
379.89 +
379.90 + // path ids
379.91 + Set<String> sourcePathIds = readIdsAttribute(fileAttributes, "sourcePathIds"); //NOI18N
379.92 + Set<String> libraryPathIds = readIdsAttribute(fileAttributes, "libraryPathIds"); //NOI18N
379.93 + Set<String> binaryLibraryPathIds = readIdsAttribute(fileAttributes, "binaryLibraryPathIds"); //NOI18N
379.94 +
379.95 + // mime types
379.96 + Set<String> mimeTypes = new HashSet<String>();
379.97 + Object mts = fileAttributes.get("mimeTypes"); //NOI18N
379.98 + if (mts instanceof String) {
379.99 + String [] arr = ((String) mts).split(","); //NOI18N
379.100 + for(String mt : arr) {
379.101 + mt = mt.trim();
379.102 + if (mt.length() > 0 && MimePath.validate(mt)) {
379.103 + mimeTypes.add(mt);
379.104 + } else {
379.105 + LOG.log(Level.WARNING, "Invalid mimetype {0}, ignoring.", mt); //NOI18N
379.106 + }
379.107 + }
379.108 + }
379.109 +
379.110 + return new DefaultPathRecognizer(sourcePathIds, libraryPathIds, binaryLibraryPathIds, Collections.unmodifiableSet(mimeTypes));
379.111 + }
379.112 +
379.113 + @Override
379.114 + public String toString() {
379.115 + return super.toString()
379.116 + + "[sourcePathIds=" + sourcePathIds //NOI18N
379.117 + + ", libraryPathIds=" + libraryPathIds //NOI18N
379.118 + + ", binaryLibraryPathIds=" + binaryLibraryPathIds //NOI18N
379.119 + + ", mimeTypes=" + mimeTypes; //NOI18N
379.120 + }
379.121 +
379.122 + // ------------------------------------------------------------------------
379.123 + // Private implementation
379.124 + // ------------------------------------------------------------------------
379.125 +
379.126 + private static final Logger LOG = Logger.getLogger(DefaultPathRecognizer.class.getName());
379.127 +
379.128 + private final Set<String> sourcePathIds;
379.129 + private final Set<String> libraryPathIds;
379.130 + private final Set<String> binaryLibraryPathIds;
379.131 + private final Set<String> mimeTypes;
379.132 +
379.133 + private DefaultPathRecognizer(Set<String> sourcePathIds, Set<String> libraryPathIds, Set<String> binaryLibraryPathIds, Set<String> mimeTypes) {
379.134 + this.sourcePathIds = sourcePathIds;
379.135 + this.libraryPathIds = libraryPathIds;
379.136 + this.binaryLibraryPathIds = binaryLibraryPathIds;
379.137 + this.mimeTypes = mimeTypes;
379.138 + }
379.139 +
379.140 + private static Set<String> readIdsAttribute(Map fileAttributes, String attributeName) {
379.141 + Set<String> ids = new HashSet<String>();
379.142 +
379.143 + Object attributeValue = fileAttributes.get(attributeName); //NOI18N
379.144 + if (attributeValue instanceof String) {
379.145 + String [] varr = ((String) attributeValue).split(","); //NOI18N
379.146 + for(String v : varr) {
379.147 + v = v.trim();
379.148 + if (v.equals("ANY")) { //NOI18N
379.149 + ids = null;
379.150 + break;
379.151 + } else if (v.length() > 0) {
379.152 + ids.add(v);
379.153 + } else {
379.154 + LOG.log(Level.WARNING, "Empty IDs are not alowed in {0} attribute, ignoring.", attributeName); //NOI18N
379.155 + }
379.156 + }
379.157 + } else {
379.158 + if (attributeValue != null) {
379.159 + LOG.log(Level.WARNING, "Invalid {0} attribute value, expecting java.lang.String, but got {1}, {2}", //NOI18N
379.160 + new Object [] { attributeName, attributeValue, attributeValue == null ? null : attributeValue.getClass()});
379.161 + }
379.162 +
379.163 + ids = Collections.<String>emptySet();
379.164 + }
379.165 +
379.166 + return ids == null ? null : Collections.unmodifiableSet(ids);
379.167 + }
379.168 +}
380.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
380.2 +++ b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/PathRecognizerRegistrationProcessor.java Mon Feb 01 12:24:26 2010 +0100
380.3 @@ -0,0 +1,195 @@
380.4 +/*
380.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
380.6 + *
380.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
380.8 + *
380.9 + * The contents of this file are subject to the terms of either the GNU
380.10 + * General Public License Version 2 only ("GPL") or the Common
380.11 + * Development and Distribution License("CDDL") (collectively, the
380.12 + * "License"). You may not use this file except in compliance with the
380.13 + * License. You can obtain a copy of the License at
380.14 + * http://www.netbeans.org/cddl-gplv2.html
380.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
380.16 + * specific language governing permissions and limitations under the
380.17 + * License. When distributing the software, include this License Header
380.18 + * Notice in each file and include the License file at
380.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
380.20 + * particular file as subject to the "Classpath" exception as provided
380.21 + * by Sun in the GPL Version 2 section of the License file that
380.22 + * accompanied this code. If applicable, add the following below the
380.23 + * License Header, with the fields enclosed by brackets [] replaced by
380.24 + * your own identifying information:
380.25 + * "Portions Copyrighted [year] [name of copyright owner]"
380.26 + *
380.27 + * If you wish your version of this file to be governed by only the CDDL
380.28 + * or only the GPL Version 2, indicate your decision by adding
380.29 + * "[Contributor] elects to include this software in this distribution
380.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
380.31 + * single choice of license, a recipient has the option to distribute
380.32 + * your version of this file under either the CDDL, the GPL Version 2 or
380.33 + * to extend the choice of license to its licensees as provided above.
380.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
380.35 + * Version 2 license, then the option applies only if the new code is
380.36 + * made subject to such option by the copyright holder.
380.37 + *
380.38 + * Contributor(s):
380.39 + *
380.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
380.41 + */
380.42 +
380.43 +package org.netbeans.modules.parsing.impl.indexing;
380.44 +
380.45 +import java.util.Set;
380.46 +import javax.annotation.processing.Processor;
380.47 +import javax.annotation.processing.RoundEnvironment;
380.48 +import javax.annotation.processing.SupportedAnnotationTypes;
380.49 +import javax.annotation.processing.SupportedSourceVersion;
380.50 +import javax.lang.model.SourceVersion;
380.51 +import javax.lang.model.element.Element;
380.52 +import javax.lang.model.element.TypeElement;
380.53 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
380.54 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
380.55 +import org.openide.filesystems.annotations.LayerBuilder;
380.56 +import org.openide.filesystems.annotations.LayerBuilder.File;
380.57 +import org.openide.filesystems.annotations.LayerGeneratingProcessor;
380.58 +import org.openide.filesystems.annotations.LayerGenerationException;
380.59 +import org.openide.util.lookup.ServiceProvider;
380.60 +
380.61 +/**
380.62 + *
380.63 + * @author Vita Stejskal
380.64 + */
380.65 +@ServiceProvider(service=Processor.class)
380.66 +@SupportedAnnotationTypes("org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration") //NOI18N
380.67 +@SupportedSourceVersion(SourceVersion.RELEASE_6)
380.68 +public class PathRecognizerRegistrationProcessor extends LayerGeneratingProcessor {
380.69 +
380.70 + @Override
380.71 + protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
380.72 + for(Element e : roundEnv.getElementsAnnotatedWith(PathRecognizerRegistration.class)) {
380.73 + TypeElement cls = (TypeElement) e;
380.74 + PathRecognizerRegistration prr = cls.getAnnotation(PathRecognizerRegistration.class);
380.75 +
380.76 + String sourcePathIds = processIds(prr.sourcePathIds());
380.77 + String libraryPathIds = processIds(prr.libraryPathIds());
380.78 + String binaryLibraryPathIds = processIds(prr.binaryLibraryPathIds());
380.79 + String mimeTypes = processMts(prr.mimeTypes());
380.80 +
380.81 + if (mimeTypes != null && (sourcePathIds != null || libraryPathIds != null || binaryLibraryPathIds != null)) {
380.82 + final LayerBuilder lb = layer(cls);
380.83 + File f = instanceFile(lb,
380.84 + "Services/Hidden/PathRecognizers", //NOI18N
380.85 + makeFilesystemName(cls.getQualifiedName().toString()),
380.86 + DefaultPathRecognizer.class,
380.87 + "createInstance", //NOI18N
380.88 + PathRecognizer.class);
380.89 +
380.90 + if (sourcePathIds != null) {
380.91 + f.stringvalue("sourcePathIds", sourcePathIds); //NOI18N
380.92 + }
380.93 + if (libraryPathIds != null) {
380.94 + f.stringvalue("libraryPathIds", libraryPathIds); //NOI18N
380.95 + }
380.96 + if (binaryLibraryPathIds != null) {
380.97 + f.stringvalue("binaryLibraryPathIds", binaryLibraryPathIds); //NOI18N
380.98 + }
380.99 + if (mimeTypes != null) {
380.100 + f.stringvalue("mimeTypes", mimeTypes); //NOI18N
380.101 + }
380.102 +
380.103 + f.write();
380.104 + }
380.105 + }
380.106 + return true;
380.107 + }
380.108 +
380.109 + private static String processIds(String [] ids) {
380.110 + if (ids.length == 0) {
380.111 + return null;
380.112 + } else if (ids.length == 1 && ids[0].equals("ANY")) {
380.113 + return "ANY"; //NOI18N
380.114 + } else {
380.115 + StringBuilder sb = new StringBuilder();
380.116 + for(String s : ids) {
380.117 + if (s == null) {
380.118 + continue;
380.119 + }
380.120 +
380.121 + s = s.trim();
380.122 + if (s.length() == 0 || s.equals("ANY")) {
380.123 + continue;
380.124 + }
380.125 +
380.126 + if (sb.length() > 0) {
380.127 + sb.append(','); //NOI18N
380.128 + }
380.129 + sb.append(s);
380.130 + }
380.131 + return sb.length() > 0 ? sb.toString() : null;
380.132 + }
380.133 + }
380.134 +
380.135 + private static String processMts(String [] mts) {
380.136 + if (mts == null || mts.length == 0) {
380.137 + return null;
380.138 + } else {
380.139 + StringBuilder sb = new StringBuilder();
380.140 + for(String s : mts) {
380.141 + if (s == null) {
380.142 + continue;
380.143 + }
380.144 +
380.145 + s = s.trim();
380.146 + if (s.length() == 0) {
380.147 + continue;
380.148 + }
380.149 +
380.150 + if (sb.length() > 0) {
380.151 + sb.append(','); //NOI18N
380.152 + }
380.153 + sb.append(s);
380.154 + }
380.155 + return sb.length() > 0 ? sb.toString() : null;
380.156 + }
380.157 + }
380.158 +
380.159 + private static File instanceFile(LayerBuilder b, String folder, String name, Class implClass, String factoryMethod, Class... instanceOf) {
380.160 + String basename;
380.161 + if (name == null) {
380.162 + basename = implClass.getName().replace('.', '-'); //NOI18N
380.163 + if (factoryMethod != null) {
380.164 + basename += "-" + factoryMethod; //NOI18N
380.165 + }
380.166 + } else {
380.167 + basename = name;
380.168 + }
380.169 +
380.170 + File f = b.file(folder + "/" + basename + ".instance"); //NOI18N
380.171 + if (implClass != null) {
380.172 + if (factoryMethod != null) {
380.173 + f.methodvalue("instanceCreate", implClass.getName(), factoryMethod); //NOI18N
380.174 + } else {
380.175 + f.stringvalue("instanceClass", implClass.getName()); //NOI18N
380.176 + }
380.177 + }
380.178 +
380.179 + for(Class c : instanceOf) {
380.180 + f.stringvalue("instanceOf", c.getName()); //NOI18N
380.181 + }
380.182 +
380.183 + return f;
380.184 + }
380.185 +
380.186 + private static String makeFilesystemName(String s) {
380.187 + StringBuilder sb = new StringBuilder(s.length());
380.188 + for(int i = 0; i < s.length(); i++) {
380.189 + char c = s.charAt(i);
380.190 + if (Character.isLetterOrDigit(c)) {
380.191 + sb.append(c);
380.192 + } else {
380.193 + sb.append("-"); //NOI18N
380.194 + }
380.195 + }
380.196 + return sb.toString();
380.197 + }
380.198 +}
381.1 --- a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/errors/TaskCache.java Mon Feb 01 12:23:06 2010 +0100
381.2 +++ b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/errors/TaskCache.java Mon Feb 01 12:24:26 2010 +0100
381.3 @@ -217,8 +217,8 @@
381.4
381.5 if (modified) {
381.6 c.toRefresh.add(currentFile = new URL(currentFile, "."));
381.7 -
381.8 - while (!root.equals(currentFile)) {
381.9 + final String relativePath = i.getRelativePath();
381.10 + for (int depth = relativePath.split("/").length-1; depth>0; depth--) { //NOI18N
381.11 currentFile = new URL(currentFile, "..");
381.12 c.toRefresh.add(currentFile);
381.13 }
382.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
382.2 +++ b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/PathRecognizerRegistration.java Mon Feb 01 12:24:26 2010 +0100
382.3 @@ -0,0 +1,96 @@
382.4 +/*
382.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
382.6 + *
382.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
382.8 + *
382.9 + * The contents of this file are subject to the terms of either the GNU
382.10 + * General Public License Version 2 only ("GPL") or the Common
382.11 + * Development and Distribution License("CDDL") (collectively, the
382.12 + * "License"). You may not use this file except in compliance with the
382.13 + * License. You can obtain a copy of the License at
382.14 + * http://www.netbeans.org/cddl-gplv2.html
382.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
382.16 + * specific language governing permissions and limitations under the
382.17 + * License. When distributing the software, include this License Header
382.18 + * Notice in each file and include the License file at
382.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
382.20 + * particular file as subject to the "Classpath" exception as provided
382.21 + * by Sun in the GPL Version 2 section of the License file that
382.22 + * accompanied this code. If applicable, add the following below the
382.23 + * License Header, with the fields enclosed by brackets [] replaced by
382.24 + * your own identifying information:
382.25 + * "Portions Copyrighted [year] [name of copyright owner]"
382.26 + *
382.27 + * If you wish your version of this file to be governed by only the CDDL
382.28 + * or only the GPL Version 2, indicate your decision by adding
382.29 + * "[Contributor] elects to include this software in this distribution
382.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
382.31 + * single choice of license, a recipient has the option to distribute
382.32 + * your version of this file under either the CDDL, the GPL Version 2 or
382.33 + * to extend the choice of license to its licensees as provided above.
382.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
382.35 + * Version 2 license, then the option applies only if the new code is
382.36 + * made subject to such option by the copyright holder.
382.37 + *
382.38 + * Contributor(s):
382.39 + *
382.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
382.41 + */
382.42 +
382.43 +package org.netbeans.modules.parsing.spi.indexing;
382.44 +
382.45 +import java.lang.annotation.ElementType;
382.46 +import java.lang.annotation.Retention;
382.47 +import java.lang.annotation.RetentionPolicy;
382.48 +import java.lang.annotation.Target;
382.49 +import org.netbeans.api.java.classpath.GlobalPathRegistry;
382.50 +
382.51 +/**
382.52 + * Registers a <code>PathRecognizer</code> in the default <code>Lookup</code>.
382.53 + *
382.54 + * <p class="nonnormative">
382.55 + * This annotation can be added to any type, but typically you should add it to an
382.56 + * indexer factory or a CSL language definition.
382.57 + *
382.58 + * @author Vita Stejskal
382.59 + * @since 1.32
382.60 + */
382.61 +@Target(ElementType.TYPE)
382.62 +@Retention(RetentionPolicy.SOURCE)
382.63 +public @interface PathRecognizerRegistration {
382.64 +
382.65 + /**
382.66 + * Gets classpath IDs for source paths registered in
382.67 + * the {@link GlobalPathRegistry}.
382.68 + *
382.69 + * @return The list of source path IDs; <code>"ANY"</code> means any source path ID
382.70 + * and an empty array (<code>{}</code>) means no source path ID.
382.71 + */
382.72 + public String [] sourcePathIds() default "ANY"; //NOI18N
382.73 +
382.74 + /**
382.75 + * Gets classpath IDs for library paths registered in
382.76 + * the {@link GlobalPathRegistry}.
382.77 + *
382.78 + * @return The list of source path IDs; <code>"ANY"</code> means any source path ID
382.79 + * and an empty array (<code>{}</code>) means no source path ID.
382.80 + */
382.81 + public String [] libraryPathIds() default "ANY"; //NOI18N
382.82 +
382.83 + /**
382.84 + * Gets classpath IDs for binray library paths registered in
382.85 + * the {@link GlobalPathRegistry}.
382.86 + *
382.87 + * @return The list of source path IDs; <code>"ANY"</code> means any source path ID
382.88 + * and an empty array (<code>{}</code>) means no source path ID.
382.89 + */
382.90 + public String [] binaryLibraryPathIds() default "ANY"; //NOI18N
382.91 +
382.92 + /**
382.93 + * Gets mime types of files relevant for the paths identified by the other methods.
382.94 + *
382.95 + * @return The list of mime types; <code>null</code>, an empty array (<code>{}</code>)
382.96 + * and empty strings (<code>""</code>) are ignored.
382.97 + */
382.98 + public String [] mimeTypes() default {};
382.99 +}
383.1 --- a/php.editor/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
383.2 +++ b/php.editor/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
383.3 @@ -1,7 +1,7 @@
383.4 javac.source=1.6
383.5 javac.compilerargs=-Xlint -Xlint:-serial
383.6 nbm.needs.restart=true
383.7 -spec.version.base=1.10.0
383.8 +spec.version.base=1.11.0
383.9 test-unit-sys-prop.xtest.js.home=${netbeans.dest.dir}/gsf
383.10 release.external/phpdocdesc.zip=docs/phpdocdesc.zip
383.11 release.external/predefined_vars.zip=docs/predefined_vars.zip
384.1 --- a/php.editor/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
384.2 +++ b/php.editor/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
384.3 @@ -55,8 +55,8 @@
384.4 <build-prerequisite/>
384.5 <compile-dependency/>
384.6 <run-dependency>
384.7 - <release-version>1</release-version>
384.8 - <specification-version>1.19</specification-version>
384.9 + <release-version>2</release-version>
384.10 + <specification-version>2.1</specification-version>
384.11 </run-dependency>
384.12 </dependency>
384.13 <dependency>
385.1 --- a/php.editor/src/org/netbeans/modules/php/editor/PHPLanguage.java Mon Feb 01 12:23:06 2010 +0100
385.2 +++ b/php.editor/src/org/netbeans/modules/php/editor/PHPLanguage.java Mon Feb 01 12:24:26 2010 +0100
385.3 @@ -56,6 +56,7 @@
385.4 import org.netbeans.modules.csl.spi.LanguageRegistration;
385.5 import org.netbeans.modules.parsing.spi.Parser;
385.6 import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
385.7 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
385.8 import org.netbeans.modules.php.editor.indent.PHPBracketCompleter;
385.9 import org.netbeans.modules.php.editor.indent.PHPFormatter;
385.10 import org.netbeans.modules.php.editor.index.PHPIndexer;
385.11 @@ -75,6 +76,7 @@
385.12 * @author Petr Pisl
385.13 */
385.14 @LanguageRegistration(mimeType="text/x-php5") //NOI18N
385.15 +@PathRecognizerRegistration(mimeTypes="text/x-php5", sourcePathIds=PhpSourcePath.SOURCE_CP, libraryPathIds=PhpSourcePath.BOOT_CP, binaryLibraryPathIds={}) //NOI18N
385.16 public class PHPLanguage extends DefaultLanguageConfig {
385.17
385.18 @Override
386.1 --- a/php.editor/src/org/netbeans/modules/php/editor/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
386.2 +++ b/php.editor/src/org/netbeans/modules/php/editor/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
386.3 @@ -41,8 +41,12 @@
386.4 <attr name="position" intvalue="0"/>
386.5 </file>
386.6 </folder>
386.7 - <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
386.8 - <file name="org-netbeans-modules-php-editor-PhpEmbeddingProvider$Factory.instance"/>
386.9 + <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
386.10 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
386.11 + </file>
386.12 + <file name="org-netbeans-modules-php-editor-PhpEmbeddingProvider$Factory.instance">
386.13 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
386.14 + </file>
386.15 <folder name="FontsColors">
386.16 <folder name="NetBeans">
386.17 <folder name="Defaults">
387.1 --- a/php.editor/src/org/netbeans/modules/php/editor/verification/AddUseImportRule.java Mon Feb 01 12:23:06 2010 +0100
387.2 +++ b/php.editor/src/org/netbeans/modules/php/editor/verification/AddUseImportRule.java Mon Feb 01 12:24:26 2010 +0100
387.3 @@ -49,7 +49,7 @@
387.4 import org.netbeans.modules.csl.api.Hint;
387.5 import org.netbeans.modules.csl.api.HintFix;
387.6 import org.netbeans.modules.csl.api.OffsetRange;
387.7 -import org.netbeans.modules.csl.core.UiUtils;
387.8 +import org.netbeans.modules.csl.api.UiUtils;
387.9 import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport.Kind;
387.10 import org.netbeans.modules.php.editor.index.IndexedClass;
387.11 import org.netbeans.modules.php.editor.index.IndexedConstant;
388.1 --- a/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceHint.java Mon Feb 01 12:23:06 2010 +0100
388.2 +++ b/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceHint.java Mon Feb 01 12:24:26 2010 +0100
388.3 @@ -52,7 +52,7 @@
388.4 import org.netbeans.modules.csl.api.Hint;
388.5 import org.netbeans.modules.csl.api.HintFix;
388.6 import org.netbeans.modules.csl.api.OffsetRange;
388.7 -import org.netbeans.modules.csl.core.UiUtils;
388.8 +import org.netbeans.modules.csl.api.UiUtils;
388.9 import org.netbeans.modules.csl.spi.GsfUtilities;
388.10 import org.netbeans.modules.parsing.spi.indexing.support.QuerySupport.Kind;
388.11 import org.netbeans.modules.php.editor.CodeUtils;
389.1 --- a/php.project/manifest.mf Mon Feb 01 12:23:06 2010 +0100
389.2 +++ b/php.project/manifest.mf Mon Feb 01 12:24:26 2010 +0100
389.3 @@ -1,6 +1,6 @@
389.4 Manifest-Version: 1.0
389.5 AutoUpdate-Show-In-Client: false
389.6 -OpenIDE-Module-Specification-Version: 2.23
389.7 +OpenIDE-Module-Specification-Version: 2.24
389.8 OpenIDE-Module: org.netbeans.modules.php.project
389.9 OpenIDE-Module-Layer: org/netbeans/modules/php/project/resources/layer.xml
389.10 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/project/resources/Bundle.properties
390.1 --- a/php.project/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
390.2 +++ b/php.project/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
390.3 @@ -87,8 +87,8 @@
390.4 <build-prerequisite/>
390.5 <compile-dependency/>
390.6 <run-dependency>
390.7 - <release-version>1</release-version>
390.8 - <specification-version>1.8</specification-version>
390.9 + <release-version>2</release-version>
390.10 + <specification-version>2.1</specification-version>
390.11 </run-dependency>
390.12 </dependency>
390.13 <dependency>
391.1 --- a/php.refactoring/manifest.mf Mon Feb 01 12:23:06 2010 +0100
391.2 +++ b/php.refactoring/manifest.mf Mon Feb 01 12:24:26 2010 +0100
391.3 @@ -3,5 +3,5 @@
391.4 OpenIDE-Module: org.netbeans.modules.php.refactoring
391.5 OpenIDE-Module-Layer: org/netbeans/modules/refactoring/php/resources/mf-layer.xml
391.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/refactoring/php/Bundle.properties
391.7 -OpenIDE-Module-Specification-Version: 1.8
391.8 +OpenIDE-Module-Specification-Version: 1.9
391.9
392.1 --- a/php.refactoring/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
392.2 +++ b/php.refactoring/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
392.3 @@ -28,8 +28,8 @@
392.4 <build-prerequisite/>
392.5 <compile-dependency/>
392.6 <run-dependency>
392.7 - <release-version>1</release-version>
392.8 - <specification-version>1.8</specification-version>
392.9 + <release-version>2</release-version>
392.10 + <specification-version>2.1</specification-version>
392.11 </run-dependency>
392.12 </dependency>
392.13 <dependency>
393.1 --- a/php.refactoring/src/org/netbeans/modules/refactoring/php/findusages/WhereUsedSupport.java Mon Feb 01 12:23:06 2010 +0100
393.2 +++ b/php.refactoring/src/org/netbeans/modules/refactoring/php/findusages/WhereUsedSupport.java Mon Feb 01 12:24:26 2010 +0100
393.3 @@ -51,7 +51,7 @@
393.4 import org.netbeans.modules.csl.api.ElementKind;
393.5 import org.netbeans.modules.csl.api.Modifier;
393.6 import org.netbeans.modules.csl.api.OffsetRange;
393.7 -import org.netbeans.modules.csl.core.UiUtils;
393.8 +import org.netbeans.modules.csl.api.UiUtils;
393.9 import org.netbeans.modules.csl.spi.ParserResult;
393.10 import org.netbeans.modules.parsing.api.ParserManager;
393.11 import org.netbeans.modules.parsing.api.ResultIterator;
394.1 --- a/php.refactoring/src/org/netbeans/modules/refactoring/php/ui/tree/FolderTreeElement.java Mon Feb 01 12:23:06 2010 +0100
394.2 +++ b/php.refactoring/src/org/netbeans/modules/refactoring/php/ui/tree/FolderTreeElement.java Mon Feb 01 12:24:26 2010 +0100
394.3 @@ -49,7 +49,7 @@
394.4 import org.netbeans.api.project.SourceGroup;
394.5 import org.netbeans.api.project.Sources;
394.6 import org.netbeans.modules.csl.api.ElementKind;
394.7 -import org.netbeans.modules.csl.core.UiUtils;
394.8 +import org.netbeans.modules.csl.api.UiUtils;
394.9 import org.netbeans.modules.php.project.api.PhpSourcePath;
394.10 import org.netbeans.modules.refactoring.spi.ui.*;
394.11 import org.openide.filesystems.FileObject;
395.1 --- a/php.symfony/manifest.mf Mon Feb 01 12:23:06 2010 +0100
395.2 +++ b/php.symfony/manifest.mf Mon Feb 01 12:24:26 2010 +0100
395.3 @@ -2,5 +2,5 @@
395.4 OpenIDE-Module: org.netbeans.modules.php.symfony
395.5 OpenIDE-Module-Layer: org/netbeans/modules/php/symfony/resources/layer.xml
395.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/symfony/resources/Bundle.properties
395.7 -OpenIDE-Module-Specification-Version: 1.5
395.8 +OpenIDE-Module-Specification-Version: 1.6
395.9
396.1 --- a/php.symfony/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
396.2 +++ b/php.symfony/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
396.3 @@ -10,8 +10,8 @@
396.4 <build-prerequisite/>
396.5 <compile-dependency/>
396.6 <run-dependency>
396.7 - <release-version>1</release-version>
396.8 - <specification-version>1.11</specification-version>
396.9 + <release-version>2</release-version>
396.10 + <specification-version>2.1</specification-version>
396.11 </run-dependency>
396.12 </dependency>
396.13 <dependency>
397.1 --- a/php.symfony/src/org/netbeans/modules/php/symfony/ui/actions/GoToActionOrViewAction.java Mon Feb 01 12:23:06 2010 +0100
397.2 +++ b/php.symfony/src/org/netbeans/modules/php/symfony/ui/actions/GoToActionOrViewAction.java Mon Feb 01 12:24:26 2010 +0100
397.3 @@ -48,7 +48,7 @@
397.4 import javax.swing.Action;
397.5 import javax.swing.JEditorPane;
397.6 import javax.swing.text.TextAction;
397.7 -import org.netbeans.modules.csl.core.UiUtils;
397.8 +import org.netbeans.modules.csl.api.UiUtils;
397.9 import org.netbeans.modules.editor.NbEditorUtilities;
397.10 import org.netbeans.modules.php.api.editor.EditorSupport;
397.11 import org.netbeans.modules.php.api.editor.PhpClass;
398.1 --- a/php.zend/manifest.mf Mon Feb 01 12:23:06 2010 +0100
398.2 +++ b/php.zend/manifest.mf Mon Feb 01 12:24:26 2010 +0100
398.3 @@ -2,5 +2,5 @@
398.4 OpenIDE-Module: org.netbeans.modules.php.zend
398.5 OpenIDE-Module-Layer: org/netbeans/modules/php/zend/resources/layer.xml
398.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/zend/resources/Bundle.properties
398.7 -OpenIDE-Module-Specification-Version: 1.0
398.8 +OpenIDE-Module-Specification-Version: 1.1
398.9
399.1 --- a/php.zend/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
399.2 +++ b/php.zend/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
399.3 @@ -10,8 +10,8 @@
399.4 <build-prerequisite/>
399.5 <compile-dependency/>
399.6 <run-dependency>
399.7 - <release-version>1</release-version>
399.8 - <specification-version>1.16</specification-version>
399.9 + <release-version>2</release-version>
399.10 + <specification-version>2.1</specification-version>
399.11 </run-dependency>
399.12 </dependency>
399.13 <dependency>
400.1 --- a/php.zend/src/org/netbeans/modules/php/zend/ui/actions/GoToActionOrViewAction.java Mon Feb 01 12:23:06 2010 +0100
400.2 +++ b/php.zend/src/org/netbeans/modules/php/zend/ui/actions/GoToActionOrViewAction.java Mon Feb 01 12:24:26 2010 +0100
400.3 @@ -46,7 +46,7 @@
400.4 import javax.swing.Action;
400.5 import javax.swing.JEditorPane;
400.6 import javax.swing.text.TextAction;
400.7 -import org.netbeans.modules.csl.core.UiUtils;
400.8 +import org.netbeans.modules.csl.api.UiUtils;
400.9 import org.netbeans.modules.editor.NbEditorUtilities;
400.10 import org.netbeans.modules.php.api.editor.EditorSupport;
400.11 import org.netbeans.modules.php.api.editor.PhpClass;
401.1 --- a/project.ant/src/org/netbeans/modules/project/ant/AntBasedProcessor.java Mon Feb 01 12:23:06 2010 +0100
401.2 +++ b/project.ant/src/org/netbeans/modules/project/ant/AntBasedProcessor.java Mon Feb 01 12:24:26 2010 +0100
401.3 @@ -77,7 +77,9 @@
401.4 if (roundEnv.processingOver()) {
401.5 return false;
401.6 }
401.7 - TypeMirror antHelper = processingEnv.getElementUtils().getTypeElement(AntProjectHelper.class.getName()).asType();
401.8 + TypeElement aphType = processingEnv.getElementUtils().getTypeElement(AntProjectHelper.class.getName());
401.9 + assert aphType != null : "Cannot find AntProjectHelper in " + processingEnv;
401.10 + TypeMirror antHelper = aphType.asType();
401.11 TypeMirror project = processingEnv.getElementUtils().getTypeElement(Project.class.getName()).asType();
401.12 for (Element e : roundEnv.getElementsAnnotatedWith(AntBasedProjectRegistration.class)) {
401.13 AntBasedProjectRegistration reg = e.getAnnotation(AntBasedProjectRegistration.class);
402.1 --- a/ruby.extrahints/manifest.mf Mon Feb 01 12:23:06 2010 +0100
402.2 +++ b/ruby.extrahints/manifest.mf Mon Feb 01 12:24:26 2010 +0100
402.3 @@ -3,4 +3,4 @@
402.4 OpenIDE-Module: org.netbeans.modules.ruby.extrahints/1
402.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ruby/extrahints/Bundle.properties
402.6 OpenIDE-Module-Layer: org/netbeans/modules/ruby/extrahints/layer.xml
402.7 -OpenIDE-Module-Specification-Version: 0.47
402.8 +OpenIDE-Module-Specification-Version: 0.48
403.1 --- a/ruby.extrahints/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
403.2 +++ b/ruby.extrahints/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
403.3 @@ -37,8 +37,8 @@
403.4 <build-prerequisite/>
403.5 <compile-dependency/>
403.6 <run-dependency>
403.7 - <release-version>1</release-version>
403.8 - <specification-version>1.8</specification-version>
403.9 + <release-version>2</release-version>
403.10 + <specification-version>2.1</specification-version>
403.11 </run-dependency>
403.12 </dependency>
403.13 <dependency>
404.1 --- a/ruby.hints/manifest.mf Mon Feb 01 12:23:06 2010 +0100
404.2 +++ b/ruby.hints/manifest.mf Mon Feb 01 12:24:26 2010 +0100
404.3 @@ -1,6 +1,6 @@
404.4 Manifest-Version: 1.0
404.5 OpenIDE-Module: org.netbeans.modules.ruby.hints/1
404.6 -OpenIDE-Module-Specification-Version: 0.44
404.7 +OpenIDE-Module-Specification-Version: 0.45
404.8 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ruby/hints/Bundle.properties
404.9 OpenIDE-Module-Layer: org/netbeans/modules/ruby/hints/layer.xml
404.10 AutoUpdate-Show-In-Client: false
405.1 --- a/ruby.hints/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
405.2 +++ b/ruby.hints/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
405.3 @@ -46,8 +46,8 @@
405.4 <build-prerequisite/>
405.5 <compile-dependency/>
405.6 <run-dependency>
405.7 - <release-version>1</release-version>
405.8 - <specification-version>1.8</specification-version>
405.9 + <release-version>2</release-version>
405.10 + <specification-version>2.1</specification-version>
405.11 </run-dependency>
405.12 </dependency>
405.13 <dependency>
406.1 --- a/ruby.hints/test/unit/src/org/netbeans/modules/ruby/hints/HintTestBase.java Mon Feb 01 12:23:06 2010 +0100
406.2 +++ b/ruby.hints/test/unit/src/org/netbeans/modules/ruby/hints/HintTestBase.java Mon Feb 01 12:24:26 2010 +0100
406.3 @@ -43,8 +43,6 @@
406.4 import org.netbeans.modules.csl.api.HintSeverity;
406.5 import org.netbeans.modules.csl.api.HintsProvider;
406.6 import org.netbeans.modules.csl.api.Rule;
406.7 -import org.netbeans.modules.csl.core.Language;
406.8 -import org.netbeans.modules.csl.core.LanguageRegistry;
406.9 import org.netbeans.modules.csl.hints.infrastructure.GsfHintsManager;
406.10 import org.netbeans.modules.csl.spi.ParserResult;
406.11 import org.netbeans.modules.ruby.AstUtilities;
406.12 @@ -166,25 +164,4 @@
406.13 assertTrue(fails.toString(), fails.size() == 0);
406.14 }
406.15
406.16 - @SuppressWarnings("unchecked")
406.17 - public void ensureRegistered(RubyAstRule hint) throws Exception {
406.18 - Language language = LanguageRegistry.getInstance().getLanguageByMimeType(RubyInstallation.RUBY_MIME_TYPE);
406.19 - assertNotNull(language.getHintsProvider());
406.20 - GsfHintsManager hintsManager = language.getHintsManager();
406.21 - Map<NodeType, List<RubyAstRule>> hints = (Map)hintsManager.getHints();
406.22 - Set<NodeType> kinds = hint.getKinds();
406.23 - for (NodeType nodeType : kinds) {
406.24 - List<RubyAstRule> rules = hints.get(nodeType);
406.25 - assertNotNull(rules);
406.26 - boolean found = false;
406.27 - for (RubyAstRule rule : rules) {
406.28 - if (rule.getClass() == hint.getClass()) {
406.29 - found = true;
406.30 - break;
406.31 - }
406.32 - }
406.33 -
406.34 - assertTrue(found);
406.35 - }
406.36 - }
406.37 }
407.1 --- a/ruby.merbproject/manifest.mf Mon Feb 01 12:23:06 2010 +0100
407.2 +++ b/ruby.merbproject/manifest.mf Mon Feb 01 12:24:26 2010 +0100
407.3 @@ -3,5 +3,5 @@
407.4 OpenIDE-Module-Layer: org/netbeans/modules/ruby/merbproject/ui/resources/layer.xml
407.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ruby/merbproject/Bundle.properties
407.6 OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
407.7 -OpenIDE-Module-Specification-Version: 1.1
407.8 +OpenIDE-Module-Specification-Version: 1.2
407.9 AutoUpdate-Show-In-Client: false
408.1 --- a/ruby.merbproject/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
408.2 +++ b/ruby.merbproject/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
408.3 @@ -37,8 +37,8 @@
408.4 <build-prerequisite/>
408.5 <compile-dependency/>
408.6 <run-dependency>
408.7 - <release-version>1</release-version>
408.8 - <specification-version>1.8</specification-version>
408.9 + <release-version>2</release-version>
408.10 + <specification-version>2.1</specification-version>
408.11 </run-dependency>
408.12 </dependency>
408.13 <dependency>
409.1 --- a/ruby.platform/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
409.2 +++ b/ruby.platform/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
409.3 @@ -78,8 +78,8 @@
409.4 <build-prerequisite/>
409.5 <compile-dependency/>
409.6 <run-dependency>
409.7 - <release-version>1</release-version>
409.8 - <specification-version>1.8</specification-version>
409.9 + <release-version>2</release-version>
409.10 + <specification-version>2.1</specification-version>
409.11 </run-dependency>
409.12 </dependency>
409.13 <dependency>
410.1 --- a/ruby.project/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
410.2 +++ b/ruby.project/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
410.3 @@ -55,8 +55,8 @@
410.4 <build-prerequisite/>
410.5 <compile-dependency/>
410.6 <run-dependency>
410.7 - <release-version>1</release-version>
410.8 - <specification-version>1.8</specification-version>
410.9 + <release-version>2</release-version>
410.10 + <specification-version>2.1</specification-version>
410.11 </run-dependency>
410.12 </dependency>
410.13 <dependency>
411.1 --- a/ruby.railsprojects/manifest.mf Mon Feb 01 12:23:06 2010 +0100
411.2 +++ b/ruby.railsprojects/manifest.mf Mon Feb 01 12:24:26 2010 +0100
411.3 @@ -3,5 +3,5 @@
411.4 OpenIDE-Module-Layer: org/netbeans/modules/ruby/railsprojects/ui/resources/layer.xml
411.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ruby/railsprojects/Bundle.properties
411.6 OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
411.7 -OpenIDE-Module-Specification-Version: 1.7
411.8 +OpenIDE-Module-Specification-Version: 1.8
411.9 AutoUpdate-Show-In-Client: false
412.1 --- a/ruby.railsprojects/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
412.2 +++ b/ruby.railsprojects/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
412.3 @@ -46,8 +46,8 @@
412.4 <build-prerequisite/>
412.5 <compile-dependency/>
412.6 <run-dependency>
412.7 - <release-version>1</release-version>
412.8 - <specification-version>1.8</specification-version>
412.9 + <release-version>2</release-version>
412.10 + <specification-version>2.1</specification-version>
412.11 </run-dependency>
412.12 </dependency>
412.13 <dependency>
413.1 --- a/ruby.refactoring/manifest.mf Mon Feb 01 12:23:06 2010 +0100
413.2 +++ b/ruby.refactoring/manifest.mf Mon Feb 01 12:24:26 2010 +0100
413.3 @@ -3,4 +3,4 @@
413.4 OpenIDE-Module-Layer: org/netbeans/modules/refactoring/ruby/resources/mf-layer.xml
413.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/refactoring/ruby/resources/Bundle.properties
413.6 AutoUpdate-Show-In-Client: false
413.7 -OpenIDE-Module-Specification-Version: 0.68
413.8 +OpenIDE-Module-Specification-Version: 0.69
414.1 --- a/ruby.refactoring/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
414.2 +++ b/ruby.refactoring/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
414.3 @@ -28,8 +28,8 @@
414.4 <build-prerequisite/>
414.5 <compile-dependency/>
414.6 <run-dependency>
414.7 - <release-version>1</release-version>
414.8 - <specification-version>1.8</specification-version>
414.9 + <release-version>2</release-version>
414.10 + <specification-version>2.1</specification-version>
414.11 </run-dependency>
414.12 </dependency>
414.13 <dependency>
415.1 --- a/ruby.refactoring/src/org/netbeans/modules/refactoring/ruby/WhereUsedElement.java Mon Feb 01 12:23:06 2010 +0100
415.2 +++ b/ruby.refactoring/src/org/netbeans/modules/refactoring/ruby/WhereUsedElement.java Mon Feb 01 12:24:26 2010 +0100
415.3 @@ -48,7 +48,7 @@
415.4 import org.netbeans.editor.Utilities;
415.5 import org.netbeans.modules.csl.api.Modifier;
415.6 import org.netbeans.modules.csl.api.OffsetRange;
415.7 -import org.netbeans.modules.csl.core.UiUtils;
415.8 +import org.netbeans.modules.csl.api.UiUtils;
415.9 import org.netbeans.modules.csl.spi.GsfUtilities;
415.10 import org.netbeans.modules.csl.spi.ParserResult;
415.11 import org.netbeans.modules.refactoring.ruby.ui.tree.ElementGripFactory;
416.1 --- a/ruby.refactoring/src/org/netbeans/modules/refactoring/ruby/plugins/RubyWhereUsedQueryPlugin.java Mon Feb 01 12:23:06 2010 +0100
416.2 +++ b/ruby.refactoring/src/org/netbeans/modules/refactoring/ruby/plugins/RubyWhereUsedQueryPlugin.java Mon Feb 01 12:24:26 2010 +0100
416.3 @@ -69,7 +69,7 @@
416.4 import org.netbeans.modules.csl.api.Modifier;
416.5 import org.netbeans.modules.csl.api.OffsetRange;
416.6 import org.netbeans.modules.csl.api.Severity;
416.7 -import org.netbeans.modules.csl.core.UiUtils;
416.8 +import org.netbeans.modules.csl.api.UiUtils;
416.9 import org.netbeans.modules.csl.spi.ParserResult;
416.10 import org.netbeans.modules.csl.spi.support.ModificationResult;
416.11 import org.netbeans.modules.refactoring.api.Problem;
417.1 --- a/ruby.refactoring/src/org/netbeans/modules/refactoring/ruby/ui/tree/FolderTreeElement.java Mon Feb 01 12:23:06 2010 +0100
417.2 +++ b/ruby.refactoring/src/org/netbeans/modules/refactoring/ruby/ui/tree/FolderTreeElement.java Mon Feb 01 12:24:26 2010 +0100
417.3 @@ -48,8 +48,8 @@
417.4 import org.netbeans.api.project.SourceGroup;
417.5 import org.netbeans.api.project.Sources;
417.6 import org.netbeans.modules.csl.api.ElementKind;
417.7 -import org.netbeans.modules.csl.core.UiUtils;
417.8 import org.netbeans.api.java.classpath.ClassPath;
417.9 +import org.netbeans.modules.csl.api.UiUtils;
417.10 import org.netbeans.modules.refactoring.spi.ui.*;
417.11 import org.netbeans.modules.refactoring.spi.ui.TreeElementFactory;
417.12 import org.netbeans.modules.ruby.rubyproject.RubyProject;
418.1 --- a/ruby.rhtml/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
418.2 +++ b/ruby.rhtml/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
418.3 @@ -39,7 +39,7 @@
418.4
418.5 javac.compilerargs=-Xlint -Xlint:-serial
418.6 javac.source=1.6
418.7 -spec.version.base=0.71.0
418.8 +spec.version.base=0.72.0
418.9
418.10 test-unit-sys-prop.xtest.jruby.home=${netbeans.dest.dir}/ruby/jruby-1.2.0
418.11
419.1 --- a/ruby.rhtml/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
419.2 +++ b/ruby.rhtml/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
419.3 @@ -19,8 +19,8 @@
419.4 <build-prerequisite/>
419.5 <compile-dependency/>
419.6 <run-dependency>
419.7 - <release-version>1</release-version>
419.8 - <specification-version>1.19</specification-version>
419.9 + <release-version>2</release-version>
419.10 + <specification-version>2.1</specification-version>
419.11 </run-dependency>
419.12 </dependency>
419.13 <dependency>
419.14 @@ -256,6 +256,10 @@
419.15 <recursive/>
419.16 </test-dependency>
419.17 <test-dependency>
419.18 + <code-name-base>org.netbeans.libs.junit4</code-name-base>
419.19 + <compile-dependency/>
419.20 + </test-dependency>
419.21 + <test-dependency>
419.22 <code-name-base>org.netbeans.modules.csl.api</code-name-base>
419.23 <recursive/>
419.24 <compile-dependency/>
419.25 @@ -316,6 +320,11 @@
419.26 <recursive/>
419.27 </test-dependency>
419.28 <test-dependency>
419.29 + <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
419.30 + <recursive/>
419.31 + <compile-dependency/>
419.32 + </test-dependency>
419.33 + <test-dependency>
419.34 <code-name-base>org.netbeans.modules.progress.ui</code-name-base>
419.35 <recursive/>
419.36 </test-dependency>
420.1 --- a/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/RhtmlLanguage.java Mon Feb 01 12:23:06 2010 +0100
420.2 +++ b/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/RhtmlLanguage.java Mon Feb 01 12:24:26 2010 +0100
420.3 @@ -51,11 +51,13 @@
420.4 import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
420.5 import org.netbeans.modules.csl.spi.LanguageRegistration;
420.6 import org.netbeans.modules.parsing.spi.Parser;
420.7 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
420.8 import org.netbeans.modules.ruby.RubyIndexer;
420.9 import org.netbeans.modules.ruby.RubyStructureAnalyzer;
420.10 import org.netbeans.modules.ruby.RubyUtils;
420.11
420.12 @LanguageRegistration(mimeType="application/x-httpd-eruby", useCustomEditorKit=true) //NOI18N
420.13 +@PathRecognizerRegistration(mimeTypes="application/x-httpd-eruby", sourcePathIds=RubyLanguage.SOURCE, libraryPathIds=RubyLanguage.BOOT, binaryLibraryPathIds={}) //NOI18N
420.14 public class RhtmlLanguage extends DefaultLanguageConfig {
420.15
420.16 public RhtmlLanguage() {
421.1 --- a/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/editor/RhtmlKit.java Mon Feb 01 12:23:06 2010 +0100
421.2 +++ b/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/editor/RhtmlKit.java Mon Feb 01 12:24:26 2010 +0100
421.3 @@ -60,21 +60,19 @@
421.4 import org.netbeans.editor.ext.html.dtd.Registry;
421.5 import org.netbeans.lib.editor.util.CharSequenceUtilities;
421.6 import org.netbeans.lib.editor.util.swing.DocumentUtilities;
421.7 -import org.netbeans.modules.csl.core.DeleteToNextCamelCasePosition;
421.8 -import org.netbeans.modules.csl.core.DeleteToPreviousCamelCasePosition;
421.9 -import org.netbeans.modules.csl.core.GsfEditorKitFactory;
421.10 -import org.netbeans.modules.csl.core.NextCamelCasePosition;
421.11 -import org.netbeans.modules.csl.core.PreviousCamelCasePosition;
421.12 -import org.netbeans.modules.csl.core.SelectCodeElementAction;
421.13 -import org.netbeans.modules.csl.core.SelectNextCamelCasePosition;
421.14 -import org.netbeans.modules.csl.core.SelectPreviousCamelCasePosition;
421.15 -import org.netbeans.modules.csl.editor.InstantRenameAction;
421.16 +import org.netbeans.modules.csl.api.DeleteToNextCamelCasePosition;
421.17 +import org.netbeans.modules.csl.api.DeleteToPreviousCamelCasePosition;
421.18 +import org.netbeans.modules.csl.api.InstantRenameAction;
421.19 +import org.netbeans.modules.csl.api.NextCamelCasePosition;
421.20 +import org.netbeans.modules.csl.api.PreviousCamelCasePosition;
421.21 +import org.netbeans.modules.csl.api.SelectCodeElementAction;
421.22 +import org.netbeans.modules.csl.api.SelectNextCamelCasePosition;
421.23 +import org.netbeans.modules.csl.api.SelectPreviousCamelCasePosition;
421.24 import org.netbeans.modules.html.editor.api.HtmlKit;
421.25 import org.netbeans.modules.html.editor.api.gsf.HtmlParserResult;
421.26 import org.netbeans.modules.ruby.lexer.RubyTokenId;
421.27 import org.netbeans.modules.ruby.rhtml.lexer.api.RhtmlTokenId;
421.28 import org.netbeans.modules.ruby.rhtml.spi.DtdResolver;
421.29 -import org.openide.util.Exceptions;
421.30 import org.openide.util.Lookup;
421.31
421.32 /**
421.33 @@ -155,16 +153,26 @@
421.34 new RhtmlToggleCommentAction(),
421.35 new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true),
421.36 new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false),
421.37 - new NextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, nextWordAction)),
421.38 - new PreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, previousWordAction)),
421.39 - new SelectNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionNextWordAction)),
421.40 - new SelectPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionPreviousWordAction)),
421.41 - new DeleteToNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removeNextWordAction)),
421.42 - new DeleteToPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removePreviousWordAction)),
421.43 + new NextCamelCasePosition(findAction(superActions, nextWordAction)),
421.44 + new PreviousCamelCasePosition(findAction(superActions, previousWordAction)),
421.45 + new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)),
421.46 + new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)),
421.47 + new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)),
421.48 + new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)),
421.49 new InstantRenameAction(),
421.50 });
421.51 }
421.52
421.53 + private static Action findAction(Action [] actions, String name) {
421.54 + for(Action a : actions) {
421.55 + Object nameObj = a.getValue(Action.NAME);
421.56 + if (nameObj instanceof String && name.equals(nameObj)) {
421.57 + return a;
421.58 + }
421.59 + }
421.60 + return null;
421.61 + }
421.62 +
421.63 private boolean handleDeletion(BaseDocument doc, int dotPos) {
421.64 if (dotPos > 0) {
421.65 try {
421.66 @@ -481,7 +489,7 @@
421.67 }
421.68 final BaseDocument doc = (BaseDocument)target.getDocument();
421.69 doc.runAtomic(new Runnable() {
421.70 - public void run() {
421.71 + public @Override void run() {
421.72 try {
421.73 Caret caret = target.getCaret();
421.74 int startPos;
422.1 --- a/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
422.2 +++ b/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
422.3 @@ -108,13 +108,25 @@
422.4 <attr name="position" intvalue="0"/>
422.5 </file>
422.6 </folder>
422.7 - <file name="org-netbeans-modules-ruby-rhtml-editor-RubyEmbeddingProvider$Factory.instance"/>
422.8 - <file name="org-netbeans-modules-ruby-rhtml-editor-HtmlEmbeddingProvider$Factory.instance"/>
422.9 + <file name="org-netbeans-modules-ruby-rhtml-editor-RubyEmbeddingProvider$Factory.instance">
422.10 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
422.11 + </file>
422.12 + <file name="org-netbeans-modules-ruby-rhtml-editor-HtmlEmbeddingProvider$Factory.instance">
422.13 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
422.14 + </file>
422.15
422.16 - <file name="org-netbeans-modules-ruby-rhtml-RhtmlIndentTaskFactory.instance"/>
422.17 - <file name="org-netbeans-modules-ruby-rhtml-EmbeddedSectionsHighlighting$Factory.instance"/>
422.18 - <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
422.19 - <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
422.20 + <file name="org-netbeans-modules-ruby-rhtml-RhtmlIndentTaskFactory.instance">
422.21 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
422.22 + </file>
422.23 + <file name="org-netbeans-modules-ruby-rhtml-EmbeddedSectionsHighlighting$Factory.instance">
422.24 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
422.25 + </file>
422.26 + <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
422.27 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
422.28 + </file>
422.29 + <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
422.30 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
422.31 + </file>
422.32 <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
422.33 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
422.34 <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
423.1 --- a/ruby.rhtml/test/unit/src/org/netbeans/modules/ruby/rhtml/RhtmlTestBase.java Mon Feb 01 12:23:06 2010 +0100
423.2 +++ b/ruby.rhtml/test/unit/src/org/netbeans/modules/ruby/rhtml/RhtmlTestBase.java Mon Feb 01 12:24:26 2010 +0100
423.3 @@ -29,9 +29,6 @@
423.4 package org.netbeans.modules.ruby.rhtml;
423.5
423.6 import java.awt.event.ActionEvent;
423.7 -import java.util.ArrayList;
423.8 -import java.util.Collections;
423.9 -import java.util.List;
423.10 import javax.swing.Action;
423.11 import javax.swing.JEditorPane;
423.12 import org.netbeans.api.editor.mimelookup.MimePath;
423.13 @@ -42,19 +39,13 @@
423.14 import org.netbeans.editor.Formatter;
423.15 import org.netbeans.editor.ext.ExtFormatter;
423.16 import org.netbeans.lib.lexer.test.TestLanguageProvider;
423.17 -import org.netbeans.modules.csl.core.Language;
423.18 -import org.netbeans.modules.csl.core.LanguageRegistry;
423.19 import org.netbeans.modules.html.editor.indent.HtmlIndentTaskFactory;
423.20 import org.netbeans.modules.ruby.RubyTestBase;
423.21 import org.netbeans.modules.ruby.rhtml.editor.RhtmlKit;
423.22 import org.netbeans.modules.ruby.rhtml.lexer.api.RhtmlTokenId;
423.23 import org.openide.filesystems.FileObject;
423.24 -import org.netbeans.modules.csl.editor.codetemplates.CslCorePackageAccessor;
423.25 import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
423.26 -import org.netbeans.modules.ruby.RubyKeystrokeHandler;
423.27 -import org.netbeans.modules.ruby.RubyRenameHandler;
423.28 import org.netbeans.modules.ruby.lexer.RubyTokenId;
423.29 -import org.openide.filesystems.FileUtil;
423.30
423.31 /**
423.32 *
423.33 @@ -99,23 +90,6 @@
423.34
423.35 Formatter.setFormatter(RhtmlKit.class, new ExtFormatter(RhtmlKit.class));
423.36
423.37 - LanguageRegistry registry = LanguageRegistry.getInstance();
423.38 - List<Action> actions = Collections.emptyList();
423.39 - if (!LanguageRegistry.getInstance().isSupported(RhtmlTokenId.MIME_TYPE)) {
423.40 - Language dl = new Language("org/netbeans/modules/ruby/jrubydoc.png", RhtmlTokenId.MIME_TYPE,
423.41 - actions, new RhtmlLanguage(),
423.42 - new RhtmlCompleter(), new RubyRenameHandler(), new RhtmlFinder(),
423.43 - null, new RubyKeystrokeHandler(), null, null, null, true);
423.44 - List<Language> languages = new ArrayList<Language>();
423.45 - languages.add(dl);
423.46 - CslCorePackageAccessor.get().languageRegistryAddLanguages(languages);
423.47 -
423.48 - String mimeFolder = "Editors/" + dl.getMimeType();
423.49 - final FileObject root = FileUtil.getConfigFile(mimeFolder); // NOI18N
423.50 - if (root == null) {
423.51 - FileUtil.createFolder(FileUtil.getConfigRoot(), mimeFolder);
423.52 - }
423.53 - }
423.54 }
423.55
423.56 @Override
424.1 --- a/ruby.testrunner/manifest.mf Mon Feb 01 12:23:06 2010 +0100
424.2 +++ b/ruby.testrunner/manifest.mf Mon Feb 01 12:24:26 2010 +0100
424.3 @@ -2,5 +2,5 @@
424.4 AutoUpdate-Show-In-Client: false
424.5 OpenIDE-Module: org.netbeans.modules.ruby.testrunner
424.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ruby/testrunner/Bundle.properties
424.7 -OpenIDE-Module-Specification-Version: 1.6
424.8 +OpenIDE-Module-Specification-Version: 1.7
424.9
425.1 --- a/ruby.testrunner/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
425.2 +++ b/ruby.testrunner/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
425.3 @@ -26,8 +26,8 @@
425.4 <build-prerequisite/>
425.5 <compile-dependency/>
425.6 <run-dependency>
425.7 - <release-version>1</release-version>
425.8 - <specification-version>1.8</specification-version>
425.9 + <release-version>2</release-version>
425.10 + <specification-version>2.1</specification-version>
425.11 </run-dependency>
425.12 </dependency>
425.13 <dependency>
426.1 --- a/ruby/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
426.2 +++ b/ruby/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
426.3 @@ -55,8 +55,8 @@
426.4 <build-prerequisite/>
426.5 <compile-dependency/>
426.6 <run-dependency>
426.7 - <release-version>1</release-version>
426.8 - <specification-version>1.19</specification-version>
426.9 + <release-version>2</release-version>
426.10 + <specification-version>2.1</specification-version>
426.11 </run-dependency>
426.12 </dependency>
426.13 <dependency>
427.1 --- a/ruby/src/org/netbeans/modules/ruby/RubyLanguage.java Mon Feb 01 12:23:06 2010 +0100
427.2 +++ b/ruby/src/org/netbeans/modules/ruby/RubyLanguage.java Mon Feb 01 12:24:26 2010 +0100
427.3 @@ -56,6 +56,7 @@
427.4 import org.netbeans.modules.csl.spi.LanguageRegistration;
427.5 import org.netbeans.modules.parsing.spi.Parser;
427.6 import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
427.7 +import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
427.8 import org.netbeans.modules.ruby.lexer.RubyTokenId;
427.9
427.10 /*
427.11 @@ -64,6 +65,7 @@
427.12 * @author Tor Norbye
427.13 */
427.14 @LanguageRegistration(mimeType="text/x-ruby")
427.15 +@PathRecognizerRegistration(mimeTypes="text/x-ruby", sourcePathIds=RubyLanguage.SOURCE, libraryPathIds=RubyLanguage.BOOT, binaryLibraryPathIds={}) //NOI18N
427.16 public class RubyLanguage extends DefaultLanguageConfig {
427.17
427.18 public final static String BOOT = "ruby/classpath/boot";
428.1 --- a/subversion/src/org/netbeans/modules/subversion/DiskMapTurboProvider.java Mon Feb 01 12:23:06 2010 +0100
428.2 +++ b/subversion/src/org/netbeans/modules/subversion/DiskMapTurboProvider.java Mon Feb 01 12:24:26 2010 +0100
428.3 @@ -41,6 +41,7 @@
428.4
428.5 package org.netbeans.modules.subversion;
428.6
428.7 +import org.netbeans.modules.versioning.util.FileUtils;
428.8 import org.netbeans.modules.turbo.CacheIndex;
428.9 import org.netbeans.modules.subversion.util.*;
428.10 import org.netbeans.modules.turbo.TurboProvider;
429.1 --- a/subversion/src/org/netbeans/modules/subversion/FileStatusCache.java Mon Feb 01 12:23:06 2010 +0100
429.2 +++ b/subversion/src/org/netbeans/modules/subversion/FileStatusCache.java Mon Feb 01 12:24:26 2010 +0100
429.3 @@ -1331,8 +1331,8 @@
429.4 LABELS_CACHE_LOG.log(Level.WARNING, "LabelInfoRefreshTask: failed getting info and info for {0}", file.getAbsolutePath());
429.5 LABELS_CACHE_LOG.log(Level.INFO, null, ex);
429.6 }
429.7 - labels.put(file, FAKE_LABEL_INFO);
429.8 }
429.9 + labels.put(file, FAKE_LABEL_INFO);
429.10 }
429.11 }
429.12 synchronized (fileLabels) {
430.1 --- a/subversion/src/org/netbeans/modules/subversion/FilesystemHandler.java Mon Feb 01 12:23:06 2010 +0100
430.2 +++ b/subversion/src/org/netbeans/modules/subversion/FilesystemHandler.java Mon Feb 01 12:24:26 2010 +0100
430.3 @@ -42,7 +42,7 @@
430.4 package org.netbeans.modules.subversion;
430.5
430.6 import javax.swing.SwingUtilities;
430.7 -import org.netbeans.modules.subversion.util.FileUtils;
430.8 +import org.netbeans.modules.versioning.util.FileUtils;
430.9 import org.netbeans.modules.subversion.util.SvnUtils;
430.10 import org.netbeans.modules.subversion.client.SvnClient;
430.11 import java.io.File;
431.1 --- a/subversion/src/org/netbeans/modules/subversion/SvnFileNode.java Mon Feb 01 12:23:06 2010 +0100
431.2 +++ b/subversion/src/org/netbeans/modules/subversion/SvnFileNode.java Mon Feb 01 12:24:26 2010 +0100
431.3 @@ -63,6 +63,8 @@
431.4 private String relativePath;
431.5 private String copy;
431.6 private boolean copyScanned;
431.7 + private Boolean fileFlag;
431.8 + private String mimeType;
431.9
431.10 public SvnFileNode(File file) {
431.11 this.file = FileUtil.normalizeFile(file);
431.12 @@ -81,11 +83,13 @@
431.13 return file;
431.14 }
431.15
431.16 + @Override
431.17 public boolean equals(Object o) {
431.18 if (this == o) return true;
431.19 return o instanceof SvnFileNode && file.equals(((SvnFileNode) o).file);
431.20 }
431.21
431.22 + @Override
431.23 public int hashCode() {
431.24 return file.hashCode();
431.25 }
431.26 @@ -131,4 +135,18 @@
431.27 }
431.28 return copy;
431.29 }
431.30 +
431.31 + public boolean isFile () {
431.32 + if (fileFlag == null) {
431.33 + fileFlag = file.isFile();
431.34 + }
431.35 + return fileFlag;
431.36 + }
431.37 +
431.38 + public String getMimeType () {
431.39 + if (isFile() && mimeType == null) {
431.40 + mimeType = SvnUtils.getMimeType(file);
431.41 + }
431.42 + return mimeType;
431.43 + }
431.44 }
432.1 --- a/subversion/src/org/netbeans/modules/subversion/VersionsCache.java Mon Feb 01 12:23:06 2010 +0100
432.2 +++ b/subversion/src/org/netbeans/modules/subversion/VersionsCache.java Mon Feb 01 12:24:26 2010 +0100
432.3 @@ -45,7 +45,7 @@
432.4 import org.netbeans.modules.subversion.client.*;
432.5 import org.netbeans.modules.subversion.ui.diff.Setup;
432.6 import org.netbeans.modules.subversion.util.*;
432.7 -import org.netbeans.modules.subversion.util.FileUtils;
432.8 +import org.netbeans.modules.versioning.util.FileUtils;
432.9 import org.openide.filesystems.FileUtil;
432.10 import org.tigris.subversion.svnclientadapter.*;
432.11
433.1 --- a/subversion/src/org/netbeans/modules/subversion/client/SvnClientExceptionHandler.java Mon Feb 01 12:23:06 2010 +0100
433.2 +++ b/subversion/src/org/netbeans/modules/subversion/client/SvnClientExceptionHandler.java Mon Feb 01 12:24:26 2010 +0100
433.3 @@ -79,7 +79,7 @@
433.4 import org.netbeans.modules.subversion.config.CertificateFile;
433.5 import org.netbeans.modules.subversion.ui.repository.Repository;
433.6 import org.netbeans.modules.subversion.ui.repository.RepositoryConnection;
433.7 -import org.netbeans.modules.subversion.util.FileUtils;
433.8 +import org.netbeans.modules.versioning.util.FileUtils;
433.9 import org.netbeans.modules.subversion.util.ProxySettings;
433.10 import org.netbeans.modules.subversion.util.SvnUtils;
433.11 import org.netbeans.modules.versioning.util.Utils;
434.1 --- a/subversion/src/org/netbeans/modules/subversion/config/KVFile.java Mon Feb 01 12:23:06 2010 +0100
434.2 +++ b/subversion/src/org/netbeans/modules/subversion/config/KVFile.java Mon Feb 01 12:24:26 2010 +0100
434.3 @@ -53,7 +53,7 @@
434.4 import java.util.TreeMap;
434.5 import java.util.logging.Level;
434.6 import org.netbeans.modules.subversion.Subversion;
434.7 -import org.netbeans.modules.subversion.util.FileUtils;
434.8 +import org.netbeans.modules.versioning.util.FileUtils;
434.9
434.10 /**
434.11 * Handles the credential or property files used by Subversion.
435.1 --- a/subversion/src/org/netbeans/modules/subversion/config/SvnConfigFiles.java Mon Feb 01 12:23:06 2010 +0100
435.2 +++ b/subversion/src/org/netbeans/modules/subversion/config/SvnConfigFiles.java Mon Feb 01 12:24:26 2010 +0100
435.3 @@ -60,7 +60,7 @@
435.4 import org.netbeans.modules.subversion.Subversion;
435.5 import org.netbeans.modules.subversion.SvnModuleConfig;
435.6 import org.netbeans.modules.subversion.ui.repository.RepositoryConnection;
435.7 -import org.netbeans.modules.subversion.util.FileUtils;
435.8 +import org.netbeans.modules.versioning.util.FileUtils;
435.9 import org.netbeans.modules.subversion.util.ProxySettings;
435.10 import org.netbeans.modules.subversion.util.SvnUtils;
435.11 import org.openide.filesystems.FileUtil;
436.1 Binary file subversion/src/org/netbeans/modules/subversion/resources/icons/load_template.png has changed
437.1 --- a/subversion/src/org/netbeans/modules/subversion/ui/commit/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
437.2 +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
437.3 @@ -120,14 +120,22 @@
437.4 MSG_CommitForm_ErrorConflicts=You cannot commit Files with Conflicts. Edit Files and resolve Conflicts first.
437.5 MSG_CommitForm_ErrorMultipleBranches = Warning: Committing to multiple Branches, see Branch column.
437.6 MSG_CommitForm_InfoBranch = Committing to "{0}" Branch.
437.7 -CTL_CommitForm_FilesToCommit=&By clicking on a Field in the 'Commit Action' Column you may specify some additional Actions.
437.8 +CTL_CommitForm_FilesToCommit=&By right-clicking on a row you may specify some additional Actions.
437.9
437.10 ACSD_CommitTable = Lists files to commit along with their commit options which you can change.
437.11 +CTL_CommitTable_Column_Commit = Commit
437.12 +CTL_CommitTable_Column_Description = Include/Exclude from commit
437.13 CTL_CommitTable_Column_File = File
437.14 CTL_CommitTable_Column_Branch = Branch
437.15 CTL_CommitTable_Column_Status = Status
437.16 CTL_CommitTable_Column_Action = Commit Action
437.17 CTL_CommitTable_Column_Folder = Repository Path
437.18 +CTL_CommitTable_IncludeAction = &Include In Commit
437.19 +CTL_CommitTable_IncludeRecursivelyAction = Include &Recursively
437.20 +CTL_CommitTable_ExcludeAction = &Exclude From Commit
437.21 +CTL_CommitTable_ExcludeRecursivelyAction = Exclude &Recursively
437.22 +CTL_CommitTable_AddBinaryAction = Add As &Binary
437.23 +CTL_CommitTable_AddTextAction = Add As &Text
437.24
437.25 CTL_CommitOption_AddAsText = Add as Text
437.26 CTL_CommitOption_AddAsBinary = Add as Binary
437.27 @@ -160,6 +168,7 @@
437.28 CTL_CommitForm_RecentPrompt = Recent Commit &Messages:
437.29
437.30 CTL_CommitForm_RecentMessages=Recent Messages
437.31 +CTL_CommitForm_LoadTemplate=Load Template
437.32
437.33 LBL_Advanced=Advanced:
437.34 LBL_advanced=Advanced:
438.1 --- a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitAction.java Mon Feb 01 12:23:06 2010 +0100
438.2 +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitAction.java Mon Feb 01 12:24:26 2010 +0100
438.3 @@ -93,6 +93,7 @@
438.4
438.5 static final String RECENT_COMMIT_MESSAGES = "recentCommitMessage";
438.6
438.7 + @Override
438.8 protected String getBaseName(Node[] nodes) {
438.9 return "CTL_MenuItem_Commit"; // NOI18N
438.10 }
438.11 @@ -169,8 +170,8 @@
438.12 Set<File> ret = new HashSet<File>();
438.13 FileStatusCache cache = Subversion.getInstance().getStatusCache();
438.14 for (File file : fileList) {
438.15 - File parent = null;
438.16 - while((parent = file.getParentFile()) != null) {
438.17 + File parent = file;
438.18 + while((parent = parent.getParentFile()) != null) {
438.19 if (checked.contains(parent)) {
438.20 break;
438.21 }
438.22 @@ -252,11 +253,13 @@
438.23 new HelpCtx(CommitAction.class),
438.24 null);
438.25 panel.addVersioningListener(new VersioningListener() {
438.26 + @Override
438.27 public void versioningEvent(VersioningEvent event) {
438.28 refreshCommitDialog(panel, data, commitButton);
438.29 }
438.30 });
438.31 data.getTableModel().addTableModelListener(new TableModelListener() {
438.32 + @Override
438.33 public void tableChanged(TableModelEvent e) {
438.34 refreshCommitDialog(panel, data, commitButton);
438.35 }
438.36 @@ -286,6 +289,7 @@
438.37 }
438.38 RequestProcessor rp = Subversion.getInstance().getRequestProcessor(repository);
438.39 SvnProgressSupport support = new SvnProgressSupport() {
438.40 + @Override
438.41 public void perform() {
438.42 performCommit(message, commitFiles, ctx, this, hooks);
438.43 }
438.44 @@ -296,6 +300,7 @@
438.45 private static SvnProgressSupport getProgressSupport(final Context ctx, final CommitTable data, JPanel progressPanel) {
438.46 SvnProgressSupport support = new PanelProgressSupport(progressPanel) {
438.47
438.48 + @Override
438.49 public void perform() {
438.50 // get files without exclusions
438.51 File[] contextFiles = ctx.getFiles();
438.52 @@ -307,9 +312,7 @@
438.53 // add also the roots to the to be commited list.
438.54 List<File> rootFiles = ctx.getRoots();
438.55 Set<File> filesSet = new HashSet<File>();
438.56 - for (File file : contextFiles) {
438.57 - filesSet.add(file);
438.58 - }
438.59 + filesSet.addAll(Arrays.asList(contextFiles));
438.60 for (File file : rootFiles) {
438.61 filesSet.add(file);
438.62 }
438.63 @@ -358,12 +361,13 @@
438.64 }
438.65 }
438.66
438.67 - if (fileList.size() == 0) {
438.68 + if (fileList.isEmpty()) {
438.69 return;
438.70 }
438.71 fileList.addAll(getUnversionedParents(fileList, false));
438.72 final SvnFileNode[] nodes = getFileNodes(fileList, this);
438.73 SwingUtilities.invokeLater(new Runnable() {
438.74 + @Override
438.75 public void run() {
438.76 data.setNodes(nodes);
438.77 }
438.78 @@ -417,10 +421,10 @@
438.79 }
438.80
438.81 if (stickyTags.size() > 1) {
438.82 - table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_BRANCH, CommitTableModel.COLUMN_NAME_STATUS,
438.83 - CommitTableModel.COLUMN_NAME_ACTION, CommitTableModel.COLUMN_NAME_PATH });
438.84 + table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_COMMIT, CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_BRANCH,
438.85 + CommitTableModel.COLUMN_NAME_STATUS, CommitTableModel.COLUMN_NAME_ACTION, CommitTableModel.COLUMN_NAME_PATH });
438.86 } else {
438.87 - table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_STATUS,
438.88 + table.setColumns(new String [] { CommitTableModel.COLUMN_NAME_COMMIT, CommitTableModel.COLUMN_NAME_NAME, CommitTableModel.COLUMN_NAME_STATUS,
438.89 CommitTableModel.COLUMN_NAME_ACTION, CommitTableModel.COLUMN_NAME_PATH });
438.90 }
438.91
438.92 @@ -428,7 +432,7 @@
438.93 DialogDescriptor dd = (DialogDescriptor) panel.getClientProperty("DialogDescriptor"); // NOI18N
438.94 String errorLabel;
438.95 if (stickyTags.size() <= 1) {
438.96 - String stickyTag = stickyTags.size() == 0 ? null : (String) stickyTags.iterator().next();
438.97 + String stickyTag = stickyTags.isEmpty() ? null : (String) stickyTags.iterator().next();
438.98 if (stickyTag == null) {
438.99 dd.setTitle(MessageFormat.format(loc.getString("CTL_CommitDialog_Title"), new Object [] { contentTitle }));
438.100 errorLabel = ""; // NOI18N
438.101 @@ -449,6 +453,7 @@
438.102 commit.setEnabled(enabled && containsCommitable(table));
438.103 }
438.104
438.105 + @Override
438.106 protected void performContextAction(Node[] nodes) {
438.107 if(!Subversion.getInstance().checkClientAvailable()) {
438.108 return;
438.109 @@ -682,7 +687,7 @@
438.110 }
438.111
438.112 private static void afterCommit(Collection<SvnHook> hooks, List<File> files, String message, List<ISVNLogMessage> logs) {
438.113 - if(hooks.size() == 0) {
438.114 + if(hooks.isEmpty()) {
438.115 return;
438.116 }
438.117 List<SvnHookContext.LogEntry> entries = new ArrayList<SvnHookContext.LogEntry>(logs.size());
438.118 @@ -712,7 +717,7 @@
438.119 Subversion.LOG.log(Level.INFO, null, ex);
438.120 }
438.121 if (Subversion.LOG.isLoggable(Level.FINER)) {
438.122 - Subversion.LOG.log(Level.FINER, CommitAction.class.getName() + ": getting last commit message for svn hooks");
438.123 + Subversion.LOG.log(Level.FINER, "{0}: getting last commit message for svn hooks", CommitAction.class.getName());
438.124 }
438.125 ISVNLogMessage[] ls = client.getLogMessages(SvnUtils.getRepositoryRootUrl(file), rev, rev);
438.126 if (ls.length > 0) {
439.1 --- a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java Mon Feb 01 12:23:06 2010 +0100
439.2 +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java Mon Feb 01 12:24:26 2010 +0100
439.3 @@ -83,6 +83,7 @@
439.4 import org.netbeans.modules.subversion.util.SvnUtils;
439.5 import org.netbeans.modules.versioning.util.AutoResizingPanel;
439.6 import org.netbeans.modules.versioning.util.PlaceholderPanel;
439.7 +import org.netbeans.modules.versioning.util.TemplateSelector;
439.8 import org.netbeans.modules.versioning.util.VerticallyNonResizingPanel;
439.9 import org.openide.awt.Mnemonics;
439.10 import static java.awt.Component.LEFT_ALIGNMENT;
439.11 @@ -115,6 +116,7 @@
439.12 private final JScrollPane jScrollPane1 = new JScrollPane();
439.13 private final JTextArea messageTextArea = new JTextArea();
439.14 private final JLabel recentLink = new JLabel();
439.15 + private final JLabel templateLink = new JLabel();
439.16 private Icon expandedIcon, collapsedIcon;
439.17 final PlaceholderPanel progressPanel = new PlaceholderPanel();
439.18
439.19 @@ -152,16 +154,20 @@
439.20 commitTable.getTableModel().addTableModelListener(this);
439.21 listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
439.22
439.23 - final List<String> messages = Utils.getStringList(SvnModuleConfig.getDefault().getPreferences(), CommitAction.RECENT_COMMIT_MESSAGES);
439.24 SwingUtilities.invokeLater(new Runnable() {
439.25 public void run() {
439.26 - if (messages.size() > 0) {
439.27 - messageTextArea.setText(messages.get(0));
439.28 + TemplateSelector ts = new TemplateSelector(SvnModuleConfig.getDefault().getPreferences());
439.29 + if(ts.isAutofill()) {
439.30 + messageTextArea.setText(ts.getTemplate());
439.31 + } else {
439.32 + final List<String> messages = Utils.getStringList(SvnModuleConfig.getDefault().getPreferences(), CommitAction.RECENT_COMMIT_MESSAGES);
439.33 + if (messages.size() > 0) {
439.34 + messageTextArea.setText(messages.get(0));
439.35 + }
439.36 }
439.37 messageTextArea.selectAll();
439.38 }
439.39 });
439.40 -
439.41 initCollapsibleSections();
439.42 }
439.43
439.44 @@ -294,6 +300,13 @@
439.45 }
439.46 }
439.47
439.48 + private void onTemplate() {
439.49 + TemplateSelector ts = new TemplateSelector(SvnModuleConfig.getDefault().getPreferences());
439.50 + if(ts.show()) {
439.51 + messageTextArea.setText(ts.getTemplate());
439.52 + }
439.53 + }
439.54 +
439.55 public void preferenceChange(PreferenceChangeEvent evt) {
439.56 if (evt.getKey().startsWith(SvnModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
439.57 Runnable inAWT = new Runnable() {
439.58 @@ -327,6 +340,9 @@
439.59 recentLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/recent_messages.png"))); // NOI18N
439.60 recentLink.setToolTipText(getMessage("CTL_CommitForm_RecentMessages")); // NOI18N
439.61
439.62 + templateLink.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/load_template.png"))); // NOI18N
439.63 + templateLink.setToolTipText(getMessage("CTL_CommitForm_LoadTemplate")); // NOI18N
439.64 +
439.65 messageTextArea.setColumns(60); //this determines the preferred width of the whole dialog
439.66 messageTextArea.setLineWrap(true);
439.67 messageTextArea.setRows(4);
439.68 @@ -347,8 +363,11 @@
439.69 topPanel.add(jLabel1);
439.70 topPanel.add(Box.createHorizontalGlue());
439.71 topPanel.add(recentLink);
439.72 + topPanel.add(makeHorizontalStrut(recentLink, templateLink, RELATED));
439.73 + topPanel.add(templateLink);
439.74 jLabel1.setAlignmentY(BOTTOM_ALIGNMENT);
439.75 recentLink.setAlignmentY(BOTTOM_ALIGNMENT);
439.76 + templateLink.setAlignmentY(BOTTOM_ALIGNMENT);
439.77
439.78 JPanel bottomPanel = new VerticallyNonResizingPanel();
439.79 bottomPanel.setLayout(new BoxLayout(bottomPanel, X_AXIS));
439.80 @@ -396,6 +415,13 @@
439.81 onBrowseRecentMessages();
439.82 }
439.83 });
439.84 + templateLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
439.85 + templateLink.addMouseListener(new MouseAdapter() {
439.86 + @Override
439.87 + public void mouseClicked(MouseEvent e) {
439.88 + onTemplate();
439.89 + }
439.90 + });
439.91 }
439.92
439.93 private Component makeVerticalStrut(JComponent compA,
439.94 @@ -410,6 +436,18 @@
439.95 return Box.createVerticalStrut(height);
439.96 }
439.97
439.98 + private Component makeHorizontalStrut(JComponent compA,
439.99 + JComponent compB,
439.100 + int relatedUnrelated) {
439.101 + int width = LayoutStyle.getSharedInstance().getPreferredGap(
439.102 + compA,
439.103 + compB,
439.104 + relatedUnrelated,
439.105 + WEST,
439.106 + this);
439.107 + return Box.createHorizontalStrut(width);
439.108 + }
439.109 +
439.110 private int getContainerGap(int direction) {
439.111 return LayoutStyle.getSharedInstance().getContainerGap(this,
439.112 direction,
440.1 --- a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitTable.java Mon Feb 01 12:23:06 2010 +0100
440.2 +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitTable.java Mon Feb 01 12:24:26 2010 +0100
440.3 @@ -45,7 +45,6 @@
440.4 import org.netbeans.modules.versioning.util.TableSorter;
440.5 import org.netbeans.modules.subversion.util.SvnUtils;
440.6 import org.netbeans.modules.subversion.SvnFileNode;
440.7 -import org.netbeans.modules.subversion.FileInformation;
440.8 import org.netbeans.modules.subversion.Subversion;
440.9 import org.openide.util.NbBundle;
440.10
440.11 @@ -58,18 +57,26 @@
440.12 import javax.swing.table.TableModel;
440.13 import javax.swing.table.TableColumnModel;
440.14 import java.awt.Component;
440.15 -import java.lang.String;
440.16 +import java.awt.Point;
440.17 +import java.awt.event.ActionEvent;
440.18 +import java.awt.event.KeyEvent;
440.19 +import java.awt.event.MouseEvent;
440.20 +import java.awt.event.MouseListener;
440.21 import java.util.*;
440.22 +import javax.swing.table.TableCellRenderer;
440.23 +import org.netbeans.modules.subversion.FileInformation;
440.24 import org.netbeans.modules.versioning.util.SortedTable;
440.25 +import org.openide.awt.Mnemonics;
440.26
440.27 /**
440.28 * {@link #getComponent Table} that displays nodes in the commit dialog.
440.29 *
440.30 * @author Maros Sandor
440.31 */
440.32 -public class CommitTable implements AncestorListener, TableModelListener {
440.33 +public class CommitTable implements AncestorListener, TableModelListener, MouseListener {
440.34
440.35 public static String [] COMMIT_COLUMNS = new String [] {
440.36 + CommitTableModel.COLUMN_NAME_COMMIT,
440.37 CommitTableModel.COLUMN_NAME_NAME,
440.38 CommitTableModel.COLUMN_NAME_STATUS,
440.39 CommitTableModel.COLUMN_NAME_ACTION,
440.40 @@ -77,7 +84,8 @@
440.41 };
440.42
440.43 public static String [] IMPORT_COLUMNS = new String [] {
440.44 - CommitTableModel.COLUMN_NAME_NAME,
440.45 + CommitTableModel.COLUMN_NAME_COMMIT,
440.46 + CommitTableModel.COLUMN_NAME_NAME,
440.47 CommitTableModel.COLUMN_NAME_ACTION,
440.48 CommitTableModel.COLUMN_NAME_PATH
440.49 };
440.50 @@ -111,16 +119,27 @@
440.51 table = new SortedTable(this.sorter);
440.52 table.getTableHeader().setReorderingAllowed(false);
440.53 table.setDefaultRenderer(String.class, new CommitStringsCellRenderer());
440.54 - table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
440.55 + table.setDefaultRenderer(Boolean.class, new CheckboxCellRenderer());
440.56 + table.setDefaultEditor(Boolean.class, new CheckboxCellEditor());
440.57 table.getTableHeader().setReorderingAllowed(true);
440.58 table.setRowHeight(table.getRowHeight() * 6 / 5);
440.59 table.addAncestorListener(this);
440.60 component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
440.61 label.setLabelFor(table);
440.62 - table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CommitTable.class, "ACSD_CommitTable")); // NOI18N
440.63 + table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CommitTable.class, "ACSD_CommitTable")); // NOI18N
440.64 + table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
440.65 + KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK ), "org.openide.actions.PopupAction"); // NOI18N
440.66 + table.getActionMap().put("org.openide.actions.PopupAction", new AbstractAction() { // NOI18N
440.67 + @Override
440.68 + public void actionPerformed(ActionEvent e) {
440.69 + showPopup(org.netbeans.modules.versioning.util.Utils.getPositionForPopup(table));
440.70 + }
440.71 + });
440.72 + table.addMouseListener(this);
440.73 setColumns(columns);
440.74 }
440.75
440.76 + @Override
440.77 public void ancestorAdded(AncestorEvent event) {
440.78 setDefaultColumnSizes();
440.79 }
440.80 @@ -133,11 +152,14 @@
440.81 TableColumnModel columnModel = table.getColumnModel();
440.82 if (columns == null || columnModel == null) return; // unsure when this methed will be called (component realization)
440.83 if (columnModel.getColumnCount() != columns.length) return;
440.84 - if (columns.length == 3) {
440.85 + if (columns.length == 4) {
440.86 for (int i = 0; i < columns.length; i++) {
440.87 String col = columns[i];
440.88 sorter.setColumnComparator(i, null);
440.89 - if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
440.90 + if (col.equals(CommitTableModel.COLUMN_NAME_COMMIT)) {
440.91 + columnModel.getColumn(i).setMinWidth(new JCheckBox().getMinimumSize().width);
440.92 + columnModel.getColumn(i).setPreferredWidth(new JCheckBox().getPreferredSize().width);
440.93 + } else if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
440.94 sorter.setColumnComparator(i, new FileNameComparator());
440.95 columnModel.getColumn(i).setPreferredWidth(width * 30 / 100);
440.96 } else if (col.equals(CommitTableModel.COLUMN_NAME_ACTION)) {
440.97 @@ -146,11 +168,14 @@
440.98 columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
440.99 }
440.100 }
440.101 - } else if (columns.length == 4) {
440.102 + } else if (columns.length == 5) {
440.103 for (int i = 0; i < columns.length; i++) {
440.104 String col = columns[i];
440.105 sorter.setColumnComparator(i, null);
440.106 - if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
440.107 + if (col.equals(CommitTableModel.COLUMN_NAME_COMMIT)) {
440.108 + columnModel.getColumn(i).setMinWidth(new JCheckBox().getMinimumSize().width);
440.109 + columnModel.getColumn(i).setPreferredWidth(new JCheckBox().getPreferredSize().width);
440.110 + } else if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
440.111 sorter.setColumnComparator(i, new FileNameComparator());
440.112 columnModel.getColumn(i).setPreferredWidth(width * 30 / 100);
440.113 } else if (col.equals(CommitTableModel.COLUMN_NAME_STATUS)) {
440.114 @@ -162,11 +187,14 @@
440.115 columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
440.116 }
440.117 }
440.118 - } else if (columns.length == 5) {
440.119 + } else if (columns.length == 6) {
440.120 for (int i = 0; i < columns.length; i++) {
440.121 String col = columns[i];
440.122 sorter.setColumnComparator(i, null);
440.123 - if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
440.124 + if (col.equals(CommitTableModel.COLUMN_NAME_COMMIT)) {
440.125 + columnModel.getColumn(i).setMinWidth(new JCheckBox().getMinimumSize().width);
440.126 + columnModel.getColumn(i).setPreferredWidth(new JCheckBox().getPreferredSize().width);
440.127 + } else if (col.equals(CommitTableModel.COLUMN_NAME_NAME)) {
440.128 sorter.setColumnComparator(i, new FileNameComparator());
440.129 columnModel.getColumn(i).setPreferredWidth(width * 25 / 100);
440.130 } else if (col.equals(CommitTableModel.COLUMN_NAME_STATUS)) {
440.131 @@ -199,9 +227,11 @@
440.132 return sorter;
440.133 }
440.134
440.135 + @Override
440.136 public void ancestorMoved(AncestorEvent event) {
440.137 }
440.138
440.139 + @Override
440.140 public void ancestorRemoved(AncestorEvent event) {
440.141 }
440.142
440.143 @@ -244,6 +274,7 @@
440.144 return tableModel;
440.145 }
440.146
440.147 + @Override
440.148 public void tableChanged(TableModelEvent e) {
440.149 // change in commit options may alter name rendering (strikethrough)
440.150 table.repaint();
440.151 @@ -253,58 +284,178 @@
440.152 tableModel.setRootFile(repositoryPath, rootLocalPath);
440.153 }
440.154
440.155 - private class CommitOptionsCellEditor extends DefaultCellEditor {
440.156 + private void showPopup (final MouseEvent e) {
440.157 + int row = table.rowAtPoint(e.getPoint());
440.158 + int col = table.columnAtPoint(e.getPoint());
440.159 + if (row != -1) {
440.160 + boolean makeRowSelected = true;
440.161 + int [] selectedrows = table.getSelectedRows();
440.162 + for (int i = 0; i < selectedrows.length; i++) {
440.163 + if (row == selectedrows[i]) {
440.164 + makeRowSelected = false;
440.165 + break;
440.166 + }
440.167 + }
440.168 + if (makeRowSelected) {
440.169 + table.getSelectionModel().setSelectionInterval(row, row);
440.170 + }
440.171 + }
440.172 + if (col != -1) {
440.173 + boolean makeColSelected = true;
440.174 + int [] selectedcols = table.getSelectedColumns();
440.175 + for (int i = 0; i < selectedcols.length; i++) {
440.176 + if (col == selectedcols[i]) {
440.177 + makeColSelected = false;
440.178 + break;
440.179 + }
440.180 + }
440.181 + if (makeColSelected) {
440.182 + table.getColumnModel().getSelectionModel().setSelectionInterval(col, col);
440.183 + }
440.184 + }
440.185 + SwingUtilities.invokeLater(new Runnable() {
440.186 + @Override
440.187 + public void run() {
440.188 + // invoke later so the selection on the table will be set first
440.189 + JPopupMenu menu = getPopup();
440.190 + menu.show(table, e.getX(), e.getY());
440.191 + }
440.192 + });
440.193 + }
440.194
440.195 - private final Object[] dirAddOptions = new Object [] {
440.196 - CommitOptions.ADD_DIRECTORY,
440.197 - CommitOptions.EXCLUDE
440.198 - };
440.199 -
440.200 - private final Object[] addOptions = new Object [] {
440.201 - CommitOptions.ADD_TEXT,
440.202 - CommitOptions.ADD_BINARY,
440.203 - CommitOptions.EXCLUDE
440.204 - };
440.205 - private final Object[] commitOptions = new Object [] {
440.206 - CommitOptions.COMMIT,
440.207 - CommitOptions.EXCLUDE
440.208 - };
440.209 + private void showPopup (Point p) {
440.210 + JPopupMenu menu = getPopup();
440.211 + menu.show(table, p.x, p.y);
440.212 + }
440.213
440.214 - private final Object[] removeOptions = new Object [] {
440.215 - CommitOptions.COMMIT_REMOVE,
440.216 - CommitOptions.EXCLUDE
440.217 - };
440.218 + private JPopupMenu getPopup() {
440.219
440.220 - public CommitOptionsCellEditor() {
440.221 - super(new JComboBox());
440.222 + JPopupMenu menu = new JPopupMenu();
440.223 + JMenuItem item;
440.224 + boolean onlyIncluded = true;
440.225 + boolean anyDirectory = false;
440.226 + boolean addAllowed = true;
440.227 + for (int rowIndex : table.getSelectedRows()) {
440.228 + int row = sorter.modelIndex(rowIndex);
440.229 + SvnFileNode node = tableModel.getNode(row);
440.230 + FileInformation fileInfo = node.getInformation();
440.231 + if (CommitOptions.EXCLUDE.equals(tableModel.getOptions(row))) {
440.232 + onlyIncluded = false;
440.233 + }
440.234 + if (fileInfo.isDirectory()) {
440.235 + anyDirectory = true;
440.236 + }
440.237 + if (!node.isFile() || (node.getInformation().getStatus() & FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY) == 0) {
440.238 + addAllowed = false;
440.239 + }
440.240 + }
440.241 + final boolean include = !onlyIncluded;
440.242 + item = menu.add(new PopupAction(NbBundle.getMessage(CommitTable.class, include ? "CTL_CommitTable_IncludeAction" : "CTL_CommitTable_ExcludeAction")) { // NOI18N
440.243 + @Override
440.244 + public void performAction (ActionEvent e) {
440.245 + int[] rows = getRows();
440.246 + tableModel.setIncluded(rows, include, false);
440.247 + }
440.248 + });
440.249 + Mnemonics.setLocalizedText(item, item.getText());
440.250 + item = menu.add(new PopupAction(NbBundle.getMessage(CommitTable.class, include ? "CTL_CommitTable_IncludeRecursivelyAction" : "CTL_CommitTable_ExcludeRecursivelyAction")) { // NOI18N
440.251 + @Override
440.252 + public void performAction (ActionEvent e) {
440.253 + int[] rows = getRows();
440.254 + tableModel.setIncluded(rows, include, true);
440.255 + }
440.256 + });
440.257 + Mnemonics.setLocalizedText(item, item.getText());
440.258 + item.setEnabled(anyDirectory);
440.259 + item = menu.add(new PopupAction(NbBundle.getMessage(CommitTable.class, "CTL_CommitTable_AddTextAction")) { // NOI18N
440.260 + @Override
440.261 + public void performAction (ActionEvent e) {
440.262 + int[] rows = getRows();
440.263 + tableModel.setAdded(rows, CommitOptions.ADD_TEXT);
440.264 + }
440.265 + });
440.266 + Mnemonics.setLocalizedText(item, item.getText());
440.267 + item.setEnabled(addAllowed);
440.268 + item = menu.add(new PopupAction(NbBundle.getMessage(CommitTable.class, "CTL_CommitTable_AddBinaryAction")) { // NOI18N
440.269 + @Override
440.270 + public void performAction (ActionEvent e) {
440.271 + int[] rows = getRows();
440.272 + tableModel.setAdded(rows, CommitOptions.ADD_BINARY);
440.273 + }
440.274 + });
440.275 + Mnemonics.setLocalizedText(item, item.getText());
440.276 + item.setEnabled(addAllowed);
440.277 + return menu;
440.278 + }
440.279 +
440.280 + @Override
440.281 + public void mouseEntered(MouseEvent e) {
440.282 + }
440.283 +
440.284 + @Override
440.285 + public void mouseExited(MouseEvent e) {
440.286 + }
440.287 +
440.288 + @Override
440.289 + public void mousePressed(MouseEvent e) {
440.290 + if (e.isPopupTrigger()) {
440.291 + showPopup(e);
440.292 + }
440.293 + }
440.294 +
440.295 + @Override
440.296 + public void mouseReleased(MouseEvent e) {
440.297 + if (e.isPopupTrigger()) {
440.298 + showPopup(e);
440.299 + }
440.300 + }
440.301 +
440.302 + @Override
440.303 + public void mouseClicked(MouseEvent e) {
440.304 + // not interested
440.305 + }
440.306 +
440.307 + /**
440.308 + * This action keeps selection of rows in the table
440.309 + */
440.310 + private abstract class PopupAction extends AbstractAction {
440.311 +
440.312 + private int[] rows;
440.313 +
440.314 + public PopupAction (String name) {
440.315 + super(name);
440.316 }
440.317
440.318 - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
440.319 - FileInformation info = tableModel.getNode(sorter.modelIndex(row)).getInformation();
440.320 - int fileStatus = info.getStatus();
440.321 - JComboBox combo = (JComboBox) editorComponent;
440.322 - if (fileStatus == FileInformation.STATUS_VERSIONED_DELETEDLOCALLY || fileStatus == FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY) {
440.323 - combo.setModel(new DefaultComboBoxModel(removeOptions));
440.324 - } else if ((fileStatus & (FileInformation.STATUS_IN_REPOSITORY | FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) == 0) {
440.325 - if (info.isDirectory()) {
440.326 - combo.setModel(new DefaultComboBoxModel(dirAddOptions));
440.327 - } else {
440.328 - combo.setModel(new DefaultComboBoxModel(addOptions));
440.329 + @Override
440.330 + public final void actionPerformed(ActionEvent e) {
440.331 + rows = table.getSelectedRows();
440.332 + int rowCount = table.getRowCount();
440.333 + for (int i = 0; i < rows.length; ++i) {
440.334 + rows[i] = sorter.modelIndex(rows[i]);
440.335 + }
440.336 + performAction(e);
440.337 + if (rowCount == table.getRowCount()) {
440.338 + for (int i = 0; i < rows.length; ++i) {
440.339 + table.getSelectionModel().addSelectionInterval(sorter.viewIndex(rows[i]), sorter.viewIndex(rows[i]));
440.340 }
440.341 - } else {
440.342 - combo.setModel(new DefaultComboBoxModel(commitOptions));
440.343 }
440.344 - return super.getTableCellEditorComponent(table, value, isSelected, row, column);
440.345 }
440.346 +
440.347 + protected int[] getRows () {
440.348 + return rows;
440.349 + }
440.350 +
440.351 + protected abstract void performAction (ActionEvent e);
440.352 }
440.353
440.354 private class CommitStringsCellRenderer extends DefaultTableCellRenderer {
440.355
440.356 private FilePathCellRenderer pathRenderer = new FilePathCellRenderer();
440.357
440.358 + @Override
440.359 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
440.360 int col = table.convertColumnIndexToModel(column);
440.361 - if (columns[col] == CommitTableModel.COLUMN_NAME_NAME) {
440.362 + if (CommitTableModel.COLUMN_NAME_NAME.equals(columns[col])) {
440.363 TableSorter sorter = (TableSorter) table.getModel();
440.364 CommitTableModel model = (CommitTableModel) sorter.getTableModel();
440.365 SvnFileNode node = model.getNode(sorter.modelIndex(row));
440.366 @@ -317,7 +468,7 @@
440.367 value = "<html><s>" + value + "</s></html>"; // NOI18N
440.368 }
440.369 return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
440.370 - } else if (columns[col] == CommitTableModel.COLUMN_NAME_PATH) {
440.371 + } else if (CommitTableModel.COLUMN_NAME_PATH.equals(columns[col])) {
440.372 return pathRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
440.373 } else {
440.374 return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
440.375 @@ -325,6 +476,36 @@
440.376 }
440.377 }
440.378
440.379 + private class CheckboxCellRenderer extends JCheckBox implements TableCellRenderer {
440.380 +
440.381 + public CheckboxCellRenderer() {
440.382 + setToolTipText(NbBundle.getMessage(CommitTable.class, "CTL_CommitTable_Column_Description")); //NOI18N
440.383 + }
440.384 +
440.385 + @Override
440.386 + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
440.387 + setSelected(value == null ? false : (Boolean) value);
440.388 + setBackground(hasFocus || isSelected ? table.getSelectionBackground() : table.getBackground());
440.389 + setHorizontalAlignment(SwingConstants.LEFT);
440.390 + return this;
440.391 + }
440.392 + }
440.393 +
440.394 + private class CheckboxCellEditor extends DefaultCellEditor {
440.395 +
440.396 + public CheckboxCellEditor() {
440.397 + super(new JCheckBox());
440.398 + }
440.399 +
440.400 + @Override
440.401 + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
440.402 + JCheckBox checkbox = (JCheckBox) editorComponent;
440.403 + checkbox.setSelected(value == null ? false : (Boolean) value);
440.404 + checkbox.setHorizontalAlignment(SwingConstants.LEFT);
440.405 + return super.getTableCellEditorComponent(table, value, isSelected, row, column);
440.406 + }
440.407 + }
440.408 +
440.409 private class StatusComparator extends SvnUtils.ByImportanceComparator {
440.410 public int compare(Object o1, Object o2) {
440.411 Integer row1 = (Integer) o1;
440.412 @@ -335,6 +516,7 @@
440.413 }
440.414
440.415 private class FileNameComparator implements Comparator {
440.416 + @Override
440.417 public int compare(Object o1, Object o2) {
440.418 Integer row1 = (Integer) o1;
440.419 Integer row2 = (Integer) o2;
441.1 --- a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitTableModel.java Mon Feb 01 12:23:06 2010 +0100
441.2 +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitTableModel.java Mon Feb 01 12:24:26 2010 +0100
441.3 @@ -49,7 +49,6 @@
441.4 import java.util.*;
441.5 import java.io.File;
441.6 import org.netbeans.modules.subversion.SvnModuleConfig;
441.7 -import org.tigris.subversion.svnclientadapter.SVNUrl;
441.8
441.9 /**
441.10 * Table model for the Commit dialog table.
441.11 @@ -58,17 +57,20 @@
441.12 */
441.13 public class CommitTableModel extends AbstractTableModel {
441.14
441.15 + public static final String COLUMN_NAME_COMMIT = "commit"; // NOI18N
441.16 public static final String COLUMN_NAME_NAME = "name"; // NOI18N
441.17 public static final String COLUMN_NAME_STATUS = "status"; // NOI18N
441.18 public static final String COLUMN_NAME_ACTION = "action"; // NOI18N
441.19 public static final String COLUMN_NAME_PATH = "path"; // NOI18N
441.20 public static final String COLUMN_NAME_BRANCH = "branch"; // NOI18N
441.21
441.22 + private final int STATUS_DELETED = FileInformation.STATUS_VERSIONED_DELETEDLOCALLY | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY;
441.23 + private final int STATUS_NEW = FileInformation.STATUS_VERSIONED_ADDEDLOCALLY | FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY;
441.24 +
441.25 private class RootFile {
441.26 String repositoryPath;
441.27 String rootLocalPath;
441.28 }
441.29 - private Set<SVNUrl> repositoryRoots;
441.30 private RootFile rootFile;
441.31
441.32 /**
441.33 @@ -78,6 +80,9 @@
441.34
441.35 {
441.36 ResourceBundle loc = NbBundle.getBundle(CommitTableModel.class);
441.37 + columnLabels.put(COLUMN_NAME_COMMIT, new String [] {
441.38 + loc.getString("CTL_CommitTable_Column_Commit"), // NOI18N
441.39 + loc.getString("CTL_CommitTable_Column_Description")}); // NOI18N
441.40 columnLabels.put(COLUMN_NAME_NAME, new String [] {
441.41 loc.getString("CTL_CommitTable_Column_File"),
441.42 loc.getString("CTL_CommitTable_Column_File")});
441.43 @@ -97,6 +102,7 @@
441.44
441.45 private CommitOptions [] commitOptions;
441.46 private SvnFileNode [] nodes;
441.47 + private Index index;
441.48
441.49 private String [] columns;
441.50
441.51 @@ -111,6 +117,7 @@
441.52
441.53 void setNodes(SvnFileNode [] nodes) {
441.54 this.nodes = nodes;
441.55 + this.index = new Index();
441.56 defaultCommitOptions();
441.57 fireTableDataChanged();
441.58 }
441.59 @@ -132,35 +139,46 @@
441.60 return ret;
441.61 }
441.62
441.63 + @Override
441.64 public String getColumnName(int column) {
441.65 return columnLabels.get(columns[column])[0];
441.66 }
441.67
441.68 + @Override
441.69 public int getColumnCount() {
441.70 return columns.length;
441.71 }
441.72
441.73 + @Override
441.74 public int getRowCount() {
441.75 return nodes.length;
441.76 }
441.77
441.78 + @Override
441.79 public Class getColumnClass(int columnIndex) {
441.80 String col = columns[columnIndex];
441.81 - if (col.equals(COLUMN_NAME_ACTION)) {
441.82 + if (col.equals(COLUMN_NAME_COMMIT)) {
441.83 + return Boolean.class;
441.84 + } else if (col.equals(COLUMN_NAME_ACTION)) {
441.85 return CommitOptions.class;
441.86 + } else {
441.87 + return String.class;
441.88 }
441.89 - return String.class;
441.90 }
441.91
441.92 + @Override
441.93 public boolean isCellEditable(int rowIndex, int columnIndex) {
441.94 String col = columns[columnIndex];
441.95 - return col.equals(COLUMN_NAME_ACTION);
441.96 + return col.equals(COLUMN_NAME_COMMIT);
441.97 }
441.98
441.99 + @Override
441.100 public Object getValueAt(int rowIndex, int columnIndex) {
441.101 SvnFileNode node;
441.102 String col = columns[columnIndex];
441.103 - if (col.equals(COLUMN_NAME_NAME)) {
441.104 + if (col.equals(COLUMN_NAME_COMMIT)) {
441.105 + return commitOptions[rowIndex] != CommitOptions.EXCLUDE;
441.106 + } else if (col.equals(COLUMN_NAME_NAME)) {
441.107 return nodes[rowIndex].getName();
441.108 } else if (col.equals(COLUMN_NAME_BRANCH)) {
441.109 String branch = nodes[rowIndex].getCopy();
441.110 @@ -190,19 +208,24 @@
441.111 throw new IllegalArgumentException("Column index out of range: " + columnIndex); // NOI18N
441.112 }
441.113
441.114 + @Override
441.115 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
441.116 String col = columns[columnIndex];
441.117 if (col.equals(COLUMN_NAME_ACTION)) {
441.118 commitOptions[rowIndex] = (CommitOptions) aValue;
441.119 - fireTableCellUpdated(rowIndex, columnIndex);
441.120 + } else if (col.equals(COLUMN_NAME_COMMIT)) {
441.121 + commitOptions[rowIndex] = getCommitOptions(rowIndex, ((Boolean) aValue));
441.122 } else {
441.123 throw new IllegalArgumentException("Column index out of range: " + columnIndex); // NOI18N
441.124 }
441.125 + includeExcludeTree(new int[] {rowIndex}, commitOptions[rowIndex] != CommitOptions.EXCLUDE, false);
441.126 + fireTableRowsUpdated(0, getRowCount() - 1);
441.127 }
441.128
441.129 private void defaultCommitOptions() {
441.130 boolean excludeNew = SvnModuleConfig.getDefault().getExludeNewFiles();
441.131 commitOptions = SvnUtils.createDefaultCommitOptions(nodes, excludeNew);
441.132 + ensureFilesExcluded();
441.133 }
441.134
441.135 public SvnFileNode getNode(int row) {
441.136 @@ -213,17 +236,176 @@
441.137 return commitOptions[row];
441.138 }
441.139
441.140 - private Set<SVNUrl> getRepositoryRoots() {
441.141 - if(repositoryRoots == null) {
441.142 - repositoryRoots = new HashSet<SVNUrl>();
441.143 - }
441.144 - return repositoryRoots;
441.145 - }
441.146 -
441.147 void setRootFile(String repositoryPath, String rootLocalPath) {
441.148 rootFile = new RootFile();
441.149 rootFile.repositoryPath = repositoryPath;
441.150 rootFile.rootLocalPath = rootLocalPath;
441.151 }
441.152
441.153 + void setIncluded (int[] rows, boolean include, boolean recursively) {
441.154 + for (int rowIndex : rows) {
441.155 + commitOptions[rowIndex] = getCommitOptions(rowIndex, include);
441.156 + }
441.157 + includeExcludeTree(rows, include, recursively);
441.158 + fireTableRowsUpdated(0, getRowCount() - 1);
441.159 + }
441.160 +
441.161 + void setAdded (int[] rows, CommitOptions addOption) {
441.162 + for (int rowIndex : rows) {
441.163 + commitOptions[rowIndex] = addOption;
441.164 + }
441.165 + includeExcludeTree(rows, true, false);
441.166 + fireTableRowsUpdated(0, getRowCount() - 1);
441.167 + }
441.168 +
441.169 + private void includeExcludeTree (int[] rows, boolean include, boolean recursively) {
441.170 + LinkedList<Integer> rowList = new LinkedList<Integer>();
441.171 + for (int row : rows) {
441.172 + rowList.add(row);
441.173 + }
441.174 + if (include) {
441.175 + includeExcludeChildren(rowList, recursively ? FileInformation.STATUS_ALL : STATUS_DELETED, true);
441.176 + includeExcludeParents(rowList, STATUS_NEW, true);
441.177 + } else {
441.178 + includeExcludeChildren(rowList, recursively ? FileInformation.STATUS_ALL : STATUS_NEW, false);
441.179 + includeExcludeParents(rowList, STATUS_DELETED, false);
441.180 + }
441.181 + }
441.182 +
441.183 + private CommitOptions getCommitOptions (int rowIndex, boolean include) {
441.184 + return include ? getCommitOptions(rowIndex) : CommitOptions.EXCLUDE;
441.185 + }
441.186 +
441.187 + private CommitOptions getCommitOptions (int rowIndex) {
441.188 + SvnFileNode node = nodes[rowIndex];
441.189 + return SvnUtils.getDefaultCommitOptions(node, false);
441.190 + }
441.191 +
441.192 + private void ensureFilesExcluded () {
441.193 + LinkedList<Integer> newFilesExcluded = new LinkedList<Integer>();
441.194 + LinkedList<Integer> deletedFilesExcluded = new LinkedList<Integer>();
441.195 + for (int i = 0; i < nodes.length; ++i) {
441.196 + SvnFileNode node = nodes[i];
441.197 + if (CommitOptions.EXCLUDE.equals(commitOptions[i])
441.198 + && (node.getInformation().getStatus() & (STATUS_NEW)) != 0) {
441.199 + newFilesExcluded.add(i);
441.200 + } else if (CommitOptions.EXCLUDE.equals(commitOptions[i])
441.201 + && (node.getInformation().getStatus() & (STATUS_DELETED)) != 0) {
441.202 + deletedFilesExcluded.add(i);
441.203 + }
441.204 + }
441.205 + includeExcludeChildren(newFilesExcluded, STATUS_NEW, false);
441.206 + includeExcludeParents(deletedFilesExcluded, STATUS_DELETED, false);
441.207 + }
441.208 +
441.209 + private void includeExcludeParents (Collection<Integer> nodeIndexes, int statusMask, boolean include) {
441.210 + boolean includeExcludeWholeTree = include && (statusMask & (STATUS_DELETED)) != 0
441.211 + || !include && (statusMask & (STATUS_NEW)) != 0;
441.212 + HashSet<Integer> toCheck = new HashSet<Integer>();
441.213 + boolean[] checkedNodes = new boolean[nodes.length];
441.214 + outer:
441.215 + for (int nodeIndex : nodeIndexes) {
441.216 + checkedNodes[nodeIndex] = true;
441.217 + Integer parentIndex = nodeIndex;
441.218 + while (parentIndex != null && (nodes[parentIndex].getInformation().getStatus() & statusMask) != 0) {
441.219 + nodeIndex = parentIndex;
441.220 + if (!includeExcludeWholeTree
441.221 + && includeExcludeEnabled(nodeIndex, include)) { // do not include already included file, which could reset Add as Binary to Add as Text and vice versa
441.222 + commitOptions[nodeIndex] = getCommitOptions(nodeIndex, include);
441.223 + }
441.224 + parentIndex = index.getParent(nodeIndex);
441.225 + if (parentIndex != null && checkedNodes[parentIndex]) {
441.226 + continue outer;
441.227 + }
441.228 + }
441.229 + toCheck.add(nodeIndex);
441.230 + }
441.231 + if (includeExcludeWholeTree) {
441.232 + includeExcludeChildren(toCheck, statusMask, include);
441.233 + }
441.234 + }
441.235 +
441.236 + private void includeExcludeChildren (Collection<Integer> nodeIndexes, int statusMask, boolean include) {
441.237 + boolean[] checkedNodes = new boolean[nodes.length];
441.238 + HashSet<Integer> toCheck = new HashSet<Integer>();
441.239 + for (int nodeIndex : nodeIndexes) {
441.240 + toCheck.add(nodeIndex);
441.241 + }
441.242 + while (!toCheck.isEmpty()) {
441.243 + Iterator<Integer> it = toCheck.iterator();
441.244 + Integer nodeIndex = it.next();
441.245 + it.remove();
441.246 + if (checkedNodes[nodeIndex]) {
441.247 + continue;
441.248 + }
441.249 + checkedNodes[nodeIndex] = true;
441.250 + SvnFileNode node = nodes[nodeIndex];
441.251 + if ((node.getInformation().getStatus() & statusMask) != 0) {
441.252 + if (includeExcludeEnabled(nodeIndex, include)) { // do not include already included file, which could reset Add as Binary to Add as Text and vice versa
441.253 + commitOptions[nodeIndex] = getCommitOptions(nodeIndex, include);
441.254 + }
441.255 + Integer[] childrenIndexes = index.getChildren(nodeIndex);
441.256 + if (childrenIndexes != null) {
441.257 + toCheck.addAll(Arrays.asList(childrenIndexes));
441.258 + }
441.259 + }
441.260 + }
441.261 + }
441.262 +
441.263 + private boolean includeExcludeEnabled (int nodeIndex, boolean include) {
441.264 + return !include || commitOptions[nodeIndex] == CommitOptions.EXCLUDE;
441.265 + }
441.266 +
441.267 + private class Index {
441.268 +
441.269 + private HashMap<File, Value> fileToIndex;
441.270 +
441.271 + public Index() {
441.272 + constructIndex();
441.273 + }
441.274 +
441.275 + private void constructIndex () {
441.276 + fileToIndex = new HashMap<File, Value>(nodes.length);
441.277 + for (int i = 0; i < nodes.length; ++i) {
441.278 + Value value = new Value(i);
441.279 + fileToIndex.put(nodes[i].getFile(), value);
441.280 + }
441.281 + for (int i = 0; i < nodes.length; ++i) {
441.282 + File parentFile = nodes[i].getFile().getParentFile();
441.283 + if (parentFile != null) {
441.284 + Value value = fileToIndex.get(parentFile);
441.285 + if (value != null) {
441.286 + value.addChild(i);
441.287 + }
441.288 + }
441.289 + }
441.290 + }
441.291 +
441.292 + private Integer getParent (int nodeIndex) {
441.293 + File parentFile = nodes[nodeIndex].getFile().getParentFile();
441.294 + Value parentValue = parentFile == null ? null : fileToIndex.get(parentFile);
441.295 + return parentValue == null ? null : parentValue.nodeIndex;
441.296 + }
441.297 +
441.298 + private Integer[] getChildren (int nodeIndex) {
441.299 + Value value = fileToIndex.get(nodes[nodeIndex].getFile());
441.300 + return value == null || value.childrenIndexes == null ? null : value.childrenIndexes.toArray(new Integer[value.childrenIndexes.size()]);
441.301 + }
441.302 +
441.303 + private class Value {
441.304 + private Integer nodeIndex;
441.305 + private Set<Integer> childrenIndexes;
441.306 +
441.307 + private Value(int index) {
441.308 + this.nodeIndex = index;
441.309 + }
441.310 +
441.311 + private void addChild(int childIndex) {
441.312 + if (childrenIndexes == null) {
441.313 + childrenIndexes = new HashSet<Integer>();
441.314 + }
441.315 + childrenIndexes.add(childIndex);
441.316 + }
441.317 + }
441.318 + }
441.319 }
442.1 --- a/subversion/src/org/netbeans/modules/subversion/ui/wizards/importstep/ImportStep.java Mon Feb 01 12:23:06 2010 +0100
442.2 +++ b/subversion/src/org/netbeans/modules/subversion/ui/wizards/importstep/ImportStep.java Mon Feb 01 12:24:26 2010 +0100
442.3 @@ -60,7 +60,7 @@
442.4 import org.netbeans.modules.subversion.ui.browser.BrowserAction;
442.5 import org.netbeans.modules.subversion.ui.browser.RepositoryPaths;
442.6 import org.netbeans.modules.subversion.ui.checkout.CheckoutAction;
442.7 -import org.netbeans.modules.subversion.util.FileUtils;
442.8 +import org.netbeans.modules.versioning.util.FileUtils;
442.9 import org.netbeans.modules.subversion.util.SvnUtils;
442.10 import org.openide.DialogDisplayer;
442.11 import org.openide.NotifyDescriptor;
443.1 --- a/subversion/src/org/netbeans/modules/subversion/util/FileUtils.java Mon Feb 01 12:23:06 2010 +0100
443.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
443.3 @@ -1,331 +0,0 @@
443.4 -/*
443.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
443.6 - *
443.7 - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
443.8 - *
443.9 - * The contents of this file are subject to the terms of either the GNU
443.10 - * General Public License Version 2 only ("GPL") or the Common
443.11 - * Development and Distribution License("CDDL") (collectively, the
443.12 - * "License"). You may not use this file except in compliance with the
443.13 - * License. You can obtain a copy of the License at
443.14 - * http://www.netbeans.org/cddl-gplv2.html
443.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
443.16 - * specific language governing permissions and limitations under the
443.17 - * License. When distributing the software, include this License Header
443.18 - * Notice in each file and include the License file at
443.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
443.20 - * particular file as subject to the "Classpath" exception as provided
443.21 - * by Sun in the GPL Version 2 section of the License file that
443.22 - * accompanied this code. If applicable, add the following below the
443.23 - * License Header, with the fields enclosed by brackets [] replaced by
443.24 - * your own identifying information:
443.25 - * "Portions Copyrighted [year] [name of copyright owner]"
443.26 - *
443.27 - * Contributor(s):
443.28 - *
443.29 - * The Original Software is NetBeans. The Initial Developer of the Original
443.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
443.31 - * Microsystems, Inc. All Rights Reserved.
443.32 - *
443.33 - * If you wish your version of this file to be governed by only the CDDL
443.34 - * or only the GPL Version 2, indicate your decision by adding
443.35 - * "[Contributor] elects to include this software in this distribution
443.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
443.37 - * single choice of license, a recipient has the option to distribute
443.38 - * your version of this file under either the CDDL, the GPL Version 2 or
443.39 - * to extend the choice of license to its licensees as provided above.
443.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
443.41 - * Version 2 license, then the option applies only if the new code is
443.42 - * made subject to such option by the copyright holder.
443.43 - */
443.44 -
443.45 -package org.netbeans.modules.subversion.util;
443.46 -
443.47 -import java.io.*;
443.48 -import java.util.logging.Level;
443.49 -import org.netbeans.modules.subversion.Subversion;
443.50 -import org.openide.filesystems.FileUtil;
443.51 -
443.52 -/**
443.53 - *
443.54 - * @author pkuzel
443.55 - */
443.56 -public class FileUtils {
443.57 -
443.58 - /**
443.59 - * Copies the specified sourceFile to the specified targetFile.
443.60 - */
443.61 - public static void copyFile(File sourceFile, File targetFile) throws IOException {
443.62 - if (sourceFile == null || targetFile == null) {
443.63 - throw new NullPointerException("sourceFile and targetFile must not be null"); // NOI18N
443.64 - }
443.65 -
443.66 - InputStream inputStream = null;
443.67 - try {
443.68 - inputStream = createInputStream(sourceFile);
443.69 - copyStreamToFile(inputStream, targetFile);
443.70 - } finally {
443.71 - if (inputStream != null) {
443.72 - try {
443.73 - inputStream.close();
443.74 - }
443.75 - catch (IOException ex) {
443.76 - // ignore
443.77 - }
443.78 - }
443.79 - }
443.80 - }
443.81 -
443.82 - public static void copyDirFiles(File sourceDir, File targetDir) {
443.83 - copyDirFiles(sourceDir, targetDir, false);
443.84 - }
443.85 -
443.86 - public static void copyDirFiles(File sourceDir, File targetDir, boolean preserveTimestamp) {
443.87 - File[] files = sourceDir.listFiles();
443.88 -
443.89 - if(files==null || files.length == 0) {
443.90 - targetDir.mkdirs();
443.91 - if(preserveTimestamp) targetDir.setLastModified(sourceDir.lastModified());
443.92 - return;
443.93 - }
443.94 - if(preserveTimestamp) targetDir.setLastModified(sourceDir.lastModified());
443.95 - for (int i = 0; i < files.length; i++) {
443.96 - try {
443.97 - File target = FileUtil.normalizeFile(new File(targetDir.getAbsolutePath() + "/" + files[i].getName())); // NOI18N
443.98 - if(files[i].isDirectory()) {
443.99 - copyDirFiles(files[i], target, preserveTimestamp);
443.100 - } else {
443.101 - FileUtils.copyFile (files[i], target);
443.102 - if(preserveTimestamp) target.setLastModified(files[i].lastModified());
443.103 - }
443.104 - } catch (IOException ex) {
443.105 - Subversion.LOG.log(Level.INFO, null, ex); // should not happen
443.106 - }
443.107 - }
443.108 - }
443.109 -
443.110 - /**
443.111 - * Copies the specified sourceFile to the specified targetFile.
443.112 - * It <b>closes</b> the input stream.
443.113 - */
443.114 - public static void copyStreamToFile(InputStream inputStream, File targetFile) throws IOException {
443.115 - if (inputStream == null || targetFile == null) {
443.116 - throw new NullPointerException("sourcStream and targetFile must not be null"); // NOI18N
443.117 - }
443.118 -
443.119 - // ensure existing parent directories
443.120 - File directory = targetFile.getParentFile();
443.121 - if (!directory.exists() && !directory.mkdirs()) {
443.122 - throw new IOException("Could not create directory '" + directory + "'"); // NOI18N
443.123 - }
443.124 -
443.125 - OutputStream outputStream = null;
443.126 - try {
443.127 - outputStream = createOutputStream(targetFile);
443.128 - try {
443.129 - byte[] buffer = new byte[32768];
443.130 - for (int readBytes = inputStream.read(buffer);
443.131 - readBytes > 0;
443.132 - readBytes = inputStream.read(buffer)) {
443.133 - outputStream.write(buffer, 0, readBytes);
443.134 - }
443.135 - }
443.136 - catch (IOException ex) {
443.137 - targetFile.delete();
443.138 - throw ex;
443.139 - }
443.140 - }
443.141 - finally {
443.142 - if (inputStream != null) {
443.143 - try {
443.144 - inputStream.close();
443.145 - }
443.146 - catch (IOException ex) {
443.147 - // ignore
443.148 - }
443.149 - }
443.150 - if (outputStream != null) {
443.151 - try {
443.152 - outputStream.close();
443.153 - }
443.154 - catch (IOException ex) {
443.155 - // ignore
443.156 - }
443.157 - }
443.158 - }
443.159 - }
443.160 -
443.161 - /**
443.162 - * Reads the data from the <code>file</code> and returns it as an array of bytes.
443.163 - * @param file file to be read
443.164 - * @return file contents as a byte array
443.165 - * @throws java.io.IOException
443.166 - */
443.167 - public static byte[] getFileContentsAsByteArray (File file) throws IOException {
443.168 - ByteArrayOutputStream baos = new ByteArrayOutputStream(1024 * 5);
443.169 - BufferedInputStream bis = null;
443.170 - try {
443.171 - bis = createInputStream(file);
443.172 - byte[] buffer = new byte[1024];
443.173 - for (int byteRead = bis.read(buffer); byteRead > 0; byteRead = bis.read(buffer)) {
443.174 - baos.write(buffer, 0, byteRead);
443.175 - }
443.176 - } finally {
443.177 - if (bis != null) {
443.178 - bis.close();
443.179 - }
443.180 - }
443.181 - return baos.toByteArray();
443.182 - }
443.183 -
443.184 - /**
443.185 - * Recursively deletes all files and directories under a given file/directory.
443.186 - *
443.187 - * @param file file/directory to delete
443.188 - */
443.189 - public static void deleteRecursively(File file) {
443.190 - if (file.isDirectory()) {
443.191 - File [] files = file.listFiles();
443.192 - for (int i = 0; i < files.length; i++) {
443.193 - deleteRecursively(files[i]);
443.194 - }
443.195 - }
443.196 - file.delete();
443.197 - }
443.198 -
443.199 - /**
443.200 - * Do the best to rename the file.
443.201 - * @param orig regular file
443.202 - * @param dest regular file (if exists it's rewritten)
443.203 - */
443.204 - public static void renameFile(File orig, File dest) throws IOException {
443.205 - boolean destExists = dest.exists();
443.206 - if (destExists) {
443.207 - for (int i = 0; i<3; i++) {
443.208 - if (dest.delete()) {
443.209 - destExists = false;
443.210 - break;
443.211 - }
443.212 - try {
443.213 - Thread.sleep(71);
443.214 - } catch (InterruptedException e) {
443.215 - }
443.216 - }
443.217 - }
443.218 -
443.219 - if (destExists == false) {
443.220 - for (int i = 0; i<3; i++) {
443.221 - if (orig.renameTo(dest)) {
443.222 - return;
443.223 - }
443.224 - try {
443.225 - Thread.sleep(71);
443.226 - } catch (InterruptedException e) {
443.227 - }
443.228 - }
443.229 - }
443.230 -
443.231 - // requires less permisions than renameTo
443.232 - FileUtils.copyFile(orig, dest);
443.233 -
443.234 - for (int i = 0; i<3; i++) {
443.235 - if (orig.delete()) {
443.236 - return;
443.237 - }
443.238 - try {
443.239 - Thread.sleep(71);
443.240 - } catch (InterruptedException e) {
443.241 - }
443.242 - }
443.243 - throw new IOException("Can not delete: " + orig.getAbsolutePath()); // NOI18N
443.244 - }
443.245 -
443.246 - /**
443.247 - * This utility class needs not to be instantiated anywhere.
443.248 - */
443.249 - private FileUtils() {
443.250 - }
443.251 -
443.252 - public static BufferedInputStream createInputStream(File file) throws IOException {
443.253 - int retry = 0;
443.254 - while (true) {
443.255 - try {
443.256 - return new BufferedInputStream(new FileInputStream(file));
443.257 - } catch (IOException ex) {
443.258 - retry++;
443.259 - if (retry > 7) {
443.260 - throw ex;
443.261 - }
443.262 - try {
443.263 - Thread.sleep(retry * 34);
443.264 - } catch (InterruptedException iex) {
443.265 - throw ex;
443.266 - }
443.267 - }
443.268 - }
443.269 - }
443.270 -
443.271 - public static BufferedOutputStream createOutputStream(File file) throws IOException {
443.272 - int retry = 0;
443.273 - while (true) {
443.274 - try {
443.275 - return new BufferedOutputStream(new FileOutputStream(file));
443.276 - } catch (IOException ex) {
443.277 - retry++;
443.278 - if (retry > 7) {
443.279 - throw ex;
443.280 - }
443.281 - try {
443.282 - Thread.sleep(retry * 34);
443.283 - } catch (InterruptedException iex) {
443.284 - throw ex;
443.285 - }
443.286 - }
443.287 - }
443.288 - }
443.289 -
443.290 - /** Creates new tmp dir in java.io.tmpdir */
443.291 - public static File createTmpFolder(String prefix) {
443.292 - String tmpDir = System.getProperty("java.io.tmpdir"); // NOI18N
443.293 - File tmpFolder = new File(tmpDir);
443.294 - File checkoutFolder = null;
443.295 - try {
443.296 - // generate unique name for tmp folder
443.297 - File tmp = File.createTempFile(prefix, "", tmpFolder); // NOI18N
443.298 - if (tmp.delete() == false) {
443.299 - return checkoutFolder;
443.300 - }
443.301 - if (tmp.mkdirs() == false) {
443.302 - return checkoutFolder;
443.303 - }
443.304 - checkoutFolder = FileUtil.normalizeFile(tmp);
443.305 - } catch (IOException e) {
443.306 - Subversion.LOG.log(Level.SEVERE, null, e);
443.307 - }
443.308 - return checkoutFolder;
443.309 - }
443.310 -
443.311 - /**
443.312 - * Returns the first found file whose filename is the same (in a case insensitive way) as given <code>file</code>'s.
443.313 - * @param file
443.314 - * @return the first found file with the same name, but ignoring case, or <code>null</code> if no such file is found.
443.315 - */
443.316 - public static String getExistingFilenameInParent(File file) {
443.317 - String filename = null;
443.318 - if (file == null) {
443.319 - return filename;
443.320 - }
443.321 - File parent = file.getParentFile();
443.322 - if (parent == null) {
443.323 - return filename;
443.324 - }
443.325 - File[] children = parent.listFiles();
443.326 - for (File child : children) {
443.327 - if (file.getName().equalsIgnoreCase(child.getName())) {
443.328 - filename = child.getName();
443.329 - break;
443.330 - }
443.331 - }
443.332 - return filename;
443.333 - }
443.334 -}
444.1 --- a/subversion/src/org/netbeans/modules/subversion/util/SvnUtils.java Mon Feb 01 12:23:06 2010 +0100
444.2 +++ b/subversion/src/org/netbeans/modules/subversion/util/SvnUtils.java Mon Feb 01 12:24:26 2010 +0100
444.3 @@ -1361,17 +1361,7 @@
444.4 if (SvnModuleConfig.getDefault().isExcludedFromCommit(file.getAbsolutePath())) {
444.5 commitOptions[i] = CommitOptions.EXCLUDE;
444.6 } else {
444.7 - switch (node.getInformation().getStatus()) {
444.8 - case FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY:
444.9 - commitOptions[i] = excludeNew ? CommitOptions.EXCLUDE : getDefaultCommitOptions(node.getFile());
444.10 - break;
444.11 - case FileInformation.STATUS_VERSIONED_DELETEDLOCALLY:
444.12 - case FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY:
444.13 - commitOptions[i] = CommitOptions.COMMIT_REMOVE;
444.14 - break;
444.15 - default:
444.16 - commitOptions[i] = CommitOptions.COMMIT;
444.17 - }
444.18 + commitOptions[i] = getDefaultCommitOptions(node, excludeNew);
444.19 }
444.20 }
444.21 return commitOptions;
444.22 @@ -1434,9 +1424,32 @@
444.23 }
444.24 }
444.25
444.26 - private static CommitOptions getDefaultCommitOptions(File file) {
444.27 - if (file.isFile()) {
444.28 - if (getMimeType(file).startsWith("text")) {
444.29 + /**
444.30 + * Similar to {@link #getDefaultCommitOptions(org.netbeans.modules.subversion.SvnFileNode, boolean) } but does not consider exclusions, so
444.31 + * the return value will always be a variation of {@link CommitOptions#COMMIT } (unless excludeNew is set to true)
444.32 + * @param node
444.33 + * @param excludeNew
444.34 + * @return
444.35 + */
444.36 + public static CommitOptions getDefaultCommitOptions (SvnFileNode node, boolean excludeNew) {
444.37 + CommitOptions commitOptions;
444.38 + switch (node.getInformation().getStatus()) {
444.39 + case FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY:
444.40 + commitOptions = excludeNew ? CommitOptions.EXCLUDE : getDefaultCommitOptions(node);
444.41 + break;
444.42 + case FileInformation.STATUS_VERSIONED_DELETEDLOCALLY:
444.43 + case FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY:
444.44 + commitOptions = CommitOptions.COMMIT_REMOVE;
444.45 + break;
444.46 + default:
444.47 + commitOptions = CommitOptions.COMMIT;
444.48 + }
444.49 + return commitOptions;
444.50 + }
444.51 +
444.52 + private static CommitOptions getDefaultCommitOptions(SvnFileNode node) {
444.53 + if (node.isFile()) {
444.54 + if (node.getMimeType().startsWith("text")) { //NOI18N
444.55 return CommitOptions.ADD_TEXT;
444.56 } else {
444.57 return CommitOptions.ADD_BINARY;
444.58 @@ -1445,4 +1458,4 @@
444.59 return CommitOptions.ADD_DIRECTORY;
444.60 }
444.61 }
444.62 - }
444.63 +}
445.1 --- a/subversion/test/unit/src/org/netbeans/modules/subversion/AbstractSvnTest.java Mon Feb 01 12:23:06 2010 +0100
445.2 +++ b/subversion/test/unit/src/org/netbeans/modules/subversion/AbstractSvnTest.java Mon Feb 01 12:24:26 2010 +0100
445.3 @@ -55,7 +55,7 @@
445.4 import org.openide.filesystems.FileUtil;
445.5 import org.openide.loaders.DataObject;
445.6 import org.openide.util.Exceptions;
445.7 -import org.netbeans.modules.subversion.util.FileUtils;
445.8 +import org.netbeans.modules.versioning.util.FileUtils;
445.9 import org.netbeans.modules.subversion.utils.TestUtilities;
445.10 import org.netbeans.modules.versioning.util.Utils;
445.11 import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
446.1 --- a/subversion/test/unit/src/org/netbeans/modules/subversion/ApiTest.java Mon Feb 01 12:23:06 2010 +0100
446.2 +++ b/subversion/test/unit/src/org/netbeans/modules/subversion/ApiTest.java Mon Feb 01 12:24:26 2010 +0100
446.3 @@ -47,7 +47,7 @@
446.4 import java.util.logging.Level;
446.5 import org.netbeans.junit.NbTestCase;
446.6 import org.netbeans.modules.subversion.ui.wizards.checkoutstep.CheckoutStep;
446.7 -import org.netbeans.modules.subversion.util.FileUtils;
446.8 +import org.netbeans.modules.versioning.util.FileUtils;
446.9 import org.netbeans.modules.subversion.util.SvnUtils;
446.10 import org.netbeans.modules.subversion.utils.TestUtilities;
446.11 import org.tigris.subversion.svnclientadapter.ISVNInfo;
447.1 --- a/subversion/test/unit/src/org/netbeans/modules/subversion/client/AbstractCommandTest.java Mon Feb 01 12:23:06 2010 +0100
447.2 +++ b/subversion/test/unit/src/org/netbeans/modules/subversion/client/AbstractCommandTest.java Mon Feb 01 12:24:26 2010 +0100
447.3 @@ -63,7 +63,7 @@
447.4 import java.util.TreeSet;
447.5 import org.netbeans.modules.subversion.AbstractSvnTest;
447.6 import org.netbeans.modules.subversion.Subversion;
447.7 -import org.netbeans.modules.subversion.util.FileUtils;
447.8 +import org.netbeans.modules.versioning.util.FileUtils;
447.9 import org.netbeans.modules.subversion.utils.TestUtilities;
447.10 import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
447.11 import org.tigris.subversion.svnclientadapter.ISVNDirEntry;
448.1 --- a/subversion/test/unit/src/org/netbeans/modules/subversion/client/cli/AbstractCLITest.java Mon Feb 01 12:23:06 2010 +0100
448.2 +++ b/subversion/test/unit/src/org/netbeans/modules/subversion/client/cli/AbstractCLITest.java Mon Feb 01 12:24:26 2010 +0100
448.3 @@ -55,7 +55,7 @@
448.4 import java.util.Set;
448.5 import org.netbeans.modules.subversion.AbstractSvnTest;
448.6 import org.netbeans.modules.subversion.Subversion;
448.7 -import org.netbeans.modules.subversion.util.FileUtils;
448.8 +import org.netbeans.modules.versioning.util.FileUtils;
448.9 import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
448.10 import org.tigris.subversion.svnclientadapter.ISVNDirEntry;
448.11 import org.tigris.subversion.svnclientadapter.ISVNInfo;
449.1 --- a/subversion/test/unit/src/org/netbeans/modules/subversion/client/cli/RelocateTest.java Mon Feb 01 12:23:06 2010 +0100
449.2 +++ b/subversion/test/unit/src/org/netbeans/modules/subversion/client/cli/RelocateTest.java Mon Feb 01 12:24:26 2010 +0100
449.3 @@ -40,7 +40,7 @@
449.4 package org.netbeans.modules.subversion.client.cli;
449.5
449.6 import java.io.File;
449.7 -import org.netbeans.modules.subversion.util.FileUtils;
449.8 +import org.netbeans.modules.versioning.util.FileUtils;
449.9 import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
449.10 import org.tigris.subversion.svnclientadapter.SVNUrl;
449.11
450.1 --- a/subversion/test/unit/src/org/netbeans/modules/subversion/client/commands/RelocateTest.java Mon Feb 01 12:23:06 2010 +0100
450.2 +++ b/subversion/test/unit/src/org/netbeans/modules/subversion/client/commands/RelocateTest.java Mon Feb 01 12:24:26 2010 +0100
450.3 @@ -41,7 +41,7 @@
450.4
450.5 import org.netbeans.modules.subversion.client.AbstractCommandTest;
450.6 import java.io.File;
450.7 -import org.netbeans.modules.subversion.util.FileUtils;
450.8 +import org.netbeans.modules.versioning.util.FileUtils;
450.9 import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
450.10 import org.tigris.subversion.svnclientadapter.SVNUrl;
450.11
451.1 --- a/versioning.util/src/org/netbeans/modules/versioning/util/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
451.2 +++ b/versioning.util/src/org/netbeans/modules/versioning/util/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
451.3 @@ -91,3 +91,15 @@
451.4 CTL_FileSelector_Select=Select
451.5
451.6 MSG_NotificationBubble_Title=Recent changes in the repository.
451.7 +TemplatesPanel.jLabel1.text=Template:
451.8 +TemplatesPanel.autoFillInCheckBox.text=Automatically fill into commit message
451.9 +TemplatesPanel.openButton.text=&Load File...
451.10 +TemplatesPanel.saveButton.text=&Save as File...
451.11 +CTL_TemplateTitle=Select Template
451.12 +TemplatesPanel.openButton.actionCommand=Load File...
451.13 +CTL_SelectTemplate=Select Template File
451.14 +ACSD_SelectTemplate =Lets you to browse for a template file
451.15 +CTL_Load=Load
451.16 +CTL_Save=Save
451.17 +LBL_FileTooBig=File too big
451.18 +MSG_FileTooBig=The selected file seems to be too big. Do you want to open it anyway?
451.19 \ No newline at end of file
452.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
452.2 +++ b/versioning.util/src/org/netbeans/modules/versioning/util/FileUtils.java Mon Feb 01 12:24:26 2010 +0100
452.3 @@ -0,0 +1,330 @@
452.4 +/*
452.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
452.6 + *
452.7 + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
452.8 + *
452.9 + * The contents of this file are subject to the terms of either the GNU
452.10 + * General Public License Version 2 only ("GPL") or the Common
452.11 + * Development and Distribution License("CDDL") (collectively, the
452.12 + * "License"). You may not use this file except in compliance with the
452.13 + * License. You can obtain a copy of the License at
452.14 + * http://www.netbeans.org/cddl-gplv2.html
452.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
452.16 + * specific language governing permissions and limitations under the
452.17 + * License. When distributing the software, include this License Header
452.18 + * Notice in each file and include the License file at
452.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
452.20 + * particular file as subject to the "Classpath" exception as provided
452.21 + * by Sun in the GPL Version 2 section of the License file that
452.22 + * accompanied this code. If applicable, add the following below the
452.23 + * License Header, with the fields enclosed by brackets [] replaced by
452.24 + * your own identifying information:
452.25 + * "Portions Copyrighted [year] [name of copyright owner]"
452.26 + *
452.27 + * Contributor(s):
452.28 + *
452.29 + * The Original Software is NetBeans. The Initial Developer of the Original
452.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
452.31 + * Microsystems, Inc. All Rights Reserved.
452.32 + *
452.33 + * If you wish your version of this file to be governed by only the CDDL
452.34 + * or only the GPL Version 2, indicate your decision by adding
452.35 + * "[Contributor] elects to include this software in this distribution
452.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
452.37 + * single choice of license, a recipient has the option to distribute
452.38 + * your version of this file under either the CDDL, the GPL Version 2 or
452.39 + * to extend the choice of license to its licensees as provided above.
452.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
452.41 + * Version 2 license, then the option applies only if the new code is
452.42 + * made subject to such option by the copyright holder.
452.43 + */
452.44 +
452.45 +package org.netbeans.modules.versioning.util;
452.46 +
452.47 +import java.io.*;
452.48 +import java.util.logging.Level;
452.49 +import org.openide.filesystems.FileUtil;
452.50 +
452.51 +/**
452.52 + *
452.53 + * @author pkuzel
452.54 + */
452.55 +public class FileUtils {
452.56 +
452.57 + /**
452.58 + * Copies the specified sourceFile to the specified targetFile.
452.59 + */
452.60 + public static void copyFile(File sourceFile, File targetFile) throws IOException {
452.61 + if (sourceFile == null || targetFile == null) {
452.62 + throw new NullPointerException("sourceFile and targetFile must not be null"); // NOI18N
452.63 + }
452.64 +
452.65 + InputStream inputStream = null;
452.66 + try {
452.67 + inputStream = createInputStream(sourceFile);
452.68 + copyStreamToFile(inputStream, targetFile);
452.69 + } finally {
452.70 + if (inputStream != null) {
452.71 + try {
452.72 + inputStream.close();
452.73 + }
452.74 + catch (IOException ex) {
452.75 + // ignore
452.76 + }
452.77 + }
452.78 + }
452.79 + }
452.80 +
452.81 + public static void copyDirFiles(File sourceDir, File targetDir) {
452.82 + copyDirFiles(sourceDir, targetDir, false);
452.83 + }
452.84 +
452.85 + public static void copyDirFiles(File sourceDir, File targetDir, boolean preserveTimestamp) {
452.86 + File[] files = sourceDir.listFiles();
452.87 +
452.88 + if(files==null || files.length == 0) {
452.89 + targetDir.mkdirs();
452.90 + if(preserveTimestamp) targetDir.setLastModified(sourceDir.lastModified());
452.91 + return;
452.92 + }
452.93 + if(preserveTimestamp) targetDir.setLastModified(sourceDir.lastModified());
452.94 + for (int i = 0; i < files.length; i++) {
452.95 + try {
452.96 + File target = FileUtil.normalizeFile(new File(targetDir.getAbsolutePath() + "/" + files[i].getName())); // NOI18N
452.97 + if(files[i].isDirectory()) {
452.98 + copyDirFiles(files[i], target, preserveTimestamp);
452.99 + } else {
452.100 + FileUtils.copyFile (files[i], target);
452.101 + if(preserveTimestamp) target.setLastModified(files[i].lastModified());
452.102 + }
452.103 + } catch (IOException ex) {
452.104 + Utils.logWarn(FileUtils.class, ex);
452.105 + }
452.106 + }
452.107 + }
452.108 +
452.109 + /**
452.110 + * Copies the specified sourceFile to the specified targetFile.
452.111 + * It <b>closes</b> the input stream.
452.112 + */
452.113 + public static void copyStreamToFile(InputStream inputStream, File targetFile) throws IOException {
452.114 + if (inputStream == null || targetFile == null) {
452.115 + throw new NullPointerException("sourcStream and targetFile must not be null"); // NOI18N
452.116 + }
452.117 +
452.118 + // ensure existing parent directories
452.119 + File directory = targetFile.getParentFile();
452.120 + if (!directory.exists() && !directory.mkdirs()) {
452.121 + throw new IOException("Could not create directory '" + directory + "'"); // NOI18N
452.122 + }
452.123 +
452.124 + OutputStream outputStream = null;
452.125 + try {
452.126 + outputStream = createOutputStream(targetFile);
452.127 + try {
452.128 + byte[] buffer = new byte[32768];
452.129 + for (int readBytes = inputStream.read(buffer);
452.130 + readBytes > 0;
452.131 + readBytes = inputStream.read(buffer)) {
452.132 + outputStream.write(buffer, 0, readBytes);
452.133 + }
452.134 + }
452.135 + catch (IOException ex) {
452.136 + targetFile.delete();
452.137 + throw ex;
452.138 + }
452.139 + }
452.140 + finally {
452.141 + if (inputStream != null) {
452.142 + try {
452.143 + inputStream.close();
452.144 + }
452.145 + catch (IOException ex) {
452.146 + // ignore
452.147 + }
452.148 + }
452.149 + if (outputStream != null) {
452.150 + try {
452.151 + outputStream.close();
452.152 + }
452.153 + catch (IOException ex) {
452.154 + // ignore
452.155 + }
452.156 + }
452.157 + }
452.158 + }
452.159 +
452.160 + /**
452.161 + * Reads the data from the <code>file</code> and returns it as an array of bytes.
452.162 + * @param file file to be read
452.163 + * @return file contents as a byte array
452.164 + * @throws java.io.IOException
452.165 + */
452.166 + public static byte[] getFileContentsAsByteArray (File file) throws IOException {
452.167 + ByteArrayOutputStream baos = new ByteArrayOutputStream(1024 * 5);
452.168 + BufferedInputStream bis = null;
452.169 + try {
452.170 + bis = createInputStream(file);
452.171 + byte[] buffer = new byte[1024];
452.172 + for (int byteRead = bis.read(buffer); byteRead > 0; byteRead = bis.read(buffer)) {
452.173 + baos.write(buffer, 0, byteRead);
452.174 + }
452.175 + } finally {
452.176 + if (bis != null) {
452.177 + bis.close();
452.178 + }
452.179 + }
452.180 + return baos.toByteArray();
452.181 + }
452.182 +
452.183 + /**
452.184 + * Recursively deletes all files and directories under a given file/directory.
452.185 + *
452.186 + * @param file file/directory to delete
452.187 + */
452.188 + public static void deleteRecursively(File file) {
452.189 + if (file.isDirectory()) {
452.190 + File [] files = file.listFiles();
452.191 + for (int i = 0; i < files.length; i++) {
452.192 + deleteRecursively(files[i]);
452.193 + }
452.194 + }
452.195 + file.delete();
452.196 + }
452.197 +
452.198 + /**
452.199 + * Do the best to rename the file.
452.200 + * @param orig regular file
452.201 + * @param dest regular file (if exists it's rewritten)
452.202 + */
452.203 + public static void renameFile(File orig, File dest) throws IOException {
452.204 + boolean destExists = dest.exists();
452.205 + if (destExists) {
452.206 + for (int i = 0; i<3; i++) {
452.207 + if (dest.delete()) {
452.208 + destExists = false;
452.209 + break;
452.210 + }
452.211 + try {
452.212 + Thread.sleep(71);
452.213 + } catch (InterruptedException e) {
452.214 + }
452.215 + }
452.216 + }
452.217 +
452.218 + if (destExists == false) {
452.219 + for (int i = 0; i<3; i++) {
452.220 + if (orig.renameTo(dest)) {
452.221 + return;
452.222 + }
452.223 + try {
452.224 + Thread.sleep(71);
452.225 + } catch (InterruptedException e) {
452.226 + }
452.227 + }
452.228 + }
452.229 +
452.230 + // requires less permisions than renameTo
452.231 + FileUtils.copyFile(orig, dest);
452.232 +
452.233 + for (int i = 0; i<3; i++) {
452.234 + if (orig.delete()) {
452.235 + return;
452.236 + }
452.237 + try {
452.238 + Thread.sleep(71);
452.239 + } catch (InterruptedException e) {
452.240 + }
452.241 + }
452.242 + throw new IOException("Can not delete: " + orig.getAbsolutePath()); // NOI18N
452.243 + }
452.244 +
452.245 + /**
452.246 + * This utility class needs not to be instantiated anywhere.
452.247 + */
452.248 + private FileUtils() {
452.249 + }
452.250 +
452.251 + public static BufferedInputStream createInputStream(File file) throws IOException {
452.252 + int retry = 0;
452.253 + while (true) {
452.254 + try {
452.255 + return new BufferedInputStream(new FileInputStream(file));
452.256 + } catch (IOException ex) {
452.257 + retry++;
452.258 + if (retry > 7) {
452.259 + throw ex;
452.260 + }
452.261 + try {
452.262 + Thread.sleep(retry * 34);
452.263 + } catch (InterruptedException iex) {
452.264 + throw ex;
452.265 + }
452.266 + }
452.267 + }
452.268 + }
452.269 +
452.270 + public static BufferedOutputStream createOutputStream(File file) throws IOException {
452.271 + int retry = 0;
452.272 + while (true) {
452.273 + try {
452.274 + return new BufferedOutputStream(new FileOutputStream(file));
452.275 + } catch (IOException ex) {
452.276 + retry++;
452.277 + if (retry > 7) {
452.278 + throw ex;
452.279 + }
452.280 + try {
452.281 + Thread.sleep(retry * 34);
452.282 + } catch (InterruptedException iex) {
452.283 + throw ex;
452.284 + }
452.285 + }
452.286 + }
452.287 + }
452.288 +
452.289 + /** Creates new tmp dir in java.io.tmpdir */
452.290 + public static File createTmpFolder(String prefix) {
452.291 + String tmpDir = System.getProperty("java.io.tmpdir"); // NOI18N
452.292 + File tmpFolder = new File(tmpDir);
452.293 + File checkoutFolder = null;
452.294 + try {
452.295 + // generate unique name for tmp folder
452.296 + File tmp = File.createTempFile(prefix, "", tmpFolder); // NOI18N
452.297 + if (tmp.delete() == false) {
452.298 + return checkoutFolder;
452.299 + }
452.300 + if (tmp.mkdirs() == false) {
452.301 + return checkoutFolder;
452.302 + }
452.303 + checkoutFolder = FileUtil.normalizeFile(tmp);
452.304 + } catch (IOException e) {
452.305 + Utils.logError(FileUtils.class, e);
452.306 + }
452.307 + return checkoutFolder;
452.308 + }
452.309 +
452.310 + /**
452.311 + * Returns the first found file whose filename is the same (in a case insensitive way) as given <code>file</code>'s.
452.312 + * @param file
452.313 + * @return the first found file with the same name, but ignoring case, or <code>null</code> if no such file is found.
452.314 + */
452.315 + public static String getExistingFilenameInParent(File file) {
452.316 + String filename = null;
452.317 + if (file == null) {
452.318 + return filename;
452.319 + }
452.320 + File parent = file.getParentFile();
452.321 + if (parent == null) {
452.322 + return filename;
452.323 + }
452.324 + File[] children = parent.listFiles();
452.325 + for (File child : children) {
452.326 + if (file.getName().equalsIgnoreCase(child.getName())) {
452.327 + filename = child.getName();
452.328 + break;
452.329 + }
452.330 + }
452.331 + return filename;
452.332 + }
452.333 +}
453.1 --- a/versioning.util/src/org/netbeans/modules/versioning/util/TableSorter.java Mon Feb 01 12:23:06 2010 +0100
453.2 +++ b/versioning.util/src/org/netbeans/modules/versioning/util/TableSorter.java Mon Feb 01 12:24:26 2010 +0100
453.3 @@ -312,6 +312,10 @@
453.4 return getViewToModel()[viewIndex].modelIndex;
453.5 }
453.6
453.7 + public int viewIndex(int modelIndex) {
453.8 + return getModelToView()[modelIndex];
453.9 + }
453.10 +
453.11 private int[] getModelToView() {
453.12 if (modelToView == null) {
453.13 int n = getViewToModel().length;
454.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
454.2 +++ b/versioning.util/src/org/netbeans/modules/versioning/util/TemplateSelector.java Mon Feb 01 12:24:26 2010 +0100
454.3 @@ -0,0 +1,220 @@
454.4 +
454.5 +/*
454.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
454.7 + *
454.8 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
454.9 + *
454.10 + * The contents of this file are subject to the terms of either the GNU
454.11 + * General Public License Version 2 only ("GPL") or the Common
454.12 + * Development and Distribution License("CDDL") (collectively, the
454.13 + * "License"). You may not use this file except in compliance with the
454.14 + * License. You can obtain a copy of the License at
454.15 + * http://www.netbeans.org/cddl-gplv2.html
454.16 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
454.17 + * specific language governing permissions and limitations under the
454.18 + * License. When distributing the software, include this License Header
454.19 + * Notice in each file and include the License file at
454.20 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
454.21 + * particular file as subject to the "Classpath" exception as provided
454.22 + * by Sun in the GPL Version 2 section of the License file that
454.23 + * accompanied this code. If applicable, add the following below the
454.24 + * License Header, with the fields enclosed by brackets [] replaced by
454.25 + * your own identifying information:
454.26 + * "Portions Copyrighted [year] [name of copyright owner]"
454.27 + *
454.28 + * If you wish your version of this file to be governed by only the CDDL
454.29 + * or only the GPL Version 2, indicate your decision by adding
454.30 + * "[Contributor] elects to include this software in this distribution
454.31 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
454.32 + * single choice of license, a recipient has the option to distribute
454.33 + * your version of this file under either the CDDL, the GPL Version 2 or
454.34 + * to extend the choice of license to its licensees as provided above.
454.35 + * However, if you add GPL Version 2 code and therefore, elected the GPL
454.36 + * Version 2 license, then the option applies only if the new code is
454.37 + * made subject to such option by the copyright holder.
454.38 + *
454.39 + * Contributor(s):
454.40 + *
454.41 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
454.42 + */
454.43 +
454.44 +package org.netbeans.modules.versioning.util;
454.45 +
454.46 +import java.awt.event.ActionEvent;
454.47 +import java.awt.event.ActionListener;
454.48 +import java.io.ByteArrayInputStream;
454.49 +import java.io.File;
454.50 +import java.io.IOException;
454.51 +import java.util.prefs.Preferences;
454.52 +import javax.swing.JFileChooser;
454.53 +import org.openide.DialogDescriptor;
454.54 +import org.openide.DialogDisplayer;
454.55 +import org.openide.NotifyDescriptor;
454.56 +import org.openide.util.HelpCtx;
454.57 +import org.openide.util.NbBundle;
454.58 +
454.59 +/**
454.60 + *
454.61 + * @author Tomas Stupka
454.62 + */
454.63 +public class TemplateSelector implements ActionListener {
454.64 +
454.65 + private static final String KEY_AUTO_FILL = "vcstemplate.autofill"; // NOI18N
454.66 + private static final String KEY_TEMPLATE = "vcstemplate.value"; // NOI18N
454.67 + private static final String KEY_TEMPLATE_FILE = "vcstemplate.templatefile"; // NOI18N
454.68 +
454.69 + private TemplatesPanel panel;
454.70 + private final Preferences preferences;
454.71 +
454.72 + public TemplateSelector(Preferences preferences) {
454.73 + this.preferences = preferences;
454.74 + }
454.75 +
454.76 + public boolean show() {
454.77 + getPanel().autoFillInCheckBox.setSelected(isAutofill());
454.78 + getPanel().templateTextArea.setText(getTemplate());
454.79 + if(showPanel()) {
454.80 + setAutofill(getPanel().autoFillInCheckBox.isSelected());
454.81 + setTemplate(getPanel().templateTextArea.getText());
454.82 + return true;
454.83 + }
454.84 + return false;
454.85 + }
454.86 +
454.87 + private boolean showPanel() {
454.88 + DialogDescriptor descriptor = new DialogDescriptor (
454.89 + getPanel(),
454.90 + NbBundle.getMessage(TemplateSelector.class, "CTL_TemplateTitle"), // NOI18N
454.91 + true,
454.92 + new Object[] {DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION},
454.93 + DialogDescriptor.OK_OPTION,
454.94 + DialogDescriptor.DEFAULT_ALIGN,
454.95 + new HelpCtx(TemplatesPanel.class),
454.96 + null);
454.97 + return DialogDisplayer.getDefault().notify(descriptor) == DialogDescriptor.OK_OPTION;
454.98 + }
454.99 +
454.100 + private TemplatesPanel getPanel() {
454.101 + if(panel == null) {
454.102 + panel = new TemplatesPanel();
454.103 + panel.openButton.addActionListener(this);
454.104 + panel.saveButton.addActionListener(this);
454.105 + }
454.106 + return panel;
454.107 + }
454.108 +
454.109 + public boolean isAutofill() {
454.110 + return preferences.getBoolean(KEY_AUTO_FILL, false);
454.111 + }
454.112 +
454.113 + public String getTemplate() {
454.114 + return preferences.get(KEY_TEMPLATE, ""); // NOI18N
454.115 + }
454.116 +
454.117 + private void setAutofill(boolean bl) {
454.118 + preferences.putBoolean(KEY_AUTO_FILL, bl);
454.119 + }
454.120 +
454.121 + private void setTemplate(String template) {
454.122 + preferences.put(KEY_TEMPLATE, template);
454.123 + }
454.124 +
454.125 + @Override
454.126 + public void actionPerformed(ActionEvent e) {
454.127 + if(e.getSource() == getPanel().openButton) {
454.128 + onOpen();
454.129 + } else if(e.getSource() == getPanel().saveButton) {
454.130 + onSave();
454.131 + }
454.132 + }
454.133 +
454.134 + private void onOpen() {
454.135 + File file = selectFile(JFileChooser.OPEN_DIALOG, NbBundle.getMessage(TemplateSelector.class, "CTL_Load")); // NOI18N
454.136 + if (file == null) {
454.137 + return;
454.138 + }
454.139 +
454.140 + try {
454.141 + byte[] bytes = getFileContentsAsByteArray(file);
454.142 + if (bytes != null) {
454.143 + getPanel().templateTextArea.setText(new String(bytes));
454.144 + }
454.145 + } catch (IOException ex) {
454.146 + Utils.logError(TemplatesPanel.class, ex);
454.147 + }
454.148 + preferences.put(KEY_TEMPLATE_FILE, file.getAbsolutePath());
454.149 + }
454.150 +
454.151 + private void onSave() {
454.152 + File file = selectFile(JFileChooser.SAVE_DIALOG, NbBundle.getMessage(TemplateSelector.class, "CTL_Save")); // NOI18N
454.153 + if (file == null) {
454.154 + return;
454.155 + }
454.156 +
454.157 + String template = getPanel().templateTextArea.getText();
454.158 + try {
454.159 + FileUtils.copyStreamToFile(new ByteArrayInputStream(template.getBytes()), file);
454.160 + } catch (IOException ex) {
454.161 + Utils.logError(TemplatesPanel.class, ex);
454.162 + }
454.163 + preferences.put(KEY_TEMPLATE_FILE, file.getAbsolutePath());
454.164 + }
454.165 +
454.166 + private File selectFile(int dialogType, String approveButtonText) {
454.167 + JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(TemplateSelector.class, "ACSD_SelectTemplate")/*, defaultDir*/);// NOI18N
454.168 + fileChooser.setDialogTitle(NbBundle.getMessage(TemplateSelector.class, "CTL_SelectTemplate"));// NOI18N
454.169 + fileChooser.setMultiSelectionEnabled(false);
454.170 + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
454.171 + fileChooser.setDialogType(dialogType);
454.172 +
454.173 + File file = getTemplateFile();
454.174 +
454.175 +// if(file.isFile() && dialogType == JFileChooser.OPEN_DIALOG) {
454.176 +// fileChooser.setSelectedFile(file);
454.177 +// } else {
454.178 +// fileChooser.setCurrentDirectory(file.isFile() ? file.getParentFile() : file);
454.179 +// }
454.180 + if(file.isFile() ) {
454.181 + fileChooser.setSelectedFile(file);
454.182 + } else {
454.183 + fileChooser.setCurrentDirectory(file);
454.184 + }
454.185 +
454.186 + fileChooser.showDialog(getPanel(), approveButtonText);
454.187 + File f = fileChooser.getSelectedFile();
454.188 + return f;
454.189 + }
454.190 +
454.191 + private File getTemplateFile() {
454.192 + File file = null;
454.193 +
454.194 + String tmpFile = preferences.get(KEY_TEMPLATE_FILE, null);
454.195 + if(tmpFile != null) {
454.196 + file = new File(tmpFile);
454.197 + }
454.198 +
454.199 + if (file == null) {
454.200 + file = new File(System.getProperty("user.home")); // NOI18N
454.201 + }
454.202 + return file;
454.203 + }
454.204 +
454.205 + private static byte[] getFileContentsAsByteArray (File file) throws IOException {
454.206 + long length = file.length();
454.207 + if(length > 1024 * 10) {
454.208 + NotifyDescriptor nd =
454.209 + new NotifyDescriptor(
454.210 + NbBundle.getMessage(TemplateSelector.class, "MSG_FileTooBig"),
454.211 + NbBundle.getMessage(TemplateSelector.class, "LBL_FileTooBig"), // NOI18N
454.212 + NotifyDescriptor.DEFAULT_OPTION,
454.213 + NotifyDescriptor.WARNING_MESSAGE,
454.214 + new Object[] {NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION},
454.215 + NotifyDescriptor.OK_OPTION);
454.216 + if(DialogDisplayer.getDefault().notify(nd) != NotifyDescriptor.OK_OPTION) {
454.217 + return null;
454.218 + }
454.219 + }
454.220 +
454.221 + return FileUtils.getFileContentsAsByteArray(file);
454.222 + }
454.223 +}
455.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
455.2 +++ b/versioning.util/src/org/netbeans/modules/versioning/util/TemplatesPanel.form Mon Feb 01 12:24:26 2010 +0100
455.3 @@ -0,0 +1,113 @@
455.4 +<?xml version="1.0" encoding="UTF-8" ?>
455.5 +
455.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
455.7 + <AuxValues>
455.8 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
455.9 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
455.10 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
455.11 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
455.12 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
455.13 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
455.14 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
455.15 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
455.16 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
455.17 + </AuxValues>
455.18 +
455.19 + <Layout>
455.20 + <DimensionLayout dim="0">
455.21 + <Group type="103" groupAlignment="0" attributes="0">
455.22 + <Group type="102" alignment="0" attributes="0">
455.23 + <EmptySpace max="-2" attributes="0"/>
455.24 + <Group type="103" groupAlignment="0" attributes="0">
455.25 + <Component id="jScrollPane1" alignment="0" pref="486" max="32767" attributes="0"/>
455.26 + <Component id="autoFillInCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
455.27 + <Group type="102" alignment="0" attributes="0">
455.28 + <Component id="openButton" min="-2" max="-2" attributes="0"/>
455.29 + <EmptySpace max="-2" attributes="0"/>
455.30 + <Component id="saveButton" min="-2" max="-2" attributes="0"/>
455.31 + </Group>
455.32 + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
455.33 + </Group>
455.34 + <EmptySpace max="-2" attributes="0"/>
455.35 + </Group>
455.36 + </Group>
455.37 + </DimensionLayout>
455.38 + <DimensionLayout dim="1">
455.39 + <Group type="103" groupAlignment="0" attributes="0">
455.40 + <Group type="102" alignment="1" attributes="0">
455.41 + <EmptySpace max="-2" attributes="0"/>
455.42 + <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
455.43 + <EmptySpace max="-2" attributes="0"/>
455.44 + <Component id="jScrollPane1" pref="236" max="32767" attributes="0"/>
455.45 + <EmptySpace max="-2" attributes="0"/>
455.46 + <Component id="autoFillInCheckBox" min="-2" max="-2" attributes="0"/>
455.47 + <EmptySpace min="-2" max="-2" attributes="0"/>
455.48 + <Group type="103" groupAlignment="3" attributes="0">
455.49 + <Component id="openButton" alignment="3" min="-2" max="-2" attributes="0"/>
455.50 + <Component id="saveButton" alignment="3" min="-2" max="-2" attributes="0"/>
455.51 + </Group>
455.52 + </Group>
455.53 + </Group>
455.54 + </DimensionLayout>
455.55 + </Layout>
455.56 + <SubComponents>
455.57 + <Component class="javax.swing.JLabel" name="jLabel1">
455.58 + <Properties>
455.59 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
455.60 + <ResourceString bundle="org/netbeans/modules/versioning/util/Bundle.properties" key="TemplatesPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
455.61 + </Property>
455.62 + </Properties>
455.63 + </Component>
455.64 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
455.65 + <AuxValues>
455.66 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
455.67 + </AuxValues>
455.68 +
455.69 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
455.70 + <SubComponents>
455.71 + <Component class="javax.swing.JTextArea" name="templateTextArea">
455.72 + <Properties>
455.73 + <Property name="columns" type="int" value="20"/>
455.74 + <Property name="rows" type="int" value="5"/>
455.75 + </Properties>
455.76 + <AuxValues>
455.77 + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
455.78 + </AuxValues>
455.79 + </Component>
455.80 + </SubComponents>
455.81 + </Container>
455.82 + <Component class="javax.swing.JCheckBox" name="autoFillInCheckBox">
455.83 + <Properties>
455.84 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
455.85 + <ResourceString bundle="org/netbeans/modules/versioning/util/Bundle.properties" key="TemplatesPanel.autoFillInCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
455.86 + </Property>
455.87 + </Properties>
455.88 + <AuxValues>
455.89 + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
455.90 + </AuxValues>
455.91 + </Component>
455.92 + <Component class="javax.swing.JButton" name="openButton">
455.93 + <Properties>
455.94 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
455.95 + <ResourceString bundle="org/netbeans/modules/versioning/util/Bundle.properties" key="TemplatesPanel.openButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
455.96 + </Property>
455.97 + <Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
455.98 + <ResourceString bundle="org/netbeans/modules/versioning/util/Bundle.properties" key="TemplatesPanel.openButton.actionCommand" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
455.99 + </Property>
455.100 + </Properties>
455.101 + <AuxValues>
455.102 + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
455.103 + </AuxValues>
455.104 + </Component>
455.105 + <Component class="javax.swing.JButton" name="saveButton">
455.106 + <Properties>
455.107 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
455.108 + <ResourceString bundle="org/netbeans/modules/versioning/util/Bundle.properties" key="TemplatesPanel.saveButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
455.109 + </Property>
455.110 + </Properties>
455.111 + <AuxValues>
455.112 + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
455.113 + </AuxValues>
455.114 + </Component>
455.115 + </SubComponents>
455.116 +</Form>
456.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
456.2 +++ b/versioning.util/src/org/netbeans/modules/versioning/util/TemplatesPanel.java Mon Feb 01 12:24:26 2010 +0100
456.3 @@ -0,0 +1,128 @@
456.4 +/*
456.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
456.6 + *
456.7 + * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
456.8 + *
456.9 + * The contents of this file are subject to the terms of either the GNU
456.10 + * General Public License Version 2 only ("GPL") or the Common
456.11 + * Development and Distribution License("CDDL") (collectively, the
456.12 + * "License"). You may not use this file except in compliance with the
456.13 + * License. You can obtain a copy of the License at
456.14 + * http://www.netbeans.org/cddl-gplv2.html
456.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
456.16 + * specific language governing permissions and limitations under the
456.17 + * License. When distributing the software, include this License Header
456.18 + * Notice in each file and include the License file at
456.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
456.20 + * particular file as subject to the "Classpath" exception as provided
456.21 + * by Sun in the GPL Version 2 section of the License file that
456.22 + * accompanied this code. If applicable, add the following below the
456.23 + * License Header, with the fields enclosed by brackets [] replaced by
456.24 + * your own identifying information:
456.25 + * "Portions Copyrighted [year] [name of copyright owner]"
456.26 + *
456.27 + * If you wish your version of this file to be governed by only the CDDL
456.28 + * or only the GPL Version 2, indicate your decision by adding
456.29 + * "[Contributor] elects to include this software in this distribution
456.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
456.31 + * single choice of license, a recipient has the option to distribute
456.32 + * your version of this file under either the CDDL, the GPL Version 2 or
456.33 + * to extend the choice of license to its licensees as provided above.
456.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
456.35 + * Version 2 license, then the option applies only if the new code is
456.36 + * made subject to such option by the copyright holder.
456.37 + *
456.38 + * Contributor(s):
456.39 + *
456.40 + * Portions Copyrighted 2010 Sun Microsystems, Inc.
456.41 + */
456.42 +
456.43 +/*
456.44 + * TemplatesPanel.java
456.45 + *
456.46 + * Created on Jan 27, 2010, 2:00:23 PM
456.47 + */
456.48 +
456.49 +package org.netbeans.modules.versioning.util;
456.50 +
456.51 +/**
456.52 + *
456.53 + * @author Tomas Stupka
456.54 + */
456.55 +class TemplatesPanel extends javax.swing.JPanel {
456.56 +
456.57 + /** Creates new form TemplatesPanel */
456.58 + public TemplatesPanel() {
456.59 + initComponents();
456.60 + }
456.61 +
456.62 + /** This method is called from within the constructor to
456.63 + * initialize the form.
456.64 + * WARNING: Do NOT modify this code. The content of this method is
456.65 + * always regenerated by the Form Editor.
456.66 + */
456.67 + @SuppressWarnings("unchecked")
456.68 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
456.69 + private void initComponents() {
456.70 +
456.71 + jLabel1 = new javax.swing.JLabel();
456.72 + jScrollPane1 = new javax.swing.JScrollPane();
456.73 +
456.74 + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(TemplatesPanel.class, "TemplatesPanel.jLabel1.text")); // NOI18N
456.75 +
456.76 + templateTextArea.setColumns(20);
456.77 + templateTextArea.setRows(5);
456.78 + jScrollPane1.setViewportView(templateTextArea);
456.79 +
456.80 + org.openide.awt.Mnemonics.setLocalizedText(autoFillInCheckBox, org.openide.util.NbBundle.getMessage(TemplatesPanel.class, "TemplatesPanel.autoFillInCheckBox.text")); // NOI18N
456.81 +
456.82 + org.openide.awt.Mnemonics.setLocalizedText(openButton, org.openide.util.NbBundle.getMessage(TemplatesPanel.class, "TemplatesPanel.openButton.text")); // NOI18N
456.83 + openButton.setActionCommand(org.openide.util.NbBundle.getMessage(TemplatesPanel.class, "TemplatesPanel.openButton.actionCommand")); // NOI18N
456.84 +
456.85 + org.openide.awt.Mnemonics.setLocalizedText(saveButton, org.openide.util.NbBundle.getMessage(TemplatesPanel.class, "TemplatesPanel.saveButton.text")); // NOI18N
456.86 +
456.87 + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
456.88 + this.setLayout(layout);
456.89 + layout.setHorizontalGroup(
456.90 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
456.91 + .add(layout.createSequentialGroup()
456.92 + .addContainerGap()
456.93 + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
456.94 + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
456.95 + .add(autoFillInCheckBox)
456.96 + .add(layout.createSequentialGroup()
456.97 + .add(openButton)
456.98 + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
456.99 + .add(saveButton))
456.100 + .add(jLabel1))
456.101 + .addContainerGap())
456.102 + );
456.103 + layout.setVerticalGroup(
456.104 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
456.105 + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
456.106 + .addContainerGap()
456.107 + .add(jLabel1)
456.108 + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
456.109 + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
456.110 + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
456.111 + .add(autoFillInCheckBox)
456.112 + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
456.113 + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
456.114 + .add(openButton)
456.115 + .add(saveButton)))
456.116 + );
456.117 + }// </editor-fold>//GEN-END:initComponents
456.118 +
456.119 +
456.120 + // Variables declaration - do not modify//GEN-BEGIN:variables
456.121 + final javax.swing.JCheckBox autoFillInCheckBox = new javax.swing.JCheckBox();
456.122 + private javax.swing.JLabel jLabel1;
456.123 + private javax.swing.JScrollPane jScrollPane1;
456.124 + final javax.swing.JButton openButton = new javax.swing.JButton();
456.125 + final javax.swing.JButton saveButton = new javax.swing.JButton();
456.126 + final javax.swing.JTextArea templateTextArea = new javax.swing.JTextArea();
456.127 + // End of variables declaration//GEN-END:variables
456.128 +
456.129 +
456.130 +
456.131 +}
457.1 --- a/versioning.util/src/org/netbeans/modules/versioning/util/Utils.java Mon Feb 01 12:23:06 2010 +0100
457.2 +++ b/versioning.util/src/org/netbeans/modules/versioning/util/Utils.java Mon Feb 01 12:24:26 2010 +0100
457.3 @@ -856,6 +856,16 @@
457.4 * @param caller caller object for logger name determination
457.5 * @param e exception that defines the error
457.6 */
457.7 + public static void logInfo(Class caller, Throwable e) {
457.8 + Logger.getLogger(caller.getName()).log(Level.INFO, e.getMessage(), e);
457.9 + }
457.10 +
457.11 + /**
457.12 + * Convenience method for awkward Logger invocation.
457.13 + *
457.14 + * @param caller caller object for logger name determination
457.15 + * @param e exception that defines the error
457.16 + */
457.17 public static void logWarn(Class caller, Throwable e) {
457.18 Logger.getLogger(caller.getName()).log(Level.WARNING, e.getMessage(), e);
457.19 }
458.1 --- a/web.core.syntax/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
458.2 +++ b/web.core.syntax/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
458.3 @@ -47,7 +47,7 @@
458.4 javac.source=1.6
458.5 javadoc.arch=${basedir}/arch.xml
458.6
458.7 -spec.version.base=2.9.0
458.8 +spec.version.base=2.10.0
458.9
458.10 test.config.validation.includes=\
458.11 **/AutoCompletionTest.class,**/CompletionTest.class
459.1 --- a/web.core.syntax/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
459.2 +++ b/web.core.syntax/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
459.3 @@ -86,8 +86,8 @@
459.4 <build-prerequisite/>
459.5 <compile-dependency/>
459.6 <run-dependency>
459.7 - <release-version>1</release-version>
459.8 - <specification-version>1.19</specification-version>
459.9 + <release-version>2</release-version>
459.10 + <specification-version>2.1</specification-version>
459.11 </run-dependency>
459.12 </dependency>
459.13 <dependency>
460.1 --- a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/JspKit.java Mon Feb 01 12:23:06 2010 +0100
460.2 +++ b/web.core.syntax/src/org/netbeans/modules/web/core/syntax/JspKit.java Mon Feb 01 12:24:26 2010 +0100
460.3 @@ -42,15 +42,9 @@
460.4 package org.netbeans.modules.web.core.syntax;
460.5
460.6
460.7 -import java.util.List;
460.8 import java.util.Map;
460.9 import org.netbeans.editor.ext.ExtKit;
460.10 import org.netbeans.modules.csl.api.KeystrokeHandler;
460.11 -import org.netbeans.modules.csl.core.Language;
460.12 -import org.netbeans.modules.csl.core.LanguageRegistry;
460.13 -import org.netbeans.modules.csl.core.SelectCodeElementAction;
460.14 -import org.netbeans.modules.csl.editor.InstantRenameAction;
460.15 -import org.netbeans.modules.csl.editor.ToggleBlockCommentAction;
460.16 import org.netbeans.modules.editor.NbEditorDocument;
460.17 import org.netbeans.modules.editor.NbEditorKit;
460.18 import org.netbeans.modules.web.core.syntax.deprecated.Jsp11Syntax;
460.19 @@ -81,6 +75,10 @@
460.20 import org.netbeans.editor.BaseKit.InsertBreakAction;
460.21 import org.netbeans.editor.ext.ExtKit.ExtDefaultKeyTypedAction;
460.22 import org.netbeans.editor.ext.ExtKit.ExtDeleteCharAction;
460.23 +import org.netbeans.modules.csl.api.InstantRenameAction;
460.24 +import org.netbeans.modules.csl.api.SelectCodeElementAction;
460.25 +import org.netbeans.modules.csl.api.ToggleBlockCommentAction;
460.26 +import org.netbeans.modules.csl.api.UiUtils;
460.27 import org.netbeans.spi.lexer.MutableTextInput;
460.28
460.29 /**
460.30 @@ -333,18 +331,6 @@
460.31 return new org.openide.util.HelpCtx(JspKit.class);
460.32 }
460.33
460.34 - static KeystrokeHandler getBracketCompletion(Document doc, int offset) {
460.35 - BaseDocument baseDoc = (BaseDocument) doc;
460.36 - List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset);
460.37 - for (Language l : list) {
460.38 - if (l.getBracketCompletion() != null) {
460.39 - return l.getBracketCompletion();
460.40 - }
460.41 - }
460.42 -
460.43 - return null;
460.44 - }
460.45 -
460.46 /**
460.47 * Returns true if bracket completion is enabled in options.
460.48 */
460.49 @@ -384,7 +370,7 @@
460.50 @Override
460.51 protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) {
460.52 if (completionSettingEnabled()) {
460.53 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, caret.getDot());
460.54 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, caret.getDot());
460.55
460.56 if (bracketCompletion != null) {
460.57 try {
460.58 @@ -468,7 +454,7 @@
460.59 Caret caret, String str,
460.60 boolean overwrite) throws BadLocationException {
460.61 if (completionSettingEnabled()) {
460.62 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
460.63 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
460.64
460.65 if (bracketCompletion != null) {
460.66 // TODO - check if we're in a comment etc. and if so, do nothing
460.67 @@ -499,7 +485,7 @@
460.68 BaseDocument doc = (BaseDocument) document;
460.69
460.70 if (completionSettingEnabled()) {
460.71 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
460.72 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
460.73
460.74 if (bracketCompletion != null) {
460.75 try {
460.76 @@ -580,7 +566,7 @@
460.77 @Override
460.78 protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch) throws BadLocationException {
460.79 if (completionSettingEnabled()) {
460.80 - KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
460.81 + KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos);
460.82
460.83 if (bracketCompletion != null) {
460.84 bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch);
461.1 --- a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/resources/layer.xml Mon Feb 01 12:23:06 2010 +0100
461.2 +++ b/web.core.syntax/src/org/netbeans/modules/web/core/syntax/resources/layer.xml Mon Feb 01 12:24:26 2010 +0100
461.3 @@ -54,7 +54,9 @@
461.4 </file>
461.5 <folder name="text">
461.6 <folder name="x-java">
461.7 - <file name="org-netbeans-modules-web-core-syntax-indent-JspJavaIndentTaskFactory.instance"/>
461.8 + <file name="org-netbeans-modules-web-core-syntax-indent-JspJavaIndentTaskFactory.instance">
461.9 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
461.10 + </file>
461.11 <folder name="CodeTemplates">
461.12 <folder name="Defaults">
461.13 <file name="codetemplates.shadow">
461.14 @@ -90,10 +92,18 @@
461.15 <attr name="scrollable" boolvalue="false"/>
461.16 </file>
461.17 </folder>
461.18 - <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance"/>
461.19 - <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
461.20 - <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance"/>
461.21 - <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
461.22 + <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance">
461.23 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
461.24 + </file>
461.25 + <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
461.26 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
461.27 + </file>
461.28 + <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance">
461.29 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
461.30 + </file>
461.31 + <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
461.32 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
461.33 + </file>
461.34 <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
461.35 <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
461.36 <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
461.37 @@ -179,12 +189,20 @@
461.38 <attr name="instanceOf" stringvalue="org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt"/>
461.39 </file>
461.40 </folder>
461.41 - <file name="org-netbeans-modules-web-core-syntax-JspParserFactory.instance"/>
461.42 - <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance"/>
461.43 - <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance"/>
461.44 + <file name="org-netbeans-modules-web-core-syntax-JspParserFactory.instance">
461.45 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
461.46 + </file>
461.47 + <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance">
461.48 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
461.49 + </file>
461.50 + <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance">
461.51 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
461.52 + </file>
461.53 </folder>
461.54 <folder name="x-el">
461.55 - <file name="org-netbeans-modules-web-core-syntax-indent-ExpressionLanguageIndentTaskFactory.instance"/>
461.56 + <file name="org-netbeans-modules-web-core-syntax-indent-ExpressionLanguageIndentTaskFactory.instance">
461.57 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
461.58 + </file>
461.59 </folder>
461.60 <folder name="x-tag">
461.61 <file name="TagImportProcesor.instance">
461.62 @@ -208,10 +226,18 @@
461.63 <attr name="scrollable" boolvalue="false"/>
461.64 </file>
461.65 </folder>
461.66 - <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance"/>
461.67 - <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
461.68 - <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance"/>
461.69 - <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
461.70 + <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance">
461.71 + <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
461.72 + </file>
461.73 + <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
461.74 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
461.75 + </file>
461.76 + <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance">
461.77 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
461.78 + </file>
461.79 + <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
461.80 + <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
461.81 + </file>
461.82 <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.web.core.syntax.resources.Bundle"/>
461.83 <folder name="FontsColors">
461.84 <folder name="NetBeans">
461.85 @@ -285,8 +311,12 @@
461.86 <attr name="instanceOf" stringvalue="org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt"/>
461.87 </file>
461.88 </folder>
461.89 - <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance"/>
461.90 - <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance"/>
461.91 + <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance">
461.92 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
461.93 + </file>
461.94 + <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance">
461.95 + <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
461.96 + </file>
461.97 </folder>
461.98 </folder>
461.99 </folder>
462.1 --- a/web.core.syntax/test/unit/src/org/netbeans/modules/web/core/syntax/formatting/JspIndenterTest.java Mon Feb 01 12:23:06 2010 +0100
462.2 +++ b/web.core.syntax/test/unit/src/org/netbeans/modules/web/core/syntax/formatting/JspIndenterTest.java Mon Feb 01 12:24:26 2010 +0100
462.3 @@ -61,7 +61,6 @@
462.4 import org.netbeans.modules.csl.api.DataLoadersBridge;
462.5 import org.netbeans.modules.csl.api.Formatter;
462.6 import org.netbeans.modules.csl.api.test.CslTestBase.IndentPrefs;
462.7 -import org.netbeans.modules.csl.core.GsfIndentTaskFactory;
462.8 import org.netbeans.modules.css.editor.indent.CssIndentTaskFactory;
462.9 import org.netbeans.modules.css.formatting.api.support.AbstractIndenter;
462.10 import org.netbeans.modules.css.lexer.api.CssTokenId;
462.11 @@ -143,7 +142,6 @@
462.12 MockMimeLookup.setInstances(MimePath.parse("text/x-java"), factory, new JavacParserFactory(), new ClassParserFactory());
462.13 ExpressionLanguageIndentTaskFactory elReformatFactory = new ExpressionLanguageIndentTaskFactory();
462.14 MockMimeLookup.setInstances(MimePath.parse("text/x-el"), elReformatFactory);
462.15 - GsfIndentTaskFactory jsFactory = new GsfIndentTaskFactory();
462.16 // adding javascript formatter makes some tests randomly fail;
462.17 // for now I'm disabling
462.18 //MockMimeLookup.setInstances(MimePath.parse("text/javascript"), jsFactory, new GsfParserFactory());
463.1 --- a/web.jsf.editor/manifest.mf Mon Feb 01 12:23:06 2010 +0100
463.2 +++ b/web.jsf.editor/manifest.mf Mon Feb 01 12:24:26 2010 +0100
463.3 @@ -2,6 +2,6 @@
463.4 OpenIDE-Module: org.netbeans.modules.web.jsf.editor
463.5 OpenIDE-Module-Layer: org/netbeans/modules/web/jsf/editor/resources/layer.xml
463.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/web/jsf/editor/resources/Bundle.properties
463.7 -OpenIDE-Module-Specification-Version: 1.5
463.8 +OpenIDE-Module-Specification-Version: 1.6
463.9 AutoUpdate-Show-In-Client: false
463.10
464.1 --- a/web.jsf.editor/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
464.2 +++ b/web.jsf.editor/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
464.3 @@ -77,8 +77,8 @@
464.4 <build-prerequisite/>
464.5 <compile-dependency/>
464.6 <run-dependency>
464.7 - <release-version>1</release-version>
464.8 - <specification-version>1.11</specification-version>
464.9 + <release-version>2</release-version>
464.10 + <specification-version>2.1</specification-version>
464.11 </run-dependency>
464.12 </dependency>
464.13 <dependency>
465.1 --- a/web.jsf/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
465.2 +++ b/web.jsf/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
465.3 @@ -38,7 +38,7 @@
465.4 # made subject to such option by the copyright holder.
465.5
465.6 javac.source=1.6
465.7 -spec.version.base=1.17.0
465.8 +spec.version.base=1.18.0
465.9
465.10
465.11 test.qa-functional.cp.extra=\
466.1 --- a/web.jsf/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
466.2 +++ b/web.jsf/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
466.3 @@ -138,8 +138,8 @@
466.4 <build-prerequisite/>
466.5 <compile-dependency/>
466.6 <run-dependency>
466.7 - <release-version>1</release-version>
466.8 - <specification-version>1.11</specification-version>
466.9 + <release-version>2</release-version>
466.10 + <specification-version>2.1</specification-version>
466.11 </run-dependency>
466.12 </dependency>
466.13 <dependency>
467.1 --- a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/Bundle.properties Mon Feb 01 12:23:06 2010 +0100
467.2 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/wizards/Bundle.properties Mon Feb 01 12:24:26 2010 +0100
467.3 @@ -45,6 +45,7 @@
467.4
467.5 LBL_WizardTitle_FromEntity=JSF Pages from Entity Classes
467.6 LBL_JSFPagesAndClasses=Generate JSF Pages and Classes
467.7 +LBL_PersistenceUnitSetup=Persistence Unit Provider and Database
467.8
467.9 # Sample ResourceBundle properties file
467.10 TITLE_x_of_y={0} of {1}
468.1 --- a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/PersistenceClientIterator.java Mon Feb 01 12:23:06 2010 +0100
468.2 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/wizards/PersistenceClientIterator.java Mon Feb 01 12:24:26 2010 +0100
468.3 @@ -90,8 +90,11 @@
468.4 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
468.5 import org.netbeans.modules.j2ee.ejbcore.ejb.wizard.jpa.dao.EjbFacadeWizardIterator;
468.6 import org.netbeans.modules.j2ee.persistence.dd.PersistenceUtils;
468.7 +import org.netbeans.modules.j2ee.persistence.wizard.Util;
468.8 import org.netbeans.modules.j2ee.persistence.wizard.fromdb.ProgressPanel;
468.9 import org.netbeans.modules.j2ee.persistence.wizard.jpacontroller.JpaControllerIterator;
468.10 +import org.netbeans.modules.j2ee.persistence.wizard.unit.PersistenceUnitWizardDescriptor;
468.11 +import org.netbeans.modules.j2ee.persistence.wizard.unit.PersistenceUnitWizardPanel.TableGeneration;
468.12 import org.netbeans.modules.web.api.webmodule.ExtenderController;
468.13 import org.netbeans.modules.web.api.webmodule.WebModule;
468.14 import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
468.15 @@ -146,15 +149,20 @@
468.16 final boolean jsf2Generator = "true".equals(wizard.getProperty(JSF2_GENERATOR_PROPERTY)) && "Facelets".equals(preferredLanguage); //NOI18N
468.17 final String bundleName = (String)wizard.getProperty(WizardProperties.LOCALIZATION_BUNDLE_NAME);
468.18
468.19 - PersistenceUnit persistenceUnit =
468.20 - (PersistenceUnit) wizard.getProperty(org.netbeans.modules.j2ee.persistence.wizard.WizardProperties.PERSISTENCE_UNIT);
468.21 + boolean createPersistenceUnit = (Boolean) wizard.getProperty(org.netbeans.modules.j2ee.persistence.wizard.WizardProperties.CREATE_PERSISTENCE_UNIT);
468.22
468.23 - if (persistenceUnit != null){
468.24 - try {
468.25 - ProviderUtil.addPersistenceUnit(persistenceUnit, Templates.getProject(wizard));
468.26 - }
468.27 - catch (InvalidPersistenceXmlException e) {
468.28 - throw new IOException(e.toString());
468.29 + if (createPersistenceUnit) {
468.30 + PersistenceUnitWizardDescriptor puPanel = (PersistenceUnitWizardDescriptor) (panels[panels.length - 1] instanceof PersistenceUnitWizardDescriptor ? panels[panels.length - 1] : null);
468.31 + if(puPanel!=null) {
468.32 + try {
468.33 + PersistenceUnit punit = Util.buildPersistenceUnitUsingData(project, puPanel.getPersistenceUnitName(), puPanel.getDBResourceSelection(), TableGeneration.NONE, puPanel.getSelectedProvider());
468.34 + ProviderUtil.setTableGeneration(punit, puPanel.getTableGeneration(), puPanel.getSelectedProvider());
468.35 + if (punit != null){
468.36 + ProviderUtil.addPersistenceUnit(punit, project);
468.37 + }
468.38 + } catch (InvalidPersistenceXmlException e) {
468.39 + throw new IOException(e.toString());
468.40 + }
468.41 }
468.42 }
468.43
468.44 @@ -667,6 +675,7 @@
468.45 return null;
468.46 }
468.47
468.48 + @Override
468.49 public void initialize(TemplateWizard wizard) {
468.50 index = 0;
468.51 wme = null;
468.52 @@ -694,26 +703,36 @@
468.53
468.54 JSFFrameworkProvider fp = new JSFFrameworkProvider();
468.55 String[] names;
468.56 - if (fp.isInWebModule(wm)) {
468.57 - panels = new WizardDescriptor.Panel[] { secondPanel, thirdPanel };
468.58 - names = new String[] {
468.59 - NbBundle.getMessage(PersistenceClientIterator.class, "LBL_EntityClasses"),
468.60 - NbBundle.getMessage(PersistenceClientIterator.class, "LBL_JSFPagesAndClasses")
468.61 - };
468.62 + ArrayList<WizardDescriptor.Panel> panelsList = new ArrayList<WizardDescriptor.Panel>();
468.63 + ArrayList<String> namesList = new ArrayList<String>();
468.64 + panelsList.add(secondPanel);
468.65 + panelsList.add(thirdPanel);
468.66 + namesList.add(NbBundle.getMessage(PersistenceClientIterator.class, "LBL_EntityClasses"));
468.67 + namesList.add(NbBundle.getMessage(PersistenceClientIterator.class, "LBL_JSFPagesAndClasses"));
468.68 +
468.69 + if (!fp.isInWebModule(wm)) {
468.70 + updateWebModuleExtender(project, wm, fp);
468.71 + JSFConfigurationWizardPanel jsfWizPanel = new JSFConfigurationWizardPanel(wme);
468.72 + thirdPanel.setFinishPanel(false);
468.73 + panelsList.add(jsfWizPanel);
468.74 + namesList.add(NbBundle.getMessage(PersistenceClientIterator.class, "LBL_JSF_Config_CRUD"));
468.75 }
468.76 - else {
468.77 - updateWebModuleExtender(project, wm, fp);
468.78 -
468.79 - JSFConfigurationWizardPanel jsfWizPanel = new JSFConfigurationWizardPanel(wme);
468.80 -
468.81 - thirdPanel.setFinishPanel(false);
468.82 - panels = new WizardDescriptor.Panel[] { secondPanel, thirdPanel, jsfWizPanel };
468.83 - names = new String[] {
468.84 - NbBundle.getMessage(PersistenceClientIterator.class, "LBL_EntityClasses"),
468.85 - NbBundle.getMessage(PersistenceClientIterator.class, "LBL_JSFPagesAndClasses"),
468.86 - NbBundle.getMessage(PersistenceClientIterator.class, "LBL_JSF_Config_CRUD"),
468.87 - };
468.88 +
468.89 + boolean noPuNeeded = true;
468.90 + try {
468.91 + noPuNeeded = ProviderUtil.persistenceExists(project) || !ProviderUtil.isValidServerInstanceOrNone(project);
468.92 + } catch (InvalidPersistenceXmlException ex) {
468.93 + Logger.getLogger(JpaControllerIterator.class.getName()).log(Level.FINE, "Invalid persistence.xml: "+ ex.getPath()); //NOI18N
468.94 }
468.95 +
468.96 + if(!noPuNeeded){
468.97 + panelsList.add(new PersistenceUnitWizardDescriptor(project));
468.98 + namesList.add(NbBundle.getMessage(PersistenceClientIterator.class, "LBL_PersistenceUnitSetup"));
468.99 + }
468.100 +
468.101 + panels = panelsList.toArray(new WizardDescriptor.Panel[0]);
468.102 + names = namesList.toArray(new String[0]);
468.103 +
468.104 wizard.putProperty("NewFileWizard_Title",
468.105 NbBundle.getMessage(PersistenceClientIterator.class, "Templates/Persistence/JsfFromDB"));
468.106 Wizards.mergeSteps(wizard, panels, names);
468.107 @@ -752,19 +771,23 @@
468.108 return res;
468.109 }
468.110
468.111 + @Override
468.112 public void uninitialize(TemplateWizard wiz) {
468.113 panels = null;
468.114 wme = null;
468.115 }
468.116
468.117 + @Override
468.118 public WizardDescriptor.Panel current() {
468.119 return panels[index];
468.120 }
468.121
468.122 + @Override
468.123 public String name() {
468.124 return NbBundle.getMessage (PersistenceClientIterator.class, "LBL_WizardTitle_FromEntity");
468.125 }
468.126
468.127 + @Override
468.128 public boolean hasNext() {
468.129 return index < panels.length - 1;
468.130 }
469.1 --- a/websvc.rest/src/org/netbeans/modules/websvc/rest/client/ClientJavaSourceHelper.java Mon Feb 01 12:23:06 2010 +0100
469.2 +++ b/websvc.rest/src/org/netbeans/modules/websvc/rest/client/ClientJavaSourceHelper.java Mon Feb 01 12:24:26 2010 +0100
469.3 @@ -48,6 +48,7 @@
469.4 import com.sun.source.tree.Tree;
469.5 import com.sun.source.tree.TypeParameterTree;
469.6 import com.sun.source.tree.VariableTree;
469.7 +import java.io.IOException;
469.8 import java.util.List;
469.9 import java.util.ArrayList;
469.10 import java.util.Collections;
469.11 @@ -77,6 +78,7 @@
469.12 import org.netbeans.modules.websvc.rest.model.api.RestMethodDescription;
469.13 import org.netbeans.modules.websvc.rest.model.api.RestServiceDescription;
469.14 import org.netbeans.modules.websvc.rest.model.api.SubResourceLocator;
469.15 +import org.netbeans.modules.websvc.rest.spi.RestSupport;
469.16 import org.netbeans.modules.websvc.rest.support.AbstractTask;
469.17 import org.netbeans.modules.websvc.rest.support.JavaSourceHelper;
469.18 import org.openide.filesystems.FileObject;
469.19 @@ -543,10 +545,16 @@
469.20 contextRoot = contextRoot.substring(1);
469.21 }
469.22 }
469.23 -
469.24 + String applicationPath = "resources"; //NOI18N
469.25 + RestSupport restSupport = project.getLookup().lookup(RestSupport.class);
469.26 + if (restSupport != null) {
469.27 + try {
469.28 + applicationPath = restSupport.getApplicationPath();
469.29 + } catch (IOException ex) {}
469.30 + }
469.31 return "http://" + hostName + ":" + portNumber + "/" + //NOI18N
469.32 (contextRoot != null && !contextRoot.equals("") ? contextRoot : "") + //NOI18N
469.33 - "/resources" + uri; //NOI18N
469.34 + "/"+applicationPath + uri; //NOI18N
469.35 }
469.36
469.37 private static MethodTree createHttpPOSTMethod(WorkingCopy copy, String httpMethod, HttpMimeType requestMimeType, String responseType, String path) {
470.1 --- a/websvc.rest/src/org/netbeans/modules/websvc/rest/nodes/TestResourceUriAction.java Mon Feb 01 12:23:06 2010 +0100
470.2 +++ b/websvc.rest/src/org/netbeans/modules/websvc/rest/nodes/TestResourceUriAction.java Mon Feb 01 12:24:26 2010 +0100
470.3 @@ -55,6 +55,7 @@
470.4 import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerInstance;
470.5 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
470.6 import org.netbeans.modules.websvc.api.support.LogUtils;
470.7 +import org.netbeans.modules.websvc.rest.spi.RestSupport;
470.8 import org.openide.DialogDisplayer;
470.9 import org.openide.NotifyDescriptor;
470.10 import org.openide.awt.HtmlBrowser;
470.11 @@ -186,9 +187,17 @@
470.12 }
470.13 }
470.14
470.15 + String applicationPath = "resources"; //NOI18N
470.16 + RestSupport restSupport = project.getLookup().lookup(RestSupport.class);
470.17 + if (restSupport != null) {
470.18 + try {
470.19 + applicationPath = restSupport.getApplicationPath();
470.20 + } catch (IOException ex) {}
470.21 + }
470.22 +
470.23 return "http://" + hostName + ":" + portNumber + "/" + //NOI18N
470.24 (contextRoot != null && !contextRoot.equals("") ? contextRoot : "") + //NOI18N
470.25 - "/resources" + uri; //NOI18N
470.26 + "/"+applicationPath + uri; //NOI18N
470.27 }
470.28
470.29 @Override
471.1 --- a/websvc.saas.codegen.j2ee/src/org/netbeans/modules/websvc/saas/codegen/j2ee/support/J2eeUtil.java Mon Feb 01 12:23:06 2010 +0100
471.2 +++ b/websvc.saas.codegen.j2ee/src/org/netbeans/modules/websvc/saas/codegen/j2ee/support/J2eeUtil.java Mon Feb 01 12:24:26 2010 +0100
471.3 @@ -49,7 +49,9 @@
471.4 import java.util.Map;
471.5 import java.util.logging.Level;
471.6 import java.util.logging.Logger;
471.7 +import javax.lang.model.element.AnnotationMirror;
471.8 import javax.lang.model.element.Modifier;
471.9 +import javax.lang.model.element.Name;
471.10 import javax.lang.model.element.TypeElement;
471.11 import org.netbeans.api.java.source.CancellableTask;
471.12 import org.netbeans.api.java.source.CompilationController;
471.13 @@ -537,28 +539,43 @@
471.14
471.15 public void run(WorkingCopy workingCopy) throws Exception {
471.16 workingCopy.toPhase(Phase.RESOLVED);
471.17 - ClassTree classTree = getPublicTopLevelTree(workingCopy);
471.18 - if (classTree != null) {
471.19 - TreeMaker make = workingCopy.getTreeMaker();
471.20 - TypeElement servletAn = workingCopy.getElements().getTypeElement("javax.servlet.annotation.WebServlet"); //NOI18N
471.21 - if (servletAn != null) {
471.22 - List<ExpressionTree> attrs = new ArrayList<ExpressionTree>();
471.23 - attrs.add(
471.24 - make.Assignment(make.Identifier("name"), make.Literal(servletName))); //NOI18N
471.25 - attrs.add(
471.26 - make.Assignment(make.Identifier("urlPatterns"), make.Literal(urlPattern))); //NOI18N
471.27 + TypeElement servletAn = workingCopy.getElements().getTypeElement("javax.servlet.annotation.WebServlet"); //NOI18N
471.28 + if (servletAn != null) {
471.29 + boolean found = false;
471.30 + TypeElement classEl = getPublicTopLevelElement(workingCopy);
471.31 + if (classEl != null) {
471.32 + List<? extends AnnotationMirror> annotations = classEl.getAnnotationMirrors();
471.33
471.34 - AnnotationTree servletAnnotation = make.Annotation(
471.35 - make.QualIdent(servletAn),
471.36 - attrs);
471.37 - ClassTree modifiedClass = make.Class(
471.38 - make.addModifiersAnnotation(classTree.getModifiers(), servletAnnotation),
471.39 - classTree.getSimpleName(),
471.40 - classTree.getTypeParameters(),
471.41 - classTree.getExtendsClause(),
471.42 - classTree.getImplementsClause(),
471.43 - classTree.getMembers());
471.44 - workingCopy.rewrite(classTree, modifiedClass);
471.45 + for (AnnotationMirror m : annotations) {
471.46 + Name qualifiedName = ((TypeElement)m.getAnnotationType().asElement()).getQualifiedName();
471.47 + if (qualifiedName.contentEquals("javax.servlet.annotation.WebServlet")) { //NOI18N
471.48 + found = true;
471.49 + break;
471.50 + }
471.51 + }
471.52 + }
471.53 + if (!found) {
471.54 + ClassTree classTree = getPublicTopLevelTree(workingCopy);
471.55 + if (classTree != null) {
471.56 + TreeMaker make = workingCopy.getTreeMaker();
471.57 + List<ExpressionTree> attrs = new ArrayList<ExpressionTree>();
471.58 + attrs.add(
471.59 + make.Assignment(make.Identifier("name"), make.Literal(servletName))); //NOI18N
471.60 + attrs.add(
471.61 + make.Assignment(make.Identifier("urlPatterns"), make.Literal(urlPattern))); //NOI18N
471.62 +
471.63 + AnnotationTree servletAnnotation = make.Annotation(
471.64 + make.QualIdent(servletAn),
471.65 + attrs);
471.66 + ClassTree modifiedClass = make.Class(
471.67 + make.addModifiersAnnotation(classTree.getModifiers(), servletAnnotation),
471.68 + classTree.getSimpleName(),
471.69 + classTree.getTypeParameters(),
471.70 + classTree.getExtendsClause(),
471.71 + classTree.getImplementsClause(),
471.72 + classTree.getMembers());
471.73 + workingCopy.rewrite(classTree, modifiedClass);
471.74 + }
471.75 }
471.76 }
471.77 }
472.1 --- a/xml.text/nbproject/project.properties Mon Feb 01 12:23:06 2010 +0100
472.2 +++ b/xml.text/nbproject/project.properties Mon Feb 01 12:24:26 2010 +0100
472.3 @@ -38,7 +38,7 @@
472.4 # made subject to such option by the copyright holder.
472.5
472.6 javac.source=1.6
472.7 -spec.version.base=1.22.0
472.8 +spec.version.base=1.23.0
472.9
472.10 test.unit.cp.extra=${openide.dir}/core/openide.jar:${openide.loaders.dir}/core/openide-loaders.jar
472.11 test.unit.run.cp.extra=${test.unit.cp.extra}
473.1 --- a/xml.text/nbproject/project.xml Mon Feb 01 12:23:06 2010 +0100
473.2 +++ b/xml.text/nbproject/project.xml Mon Feb 01 12:24:26 2010 +0100
473.3 @@ -69,8 +69,8 @@
473.4 <build-prerequisite/>
473.5 <compile-dependency/>
473.6 <run-dependency>
473.7 - <release-version>1</release-version>
473.8 - <specification-version>1.8</specification-version>
473.9 + <release-version>2</release-version>
473.10 + <specification-version>2.1</specification-version>
473.11 </run-dependency>
473.12 </dependency>
473.13 <dependency>
474.1 --- a/xml.text/src/org/netbeans/modules/xml/text/syntax/XMLKit.java Mon Feb 01 12:23:06 2010 +0100
474.2 +++ b/xml.text/src/org/netbeans/modules/xml/text/syntax/XMLKit.java Mon Feb 01 12:24:26 2010 +0100
474.3 @@ -57,7 +57,7 @@
474.4
474.5 // we depend on NetBeans editor stuff
474.6 import org.netbeans.editor.*;
474.7 -import org.netbeans.modules.csl.editor.ToggleBlockCommentAction;
474.8 +import org.netbeans.modules.csl.api.ToggleBlockCommentAction;
474.9 import org.netbeans.modules.editor.*;
474.10
474.11 import org.netbeans.modules.xml.text.XmlCommentHandler;