本文整理汇总了Java中org.openide.filesystems.FileObject.isVirtual方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.isVirtual方法的具体用法?Java FileObject.isVirtual怎么用?Java FileObject.isVirtual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.isVirtual方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fastCheckParameters
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public Problem fastCheckParameters() {
Problem result = null;
String newName = refactoring.getInterfaceName();
if (!Utilities.isJavaIdentifier(newName)) {
result = createProblem(result, true, NbBundle.getMessage(ExtractInterfaceRefactoringPlugin.class, "ERR_InvalidIdentifier", newName)); // NOI18N
return result;
}
FileObject primFile = refactoring.getSourceType().getFileObject();
FileObject folder = primFile.getParent();
FileObject[] children = folder.getChildren();
for (FileObject child: children) {
if (!child.isVirtual() && child.getName().equalsIgnoreCase(newName) && "java".equalsIgnoreCase(child.getExt())) { // NOI18N
result = createProblem(result, true, NbBundle.getMessage(ExtractInterfaceRefactoringPlugin.class, "ERR_ClassClash", newName, pkgName)); // NOI18N
return result;
}
}
return super.fastCheckParameters();
}
示例2: fastCheckParameters
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public Problem fastCheckParameters() {
Problem result = null;
String newName = refactoring.getSuperClassName();
if (!Utilities.isJavaIdentifier(newName)) {
result = createProblem(result, true, NbBundle.getMessage(ExtractSuperclassRefactoringPlugin.class, "ERR_InvalidIdentifier", newName)); // NOI18N
return result;
}
FileObject primFile = refactoring.getSourceType().getFileObject();
FileObject folder = primFile.getParent();
FileObject[] children = folder.getChildren();
for (FileObject child: children) {
if (!child.isVirtual() && child.getName().equals(newName) && "java".equals(child.getExt())) { // NOI18N
result = createProblem(result, true, NbBundle.getMessage(ExtractSuperclassRefactoringPlugin.class, "ERR_ClassClash", newName, pkgName)); // NOI18N
return result;
}
}
return super.fastCheckParameters();
}
示例3: collectFiles
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void collectFiles(FileObject parent, Collection<FileObject> accepted, SharabilityQuery.Sharability parentSharab) {
for (FileObject fo : parent.getChildren()) {
if (!VisibilityQuery.getDefault().isVisible(fo)) {
// #66765: ignore invisible files/folders, like CVS subdirectory
continue;
}
SharabilityQuery.Sharability sharab;
if (parentSharab == SharabilityQuery.Sharability.UNKNOWN || parentSharab == SharabilityQuery.Sharability.MIXED) {
sharab = SharabilityQuery.getSharability(fo);
} else {
sharab = parentSharab;
}
if (sharab == SharabilityQuery.Sharability.NOT_SHARABLE) {
continue;
}
if (fo.isData() && !fo.isVirtual()) {
accepted.add(fo);
} else if (fo.isFolder()) {
accepted.add(fo);
collectFiles(fo, accepted, sharab);
}
}
}
示例4: findTarget
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static Object [] findTarget(String [] path) {
FileObject target = FileUtil.getConfigRoot();
boolean isTarget = 0 == path.length;
for (int i = 0; i < path.length; i++) {
FileObject f = target.getFileObject(path[i]);
if (f == null || !f.isFolder() || !f.isValid() || f.isVirtual()) {
break;
} else {
target = f;
isTarget = i + 1 == path.length;
}
}
return new Object [] { target, Boolean.valueOf(isTarget) };
}
示例5: isProject2
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public @Override Result isProject2(FileObject projectDirectory) {
if (FileUtil.toFile(projectDirectory) == null) {
return null;
}
FileObject projectFile = projectDirectory.getFileObject(PROJECT_XML_PATH);
//#54488: Added check for virtual
if (projectFile == null || !projectFile.isData() || projectFile.isVirtual()) {
return null;
}
File projectDiskFile = FileUtil.toFile(projectFile);
//#63834: if projectFile exists and projectDiskFile does not, do nothing:
if (projectDiskFile == null) {
return null;
}
try {
Document projectXml = loadProjectXml(projectDiskFile);
if (projectXml != null) {
Element typeEl = XMLUtil.findElement(projectXml.getDocumentElement(), "type", PROJECT_NS); // NOI18N
if (typeEl != null) {
String type = XMLUtil.findText(typeEl);
if (type != null) {
AntBasedProjectType provider = findAntBasedProjectType(type);
if (provider != null) {
if (provider instanceof AntBasedGenericType) {
return new ProjectManager.Result(((AntBasedGenericType)provider).getIcon());
} else {
//put special icon?
return new ProjectManager.Result(null);
}
}
}
}
}
} catch (IOException ex) {
LOG.log(Level.FINE, "Failed to load the project.xml file.", ex);
}
// better have false positives than false negatives (according to the ProjectManager.isProject/isProject2 javadoc.
return new ProjectManager.Result(null);
}
示例6: addSourceRoots
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void addSourceRoots(ClassPath ecp,
List<FileObject> allSourceRoots,
Set<FileObject> preferredRoots) {
FileObject[] sourceRoots = ecp.getRoots();
for (FileObject fr : sourceRoots) {
if (!preferredRoots.contains(fr) && !fr.isVirtual()) {
allSourceRoots.add(fr);
preferredRoots.add(fr);
}
}
}
示例7: resourceTextKeyReleased
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void resourceTextKeyReleased(java.awt.event.KeyEvent evt) {
if (!innerResourceTextContent.equals(resourceText.getText())
&& resourceText.getText().trim().length() != 0) {
String bundlePath = resourceText.getText()
.replaceAll("[.]", "/") //NOI18N
.concat(".properties"); //NOI18N
FileObject resourceFO = Util.getResource(file, bundlePath);
if ((resourceFO != null) && resourceFO.isValid() && !resourceFO.isVirtual()) {
try {
setResource(DataObject.find(resourceFO));
warningLabel.setText(""); //NOI18N
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
} else {
warningLabel.setText(
I18nUtil.getBundle().getString("LBL_InvalidBundle") //NOI18N
+ bundlePath); //NOI18N
setEmptyResource();
}
} else {
warningLabel.setText(""); //NOI18N
if ("".equals(resourceText.getText())) {
setEmptyResource();
}
}
}
示例8: getMainClasses
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Returns classes declared in the given source file which have the main method.
* @param fo source file
* @return the classes containing main method
* @throws IllegalArgumentException when file does not exist or is not a java source file.
*/
public static Collection<ElementHandle<TypeElement>> getMainClasses (final @NonNull FileObject fo) {
Parameters.notNull("fo", fo); //NOI18N
if (!fo.isValid()) {
throw new IllegalArgumentException ("FileObject : " + FileUtil.getFileDisplayName(fo) + " is not valid."); //NOI18N
}
if (fo.isVirtual()) {
throw new IllegalArgumentException ("FileObject : " + FileUtil.getFileDisplayName(fo) + " is virtual."); //NOI18N
}
final JavaSource js = JavaSource.forFileObject(fo);
if (js == null) {
throw new IllegalArgumentException ();
}
try {
final LinkedHashSet<ElementHandle<TypeElement>> result = new LinkedHashSet<> ();
js.runUserActionTask(new Task<CompilationController>() {
@Override
public void run(final CompilationController control) throws Exception {
if (control.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED).compareTo (JavaSource.Phase.ELEMENTS_RESOLVED)>=0) {
final List<TypeElement> types = new ArrayList<>();
final ElementScanner6<Void,Void> visitor = new ElementScanner6<Void, Void>() {
@Override
public Void visitType(TypeElement e, Void p) {
if (e.getEnclosingElement().getKind() == ElementKind.PACKAGE
|| e.getModifiers().contains(Modifier.STATIC)) {
types.add(e);
return super.visitType(e, p);
} else {
return null;
}
}
};
visitor.scan(control.getTopLevelElements(), null);
for (TypeElement type : types) {
for (ExecutableElement exec : ElementFilter.methodsIn(control.getElements().getAllMembers(type))) {
if (SourceUtils.isMainMethod(exec)) {
result.add (ElementHandle.create(type));
}
}
}
}
}
}, true);
return result;
} catch (IOException ioe) {
Exceptions.printStackTrace(ioe);
return Collections.<ElementHandle<TypeElement>>emptySet();
}
}
示例9: getPaletteFromTopComponent
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
PaletteController getPaletteFromTopComponent( TopComponent tc, boolean mustBeShowing, boolean isOpened ) {
if( null == tc || (!tc.isShowing() && mustBeShowing) )
return null;
PaletteController pc = (PaletteController)tc.getLookup().lookup( PaletteController.class );
//#231997 - TopComponent.getSubComponents() can be called from EDT only
//The only drawback of commenting out the code below is that a split view of
//a form designer showing source and design hides the palette window
//when the source split is the active one and some other TopComponent is activated
// if (pc == null && isOpened) {
// TopComponent.SubComponent[] subComponents = tc.getSubComponents();
// for (int i = 0; i < subComponents.length; i++) {
// TopComponent.SubComponent subComponent = subComponents[i];
// Lookup subComponentLookup = subComponent.getLookup();
// if (subComponentLookup != null) {
// pc = (PaletteController) subComponentLookup.lookup(PaletteController.class);
// if (pc != null && (subComponent.isActive() || subComponent.isShowing())) {
// break;
// }
// }
// }
// }
if( null == pc && isOpened ) {
//check if there's any palette assigned to TopComponent's mime type
Node[] activeNodes = tc.getActivatedNodes();
if( null != activeNodes && activeNodes.length > 0 ) {
DataObject dob = activeNodes[0].getLookup().lookup( DataObject.class );
if( null != dob ) {
while( dob instanceof DataShadow ) {
dob = ((DataShadow)dob).getOriginal();
}
FileObject fo = dob.getPrimaryFile();
if( !fo.isVirtual() ) {
String mimeType = fo.getMIMEType();
pc = getPaletteFromMimeType( mimeType );
}
}
}
}
return pc;
}
示例10: loadProject
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public @Override Project loadProject(FileObject projectDirectory, ProjectState state) throws IOException {
if (FileUtil.toFile(projectDirectory) == null) {
LOG.log(Level.FINER, "no disk dir {0}", projectDirectory);
return null;
}
FileObject projectFile = projectDirectory.getFileObject(PROJECT_XML_PATH);
if (projectFile == null) {
LOG.log(Level.FINER, "no {0}/nbproject/project.xml", projectDirectory);
return null;
}
//#54488: Added check for virtual
if (!projectFile.isData() || projectFile.isVirtual()) {
LOG.log(Level.FINE, "not concrete data file {0}/nbproject/project.xml", projectDirectory);
return null;
}
File projectDiskFile = FileUtil.toFile(projectFile);
//#63834: if projectFile exists and projectDiskFile does not, do nothing:
if (projectDiskFile == null) {
LOG.log(Level.FINE, "{0} not mappable to file", projectFile);
return null;
}
Document projectXml = loadProjectXml(projectDiskFile);
if (projectXml == null) {
LOG.log(Level.FINE, "could not load {0}", projectDiskFile);
return null;
}
Element typeEl = XMLUtil.findElement(projectXml.getDocumentElement(), "type", PROJECT_NS); // NOI18N
if (typeEl == null) {
LOG.log(Level.FINE, "no <type> in {0}", projectDiskFile);
return null;
}
String type = XMLUtil.findText(typeEl);
if (type == null) {
LOG.log(Level.FINE, "no <type> text in {0}", projectDiskFile);
return null;
}
AntBasedProjectType provider = findAntBasedProjectType(type);
if (provider == null) {
LOG.log(Level.FINE, "no provider for {0}", type);
return null;
}
AntProjectHelper helper = HELPER_CALLBACK.createHelper(projectDirectory, projectXml, state, provider);
Project project = provider.createProject(helper);
synchronized (helper2Project) {
project2Helper.put(project, new WeakReference<AntProjectHelper>(helper));
helper2Project.put(helper, new WeakReference<Project>(project));
}
synchronized (AntBasedProjectFactorySingleton.class) {
List<Reference<AntProjectHelper>> l = type2Projects.get(provider);
if (l == null) {
type2Projects.put(provider, l = new ArrayList<Reference<AntProjectHelper>>());
}
l.add(new WeakReference<AntProjectHelper>(helper));
}
return project;
}
示例11: wizardEnabled
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Shared enableness logic. Either DataObject.Container or EditorCookie must be present on all nodes.*/
static boolean wizardEnabled(Node[] activatedNodes) {
if (activatedNodes == null || activatedNodes.length == 0) {
return false;
}
for (Node node : activatedNodes) {
/*
* This block of code fixes IssueZilla bug #63461:
*
* Apisupport modules visualizes the contents of layer.xml
* in project view. The popup for folders in the layer.xml
* contains Tools->Internationalize->* actions.
*
* Generally should hide on nonlocal files, I suppose.
*
* Local files are recognized by protocol of the corresponding URL -
* local files are those that have protocol "file".
*/
DataObject dobj = node.getCookie(DataObject.class);
if (dobj != null) {
FileObject primaryFile = dobj.getPrimaryFile();
boolean isLocal;
try {
isLocal = !primaryFile.isVirtual()
&& primaryFile.isValid()
&& primaryFile.getURL().getProtocol()
.equals("file"); //NOI18N
} catch (FileStateInvalidException ex) {
isLocal = false;
}
if (isLocal == false) {
return false;
}
}
Object container = node.getCookie(DataObject.Container.class);
if (container != null) {
continue;
}
// if (node.getCookie(EditorCookie.class) == null) {
// return false;
// }
if (dobj == null) {
return false;
}
Future<Project[]> openProjects = OpenProjects.getDefault().openProjects();
if(!openProjects.isDone()) {
return false;
}
// check that the node has project
if (FileOwnerQuery.getOwner(dobj.getPrimaryFile()) == null) {
return false;
}
}
return true;
}