Package net.sf.jmp3renamer.util

Examples of net.sf.jmp3renamer.util.MyFile


  private void analyzeFiles() {
    List<MyFile> files = FileManager.getInstance().getFiles();

    for (int i = 0; i < files.size() && running; i++) {
      Dataset dataset = new Dataset();
      MyFile element = (MyFile) files.get(i);
      status.setText(I18N.translate("analyzing") + element);
      int percent = (int) ((double) i / (double) files.size() * 100);
      progress.setValue(percent);

      if (DoubleFinder.getProperty("use_md5").equals("true")) {
View Full Code Here


  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("DELETE")) {
      int index = fileList.getSelectedIndex();
      if (index >= 0) {
        Dataset dataset = (Dataset) fileListModel.getElementAt(index);
        MyFile file = dataset.getFile();
        boolean deleted = file.delete();
        if (deleted) {
          fileListModel.removeElement(dataset);
          int fileIndex = FileManager.getInstance().getFiles().indexOf(
              file);
          FileManager.getInstance().removeRow(fileIndex);
View Full Code Here

    }

    public void update(Object o, int row, int action) {
        DefaultTableModel model = (DefaultTableModel) dirtable.getModel();
        if(action == RowObserver.INSERT) {
            MyFile file = (MyFile)o;
            Vector<Object> r = new Vector<Object>();
            r.add(file.getIcon());
            r.add(file);
            model.addRow(r);
            model.fireTableRowsInserted(model.getRowCount()-1, model.getRowCount()-1);
        } else if(action == RowObserver.REMOVE){
            model.removeRow(row);
            model.fireTableRowsDeleted(row, row);
        } else if(action == RowObserver.UPDATE){
            MyFile file = (MyFile)o;
            model.setValueAt(file.getIcon(), row, 0);
            model.setValueAt(file, row, 1);
            model.fireTableRowsUpdated(row, row);
        } else if(action == RowObserver.REMOVEALL) {
            model.setRowCount(0);
            dirtable.repaint();
View Full Code Here

            this.files.clear();
            this.additionalFiles.clear();
            notifyRowObservers(null, 0, RowObserver.REMOVEALL);
            List<File> _files = findFiles(file, recursive, supportedFiles);
            for (File f : _files) {
                this.files.add(new MyFile(f));
            }

            // sort files by name
            Collections.sort(getFiles());
            Collections.reverse(getFiles());
View Full Code Here

        File oldDir = null;
        // move, rename and tag the audio files
        for (int i = 0; i < count; i++) {
            DataSet dataset = datasets.get(i);
            MyFile oldFile = files.get(i);
            File newFile = getNewFile(dataset, oldFile);

            // store the old directory, so that we can delete
            // it after renaming the files
            oldDir = oldFile.getParentFile();

            // change file state to renaming
            oldFile.setRenaming();
            notifyObservers();
            notifyRowObservers(oldFile, i, RowObserver.UPDATE);

            // move the file
            try {
                Ant.moveFile(oldFile, newFile);
            } catch (BuildException e) {
                oldFile.setFailed();
                notifyObservers();
                notifyRowObservers(oldFile, i, RowObserver.UPDATE);
                logger.warn(I18N.translate("error.rename_file", new Object[] {oldFile, newFile}), e);
                continue;
            }

            // update the file table
            MyFile file = new MyFile(newFile);
            files.set(i, file);
            file.setOK();

            // tag the file
            FilePlugin plugin = suffixToPlugin.get(file.getSuffix());
            try {
                plugin.setMetaData(file, dataset);
            } catch (Exception e) {
                logger.warn("Couldn't save metadata to file", e);
                file.setMetaFailed();
            }

            notifyObservers();
            notifyRowObservers(file, i, RowObserver.UPDATE);
        }
View Full Code Here

    private void moveAdditionalFiles() {
        // determine destination directory
        List<DataSet> datasets = DataManager.getInstance().getDatasets();
        DataSet dataset = datasets.get(0);
        MyFile oldFile = files.get(0);
        File file = getNewFile(dataset, oldFile);
        File destinationDirectory = file.getParentFile();

        // move additional files (cover etc.)
        boolean success = true;
View Full Code Here

        if(file.exists()) {
            if(file.isDirectory()) {
                logger.info(I18N.translate("info.skip_dir"), file.getAbsolutePath());
                return;
            }
            MyFile myFile = new MyFile(file);
            for (ExtendedFileFilter filter : fileFilters) {
                if(filter.accept(myFile)) {
                    if(!files.contains(myFile)) {
                        this.files.add(myFile);
                        notifyObservers();
View Full Code Here

        private List<String> suffices = new Vector<String>();

        public boolean accept(File f) {
            if(!f.isDirectory()) {
                MyFile file = new MyFile(f);
                if(suffices.contains(file.getSuffix())) {
                    return true;
                }
            }
            return false;
        }
View Full Code Here

        if (value == null) {
            this.setText("");
        } else if (value instanceof ImageIcon) {
            this.setIcon((ImageIcon) value);
            MyFile file = (MyFile) table.getModel().getValueAt(row, 1);
            AnimatedIcon.setHost(this);
            this.setToolTipText(file.getToolTip());
        } else {
            this.setText("");
        }
        return this;
    }
View Full Code Here

    public void update(Observable o, Object obj) {
        @SuppressWarnings("unchecked")
        List<MyFile> files = (List<MyFile>) obj;
        if (files.size() > 0) {
            MyFile file = files.get(0);
            lOldnameView.setText(file.getName());
            tUserRegex.setEnabled(true);
            extractDataButton.setEnabled(true);
            preview();
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.jmp3renamer.util.MyFile

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.