Package com.mucommander.commons.file

Examples of com.mucommander.commons.file.AbstractFile


     * This method must be called before instantiating CommandBar for the first time.
     */
    public static void loadCommandBar() throws Exception {

      // Load user's file if exist
      AbstractFile commandBarFile = getDescriptionFile();
      if(commandBarFile != null && commandBarFile.exists()) {
        CommandBarReader reader = new CommandBarReader(commandBarFile);
        CommandBarAttributes.setAttributes(reader.getActionsRead(), reader.getAlternateActionsRead(), reader.getModifierRead());
      }
      else {
        CommandBarAttributes.restoreDefault();
View Full Code Here


     * @throws IOException
     * @throws IOException
     */
    public static void saveCommandBar() throws IOException {
      if (CommandBarAttributes.areDefaultAttributes()) {
        AbstractFile commandBarFile = getDescriptionFile();
          if(commandBarFile != null && commandBarFile.exists()) {
            LOGGER.info("Command bar use default settings, removing descriptor file");
            commandBarFile.delete();
          }
          else
            LOGGER.debug("Command bar not modified, not saving");
      }
      else if (commandBarWriter != null) {
View Full Code Here

     * By default, this file is {@link #DEFAULT_COMMAND_BAR_FILE_NAME} within the preferences folder.
     * @param  path                  path to the command bar descriptor file
     * @throws FileNotFoundException if the specified file is not accessible.
     */
    public static void setDescriptionFile(String path) throws FileNotFoundException {
        AbstractFile file;

        if((file = FileFactory.getFile(path)) == null)
            setDescriptionFile(new File(path));
        else
            setDescriptionFile(file);
View Full Code Here

    Vector<String> result = new Vector<String>();
    int index = Math.max(path.lastIndexOf('\\'), path.lastIndexOf('/'))
    if (index != -1) {
          String currentDirectoryName = path.substring(0, index+1);
         
          AbstractFile currentDirectory = FileFactory.getFile(currentDirectoryName);
          if (currentDirectory != null && currentDirectory.exists()) {         
            long currentDirectoryDate = currentDirectory.getDate();
            if (cachedDirectoryName == null || !cachedDirectoryName.equals(currentDirectoryName) || currentDirectoryDate != cachedDirectoryDate) {
              AbstractFile[] currentDirectoryFiles;
          try {
            currentDirectoryFiles = getFiles(currentDirectory);
          } catch (IOException e) {
                        LOGGER.debug("Caught exception", e);
            return new Vector<String>();
          }
   
              int nbCurrentDirectoryFiles = currentDirectoryFiles.length;
              cachedDirectoryFileNames = new String[nbCurrentDirectoryFiles];
             
              for (int i=0; i<nbCurrentDirectoryFiles; i++) {
                AbstractFile abstractFileI = currentDirectoryFiles[i];
            cachedDirectoryFileNames[i] = abstractFileI.getName() + (abstractFileI.isDirectory() ? abstractFileI.getSeparator() : "");
              }
             
              Arrays.sort(cachedDirectoryFileNames, String.CASE_INSENSITIVE_ORDER);
             
              cachedDirectoryName = currentDirectory.getAbsolutePath() + (currentDirectory.isDirectory() ? "" : currentDirectory.getSeparator());
View Full Code Here

    /**
     * Parses the XML file describing the toolbar's buttons and associated actions.
     * If the file doesn't exist, default toolbar elements will be used.
     */
    public static void loadDescriptionFile() throws Exception {
      AbstractFile descriptionFile = getDescriptionFile();
        if (descriptionFile != null && descriptionFile.exists()) {
          ToolBarReader reader = new ToolBarReader(descriptionFile);
          ToolBarAttributes.setActions(reader.getActionsRead());
        }
        else
          LOGGER.debug("User toolbar.xml was not found, using default toolbar");
View Full Code Here

     * @throws IOException
     * @throws IOException
     */
    public static void saveToolBar() throws IOException {
      if (ToolBarAttributes.areDefaultAttributes()) {
        AbstractFile toolBarFile = getDescriptionFile();
        if (toolBarFile != null && toolBarFile.exists()) {
          LOGGER.info("Toolbar use default settings, removing descriptor file");
          toolBarFile.delete();
        }
        else
          LOGGER.debug("Toolbar not modified, not saving");
      }
      else if (toolBarWriter != null) {
View Full Code Here

     * Sets the path to the toolbar description file to be loaded when calling {@link #loadDescriptionFile()}.
     * By default, this file is {@link #DEFAULT_TOOLBAR_FILE_NAME} within the preferences folder.
     * @param path path to the toolbar descriptor file
     */
    public static void setDescriptionFile(String path) throws FileNotFoundException {
        AbstractFile file;

        if((file = FileFactory.getFile(path)) == null)
            setDescriptionFile(new File(path));
        else
            setDescriptionFile(file);
View Full Code Here

    //////////////////////////////////////////////

    @Override
    protected PathFieldContent computeInitialPath(FileSet files) {
        String initialPath = mainFrame.getInactivePanel().getCurrentFolder().getAbsolutePath(true);
        AbstractFile file;
        String fileName;
        // Computes the archive's default name:
        // - if it only contains one file, uses that file's name.
        // - if it contains more than one file, uses the FileSet's parent folder's name.
        if(files.size() == 1) {
            file = files.elementAt(0);
            fileName = file.isDirectory() && !DesktopManager.isApplication(file)
                    ?file.getName()
                    :file.getNameWithoutExtension();
        }
        else {
            file = files.getBaseFolder();
            fileName = file.isRoot()?"":DesktopManager.isApplication(file)?file.getNameWithoutExtension():file.getName();
        }

        return new PathFieldContent(initialPath + fileName + "." + Archiver.getFormatExtension(lastFormat), initialPath.length(), initialPath.length() + fileName.length());
    }
View Full Code Here

            // Remove any previous volumes from the Go menu
            // as they might have changed since menu was last selected
            for(int i=goMenu.getItemCount(); i> volumeOffset; i--)
                goMenu.remove(volumeOffset);

            AbstractFile volumes[] = LocalFile.getVolumes();
            int nbFolders = volumes.length;

            for(int i=0; i<nbFolders; i++)
                goMenu.add(new OpenLocationAction(mainFrame, new Hashtable<String, Object>(), volumes[i]));
        }
View Full Code Here

        setTitle(title);

        // Use new Window decorations introduced in Mac OS X 10.5 (Leopard)
        if(OsFamily.MAC_OS_X.isCurrent() && OsVersion.MAC_OS_X_10_5.isCurrentOrHigher()) {
            // Displays the document icon in the window title bar, works only for local files
            AbstractFile currentFolder = activeTable.getFolderPanel().getCurrentFolder();
            Object javaIoFile;
            if(currentFolder.getURL().getScheme().equals(FileProtocols.FILE)) {
                // If the current folder is an archive entry, display the archive file, this is the closest we can get
                // with a java.io.File
                if(currentFolder.hasAncestor(AbstractArchiveEntryFile.class))
                    javaIoFile = currentFolder.getParentArchive().getUnderlyingFileObject();
                else
                    javaIoFile = currentFolder.getUnderlyingFileObject();
            }
            else {
                // If the current folder is not a local file, use the special /Network directory which is sort of
                // 'Network Neighborhood'.
                javaIoFile = new java.io.File("/Network");
View Full Code Here

TOP

Related Classes of com.mucommander.commons.file.AbstractFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.