Java Code Examples for org.netbeans.api.project.Sources#getSourceGroups()

The following examples show how to use org.netbeans.api.project.Sources#getSourceGroups() . 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: PersistenceUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * method check target compile classpath for presence of persitence classes of certain version
 * returns max supported specification
 * @param project
 * @return
 */
public static String getJPAVersion(Project target)
{
    String version=null;
    Sources sources=ProjectUtils.getSources(target);
    SourceGroup groups[]=sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    SourceGroup firstGroup=groups[0];
    FileObject fo=firstGroup.getRootFolder();
    ClassPath compile=ClassPath.getClassPath(fo, ClassPath.COMPILE);
    if(compile.findResource("javax/persistence/criteria/CriteriaUpdate.class")!=null) {
        version=Persistence.VERSION_2_1;
    } else if(compile.findResource("javax/persistence/criteria/JoinType.class")!=null) {
        version=Persistence.VERSION_2_0;
    } else if(compile.findResource("javax/persistence/Entity.class")!=null) {
        version=Persistence.VERSION_1_0;
    }
    return version;
}
 
Example 2
Source File: MavenSourcesImplTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testNewlyCreatedSourceGroup() throws Exception { // #200969
    TestFileUtils.writeFile(d, "pom.xml", "<project><modelVersion>4.0.0</modelVersion><groupId>g</groupId><artifactId>a</artifactId><version>0</version></project>");
    FileObject main = FileUtil.createFolder(d, "src/main/java");
    Project p = ProjectManager.getDefault().findProject(d);
    Sources s = ProjectUtils.getSources(p);
    SourceGroup[] grps = s.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    assertEquals(1, grps.length);
    assertEquals(main, grps[0].getRootFolder());
    MockChangeListener l = new MockChangeListener();
    s.addChangeListener(l);
    SourceGroup g2 = SourceGroupModifier.createSourceGroup(p, JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_HINT_TEST);
    l.assertEvent();
    grps = s.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    assertEquals(2, grps.length);
    assertEquals(main, grps[0].getRootFolder());
    assertEquals(g2, grps[1]);
}
 
Example 3
Source File: DefaultPlugin.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Finds a Java source group the given file belongs to.
 * 
 * @param  file  {@literal FileObject} to find a {@literal SourceGroup} for
 * @return  the found {@literal SourceGroup}, or {@literal null} if the given
 *          file does not belong to any Java source group
 */
private static SourceGroup findSourceGroup(FileObject file) {
    final Project project = FileOwnerQuery.getOwner(file);
    if (project == null) {
        return null;
    }

    Sources src = ProjectUtils.getSources(project);
    SourceGroup[] srcGrps = src.getSourceGroups(SOURCES_TYPE_JAVA);
    for (SourceGroup srcGrp : srcGrps) {
        FileObject rootFolder = srcGrp.getRootFolder();
        if (((file == rootFolder) || FileUtil.isParentOf(rootFolder, file)) 
                && srcGrp.contains(file)) {
            return srcGrp;
        }
    }
    return null;
}
 
Example 4
Source File: TargetEvaluator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Used by the ObjectNameWizard panel to set the target folder
 * gotten from the system wizard initially. 
 */
void setInitialFolder(DataFolder selectedFolder, Project p) {
    if (selectedFolder == null) {
        return;
    }
    FileObject targetFolder = selectedFolder.getPrimaryFile();
    Sources sources = ProjectUtils.getSources(p);
    SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    String packageName = null;
    for (int i = 0; i < groups.length && packageName == null; i++) {
        packageName = org.openide.filesystems.FileUtil.getRelativePath(groups[i].getRootFolder(), targetFolder);
        deployData.setWebApp(DeployData.getWebAppFor(groups[i].getRootFolder()));
    }
    if (packageName == null) {
        packageName = "";
    }
    setInitialPath(packageName);
}
 
Example 5
Source File: ClientDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void refreshSourceFolders() {
    ArrayList srcRootList = new ArrayList();
    
    Project project = FileOwnerQuery.getOwner(getPrimaryFile());
    if (project != null) {
        Sources sources = ProjectUtils.getSources(project);
        SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (int i = 0; i < groups.length; i++) {
            if (WebModule.getWebModule(groups [i].getRootFolder()) != null) {
                srcRootList.add(groups [i].getRootFolder());
                DataLoaderPool.getDefault().removeOperationListener(operationListener); //avoid being added multiple times
                DataLoaderPool.getDefault().addOperationListener(operationListener);
            }
        }
    }
    srcRoots = (FileObject []) srcRootList.toArray(new FileObject [srcRootList.size()]);
}
 
Example 6
Source File: AddDependencyAction.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void findCompileTimeDependencies(NbAndroidProject project, List<ArtifactData> compileDependecies) {
    final ClassPathProvider cpProvider = project.getLookup().lookup(ClassPathProvider.class);
    if (cpProvider != null) {
        Sources srcs = ProjectUtils.getSources(project);
        SourceGroup[] sourceGroups = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        Set<FileObject> roots = Sets.newHashSet();
        for (SourceGroup sg : sourceGroups) {
            roots.add(sg.getRootFolder());
        }
        Iterable<ClassPath> compileCPs = Iterables.transform(roots, new Function<FileObject, ClassPath>() {

            @Override
            public ClassPath apply(FileObject f) {
                return cpProvider.findClassPath(f, ClassPath.COMPILE);
            }
        });
        ClassPath compileCP
                = ClassPathSupport.createProxyClassPath(Lists.newArrayList(compileCPs).toArray(new ClassPath[0]));
        if (cpProvider instanceof AndroidClassPath) {
            for (FileObject cpRoot : compileCP.getRoots()) {
                ArtifactData lib = ((AndroidClassPath) cpProvider).getArtifactData(cpRoot.toURL());
                compileDependecies.add(lib);
            }
        }
    }
}
 
Example 7
Source File: DocRenderer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("PHPPlatform=PHP Platform")
private static String getLocation(PhpElement indexedElement) {
    String location = null;
    if (indexedElement.isPlatform()) {
        location = Bundle.PHPPlatform();
    } else {
        FileObject fobj = indexedElement.getFileObject();
        if (fobj != null) {
            Project project = FileOwnerQuery.getOwner(fobj);
            if (project != null) {
                // find the appropriate source root
                Sources sources = ProjectUtils.getSources(project);
                // TODO the PHPSOURCE constatnt has to be published in the project api
                for (SourceGroup group : sources.getSourceGroups("PHPSOURCE")) {
                    //NOI18N
                    String relativePath = FileUtil.getRelativePath(group.getRootFolder(), fobj);
                    if (relativePath != null) {
                        location = relativePath;
                        break;
                    }
                }
                if (location == null) {
                    // just to be sure, that the relative location was resolved
                    location = fobj.getPath();
                }
            } else {
                location = indexedElement.getFilenameUrl();
            }
        }
    }
    return location;
}
 
Example 8
Source File: ClassNamePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateRoots() {
    enableDisable();
    if (project == null) {
        return;
    }
    Sources sources = ProjectUtils.getSources(project);
    groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    // XXX why?? This is probably wrong. If the project has no Java groups,
    // you cannot move anything into it.
    if (groups.length == 0) {
        groups = sources.getSourceGroups( Sources.TYPE_GENERIC ); 
    }
    
    int preselectedItem = 0;
    if (anchor != null) {
        for( int i = 0; i < groups.length; i++ ) {
            if (groups[i].contains(anchor)) {
                preselectedItem = i;
                break;
            }
        }
    }
            
    // Setup comboboxes 
    locationSelect.setModel(new DefaultComboBoxModel(groups));
    if(groups.length > 0) {
        locationSelect.setSelectedIndex(preselectedItem);
    }
}
 
Example 9
Source File: ClientProjectUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static FileObject getSiteRoot(Project project) {
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = sources.getSourceGroups(WebClientProjectConstants.SOURCES_TYPE_HTML5_SITE_ROOT);
    if (sourceGroups.length == 0 ) {
        return project.getProjectDirectory().getFileObject("www");
    }
    return sourceGroups[0].getRootFolder();
}
 
Example 10
Source File: RestControllerWizardIterator.java    From nb-springboot with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    wizard.putProperty(WIZ_CRUD_METHODS, false);
    wizard.putProperty(WIZ_ERROR_HANDLING, 0);
    Project project = Templates.getProject(wizard);
    Sources src = ProjectUtils.getSources(project);
    SourceGroup[] groups = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    panel = JavaTemplates.createPackageChooser(project, groups, new RestControllerWizardPanel1(), true);
    // force creation of visual part
    JComponent cmp = (JComponent) panel.getComponent();
    cmp.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 0);
    cmp.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, TemplateUtils.createSteps(wizard, new String[]{cmp.getName()}));
}
 
Example 11
Source File: TagInfoPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void readSettings(Object settings) {
    TemplateWizard w = (TemplateWizard)settings;
    //Project project = Templates.getProject(w);
    String targetName = w.getTargetName();
    org.openide.filesystems.FileObject targetFolder = Templates.getTargetFolder(w);
    Project project = Templates.getProject( w );
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    String packageName = null;
    for (int i = 0; i < groups.length && packageName == null; i++) {
        packageName = org.openide.filesystems.FileUtil.getRelativePath (groups [i].getRootFolder (), targetFolder);
    }
    if (packageName == null)
        packageName = ""; //NOI18N
    packageName = packageName.replace('/','.');
    
    if (targetName!=null) {
        if (packageName.length()>0)
            className=packageName+"."+targetName;//NOI18N
        else
            className=targetName;
        component.setClassName(className);
        if (component.getTagName().length()==0)
            component.setTagName(targetName);
    }
    Boolean bodySupport = (Boolean)w.getProperty("BODY_SUPPORT");//NOI18N
    if (bodySupport!=null && bodySupport.booleanValue()) 
        component.setBodySupport(true);
    else component.setBodySupport(false);
}
 
Example 12
Source File: ReactRestControllerWizardIterator.java    From nb-springboot with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    wizard.putProperty(WIZ_CRUD_METHODS, false);
    wizard.putProperty(WIZ_ERROR_HANDLING, 0);
    Project project = Templates.getProject(wizard);
    Sources src = ProjectUtils.getSources(project);
    SourceGroup[] groups = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    panel = JavaTemplates.createPackageChooser(project, groups, new RestControllerWizardPanel1(), true);
    // force creation of visual part
    JComponent cmp = (JComponent) panel.getComponent();
    cmp.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 0);
    cmp.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, TemplateUtils.createSteps(wizard, new String[]{cmp.getName()}));
}
 
Example 13
Source File: AbstractIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(TemplateWizard wizard) {
    WizardDescriptor.Panel<WizardDescriptor> folderPanel;
    Project project = Templates.getProject(wizard);
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_WEB_INF);
    if (sourceGroups.length == 0) {
        sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_DOC_ROOT);
    }
    if (sourceGroups.length == 0) {
        sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
    }
    folderPanel = Templates.buildSimpleTargetChooser(project, sourceGroups).create();
    folderPanel = new ValidationPanel(wizard, folderPanel);
    panels = new WizardDescriptor.Panel[]{folderPanel};

    // Creating steps.
    Object prop = wizard.getProperty(WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
    String[] beforeSteps = null;
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[]) prop;
    }
    String[] steps = createSteps(beforeSteps, panels);

    for (int i = 0; i < panels.length; i++) {
        JComponent jc = (JComponent) panels[i].getComponent();
        if (steps[i] == null) {
            steps[i] = jc.getName();
        }
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (i)); // NOI18N
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
    }

    Templates.setTargetName(wizard, getDefaultName());
    Templates.setTargetFolder(wizard, getTargetFolder(project));
}
 
Example 14
Source File: WebReplaceTokenProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String convertJavaAction(String action, FileObject fo) {
    //TODO sorty of clashes with .main (if both servlet and main are present.
    // also prohitibs any other conversion method.
    if ( fo.getAttribute(ATTR_EXECUTION_URI) == null && servletFilesScanning(fo)) {
        return null;
    }
    Sources srcs = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    for (SourceGroup group : sourceGroups) {
        if (!"2TestSourceRoot".equals(group.getName())) { //NOI18N hack
            String relPath = FileUtil.getRelativePath(group.getRootFolder(), fo);
            if (relPath != null) {
                if (fo.getAttribute(ATTR_EXECUTION_URI) != null ||
                        Boolean.TRUE.equals(fo.getAttribute(IS_SERVLET_FILE))) {//NOI18N
                    return action + ".deploy"; //NOI18N
                }
                if (isServletFile(fo,false))  {
                    try {
                        fo.setAttribute(IS_SERVLET_FILE, Boolean.TRUE);
                    } catch (java.io.IOException ex) {
                        //we tried
                    }
                    return action + ".deploy"; //NOI18N
                }
            }
        }
    }
    return null;
}
 
Example 15
Source File: WebProjectClassPathModifierTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testRemoveRoots() throws Exception {
    File f = new File(getDataDir().getAbsolutePath(), "projects/WebApplication1");
    FileObject projdir = FileUtil.toFileObject(f);
    WebProject webProject = (WebProject) ProjectManager.getDefault().findProject(projdir);
    
    Sources sources = ProjectUtils.getSources(webProject);
    SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    FileObject srcJava = webProject.getSourceRoots().getRoots()[0];
    assertEquals("We should edit sources", "${src.dir}", groups[0].getName());
    String classPathProperty = webProject.getClassPathProvider().getPropertyName(groups[0], ClassPath.COMPILE)[0];
    
    AntProjectHelper helper = webProject.getAntProjectHelper();
    
    // create src folder
    final String srcFolder = "srcFolder";
    File folder = new File(getDataDir().getAbsolutePath(), srcFolder);
    if (folder.exists()) {
        folder.delete();
    }
    FileUtil.createFolder(folder);
    URL[] cpRoots = new URL[]{folder.toURL()};
    
    // init
    EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    String cpProperty = props.getProperty(classPathProperty);
    boolean alreadyOnCp = cpProperty.indexOf(srcFolder) != -1;
    //assertFalse("srcFolder should not be on cp", alreadyInCp);
    
    // add
    boolean addRoots = ProjectClassPathModifier.addRoots(cpRoots, srcJava, ClassPath.COMPILE);
    // we do not check this - it can be already on cp (tests are created only before the 1st test starts)
    if (!alreadyOnCp) {
        assertTrue(addRoots);
    }
    props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    cpProperty = props.getProperty(classPathProperty);
    assertTrue("srcFolder should be on cp", cpProperty.indexOf(srcFolder) != -1);
    
    // simulate #113390
    folder.delete();
    assertFalse("srcFolder should not exist.", folder.exists());
    
    // remove
    boolean removeRoots = ProjectClassPathModifier.removeRoots(cpRoots, srcJava, ClassPath.COMPILE);
    assertTrue(removeRoots);
    props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    cpProperty = props.getProperty(classPathProperty);
    assertTrue("srcFolder should not be on cp", cpProperty.indexOf(srcFolder) == -1);
}
 
Example 16
Source File: NewKarmaConfWizardIterator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private SourceGroup[] getSourceGroups(Project project) {
    Sources sources = ProjectUtils.getSources(project);
    return sources.getSourceGroups(Sources.TYPE_GENERIC);
}
 
Example 17
Source File: DatabaseTablesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isValid() {


    // TODO: RETOUCHE
    //            if (JavaMetamodel.getManager().isScanInProgress()) {
    if (false){
        if (!waitingForScan) {
            waitingForScan = true;
            RequestProcessor.Task task = RequestProcessor.getDefault().create(new Runnable() {
                @Override
                public void run() {
                    // TODO: RETOUCHE
                    //                            JavaMetamodel.getManager().waitScanFinished();
                    waitingForScan = false;
                    changeSupport.fireChange();
                }
            });
            setErrorMessage(NbBundle.getMessage(DatabaseTablesPanel.class, "scanning-in-progress"));
            task.schedule(0);
        }
        return false;
    }
    Sources sources=ProjectUtils.getSources(project);
    SourceGroup groups[]=sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if(groups == null || groups.length == 0) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesPanel.class,"ERR_JavaSourceGroup")); //NOI18N
        getComponent().datasourceComboBox.setEnabled(false);
        getComponent().dbschemaComboBox.setEnabled(false);
        return false;
    }

    if (SourceLevelChecker.isSourceLevel14orLower(project)) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesPanel.class, "ERR_NeedProperSourceLevel"));
        return false;
    }

    if (getComponent().getSourceSchemaElement() == null) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesPanel.class, "ERR_SelectTableSource"));
        return false;
    }

    if (getComponent().getTableClosure().getSelectedTables().size() <= 0) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesPanel.class, "ERR_SelectTables"));
        return false;
    }

    // any view among selected tables?
    for (Table table : getComponent().getTableClosure().getSelectedTables()) {
        if (!table.isTable()) {
            setWarningMessage(NbBundle.getMessage(DatabaseTablesPanel.class, "MSG_ViewSelected"));
            return true;
        }
    }

    setErrorMessage(" "); // NOI18N

    if (!ProviderUtil.isValidServerInstanceOrNone(project)) {
        setWarningMessage(NbBundle.getMessage(DatabaseTablesPanel.class, "ERR_MissingServer"));
    }

    return true;
}
 
Example 18
Source File: SAMLHolderOfKeyProfile.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setClientDefaults(WSDLComponent component, WSDLComponent serviceBinding, Project p) {
        ProprietarySecurityPolicyModelHelper.setStoreLocation(component, null, false, true);
        ProprietarySecurityPolicyModelHelper.setStoreLocation(component, null, true, true);
        ProprietarySecurityPolicyModelHelper.removeCallbackHandlerConfiguration((Binding) component);
//        if (Util.isTomcat(p)) {
            String kstoreLoc = ServerUtils.getStoreLocation(p, false, true);
            ProprietarySecurityPolicyModelHelper.setStoreLocation(component, kstoreLoc, false, true);
            ProprietarySecurityPolicyModelHelper.setStoreType(component, KeystorePanel.JKS, false, true);
            ProprietarySecurityPolicyModelHelper.setStorePassword(component, KeystorePanel.DEFAULT_PASSWORD, false, true);

            String tstoreLoc = ServerUtils.getStoreLocation(p, true, true);
            ProprietarySecurityPolicyModelHelper.setStoreLocation(component, tstoreLoc, true, true);
            ProprietarySecurityPolicyModelHelper.setStoreType(component, KeystorePanel.JKS, true, true);
            ProprietarySecurityPolicyModelHelper.setStorePassword(component, KeystorePanel.DEFAULT_PASSWORD, true, true);
//        }
        ProprietarySecurityPolicyModelHelper.setKeyStoreAlias(component, ProfilesModelHelper.XWS_SECURITY_CLIENT, true);
        ProprietarySecurityPolicyModelHelper.setTrustPeerAlias(component, ProfilesModelHelper.XWS_SECURITY_SERVER, true);

        FileObject targetFolder = null;
        
        Sources sources = ProjectUtils.getSources(p);
        SourceGroup[] sourceGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        if ((sourceGroups != null) && (sourceGroups.length > 0)) {
            targetFolder = sourceGroups[0].getRootFolder();
        }
        
        SamlCallbackCreator samlCreator = new SamlCallbackCreator();
        String samlVersion = getSamlVersion((Binding)serviceBinding);
        String cbName = "SamlCallbackHandler";
        
        if (targetFolder != null) {
            if (targetFolder.getFileObject(PKGNAME) == null) {
                try {
                    targetFolder = targetFolder.createFolder(PKGNAME);
                } catch (IOException ex) {
                    Logger.getLogger("global").log(Level.SEVERE, null, ex);
                }
            } else {
                targetFolder = targetFolder.getFileObject(PKGNAME);
            }
            if (ComboConstants.SAML_V2011.equals(samlVersion)) {
                cbName = "Saml20HOKCallbackHandler";
                if (targetFolder.getFileObject(cbName, "java") == null) {
                    samlCreator.generateSamlCBHandler(targetFolder, 
                        cbName, SamlCallbackCreator.HOK, SamlCallbackCreator.SAML20);
                }
            } else {
                cbName = "Saml11HOKCallbackHandler";
                if (targetFolder.getFileObject(cbName, "java") == null) {
                    samlCreator.generateSamlCBHandler(targetFolder, 
                        cbName, SamlCallbackCreator.HOK, SamlCallbackCreator.SAML11);
                }
            }
        }
        ProprietarySecurityPolicyModelHelper.setCallbackHandler(
                (Binding)component, CallbackHandler.SAML_CBHANDLER, PKGNAME + "." + cbName, null, true);
    }
 
Example 19
Source File: DatabaseTablesSelectorPanel.java    From jeddict with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isValid() {

    // TODO: RETOUCHE
    //            if (JavaMetamodel.getManager().isScanInProgress()) {
    if (false) {
        if (!waitingForScan) {
            waitingForScan = true;
            RequestProcessor.Task task = RequestProcessor.getDefault().create(() -> {
                // TODO: RETOUCHE
                //                            JavaMetamodel.getManager().waitScanFinished();
                waitingForScan = false;
                changeSupport.fireChange();
            });
            setErrorMessage(NbBundle.getMessage(DatabaseTablesSelectorPanel.class, "scanning-in-progress"));
            task.schedule(0);
        }
        return false;
    }
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup groups[] = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (groups == null || groups.length == 0) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesSelectorPanel.class, "ERR_JavaSourceGroup")); //NOI18N
        getComponent().datasourceComboBox.setEnabled(false);
        getComponent().dbschemaComboBox.setEnabled(false);
        return false;
    }

    if (!cmp && SourceLevelChecker.isSourceLevel14orLower(project)) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesSelectorPanel.class, "ERR_NeedProperSourceLevel"));
        return false;
    }

    if (getComponent().getSourceSchemaElement() == null) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesSelectorPanel.class, "ERR_SelectTableSource"));
        return false;
    }

    if (getComponent().getTableClosure().getSelectedTables().size() <= 0) {
        setErrorMessage(NbBundle.getMessage(DatabaseTablesSelectorPanel.class, "ERR_SelectTables"));
        return false;
    }

    // any view among selected tables?
    for (Table table : getComponent().getTableClosure().getSelectedTables()) {
        if (!table.isTable()) {
            setWarningMessage(NbBundle.getMessage(DatabaseTablesSelectorPanel.class, "MSG_ViewSelected"));
            return true;
        }
    }
    setErrorMessage(" "); // NOI18N
    return true;
}
 
Example 20
Source File: SourcesHelperTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testMinimalSubfolders () throws Exception {
    scratch = TestUtil.makeScratchDir(this); // have our own setup
    maindir = scratch.createFolder("dir");
    projdir = maindir.createFolder("proj-dir");
    src1dir = maindir.createFolder("src1");
    
    // <editor-fold desc="create files in group #1">
    FileUtil.createData(src1dir, "com/sun/tools/javac/Main.java");
    FileUtil.createData(src1dir, "com/sun/tools/internal/ws/processor/model/java/JavaArrayType.java");
    FileUtil.createData(src1dir, "sun/tools/javac/Main.java");
    FileUtil.createData(src1dir, "sunw/io/Serializable.java");
    FileUtil.createData(src1dir, "java/lang/Byte.java");
    FileUtil.createData(src1dir, "java/text/resources/Messages.properties");
    FileUtil.createData(src1dir, "java/text/resources/Messages_zh.properties");
    FileUtil.createData(src1dir, "java/text/resources/Messages_zh_TW.properties");
    FileUtil.createData(src1dir, "java/text/resources/x_y/z.properties");
    // </editor-fold>
    
    // <editor-fold desc="other setup #1">
    h = ProjectGenerator.createProject(projdir, "test");
    project = ProjectManager.getDefault().findProject(projdir);
    EditableProperties p = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    p.setProperty("src1.dir", "../src1");
    // </editor-fold>
    // <editor-fold desc="includes & excludes">
    p.setProperty("src1.includes", "com/sun/tools/**");
    // </editor-fold>
    // <editor-fold desc="other setup #2">
    h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, p);
    ProjectManager.getDefault().saveProject(project);
    //minimalSubfolders = true
    sh = new SourcesHelper(project, h, h.getStandardPropertyEvaluator());
    sh.sourceRoot("${src1.dir}").includes("${src1.includes}").excludes("${src1.excludes}").displayName("Sources #1").add();
    sh.sourceRoot("${src1.dir}").type("java").includes("${src1.includes}").excludes("${src1.excludes}").displayName("Packages #1").add();
    sh.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT, true);
    Sources s = sh.createSources();
    SourceGroup[] groups = s.getSourceGroups("java");
    SourceGroup g1 = groups[0];
    assertEquals("Packages #1", g1.getDisplayName());
    assertNull(FileOwnerQuery.getOwner(src1dir));
    //minimalSubfolders = false
    sh = new SourcesHelper(project, h, h.getStandardPropertyEvaluator());
    sh.sourceRoot("${src1.dir}").includes("${src1.includes}").excludes("${src1.excludes}").displayName("Sources #1").add();
    sh.sourceRoot("${src1.dir}").type("java").includes("${src1.includes}").excludes("${src1.excludes}").displayName("Packages #1").add();
    sh.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT, false);
    s = sh.createSources();
    groups = s.getSourceGroups("java");
    g1 = groups[0];
    assertEquals("Packages #1", g1.getDisplayName());
    assertEquals(project, FileOwnerQuery.getOwner(src1dir));
}