本文整理汇总了Java中org.netbeans.api.project.FileOwnerQuery.markExternalOwner方法的典型用法代码示例。如果您正苦于以下问题:Java FileOwnerQuery.markExternalOwner方法的具体用法?Java FileOwnerQuery.markExternalOwner怎么用?Java FileOwnerQuery.markExternalOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.project.FileOwnerQuery
的用法示例。
在下文中一共展示了FileOwnerQuery.markExternalOwner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: propertyChange
import org.netbeans.api.project.FileOwnerQuery; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent pce) {
if (NbMavenProject.PROP_PROJECT.equals(pce.getPropertyName())) {
NbMavenProjectImpl project = proj.getLookup().lookup(NbMavenProjectImpl.class);
Set<URI> newuris = getProjectExternalSourceRoots(project);
synchronized (uriReferences) {
Set<URI> olduris = new HashSet<URI>(uriReferences);
olduris.removeAll(newuris);
newuris.removeAll(uriReferences);
for (URI old : olduris) {
FileOwnerQuery.markExternalOwner(old, null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
}
for (URI nw : newuris) {
FileOwnerQuery.markExternalOwner(nw, proj, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
}
uriReferences.removeAll(olduris);
uriReferences.addAll(newuris);
}
}
}
示例2: testIncludesFiredJustOnce
import org.netbeans.api.project.FileOwnerQuery; //导入方法依赖的package包/类
public void testIncludesFiredJustOnce() throws Exception {
File src1 = new File(getWorkDir(), "src1");
src1.mkdir();
File src2 = new File(getWorkDir(), "src2");
src2.mkdir();
AntProjectHelper h = J2SEProjectGenerator.createProject(new File(getWorkDir(), "prj"), "test", new File[] {src1, src2}, new File[0], null, null, null);
Project p = ProjectManager.getDefault().findProject(h.getProjectDirectory());
FileOwnerQuery.markExternalOwner(Utilities.toURI(src1), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
ClassPath cp = ClassPath.getClassPath(FileUtil.toFileObject(src1), ClassPath.SOURCE);
assertNotNull(cp);
assertEquals(2, cp.getRoots().length);
ClassPath.Entry cpe2 = cp.entries().get(1);
assertEquals(Utilities.toURI(src2).toURL(), cpe2.getURL());
assertTrue(cpe2.includes("stuff/"));
assertTrue(cpe2.includes("whatever/"));
class L implements PropertyChangeListener {
int cnt;
public void propertyChange(PropertyChangeEvent e) {
if (ClassPath.PROP_INCLUDES.equals(e.getPropertyName())) {
cnt++;
}
}
}
L l = new L();
cp.addPropertyChangeListener(l);
EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
ep.setProperty(ProjectProperties.INCLUDES, "whatever/");
h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
ProjectManager.getDefault().saveProject(p);
assertEquals(1, l.cnt);
assertFalse(cpe2.includes("stuff/"));
assertTrue(cpe2.includes("whatever/"));
ep.setProperty(ProjectProperties.INCLUDES, "whateverelse/");
h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
ProjectManager.getDefault().saveProject(p);
assertEquals(2, l.cnt);
assertFalse(cpe2.includes("stuff/"));
assertFalse(cpe2.includes("whatever/"));
ep.remove(ProjectProperties.INCLUDES);
h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
ProjectManager.getDefault().saveProject(p);
assertEquals(3, l.cnt);
assertTrue(cpe2.includes("stuff/"));
assertTrue(cpe2.includes("whatever/"));
}