本文整理汇总了Java中org.netbeans.api.project.FileOwnerQuery类的典型用法代码示例。如果您正苦于以下问题:Java FileOwnerQuery类的具体用法?Java FileOwnerQuery怎么用?Java FileOwnerQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileOwnerQuery类属于org.netbeans.api.project包,在下文中一共展示了FileOwnerQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPersistenceScope
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
private PersistenceScope getPersistenceScope() {
if (treePathHandle == null) {
return null;
}
Project project = FileOwnerQuery.getOwner(treePathHandle.getFileObject());
if (project == null) {
return null;
}
PersistenceScopes scopes = PersistenceScopes.getPersistenceScopes(project);
if (scopes == null) {
return null; // project of this type doesn't provide a list of persistence scopes
}
if (scopes.getPersistenceScopes().length == 0) {
return null;
}
return scopes.getPersistenceScopes()[0];
}
示例2: isOnSourceClasspath
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
public static boolean isOnSourceClasspath(FileObject fo) {
Project p = FileOwnerQuery.getOwner(fo);
if (p==null) {
return false;
}
if (OpenProjects.getDefault().isProjectOpen(p)) {
SourceGroup[] gr = ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
for (int j = 0; j < gr.length; j++) {
if (fo==gr[j].getRootFolder()) {
return true;
}
if (FileUtil.isParentOf(gr[j].getRootFolder(), fo)) {
return true;
}
}
return false;
}
return false;
}
示例3: getPersistenceXmls
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
/**
* Gets the persistence.xml files in the project to which the given
* <code>refactoringSource</code> belongs.
* @param refactoringSource
* @return the persistence.xml files in the project to which the refactored
* class belongs or an empty list if the class does not belong to any project.
*/
protected final List<FileObject> getPersistenceXmls(FileObject refactoringSource){
Project project = FileOwnerQuery.getOwner(refactoringSource);
if (project == null){
return Collections.<FileObject>emptyList();
}
List<FileObject> result = new ArrayList<FileObject>();
PersistenceScope[] persistenceScopes = PersistenceUtils.getPersistenceScopes(project);
for (int i = 0; i < persistenceScopes.length; i++) {
FileObject persistenceXmlFo = persistenceScopes[i].getPersistenceXml();
if(persistenceXmlFo != null) {
result.add(persistenceXmlFo);
}
}
return result;
}
示例4: getMainClasses
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
@Override
public Set<SourceClassInfo> getMainClasses(final FileObject fo) {
final Set<SourceClassInfo> mainClasses = new HashSet<SourceClassInfo>();
Project p = FileOwnerQuery.getOwner(fo);
if (p == null) {
return Collections.EMPTY_SET;
}
ClasspathInfo cpInfo = ClasspathInfoFactory.infoFor(p);
for(ElementHandle<TypeElement> handle : SourceUtils.getMainClasses(fo)) {
mainClasses.add(new JavacClassInfo(handle, cpInfo));
}
return mainClasses;
}
示例5: isTestClass
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
public static boolean isTestClass(Node activatedNode) {
FileObject fileObject = org.netbeans.modules.gsf.testrunner.ui.api.UICommonUtils.getFileObjectFromNode(activatedNode);
if (fileObject != null && CommonTestUtil.isJavaFile(fileObject)) {
Project project = FileOwnerQuery.getOwner(fileObject);
if (project != null) {
SourceGroup[] javaSGs = new JavaUtils(project).getJavaSourceGroups();
for (int i = 0; i < javaSGs.length; i++) {
SourceGroup javaSG = javaSGs[i];
FileObject rootFolder = javaSG.getRootFolder();
URL[] testRoots = UnitTestForSourceQuery.findUnitTests(rootFolder);
URL[] sourceRoots = UnitTestForSourceQuery.findSources(rootFolder);
if (((fileObject == rootFolder) || FileUtil.isParentOf(rootFolder, fileObject)) && javaSG.contains(fileObject)) {
// activated FO is contained in the javaSG source group
if (testRoots.length == 0 && sourceRoots.length > 0) {
// javaSG has corresponding source root but no corresponding test root,
// thus the activated FO is a test class, so activate action
return true;
}
}
}
}
}
return false;
}
示例6: getRootNodes
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
private static List<Node> getRootNodes(Project prj,
List<FileObject> roots,
FilteredNode.NodeFilter filter,
boolean includeFiles) {
List<Node> nodes = new ArrayList<Node>(roots.size());
for (FileObject rfo : roots) {
try {
if (includeFiles || (FileUtil.toFile(rfo)!=null)) {
Project owner = org.netbeans.api.project.FileOwnerQuery.getOwner(rfo);
Node origNode = DataObject.find(rfo).getNodeDelegate();
FilteredNode node = new FilteredNode(origNode,filter, getDisplayName(rfo, owner, prj!=owner));
nodes.add(node);
}
} catch (org.openide.loaders.DataObjectNotFoundException ex) {}
}
return nodes;
}
示例7: getChatLink
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
public static String getChatLink(FileObject fo, int line) {
ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
String ret = ""; // NOI18N
if (cp != null) {
ret = cp.getResourceName(fo);
} else {
Project p = FileOwnerQuery.getOwner(fo);
if (p != null) {
ret = "{$" + // NOI18N
ProjectUtils.getInformation(p).getName() +
"}/" + // NOI18N
FileUtil.getRelativePath(p.getProjectDirectory(), fo);
} else {
ret = fo.getPath();
}
}
ret += ":" + line; // NOI18N
ret = "FILE:" + ret; // NOI18N
return ret;
}
示例8: enable
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
protected boolean enable(Node[] node) {
if (node.length == 0) {
return false;
}
DataObject dobj = (DataObject) node[0].getLookup().lookup(DataObject.class);
if (dobj == null) {
return false;
}
FileObject fo = dobj.getPrimaryFile();
Project project = FileOwnerQuery.getOwner(fo);
if(project == null)
return false;
Sources sources = ProjectUtils.getSources(project);
SourceGroup[] srcGrps = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
if (srcGrps == null || srcGrps.length == 0) {
return false;
} else {
return true;
}
}
示例9: getIcon
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
@Override public Icon getIcon() {
if (!art.getVersion().isEmpty()) {
try {
Project p = FileOwnerQuery.getOwner(RepositoryUtil.downloadArtifact(art).toURI());
if (p != null) {
return ProjectUtils.getInformation(p).getIcon();
}
} catch (Exception x) {
LOG.log(Level.FINE, null, "could not check project icon for " + art);
}
return ImageUtilities.loadImageIcon(IconResources.ICON_DEPENDENCY_JAR, true);
} else if (!art.getArtifactId().isEmpty()) {
// XXX should probably be moved into NodeUtils
return ImageUtilities.loadImageIcon("org/netbeans/modules/maven/repository/ArtifactBadge.png", true);
} else {
return ImageUtilities.image2Icon(NodeUtils.getTreeFolderIcon(false));
}
}
示例10: isOnSourceClasspath
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
/**
* Is given file on any source classpath?
*
* @param fo
* @return
* @deprecated
*/
@Deprecated
public static boolean isOnSourceClasspath(FileObject fo) {
Project pr = FileOwnerQuery.getOwner(fo);
if (pr == null) {
return false;
}
//workaround for 143542
for (String type : new String[]{JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_TYPE_RESOURCES}) {
for (SourceGroup sg : ProjectUtils.getSources(pr).getSourceGroups(type)) {
if (fo == sg.getRootFolder() || (FileUtil.isParentOf(sg.getRootFolder(), fo) && sg.contains(fo))) {
return ClassPath.getClassPath(fo, ClassPath.SOURCE) != null;
}
}
}
return false;
//end of workaround
//return ClassPath.getClassPath(fo, ClassPath.SOURCE)!=null;
}
示例11: getJavaSource
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
public static JavaSource getJavaSource(Document doc) {
FileObject fileObject = NbEditorUtilities.getFileObject(doc);
if (fileObject == null) {
return null;
}
Project project = FileOwnerQuery.getOwner(fileObject);
if (project == null) {
return null;
}
// XXX this only works correctly with projects with a single sourcepath,
// but we don't plan to support another kind of projects anyway (what about Maven?).
// mkleint: Maven has just one sourceroot for java sources, the config files are placed under
// different source root though. JavaProjectConstants.SOURCES_TYPE_RESOURCES
SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
for (SourceGroup sourceGroup : sourceGroups) {
return JavaSource.create(ClasspathInfo.create(sourceGroup.getRootFolder()));
}
return null;
}
示例12: rememberLibraryLocation
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
private void rememberLibraryLocation() {
libraryWithinProject = false;
absolutesRelPath = null;
libraryPath = helper.getAntProjectHelper().getLibrariesLocation();
if (libraryPath != null) {
File prjRoot = FileUtil.toFile(project.getProjectDirectory());
libraryFile = PropertyUtils.resolveFile(prjRoot, libraryPath);
if (FileOwnerQuery.getOwner(Utilities.toURI(libraryFile)) == project &&
libraryFile.getAbsolutePath().startsWith(prjRoot.getAbsolutePath())) {
//do not update the relative path if within the project..
libraryWithinProject = true;
FileObject fo = FileUtil.toFileObject(libraryFile);
if (new File(libraryPath).isAbsolute() && fo != null) {
// if absolte path within project, it will get moved/copied..
absolutesRelPath = FileUtil.getRelativePath(project.getProjectDirectory(), fo);
}
}
}
}
示例13: applyPatch
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
@Override
public void applyPatch(final File patchFile) {
UIUtils.runInAWT(new Runnable() {
@Override
public void run() {
final File context = selectPatchContext();
if (context != null) {
RP.post(new Runnable() {
@Override
public void run() {
try {
PatchUtils.applyPatch(patchFile, context);
Project project = FileOwnerQuery.getOwner(Utilities.toURI(context));
if(project != null && !OpenProjects.getDefault().isProjectOpen(project)) {
OpenProjects.getDefault().open(new Project[] {project}, false);
}
} catch (IOException ex) {
LOG.log(Level.INFO, ex.getMessage(), ex);
}
}
});
}
}
});
}
示例14: FileChooser
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
/**
* Create chooser for given AntProjectHelper. Standard file chooser is shown
* if project is not sharable.
*
* @param helper ant project helper; cannot be null
* @param copyAllowed is file copying allowed
*/
public FileChooser(AntProjectHelper helper, boolean copyAllowed) {
super();
FileObject projectFolder = helper.getProjectDirectory();
Project p = projectFolder != null ? FileOwnerQuery.getOwner(projectFolder): null;
LibraryManager lm = p != null ? ReferenceHelper.getProjectLibraryManager(p) : null;
if (lm != null) {
URL u = lm.getLocation();
if (u != null) {
File libBase = Utilities.toFile(URI.create(u.toExternalForm())).getParentFile();
accessory = new FileChooserAccessory(this, FileUtil.toFile(helper.getProjectDirectory()),
libBase, copyAllowed);
setAccessory(accessory);
}
}
}
示例15: getOwningMavenProject
import org.netbeans.api.project.FileOwnerQuery; //导入依赖的package包/类
private Project getOwningMavenProject(FileObject file) {
Project prj = FileOwnerQuery.getOwner(file);
if (prj == null || !prj.equals(project)) {
return null;
}
//#180447
if (!prj.getProjectDirectory().isValid()) {
return null;
}
NbMavenProject mvn = prj.getLookup().lookup(NbMavenProject.class);
if (mvn == null) {
return null;
}
if (RunUtils.isCompileOnSaveEnabled(prj)) {
return prj;
}
return null;
}