@Override public String getName() { if(!getNameSet) { getName = file.getName(); getNameSet = true; } return getName; }
/** * Creates a new OpenLocationAction instance using the filename of the provided AbstractFile * as label. */ public OpenLocationAction(MainFrame mainFrame, Map<String,Object> properties, AbstractFile file) { this(mainFrame, properties, file, file.getName()); }
/** * Sets the file currently being processed. * @param file the file currently being processed. */ private void setCurrentFile(AbstractFile file) { this.currentFile = file; // Update current file information returned by getCurrentFilename() this.currentFilename = "'" + file.getName() + "'"; }
public String getCriterionValue(AbstractFile file) { return file.getName(); } }
/** * Returns <code>true</code> if this file is hidden. * * <p>This default implementation is solely based on the filename and returns <code>true</code> if this * file's name starts with '.'. This method should be overriden if the underlying filesystem has a notion * of hidden files.</p> * * @return true if this file is hidden */ public boolean isHidden() { return getName().startsWith("."); }
protected static String getTemporaryFileName(AbstractFile files) { try { return FileFactory.getTemporaryFile(files.getName(), true).getName(); } catch(IOException e) { // Should never happen under normal circumstances. LOGGER.warn("Caught exception instantiating temporary file, this should not happen!"); return files.getName(); } } }
public Object getValueAt(int rowIndex, int columnIndex) { AbstractFile f = files.get(rowIndex); switch (columnIndex) { case COL_ORIG_NAME: return f.getName(); case COL_CHANGED_NAME: return newNames.get(rowIndex); case COL_CHANGE_BLOCK: return blockNames.get(rowIndex); } return null; }
/** * Returns this file's extension, <code>null</code> if this file's name doesn't have an extension. * * <p>A filename has an extension if and only if:<br/> * - it contains at least one <code>.</code> character<br/> * - the last <code>.</code> is not the last character of the filename<br/> * - the last <code>.</code> is not the first character of the filename</p> * * @return this file's extension, <code>null</code> if this file's name doesn't have an extension */ public String getExtension() { return getExtension(getName()); }
@Override public String apply(AbstractFile file) { // split name & extension String name; String oldName = file.getName(); int dot = oldName.lastIndexOf('.'); if (dot >= 0) { name = oldName.substring(0, dot); } else { name = oldName; } return extractNamePart(name); }
/** * Returns the MIME type of the given file (determined by the file extension), <code>null</code> * if the type is unknown (unknown or no extension) or if the file is a folder. */ public static String getMimeType(AbstractFile file) { if(file.isDirectory()) return null; String name = file.getName(); int pos = name.lastIndexOf('.'); if(pos==-1) return null; return mimeTypes.get(name.substring(pos+1, name.length()).toLowerCase()); }
@Override public String apply(AbstractFile file) { AbstractFile parent = file.getParent(); if (parent != null) return extractNamePart(parent.getName()); return ""; }
@Override protected PathFieldContent computeInitialPath(FileSet files) { AbstractFile file = files.elementAt(0); return selectDestinationFilename(file, file.getName(), 0); } }
private static AbstractFile getTempDestJar(AbstractFile destJar) { try { return createTemporaryFolder().getChild(destJar.getName()); } catch(IOException e) { return destJar; } }
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { // get file name and create default component (JLabel) to display it AbstractFile file = (AbstractFile) value; String name = file.isRoot()?file.getAbsolutePath():file.getName(); super.getTreeCellRendererComponent(tree, name, sel, expanded, leaf, row, hasFocus); setIcon(model.getCurrentIcon(file)); return this; }
private SelfUpdateJob(ProgressDialog progressDialog, MainFrame mainFrame, FileSet files, AbstractFile destJar, AbstractFile tempDestJar) { super(progressDialog, mainFrame, files, tempDestJar.getParent(), tempDestJar.getName(), TransferMode.DOWNLOAD, FileCollisionDialog.OVERWRITE_ACTION); this.destJar = destJar; this.tempDestJar = tempDestJar; this.classLoader = getClass().getClassLoader(); directoryOrClassFileFilter = new OrFileFilter( new AttributeFileFilter(FileAttribute.DIRECTORY), new ExtensionFilenameFilter(".class") ); }
@Override protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) { return new MoveJob( progressDialog, mainFrame, files, resolvedDest.getDestinationFolder(), resolvedDest.getDestinationType()==PathUtils.ResolvedDestination.EXISTING_FOLDER?null:resolvedDest.getDestinationFile().getName(), defaultFileExistsAction, false); }
@Override protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) { return new CopyJob( progressDialog, mainFrame, files, resolvedDest.getDestinationFolder(), resolvedDest.getDestinationType()==PathUtils.ResolvedDestination.EXISTING_FOLDER?null:resolvedDest.getDestinationFile().getName(), TransferMode.DOWNLOAD, defaultFileExistsAction); }
protected static AbstractFile getTemporaryFolder(FileSet files) { AbstractFile tempFolder; try { tempFolder = FileFactory.getTemporaryFile(files.getBaseFolder().getName(), true); tempFolder.mkdir(); } catch(IOException e) { tempFolder = FileFactory.getTemporaryFolder(); } return tempFolder; }
@Override protected PathFieldContent computeInitialPath(FileSet files) { AbstractFile file = files.elementAt(0); // AbstractFile activeFolder = mainFrame.getActiveTable().getCurrentFolder(); AbstractFile unactiveFolder = mainFrame.getInactivePanel().getCurrentFolder(); // Fill text field with current folder's absolute path and file name return new PathFieldContent(unactiveFolder.getAbsolutePath(true)+file.getName()); }
public void encodingChanged(Object source, String oldEncoding, String newEncoding) { try { // Reload the file using the new encoding // Note: loadDocument closes the InputStream loadDocument(getCurrentFile().getInputStream(), newEncoding, null); } catch(IOException ex) { InformationDialog.showErrorDialog(getFrame(), Translator.get("read_error"), Translator.get("file_editor.cannot_read_file", getCurrentFile().getName())); } } }