#188652 - 47s - php.smarty.SmartyPhpFrameworkProvider.isInPhpModule()
authorMartin Fousek <marfous@netbeans.org>
Tue, 07 Jun 2011 11:20:19 +0200
changeset 17500b765536363d2
parent 17462 8969adb34bc9
child 17501 30633dc1fae0
#188652 - 47s - php.smarty.SmartyPhpFrameworkProvider.isInPhpModule()
php.smarty/manifest.mf
php.smarty/nbproject/project.xml
php.smarty/src/org/netbeans/modules/php/smarty/Bundle.properties
php.smarty/src/org/netbeans/modules/php/smarty/SmartyPhpFrameworkProvider.java
     1.1 --- a/php.smarty/manifest.mf	Sun May 29 23:07:23 2011 -0400
     1.2 +++ b/php.smarty/manifest.mf	Tue Jun 07 11:20:19 2011 +0200
     1.3 @@ -2,5 +2,5 @@
     1.4  OpenIDE-Module: org.netbeans.modules.php.smarty
     1.5  OpenIDE-Module-Layer: org/netbeans/modules/php/smarty/resources/layer.xml
     1.6  OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/smarty/resources/Bundle.properties
     1.7 -OpenIDE-Module-Specification-Version: 1.51
     1.8 +OpenIDE-Module-Specification-Version: 1.52
     1.9  
     2.1 --- a/php.smarty/nbproject/project.xml	Sun May 29 23:07:23 2011 -0400
     2.2 +++ b/php.smarty/nbproject/project.xml	Tue Jun 07 11:20:19 2011 +0200
     2.3 @@ -6,6 +6,15 @@
     2.4              <code-name-base>org.netbeans.modules.php.smarty</code-name-base>
     2.5              <module-dependencies>
     2.6                  <dependency>
     2.7 +                    <code-name-base>org.netbeans.api.progress</code-name-base>
     2.8 +                    <build-prerequisite/>
     2.9 +                    <compile-dependency/>
    2.10 +                    <run-dependency>
    2.11 +                        <release-version>1</release-version>
    2.12 +                        <specification-version>1.25</specification-version>
    2.13 +                    </run-dependency>
    2.14 +                </dependency>
    2.15 +                <dependency>
    2.16                      <code-name-base>org.netbeans.modules.csl.api</code-name-base>
    2.17                      <build-prerequisite/>
    2.18                      <compile-dependency/>
     3.1 --- a/php.smarty/src/org/netbeans/modules/php/smarty/Bundle.properties	Sun May 29 23:07:23 2011 -0400
     3.2 +++ b/php.smarty/src/org/netbeans/modules/php/smarty/Bundle.properties	Tue Jun 07 11:20:19 2011 +0200
     3.3 @@ -42,3 +42,5 @@
     3.4  # framework customizer extender
     3.5  LBL_Smarty=Smarty
     3.6  
     3.7 +MSG_SearchingForSmartyExt=Scanning for Smarty file extensions in project.
     3.8 +
     4.1 --- a/php.smarty/src/org/netbeans/modules/php/smarty/SmartyPhpFrameworkProvider.java	Sun May 29 23:07:23 2011 -0400
     4.2 +++ b/php.smarty/src/org/netbeans/modules/php/smarty/SmartyPhpFrameworkProvider.java	Tue Jun 07 11:20:19 2011 +0200
     4.3 @@ -39,6 +39,9 @@
     4.4  package org.netbeans.modules.php.smarty;
     4.5  
     4.6  import java.io.File;
     4.7 +import java.util.logging.Level;
     4.8 +import java.util.logging.Logger;
     4.9 +import org.netbeans.api.progress.ProgressUtils;
    4.10  import org.netbeans.modules.php.api.phpmodule.BadgeIcon;
    4.11  import org.netbeans.modules.php.api.phpmodule.PhpModule;
    4.12  import org.netbeans.modules.php.api.phpmodule.PhpModuleProperties;
    4.13 @@ -136,17 +139,33 @@
    4.14      @Override
    4.15      public boolean isInPhpModule(final PhpModule phpModule) {
    4.16          // get php files within the module
    4.17 -        final FoundSmarty fs = new FoundSmarty();
    4.18 +        long time = System.currentTimeMillis();
    4.19 +        try {
    4.20 +            final FoundSmarty fs = new FoundSmarty();
    4.21  
    4.22 -        if (phpModule.getPreferences(SmartyPhpFrameworkProvider.class, true).get(SMARTY_AVAILABLE, "0").equals("1")) {
    4.23 -            fs.setFound(true);
    4.24 -        }
    4.25 +            if (phpModule.getPreferences(SmartyPhpFrameworkProvider.class, true).get(SMARTY_AVAILABLE, "0").equals("1")) {
    4.26 +                fs.setFound(true);
    4.27 +            }
    4.28  
    4.29 -        if (fs.isFound()) {
    4.30 -            return true;
    4.31 -        } else {
    4.32 -            FileObject sourceDirectory = phpModule.getSourceDirectory();
    4.33 -            return locatedTplFiles(sourceDirectory, SmartyOptions.getInstance().getScanningDepth(), 0);
    4.34 +            if (fs.isFound()) {
    4.35 +                return true;
    4.36 +            } else {
    4.37 +                ProgressUtils.showProgressDialogAndRun(new Runnable() {
    4.38 +                    @Override
    4.39 +                    public void run() {
    4.40 +                        FileObject sourceDirectory = phpModule.getSourceDirectory();
    4.41 +                        if (locatedTplFiles(sourceDirectory, SmartyOptions.getInstance().getScanningDepth(), 0)) {
    4.42 +                            phpModule.getPreferences(SmartyPhpFrameworkProvider.class, true).put(SMARTY_AVAILABLE, "1");
    4.43 +                            fs.setFound(true);
    4.44 +                        }
    4.45 +                    }
    4.46 +                }, NbBundle.getMessage(SmartyPhpFrameworkProvider.class, "MSG_SearchingForSmartyExt"));
    4.47 +                
    4.48 +            }
    4.49 +            return fs.isFound();
    4.50 +        } finally {
    4.51 +            Logger.getLogger(SmartyPhpFrameworkProvider.class.getName()).log(
    4.52 +                    Level.INFO, "Smarty.isInPhpModule total time spent={0} ms", (System.currentTimeMillis() - time));
    4.53          }
    4.54      }
    4.55