Java Code Examples for org.netbeans.api.project.ProjectInformation#getName()

The following examples show how to use org.netbeans.api.project.ProjectInformation#getName() . 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: SendJMSGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private String generateDestinationReference(EnterpriseReferenceContainer container, FileObject referencingFile, String referencingClass) throws IOException {
    // this may need to generalized later if jms producers are expected
    // in web modules
    ProjectInformation projectInformation = ProjectUtils.getInformation(mdbHolderProject);
    String link = projectInformation.getName() + ".jar#" + messageDestination.getName();
    Project referenceingProject = FileOwnerQuery.getOwner(referencingFile);
    if (mdbHolderProject.equals(referenceingProject)) {
        link = link.substring(link.indexOf('#') + 1);
    }
    MessageDestinationReference ref = MessageDestinationReference.create(
            messageDestination.getName(),
            messageDestination.getType() == MessageDestination.Type.QUEUE ? "javax.jms.Queue" : "javax.jms.Topic",
            PRODUCES,
            link
            );
    return container.addDestinationRef(ref, referencingFile, referencingClass);
}
 
Example 2
Source File: FeatureProjectFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public String getName() {
    ProjectInformation info = delegate.lookup(ProjectInformation.class);
    if (info != null && info != this) {
        return info.getName();
    }
    return dir.getNameExt();
}
 
Example 3
Source File: SunONEDeploymentConfiguration.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String getProjectName(File file) {
    String result = null;
    FileObject fo = FileUtil.toFileObject(file);
    if (fo != null) {
        Project project = FileOwnerQuery.getOwner(fo);
        if (project != null) {
            ProjectInformation info = ProjectUtils.getInformation(project);
            if (info != null) {
                result = info.getName();
            }
        }
    }
    return result;
}
 
Example 4
Source File: JSEApplicationClassChooser.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateText() {
    String className = getNewClassName();
    if (className == null) {
        ProjectInformation info = ProjectUtils.getInformation(project);
        className = info.getName(); //support.getParent().getCurrentFileName();
        String firstChar = String.valueOf(className.charAt(0)).toUpperCase();
        String otherChars = className.substring(1);
        className = firstChar + otherChars + NbBundle.getMessage(JSEApplicationClassChooser.class, "TXT_FileNameApplicationClassPostfix"); // NOI18N
        textFieldClassName.setText(className);
    }
}
 
Example 5
Source File: DefaultProjectConvertorServices.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
@NonNull
public String getName() {
    final ProjectInformation d = delegate;
    return d != null ?
        d.getName() :
        project.getProjectDirectory().getName();
}
 
Example 6
Source File: TemplateAttributesProviderImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, ?> attributesFor(DataObject template, DataFolder target, String name) {
    Map<String, String> values = new HashMap<String, String>();
    EditableProperties priv  = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
    EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    String licensePath = priv.getProperty("project.licensePath");
    if (licensePath == null) {
        licensePath = props.getProperty("project.licensePath");
    }
    if (licensePath != null) {
        licensePath = helper.getStandardPropertyEvaluator().evaluate(licensePath);
        if (licensePath != null) {
            File path = FileUtil.normalizeFile(helper.resolveFile(licensePath));
            if (path.exists() && path.isAbsolute()) { //is this necessary? should prevent failed license header inclusion
                URI uri = Utilities.toURI(path);
                licensePath = uri.toString();
                values.put("licensePath", licensePath);
            } else {
                LOG.log(Level.INFO, "project.licensePath value not accepted - " + licensePath);
            }
        }
    }
    String license = priv.getProperty("project.license"); // NOI18N
    if (license == null) {
        license = props.getProperty("project.license"); // NOI18N
    }
    if (license != null) {
        values.put("license", license); // NOI18N
    }
    Charset charset = encodingQuery.getEncoding(target.getPrimaryFile());
    String encoding = (charset != null) ? charset.name() : null;
    if (encoding != null) {
        values.put("encoding", encoding); // NOI18N
    }
    try {
        Project prj = ProjectManager.getDefault().findProject(helper.getProjectDirectory());
        ProjectInformation info = ProjectUtils.getInformation(prj);
        if (info != null) {
            String pname = info.getName();
            if (pname != null) {
                values.put("name", pname);// NOI18N
            }
            String pdname = info.getDisplayName();
            if (pdname != null) {
                values.put("displayName", pdname);// NOI18N
            }
        }
    } catch (Exception ex) {
        //not really important, just log.
        Logger.getLogger(TemplateAttributesProviderImpl.class.getName()).log(Level.FINE, "", ex);
    }

    if (values.isEmpty()) {
        return null;
    } else {
        return Collections.singletonMap("project", values); // NOI18N
    }
}