Refactored packages to better conform to naming conventions.
authorNils Hoffmann <nhoffmann@netbeans.org>
Fri, 04 Jan 2013 15:27:42 +0100
changeset 17972ae1c51f07289
parent 17971 10f00750c2ec
child 17973 fa82becb74f2
Refactored packages to better conform to naming conventions.
Refactored testing code, added tests for LicenseHeader.
Added arch.xml.
licensechanger/arch.xml
licensechanger/nbproject/project.properties
licensechanger/nbproject/project.xml
licensechanger/src/org/netbeans/modules/licensechanger/api/FileHandler.java
licensechanger/src/org/netbeans/modules/licensechanger/api/LicenseHeader.java
licensechanger/src/org/netbeans/modules/licensechanger/api/Offsets.java
licensechanger/src/org/netbeans/modules/licensechanger/api/RegexpFileHandler.java
licensechanger/src/org/netbeans/modules/licensechanger/freemarker/Project.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/JavaFileHandler.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/PropertiesFileHandler.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/XmlFileHandler.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/ChooseFileTypesPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/ChooseFileTypesPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/ChooseFileTypesWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChangerWizardAction.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChooserPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChooserPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChooserWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LineEndingsPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LineEndingsPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/PreviewPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/PreviewPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/PreviewWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/SelectFoldersPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/SelectFoldersPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/SelectFoldersWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/Bundle.properties
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/CheckableNodeCapability.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/FileChildren.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/FileLoader.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/FolderChildren.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/LicenseChangerRunnable.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/LineEndingPreference.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/Offsets.java
licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/WizardProperties.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/Bundle.properties
licensechanger/src/org/netbeans/modules/licensechanger/wizard/ChooseFileTypesPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/wizard/ChooseFileTypesPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/ChooseFileTypesWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChangerWizardAction.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChooserPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChooserPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChooserWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/LineEndingsPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/wizard/LineEndingsPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/PreviewPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/wizard/PreviewPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/PreviewWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/SelectFoldersPanel.form
licensechanger/src/org/netbeans/modules/licensechanger/wizard/SelectFoldersPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/SelectFoldersWizardPanel.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/Bundle.properties
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/CheckableNodeCapability.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/FileChildren.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/FileLoader.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/FolderChildren.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/LicenseChangerRunnable.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/LineEndingPreference.java
licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/WizardProperties.java
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/TestUtils.java
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/api/LicenseHeaderTest.java
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/fake_license.txt
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/license-test.txt
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/GroovyFileHandlerTest.java
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/JavaFileHandlerTest.java
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/PropertiesFileHandlerTest.java
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/XmlFileHandlerTest.java
licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/fake_license.txt
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/licensechanger/arch.xml	Fri Jan 04 15:27:42 2013 +0100
     1.3 @@ -0,0 +1,1081 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!DOCTYPE api-answers PUBLIC "-//NetBeans//DTD Arch Answers//EN" "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd" [
     1.6 +  <!ENTITY api-questions SYSTEM "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch-api-questions.xml">
     1.7 +]>
     1.8 +
     1.9 +<api-answers
    1.10 +  question-version="1.29"
    1.11 +  author="yourname@netbeans.org"
    1.12 +>
    1.13 +
    1.14 +  &api-questions;
    1.15 +
    1.16 +
    1.17 +<!--
    1.18 +        <question id="arch-overall" when="init">
    1.19 +            Describe the overall architecture. 
    1.20 +            <hint>
    1.21 +            What will be API for 
    1.22 +            <a href="http://wiki.netbeans.org/API_Design#Separate_API_for_clients_from_support_API">
    1.23 +                clients and what support API</a>? 
    1.24 +            What parts will be pluggable?
    1.25 +            How will plug-ins be registered? Please use <code>&lt;api type="export"/&gt;</code>
    1.26 +            to describe your general APIs and specify their
    1.27 +            <a href="http://wiki.netbeans.org/API_Stability#Private">
    1.28 +            stability categories</a>.
    1.29 +            If possible please provide simple diagrams.
    1.30 +            </hint>
    1.31 +        </question>
    1.32 +-->
    1.33 + <answer id="arch-overall">
    1.34 +  <p>
    1.35 +   XXX no answer for arch-overall
    1.36 +  <api type="export" name=""
    1.37 +  </p>
    1.38 + </answer>
    1.39 +
    1.40 +
    1.41 +
    1.42 +<!--
    1.43 +        <question id="arch-quality" when="init">
    1.44 +            How will the <a href="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a>
    1.45 +            of your code be tested and 
    1.46 +            how are future regressions going to be prevented?
    1.47 +            <hint>
    1.48 +            What kind of testing do
    1.49 +            you want to use? How much functionality, in which areas,
    1.50 +            should be covered by the tests? How you find out that your
    1.51 +            project was successful?
    1.52 +            </hint>
    1.53 +        </question>
    1.54 +-->
    1.55 + <answer id="arch-quality">
    1.56 +  <p>
    1.57 +   XXX no answer for arch-quality
    1.58 +  </p>
    1.59 + </answer>
    1.60 +
    1.61 +
    1.62 +
    1.63 +<!--
    1.64 +        <question id="arch-time" when="init">
    1.65 +            What are the time estimates of the work?
    1.66 +            <hint>
    1.67 +            Please express your estimates of how long the design, implementation,
    1.68 +            stabilization are likely to last. How many people will be needed to
    1.69 +            implement this and what is the expected milestone by which the work should be 
    1.70 +            ready?
    1.71 +            </hint>
    1.72 +        </question>
    1.73 +-->
    1.74 + <answer id="arch-time">
    1.75 +  <p>
    1.76 +   XXX no answer for arch-time
    1.77 +  </p>
    1.78 + </answer>
    1.79 +
    1.80 +
    1.81 +
    1.82 +<!--
    1.83 +        <question id="arch-usecases" when="init">
    1.84 +            <hint>
    1.85 +                Content of this answer will be displayed as part of page at
    1.86 +                http://www.netbeans.org/download/dev/javadoc/usecases.html 
    1.87 +                You can use tags &lt;usecase name="name&gt; regular html description &lt;/usecase&gt;
    1.88 +                and if you want to use an URL you can prefix if with @TOP@ to begin
    1.89 +                at the root of your javadoc
    1.90 +            </hint>
    1.91 +        
    1.92 +            Describe the main <a href="http://wiki.netbeans.org/API_Design#The_Importance_of_Being_Use_Case_Oriented">
    1.93 +            use cases</a> of the new API. Who will use it under
    1.94 +            what circumstances? What kind of code would typically need to be written
    1.95 +            to use the module?
    1.96 +        </question>
    1.97 +-->
    1.98 + <answer id="arch-usecases">
    1.99 +  <p>
   1.100 +   XXX no answer for arch-usecases
   1.101 +  </p>
   1.102 + </answer>
   1.103 +
   1.104 +
   1.105 +
   1.106 +<!--
   1.107 +        <question id="arch-what" when="init">
   1.108 +            What is this project good for?
   1.109 +            <hint>
   1.110 +            Please provide here a few lines describing the project, 
   1.111 +            what problem it should solve, provide links to documentation, 
   1.112 +            specifications, etc.
   1.113 +            </hint>
   1.114 +        </question>
   1.115 +-->
   1.116 + <answer id="arch-what">
   1.117 +  <p>
   1.118 +  The Licensechanger plugin allows users to alter the license header used in their project's source files. It 
   1.119 +  integrates with the NetBeans template mechanism and accesses license header templates available within the IDE.
   1.120 +  The plugin provides a convenient wizard that may be invoked from the Tools-&gt;Change License Header menu on 
   1.121 +  source code or file system folders. It allows for further customizations, such as setting a distinct copyright holder and 
   1.122 +  to update the project's default license header used when new source files are created.
   1.123 +  </p>
   1.124 + </answer>
   1.125 +
   1.126 +
   1.127 +
   1.128 +<!--
   1.129 +        <question id="arch-where" when="impl">
   1.130 +            Where one can find sources for your module?
   1.131 +            <hint>
   1.132 +                Please provide link to the Hg web client at
   1.133 +                http://hg.netbeans.org/
   1.134 +                or just use tag defaultanswer generate='here'
   1.135 +            </hint>
   1.136 +        </question>
   1.137 +-->
   1.138 + <answer id="arch-where">
   1.139 +  <defaultanswer generate='here' />
   1.140 + </answer>
   1.141 +
   1.142 +
   1.143 +
   1.144 +<!--
   1.145 +        <question id="compat-deprecation" when="init">
   1.146 +            How the introduction of your project influences functionality
   1.147 +            provided by previous version of the product?
   1.148 +            <hint>
   1.149 +            If you are planning to deprecate/remove/change any existing APIs,
   1.150 +            list them here accompanied with the reason explaining why you
   1.151 +            are doing so.
   1.152 +            </hint>
   1.153 +        </question>
   1.154 +-->
   1.155 + <answer id="compat-deprecation">
   1.156 +  <p>
   1.157 +   XXX no answer for compat-deprecation
   1.158 +  </p>
   1.159 + </answer>
   1.160 +
   1.161 +
   1.162 +
   1.163 +<!--
   1.164 +        <question id="compat-i18n" when="impl">
   1.165 +            Is your module correctly internationalized?
   1.166 +            <hint>
   1.167 +            Correct internationalization means that it obeys instructions 
   1.168 +            at <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/i18n-branding.html">
   1.169 +            NetBeans I18N pages</a>.
   1.170 +            </hint>
   1.171 +        </question>
   1.172 +-->
   1.173 + <answer id="compat-i18n">
   1.174 +  <p>
   1.175 +   XXX no answer for compat-i18n
   1.176 +  </p>
   1.177 + </answer>
   1.178 +
   1.179 +
   1.180 +
   1.181 +<!--
   1.182 +        <question id="compat-standards" when="init">
   1.183 +            Does the module implement or define any standards? Is the 
   1.184 +            implementation exact or does it deviate somehow?
   1.185 +        </question>
   1.186 +-->
   1.187 + <answer id="compat-standards">
   1.188 +  <p>
   1.189 +   XXX no answer for compat-standards
   1.190 +  </p>
   1.191 + </answer>
   1.192 +
   1.193 +
   1.194 +
   1.195 +<!--
   1.196 +        <question id="compat-version" when="impl">
   1.197 +            Can your module coexist with earlier and future
   1.198 +            versions of itself? Can you correctly read all old settings? Will future
   1.199 +            versions be able to read your current settings? Can you read
   1.200 +            or politely ignore settings stored by a future version?
   1.201 +            
   1.202 +            <hint>
   1.203 +            Very helpful for reading settings is to store version number
   1.204 +            there, so future versions can decide whether how to read/convert
   1.205 +            the settings and older versions can ignore the new ones.
   1.206 +            </hint>
   1.207 +        </question>
   1.208 +-->
   1.209 + <answer id="compat-version">
   1.210 +  <p>
   1.211 +   XXX no answer for compat-version
   1.212 +  </p>
   1.213 + </answer>
   1.214 +
   1.215 +
   1.216 +
   1.217 +<!--
   1.218 +        <question id="dep-jre" when="final">
   1.219 +            Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?
   1.220 +            <hint>
   1.221 +            It is expected that if your module runs on 1.x that it will run 
   1.222 +            on 1.x+1 if no, state that please. Also describe here cases where
   1.223 +            you run different code on different versions of JRE and why.
   1.224 +            </hint>
   1.225 +        </question>
   1.226 +-->
   1.227 + <answer id="dep-jre">
   1.228 +  <p>
   1.229 +   XXX no answer for dep-jre
   1.230 +  </p>
   1.231 + </answer>
   1.232 +
   1.233 +
   1.234 +
   1.235 +<!--
   1.236 +        <question id="dep-jrejdk" when="final">
   1.237 +            Do you require the JDK or is the JRE enough?
   1.238 +        </question>
   1.239 +-->
   1.240 + <answer id="dep-jrejdk">
   1.241 +  <p>
   1.242 +   XXX no answer for dep-jrejdk
   1.243 +  </p>
   1.244 + </answer>
   1.245 +
   1.246 +
   1.247 +
   1.248 +<!--
   1.249 +        <question id="dep-nb" when="init">
   1.250 +            What other NetBeans projects and modules does this one depend on?
   1.251 +            <hint>
   1.252 +            Depending on other NetBeans projects influnces the ability of
   1.253 +            users of your work to customize their own branded version of
   1.254 +            NetBeans by enabling and disabling some modules. Too
   1.255 +            much dependencies restrict this kind of customization. If that
   1.256 +            is your case, then you may want to split your functionality into
   1.257 +            pieces of autoload, eager and regular modules which can be
   1.258 +            enabled independently. Usually the answer to this question
   1.259 +            is generated from your <code>project.xml</code> file, but
   1.260 +            if it is not guessed correctly, you can suppress it by
   1.261 +            specifying &lt;defaultanswer generate="none"/&gt; and
   1.262 +            write here your own. Please describe such projects as imported APIs using
   1.263 +            the <code>&lt;api name="identification" type="import or export" category="stable" url="where is the description" /&gt;</code>.
   1.264 +            By doing this information gets listed in the summary page of your
   1.265 +            javadoc.
   1.266 +            </hint>
   1.267 +        </question>
   1.268 +-->
   1.269 + <answer id="dep-nb">
   1.270 +  <defaultanswer generate='here' />
   1.271 + </answer>
   1.272 +
   1.273 +
   1.274 +
   1.275 +<!--
   1.276 +        <question id="dep-non-nb" when="init">
   1.277 +            What other projects outside NetBeans does this one depend on?
   1.278 +            
   1.279 +            <hint>
   1.280 +            Depending on 3rd party libraries is always problematic,
   1.281 +            especially if they are not open source, as that complicates
   1.282 +            the licensing scheme of NetBeans. Please enumerate your
   1.283 +            external dependencies here, so it is correctly understood since
   1.284 +            the begining what are the legal implications of your project.
   1.285 +            Also please note that
   1.286 +            some non-NetBeans projects are packaged as NetBeans modules
   1.287 +            (see <a href="http://libs.netbeans.org/">libraries</a>) and
   1.288 +            it is preferred to use this approach when more modules may
   1.289 +            depend and share such third-party libraries.
   1.290 +            </hint>
   1.291 +        </question>
   1.292 +-->
   1.293 + <answer id="dep-non-nb">
   1.294 +  <p>
   1.295 +   XXX no answer for dep-non-nb
   1.296 +  </p>
   1.297 + </answer>
   1.298 +
   1.299 +
   1.300 +
   1.301 +<!--
   1.302 +        <question id="dep-platform" when="init">
   1.303 +            On which platforms does your module run? Does it run in the same
   1.304 +            way on each?
   1.305 +            <hint>
   1.306 +            If you plan any dependency on OS or any usage of native code,
   1.307 +            please describe why you are doing so and describe how you envision
   1.308 +            to enforce the portability of your code.
   1.309 +            Please note that there is a support for <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#how-os-specific">OS conditionally
   1.310 +            enabled modules</a> which together with autoload/eager modules
   1.311 +            can allow you to enable to provide the best OS aware support
   1.312 +            on certain OSes while providing compatibility bridge on the not
   1.313 +            supported ones.
   1.314 +            Also please list the supported
   1.315 +            OSes/HW platforms and mentioned the lovest version of JDK required
   1.316 +            for your project to run on. Also state whether JRE is enough or
   1.317 +            you really need JDK.
   1.318 +            </hint>
   1.319 +        </question>
   1.320 +-->
   1.321 + <answer id="dep-platform">
   1.322 +  <p>
   1.323 +   XXX no answer for dep-platform
   1.324 +  </p>
   1.325 + </answer>
   1.326 +
   1.327 +
   1.328 +
   1.329 +<!--
   1.330 +        <question id="deploy-dependencies" when="final">
   1.331 +            What do other modules need to do to declare a dependency on this one,
   1.332 +            in addition to or instead of the normal module dependency declaration
   1.333 +            (e.g. tokens to require)?
   1.334 +            <hint>
   1.335 +                Provide a sample of the actual lines you would add to a module manifest
   1.336 +                to declare a dependency, for example OpenIDE-Module-Requires: some.token.
   1.337 +                If other modules should not depend on this module, or should just use a
   1.338 +                simple regular module dependency, you can just answer "nothing". If you
   1.339 +                intentionally expose a semistable API to clients using implementation
   1.340 +                dependencies, you should mention that here (but there is no need to give
   1.341 +                an example of usage).
   1.342 +            </hint>
   1.343 +        </question>
   1.344 +-->
   1.345 + <answer id="deploy-dependencies">
   1.346 +  <p>
   1.347 +   XXX no answer for deploy-dependencies
   1.348 +  </p>
   1.349 + </answer>
   1.350 +
   1.351 +
   1.352 +
   1.353 +<!--
   1.354 +        <question id="deploy-jar" when="impl">
   1.355 +            Do you deploy just module JAR file(s) or other files as well?
   1.356 +            <hint>
   1.357 +            Usually a module consist of one JAR file (perhaps with Class-Path
   1.358 +            extensions) and also a configuration file that enables it. If you
   1.359 +            have any other files, use
   1.360 +            &lt;api group="java.io.File" name="yourname" type="export" category="friend"&gt;...&lt;/api&gt;
   1.361 +            to define the location, name and stability of your files (of course
   1.362 +            changing "yourname" and "friend" to suit your needs).
   1.363 +            
   1.364 +            If it uses more than one JAR, describe where they are located, how
   1.365 +            they refer to each other. 
   1.366 +            If it consist of module JAR(s) and other files, please describe
   1.367 +            what is their purpose, why other files are necessary. Please 
   1.368 +            make sure that installation/uninstallation leaves the system 
   1.369 +            in state as it was before installation.
   1.370 +            </hint>
   1.371 +        </question>
   1.372 +-->
   1.373 + <answer id="deploy-jar">
   1.374 +  <p>
   1.375 +   XXX no answer for deploy-jar
   1.376 +  </p>
   1.377 + </answer>
   1.378 +
   1.379 +
   1.380 +
   1.381 +<!--
   1.382 +        <question id="deploy-nbm" when="impl">
   1.383 +            Can you deploy an NBM via the Update Center?
   1.384 +            <hint>
   1.385 +            If not why?
   1.386 +            </hint>
   1.387 +        </question>
   1.388 +-->
   1.389 + <answer id="deploy-nbm">
   1.390 +  <p>
   1.391 +   XXX no answer for deploy-nbm
   1.392 +  </p>
   1.393 + </answer>
   1.394 +
   1.395 +
   1.396 +
   1.397 +<!--
   1.398 +        <question id="deploy-packages" when="init">
   1.399 +            Are packages of your module made inaccessible by not declaring them
   1.400 +            public?
   1.401 +            
   1.402 +            <hint>
   1.403 +            By default NetBeans build harness treats all packages are private.
   1.404 +            If you export some of them - either as public or friend packages,
   1.405 +            you should have a reason. If the reason is described elsewhere
   1.406 +            in this document, you can ignore this question.
   1.407 +            </hint>
   1.408 +        </question>
   1.409 +-->
   1.410 + <answer id="deploy-packages">
   1.411 +  <p>
   1.412 +   XXX no answer for deploy-packages
   1.413 +  </p>
   1.414 + </answer>
   1.415 +
   1.416 +
   1.417 +
   1.418 +<!--
   1.419 +        <question id="deploy-shared" when="final">
   1.420 +            Do you need to be installed in the shared location only, or in the user directory only,
   1.421 +            or can your module be installed anywhere?
   1.422 +            <hint>
   1.423 +            Installation location shall not matter, if it does explain why.
   1.424 +            Consider also whether <code>InstalledFileLocator</code> can help.
   1.425 +            </hint>
   1.426 +        </question>
   1.427 +-->
   1.428 + <answer id="deploy-shared">
   1.429 +  <p>
   1.430 +   XXX no answer for deploy-shared
   1.431 +  </p>
   1.432 + </answer>
   1.433 +
   1.434 +
   1.435 +
   1.436 +<!--
   1.437 +        <question id="exec-ant-tasks" when="impl">
   1.438 +            Do you define or register any ant tasks that other can use?
   1.439 +            
   1.440 +            <hint>
   1.441 +            If you provide an ant task that users can use, you need to be very
   1.442 +            careful about its syntax and behaviour, as it most likely forms an
   1.443 +	          API for end users and as there is a lot of end users, their reaction
   1.444 +            when such API gets broken can be pretty strong.
   1.445 +            </hint>
   1.446 +        </question>
   1.447 +-->
   1.448 + <answer id="exec-ant-tasks">
   1.449 +  <p>
   1.450 +   XXX no answer for exec-ant-tasks
   1.451 +  </p>
   1.452 + </answer>
   1.453 +
   1.454 +
   1.455 +
   1.456 +<!--
   1.457 +        <question id="exec-classloader" when="impl">
   1.458 +            Does your code create its own class loader(s)?
   1.459 +            <hint>
   1.460 +            A bit unusual. Please explain why and what for.
   1.461 +            </hint>
   1.462 +        </question>
   1.463 +-->
   1.464 + <answer id="exec-classloader">
   1.465 +  <p>
   1.466 +   XXX no answer for exec-classloader
   1.467 +  </p>
   1.468 + </answer>
   1.469 +
   1.470 +
   1.471 +
   1.472 +<!--
   1.473 +        <question id="exec-component" when="impl">
   1.474 +            Is execution of your code influenced by any (string) property
   1.475 +            of any of your components?
   1.476 +            
   1.477 +            <hint>
   1.478 +            Often <code>JComponent.getClientProperty</code>, <code>Action.getValue</code>
   1.479 +            or <code>PropertyDescriptor.getValue</code>, etc. are used to influence
   1.480 +            a behavior of some code. This of course forms an interface that should
   1.481 +            be documented. Also if one depends on some interface that an object
   1.482 +            implements (<code>component instanceof Runnable</code>) that forms an
   1.483 +            API as well.
   1.484 +            </hint>
   1.485 +        </question>
   1.486 +-->
   1.487 + <answer id="exec-component">
   1.488 +  <p>
   1.489 +   XXX no answer for exec-component
   1.490 +  </p>
   1.491 + </answer>
   1.492 +
   1.493 +
   1.494 +
   1.495 +<!--
   1.496 +        <question id="exec-introspection" when="impl">
   1.497 +            Does your module use any kind of runtime type information (<code>instanceof</code>,
   1.498 +            work with <code>java.lang.Class</code>, etc.)?
   1.499 +            <hint>
   1.500 +            Check for cases when you have an object of type A and you also
   1.501 +            expect it to (possibly) be of type B and do some special action. That
   1.502 +            should be documented. The same applies on operations in meta-level
   1.503 +            (Class.isInstance(...), Class.isAssignableFrom(...), etc.).
   1.504 +            </hint>
   1.505 +        </question>
   1.506 +-->
   1.507 + <answer id="exec-introspection">
   1.508 +  <p>
   1.509 +   XXX no answer for exec-introspection
   1.510 +  </p>
   1.511 + </answer>
   1.512 +
   1.513 +
   1.514 +
   1.515 +<!--
   1.516 +        <question id="exec-privateaccess" when="final">
   1.517 +            Are you aware of any other parts of the system calling some of 
   1.518 +            your methods by reflection?
   1.519 +            <hint>
   1.520 +            If so, describe the "contract" as an API. Likely private or friend one, but
   1.521 +            still API and consider rewrite of it.
   1.522 +            </hint>
   1.523 +        </question>
   1.524 +-->
   1.525 + <answer id="exec-privateaccess">
   1.526 +  <p>
   1.527 +   XXX no answer for exec-privateaccess
   1.528 +  </p>
   1.529 + </answer>
   1.530 +
   1.531 +
   1.532 +
   1.533 +<!--
   1.534 +        <question id="exec-process" when="impl">
   1.535 +            Do you execute an external process from your module? How do you ensure
   1.536 +            that the result is the same on different platforms? Do you parse output?
   1.537 +            Do you depend on result code?
   1.538 +            <hint>
   1.539 +            If you feed an input, parse the output please declare that as an API.
   1.540 +            </hint>
   1.541 +        </question>
   1.542 +-->
   1.543 + <answer id="exec-process">
   1.544 +  <p>
   1.545 +   XXX no answer for exec-process
   1.546 +  </p>
   1.547 + </answer>
   1.548 +
   1.549 +
   1.550 +
   1.551 +<!--
   1.552 +        <question id="exec-property" when="impl">
   1.553 +            Is execution of your code influenced by any environment or
   1.554 +            Java system (<code>System.getProperty</code>) property?
   1.555 +            On a similar note, is there something interesting that you
   1.556 +            pass to <code>java.util.logging.Logger</code>? Or do you observe
   1.557 +            what others log?
   1.558 +            <hint>
   1.559 +            If there is a property that can change the behavior of your 
   1.560 +            code, somebody will likely use it. You should describe what it does 
   1.561 +            and the <a href="http://wiki.netbeans.org/API_Stability">stability category</a>
   1.562 +            of this API. You may use
   1.563 +            <pre>
   1.564 +                &lt;api type="export" group="property" name="id" category="private" url="http://..."&gt;
   1.565 +                    description of the property, where it is used, what it influence, etc.
   1.566 +                &lt;/api&gt;            
   1.567 +            </pre>
   1.568 +            </hint>
   1.569 +        </question>
   1.570 +-->
   1.571 + <answer id="exec-property">
   1.572 +  <p>
   1.573 +   XXX no answer for exec-property
   1.574 +  </p>
   1.575 + </answer>
   1.576 +
   1.577 +
   1.578 +
   1.579 +<!--
   1.580 +        <question id="exec-reflection" when="impl">
   1.581 +            Does your code use Java Reflection to execute other code?
   1.582 +            <hint>
   1.583 +            This usually indicates a missing or insufficient API in the other
   1.584 +            part of the system. If the other side is not aware of your dependency
   1.585 +            this contract can be easily broken.
   1.586 +            </hint>
   1.587 +        </question>
   1.588 +-->
   1.589 + <answer id="exec-reflection">
   1.590 +  <p>
   1.591 +   XXX no answer for exec-reflection
   1.592 +  </p>
   1.593 + </answer>
   1.594 +
   1.595 +
   1.596 +
   1.597 +<!--
   1.598 +        <question id="exec-threading" when="init">
   1.599 +            What threading models, if any, does your module adhere to? How the
   1.600 +            project behaves with respect to threading?
   1.601 +            <hint>
   1.602 +                Is your API threadsafe? Can it be accessed from any threads or
   1.603 +                just from some dedicated ones? Any special relation to AWT and
   1.604 +                its Event Dispatch thread? Also
   1.605 +                if your module calls foreign APIs which have a specific threading model,
   1.606 +                indicate how you comply with the requirements for multithreaded access
   1.607 +                (synchronization, mutexes, etc.) applicable to those APIs.
   1.608 +                If your module defines any APIs, or has complex internal structures
   1.609 +                that might be used from multiple threads, declare how you protect
   1.610 +                data against concurrent access, race conditions, deadlocks, etc.,
   1.611 +                and whether such rules are enforced by runtime warnings, errors, assertions, etc.
   1.612 +                Examples: a class might be non-thread-safe (like Java Collections); might
   1.613 +                be fully thread-safe (internal locking); might require access through a mutex
   1.614 +                (and may or may not automatically acquire that mutex on behalf of a client method);
   1.615 +                might be able to run only in the event queue; etc.
   1.616 +                Also describe when any events are fired: synchronously, asynchronously, etc.
   1.617 +                Ideas: <a href="http://core.netbeans.org/proposals/threading/index.html#recommendations">Threading Recommendations</a> (in progress)
   1.618 +            </hint>
   1.619 +        </question>
   1.620 +-->
   1.621 + <answer id="exec-threading">
   1.622 +  <p>
   1.623 +   XXX no answer for exec-threading
   1.624 +  </p>
   1.625 + </answer>
   1.626 +
   1.627 +
   1.628 +
   1.629 +<!--
   1.630 +        <question id="format-clipboard" when="impl">
   1.631 +            Which data flavors (if any) does your code read from or insert to
   1.632 +            the clipboard (by access to clipboard on means calling methods on <code>java.awt.datatransfer.Transferable</code>?
   1.633 +            
   1.634 +            <hint>
   1.635 +            Often Node's deal with clipboard by usage of <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
   1.636 +            Check your code for overriding these methods.
   1.637 +            </hint>
   1.638 +        </question>
   1.639 +-->
   1.640 + <answer id="format-clipboard">
   1.641 +  <p>
   1.642 +   XXX no answer for format-clipboard
   1.643 +  </p>
   1.644 + </answer>
   1.645 +
   1.646 +
   1.647 +
   1.648 +<!--
   1.649 +        <question id="format-dnd" when="impl">
   1.650 +            Which protocols (if any) does your code understand during Drag &amp; Drop?
   1.651 +            <hint>
   1.652 +            Often Node's deal with clipboard by usage of <code>Node.drag, Node.getDropType</code>. 
   1.653 +            Check your code for overriding these methods. Btw. if they are not overridden, they
   1.654 +            by default delegate to <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
   1.655 +            </hint>
   1.656 +        </question>
   1.657 +-->
   1.658 + <answer id="format-dnd">
   1.659 +  <p>
   1.660 +   XXX no answer for format-dnd
   1.661 +  </p>
   1.662 + </answer>
   1.663 +
   1.664 +
   1.665 +
   1.666 +<!--
   1.667 +        <question id="format-types" when="impl">
   1.668 +            Which protocols and file formats (if any) does your module read or write on disk,
   1.669 +            or transmit or receive over the network? Do you generate an ant build script?
   1.670 +            Can it be edited and modified? 
   1.671 +            
   1.672 +            <hint>
   1.673 +            <p>
   1.674 +            Files can be read and written by other programs, modules and users. If they influence
   1.675 +            your behaviour, make sure you either document the format or claim that it is a private
   1.676 +            api (using the &lt;api&gt; tag). 
   1.677 +            </p>
   1.678 +            
   1.679 +            <p>
   1.680 +            If you generate an ant build file, this is very likely going to be seen by end users and
   1.681 +            they will be attempted to edit it. You should be ready for that and provide here a link
   1.682 +            to documentation that you have for such purposes and also describe how you are going to
   1.683 +            understand such files during next release, when you (very likely) slightly change the 
   1.684 +            format.
   1.685 +            </p>
   1.686 +            </hint>
   1.687 +        </question>
   1.688 +-->
   1.689 + <answer id="format-types">
   1.690 +  <p>
   1.691 +   XXX no answer for format-types
   1.692 +  </p>
   1.693 + </answer>
   1.694 +
   1.695 +
   1.696 +
   1.697 +<!--
   1.698 +        <question id="lookup-lookup" when="init">
   1.699 +            Does your module use <code>org.openide.util.Lookup</code>
   1.700 +            or any similar technology to find any components to communicate with? Which ones?
   1.701 +            
   1.702 +            <hint>
   1.703 +            NetBeans is build around a generic registry of services called
   1.704 +            lookup. It is preferable to use it for registration and discovery
   1.705 +            if possible. See
   1.706 +            <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-util/org/openide/util/lookup/doc-files/index.html">
   1.707 +            The Solution to Comunication Between Components
   1.708 +            </a>. If you do not plan to use lookup and insist usage
   1.709 +            of other solution, then please describe why it is not working for
   1.710 +            you.
   1.711 +            <br/>
   1.712 +            When filling the final version of your arch document, please
   1.713 +            describe the interfaces you are searching for, where 
   1.714 +            are defined, whether you are searching for just one or more of them,
   1.715 +            if the order is important, etc. Also classify the stability of such
   1.716 +            API contract. Use &lt;api group=&amp;lookup&amp; /&gt; tag, so
   1.717 +            your information gets listed in the summary page of your javadoc.
   1.718 +            </hint>
   1.719 +        </question>
   1.720 +-->
   1.721 + <answer id="lookup-lookup">
   1.722 +  <p>
   1.723 +   XXX no answer for lookup-lookup
   1.724 +  </p>
   1.725 + </answer>
   1.726 +
   1.727 +
   1.728 +
   1.729 +<!--
   1.730 +        <question id="lookup-register" when="final">
   1.731 +            Do you register anything into lookup for other code to find?
   1.732 +            <hint>
   1.733 +            Do you register using layer file or using a declarative annotation such as <code>@ServiceProvider</code>?
   1.734 +            Who is supposed to find your component?
   1.735 +            </hint>
   1.736 +        </question>
   1.737 +-->
   1.738 + <answer id="lookup-register">
   1.739 +  <p>
   1.740 +   XXX no answer for lookup-register
   1.741 +  </p>
   1.742 + </answer>
   1.743 +
   1.744 +
   1.745 +
   1.746 +<!--
   1.747 +        <question id="lookup-remove" when="final">
   1.748 +            Do you remove entries of other modules from lookup?
   1.749 +            <hint>
   1.750 +            Why? Of course, that is possible, but it can be dangerous. Is the module
   1.751 +            your are masking resource from aware of what you are doing?
   1.752 +            </hint>
   1.753 +        </question>
   1.754 +-->
   1.755 + <answer id="lookup-remove">
   1.756 +  <p>
   1.757 +   XXX no answer for lookup-remove
   1.758 +  </p>
   1.759 + </answer>
   1.760 +
   1.761 +
   1.762 +
   1.763 +<!--
   1.764 +        <question id="perf-exit" when="final">
   1.765 +            Does your module run any code on exit?
   1.766 +        </question>
   1.767 +-->
   1.768 + <answer id="perf-exit">
   1.769 +  <p>
   1.770 +   XXX no answer for perf-exit
   1.771 +  </p>
   1.772 + </answer>
   1.773 +
   1.774 +
   1.775 +
   1.776 +<!--
   1.777 +        <question id="perf-huge_dialogs" when="final">
   1.778 +            Does your module contain any dialogs or wizards with a large number of
   1.779 +            GUI controls such as combo boxes, lists, trees, or text areas?
   1.780 +        </question>
   1.781 +-->
   1.782 + <answer id="perf-huge_dialogs">
   1.783 +  <p>
   1.784 +   XXX no answer for perf-huge_dialogs
   1.785 +  </p>
   1.786 + </answer>
   1.787 +
   1.788 +
   1.789 +
   1.790 +<!--
   1.791 +        <question id="perf-limit" when="init">
   1.792 +            Are there any hard-coded or practical limits in the number or size of
   1.793 +            elements your code can handle?
   1.794 +            <hint>
   1.795 +                Most of algorithms have increasing memory and speed complexity
   1.796 +                with respect to size of data they operate on. What is the critical
   1.797 +                part of your project that can be seen as a bottleneck with
   1.798 +                respect to speed or required memory? What are the practical
   1.799 +                sizes of data you tested your project with? What is your estimate
   1.800 +                of potential size of data that would cause visible performance
   1.801 +                problems? Is there some kind of check to detect such situation
   1.802 +                and prevent "hard" crashes - for example the CloneableEditorSupport
   1.803 +                checks for size of a file to be opened in editor
   1.804 +                and if it is larger than 1Mb it shows a dialog giving the
   1.805 +                user the right to decide - e.g. to cancel or commit suicide.
   1.806 +            </hint>
   1.807 +        </question>
   1.808 +-->
   1.809 + <answer id="perf-limit">
   1.810 +  <p>
   1.811 +   XXX no answer for perf-limit
   1.812 +  </p>
   1.813 + </answer>
   1.814 +
   1.815 +
   1.816 +
   1.817 +<!--
   1.818 +        <question id="perf-mem" when="final">
   1.819 +            How much memory does your component consume? Estimate
   1.820 +            with a relation to the number of windows, etc.
   1.821 +        </question>
   1.822 +-->
   1.823 + <answer id="perf-mem">
   1.824 +  <p>
   1.825 +   XXX no answer for perf-mem
   1.826 +  </p>
   1.827 + </answer>
   1.828 +
   1.829 +
   1.830 +
   1.831 +<!--
   1.832 +        <question id="perf-menus" when="final">
   1.833 +            Does your module use dynamically updated context menus, or
   1.834 +            context-sensitive actions with complicated and slow enablement logic?
   1.835 +            <hint>
   1.836 +                If you do a lot of tricks when adding actions to regular or context menus, you can significantly
   1.837 +                slow down display of the menu, even when the user is not using your action. Pay attention to
   1.838 +                actions you add to the main menu bar, and to context menus of foreign nodes or components. If
   1.839 +                the action is conditionally enabled, or changes its display dynamically, you need to check the
   1.840 +                impact on performance. In some cases it may be more appropriate to make a simple action that is
   1.841 +                always enabled but does more detailed checks in a dialog if it is actually run.
   1.842 +            </hint>
   1.843 +        </question>
   1.844 +-->
   1.845 + <answer id="perf-menus">
   1.846 +  <p>
   1.847 +   XXX no answer for perf-menus
   1.848 +  </p>
   1.849 + </answer>
   1.850 +
   1.851 +
   1.852 +
   1.853 +<!--
   1.854 +        <question id="perf-progress" when="final">
   1.855 +            Does your module execute any long-running tasks?
   1.856 +            
   1.857 +            <hint>Long running tasks should never block 
   1.858 +            AWT thread as it badly hurts the UI
   1.859 +            <a href="http://performance.netbeans.org/responsiveness/issues.html">
   1.860 +            responsiveness</a>.
   1.861 +            Tasks like connecting over
   1.862 +            network, computing huge amount of data, compilation
   1.863 +            be done asynchronously (for example
   1.864 +            using <code>RequestProcessor</code>), definitively it should 
   1.865 +            not block AWT thread.
   1.866 +            </hint>
   1.867 +        </question>
   1.868 +-->
   1.869 + <answer id="perf-progress">
   1.870 +  <p>
   1.871 +   XXX no answer for perf-progress
   1.872 +  </p>
   1.873 + </answer>
   1.874 +
   1.875 +
   1.876 +
   1.877 +<!--
   1.878 +        <question id="perf-scale" when="init">
   1.879 +            Which external criteria influence the performance of your
   1.880 +            program (size of file in editor, number of files in menu, 
   1.881 +            in source directory, etc.) and how well your code scales?
   1.882 +            <hint>
   1.883 +            Please include some estimates, there are other more detailed 
   1.884 +            questions to answer in later phases of implementation. 
   1.885 +            </hint>
   1.886 +        </question>
   1.887 +-->
   1.888 + <answer id="perf-scale">
   1.889 +  <p>
   1.890 +   XXX no answer for perf-scale
   1.891 +  </p>
   1.892 + </answer>
   1.893 +
   1.894 +
   1.895 +
   1.896 +<!--
   1.897 +        <question id="perf-spi" when="init">
   1.898 +            How the performance of the plugged in code will be enforced?
   1.899 +            <hint>
   1.900 +            If you allow foreign code to be plugged into your own module, how
   1.901 +            do you enforce that it will behave correctly and quickly and will not
   1.902 +            negatively influence the performance of your own module?
   1.903 +            </hint>
   1.904 +        </question>
   1.905 +-->
   1.906 + <answer id="perf-spi">
   1.907 +  <p>
   1.908 +   XXX no answer for perf-spi
   1.909 +  </p>
   1.910 + </answer>
   1.911 +
   1.912 +
   1.913 +
   1.914 +<!--
   1.915 +        <question id="perf-startup" when="final">
   1.916 +            Does your module run any code on startup?
   1.917 +        </question>
   1.918 +-->
   1.919 + <answer id="perf-startup">
   1.920 +  <p>
   1.921 +   XXX no answer for perf-startup
   1.922 +  </p>
   1.923 + </answer>
   1.924 +
   1.925 +
   1.926 +
   1.927 +<!--
   1.928 +        <question id="perf-wakeup" when="final">
   1.929 +            Does any piece of your code wake up periodically and do something
   1.930 +            even when the system is otherwise idle (no user interaction)?
   1.931 +        </question>
   1.932 +-->
   1.933 + <answer id="perf-wakeup">
   1.934 +  <p>
   1.935 +   XXX no answer for perf-wakeup
   1.936 +  </p>
   1.937 + </answer>
   1.938 +
   1.939 +
   1.940 +
   1.941 +<!--
   1.942 +        <question id="resources-file" when="final">
   1.943 +            Does your module use <code>java.io.File</code> directly?
   1.944 +            
   1.945 +            <hint>
   1.946 +            NetBeans provide a logical wrapper over plain files called 
   1.947 +            <code>org.openide.filesystems.FileObject</code> that
   1.948 +            provides uniform access to such resources and is the preferred
   1.949 +            way that should be used. But of course there can be situations when
   1.950 +            this is not suitable.
   1.951 +            </hint>
   1.952 +        </question>
   1.953 +-->
   1.954 + <answer id="resources-file">
   1.955 +  <p>
   1.956 +   XXX no answer for resources-file
   1.957 +  </p>
   1.958 + </answer>
   1.959 +
   1.960 +
   1.961 +
   1.962 +<!--
   1.963 +        <question id="resources-layer" when="final">
   1.964 +            Does your module provide own layer? Does it create any files or
   1.965 +            folders in it? What it is trying to communicate by that and with which 
   1.966 +            components?
   1.967 +            
   1.968 +            <hint>
   1.969 +            NetBeans allows automatic and declarative installation of resources 
   1.970 +            by module layers. Module register files into appropriate places
   1.971 +            and other components use that information to perform their task
   1.972 +            (build menu, toolbar, window layout, list of templates, set of
   1.973 +            options, etc.). 
   1.974 +            </hint>
   1.975 +        </question>
   1.976 +-->
   1.977 + <answer id="resources-layer">
   1.978 +  <p>
   1.979 +   XXX no answer for resources-layer
   1.980 +  </p>
   1.981 + </answer>
   1.982 +
   1.983 +
   1.984 +
   1.985 +<!--
   1.986 +        <question id="resources-mask" when="final">
   1.987 +            Does your module mask/hide/override any resources provided by other modules in
   1.988 +            their layers?
   1.989 +            
   1.990 +            <hint>
   1.991 +            If you mask a file provided by another module, you probably depend
   1.992 +            on that and do not want the other module to (for example) change
   1.993 +            the file's name. That module shall thus make that file available as an API
   1.994 +            of some stability category.
   1.995 +            </hint>
   1.996 +        </question>
   1.997 +-->
   1.998 + <answer id="resources-mask">
   1.999 +  <p>
  1.1000 +   XXX no answer for resources-mask
  1.1001 +  </p>
  1.1002 + </answer>
  1.1003 +
  1.1004 +
  1.1005 +
  1.1006 +<!--
  1.1007 +        <question id="resources-preferences" when="final">
  1.1008 +            Does your module uses preferences via Preferences API? Does your module use NbPreferences or
  1.1009 +            or regular JDK Preferences ? Does it read, write or both ? 
  1.1010 +            Does it share preferences with other modules ? If so, then why ?
  1.1011 +            <hint>
  1.1012 +                You may use
  1.1013 +                    &lt;api type="export" group="preferences"
  1.1014 +                    name="preference node name" category="private"&gt;
  1.1015 +                    description of individual keys, where it is used, what it
  1.1016 +                    influences, whether the module reads/write it, etc.
  1.1017 +                    &lt;/api&gt;
  1.1018 +                Due to XML ID restrictions, rather than /org/netbeans/modules/foo give the "name" as org.netbeans.modules.foo.
  1.1019 +                Note that if you use NbPreferences this name will then be the same as the code name base of the module.
  1.1020 +            </hint>
  1.1021 +        </question>
  1.1022 +-->
  1.1023 + <answer id="resources-preferences">
  1.1024 +  <p>
  1.1025 +   XXX no answer for resources-preferences
  1.1026 +  </p>
  1.1027 + </answer>
  1.1028 +
  1.1029 +
  1.1030 +
  1.1031 +<!--
  1.1032 +        <question id="resources-read" when="final">
  1.1033 +            Does your module read any resources from layers? For what purpose?
  1.1034 +            
  1.1035 +            <hint>
  1.1036 +            As this is some kind of intermodule dependency, it is a kind of API.
  1.1037 +            Please describe it and classify according to 
  1.1038 +            <a href="http://wiki.netbeans.org/API_Design#What_is_an_API.3F">
  1.1039 +            common stability categories</a>.
  1.1040 +            </hint>
  1.1041 +        </question>
  1.1042 +-->
  1.1043 + <answer id="resources-read">
  1.1044 +  <p>
  1.1045 +   XXX no answer for resources-read
  1.1046 +  </p>
  1.1047 + </answer>
  1.1048 +
  1.1049 +
  1.1050 +
  1.1051 +<!--
  1.1052 +        <question id="security-grant" when="final">
  1.1053 +            Does your code grant additional rights to some other code?
  1.1054 +            <hint>Avoid using a class loader that adds extra
  1.1055 +            permissions to loaded code unless really necessary.
  1.1056 +            Also note that your API implementation
  1.1057 +            can also expose unneeded permissions to enemy code by
  1.1058 +            calling AccessController.doPrivileged().</hint>
  1.1059 +        </question>
  1.1060 +-->
  1.1061 + <answer id="security-grant">
  1.1062 +  <p>
  1.1063 +   XXX no answer for security-grant
  1.1064 +  </p>
  1.1065 + </answer>
  1.1066 +
  1.1067 +
  1.1068 +
  1.1069 +<!--
  1.1070 +        <question id="security-policy" when="final">
  1.1071 +            Does your functionality require modifications to the standard policy file?
  1.1072 +            <hint>Your code might pass control to third-party code not
  1.1073 +            coming from trusted domains. This could be code downloaded over the
  1.1074 +            network or code coming from libraries that are not bundled
  1.1075 +            with NetBeans. Which permissions need to be granted to which domains?</hint>
  1.1076 +        </question>
  1.1077 +-->
  1.1078 + <answer id="security-policy">
  1.1079 +  <p>
  1.1080 +   XXX no answer for security-policy
  1.1081 +  </p>
  1.1082 + </answer>
  1.1083 +
  1.1084 +</api-answers>
     2.1 --- a/licensechanger/nbproject/project.properties	Wed Jan 02 13:38:30 2013 +0100
     2.2 +++ b/licensechanger/nbproject/project.properties	Fri Jan 04 15:27:42 2013 +0100
     2.3 @@ -1,3 +1,4 @@
     2.4  javac.source=1.6
     2.5  javac.compilerargs=-Xlint -Xlint:-serial
     2.6 +javadoc.arch=${basedir}/arch.xml
     2.7  nbm.module.author=Tim Boudreau
     3.1 --- a/licensechanger/nbproject/project.xml	Wed Jan 02 13:38:30 2013 +0100
     3.2 +++ b/licensechanger/nbproject/project.xml	Fri Jan 04 15:27:42 2013 +0100
     3.3 @@ -136,9 +136,21 @@
     3.4                  <test-type>
     3.5                      <name>unit</name>
     3.6                      <test-dependency>
     3.7 +                        <code-name-base>org.netbeans.insane</code-name-base>
     3.8 +                        <compile-dependency/>
     3.9 +                    </test-dependency>
    3.10 +                    <test-dependency>
    3.11                          <code-name-base>org.netbeans.libs.junit4</code-name-base>
    3.12                          <compile-dependency/>
    3.13                      </test-dependency>
    3.14 +                    <test-dependency>
    3.15 +                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
    3.16 +                        <compile-dependency/>
    3.17 +                    </test-dependency>
    3.18 +                    <test-dependency>
    3.19 +                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
    3.20 +                        <compile-dependency/>
    3.21 +                    </test-dependency>
    3.22                  </test-type>
    3.23              </test-dependencies>
    3.24              <public-packages>
     4.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/api/FileHandler.java	Wed Jan 02 13:38:30 2013 +0100
     4.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/api/FileHandler.java	Fri Jan 04 15:27:42 2013 +0100
     4.3 @@ -52,8 +52,8 @@
     4.4  import javax.script.ScriptEngine;
     4.5  import javax.script.ScriptEngineManager;
     4.6  import javax.script.ScriptException;
     4.7 -import org.netbeans.modules.licensechanger.spi.wizard.utils.Offsets;
     4.8 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
     4.9 +import org.netbeans.modules.licensechanger.freemarker.Project;
    4.10 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
    4.11  import org.openide.filesystems.FileObject;
    4.12  import org.openide.filesystems.FileUtil;
    4.13  import org.openide.util.Exceptions;
    4.14 @@ -106,7 +106,7 @@
    4.15       * <code>${licenseLast}</code> to determine whether the licenseText has
    4.16       * already been interpolated or if it needs escaping.
    4.17       *
    4.18 -     * @param licenseText the license test with freemarker template tokens
    4.19 +     * @param licenseText the license text with freemarker template tokens
    4.20       * @param additionalBindings additional binding values for freemarker
    4.21       * interpolation
    4.22       * @return the resolved licenseText
    4.23 @@ -195,23 +195,6 @@
    4.24          return after.toString();
    4.25      }
    4.26  
    4.27 -    /**
    4.28 -     * Freemarker expects project.organization to be the field 'organization' in
    4.29 -     * an object. This provides a thin wrapper for that. Class must be public to
    4.30 -     * be accessible by freemarker.
    4.31 -     */
    4.32 -    public class Project {
    4.33 -
    4.34 -        private final String organization;
    4.35 -
    4.36 -        public Project(String organization) {
    4.37 -            this.organization = organization;
    4.38 -        }
    4.39 -
    4.40 -        public String getOrganization() {
    4.41 -            return this.organization;
    4.42 -        }
    4.43 -    }
    4.44      static Pattern p = Pattern.compile("(.*?)\\n|\\z", Pattern.UNIX_LINES);
    4.45  
    4.46      public static String[] splitIntoLines(CharSequence content) {
     5.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/api/LicenseHeader.java	Wed Jan 02 13:38:30 2013 +0100
     5.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/api/LicenseHeader.java	Fri Jan 04 15:27:42 2013 +0100
     5.3 @@ -67,26 +67,37 @@
     5.4       * <code>FileObject</code>'s name. According to NetBeans conventions,
     5.5       * license file names start with a prefixed <em>license-</em> before the
     5.6       * actual license abbreviation, e.g. <em>epl10</em> for the Eclipse public
     5.7 -     * license version 1.0.</p>
     5.8 +     * license version 1.0 will have a final name of
     5.9 +     * <em>license-epl10.txt</em>.</p>
    5.10       *
    5.11 -     * @param file
    5.12 -     * @param licenseName
    5.13 -     * @param netBeansTemplate
    5.14 -     * @return
    5.15 +     * <p>If the passed in licenseName starts with <em>license-</em>, that
    5.16 +     * prefix is removed.</p>
    5.17 +     *
    5.18 +     * @param file the FileObject containing the license header text
    5.19 +     * @param licenseName the name of the license
    5.20 +     * @param netBeansTemplate whether the license is a netbeans template or not
    5.21 +     * @return a new LicenseHeader
    5.22 +     * @throws NullPointerException if file is null
    5.23       */
    5.24 -    public static LicenseHeader fromFileObject(FileObject file, String licenseName, boolean isNetBeansTemplate) {
    5.25 +    public static LicenseHeader fromFileObject(FileObject file, String licenseName, boolean isNetBeansTemplate) throws NullPointerException {
    5.26 +        if(file == null) {
    5.27 +            throw new NullPointerException("Parameter 'file' must not be null!");
    5.28 +        }
    5.29          String name;
    5.30          if (licenseName == null) {
    5.31              name = file.getName();
    5.32 -            name = name.substring("license-".length());
    5.33          } else {
    5.34              name = licenseName;
    5.35          }
    5.36 +        if (name.startsWith("license-")) {
    5.37 +            name = name.substring("license-".length());
    5.38 +        }
    5.39          String content;
    5.40          InputStream in = null;
    5.41 +        ByteArrayOutputStream out = null;
    5.42          try {
    5.43              in = new BufferedInputStream(file.getInputStream());
    5.44 -            ByteArrayOutputStream out = new ByteArrayOutputStream();
    5.45 +            out = new ByteArrayOutputStream();
    5.46              FileUtil.copy(in, out);
    5.47              content = new String(out.toByteArray());
    5.48              LicenseHeader header = new LicenseHeader(name, content, file, isNetBeansTemplate);
    5.49 @@ -102,17 +113,56 @@
    5.50              } catch (IOException ex) {
    5.51                  Exceptions.printStackTrace(ex);
    5.52              }
    5.53 +            try {
    5.54 +                if (out != null) {
    5.55 +                    out.close();
    5.56 +                }
    5.57 +            } catch (IOException ex) {
    5.58 +                Exceptions.printStackTrace(ex);
    5.59 +            }
    5.60          }
    5.61      }
    5.62  
    5.63 -    public static LicenseHeader fromFileObject(FileObject file, String licenseName) {
    5.64 +    /**
    5.65 +     * <p>Creates a
    5.66 +     * <code>LicenseHeader</code> from a given
    5.67 +     * <code>FileObject</code> and
    5.68 +     * <code>licenseName</code>.</p>
    5.69 +     *
    5.70 +     * @param file the FileObject containing the license header text
    5.71 +     * @param licenseName the name of the license
    5.72 +     * @return a new LicenseHeader
    5.73 +     * @see #fromFileObject(org.openide.filesystems.FileObject,
    5.74 +     * java.lang.String, boolean)
    5.75 +     */
    5.76 +    public static LicenseHeader fromFileObject(FileObject file, String licenseName) throws NullPointerException {
    5.77          return fromFileObject(file, licenseName, false);
    5.78      }
    5.79  
    5.80 -    public static LicenseHeader fromFile(File file) {
    5.81 +    /**
    5.82 +     * <p>Creates a
    5.83 +     * <code>LicenseHeader</code> from a given
    5.84 +     * <code>File</code>.</p>
    5.85 +     *
    5.86 +     * @param file the File containing the license header text
    5.87 +     * @return a new LicenseHeader
    5.88 +     *
    5.89 +     * @see #fromFileObject(org.openide.filesystems.FileObject,
    5.90 +     * java.lang.String)
    5.91 +     */
    5.92 +    public static LicenseHeader fromFile(File file) throws NullPointerException {
    5.93 +        if(file==null) {
    5.94 +            throw new NullPointerException("Parameter 'file' must not be null!");
    5.95 +        }
    5.96          return fromFileObject(FileUtil.toFileObject(file), null);
    5.97      }
    5.98  
    5.99 +    /**
   5.100 +     * <p>Retrieves and returns the available license templates converted to
   5.101 +     * {@link LicenseHeader} objects. Empty licenses are not returned.</p>
   5.102 +     *
   5.103 +     * @return the available license headers
   5.104 +     */
   5.105      public static Collection<? extends LicenseHeader> fromTemplates() {
   5.106          FileObject licenseTemplates = FileUtil.getConfigFile("Templates/Licenses");
   5.107          List<LicenseHeader> templateLicenses = new LinkedList<LicenseHeader>();
   5.108 @@ -123,73 +173,175 @@
   5.109              if (licenseHeader.getLicenseHeader() == null || licenseHeader.getLicenseHeader().isEmpty()) {
   5.110                  System.err.println("License file " + name + " seems to be empty! Skipping...");
   5.111              } else {
   5.112 -                licenseHeader.setNetBeansTemplate(true);
   5.113 +//                licenseHeader.setNetBeansTemplate(true);
   5.114                  templateLicenses.add(licenseHeader);
   5.115              }
   5.116          }
   5.117          return templateLicenses;
   5.118      }
   5.119  
   5.120 -    public static void addAsNetBeansTemplate(LicenseHeader header) {
   5.121 +    /**
   5.122 +     * <p>Add the given header as a netbeans template under
   5.123 +     * <code>Templates/Licenses</code>.</p>
   5.124 +     *
   5.125 +     * <p>The new license template will have a name according to license
   5.126 +     * template conventions. E.g. a license header with name
   5.127 +     * <code>example</code> will result in a template file stored at
   5.128 +     * <code>Templates/Licenses/license-example.txt</code> in the virtual file
   5.129 +     * system. The file can be retrieved via
   5.130 +     * <code>FileUtil.getConfigFile("Templates/Licenses/license-example.txt")</code>.</p>
   5.131 +     *
   5.132 +     * @param header the license header to add as a template
   5.133 +     * @return the license header representing the netbeans template or
   5.134 +     * <em>null</em> if any exceptions occurred.
   5.135 +     */
   5.136 +    public static LicenseHeader addAsNetBeansTemplate(LicenseHeader header) {
   5.137          String filename = "license-" + header.getName() + ".txt";
   5.138          FileObject licenseTemplates = FileUtil.getConfigFile("Templates/Licenses");
   5.139          BufferedWriter bos = null;
   5.140          try {
   5.141              FileObject templateFile = licenseTemplates.createData(filename);
   5.142 -            bos = new BufferedWriter(new OutputStreamWriter(templateFile.getOutputStream(), Charset.forName("UTF-8")));
   5.143 -            bos.write(header.getLicenseHeader());
   5.144 -            header.setNetBeansTemplate(true);
   5.145 +            try {
   5.146 +                DataObject dobj = DataObject.find(templateFile);
   5.147 +                dobj.setTemplate(true);
   5.148 +                dobj.getNodeDelegate().setDisplayName(filename);
   5.149 +            } catch (DataObjectNotFoundException donfe) {
   5.150 +                Exceptions.printStackTrace(donfe);
   5.151 +            }
   5.152 +            //even if the dataobject was not found, 
   5.153 +            //we can still write our template to the file object
   5.154 +            try {
   5.155 +                bos = new BufferedWriter(new OutputStreamWriter(templateFile.getOutputStream(), Charset.forName("UTF-8")));
   5.156 +                bos.write(header.getLicenseHeader());
   5.157 +                bos.close();
   5.158 +            } catch (IOException ioex) {
   5.159 +                Exceptions.printStackTrace(ioex);
   5.160 +            } finally {
   5.161 +                try {
   5.162 +                    if (bos != null) {
   5.163 +                        bos.close();
   5.164 +                    }
   5.165 +                } catch (IOException ex) {
   5.166 +                    Exceptions.printStackTrace(ex);
   5.167 +                }
   5.168 +            }
   5.169 +            return LicenseHeader.fromFileObject(templateFile, null, true);
   5.170          } catch (IOException ex) {
   5.171              Exceptions.printStackTrace(ex);
   5.172 -        } finally {
   5.173 -            try {
   5.174 -                if (bos != null) {
   5.175 -                    bos.close();
   5.176 -                }
   5.177 -            } catch (IOException ex) {
   5.178 -                Exceptions.printStackTrace(ex);
   5.179 -            }
   5.180 +//        } finally {
   5.181          }
   5.182 +        return null;
   5.183      }
   5.184      private final String name;
   5.185      private final String licenseHeader;
   5.186      private final FileObject fo;
   5.187 -    private boolean netBeansTemplate = false;
   5.188 +    private final boolean netBeansTemplate;
   5.189  
   5.190      private LicenseHeader(String name, String licenseHeader, FileObject fo, boolean netBeansTemplate) {
   5.191 +        if (name == null) {
   5.192 +            throw new NullPointerException("Parameter 'name' must not be null!");
   5.193 +        }
   5.194 +        if (licenseHeader == null) {
   5.195 +            throw new NullPointerException("Parameter 'licenseHeader' must not be null!");
   5.196 +        }
   5.197          this.name = name;
   5.198          this.licenseHeader = licenseHeader;
   5.199          this.fo = fo;
   5.200          this.netBeansTemplate = netBeansTemplate;
   5.201      }
   5.202  
   5.203 +    /**
   5.204 +     * <p>Returns the name of this LicenseHeader.</p>
   5.205 +     *
   5.206 +     * @return the license header name
   5.207 +     */
   5.208      public String getName() {
   5.209          return name;
   5.210      }
   5.211  
   5.212 +    /**
   5.213 +     * <p>Returns the raw license header text that may require further
   5.214 +     * interpolation by e.g. freemarker.</p>
   5.215 +     *
   5.216 +     * @return the raw license header text
   5.217 +     */
   5.218      public String getLicenseHeader() {
   5.219          return licenseHeader;
   5.220      }
   5.221  
   5.222 +    /**
   5.223 +     * <p>The FileObject associated to this LicenseHeader.</p>
   5.224 +     *
   5.225 +     * @return the physical file object
   5.226 +     */
   5.227      public FileObject getFileObject() {
   5.228          return this.fo;
   5.229      }
   5.230  
   5.231 +    /**
   5.232 +     * <p>For informational purposes only. The method returns true, if 
   5.233 +     * {@link LicenseHeader#addAsNetBeansTemplate(org.netbeans.modules.licensechanger.api.LicenseHeader) }
   5.234 +     * has been used to add a custom license, or if the LicenseHeader has been
   5.235 +     * loaded via {@link LicenseHeader#fromTemplates() }.</p>
   5.236 +     *
   5.237 +     * @return whether this is a NetBeans template
   5.238 +     */
   5.239      public boolean isNetBeansTemplate() {
   5.240          return netBeansTemplate;
   5.241      }
   5.242  
   5.243 -    public void setNetBeansTemplate(boolean netBeansTemplate) {
   5.244 -        this.netBeansTemplate = netBeansTemplate;
   5.245 +    /**
   5.246 +     * Returns the display name of the associated
   5.247 +     * <code>FileObject</code>'s
   5.248 +     * <code>DataObject</code>. If no
   5.249 +     * <code>DataObject</code> can be found, the name of this LicenseHeader is
   5.250 +     * returned.
   5.251 +     *
   5.252 +     * @return the display name
   5.253 +     */
   5.254 +    @Override
   5.255 +    public String toString() {
   5.256 +        if (fo != null) {
   5.257 +            try {
   5.258 +                return DataObject.find(getFileObject()).getNodeDelegate().getDisplayName();
   5.259 +            } catch (DataObjectNotFoundException ex) {
   5.260 +                Exceptions.printStackTrace(ex);
   5.261 +            }
   5.262 +        }
   5.263 +        return name;
   5.264      }
   5.265  
   5.266      @Override
   5.267 -    public String toString() {
   5.268 -        try {
   5.269 -            return DataObject.find(getFileObject()).getNodeDelegate().getDisplayName();
   5.270 -        } catch (DataObjectNotFoundException ex) {
   5.271 -            Exceptions.printStackTrace(ex);
   5.272 +    public int hashCode() {
   5.273 +        int hash = 7;
   5.274 +        hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
   5.275 +        hash = 59 * hash + (this.licenseHeader != null ? this.licenseHeader.hashCode() : 0);
   5.276 +        hash = 59 * hash + (this.fo != null ? this.fo.hashCode() : 0);
   5.277 +        hash = 59 * hash + (this.netBeansTemplate ? 1 : 0);
   5.278 +        return hash;
   5.279 +    }
   5.280 +
   5.281 +    @Override
   5.282 +    public boolean equals(Object obj) {
   5.283 +        if (obj == null) {
   5.284 +            return false;
   5.285          }
   5.286 -        return name;
   5.287 +        if (getClass() != obj.getClass()) {
   5.288 +            return false;
   5.289 +        }
   5.290 +        final LicenseHeader other = (LicenseHeader) obj;
   5.291 +        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
   5.292 +            return false;
   5.293 +        }
   5.294 +        if ((this.licenseHeader == null) ? (other.licenseHeader != null) : !this.licenseHeader.equals(other.licenseHeader)) {
   5.295 +            return false;
   5.296 +        }
   5.297 +        if (this.fo != other.fo && (this.fo == null || !this.fo.equals(other.fo))) {
   5.298 +            return false;
   5.299 +        }
   5.300 +        if (this.netBeansTemplate != other.netBeansTemplate) {
   5.301 +            return false;
   5.302 +        }
   5.303 +        return true;
   5.304      }
   5.305  }
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/api/Offsets.java	Fri Jan 04 15:27:42 2013 +0100
     6.3 @@ -0,0 +1,62 @@
     6.4 +/*
     6.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     6.6 + *
     6.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
     6.8 + *
     6.9 + * The contents of this file are subject to the terms of either the GNU
    6.10 + * General Public License Version 2 only ("GPL") or the Common
    6.11 + * Development and Distribution License("CDDL") (collectively, the
    6.12 + * "License"). You may not use this file except in compliance with the
    6.13 + * License. You can obtain a copy of the License at
    6.14 + * http://www.netbeans.org/cddl-gplv2.html
    6.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    6.16 + * specific language governing permissions and limitations under the
    6.17 + * License.  When distributing the software, include this License Header
    6.18 + * Notice in each file and include the License file at
    6.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    6.20 + * particular file as subject to the "Classpath" exception as provided
    6.21 + * by Sun in the GPL Version 2 section of the License file that
    6.22 + * accompanied this code. If applicable, add the following below the
    6.23 + * License Header, with the fields enclosed by brackets [] replaced by
    6.24 + * your own identifying information:
    6.25 + * "Portions Copyrighted [year] [name of copyright owner]"
    6.26 + *
    6.27 + * If you wish your version of this file to be governed by only the CDDL
    6.28 + * or only the GPL Version 2, indicate your decision by adding
    6.29 + * "[Contributor] elects to include this software in this distribution
    6.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    6.31 + * single choice of license, a recipient has the option to distribute
    6.32 + * your version of this file under either the CDDL, the GPL Version 2 or
    6.33 + * to extend the choice of license to its licensees as provided above.
    6.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    6.35 + * Version 2 license, then the option applies only if the new code is
    6.36 + * made subject to such option by the copyright holder.
    6.37 + *
    6.38 + * Contributor(s):
    6.39 + *
    6.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
    6.41 + */
    6.42 +package org.netbeans.modules.licensechanger.api;
    6.43 +
    6.44 +/**
    6.45 + *
    6.46 + * @author Tim Boudreau
    6.47 + */
    6.48 +public final class Offsets {
    6.49 +
    6.50 +    private final int start;
    6.51 +    private final int end;
    6.52 +
    6.53 +    public Offsets(int start, int end) {
    6.54 +        this.start = start;
    6.55 +        this.end = end;
    6.56 +    }
    6.57 +
    6.58 +    public int getEnd() {
    6.59 +        return end;
    6.60 +    }
    6.61 +
    6.62 +    public int getStart() {
    6.63 +        return start;
    6.64 +    }
    6.65 +}
     7.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/api/RegexpFileHandler.java	Wed Jan 02 13:38:30 2013 +0100
     7.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/api/RegexpFileHandler.java	Fri Jan 04 15:27:42 2013 +0100
     7.3 @@ -40,7 +40,6 @@
     7.4  
     7.5  import java.util.regex.Matcher;
     7.6  import java.util.regex.Pattern;
     7.7 -import org.netbeans.modules.licensechanger.spi.wizard.utils.Offsets;
     7.8  
     7.9  /**
    7.10   *
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/freemarker/Project.java	Fri Jan 04 15:27:42 2013 +0100
     8.3 @@ -0,0 +1,62 @@
     8.4 +/*
     8.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     8.6 + *
     8.7 + * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
     8.8 + *
     8.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    8.10 + * Other names may be trademarks of their respective owners.
    8.11 + *
    8.12 + * The contents of this file are subject to the terms of either the GNU
    8.13 + * General Public License Version 2 only ("GPL") or the Common
    8.14 + * Development and Distribution License("CDDL") (collectively, the
    8.15 + * "License"). You may not use this file except in compliance with the
    8.16 + * License. You can obtain a copy of the License at
    8.17 + * http://www.netbeans.org/cddl-gplv2.html
    8.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    8.19 + * specific language governing permissions and limitations under the
    8.20 + * License.  When distributing the software, include this License Header
    8.21 + * Notice in each file and include the License file at
    8.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    8.23 + * particular file as subject to the "Classpath" exception as provided
    8.24 + * by Oracle in the GPL Version 2 section of the License file that
    8.25 + * accompanied this code. If applicable, add the following below the
    8.26 + * License Header, with the fields enclosed by brackets [] replaced by
    8.27 + * your own identifying information:
    8.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    8.29 + *
    8.30 + * If you wish your version of this file to be governed by only the CDDL
    8.31 + * or only the GPL Version 2, indicate your decision by adding
    8.32 + * "[Contributor] elects to include this software in this distribution
    8.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    8.34 + * single choice of license, a recipient has the option to distribute
    8.35 + * your version of this file under either the CDDL, the GPL Version 2 or
    8.36 + * to extend the choice of license to its licensees as provided above.
    8.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    8.38 + * Version 2 license, then the option applies only if the new code is
    8.39 + * made subject to such option by the copyright holder.
    8.40 + *
    8.41 + * Contributor(s):
    8.42 + *
    8.43 + * Portions Copyrighted 2013 Sun Microsystems, Inc.
    8.44 + */
    8.45 +package org.netbeans.modules.licensechanger.freemarker;
    8.46 +
    8.47 +/**
    8.48 + * Freemarker expects project.organization to be the field 'organization' in an
    8.49 + * object. This provides a thin wrapper for that. Class must be public to be
    8.50 + * accessible by freemarker.
    8.51 + * 
    8.52 + * @author Nils Hoffmann
    8.53 + */
    8.54 +public class Project {
    8.55 +
    8.56 +    private final String organization;
    8.57 +
    8.58 +    public Project(String organization) {
    8.59 +        this.organization = organization;
    8.60 +    }
    8.61 +
    8.62 +    public String getOrganization() {
    8.63 +        return this.organization;
    8.64 +    }
    8.65 +}
     9.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/JavaFileHandler.java	Wed Jan 02 13:38:30 2013 +0100
     9.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/JavaFileHandler.java	Fri Jan 04 15:27:42 2013 +0100
     9.3 @@ -39,7 +39,7 @@
     9.4  package org.netbeans.modules.licensechanger.spi.handlers;
     9.5  
     9.6  import org.netbeans.modules.licensechanger.api.FileHandler;
     9.7 -import org.netbeans.modules.licensechanger.spi.wizard.utils.Offsets;
     9.8 +import org.netbeans.modules.licensechanger.api.Offsets;
     9.9  import org.openide.filesystems.FileObject;
    9.10  import org.openide.util.NbBundle;
    9.11  
    10.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/PropertiesFileHandler.java	Wed Jan 02 13:38:30 2013 +0100
    10.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/PropertiesFileHandler.java	Fri Jan 04 15:27:42 2013 +0100
    10.3 @@ -39,7 +39,7 @@
    10.4  package org.netbeans.modules.licensechanger.spi.handlers;
    10.5  
    10.6  import org.netbeans.modules.licensechanger.api.FileHandler;
    10.7 -import org.netbeans.modules.licensechanger.spi.wizard.utils.Offsets;
    10.8 +import org.netbeans.modules.licensechanger.api.Offsets;
    10.9  import org.openide.filesystems.FileObject;
   10.10  import org.openide.util.NbBundle;
   10.11  
    11.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/XmlFileHandler.java	Wed Jan 02 13:38:30 2013 +0100
    11.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/spi/handlers/XmlFileHandler.java	Fri Jan 04 15:27:42 2013 +0100
    11.3 @@ -43,7 +43,7 @@
    11.4  import java.util.regex.Matcher;
    11.5  import java.util.regex.Pattern;
    11.6  import org.netbeans.modules.licensechanger.api.FileHandler;
    11.7 -import org.netbeans.modules.licensechanger.spi.wizard.utils.Offsets;
    11.8 +import org.netbeans.modules.licensechanger.api.Offsets;
    11.9  import org.openide.filesystems.FileObject;
   11.10  import org.openide.util.Exceptions;
   11.11  import org.openide.util.NbBundle;
    12.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties	Wed Jan 02 13:38:30 2013 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,39 +0,0 @@
    12.4 -BROWSE_LICENSE_TITLE=Locate License File
    12.5 -MSG_SELECT_A_LICENSE=Select a License or Browse for file
    12.6 -ERR_COULD_NOT_LOAD=Could not load {0}
    12.7 -
    12.8 -WIZARD_TITLE=Add/Replace License Headers
    12.9 -#chooseFileTypes=Select File Types
   12.10 -#chooseLicense=Select License
   12.11 -#chooseFolders=Prune Folders
   12.12 -#chooseFiles=Choose Files
   12.13 -#preview=Preview
   12.14 -LBL_CHANGE_LICENSE=Change License Headers
   12.15 -
   12.16 -LicenseChooserPanel.chooseLabel.text=Choose License
   12.17 -LicenseChooserPanel.browseButton.text=Browse
   12.18 -LicenseChooserPanel.updateDefaultProjectLicense.text=Set as default project license
   12.19 -
   12.20 -ChooseFileTypesPanel.noCustomizerLabel.text=[no customizer]
   12.21 -ChooseFileTypesPanel.customizerPanel.border.title=File Type Settings
   12.22 -ChooseFileTypesPanel.copyrightHolderLabel.text=Copyright Holder
   12.23 -ChooseFileTypesPanel.licensePropertiesPanel.border.title=License Properties
   12.24 -ChooseFileTypesPanel.storeInUserProperties.text=Store in User.properties
   12.25 -ChooseFileTypesPanel.nodesLabel.text=File Types
   12.26 -
   12.27 -SelectFoldersPanel.jLabel1.text=Uncheck Folders that Should Be Ignored
   12.28 -SelectFoldersPanel.nodesLabel.text=Folders
   12.29 -
   12.30 -LineEndingsPanel.border.title=Line Endings
   12.31 -LineEndingsPanel.noChangeButton.text=Do Not Change
   12.32 -LineEndingsPanel.systemDefaultButton.text=Force System Default
   12.33 -LineEndingsPanel.newlineButton.text=Force Newline
   12.34 -LineEndingsPanel.forceCrlf.text=Force CRLF
   12.35 -LineEndingsPanel.newlineButton.text_1=Force Newline
   12.36 -LineEndingsPanel.systemDefaultButton.text_1=Force System Default
   12.37 -LineEndingsPanel.noChangeButton.text_1=Do Not Change
   12.38 -LineEndingsPanel.forceCrlf.text_1=Force CRLF
   12.39 -
   12.40 -PreviewPanel.jLabel1.text=Select File for Preview
   12.41 -PreviewPanel.jLabel3.text=jLabel3
   12.42 -PreviewPanel.nodesLabel.text=Files
    13.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/ChooseFileTypesPanel.form	Wed Jan 02 13:38:30 2013 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,186 +0,0 @@
    13.4 -<?xml version="1.0" encoding="UTF-8" ?>
    13.5 -
    13.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    13.7 -  <AuxValues>
    13.8 -    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    13.9 -    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   13.10 -    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   13.11 -    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   13.12 -    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   13.13 -    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   13.14 -    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   13.15 -    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   13.16 -    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   13.17 -  </AuxValues>
   13.18 -
   13.19 -  <Layout>
   13.20 -    <DimensionLayout dim="0">
   13.21 -      <Group type="103" groupAlignment="0" attributes="0">
   13.22 -          <Group type="102" attributes="0">
   13.23 -              <EmptySpace max="-2" attributes="0"/>
   13.24 -              <Group type="103" groupAlignment="0" attributes="0">
   13.25 -                  <Component id="jScrollPane1" alignment="0" pref="804" max="32767" attributes="0"/>
   13.26 -                  <Group type="102" alignment="1" attributes="0">
   13.27 -                      <Component id="customizerPanel" pref="559" max="32767" attributes="0"/>
   13.28 -                      <EmptySpace max="-2" attributes="0"/>
   13.29 -                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
   13.30 -                          <Component id="lineEndingsPanel1" pref="239" max="32767" attributes="0"/>
   13.31 -                          <Component id="licensePropertiesPanel" max="32767" attributes="0"/>
   13.32 -                      </Group>
   13.33 -                  </Group>
   13.34 -              </Group>
   13.35 -              <EmptySpace max="-2" attributes="0"/>
   13.36 -          </Group>
   13.37 -      </Group>
   13.38 -    </DimensionLayout>
   13.39 -    <DimensionLayout dim="1">
   13.40 -      <Group type="103" groupAlignment="0" attributes="0">
   13.41 -          <Group type="102" alignment="0" attributes="0">
   13.42 -              <EmptySpace max="-2" attributes="0"/>
   13.43 -              <Component id="jScrollPane1" min="-2" pref="137" max="-2" attributes="0"/>
   13.44 -              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   13.45 -              <Group type="103" groupAlignment="0" attributes="0">
   13.46 -                  <Component id="customizerPanel" pref="361" max="32767" attributes="0"/>
   13.47 -                  <Group type="102" attributes="0">
   13.48 -                      <Component id="lineEndingsPanel1" min="-2" max="-2" attributes="0"/>
   13.49 -                      <EmptySpace type="separate" max="-2" attributes="0"/>
   13.50 -                      <Component id="licensePropertiesPanel" max="32767" attributes="0"/>
   13.51 -                  </Group>
   13.52 -              </Group>
   13.53 -              <EmptySpace max="-2" attributes="0"/>
   13.54 -          </Group>
   13.55 -      </Group>
   13.56 -    </DimensionLayout>
   13.57 -  </Layout>
   13.58 -  <SubComponents>
   13.59 -    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
   13.60 -      <Properties>
   13.61 -        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   13.62 -          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
   13.63 -            <LineBorder>
   13.64 -              <Color PropertyName="color" blue="99" green="a8" id="controlShadow" palette="3" red="ac" type="palette"/>
   13.65 -            </LineBorder>
   13.66 -          </Border>
   13.67 -        </Property>
   13.68 -      </Properties>
   13.69 -      <AuxValues>
   13.70 -        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineView()"/>
   13.71 -      </AuxValues>
   13.72 -
   13.73 -      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
   13.74 -    </Container>
   13.75 -    <Container class="javax.swing.JPanel" name="customizerPanel">
   13.76 -      <Properties>
   13.77 -        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   13.78 -          <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
   13.79 -            <TitledBorder title="File Type Settings">
   13.80 -              <ResourceString PropertyName="titleX" bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="ChooseFileTypesPanel.customizerPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   13.81 -            </TitledBorder>
   13.82 -          </Border>
   13.83 -        </Property>
   13.84 -      </Properties>
   13.85 -      <AccessibilityProperties>
   13.86 -        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   13.87 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="ChooseFileTypesPanel.customizerPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   13.88 -        </Property>
   13.89 -      </AccessibilityProperties>
   13.90 -
   13.91 -      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
   13.92 -      <SubComponents>
   13.93 -        <Component class="javax.swing.JLabel" name="noCustomizerLabel">
   13.94 -          <Properties>
   13.95 -            <Property name="horizontalAlignment" type="int" value="0"/>
   13.96 -            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   13.97 -              <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="ChooseFileTypesPanel.noCustomizerLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   13.98 -            </Property>
   13.99 -            <Property name="enabled" type="boolean" value="false"/>
  13.100 -          </Properties>
  13.101 -          <AccessibilityProperties>
  13.102 -            <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  13.103 -              <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="ChooseFileTypesPanel.noCustomizerLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  13.104 -            </Property>
  13.105 -          </AccessibilityProperties>
  13.106 -          <Constraints>
  13.107 -            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
  13.108 -              <BorderConstraints direction="Center"/>
  13.109 -            </Constraint>
  13.110 -          </Constraints>
  13.111 -        </Component>
  13.112 -      </SubComponents>
  13.113 -    </Container>
  13.114 -    <Component class="org.netbeans.modules.licensechanger.spi.wizard.LineEndingsPanel" name="lineEndingsPanel1">
  13.115 -    </Component>
  13.116 -    <Container class="javax.swing.JPanel" name="licensePropertiesPanel">
  13.117 -      <Properties>
  13.118 -        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
  13.119 -          <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
  13.120 -            <TitledBorder title="License Properties">
  13.121 -              <ResourceString PropertyName="titleX" bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="ChooseFileTypesPanel.licensePropertiesPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  13.122 -            </TitledBorder>
  13.123 -          </Border>
  13.124 -        </Property>
  13.125 -      </Properties>
  13.126 -
  13.127 -      <Layout>
  13.128 -        <DimensionLayout dim="0">
  13.129 -          <Group type="103" groupAlignment="0" attributes="0">
  13.130 -              <Group type="102" attributes="0">
  13.131 -                  <EmptySpace max="-2" attributes="0"/>
  13.132 -                  <Group type="103" groupAlignment="0" attributes="0">
  13.133 -                      <Component id="copyrightHolderField" max="32767" attributes="0"/>
  13.134 -                      <Group type="102" attributes="0">
  13.135 -                          <Component id="copyrightHolderLabel" min="-2" max="-2" attributes="0"/>
  13.136 -                          <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
  13.137 -                      </Group>
  13.138 -                      <Component id="storeInUserProperties" max="32767" attributes="0"/>
  13.139 -                  </Group>
  13.140 -                  <EmptySpace max="-2" attributes="0"/>
  13.141 -              </Group>
  13.142 -          </Group>
  13.143 -        </DimensionLayout>
  13.144 -        <DimensionLayout dim="1">
  13.145 -          <Group type="103" groupAlignment="0" attributes="0">
  13.146 -              <Group type="102" alignment="0" attributes="0">
  13.147 -                  <EmptySpace max="-2" attributes="0"/>
  13.148 -                  <Component id="copyrightHolderLabel" min="-2" max="-2" attributes="0"/>
  13.149 -                  <EmptySpace max="-2" attributes="0"/>
  13.150 -                  <Component id="copyrightHolderField" min="-2" max="-2" attributes="0"/>
  13.151 -                  <EmptySpace max="-2" attributes="0"/>
  13.152 -                  <Component id="storeInUserProperties" min="-2" max="-2" attributes="0"/>
  13.153 -                  <EmptySpace max="32767" attributes="0"/>
  13.154 -              </Group>
  13.155 -          </Group>
  13.156 -        </DimensionLayout>
  13.157 -      </Layout>
  13.158 -      <SubComponents>
  13.159 -        <Component class="javax.swing.JLabel" name="copyrightHolderLabel">
  13.160 -          <Properties>
  13.161 -            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
  13.162 -              <ComponentRef name="copyrightHolderField"/>
  13.163 -            </Property>
  13.164 -            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  13.165 -              <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="ChooseFileTypesPanel.copyrightHolderLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  13.166 -            </Property>
  13.167 -          </Properties>
  13.168 -        </Component>
  13.169 -        <Component class="javax.swing.JTextField" name="copyrightHolderField">
  13.170 -          <Properties>
  13.171 -            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
  13.172 -              <Connection code="System.getProperty(&quot;user.name&quot;) == null ? &quot;&quot; : System.getProperty(&quot;user.name&quot;)" type="code"/>
  13.173 -            </Property>
  13.174 -          </Properties>
  13.175 -          <Events>
  13.176 -            <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="copyrightHolderFieldFocusGained"/>
  13.177 -          </Events>
  13.178 -        </Component>
  13.179 -        <Component class="javax.swing.JCheckBox" name="storeInUserProperties">
  13.180 -          <Properties>
  13.181 -            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  13.182 -              <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="ChooseFileTypesPanel.storeInUserProperties.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  13.183 -            </Property>
  13.184 -          </Properties>
  13.185 -        </Component>
  13.186 -      </SubComponents>
  13.187 -    </Container>
  13.188 -  </SubComponents>
  13.189 -</Form>
    14.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/ChooseFileTypesPanel.java	Wed Jan 02 13:38:30 2013 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,295 +0,0 @@
    14.4 -/*
    14.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    14.6 - *
    14.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    14.8 - *
    14.9 - * The contents of this file are subject to the terms of either the GNU
   14.10 - * General Public License Version 2 only ("GPL") or the Common
   14.11 - * Development and Distribution License("CDDL") (collectively, the
   14.12 - * "License"). You may not use this file except in compliance with the
   14.13 - * License. You can obtain a copy of the License at
   14.14 - * http://www.netbeans.org/cddl-gplv2.html
   14.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   14.16 - * specific language governing permissions and limitations under the
   14.17 - * License.  When distributing the software, include this License Header
   14.18 - * Notice in each file and include the License file at
   14.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   14.20 - * particular file as subject to the "Classpath" exception as provided
   14.21 - * by Sun in the GPL Version 2 section of the License file that
   14.22 - * accompanied this code. If applicable, add the following below the
   14.23 - * License Header, with the fields enclosed by brackets [] replaced by
   14.24 - * your own identifying information:
   14.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   14.26 - *
   14.27 - * If you wish your version of this file to be governed by only the CDDL
   14.28 - * or only the GPL Version 2, indicate your decision by adding
   14.29 - * "[Contributor] elects to include this software in this distribution
   14.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   14.31 - * single choice of license, a recipient has the option to distribute
   14.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   14.33 - * to extend the choice of license to its licensees as provided above.
   14.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   14.35 - * Version 2 license, then the option applies only if the new code is
   14.36 - * made subject to such option by the copyright holder.
   14.37 - *
   14.38 - * Contributor(s):
   14.39 - *
   14.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   14.41 - */
   14.42 -
   14.43 -/*
   14.44 - * NewJPanel.java
   14.45 - *
   14.46 - * Created on Mar 20, 2009, 1:14:43 AM
   14.47 - */
   14.48 -package org.netbeans.modules.licensechanger.spi.wizard;
   14.49 -
   14.50 -import java.beans.PropertyChangeEvent;
   14.51 -import java.beans.PropertyChangeListener;
   14.52 -import java.util.Collections;
   14.53 -import java.util.Comparator;
   14.54 -import java.util.HashSet;
   14.55 -import java.util.List;
   14.56 -import java.util.Set;
   14.57 -import org.netbeans.modules.licensechanger.api.Customizable;
   14.58 -import org.netbeans.modules.licensechanger.api.FileHandler;
   14.59 -import org.netbeans.modules.licensechanger.spi.wizard.utils.CheckableNodeCapability;
   14.60 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   14.61 -import org.netbeans.swing.outline.DefaultOutlineModel;
   14.62 -import org.openide.explorer.ExplorerManager;
   14.63 -import org.openide.explorer.view.CheckableNode;
   14.64 -import org.openide.explorer.view.OutlineView;
   14.65 -import org.openide.nodes.AbstractNode;
   14.66 -import org.openide.nodes.ChildFactory;
   14.67 -import org.openide.nodes.Children;
   14.68 -import org.openide.nodes.Node;
   14.69 -import org.openide.util.Lookup;
   14.70 -import org.openide.util.NbPreferences;
   14.71 -import org.openide.util.lookup.Lookups;
   14.72 -
   14.73 -/**
   14.74 - *
   14.75 - * @author Tim Boudreau
   14.76 - * @author Nils Hoffmann (Refactoring)
   14.77 - */
   14.78 -public class ChooseFileTypesPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener {
   14.79 -
   14.80 -    private final ExplorerManager mgr = new ExplorerManager();
   14.81 -
   14.82 -    public ChooseFileTypesPanel() {
   14.83 -        initComponents();
   14.84 -        String copyrightHolder =
   14.85 -                NbPreferences.forModule(ChooseFileTypesWizardPanel.class)
   14.86 -                .get(WizardProperties.KEY_COPYRIGHT_HOLDER, null);
   14.87 -        if (copyrightHolder != null && !copyrightHolder.trim().isEmpty()) {
   14.88 -            copyrightHolderField.setText(copyrightHolder);
   14.89 -        }
   14.90 -        mgr.setRootContext(new AbstractNode(Children.create(new FileHandlerChildren(), false)));
   14.91 -        mgr.addPropertyChangeListener(this);
   14.92 -        updateMap();
   14.93 -        updateView();
   14.94 -    }
   14.95 -
   14.96 -    private void updateMap() {
   14.97 -        Set<FileHandler> handlers = getFileHandlers();
   14.98 -        firePropertyChange(WizardProperties.KEY_FILE_HANDLERS, null, handlers);
   14.99 -    }
  14.100 -
  14.101 -    /**
  14.102 -     * This method is called from within the constructor to initialize the form.
  14.103 -     * WARNING: Do NOT modify this code. The content of this method is always
  14.104 -     * regenerated by the Form Editor.
  14.105 -     */
  14.106 -    @SuppressWarnings("unchecked")
  14.107 -    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  14.108 -    private void initComponents() {
  14.109 -
  14.110 -        jScrollPane1 = new OutlineView();
  14.111 -        customizerPanel = new javax.swing.JPanel();
  14.112 -        noCustomizerLabel = new javax.swing.JLabel();
  14.113 -        lineEndingsPanel1 = new org.netbeans.modules.licensechanger.spi.wizard.LineEndingsPanel();
  14.114 -        licensePropertiesPanel = new javax.swing.JPanel();
  14.115 -        copyrightHolderLabel = new javax.swing.JLabel();
  14.116 -        copyrightHolderField = new javax.swing.JTextField();
  14.117 -        storeInUserProperties = new javax.swing.JCheckBox();
  14.118 -
  14.119 -        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("controlShadow")));
  14.120 -
  14.121 -        customizerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.customizerPanel.border.title"))); // NOI18N
  14.122 -        customizerPanel.setLayout(new java.awt.BorderLayout());
  14.123 -
  14.124 -        noCustomizerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  14.125 -        noCustomizerLabel.setText(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.noCustomizerLabel.text")); // NOI18N
  14.126 -        noCustomizerLabel.setEnabled(false);
  14.127 -        customizerPanel.add(noCustomizerLabel, java.awt.BorderLayout.CENTER);
  14.128 -        noCustomizerLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.noCustomizerLabel.text")); // NOI18N
  14.129 -
  14.130 -        licensePropertiesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.licensePropertiesPanel.border.title"))); // NOI18N
  14.131 -
  14.132 -        copyrightHolderLabel.setLabelFor(copyrightHolderField);
  14.133 -        copyrightHolderLabel.setText(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.copyrightHolderLabel.text")); // NOI18N
  14.134 -
  14.135 -        copyrightHolderField.setText(System.getProperty("user.name") == null ? "" : System.getProperty("user.name"));
  14.136 -        copyrightHolderField.addFocusListener(new java.awt.event.FocusAdapter() {
  14.137 -            public void focusGained(java.awt.event.FocusEvent evt) {
  14.138 -                copyrightHolderFieldFocusGained(evt);
  14.139 -            }
  14.140 -        });
  14.141 -
  14.142 -        storeInUserProperties.setText(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.storeInUserProperties.text")); // NOI18N
  14.143 -
  14.144 -        javax.swing.GroupLayout licensePropertiesPanelLayout = new javax.swing.GroupLayout(licensePropertiesPanel);
  14.145 -        licensePropertiesPanel.setLayout(licensePropertiesPanelLayout);
  14.146 -        licensePropertiesPanelLayout.setHorizontalGroup(
  14.147 -            licensePropertiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  14.148 -            .addGroup(licensePropertiesPanelLayout.createSequentialGroup()
  14.149 -                .addContainerGap()
  14.150 -                .addGroup(licensePropertiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  14.151 -                    .addComponent(copyrightHolderField)
  14.152 -                    .addGroup(licensePropertiesPanelLayout.createSequentialGroup()
  14.153 -                        .addComponent(copyrightHolderLabel)
  14.154 -                        .addGap(0, 0, Short.MAX_VALUE))
  14.155 -                    .addComponent(storeInUserProperties, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  14.156 -                .addContainerGap())
  14.157 -        );
  14.158 -        licensePropertiesPanelLayout.setVerticalGroup(
  14.159 -            licensePropertiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  14.160 -            .addGroup(licensePropertiesPanelLayout.createSequentialGroup()
  14.161 -                .addContainerGap()
  14.162 -                .addComponent(copyrightHolderLabel)
  14.163 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  14.164 -                .addComponent(copyrightHolderField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  14.165 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  14.166 -                .addComponent(storeInUserProperties)
  14.167 -                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  14.168 -        );
  14.169 -
  14.170 -        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  14.171 -        this.setLayout(layout);
  14.172 -        layout.setHorizontalGroup(
  14.173 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  14.174 -            .addGroup(layout.createSequentialGroup()
  14.175 -                .addContainerGap()
  14.176 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  14.177 -                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 804, Short.MAX_VALUE)
  14.178 -                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  14.179 -                        .addComponent(customizerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
  14.180 -                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  14.181 -                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  14.182 -                            .addComponent(lineEndingsPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
  14.183 -                            .addComponent(licensePropertiesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  14.184 -                .addContainerGap())
  14.185 -        );
  14.186 -        layout.setVerticalGroup(
  14.187 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  14.188 -            .addGroup(layout.createSequentialGroup()
  14.189 -                .addContainerGap()
  14.190 -                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
  14.191 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  14.192 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  14.193 -                    .addComponent(customizerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
  14.194 -                    .addGroup(layout.createSequentialGroup()
  14.195 -                        .addComponent(lineEndingsPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  14.196 -                        .addGap(18, 18, 18)
  14.197 -                        .addComponent(licensePropertiesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  14.198 -                .addContainerGap())
  14.199 -        );
  14.200 -
  14.201 -        customizerPanel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.customizerPanel.border.title")); // NOI18N
  14.202 -    }// </editor-fold>//GEN-END:initComponents
  14.203 -
  14.204 -    private void copyrightHolderFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_copyrightHolderFieldFocusGained
  14.205 -        copyrightHolderField.selectAll();
  14.206 -    }//GEN-LAST:event_copyrightHolderFieldFocusGained
  14.207 -    // Variables declaration - do not modify//GEN-BEGIN:variables
  14.208 -    private javax.swing.JTextField copyrightHolderField;
  14.209 -    private javax.swing.JLabel copyrightHolderLabel;
  14.210 -    private javax.swing.JPanel customizerPanel;
  14.211 -    private javax.swing.JScrollPane jScrollPane1;
  14.212 -    private javax.swing.JPanel licensePropertiesPanel;
  14.213 -    private org.netbeans.modules.licensechanger.spi.wizard.LineEndingsPanel lineEndingsPanel1;
  14.214 -    private javax.swing.JLabel noCustomizerLabel;
  14.215 -    private javax.swing.JCheckBox storeInUserProperties;
  14.216 -    // End of variables declaration//GEN-END:variables
  14.217 -
  14.218 -    @Override
  14.219 -    public ExplorerManager getExplorerManager() {
  14.220 -        return mgr;
  14.221 -    }
  14.222 -
  14.223 -    public Set<FileHandler> getFileHandlers() {
  14.224 -        Set<FileHandler> result = new HashSet<FileHandler>();
  14.225 -        for (Node n : mgr.getRootContext().getChildren().getNodes(true)) {
  14.226 -            CheckableNode cn = n.getLookup().lookup(CheckableNode.class);
  14.227 -            if (cn != null && cn.isSelected()) {
  14.228 -                result.addAll(n.getLookup().lookupAll(FileHandler.class));
  14.229 -            }
  14.230 -        }
  14.231 -        return result;
  14.232 -    }
  14.233 -
  14.234 -    @Override
  14.235 -    public void propertyChange(PropertyChangeEvent evt) {
  14.236 -        if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
  14.237 -            Node[] n = mgr.getSelectedNodes();
  14.238 -            updateCustomizer(n.length == 1 ? n[0].getLookup().lookup(Customizable.class) : null);
  14.239 -        }
  14.240 -    }
  14.241 -
  14.242 -    public String getCopyrightHolder() {
  14.243 -        return copyrightHolderField.getText();
  14.244 -    }
  14.245 -
  14.246 -    public void setCopyrightHolder(String copyrightHolder) {
  14.247 -        copyrightHolderField.setText(copyrightHolder);
  14.248 -    }
  14.249 -
  14.250 -    public boolean isStoreInUserProperties() {
  14.251 -        return storeInUserProperties.isSelected();
  14.252 -    }
  14.253 -
  14.254 -    public void setStoreInUserProperties(boolean b) {
  14.255 -        storeInUserProperties.setSelected(b);
  14.256 -    }
  14.257 -
  14.258 -    private void updateView() {
  14.259 -        OutlineView ov = (OutlineView) jScrollPane1;
  14.260 -        ov.getOutline().setRootVisible(false);
  14.261 -        ov.setPopupAllowed(false);
  14.262 -        ov.setTreeSortable(false);
  14.263 -        ov.getOutline().setShowGrid(false);
  14.264 -        String headerName = org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "SelectFoldersPanel.nodesLabel.text"); // NOI18N
  14.265 -        ((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(headerName);
  14.266 -        setName("Choose File Types");
  14.267 -    }
  14.268 -
  14.269 -    private static final class FileHandlerChildren extends ChildFactory<FileHandler> {
  14.270 -
  14.271 -        @Override
  14.272 -        protected boolean createKeys(List<FileHandler> toPopulate) {
  14.273 -            toPopulate.addAll(Lookup.getDefault().lookupAll(FileHandler.class));
  14.274 -            Collections.sort(toPopulate, new Comparator<FileHandler>() {
  14.275 -                @Override
  14.276 -                public int compare(FileHandler t, FileHandler t1) {
  14.277 -                    return t.getDisplayName().compareTo(t1.getDisplayName());
  14.278 -                }
  14.279 -            });
  14.280 -            return true;
  14.281 -        }
  14.282 -
  14.283 -        @Override
  14.284 -        protected Node createNodeForKey(FileHandler key) {
  14.285 -            AbstractNode result = new AbstractNode(Children.LEAF, Lookups.fixed(key, new CheckableNodeCapability()));
  14.286 -            result.setDisplayName(key.getDisplayName());
  14.287 -            return result;
  14.288 -        }
  14.289 -    }
  14.290 -
  14.291 -    private void updateCustomizer(Customizable c) {
  14.292 -        customizerPanel.removeAll();
  14.293 -        customizerPanel.add(c == null ? noCustomizerLabel : c.getCustomizer());
  14.294 -        invalidate();
  14.295 -        revalidate();
  14.296 -        repaint();
  14.297 -    }
  14.298 -}
    15.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/ChooseFileTypesWizardPanel.java	Wed Jan 02 13:38:30 2013 +0100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,137 +0,0 @@
    15.4 -/*
    15.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    15.6 - *
    15.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    15.8 - *
    15.9 - * The contents of this file are subject to the terms of either the GNU
   15.10 - * General Public License Version 2 only ("GPL") or the Common
   15.11 - * Development and Distribution License("CDDL") (collectively, the
   15.12 - * "License"). You may not use this file except in compliance with the
   15.13 - * License. You can obtain a copy of the License at
   15.14 - * http://www.netbeans.org/cddl-gplv2.html
   15.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   15.16 - * specific language governing permissions and limitations under the
   15.17 - * License.  When distributing the software, include this License Header
   15.18 - * Notice in each file and include the License file at
   15.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   15.20 - * particular file as subject to the "Classpath" exception as provided
   15.21 - * by Sun in the GPL Version 2 section of the License file that
   15.22 - * accompanied this code. If applicable, add the following below the
   15.23 - * License Header, with the fields enclosed by brackets [] replaced by
   15.24 - * your own identifying information:
   15.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   15.26 - *
   15.27 - * If you wish your version of this file to be governed by only the CDDL
   15.28 - * or only the GPL Version 2, indicate your decision by adding
   15.29 - * "[Contributor] elects to include this software in this distribution
   15.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   15.31 - * single choice of license, a recipient has the option to distribute
   15.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   15.33 - * to extend the choice of license to its licensees as provided above.
   15.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   15.35 - * Version 2 license, then the option applies only if the new code is
   15.36 - * made subject to such option by the copyright holder.
   15.37 - *
   15.38 - * Contributor(s):
   15.39 - *
   15.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   15.41 - */
   15.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   15.43 -
   15.44 -import java.beans.PropertyChangeEvent;
   15.45 -import java.beans.PropertyChangeListener;
   15.46 -import javax.swing.event.ChangeListener;
   15.47 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   15.48 -import org.openide.WizardDescriptor;
   15.49 -import org.openide.WizardValidationException;
   15.50 -import org.openide.util.ChangeSupport;
   15.51 -import org.openide.util.HelpCtx;
   15.52 -import org.openide.util.NbPreferences;
   15.53 -
   15.54 -/**
   15.55 - *
   15.56 - * @author Nils Hoffmann
   15.57 - */
   15.58 -public class ChooseFileTypesWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   15.59 -
   15.60 -    /**
   15.61 -     * The visual component that displays this panel. If you need to access the
   15.62 -     * component from this class, just use getComponent().
   15.63 -     */
   15.64 -    private ChooseFileTypesPanel component;
   15.65 -    private WizardDescriptor wiz;
   15.66 -    private boolean valid = true;
   15.67 -    private ChangeSupport cs = new ChangeSupport(this);
   15.68 -
   15.69 -    // Get the visual component for the panel. In this template, the component
   15.70 -    // is kept separate. This can be more efficient: if the wizard is created
   15.71 -    // but never displayed, or not all panels are displayed, it is better to
   15.72 -    // create only those which really need to be visible.
   15.73 -    @Override
   15.74 -    public ChooseFileTypesPanel getComponent() {
   15.75 -        if (component == null) {
   15.76 -            component = new ChooseFileTypesPanel();
   15.77 -            component.addPropertyChangeListener(this);
   15.78 -        }
   15.79 -        return component;
   15.80 -    }
   15.81 -
   15.82 -    @Override
   15.83 -    public HelpCtx getHelp() {
   15.84 -        // Show no Help button for this panel:
   15.85 -        return HelpCtx.DEFAULT_HELP;
   15.86 -        // If you have context help:
   15.87 -        // return new HelpCtx("help.key.here");
   15.88 -    }
   15.89 -
   15.90 -    @Override
   15.91 -    public boolean isValid() {
   15.92 -        return valid;
   15.93 -    }
   15.94 -
   15.95 -    @Override
   15.96 -    public void addChangeListener(ChangeListener l) {
   15.97 -        cs.addChangeListener(l);
   15.98 -    }
   15.99 -
  15.100 -    @Override
  15.101 -    public void removeChangeListener(ChangeListener l) {
  15.102 -        cs.removeChangeListener(l);
  15.103 -    }
  15.104 -
  15.105 -    @Override
  15.106 -    public void propertyChange(PropertyChangeEvent pce) {
  15.107 -        cs.fireChange();
  15.108 -    }
  15.109 -
  15.110 -    @Override
  15.111 -    public void readSettings(WizardDescriptor wiz) {
  15.112 -        this.wiz = wiz;
  15.113 -        Boolean storeInUserProperties = (Boolean) wiz.getProperty(WizardProperties.KEY_STORE_IN_USER_PROPERTIES);
  15.114 -        ChooseFileTypesPanel panel = getComponent();
  15.115 -        if (storeInUserProperties != null) {
  15.116 -            panel.setStoreInUserProperties(storeInUserProperties);
  15.117 -        }
  15.118 -        String copyrightHolder = (String) wiz.getProperty(WizardProperties.KEY_COPYRIGHT_HOLDER);
  15.119 -        if (copyrightHolder == null) {
  15.120 -            copyrightHolder = NbPreferences.forModule(ChooseFileTypesWizardPanel.class).get(WizardProperties.KEY_COPYRIGHT_HOLDER, "");
  15.121 -        }
  15.122 -        panel.setCopyrightHolder(copyrightHolder);
  15.123 -    }
  15.124 -
  15.125 -    @Override
  15.126 -    public void storeSettings(WizardDescriptor wiz) {
  15.127 -        wiz.putProperty(WizardProperties.KEY_FILE_HANDLERS, getComponent().getFileHandlers());
  15.128 -        String copyrightHolder = getComponent().getCopyrightHolder();
  15.129 -        if (copyrightHolder != null && !copyrightHolder.isEmpty()) {
  15.130 -            wiz.putProperty(WizardProperties.KEY_COPYRIGHT_HOLDER, copyrightHolder);
  15.131 -            NbPreferences.forModule(ChooseFileTypesWizardPanel.class).put(WizardProperties.KEY_COPYRIGHT_HOLDER, copyrightHolder);
  15.132 -        }
  15.133 -        wiz.putProperty(WizardProperties.KEY_STORE_IN_USER_PROPERTIES, Boolean.valueOf(getComponent().isStoreInUserProperties()));
  15.134 -    }
  15.135 -
  15.136 -    @Override
  15.137 -    public void validate() throws WizardValidationException {
  15.138 -        valid = true;
  15.139 -    }
  15.140 -}
    16.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChangerWizardAction.java	Wed Jan 02 13:38:30 2013 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,148 +0,0 @@
    16.4 -/*
    16.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    16.6 - *
    16.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    16.8 - *
    16.9 - * The contents of this file are subject to the terms of either the GNU
   16.10 - * General Public License Version 2 only ("GPL") or the Common
   16.11 - * Development and Distribution License("CDDL") (collectively, the
   16.12 - * "License"). You may not use this file except in compliance with the
   16.13 - * License. You can obtain a copy of the License at
   16.14 - * http://www.netbeans.org/cddl-gplv2.html
   16.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   16.16 - * specific language governing permissions and limitations under the
   16.17 - * License.  When distributing the software, include this License Header
   16.18 - * Notice in each file and include the License file at
   16.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   16.20 - * particular file as subject to the "Classpath" exception as provided
   16.21 - * by Sun in the GPL Version 2 section of the License file that
   16.22 - * accompanied this code. If applicable, add the following below the
   16.23 - * License Header, with the fields enclosed by brackets [] replaced by
   16.24 - * your own identifying information:
   16.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   16.26 - *
   16.27 - * If you wish your version of this file to be governed by only the CDDL
   16.28 - * or only the GPL Version 2, indicate your decision by adding
   16.29 - * "[Contributor] elects to include this software in this distribution
   16.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   16.31 - * single choice of license, a recipient has the option to distribute
   16.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   16.33 - * to extend the choice of license to its licensees as provided above.
   16.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   16.35 - * Version 2 license, then the option applies only if the new code is
   16.36 - * made subject to such option by the copyright holder.
   16.37 - *
   16.38 - * Contributor(s):
   16.39 - *
   16.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   16.41 - */
   16.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   16.43 -
   16.44 -import java.awt.Component;
   16.45 -import java.awt.event.ActionEvent;
   16.46 -import java.awt.event.ActionListener;
   16.47 -import java.text.MessageFormat;
   16.48 -import java.util.ArrayList;
   16.49 -import java.util.HashSet;
   16.50 -import java.util.List;
   16.51 -import java.util.Set;
   16.52 -import javax.swing.JComponent;
   16.53 -import org.netbeans.api.project.*;
   16.54 -import org.netbeans.modules.licensechanger.spi.wizard.utils.LicenseChangerRunnable;
   16.55 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   16.56 -import org.openide.DialogDisplayer;
   16.57 -import org.openide.WizardDescriptor;
   16.58 -import org.openide.awt.ActionID;
   16.59 -import org.openide.awt.ActionReference;
   16.60 -import org.openide.awt.ActionReferences;
   16.61 -import org.openide.awt.ActionRegistration;
   16.62 -import org.openide.filesystems.FileObject;
   16.63 -import org.openide.loaders.DataObject;
   16.64 -import org.openide.util.*;
   16.65 -
   16.66 -/**
   16.67 - * Context-sensitive action to launch the license header change wizard.
   16.68 - *
   16.69 - * @author Nils Hoffmann
   16.70 - */
   16.71 -@ActionID(
   16.72 -    category = "Tools",
   16.73 -id = "org.netbeans.modules.licensechanger.wizard.LicenseChangerWizardAction")
   16.74 -@ActionRegistration(
   16.75 -    displayName = "#CTL_LicenseChangerWizardAction")
   16.76 -@ActionReferences(
   16.77 -//    @ActionReference(path = "Loaders/folder/any/Actions", position = 951)
   16.78 -@ActionReference(path = "UI/ToolActions/Files", position = 951))
   16.79 -@NbBundle.Messages("CTL_LicenseChangerWizardAction=Change License Header")
   16.80 -public final class LicenseChangerWizardAction implements ActionListener {
   16.81 -
   16.82 -    private List<DataObject> context;
   16.83 -
   16.84 -    public LicenseChangerWizardAction(List<DataObject> context) {
   16.85 -        this.context = context;
   16.86 -    }
   16.87 -
   16.88 -    /**
   16.89 -     * Used to return the parent folder of a file or the folder itself.
   16.90 -     *
   16.91 -     * @param fo
   16.92 -     * @return
   16.93 -     */
   16.94 -    private FileObject addFileObject(FileObject fo) {
   16.95 -        if (fo.isFolder()) {
   16.96 -            return fo;
   16.97 -        }
   16.98 -        return fo.getParent();
   16.99 -    }
  16.100 -
  16.101 -    @Override
  16.102 -    public void actionPerformed(ActionEvent e) {
  16.103 -        Set<FileObject> files = new HashSet<FileObject>();
  16.104 -        Project owningProject = null;
  16.105 -        for (DataObject ob : context) {
  16.106 -            FileObject fo = ob.getPrimaryFile();
  16.107 -            Project proj = FileOwnerQuery.getOwner(fo);
  16.108 -            if (owningProject == null) {
  16.109 -                owningProject = proj;
  16.110 -                //TODO implement better exclusion of build directories 
  16.111 -                files.add(addFileObject(fo));
  16.112 -            } else {
  16.113 -                if (owningProject.equals(proj)) {
  16.114 -                    files.add(addFileObject(fo));
  16.115 -                } else {
  16.116 -                    Exceptions.printStackTrace(new IllegalStateException("Can only handle folders below one project!"));
  16.117 -                    return;
  16.118 -                }
  16.119 -            }
  16.120 -        }
  16.121 -
  16.122 -        List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
  16.123 -        panels.add(new ChooseFileTypesWizardPanel());
  16.124 -        panels.add(new LicenseChooserWizardPanel());
  16.125 -        panels.add(new SelectFoldersWizardPanel());
  16.126 -        panels.add(new PreviewWizardPanel());
  16.127 -        String[] steps = new String[panels.size()];
  16.128 -        for (int i = 0; i < panels.size(); i++) {
  16.129 -            Component c = panels.get(i).getComponent();
  16.130 -            // Default step name to component name of panel.
  16.131 -            steps[i] = c.getName();
  16.132 -            if (c instanceof JComponent) { // assume Swing components
  16.133 -                JComponent jc = (JComponent) c;
  16.134 -                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
  16.135 -                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
  16.136 -                jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
  16.137 -                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
  16.138 -                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
  16.139 -            }
  16.140 -        }
  16.141 -        WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<WizardDescriptor>(panels));
  16.142 -        // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
  16.143 -        wiz.setTitleFormat(new MessageFormat("{0}"));
  16.144 -        wiz.setTitle("Change License Headers");
  16.145 -        wiz.putProperty(WizardProperties.KEY_ROOT_FILES, files);
  16.146 -        wiz.putProperty(WizardProperties.KEY_PROJECT, owningProject);
  16.147 -        if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
  16.148 -            RequestProcessor.getDefault().post(new LicenseChangerRunnable(wiz));
  16.149 -        }
  16.150 -    }
  16.151 -}
    17.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChooserPanel.form	Wed Jan 02 13:38:30 2013 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,116 +0,0 @@
    17.4 -<?xml version="1.0" encoding="UTF-8" ?>
    17.5 -
    17.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    17.7 -  <AuxValues>
    17.8 -    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    17.9 -    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   17.10 -    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   17.11 -    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   17.12 -    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   17.13 -    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   17.14 -    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   17.15 -    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   17.16 -    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   17.17 -  </AuxValues>
   17.18 -
   17.19 -  <Layout>
   17.20 -    <DimensionLayout dim="0">
   17.21 -      <Group type="103" groupAlignment="0" attributes="0">
   17.22 -          <Group type="102" alignment="0" attributes="0">
   17.23 -              <EmptySpace max="-2" attributes="0"/>
   17.24 -              <Group type="103" groupAlignment="0" attributes="0">
   17.25 -                  <Component id="jScrollPane2" max="32767" attributes="0"/>
   17.26 -                  <Group type="102" alignment="0" attributes="0">
   17.27 -                      <Component id="chooseLabel" min="-2" max="-2" attributes="0"/>
   17.28 -                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
   17.29 -                      <Component id="selectLicense" max="32767" attributes="0"/>
   17.30 -                  </Group>
   17.31 -                  <Group type="102" alignment="1" attributes="0">
   17.32 -                      <Component id="updateDefaultProjectLicense" min="-2" max="-2" attributes="0"/>
   17.33 -                      <EmptySpace max="32767" attributes="0"/>
   17.34 -                      <Component id="browseButton" min="-2" max="-2" attributes="0"/>
   17.35 -                  </Group>
   17.36 -              </Group>
   17.37 -              <EmptySpace max="-2" attributes="0"/>
   17.38 -          </Group>
   17.39 -      </Group>
   17.40 -    </DimensionLayout>
   17.41 -    <DimensionLayout dim="1">
   17.42 -      <Group type="103" groupAlignment="0" attributes="0">
   17.43 -          <Group type="102" alignment="0" attributes="0">
   17.44 -              <EmptySpace min="-2" max="-2" attributes="0"/>
   17.45 -              <Group type="103" groupAlignment="3" attributes="0">
   17.46 -                  <Component id="chooseLabel" alignment="3" min="-2" max="-2" attributes="0"/>
   17.47 -                  <Component id="selectLicense" alignment="3" min="-2" max="-2" attributes="0"/>
   17.48 -              </Group>
   17.49 -              <EmptySpace max="-2" attributes="0"/>
   17.50 -              <Component id="jScrollPane2" pref="223" max="32767" attributes="0"/>
   17.51 -              <EmptySpace max="-2" attributes="0"/>
   17.52 -              <Group type="103" groupAlignment="0" attributes="0">
   17.53 -                  <Component id="browseButton" min="-2" max="-2" attributes="0"/>
   17.54 -                  <Component id="updateDefaultProjectLicense" min="-2" max="-2" attributes="0"/>
   17.55 -              </Group>
   17.56 -              <EmptySpace max="-2" attributes="0"/>
   17.57 -          </Group>
   17.58 -      </Group>
   17.59 -    </DimensionLayout>
   17.60 -  </Layout>
   17.61 -  <SubComponents>
   17.62 -    <Component class="javax.swing.JLabel" name="chooseLabel">
   17.63 -      <Properties>
   17.64 -        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
   17.65 -          <ComponentRef name="selectLicense"/>
   17.66 -        </Property>
   17.67 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   17.68 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LicenseChooserPanel.chooseLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   17.69 -        </Property>
   17.70 -      </Properties>
   17.71 -    </Component>
   17.72 -    <Component class="javax.swing.JComboBox" name="selectLicense">
   17.73 -      <Properties>
   17.74 -        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
   17.75 -          <StringArray count="1">
   17.76 -            <StringItem index="0" value="[loading licenses]"/>
   17.77 -          </StringArray>
   17.78 -        </Property>
   17.79 -      </Properties>
   17.80 -      <Events>
   17.81 -        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="licenseSelected"/>
   17.82 -      </Events>
   17.83 -    </Component>
   17.84 -    <Component class="javax.swing.JButton" name="browseButton">
   17.85 -      <Properties>
   17.86 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   17.87 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LicenseChooserPanel.browseButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   17.88 -        </Property>
   17.89 -      </Properties>
   17.90 -      <Events>
   17.91 -        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseForLicense"/>
   17.92 -      </Events>
   17.93 -    </Component>
   17.94 -    <Component class="javax.swing.JCheckBox" name="updateDefaultProjectLicense">
   17.95 -      <Properties>
   17.96 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   17.97 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LicenseChooserPanel.updateDefaultProjectLicense.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   17.98 -        </Property>
   17.99 -      </Properties>
  17.100 -    </Component>
  17.101 -    <Container class="javax.swing.JScrollPane" name="jScrollPane2">
  17.102 -      <AuxValues>
  17.103 -        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
  17.104 -      </AuxValues>
  17.105 -
  17.106 -      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
  17.107 -      <SubComponents>
  17.108 -        <Component class="javax.swing.JEditorPane" name="licenseText">
  17.109 -          <Properties>
  17.110 -            <Property name="editable" type="boolean" value="false"/>
  17.111 -          </Properties>
  17.112 -          <AuxValues>
  17.113 -            <AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="licenseText.setContentType(&quot;text/plain&quot;);"/>
  17.114 -          </AuxValues>
  17.115 -        </Component>
  17.116 -      </SubComponents>
  17.117 -    </Container>
  17.118 -  </SubComponents>
  17.119 -</Form>
    18.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChooserPanel.java	Wed Jan 02 13:38:30 2013 +0100
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,300 +0,0 @@
    18.4 -/*
    18.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    18.6 - *
    18.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    18.8 - *
    18.9 - * The contents of this file are subject to the terms of either the GNU
   18.10 - * General Public License Version 2 only ("GPL") or the Common
   18.11 - * Development and Distribution License("CDDL") (collectively, the
   18.12 - * "License"). You may not use this file except in compliance with the
   18.13 - * License. You can obtain a copy of the License at
   18.14 - * http://www.netbeans.org/cddl-gplv2.html
   18.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   18.16 - * specific language governing permissions and limitations under the
   18.17 - * License.  When distributing the software, include this License Header
   18.18 - * Notice in each file and include the License file at
   18.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   18.20 - * particular file as subject to the "Classpath" exception as provided
   18.21 - * by Sun in the GPL Version 2 section of the License file that
   18.22 - * accompanied this code. If applicable, add the following below the
   18.23 - * License Header, with the fields enclosed by brackets [] replaced by
   18.24 - * your own identifying information:
   18.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   18.26 - *
   18.27 - * If you wish your version of this file to be governed by only the CDDL
   18.28 - * or only the GPL Version 2, indicate your decision by adding
   18.29 - * "[Contributor] elects to include this software in this distribution
   18.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   18.31 - * single choice of license, a recipient has the option to distribute
   18.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   18.33 - * to extend the choice of license to its licensees as provided above.
   18.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   18.35 - * Version 2 license, then the option applies only if the new code is
   18.36 - * made subject to such option by the copyright holder.
   18.37 - *
   18.38 - * Contributor(s):
   18.39 - *
   18.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   18.41 - */
   18.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   18.43 -
   18.44 -import java.awt.Component;
   18.45 -import java.awt.EventQueue;
   18.46 -import java.io.File;
   18.47 -import java.io.IOException;
   18.48 -import javax.swing.DefaultComboBoxModel;
   18.49 -import javax.swing.SwingUtilities;
   18.50 -import javax.swing.event.DocumentEvent;
   18.51 -import javax.swing.event.DocumentListener;
   18.52 -import org.netbeans.modules.licensechanger.api.LicenseHeader;
   18.53 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   18.54 -import org.openide.filesystems.FileChooserBuilder;
   18.55 -import org.openide.util.Exceptions;
   18.56 -import org.openide.util.NbBundle;
   18.57 -import org.openide.util.RequestProcessor;
   18.58 -
   18.59 -/**
   18.60 - *
   18.61 - * @author Tim Boudreau
   18.62 - * @author Nils Hoffmann (Refactoring)
   18.63 - */
   18.64 -public class LicenseChooserPanel extends javax.swing.JPanel implements Runnable, DocumentListener {
   18.65 -
   18.66 -    private volatile boolean licensesLoaded;
   18.67 -    private volatile boolean loadingLicenses;
   18.68 -
   18.69 -    /**
   18.70 -     * Creates new form LicenseChooser
   18.71 -     */
   18.72 -    public LicenseChooserPanel() {
   18.73 -        initComponents();
   18.74 -        enabled(false);
   18.75 -        licenseText.getDocument().addDocumentListener(this);
   18.76 -        licenseText.setText(WizardProperties.VALUE_DEFAULT_LICENSE_TEXT);
   18.77 -        setName("Choose License Header");
   18.78 -    }
   18.79 -
   18.80 -    /**
   18.81 -     * This method is called from within the constructor to initialize the form.
   18.82 -     * WARNING: Do NOT modify this code. The content of this method is always
   18.83 -     * regenerated by the Form Editor.
   18.84 -     */
   18.85 -    @SuppressWarnings("unchecked")
   18.86 -    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   18.87 -    private void initComponents() {
   18.88 -
   18.89 -        chooseLabel = new javax.swing.JLabel();
   18.90 -        selectLicense = new javax.swing.JComboBox();
   18.91 -        browseButton = new javax.swing.JButton();
   18.92 -        updateDefaultProjectLicense = new javax.swing.JCheckBox();
   18.93 -        jScrollPane2 = new javax.swing.JScrollPane();
   18.94 -        licenseText = new javax.swing.JEditorPane();
   18.95 -
   18.96 -        chooseLabel.setLabelFor(selectLicense);
   18.97 -        chooseLabel.setText(org.openide.util.NbBundle.getMessage(LicenseChooserPanel.class, "LicenseChooserPanel.chooseLabel.text")); // NOI18N
   18.98 -
   18.99 -        selectLicense.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[loading licenses]" }));
  18.100 -        selectLicense.addActionListener(new java.awt.event.ActionListener() {
  18.101 -            public void actionPerformed(java.awt.event.ActionEvent evt) {
  18.102 -                licenseSelected(evt);
  18.103 -            }
  18.104 -        });
  18.105 -
  18.106 -        browseButton.setText(org.openide.util.NbBundle.getMessage(LicenseChooserPanel.class, "LicenseChooserPanel.browseButton.text")); // NOI18N
  18.107 -        browseButton.addActionListener(new java.awt.event.ActionListener() {
  18.108 -            public void actionPerformed(java.awt.event.ActionEvent evt) {
  18.109 -                browseForLicense(evt);
  18.110 -            }
  18.111 -        });
  18.112 -
  18.113 -        updateDefaultProjectLicense.setText(org.openide.util.NbBundle.getMessage(LicenseChooserPanel.class, "LicenseChooserPanel.updateDefaultProjectLicense.text")); // NOI18N
  18.114 -
  18.115 -        licenseText.setEditable(false);
  18.116 -        jScrollPane2.setViewportView(licenseText);
  18.117 -        licenseText.setContentType("text/plain");
  18.118 -
  18.119 -        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  18.120 -        this.setLayout(layout);
  18.121 -        layout.setHorizontalGroup(
  18.122 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  18.123 -            .addGroup(layout.createSequentialGroup()
  18.124 -                .addContainerGap()
  18.125 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  18.126 -                    .addComponent(jScrollPane2)
  18.127 -                    .addGroup(layout.createSequentialGroup()
  18.128 -                        .addComponent(chooseLabel)
  18.129 -                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  18.130 -                        .addComponent(selectLicense, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  18.131 -                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  18.132 -                        .addComponent(updateDefaultProjectLicense)
  18.133 -                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  18.134 -                        .addComponent(browseButton)))
  18.135 -                .addContainerGap())
  18.136 -        );
  18.137 -        layout.setVerticalGroup(
  18.138 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  18.139 -            .addGroup(layout.createSequentialGroup()
  18.140 -                .addContainerGap()
  18.141 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  18.142 -                    .addComponent(chooseLabel)
  18.143 -                    .addComponent(selectLicense, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  18.144 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  18.145 -                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
  18.146 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  18.147 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  18.148 -                    .addComponent(browseButton)
  18.149 -                    .addComponent(updateDefaultProjectLicense))
  18.150 -                .addContainerGap())
  18.151 -        );
  18.152 -    }// </editor-fold>//GEN-END:initComponents
  18.153 -
  18.154 -    private void licenseSelected(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_licenseSelected
  18.155 -        if (loadingLicenses || !selectLicense.isEnabled()) {
  18.156 -            return;
  18.157 -        }
  18.158 -        loadLicenseFromResource((LicenseHeader) selectLicense.getSelectedItem());
  18.159 -    }//GEN-LAST:event_licenseSelected
  18.160 -
  18.161 -    private void browseForLicense(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseForLicense
  18.162 -        File f;
  18.163 -        if ((f = new FileChooserBuilder(LicenseChooserPanel.class).setTitle(
  18.164 -                NbBundle.getMessage(LicenseChooserPanel.class, "BROWSE_LICENSE_TITLE")) //NOI18N
  18.165 -                .setFilesOnly(true).showOpenDialog()) != null) {
  18.166 -            updateDefaultProjectLicense.setSelected(false);
  18.167 -            DefaultComboBoxModel dcbm = (DefaultComboBoxModel) selectLicense.getModel();
  18.168 -            LicenseHeader lh = LicenseHeader.fromFile(f);
  18.169 -            LicenseHeader.addAsNetBeansTemplate(lh);
  18.170 -            for (LicenseHeader header : LicenseHeader.fromTemplates()) {
  18.171 -                if (header.getName().equals(lh.getName())) {
  18.172 -//                    System.out.println("Found newly added template!");
  18.173 -                    dcbm.addElement(header);
  18.174 -                    dcbm.setSelectedItem(header);
  18.175 -                    loadLicenseFromResource(header);
  18.176 -                }
  18.177 -            }
  18.178 -        }
  18.179 -    }//GEN-LAST:event_browseForLicense
  18.180 -
  18.181 -    @Override
  18.182 -    public void addNotify() {
  18.183 -        super.addNotify();
  18.184 -        if (!licensesLoaded && !loadingLicenses) {
  18.185 -            loadingLicenses = true;
  18.186 -            enabled(false);
  18.187 -            RequestProcessor.getDefault().post(this);
  18.188 -        }
  18.189 -    }
  18.190 -    // Variables declaration - do not modify//GEN-BEGIN:variables
  18.191 -    private javax.swing.JButton browseButton;
  18.192 -    private javax.swing.JLabel chooseLabel;
  18.193 -    private javax.swing.JScrollPane jScrollPane2;
  18.194 -    private javax.swing.JEditorPane licenseText;
  18.195 -    private javax.swing.JComboBox selectLicense;
  18.196 -    private javax.swing.JCheckBox updateDefaultProjectLicense;
  18.197 -    // End of variables declaration//GEN-END:variables
  18.198 -
  18.199 -    private void enabled(boolean val) {
  18.200 -        for (Component c : getComponents()) {
  18.201 -            c.setEnabled(val);
  18.202 -        }
  18.203 -    }
  18.204 -
  18.205 -    private void initLicenses() throws IOException {
  18.206 -        assert !EventQueue.isDispatchThread();
  18.207 -        final DefaultComboBoxModel mdl = new DefaultComboBoxModel();
  18.208 -        for (LicenseHeader header : LicenseHeader.fromTemplates()) {
  18.209 -            mdl.addElement(header);
  18.210 -        }
  18.211 -        EventQueue.invokeLater(new Runnable() {
  18.212 -            @Override
  18.213 -            public void run() {
  18.214 -                mdl.setSelectedItem(NbBundle.getMessage(LicenseChooserPanel.class,
  18.215 -                        "MSG_SELECT_A_LICENSE")); //NOI18N
  18.216 -                selectLicense.setModel(mdl);
  18.217 -                enabled(true);
  18.218 -                licensesLoaded = true;
  18.219 -                loadingLicenses = false;
  18.220 -            }
  18.221 -        });
  18.222 -    }
  18.223 -
  18.224 -    @Override
  18.225 -    public void run() {
  18.226 -        try {
  18.227 -            initLicenses();
  18.228 -        } catch (IOException ex) {
  18.229 -            Exceptions.printStackTrace(ex);
  18.230 -        }
  18.231 -    }
  18.232 -
  18.233 -    private void loadLicenseFromResource(LicenseHeader header) {
  18.234 -        enabled(false);
  18.235 -        SwingUtilities.invokeLater(new ResourceLoader(header));
  18.236 -    }
  18.237 -
  18.238 -    public String getLicenseText() {
  18.239 -        return licenseText.getText();
  18.240 -    }
  18.241 -
  18.242 -    public String getLicenseName() {
  18.243 -        Object obj = selectLicense.getSelectedItem();
  18.244 -        if (obj != null && obj instanceof LicenseHeader) {
  18.245 -            LicenseHeader header = (LicenseHeader) obj;
  18.246 -            return header.getName();
  18.247 -        }
  18.248 -        return null;
  18.249 -    }
  18.250 -
  18.251 -    public boolean isUpdateDefaultProjectLicense() {
  18.252 -        return updateDefaultProjectLicense.isSelected();
  18.253 -    }
  18.254 -
  18.255 -    public void setUpdateDefaultProjectLicense(boolean b) {
  18.256 -        updateDefaultProjectLicense.setSelected(b);
  18.257 -    }
  18.258 -
  18.259 -    private void updateLicense() {
  18.260 -        licenseText.setEditable(false);
  18.261 -        String txt = licenseText.getText();
  18.262 -        if (!txt.endsWith("\n")) {
  18.263 -            txt += "\n";
  18.264 -        }
  18.265 -        firePropertyChange(WizardProperties.KEY_LICENSE_TEXT, null, txt);
  18.266 -    }
  18.267 -
  18.268 -    @Override
  18.269 -    public void insertUpdate(DocumentEvent e) {
  18.270 -        updateLicense();
  18.271 -    }
  18.272 -
  18.273 -    @Override
  18.274 -    public void removeUpdate(DocumentEvent e) {
  18.275 -        updateLicense();
  18.276 -    }
  18.277 -
  18.278 -    @Override
  18.279 -    public void changedUpdate(DocumentEvent e) {
  18.280 -        updateLicense();
  18.281 -    }
  18.282 -
  18.283 -    private class ResourceLoader implements Runnable {
  18.284 -
  18.285 -        private LicenseHeader header;
  18.286 -
  18.287 -        ResourceLoader(LicenseHeader header) {
  18.288 -            this.header = header;
  18.289 -        }
  18.290 -
  18.291 -        @Override
  18.292 -        public void run() {
  18.293 -            licenseText.setText(header.getLicenseHeader());
  18.294 -            String mimeType = header.getFileObject().getMIMEType();
  18.295 -            licenseText.setContentType(mimeType);
  18.296 -            enabled(true);
  18.297 -        }
  18.298 -    }
  18.299 -
  18.300 -    public void setLicenseText(String text) {
  18.301 -        licenseText.setText(text);
  18.302 -    }
  18.303 -}
    19.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LicenseChooserWizardPanel.java	Wed Jan 02 13:38:30 2013 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,147 +0,0 @@
    19.4 -/*
    19.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    19.6 - *
    19.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    19.8 - *
    19.9 - * The contents of this file are subject to the terms of either the GNU
   19.10 - * General Public License Version 2 only ("GPL") or the Common
   19.11 - * Development and Distribution License("CDDL") (collectively, the
   19.12 - * "License"). You may not use this file except in compliance with the
   19.13 - * License. You can obtain a copy of the License at
   19.14 - * http://www.netbeans.org/cddl-gplv2.html
   19.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   19.16 - * specific language governing permissions and limitations under the
   19.17 - * License.  When distributing the software, include this License Header
   19.18 - * Notice in each file and include the License file at
   19.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   19.20 - * particular file as subject to the "Classpath" exception as provided
   19.21 - * by Sun in the GPL Version 2 section of the License file that
   19.22 - * accompanied this code. If applicable, add the following below the
   19.23 - * License Header, with the fields enclosed by brackets [] replaced by
   19.24 - * your own identifying information:
   19.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   19.26 - *
   19.27 - * If you wish your version of this file to be governed by only the CDDL
   19.28 - * or only the GPL Version 2, indicate your decision by adding
   19.29 - * "[Contributor] elects to include this software in this distribution
   19.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   19.31 - * single choice of license, a recipient has the option to distribute
   19.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   19.33 - * to extend the choice of license to its licensees as provided above.
   19.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   19.35 - * Version 2 license, then the option applies only if the new code is
   19.36 - * made subject to such option by the copyright holder.
   19.37 - *
   19.38 - * Contributor(s):
   19.39 - *
   19.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   19.41 - */
   19.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   19.43 -
   19.44 -import java.beans.PropertyChangeEvent;
   19.45 -import java.beans.PropertyChangeListener;
   19.46 -import javax.swing.event.ChangeListener;
   19.47 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   19.48 -import org.openide.WizardDescriptor;
   19.49 -import org.openide.WizardValidationException;
   19.50 -import org.openide.util.ChangeSupport;
   19.51 -import org.openide.util.HelpCtx;
   19.52 -
   19.53 -/**
   19.54 - *
   19.55 - * @author Nils Hoffmann
   19.56 - */
   19.57 -public class LicenseChooserWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   19.58 -
   19.59 -    /**
   19.60 -     * The visual component that displays this panel. If you need to access the
   19.61 -     * component from this class, just use getComponent().
   19.62 -     */
   19.63 -    private LicenseChooserPanel component;
   19.64 -    private WizardDescriptor wiz;
   19.65 -    private boolean valid = false;
   19.66 -    private ChangeSupport cs = new ChangeSupport(this);
   19.67 -
   19.68 -    // Get the visual component for the panel. In this template, the component
   19.69 -    // is kept separate. This can be more efficient: if the wizard is created
   19.70 -    // but never displayed, or not all panels are displayed, it is better to
   19.71 -    // create only those which really need to be visible.
   19.72 -    @Override
   19.73 -    public LicenseChooserPanel getComponent() {
   19.74 -        if (component == null) {
   19.75 -            component = new LicenseChooserPanel();
   19.76 -            component.addPropertyChangeListener(this);
   19.77 -        }
   19.78 -        return component;
   19.79 -    }
   19.80 -
   19.81 -    @Override
   19.82 -    public HelpCtx getHelp() {
   19.83 -        // Show no Help button for this panel:
   19.84 -        return HelpCtx.DEFAULT_HELP;
   19.85 -        // If you have context help:
   19.86 -        // return new HelpCtx("help.key.here");
   19.87 -    }
   19.88 -
   19.89 -    @Override
   19.90 -    public boolean isValid() {
   19.91 -        return valid;
   19.92 -    }
   19.93 -
   19.94 -    @Override
   19.95 -    public void addChangeListener(ChangeListener l) {
   19.96 -        cs.addChangeListener(l);
   19.97 -    }
   19.98 -
   19.99 -    @Override
  19.100 -    public void removeChangeListener(ChangeListener l) {
  19.101 -        cs.removeChangeListener(l);
  19.102 -    }
  19.103 -
  19.104 -    @Override
  19.105 -    public void propertyChange(PropertyChangeEvent pce) {
  19.106 -        cs.fireChange();
  19.107 -        try {
  19.108 -            validate();
  19.109 -        } catch (WizardValidationException ex) {
  19.110 -            if (wiz != null) {
  19.111 -                wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Please select a license!");
  19.112 -            }
  19.113 -        }
  19.114 -    }
  19.115 -
  19.116 -    @Override
  19.117 -    public void readSettings(WizardDescriptor wiz) {
  19.118 -        this.wiz = wiz;
  19.119 -        Object obj = wiz.getProperty(WizardProperties.KEY_LICENSE_TEXT);
  19.120 -        if (obj != null && obj instanceof String) {
  19.121 -            getComponent().setLicenseText((String) obj);
  19.122 -        }
  19.123 -        Boolean b = (Boolean) wiz.getProperty(WizardProperties.KEY_UPDATE_DEFAULT_PROJECT_LICENSE);
  19.124 -        if (b != null) {
  19.125 -            getComponent().setUpdateDefaultProjectLicense(b);
  19.126 -        }
  19.127 -    }
  19.128 -
  19.129 -    @Override
  19.130 -    public void storeSettings(WizardDescriptor wiz) {
  19.131 -        wiz.putProperty(WizardProperties.KEY_LICENSE_TEXT, getComponent().getLicenseText());
  19.132 -        wiz.putProperty(WizardProperties.KEY_LICENSE_NAME, getComponent().getLicenseName());
  19.133 -        wiz.putProperty(WizardProperties.KEY_UPDATE_DEFAULT_PROJECT_LICENSE, Boolean.valueOf(getComponent().isUpdateDefaultProjectLicense()));
  19.134 -    }
  19.135 -
  19.136 -    @Override
  19.137 -    public void validate() throws WizardValidationException {
  19.138 -        valid = true;
  19.139 -        if (getComponent().getLicenseText() == null
  19.140 -                || getComponent().getLicenseText().equals(WizardProperties.VALUE_DEFAULT_LICENSE_TEXT)) {
  19.141 -            valid = false;
  19.142 -            throw new WizardValidationException(component, "Please select a license!", null);
  19.143 -        }
  19.144 -        if (wiz != null) {
  19.145 -            wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
  19.146 -            wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, null);
  19.147 -            wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
  19.148 -        }
  19.149 -    }
  19.150 -}
    20.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LineEndingsPanel.form	Wed Jan 02 13:38:30 2013 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,119 +0,0 @@
    20.4 -<?xml version="1.0" encoding="UTF-8" ?>
    20.5 -
    20.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    20.7 -  <NonVisualComponents>
    20.8 -    <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
    20.9 -    </Component>
   20.10 -  </NonVisualComponents>
   20.11 -  <Properties>
   20.12 -    <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   20.13 -      <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
   20.14 -        <TitledBorder title="Line Endings">
   20.15 -          <ResourceString PropertyName="titleX" bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LineEndingsPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   20.16 -        </TitledBorder>
   20.17 -      </Border>
   20.18 -    </Property>
   20.19 -  </Properties>
   20.20 -  <AccessibilityProperties>
   20.21 -    <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   20.22 -      <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LineEndingsPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   20.23 -    </Property>
   20.24 -  </AccessibilityProperties>
   20.25 -  <AuxValues>
   20.26 -    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
   20.27 -    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   20.28 -    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   20.29 -    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   20.30 -    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   20.31 -    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   20.32 -    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   20.33 -    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   20.34 -    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   20.35 -  </AuxValues>
   20.36 -
   20.37 -  <Layout>
   20.38 -    <DimensionLayout dim="0">
   20.39 -      <Group type="103" groupAlignment="0" attributes="0">
   20.40 -          <Group type="102" attributes="0">
   20.41 -              <EmptySpace max="-2" attributes="0"/>
   20.42 -              <Group type="103" groupAlignment="0" attributes="0">
   20.43 -                  <Component id="noChangeButton" alignment="0" min="-2" max="-2" attributes="0"/>
   20.44 -                  <Component id="systemDefaultButton" alignment="0" min="-2" max="-2" attributes="0"/>
   20.45 -                  <Component id="newlineButton" alignment="0" min="-2" max="-2" attributes="0"/>
   20.46 -                  <Component id="forceCrlf" alignment="0" min="-2" max="-2" attributes="0"/>
   20.47 -              </Group>
   20.48 -              <EmptySpace max="32767" attributes="0"/>
   20.49 -          </Group>
   20.50 -      </Group>
   20.51 -    </DimensionLayout>
   20.52 -    <DimensionLayout dim="1">
   20.53 -      <Group type="103" groupAlignment="0" attributes="0">
   20.54 -          <Group type="102" alignment="0" attributes="0">
   20.55 -              <Component id="noChangeButton" min="-2" max="-2" attributes="0"/>
   20.56 -              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   20.57 -              <Component id="systemDefaultButton" min="-2" max="-2" attributes="0"/>
   20.58 -              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   20.59 -              <Component id="newlineButton" min="-2" max="-2" attributes="0"/>
   20.60 -              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   20.61 -              <Component id="forceCrlf" min="-2" max="-2" attributes="0"/>
   20.62 -              <EmptySpace max="32767" attributes="0"/>
   20.63 -          </Group>
   20.64 -      </Group>
   20.65 -    </DimensionLayout>
   20.66 -  </Layout>
   20.67 -  <SubComponents>
   20.68 -    <Component class="javax.swing.JRadioButton" name="noChangeButton">
   20.69 -      <Properties>
   20.70 -        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
   20.71 -          <ComponentRef name="buttonGroup1"/>
   20.72 -        </Property>
   20.73 -        <Property name="selected" type="boolean" value="true"/>
   20.74 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   20.75 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LineEndingsPanel.noChangeButton.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   20.76 -        </Property>
   20.77 -      </Properties>
   20.78 -      <Events>
   20.79 -        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
   20.80 -      </Events>
   20.81 -    </Component>
   20.82 -    <Component class="javax.swing.JRadioButton" name="systemDefaultButton">
   20.83 -      <Properties>
   20.84 -        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
   20.85 -          <ComponentRef name="buttonGroup1"/>
   20.86 -        </Property>
   20.87 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   20.88 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LineEndingsPanel.systemDefaultButton.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   20.89 -        </Property>
   20.90 -      </Properties>
   20.91 -      <Events>
   20.92 -        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
   20.93 -      </Events>
   20.94 -    </Component>
   20.95 -    <Component class="javax.swing.JRadioButton" name="newlineButton">
   20.96 -      <Properties>
   20.97 -        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
   20.98 -          <ComponentRef name="buttonGroup1"/>
   20.99 -        </Property>
  20.100 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  20.101 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LineEndingsPanel.newlineButton.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  20.102 -        </Property>
  20.103 -      </Properties>
  20.104 -      <Events>
  20.105 -        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
  20.106 -      </Events>
  20.107 -    </Component>
  20.108 -    <Component class="javax.swing.JRadioButton" name="forceCrlf">
  20.109 -      <Properties>
  20.110 -        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
  20.111 -          <ComponentRef name="buttonGroup1"/>
  20.112 -        </Property>
  20.113 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  20.114 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="LineEndingsPanel.forceCrlf.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  20.115 -        </Property>
  20.116 -      </Properties>
  20.117 -      <Events>
  20.118 -        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
  20.119 -      </Events>
  20.120 -    </Component>
  20.121 -  </SubComponents>
  20.122 -</Form>
    21.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/LineEndingsPanel.java	Wed Jan 02 13:38:30 2013 +0100
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,171 +0,0 @@
    21.4 -/*
    21.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    21.6 - *
    21.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    21.8 - *
    21.9 - * The contents of this file are subject to the terms of either the GNU
   21.10 - * General Public License Version 2 only ("GPL") or the Common
   21.11 - * Development and Distribution License("CDDL") (collectively, the
   21.12 - * "License"). You may not use this file except in compliance with the
   21.13 - * License. You can obtain a copy of the License at
   21.14 - * http://www.netbeans.org/cddl-gplv2.html
   21.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   21.16 - * specific language governing permissions and limitations under the
   21.17 - * License.  When distributing the software, include this License Header
   21.18 - * Notice in each file and include the License file at
   21.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   21.20 - * particular file as subject to the "Classpath" exception as provided
   21.21 - * by Sun in the GPL Version 2 section of the License file that
   21.22 - * accompanied this code. If applicable, add the following below the
   21.23 - * License Header, with the fields enclosed by brackets [] replaced by
   21.24 - * your own identifying information:
   21.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   21.26 - *
   21.27 - * If you wish your version of this file to be governed by only the CDDL
   21.28 - * or only the GPL Version 2, indicate your decision by adding
   21.29 - * "[Contributor] elects to include this software in this distribution
   21.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   21.31 - * single choice of license, a recipient has the option to distribute
   21.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   21.33 - * to extend the choice of license to its licensees as provided above.
   21.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   21.35 - * Version 2 license, then the option applies only if the new code is
   21.36 - * made subject to such option by the copyright holder.
   21.37 - *
   21.38 - * Contributor(s):
   21.39 - *
   21.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   21.41 - */
   21.42 -
   21.43 -/*
   21.44 - * LineEndingsPanel.java
   21.45 - *
   21.46 - * Created on Mar 20, 2009, 12:33:04 AM
   21.47 - */
   21.48 -package org.netbeans.modules.licensechanger.spi.wizard;
   21.49 -
   21.50 -import javax.swing.JRadioButton;
   21.51 -import org.netbeans.modules.licensechanger.spi.wizard.utils.LineEndingPreference;
   21.52 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   21.53 -import org.openide.util.NbPreferences;
   21.54 -
   21.55 -/**
   21.56 - *
   21.57 - * @author Administrator
   21.58 - */
   21.59 -public class LineEndingsPanel extends javax.swing.JPanel {
   21.60 -
   21.61 -    /**
   21.62 -     * Creates new form LineEndingsPanel
   21.63 -     */
   21.64 -    public LineEndingsPanel() {
   21.65 -        initComponents();
   21.66 -        forceCrlf.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.FORCE_CRLF);
   21.67 -        noChangeButton.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.NO_CHANGE);
   21.68 -        newlineButton.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.FORCE_NEWLINE);
   21.69 -        systemDefaultButton.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.SYSTEM_DEFAULT);
   21.70 -    }
   21.71 -
   21.72 -    /**
   21.73 -     * This method is called from within the constructor to initialize the form.
   21.74 -     * WARNING: Do NOT modify this code. The content of this method is always
   21.75 -     * regenerated by the Form Editor.
   21.76 -     */
   21.77 -    @SuppressWarnings("unchecked")
   21.78 -    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   21.79 -    private void initComponents() {
   21.80 -
   21.81 -        buttonGroup1 = new javax.swing.ButtonGroup();
   21.82 -        noChangeButton = new javax.swing.JRadioButton();
   21.83 -        systemDefaultButton = new javax.swing.JRadioButton();
   21.84 -        newlineButton = new javax.swing.JRadioButton();
   21.85 -        forceCrlf = new javax.swing.JRadioButton();
   21.86 -
   21.87 -        setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.border.title"))); // NOI18N
   21.88 -
   21.89 -        buttonGroup1.add(noChangeButton);
   21.90 -        noChangeButton.setSelected(true);
   21.91 -        noChangeButton.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.noChangeButton.text_1")); // NOI18N
   21.92 -        noChangeButton.addActionListener(new java.awt.event.ActionListener() {
   21.93 -            public void actionPerformed(java.awt.event.ActionEvent evt) {
   21.94 -                lineEndingPreferenceChanged(evt);
   21.95 -            }
   21.96 -        });
   21.97 -
   21.98 -        buttonGroup1.add(systemDefaultButton);
   21.99 -        systemDefaultButton.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.systemDefaultButton.text_1")); // NOI18N
  21.100 -        systemDefaultButton.addActionListener(new java.awt.event.ActionListener() {
  21.101 -            public void actionPerformed(java.awt.event.ActionEvent evt) {
  21.102 -                lineEndingPreferenceChanged(evt);
  21.103 -            }
  21.104 -        });
  21.105 -
  21.106 -        buttonGroup1.add(newlineButton);
  21.107 -        newlineButton.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.newlineButton.text_1")); // NOI18N
  21.108 -        newlineButton.addActionListener(new java.awt.event.ActionListener() {
  21.109 -            public void actionPerformed(java.awt.event.ActionEvent evt) {
  21.110 -                lineEndingPreferenceChanged(evt);
  21.111 -            }
  21.112 -        });
  21.113 -
  21.114 -        buttonGroup1.add(forceCrlf);
  21.115 -        forceCrlf.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.forceCrlf.text_1")); // NOI18N
  21.116 -        forceCrlf.addActionListener(new java.awt.event.ActionListener() {
  21.117 -            public void actionPerformed(java.awt.event.ActionEvent evt) {
  21.118 -                lineEndingPreferenceChanged(evt);
  21.119 -            }
  21.120 -        });
  21.121 -
  21.122 -        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  21.123 -        this.setLayout(layout);
  21.124 -        layout.setHorizontalGroup(
  21.125 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  21.126 -            .addGroup(layout.createSequentialGroup()
  21.127 -                .addContainerGap()
  21.128 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  21.129 -                    .addComponent(noChangeButton)
  21.130 -                    .addComponent(systemDefaultButton)
  21.131 -                    .addComponent(newlineButton)
  21.132 -                    .addComponent(forceCrlf))
  21.133 -                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  21.134 -        );
  21.135 -        layout.setVerticalGroup(
  21.136 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  21.137 -            .addGroup(layout.createSequentialGroup()
  21.138 -                .addComponent(noChangeButton)
  21.139 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  21.140 -                .addComponent(systemDefaultButton)
  21.141 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  21.142 -                .addComponent(newlineButton)
  21.143 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  21.144 -                .addComponent(forceCrlf)
  21.145 -                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  21.146 -        );
  21.147 -
  21.148 -        getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.border.title")); // NOI18N
  21.149 -    }// </editor-fold>//GEN-END:initComponents
  21.150 -
  21.151 -    private void lineEndingPreferenceChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lineEndingPreferenceChanged
  21.152 -        for (JRadioButton b : new JRadioButton[]{forceCrlf, newlineButton, noChangeButton, systemDefaultButton}) {
  21.153 -            if (b.isSelected()) {
  21.154 -                LineEndingPreference x = (LineEndingPreference) b.getClientProperty(WizardProperties.PROP_ENDING);
  21.155 -                if (x != null) {
  21.156 -                    NbPreferences.forModule(LineEndingsPanel.class).put(WizardProperties.PROP_ENDING, x.name());
  21.157 -                }
  21.158 -                break;
  21.159 -            }
  21.160 -        }
  21.161 -    }//GEN-LAST:event_lineEndingPreferenceChanged
  21.162 -
  21.163 -    public static LineEndingPreference getLineEndingPrefs() {
  21.164 -        String ending = NbPreferences.forModule(LineEndingsPanel.class).get(WizardProperties.PROP_ENDING, LineEndingPreference.NO_CHANGE.name());
  21.165 -        return LineEndingPreference.valueOf(ending);
  21.166 -    }
  21.167 -    // Variables declaration - do not modify//GEN-BEGIN:variables
  21.168 -    private javax.swing.ButtonGroup buttonGroup1;
  21.169 -    private javax.swing.JRadioButton forceCrlf;
  21.170 -    private javax.swing.JRadioButton newlineButton;
  21.171 -    private javax.swing.JRadioButton noChangeButton;
  21.172 -    private javax.swing.JRadioButton systemDefaultButton;
  21.173 -    // End of variables declaration//GEN-END:variables
  21.174 -}
    22.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/PreviewPanel.form	Wed Jan 02 13:38:30 2013 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,105 +0,0 @@
    22.4 -<?xml version="1.0" encoding="UTF-8" ?>
    22.5 -
    22.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    22.7 -  <AuxValues>
    22.8 -    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    22.9 -    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   22.10 -    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   22.11 -    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   22.12 -    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   22.13 -    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   22.14 -    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   22.15 -    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   22.16 -    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   22.17 -  </AuxValues>
   22.18 -
   22.19 -  <Layout>
   22.20 -    <DimensionLayout dim="0">
   22.21 -      <Group type="103" groupAlignment="0" attributes="0">
   22.22 -          <Group type="102" attributes="0">
   22.23 -              <EmptySpace max="-2" attributes="0"/>
   22.24 -              <Group type="103" groupAlignment="0" attributes="0">
   22.25 -                  <Component id="jSplitPane1" alignment="0" max="32767" attributes="0"/>
   22.26 -                  <Component id="jLabel3" alignment="0" max="32767" attributes="0"/>
   22.27 -                  <Group type="102" alignment="0" attributes="0">
   22.28 -                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
   22.29 -                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
   22.30 -                  </Group>
   22.31 -              </Group>
   22.32 -              <EmptySpace max="-2" attributes="0"/>
   22.33 -          </Group>
   22.34 -      </Group>
   22.35 -    </DimensionLayout>
   22.36 -    <DimensionLayout dim="1">
   22.37 -      <Group type="103" groupAlignment="0" attributes="0">
   22.38 -          <Group type="102" alignment="1" attributes="0">
   22.39 -              <EmptySpace max="-2" attributes="0"/>
   22.40 -              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
   22.41 -              <EmptySpace max="-2" attributes="0"/>
   22.42 -              <Component id="jSplitPane1" pref="384" max="32767" attributes="0"/>
   22.43 -              <EmptySpace max="-2" attributes="0"/>
   22.44 -              <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
   22.45 -          </Group>
   22.46 -      </Group>
   22.47 -    </DimensionLayout>
   22.48 -  </Layout>
   22.49 -  <SubComponents>
   22.50 -    <Container class="javax.swing.JSplitPane" name="jSplitPane1">
   22.51 -      <Properties>
   22.52 -        <Property name="dividerLocation" type="int" value="200"/>
   22.53 -        <Property name="orientation" type="int" value="0"/>
   22.54 -        <Property name="resizeWeight" type="double" value="0.5"/>
   22.55 -      </Properties>
   22.56 -
   22.57 -      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
   22.58 -      <SubComponents>
   22.59 -        <Container class="javax.swing.JScrollPane" name="fileList">
   22.60 -          <AuxValues>
   22.61 -            <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineView()"/>
   22.62 -          </AuxValues>
   22.63 -          <Constraints>
   22.64 -            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
   22.65 -              <JSplitPaneConstraints position="top"/>
   22.66 -            </Constraint>
   22.67 -          </Constraints>
   22.68 -
   22.69 -          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
   22.70 -        </Container>
   22.71 -        <Container class="javax.swing.JPanel" name="diffPanel">
   22.72 -          <Constraints>
   22.73 -            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
   22.74 -              <JSplitPaneConstraints position="right"/>
   22.75 -            </Constraint>
   22.76 -          </Constraints>
   22.77 -
   22.78 -          <Layout>
   22.79 -            <DimensionLayout dim="0">
   22.80 -              <Group type="103" groupAlignment="0" attributes="0">
   22.81 -                  <EmptySpace min="0" pref="417" max="32767" attributes="0"/>
   22.82 -              </Group>
   22.83 -            </DimensionLayout>
   22.84 -            <DimensionLayout dim="1">
   22.85 -              <Group type="103" groupAlignment="0" attributes="0">
   22.86 -                  <EmptySpace min="0" pref="178" max="32767" attributes="0"/>
   22.87 -              </Group>
   22.88 -            </DimensionLayout>
   22.89 -          </Layout>
   22.90 -        </Container>
   22.91 -      </SubComponents>
   22.92 -    </Container>
   22.93 -    <Component class="javax.swing.JLabel" name="jLabel3">
   22.94 -      <Properties>
   22.95 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   22.96 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="PreviewPanel.jLabel3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   22.97 -        </Property>
   22.98 -      </Properties>
   22.99 -    </Component>
  22.100 -    <Component class="javax.swing.JLabel" name="jLabel1">
  22.101 -      <Properties>
  22.102 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  22.103 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="PreviewPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  22.104 -        </Property>
  22.105 -      </Properties>
  22.106 -    </Component>
  22.107 -  </SubComponents>
  22.108 -</Form>
    23.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/PreviewPanel.java	Wed Jan 02 13:38:30 2013 +0100
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,361 +0,0 @@
    23.4 -/*
    23.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    23.6 - *
    23.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    23.8 - *
    23.9 - * The contents of this file are subject to the terms of either the GNU
   23.10 - * General Public License Version 2 only ("GPL") or the Common
   23.11 - * Development and Distribution License("CDDL") (collectively, the
   23.12 - * "License"). You may not use this file except in compliance with the
   23.13 - * License. You can obtain a copy of the License at
   23.14 - * http://www.netbeans.org/cddl-gplv2.html
   23.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   23.16 - * specific language governing permissions and limitations under the
   23.17 - * License.  When distributing the software, include this License Header
   23.18 - * Notice in each file and include the License file at
   23.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   23.20 - * particular file as subject to the "Classpath" exception as provided
   23.21 - * by Sun in the GPL Version 2 section of the License file that
   23.22 - * accompanied this code. If applicable, add the following below the
   23.23 - * License Header, with the fields enclosed by brackets [] replaced by
   23.24 - * your own identifying information:
   23.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   23.26 - *
   23.27 - * If you wish your version of this file to be governed by only the CDDL
   23.28 - * or only the GPL Version 2, indicate your decision by adding
   23.29 - * "[Contributor] elects to include this software in this distribution
   23.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   23.31 - * single choice of license, a recipient has the option to distribute
   23.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   23.33 - * to extend the choice of license to its licensees as provided above.
   23.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   23.35 - * Version 2 license, then the option applies only if the new code is
   23.36 - * made subject to such option by the copyright holder.
   23.37 - *
   23.38 - * Contributor(s):
   23.39 - *
   23.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   23.41 - */
   23.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   23.43 -
   23.44 -import java.awt.EventQueue;
   23.45 -import java.beans.PropertyChangeEvent;
   23.46 -import java.beans.PropertyChangeListener;
   23.47 -import java.io.ByteArrayOutputStream;
   23.48 -import java.io.IOException;
   23.49 -import java.io.PrintWriter;
   23.50 -import java.io.StringReader;
   23.51 -import java.util.Collections;
   23.52 -import java.util.HashSet;
   23.53 -import java.util.Map;
   23.54 -import java.util.Set;
   23.55 -import org.netbeans.api.diff.Diff;
   23.56 -import org.netbeans.api.diff.DiffView;
   23.57 -import org.netbeans.api.diff.StreamSource;
   23.58 -import org.netbeans.modules.licensechanger.api.FileHandler;
   23.59 -import org.netbeans.modules.licensechanger.spi.wizard.utils.FileChildren;
   23.60 -import org.netbeans.modules.licensechanger.spi.wizard.utils.FileChildren.FileItem;
   23.61 -import org.netbeans.modules.licensechanger.spi.wizard.utils.FileLoader;
   23.62 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   23.63 -import org.netbeans.swing.outline.DefaultOutlineModel;
   23.64 -import org.openide.explorer.ExplorerManager;
   23.65 -import org.openide.explorer.view.CheckableNode;
   23.66 -import org.openide.explorer.view.OutlineView;
   23.67 -import org.openide.filesystems.FileObject;
   23.68 -import org.openide.nodes.AbstractNode;
   23.69 -import org.openide.nodes.Children;
   23.70 -import org.openide.nodes.Node;
   23.71 -import org.openide.util.Exceptions;
   23.72 -import org.openide.util.RequestProcessor;
   23.73 -import org.openide.util.RequestProcessor.Task;
   23.74 -
   23.75 -/**
   23.76 - *
   23.77 - * @author Tim Boudreau
   23.78 - * @author Nils Hoffmann (Refactoring, Diff API inclusion)
   23.79 - */
   23.80 -public class PreviewPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener {
   23.81 -
   23.82 -    private final ExplorerManager mgr = new ExplorerManager();
   23.83 -    private ItemLoader loader;
   23.84 -    private String licenseText;
   23.85 -    private Diff diff;
   23.86 -    private Map<String, Object> properties;
   23.87 -
   23.88 -    public PreviewPanel() {
   23.89 -        diff = Diff.getDefault();
   23.90 -        initComponents();
   23.91 -        mgr.addPropertyChangeListener(this);
   23.92 -        jLabel3.setText("  ");
   23.93 -        updateView();
   23.94 -    }
   23.95 -
   23.96 -    private void updateView() {
   23.97 -        OutlineView ov = (OutlineView) fileList;
   23.98 -        ov.getOutline().setRootVisible(false);
   23.99 -        ov.setPopupAllowed(false);
  23.100 -        ov.setTreeSortable(false);
  23.101 -        ov.getOutline().setShowGrid(false);
  23.102 -        String headerName = org.openide.util.NbBundle.getMessage(PreviewPanel.class, "PreviewPanel.nodesLabel.text"); // NOI18N
  23.103 -        ((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(headerName);
  23.104 -        setName("Preview Changes");
  23.105 -    }
  23.106 -
  23.107 -    public void setFolders(Set<FileObject> folders, Set<FileHandler> fileHandler) {
  23.108 -        Children kids = Children.create(new FileChildren(folders, fileHandler), true);
  23.109 -        mgr.setRootContext(new AbstractNode(kids));
  23.110 -        updateView();
  23.111 -        updateItems();
  23.112 -    }
  23.113 -
  23.114 -    public Set<FileItem> getSelectedItems() {
  23.115 -        Set<FileItem> s = new HashSet<FileItem>();
  23.116 -        for (Node n : mgr.getRootContext().getChildren().getNodes(true)) {
  23.117 -            CheckableNode cn = n.getLookup().lookup(CheckableNode.class);
  23.118 -            if (cn != null && cn.isSelected()) {
  23.119 -                s.addAll(n.getLookup().lookupAll(FileItem.class));
  23.120 -            }
  23.121 -        }
  23.122 -        return s;
  23.123 -    }
  23.124 -
  23.125 -    private void updateItems() {
  23.126 -        Set<FileItem> s = getSelectedItems();
  23.127 -        firePropertyChange(WizardProperties.KEY_ITEMS, null, s);
  23.128 -    }
  23.129 -
  23.130 -    public void setLicenseText(String licenseText) {
  23.131 -        this.licenseText = licenseText;
  23.132 -        firePropertyChange(WizardProperties.KEY_LICENSE_TEXT, null, this.licenseText);
  23.133 -    }
  23.134 -
  23.135 -    void setProperties(Map<String, Object> properties) {
  23.136 -        this.properties = properties;
  23.137 -    }
  23.138 -
  23.139 -    /**
  23.140 -     * This method is called from within the constructor to initialize the form.
  23.141 -     * WARNING: Do NOT modify this code. The content of this method is always
  23.142 -     * regenerated by the Form Editor.
  23.143 -     */
  23.144 -    @SuppressWarnings("unchecked")
  23.145 -    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  23.146 -    private void initComponents() {
  23.147 -
  23.148 -        jSplitPane1 = new javax.swing.JSplitPane();
  23.149 -        fileList = new OutlineView();
  23.150 -        diffPanel = new javax.swing.JPanel();
  23.151 -        jLabel3 = new javax.swing.JLabel();
  23.152 -        jLabel1 = new javax.swing.JLabel();
  23.153 -
  23.154 -        jSplitPane1.setDividerLocation(200);
  23.155 -        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
  23.156 -        jSplitPane1.setResizeWeight(0.5);
  23.157 -        jSplitPane1.setTopComponent(fileList);
  23.158 -
  23.159 -        javax.swing.GroupLayout diffPanelLayout = new javax.swing.GroupLayout(diffPanel);
  23.160 -        diffPanel.setLayout(diffPanelLayout);
  23.161 -        diffPanelLayout.setHorizontalGroup(
  23.162 -            diffPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  23.163 -            .addGap(0, 417, Short.MAX_VALUE)
  23.164 -        );
  23.165 -        diffPanelLayout.setVerticalGroup(
  23.166 -            diffPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  23.167 -            .addGap(0, 190, Short.MAX_VALUE)
  23.168 -        );
  23.169 -
  23.170 -        jSplitPane1.setRightComponent(diffPanel);
  23.171 -
  23.172 -        jLabel3.setText(org.openide.util.NbBundle.getMessage(PreviewPanel.class, "PreviewPanel.jLabel3.text")); // NOI18N
  23.173 -
  23.174 -        jLabel1.setText(org.openide.util.NbBundle.getMessage(PreviewPanel.class, "PreviewPanel.jLabel1.text")); // NOI18N
  23.175 -
  23.176 -        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  23.177 -        this.setLayout(layout);
  23.178 -        layout.setHorizontalGroup(
  23.179 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  23.180 -            .addGroup(layout.createSequentialGroup()
  23.181 -                .addContainerGap()
  23.182 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  23.183 -                    .addComponent(jSplitPane1)
  23.184 -                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  23.185 -                    .addGroup(layout.createSequentialGroup()
  23.186 -                        .addComponent(jLabel1)
  23.187 -                        .addGap(0, 0, Short.MAX_VALUE)))
  23.188 -                .addContainerGap())
  23.189 -        );
  23.190 -        layout.setVerticalGroup(
  23.191 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  23.192 -            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  23.193 -                .addContainerGap()
  23.194 -                .addComponent(jLabel1)
  23.195 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  23.196 -                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
  23.197 -                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  23.198 -                .addComponent(jLabel3))
  23.199 -        );
  23.200 -    }// </editor-fold>//GEN-END:initComponents
  23.201 -    // Variables declaration - do not modify//GEN-BEGIN:variables
  23.202 -    private javax.swing.JPanel diffPanel;
  23.203 -    private javax.swing.JScrollPane fileList;
  23.204 -    private javax.swing.JLabel jLabel1;
  23.205 -    private javax.swing.JLabel jLabel3;
  23.206 -    private javax.swing.JSplitPane jSplitPane1;
  23.207 -    // End of variables declaration//GEN-END:variables
  23.208 -
  23.209 -    @Override
  23.210 -    public ExplorerManager getExplorerManager() {
  23.211 -        return mgr;
  23.212 -    }
  23.213 -
  23.214 -    @Override
  23.215 -    public void propertyChange(PropertyChangeEvent evt) {
  23.216 -        if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
  23.217 -            Node[] n = mgr.getSelectedNodes();
  23.218 -            if (n.length > 0) {
  23.219 -                FileItem item = n[0].getLookup().lookup(FileItem.class);
  23.220 -                if (item != null) {
  23.221 -                    setFileItem(item);
  23.222 -                    // XXX use FileUtil.getFileDisplayName rather than FileObject.getPath
  23.223 -
  23.224 -                    jLabel3.setText(item.getFile().getPath());
  23.225 -                } else {
  23.226 -//                    before.setText("");
  23.227 -                    jLabel3.setText("  ");
  23.228 -                }
  23.229 -            } else {
  23.230 -//                before.setText("");
  23.231 -//                after.setText("");
  23.232 -                jLabel3.setText("  ");
  23.233 -            }
  23.234 -        }
  23.235 -    }
  23.236 -
  23.237 -    private void setFileItem(FileItem item) {
  23.238 -        if (item.getFile().isValid()) {
  23.239 -            // XXX should use Diff API instead (like refactoring preview)
  23.240 -//            before.setContentType("text/plain");
  23.241 -//            after.setContentType("text/plain");
  23.242 -//            before.setText("Loading " + item.getFile().getPath());
  23.243 -//            after.setText("Loading " + item.getFile().getPath());
  23.244 -            ItemLoader ldr = new ItemLoader(item);
  23.245 -            setLoader(ldr);
  23.246 -        }
  23.247 -    }
  23.248 -
  23.249 -    private synchronized void setLoader(ItemLoader ldr) {
  23.250 -        if (loader != null) {
  23.251 -            loader.cancel();
  23.252 -        }
  23.253 -        this.loader = ldr;
  23.254 -        loader.start();
  23.255 -    }
  23.256 -
  23.257 -    private class ItemLoader implements Runnable {
  23.258 -
  23.259 -        private final Task task;
  23.260 -        private volatile boolean cancelled;
  23.261 -        private final FileItem item;
  23.262 -        private volatile String beforeText = "Cancelled";
  23.263 -        private volatile String afterText = "Cancelled";
  23.264 -
  23.265 -        public ItemLoader(FileItem item) {
  23.266 -            this.item = item;
  23.267 -            task = RequestProcessor.getDefault().create(this);
  23.268 -        }
  23.269 -
  23.270 -        void start() {
  23.271 -            task.schedule(200);
  23.272 -        }
  23.273 -
  23.274 -        public void cancel() {
  23.275 -            cancelled = true;
  23.276 -            task.cancel();
  23.277 -        }
  23.278 -
  23.279 -        private void loadFile() throws IOException {
  23.280 -            beforeText = FileLoader.loadFile(item.getFile());
  23.281 -        }
  23.282 -
  23.283 -        @Override
  23.284 -        public void run() {
  23.285 -            if (cancelled) {
  23.286 -                return;
  23.287 -            }
  23.288 -            if (!EventQueue.isDispatchThread()) {
  23.289 -                try {
  23.290 -                    if (cancelled) {
  23.291 -                        return;
  23.292 -                    }
  23.293 -                    if (!item.getFile().isValid()) {
  23.294 -                        beforeText = "Invalid file";
  23.295 -                        afterText = "Invalid file";
  23.296 -                        return;
  23.297 -                    }
  23.298 -                    if (!item.getFile().canRead()) {
  23.299 -                        beforeText = "Cannot read " + item.getFile().getPath();
  23.300 -                        afterText = "Cannot read " + item.getFile().getPath();
  23.301 -                        return;
  23.302 -                    }
  23.303 -                    if (item.getFile().getSize() >= Integer.MAX_VALUE) {
  23.304 -                        beforeText = "File too long: " + item.getFile().getPath();
  23.305 -                        afterText = "File too long: " + item.getFile().getPath();
  23.306 -                        return;
  23.307 -                    }
  23.308 -                    if (item.getFile().getSize() == 0) {
  23.309 -                        beforeText = "Empty file";
  23.310 -                        afterText = "Empty file";
  23.311 -                        return;
  23.312 -                    }
  23.313 -                    if (cancelled) {
  23.314 -                        return;
  23.315 -                    }
  23.316 -                    try {
  23.317 -                        loadFile();
  23.318 -                    } catch (IOException ex) {
  23.319 -                        ByteArrayOutputStream out = new ByteArrayOutputStream();
  23.320 -                        PrintWriter w = new PrintWriter(out);
  23.321 -                        ex.printStackTrace(w);
  23.322 -                        beforeText = new String(out.toByteArray());
  23.323 -                        afterText = "Error";
  23.324 -                        return;
  23.325 -                    }
  23.326 -                    if (cancelled) {
  23.327 -                        return;
  23.328 -                    }
  23.329 -                    if (beforeText.length() == 0) {
  23.330 -                        afterText = "";
  23.331 -                        return;
  23.332 -                    }
  23.333 -                    afterText = transform(beforeText, item.getHandler());
  23.334 -                } finally {
  23.335 -                    if (!cancelled) {
  23.336 -                        EventQueue.invokeLater(this);
  23.337 -                    }
  23.338 -                }
  23.339 -            } else {
  23.340 -                String contentType = item.getFile().getMIMEType();
  23.341 -                DiffView view;
  23.342 -                try {
  23.343 -                    view = diff.createDiff(StreamSource.createSource("Before", "Before", contentType, new StringReader(beforeText)),
  23.344 -                            StreamSource.createSource("After", "After", contentType, new StringReader(afterText)));
  23.345 -                    int dloc = jSplitPane1.getDividerLocation();
  23.346 -                    jSplitPane1.setBottomComponent(view.getComponent());
  23.347 -                    jSplitPane1.setDividerLocation(dloc);
  23.348 -                } catch (IOException ex) {
  23.349 -                    Exceptions.printStackTrace(ex);
  23.350 -                    int dloc = jSplitPane1.getDividerLocation();
  23.351 -                    jSplitPane1.setBottomComponent(diffPanel);
  23.352 -                    jSplitPane1.setDividerLocation(dloc);
  23.353 -                }
  23.354 -
  23.355 -            }
  23.356 -        }
  23.357 -
  23.358 -        private String transform(String beforeText, FileHandler handler) {
  23.359 -            return handler.transform(beforeText, licenseText,
  23.360 -                    properties == null ? Collections.<String, Object>emptyMap()
  23.361 -                    : properties);
  23.362 -        }
  23.363 -    }
  23.364 -}
    24.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/PreviewWizardPanel.java	Wed Jan 02 13:38:30 2013 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,156 +0,0 @@
    24.4 -/*
    24.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    24.6 - *
    24.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    24.8 - *
    24.9 - * The contents of this file are subject to the terms of either the GNU
   24.10 - * General Public License Version 2 only ("GPL") or the Common
   24.11 - * Development and Distribution License("CDDL") (collectively, the
   24.12 - * "License"). You may not use this file except in compliance with the
   24.13 - * License. You can obtain a copy of the License at
   24.14 - * http://www.netbeans.org/cddl-gplv2.html
   24.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   24.16 - * specific language governing permissions and limitations under the
   24.17 - * License.  When distributing the software, include this License Header
   24.18 - * Notice in each file and include the License file at
   24.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   24.20 - * particular file as subject to the "Classpath" exception as provided
   24.21 - * by Sun in the GPL Version 2 section of the License file that
   24.22 - * accompanied this code. If applicable, add the following below the
   24.23 - * License Header, with the fields enclosed by brackets [] replaced by
   24.24 - * your own identifying information:
   24.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   24.26 - *
   24.27 - * If you wish your version of this file to be governed by only the CDDL
   24.28 - * or only the GPL Version 2, indicate your decision by adding
   24.29 - * "[Contributor] elects to include this software in this distribution
   24.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   24.31 - * single choice of license, a recipient has the option to distribute
   24.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   24.33 - * to extend the choice of license to its licensees as provided above.
   24.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   24.35 - * Version 2 license, then the option applies only if the new code is
   24.36 - * made subject to such option by the copyright holder.
   24.37 - *
   24.38 - * Contributor(s):
   24.39 - *
   24.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   24.41 - */
   24.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   24.43 -
   24.44 -import java.beans.PropertyChangeEvent;
   24.45 -import java.beans.PropertyChangeListener;
   24.46 -import java.util.Set;
   24.47 -import javax.swing.event.ChangeListener;
   24.48 -import org.netbeans.modules.licensechanger.api.FileHandler;
   24.49 -import org.netbeans.modules.licensechanger.spi.wizard.utils.FileChildren.FileItem;
   24.50 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   24.51 -import org.openide.WizardDescriptor;
   24.52 -import org.openide.WizardValidationException;
   24.53 -import org.openide.filesystems.FileObject;
   24.54 -import org.openide.util.ChangeSupport;
   24.55 -import org.openide.util.HelpCtx;
   24.56 -
   24.57 -/**
   24.58 - *
   24.59 - * @author Nils Hoffmann
   24.60 - */
   24.61 -public class PreviewWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   24.62 -
   24.63 -    /**
   24.64 -     * The visual component that displays this panel. If you need to access the
   24.65 -     * component from this class, just use getComponent().
   24.66 -     */
   24.67 -    private PreviewPanel component;
   24.68 -    private WizardDescriptor wiz;
   24.69 -    private boolean valid = true;
   24.70 -    private ChangeSupport cs = new ChangeSupport(this);
   24.71 -
   24.72 -    // Get the visual component for the panel. In this template, the component
   24.73 -    // is kept separate. This can be more efficient: if the wizard is created
   24.74 -    // but never displayed, or not all panels are displayed, it is better to
   24.75 -    // create only those which really need to be visible.
   24.76 -    @Override
   24.77 -    public PreviewPanel getComponent() {
   24.78 -        if (component == null) {
   24.79 -            component = new PreviewPanel();
   24.80 -            component.addPropertyChangeListener(this);
   24.81 -        }
   24.82 -        return component;
   24.83 -    }
   24.84 -
   24.85 -    @Override
   24.86 -    public HelpCtx getHelp() {
   24.87 -        // Show no Help button for this panel:
   24.88 -        return HelpCtx.DEFAULT_HELP;
   24.89 -        // If you have context help:
   24.90 -        // return new HelpCtx("help.key.here");
   24.91 -    }
   24.92 -
   24.93 -    @Override
   24.94 -    public boolean isValid() {
   24.95 -        return valid;
   24.96 -    }
   24.97 -
   24.98 -    @Override
   24.99 -    public void addChangeListener(ChangeListener l) {
  24.100 -        cs.addChangeListener(l);
  24.101 -    }
  24.102 -
  24.103 -    @Override
  24.104 -    public void removeChangeListener(ChangeListener l) {
  24.105 -        cs.removeChangeListener(l);
  24.106 -    }
  24.107 -
  24.108 -    @Override
  24.109 -    public void propertyChange(PropertyChangeEvent pce) {
  24.110 -        cs.fireChange();
  24.111 -        try {
  24.112 -            validate();
  24.113 -        } catch (WizardValidationException ex) {
  24.114 -            if (wiz != null) {
  24.115 -                wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, ex.getMessage());
  24.116 -            }
  24.117 -        }
  24.118 -    }
  24.119 -
  24.120 -    @Override
  24.121 -    public void readSettings(WizardDescriptor wiz) {
  24.122 -        this.wiz = wiz;
  24.123 -        @SuppressWarnings("unchecked")
  24.124 -        String license = (String) wiz.getProperty(WizardProperties.KEY_LICENSE_TEXT);
  24.125 -        if (license != null) {
  24.126 -            getComponent().setLicenseText(license);
  24.127 -        }
  24.128 -        getComponent().setProperties(wiz.getProperties());
  24.129 -        @SuppressWarnings("unchecked")
  24.130 -        Set<FileHandler> fileHandler = (Set<FileHandler>) wiz.getProperty(WizardProperties.KEY_FILE_HANDLERS);
  24.131 -        @SuppressWarnings("unchecked")
  24.132 -        Set<FileObject> folders = (Set<FileObject>) wiz.getProperty(WizardProperties.KEY_FOLDERS);
  24.133 -        if (fileHandler != null && folders != null) {
  24.134 -            getComponent().setFolders(folders, fileHandler);
  24.135 -        }
  24.136 -        wiz.putProperty(WizardProperties.KEY_ITEMS, null);
  24.137 -    }
  24.138 -
  24.139 -    @Override
  24.140 -    public void storeSettings(WizardDescriptor wiz) {
  24.141 -        wiz.putProperty(WizardProperties.KEY_ITEMS, getComponent().getSelectedItems());
  24.142 -    }
  24.143 -
  24.144 -    @Override
  24.145 -    public void validate() throws WizardValidationException {
  24.146 -        valid = true;
  24.147 -        Set<FileItem> keyItems = getComponent().getSelectedItems();
  24.148 -
  24.149 -        if (keyItems == null || keyItems.isEmpty()) {
  24.150 -            valid = false;
  24.151 -            throw new WizardValidationException(component, "Please select at least one file!", null);
  24.152 -        }
  24.153 -        if (wiz != null) {
  24.154 -            wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
  24.155 -            wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, null);
  24.156 -            wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
  24.157 -        }
  24.158 -    }
  24.159 -}
    25.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/SelectFoldersPanel.form	Wed Jan 02 13:38:30 2013 +0100
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,66 +0,0 @@
    25.4 -<?xml version="1.0" encoding="UTF-8" ?>
    25.5 -
    25.6 -<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    25.7 -  <AuxValues>
    25.8 -    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    25.9 -    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   25.10 -    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   25.11 -    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   25.12 -    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   25.13 -    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   25.14 -    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   25.15 -    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   25.16 -    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   25.17 -  </AuxValues>
   25.18 -
   25.19 -  <Layout>
   25.20 -    <DimensionLayout dim="0">
   25.21 -      <Group type="103" groupAlignment="0" attributes="0">
   25.22 -          <Group type="102" alignment="0" attributes="0">
   25.23 -              <EmptySpace max="-2" attributes="0"/>
   25.24 -              <Group type="103" groupAlignment="0" attributes="0">
   25.25 -                  <Component id="jScrollPane1" alignment="0" pref="541" max="32767" attributes="0"/>
   25.26 -                  <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
   25.27 -              </Group>
   25.28 -              <EmptySpace max="-2" attributes="0"/>
   25.29 -          </Group>
   25.30 -      </Group>
   25.31 -    </DimensionLayout>
   25.32 -    <DimensionLayout dim="1">
   25.33 -      <Group type="103" groupAlignment="0" attributes="0">
   25.34 -          <Group type="102" alignment="0" attributes="0">
   25.35 -              <EmptySpace max="-2" attributes="0"/>
   25.36 -              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
   25.37 -              <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
   25.38 -              <Component id="jScrollPane1" pref="364" max="32767" attributes="0"/>
   25.39 -              <EmptySpace max="-2" attributes="0"/>
   25.40 -          </Group>
   25.41 -      </Group>
   25.42 -    </DimensionLayout>
   25.43 -  </Layout>
   25.44 -  <SubComponents>
   25.45 -    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
   25.46 -      <Properties>
   25.47 -        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   25.48 -          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
   25.49 -            <LineBorder>
   25.50 -              <Color PropertyName="color" blue="99" green="a8" id="controlShadow" palette="3" red="ac" type="palette"/>
   25.51 -            </LineBorder>
   25.52 -          </Border>
   25.53 -        </Property>
   25.54 -      </Properties>
   25.55 -      <AuxValues>
   25.56 -        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineView()"/>
   25.57 -      </AuxValues>
   25.58 -
   25.59 -      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
   25.60 -    </Container>
   25.61 -    <Component class="javax.swing.JLabel" name="jLabel1">
   25.62 -      <Properties>
   25.63 -        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   25.64 -          <ResourceString bundle="org/netbeans/modules/licensechanger/spi/wizard/Bundle.properties" key="SelectFoldersPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   25.65 -        </Property>
   25.66 -      </Properties>
   25.67 -    </Component>
   25.68 -  </SubComponents>
   25.69 -</Form>
    26.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/SelectFoldersPanel.java	Wed Jan 02 13:38:30 2013 +0100
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,168 +0,0 @@
    26.4 -/*
    26.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    26.6 - *
    26.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    26.8 - *
    26.9 - * The contents of this file are subject to the terms of either the GNU
   26.10 - * General Public License Version 2 only ("GPL") or the Common
   26.11 - * Development and Distribution License("CDDL") (collectively, the
   26.12 - * "License"). You may not use this file except in compliance with the
   26.13 - * License. You can obtain a copy of the License at
   26.14 - * http://www.netbeans.org/cddl-gplv2.html
   26.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   26.16 - * specific language governing permissions and limitations under the
   26.17 - * License.  When distributing the software, include this License Header
   26.18 - * Notice in each file and include the License file at
   26.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   26.20 - * particular file as subject to the "Classpath" exception as provided
   26.21 - * by Sun in the GPL Version 2 section of the License file that
   26.22 - * accompanied this code. If applicable, add the following below the
   26.23 - * License Header, with the fields enclosed by brackets [] replaced by
   26.24 - * your own identifying information:
   26.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   26.26 - *
   26.27 - * If you wish your version of this file to be governed by only the CDDL
   26.28 - * or only the GPL Version 2, indicate your decision by adding
   26.29 - * "[Contributor] elects to include this software in this distribution
   26.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   26.31 - * single choice of license, a recipient has the option to distribute
   26.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   26.33 - * to extend the choice of license to its licensees as provided above.
   26.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   26.35 - * Version 2 license, then the option applies only if the new code is
   26.36 - * made subject to such option by the copyright holder.
   26.37 - *
   26.38 - * Contributor(s):
   26.39 - *
   26.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   26.41 - */
   26.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   26.43 -
   26.44 -import java.util.Comparator;
   26.45 -import java.util.Set;
   26.46 -import java.util.TreeSet;
   26.47 -import org.netbeans.modules.licensechanger.spi.wizard.utils.FolderChildren;
   26.48 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   26.49 -import org.netbeans.swing.outline.DefaultOutlineModel;
   26.50 -import org.openide.explorer.ExplorerManager;
   26.51 -import org.openide.explorer.view.CheckableNode;
   26.52 -import org.openide.explorer.view.OutlineView;
   26.53 -import org.openide.filesystems.FileObject;
   26.54 -import org.openide.nodes.AbstractNode;
   26.55 -import org.openide.nodes.Children;
   26.56 -import org.openide.nodes.Node;
   26.57 -
   26.58 -/**
   26.59 - *
   26.60 - * @author Tim Boudreau
   26.61 - * @author Nils Hoffmann (Refactoring)
   26.62 - */
   26.63 -public class SelectFoldersPanel extends javax.swing.JPanel implements ExplorerManager.Provider {
   26.64 -    
   26.65 -    private final ExplorerManager mgr = new ExplorerManager();
   26.66 -    
   26.67 -    public SelectFoldersPanel() {
   26.68 -        initComponents();
   26.69 -        updateView();
   26.70 -        setName("Select Folders");
   26.71 -    }
   26.72 -    
   26.73 -    private void updateFolders() {
   26.74 -        Set<FileObject> folders = getSelectedFolders();
   26.75 -//        System.out.println("Selected folders: " + folders);
   26.76 -        firePropertyChange(WizardProperties.KEY_FOLDERS, null, folders);
   26.77 -    }
   26.78 -    
   26.79 -    private void enableUI() {
   26.80 -        jLabel1.setEnabled(true);
   26.81 -        updateView();
   26.82 -    }
   26.83 -
   26.84 -    /**
   26.85 -     * This method is called from within the constructor to initialize the form.
   26.86 -     * WARNING: Do NOT modify this code. The content of this method is always
   26.87 -     * regenerated by the Form Editor.
   26.88 -     */
   26.89 -    @SuppressWarnings("unchecked")
   26.90 -    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   26.91 -    private void initComponents() {
   26.92 -
   26.93 -        jScrollPane1 = new OutlineView();
   26.94 -        jLabel1 = new javax.swing.JLabel();
   26.95 -
   26.96 -        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("controlShadow")));
   26.97 -
   26.98 -        jLabel1.setText(org.openide.util.NbBundle.getMessage(SelectFoldersPanel.class, "SelectFoldersPanel.jLabel1.text")); // NOI18N
   26.99 -
  26.100 -        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  26.101 -        this.setLayout(layout);
  26.102 -        layout.setHorizontalGroup(
  26.103 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  26.104 -            .addGroup(layout.createSequentialGroup()
  26.105 -                .addContainerGap()
  26.106 -                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  26.107 -                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
  26.108 -                    .addComponent(jLabel1))
  26.109 -                .addContainerGap())
  26.110 -        );
  26.111 -        layout.setVerticalGroup(
  26.112 -            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  26.113 -            .addGroup(layout.createSequentialGroup()
  26.114 -                .addContainerGap()
  26.115 -                .addComponent(jLabel1)
  26.116 -                .addGap(9, 9, 9)
  26.117 -                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)
  26.118 -                .addContainerGap())
  26.119 -        );
  26.120 -    }// </editor-fold>//GEN-END:initComponents
  26.121 -    // Variables declaration - do not modify//GEN-BEGIN:variables
  26.122 -    private javax.swing.JLabel jLabel1;
  26.123 -    private javax.swing.JScrollPane jScrollPane1;
  26.124 -    // End of variables declaration//GEN-END:variables
  26.125 -
  26.126 -    @Override
  26.127 -    public ExplorerManager getExplorerManager() {
  26.128 -        return mgr;
  26.129 -    }
  26.130 -    
  26.131 -    public void setRootFiles(Set<FileObject> roots) {
  26.132 -        AbstractNode root = new AbstractNode(Children.create(new FolderChildren(roots.toArray(new FileObject[roots.size()])) {
  26.133 -            @Override
  26.134 -            public void onAllNodesCreated() {
  26.135 -                enableUI();
  26.136 -                updateFolders();
  26.137 -            }
  26.138 -        }, true));
  26.139 -        mgr.setRootContext(root);
  26.140 -        firePropertyChange("rootFiles", null, roots);
  26.141 -    }
  26.142 -    
  26.143 -    public Set<FileObject> getSelectedFolders() {
  26.144 -        Set<FileObject> folders = new TreeSet<FileObject>(new Comparator<FileObject>() {
  26.145 -            @Override
  26.146 -            public int compare(FileObject t, FileObject t1) {
  26.147 -                return t.getPath().compareTo(t1.getPath());
  26.148 -            }
  26.149 -        });
  26.150 -        for (Node n : mgr.getRootContext().getChildren().getNodes(true)) {
  26.151 -            CheckableNode cn = n.getLookup().lookup(CheckableNode.class);
  26.152 -            if (cn != null && cn.isSelected()) {
  26.153 -                FileObject f = n.getLookup().lookup(FileObject.class);
  26.154 -                if (f != null) {
  26.155 -                    folders.add(f);
  26.156 -                }
  26.157 -            }
  26.158 -        }
  26.159 -        return folders;
  26.160 -    }
  26.161 -    
  26.162 -    private void updateView() {
  26.163 -        OutlineView ov = (OutlineView) jScrollPane1;
  26.164 -        ov.getOutline().setRootVisible(false);
  26.165 -        ov.setPopupAllowed(false);
  26.166 -        ov.setTreeSortable(false);
  26.167 -        String headerName = org.openide.util.NbBundle.getMessage(SelectFoldersPanel.class, "SelectFoldersPanel.nodesLabel.text"); // NOI18N
  26.168 -        ((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(headerName);
  26.169 -        setName("Select Folders");
  26.170 -    }
  26.171 -}
    27.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/SelectFoldersWizardPanel.java	Wed Jan 02 13:38:30 2013 +0100
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,152 +0,0 @@
    27.4 -/*
    27.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    27.6 - *
    27.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    27.8 - *
    27.9 - * The contents of this file are subject to the terms of either the GNU
   27.10 - * General Public License Version 2 only ("GPL") or the Common
   27.11 - * Development and Distribution License("CDDL") (collectively, the
   27.12 - * "License"). You may not use this file except in compliance with the
   27.13 - * License. You can obtain a copy of the License at
   27.14 - * http://www.netbeans.org/cddl-gplv2.html
   27.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   27.16 - * specific language governing permissions and limitations under the
   27.17 - * License.  When distributing the software, include this License Header
   27.18 - * Notice in each file and include the License file at
   27.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   27.20 - * particular file as subject to the "Classpath" exception as provided
   27.21 - * by Sun in the GPL Version 2 section of the License file that
   27.22 - * accompanied this code. If applicable, add the following below the
   27.23 - * License Header, with the fields enclosed by brackets [] replaced by
   27.24 - * your own identifying information:
   27.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   27.26 - *
   27.27 - * If you wish your version of this file to be governed by only the CDDL
   27.28 - * or only the GPL Version 2, indicate your decision by adding
   27.29 - * "[Contributor] elects to include this software in this distribution
   27.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   27.31 - * single choice of license, a recipient has the option to distribute
   27.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   27.33 - * to extend the choice of license to its licensees as provided above.
   27.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   27.35 - * Version 2 license, then the option applies only if the new code is
   27.36 - * made subject to such option by the copyright holder.
   27.37 - *
   27.38 - * Contributor(s):
   27.39 - *
   27.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   27.41 - */
   27.42 -package org.netbeans.modules.licensechanger.spi.wizard;
   27.43 -
   27.44 -import java.beans.PropertyChangeEvent;
   27.45 -import java.beans.PropertyChangeListener;
   27.46 -import java.util.Set;
   27.47 -import javax.swing.event.ChangeListener;
   27.48 -import org.netbeans.modules.licensechanger.spi.wizard.utils.WizardProperties;
   27.49 -import org.openide.WizardDescriptor;
   27.50 -import org.openide.WizardValidationException;
   27.51 -import org.openide.filesystems.FileObject;
   27.52 -import org.openide.util.ChangeSupport;
   27.53 -import org.openide.util.HelpCtx;
   27.54 -
   27.55 -/**
   27.56 - *
   27.57 - * @author Nils Hoffmann
   27.58 - */
   27.59 -public class SelectFoldersWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   27.60 -
   27.61 -    /**
   27.62 -     * The visual component that displays this panel. If you need to access the
   27.63 -     * component from this class, just use getComponent().
   27.64 -     */
   27.65 -    private SelectFoldersPanel component;
   27.66 -    private WizardDescriptor wiz;
   27.67 -    private boolean valid = false;
   27.68 -    private ChangeSupport cs = new ChangeSupport(this);
   27.69 -
   27.70 -    // Get the visual component for the panel. In this template, the component
   27.71 -    // is kept separate. This can be more efficient: if the wizard is created
   27.72 -    // but never displayed, or not all panels are displayed, it is better to
   27.73 -    // create only those which really need to be visible.
   27.74 -    @Override
   27.75 -    public SelectFoldersPanel getComponent() {
   27.76 -        if (component == null) {
   27.77 -            component = new SelectFoldersPanel();
   27.78 -            component.addPropertyChangeListener(this);
   27.79 -        }
   27.80 -        return component;
   27.81 -    }
   27.82 -
   27.83 -    @Override
   27.84 -    public HelpCtx getHelp() {
   27.85 -        // Show no Help button for this panel:
   27.86 -        return HelpCtx.DEFAULT_HELP;
   27.87 -        // If you have context help:
   27.88 -        // return new HelpCtx("help.key.here");
   27.89 -    }
   27.90 -
   27.91 -    @Override
   27.92 -    public boolean isValid() {
   27.93 -        return valid;
   27.94 -    }
   27.95 -
   27.96 -    @Override
   27.97 -    public void addChangeListener(ChangeListener l) {
   27.98 -        cs.addChangeListener(l);
   27.99 -    }
  27.100 -
  27.101 -    @Override
  27.102 -    public void removeChangeListener(ChangeListener l) {
  27.103 -        cs.removeChangeListener(l);
  27.104 -    }
  27.105 -
  27.106 -    @Override
  27.107 -    public void propertyChange(PropertyChangeEvent pce) {
  27.108 -        cs.fireChange();
  27.109 -        try {
  27.110 -            validate();
  27.111 -        } catch (WizardValidationException ex) {
  27.112 -            if (wiz != null) {
  27.113 -                wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, ex.getMessage());
  27.114 -            }
  27.115 -        }
  27.116 -    }
  27.117 -
  27.118 -    @Override
  27.119 -    public void readSettings(WizardDescriptor wiz) {
  27.120 -        this.wiz = wiz;
  27.121 -        @SuppressWarnings("unchecked")
  27.122 -        Set<FileObject> folders = (Set<FileObject>) wiz.getProperty(WizardProperties.KEY_FOLDERS);
  27.123 -        if (folders == null || folders.isEmpty()) {
  27.124 -            Object obj = wiz.getProperty(WizardProperties.KEY_ROOT_FILES);
  27.125 -            if (obj != null) {
  27.126 -                @SuppressWarnings("unchecked")
  27.127 -                Set<FileObject> sobj = (Set<FileObject>) obj;
  27.128 -                getComponent().setRootFiles(sobj);
  27.129 -            }
  27.130 -        } else {
  27.131 -            getComponent().setRootFiles(folders);
  27.132 -        }
  27.133 -    }
  27.134 -
  27.135 -    @Override
  27.136 -    public void storeSettings(WizardDescriptor wiz) {
  27.137 -        Set<FileObject> folders = getComponent().getSelectedFolders();
  27.138 -        wiz.putProperty(WizardProperties.KEY_FOLDERS, folders);
  27.139 -    }
  27.140 -
  27.141 -    @Override
  27.142 -    public void validate() throws WizardValidationException {
  27.143 -        valid = true;
  27.144 -        Set<FileObject> folders = getComponent().getSelectedFolders();
  27.145 -        if (folders == null || folders.isEmpty()) {
  27.146 -            valid = false;
  27.147 -            throw new WizardValidationException(component, "Please select at least one folder!", null);
  27.148 -        }
  27.149 -        if (wiz != null) {
  27.150 -            wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
  27.151 -            wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, null);
  27.152 -            wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
  27.153 -        }
  27.154 -    }
  27.155 -}
    28.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/Bundle.properties	Wed Jan 02 13:38:30 2013 +0100
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,1 +0,0 @@
    28.4 -MSG_WAIT_FOLDERS=Scanning for folders, please wait...
    29.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/CheckableNodeCapability.java	Wed Jan 02 13:38:30 2013 +0100
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,74 +0,0 @@
    29.4 -/*
    29.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    29.6 - *
    29.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    29.8 - *
    29.9 - * The contents of this file are subject to the terms of either the GNU
   29.10 - * General Public License Version 2 only ("GPL") or the Common
   29.11 - * Development and Distribution License("CDDL") (collectively, the
   29.12 - * "License"). You may not use this file except in compliance with the
   29.13 - * License. You can obtain a copy of the License at
   29.14 - * http://www.netbeans.org/cddl-gplv2.html
   29.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   29.16 - * specific language governing permissions and limitations under the
   29.17 - * License.  When distributing the software, include this License Header
   29.18 - * Notice in each file and include the License file at
   29.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   29.20 - * particular file as subject to the "Classpath" exception as provided
   29.21 - * by Sun in the GPL Version 2 section of the License file that
   29.22 - * accompanied this code. If applicable, add the following below the
   29.23 - * License Header, with the fields enclosed by brackets [] replaced by
   29.24 - * your own identifying information:
   29.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   29.26 - *
   29.27 - * If you wish your version of this file to be governed by only the CDDL
   29.28 - * or only the GPL Version 2, indicate your decision by adding
   29.29 - * "[Contributor] elects to include this software in this distribution
   29.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   29.31 - * single choice of license, a recipient has the option to distribute
   29.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   29.33 - * to extend the choice of license to its licensees as provided above.
   29.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   29.35 - * Version 2 license, then the option applies only if the new code is
   29.36 - * made subject to such option by the copyright holder.
   29.37 - *
   29.38 - * Contributor(s):
   29.39 - *
   29.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   29.41 - */
   29.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   29.43 -
   29.44 -import org.openide.explorer.view.CheckableNode;
   29.45 -
   29.46 -/**
   29.47 - * Implements {@link CheckableNode} to allow display and use of checkable nodes
   29.48 - * in views.
   29.49 - *
   29.50 - * @author Nils Hoffmann
   29.51 - */
   29.52 -public class CheckableNodeCapability implements CheckableNode {
   29.53 -
   29.54 -    private boolean checkable = true;
   29.55 -    private boolean checkEnabled = true;
   29.56 -    private boolean selected = true;
   29.57 -
   29.58 -    @Override
   29.59 -    public boolean isCheckable() {
   29.60 -        return checkable;
   29.61 -    }
   29.62 -
   29.63 -    @Override
   29.64 -    public boolean isCheckEnabled() {
   29.65 -        return checkEnabled;
   29.66 -    }
   29.67 -
   29.68 -    @Override
   29.69 -    public Boolean isSelected() {
   29.70 -        return selected;
   29.71 -    }
   29.72 -
   29.73 -    @Override
   29.74 -    public void setSelected(Boolean selected) {
   29.75 -        this.selected = selected.booleanValue();
   29.76 -    }
   29.77 -}
    30.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/FileChildren.java	Wed Jan 02 13:38:30 2013 +0100
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,153 +0,0 @@
    30.4 -/*
    30.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    30.6 - *
    30.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    30.8 - *
    30.9 - * The contents of this file are subject to the terms of either the GNU
   30.10 - * General Public License Version 2 only ("GPL") or the Common
   30.11 - * Development and Distribution License("CDDL") (collectively, the
   30.12 - * "License"). You may not use this file except in compliance with the
   30.13 - * License. You can obtain a copy of the License at
   30.14 - * http://www.netbeans.org/cddl-gplv2.html
   30.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   30.16 - * specific language governing permissions and limitations under the
   30.17 - * License.  When distributing the software, include this License Header
   30.18 - * Notice in each file and include the License file at
   30.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   30.20 - * particular file as subject to the "Classpath" exception as provided
   30.21 - * by Sun in the GPL Version 2 section of the License file that
   30.22 - * accompanied this code. If applicable, add the following below the
   30.23 - * License Header, with the fields enclosed by brackets [] replaced by
   30.24 - * your own identifying information:
   30.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   30.26 - *
   30.27 - * If you wish your version of this file to be governed by only the CDDL
   30.28 - * or only the GPL Version 2, indicate your decision by adding
   30.29 - * "[Contributor] elects to include this software in this distribution
   30.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   30.31 - * single choice of license, a recipient has the option to distribute
   30.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   30.33 - * to extend the choice of license to its licensees as provided above.
   30.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   30.35 - * Version 2 license, then the option applies only if the new code is
   30.36 - * made subject to such option by the copyright holder.
   30.37 - *
   30.38 - * Contributor(s):
   30.39 - *
   30.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   30.41 - */
   30.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   30.43 -
   30.44 -import java.util.Collection;
   30.45 -import java.util.Collections;
   30.46 -import java.util.HashSet;
   30.47 -import java.util.LinkedList;
   30.48 -import java.util.List;
   30.49 -import java.util.Set;
   30.50 -import javax.swing.Action;
   30.51 -import org.netbeans.modules.licensechanger.api.FileHandler;
   30.52 -import org.openide.filesystems.FileObject;
   30.53 -import org.openide.loaders.DataObject;
   30.54 -import org.openide.loaders.DataObjectNotFoundException;
   30.55 -import org.openide.nodes.ChildFactory;
   30.56 -import org.openide.nodes.FilterNode;
   30.57 -import org.openide.nodes.Node;
   30.58 -import org.openide.util.Exceptions;
   30.59 -import org.openide.util.lookup.Lookups;
   30.60 -import org.openide.util.lookup.ProxyLookup;
   30.61 -
   30.62 -/**
   30.63 - *
   30.64 - * @author Tim Boudreau (original author)
   30.65 - * @author Nils Hoffmann (changed to use CheckableNodeCapability)
   30.66 - */
   30.67 -public class FileChildren extends ChildFactory.Detachable<FileObject> {
   30.68 -
   30.69 -    private final Set<FileObject> folders;
   30.70 -    private final Collection<? extends FileHandler> allHandlers;
   30.71 -    private final Set<FileItem> items = Collections.synchronizedSet(new HashSet<FileItem>());
   30.72 -
   30.73 -    public FileChildren(Set<FileObject> folders, Set<FileHandler> fileHandler) {
   30.74 -        assert folders != null;
   30.75 -        this.folders = new HashSet<FileObject>(folders);
   30.76 -        allHandlers = fileHandler;//Lookup.getDefault().lookupAll(FileHandler.class);
   30.77 -        //settings.put(WizardProperties.KEY_ITEMS, items);
   30.78 -    }
   30.79 -
   30.80 -    @Override
   30.81 -    protected boolean createKeys(List<FileObject> toPopulate) {
   30.82 -        toPopulate.addAll(folders);
   30.83 -        return true;
   30.84 -    }
   30.85 -
   30.86 -    @Override
   30.87 -    protected Node[] createNodesForKey(FileObject key) {
   30.88 -        List<Node> result = new LinkedList<Node>();
   30.89 -        for (FileObject fo : key.getChildren()) {
   30.90 -            if (fo.isData()) {
   30.91 -                for (FileHandler h : allHandlers) {
   30.92 -                    if (h.match(fo)) {
   30.93 -                        try {
   30.94 -                            DataObject dob = DataObject.find(fo);
   30.95 -                            FileItem item = new FileItem(h, fo);
   30.96 -                            items.add(item);
   30.97 -                            FN fn = new FN(dob.getNodeDelegate(), item);
   30.98 -                            boolean shouldChange = !h.shouldSkipFile(fo);
   30.99 -                            result.add(fn);
  30.100 -//                            fn.setValue (CheckboxListView.SELECTED, shouldChange);
  30.101 -                            break;
  30.102 -                        } catch (DataObjectNotFoundException ex) {
  30.103 -                            Exceptions.printStackTrace(ex);
  30.104 -                        }
  30.105 -                    }
  30.106 -                }
  30.107 -            }
  30.108 -        }
  30.109 -        return result.toArray(new Node[result.size()]);
  30.110 -    }
  30.111 -
  30.112 -    public static final class FileItem {
  30.113 -
  30.114 -        FileHandler handler;
  30.115 -        FileObject file;
  30.116 -
  30.117 -        public FileItem(FileHandler handler, FileObject file) {
  30.118 -            this.handler = handler;
  30.119 -            this.file = file;
  30.120 -        }
  30.121 -
  30.122 -        public FileObject getFile() {
  30.123 -            return file;
  30.124 -        }
  30.125 -
  30.126 -        public FileHandler getHandler() {
  30.127 -            return handler;
  30.128 -        }
  30.129 -    }
  30.130 -
  30.131 -    private static final class FN extends FilterNode {
  30.132 -
  30.133 -        FN(Node orig, FileItem item) {
  30.134 -            super(orig, Children.LEAF, new ProxyLookup(
  30.135 -                    Lookups.fixed(item, new CheckableNodeCapability()),
  30.136 -                    orig.getLookup()));
  30.137 -            disableDelegation(DELEGATE_GET_ACTIONS);
  30.138 -            disableDelegation(DELEGATE_GET_CONTEXT_ACTIONS);
  30.139 -            disableDelegation(DELEGATE_SET_DISPLAY_NAME);
  30.140 -            disableDelegation(DELEGATE_GET_DISPLAY_NAME);
  30.141 -            disableDelegation(DELEGATE_GET_VALUE);
  30.142 -            disableDelegation(DELEGATE_SET_VALUE);
  30.143 -            disableDelegation(DELEGATE_SET_NAME);
  30.144 -            disableDelegation(DELEGATE_GET_NAME);
  30.145 -//            setValue(CheckboxListView.SELECTED, Boolean.TRUE);
  30.146 -            setName(item.file.getPath());
  30.147 -            setDisplayName(item.file.getPath());
  30.148 -            setShortDescription(item.file.getPath());
  30.149 -        }
  30.150 -
  30.151 -        @Override
  30.152 -        public Action[] getActions(boolean ignored) {
  30.153 -            return new Action[0];
  30.154 -        }
  30.155 -    }
  30.156 -}
    31.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/FileLoader.java	Wed Jan 02 13:38:30 2013 +0100
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,80 +0,0 @@
    31.4 -/*
    31.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    31.6 - *
    31.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    31.8 - *
    31.9 - * The contents of this file are subject to the terms of either the GNU
   31.10 - * General Public License Version 2 only ("GPL") or the Common
   31.11 - * Development and Distribution License("CDDL") (collectively, the
   31.12 - * "License"). You may not use this file except in compliance with the
   31.13 - * License. You can obtain a copy of the License at
   31.14 - * http://www.netbeans.org/cddl-gplv2.html
   31.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   31.16 - * specific language governing permissions and limitations under the
   31.17 - * License.  When distributing the software, include this License Header
   31.18 - * Notice in each file and include the License file at
   31.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   31.20 - * particular file as subject to the "Classpath" exception as provided
   31.21 - * by Sun in the GPL Version 2 section of the License file that
   31.22 - * accompanied this code. If applicable, add the following below the
   31.23 - * License Header, with the fields enclosed by brackets [] replaced by
   31.24 - * your own identifying information:
   31.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   31.26 - *
   31.27 - * If you wish your version of this file to be governed by only the CDDL
   31.28 - * or only the GPL Version 2, indicate your decision by adding
   31.29 - * "[Contributor] elects to include this software in this distribution
   31.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   31.31 - * single choice of license, a recipient has the option to distribute
   31.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   31.33 - * to extend the choice of license to its licensees as provided above.
   31.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   31.35 - * Version 2 license, then the option applies only if the new code is
   31.36 - * made subject to such option by the copyright holder.
   31.37 - *
   31.38 - * Contributor(s):
   31.39 - *
   31.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   31.41 - */
   31.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   31.43 -
   31.44 -import java.io.BufferedInputStream;
   31.45 -import java.io.ByteArrayOutputStream;
   31.46 -import java.io.IOException;
   31.47 -import java.io.InputStream;
   31.48 -import java.io.UnsupportedEncodingException;
   31.49 -import java.nio.charset.Charset;
   31.50 -import org.netbeans.api.queries.FileEncodingQuery;
   31.51 -import org.openide.filesystems.FileObject;
   31.52 -import org.openide.filesystems.FileUtil;
   31.53 -
   31.54 -/**
   31.55 - * @author Tim Boudreau
   31.56 - * @author Nils Hoffmann (Refactoring)
   31.57 - */
   31.58 -public class FileLoader {
   31.59 -
   31.60 -    public static String loadFile(FileObject file) throws IOException {
   31.61 -        Charset encoding = FileEncodingQuery.getEncoding(file);
   31.62 -        InputStream in = new BufferedInputStream(file.getInputStream());
   31.63 -        ByteArrayOutputStream out = new ByteArrayOutputStream((int) file.getSize());
   31.64 -        try {
   31.65 -            FileUtil.copy(in, out);
   31.66 -            try {
   31.67 -                String result = new String(out.toByteArray(), encoding.name());
   31.68 -                String sep = System.getProperty("line.separator");
   31.69 -                //Convert everything internally to use \n
   31.70 -                if (!"\n".equals(sep) && sep != null) {
   31.71 -                    return result.replaceAll(sep, "\n");
   31.72 -                } else {
   31.73 -                    return result;
   31.74 -                }
   31.75 -            } catch (UnsupportedEncodingException q) {
   31.76 -                return new String(out.toByteArray(), FileEncodingQuery.getDefaultEncoding().name());
   31.77 -            }
   31.78 -        } finally {
   31.79 -            in.close();
   31.80 -            out.close();
   31.81 -        }
   31.82 -    }
   31.83 -}
    32.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/FolderChildren.java	Wed Jan 02 13:38:30 2013 +0100
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,185 +0,0 @@
    32.4 -/*
    32.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    32.6 - *
    32.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    32.8 - *
    32.9 - * The contents of this file are subject to the terms of either the GNU
   32.10 - * General Public License Version 2 only ("GPL") or the Common
   32.11 - * Development and Distribution License("CDDL") (collectively, the
   32.12 - * "License"). You may not use this file except in compliance with the
   32.13 - * License. You can obtain a copy of the License at
   32.14 - * http://www.netbeans.org/cddl-gplv2.html
   32.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   32.16 - * specific language governing permissions and limitations under the
   32.17 - * License.  When distributing the software, include this License Header
   32.18 - * Notice in each file and include the License file at
   32.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   32.20 - * particular file as subject to the "Classpath" exception as provided
   32.21 - * by Sun in the GPL Version 2 section of the License file that
   32.22 - * accompanied this code. If applicable, add the following below the
   32.23 - * License Header, with the fields enclosed by brackets [] replaced by
   32.24 - * your own identifying information:
   32.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   32.26 - *
   32.27 - * If you wish your version of this file to be governed by only the CDDL
   32.28 - * or only the GPL Version 2, indicate your decision by adding
   32.29 - * "[Contributor] elects to include this software in this distribution
   32.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   32.31 - * single choice of license, a recipient has the option to distribute
   32.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   32.33 - * to extend the choice of license to its licensees as provided above.
   32.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   32.35 - * Version 2 license, then the option applies only if the new code is
   32.36 - * made subject to such option by the copyright holder.
   32.37 - *
   32.38 - * Contributor(s):
   32.39 - *
   32.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   32.41 - */
   32.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   32.43 -
   32.44 -import java.awt.EventQueue;
   32.45 -import java.util.List;
   32.46 -import javax.swing.Action;
   32.47 -import org.openide.explorer.view.CheckableNode;
   32.48 -import org.openide.filesystems.FileObject;
   32.49 -import org.openide.filesystems.FileUtil;
   32.50 -import org.openide.loaders.DataObject;
   32.51 -import org.openide.loaders.DataObjectNotFoundException;
   32.52 -import org.openide.nodes.AbstractNode;
   32.53 -import org.openide.nodes.ChildFactory;
   32.54 -import org.openide.nodes.Children;
   32.55 -import org.openide.nodes.FilterNode;
   32.56 -import org.openide.nodes.Node;
   32.57 -import org.openide.util.Exceptions;
   32.58 -import org.openide.util.NbBundle;
   32.59 -import org.openide.util.NbCollections;
   32.60 -import org.openide.util.lookup.Lookups;
   32.61 -import org.openide.util.lookup.ProxyLookup;
   32.62 -
   32.63 -/**
   32.64 - *
   32.65 - * @author Tim Boudreau (original author)
   32.66 - * @author Nils Hoffmann (changed to use CheckableNodeCapability)
   32.67 - */
   32.68 -public abstract class FolderChildren extends ChildFactory.Detachable<FileObject> implements Runnable {
   32.69 -
   32.70 -    private FileObject[] roots;
   32.71 -    volatile int keyCount = 0;
   32.72 -    private int nodeCount = 0;
   32.73 -    private volatile boolean cancelled = false;
   32.74 -
   32.75 -    public FolderChildren(FileObject[] roots) {
   32.76 -        this.roots = roots;
   32.77 -    }
   32.78 -
   32.79 -    @Override
   32.80 -    protected Node createWaitNode() {
   32.81 -        AbstractNode result = new AbstractNode(Children.LEAF);
   32.82 -        result.setDisplayName(NbBundle.getMessage(FolderChildren.class, "MSG_WAIT_FOLDERS"));
   32.83 -        return result;
   32.84 -    }
   32.85 -
   32.86 -    @Override
   32.87 -    public void addNotify() {
   32.88 -        cancelled = false;
   32.89 -        super.addNotify();
   32.90 -        keyCount = 0;
   32.91 -        nodeCount = 0;
   32.92 -    }
   32.93 -
   32.94 -    @Override
   32.95 -    protected void removeNotify() {
   32.96 -        super.removeNotify();
   32.97 -        cancelled = true;
   32.98 -    }
   32.99 -
  32.100 -    private boolean shouldSkipFolder(FileObject folder) {
  32.101 -        // XXX use VisibilityQuery instead
  32.102 -        String path = folder.getPath();
  32.103 -        return path.contains(".svn") || path.contains(".cvs") || path.contains(".hg")
  32.104 -                || path.endsWith(".svn") || path.endsWith(".cvs") || path.endsWith(".hg")
  32.105 -                || path.contains("target") || path.endsWith("target") || path.contains("build") || path.endsWith("build");
  32.106 -    }
  32.107 -
  32.108 -    @Override
  32.109 -    protected boolean createKeys(List<FileObject> toPopulate) {
  32.110 -        for (FileObject f : roots) {
  32.111 -            toPopulate.add(f);
  32.112 -            keyCount++;
  32.113 -            for (FileObject fo : NbCollections.iterable(f.getChildren(true))) {
  32.114 -                if (fo.isFolder()) {
  32.115 -                    if (shouldSkipFolder(fo)) {
  32.116 -                        continue;
  32.117 -                    }
  32.118 -                    toPopulate.add(fo);
  32.119 -                    keyCount++;
  32.120 -                }
  32.121 -                if (cancelled) {
  32.122 -                    return true;
  32.123 -                }
  32.124 -            }
  32.125 -            if (cancelled) {
  32.126 -                return true;
  32.127 -            }
  32.128 -        }
  32.129 -        return true;
  32.130 -    }
  32.131 -
  32.132 -    @Override
  32.133 -    protected Node createNodeForKey(FileObject f) {
  32.134 -        try {
  32.135 -            Node n = DataObject.find(f).getNodeDelegate();
  32.136 -            nodeCount++;
  32.137 -            if (nodeCount == keyCount) {
  32.138 -                EventQueue.invokeLater(this);
  32.139 -            }
  32.140 -            return new FN(n, f);
  32.141 -        } catch (DataObjectNotFoundException ex) {
  32.142 -            Exceptions.printStackTrace(ex);
  32.143 -            return null;
  32.144 -        }
  32.145 -    }
  32.146 -
  32.147 -    public abstract void onAllNodesCreated();
  32.148 -
  32.149 -    @Override
  32.150 -    public void run() {
  32.151 -        onAllNodesCreated();
  32.152 -    }
  32.153 -
  32.154 -    private static final class FN extends FilterNode {
  32.155 -
  32.156 -        FN(Node orig, FileObject f) {
  32.157 -            super(orig, Children.LEAF, new ProxyLookup(
  32.158 -                    Lookups.fixed(f, new CheckableNodeCapability()),
  32.159 -                    orig.getLookup()));
  32.160 -            disableDelegation(DELEGATE_GET_ACTIONS);
  32.161 -            disableDelegation(DELEGATE_GET_CONTEXT_ACTIONS);
  32.162 -            disableDelegation(DELEGATE_SET_DISPLAY_NAME);
  32.163 -            disableDelegation(DELEGATE_GET_DISPLAY_NAME);
  32.164 -            disableDelegation(DELEGATE_GET_VALUE);
  32.165 -            disableDelegation(DELEGATE_SET_VALUE);
  32.166 -            disableDelegation(DELEGATE_SET_NAME);
  32.167 -            disableDelegation(DELEGATE_GET_NAME);
  32.168 -            String p = f.getPath();
  32.169 -            // XXX this is a pretty arbitrary list... maybe check SharabilityQuery?
  32.170 -            if (!p.endsWith("nbproject")
  32.171 -                    && !p.endsWith("nbproject/private")) { //NOI18N
  32.172 -//                setValue (CheckboxListView.SELECTED, Boolean.TRUE);
  32.173 -            } else {
  32.174 -                CheckableNode cn = getLookup().lookup(CheckableNode.class);
  32.175 -                if (cn != null) {
  32.176 -                    cn.setSelected(false);
  32.177 -                }
  32.178 -            }
  32.179 -            setName(p);
  32.180 -            setDisplayName(FileUtil.getFileDisplayName(f));
  32.181 -        }
  32.182 -
  32.183 -        @Override
  32.184 -        public Action[] getActions(boolean ignored) {
  32.185 -            return new Action[0];
  32.186 -        }
  32.187 -    }
  32.188 -}
    33.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/LicenseChangerRunnable.java	Wed Jan 02 13:38:30 2013 +0100
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,225 +0,0 @@
    33.4 -/*
    33.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33.6 - *
    33.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    33.8 - *
    33.9 - * The contents of this file are subject to the terms of either the GNU
   33.10 - * General Public License Version 2 only ("GPL") or the Common
   33.11 - * Development and Distribution License("CDDL") (collectively, the
   33.12 - * "License"). You may not use this file except in compliance with the
   33.13 - * License. You can obtain a copy of the License at
   33.14 - * http://www.netbeans.org/cddl-gplv2.html
   33.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   33.16 - * specific language governing permissions and limitations under the
   33.17 - * License.  When distributing the software, include this License Header
   33.18 - * Notice in each file and include the License file at
   33.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   33.20 - * particular file as subject to the "Classpath" exception as provided
   33.21 - * by Sun in the GPL Version 2 section of the License file that
   33.22 - * accompanied this code. If applicable, add the following below the
   33.23 - * License Header, with the fields enclosed by brackets [] replaced by
   33.24 - * your own identifying information:
   33.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   33.26 - *
   33.27 - * If you wish your version of this file to be governed by only the CDDL
   33.28 - * or only the GPL Version 2, indicate your decision by adding
   33.29 - * "[Contributor] elects to include this software in this distribution
   33.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   33.31 - * single choice of license, a recipient has the option to distribute
   33.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   33.33 - * to extend the choice of license to its licensees as provided above.
   33.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   33.35 - * Version 2 license, then the option applies only if the new code is
   33.36 - * made subject to such option by the copyright holder.
   33.37 - *
   33.38 - * Contributor(s):
   33.39 - *
   33.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   33.41 - */
   33.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   33.43 -
   33.44 -import java.io.*;
   33.45 -import java.nio.charset.Charset;
   33.46 -import java.util.Arrays;
   33.47 -import java.util.Set;
   33.48 -import org.netbeans.api.progress.ProgressHandle;
   33.49 -import org.netbeans.api.progress.ProgressHandleFactory;
   33.50 -import org.netbeans.api.project.*;
   33.51 -import org.netbeans.api.queries.FileEncodingQuery;
   33.52 -import org.netbeans.modules.licensechanger.spi.wizard.LineEndingsPanel;
   33.53 -import org.netbeans.modules.maven.model.ModelOperation;
   33.54 -import org.netbeans.modules.maven.model.Utilities;
   33.55 -import org.netbeans.modules.maven.model.pom.POMModel;
   33.56 -import org.netbeans.modules.maven.model.pom.Properties;
   33.57 -import org.openide.WizardDescriptor;
   33.58 -import org.openide.filesystems.*;
   33.59 -import org.openide.util.EditableProperties;
   33.60 -import org.openide.util.Exceptions;
   33.61 -
   33.62 -/**
   33.63 - * @author Tim Boudreau
   33.64 - * @author Nils Hoffmann (Refactoring)
   33.65 - */
   33.66 -public class LicenseChangerRunnable implements Runnable {
   33.67 -
   33.68 -    private final WizardDescriptor wizard;
   33.69 -
   33.70 -    public LicenseChangerRunnable(WizardDescriptor wizard) {
   33.71 -        this.wizard = wizard;
   33.72 -    }
   33.73 -
   33.74 -    @Override
   33.75 -    public void run() {
   33.76 -        ProgressHandle handle = ProgressHandleFactory.createHandle("Changing license headers");
   33.77 -        try {
   33.78 -
   33.79 -            if ((Boolean) wizard.getProperty(WizardProperties.KEY_STORE_IN_USER_PROPERTIES)) {
   33.80 -                ProjectManager.mutex().writeAccess(new Runnable() {
   33.81 -                    @Override
   33.82 -                    public void run() {
   33.83 -                        String copyrightHolder = (String) wizard.getProperty(WizardProperties.KEY_COPYRIGHT_HOLDER);
   33.84 -                        if (copyrightHolder != null && !copyrightHolder.trim().isEmpty()) {
   33.85 -                            try {
   33.86 -                                //store value of copyright holder in User.properties
   33.87 -                                FileObject userProperties = FileUtil.getConfigFile("Templates/Properties/User.properties");
   33.88 -                                java.util.Properties props = new java.util.Properties();
   33.89 -                                InputStream in = null;
   33.90 -                                try {
   33.91 -                                    in = userProperties.getInputStream();
   33.92 -                                    props.load(in);
   33.93 -                                } catch (IOException ex) {
   33.94 -                                    Exceptions.printStackTrace(ex);
   33.95 -                                    throw new RuntimeException(ex);
   33.96 -                                } finally {
   33.97 -                                    if (in != null) {
   33.98 -                                        in.close();
   33.99 -                                    }
  33.100 -                                }
  33.101 -                                props.setProperty("user", copyrightHolder);
  33.102 -                                OutputStream out = null;
  33.103 -                                try {
  33.104 -                                    out = userProperties.getOutputStream();
  33.105 -                                    props.store(out, "Updated user by licensechanger plugin.");
  33.106 -                                } catch (IOException ex) {
  33.107 -                                    Exceptions.printStackTrace(ex);
  33.108 -                                    throw new RuntimeException(ex);
  33.109 -                                } finally {
  33.110 -                                    if (out != null) {
  33.111 -                                        out.close();
  33.112 -                                    }
  33.113 -                                }
  33.114 -                            } catch (IOException ex) {
  33.115 -                                Exceptions.printStackTrace(ex);
  33.116 -                            }
  33.117 -                        }
  33.118 -                    }
  33.119 -                });
  33.120 -            }
  33.121 -            @SuppressWarnings("unchecked")
  33.122 -            Set<FileChildren.FileItem> items = (Set<FileChildren.FileItem>) wizard.getProperty(WizardProperties.KEY_ITEMS);
  33.123 -            final String licenseText = (String) wizard.getProperty(WizardProperties.KEY_LICENSE_TEXT);
  33.124 -            final String licenseName = (String) wizard.getProperty(WizardProperties.KEY_LICENSE_NAME);
  33.125 -            int ix = 0;
  33.126 -            int max = items.size();
  33.127 -            handle.start(max);
  33.128 -            Charset enc;
  33.129 -            for (FileChildren.FileItem item : items) {
  33.130 -                handle.progress(item.getFile().getNameExt(), ix);
  33.131 -                try {
  33.132 -                    String content = FileLoader.loadFile(item.file);
  33.133 -                    String nue = item.handler.transform(content, licenseText, wizard.getProperties());
  33.134 -                    LineEndingPreference pref = LineEndingsPanel.getLineEndingPrefs();
  33.135 -                    nue = LineEndingPreference.convertLineEndings(pref, content, nue);
  33.136 -
  33.137 -                    enc = FileEncodingQuery.getEncoding(item.file);
  33.138 -                    byte[] bytes;
  33.139 -                    try {
  33.140 -                        bytes = nue.getBytes(enc.name());
  33.141 -                    } catch (UnsupportedEncodingException e) {
  33.142 -                        //properties files get resource_bundle_charset
  33.143 -                        bytes = nue.getBytes(FileEncodingQuery.getDefaultEncoding().name());
  33.144 -                    }
  33.145 -                    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
  33.146 -                    BufferedOutputStream out = new BufferedOutputStream(item.file.getOutputStream());
  33.147 -                    try {
  33.148 -                        FileUtil.copy(in, out);
  33.149 -                    } finally {
  33.150 -                        out.close();
  33.151 -                        in.close();
  33.152 -                    }
  33.153 -                } catch (IOException ex) {
  33.154 -                    Exceptions.printStackTrace(ex);
  33.155 -                }
  33.156 -                ix++;
  33.157 -            }
  33.158 -            Boolean updateProjectLicense = (Boolean) wizard.getProperty(WizardProperties.KEY_UPDATE_DEFAULT_PROJECT_LICENSE);
  33.159 -            if (updateProjectLicense) {
  33.160 -//                System.out.println("Updating default license header!");
  33.161 -                Project project = (Project) wizard.getProperty(WizardProperties.KEY_PROJECT);
  33.162 -                Sources source = ProjectUtils.getSources(project);
  33.163 -                for (SourceGroup group : source.getSourceGroups(Sources.TYPE_GENERIC)) {
  33.164 -                    try {
  33.165 -                        FileObject nbprojectDir = group.getRootFolder().getFileObject("nbproject");
  33.166 -                        if (nbprojectDir != null) {
  33.167 -                            final FileObject projectProps = FileUtil.createData(nbprojectDir, "project.properties");
  33.168 -                            boolean hasProjectProperties = group.contains(projectProps);
  33.169 -                            if (hasProjectProperties) {
  33.170 -//                                System.out.println("Found project.properties at " + projectProps.getPath());
  33.171 -                                ProjectManager.mutex().writeAccess(new Runnable() {
  33.172 -                                    @Override
  33.173 -                                    public void run() {
  33.174 -                                        try {
  33.175 -                                            InputStream istream = projectProps.getInputStream();
  33.176 -                                            EditableProperties props = new EditableProperties(true);
  33.177 -                                            try {
  33.178 -                                                props.load(istream);
  33.179 -                                            } finally {
  33.180 -                                                istream.close();
  33.181 -                                            }
  33.182 -                                            props.setProperty("project.license", licenseName);
  33.183 -                                            OutputStream ostream = projectProps.getOutputStream();
  33.184 -                                            try {
  33.185 -                                                props.store(ostream);
  33.186 -                                            } finally {
  33.187 -                                                ostream.close();
  33.188 -                                            }
  33.189 -                                        } catch (IOException ex) {
  33.190 -                                            Exceptions.printStackTrace(ex);
  33.191 -                                        }
  33.192 -                                    }
  33.193 -                                });
  33.194 -
  33.195 -                            }
  33.196 -                        } else {
  33.197 -                            //check for pom.xml
  33.198 -                            FileObject pom = group.getRootFolder().getFileObject("pom.xml");
  33.199 -                            if (pom != null) {
  33.200 -//                                System.out.println("Found maven pom.xml at " + pom.getPath());
  33.201 -                                //found pom-based maven project
  33.202 -//                                String netbeansHintLicense = "<netbeans.hint.license>" + licenseName + "</netbeans.hint.license>";
  33.203 -//                                System.out.println("Please add " + netbeansHintLicense + " within your pom.xml <properties> section!");
  33.204 -                                Utilities.performPOMModelOperations(pom, Arrays.asList(new ModelOperation<POMModel>() {
  33.205 -                                    @Override
  33.206 -                                    public void performOperation(POMModel model) {
  33.207 -                                        Properties props = model.getProject().getProperties();
  33.208 -                                        if (props == null) {
  33.209 -                                            props = model.getFactory().createProperties();
  33.210 -                                            props.setProperty("netbeans.hint.license", licenseName);
  33.211 -                                            model.getProject().setProperties(props);
  33.212 -                                        } else {
  33.213 -                                            props.setProperty("netbeans.hint.license", licenseName);
  33.214 -                                        }
  33.215 -                                    }
  33.216 -                                }));
  33.217 -                            }
  33.218 -                        }
  33.219 -                    } catch (IOException ex) {
  33.220 -                        Exceptions.printStackTrace(ex);
  33.221 -                    }
  33.222 -                }
  33.223 -            }
  33.224 -        } finally {
  33.225 -            handle.finish();
  33.226 -        }
  33.227 -    }
  33.228 -}
    34.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/LineEndingPreference.java	Wed Jan 02 13:38:30 2013 +0100
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,75 +0,0 @@
    34.4 -/*
    34.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    34.6 - *
    34.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    34.8 - *
    34.9 - * The contents of this file are subject to the terms of either the GNU
   34.10 - * General Public License Version 2 only ("GPL") or the Common
   34.11 - * Development and Distribution License("CDDL") (collectively, the
   34.12 - * "License"). You may not use this file except in compliance with the
   34.13 - * License. You can obtain a copy of the License at
   34.14 - * http://www.netbeans.org/cddl-gplv2.html
   34.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   34.16 - * specific language governing permissions and limitations under the
   34.17 - * License.  When distributing the software, include this License Header
   34.18 - * Notice in each file and include the License file at
   34.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   34.20 - * particular file as subject to the "Classpath" exception as provided
   34.21 - * by Sun in the GPL Version 2 section of the License file that
   34.22 - * accompanied this code. If applicable, add the following below the
   34.23 - * License Header, with the fields enclosed by brackets [] replaced by
   34.24 - * your own identifying information:
   34.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   34.26 - *
   34.27 - * If you wish your version of this file to be governed by only the CDDL
   34.28 - * or only the GPL Version 2, indicate your decision by adding
   34.29 - * "[Contributor] elects to include this software in this distribution
   34.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   34.31 - * single choice of license, a recipient has the option to distribute
   34.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   34.33 - * to extend the choice of license to its licensees as provided above.
   34.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   34.35 - * Version 2 license, then the option applies only if the new code is
   34.36 - * made subject to such option by the copyright holder.
   34.37 - *
   34.38 - * Contributor(s):
   34.39 - *
   34.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   34.41 - */
   34.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   34.43 -
   34.44 -/**
   34.45 - * User preference for line ending conversion
   34.46 - *
   34.47 - * @author Tim Boudreau
   34.48 - */
   34.49 -public enum LineEndingPreference {
   34.50 -
   34.51 -    FORCE_CRLF,
   34.52 -    NO_CHANGE,
   34.53 -    FORCE_NEWLINE,
   34.54 -    SYSTEM_DEFAULT;
   34.55 -
   34.56 -    public static String convertLineEndings(LineEndingPreference pref, String old, String nue) {
   34.57 -        boolean oldHasCrlf = old.contains("\r\n"); //NOI18N
   34.58 -        switch (pref) {
   34.59 -            case FORCE_CRLF:
   34.60 -                return nue.replaceAll("\n", "\r\n"); //NOI18N
   34.61 -            case FORCE_NEWLINE:
   34.62 -                //We already converted everything to newline only on load
   34.63 -                return nue;
   34.64 -            case NO_CHANGE:
   34.65 -                return oldHasCrlf ? nue.replaceAll("\n", "\r\n") : //NOI18N
   34.66 -                        nue;
   34.67 -            case SYSTEM_DEFAULT:
   34.68 -                String sep = System.getProperty("line.separator"); //NOI18N
   34.69 -                if ("\n".equals(sep)) {
   34.70 -                    return nue;
   34.71 -                } else {
   34.72 -                    return nue.replaceAll("\n", sep);//NOI18N
   34.73 -                }
   34.74 -            default:
   34.75 -                throw new AssertionError();
   34.76 -        }
   34.77 -    }
   34.78 -}
    35.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/Offsets.java	Wed Jan 02 13:38:30 2013 +0100
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,62 +0,0 @@
    35.4 -/*
    35.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    35.6 - *
    35.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    35.8 - *
    35.9 - * The contents of this file are subject to the terms of either the GNU
   35.10 - * General Public License Version 2 only ("GPL") or the Common
   35.11 - * Development and Distribution License("CDDL") (collectively, the
   35.12 - * "License"). You may not use this file except in compliance with the
   35.13 - * License. You can obtain a copy of the License at
   35.14 - * http://www.netbeans.org/cddl-gplv2.html
   35.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   35.16 - * specific language governing permissions and limitations under the
   35.17 - * License.  When distributing the software, include this License Header
   35.18 - * Notice in each file and include the License file at
   35.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   35.20 - * particular file as subject to the "Classpath" exception as provided
   35.21 - * by Sun in the GPL Version 2 section of the License file that
   35.22 - * accompanied this code. If applicable, add the following below the
   35.23 - * License Header, with the fields enclosed by brackets [] replaced by
   35.24 - * your own identifying information:
   35.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   35.26 - *
   35.27 - * If you wish your version of this file to be governed by only the CDDL
   35.28 - * or only the GPL Version 2, indicate your decision by adding
   35.29 - * "[Contributor] elects to include this software in this distribution
   35.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   35.31 - * single choice of license, a recipient has the option to distribute
   35.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   35.33 - * to extend the choice of license to its licensees as provided above.
   35.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   35.35 - * Version 2 license, then the option applies only if the new code is
   35.36 - * made subject to such option by the copyright holder.
   35.37 - *
   35.38 - * Contributor(s):
   35.39 - *
   35.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   35.41 - */
   35.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   35.43 -
   35.44 -/**
   35.45 - *
   35.46 - * @author Tim Boudreau
   35.47 - */
   35.48 -public final class Offsets {
   35.49 -
   35.50 -    private final int start;
   35.51 -    private final int end;
   35.52 -
   35.53 -    public Offsets(int start, int end) {
   35.54 -        this.start = start;
   35.55 -        this.end = end;
   35.56 -    }
   35.57 -
   35.58 -    public int getEnd() {
   35.59 -        return end;
   35.60 -    }
   35.61 -
   35.62 -    public int getStart() {
   35.63 -        return start;
   35.64 -    }
   35.65 -}
    36.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/spi/wizard/utils/WizardProperties.java	Wed Jan 02 13:38:30 2013 +0100
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,64 +0,0 @@
    36.4 -/*
    36.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    36.6 - *
    36.7 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    36.8 - *
    36.9 - * The contents of this file are subject to the terms of either the GNU
   36.10 - * General Public License Version 2 only ("GPL") or the Common
   36.11 - * Development and Distribution License("CDDL") (collectively, the
   36.12 - * "License"). You may not use this file except in compliance with the
   36.13 - * License. You can obtain a copy of the License at
   36.14 - * http://www.netbeans.org/cddl-gplv2.html
   36.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   36.16 - * specific language governing permissions and limitations under the
   36.17 - * License.  When distributing the software, include this License Header
   36.18 - * Notice in each file and include the License file at
   36.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   36.20 - * particular file as subject to the "Classpath" exception as provided
   36.21 - * by Sun in the GPL Version 2 section of the License file that
   36.22 - * accompanied this code. If applicable, add the following below the
   36.23 - * License Header, with the fields enclosed by brackets [] replaced by
   36.24 - * your own identifying information:
   36.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   36.26 - *
   36.27 - * If you wish your version of this file to be governed by only the CDDL
   36.28 - * or only the GPL Version 2, indicate your decision by adding
   36.29 - * "[Contributor] elects to include this software in this distribution
   36.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   36.31 - * single choice of license, a recipient has the option to distribute
   36.32 - * your version of this file under either the CDDL, the GPL Version 2 or
   36.33 - * to extend the choice of license to its licensees as provided above.
   36.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   36.35 - * Version 2 license, then the option applies only if the new code is
   36.36 - * made subject to such option by the copyright holder.
   36.37 - *
   36.38 - * Contributor(s):
   36.39 - *
   36.40 - * Portions Copyrighted 2009 Sun Microsystems, Inc.
   36.41 - */
   36.42 -package org.netbeans.modules.licensechanger.spi.wizard.utils;
   36.43 -
   36.44 -/**
   36.45 - * Central class for Wizard-related property keys.
   36.46 - *
   36.47 - * @author Nils Hoffmann
   36.48 - */
   36.49 -public final class WizardProperties {
   36.50 -
   36.51 -    public static final String KEY_FILE_HANDLERS = "fileHandlers";
   36.52 -    public static final String KEY_ITEMS = "fileItems";
   36.53 -    public static final String KEY_LICENSE_TEXT = "licenseText";
   36.54 -    public static final String KEY_LICENSE_NAME = "licenseName";
   36.55 -    public static final String KEY_ROOT_FILES = "rootFiles";
   36.56 -    public static final String KEY_FOLDERS = "folders";
   36.57 -    public static final String KEY_UPDATE_DEFAULT_PROJECT_LICENSE = "updateDefaultProjectLicense";
   36.58 -    public static final String VALUE_DEFAULT_LICENSE_TEXT = "No License";
   36.59 -    public static final String PROP_ENDING = "ending";
   36.60 -    public static final String KEY_ENDING = "line_terminator";
   36.61 -    public static final String KEY_PROJECT = "project";
   36.62 -    public static final String KEY_COPYRIGHT_HOLDER = "project.organization";
   36.63 -    public static final String KEY_STORE_IN_USER_PROPERTIES = "storeInUserProperties";
   36.64 -
   36.65 -    private WizardProperties() {
   36.66 -    }
   36.67 -}
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/Bundle.properties	Fri Jan 04 15:27:42 2013 +0100
    37.3 @@ -0,0 +1,39 @@
    37.4 +BROWSE_LICENSE_TITLE=Locate License File
    37.5 +MSG_SELECT_A_LICENSE=Select a License or Browse for file
    37.6 +ERR_COULD_NOT_LOAD=Could not load {0}
    37.7 +
    37.8 +WIZARD_TITLE=Add/Replace License Headers
    37.9 +#chooseFileTypes=Select File Types
   37.10 +#chooseLicense=Select License
   37.11 +#chooseFolders=Prune Folders
   37.12 +#chooseFiles=Choose Files
   37.13 +#preview=Preview
   37.14 +LBL_CHANGE_LICENSE=Change License Headers
   37.15 +
   37.16 +LicenseChooserPanel.chooseLabel.text=Choose License
   37.17 +LicenseChooserPanel.browseButton.text=Browse
   37.18 +LicenseChooserPanel.updateDefaultProjectLicense.text=Set as default project license
   37.19 +
   37.20 +ChooseFileTypesPanel.noCustomizerLabel.text=[no customizer]
   37.21 +ChooseFileTypesPanel.customizerPanel.border.title=File Type Settings
   37.22 +ChooseFileTypesPanel.copyrightHolderLabel.text=Copyright Holder
   37.23 +ChooseFileTypesPanel.licensePropertiesPanel.border.title=License Properties
   37.24 +ChooseFileTypesPanel.storeInUserProperties.text=Store in User.properties
   37.25 +ChooseFileTypesPanel.nodesLabel.text=File Types
   37.26 +
   37.27 +SelectFoldersPanel.jLabel1.text=Uncheck Folders that Should Be Ignored
   37.28 +SelectFoldersPanel.nodesLabel.text=Folders
   37.29 +
   37.30 +LineEndingsPanel.border.title=Line Endings
   37.31 +LineEndingsPanel.noChangeButton.text=Do Not Change
   37.32 +LineEndingsPanel.systemDefaultButton.text=Force System Default
   37.33 +LineEndingsPanel.newlineButton.text=Force Newline
   37.34 +LineEndingsPanel.forceCrlf.text=Force CRLF
   37.35 +LineEndingsPanel.newlineButton.text_1=Force Newline
   37.36 +LineEndingsPanel.systemDefaultButton.text_1=Force System Default
   37.37 +LineEndingsPanel.noChangeButton.text_1=Do Not Change
   37.38 +LineEndingsPanel.forceCrlf.text_1=Force CRLF
   37.39 +
   37.40 +PreviewPanel.jLabel1.text=Select File for Preview
   37.41 +PreviewPanel.jLabel3.text=jLabel3
   37.42 +PreviewPanel.nodesLabel.text=Files
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/ChooseFileTypesPanel.form	Fri Jan 04 15:27:42 2013 +0100
    38.3 @@ -0,0 +1,186 @@
    38.4 +<?xml version="1.0" encoding="UTF-8" ?>
    38.5 +
    38.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    38.7 +  <AuxValues>
    38.8 +    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    38.9 +    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   38.10 +    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   38.11 +    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   38.12 +    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   38.13 +    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   38.14 +    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   38.15 +    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   38.16 +    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   38.17 +  </AuxValues>
   38.18 +
   38.19 +  <Layout>
   38.20 +    <DimensionLayout dim="0">
   38.21 +      <Group type="103" groupAlignment="0" attributes="0">
   38.22 +          <Group type="102" attributes="0">
   38.23 +              <EmptySpace max="-2" attributes="0"/>
   38.24 +              <Group type="103" groupAlignment="0" attributes="0">
   38.25 +                  <Component id="jScrollPane1" alignment="0" pref="804" max="32767" attributes="0"/>
   38.26 +                  <Group type="102" alignment="1" attributes="0">
   38.27 +                      <Component id="customizerPanel" pref="559" max="32767" attributes="0"/>
   38.28 +                      <EmptySpace max="-2" attributes="0"/>
   38.29 +                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
   38.30 +                          <Component id="lineEndingsPanel1" pref="239" max="32767" attributes="0"/>
   38.31 +                          <Component id="licensePropertiesPanel" max="32767" attributes="0"/>
   38.32 +                      </Group>
   38.33 +                  </Group>
   38.34 +              </Group>
   38.35 +              <EmptySpace max="-2" attributes="0"/>
   38.36 +          </Group>
   38.37 +      </Group>
   38.38 +    </DimensionLayout>
   38.39 +    <DimensionLayout dim="1">
   38.40 +      <Group type="103" groupAlignment="0" attributes="0">
   38.41 +          <Group type="102" alignment="0" attributes="0">
   38.42 +              <EmptySpace max="-2" attributes="0"/>
   38.43 +              <Component id="jScrollPane1" min="-2" pref="137" max="-2" attributes="0"/>
   38.44 +              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   38.45 +              <Group type="103" groupAlignment="0" attributes="0">
   38.46 +                  <Component id="customizerPanel" pref="361" max="32767" attributes="0"/>
   38.47 +                  <Group type="102" attributes="0">
   38.48 +                      <Component id="lineEndingsPanel1" min="-2" max="-2" attributes="0"/>
   38.49 +                      <EmptySpace type="separate" max="-2" attributes="0"/>
   38.50 +                      <Component id="licensePropertiesPanel" max="32767" attributes="0"/>
   38.51 +                  </Group>
   38.52 +              </Group>
   38.53 +              <EmptySpace max="-2" attributes="0"/>
   38.54 +          </Group>
   38.55 +      </Group>
   38.56 +    </DimensionLayout>
   38.57 +  </Layout>
   38.58 +  <SubComponents>
   38.59 +    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
   38.60 +      <Properties>
   38.61 +        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   38.62 +          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
   38.63 +            <LineBorder>
   38.64 +              <Color PropertyName="color" blue="99" green="a8" id="controlShadow" palette="3" red="ac" type="palette"/>
   38.65 +            </LineBorder>
   38.66 +          </Border>
   38.67 +        </Property>
   38.68 +      </Properties>
   38.69 +      <AuxValues>
   38.70 +        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineView()"/>
   38.71 +      </AuxValues>
   38.72 +
   38.73 +      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
   38.74 +    </Container>
   38.75 +    <Container class="javax.swing.JPanel" name="customizerPanel">
   38.76 +      <Properties>
   38.77 +        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   38.78 +          <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
   38.79 +            <TitledBorder title="File Type Settings">
   38.80 +              <ResourceString PropertyName="titleX" bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="ChooseFileTypesPanel.customizerPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   38.81 +            </TitledBorder>
   38.82 +          </Border>
   38.83 +        </Property>
   38.84 +      </Properties>
   38.85 +      <AccessibilityProperties>
   38.86 +        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   38.87 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="ChooseFileTypesPanel.customizerPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   38.88 +        </Property>
   38.89 +      </AccessibilityProperties>
   38.90 +
   38.91 +      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
   38.92 +      <SubComponents>
   38.93 +        <Component class="javax.swing.JLabel" name="noCustomizerLabel">
   38.94 +          <Properties>
   38.95 +            <Property name="horizontalAlignment" type="int" value="0"/>
   38.96 +            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   38.97 +              <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="ChooseFileTypesPanel.noCustomizerLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   38.98 +            </Property>
   38.99 +            <Property name="enabled" type="boolean" value="false"/>
  38.100 +          </Properties>
  38.101 +          <AccessibilityProperties>
  38.102 +            <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  38.103 +              <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="ChooseFileTypesPanel.noCustomizerLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  38.104 +            </Property>
  38.105 +          </AccessibilityProperties>
  38.106 +          <Constraints>
  38.107 +            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
  38.108 +              <BorderConstraints direction="Center"/>
  38.109 +            </Constraint>
  38.110 +          </Constraints>
  38.111 +        </Component>
  38.112 +      </SubComponents>
  38.113 +    </Container>
  38.114 +    <Component class="org.netbeans.modules.licensechanger.wizard.LineEndingsPanel" name="lineEndingsPanel1">
  38.115 +    </Component>
  38.116 +    <Container class="javax.swing.JPanel" name="licensePropertiesPanel">
  38.117 +      <Properties>
  38.118 +        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
  38.119 +          <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
  38.120 +            <TitledBorder title="License Properties">
  38.121 +              <ResourceString PropertyName="titleX" bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="ChooseFileTypesPanel.licensePropertiesPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  38.122 +            </TitledBorder>
  38.123 +          </Border>
  38.124 +        </Property>
  38.125 +      </Properties>
  38.126 +
  38.127 +      <Layout>
  38.128 +        <DimensionLayout dim="0">
  38.129 +          <Group type="103" groupAlignment="0" attributes="0">
  38.130 +              <Group type="102" attributes="0">
  38.131 +                  <EmptySpace max="-2" attributes="0"/>
  38.132 +                  <Group type="103" groupAlignment="0" attributes="0">
  38.133 +                      <Component id="copyrightHolderField" max="32767" attributes="0"/>
  38.134 +                      <Group type="102" attributes="0">
  38.135 +                          <Component id="copyrightHolderLabel" min="-2" max="-2" attributes="0"/>
  38.136 +                          <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
  38.137 +                      </Group>
  38.138 +                      <Component id="storeInUserProperties" max="32767" attributes="0"/>
  38.139 +                  </Group>
  38.140 +                  <EmptySpace max="-2" attributes="0"/>
  38.141 +              </Group>
  38.142 +          </Group>
  38.143 +        </DimensionLayout>
  38.144 +        <DimensionLayout dim="1">
  38.145 +          <Group type="103" groupAlignment="0" attributes="0">
  38.146 +              <Group type="102" alignment="0" attributes="0">
  38.147 +                  <EmptySpace max="-2" attributes="0"/>
  38.148 +                  <Component id="copyrightHolderLabel" min="-2" max="-2" attributes="0"/>
  38.149 +                  <EmptySpace max="-2" attributes="0"/>
  38.150 +                  <Component id="copyrightHolderField" min="-2" max="-2" attributes="0"/>
  38.151 +                  <EmptySpace max="-2" attributes="0"/>
  38.152 +                  <Component id="storeInUserProperties" min="-2" max="-2" attributes="0"/>
  38.153 +                  <EmptySpace max="32767" attributes="0"/>
  38.154 +              </Group>
  38.155 +          </Group>
  38.156 +        </DimensionLayout>
  38.157 +      </Layout>
  38.158 +      <SubComponents>
  38.159 +        <Component class="javax.swing.JLabel" name="copyrightHolderLabel">
  38.160 +          <Properties>
  38.161 +            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
  38.162 +              <ComponentRef name="copyrightHolderField"/>
  38.163 +            </Property>
  38.164 +            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  38.165 +              <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="ChooseFileTypesPanel.copyrightHolderLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  38.166 +            </Property>
  38.167 +          </Properties>
  38.168 +        </Component>
  38.169 +        <Component class="javax.swing.JTextField" name="copyrightHolderField">
  38.170 +          <Properties>
  38.171 +            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
  38.172 +              <Connection code="System.getProperty(&quot;user.name&quot;) == null ? &quot;&quot; : System.getProperty(&quot;user.name&quot;)" type="code"/>
  38.173 +            </Property>
  38.174 +          </Properties>
  38.175 +          <Events>
  38.176 +            <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="copyrightHolderFieldFocusGained"/>
  38.177 +          </Events>
  38.178 +        </Component>
  38.179 +        <Component class="javax.swing.JCheckBox" name="storeInUserProperties">
  38.180 +          <Properties>
  38.181 +            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  38.182 +              <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="ChooseFileTypesPanel.storeInUserProperties.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  38.183 +            </Property>
  38.184 +          </Properties>
  38.185 +        </Component>
  38.186 +      </SubComponents>
  38.187 +    </Container>
  38.188 +  </SubComponents>
  38.189 +</Form>
  38.190 \ No newline at end of file
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/ChooseFileTypesPanel.java	Fri Jan 04 15:27:42 2013 +0100
    39.3 @@ -0,0 +1,295 @@
    39.4 +/*
    39.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    39.6 + *
    39.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    39.8 + *
    39.9 + * The contents of this file are subject to the terms of either the GNU
   39.10 + * General Public License Version 2 only ("GPL") or the Common
   39.11 + * Development and Distribution License("CDDL") (collectively, the
   39.12 + * "License"). You may not use this file except in compliance with the
   39.13 + * License. You can obtain a copy of the License at
   39.14 + * http://www.netbeans.org/cddl-gplv2.html
   39.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   39.16 + * specific language governing permissions and limitations under the
   39.17 + * License.  When distributing the software, include this License Header
   39.18 + * Notice in each file and include the License file at
   39.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   39.20 + * particular file as subject to the "Classpath" exception as provided
   39.21 + * by Sun in the GPL Version 2 section of the License file that
   39.22 + * accompanied this code. If applicable, add the following below the
   39.23 + * License Header, with the fields enclosed by brackets [] replaced by
   39.24 + * your own identifying information:
   39.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   39.26 + *
   39.27 + * If you wish your version of this file to be governed by only the CDDL
   39.28 + * or only the GPL Version 2, indicate your decision by adding
   39.29 + * "[Contributor] elects to include this software in this distribution
   39.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   39.31 + * single choice of license, a recipient has the option to distribute
   39.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   39.33 + * to extend the choice of license to its licensees as provided above.
   39.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   39.35 + * Version 2 license, then the option applies only if the new code is
   39.36 + * made subject to such option by the copyright holder.
   39.37 + *
   39.38 + * Contributor(s):
   39.39 + *
   39.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   39.41 + */
   39.42 +
   39.43 +/*
   39.44 + * NewJPanel.java
   39.45 + *
   39.46 + * Created on Mar 20, 2009, 1:14:43 AM
   39.47 + */
   39.48 +package org.netbeans.modules.licensechanger.wizard;
   39.49 +
   39.50 +import java.beans.PropertyChangeEvent;
   39.51 +import java.beans.PropertyChangeListener;
   39.52 +import java.util.Collections;
   39.53 +import java.util.Comparator;
   39.54 +import java.util.HashSet;
   39.55 +import java.util.List;
   39.56 +import java.util.Set;
   39.57 +import org.netbeans.modules.licensechanger.api.Customizable;
   39.58 +import org.netbeans.modules.licensechanger.api.FileHandler;
   39.59 +import org.netbeans.modules.licensechanger.wizard.utils.CheckableNodeCapability;
   39.60 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   39.61 +import org.netbeans.swing.outline.DefaultOutlineModel;
   39.62 +import org.openide.explorer.ExplorerManager;
   39.63 +import org.openide.explorer.view.CheckableNode;
   39.64 +import org.openide.explorer.view.OutlineView;
   39.65 +import org.openide.nodes.AbstractNode;
   39.66 +import org.openide.nodes.ChildFactory;
   39.67 +import org.openide.nodes.Children;
   39.68 +import org.openide.nodes.Node;
   39.69 +import org.openide.util.Lookup;
   39.70 +import org.openide.util.NbPreferences;
   39.71 +import org.openide.util.lookup.Lookups;
   39.72 +
   39.73 +/**
   39.74 + *
   39.75 + * @author Tim Boudreau
   39.76 + * @author Nils Hoffmann (Refactoring)
   39.77 + */
   39.78 +public class ChooseFileTypesPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener {
   39.79 +
   39.80 +    private final ExplorerManager mgr = new ExplorerManager();
   39.81 +
   39.82 +    public ChooseFileTypesPanel() {
   39.83 +        initComponents();
   39.84 +        String copyrightHolder =
   39.85 +                NbPreferences.forModule(ChooseFileTypesWizardPanel.class)
   39.86 +                .get(WizardProperties.KEY_COPYRIGHT_HOLDER, null);
   39.87 +        if (copyrightHolder != null && !copyrightHolder.trim().isEmpty()) {
   39.88 +            copyrightHolderField.setText(copyrightHolder);
   39.89 +        }
   39.90 +        mgr.setRootContext(new AbstractNode(Children.create(new FileHandlerChildren(), false)));
   39.91 +        mgr.addPropertyChangeListener(this);
   39.92 +        updateMap();
   39.93 +        updateView();
   39.94 +    }
   39.95 +
   39.96 +    private void updateMap() {
   39.97 +        Set<FileHandler> handlers = getFileHandlers();
   39.98 +        firePropertyChange(WizardProperties.KEY_FILE_HANDLERS, null, handlers);
   39.99 +    }
  39.100 +
  39.101 +    /**
  39.102 +     * This method is called from within the constructor to initialize the form.
  39.103 +     * WARNING: Do NOT modify this code. The content of this method is always
  39.104 +     * regenerated by the Form Editor.
  39.105 +     */
  39.106 +    @SuppressWarnings("unchecked")
  39.107 +    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  39.108 +    private void initComponents() {
  39.109 +
  39.110 +        jScrollPane1 = new OutlineView();
  39.111 +        customizerPanel = new javax.swing.JPanel();
  39.112 +        noCustomizerLabel = new javax.swing.JLabel();
  39.113 +        lineEndingsPanel1 = new org.netbeans.modules.licensechanger.wizard.LineEndingsPanel();
  39.114 +        licensePropertiesPanel = new javax.swing.JPanel();
  39.115 +        copyrightHolderLabel = new javax.swing.JLabel();
  39.116 +        copyrightHolderField = new javax.swing.JTextField();
  39.117 +        storeInUserProperties = new javax.swing.JCheckBox();
  39.118 +
  39.119 +        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("controlShadow")));
  39.120 +
  39.121 +        customizerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.customizerPanel.border.title"))); // NOI18N
  39.122 +        customizerPanel.setLayout(new java.awt.BorderLayout());
  39.123 +
  39.124 +        noCustomizerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  39.125 +        noCustomizerLabel.setText(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.noCustomizerLabel.text")); // NOI18N
  39.126 +        noCustomizerLabel.setEnabled(false);
  39.127 +        customizerPanel.add(noCustomizerLabel, java.awt.BorderLayout.CENTER);
  39.128 +        noCustomizerLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.noCustomizerLabel.text")); // NOI18N
  39.129 +
  39.130 +        licensePropertiesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.licensePropertiesPanel.border.title"))); // NOI18N
  39.131 +
  39.132 +        copyrightHolderLabel.setLabelFor(copyrightHolderField);
  39.133 +        copyrightHolderLabel.setText(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.copyrightHolderLabel.text")); // NOI18N
  39.134 +
  39.135 +        copyrightHolderField.setText(System.getProperty("user.name") == null ? "" : System.getProperty("user.name"));
  39.136 +        copyrightHolderField.addFocusListener(new java.awt.event.FocusAdapter() {
  39.137 +            public void focusGained(java.awt.event.FocusEvent evt) {
  39.138 +                copyrightHolderFieldFocusGained(evt);
  39.139 +            }
  39.140 +        });
  39.141 +
  39.142 +        storeInUserProperties.setText(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.storeInUserProperties.text")); // NOI18N
  39.143 +
  39.144 +        javax.swing.GroupLayout licensePropertiesPanelLayout = new javax.swing.GroupLayout(licensePropertiesPanel);
  39.145 +        licensePropertiesPanel.setLayout(licensePropertiesPanelLayout);
  39.146 +        licensePropertiesPanelLayout.setHorizontalGroup(
  39.147 +            licensePropertiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  39.148 +            .addGroup(licensePropertiesPanelLayout.createSequentialGroup()
  39.149 +                .addContainerGap()
  39.150 +                .addGroup(licensePropertiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  39.151 +                    .addComponent(copyrightHolderField)
  39.152 +                    .addGroup(licensePropertiesPanelLayout.createSequentialGroup()
  39.153 +                        .addComponent(copyrightHolderLabel)
  39.154 +                        .addGap(0, 0, Short.MAX_VALUE))
  39.155 +                    .addComponent(storeInUserProperties, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  39.156 +                .addContainerGap())
  39.157 +        );
  39.158 +        licensePropertiesPanelLayout.setVerticalGroup(
  39.159 +            licensePropertiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  39.160 +            .addGroup(licensePropertiesPanelLayout.createSequentialGroup()
  39.161 +                .addContainerGap()
  39.162 +                .addComponent(copyrightHolderLabel)
  39.163 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  39.164 +                .addComponent(copyrightHolderField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  39.165 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  39.166 +                .addComponent(storeInUserProperties)
  39.167 +                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  39.168 +        );
  39.169 +
  39.170 +        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  39.171 +        this.setLayout(layout);
  39.172 +        layout.setHorizontalGroup(
  39.173 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  39.174 +            .addGroup(layout.createSequentialGroup()
  39.175 +                .addContainerGap()
  39.176 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  39.177 +                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 804, Short.MAX_VALUE)
  39.178 +                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  39.179 +                        .addComponent(customizerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
  39.180 +                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  39.181 +                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  39.182 +                            .addComponent(lineEndingsPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
  39.183 +                            .addComponent(licensePropertiesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  39.184 +                .addContainerGap())
  39.185 +        );
  39.186 +        layout.setVerticalGroup(
  39.187 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  39.188 +            .addGroup(layout.createSequentialGroup()
  39.189 +                .addContainerGap()
  39.190 +                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
  39.191 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  39.192 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  39.193 +                    .addComponent(customizerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
  39.194 +                    .addGroup(layout.createSequentialGroup()
  39.195 +                        .addComponent(lineEndingsPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  39.196 +                        .addGap(18, 18, 18)
  39.197 +                        .addComponent(licensePropertiesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  39.198 +                .addContainerGap())
  39.199 +        );
  39.200 +
  39.201 +        customizerPanel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "ChooseFileTypesPanel.customizerPanel.border.title")); // NOI18N
  39.202 +    }// </editor-fold>//GEN-END:initComponents
  39.203 +
  39.204 +    private void copyrightHolderFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_copyrightHolderFieldFocusGained
  39.205 +        copyrightHolderField.selectAll();
  39.206 +    }//GEN-LAST:event_copyrightHolderFieldFocusGained
  39.207 +    // Variables declaration - do not modify//GEN-BEGIN:variables
  39.208 +    private javax.swing.JTextField copyrightHolderField;
  39.209 +    private javax.swing.JLabel copyrightHolderLabel;
  39.210 +    private javax.swing.JPanel customizerPanel;
  39.211 +    private javax.swing.JScrollPane jScrollPane1;
  39.212 +    private javax.swing.JPanel licensePropertiesPanel;
  39.213 +    private org.netbeans.modules.licensechanger.wizard.LineEndingsPanel lineEndingsPanel1;
  39.214 +    private javax.swing.JLabel noCustomizerLabel;
  39.215 +    private javax.swing.JCheckBox storeInUserProperties;
  39.216 +    // End of variables declaration//GEN-END:variables
  39.217 +
  39.218 +    @Override
  39.219 +    public ExplorerManager getExplorerManager() {
  39.220 +        return mgr;
  39.221 +    }
  39.222 +
  39.223 +    public Set<FileHandler> getFileHandlers() {
  39.224 +        Set<FileHandler> result = new HashSet<FileHandler>();
  39.225 +        for (Node n : mgr.getRootContext().getChildren().getNodes(true)) {
  39.226 +            CheckableNode cn = n.getLookup().lookup(CheckableNode.class);
  39.227 +            if (cn != null && cn.isSelected()) {
  39.228 +                result.addAll(n.getLookup().lookupAll(FileHandler.class));
  39.229 +            }
  39.230 +        }
  39.231 +        return result;
  39.232 +    }
  39.233 +
  39.234 +    @Override
  39.235 +    public void propertyChange(PropertyChangeEvent evt) {
  39.236 +        if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
  39.237 +            Node[] n = mgr.getSelectedNodes();
  39.238 +            updateCustomizer(n.length == 1 ? n[0].getLookup().lookup(Customizable.class) : null);
  39.239 +        }
  39.240 +    }
  39.241 +
  39.242 +    public String getCopyrightHolder() {
  39.243 +        return copyrightHolderField.getText();
  39.244 +    }
  39.245 +
  39.246 +    public void setCopyrightHolder(String copyrightHolder) {
  39.247 +        copyrightHolderField.setText(copyrightHolder);
  39.248 +    }
  39.249 +
  39.250 +    public boolean isStoreInUserProperties() {
  39.251 +        return storeInUserProperties.isSelected();
  39.252 +    }
  39.253 +
  39.254 +    public void setStoreInUserProperties(boolean b) {
  39.255 +        storeInUserProperties.setSelected(b);
  39.256 +    }
  39.257 +
  39.258 +    private void updateView() {
  39.259 +        OutlineView ov = (OutlineView) jScrollPane1;
  39.260 +        ov.getOutline().setRootVisible(false);
  39.261 +        ov.setPopupAllowed(false);
  39.262 +        ov.setTreeSortable(false);
  39.263 +        ov.getOutline().setShowGrid(false);
  39.264 +        String headerName = org.openide.util.NbBundle.getMessage(ChooseFileTypesPanel.class, "SelectFoldersPanel.nodesLabel.text"); // NOI18N
  39.265 +        ((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(headerName);
  39.266 +        setName("Choose File Types");
  39.267 +    }
  39.268 +
  39.269 +    private static final class FileHandlerChildren extends ChildFactory<FileHandler> {
  39.270 +
  39.271 +        @Override
  39.272 +        protected boolean createKeys(List<FileHandler> toPopulate) {
  39.273 +            toPopulate.addAll(Lookup.getDefault().lookupAll(FileHandler.class));
  39.274 +            Collections.sort(toPopulate, new Comparator<FileHandler>() {
  39.275 +                @Override
  39.276 +                public int compare(FileHandler t, FileHandler t1) {
  39.277 +                    return t.getDisplayName().compareTo(t1.getDisplayName());
  39.278 +                }
  39.279 +            });
  39.280 +            return true;
  39.281 +        }
  39.282 +
  39.283 +        @Override
  39.284 +        protected Node createNodeForKey(FileHandler key) {
  39.285 +            AbstractNode result = new AbstractNode(Children.LEAF, Lookups.fixed(key, new CheckableNodeCapability()));
  39.286 +            result.setDisplayName(key.getDisplayName());
  39.287 +            return result;
  39.288 +        }
  39.289 +    }
  39.290 +
  39.291 +    private void updateCustomizer(Customizable c) {
  39.292 +        customizerPanel.removeAll();
  39.293 +        customizerPanel.add(c == null ? noCustomizerLabel : c.getCustomizer());
  39.294 +        invalidate();
  39.295 +        revalidate();
  39.296 +        repaint();
  39.297 +    }
  39.298 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/ChooseFileTypesWizardPanel.java	Fri Jan 04 15:27:42 2013 +0100
    40.3 @@ -0,0 +1,137 @@
    40.4 +/*
    40.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    40.6 + *
    40.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    40.8 + *
    40.9 + * The contents of this file are subject to the terms of either the GNU
   40.10 + * General Public License Version 2 only ("GPL") or the Common
   40.11 + * Development and Distribution License("CDDL") (collectively, the
   40.12 + * "License"). You may not use this file except in compliance with the
   40.13 + * License. You can obtain a copy of the License at
   40.14 + * http://www.netbeans.org/cddl-gplv2.html
   40.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   40.16 + * specific language governing permissions and limitations under the
   40.17 + * License.  When distributing the software, include this License Header
   40.18 + * Notice in each file and include the License file at
   40.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   40.20 + * particular file as subject to the "Classpath" exception as provided
   40.21 + * by Sun in the GPL Version 2 section of the License file that
   40.22 + * accompanied this code. If applicable, add the following below the
   40.23 + * License Header, with the fields enclosed by brackets [] replaced by
   40.24 + * your own identifying information:
   40.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   40.26 + *
   40.27 + * If you wish your version of this file to be governed by only the CDDL
   40.28 + * or only the GPL Version 2, indicate your decision by adding
   40.29 + * "[Contributor] elects to include this software in this distribution
   40.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   40.31 + * single choice of license, a recipient has the option to distribute
   40.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   40.33 + * to extend the choice of license to its licensees as provided above.
   40.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   40.35 + * Version 2 license, then the option applies only if the new code is
   40.36 + * made subject to such option by the copyright holder.
   40.37 + *
   40.38 + * Contributor(s):
   40.39 + *
   40.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   40.41 + */
   40.42 +package org.netbeans.modules.licensechanger.wizard;
   40.43 +
   40.44 +import java.beans.PropertyChangeEvent;
   40.45 +import java.beans.PropertyChangeListener;
   40.46 +import javax.swing.event.ChangeListener;
   40.47 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   40.48 +import org.openide.WizardDescriptor;
   40.49 +import org.openide.WizardValidationException;
   40.50 +import org.openide.util.ChangeSupport;
   40.51 +import org.openide.util.HelpCtx;
   40.52 +import org.openide.util.NbPreferences;
   40.53 +
   40.54 +/**
   40.55 + *
   40.56 + * @author Nils Hoffmann
   40.57 + */
   40.58 +public class ChooseFileTypesWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   40.59 +
   40.60 +    /**
   40.61 +     * The visual component that displays this panel. If you need to access the
   40.62 +     * component from this class, just use getComponent().
   40.63 +     */
   40.64 +    private ChooseFileTypesPanel component;
   40.65 +    private WizardDescriptor wiz;
   40.66 +    private boolean valid = true;
   40.67 +    private ChangeSupport cs = new ChangeSupport(this);
   40.68 +
   40.69 +    // Get the visual component for the panel. In this template, the component
   40.70 +    // is kept separate. This can be more efficient: if the wizard is created
   40.71 +    // but never displayed, or not all panels are displayed, it is better to
   40.72 +    // create only those which really need to be visible.
   40.73 +    @Override
   40.74 +    public ChooseFileTypesPanel getComponent() {
   40.75 +        if (component == null) {
   40.76 +            component = new ChooseFileTypesPanel();
   40.77 +            component.addPropertyChangeListener(this);
   40.78 +        }
   40.79 +        return component;
   40.80 +    }
   40.81 +
   40.82 +    @Override
   40.83 +    public HelpCtx getHelp() {
   40.84 +        // Show no Help button for this panel:
   40.85 +        return HelpCtx.DEFAULT_HELP;
   40.86 +        // If you have context help:
   40.87 +        // return new HelpCtx("help.key.here");
   40.88 +    }
   40.89 +
   40.90 +    @Override
   40.91 +    public boolean isValid() {
   40.92 +        return valid;
   40.93 +    }
   40.94 +
   40.95 +    @Override
   40.96 +    public void addChangeListener(ChangeListener l) {
   40.97 +        cs.addChangeListener(l);
   40.98 +    }
   40.99 +
  40.100 +    @Override
  40.101 +    public void removeChangeListener(ChangeListener l) {
  40.102 +        cs.removeChangeListener(l);
  40.103 +    }
  40.104 +
  40.105 +    @Override
  40.106 +    public void propertyChange(PropertyChangeEvent pce) {
  40.107 +        cs.fireChange();
  40.108 +    }
  40.109 +
  40.110 +    @Override
  40.111 +    public void readSettings(WizardDescriptor wiz) {
  40.112 +        this.wiz = wiz;
  40.113 +        Boolean storeInUserProperties = (Boolean) wiz.getProperty(WizardProperties.KEY_STORE_IN_USER_PROPERTIES);
  40.114 +        ChooseFileTypesPanel panel = getComponent();
  40.115 +        if (storeInUserProperties != null) {
  40.116 +            panel.setStoreInUserProperties(storeInUserProperties);
  40.117 +        }
  40.118 +        String copyrightHolder = (String) wiz.getProperty(WizardProperties.KEY_COPYRIGHT_HOLDER);
  40.119 +        if (copyrightHolder == null) {
  40.120 +            copyrightHolder = NbPreferences.forModule(ChooseFileTypesWizardPanel.class).get(WizardProperties.KEY_COPYRIGHT_HOLDER, "");
  40.121 +        }
  40.122 +        panel.setCopyrightHolder(copyrightHolder);
  40.123 +    }
  40.124 +
  40.125 +    @Override
  40.126 +    public void storeSettings(WizardDescriptor wiz) {
  40.127 +        wiz.putProperty(WizardProperties.KEY_FILE_HANDLERS, getComponent().getFileHandlers());
  40.128 +        String copyrightHolder = getComponent().getCopyrightHolder();
  40.129 +        if (copyrightHolder != null && !copyrightHolder.isEmpty()) {
  40.130 +            wiz.putProperty(WizardProperties.KEY_COPYRIGHT_HOLDER, copyrightHolder);
  40.131 +            NbPreferences.forModule(ChooseFileTypesWizardPanel.class).put(WizardProperties.KEY_COPYRIGHT_HOLDER, copyrightHolder);
  40.132 +        }
  40.133 +        wiz.putProperty(WizardProperties.KEY_STORE_IN_USER_PROPERTIES, Boolean.valueOf(getComponent().isStoreInUserProperties()));
  40.134 +    }
  40.135 +
  40.136 +    @Override
  40.137 +    public void validate() throws WizardValidationException {
  40.138 +        valid = true;
  40.139 +    }
  40.140 +}
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChangerWizardAction.java	Fri Jan 04 15:27:42 2013 +0100
    41.3 @@ -0,0 +1,148 @@
    41.4 +/*
    41.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    41.6 + *
    41.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    41.8 + *
    41.9 + * The contents of this file are subject to the terms of either the GNU
   41.10 + * General Public License Version 2 only ("GPL") or the Common
   41.11 + * Development and Distribution License("CDDL") (collectively, the
   41.12 + * "License"). You may not use this file except in compliance with the
   41.13 + * License. You can obtain a copy of the License at
   41.14 + * http://www.netbeans.org/cddl-gplv2.html
   41.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   41.16 + * specific language governing permissions and limitations under the
   41.17 + * License.  When distributing the software, include this License Header
   41.18 + * Notice in each file and include the License file at
   41.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   41.20 + * particular file as subject to the "Classpath" exception as provided
   41.21 + * by Sun in the GPL Version 2 section of the License file that
   41.22 + * accompanied this code. If applicable, add the following below the
   41.23 + * License Header, with the fields enclosed by brackets [] replaced by
   41.24 + * your own identifying information:
   41.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   41.26 + *
   41.27 + * If you wish your version of this file to be governed by only the CDDL
   41.28 + * or only the GPL Version 2, indicate your decision by adding
   41.29 + * "[Contributor] elects to include this software in this distribution
   41.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   41.31 + * single choice of license, a recipient has the option to distribute
   41.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   41.33 + * to extend the choice of license to its licensees as provided above.
   41.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   41.35 + * Version 2 license, then the option applies only if the new code is
   41.36 + * made subject to such option by the copyright holder.
   41.37 + *
   41.38 + * Contributor(s):
   41.39 + *
   41.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   41.41 + */
   41.42 +package org.netbeans.modules.licensechanger.wizard;
   41.43 +
   41.44 +import java.awt.Component;
   41.45 +import java.awt.event.ActionEvent;
   41.46 +import java.awt.event.ActionListener;
   41.47 +import java.text.MessageFormat;
   41.48 +import java.util.ArrayList;
   41.49 +import java.util.HashSet;
   41.50 +import java.util.List;
   41.51 +import java.util.Set;
   41.52 +import javax.swing.JComponent;
   41.53 +import org.netbeans.api.project.*;
   41.54 +import org.netbeans.modules.licensechanger.wizard.utils.LicenseChangerRunnable;
   41.55 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   41.56 +import org.openide.DialogDisplayer;
   41.57 +import org.openide.WizardDescriptor;
   41.58 +import org.openide.awt.ActionID;
   41.59 +import org.openide.awt.ActionReference;
   41.60 +import org.openide.awt.ActionReferences;
   41.61 +import org.openide.awt.ActionRegistration;
   41.62 +import org.openide.filesystems.FileObject;
   41.63 +import org.openide.loaders.DataObject;
   41.64 +import org.openide.util.*;
   41.65 +
   41.66 +/**
   41.67 + * Context-sensitive action to launch the license header change wizard.
   41.68 + *
   41.69 + * @author Nils Hoffmann
   41.70 + */
   41.71 +@ActionID(
   41.72 +    category = "Tools",
   41.73 +id = "org.netbeans.modules.licensechanger.wizard.LicenseChangerWizardAction")
   41.74 +@ActionRegistration(
   41.75 +    displayName = "#CTL_LicenseChangerWizardAction")
   41.76 +@ActionReferences(
   41.77 +//    @ActionReference(path = "Loaders/folder/any/Actions", position = 951)
   41.78 +@ActionReference(path = "UI/ToolActions/Files", position = 951))
   41.79 +@NbBundle.Messages("CTL_LicenseChangerWizardAction=Change License Header")
   41.80 +public final class LicenseChangerWizardAction implements ActionListener {
   41.81 +
   41.82 +    private List<DataObject> context;
   41.83 +
   41.84 +    public LicenseChangerWizardAction(List<DataObject> context) {
   41.85 +        this.context = context;
   41.86 +    }
   41.87 +
   41.88 +    /**
   41.89 +     * Used to return the parent folder of a file or the folder itself.
   41.90 +     *
   41.91 +     * @param fo
   41.92 +     * @return
   41.93 +     */
   41.94 +    private FileObject addFileObject(FileObject fo) {
   41.95 +        if (fo.isFolder()) {
   41.96 +            return fo;
   41.97 +        }
   41.98 +        return fo.getParent();
   41.99 +    }
  41.100 +
  41.101 +    @Override
  41.102 +    public void actionPerformed(ActionEvent e) {
  41.103 +        Set<FileObject> files = new HashSet<FileObject>();
  41.104 +        Project owningProject = null;
  41.105 +        for (DataObject ob : context) {
  41.106 +            FileObject fo = ob.getPrimaryFile();
  41.107 +            Project proj = FileOwnerQuery.getOwner(fo);
  41.108 +            if (owningProject == null) {
  41.109 +                owningProject = proj;
  41.110 +                //TODO implement better exclusion of build directories 
  41.111 +                files.add(addFileObject(fo));
  41.112 +            } else {
  41.113 +                if (owningProject.equals(proj)) {
  41.114 +                    files.add(addFileObject(fo));
  41.115 +                } else {
  41.116 +                    Exceptions.printStackTrace(new IllegalStateException("Can only handle folders below one project!"));
  41.117 +                    return;
  41.118 +                }
  41.119 +            }
  41.120 +        }
  41.121 +
  41.122 +        List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
  41.123 +        panels.add(new ChooseFileTypesWizardPanel());
  41.124 +        panels.add(new LicenseChooserWizardPanel());
  41.125 +        panels.add(new SelectFoldersWizardPanel());
  41.126 +        panels.add(new PreviewWizardPanel());
  41.127 +        String[] steps = new String[panels.size()];
  41.128 +        for (int i = 0; i < panels.size(); i++) {
  41.129 +            Component c = panels.get(i).getComponent();
  41.130 +            // Default step name to component name of panel.
  41.131 +            steps[i] = c.getName();
  41.132 +            if (c instanceof JComponent) { // assume Swing components
  41.133 +                JComponent jc = (JComponent) c;
  41.134 +                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
  41.135 +                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
  41.136 +                jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
  41.137 +                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
  41.138 +                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
  41.139 +            }
  41.140 +        }
  41.141 +        WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<WizardDescriptor>(panels));
  41.142 +        // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
  41.143 +        wiz.setTitleFormat(new MessageFormat("{0}"));
  41.144 +        wiz.setTitle("Change License Headers");
  41.145 +        wiz.putProperty(WizardProperties.KEY_ROOT_FILES, files);
  41.146 +        wiz.putProperty(WizardProperties.KEY_PROJECT, owningProject);
  41.147 +        if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
  41.148 +            RequestProcessor.getDefault().post(new LicenseChangerRunnable(wiz));
  41.149 +        }
  41.150 +    }
  41.151 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChooserPanel.form	Fri Jan 04 15:27:42 2013 +0100
    42.3 @@ -0,0 +1,116 @@
    42.4 +<?xml version="1.0" encoding="UTF-8" ?>
    42.5 +
    42.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    42.7 +  <AuxValues>
    42.8 +    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    42.9 +    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   42.10 +    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   42.11 +    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   42.12 +    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   42.13 +    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   42.14 +    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   42.15 +    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   42.16 +    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   42.17 +  </AuxValues>
   42.18 +
   42.19 +  <Layout>
   42.20 +    <DimensionLayout dim="0">
   42.21 +      <Group type="103" groupAlignment="0" attributes="0">
   42.22 +          <Group type="102" alignment="0" attributes="0">
   42.23 +              <EmptySpace max="-2" attributes="0"/>
   42.24 +              <Group type="103" groupAlignment="0" attributes="0">
   42.25 +                  <Component id="jScrollPane2" max="32767" attributes="0"/>
   42.26 +                  <Group type="102" alignment="0" attributes="0">
   42.27 +                      <Component id="chooseLabel" min="-2" max="-2" attributes="0"/>
   42.28 +                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
   42.29 +                      <Component id="selectLicense" max="32767" attributes="0"/>
   42.30 +                  </Group>
   42.31 +                  <Group type="102" alignment="1" attributes="0">
   42.32 +                      <Component id="updateDefaultProjectLicense" min="-2" max="-2" attributes="0"/>
   42.33 +                      <EmptySpace max="32767" attributes="0"/>
   42.34 +                      <Component id="browseButton" min="-2" max="-2" attributes="0"/>
   42.35 +                  </Group>
   42.36 +              </Group>
   42.37 +              <EmptySpace max="-2" attributes="0"/>
   42.38 +          </Group>
   42.39 +      </Group>
   42.40 +    </DimensionLayout>
   42.41 +    <DimensionLayout dim="1">
   42.42 +      <Group type="103" groupAlignment="0" attributes="0">
   42.43 +          <Group type="102" alignment="0" attributes="0">
   42.44 +              <EmptySpace min="-2" max="-2" attributes="0"/>
   42.45 +              <Group type="103" groupAlignment="3" attributes="0">
   42.46 +                  <Component id="chooseLabel" alignment="3" min="-2" max="-2" attributes="0"/>
   42.47 +                  <Component id="selectLicense" alignment="3" min="-2" max="-2" attributes="0"/>
   42.48 +              </Group>
   42.49 +              <EmptySpace max="-2" attributes="0"/>
   42.50 +              <Component id="jScrollPane2" pref="223" max="32767" attributes="0"/>
   42.51 +              <EmptySpace max="-2" attributes="0"/>
   42.52 +              <Group type="103" groupAlignment="0" attributes="0">
   42.53 +                  <Component id="browseButton" min="-2" max="-2" attributes="0"/>
   42.54 +                  <Component id="updateDefaultProjectLicense" min="-2" max="-2" attributes="0"/>
   42.55 +              </Group>
   42.56 +              <EmptySpace max="-2" attributes="0"/>
   42.57 +          </Group>
   42.58 +      </Group>
   42.59 +    </DimensionLayout>
   42.60 +  </Layout>
   42.61 +  <SubComponents>
   42.62 +    <Component class="javax.swing.JLabel" name="chooseLabel">
   42.63 +      <Properties>
   42.64 +        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
   42.65 +          <ComponentRef name="selectLicense"/>
   42.66 +        </Property>
   42.67 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   42.68 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LicenseChooserPanel.chooseLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   42.69 +        </Property>
   42.70 +      </Properties>
   42.71 +    </Component>
   42.72 +    <Component class="javax.swing.JComboBox" name="selectLicense">
   42.73 +      <Properties>
   42.74 +        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
   42.75 +          <StringArray count="1">
   42.76 +            <StringItem index="0" value="[loading licenses]"/>
   42.77 +          </StringArray>
   42.78 +        </Property>
   42.79 +      </Properties>
   42.80 +      <Events>
   42.81 +        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="licenseSelected"/>
   42.82 +      </Events>
   42.83 +    </Component>
   42.84 +    <Component class="javax.swing.JButton" name="browseButton">
   42.85 +      <Properties>
   42.86 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   42.87 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LicenseChooserPanel.browseButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   42.88 +        </Property>
   42.89 +      </Properties>
   42.90 +      <Events>
   42.91 +        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseForLicense"/>
   42.92 +      </Events>
   42.93 +    </Component>
   42.94 +    <Component class="javax.swing.JCheckBox" name="updateDefaultProjectLicense">
   42.95 +      <Properties>
   42.96 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   42.97 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LicenseChooserPanel.updateDefaultProjectLicense.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   42.98 +        </Property>
   42.99 +      </Properties>
  42.100 +    </Component>
  42.101 +    <Container class="javax.swing.JScrollPane" name="jScrollPane2">
  42.102 +      <AuxValues>
  42.103 +        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
  42.104 +      </AuxValues>
  42.105 +
  42.106 +      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
  42.107 +      <SubComponents>
  42.108 +        <Component class="javax.swing.JEditorPane" name="licenseText">
  42.109 +          <Properties>
  42.110 +            <Property name="editable" type="boolean" value="false"/>
  42.111 +          </Properties>
  42.112 +          <AuxValues>
  42.113 +            <AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="licenseText.setContentType(&quot;text/plain&quot;);"/>
  42.114 +          </AuxValues>
  42.115 +        </Component>
  42.116 +      </SubComponents>
  42.117 +    </Container>
  42.118 +  </SubComponents>
  42.119 +</Form>
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChooserPanel.java	Fri Jan 04 15:27:42 2013 +0100
    43.3 @@ -0,0 +1,300 @@
    43.4 +/*
    43.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    43.6 + *
    43.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    43.8 + *
    43.9 + * The contents of this file are subject to the terms of either the GNU
   43.10 + * General Public License Version 2 only ("GPL") or the Common
   43.11 + * Development and Distribution License("CDDL") (collectively, the
   43.12 + * "License"). You may not use this file except in compliance with the
   43.13 + * License. You can obtain a copy of the License at
   43.14 + * http://www.netbeans.org/cddl-gplv2.html
   43.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   43.16 + * specific language governing permissions and limitations under the
   43.17 + * License.  When distributing the software, include this License Header
   43.18 + * Notice in each file and include the License file at
   43.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   43.20 + * particular file as subject to the "Classpath" exception as provided
   43.21 + * by Sun in the GPL Version 2 section of the License file that
   43.22 + * accompanied this code. If applicable, add the following below the
   43.23 + * License Header, with the fields enclosed by brackets [] replaced by
   43.24 + * your own identifying information:
   43.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   43.26 + *
   43.27 + * If you wish your version of this file to be governed by only the CDDL
   43.28 + * or only the GPL Version 2, indicate your decision by adding
   43.29 + * "[Contributor] elects to include this software in this distribution
   43.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   43.31 + * single choice of license, a recipient has the option to distribute
   43.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   43.33 + * to extend the choice of license to its licensees as provided above.
   43.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   43.35 + * Version 2 license, then the option applies only if the new code is
   43.36 + * made subject to such option by the copyright holder.
   43.37 + *
   43.38 + * Contributor(s):
   43.39 + *
   43.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   43.41 + */
   43.42 +package org.netbeans.modules.licensechanger.wizard;
   43.43 +
   43.44 +import java.awt.Component;
   43.45 +import java.awt.EventQueue;
   43.46 +import java.io.File;
   43.47 +import java.io.IOException;
   43.48 +import javax.swing.DefaultComboBoxModel;
   43.49 +import javax.swing.SwingUtilities;
   43.50 +import javax.swing.event.DocumentEvent;
   43.51 +import javax.swing.event.DocumentListener;
   43.52 +import org.netbeans.modules.licensechanger.api.LicenseHeader;
   43.53 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   43.54 +import org.openide.filesystems.FileChooserBuilder;
   43.55 +import org.openide.util.Exceptions;
   43.56 +import org.openide.util.NbBundle;
   43.57 +import org.openide.util.RequestProcessor;
   43.58 +
   43.59 +/**
   43.60 + *
   43.61 + * @author Tim Boudreau
   43.62 + * @author Nils Hoffmann (Refactoring)
   43.63 + */
   43.64 +public class LicenseChooserPanel extends javax.swing.JPanel implements Runnable, DocumentListener {
   43.65 +
   43.66 +    private volatile boolean licensesLoaded;
   43.67 +    private volatile boolean loadingLicenses;
   43.68 +
   43.69 +    /**
   43.70 +     * Creates new form LicenseChooser
   43.71 +     */
   43.72 +    public LicenseChooserPanel() {
   43.73 +        initComponents();
   43.74 +        enabled(false);
   43.75 +        licenseText.getDocument().addDocumentListener(this);
   43.76 +        licenseText.setText(WizardProperties.VALUE_DEFAULT_LICENSE_TEXT);
   43.77 +        setName("Choose License Header");
   43.78 +    }
   43.79 +
   43.80 +    /**
   43.81 +     * This method is called from within the constructor to initialize the form.
   43.82 +     * WARNING: Do NOT modify this code. The content of this method is always
   43.83 +     * regenerated by the Form Editor.
   43.84 +     */
   43.85 +    @SuppressWarnings("unchecked")
   43.86 +    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   43.87 +    private void initComponents() {
   43.88 +
   43.89 +        chooseLabel = new javax.swing.JLabel();
   43.90 +        selectLicense = new javax.swing.JComboBox();
   43.91 +        browseButton = new javax.swing.JButton();
   43.92 +        updateDefaultProjectLicense = new javax.swing.JCheckBox();
   43.93 +        jScrollPane2 = new javax.swing.JScrollPane();
   43.94 +        licenseText = new javax.swing.JEditorPane();
   43.95 +
   43.96 +        chooseLabel.setLabelFor(selectLicense);
   43.97 +        chooseLabel.setText(org.openide.util.NbBundle.getMessage(LicenseChooserPanel.class, "LicenseChooserPanel.chooseLabel.text")); // NOI18N
   43.98 +
   43.99 +        selectLicense.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[loading licenses]" }));
  43.100 +        selectLicense.addActionListener(new java.awt.event.ActionListener() {
  43.101 +            public void actionPerformed(java.awt.event.ActionEvent evt) {
  43.102 +                licenseSelected(evt);
  43.103 +            }
  43.104 +        });
  43.105 +
  43.106 +        browseButton.setText(org.openide.util.NbBundle.getMessage(LicenseChooserPanel.class, "LicenseChooserPanel.browseButton.text")); // NOI18N
  43.107 +        browseButton.addActionListener(new java.awt.event.ActionListener() {
  43.108 +            public void actionPerformed(java.awt.event.ActionEvent evt) {
  43.109 +                browseForLicense(evt);
  43.110 +            }
  43.111 +        });
  43.112 +
  43.113 +        updateDefaultProjectLicense.setText(org.openide.util.NbBundle.getMessage(LicenseChooserPanel.class, "LicenseChooserPanel.updateDefaultProjectLicense.text")); // NOI18N
  43.114 +
  43.115 +        licenseText.setEditable(false);
  43.116 +        jScrollPane2.setViewportView(licenseText);
  43.117 +        licenseText.setContentType("text/plain");
  43.118 +
  43.119 +        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  43.120 +        this.setLayout(layout);
  43.121 +        layout.setHorizontalGroup(
  43.122 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  43.123 +            .addGroup(layout.createSequentialGroup()
  43.124 +                .addContainerGap()
  43.125 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  43.126 +                    .addComponent(jScrollPane2)
  43.127 +                    .addGroup(layout.createSequentialGroup()
  43.128 +                        .addComponent(chooseLabel)
  43.129 +                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  43.130 +                        .addComponent(selectLicense, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  43.131 +                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  43.132 +                        .addComponent(updateDefaultProjectLicense)
  43.133 +                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  43.134 +                        .addComponent(browseButton)))
  43.135 +                .addContainerGap())
  43.136 +        );
  43.137 +        layout.setVerticalGroup(
  43.138 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  43.139 +            .addGroup(layout.createSequentialGroup()
  43.140 +                .addContainerGap()
  43.141 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  43.142 +                    .addComponent(chooseLabel)
  43.143 +                    .addComponent(selectLicense, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  43.144 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  43.145 +                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
  43.146 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  43.147 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  43.148 +                    .addComponent(browseButton)
  43.149 +                    .addComponent(updateDefaultProjectLicense))
  43.150 +                .addContainerGap())
  43.151 +        );
  43.152 +    }// </editor-fold>//GEN-END:initComponents
  43.153 +
  43.154 +    private void licenseSelected(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_licenseSelected
  43.155 +        if (loadingLicenses || !selectLicense.isEnabled()) {
  43.156 +            return;
  43.157 +        }
  43.158 +        loadLicenseFromResource((LicenseHeader) selectLicense.getSelectedItem());
  43.159 +    }//GEN-LAST:event_licenseSelected
  43.160 +
  43.161 +    private void browseForLicense(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseForLicense
  43.162 +        File f;
  43.163 +        if ((f = new FileChooserBuilder(LicenseChooserPanel.class).setTitle(
  43.164 +                NbBundle.getMessage(LicenseChooserPanel.class, "BROWSE_LICENSE_TITLE")) //NOI18N
  43.165 +                .setFilesOnly(true).showOpenDialog()) != null) {
  43.166 +            updateDefaultProjectLicense.setSelected(false);
  43.167 +            DefaultComboBoxModel dcbm = (DefaultComboBoxModel) selectLicense.getModel();
  43.168 +            LicenseHeader lh = LicenseHeader.fromFile(f);
  43.169 +            LicenseHeader.addAsNetBeansTemplate(lh);
  43.170 +            for (LicenseHeader header : LicenseHeader.fromTemplates()) {
  43.171 +                if (header.getName().equals(lh.getName())) {
  43.172 +//                    System.out.println("Found newly added template!");
  43.173 +                    dcbm.addElement(header);
  43.174 +                    dcbm.setSelectedItem(header);
  43.175 +                    loadLicenseFromResource(header);
  43.176 +                }
  43.177 +            }
  43.178 +        }
  43.179 +    }//GEN-LAST:event_browseForLicense
  43.180 +
  43.181 +    @Override
  43.182 +    public void addNotify() {
  43.183 +        super.addNotify();
  43.184 +        if (!licensesLoaded && !loadingLicenses) {
  43.185 +            loadingLicenses = true;
  43.186 +            enabled(false);
  43.187 +            RequestProcessor.getDefault().post(this);
  43.188 +        }
  43.189 +    }
  43.190 +    // Variables declaration - do not modify//GEN-BEGIN:variables
  43.191 +    private javax.swing.JButton browseButton;
  43.192 +    private javax.swing.JLabel chooseLabel;
  43.193 +    private javax.swing.JScrollPane jScrollPane2;
  43.194 +    private javax.swing.JEditorPane licenseText;
  43.195 +    private javax.swing.JComboBox selectLicense;
  43.196 +    private javax.swing.JCheckBox updateDefaultProjectLicense;
  43.197 +    // End of variables declaration//GEN-END:variables
  43.198 +
  43.199 +    private void enabled(boolean val) {
  43.200 +        for (Component c : getComponents()) {
  43.201 +            c.setEnabled(val);
  43.202 +        }
  43.203 +    }
  43.204 +
  43.205 +    private void initLicenses() throws IOException {
  43.206 +        assert !EventQueue.isDispatchThread();
  43.207 +        final DefaultComboBoxModel mdl = new DefaultComboBoxModel();
  43.208 +        for (LicenseHeader header : LicenseHeader.fromTemplates()) {
  43.209 +            mdl.addElement(header);
  43.210 +        }
  43.211 +        EventQueue.invokeLater(new Runnable() {
  43.212 +            @Override
  43.213 +            public void run() {
  43.214 +                mdl.setSelectedItem(NbBundle.getMessage(LicenseChooserPanel.class,
  43.215 +                        "MSG_SELECT_A_LICENSE")); //NOI18N
  43.216 +                selectLicense.setModel(mdl);
  43.217 +                enabled(true);
  43.218 +                licensesLoaded = true;
  43.219 +                loadingLicenses = false;
  43.220 +            }
  43.221 +        });
  43.222 +    }
  43.223 +
  43.224 +    @Override
  43.225 +    public void run() {
  43.226 +        try {
  43.227 +            initLicenses();
  43.228 +        } catch (IOException ex) {
  43.229 +            Exceptions.printStackTrace(ex);
  43.230 +        }
  43.231 +    }
  43.232 +
  43.233 +    private void loadLicenseFromResource(LicenseHeader header) {
  43.234 +        enabled(false);
  43.235 +        SwingUtilities.invokeLater(new ResourceLoader(header));
  43.236 +    }
  43.237 +
  43.238 +    public String getLicenseText() {
  43.239 +        return licenseText.getText();
  43.240 +    }
  43.241 +
  43.242 +    public String getLicenseName() {
  43.243 +        Object obj = selectLicense.getSelectedItem();
  43.244 +        if (obj != null && obj instanceof LicenseHeader) {
  43.245 +            LicenseHeader header = (LicenseHeader) obj;
  43.246 +            return header.getName();
  43.247 +        }
  43.248 +        return null;
  43.249 +    }
  43.250 +
  43.251 +    public boolean isUpdateDefaultProjectLicense() {
  43.252 +        return updateDefaultProjectLicense.isSelected();
  43.253 +    }
  43.254 +
  43.255 +    public void setUpdateDefaultProjectLicense(boolean b) {
  43.256 +        updateDefaultProjectLicense.setSelected(b);
  43.257 +    }
  43.258 +
  43.259 +    private void updateLicense() {
  43.260 +        licenseText.setEditable(false);
  43.261 +        String txt = licenseText.getText();
  43.262 +        if (!txt.endsWith("\n")) {
  43.263 +            txt += "\n";
  43.264 +        }
  43.265 +        firePropertyChange(WizardProperties.KEY_LICENSE_TEXT, null, txt);
  43.266 +    }
  43.267 +
  43.268 +    @Override
  43.269 +    public void insertUpdate(DocumentEvent e) {
  43.270 +        updateLicense();
  43.271 +    }
  43.272 +
  43.273 +    @Override
  43.274 +    public void removeUpdate(DocumentEvent e) {
  43.275 +        updateLicense();
  43.276 +    }
  43.277 +
  43.278 +    @Override
  43.279 +    public void changedUpdate(DocumentEvent e) {
  43.280 +        updateLicense();
  43.281 +    }
  43.282 +
  43.283 +    private class ResourceLoader implements Runnable {
  43.284 +
  43.285 +        private LicenseHeader header;
  43.286 +
  43.287 +        ResourceLoader(LicenseHeader header) {
  43.288 +            this.header = header;
  43.289 +        }
  43.290 +
  43.291 +        @Override
  43.292 +        public void run() {
  43.293 +            licenseText.setText(header.getLicenseHeader());
  43.294 +            String mimeType = header.getFileObject().getMIMEType();
  43.295 +            licenseText.setContentType(mimeType);
  43.296 +            enabled(true);
  43.297 +        }
  43.298 +    }
  43.299 +
  43.300 +    public void setLicenseText(String text) {
  43.301 +        licenseText.setText(text);
  43.302 +    }
  43.303 +}
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/LicenseChooserWizardPanel.java	Fri Jan 04 15:27:42 2013 +0100
    44.3 @@ -0,0 +1,147 @@
    44.4 +/*
    44.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    44.6 + *
    44.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    44.8 + *
    44.9 + * The contents of this file are subject to the terms of either the GNU
   44.10 + * General Public License Version 2 only ("GPL") or the Common
   44.11 + * Development and Distribution License("CDDL") (collectively, the
   44.12 + * "License"). You may not use this file except in compliance with the
   44.13 + * License. You can obtain a copy of the License at
   44.14 + * http://www.netbeans.org/cddl-gplv2.html
   44.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   44.16 + * specific language governing permissions and limitations under the
   44.17 + * License.  When distributing the software, include this License Header
   44.18 + * Notice in each file and include the License file at
   44.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   44.20 + * particular file as subject to the "Classpath" exception as provided
   44.21 + * by Sun in the GPL Version 2 section of the License file that
   44.22 + * accompanied this code. If applicable, add the following below the
   44.23 + * License Header, with the fields enclosed by brackets [] replaced by
   44.24 + * your own identifying information:
   44.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   44.26 + *
   44.27 + * If you wish your version of this file to be governed by only the CDDL
   44.28 + * or only the GPL Version 2, indicate your decision by adding
   44.29 + * "[Contributor] elects to include this software in this distribution
   44.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   44.31 + * single choice of license, a recipient has the option to distribute
   44.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   44.33 + * to extend the choice of license to its licensees as provided above.
   44.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   44.35 + * Version 2 license, then the option applies only if the new code is
   44.36 + * made subject to such option by the copyright holder.
   44.37 + *
   44.38 + * Contributor(s):
   44.39 + *
   44.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   44.41 + */
   44.42 +package org.netbeans.modules.licensechanger.wizard;
   44.43 +
   44.44 +import java.beans.PropertyChangeEvent;
   44.45 +import java.beans.PropertyChangeListener;
   44.46 +import javax.swing.event.ChangeListener;
   44.47 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   44.48 +import org.openide.WizardDescriptor;
   44.49 +import org.openide.WizardValidationException;
   44.50 +import org.openide.util.ChangeSupport;
   44.51 +import org.openide.util.HelpCtx;
   44.52 +
   44.53 +/**
   44.54 + *
   44.55 + * @author Nils Hoffmann
   44.56 + */
   44.57 +public class LicenseChooserWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   44.58 +
   44.59 +    /**
   44.60 +     * The visual component that displays this panel. If you need to access the
   44.61 +     * component from this class, just use getComponent().
   44.62 +     */
   44.63 +    private LicenseChooserPanel component;
   44.64 +    private WizardDescriptor wiz;
   44.65 +    private boolean valid = false;
   44.66 +    private ChangeSupport cs = new ChangeSupport(this);
   44.67 +
   44.68 +    // Get the visual component for the panel. In this template, the component
   44.69 +    // is kept separate. This can be more efficient: if the wizard is created
   44.70 +    // but never displayed, or not all panels are displayed, it is better to
   44.71 +    // create only those which really need to be visible.
   44.72 +    @Override
   44.73 +    public LicenseChooserPanel getComponent() {
   44.74 +        if (component == null) {
   44.75 +            component = new LicenseChooserPanel();
   44.76 +            component.addPropertyChangeListener(this);
   44.77 +        }
   44.78 +        return component;
   44.79 +    }
   44.80 +
   44.81 +    @Override
   44.82 +    public HelpCtx getHelp() {
   44.83 +        // Show no Help button for this panel:
   44.84 +        return HelpCtx.DEFAULT_HELP;
   44.85 +        // If you have context help:
   44.86 +        // return new HelpCtx("help.key.here");
   44.87 +    }
   44.88 +
   44.89 +    @Override
   44.90 +    public boolean isValid() {
   44.91 +        return valid;
   44.92 +    }
   44.93 +
   44.94 +    @Override
   44.95 +    public void addChangeListener(ChangeListener l) {
   44.96 +        cs.addChangeListener(l);
   44.97 +    }
   44.98 +
   44.99 +    @Override
  44.100 +    public void removeChangeListener(ChangeListener l) {
  44.101 +        cs.removeChangeListener(l);
  44.102 +    }
  44.103 +
  44.104 +    @Override
  44.105 +    public void propertyChange(PropertyChangeEvent pce) {
  44.106 +        cs.fireChange();
  44.107 +        try {
  44.108 +            validate();
  44.109 +        } catch (WizardValidationException ex) {
  44.110 +            if (wiz != null) {
  44.111 +                wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Please select a license!");
  44.112 +            }
  44.113 +        }
  44.114 +    }
  44.115 +
  44.116 +    @Override
  44.117 +    public void readSettings(WizardDescriptor wiz) {
  44.118 +        this.wiz = wiz;
  44.119 +        Object obj = wiz.getProperty(WizardProperties.KEY_LICENSE_TEXT);
  44.120 +        if (obj != null && obj instanceof String) {
  44.121 +            getComponent().setLicenseText((String) obj);
  44.122 +        }
  44.123 +        Boolean b = (Boolean) wiz.getProperty(WizardProperties.KEY_UPDATE_DEFAULT_PROJECT_LICENSE);
  44.124 +        if (b != null) {
  44.125 +            getComponent().setUpdateDefaultProjectLicense(b);
  44.126 +        }
  44.127 +    }
  44.128 +
  44.129 +    @Override
  44.130 +    public void storeSettings(WizardDescriptor wiz) {
  44.131 +        wiz.putProperty(WizardProperties.KEY_LICENSE_TEXT, getComponent().getLicenseText());
  44.132 +        wiz.putProperty(WizardProperties.KEY_LICENSE_NAME, getComponent().getLicenseName());
  44.133 +        wiz.putProperty(WizardProperties.KEY_UPDATE_DEFAULT_PROJECT_LICENSE, Boolean.valueOf(getComponent().isUpdateDefaultProjectLicense()));
  44.134 +    }
  44.135 +
  44.136 +    @Override
  44.137 +    public void validate() throws WizardValidationException {
  44.138 +        valid = true;
  44.139 +        if (getComponent().getLicenseText() == null
  44.140 +                || getComponent().getLicenseText().equals(WizardProperties.VALUE_DEFAULT_LICENSE_TEXT)) {
  44.141 +            valid = false;
  44.142 +            throw new WizardValidationException(component, "Please select a license!", null);
  44.143 +        }
  44.144 +        if (wiz != null) {
  44.145 +            wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
  44.146 +            wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, null);
  44.147 +            wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
  44.148 +        }
  44.149 +    }
  44.150 +}
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/LineEndingsPanel.form	Fri Jan 04 15:27:42 2013 +0100
    45.3 @@ -0,0 +1,119 @@
    45.4 +<?xml version="1.0" encoding="UTF-8" ?>
    45.5 +
    45.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    45.7 +  <NonVisualComponents>
    45.8 +    <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
    45.9 +    </Component>
   45.10 +  </NonVisualComponents>
   45.11 +  <Properties>
   45.12 +    <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   45.13 +      <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
   45.14 +        <TitledBorder title="Line Endings">
   45.15 +          <ResourceString PropertyName="titleX" bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LineEndingsPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   45.16 +        </TitledBorder>
   45.17 +      </Border>
   45.18 +    </Property>
   45.19 +  </Properties>
   45.20 +  <AccessibilityProperties>
   45.21 +    <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   45.22 +      <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LineEndingsPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   45.23 +    </Property>
   45.24 +  </AccessibilityProperties>
   45.25 +  <AuxValues>
   45.26 +    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
   45.27 +    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   45.28 +    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   45.29 +    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   45.30 +    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   45.31 +    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   45.32 +    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   45.33 +    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   45.34 +    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   45.35 +  </AuxValues>
   45.36 +
   45.37 +  <Layout>
   45.38 +    <DimensionLayout dim="0">
   45.39 +      <Group type="103" groupAlignment="0" attributes="0">
   45.40 +          <Group type="102" attributes="0">
   45.41 +              <EmptySpace max="-2" attributes="0"/>
   45.42 +              <Group type="103" groupAlignment="0" attributes="0">
   45.43 +                  <Component id="noChangeButton" alignment="0" min="-2" max="-2" attributes="0"/>
   45.44 +                  <Component id="systemDefaultButton" alignment="0" min="-2" max="-2" attributes="0"/>
   45.45 +                  <Component id="newlineButton" alignment="0" min="-2" max="-2" attributes="0"/>
   45.46 +                  <Component id="forceCrlf" alignment="0" min="-2" max="-2" attributes="0"/>
   45.47 +              </Group>
   45.48 +              <EmptySpace max="32767" attributes="0"/>
   45.49 +          </Group>
   45.50 +      </Group>
   45.51 +    </DimensionLayout>
   45.52 +    <DimensionLayout dim="1">
   45.53 +      <Group type="103" groupAlignment="0" attributes="0">
   45.54 +          <Group type="102" alignment="0" attributes="0">
   45.55 +              <Component id="noChangeButton" min="-2" max="-2" attributes="0"/>
   45.56 +              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   45.57 +              <Component id="systemDefaultButton" min="-2" max="-2" attributes="0"/>
   45.58 +              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   45.59 +              <Component id="newlineButton" min="-2" max="-2" attributes="0"/>
   45.60 +              <EmptySpace type="unrelated" max="-2" attributes="0"/>
   45.61 +              <Component id="forceCrlf" min="-2" max="-2" attributes="0"/>
   45.62 +              <EmptySpace max="32767" attributes="0"/>
   45.63 +          </Group>
   45.64 +      </Group>
   45.65 +    </DimensionLayout>
   45.66 +  </Layout>
   45.67 +  <SubComponents>
   45.68 +    <Component class="javax.swing.JRadioButton" name="noChangeButton">
   45.69 +      <Properties>
   45.70 +        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
   45.71 +          <ComponentRef name="buttonGroup1"/>
   45.72 +        </Property>
   45.73 +        <Property name="selected" type="boolean" value="true"/>
   45.74 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   45.75 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LineEndingsPanel.noChangeButton.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   45.76 +        </Property>
   45.77 +      </Properties>
   45.78 +      <Events>
   45.79 +        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
   45.80 +      </Events>
   45.81 +    </Component>
   45.82 +    <Component class="javax.swing.JRadioButton" name="systemDefaultButton">
   45.83 +      <Properties>
   45.84 +        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
   45.85 +          <ComponentRef name="buttonGroup1"/>
   45.86 +        </Property>
   45.87 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   45.88 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LineEndingsPanel.systemDefaultButton.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   45.89 +        </Property>
   45.90 +      </Properties>
   45.91 +      <Events>
   45.92 +        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
   45.93 +      </Events>
   45.94 +    </Component>
   45.95 +    <Component class="javax.swing.JRadioButton" name="newlineButton">
   45.96 +      <Properties>
   45.97 +        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
   45.98 +          <ComponentRef name="buttonGroup1"/>
   45.99 +        </Property>
  45.100 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  45.101 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LineEndingsPanel.newlineButton.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  45.102 +        </Property>
  45.103 +      </Properties>
  45.104 +      <Events>
  45.105 +        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
  45.106 +      </Events>
  45.107 +    </Component>
  45.108 +    <Component class="javax.swing.JRadioButton" name="forceCrlf">
  45.109 +      <Properties>
  45.110 +        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
  45.111 +          <ComponentRef name="buttonGroup1"/>
  45.112 +        </Property>
  45.113 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  45.114 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="LineEndingsPanel.forceCrlf.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  45.115 +        </Property>
  45.116 +      </Properties>
  45.117 +      <Events>
  45.118 +        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineEndingPreferenceChanged"/>
  45.119 +      </Events>
  45.120 +    </Component>
  45.121 +  </SubComponents>
  45.122 +</Form>
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/LineEndingsPanel.java	Fri Jan 04 15:27:42 2013 +0100
    46.3 @@ -0,0 +1,171 @@
    46.4 +/*
    46.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    46.6 + *
    46.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    46.8 + *
    46.9 + * The contents of this file are subject to the terms of either the GNU
   46.10 + * General Public License Version 2 only ("GPL") or the Common
   46.11 + * Development and Distribution License("CDDL") (collectively, the
   46.12 + * "License"). You may not use this file except in compliance with the
   46.13 + * License. You can obtain a copy of the License at
   46.14 + * http://www.netbeans.org/cddl-gplv2.html
   46.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   46.16 + * specific language governing permissions and limitations under the
   46.17 + * License.  When distributing the software, include this License Header
   46.18 + * Notice in each file and include the License file at
   46.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   46.20 + * particular file as subject to the "Classpath" exception as provided
   46.21 + * by Sun in the GPL Version 2 section of the License file that
   46.22 + * accompanied this code. If applicable, add the following below the
   46.23 + * License Header, with the fields enclosed by brackets [] replaced by
   46.24 + * your own identifying information:
   46.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   46.26 + *
   46.27 + * If you wish your version of this file to be governed by only the CDDL
   46.28 + * or only the GPL Version 2, indicate your decision by adding
   46.29 + * "[Contributor] elects to include this software in this distribution
   46.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   46.31 + * single choice of license, a recipient has the option to distribute
   46.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   46.33 + * to extend the choice of license to its licensees as provided above.
   46.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   46.35 + * Version 2 license, then the option applies only if the new code is
   46.36 + * made subject to such option by the copyright holder.
   46.37 + *
   46.38 + * Contributor(s):
   46.39 + *
   46.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   46.41 + */
   46.42 +
   46.43 +/*
   46.44 + * LineEndingsPanel.java
   46.45 + *
   46.46 + * Created on Mar 20, 2009, 12:33:04 AM
   46.47 + */
   46.48 +package org.netbeans.modules.licensechanger.wizard;
   46.49 +
   46.50 +import javax.swing.JRadioButton;
   46.51 +import org.netbeans.modules.licensechanger.wizard.utils.LineEndingPreference;
   46.52 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   46.53 +import org.openide.util.NbPreferences;
   46.54 +
   46.55 +/**
   46.56 + *
   46.57 + * @author Administrator
   46.58 + */
   46.59 +public class LineEndingsPanel extends javax.swing.JPanel {
   46.60 +
   46.61 +    /**
   46.62 +     * Creates new form LineEndingsPanel
   46.63 +     */
   46.64 +    public LineEndingsPanel() {
   46.65 +        initComponents();
   46.66 +        forceCrlf.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.FORCE_CRLF);
   46.67 +        noChangeButton.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.NO_CHANGE);
   46.68 +        newlineButton.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.FORCE_NEWLINE);
   46.69 +        systemDefaultButton.putClientProperty(WizardProperties.PROP_ENDING, LineEndingPreference.SYSTEM_DEFAULT);
   46.70 +    }
   46.71 +
   46.72 +    /**
   46.73 +     * This method is called from within the constructor to initialize the form.
   46.74 +     * WARNING: Do NOT modify this code. The content of this method is always
   46.75 +     * regenerated by the Form Editor.
   46.76 +     */
   46.77 +    @SuppressWarnings("unchecked")
   46.78 +    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   46.79 +    private void initComponents() {
   46.80 +
   46.81 +        buttonGroup1 = new javax.swing.ButtonGroup();
   46.82 +        noChangeButton = new javax.swing.JRadioButton();
   46.83 +        systemDefaultButton = new javax.swing.JRadioButton();
   46.84 +        newlineButton = new javax.swing.JRadioButton();
   46.85 +        forceCrlf = new javax.swing.JRadioButton();
   46.86 +
   46.87 +        setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.border.title"))); // NOI18N
   46.88 +
   46.89 +        buttonGroup1.add(noChangeButton);
   46.90 +        noChangeButton.setSelected(true);
   46.91 +        noChangeButton.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.noChangeButton.text_1")); // NOI18N
   46.92 +        noChangeButton.addActionListener(new java.awt.event.ActionListener() {
   46.93 +            public void actionPerformed(java.awt.event.ActionEvent evt) {
   46.94 +                lineEndingPreferenceChanged(evt);
   46.95 +            }
   46.96 +        });
   46.97 +
   46.98 +        buttonGroup1.add(systemDefaultButton);
   46.99 +        systemDefaultButton.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.systemDefaultButton.text_1")); // NOI18N
  46.100 +        systemDefaultButton.addActionListener(new java.awt.event.ActionListener() {
  46.101 +            public void actionPerformed(java.awt.event.ActionEvent evt) {
  46.102 +                lineEndingPreferenceChanged(evt);
  46.103 +            }
  46.104 +        });
  46.105 +
  46.106 +        buttonGroup1.add(newlineButton);
  46.107 +        newlineButton.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.newlineButton.text_1")); // NOI18N
  46.108 +        newlineButton.addActionListener(new java.awt.event.ActionListener() {
  46.109 +            public void actionPerformed(java.awt.event.ActionEvent evt) {
  46.110 +                lineEndingPreferenceChanged(evt);
  46.111 +            }
  46.112 +        });
  46.113 +
  46.114 +        buttonGroup1.add(forceCrlf);
  46.115 +        forceCrlf.setText(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.forceCrlf.text_1")); // NOI18N
  46.116 +        forceCrlf.addActionListener(new java.awt.event.ActionListener() {
  46.117 +            public void actionPerformed(java.awt.event.ActionEvent evt) {
  46.118 +                lineEndingPreferenceChanged(evt);
  46.119 +            }
  46.120 +        });
  46.121 +
  46.122 +        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  46.123 +        this.setLayout(layout);
  46.124 +        layout.setHorizontalGroup(
  46.125 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  46.126 +            .addGroup(layout.createSequentialGroup()
  46.127 +                .addContainerGap()
  46.128 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  46.129 +                    .addComponent(noChangeButton)
  46.130 +                    .addComponent(systemDefaultButton)
  46.131 +                    .addComponent(newlineButton)
  46.132 +                    .addComponent(forceCrlf))
  46.133 +                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  46.134 +        );
  46.135 +        layout.setVerticalGroup(
  46.136 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  46.137 +            .addGroup(layout.createSequentialGroup()
  46.138 +                .addComponent(noChangeButton)
  46.139 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  46.140 +                .addComponent(systemDefaultButton)
  46.141 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  46.142 +                .addComponent(newlineButton)
  46.143 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  46.144 +                .addComponent(forceCrlf)
  46.145 +                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  46.146 +        );
  46.147 +
  46.148 +        getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LineEndingsPanel.class, "LineEndingsPanel.border.title")); // NOI18N
  46.149 +    }// </editor-fold>//GEN-END:initComponents
  46.150 +
  46.151 +    private void lineEndingPreferenceChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lineEndingPreferenceChanged
  46.152 +        for (JRadioButton b : new JRadioButton[]{forceCrlf, newlineButton, noChangeButton, systemDefaultButton}) {
  46.153 +            if (b.isSelected()) {
  46.154 +                LineEndingPreference x = (LineEndingPreference) b.getClientProperty(WizardProperties.PROP_ENDING);
  46.155 +                if (x != null) {
  46.156 +                    NbPreferences.forModule(LineEndingsPanel.class).put(WizardProperties.PROP_ENDING, x.name());
  46.157 +                }
  46.158 +                break;
  46.159 +            }
  46.160 +        }
  46.161 +    }//GEN-LAST:event_lineEndingPreferenceChanged
  46.162 +
  46.163 +    public static LineEndingPreference getLineEndingPrefs() {
  46.164 +        String ending = NbPreferences.forModule(LineEndingsPanel.class).get(WizardProperties.PROP_ENDING, LineEndingPreference.NO_CHANGE.name());
  46.165 +        return LineEndingPreference.valueOf(ending);
  46.166 +    }
  46.167 +    // Variables declaration - do not modify//GEN-BEGIN:variables
  46.168 +    private javax.swing.ButtonGroup buttonGroup1;
  46.169 +    private javax.swing.JRadioButton forceCrlf;
  46.170 +    private javax.swing.JRadioButton newlineButton;
  46.171 +    private javax.swing.JRadioButton noChangeButton;
  46.172 +    private javax.swing.JRadioButton systemDefaultButton;
  46.173 +    // End of variables declaration//GEN-END:variables
  46.174 +}
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/PreviewPanel.form	Fri Jan 04 15:27:42 2013 +0100
    47.3 @@ -0,0 +1,105 @@
    47.4 +<?xml version="1.0" encoding="UTF-8" ?>
    47.5 +
    47.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    47.7 +  <AuxValues>
    47.8 +    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    47.9 +    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   47.10 +    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   47.11 +    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   47.12 +    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   47.13 +    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   47.14 +    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   47.15 +    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   47.16 +    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   47.17 +  </AuxValues>
   47.18 +
   47.19 +  <Layout>
   47.20 +    <DimensionLayout dim="0">
   47.21 +      <Group type="103" groupAlignment="0" attributes="0">
   47.22 +          <Group type="102" attributes="0">
   47.23 +              <EmptySpace max="-2" attributes="0"/>
   47.24 +              <Group type="103" groupAlignment="0" attributes="0">
   47.25 +                  <Component id="jSplitPane1" alignment="0" max="32767" attributes="0"/>
   47.26 +                  <Component id="jLabel3" alignment="0" max="32767" attributes="0"/>
   47.27 +                  <Group type="102" alignment="0" attributes="0">
   47.28 +                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
   47.29 +                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
   47.30 +                  </Group>
   47.31 +              </Group>
   47.32 +              <EmptySpace max="-2" attributes="0"/>
   47.33 +          </Group>
   47.34 +      </Group>
   47.35 +    </DimensionLayout>
   47.36 +    <DimensionLayout dim="1">
   47.37 +      <Group type="103" groupAlignment="0" attributes="0">
   47.38 +          <Group type="102" alignment="1" attributes="0">
   47.39 +              <EmptySpace max="-2" attributes="0"/>
   47.40 +              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
   47.41 +              <EmptySpace max="-2" attributes="0"/>
   47.42 +              <Component id="jSplitPane1" pref="384" max="32767" attributes="0"/>
   47.43 +              <EmptySpace max="-2" attributes="0"/>
   47.44 +              <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
   47.45 +          </Group>
   47.46 +      </Group>
   47.47 +    </DimensionLayout>
   47.48 +  </Layout>
   47.49 +  <SubComponents>
   47.50 +    <Container class="javax.swing.JSplitPane" name="jSplitPane1">
   47.51 +      <Properties>
   47.52 +        <Property name="dividerLocation" type="int" value="200"/>
   47.53 +        <Property name="orientation" type="int" value="0"/>
   47.54 +        <Property name="resizeWeight" type="double" value="0.5"/>
   47.55 +      </Properties>
   47.56 +
   47.57 +      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
   47.58 +      <SubComponents>
   47.59 +        <Container class="javax.swing.JScrollPane" name="fileList">
   47.60 +          <AuxValues>
   47.61 +            <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineView()"/>
   47.62 +          </AuxValues>
   47.63 +          <Constraints>
   47.64 +            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
   47.65 +              <JSplitPaneConstraints position="top"/>
   47.66 +            </Constraint>
   47.67 +          </Constraints>
   47.68 +
   47.69 +          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
   47.70 +        </Container>
   47.71 +        <Container class="javax.swing.JPanel" name="diffPanel">
   47.72 +          <Constraints>
   47.73 +            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
   47.74 +              <JSplitPaneConstraints position="right"/>
   47.75 +            </Constraint>
   47.76 +          </Constraints>
   47.77 +
   47.78 +          <Layout>
   47.79 +            <DimensionLayout dim="0">
   47.80 +              <Group type="103" groupAlignment="0" attributes="0">
   47.81 +                  <EmptySpace min="0" pref="417" max="32767" attributes="0"/>
   47.82 +              </Group>
   47.83 +            </DimensionLayout>
   47.84 +            <DimensionLayout dim="1">
   47.85 +              <Group type="103" groupAlignment="0" attributes="0">
   47.86 +                  <EmptySpace min="0" pref="178" max="32767" attributes="0"/>
   47.87 +              </Group>
   47.88 +            </DimensionLayout>
   47.89 +          </Layout>
   47.90 +        </Container>
   47.91 +      </SubComponents>
   47.92 +    </Container>
   47.93 +    <Component class="javax.swing.JLabel" name="jLabel3">
   47.94 +      <Properties>
   47.95 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   47.96 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="PreviewPanel.jLabel3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   47.97 +        </Property>
   47.98 +      </Properties>
   47.99 +    </Component>
  47.100 +    <Component class="javax.swing.JLabel" name="jLabel1">
  47.101 +      <Properties>
  47.102 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
  47.103 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="PreviewPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
  47.104 +        </Property>
  47.105 +      </Properties>
  47.106 +    </Component>
  47.107 +  </SubComponents>
  47.108 +</Form>
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/PreviewPanel.java	Fri Jan 04 15:27:42 2013 +0100
    48.3 @@ -0,0 +1,361 @@
    48.4 +/*
    48.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    48.6 + *
    48.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    48.8 + *
    48.9 + * The contents of this file are subject to the terms of either the GNU
   48.10 + * General Public License Version 2 only ("GPL") or the Common
   48.11 + * Development and Distribution License("CDDL") (collectively, the
   48.12 + * "License"). You may not use this file except in compliance with the
   48.13 + * License. You can obtain a copy of the License at
   48.14 + * http://www.netbeans.org/cddl-gplv2.html
   48.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   48.16 + * specific language governing permissions and limitations under the
   48.17 + * License.  When distributing the software, include this License Header
   48.18 + * Notice in each file and include the License file at
   48.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   48.20 + * particular file as subject to the "Classpath" exception as provided
   48.21 + * by Sun in the GPL Version 2 section of the License file that
   48.22 + * accompanied this code. If applicable, add the following below the
   48.23 + * License Header, with the fields enclosed by brackets [] replaced by
   48.24 + * your own identifying information:
   48.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   48.26 + *
   48.27 + * If you wish your version of this file to be governed by only the CDDL
   48.28 + * or only the GPL Version 2, indicate your decision by adding
   48.29 + * "[Contributor] elects to include this software in this distribution
   48.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   48.31 + * single choice of license, a recipient has the option to distribute
   48.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   48.33 + * to extend the choice of license to its licensees as provided above.
   48.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   48.35 + * Version 2 license, then the option applies only if the new code is
   48.36 + * made subject to such option by the copyright holder.
   48.37 + *
   48.38 + * Contributor(s):
   48.39 + *
   48.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   48.41 + */
   48.42 +package org.netbeans.modules.licensechanger.wizard;
   48.43 +
   48.44 +import java.awt.EventQueue;
   48.45 +import java.beans.PropertyChangeEvent;
   48.46 +import java.beans.PropertyChangeListener;
   48.47 +import java.io.ByteArrayOutputStream;
   48.48 +import java.io.IOException;
   48.49 +import java.io.PrintWriter;
   48.50 +import java.io.StringReader;
   48.51 +import java.util.Collections;
   48.52 +import java.util.HashSet;
   48.53 +import java.util.Map;
   48.54 +import java.util.Set;
   48.55 +import org.netbeans.api.diff.Diff;
   48.56 +import org.netbeans.api.diff.DiffView;
   48.57 +import org.netbeans.api.diff.StreamSource;
   48.58 +import org.netbeans.modules.licensechanger.api.FileHandler;
   48.59 +import org.netbeans.modules.licensechanger.wizard.utils.FileChildren;
   48.60 +import org.netbeans.modules.licensechanger.wizard.utils.FileChildren.FileItem;
   48.61 +import org.netbeans.modules.licensechanger.wizard.utils.FileLoader;
   48.62 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   48.63 +import org.netbeans.swing.outline.DefaultOutlineModel;
   48.64 +import org.openide.explorer.ExplorerManager;
   48.65 +import org.openide.explorer.view.CheckableNode;
   48.66 +import org.openide.explorer.view.OutlineView;
   48.67 +import org.openide.filesystems.FileObject;
   48.68 +import org.openide.nodes.AbstractNode;
   48.69 +import org.openide.nodes.Children;
   48.70 +import org.openide.nodes.Node;
   48.71 +import org.openide.util.Exceptions;
   48.72 +import org.openide.util.RequestProcessor;
   48.73 +import org.openide.util.RequestProcessor.Task;
   48.74 +
   48.75 +/**
   48.76 + *
   48.77 + * @author Tim Boudreau
   48.78 + * @author Nils Hoffmann (Refactoring, Diff API inclusion)
   48.79 + */
   48.80 +public class PreviewPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener {
   48.81 +
   48.82 +    private final ExplorerManager mgr = new ExplorerManager();
   48.83 +    private ItemLoader loader;
   48.84 +    private String licenseText;
   48.85 +    private Diff diff;
   48.86 +    private Map<String, Object> properties;
   48.87 +
   48.88 +    public PreviewPanel() {
   48.89 +        diff = Diff.getDefault();
   48.90 +        initComponents();
   48.91 +        mgr.addPropertyChangeListener(this);
   48.92 +        jLabel3.setText("  ");
   48.93 +        updateView();
   48.94 +    }
   48.95 +
   48.96 +    private void updateView() {
   48.97 +        OutlineView ov = (OutlineView) fileList;
   48.98 +        ov.getOutline().setRootVisible(false);
   48.99 +        ov.setPopupAllowed(false);
  48.100 +        ov.setTreeSortable(false);
  48.101 +        ov.getOutline().setShowGrid(false);
  48.102 +        String headerName = org.openide.util.NbBundle.getMessage(PreviewPanel.class, "PreviewPanel.nodesLabel.text"); // NOI18N
  48.103 +        ((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(headerName);
  48.104 +        setName("Preview Changes");
  48.105 +    }
  48.106 +
  48.107 +    public void setFolders(Set<FileObject> folders, Set<FileHandler> fileHandler) {
  48.108 +        Children kids = Children.create(new FileChildren(folders, fileHandler), true);
  48.109 +        mgr.setRootContext(new AbstractNode(kids));
  48.110 +        updateView();
  48.111 +        updateItems();
  48.112 +    }
  48.113 +
  48.114 +    public Set<FileItem> getSelectedItems() {
  48.115 +        Set<FileItem> s = new HashSet<FileItem>();
  48.116 +        for (Node n : mgr.getRootContext().getChildren().getNodes(true)) {
  48.117 +            CheckableNode cn = n.getLookup().lookup(CheckableNode.class);
  48.118 +            if (cn != null && cn.isSelected()) {
  48.119 +                s.addAll(n.getLookup().lookupAll(FileItem.class));
  48.120 +            }
  48.121 +        }
  48.122 +        return s;
  48.123 +    }
  48.124 +
  48.125 +    private void updateItems() {
  48.126 +        Set<FileItem> s = getSelectedItems();
  48.127 +        firePropertyChange(WizardProperties.KEY_ITEMS, null, s);
  48.128 +    }
  48.129 +
  48.130 +    public void setLicenseText(String licenseText) {
  48.131 +        this.licenseText = licenseText;
  48.132 +        firePropertyChange(WizardProperties.KEY_LICENSE_TEXT, null, this.licenseText);
  48.133 +    }
  48.134 +
  48.135 +    void setProperties(Map<String, Object> properties) {
  48.136 +        this.properties = properties;
  48.137 +    }
  48.138 +
  48.139 +    /**
  48.140 +     * This method is called from within the constructor to initialize the form.
  48.141 +     * WARNING: Do NOT modify this code. The content of this method is always
  48.142 +     * regenerated by the Form Editor.
  48.143 +     */
  48.144 +    @SuppressWarnings("unchecked")
  48.145 +    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  48.146 +    private void initComponents() {
  48.147 +
  48.148 +        jSplitPane1 = new javax.swing.JSplitPane();
  48.149 +        fileList = new OutlineView();
  48.150 +        diffPanel = new javax.swing.JPanel();
  48.151 +        jLabel3 = new javax.swing.JLabel();
  48.152 +        jLabel1 = new javax.swing.JLabel();
  48.153 +
  48.154 +        jSplitPane1.setDividerLocation(200);
  48.155 +        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
  48.156 +        jSplitPane1.setResizeWeight(0.5);
  48.157 +        jSplitPane1.setTopComponent(fileList);
  48.158 +
  48.159 +        javax.swing.GroupLayout diffPanelLayout = new javax.swing.GroupLayout(diffPanel);
  48.160 +        diffPanel.setLayout(diffPanelLayout);
  48.161 +        diffPanelLayout.setHorizontalGroup(
  48.162 +            diffPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  48.163 +            .addGap(0, 417, Short.MAX_VALUE)
  48.164 +        );
  48.165 +        diffPanelLayout.setVerticalGroup(
  48.166 +            diffPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  48.167 +            .addGap(0, 178, Short.MAX_VALUE)
  48.168 +        );
  48.169 +
  48.170 +        jSplitPane1.setRightComponent(diffPanel);
  48.171 +
  48.172 +        jLabel3.setText(org.openide.util.NbBundle.getMessage(PreviewPanel.class, "PreviewPanel.jLabel3.text")); // NOI18N
  48.173 +
  48.174 +        jLabel1.setText(org.openide.util.NbBundle.getMessage(PreviewPanel.class, "PreviewPanel.jLabel1.text")); // NOI18N
  48.175 +
  48.176 +        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  48.177 +        this.setLayout(layout);
  48.178 +        layout.setHorizontalGroup(
  48.179 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  48.180 +            .addGroup(layout.createSequentialGroup()
  48.181 +                .addContainerGap()
  48.182 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  48.183 +                    .addComponent(jSplitPane1)
  48.184 +                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  48.185 +                    .addGroup(layout.createSequentialGroup()
  48.186 +                        .addComponent(jLabel1)
  48.187 +                        .addGap(0, 0, Short.MAX_VALUE)))
  48.188 +                .addContainerGap())
  48.189 +        );
  48.190 +        layout.setVerticalGroup(
  48.191 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  48.192 +            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  48.193 +                .addContainerGap()
  48.194 +                .addComponent(jLabel1)
  48.195 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  48.196 +                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
  48.197 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  48.198 +                .addComponent(jLabel3))
  48.199 +        );
  48.200 +    }// </editor-fold>//GEN-END:initComponents
  48.201 +    // Variables declaration - do not modify//GEN-BEGIN:variables
  48.202 +    private javax.swing.JPanel diffPanel;
  48.203 +    private javax.swing.JScrollPane fileList;
  48.204 +    private javax.swing.JLabel jLabel1;
  48.205 +    private javax.swing.JLabel jLabel3;
  48.206 +    private javax.swing.JSplitPane jSplitPane1;
  48.207 +    // End of variables declaration//GEN-END:variables
  48.208 +
  48.209 +    @Override
  48.210 +    public ExplorerManager getExplorerManager() {
  48.211 +        return mgr;
  48.212 +    }
  48.213 +
  48.214 +    @Override
  48.215 +    public void propertyChange(PropertyChangeEvent evt) {
  48.216 +        if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
  48.217 +            Node[] n = mgr.getSelectedNodes();
  48.218 +            if (n.length > 0) {
  48.219 +                FileItem item = n[0].getLookup().lookup(FileItem.class);
  48.220 +                if (item != null) {
  48.221 +                    setFileItem(item);
  48.222 +                    // XXX use FileUtil.getFileDisplayName rather than FileObject.getPath
  48.223 +
  48.224 +                    jLabel3.setText(item.getFile().getPath());
  48.225 +                } else {
  48.226 +//                    before.setText("");
  48.227 +                    jLabel3.setText("  ");
  48.228 +                }
  48.229 +            } else {
  48.230 +//                before.setText("");
  48.231 +//                after.setText("");
  48.232 +                jLabel3.setText("  ");
  48.233 +            }
  48.234 +        }
  48.235 +    }
  48.236 +
  48.237 +    private void setFileItem(FileItem item) {
  48.238 +        if (item.getFile().isValid()) {
  48.239 +            // XXX should use Diff API instead (like refactoring preview)
  48.240 +//            before.setContentType("text/plain");
  48.241 +//            after.setContentType("text/plain");
  48.242 +//            before.setText("Loading " + item.getFile().getPath());
  48.243 +//            after.setText("Loading " + item.getFile().getPath());
  48.244 +            ItemLoader ldr = new ItemLoader(item);
  48.245 +            setLoader(ldr);
  48.246 +        }
  48.247 +    }
  48.248 +
  48.249 +    private synchronized void setLoader(ItemLoader ldr) {
  48.250 +        if (loader != null) {
  48.251 +            loader.cancel();
  48.252 +        }
  48.253 +        this.loader = ldr;
  48.254 +        loader.start();
  48.255 +    }
  48.256 +
  48.257 +    private class ItemLoader implements Runnable {
  48.258 +
  48.259 +        private final Task task;
  48.260 +        private volatile boolean cancelled;
  48.261 +        private final FileItem item;
  48.262 +        private volatile String beforeText = "Cancelled";
  48.263 +        private volatile String afterText = "Cancelled";
  48.264 +
  48.265 +        public ItemLoader(FileItem item) {
  48.266 +            this.item = item;
  48.267 +            task = RequestProcessor.getDefault().create(this);
  48.268 +        }
  48.269 +
  48.270 +        void start() {
  48.271 +            task.schedule(200);
  48.272 +        }
  48.273 +
  48.274 +        public void cancel() {
  48.275 +            cancelled = true;
  48.276 +            task.cancel();
  48.277 +        }
  48.278 +
  48.279 +        private void loadFile() throws IOException {
  48.280 +            beforeText = FileLoader.loadFile(item.getFile());
  48.281 +        }
  48.282 +
  48.283 +        @Override
  48.284 +        public void run() {
  48.285 +            if (cancelled) {
  48.286 +                return;
  48.287 +            }
  48.288 +            if (!EventQueue.isDispatchThread()) {
  48.289 +                try {
  48.290 +                    if (cancelled) {
  48.291 +                        return;
  48.292 +                    }
  48.293 +                    if (!item.getFile().isValid()) {
  48.294 +                        beforeText = "Invalid file";
  48.295 +                        afterText = "Invalid file";
  48.296 +                        return;
  48.297 +                    }
  48.298 +                    if (!item.getFile().canRead()) {
  48.299 +                        beforeText = "Cannot read " + item.getFile().getPath();
  48.300 +                        afterText = "Cannot read " + item.getFile().getPath();
  48.301 +                        return;
  48.302 +                    }
  48.303 +                    if (item.getFile().getSize() >= Integer.MAX_VALUE) {
  48.304 +                        beforeText = "File too long: " + item.getFile().getPath();
  48.305 +                        afterText = "File too long: " + item.getFile().getPath();
  48.306 +                        return;
  48.307 +                    }
  48.308 +                    if (item.getFile().getSize() == 0) {
  48.309 +                        beforeText = "Empty file";
  48.310 +                        afterText = "Empty file";
  48.311 +                        return;
  48.312 +                    }
  48.313 +                    if (cancelled) {
  48.314 +                        return;
  48.315 +                    }
  48.316 +                    try {
  48.317 +                        loadFile();
  48.318 +                    } catch (IOException ex) {
  48.319 +                        ByteArrayOutputStream out = new ByteArrayOutputStream();
  48.320 +                        PrintWriter w = new PrintWriter(out);
  48.321 +                        ex.printStackTrace(w);
  48.322 +                        beforeText = new String(out.toByteArray());
  48.323 +                        afterText = "Error";
  48.324 +                        return;
  48.325 +                    }
  48.326 +                    if (cancelled) {
  48.327 +                        return;
  48.328 +                    }
  48.329 +                    if (beforeText.length() == 0) {
  48.330 +                        afterText = "";
  48.331 +                        return;
  48.332 +                    }
  48.333 +                    afterText = transform(beforeText, item.getHandler());
  48.334 +                } finally {
  48.335 +                    if (!cancelled) {
  48.336 +                        EventQueue.invokeLater(this);
  48.337 +                    }
  48.338 +                }
  48.339 +            } else {
  48.340 +                String contentType = item.getFile().getMIMEType();
  48.341 +                DiffView view;
  48.342 +                try {
  48.343 +                    view = diff.createDiff(StreamSource.createSource("Before", "Before", contentType, new StringReader(beforeText)),
  48.344 +                            StreamSource.createSource("After", "After", contentType, new StringReader(afterText)));
  48.345 +                    int dloc = jSplitPane1.getDividerLocation();
  48.346 +                    jSplitPane1.setBottomComponent(view.getComponent());
  48.347 +                    jSplitPane1.setDividerLocation(dloc);
  48.348 +                } catch (IOException ex) {
  48.349 +                    Exceptions.printStackTrace(ex);
  48.350 +                    int dloc = jSplitPane1.getDividerLocation();
  48.351 +                    jSplitPane1.setBottomComponent(diffPanel);
  48.352 +                    jSplitPane1.setDividerLocation(dloc);
  48.353 +                }
  48.354 +
  48.355 +            }
  48.356 +        }
  48.357 +
  48.358 +        private String transform(String beforeText, FileHandler handler) {
  48.359 +            return handler.transform(beforeText, licenseText,
  48.360 +                    properties == null ? Collections.<String, Object>emptyMap()
  48.361 +                    : properties);
  48.362 +        }
  48.363 +    }
  48.364 +}
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/PreviewWizardPanel.java	Fri Jan 04 15:27:42 2013 +0100
    49.3 @@ -0,0 +1,156 @@
    49.4 +/*
    49.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    49.6 + *
    49.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    49.8 + *
    49.9 + * The contents of this file are subject to the terms of either the GNU
   49.10 + * General Public License Version 2 only ("GPL") or the Common
   49.11 + * Development and Distribution License("CDDL") (collectively, the
   49.12 + * "License"). You may not use this file except in compliance with the
   49.13 + * License. You can obtain a copy of the License at
   49.14 + * http://www.netbeans.org/cddl-gplv2.html
   49.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   49.16 + * specific language governing permissions and limitations under the
   49.17 + * License.  When distributing the software, include this License Header
   49.18 + * Notice in each file and include the License file at
   49.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   49.20 + * particular file as subject to the "Classpath" exception as provided
   49.21 + * by Sun in the GPL Version 2 section of the License file that
   49.22 + * accompanied this code. If applicable, add the following below the
   49.23 + * License Header, with the fields enclosed by brackets [] replaced by
   49.24 + * your own identifying information:
   49.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   49.26 + *
   49.27 + * If you wish your version of this file to be governed by only the CDDL
   49.28 + * or only the GPL Version 2, indicate your decision by adding
   49.29 + * "[Contributor] elects to include this software in this distribution
   49.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   49.31 + * single choice of license, a recipient has the option to distribute
   49.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   49.33 + * to extend the choice of license to its licensees as provided above.
   49.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   49.35 + * Version 2 license, then the option applies only if the new code is
   49.36 + * made subject to such option by the copyright holder.
   49.37 + *
   49.38 + * Contributor(s):
   49.39 + *
   49.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   49.41 + */
   49.42 +package org.netbeans.modules.licensechanger.wizard;
   49.43 +
   49.44 +import java.beans.PropertyChangeEvent;
   49.45 +import java.beans.PropertyChangeListener;
   49.46 +import java.util.Set;
   49.47 +import javax.swing.event.ChangeListener;
   49.48 +import org.netbeans.modules.licensechanger.api.FileHandler;
   49.49 +import org.netbeans.modules.licensechanger.wizard.utils.FileChildren.FileItem;
   49.50 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   49.51 +import org.openide.WizardDescriptor;
   49.52 +import org.openide.WizardValidationException;
   49.53 +import org.openide.filesystems.FileObject;
   49.54 +import org.openide.util.ChangeSupport;
   49.55 +import org.openide.util.HelpCtx;
   49.56 +
   49.57 +/**
   49.58 + *
   49.59 + * @author Nils Hoffmann
   49.60 + */
   49.61 +public class PreviewWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   49.62 +
   49.63 +    /**
   49.64 +     * The visual component that displays this panel. If you need to access the
   49.65 +     * component from this class, just use getComponent().
   49.66 +     */
   49.67 +    private PreviewPanel component;
   49.68 +    private WizardDescriptor wiz;
   49.69 +    private boolean valid = true;
   49.70 +    private ChangeSupport cs = new ChangeSupport(this);
   49.71 +
   49.72 +    // Get the visual component for the panel. In this template, the component
   49.73 +    // is kept separate. This can be more efficient: if the wizard is created
   49.74 +    // but never displayed, or not all panels are displayed, it is better to
   49.75 +    // create only those which really need to be visible.
   49.76 +    @Override
   49.77 +    public PreviewPanel getComponent() {
   49.78 +        if (component == null) {
   49.79 +            component = new PreviewPanel();
   49.80 +            component.addPropertyChangeListener(this);
   49.81 +        }
   49.82 +        return component;
   49.83 +    }
   49.84 +
   49.85 +    @Override
   49.86 +    public HelpCtx getHelp() {
   49.87 +        // Show no Help button for this panel:
   49.88 +        return HelpCtx.DEFAULT_HELP;
   49.89 +        // If you have context help:
   49.90 +        // return new HelpCtx("help.key.here");
   49.91 +    }
   49.92 +
   49.93 +    @Override
   49.94 +    public boolean isValid() {
   49.95 +        return valid;
   49.96 +    }
   49.97 +
   49.98 +    @Override
   49.99 +    public void addChangeListener(ChangeListener l) {
  49.100 +        cs.addChangeListener(l);
  49.101 +    }
  49.102 +
  49.103 +    @Override
  49.104 +    public void removeChangeListener(ChangeListener l) {
  49.105 +        cs.removeChangeListener(l);
  49.106 +    }
  49.107 +
  49.108 +    @Override
  49.109 +    public void propertyChange(PropertyChangeEvent pce) {
  49.110 +        cs.fireChange();
  49.111 +        try {
  49.112 +            validate();
  49.113 +        } catch (WizardValidationException ex) {
  49.114 +            if (wiz != null) {
  49.115 +                wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, ex.getMessage());
  49.116 +            }
  49.117 +        }
  49.118 +    }
  49.119 +
  49.120 +    @Override
  49.121 +    public void readSettings(WizardDescriptor wiz) {
  49.122 +        this.wiz = wiz;
  49.123 +        @SuppressWarnings("unchecked")
  49.124 +        String license = (String) wiz.getProperty(WizardProperties.KEY_LICENSE_TEXT);
  49.125 +        if (license != null) {
  49.126 +            getComponent().setLicenseText(license);
  49.127 +        }
  49.128 +        getComponent().setProperties(wiz.getProperties());
  49.129 +        @SuppressWarnings("unchecked")
  49.130 +        Set<FileHandler> fileHandler = (Set<FileHandler>) wiz.getProperty(WizardProperties.KEY_FILE_HANDLERS);
  49.131 +        @SuppressWarnings("unchecked")
  49.132 +        Set<FileObject> folders = (Set<FileObject>) wiz.getProperty(WizardProperties.KEY_FOLDERS);
  49.133 +        if (fileHandler != null && folders != null) {
  49.134 +            getComponent().setFolders(folders, fileHandler);
  49.135 +        }
  49.136 +        wiz.putProperty(WizardProperties.KEY_ITEMS, null);
  49.137 +    }
  49.138 +
  49.139 +    @Override
  49.140 +    public void storeSettings(WizardDescriptor wiz) {
  49.141 +        wiz.putProperty(WizardProperties.KEY_ITEMS, getComponent().getSelectedItems());
  49.142 +    }
  49.143 +
  49.144 +    @Override
  49.145 +    public void validate() throws WizardValidationException {
  49.146 +        valid = true;
  49.147 +        Set<FileItem> keyItems = getComponent().getSelectedItems();
  49.148 +
  49.149 +        if (keyItems == null || keyItems.isEmpty()) {
  49.150 +            valid = false;
  49.151 +            throw new WizardValidationException(component, "Please select at least one file!", null);
  49.152 +        }
  49.153 +        if (wiz != null) {
  49.154 +            wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
  49.155 +            wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, null);
  49.156 +            wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
  49.157 +        }
  49.158 +    }
  49.159 +}
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/SelectFoldersPanel.form	Fri Jan 04 15:27:42 2013 +0100
    50.3 @@ -0,0 +1,66 @@
    50.4 +<?xml version="1.0" encoding="UTF-8" ?>
    50.5 +
    50.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
    50.7 +  <AuxValues>
    50.8 +    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
    50.9 +    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
   50.10 +    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
   50.11 +    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
   50.12 +    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
   50.13 +    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
   50.14 +    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
   50.15 +    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
   50.16 +    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
   50.17 +  </AuxValues>
   50.18 +
   50.19 +  <Layout>
   50.20 +    <DimensionLayout dim="0">
   50.21 +      <Group type="103" groupAlignment="0" attributes="0">
   50.22 +          <Group type="102" alignment="0" attributes="0">
   50.23 +              <EmptySpace max="-2" attributes="0"/>
   50.24 +              <Group type="103" groupAlignment="0" attributes="0">
   50.25 +                  <Component id="jScrollPane1" alignment="0" pref="541" max="32767" attributes="0"/>
   50.26 +                  <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
   50.27 +              </Group>
   50.28 +              <EmptySpace max="-2" attributes="0"/>
   50.29 +          </Group>
   50.30 +      </Group>
   50.31 +    </DimensionLayout>
   50.32 +    <DimensionLayout dim="1">
   50.33 +      <Group type="103" groupAlignment="0" attributes="0">
   50.34 +          <Group type="102" alignment="0" attributes="0">
   50.35 +              <EmptySpace max="-2" attributes="0"/>
   50.36 +              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
   50.37 +              <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
   50.38 +              <Component id="jScrollPane1" pref="364" max="32767" attributes="0"/>
   50.39 +              <EmptySpace max="-2" attributes="0"/>
   50.40 +          </Group>
   50.41 +      </Group>
   50.42 +    </DimensionLayout>
   50.43 +  </Layout>
   50.44 +  <SubComponents>
   50.45 +    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
   50.46 +      <Properties>
   50.47 +        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
   50.48 +          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
   50.49 +            <LineBorder>
   50.50 +              <Color PropertyName="color" blue="99" green="a8" id="controlShadow" palette="3" red="ac" type="palette"/>
   50.51 +            </LineBorder>
   50.52 +          </Border>
   50.53 +        </Property>
   50.54 +      </Properties>
   50.55 +      <AuxValues>
   50.56 +        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineView()"/>
   50.57 +      </AuxValues>
   50.58 +
   50.59 +      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
   50.60 +    </Container>
   50.61 +    <Component class="javax.swing.JLabel" name="jLabel1">
   50.62 +      <Properties>
   50.63 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   50.64 +          <ResourceString bundle="org/netbeans/modules/licensechanger/wizard/Bundle.properties" key="SelectFoldersPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
   50.65 +        </Property>
   50.66 +      </Properties>
   50.67 +    </Component>
   50.68 +  </SubComponents>
   50.69 +</Form>
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/SelectFoldersPanel.java	Fri Jan 04 15:27:42 2013 +0100
    51.3 @@ -0,0 +1,168 @@
    51.4 +/*
    51.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    51.6 + *
    51.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    51.8 + *
    51.9 + * The contents of this file are subject to the terms of either the GNU
   51.10 + * General Public License Version 2 only ("GPL") or the Common
   51.11 + * Development and Distribution License("CDDL") (collectively, the
   51.12 + * "License"). You may not use this file except in compliance with the
   51.13 + * License. You can obtain a copy of the License at
   51.14 + * http://www.netbeans.org/cddl-gplv2.html
   51.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   51.16 + * specific language governing permissions and limitations under the
   51.17 + * License.  When distributing the software, include this License Header
   51.18 + * Notice in each file and include the License file at
   51.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   51.20 + * particular file as subject to the "Classpath" exception as provided
   51.21 + * by Sun in the GPL Version 2 section of the License file that
   51.22 + * accompanied this code. If applicable, add the following below the
   51.23 + * License Header, with the fields enclosed by brackets [] replaced by
   51.24 + * your own identifying information:
   51.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   51.26 + *
   51.27 + * If you wish your version of this file to be governed by only the CDDL
   51.28 + * or only the GPL Version 2, indicate your decision by adding
   51.29 + * "[Contributor] elects to include this software in this distribution
   51.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   51.31 + * single choice of license, a recipient has the option to distribute
   51.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   51.33 + * to extend the choice of license to its licensees as provided above.
   51.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   51.35 + * Version 2 license, then the option applies only if the new code is
   51.36 + * made subject to such option by the copyright holder.
   51.37 + *
   51.38 + * Contributor(s):
   51.39 + *
   51.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   51.41 + */
   51.42 +package org.netbeans.modules.licensechanger.wizard;
   51.43 +
   51.44 +import java.util.Comparator;
   51.45 +import java.util.Set;
   51.46 +import java.util.TreeSet;
   51.47 +import org.netbeans.modules.licensechanger.wizard.utils.FolderChildren;
   51.48 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   51.49 +import org.netbeans.swing.outline.DefaultOutlineModel;
   51.50 +import org.openide.explorer.ExplorerManager;
   51.51 +import org.openide.explorer.view.CheckableNode;
   51.52 +import org.openide.explorer.view.OutlineView;
   51.53 +import org.openide.filesystems.FileObject;
   51.54 +import org.openide.nodes.AbstractNode;
   51.55 +import org.openide.nodes.Children;
   51.56 +import org.openide.nodes.Node;
   51.57 +
   51.58 +/**
   51.59 + *
   51.60 + * @author Tim Boudreau
   51.61 + * @author Nils Hoffmann (Refactoring)
   51.62 + */
   51.63 +public class SelectFoldersPanel extends javax.swing.JPanel implements ExplorerManager.Provider {
   51.64 +    
   51.65 +    private final ExplorerManager mgr = new ExplorerManager();
   51.66 +    
   51.67 +    public SelectFoldersPanel() {
   51.68 +        initComponents();
   51.69 +        updateView();
   51.70 +        setName("Select Folders");
   51.71 +    }
   51.72 +    
   51.73 +    private void updateFolders() {
   51.74 +        Set<FileObject> folders = getSelectedFolders();
   51.75 +//        System.out.println("Selected folders: " + folders);
   51.76 +        firePropertyChange(WizardProperties.KEY_FOLDERS, null, folders);
   51.77 +    }
   51.78 +    
   51.79 +    private void enableUI() {
   51.80 +        jLabel1.setEnabled(true);
   51.81 +        updateView();
   51.82 +    }
   51.83 +
   51.84 +    /**
   51.85 +     * This method is called from within the constructor to initialize the form.
   51.86 +     * WARNING: Do NOT modify this code. The content of this method is always
   51.87 +     * regenerated by the Form Editor.
   51.88 +     */
   51.89 +    @SuppressWarnings("unchecked")
   51.90 +    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   51.91 +    private void initComponents() {
   51.92 +
   51.93 +        jScrollPane1 = new OutlineView();
   51.94 +        jLabel1 = new javax.swing.JLabel();
   51.95 +
   51.96 +        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("controlShadow")));
   51.97 +
   51.98 +        jLabel1.setText(org.openide.util.NbBundle.getMessage(SelectFoldersPanel.class, "SelectFoldersPanel.jLabel1.text")); // NOI18N
   51.99 +
  51.100 +        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  51.101 +        this.setLayout(layout);
  51.102 +        layout.setHorizontalGroup(
  51.103 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  51.104 +            .addGroup(layout.createSequentialGroup()
  51.105 +                .addContainerGap()
  51.106 +                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  51.107 +                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
  51.108 +                    .addComponent(jLabel1))
  51.109 +                .addContainerGap())
  51.110 +        );
  51.111 +        layout.setVerticalGroup(
  51.112 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  51.113 +            .addGroup(layout.createSequentialGroup()
  51.114 +                .addContainerGap()
  51.115 +                .addComponent(jLabel1)
  51.116 +                .addGap(9, 9, 9)
  51.117 +                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)
  51.118 +                .addContainerGap())
  51.119 +        );
  51.120 +    }// </editor-fold>//GEN-END:initComponents
  51.121 +    // Variables declaration - do not modify//GEN-BEGIN:variables
  51.122 +    private javax.swing.JLabel jLabel1;
  51.123 +    private javax.swing.JScrollPane jScrollPane1;
  51.124 +    // End of variables declaration//GEN-END:variables
  51.125 +
  51.126 +    @Override
  51.127 +    public ExplorerManager getExplorerManager() {
  51.128 +        return mgr;
  51.129 +    }
  51.130 +    
  51.131 +    public void setRootFiles(Set<FileObject> roots) {
  51.132 +        AbstractNode root = new AbstractNode(Children.create(new FolderChildren(roots.toArray(new FileObject[roots.size()])) {
  51.133 +            @Override
  51.134 +            public void onAllNodesCreated() {
  51.135 +                enableUI();
  51.136 +                updateFolders();
  51.137 +            }
  51.138 +        }, true));
  51.139 +        mgr.setRootContext(root);
  51.140 +        firePropertyChange("rootFiles", null, roots);
  51.141 +    }
  51.142 +    
  51.143 +    public Set<FileObject> getSelectedFolders() {
  51.144 +        Set<FileObject> folders = new TreeSet<FileObject>(new Comparator<FileObject>() {
  51.145 +            @Override
  51.146 +            public int compare(FileObject t, FileObject t1) {
  51.147 +                return t.getPath().compareTo(t1.getPath());
  51.148 +            }
  51.149 +        });
  51.150 +        for (Node n : mgr.getRootContext().getChildren().getNodes(true)) {
  51.151 +            CheckableNode cn = n.getLookup().lookup(CheckableNode.class);
  51.152 +            if (cn != null && cn.isSelected()) {
  51.153 +                FileObject f = n.getLookup().lookup(FileObject.class);
  51.154 +                if (f != null) {
  51.155 +                    folders.add(f);
  51.156 +                }
  51.157 +            }
  51.158 +        }
  51.159 +        return folders;
  51.160 +    }
  51.161 +    
  51.162 +    private void updateView() {
  51.163 +        OutlineView ov = (OutlineView) jScrollPane1;
  51.164 +        ov.getOutline().setRootVisible(false);
  51.165 +        ov.setPopupAllowed(false);
  51.166 +        ov.setTreeSortable(false);
  51.167 +        String headerName = org.openide.util.NbBundle.getMessage(SelectFoldersPanel.class, "SelectFoldersPanel.nodesLabel.text"); // NOI18N
  51.168 +        ((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(headerName);
  51.169 +        setName("Select Folders");
  51.170 +    }
  51.171 +}
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/SelectFoldersWizardPanel.java	Fri Jan 04 15:27:42 2013 +0100
    52.3 @@ -0,0 +1,152 @@
    52.4 +/*
    52.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    52.6 + *
    52.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    52.8 + *
    52.9 + * The contents of this file are subject to the terms of either the GNU
   52.10 + * General Public License Version 2 only ("GPL") or the Common
   52.11 + * Development and Distribution License("CDDL") (collectively, the
   52.12 + * "License"). You may not use this file except in compliance with the
   52.13 + * License. You can obtain a copy of the License at
   52.14 + * http://www.netbeans.org/cddl-gplv2.html
   52.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   52.16 + * specific language governing permissions and limitations under the
   52.17 + * License.  When distributing the software, include this License Header
   52.18 + * Notice in each file and include the License file at
   52.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   52.20 + * particular file as subject to the "Classpath" exception as provided
   52.21 + * by Sun in the GPL Version 2 section of the License file that
   52.22 + * accompanied this code. If applicable, add the following below the
   52.23 + * License Header, with the fields enclosed by brackets [] replaced by
   52.24 + * your own identifying information:
   52.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   52.26 + *
   52.27 + * If you wish your version of this file to be governed by only the CDDL
   52.28 + * or only the GPL Version 2, indicate your decision by adding
   52.29 + * "[Contributor] elects to include this software in this distribution
   52.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   52.31 + * single choice of license, a recipient has the option to distribute
   52.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   52.33 + * to extend the choice of license to its licensees as provided above.
   52.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   52.35 + * Version 2 license, then the option applies only if the new code is
   52.36 + * made subject to such option by the copyright holder.
   52.37 + *
   52.38 + * Contributor(s):
   52.39 + *
   52.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   52.41 + */
   52.42 +package org.netbeans.modules.licensechanger.wizard;
   52.43 +
   52.44 +import java.beans.PropertyChangeEvent;
   52.45 +import java.beans.PropertyChangeListener;
   52.46 +import java.util.Set;
   52.47 +import javax.swing.event.ChangeListener;
   52.48 +import org.netbeans.modules.licensechanger.wizard.utils.WizardProperties;
   52.49 +import org.openide.WizardDescriptor;
   52.50 +import org.openide.WizardValidationException;
   52.51 +import org.openide.filesystems.FileObject;
   52.52 +import org.openide.util.ChangeSupport;
   52.53 +import org.openide.util.HelpCtx;
   52.54 +
   52.55 +/**
   52.56 + *
   52.57 + * @author Nils Hoffmann
   52.58 + */
   52.59 +public class SelectFoldersWizardPanel implements WizardDescriptor.ValidatingPanel<WizardDescriptor>, PropertyChangeListener {
   52.60 +
   52.61 +    /**
   52.62 +     * The visual component that displays this panel. If you need to access the
   52.63 +     * component from this class, just use getComponent().
   52.64 +     */
   52.65 +    private SelectFoldersPanel component;
   52.66 +    private WizardDescriptor wiz;
   52.67 +    private boolean valid = false;
   52.68 +    private ChangeSupport cs = new ChangeSupport(this);
   52.69 +
   52.70 +    // Get the visual component for the panel. In this template, the component
   52.71 +    // is kept separate. This can be more efficient: if the wizard is created
   52.72 +    // but never displayed, or not all panels are displayed, it is better to
   52.73 +    // create only those which really need to be visible.
   52.74 +    @Override
   52.75 +    public SelectFoldersPanel getComponent() {
   52.76 +        if (component == null) {
   52.77 +            component = new SelectFoldersPanel();
   52.78 +            component.addPropertyChangeListener(this);
   52.79 +        }
   52.80 +        return component;
   52.81 +    }
   52.82 +
   52.83 +    @Override
   52.84 +    public HelpCtx getHelp() {
   52.85 +        // Show no Help button for this panel:
   52.86 +        return HelpCtx.DEFAULT_HELP;
   52.87 +        // If you have context help:
   52.88 +        // return new HelpCtx("help.key.here");
   52.89 +    }
   52.90 +
   52.91 +    @Override
   52.92 +    public boolean isValid() {
   52.93 +        return valid;
   52.94 +    }
   52.95 +
   52.96 +    @Override
   52.97 +    public void addChangeListener(ChangeListener l) {
   52.98 +        cs.addChangeListener(l);
   52.99 +    }
  52.100 +
  52.101 +    @Override
  52.102 +    public void removeChangeListener(ChangeListener l) {
  52.103 +        cs.removeChangeListener(l);
  52.104 +    }
  52.105 +
  52.106 +    @Override
  52.107 +    public void propertyChange(PropertyChangeEvent pce) {
  52.108 +        cs.fireChange();
  52.109 +        try {
  52.110 +            validate();
  52.111 +        } catch (WizardValidationException ex) {
  52.112 +            if (wiz != null) {
  52.113 +                wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, ex.getMessage());
  52.114 +            }
  52.115 +        }
  52.116 +    }
  52.117 +
  52.118 +    @Override
  52.119 +    public void readSettings(WizardDescriptor wiz) {
  52.120 +        this.wiz = wiz;
  52.121 +        @SuppressWarnings("unchecked")
  52.122 +        Set<FileObject> folders = (Set<FileObject>) wiz.getProperty(WizardProperties.KEY_FOLDERS);
  52.123 +        if (folders == null || folders.isEmpty()) {
  52.124 +            Object obj = wiz.getProperty(WizardProperties.KEY_ROOT_FILES);
  52.125 +            if (obj != null) {
  52.126 +                @SuppressWarnings("unchecked")
  52.127 +                Set<FileObject> sobj = (Set<FileObject>) obj;
  52.128 +                getComponent().setRootFiles(sobj);
  52.129 +            }
  52.130 +        } else {
  52.131 +            getComponent().setRootFiles(folders);
  52.132 +        }
  52.133 +    }
  52.134 +
  52.135 +    @Override
  52.136 +    public void storeSettings(WizardDescriptor wiz) {
  52.137 +        Set<FileObject> folders = getComponent().getSelectedFolders();
  52.138 +        wiz.putProperty(WizardProperties.KEY_FOLDERS, folders);
  52.139 +    }
  52.140 +
  52.141 +    @Override
  52.142 +    public void validate() throws WizardValidationException {
  52.143 +        valid = true;
  52.144 +        Set<FileObject> folders = getComponent().getSelectedFolders();
  52.145 +        if (folders == null || folders.isEmpty()) {
  52.146 +            valid = false;
  52.147 +            throw new WizardValidationException(component, "Please select at least one folder!", null);
  52.148 +        }
  52.149 +        if (wiz != null) {
  52.150 +            wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
  52.151 +            wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, null);
  52.152 +            wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
  52.153 +        }
  52.154 +    }
  52.155 +}
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/Bundle.properties	Fri Jan 04 15:27:42 2013 +0100
    53.3 @@ -0,0 +1,1 @@
    53.4 +MSG_WAIT_FOLDERS=Scanning for folders, please wait...
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/CheckableNodeCapability.java	Fri Jan 04 15:27:42 2013 +0100
    54.3 @@ -0,0 +1,74 @@
    54.4 +/*
    54.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    54.6 + *
    54.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    54.8 + *
    54.9 + * The contents of this file are subject to the terms of either the GNU
   54.10 + * General Public License Version 2 only ("GPL") or the Common
   54.11 + * Development and Distribution License("CDDL") (collectively, the
   54.12 + * "License"). You may not use this file except in compliance with the
   54.13 + * License. You can obtain a copy of the License at
   54.14 + * http://www.netbeans.org/cddl-gplv2.html
   54.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   54.16 + * specific language governing permissions and limitations under the
   54.17 + * License.  When distributing the software, include this License Header
   54.18 + * Notice in each file and include the License file at
   54.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   54.20 + * particular file as subject to the "Classpath" exception as provided
   54.21 + * by Sun in the GPL Version 2 section of the License file that
   54.22 + * accompanied this code. If applicable, add the following below the
   54.23 + * License Header, with the fields enclosed by brackets [] replaced by
   54.24 + * your own identifying information:
   54.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   54.26 + *
   54.27 + * If you wish your version of this file to be governed by only the CDDL
   54.28 + * or only the GPL Version 2, indicate your decision by adding
   54.29 + * "[Contributor] elects to include this software in this distribution
   54.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   54.31 + * single choice of license, a recipient has the option to distribute
   54.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   54.33 + * to extend the choice of license to its licensees as provided above.
   54.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   54.35 + * Version 2 license, then the option applies only if the new code is
   54.36 + * made subject to such option by the copyright holder.
   54.37 + *
   54.38 + * Contributor(s):
   54.39 + *
   54.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   54.41 + */
   54.42 +package org.netbeans.modules.licensechanger.wizard.utils;
   54.43 +
   54.44 +import org.openide.explorer.view.CheckableNode;
   54.45 +
   54.46 +/**
   54.47 + * Implements {@link CheckableNode} to allow display and use of checkable nodes
   54.48 + * in views.
   54.49 + *
   54.50 + * @author Nils Hoffmann
   54.51 + */
   54.52 +public class CheckableNodeCapability implements CheckableNode {
   54.53 +
   54.54 +    private boolean checkable = true;
   54.55 +    private boolean checkEnabled = true;
   54.56 +    private boolean selected = true;
   54.57 +
   54.58 +    @Override
   54.59 +    public boolean isCheckable() {
   54.60 +        return checkable;
   54.61 +    }
   54.62 +
   54.63 +    @Override
   54.64 +    public boolean isCheckEnabled() {
   54.65 +        return checkEnabled;
   54.66 +    }
   54.67 +
   54.68 +    @Override
   54.69 +    public Boolean isSelected() {
   54.70 +        return selected;
   54.71 +    }
   54.72 +
   54.73 +    @Override
   54.74 +    public void setSelected(Boolean selected) {
   54.75 +        this.selected = selected.booleanValue();
   54.76 +    }
   54.77 +}
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/FileChildren.java	Fri Jan 04 15:27:42 2013 +0100
    55.3 @@ -0,0 +1,153 @@
    55.4 +/*
    55.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    55.6 + *
    55.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    55.8 + *
    55.9 + * The contents of this file are subject to the terms of either the GNU
   55.10 + * General Public License Version 2 only ("GPL") or the Common
   55.11 + * Development and Distribution License("CDDL") (collectively, the
   55.12 + * "License"). You may not use this file except in compliance with the
   55.13 + * License. You can obtain a copy of the License at
   55.14 + * http://www.netbeans.org/cddl-gplv2.html
   55.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   55.16 + * specific language governing permissions and limitations under the
   55.17 + * License.  When distributing the software, include this License Header
   55.18 + * Notice in each file and include the License file at
   55.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   55.20 + * particular file as subject to the "Classpath" exception as provided
   55.21 + * by Sun in the GPL Version 2 section of the License file that
   55.22 + * accompanied this code. If applicable, add the following below the
   55.23 + * License Header, with the fields enclosed by brackets [] replaced by
   55.24 + * your own identifying information:
   55.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   55.26 + *
   55.27 + * If you wish your version of this file to be governed by only the CDDL
   55.28 + * or only the GPL Version 2, indicate your decision by adding
   55.29 + * "[Contributor] elects to include this software in this distribution
   55.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   55.31 + * single choice of license, a recipient has the option to distribute
   55.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   55.33 + * to extend the choice of license to its licensees as provided above.
   55.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   55.35 + * Version 2 license, then the option applies only if the new code is
   55.36 + * made subject to such option by the copyright holder.
   55.37 + *
   55.38 + * Contributor(s):
   55.39 + *
   55.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   55.41 + */
   55.42 +package org.netbeans.modules.licensechanger.wizard.utils;
   55.43 +
   55.44 +import java.util.Collection;
   55.45 +import java.util.Collections;
   55.46 +import java.util.HashSet;
   55.47 +import java.util.LinkedList;
   55.48 +import java.util.List;
   55.49 +import java.util.Set;
   55.50 +import javax.swing.Action;
   55.51 +import org.netbeans.modules.licensechanger.api.FileHandler;
   55.52 +import org.openide.filesystems.FileObject;
   55.53 +import org.openide.loaders.DataObject;
   55.54 +import org.openide.loaders.DataObjectNotFoundException;
   55.55 +import org.openide.nodes.ChildFactory;
   55.56 +import org.openide.nodes.FilterNode;
   55.57 +import org.openide.nodes.Node;
   55.58 +import org.openide.util.Exceptions;
   55.59 +import org.openide.util.lookup.Lookups;
   55.60 +import org.openide.util.lookup.ProxyLookup;
   55.61 +
   55.62 +/**
   55.63 + *
   55.64 + * @author Tim Boudreau (original author)
   55.65 + * @author Nils Hoffmann (changed to use CheckableNodeCapability)
   55.66 + */
   55.67 +public class FileChildren extends ChildFactory.Detachable<FileObject> {
   55.68 +
   55.69 +    private final Set<FileObject> folders;
   55.70 +    private final Collection<? extends FileHandler> allHandlers;
   55.71 +    private final Set<FileItem> items = Collections.synchronizedSet(new HashSet<FileItem>());
   55.72 +
   55.73 +    public FileChildren(Set<FileObject> folders, Set<FileHandler> fileHandler) {
   55.74 +        assert folders != null;
   55.75 +        this.folders = new HashSet<FileObject>(folders);
   55.76 +        allHandlers = fileHandler;//Lookup.getDefault().lookupAll(FileHandler.class);
   55.77 +        //settings.put(WizardProperties.KEY_ITEMS, items);
   55.78 +    }
   55.79 +
   55.80 +    @Override
   55.81 +    protected boolean createKeys(List<FileObject> toPopulate) {
   55.82 +        toPopulate.addAll(folders);
   55.83 +        return true;
   55.84 +    }
   55.85 +
   55.86 +    @Override
   55.87 +    protected Node[] createNodesForKey(FileObject key) {
   55.88 +        List<Node> result = new LinkedList<Node>();
   55.89 +        for (FileObject fo : key.getChildren()) {
   55.90 +            if (fo.isData()) {
   55.91 +                for (FileHandler h : allHandlers) {
   55.92 +                    if (h.match(fo)) {
   55.93 +                        try {
   55.94 +                            DataObject dob = DataObject.find(fo);
   55.95 +                            FileItem item = new FileItem(h, fo);
   55.96 +                            items.add(item);
   55.97 +                            FN fn = new FN(dob.getNodeDelegate(), item);
   55.98 +                            boolean shouldChange = !h.shouldSkipFile(fo);
   55.99 +                            result.add(fn);
  55.100 +//                            fn.setValue (CheckboxListView.SELECTED, shouldChange);
  55.101 +                            break;
  55.102 +                        } catch (DataObjectNotFoundException ex) {
  55.103 +                            Exceptions.printStackTrace(ex);
  55.104 +                        }
  55.105 +                    }
  55.106 +                }
  55.107 +            }
  55.108 +        }
  55.109 +        return result.toArray(new Node[result.size()]);
  55.110 +    }
  55.111 +
  55.112 +    public static final class FileItem {
  55.113 +
  55.114 +        FileHandler handler;
  55.115 +        FileObject file;
  55.116 +
  55.117 +        public FileItem(FileHandler handler, FileObject file) {
  55.118 +            this.handler = handler;
  55.119 +            this.file = file;
  55.120 +        }
  55.121 +
  55.122 +        public FileObject getFile() {
  55.123 +            return file;
  55.124 +        }
  55.125 +
  55.126 +        public FileHandler getHandler() {
  55.127 +            return handler;
  55.128 +        }
  55.129 +    }
  55.130 +
  55.131 +    private static final class FN extends FilterNode {
  55.132 +
  55.133 +        FN(Node orig, FileItem item) {
  55.134 +            super(orig, Children.LEAF, new ProxyLookup(
  55.135 +                    Lookups.fixed(item, new CheckableNodeCapability()),
  55.136 +                    orig.getLookup()));
  55.137 +            disableDelegation(DELEGATE_GET_ACTIONS);
  55.138 +            disableDelegation(DELEGATE_GET_CONTEXT_ACTIONS);
  55.139 +            disableDelegation(DELEGATE_SET_DISPLAY_NAME);
  55.140 +            disableDelegation(DELEGATE_GET_DISPLAY_NAME);
  55.141 +            disableDelegation(DELEGATE_GET_VALUE);
  55.142 +            disableDelegation(DELEGATE_SET_VALUE);
  55.143 +            disableDelegation(DELEGATE_SET_NAME);
  55.144 +            disableDelegation(DELEGATE_GET_NAME);
  55.145 +//            setValue(CheckboxListView.SELECTED, Boolean.TRUE);
  55.146 +            setName(item.file.getPath());
  55.147 +            setDisplayName(item.file.getPath());
  55.148 +            setShortDescription(item.file.getPath());
  55.149 +        }
  55.150 +
  55.151 +        @Override
  55.152 +        public Action[] getActions(boolean ignored) {
  55.153 +            return new Action[0];
  55.154 +        }
  55.155 +    }
  55.156 +}
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/FileLoader.java	Fri Jan 04 15:27:42 2013 +0100
    56.3 @@ -0,0 +1,80 @@
    56.4 +/*
    56.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    56.6 + *
    56.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    56.8 + *
    56.9 + * The contents of this file are subject to the terms of either the GNU
   56.10 + * General Public License Version 2 only ("GPL") or the Common
   56.11 + * Development and Distribution License("CDDL") (collectively, the
   56.12 + * "License"). You may not use this file except in compliance with the
   56.13 + * License. You can obtain a copy of the License at
   56.14 + * http://www.netbeans.org/cddl-gplv2.html
   56.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   56.16 + * specific language governing permissions and limitations under the
   56.17 + * License.  When distributing the software, include this License Header
   56.18 + * Notice in each file and include the License file at
   56.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   56.20 + * particular file as subject to the "Classpath" exception as provided
   56.21 + * by Sun in the GPL Version 2 section of the License file that
   56.22 + * accompanied this code. If applicable, add the following below the
   56.23 + * License Header, with the fields enclosed by brackets [] replaced by
   56.24 + * your own identifying information:
   56.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   56.26 + *
   56.27 + * If you wish your version of this file to be governed by only the CDDL
   56.28 + * or only the GPL Version 2, indicate your decision by adding
   56.29 + * "[Contributor] elects to include this software in this distribution
   56.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   56.31 + * single choice of license, a recipient has the option to distribute
   56.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   56.33 + * to extend the choice of license to its licensees as provided above.
   56.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   56.35 + * Version 2 license, then the option applies only if the new code is
   56.36 + * made subject to such option by the copyright holder.
   56.37 + *
   56.38 + * Contributor(s):
   56.39 + *
   56.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   56.41 + */
   56.42 +package org.netbeans.modules.licensechanger.wizard.utils;
   56.43 +
   56.44 +import java.io.BufferedInputStream;
   56.45 +import java.io.ByteArrayOutputStream;
   56.46 +import java.io.IOException;
   56.47 +import java.io.InputStream;
   56.48 +import java.io.UnsupportedEncodingException;
   56.49 +import java.nio.charset.Charset;
   56.50 +import org.netbeans.api.queries.FileEncodingQuery;
   56.51 +import org.openide.filesystems.FileObject;
   56.52 +import org.openide.filesystems.FileUtil;
   56.53 +
   56.54 +/**
   56.55 + * @author Tim Boudreau
   56.56 + * @author Nils Hoffmann (Refactoring)
   56.57 + */
   56.58 +public class FileLoader {
   56.59 +
   56.60 +    public static String loadFile(FileObject file) throws IOException {
   56.61 +        Charset encoding = FileEncodingQuery.getEncoding(file);
   56.62 +        InputStream in = new BufferedInputStream(file.getInputStream());
   56.63 +        ByteArrayOutputStream out = new ByteArrayOutputStream((int) file.getSize());
   56.64 +        try {
   56.65 +            FileUtil.copy(in, out);
   56.66 +            try {
   56.67 +                String result = new String(out.toByteArray(), encoding.name());
   56.68 +                String sep = System.getProperty("line.separator");
   56.69 +                //Convert everything internally to use \n
   56.70 +                if (!"\n".equals(sep) && sep != null) {
   56.71 +                    return result.replaceAll(sep, "\n");
   56.72 +                } else {
   56.73 +                    return result;
   56.74 +                }
   56.75 +            } catch (UnsupportedEncodingException q) {
   56.76 +                return new String(out.toByteArray(), FileEncodingQuery.getDefaultEncoding().name());
   56.77 +            }
   56.78 +        } finally {
   56.79 +            in.close();
   56.80 +            out.close();
   56.81 +        }
   56.82 +    }
   56.83 +}
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/FolderChildren.java	Fri Jan 04 15:27:42 2013 +0100
    57.3 @@ -0,0 +1,185 @@
    57.4 +/*
    57.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    57.6 + *
    57.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    57.8 + *
    57.9 + * The contents of this file are subject to the terms of either the GNU
   57.10 + * General Public License Version 2 only ("GPL") or the Common
   57.11 + * Development and Distribution License("CDDL") (collectively, the
   57.12 + * "License"). You may not use this file except in compliance with the
   57.13 + * License. You can obtain a copy of the License at
   57.14 + * http://www.netbeans.org/cddl-gplv2.html
   57.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   57.16 + * specific language governing permissions and limitations under the
   57.17 + * License.  When distributing the software, include this License Header
   57.18 + * Notice in each file and include the License file at
   57.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   57.20 + * particular file as subject to the "Classpath" exception as provided
   57.21 + * by Sun in the GPL Version 2 section of the License file that
   57.22 + * accompanied this code. If applicable, add the following below the
   57.23 + * License Header, with the fields enclosed by brackets [] replaced by
   57.24 + * your own identifying information:
   57.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   57.26 + *
   57.27 + * If you wish your version of this file to be governed by only the CDDL
   57.28 + * or only the GPL Version 2, indicate your decision by adding
   57.29 + * "[Contributor] elects to include this software in this distribution
   57.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   57.31 + * single choice of license, a recipient has the option to distribute
   57.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   57.33 + * to extend the choice of license to its licensees as provided above.
   57.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   57.35 + * Version 2 license, then the option applies only if the new code is
   57.36 + * made subject to such option by the copyright holder.
   57.37 + *
   57.38 + * Contributor(s):
   57.39 + *
   57.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   57.41 + */
   57.42 +package org.netbeans.modules.licensechanger.wizard.utils;
   57.43 +
   57.44 +import java.awt.EventQueue;
   57.45 +import java.util.List;
   57.46 +import javax.swing.Action;
   57.47 +import org.openide.explorer.view.CheckableNode;
   57.48 +import org.openide.filesystems.FileObject;
   57.49 +import org.openide.filesystems.FileUtil;
   57.50 +import org.openide.loaders.DataObject;
   57.51 +import org.openide.loaders.DataObjectNotFoundException;
   57.52 +import org.openide.nodes.AbstractNode;
   57.53 +import org.openide.nodes.ChildFactory;
   57.54 +import org.openide.nodes.Children;
   57.55 +import org.openide.nodes.FilterNode;
   57.56 +import org.openide.nodes.Node;
   57.57 +import org.openide.util.Exceptions;
   57.58 +import org.openide.util.NbBundle;
   57.59 +import org.openide.util.NbCollections;
   57.60 +import org.openide.util.lookup.Lookups;
   57.61 +import org.openide.util.lookup.ProxyLookup;
   57.62 +
   57.63 +/**
   57.64 + *
   57.65 + * @author Tim Boudreau (original author)
   57.66 + * @author Nils Hoffmann (changed to use CheckableNodeCapability)
   57.67 + */
   57.68 +public abstract class FolderChildren extends ChildFactory.Detachable<FileObject> implements Runnable {
   57.69 +
   57.70 +    private FileObject[] roots;
   57.71 +    volatile int keyCount = 0;
   57.72 +    private int nodeCount = 0;
   57.73 +    private volatile boolean cancelled = false;
   57.74 +
   57.75 +    public FolderChildren(FileObject[] roots) {
   57.76 +        this.roots = roots;
   57.77 +    }
   57.78 +
   57.79 +    @Override
   57.80 +    protected Node createWaitNode() {
   57.81 +        AbstractNode result = new AbstractNode(Children.LEAF);
   57.82 +        result.setDisplayName(NbBundle.getMessage(FolderChildren.class, "MSG_WAIT_FOLDERS"));
   57.83 +        return result;
   57.84 +    }
   57.85 +
   57.86 +    @Override
   57.87 +    public void addNotify() {
   57.88 +        cancelled = false;
   57.89 +        super.addNotify();
   57.90 +        keyCount = 0;
   57.91 +        nodeCount = 0;
   57.92 +    }
   57.93 +
   57.94 +    @Override
   57.95 +    protected void removeNotify() {
   57.96 +        super.removeNotify();
   57.97 +        cancelled = true;
   57.98 +    }
   57.99 +
  57.100 +    private boolean shouldSkipFolder(FileObject folder) {
  57.101 +        // XXX use VisibilityQuery instead
  57.102 +        String path = folder.getPath();
  57.103 +        return path.contains(".svn") || path.contains(".cvs") || path.contains(".hg")
  57.104 +                || path.endsWith(".svn") || path.endsWith(".cvs") || path.endsWith(".hg")
  57.105 +                || path.contains("target") || path.endsWith("target") || path.contains("build") || path.endsWith("build");
  57.106 +    }
  57.107 +
  57.108 +    @Override
  57.109 +    protected boolean createKeys(List<FileObject> toPopulate) {
  57.110 +        for (FileObject f : roots) {
  57.111 +            toPopulate.add(f);
  57.112 +            keyCount++;
  57.113 +            for (FileObject fo : NbCollections.iterable(f.getChildren(true))) {
  57.114 +                if (fo.isFolder()) {
  57.115 +                    if (shouldSkipFolder(fo)) {
  57.116 +                        continue;
  57.117 +                    }
  57.118 +                    toPopulate.add(fo);
  57.119 +                    keyCount++;
  57.120 +                }
  57.121 +                if (cancelled) {
  57.122 +                    return true;
  57.123 +                }
  57.124 +            }
  57.125 +            if (cancelled) {
  57.126 +                return true;
  57.127 +            }
  57.128 +        }
  57.129 +        return true;
  57.130 +    }
  57.131 +
  57.132 +    @Override
  57.133 +    protected Node createNodeForKey(FileObject f) {
  57.134 +        try {
  57.135 +            Node n = DataObject.find(f).getNodeDelegate();
  57.136 +            nodeCount++;
  57.137 +            if (nodeCount == keyCount) {
  57.138 +                EventQueue.invokeLater(this);
  57.139 +            }
  57.140 +            return new FN(n, f);
  57.141 +        } catch (DataObjectNotFoundException ex) {
  57.142 +            Exceptions.printStackTrace(ex);
  57.143 +            return null;
  57.144 +        }
  57.145 +    }
  57.146 +
  57.147 +    public abstract void onAllNodesCreated();
  57.148 +
  57.149 +    @Override
  57.150 +    public void run() {
  57.151 +        onAllNodesCreated();
  57.152 +    }
  57.153 +
  57.154 +    private static final class FN extends FilterNode {
  57.155 +
  57.156 +        FN(Node orig, FileObject f) {
  57.157 +            super(orig, Children.LEAF, new ProxyLookup(
  57.158 +                    Lookups.fixed(f, new CheckableNodeCapability()),
  57.159 +                    orig.getLookup()));
  57.160 +            disableDelegation(DELEGATE_GET_ACTIONS);
  57.161 +            disableDelegation(DELEGATE_GET_CONTEXT_ACTIONS);
  57.162 +            disableDelegation(DELEGATE_SET_DISPLAY_NAME);
  57.163 +            disableDelegation(DELEGATE_GET_DISPLAY_NAME);
  57.164 +            disableDelegation(DELEGATE_GET_VALUE);
  57.165 +            disableDelegation(DELEGATE_SET_VALUE);
  57.166 +            disableDelegation(DELEGATE_SET_NAME);
  57.167 +            disableDelegation(DELEGATE_GET_NAME);
  57.168 +            String p = f.getPath();
  57.169 +            // XXX this is a pretty arbitrary list... maybe check SharabilityQuery?
  57.170 +            if (!p.endsWith("nbproject")
  57.171 +                    && !p.endsWith("nbproject/private")) { //NOI18N
  57.172 +//                setValue (CheckboxListView.SELECTED, Boolean.TRUE);
  57.173 +            } else {
  57.174 +                CheckableNode cn = getLookup().lookup(CheckableNode.class);
  57.175 +                if (cn != null) {
  57.176 +                    cn.setSelected(false);
  57.177 +                }
  57.178 +            }
  57.179 +            setName(p);
  57.180 +            setDisplayName(FileUtil.getFileDisplayName(f));
  57.181 +        }
  57.182 +
  57.183 +        @Override
  57.184 +        public Action[] getActions(boolean ignored) {
  57.185 +            return new Action[0];
  57.186 +        }
  57.187 +    }
  57.188 +}
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/LicenseChangerRunnable.java	Fri Jan 04 15:27:42 2013 +0100
    58.3 @@ -0,0 +1,225 @@
    58.4 +/*
    58.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    58.6 + *
    58.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    58.8 + *
    58.9 + * The contents of this file are subject to the terms of either the GNU
   58.10 + * General Public License Version 2 only ("GPL") or the Common
   58.11 + * Development and Distribution License("CDDL") (collectively, the
   58.12 + * "License"). You may not use this file except in compliance with the
   58.13 + * License. You can obtain a copy of the License at
   58.14 + * http://www.netbeans.org/cddl-gplv2.html
   58.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   58.16 + * specific language governing permissions and limitations under the
   58.17 + * License.  When distributing the software, include this License Header
   58.18 + * Notice in each file and include the License file at
   58.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   58.20 + * particular file as subject to the "Classpath" exception as provided
   58.21 + * by Sun in the GPL Version 2 section of the License file that
   58.22 + * accompanied this code. If applicable, add the following below the
   58.23 + * License Header, with the fields enclosed by brackets [] replaced by
   58.24 + * your own identifying information:
   58.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   58.26 + *
   58.27 + * If you wish your version of this file to be governed by only the CDDL
   58.28 + * or only the GPL Version 2, indicate your decision by adding
   58.29 + * "[Contributor] elects to include this software in this distribution
   58.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   58.31 + * single choice of license, a recipient has the option to distribute
   58.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   58.33 + * to extend the choice of license to its licensees as provided above.
   58.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   58.35 + * Version 2 license, then the option applies only if the new code is
   58.36 + * made subject to such option by the copyright holder.
   58.37 + *
   58.38 + * Contributor(s):
   58.39 + *
   58.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   58.41 + */
   58.42 +package org.netbeans.modules.licensechanger.wizard.utils;
   58.43 +
   58.44 +import java.io.*;
   58.45 +import java.nio.charset.Charset;
   58.46 +import java.util.Arrays;
   58.47 +import java.util.Set;
   58.48 +import org.netbeans.api.progress.ProgressHandle;
   58.49 +import org.netbeans.api.progress.ProgressHandleFactory;
   58.50 +import org.netbeans.api.project.*;
   58.51 +import org.netbeans.api.queries.FileEncodingQuery;
   58.52 +import org.netbeans.modules.licensechanger.wizard.LineEndingsPanel;
   58.53 +import org.netbeans.modules.maven.model.ModelOperation;
   58.54 +import org.netbeans.modules.maven.model.Utilities;
   58.55 +import org.netbeans.modules.maven.model.pom.POMModel;
   58.56 +import org.netbeans.modules.maven.model.pom.Properties;
   58.57 +import org.openide.WizardDescriptor;
   58.58 +import org.openide.filesystems.*;
   58.59 +import org.openide.util.EditableProperties;
   58.60 +import org.openide.util.Exceptions;
   58.61 +
   58.62 +/**
   58.63 + * @author Tim Boudreau
   58.64 + * @author Nils Hoffmann (Refactoring)
   58.65 + */
   58.66 +public class LicenseChangerRunnable implements Runnable {
   58.67 +
   58.68 +    private final WizardDescriptor wizard;
   58.69 +
   58.70 +    public LicenseChangerRunnable(WizardDescriptor wizard) {
   58.71 +        this.wizard = wizard;
   58.72 +    }
   58.73 +
   58.74 +    @Override
   58.75 +    public void run() {
   58.76 +        ProgressHandle handle = ProgressHandleFactory.createHandle("Changing license headers");
   58.77 +        try {
   58.78 +
   58.79 +            if ((Boolean) wizard.getProperty(WizardProperties.KEY_STORE_IN_USER_PROPERTIES)) {
   58.80 +                ProjectManager.mutex().writeAccess(new Runnable() {
   58.81 +                    @Override
   58.82 +                    public void run() {
   58.83 +                        String copyrightHolder = (String) wizard.getProperty(WizardProperties.KEY_COPYRIGHT_HOLDER);
   58.84 +                        if (copyrightHolder != null && !copyrightHolder.trim().isEmpty()) {
   58.85 +                            try {
   58.86 +                                //store value of copyright holder in User.properties
   58.87 +                                FileObject userProperties = FileUtil.getConfigFile("Templates/Properties/User.properties");
   58.88 +                                java.util.Properties props = new java.util.Properties();
   58.89 +                                InputStream in = null;
   58.90 +                                try {
   58.91 +                                    in = userProperties.getInputStream();
   58.92 +                                    props.load(in);
   58.93 +                                } catch (IOException ex) {
   58.94 +                                    Exceptions.printStackTrace(ex);
   58.95 +                                    throw new RuntimeException(ex);
   58.96 +                                } finally {
   58.97 +                                    if (in != null) {
   58.98 +                                        in.close();
   58.99 +                                    }
  58.100 +                                }
  58.101 +                                props.setProperty("user", copyrightHolder);
  58.102 +                                OutputStream out = null;
  58.103 +                                try {
  58.104 +                                    out = userProperties.getOutputStream();
  58.105 +                                    props.store(out, "Updated user by licensechanger plugin.");
  58.106 +                                } catch (IOException ex) {
  58.107 +                                    Exceptions.printStackTrace(ex);
  58.108 +                                    throw new RuntimeException(ex);
  58.109 +                                } finally {
  58.110 +                                    if (out != null) {
  58.111 +                                        out.close();
  58.112 +                                    }
  58.113 +                                }
  58.114 +                            } catch (IOException ex) {
  58.115 +                                Exceptions.printStackTrace(ex);
  58.116 +                            }
  58.117 +                        }
  58.118 +                    }
  58.119 +                });
  58.120 +            }
  58.121 +            @SuppressWarnings("unchecked")
  58.122 +            Set<FileChildren.FileItem> items = (Set<FileChildren.FileItem>) wizard.getProperty(WizardProperties.KEY_ITEMS);
  58.123 +            final String licenseText = (String) wizard.getProperty(WizardProperties.KEY_LICENSE_TEXT);
  58.124 +            final String licenseName = (String) wizard.getProperty(WizardProperties.KEY_LICENSE_NAME);
  58.125 +            int ix = 0;
  58.126 +            int max = items.size();
  58.127 +            handle.start(max);
  58.128 +            Charset enc;
  58.129 +            for (FileChildren.FileItem item : items) {
  58.130 +                handle.progress(item.getFile().getNameExt(), ix);
  58.131 +                try {
  58.132 +                    String content = FileLoader.loadFile(item.file);
  58.133 +                    String nue = item.handler.transform(content, licenseText, wizard.getProperties());
  58.134 +                    LineEndingPreference pref = LineEndingsPanel.getLineEndingPrefs();
  58.135 +                    nue = LineEndingPreference.convertLineEndings(pref, content, nue);
  58.136 +
  58.137 +                    enc = FileEncodingQuery.getEncoding(item.file);
  58.138 +                    byte[] bytes;
  58.139 +                    try {
  58.140 +                        bytes = nue.getBytes(enc.name());
  58.141 +                    } catch (UnsupportedEncodingException e) {
  58.142 +                        //properties files get resource_bundle_charset
  58.143 +                        bytes = nue.getBytes(FileEncodingQuery.getDefaultEncoding().name());
  58.144 +                    }
  58.145 +                    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
  58.146 +                    BufferedOutputStream out = new BufferedOutputStream(item.file.getOutputStream());
  58.147 +                    try {
  58.148 +                        FileUtil.copy(in, out);
  58.149 +                    } finally {
  58.150 +                        out.close();
  58.151 +                        in.close();
  58.152 +                    }
  58.153 +                } catch (IOException ex) {
  58.154 +                    Exceptions.printStackTrace(ex);
  58.155 +                }
  58.156 +                ix++;
  58.157 +            }
  58.158 +            Boolean updateProjectLicense = (Boolean) wizard.getProperty(WizardProperties.KEY_UPDATE_DEFAULT_PROJECT_LICENSE);
  58.159 +            if (updateProjectLicense) {
  58.160 +//                System.out.println("Updating default license header!");
  58.161 +                Project project = (Project) wizard.getProperty(WizardProperties.KEY_PROJECT);
  58.162 +                Sources source = ProjectUtils.getSources(project);
  58.163 +                for (SourceGroup group : source.getSourceGroups(Sources.TYPE_GENERIC)) {
  58.164 +                    try {
  58.165 +                        FileObject nbprojectDir = group.getRootFolder().getFileObject("nbproject");
  58.166 +                        if (nbprojectDir != null) {
  58.167 +                            final FileObject projectProps = FileUtil.createData(nbprojectDir, "project.properties");
  58.168 +                            boolean hasProjectProperties = group.contains(projectProps);
  58.169 +                            if (hasProjectProperties) {
  58.170 +//                                System.out.println("Found project.properties at " + projectProps.getPath());
  58.171 +                                ProjectManager.mutex().writeAccess(new Runnable() {
  58.172 +                                    @Override
  58.173 +                                    public void run() {
  58.174 +                                        try {
  58.175 +                                            InputStream istream = projectProps.getInputStream();
  58.176 +                                            EditableProperties props = new EditableProperties(true);
  58.177 +                                            try {
  58.178 +                                                props.load(istream);
  58.179 +                                            } finally {
  58.180 +                                                istream.close();
  58.181 +                                            }
  58.182 +                                            props.setProperty("project.license", licenseName);
  58.183 +                                            OutputStream ostream = projectProps.getOutputStream();
  58.184 +                                            try {
  58.185 +                                                props.store(ostream);
  58.186 +                                            } finally {
  58.187 +                                                ostream.close();
  58.188 +                                            }
  58.189 +                                        } catch (IOException ex) {
  58.190 +                                            Exceptions.printStackTrace(ex);
  58.191 +                                        }
  58.192 +                                    }
  58.193 +                                });
  58.194 +
  58.195 +                            }
  58.196 +                        } else {
  58.197 +                            //check for pom.xml
  58.198 +                            FileObject pom = group.getRootFolder().getFileObject("pom.xml");
  58.199 +                            if (pom != null) {
  58.200 +//                                System.out.println("Found maven pom.xml at " + pom.getPath());
  58.201 +                                //found pom-based maven project
  58.202 +//                                String netbeansHintLicense = "<netbeans.hint.license>" + licenseName + "</netbeans.hint.license>";
  58.203 +//                                System.out.println("Please add " + netbeansHintLicense + " within your pom.xml <properties> section!");
  58.204 +                                Utilities.performPOMModelOperations(pom, Arrays.asList(new ModelOperation<POMModel>() {
  58.205 +                                    @Override
  58.206 +                                    public void performOperation(POMModel model) {
  58.207 +                                        Properties props = model.getProject().getProperties();
  58.208 +                                        if (props == null) {
  58.209 +                                            props = model.getFactory().createProperties();
  58.210 +                                            props.setProperty("netbeans.hint.license", licenseName);
  58.211 +                                            model.getProject().setProperties(props);
  58.212 +                                        } else {
  58.213 +                                            props.setProperty("netbeans.hint.license", licenseName);
  58.214 +                                        }
  58.215 +                                    }
  58.216 +                                }));
  58.217 +                            }
  58.218 +                        }
  58.219 +                    } catch (IOException ex) {
  58.220 +                        Exceptions.printStackTrace(ex);
  58.221 +                    }
  58.222 +                }
  58.223 +            }
  58.224 +        } finally {
  58.225 +            handle.finish();
  58.226 +        }
  58.227 +    }
  58.228 +}
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/LineEndingPreference.java	Fri Jan 04 15:27:42 2013 +0100
    59.3 @@ -0,0 +1,75 @@
    59.4 +/*
    59.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    59.6 + *
    59.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    59.8 + *
    59.9 + * The contents of this file are subject to the terms of either the GNU
   59.10 + * General Public License Version 2 only ("GPL") or the Common
   59.11 + * Development and Distribution License("CDDL") (collectively, the
   59.12 + * "License"). You may not use this file except in compliance with the
   59.13 + * License. You can obtain a copy of the License at
   59.14 + * http://www.netbeans.org/cddl-gplv2.html
   59.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   59.16 + * specific language governing permissions and limitations under the
   59.17 + * License.  When distributing the software, include this License Header
   59.18 + * Notice in each file and include the License file at
   59.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   59.20 + * particular file as subject to the "Classpath" exception as provided
   59.21 + * by Sun in the GPL Version 2 section of the License file that
   59.22 + * accompanied this code. If applicable, add the following below the
   59.23 + * License Header, with the fields enclosed by brackets [] replaced by
   59.24 + * your own identifying information:
   59.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   59.26 + *
   59.27 + * If you wish your version of this file to be governed by only the CDDL
   59.28 + * or only the GPL Version 2, indicate your decision by adding
   59.29 + * "[Contributor] elects to include this software in this distribution
   59.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   59.31 + * single choice of license, a recipient has the option to distribute
   59.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   59.33 + * to extend the choice of license to its licensees as provided above.
   59.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   59.35 + * Version 2 license, then the option applies only if the new code is
   59.36 + * made subject to such option by the copyright holder.
   59.37 + *
   59.38 + * Contributor(s):
   59.39 + *
   59.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   59.41 + */
   59.42 +package org.netbeans.modules.licensechanger.wizard.utils;
   59.43 +
   59.44 +/**
   59.45 + * User preference for line ending conversion
   59.46 + *
   59.47 + * @author Tim Boudreau
   59.48 + */
   59.49 +public enum LineEndingPreference {
   59.50 +
   59.51 +    FORCE_CRLF,
   59.52 +    NO_CHANGE,
   59.53 +    FORCE_NEWLINE,
   59.54 +    SYSTEM_DEFAULT;
   59.55 +
   59.56 +    public static String convertLineEndings(LineEndingPreference pref, String old, String nue) {
   59.57 +        boolean oldHasCrlf = old.contains("\r\n"); //NOI18N
   59.58 +        switch (pref) {
   59.59 +            case FORCE_CRLF:
   59.60 +                return nue.replaceAll("\n", "\r\n"); //NOI18N
   59.61 +            case FORCE_NEWLINE:
   59.62 +                //We already converted everything to newline only on load
   59.63 +                return nue;
   59.64 +            case NO_CHANGE:
   59.65 +                return oldHasCrlf ? nue.replaceAll("\n", "\r\n") : //NOI18N
   59.66 +                        nue;
   59.67 +            case SYSTEM_DEFAULT:
   59.68 +                String sep = System.getProperty("line.separator"); //NOI18N
   59.69 +                if ("\n".equals(sep)) {
   59.70 +                    return nue;
   59.71 +                } else {
   59.72 +                    return nue.replaceAll("\n", sep);//NOI18N
   59.73 +                }
   59.74 +            default:
   59.75 +                throw new AssertionError();
   59.76 +        }
   59.77 +    }
   59.78 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/wizard/utils/WizardProperties.java	Fri Jan 04 15:27:42 2013 +0100
    60.3 @@ -0,0 +1,64 @@
    60.4 +/*
    60.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    60.6 + *
    60.7 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
    60.8 + *
    60.9 + * The contents of this file are subject to the terms of either the GNU
   60.10 + * General Public License Version 2 only ("GPL") or the Common
   60.11 + * Development and Distribution License("CDDL") (collectively, the
   60.12 + * "License"). You may not use this file except in compliance with the
   60.13 + * License. You can obtain a copy of the License at
   60.14 + * http://www.netbeans.org/cddl-gplv2.html
   60.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   60.16 + * specific language governing permissions and limitations under the
   60.17 + * License.  When distributing the software, include this License Header
   60.18 + * Notice in each file and include the License file at
   60.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   60.20 + * particular file as subject to the "Classpath" exception as provided
   60.21 + * by Sun in the GPL Version 2 section of the License file that
   60.22 + * accompanied this code. If applicable, add the following below the
   60.23 + * License Header, with the fields enclosed by brackets [] replaced by
   60.24 + * your own identifying information:
   60.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   60.26 + *
   60.27 + * If you wish your version of this file to be governed by only the CDDL
   60.28 + * or only the GPL Version 2, indicate your decision by adding
   60.29 + * "[Contributor] elects to include this software in this distribution
   60.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   60.31 + * single choice of license, a recipient has the option to distribute
   60.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   60.33 + * to extend the choice of license to its licensees as provided above.
   60.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   60.35 + * Version 2 license, then the option applies only if the new code is
   60.36 + * made subject to such option by the copyright holder.
   60.37 + *
   60.38 + * Contributor(s):
   60.39 + *
   60.40 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
   60.41 + */
   60.42 +package org.netbeans.modules.licensechanger.wizard.utils;
   60.43 +
   60.44 +/**
   60.45 + * Central class for Wizard-related property keys.
   60.46 + *
   60.47 + * @author Nils Hoffmann
   60.48 + */
   60.49 +public final class WizardProperties {
   60.50 +
   60.51 +    public static final String KEY_FILE_HANDLERS = "fileHandlers";
   60.52 +    public static final String KEY_ITEMS = "fileItems";
   60.53 +    public static final String KEY_LICENSE_TEXT = "licenseText";
   60.54 +    public static final String KEY_LICENSE_NAME = "licenseName";
   60.55 +    public static final String KEY_ROOT_FILES = "rootFiles";
   60.56 +    public static final String KEY_FOLDERS = "folders";
   60.57 +    public static final String KEY_UPDATE_DEFAULT_PROJECT_LICENSE = "updateDefaultProjectLicense";
   60.58 +    public static final String VALUE_DEFAULT_LICENSE_TEXT = "No License";
   60.59 +    public static final String PROP_ENDING = "ending";
   60.60 +    public static final String KEY_ENDING = "line_terminator";
   60.61 +    public static final String KEY_PROJECT = "project";
   60.62 +    public static final String KEY_COPYRIGHT_HOLDER = "project.organization";
   60.63 +    public static final String KEY_STORE_IN_USER_PROPERTIES = "storeInUserProperties";
   60.64 +
   60.65 +    private WizardProperties() {
   60.66 +    }
   60.67 +}
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/TestUtils.java	Fri Jan 04 15:27:42 2013 +0100
    61.3 @@ -0,0 +1,114 @@
    61.4 +/*
    61.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    61.6 + *
    61.7 + * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
    61.8 + *
    61.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   61.10 + * Other names may be trademarks of their respective owners.
   61.11 + *
   61.12 + * The contents of this file are subject to the terms of either the GNU
   61.13 + * General Public License Version 2 only ("GPL") or the Common
   61.14 + * Development and Distribution License("CDDL") (collectively, the
   61.15 + * "License"). You may not use this file except in compliance with the
   61.16 + * License. You can obtain a copy of the License at
   61.17 + * http://www.netbeans.org/cddl-gplv2.html
   61.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   61.19 + * specific language governing permissions and limitations under the
   61.20 + * License.  When distributing the software, include this License Header
   61.21 + * Notice in each file and include the License file at
   61.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   61.23 + * particular file as subject to the "Classpath" exception as provided
   61.24 + * by Oracle in the GPL Version 2 section of the License file that
   61.25 + * accompanied this code. If applicable, add the following below the
   61.26 + * License Header, with the fields enclosed by brackets [] replaced by
   61.27 + * your own identifying information:
   61.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   61.29 + *
   61.30 + * If you wish your version of this file to be governed by only the CDDL
   61.31 + * or only the GPL Version 2, indicate your decision by adding
   61.32 + * "[Contributor] elects to include this software in this distribution
   61.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   61.34 + * single choice of license, a recipient has the option to distribute
   61.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   61.36 + * to extend the choice of license to its licensees as provided above.
   61.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   61.38 + * Version 2 license, then the option applies only if the new code is
   61.39 + * made subject to such option by the copyright holder.
   61.40 + *
   61.41 + * Contributor(s):
   61.42 + *
   61.43 + * Portions Copyrighted 2013 Sun Microsystems, Inc.
   61.44 + */
   61.45 +package org.netbeans.modules.licensechanger;
   61.46 +
   61.47 +import java.io.BufferedOutputStream;
   61.48 +import java.io.ByteArrayInputStream;
   61.49 +import java.io.ByteArrayOutputStream;
   61.50 +import java.io.File;
   61.51 +import java.io.FileOutputStream;
   61.52 +import java.io.IOException;
   61.53 +import java.io.InputStream;
   61.54 +import java.io.OutputStream;
   61.55 +import java.nio.charset.Charset;
   61.56 +import static org.junit.Assert.*;
   61.57 +import org.openide.filesystems.FileUtil;
   61.58 +
   61.59 +/**
   61.60 + *
   61.61 + * @author Nils Hoffmann
   61.62 + */
   61.63 +public class TestUtils {
   61.64 +
   61.65 +    public static String getLicense() throws Exception {
   61.66 +        return readFile("fake_license.txt");
   61.67 +    }
   61.68 +
   61.69 +    public static String readFile(Class<?> clazz, String name) throws Exception {
   61.70 +        InputStream in = clazz.getResourceAsStream(name);
   61.71 +        if (in == null) {
   61.72 +            fail("No input stream for " + name);
   61.73 +        }
   61.74 +        ByteArrayOutputStream out = new ByteArrayOutputStream();
   61.75 +        try {
   61.76 +            FileUtil.copy(in, out);
   61.77 +        } finally {
   61.78 +            in.close();
   61.79 +            out.close();
   61.80 +        }
   61.81 +        String result = new String(out.toByteArray(), "UTF-8");
   61.82 +        return result.replace("\r\n", "\n");
   61.83 +    }
   61.84 +
   61.85 +    public static String readFile(String name) throws Exception {
   61.86 +        return TestUtils.readFile(TestUtils.class, name);
   61.87 +    }
   61.88 +    
   61.89 +    public static void writeStream(String s, OutputStream os) throws Exception {
   61.90 +        InputStream is = new ByteArrayInputStream(s.getBytes(Charset.forName("UTF-8")));
   61.91 +        try {
   61.92 +            FileUtil.copy(is, os);
   61.93 +        } catch (IOException ioex) {
   61.94 +            throw ioex;
   61.95 +        } finally {
   61.96 +            if (is != null) {
   61.97 +                try {
   61.98 +                    is.close();
   61.99 +                } catch (IOException ioex) {
  61.100 +                    throw ioex;
  61.101 +                }
  61.102 +            }
  61.103 +            if (os != null) {
  61.104 +                try {
  61.105 +                    os.close();
  61.106 +                } catch (IOException ioex) {
  61.107 +                    throw ioex;
  61.108 +                }
  61.109 +            }
  61.110 +        }
  61.111 +    }
  61.112 +
  61.113 +    public static void writeFile(String s, File f) throws Exception {
  61.114 +        OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
  61.115 +        writeStream(s,os);
  61.116 +    }
  61.117 +}
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/api/LicenseHeaderTest.java	Fri Jan 04 15:27:42 2013 +0100
    62.3 @@ -0,0 +1,178 @@
    62.4 +/*
    62.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    62.6 + *
    62.7 + * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
    62.8 + *
    62.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   62.10 + * Other names may be trademarks of their respective owners.
   62.11 + *
   62.12 + * The contents of this file are subject to the terms of either the GNU
   62.13 + * General Public License Version 2 only ("GPL") or the Common
   62.14 + * Development and Distribution License("CDDL") (collectively, the
   62.15 + * "License"). You may not use this file except in compliance with the
   62.16 + * License. You can obtain a copy of the License at
   62.17 + * http://www.netbeans.org/cddl-gplv2.html
   62.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   62.19 + * specific language governing permissions and limitations under the
   62.20 + * License.  When distributing the software, include this License Header
   62.21 + * Notice in each file and include the License file at
   62.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   62.23 + * particular file as subject to the "Classpath" exception as provided
   62.24 + * by Oracle in the GPL Version 2 section of the License file that
   62.25 + * accompanied this code. If applicable, add the following below the
   62.26 + * License Header, with the fields enclosed by brackets [] replaced by
   62.27 + * your own identifying information:
   62.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   62.29 + *
   62.30 + * If you wish your version of this file to be governed by only the CDDL
   62.31 + * or only the GPL Version 2, indicate your decision by adding
   62.32 + * "[Contributor] elects to include this software in this distribution
   62.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   62.34 + * single choice of license, a recipient has the option to distribute
   62.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   62.36 + * to extend the choice of license to its licensees as provided above.
   62.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   62.38 + * Version 2 license, then the option applies only if the new code is
   62.39 + * made subject to such option by the copyright holder.
   62.40 + *
   62.41 + * Contributor(s):
   62.42 + *
   62.43 + * Portions Copyrighted 2013 Sun Microsystems, Inc.
   62.44 + */
   62.45 +package org.netbeans.modules.licensechanger.api;
   62.46 +
   62.47 +import java.io.File;
   62.48 +import java.io.IOException;
   62.49 +import java.util.Collection;
   62.50 +import junit.framework.Assert;
   62.51 +import org.junit.Test;
   62.52 +import org.junit.Before;
   62.53 +import org.junit.experimental.categories.Categories;
   62.54 +import org.netbeans.junit.NbTestCase;
   62.55 +import static org.netbeans.modules.licensechanger.TestUtils.*;
   62.56 +import org.openide.filesystems.FileObject;
   62.57 +import org.openide.filesystems.FileUtil;
   62.58 +import org.openide.util.Exceptions;
   62.59 +
   62.60 +/**
   62.61 + *
   62.62 + * @author Nils Hoffmann
   62.63 + */
   62.64 +public class LicenseHeaderTest extends NbTestCase {
   62.65 +
   62.66 +    private LicenseHeader golden;
   62.67 +
   62.68 +    public LicenseHeaderTest(String name) {
   62.69 +        super(name);
   62.70 +    }
   62.71 +
   62.72 +    @Before
   62.73 +    @Override
   62.74 +    public void setUp() throws Exception {
   62.75 +        super.setUp();
   62.76 +        System.out.println("Creating golden license header");
   62.77 +        File f;
   62.78 +        try {
   62.79 +            f = new File(getWorkDir(), "license-test.txt");
   62.80 +            writeFile(readFile("license-test.txt"), f);
   62.81 +            Assert.assertTrue(f.exists());
   62.82 +            golden = LicenseHeader.fromFile(f);
   62.83 +            System.out.println("Golden: " + golden);
   62.84 +        } catch (IOException ex) {
   62.85 +            Exceptions.printStackTrace(ex);
   62.86 +        }
   62.87 +    }
   62.88 +
   62.89 +    /**
   62.90 +     * Test that file object may not be null, of class LicenseHeader.
   62.91 +     */
   62.92 +    @Test
   62.93 +    public void testNullArgs1() {
   62.94 +        boolean npeCaught = false;
   62.95 +        try {
   62.96 +            LicenseHeader actual = LicenseHeader.fromFileObject(null, golden.getName(), false);
   62.97 +        } catch (NullPointerException npe) {
   62.98 +            npeCaught = true;
   62.99 +        }
  62.100 +        Assert.assertTrue(npeCaught);
  62.101 +    }
  62.102 +    
  62.103 +    /**
  62.104 +     * Test that file object may not be null, of class LicenseHeader.
  62.105 +     */
  62.106 +    @Test
  62.107 +    public void testNullArgs2() {
  62.108 +        boolean npeCaught = false;
  62.109 +        try {
  62.110 +            LicenseHeader actual = LicenseHeader.fromFileObject(null, golden.getName());
  62.111 +        } catch (NullPointerException npe) {
  62.112 +            npeCaught = true;
  62.113 +        }
  62.114 +        Assert.assertTrue(npeCaught);
  62.115 +    }
  62.116 +    
  62.117 +    /**
  62.118 +     * Test that file object may not be null, of class LicenseHeader.
  62.119 +     */
  62.120 +    @Test
  62.121 +    public void testNullArgs3() {
  62.122 +        boolean npeCaught = false;
  62.123 +        try {
  62.124 +            LicenseHeader actual = LicenseHeader.fromFile(null);
  62.125 +        } catch (NullPointerException npe) {
  62.126 +            npeCaught = true;
  62.127 +        }
  62.128 +        Assert.assertTrue(npeCaught);
  62.129 +    }
  62.130 +    
  62.131 +    /**
  62.132 +     * Test retrieval of license header name from file object, of class LicenseHeader.
  62.133 +     */
  62.134 +    @Test
  62.135 +    public void testNullArgs4() {
  62.136 +        LicenseHeader actual = LicenseHeader.fromFileObject(golden.getFileObject(), null, false);
  62.137 +    }
  62.138 +
  62.139 +    /**
  62.140 +     * Test of fromFileObject method, of class LicenseHeader.
  62.141 +     */
  62.142 +    @Test
  62.143 +    public void testFromFileObject_3args() {
  62.144 +        LicenseHeader actual = LicenseHeader.fromFileObject(golden.getFileObject(), golden.getName(), false);
  62.145 +        Assert.assertEquals(golden, actual);
  62.146 +    }
  62.147 +
  62.148 +    /**
  62.149 +     * Test of fromFileObject method, of class LicenseHeader.
  62.150 +     */
  62.151 +    @Test
  62.152 +    public void testFromFileObject_FileObject_String() {
  62.153 +        LicenseHeader actual = LicenseHeader.fromFileObject(golden.getFileObject(), golden.getName());
  62.154 +        Assert.assertEquals(golden, actual);
  62.155 +    }
  62.156 +
  62.157 +    /**
  62.158 +     * Test of fromFile method, of class LicenseHeader.
  62.159 +     */
  62.160 +    @Test
  62.161 +    public void testFromFile() {
  62.162 +        LicenseHeader actual = LicenseHeader.fromFile(FileUtil.toFile(golden.getFileObject()));
  62.163 +        Assert.assertEquals(golden, actual);
  62.164 +    }
  62.165 +
  62.166 +    /**
  62.167 +     * Test of addAsNetBeansTemplate and fromTemplates methods, of class
  62.168 +     * LicenseHeader.
  62.169 +     */
  62.170 +    @Test
  62.171 +    public void testAddAsNetBeansTemplateFromTemplates() throws Exception {
  62.172 +        FileObject configRoot = FileUtil.getConfigRoot();
  62.173 +        FileObject licenseTemplates = configRoot.getFileObject("Templates").createFolder("Licenses");
  62.174 +        LicenseHeader goldenTemplate = LicenseHeader.addAsNetBeansTemplate(golden);
  62.175 +        Assert.assertFalse(golden.isNetBeansTemplate());
  62.176 +        Assert.assertTrue(goldenTemplate.isNetBeansTemplate());
  62.177 +        Assert.assertFalse(goldenTemplate.getLicenseHeader().isEmpty());
  62.178 +        Collection<? extends LicenseHeader> licenses = LicenseHeader.fromTemplates();
  62.179 +        Assert.assertTrue(licenses.contains(goldenTemplate));
  62.180 +    }
  62.181 +}
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/fake_license.txt	Fri Jan 04 15:27:42 2013 +0100
    63.3 @@ -0,0 +1,29 @@
    63.4 +Copyright (c) 1892-2193 Centrifugal Bumblepuppy, SRO, Inc., LLC, WTF
    63.5 +All rights reversed.
    63.6 +
    63.7 +Redistribution and use in source, binary or corpuscular forms, with or without
    63.8 +modification, are prohibited under all circumstances unless the following
    63.9 +conditions have been met:
   63.10 +
   63.11 +  1. You have an eyeball growing in the palm of your left hand
   63.12 +
   63.13 +  2. Seven dwarfs really like your golden hair
   63.14 +
   63.15 +  3. The moon has reversed its course a multiple of times divisible by
   63.16 +     the eighteenth prime number in the last year
   63.17 +
   63.18 +THIS MALWARE IS PROVIDED ``AS IS'' AND ANY IMPLICIT OR IMPLIED WARRANTIES
   63.19 +INCLUDING BUT NOT LIMITED TO EXPECTATION OF CONTINUED SURVIVAL ARE
   63.20 +DISCLAIMED.  IN NO EVENT SHALL CENTRIFUGAL BUMBLEPUPPY, SRO, INC., LLC, WTF
   63.21 +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   63.22 +ECTOPLASMIC OR GEOTHERMAL DAMAGES, INCLUDING BUT NOT LIMITED TO:
   63.23 +SPONTANEOUS HUMAN COMBUSTION, THRID ARM SYNDROME, BAD BREATH, OVOID HEART;
   63.24 +LOSS OF SOUL, ENUII OR EXISTENTIAL INFLAMMATION; OXYGEN EVASION SYNDROME,
   63.25 +BALL DROP, BECOMING A LAWYER.
   63.26 +
   63.27 +BY USING THIS SOFTWARE YOU AGREE TO THE HARVESTING OF YOUR GENETIC MATERIAL
   63.28 +AND/OR OFFSPRING WITHIN THE FIRST THOUSAND YEARS SUBSEQUENT TO FIRST USE, AND
   63.29 +AGREE TO THE USE OF REANIMATION TECHNOLOGIES IF CENTRIFUGAL BUMBLEPUPPY, SRO,
   63.30 +INC., LLC, WTF DEEMS IT NECESSARY AT THEIR SOLE DISCRETION.
   63.31 +
   63.32 +RUN, RUN NOW, AND RUN VERY FAST.
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/license-test.txt	Fri Jan 04 15:27:42 2013 +0100
    64.3 @@ -0,0 +1,45 @@
    64.4 +<#if licenseFirst??>
    64.5 +${licenseFirst}
    64.6 +</#if>
    64.7 +${licensePrefix}DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    64.8 +${licensePrefix?replace(" +$", "", "r")}
    64.9 +${licensePrefix}Copyright ${date?date?string("yyyy")} Oracle and/or its affiliates. All rights reserved.
   64.10 +${licensePrefix?replace(" +$", "", "r")}
   64.11 +${licensePrefix}Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   64.12 +${licensePrefix}Other names may be trademarks of their respective owners.
   64.13 +${licensePrefix?replace(" +$", "", "r")}
   64.14 +${licensePrefix}The contents of this file are subject to the terms of either the GNU
   64.15 +${licensePrefix}General Public License Version 2 only ("GPL") or the Common
   64.16 +${licensePrefix}Development and Distribution License("CDDL") (collectively, the
   64.17 +${licensePrefix}"License"). You may not use this file except in compliance with the
   64.18 +${licensePrefix}License. You can obtain a copy of the License at
   64.19 +${licensePrefix}http://www.netbeans.org/cddl-gplv2.html
   64.20 +${licensePrefix}or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   64.21 +${licensePrefix}specific language governing permissions and limitations under the
   64.22 +${licensePrefix}License.  When distributing the software, include this License Header
   64.23 +${licensePrefix}Notice in each file and include the License file at
   64.24 +${licensePrefix}nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   64.25 +${licensePrefix}particular file as subject to the "Classpath" exception as provided
   64.26 +${licensePrefix}by Oracle in the GPL Version 2 section of the License file that
   64.27 +${licensePrefix}accompanied this code. If applicable, add the following below the
   64.28 +${licensePrefix}License Header, with the fields enclosed by brackets [] replaced by
   64.29 +${licensePrefix}your own identifying information:
   64.30 +${licensePrefix}"Portions Copyrighted [year] [name of copyright owner]"
   64.31 +${licensePrefix?replace(" +$", "", "r")}
   64.32 +${licensePrefix}If you wish your version of this file to be governed by only the CDDL
   64.33 +${licensePrefix}or only the GPL Version 2, indicate your decision by adding
   64.34 +${licensePrefix}"[Contributor] elects to include this software in this distribution
   64.35 +${licensePrefix}under the [CDDL or GPL Version 2] license." If you do not indicate a
   64.36 +${licensePrefix}single choice of license, a recipient has the option to distribute
   64.37 +${licensePrefix}your version of this file under either the CDDL, the GPL Version 2 or
   64.38 +${licensePrefix}to extend the choice of license to its licensees as provided above.
   64.39 +${licensePrefix}However, if you add GPL Version 2 code and therefore, elected the GPL
   64.40 +${licensePrefix}Version 2 license, then the option applies only if the new code is
   64.41 +${licensePrefix}made subject to such option by the copyright holder.
   64.42 +${licensePrefix?replace(" +$", "", "r")}
   64.43 +${licensePrefix}Contributor(s):
   64.44 +${licensePrefix?replace(" +$", "", "r")}
   64.45 +${licensePrefix}Portions Copyrighted ${date?date?string("yyyy")} Sun Microsystems, Inc.
   64.46 +<#if licenseLast??>
   64.47 +${licenseLast}
   64.48 +</#if>
   64.49 \ No newline at end of file
    65.1 --- a/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/GroovyFileHandlerTest.java	Wed Jan 02 13:38:30 2013 +0100
    65.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/GroovyFileHandlerTest.java	Fri Jan 04 15:27:42 2013 +0100
    65.3 @@ -38,14 +38,12 @@
    65.4   */
    65.5  package org.netbeans.modules.licensechanger.spi.handlers;
    65.6  
    65.7 -import java.io.ByteArrayOutputStream;
    65.8 -import java.io.InputStream;
    65.9  import java.util.Collections;
   65.10  import java.util.Map;
   65.11  import static org.junit.Assert.*;
   65.12  import org.junit.Test;
   65.13 +import static org.netbeans.modules.licensechanger.TestUtils.*;
   65.14  import org.netbeans.modules.licensechanger.api.FileHandler;
   65.15 -import org.openide.filesystems.FileUtil;
   65.16  
   65.17  /**
   65.18   * Test cases for groovy license replacement.
   65.19 @@ -110,32 +108,12 @@
   65.20  
   65.21      private static String merge(String header, String template) throws Exception {
   65.22          StringBuilder sb = new StringBuilder();
   65.23 -        sb.append(readFile(header));
   65.24 -        sb.append(readFile(template));
   65.25 +        sb.append(readFile(GroovyFileHandlerTest.class,header));
   65.26 +        sb.append(readFile(GroovyFileHandlerTest.class,template));
   65.27          return sb.toString();
   65.28      }
   65.29  
   65.30      private static String getGolden(String infix) throws Exception {
   65.31 -        return readFile("resources/groovy/groovy_" + infix + "_golden.txt");
   65.32 -    }
   65.33 -
   65.34 -    static String getLicense() throws Exception {
   65.35 -        return readFile("fake_license.txt");
   65.36 -    }
   65.37 -
   65.38 -    static String readFile(String name) throws Exception {
   65.39 -        InputStream in = GroovyFileHandlerTest.class.getResourceAsStream(name);
   65.40 -        if (in == null) {
   65.41 -            fail("No input stream for " + name);
   65.42 -        }
   65.43 -        ByteArrayOutputStream out = new ByteArrayOutputStream();
   65.44 -        try {
   65.45 -            FileUtil.copy(in, out);
   65.46 -        } finally {
   65.47 -            in.close();
   65.48 -            out.close();
   65.49 -        }
   65.50 -        String result = new String(out.toByteArray(), "UTF-8");
   65.51 -        return result.replace("\r\n", "\n");
   65.52 +        return readFile(GroovyFileHandlerTest.class,"resources/groovy/groovy_" + infix + "_golden.txt");
   65.53      }
   65.54  }
    66.1 --- a/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/JavaFileHandlerTest.java	Wed Jan 02 13:38:30 2013 +0100
    66.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/JavaFileHandlerTest.java	Fri Jan 04 15:27:42 2013 +0100
    66.3 @@ -38,14 +38,12 @@
    66.4   */
    66.5  package org.netbeans.modules.licensechanger.spi.handlers;
    66.6  
    66.7 -import java.io.ByteArrayOutputStream;
    66.8 -import java.io.InputStream;
    66.9  import java.util.Collections;
   66.10  import java.util.Map;
   66.11  import static org.junit.Assert.*;
   66.12  import org.junit.Test;
   66.13 +import static org.netbeans.modules.licensechanger.TestUtils.*;
   66.14  import org.netbeans.modules.licensechanger.api.FileHandler;
   66.15 -import org.openide.filesystems.FileUtil;
   66.16  
   66.17  /**
   66.18   *
   66.19 @@ -69,7 +67,7 @@
   66.20      private void testOneVersion(String golden, String license, String filename) throws Exception {
   66.21          System.out.println("Test " + filename);
   66.22          JavaFileHandler instance = new JavaFileHandler();
   66.23 -        String original = readFile(filename);
   66.24 +        String original = readFile(JavaFileHandlerTest.class,filename);
   66.25          String processed = instance.transform(original, license, props);
   66.26          assertEqualsLineByLine(golden, processed, filename);
   66.27      }
   66.28 @@ -98,26 +96,6 @@
   66.29  //
   66.30  //    }
   66.31      private static String getGolden() throws Exception {
   66.32 -        return readFile("java_golden.txt");
   66.33 -    }
   66.34 -
   66.35 -    static String getLicense() throws Exception {
   66.36 -        return readFile("fake_license.txt");
   66.37 -    }
   66.38 -
   66.39 -    static String readFile(String name) throws Exception {
   66.40 -        InputStream in = JavaFileHandlerTest.class.getResourceAsStream(name);
   66.41 -        if (in == null) {
   66.42 -            fail("No input stream for " + name);
   66.43 -        }
   66.44 -        ByteArrayOutputStream out = new ByteArrayOutputStream();
   66.45 -        try {
   66.46 -            FileUtil.copy(in, out);
   66.47 -        } finally {
   66.48 -            in.close();
   66.49 -            out.close();
   66.50 -        }
   66.51 -        String result = new String(out.toByteArray(), "UTF-8");
   66.52 -        return result.replace("\r\n", "\n");
   66.53 +        return readFile(JavaFileHandlerTest.class,"java_golden.txt");
   66.54      }
   66.55  }
    67.1 --- a/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/PropertiesFileHandlerTest.java	Wed Jan 02 13:38:30 2013 +0100
    67.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/PropertiesFileHandlerTest.java	Fri Jan 04 15:27:42 2013 +0100
    67.3 @@ -42,6 +42,7 @@
    67.4  import java.util.Map;
    67.5  import static org.junit.Assert.*;
    67.6  import org.junit.Test;
    67.7 +import static org.netbeans.modules.licensechanger.TestUtils.*;
    67.8  
    67.9  /**
   67.10   *
   67.11 @@ -55,7 +56,7 @@
   67.12      public void testStuff() throws Exception {
   67.13          System.out.println("testStuff");
   67.14          String golden = getGolden();
   67.15 -        String license = JavaFileHandlerTest.getLicense();
   67.16 +        String license = getLicense();
   67.17          for (int i = 1; i <= 4; i++) {
   67.18              testOneVersion(golden, license, "props_" + i + ".txt");
   67.19          }
   67.20 @@ -65,7 +66,7 @@
   67.21      private void testOneVersion(String golden, String license, String filename) throws Exception {
   67.22          System.out.println("Test " + filename);
   67.23          PropertiesFileHandler instance = new PropertiesFileHandler();
   67.24 -        String original = JavaFileHandlerTest.readFile(filename);
   67.25 +        String original = readFile(PropertiesFileHandlerTest.class,filename);
   67.26          String processed = instance.transform(original, license, props);
   67.27  //        if (!original.equals(processed)) {
   67.28  //            System.out.println("************************************");
   67.29 @@ -76,6 +77,6 @@
   67.30      }
   67.31  
   67.32      private static String getGolden() throws Exception {
   67.33 -        return JavaFileHandlerTest.readFile("props_golden.txt");
   67.34 +        return readFile(PropertiesFileHandlerTest.class,"props_golden.txt");
   67.35      }
   67.36  }
    68.1 --- a/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/XmlFileHandlerTest.java	Wed Jan 02 13:38:30 2013 +0100
    68.2 +++ b/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/XmlFileHandlerTest.java	Fri Jan 04 15:27:42 2013 +0100
    68.3 @@ -45,6 +45,7 @@
    68.4  import static org.junit.Assert.*;
    68.5  import org.junit.Test;
    68.6  import org.netbeans.modules.licensechanger.api.FileHandler;
    68.7 +import static org.netbeans.modules.licensechanger.TestUtils.*;
    68.8  
    68.9  /**
   68.10   *
   68.11 @@ -60,7 +61,7 @@
   68.12          assertDeclarationFound(xml, "xml_golden.txt");
   68.13          for (int i = 1; i <= 8; i++) {
   68.14              String filename = "xml_" + i + ".txt";
   68.15 -            String content = JavaFileHandlerTest.readFile(filename);
   68.16 +            String content = readFile(XmlFileHandlerTest.class, filename);
   68.17              assertDeclarationFound(content, filename);
   68.18          }
   68.19      }
   68.20 @@ -85,7 +86,7 @@
   68.21      public void testStuff() throws Exception {
   68.22          System.out.println("testStuff");
   68.23          String golden = getGolden();
   68.24 -        String license = JavaFileHandlerTest.getLicense();
   68.25 +        String license = getLicense();
   68.26          for (int i = 1; i <= 8; i++) {
   68.27              String filename = "xml_" + i + ".txt";
   68.28              testOneVersion(golden, license, filename);
   68.29 @@ -95,7 +96,7 @@
   68.30      private void testOneVersion(String golden, String license, String filename) throws Exception {
   68.31          System.out.println("Test " + filename);
   68.32          XmlFileHandler instance = new XmlFileHandler();
   68.33 -        String original = JavaFileHandlerTest.readFile(filename);
   68.34 +        String original = readFile(XmlFileHandlerTest.class, filename);
   68.35          String processed = instance.transform(original, license, props);
   68.36          assertEqualsLineByLine(golden, processed, filename);
   68.37      }
   68.38 @@ -117,6 +118,6 @@
   68.39      }
   68.40  
   68.41      private static String getGolden() throws Exception {
   68.42 -        return JavaFileHandlerTest.readFile("xml_golden.txt");
   68.43 +        return readFile(XmlFileHandlerTest.class, "xml_golden.txt");
   68.44      }
   68.45  }
    69.1 --- a/licensechanger/test/unit/src/org/netbeans/modules/licensechanger/spi/handlers/fake_license.txt	Wed Jan 02 13:38:30 2013 +0100
    69.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.3 @@ -1,29 +0,0 @@
    69.4 -Copyright (c) 1892-2193 Centrifugal Bumblepuppy, SRO, Inc., LLC, WTF
    69.5 -All rights reversed.
    69.6 -
    69.7 -Redistribution and use in source, binary or corpuscular forms, with or without
    69.8 -modification, are prohibited under all circumstances unless the following
    69.9 -conditions have been met:
   69.10 -
   69.11 -  1. You have an eyeball growing in the palm of your left hand
   69.12 -
   69.13 -  2. Seven dwarfs really like your golden hair
   69.14 -
   69.15 -  3. The moon has reversed its course a multiple of times divisible by
   69.16 -     the eighteenth prime number in the last year
   69.17 -
   69.18 -THIS MALWARE IS PROVIDED ``AS IS'' AND ANY IMPLICIT OR IMPLIED WARRANTIES
   69.19 -INCLUDING BUT NOT LIMITED TO EXPECTATION OF CONTINUED SURVIVAL ARE
   69.20 -DISCLAIMED.  IN NO EVENT SHALL CENTRIFUGAL BUMBLEPUPPY, SRO, INC., LLC, WTF
   69.21 -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   69.22 -ECTOPLASMIC OR GEOTHERMAL DAMAGES, INCLUDING BUT NOT LIMITED TO:
   69.23 -SPONTANEOUS HUMAN COMBUSTION, THRID ARM SYNDROME, BAD BREATH, OVOID HEART;
   69.24 -LOSS OF SOUL, ENUII OR EXISTENTIAL INFLAMMATION; OXYGEN EVASION SYNDROME,
   69.25 -BALL DROP, BECOMING A LAWYER.
   69.26 -
   69.27 -BY USING THIS SOFTWARE YOU AGREE TO THE HARVESTING OF YOUR GENETIC MATERIAL
   69.28 -AND/OR OFFSPRING WITHIN THE FIRST THOUSAND YEARS SUBSEQUENT TO FIRST USE, AND
   69.29 -AGREE TO THE USE OF REANIMATION TECHNOLOGIES IF CENTRIFUGAL BUMBLEPUPPY, SRO,
   69.30 -INC., LLC, WTF DEEMS IT NECESSARY AT THEIR SOLE DISCRETION.
   69.31 -
   69.32 -RUN, RUN NOW, AND RUN VERY FAST.