本文整理匯總了Java中org.openide.filesystems.FileUtil.normalizeFile方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.normalizeFile方法的具體用法?Java FileUtil.normalizeFile怎麽用?Java FileUtil.normalizeFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.normalizeFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getClassName
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public static String getClassName(CodeProfilingPoint.Location location) {
File file = FileUtil.normalizeFile(new File(location.getFile()));
FileObject fileObject = FileUtil.toFileObject(file);
if ((fileObject == null) || !fileObject.isValid()) {
return null;
}
int documentOffset = getDocumentOffset(location);
if (documentOffset == -1) {
return null;
}
// FIXME - optimize
JavaProfilerSource src = JavaProfilerSource.createFrom(fileObject);
if (src == null) return null;
SourceClassInfo sci = src.getEnclosingClass(documentOffset);
if (sci == null) return null;
return sci.getQualifiedName();
}
示例2: saveAs
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
public void saveAs(FileObject folder, String fileName) throws IOException {
String fn = FileUtil.getFileDisplayName(folder) + File.separator + fileName;
File existingFile = FileUtil.normalizeFile(new File(fn));
if (existingFile.exists()) {
NotifyDescriptor confirm = new NotifyDescriptor.Confirmation(
NbBundle.getMessage(SQLEditorSupport.class,
"MSG_ConfirmReplace", fileName),
NbBundle.getMessage(SQLEditorSupport.class,
"MSG_ConfirmReplaceFileTitle"),
NotifyDescriptor.YES_NO_OPTION);
DialogDisplayer.getDefault().notify(confirm);
if (!confirm.getValue().equals(NotifyDescriptor.YES_OPTION)) {
return;
}
}
if (isConsole()) {
// #166370 - if console, need to save document before copying
saveDocument();
}
super.saveAs(folder, fileName);
}
示例3: browseProjectFolderActionPerformed
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseProjectFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseProjectFolderActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
if (projectFolder.getText().length() > 0 && getProjectFolder().exists()) {
chooser.setSelectedFile(getProjectFolder());
} else if (projectLocation.getText().length() > 0 && getProjectLocation().exists()) {
chooser.setSelectedFile(getProjectLocation());
} else {
chooser.setSelectedFile(ProjectChooser.getProjectsFolder());
}
chooser.setDialogTitle(NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_Browse_Project_Folder")); //NOI18N
if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File projectDir = FileUtil.normalizeFile(chooser.getSelectedFile());
projectFolder.setText(projectDir.getAbsolutePath());
}
}
示例4: getIcon
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public @Override Icon getIcon(File _f) {
File f = FileUtil.normalizeFile(_f);
Icon original = fsv.getSystemIcon(f);
if (original == null) {
// L&F (e.g. GTK) did not specify any icon.
original = EMPTY;
}
if ( isPlatformDir( f ) ) {
if ( original.equals( lastOriginal ) ) {
return lastMerged;
}
lastOriginal = original;
lastMerged = new MergedIcon(original, BADGE, -1, -1);
return lastMerged;
}
else {
return original;
}
}
示例5: testToFileObjectCaptureExternalChanges
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testToFileObjectCaptureExternalChanges () throws Exception {
FileObject testFolder_Fo = FileUtil.toFileObject(getWorkDir()).createFolder(getName());
assertNotNull(testFolder_Fo);
File testFolder = FileUtil.normalizeFile(FileUtil.toFile(testFolder_Fo));
assertNotNull(testFolder);
assertTrue(testFolder.exists());
String externalName = "newfile.external3";
File newFile = new File (testFolder, externalName);
assertFalse(newFile.exists());
assertNull(FileBasedFileSystem.getFileObject(newFile));
assertNull(testFolder_Fo.getFileObject(newFile.getName()));
assertNull(FileUtil.toFileObject(newFile));
assertTrue(newFile.createNewFile());
assertNotNull(FileUtil.toFileObject(newFile));
}
示例6: getTempDir
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private static File getTempDir (boolean deleteOnExit) {
if (tempDir == null) {
File tmpDir = new File(System.getProperty("java.io.tmpdir")); // NOI18N
for (;;) {
File dir = new File(tmpDir, "vcs-" + Long.toString(System.currentTimeMillis())); // NOI18N
if (!dir.exists() && dir.mkdirs()) {
tempDir = FileUtil.normalizeFile(dir);
if (deleteOnExit) {
tempDir.deleteOnExit();
}
break;
}
}
}
return tempDir;
}
示例7: getHome
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/** Get name of home directory. Used from layer.
*/
public static URL getHome ()
throws FileStateInvalidException, MalformedURLException {
String s = System.getProperty("user.home"); // NOI18N
File home = new File (s);
home = FileUtil.normalizeFile (home);
return Utilities.toURI (home).toURL ();
}
示例8: addSeenRoot
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private boolean addSeenRoot (File repositoryRoot, File rootToAdd) {
boolean added = false;
Set<File> seenRootsForRepository = getSeenRootsForRepository(repositoryRoot);
synchronized (seenRootsForRepository) {
if (!seenRootsForRepository.contains(repositoryRoot)) {
// try to add the file only when the repository root is not yet registered
rootToAdd = FileUtil.normalizeFile(rootToAdd);
added = !GitUtils.prepareRootFiles(repositoryRoot, seenRootsForRepository, rootToAdd);
}
}
return added;
}
示例9: createClassPath
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private static ClassPath createClassPath(String classpath) {
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
List list = new ArrayList();
while (tokenizer.hasMoreTokens()) {
String item = tokenizer.nextToken();
File f = FileUtil.normalizeFile(new File(item));
URL url = getRootURL(f);
if (url!=null) {
list.add(ClassPathSupport.createResource(url));
}
}
return ClassPathSupport.createClassPath(list);
}
示例10: getLastUsedArtifactFolder
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private static File getLastUsedArtifactFolder (final File defaultValue) {
String val = getPreferences().get(LAST_USED_ARTIFACT_FOLDER, null);
if (val != null) {
return FileUtil.normalizeFile(new File (val));
}
if (defaultValue != null) {
return defaultValue;
}
return FileUtil.normalizeFile(new File (System.getProperty("user.home")));
}
示例11: browseButtonActionPerformed
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
final JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode (JFileChooser.FILES_ONLY);
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(new SplashFileFilter());
if (lastImageFolder != null) {
chooser.setCurrentDirectory(lastImageFolder);
}
chooser.setDialogTitle(NbBundle.getMessage(CustomizerApplication.class, "LBL_Select_Splash_Image"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
splashTextField.setText(file.getAbsolutePath());
lastImageFolder = file.getParentFile();
}
}
示例12: refreshFileStatus
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
* Updates cache with scanned information for the given file
* @param file
* @param fi
* @param interestingFiles
* @param alwaysFireEvent
*/
private void refreshFileStatus(File file, FileInformation fi) {
if(file == null || fi == null) return;
FileInformation current;
synchronized (this) {
// XXX the question here is: do we want to keep ignored files in the cache (i mean those ignored by hg, not by SQ)?
// if yes, add equivalent(FILE_INFORMATION_UNKNOWN, fi) into the following test
if ((equivalent(FILE_INFORMATION_NEWLOCALLY, fi)) && (HgUtils.isIgnored(file)
|| (getCachedStatus(file.getParentFile()).getStatus() & FileInformation.STATUS_NOTVERSIONED_EXCLUDED) != 0)) {
// Sharebility query recognized this file as ignored
LOG.log(Level.FINE, "refreshFileStatus() file: {0} was LocallyNew but is NotSharable", file.getAbsolutePath()); // NOI18N
fi = file.isDirectory() ? new FileInformation(FileInformation.STATUS_NOTVERSIONED_EXCLUDED, true) : FILE_INFORMATION_EXCLUDED;
}
file = FileUtil.normalizeFile(file);
current = getInfo(file);
if (equivalent(fi, current)) {
// no need to fire an event
return;
}
if (fi.getStatus() == FileInformation.STATUS_UNKNOWN) {
removeInfo(file);
} else if (fi.getStatus() == FileInformation.STATUS_VERSIONED_UPTODATE && file.isFile()) {
removeInfo(file);
addUpToDate(file);
} else {
setInfo(file, fi);
}
updateParentInformation(file, current, fi);
}
fireFileStatusChanged(file, current, fi);
}
示例13: toFile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private static File toFile(URL u) {
if (u == null) {
throw new NullPointerException();
}
try {
URI uri = new URI(u.toExternalForm());
return FileUtil.normalizeFile(BaseUtilities.toFile(uri));
} catch (URISyntaxException | IllegalArgumentException use) {
// malformed URL
return null;
}
}
示例14: create
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@SuppressWarnings("unchecked") //Properties cast to Map<String,String>
static JavaPlatform create(Map<String,String> properties, List<URL> sources, List<URL> javadoc) {
if (properties == null) {
properties = new HashMap<> ();
}
String jdkHome = System.getProperty("jdk.home"); // NOI18N
File javaHome;
if (jdkHome == null) {
javaHome = FileUtil.normalizeFile(new File(System.getProperty("java.home")).getParentFile()); // NOI18N
} else {
javaHome = FileUtil.normalizeFile(new File(jdkHome));
}
List<URL> installFolders = new ArrayList<> ();
try {
installFolders.add (Utilities.toURI(javaHome).toURL());
} catch (MalformedURLException mue) {
Exceptions.printStackTrace(mue);
}
final Map<String,String> systemProperties = new HashMap<>();
Map<Object,Object> p = System.getProperties();
synchronized (p) {
p = new HashMap<>(p);
}
for (Map.Entry<Object,Object> e : p.entrySet()) {
final String key = (String) e.getKey();
final String value = Util.fixSymLinks(
key,
Util.removeNBArtifacts(
key,
(String) e.getValue()),
Util.toFileObjects(installFolders));
systemProperties.put(key, value);
}
return new DefaultPlatformImpl(installFolders, properties, systemProperties, sources, javadoc);
}
示例15: run
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public @Override void run() {
if (!lookingForIcon.isDirectory()) {
synchronized (this) {
lookingForIcon = null;
}
return;
}
File d = FileUtil.normalizeFile(lookingForIcon);
ProjectManager.Result r = getProjectResult(d);
Icon icon;
if (r != null) {
icon = r.getIcon();
if (icon == null) {
Project p = getProject(d);
if (p != null) {
icon = ProjectUtils.getInformation(p).getIcon();
} else {
icon = chooser.getFileSystemView().getSystemIcon(lookingForIcon);
}
}
} else {
try {
icon = chooser.getFileSystemView().getSystemIcon(lookingForIcon);
} catch (NullPointerException ex) {
//#159646: Workaround for JDK issue #6357445
// Can happen when a file was deleted on disk while project
// dialog was still open. In that case, throws an exception
// repeatedly from FSV.gSI during repaint.
icon = null;
}
}
synchronized (this) {
knownProjectIcons.put(lookingForIcon, icon);
lookingForIcon = null;
}
chooser.repaint();
}