Java Code Examples for org.netbeans.modules.php.api.phpmodule.PhpModule#getSourceDirectory()

The following examples show how to use org.netbeans.modules.php.api.phpmodule.PhpModule#getSourceDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkeletonGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "SkeletonGenerator.run.title=PHPUnit Skeleton Generator ({0})",
})
@CheckForNull
private PhpExecutable getExecutable(PhpModule phpModule, List<String> params) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        UiUtils.warnNoSources(phpModule.getDisplayName());
        return null;
    }

    return getExecutable(Bundle.SkeletonGenerator_run_title(phpModule.getDisplayName()), FileUtil.toFile(sourceDirectory))
            .optionsSubcategory(PhpUnitOptionsPanelController.OPTIONS_SUB_PATH)
            .additionalParameters(params);
}
 
Example 2
Source File: PhpUnit.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "PhpUnit.run.title=PHPUnit ({0})",
})
@CheckForNull
private PhpExecutable getExecutable(PhpModule phpModule) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        org.netbeans.modules.php.phpunit.ui.UiUtils.warnNoSources(phpModule.getDisplayName());
        return null;
    }

    return new PhpExecutable(phpUnitPath)
            .optionsSubcategory(PhpUnitOptionsPanelController.OPTIONS_SUB_PATH)
            .displayName(Bundle.PhpUnit_run_title(phpModule.getDisplayName()));
}
 
Example 3
Source File: PhpUnitTestingProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTestFile(PhpModule phpModule, FileObject fileObj) {
    if (!PhpUnit.isTestFile(fileObj.getNameExt())) {
        return false;
    }
    for (FileObject testDirectory : phpModule.getTestDirectories()) {
        if (FileUtil.isParentOf(testDirectory, fileObj)) {
            return true;
        }
    }
    if (!PhpUnitPreferences.getRunAllTestFiles(phpModule)) {
        return false;
    }
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    return sourceDirectory != null
            && FileUtil.isParentOf(sourceDirectory, fileObj);
}
 
Example 4
Source File: ZendPhpFrameworkProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public PhpModuleProperties getPhpModuleProperties(PhpModule phpModule) {
    PhpModuleProperties properties = new PhpModuleProperties();
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        // broken project
        return properties;
    }
    FileObject web = sourceDirectory.getFileObject("public"); // NOI18N
    if (web != null) {
        properties = properties.setWebRoot(web);
    }
    FileObject tests = sourceDirectory.getFileObject("tests"); // NOI18N
    if (tests != null) {
        properties = properties.setTests(tests);
    }
    return properties;
}
 
Example 5
Source File: SymfonyPhpFrameworkProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Try to locate (find) a <code>relativePath</code> in source directory.
 * Currently, it searches source dir and its subdirs (if <code>subdirs</code> equals {@code true}).
 * @return {@link FileObject} or {@code null} if not found
 */
public static FileObject locate(PhpModule phpModule, String relativePath, boolean subdirs) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        // broken project
        return null;
    }

    FileObject fileObject = sourceDirectory.getFileObject(relativePath);
    if (fileObject != null || !subdirs) {
        return fileObject;
    }
    for (FileObject child : sourceDirectory.getChildren()) {
        fileObject = child.getFileObject(relativePath);
        if (fileObject != null) {
            return fileObject;
        }
    }
    return null;
}
 
Example 6
Source File: SmartyPhpFrameworkProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static FileObject locate(PhpModule phpModule, String relativePath, boolean subdirs) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        // broken project
        return null;
    }

    FileObject fileObject = sourceDirectory.getFileObject(relativePath);
    if (fileObject != null || !subdirs) {
        return fileObject;
    }
    for (FileObject child : sourceDirectory.getChildren()) {
        fileObject = child.getFileObject(relativePath);
        if (fileObject != null) {
            return fileObject;
        }
    }
    return null;
}
 
Example 7
Source File: Composer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private ExecutionDescriptor getDescriptor(@NullAllowed PhpModule phpModule) {
    ExecutionDescriptor descriptor = PhpExecutable.DEFAULT_EXECUTION_DESCRIPTOR
            .optionsPath(ComposerOptionsPanelController.getOptionsPath())
            .inputVisible(false);
    if (phpModule != null) {
        final FileObject sourceDirectory = phpModule.getSourceDirectory();
        if (sourceDirectory != null) {
            descriptor = descriptor
                    .postExecution(new Runnable() {
                        @Override
                        public void run() {
                            // refresh sources after running command
                            sourceDirectory.refresh();
                        }
                    });
        }
    }
    return descriptor;
}
 
Example 8
Source File: Composer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@CheckForNull
private File resolveWorkDir(PhpModule phpModule, boolean forceProjectDir) {
    if (workDir != null) {
        return workDir;
    }
    if (phpModule == null) {
        return null;
    }
    FileObject composerJson = getComposerJson(phpModule);
    if (composerJson != null) {
        return FileUtil.toFile(composerJson.getParent());
    }
    FileObject dir = forceProjectDir ? phpModule.getProjectDirectory() : phpModule.getSourceDirectory();
    if (dir == null) {
        // broken project
        return null;
    }
    return FileUtil.toFile(dir);
}
 
Example 9
Source File: SymfonyPhpFrameworkProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public PhpModuleProperties getPhpModuleProperties(PhpModule phpModule) {
    PhpModuleProperties properties = new PhpModuleProperties();
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        // broken project
        return properties;
    }
    FileObject web = sourceDirectory.getFileObject("web"); // NOI18N
    if (web != null) {
        properties = properties.setWebRoot(web);
    }
    SymfonyVersion symfonyVersion = SymfonyVersion.forPhpModule(phpModule);
    if (symfonyVersion == null) {
        // #267818 - incorrect symfony installer file
        LOGGER.log(Level.INFO, "No Symfony version detected for project {0} - perhaps invalid Symfony installer selected in IDE Options?", phpModule.getDisplayName());
    } else {
        FileObject tests = symfonyVersion.getTests();
        if (tests != null) {
            properties = properties.setTests(tests);
        }
    }
    return properties;
}
 
Example 10
Source File: TestCaseStatus.java    From cakephp3-netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void scan(PhpModule phpModule, FileObject fileObject, int offset) {
    if (fileObject.isFolder() || !FileUtils.isPhpFile(fileObject)) {
        return;
    }
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        return;
    }
    String name = fileObject.getName();
    int lastIndexOfTest = name.lastIndexOf("Test"); // NOI18N
    String testedClassName = ""; // NOI18N
    if (lastIndexOfTest != -1) {
        testedClassName = name.substring(0, lastIndexOfTest);
    }
    CakePHP3Module cakeModule = CakePHP3Module.forPhpModule(phpModule);
    Set<ClassElement> classElements = getClassElements(sourceDirectory, testedClassName);
    for (ClassElement classElement : classElements) {
        FileObject fo = classElement.getFileObject();
        if (fo != null && fo != fileObject) {
            CakePHP3Module.Category category = cakeModule.getCategory(fo);
            testeds.add(GoToItemFactory.create(category, fo, offset));
        }
    }
}
 
Example 11
Source File: Zend2PhpFrameworkProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public PhpModuleProperties getPhpModuleProperties(PhpModule phpModule) {
    PhpModuleProperties properties = new PhpModuleProperties();
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        LOGGER.info("Source directory does not exist?!");
        return properties;
    }
    FileObject webRoot = sourceDirectory.getFileObject("public"); // NOI18N
    if (webRoot == null) {
        // #228244
        LOGGER.log(Level.INFO, "Public directory should exist in {0} but children are: {1}",
                new Object[] {sourceDirectory, Arrays.toString(sourceDirectory.getChildren())});
        return properties;
    }
    return properties
            .setWebRoot(webRoot);
}
 
Example 12
Source File: Nette2PhpModuleExtender.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Set<FileObject> extend(PhpModule phpModule) throws ExtendingException {
    Set<FileObject> result = new HashSet<>();
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory != null) {
        String projectDirectory = sourceDirectory.getPath();
        FileUtils.copyDirectory(new File(Nette2Options.getInstance().getSandbox()), new File(projectDirectory));
        File netteLibsDirectory = new File(projectDirectory, Constants.NETTE_LIBS_DIR);
        if (isValidNetteLibsDir(netteLibsDirectory) && getPanel().isCopyNetteCheckboxSelected()) {
            FileUtils.copyDirectory(new File(Nette2Options.getInstance().getNetteDirectory()), netteLibsDirectory);
        }
        FileObject bootstrap = FileUtil.toFileObject(new File(projectDirectory, Constants.COMMON_BOOTSTRAP_PATH));
        if (bootstrap != null && !bootstrap.isFolder() && bootstrap.isValid()) {
            result.add(bootstrap);
        }
        FileObject tempDir = sourceDirectory.getFileObject(Constants.NETTE_TEMP_DIR);
        if (tempDir != null) {
            FileUtils.chmod777Recursively(tempDir);
        }
    }
    return result;
}
 
Example 13
Source File: Codecept.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "Codecept.displayName=Codecept ({0})",
})
@CheckForNull
private PhpExecutable getExecutable(PhpModule phpModule) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        org.netbeans.modules.php.codeception.ui.UiUtils.warnNoSources(phpModule.getDisplayName());
        return null;
    }
    return new PhpExecutable(codeceptPath)
            .optionsSubcategory(CodeceptionOptionsPanelController.OPTIONS_SUB_PATH)
            .displayName(Bundle.Codecept_displayName(phpModule.getDisplayName()));
}
 
Example 14
Source File: CakePHP3ModuleCustomizerExtender.java    From cakephp3-netbeans with Apache License 2.0 5 votes vote down vote up
public CakePHP3ModuleCustomizerExtender(PhpModule phpModule) {
    isEnabled = CakePHP3Preferences.isEnabled(phpModule);
    namespace = CakePHP3Preferences.getNamespace(phpModule);
    root = CakePHP3Preferences.getRootPath(phpModule);
    src = CakePHP3Preferences.getSrcName(phpModule);
    wwwRoot = CakePHP3Preferences.getWWWRootPath(phpModule);
    css = CakePHP3Preferences.getCssUrl(phpModule);
    img = CakePHP3Preferences.getImageUrl(phpModule);
    js = CakePHP3Preferences.getJsUrl(phpModule);
    dotcake = CakePHP3Preferences.getDotcakePath(phpModule);
    FileObject srcDir = phpModule.getSourceDirectory();
    sourceDirectory = srcDir != null ? FileUtil.toFile(srcDir) : null;
}
 
Example 15
Source File: CakePHP3ModuleFactory.java    From cakephp3-netbeans with Apache License 2.0 5 votes vote down vote up
@CheckForNull
private Dotcake createDotcake(PhpModule phpModule) {
    String dotcakePath = CakePHP3Preferences.getDotcakePath(phpModule);
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        return null;
    }
    if (!StringUtils.isEmpty(dotcakePath)) {
        FileObject dotcakeFile = sourceDirectory.getFileObject(dotcakePath);
        return Dotcake.fromJson(dotcakeFile);
    }
    return null;
}
 
Example 16
Source File: Nette2FrameworkProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isInPhpModule(PhpModule phpModule) {
    boolean result = Nette2Preferences.isManuallyEnabled(phpModule);
    if (!result) {
        FileObject sourceDirectory = phpModule.getSourceDirectory();
        if (sourceDirectory != null) {
            FileObject bootstrap = getFileObject(sourceDirectory, Constants.COMMON_BOOTSTRAP_PATH);
            result = bootstrap != null && !bootstrap.isFolder() && bootstrap.isValid();
            FileObject config = getFileObject(sourceDirectory, Constants.COMMON_CONFIG_PATH);
            result = result && config != null && config.isFolder() && config.isValid();
        }
    }
    return result;
}
 
Example 17
Source File: Zend2PhpFrameworkProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isInPhpModule(PhpModule phpModule) {
    if (phpModule.isBroken()) {
        // broken project
        return false;
    }
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        // broken project
        return false;
    }
    FileObject config = sourceDirectory.getFileObject("config/application.config.php"); // NOI18N
    return config != null && config.isData() && config.isValid();
}
 
Example 18
Source File: CIPhpFrameworkProvider.java    From nb-ci-plugin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public PhpModuleProperties getPhpModuleProperties(PhpModule pm) {
    FileObject sourceDirectory = pm.getSourceDirectory();
    PhpModuleProperties properties = new PhpModuleProperties();
    if (sourceDirectory != null) {
        FileObject application = sourceDirectory.getFileObject(CIPhpFramework.DIRECTORY_APPLICATION);

        if (application != null) {
            properties = properties.setWebRoot(application);
        }
    }

    // TODO
    return properties;
}
 
Example 19
Source File: ZendPhpFrameworkProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isInPhpModule(PhpModule phpModule) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        // broken project
        return false;
    }
    FileObject zfProject = sourceDirectory.getFileObject(".zfproject.xml"); // NOI18N
    return zfProject != null && zfProject.isData() && zfProject.isValid();
}
 
Example 20
Source File: CIPhpModuleCustomizerExtender.java    From nb-ci-plugin with GNU General Public License v2.0 4 votes vote down vote up
public CIPhpModuleCustomizerExtender(PhpModule pm) {
    component = new CICustomizerPanel(pm.getSourceDirectory());
    component.setSupportEnabled(CIPreferences.isEnabled(pm));
    component.setCustomLibraryPaths(CIPreferences.getCustomLibraryPaths(pm));
    component.setVersion(CIPreferences.getVersion(pm));
}