当前位置: 首页>>代码示例>>Java>>正文


Java PersistenceLibrarySupport.getProvidersFromLibraries方法代码示例

本文整理汇总了Java中org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport.getProvidersFromLibraries方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceLibrarySupport.getProvidersFromLibraries方法的具体用法?Java PersistenceLibrarySupport.getProvidersFromLibraries怎么用?Java PersistenceLibrarySupport.getProvidersFromLibraries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport的用法示例。


在下文中一共展示了PersistenceLibrarySupport.getProvidersFromLibraries方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSupportedProviders

import org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport; //导入方法依赖的package包/类
@Override
public List<Provider> getSupportedProviders() {
    List<Provider> model = new ArrayList<Provider>();
    //get all, but remove duplicates
    for (Provider each : PersistenceLibrarySupport.getProvidersFromLibraries()) {
        boolean found = false;
        for (int i = 0; i < model.size(); i++) {
            Object elem = model.get(i);
            if (elem instanceof Provider && each.equals(elem)) {
                found = true;
                break;
            }
        }
        if (!found) {
            model.add(each);
        }
    }
    return model;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Util.java

示例2: getSupportedProviders

import org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport; //导入方法依赖的package包/类
@Override
public List<Provider> getSupportedProviders() {
    ArrayList<Provider> providers = new ArrayList<Provider>();
    for (Provider each : PersistenceLibrarySupport.getProvidersFromLibraries()){
        boolean found = false;
        for (int i = 0; i < providers.size(); i++) {
            Object elem = providers.get(i);
            if (elem instanceof Provider && each.equals(elem)){
                found = true;
                break;
            }
        }
        if (!found){
           providers.add(each);
        }
    }
    return providers;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:PersistenceProviderComboboxHelper.java

示例3: isValid

import org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport; //导入方法依赖的package包/类
@Override
public boolean isValid() {
    SourceGroup sourceGroup = getComponent().getLocationValue();
    if (sourceGroup == null) {
        setErrorMessage(NbBundle.getMessage(EntityClassesPanel.class, "ERR_JavaTargetChooser_SelectSourceGroup"));
        return false;
    }

    String packageName = getComponent().getPackageName();
    if (packageName.trim().equals("")) { // NOI18N
        setErrorMessage(NbBundle.getMessage(EntityClassesPanel.class, "ERR_JavaTargetChooser_CantUseDefaultPackage"));
        return false;
    }

    if (!JavaIdentifiers.isValidPackageName(packageName)) {
        setErrorMessage(NbBundle.getMessage(EntityClassesPanel.class,"ERR_JavaTargetChooser_InvalidPackage")); //NOI18N
        return false;
    }

    if (!SourceGroups.isFolderWritable(sourceGroup, packageName)) {
        setErrorMessage(NbBundle.getMessage(EntityClassesPanel.class, "ERR_JavaTargetChooser_UnwritablePackage")); //NOI18N
        return false;
    }

    // issue 92192: need to check that we will have a persistence provider
    // available to add to the classpath while generating entity classes (unless
    // the classpath already contains one)
    ClassPath classPath = null;
    try {
        FileObject packageFO = SourceGroups.getFolderForPackage(sourceGroup, packageName, false);
        if (packageFO == null) {
            packageFO = sourceGroup.getRootFolder();
        }
        classPath = ClassPath.getClassPath(packageFO, ClassPath.COMPILE);
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, null, e);
    }
    if (classPath != null) {
        if (classPath.findResource("javax/persistence/EntityManager.class") == null) { // NOI18N
            // initialize the provider list lazily
            if (providers == null) {
                providers = PersistenceLibrarySupport.getProvidersFromLibraries();
            }
            if (providers.size() == 0) {
                setErrorMessage(NbBundle.getMessage(EntityClassesPanel.class, "ERR_NoJavaPersistenceAPI")); // NOI18N
                return false;
            }
        }
    } else {
        LOGGER.warning("Cannot get a classpath for package " + packageName + " in " + sourceGroup); // NOI18N
    }

    SelectedTables selectedTables = getComponent().getSelectedTables();
    // check for null needed since isValid() can be called when
    // EntityClassesPanel.update() has not been called yet, e.g. from within
    // EntityClassesPanel.initialize()
    if (selectedTables != null) {
        String problem = selectedTables.getFirstProblemDisplayName();
        if (problem != null) {
            setErrorMessage(problem);
            return false;
        }
    }

    setErrorMessage(" "); // NOI18N
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:68,代码来源:EntityClassesPanel.java

示例4: isValid

import org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport; //导入方法依赖的package包/类
@Override
public boolean isValid() {
    SourceGroup sourceGroup = getComponent().getLocationValue();
    if (sourceGroup == null) {
        setErrorMessage(NbBundle.getMessage(DBScriptPanel.class, "ERR_JavaTargetChooser_SelectSourceGroup"));
        return false;
    }
    
    String packageName = getComponent().getPackageName();
    if (packageName.trim().equals("")) { // NOI18N
        setErrorMessage(NbBundle.getMessage(DBScriptPanel.class, "ERR_JavaTargetChooser_CantUseDefaultPackage"));
        return false;
    }
    
    if (!JavaIdentifiers.isValidPackageName(packageName)) {
        setErrorMessage(NbBundle.getMessage(DBScriptPanel.class, "ERR_JavaTargetChooser_InvalidPackage")); //NOI18N
        return false;
    }
    
    if (!SourceGroups.isFolderWritable(sourceGroup, packageName)) {
        setErrorMessage(NbBundle.getMessage(DBScriptPanel.class, "ERR_JavaTargetChooser_UnwritablePackage")); //NOI18N
        return false;
    }

    // issue 92192: need to check that we will have a persistence provider
    // available to add to the classpath while generating entity classes (unless
    // the classpath already contains one)
    ClassPath classPath = null;
    FileObject rPackageFO = null;
    try {
        FileObject packageFO = SourceGroups.getFolderForPackage(sourceGroup, packageName, false);
        rPackageFO = packageFO;
        if (packageFO == null) {
            packageFO = sourceGroup.getRootFolder();
        }
        classPath = ClassPath.getClassPath(packageFO, ClassPath.COMPILE);
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, null, e);
    }
    if (classPath != null) {
        if (classPath.findResource("javax/persistence/EntityManager.class") == null) { // NOI18N
            // initialize the provider list lazily
            if (providers == null) {
                providers = PersistenceLibrarySupport.getProvidersFromLibraries();
            }
            if (providers.isEmpty()) {
                setErrorMessage(NbBundle.getMessage(DBScriptPanel.class, "ERR_NoJavaPersistenceAPI")); // NOI18N
                return false;
            }
        }
    } else {
        LOGGER.log(Level.WARNING, "Cannot get a classpath for package {0} in {1}", new Object[]{packageName, sourceGroup}); // NOI18N
    }
    String name = getComponent().getScriptName().trim();
    if (name.length() == 0) {
        setErrorMessage(NbBundle.getMessage(DBScriptPanel.class, "ERR_JavaTargetChooser_InvalidNameLength0"));//NOI18N
        return false;
    }
    if (rPackageFO != null) {
        //check if file exist
        if (name.endsWith("." + EXTENSION)) {
            name = name.substring(0, name.length() - 4);
        }
        if (rPackageFO.getFileObject(name, EXTENSION) != null) {
            setErrorMessage(NbBundle.getMessage(DBScriptPanel.class, "ERR_JavaTargetChooser_InvalidNameExists", name));//NOI18N
            return false;
        }
    }
    if(deepVerify) {
        PersistenceEnvironment pe = project.getLookup().lookup(PersistenceEnvironment.class);
        List<String> problems = DBScriptWizard.run(project, null, pe, null, true);
        if(problems != null && !problems.isEmpty()){
            setErrorMessage(problems.get(0));
            return false;
        }
        deepVerify = false;
    }
    setErrorMessage(" "); // NOI18N
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:81,代码来源:DBScriptPanel.java

示例5: isValid

import org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport; //导入方法依赖的package包/类
@Override
public boolean isValid() {
    SourceGroup sourceGroup = getComponent().getLocationValue();
    if (sourceGroup == null) {
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_SelectSourceGroup"));
        return false;
    }

    String packageName = getComponent().getPackageName();
    if (packageName.trim().equals("")) { // NOI18N
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_CantUseDefaultPackage"));
        return false;
    }

    if (!JavaIdentifiers.isValidPackageName(packageName)) {
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_InvalidPackage")); //NOI18N
        return false;
    }

    if (!SourceGroupSupport.isFolderWritable(sourceGroup, packageName)) {
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_UnwritablePackage")); //NOI18N
        return false;
    }

    if (getComponent().getFileName().trim().equals("")) { // NOI18N
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_CantUseDefaultFileName"));
        return false;
    }

    // issue 92192: need to check that we will have a persistence provider
    // available to add to the classpath while generating entity classes (unless
    // the classpath already contains one)
    FileObject packageFO = SourceGroupSupport.getFolderForPackage(sourceGroup, packageName, false);
    if (packageFO == null) {
        packageFO = sourceGroup.getRootFolder();
    }
    ClassPath classPath = ClassPath.getClassPath(packageFO, ClassPath.COMPILE);

    if (classPath != null) {
        if (classPath.findResource("javax/persistence/EntityManager.class") == null) { // NOI18N
            // initialize the provider list lazily
            if (providers == null) {
                providers = PersistenceLibrarySupport.getProvidersFromLibraries();
            }
            if (providers.size() == 0) {
                setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_NoJavaPersistenceAPI")); // NOI18N
                return false;
            }
        }
    } else {
        LOGGER.warning("Cannot get a classpath for package " + packageName + " in " + sourceGroup); // NOI18N
    }

    SelectedTables selectedTables = getComponent().getSelectedTables();
    // check for null needed since isValid() can be called when
    // EntityClassesPanel.update() has not been called yet, e.g. from within
    // EntityClassesPanel.initialize()
    if (selectedTables != null) {
        String problem = selectedTables.getFirstProblemDisplayName();
        if (problem != null) {
            setErrorMessage(problem);
            return false;
        }
    }

    setErrorMessage(" "); // NOI18N
    return true;
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:69,代码来源:EntityClassesConfigurationPanel.java

示例6: isValid

import org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport; //导入方法依赖的package包/类
@Override
public boolean isValid() {
    SourceGroup sourceGroup = getComponent().getLocationValue();
    if (sourceGroup == null) {
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_SelectSourceGroup"));
        return false;
    }

    String packageName = getComponent().getPackageName();
    if (packageName.trim().equals("")) { // NOI18N
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_CantUseDefaultPackage"));
        return false;
    }

    if (!JavaIdentifiers.isValidPackageName(packageName)) {
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_InvalidPackage")); //NOI18N
        return false;
    }

    if (!SourceGroups.isFolderWritable(sourceGroup, packageName)) {
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_UnwritablePackage")); //NOI18N
        return false;
    }

    if (getComponent().getFileName().trim().equals("")) { // NOI18N
        setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_JavaTargetChooser_CantUseDefaultFileName"));
        return false;
    }

    // issue 92192: need to check that we will have a persistence provider
    // available to add to the classpath while generating entity classes (unless
    // the classpath already contains one)
    ClassPath classPath = null;
    try {
        FileObject packageFO = SourceGroups.getFolderForPackage(sourceGroup, packageName, false);
        if (packageFO == null) {
            packageFO = sourceGroup.getRootFolder();
        }
        classPath = ClassPath.getClassPath(packageFO, ClassPath.COMPILE);
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, null, e);
    }
    if (classPath != null) {
        if (classPath.findResource("javax/persistence/EntityManager.class") == null) { // NOI18N
            // initialize the provider list lazily
            if (providers == null) {
                providers = PersistenceLibrarySupport.getProvidersFromLibraries();
            }
            if (providers.size() == 0) {
                setErrorMessage(NbBundle.getMessage(EntityClassesConfigurationPanel.class, "ERR_NoJavaPersistenceAPI")); // NOI18N
                return false;
            }
        }
    } else {
        LOGGER.warning("Cannot get a classpath for package " + packageName + " in " + sourceGroup); // NOI18N
    }

    SelectedTables selectedTables = getComponent().getSelectedTables();
    // check for null needed since isValid() can be called when
    // EntityClassesPanel.update() has not been called yet, e.g. from within
    // EntityClassesPanel.initialize()
    if (selectedTables != null) {
        String problem = selectedTables.getFirstProblemDisplayName();
        if (problem != null) {
            setErrorMessage(problem);
            return false;
        }
    }

    setErrorMessage(" "); // NOI18N
    return true;
}
 
开发者ID:foxerfly,项目名称:Netbeans-JPA-Modeler,代码行数:73,代码来源:EntityClassesConfigurationPanel.java


注:本文中的org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport.getProvidersFromLibraries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。