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


Java RelatedCMPWizard类代码示例

本文整理汇总了Java中org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard的典型用法代码示例。如果您正苦于以下问题:Java RelatedCMPWizard类的具体用法?Java RelatedCMPWizard怎么用?Java RelatedCMPWizard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RelatedCMPWizard类属于org.netbeans.modules.j2ee.persistence.wizard.fromdb包,在下文中一共展示了RelatedCMPWizard类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPreferredProvider

import org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard; //导入依赖的package包/类
/**
 * check all available providers and return default/first/or ECLIPSELINK if prefereed
 * @param project
 * @return
 */
public static Provider getPreferredProvider(Project project){
    //choose default/first provider
    ArrayList<Provider> providers = getProviders(project);
    int defIndex = 0;
    if(providers.size()>1){//if it's possible to select preferred jpa2.0 provider, we'll select instead of jpa1.0 default one
        String defProviderVersion = ProviderUtil.getVersion((Provider) providers.get(0));
        boolean specialCase = (Util.isJPAVersionSupported(project, Persistence.VERSION_2_0) || Util.isJPAVersionSupported(project, Persistence.VERSION_2_1)) && (defProviderVersion == null || defProviderVersion.equals(Persistence.VERSION_1_0));//jpa 2.0 is supported by default (or first) is jpa1.0 or udefined version provider
        if(specialCase){
            for (int i = 1; i<providers.size() ; i++){
                if(ProviderUtil.ECLIPSELINK_PROVIDER.equals(providers.get(i))){//eclipselink jpa2.1 is preferred provider
                    defIndex = i;
                    break;
                }
            }
        }
    }
    if(providers.isEmpty()) {
        Logger.getLogger(RelatedCMPWizard.class.getName()).log(Level.INFO, "Can't find any providers supported by the project: {0}", project); //NOI18N
    }
    return providers.size()>0 ? providers.get(defIndex) : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Util.java

示例2: getDefaultProvider

import org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard; //导入依赖的package包/类
public static Provider getDefaultProvider(Project project) {
    PersistenceProviderSupplier providerSupplier = project.getLookup().lookup(PersistenceProviderSupplier.class);
    if ((providerSupplier != null && providerSupplier.supportsDefaultProvider())) {
        List<Provider> providers = providerSupplier.getSupportedProviders();
        if (providers.size() > 0) {
            return providers.get(0);
        }
        Logger.getLogger(RelatedCMPWizard.class.getName()).log(Level.WARNING, "Default provider support is reported without any supported providers. See: {0}", providerSupplier);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Util.java

示例3: updatePersistenceUnitButton

import org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard; //导入依赖的package包/类
private void updatePersistenceUnitButton(boolean initial) {
    String warning = " "; // NOI18N
    if (warning.trim().length() == 0) {//may need to show warning about sourc level
        String sourceLevel = SourceLevelChecker.getSourceLevel(project);
        if (sourceLevel != null) {
            if (sourceLevel.matches("1\\.[0-5]([^0-9].*)?")) {//1.0-1.5
                Provider provider = Util.getPreferredProvider(project);
                if (provider != null) {
                    String ver = ProviderUtil.getVersion(provider);
                    if ((ver != null && !Persistence.VERSION_1_0.equals(ver))) {
                        if (Util.isJPAVersionSupported(project, ver)) {
                            warning = NbBundle.getMessage(RelatedCMPWizard.class, "ERR_WrongSourceLevel", sourceLevel);
                        } else {
                            warning = NbBundle.getMessage(RelatedCMPWizard.class, "ERR_UnsupportedJpaVersion", ver, Util.getJPAVersionSupported(project, ver));
                        }
                    }
                }
            }
        }

    }

    if (warning.trim().length() > 0) {
        Icon icon = ImageUtilities.loadImageIcon("org/netbeans/modules/j2ee/persistence/ui/resources/warning.gif", false);
        createPUWarningLabel.setIcon(icon);
        createPUWarningLabel.setText(warning);
        createPUWarningLabel.setToolTipText(warning);
    } else {
        createPUWarningLabel.setIcon(null);
        createPUWarningLabel.setText(" ");
        createPUWarningLabel.setToolTipText(null);

    }
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:35,代码来源:EntityClassesConfigurationPanel.java

示例4: addPersistenceUnitToProjectRoot

import org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard; //导入依赖的package包/类
/**
 * add pu to the project's root, add persistence libraries if appropriate and known
 * add db libraries for connection if it's not conteiner managed project
 * @param project
 * @param root
 * @param pu
 * @since 1.55
 */
public static void addPersistenceUnitToProjectRoot(Project project, FileObject root, PersistenceUnit persistenceUnit) {
    String providerClass = persistenceUnit.getProvider();
    boolean libAdded = false;
    Library lib = null;
    if (providerClass != null) {
        Provider selectedProvider = ProviderUtil.getProvider(providerClass, project);
        lib = PersistenceLibrarySupport.getLibrary(selectedProvider);
        if (lib != null) {
            if (!Util.isDefaultProvider(project, selectedProvider)) {
                Util.addLibraryToProject(project, lib);
                libAdded = true;
            } else if (selectedProvider.getAnnotationProcessor() != null) {
                Util.addLibraryToProject(project, lib, JavaClassPathConstants.PROCESSOR_PATH);
                libAdded = true;
            }
        }
        if (!isContainerManaged(project)) {
            DatabaseConnection connection = ProviderUtil.getConnection(persistenceUnit);
            if (connection != null) {
                JDBCDriver[] driver = JDBCDriverManager.getDefault().getDrivers(connection.getDriverClass());
                PersistenceLibrarySupport.addDriver(project, driver[0]);
            } else {
                Logger.getLogger("global").log(Level.INFO, "Can't find connection for persistence unit"); //NOI18N
            }
        }
    }

    try {
        ProviderUtil.addPersistenceUnit(persistenceUnit, project, root);
    } catch (InvalidPersistenceXmlException ipx) {
        // just log for debugging purposes, at this point the user has
        // already been warned about an invalid persistence.xml
        Logger.getLogger(RelatedCMPWizard.class.getName()).log(Level.FINE, "Invalid persistence.xml: " + ipx.getPath(), ipx); //NOI18N
    }
    //need to add ap registration lib if exist
    if (libAdded && lib != null) {
        String projVersion = PersistenceUtils.getJPAVersion(project);
        if( projVersion == null ) {
            projVersion = "1.0";
        }//NOI18N minimum version, will not affect
        double version = Math.max(Double.parseDouble(PersistenceUtils.getJPAVersion(lib)), Double.parseDouble(projVersion));
        if (version > 1.0 && Util.isJPAVersionSupported(project, Double.toString(version))) {
            Library mLib = LibraryManager.getDefault().getLibrary(lib.getName()+"modelgen");//NOI18N
            if(mLib!=null) {
                Util.addLibraryToProject(project, mLib, JavaClassPathConstants.PROCESSOR_PATH);
            }//no real need to add modelgen to compile classpath
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:Util.java


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