本文整理匯總了Java中org.openide.filesystems.FileUtil.getFileDisplayName方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.getFileDisplayName方法的具體用法?Java FileUtil.getFileDisplayName怎麽用?Java FileUtil.getFileDisplayName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.getFileDisplayName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDisplayName
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override public @NonNull String getDisplayName() {
synchronized(displayNameTask) {
if(displayName == null) {
displayName = FileUtil.getFileDisplayName(project.getProjectDirectory());
}
if(!displayNameRunning) {
displayNameRunning = true;
if(Boolean.getBoolean("test.load.sync")) {
displayNameTask.run();
} else {
RP.schedule(displayNameTask, 100, TimeUnit.MILLISECONDS); // lots of repeating calls
}
}
return displayName;
}
}
示例2: createStyleSheetsRenderer
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private ListCellRenderer createStyleSheetsRenderer() {
return new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value == null) {
setText("<html>" + Bundle.none_item());
} else {
FileObject file = (FileObject) value;
FileObject webRoot = ProjectWebRootQuery.getWebRoot(file);
String file2string;
if (webRoot != null) {
file2string = FileUtil.getRelativePath(webRoot, file);
} else {
file2string = FileUtil.getFileDisplayName(file);
}
setText(file2string);
}
return c;
}
};
}
示例3: 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);
}
示例4: createJar
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private static FileObject createJar(
@NonNull final FileObject folder,
@NonNull final String name,
@NonNull final FileObject... content) throws IOException {
final File f = FileUtil.toFile(folder);
if (f == null) {
throw new IOException("The " + FileUtil.getFileDisplayName(folder) +" is not local");
}
final File res = new File(f,name);
try(JarOutputStream out = new JarOutputStream(new FileOutputStream(res))) {
for (FileObject c : content) {
pack(out, c, c);
}
}
return FileUtil.getArchiveRoot(FileUtil.toFileObject(res));
}
示例5: getPUDataObject
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
*Gets the <code>PUDataObject</code> associated with the given <code>fo</code>.
*
*@param fo the file object thas has an associated <code>PUDataObject</code>. Must
* not be null.
*
*@return the <code>PUDataObject</code> associated with the given <code>fo</code>.
*
*@throws IllegalArgumentException if the given <code>fo</code> is null.
*@throws InvalidPersistenceXmlException if the given file object represents
* an invalid persistence.xml file.
*/
public static PUDataObject getPUDataObject(FileObject fo) throws InvalidPersistenceXmlException {
Parameters.notNull("fo", fo); //NOI18N
DataObject dataObject = null;
try {
dataObject = DataObject.find(fo);
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
if (!(dataObject instanceof PUDataObject)) {
throw new InvalidPersistenceXmlException(FileUtil.getFileDisplayName(fo));
}
return (PUDataObject) dataObject;
}
示例6: getFileDisplayPath
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
@NonNull
public final String getFileDisplayPath() {
String res = cachedPath;
if (res == null) {
final File rootFile = FileUtil.toFile(root);
if (rootFile != null) {
try {
final String binaryName = owner.getBinaryName();
String relativePath = ci.getSourceName(binaryName);
if (relativePath == null) {
relativePath = binaryName;
int lastDot = relativePath.lastIndexOf('.'); //NOI18N
int csIndex = relativePath.indexOf('$', lastDot); //NOI18N
if (csIndex > 0 && csIndex < relativePath.length()-1) {
relativePath = binaryName.substring(0, csIndex);
}
relativePath = String.format(
"%s.%s", //NOI18N
FileObjects.convertPackage2Folder(relativePath, File.separatorChar),
FileObjects.JAVA);
}
res = new File (rootFile, relativePath).getAbsolutePath();
} catch (IOException | InterruptedException e) {
Exceptions.printStackTrace(e);
}
}
if (res == null) {
final FileObject fo = getFileObject();
res = fo == null ?
"" : //NOI18N
FileUtil.getFileDisplayName(fo);
}
cachedPath = res;
}
return res;
}
示例7: getLocationText
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public static String getLocationText(Object location) {
String text = location instanceof SourceGroup
? ((SourceGroup) location).getDisplayName()
: location instanceof FileObject
? FileUtil.getFileDisplayName((FileObject) location)
: location.toString();
return text;
}
示例8: updateTargetFolderData
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
*/
private void updateTargetFolderData() {
Object item = cboxLocation.getSelectedItem();
if (item != null) {
SourceGroup targetSourceGroup = (SourceGroup)
((NamedObject) item).object;
testRootFolder = targetSourceGroup.getRootFolder();
testsRootDirName = FileUtil.getFileDisplayName(testRootFolder);
} else {
testRootFolder = null;
testsRootDirName = ""; //NOI18N
}
}
示例9: begin
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
final void begin (FileObject fo, Font font, Color fgColor, Color bgColor, Color hfgColor, Color hbgColor, MimePath mimePath, String charset) {
styles = new Styles ();
buffer = new StringBuffer();
fileName = FileUtil.getFileDisplayName(fo);
shortFileName = fo.getNameExt();
boolHolder = new boolean [1];
this.defaultForegroundColor = fgColor;
this.defaultBackgroundColor = bgColor;
this.defaultFont = font;
this.headerForegroundColor = hfgColor;
this.headerBackgroundColor = hbgColor;
this.syntaxColoring = ColoringMap.get(mimePath.getPath()).getMap();
this.charset = charset;
}
示例10: getDisplayName
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public String getDisplayName() {
FileObject fo = URLMapper.findFileObject(location);
if (fo != null) {
return FileUtil.getFileDisplayName(fo);
} else {
return location.toExternalForm();
}
}
示例11: Rewriter
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public Rewriter(FileObject fo, PositionConverter converter, Map<Integer, String> userInfo, Source src) throws IOException {
this.src = src;
this.converter = converter;
this.userInfo = userInfo;
if (fo != null) {
prp = PositionRefProvider.get(fo);
}
if (prp == null)
throw new IOException("Could not find CloneableEditorSupport for " + FileUtil.getFileDisplayName (fo)); //NOI18N
}
示例12: ClassLoaderRef
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public ClassLoaderRef(final ClassLoader cl, final FileObject root, final boolean isModule) {
super(cl, BaseUtilities.activeReferenceQueue());
this.timeStamp = getTimeStamp(root);
this.rootPath = FileUtil.getFileDisplayName(root);
this.isModule = isModule;
LOG.log(Level.FINER, "ClassLoader for root {0} created.", new Object[]{rootPath}); //NOI18N
}
示例13: getFileDisplayName
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/** Get file display name, e.g. for JTree tooltip. */
String getFileDisplayName() {
return FileUtil.getFileDisplayName(fileObject);
}
示例14: displayName
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
public String displayName(FileObject obj) {
return FileUtil.getFileDisplayName(obj);
}
示例15: updateText
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void updateText() {
final Object selectedItem = rootComboBox.getSelectedItem();
String createdFileName;
if (selectedItem instanceof SourceGroup) {
SourceGroup g = (SourceGroup) selectedItem;
FileObject rootFolder = g.getRootFolder();
String packageName = getPackageFileName();
String documentName = documentNameTextField.getText().trim();
if (Type.FILE.equals(type)) {
final String[] pkgNamePair = JavaTargetChooserPanel.getPackageAndSimpleName(documentName);
final boolean fqn = !pkgNamePair[0].isEmpty();
if (fqn) {
if (!wasPreviouslyFQN) {
//backup the original package name
originalPackageName = getPackageName();
}
//set the textfield from the parsed FQN text
packageName = pkgNamePair[0];
documentName = pkgNamePair[1];
setPackageIgnoreEvents(packageName);
packageName = packageName.replace('.', '/'); //NOI18N
wasPreviouslyFQN = true;
} else {
if (wasPreviouslyFQN) {
//reset the package name, if the user reverts his previously entered FQN
setPackageIgnoreEvents(originalPackageName);
wasPreviouslyFQN = false;
}
}
packageComboBox.setEnabled(!fqn);
}
if (type == Type.PACKAGE) {
documentName = documentName.replace( '.', '/' ); // NOI18N
}
else if ( documentName.length() > 0 ) {
documentName = documentName + expectedExtension;
}
createdFileName = FileUtil.getFileDisplayName( rootFolder ) +
( packageName.startsWith("/") || packageName.startsWith( File.separator ) ? "" : "/" ) + // NOI18N
packageName +
( packageName.endsWith("/") || packageName.endsWith( File.separator ) || packageName.length() == 0 ? "" : "/" ) + // NOI18N
documentName;
} else {
//May be null iff nothing selected
createdFileName = ""; //NOI18N
}
fileTextField.setText( createdFileName.replace( '/', File.separatorChar ) ); // NOI18N
}