SourceForge: jubler/jubler: changeset 1035:4de4e42cb52a
Moved all file functions to JublerFile and implemented JublerFileChooser and SimpleFileFilter allowing its use to be more dynamic, especially with functions that load files externally with special needs. Cleaned up the Jubler's external functions, only create when needed. development
authorhoang_tran
Fri Oct 23 11:56:08 2009 +0100 (2 months ago)
branchdevelopment
changeset 10354de4e42cb52a
parent 1034 fdf7b60c7a0e
child 1036 b66009ffd596
Moved all file functions to JublerFile and implemented JublerFileChooser and SimpleFileFilter allowing its use to be more dynamic, especially with functions that load files externally with special needs. Cleaned up the Jubler's external functions, only create when needed.
src/com/panayotis/jubler/Jubler.java
src/com/panayotis/jubler/JublerFunction.java
src/com/panayotis/jubler/Main.java
src/com/panayotis/jubler/StaticJubler.java
src/com/panayotis/jubler/events/menu/file/AppendFromFile.java
src/com/panayotis/jubler/events/menu/file/ChildAction.java
src/com/panayotis/jubler/events/menu/file/FileNewAction.java
src/com/panayotis/jubler/events/menu/file/FileOpenAction.java
src/com/panayotis/jubler/events/menu/file/FileSaveAction.java
src/com/panayotis/jubler/events/menu/file/FileSaveAsAction.java
src/com/panayotis/jubler/events/menu/file/ImportComponent.java
src/com/panayotis/jubler/events/menu/file/RevertFileAction.java
src/com/panayotis/jubler/events/menu/tool/SplitSubtitleAction.java
src/com/panayotis/jubler/io/JublerFile.java
src/com/panayotis/jubler/io/JublerFileChooser.java
src/com/panayotis/jubler/io/SimpleFileFilter.java
src/com/panayotis/jubler/media/preview/JSubPreview.java
src/com/panayotis/jubler/os/Dropper.java
src/com/panayotis/jubler/os/SystemDependent.java
     1.1 --- a/src/com/panayotis/jubler/Jubler.java	Thu Oct 22 19:22:17 2009 +0100
     1.2 +++ b/src/com/panayotis/jubler/Jubler.java	Fri Oct 23 11:56:08 2009 +0100
     1.3 @@ -25,14 +25,12 @@
     1.4  import com.panayotis.jubler.events.app.WindowEventHandler;
     1.5  import com.panayotis.jubler.information.HelpBrowser;
     1.6  import static com.panayotis.jubler.i18n.I18N._;
     1.7 -import com.panayotis.jubler.subs.loader.SubFileFilter;
     1.8  import com.panayotis.jubler.media.MediaFile;
     1.9  import com.panayotis.jubler.options.JPreferences;
    1.10  import com.panayotis.jubler.media.console.JVideoConsole;
    1.11  import com.panayotis.jubler.media.preview.JSubPreview;
    1.12  import com.panayotis.jubler.options.IntegerComboBoxModel;
    1.13  import com.panayotis.jubler.options.ShortcutsModel;
    1.14 -import com.panayotis.jubler.os.FileCommunicator;
    1.15  import com.panayotis.jubler.subs.DropDownFunctionList;
    1.16  import com.panayotis.jubler.subs.DropDownFunctionList.FunctionList;
    1.17  import com.panayotis.jubler.subs.JSubEditor;
    1.18 @@ -41,18 +39,15 @@
    1.19  import com.panayotis.jubler.subs.SubEntry;
    1.20  import com.panayotis.jubler.subs.SubRenderer;
    1.21  import com.panayotis.jubler.subs.Subtitles;
    1.22 -import com.panayotis.jubler.tools.JDelSelection;
    1.23 -import com.panayotis.jubler.tools.JFixer;
    1.24  import com.panayotis.jubler.tools.JMarker;
    1.25  import com.panayotis.jubler.tools.JRecodeTime;
    1.26 -import com.panayotis.jubler.tools.JReplaceGlobal;
    1.27 -import com.panayotis.jubler.tools.JRounder;
    1.28  import com.panayotis.jubler.tools.JShiftTime;
    1.29 -import com.panayotis.jubler.tools.JSpeller;
    1.30  import com.panayotis.jubler.tools.JSubSplit;
    1.31  import com.panayotis.jubler.tools.JToolRealTime;
    1.32  import com.panayotis.jubler.tools.JTranslate;
    1.33  import com.panayotis.jubler.events.menu.edit.undo.UndoList;
    1.34 +import com.panayotis.jubler.io.JublerFile;
    1.35 +import com.panayotis.jubler.io.JublerFileChooser;
    1.36  import java.awt.Image;
    1.37  import java.awt.event.MouseAdapter;
    1.38  import java.awt.event.MouseEvent;
    1.39 @@ -75,6 +70,7 @@
    1.40   * @author  teras
    1.41   */
    1.42  public class Jubler extends JFrame {
    1.43 +
    1.44      public static JublerList windows;
    1.45      public static ArrayList<SubEntry> copybuffer;
    1.46      public static int selectedComponent = RecordComponent.CP_RECORD;
    1.47 @@ -85,10 +81,9 @@
    1.48      /* Window frame icon */
    1.49      public final static Image FrameIcon;
    1.50      private final static SubRenderer TableRenderer = new SubRenderer();
    1.51 -
    1.52 -
    1.53      /** File chooser dialog to open/ save subtitles */
    1.54 -    private JFileChooser filedialog;
    1.55 +    private JublerFileChooser filedialog;
    1.56 +    private JublerFile fileManager;
    1.57      /*
    1.58       * Where the subtitles for this window is stored
    1.59       */
    1.60 @@ -125,18 +120,11 @@
    1.61      private ComboBoxModel fnComboboxModel = new javax.swing.DefaultComboBoxModel(DropDownFunctionList.fnNames);
    1.62      /* Jubler tools */
    1.63      private JShiftTime shift;
    1.64 -    private JSpeller spell;
    1.65 -    private JRounder round;
    1.66 -    private JFixer fix;
    1.67 -    private JReplaceGlobal repg;
    1.68 -    private JDelSelection dels;
    1.69 -    private JMarker mark;
    1.70      private JRecodeTime recode;
    1.71 -    private JSubSplit split;
    1.72      private JTranslate translate;
    1.73      private boolean column_change;
    1.74      private JActionMap actionMap = null;
    1.75 -    
    1.76 +
    1.77      static {
    1.78          windows = new JublerList();
    1.79          copybuffer = new ArrayList<SubEntry>();
    1.80 @@ -149,48 +137,24 @@
    1.81          faqbrowse = new HelpBrowser("help/jubler-faq.html");
    1.82          FrameIcon = new ImageIcon(Jubler.class.getResource("/icons/frame.png")).getImage();
    1.83      }
    1.84 +    public JublerFunction fn = null;
    1.85  
    1.86 -    public JublerFunction fn  = null;
    1.87 -    
    1.88      /** Creates new this JubEdit */
    1.89      public Jubler() {
    1.90          initComponents();
    1.91 -        fn  = new JublerFunction(this);
    1.92          initApp();
    1.93      }
    1.94  
    1.95 -    public void initApp(){
    1.96 +    public void initApp() {
    1.97          subs = null;
    1.98 -        mfile = new MediaFile();
    1.99 -        connected_consoles = new Vector<JVideoConsole>();
   1.100 -
   1.101 -        undo = new UndoList(this);
   1.102 -        /* Initialize Tools */
   1.103 -        shift = new JShiftTime();
   1.104 -        spell = new JSpeller();
   1.105 -        round = new JRounder();
   1.106 -        fix = new JFixer();
   1.107 -        repg = new JReplaceGlobal();
   1.108 -        dels = new JDelSelection();
   1.109 -        mark = new JMarker();
   1.110 -        recode = new JRecodeTime();
   1.111 -        split = new JSubSplit();
   1.112 -        translate = new JTranslate();
   1.113 -
   1.114 -        /* Set JFileChooser properties */
   1.115 -        filedialog = new JFileChooser();
   1.116 -        filedialog.setMultiSelectionEnabled(false);
   1.117 -        filedialog.addChoosableFileFilter(new SubFileFilter());
   1.118 -        FileCommunicator.getDefaultDialogPath(filedialog);
   1.119 +        fn = new JublerFunction(this);
   1.120 +        filedialog = new JublerFileChooser(this);
   1.121 +        fileManager = new JublerFile(this);        
   1.122  
   1.123          setIconImage(FrameIcon);
   1.124 -        preview = new JSubPreview(this);
   1.125 -
   1.126          subeditor = new JSubEditor(this);
   1.127          subeditor.setAttached(true);
   1.128 -
   1.129 -        //this must be run after all control's initialisation has been done.        
   1.130 -        SubSplitPane.add(preview, JSplitPane.TOP);
   1.131 +        SubSplitPane.add(getPreview(), JSplitPane.TOP);
   1.132          fn.enablePreview(false);
   1.133  
   1.134          WebFM.setVisible(false);
   1.135 @@ -206,7 +170,6 @@
   1.136          ShortcutsModel.updateMenuNames(JublerMenuBar);
   1.137          StaticJubler.putWindowPosition(this);
   1.138          fn.openWindow();
   1.139 -        fn.updateRecentFile(null);
   1.140          actionMap = new JActionMap(this);
   1.141          /**
   1.142           * This is to make sure that the combo-box index matches the currently
   1.143 @@ -215,8 +178,9 @@
   1.144          int sel_index = DropDownFunctionList.getFunctionIndex(this.getFnOption());
   1.145          DropDownActionList.setSelectedIndex(sel_index);
   1.146          addWindowListener(new WindowEventHandler(this));
   1.147 +        fileManager.updateRecentFile(null);
   1.148      }
   1.149 -    
   1.150 +
   1.151      public Jubler(Subtitles data) {
   1.152          this();
   1.153          fn.setSubs(data);
   1.154 @@ -1120,7 +1084,6 @@
   1.155  
   1.156          pack();
   1.157      }// </editor-fold>//GEN-END:initComponents
   1.158 -
   1.159      // Variables declaration - do not modify//GEN-BEGIN:variables
   1.160      private javax.swing.JMenuItem AboutHM;
   1.161      private javax.swing.JMenuItem AfterIEM;
   1.162 @@ -1292,10 +1255,16 @@
   1.163      // End of variables declaration//GEN-END:variables
   1.164  
   1.165      public JToolRealTime getRecoder() {
   1.166 +        if (recode == null) {
   1.167 +            recode = new JRecodeTime();
   1.168 +        }
   1.169          return recode;
   1.170      }
   1.171  
   1.172      public JToolRealTime getShifter() {
   1.173 +        if (shift == null) {
   1.174 +            shift = new JShiftTime();
   1.175 +        }
   1.176          return shift;
   1.177      }
   1.178  
   1.179 @@ -1328,6 +1297,9 @@
   1.180      }
   1.181  
   1.182      public UndoList getUndoList() {
   1.183 +        if (undo == null) {
   1.184 +            undo = new UndoList(this);
   1.185 +        }
   1.186          return undo;
   1.187      }
   1.188  
   1.189 @@ -1377,7 +1349,7 @@
   1.190      public JSubEditor getSubeditor() {
   1.191          return subeditor;
   1.192      }
   1.193 -    
   1.194 +
   1.195      /**
   1.196       * @return the SubsScrollPane
   1.197       */
   1.198 @@ -1488,20 +1460,19 @@
   1.199       * @return the mfile
   1.200       */
   1.201      public MediaFile getMediaFile() {
   1.202 +        if (mfile == null) {
   1.203 +            mfile = new MediaFile();
   1.204 +        }
   1.205          return mfile;
   1.206      }
   1.207  
   1.208      /**
   1.209 -     * @param mfile the mfile to set
   1.210 -     */
   1.211 -    public void setMediaFile(MediaFile mfile) {
   1.212 -        this.mfile = mfile;
   1.213 -    }
   1.214 -
   1.215 -    /**
   1.216       * @return the connected_consoles
   1.217       */
   1.218      public Vector<JVideoConsole> getConnectedConsoles() {
   1.219 +        if (connected_consoles == null) {
   1.220 +            connected_consoles = new Vector<JVideoConsole>();
   1.221 +        }
   1.222          return connected_consoles;
   1.223      }
   1.224  
   1.225 @@ -1789,6 +1760,9 @@
   1.226       * @return the preview
   1.227       */
   1.228      public JSubPreview getPreview() {
   1.229 +        if (preview == null) {
   1.230 +            preview = new JSubPreview(this);
   1.231 +        }
   1.232          return preview;
   1.233      }
   1.234  
   1.235 @@ -1831,6 +1805,9 @@
   1.236       * @return the translate
   1.237       */
   1.238      public JTranslate getTranslate() {
   1.239 +        if (translate == null) {
   1.240 +            translate = new JTranslate();
   1.241 +        }
   1.242          return translate;
   1.243      }
   1.244  
   1.245 @@ -1848,7 +1825,6 @@
   1.246          return NewTB;
   1.247      }
   1.248  
   1.249 -
   1.250      /**
   1.251       * @param RedoTB the RedoTB to set
   1.252       */
   1.253 @@ -2149,7 +2125,8 @@
   1.254      public javax.swing.JMenuItem getRetrieveWFM() {
   1.255          return RetrieveWFM;
   1.256      }
   1.257 -   /**
   1.258 +
   1.259 +    /**
   1.260       * @return the RoundTM
   1.261       */
   1.262      public javax.swing.JMenuItem getRoundTM() {
   1.263 @@ -2344,4 +2321,19 @@
   1.264      public javax.swing.JMenu getToolsM() {
   1.265          return ToolsM;
   1.266      }
   1.267 -}//end public class Jubler extends JFrame
   1.268 \ No newline at end of file
   1.269 +
   1.270 +    /**
   1.271 +     * @return the fileManager
   1.272 +     */
   1.273 +    public JublerFile getFileManager() {
   1.274 +        return fileManager;
   1.275 +    }
   1.276 +
   1.277 +    /**
   1.278 +     * @return the RecentsFM
   1.279 +     */
   1.280 +    public javax.swing.JMenu getRecentsFM() {
   1.281 +        return RecentsFM;
   1.282 +    }
   1.283 +}//end public class Jubler extends JFrame
   1.284 +
     2.1 --- a/src/com/panayotis/jubler/JublerFunction.java	Thu Oct 22 19:22:17 2009 +0100
     2.2 +++ b/src/com/panayotis/jubler/JublerFunction.java	Fri Oct 23 11:56:08 2009 +0100
     2.3 @@ -253,17 +253,6 @@
     2.4          return where;
     2.5      }
     2.6  
     2.7 -    public void initNewFile(String fname) {
     2.8 -        UndoList undo = jb.getUndoList();
     2.9 -        JSubEditor subeditor = jb.getSubeditor();
    2.10 -
    2.11 -        undo.invalidateSaveMark();
    2.12 -        setFile(new File(fname), true);
    2.13 -        SaveFM.setEnabled(false);
    2.14 -        RevertFM.setEnabled(false);
    2.15 -        subeditor.focusOnText();
    2.16 -    }
    2.17 -
    2.18      public void setDropHandler() {
    2.19          Dropper r = new Dropper(jb);
    2.20          BasicPanel.setTransferHandler(r);
    2.21 @@ -275,28 +264,6 @@
    2.22          //SubTable.setDropTarget(new DropTarget(SubTable, r));
    2.23      }
    2.24  
    2.25 -    public void updateRecentFile(File recent) {
    2.26 -        Subtitles subs = jb.getSubtitles();
    2.27 -
    2.28 -        if (subs != null) {
    2.29 -            subs.setLastOpenedFile(recent);
    2.30 -        }
    2.31 -        FileCommunicator.updateRecentsList(recent);
    2.32 -        FileCommunicator.updateRecentsMenu();
    2.33 -    }
    2.34 -
    2.35 -    /* This method is called when an item in the recent menu is clicked */
    2.36 -    public void recentMenuCallback(String filename) {
    2.37 -        Subtitles subs = jb.getSubtitles();
    2.38 -        if (filename == null) {
    2.39 -            Jubler jub = new Jubler(new Subtitles(subs));
    2.40 -            initNewFile(subs.getCurrentFile().getPath() + _("_clone"));
    2.41 -            /* The user wants to clone current file */
    2.42 -        } else {
    2.43 -            loadFileFromHere(new File(filename), false);
    2.44 -        }
    2.45 -    }
    2.46 -
    2.47      public void addNewSubtitle(boolean is_after) {
    2.48          double prevtime, nexttime;
    2.49          double curdur, gap, avail, requested, center, start;
    2.50 @@ -389,92 +356,6 @@
    2.51          tableHasChanged(selected);
    2.52      }
    2.53  
    2.54 -    public void saveFile(File f) {
    2.55 -        UndoList undo = jb.getUndoList();
    2.56 -        Subtitles subs = jb.getSubtitles();
    2.57 -
    2.58 -        String ext = "." + Jubler.prefs.getSaveFormat().getExtension();
    2.59 -        f = FileCommunicator.stripFileFromVideoExtension(f);
    2.60 -        f = new File(f.getPath() + ext);
    2.61 -
    2.62 -
    2.63 -        String result = FileCommunicator.save(subs, f, Jubler.prefs, jb.getMediaFile());
    2.64 -        if (result == null) {
    2.65 -            /* Saving succesfull */
    2.66 -            undo.setSaveMark();
    2.67 -            setFile(f, false);
    2.68 -        } else {
    2.69 -            JIDialog.error(jb, result, _("Error while saving file"));
    2.70 -        }
    2.71 -    }
    2.72 -
    2.73 -    public void loadFileFromHere(File f, boolean force_into_same_window) {
    2.74 -        StaticJubler.setWindowPosition(jb, false);    // Use jb window as a base for open dialogs
    2.75 -
    2.76 -        loadFile(f, force_into_same_window);
    2.77 -    }
    2.78 -
    2.79 -    public void loadFile(File f, boolean force_into_same_window) {
    2.80 -        String data;
    2.81 -        Subtitles newsubs;
    2.82 -        Jubler work;
    2.83 -        boolean is_autoload;
    2.84 -
    2.85 -        Subtitles subs = jb.getSubtitles();
    2.86 -
    2.87 -        /* Find where to display jb subtitle file */
    2.88 -        if (subs == null || force_into_same_window) {
    2.89 -            work = jb;
    2.90 -        } else {
    2.91 -            work = new Jubler();
    2.92 -        }
    2.93 -
    2.94 -        /* Initialize Subtitles */
    2.95 -        newsubs = new Subtitles(jb);
    2.96 -        newsubs.setCurrentFile(FileCommunicator.stripFileFromVideoExtension(f)); // getFPS requires it
    2.97 -
    2.98 -        /* Check if jb is an auto-load subtitle file */
    2.99 -        is_autoload = f.getName().startsWith(AutoSaver.AUTOSAVEPREFIX);
   2.100 -
   2.101 -        /* Load file into memory */
   2.102 -        if (!is_autoload) {
   2.103 -            Jubler.prefs.showLoadDialog(work, work.getMediaFile(), newsubs); //Fileload dialog, if desired
   2.104 -
   2.105 -        }
   2.106 -        data = FileCommunicator.load(f, is_autoload ? null : Jubler.prefs);
   2.107 -        if (data == null) {
   2.108 -            JIDialog.error(jb, _("Could not load file. Possibly an encoding error."), _("Error while loading file"));
   2.109 -            return;
   2.110 -        }
   2.111 -        /* Strip autosave prefix from filename */
   2.112 -        if (is_autoload) {
   2.113 -            f = new File(f.getName().substring(AutoSaver.AUTOSAVEPREFIX.length() + 5));
   2.114 -            newsubs.setCurrentFile(f);
   2.115 -        }
   2.116 -
   2.117 -        /* Convert file into subtitle data */
   2.118 -        newsubs.populate(work, f, data, is_autoload ? 25 : Jubler.prefs.getLoadFPS());
   2.119 -        if (newsubs.size() == 0) {
   2.120 -            JIDialog.error(jb, _("File not recognized!"), _("Error while loading file"));
   2.121 -            return;
   2.122 -        }
   2.123 -
   2.124 -        Subtitles work_subs = work.getSubtitles();
   2.125 -        UndoList work_undo = work.getUndoList();
   2.126 -        if (work_subs != null) {
   2.127 -            work_undo.addUndo(new UndoEntry(work_subs, _("Reload subtitles")));
   2.128 -        }
   2.129 -
   2.130 -        if (is_autoload) {
   2.131 -            work_undo.invalidateSaveMark();
   2.132 -        } else {
   2.133 -            work_undo.setSaveMark();
   2.134 -        }
   2.135 -        work.fn.setSubs(newsubs);
   2.136 -        work.fn.setFile(f, true);
   2.137 -        work.getSaveFM().setEnabled(true);
   2.138 -    }
   2.139 -
   2.140      public void testVideo(Time t) {
   2.141          Subtitles subs = jb.getSubtitles();
   2.142          MediaFile mfile = jb.getMediaFile();
   2.143 @@ -505,40 +386,6 @@
   2.144          }
   2.145      }
   2.146  
   2.147 -    /* Set the filename of jb project and enanble the buttons */
   2.148 -    public void setFile(File f, boolean reset_selection) {
   2.149 -        RevertFM.setEnabled(true);
   2.150 -        ChildNFM.setEnabled(true);
   2.151 -        SaveFM.setEnabled(true);
   2.152 -        SaveAsFM.setEnabled(true);
   2.153 -        InfoFM.setEnabled(true);
   2.154 -        EditM.setEnabled(true);
   2.155 -        ToolsM.setEnabled(true);
   2.156 -
   2.157 -        SaveTB.setEnabled(true);
   2.158 -        InfoTB.setEnabled(true);
   2.159 -        CutTB.setEnabled(true);
   2.160 -        CopyTB.setEnabled(true);
   2.161 -        PasteTB.setEnabled(true);
   2.162 -        SortTB.setEnabled(true);
   2.163 -        TestTB.setEnabled(true);
   2.164 -        PreviewTB.setEnabled(true);
   2.165 -        DoItTB.setEnabled(true);
   2.166 -        DropDownActionNumberOfLine.setEnabled(true);
   2.167 -        DropDownActionNumberOfLine.setEditable(true);
   2.168 -        DropDownActionList.setEnabled(true);
   2.169 -        AppendFromFileFM.setEnabled(true);
   2.170 -        ImportComponentFM.setEnabled(true);
   2.171 -
   2.172 -        Subtitles subs = jb.getSubtitles();
   2.173 -        subs.setCurrentFile(FileCommunicator.stripFileFromVideoExtension(f));
   2.174 -        updateRecentFile(f);
   2.175 -        showInfo();
   2.176 -        if (reset_selection) {
   2.177 -            setSelectedSub(0, true);
   2.178 -        }
   2.179 -    }
   2.180 -
   2.181      public void enablePreview(boolean status) {
   2.182          BasicPanel.remove(SubSplitPane);
   2.183          BasicPanel.remove(SubsScrollPane);
     3.1 --- a/src/com/panayotis/jubler/Main.java	Thu Oct 22 19:22:17 2009 +0100
     3.2 +++ b/src/com/panayotis/jubler/Main.java	Fri Oct 23 11:56:08 2009 +0100
     3.3 @@ -36,6 +36,7 @@
     3.4  import java.awt.event.MouseEvent;
     3.5  import java.io.File;
     3.6  import java.util.Vector;
     3.7 +import java.util.logging.Level;
     3.8  import javax.swing.JWindow;
     3.9  
    3.10  /**
    3.11 @@ -48,10 +49,10 @@
    3.12       * @param args the command line arguments
    3.13       */
    3.14      public static void main(String args[]) {
    3.15 -        new DEBUG(); //initialise the debug so that we can add handler to it.
    3.16          /* Before the slightest code execution, we HAVE to grab uncaught exceptions */
    3.17          ExceptionHandler eh = new ExceptionHandler();
    3.18          Thread.setDefaultUncaughtExceptionHandler(eh);
    3.19 +        new DEBUG(); //initialise the debug so that we can add handler to it.
    3.20  
    3.21          splash = new MainSplash("/icons/splash.jpg");
    3.22          SystemDependent.setLookAndFeel();
    3.23 @@ -80,7 +81,7 @@
    3.24                              }
    3.25  
    3.26                              if (f.exists() && f.isFile() && f.canRead()) {
    3.27 -                                Jubler.windows.elementAt(0).fn.loadFile(f, false);
    3.28 +                                Jubler.windows.elementAt(0).getFileManager().loadFile(f, false);
    3.29                              }
    3.30  
    3.31                              if (autosave_counter == autosaves) {
    3.32 @@ -91,7 +92,9 @@
    3.33                              wait();
    3.34                          }
    3.35                      } catch (InterruptedException ex) {
    3.36 +                        DEBUG.logger.log(Level.WARNING, ex.toString());
    3.37                      } catch (ArrayIndexOutOfBoundsException ex) {
    3.38 +                        DEBUG.logger.log(Level.WARNING, ex.toString());
    3.39                      }
    3.40                  }
    3.41              }
     4.1 --- a/src/com/panayotis/jubler/StaticJubler.java	Thu Oct 22 19:22:17 2009 +0100
     4.2 +++ b/src/com/panayotis/jubler/StaticJubler.java	Fri Oct 23 11:56:08 2009 +0100
     4.3 @@ -189,7 +189,7 @@
     4.4      public static void populateRecentsMenu(ArrayList<String> files) {
     4.5          JMenu recent_menu;
     4.6          for (Jubler j : Jubler.windows) {
     4.7 -            recent_menu = j.RecentsFM;
     4.8 +            recent_menu = j.getRecentsFM();
     4.9  
    4.10              /* Add clone entry */
    4.11              recent_menu.removeAll();
    4.12 @@ -223,9 +223,9 @@
    4.13  
    4.14              public void actionPerformed(ActionEvent e) {
    4.15                  if (isclone_f) {
    4.16 -                    jub_f.fn.recentMenuCallback(null);
    4.17 +                    jub_f.getFileManager().recentMenuCallback(null);
    4.18                  } else {
    4.19 -                    jub_f.fn.recentMenuCallback(text_f);
    4.20 +                    jub_f.getFileManager().recentMenuCallback(text_f);
    4.21                  }
    4.22              }
    4.23          });
     5.1 --- a/src/com/panayotis/jubler/events/menu/file/AppendFromFile.java	Thu Oct 22 19:22:17 2009 +0100
     5.2 +++ b/src/com/panayotis/jubler/events/menu/file/AppendFromFile.java	Fri Oct 23 11:56:08 2009 +0100
     5.3 @@ -61,7 +61,7 @@
     5.4              
     5.5              Subtitles newsubs;
     5.6  
     5.7 -            newsubs = jublerParent.fn.loadSubtitleFile();
     5.8 +            newsubs = jublerParent.getFileManager().loadSubtitleFile();
     5.9              if (newsubs == null) {
    5.10                  return;
    5.11              }
     6.1 --- a/src/com/panayotis/jubler/events/menu/file/ChildAction.java	Thu Oct 22 19:22:17 2009 +0100
     6.2 +++ b/src/com/panayotis/jubler/events/menu/file/ChildAction.java	Fri Oct 23 11:56:08 2009 +0100
     6.3 @@ -60,7 +60,7 @@
     6.4          curjubler.fn.setSubs(s);
     6.5  
     6.6          String fname = subs.getCurrentFile().getPath() + _("_child");
     6.7 -        curjubler.fn.initNewFile(fname);
     6.8 +        curjubler.getFileManager().initNewFile(fname);
     6.9          jb.setConnectToOther(jb);
    6.10      }//end public void actionPerformed(ActionEvent evt)
    6.11  }//end public class ChildAction extends MenuAction
     7.1 --- a/src/com/panayotis/jubler/events/menu/file/FileNewAction.java	Thu Oct 22 19:22:17 2009 +0100
     7.2 +++ b/src/com/panayotis/jubler/events/menu/file/FileNewAction.java	Fri Oct 23 11:56:08 2009 +0100
     7.3 @@ -65,7 +65,7 @@
     7.4          Subtitles s = new Subtitles();
     7.5          s.add(new SubEntry(new Time(0), new Time(10), ""));
     7.6          curjubler.fn.setSubs(s);
     7.7 -        curjubler.fn.initNewFile(FileCommunicator.getCurrentPath() + _("Untitled"));
     7.8 +        curjubler.getFileManager().initNewFile(FileCommunicator.getCurrentPath() + _("Untitled"));
     7.9  
    7.10      }//end public void actionPerformed(ActionEvent evt)
    7.11  }//end public class FileNewAction extends MenuAction
     8.1 --- a/src/com/panayotis/jubler/events/menu/file/FileOpenAction.java	Thu Oct 22 19:22:17 2009 +0100
     8.2 +++ b/src/com/panayotis/jubler/events/menu/file/FileOpenAction.java	Fri Oct 23 11:56:08 2009 +0100
     8.3 @@ -57,7 +57,7 @@
     8.4              return;
     8.5          }
     8.6          FileCommunicator.setDefaultDialogPath(filedialog);
     8.7 -        jb.fn.loadFileFromHere(filedialog.getSelectedFile(), false);
     8.8 +        jb.getFileManager().loadFileFromHere(filedialog.getSelectedFile(), false);
     8.9  
    8.10      }//end public void actionPerformed(ActionEvent evt)
    8.11  }//end public class FileOpenAction extends MenuAction
     9.1 --- a/src/com/panayotis/jubler/events/menu/file/FileSaveAction.java	Thu Oct 22 19:22:17 2009 +0100
     9.2 +++ b/src/com/panayotis/jubler/events/menu/file/FileSaveAction.java	Fri Oct 23 11:56:08 2009 +0100
     9.3 @@ -55,7 +55,7 @@
     9.4          
     9.5          Jubler.prefs.showSaveDialog(jb, mfile, subs); //Show the "save options" dialog, if desired
     9.6  
     9.7 -        jb.fn.saveFile(subs.getCurrentFile());
     9.8 +        jb.getFileManager().saveFile(subs.getCurrentFile());
     9.9  
    9.10      }//end public void actionPerformed(ActionEvent evt)
    9.11  }//end public class FileSaveAction extends MenuAction
    10.1 --- a/src/com/panayotis/jubler/events/menu/file/FileSaveAsAction.java	Thu Oct 22 19:22:17 2009 +0100
    10.2 +++ b/src/com/panayotis/jubler/events/menu/file/FileSaveAsAction.java	Fri Oct 23 11:56:08 2009 +0100
    10.3 @@ -66,7 +66,7 @@
    10.4          Jubler.prefs.setShowSaveDiaglog(true);
    10.5          Jubler.prefs.showSaveDialog(jb, mfile, subs); //Show the "save options" dialog, if desired
    10.6  
    10.7 -        jb.fn.saveFile(filedialog.getSelectedFile());
    10.8 +        jb.getFileManager().saveFile(filedialog.getSelectedFile());
    10.9  
   10.10      }//end public void actionPerformed(ActionEvent evt)
   10.11  }//end public class FileSaveAsAction extends MenuAction
    11.1 --- a/src/com/panayotis/jubler/events/menu/file/ImportComponent.java	Thu Oct 22 19:22:17 2009 +0100
    11.2 +++ b/src/com/panayotis/jubler/events/menu/file/ImportComponent.java	Fri Oct 23 11:56:08 2009 +0100
    11.3 @@ -58,7 +58,7 @@
    11.4          boolean changed = false;
    11.5          SubEntry current_entry, import_entry;
    11.6          try {
    11.7 -            newsubs = jublerParent.fn.loadSubtitleFile();
    11.8 +            newsubs = jublerParent.getFileManager().loadSubtitleFile();
    11.9              if (newsubs == null) {
   11.10                  return;
   11.11              }
    12.1 --- a/src/com/panayotis/jubler/events/menu/file/RevertFileAction.java	Thu Oct 22 19:22:17 2009 +0100
    12.2 +++ b/src/com/panayotis/jubler/events/menu/file/RevertFileAction.java	Fri Oct 23 11:56:08 2009 +0100
    12.3 @@ -50,6 +50,6 @@
    12.4      public void actionPerformed(ActionEvent evt) {
    12.5          Jubler jb = jublerParent;
    12.6          Subtitles subs = jb.getSubtitles();
    12.7 -        jb.fn.loadFileFromHere(subs.getLastOpenedFile(), true);
    12.8 +        jb.getFileManager().loadFileFromHere(subs.getLastOpenedFile(), true);
    12.9      }//end public void actionPerformed(ActionEvent evt)
   12.10  }//end public class RevertFileAction extends MenuAction
    13.1 --- a/src/com/panayotis/jubler/events/menu/tool/SplitSubtitleAction.java	Thu Oct 22 19:22:17 2009 +0100
    13.2 +++ b/src/com/panayotis/jubler/events/menu/tool/SplitSubtitleAction.java	Fri Oct 23 11:56:08 2009 +0100
    13.3 @@ -104,8 +104,8 @@
    13.4          UndoList new_win_undo = newwindow.getUndoList();
    13.5          new_win_undo.invalidateSaveMark();
    13.6  
    13.7 -        newwindow.fn.setFile(new File(oldsubs.getCurrentFile() + "_2"), true);
    13.8 -        jb.fn.setFile(new File(oldsubs.getCurrentFile() + "_1"), false);
    13.9 +        newwindow.getFileManager().setFile(new File(oldsubs.getCurrentFile() + "_2"), true);
   13.10 +        jb.getFileManager().setFile(new File(oldsubs.getCurrentFile() + "_1"), false);
   13.11      }//end public void actionPerformed(ActionEvent evt)
   13.12  }//end public class SplitSubtitleAction extends MenuAction
   13.13  
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/com/panayotis/jubler/io/JublerFile.java	Fri Oct 23 11:56:08 2009 +0100
    14.3 @@ -0,0 +1,317 @@
    14.4 +/*
    14.5 + *  JublerFile.java
    14.6 + * 
    14.7 + *  Created on: 22-Oct-2009 at 21:25:08
    14.8 + * 
    14.9 + *  
   14.10 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   14.11 + * 
   14.12 + * This file is part of Jubler.
   14.13 + * 
   14.14 + * Jubler is free software; you can redistribute it and/or modify
   14.15 + * it under the terms of the GNU General Public License as published by
   14.16 + * the Free Software Foundation, version 2.
   14.17 + * 
   14.18 + * 
   14.19 + * Jubler is distributed in the hope that it will be useful,
   14.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.22 + * GNU General Public License for more details.
   14.23 + * 
   14.24 + * You should have received a copy of the GNU General Public License
   14.25 + * along with Jubler; if not, write to the Free Software
   14.26 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   14.27 + * 
   14.28 + * Contributor(s):
   14.29 + * 
   14.30 + */
   14.31 +package com.panayotis.jubler.io;
   14.32 +
   14.33 +import com.panayotis.jubler.Jubler;
   14.34 +import com.panayotis.jubler.StaticJubler;
   14.35 +import com.panayotis.jubler.events.menu.edit.undo.UndoEntry;
   14.36 +import com.panayotis.jubler.events.menu.edit.undo.UndoList;
   14.37 +import com.panayotis.jubler.os.AutoSaver;
   14.38 +import com.panayotis.jubler.os.DEBUG;
   14.39 +import com.panayotis.jubler.os.FileCommunicator;
   14.40 +import com.panayotis.jubler.os.JIDialog;
   14.41 +import com.panayotis.jubler.subs.JSubEditor;
   14.42 +import com.panayotis.jubler.subs.Subtitles;
   14.43 +import com.panayotis.jubler.subs.loader.SubFormat;
   14.44 +import java.io.File;
   14.45 +import java.util.logging.Level;
   14.46 +import javax.swing.JFileChooser;
   14.47 +import static com.panayotis.jubler.i18n.I18N._;
   14.48 +/**
   14.49 + *
   14.50 + * @author teras & hoang_tran 
   14.51 + */
   14.52 +public class JublerFile {
   14.53 +
   14.54 +    Jubler jb = null;
   14.55 +    private javax.swing.JButton CopyTB;
   14.56 +    private javax.swing.JButton CutTB;
   14.57 +    private javax.swing.JButton DoItTB;
   14.58 +    private javax.swing.JButton InfoTB;
   14.59 +    private javax.swing.JButton PasteTB;
   14.60 +    private javax.swing.JButton PreviewTB;
   14.61 +    private javax.swing.JButton SaveTB;
   14.62 +    private javax.swing.JButton SortTB;
   14.63 +    private javax.swing.JButton TestTB;
   14.64 +    private javax.swing.JComboBox DropDownActionList;
   14.65 +    private javax.swing.JComboBox DropDownActionNumberOfLine;
   14.66 +    private javax.swing.JMenu EditM;
   14.67 +    private javax.swing.JMenu ToolsM;
   14.68 +    private javax.swing.JMenuItem AppendFromFileFM;
   14.69 +    private javax.swing.JMenuItem ChildNFM;
   14.70 +    private javax.swing.JMenuItem ImportComponentFM;
   14.71 +    private javax.swing.JMenuItem InfoFM;
   14.72 +    private javax.swing.JMenuItem RevertFM;
   14.73 +    private javax.swing.JMenuItem SaveAsFM;
   14.74 +    private javax.swing.JMenuItem SaveFM;
   14.75 +
   14.76 +    private SubFormat selectedFormatHandler = null;
   14.77 +    public JublerFile(Jubler parent) {
   14.78 +        jb = parent;
   14.79 +        init();
   14.80 +    }//end public JublerFile(Jubler parent)
   14.81 +
   14.82 +    public void init(){
   14.83 +        AppendFromFileFM = jb.getAppendFromFileFM();
   14.84 +        ChildNFM = jb.getChildNFM();
   14.85 +        CopyTB = jb.getCopyTB();
   14.86 +        CutTB = jb.getCutTB();
   14.87 +        DoItTB = jb.getDoItTB();
   14.88 +        DropDownActionList = jb.getDropDownActionList();
   14.89 +        DropDownActionNumberOfLine = jb.getDropDownActionNumberOfLine();
   14.90 +        EditM = jb.getEditM();
   14.91 +        ImportComponentFM = jb.getImportComponentFM();
   14.92 +        InfoFM = jb.getInfoFM();
   14.93 +        InfoTB = jb.getInfoTB();
   14.94 +        PasteTB = jb.getPasteTB();
   14.95 +        PreviewTB = jb.getPreviewTB();
   14.96 +        RevertFM = jb.getRevertFM();
   14.97 +        SaveAsFM = jb.getSaveAsFM();
   14.98 +        SaveFM = jb.getSaveFM();
   14.99 +        SaveTB = jb.getSaveTB();
  14.100 +        SortTB = jb.getSortTB();
  14.101 +        TestTB = jb.getTestTB();
  14.102 +        ToolsM = jb.getToolsM();
  14.103 +    }//end public void init()
  14.104 +
  14.105 +    public void initNewFile(String fname) {
  14.106 +        UndoList undo = jb.getUndoList();
  14.107 +        JSubEditor subeditor = jb.getSubeditor();
  14.108 +
  14.109 +        undo.invalidateSaveMark();
  14.110 +        setFile(new File(fname), true);
  14.111 +        SaveFM.setEnabled(false);
  14.112 +        RevertFM.setEnabled(false);
  14.113 +        subeditor.focusOnText();
  14.114 +    }//end public void initNewFile(String fname)
  14.115 +
  14.116 +    /* Set the filename of jb project and enanble the buttons */
  14.117 +    public void setFile(File f, boolean reset_selection) {
  14.118 +        RevertFM.setEnabled(true);
  14.119 +        ChildNFM.setEnabled(true);
  14.120 +        SaveFM.setEnabled(true);
  14.121 +        SaveAsFM.setEnabled(true);
  14.122 +        InfoFM.setEnabled(true);
  14.123 +        EditM.setEnabled(true);
  14.124 +        ToolsM.setEnabled(true);
  14.125 +
  14.126 +        SaveTB.setEnabled(true);
  14.127 +        InfoTB.setEnabled(true);
  14.128 +        CutTB.setEnabled(true);
  14.129 +        CopyTB.setEnabled(true);
  14.130 +        PasteTB.setEnabled(true);
  14.131 +        SortTB.setEnabled(true);
  14.132 +        TestTB.setEnabled(true);
  14.133 +        PreviewTB.setEnabled(true);
  14.134 +        DoItTB.setEnabled(true);
  14.135 +        DropDownActionNumberOfLine.setEnabled(true);
  14.136 +        DropDownActionNumberOfLine.setEditable(true);
  14.137 +        DropDownActionList.setEnabled(true);
  14.138 +        AppendFromFileFM.setEnabled(true);
  14.139 +        ImportComponentFM.setEnabled(true);
  14.140 +
  14.141 +        Subtitles subs = jb.getSubtitles();
  14.142 +        subs.setCurrentFile(FileCommunicator.stripFileFromVideoExtension(f));
  14.143 +        updateRecentFile(f);
  14.144 +        jb.fn.showInfo();
  14.145 +        if (reset_selection) {
  14.146 +            jb.fn.setSelectedSub(0, true);
  14.147 +        }
  14.148 +    }
  14.149 +
  14.150 +    public void updateRecentFile(File recent) {
  14.151 +        Subtitles subs = jb.getSubtitles();
  14.152 +
  14.153 +        if (subs != null) {
  14.154 +            subs.setLastOpenedFile(recent);
  14.155 +        }
  14.156 +        FileCommunicator.updateRecentsList(recent);
  14.157 +        FileCommunicator.updateRecentsMenu();
  14.158 +    }
  14.159 +
  14.160 +    public void saveFile(File f) {
  14.161 +        UndoList undo = jb.getUndoList();
  14.162 +        Subtitles subs = jb.getSubtitles();
  14.163 +
  14.164 +        String ext = "." + Jubler.prefs.getSaveFormat().getExtension();
  14.165 +        f = FileCommunicator.stripFileFromVideoExtension(f);
  14.166 +        f = new File(f.getPath() + ext);
  14.167 +
  14.168 +
  14.169 +        String result = FileCommunicator.save(subs, f, Jubler.prefs, jb.getMediaFile());
  14.170 +        if (result == null) {
  14.171 +            /* Saving succesfull */
  14.172 +            undo.setSaveMark();
  14.173 +            setFile(f, false);
  14.174 +        } else {
  14.175 +            JIDialog.error(jb, result, _("Error while saving file"));
  14.176 +        }
  14.177 +    }
  14.178 +
  14.179 +    public void loadFileFromHere(File f, boolean force_into_same_window) {
  14.180 +        StaticJubler.setWindowPosition(jb, false);    // Use jb window as a base for open dialogs
  14.181 +
  14.182 +        loadFile(f, force_into_same_window);
  14.183 +    }
  14.184 +
  14.185 +    public void loadFile(File f, boolean force_into_same_window) {
  14.186 +        String data;
  14.187 +        Subtitles newsubs;
  14.188 +        Jubler work;
  14.189 +        boolean is_autoload;
  14.190 +
  14.191 +        Subtitles subs = jb.getSubtitles();
  14.192 +
  14.193 +        /* Find where to display jb subtitle file */
  14.194 +        if (subs == null || force_into_same_window) {
  14.195 +            work = jb;
  14.196 +        } else {
  14.197 +            work = new Jubler();
  14.198 +        }
  14.199 +
  14.200 +        /* Initialize Subtitles */
  14.201 +        newsubs = new Subtitles(jb);
  14.202 +        newsubs.setCurrentFile(FileCommunicator.stripFileFromVideoExtension(f)); // getFPS requires it
  14.203 +
  14.204 +        /* Check if jb is an auto-load subtitle file */
  14.205 +        is_autoload = f.getName().startsWith(AutoSaver.AUTOSAVEPREFIX);
  14.206 +
  14.207 +        /* Load file into memory */
  14.208 +        if (!is_autoload) {
  14.209 +            Jubler.prefs.showLoadDialog(work, work.getMediaFile(), newsubs); //Fileload dialog, if desired
  14.210 +
  14.211 +        }
  14.212 +        data = FileCommunicator.load(f, is_autoload ? null : Jubler.prefs);
  14.213 +        if (data == null) {
  14.214 +            JIDialog.error(jb, _("Could not load file. Possibly an encoding error."), _("Error while loading file"));
  14.215 +            return;
  14.216 +        }
  14.217 +        /* Strip autosave prefix from filename */
  14.218 +        if (is_autoload) {
  14.219 +            f = new File(f.getName().substring(AutoSaver.AUTOSAVEPREFIX.length() + 5));
  14.220 +            newsubs.setCurrentFile(f);
  14.221 +        }
  14.222 +
  14.223 +        /* Convert file into subtitle data */
  14.224 +        newsubs.populate(work, f, data, is_autoload ? 25 : Jubler.prefs.getLoadFPS());
  14.225 +        if (newsubs.size() == 0) {
  14.226 +            JIDialog.error(jb, _("File not recognized!"), _("Error while loading file"));
  14.227 +            return;
  14.228 +        }
  14.229 +
  14.230 +        Subtitles work_subs = work.getSubtitles();
  14.231 +        UndoList work_undo = work.getUndoList();
  14.232 +        if (work_subs != null) {
  14.233 +            work_undo.addUndo(new UndoEntry(work_subs, _("Reload subtitles")));
  14.234 +        }
  14.235 +
  14.236 +        if (is_autoload) {
  14.237 +            work_undo.invalidateSaveMark();
  14.238 +        } else {
  14.239 +            work_undo.setSaveMark();
  14.240 +        }
  14.241 +        work.fn.setSubs(newsubs);
  14.242 +        work.getFileManager().setFile(f, true);
  14.243 +        work.getSaveFM().setEnabled(true);
  14.244 +    }
  14.245 +
  14.246 +    /**
  14.247 +     * This routine loads a new subtitle file for use in addition with
  14.248 +     * the loaded subtitle set. This function is used in import and append
  14.249 +     * operations.
  14.250 +     *
  14.251 +     * @return new set of subtitle events stored in an instance of
  14.252 +     * {@link Subtitles} or null if the user has cancelled the operation
  14.253 +     * or the file format is not recognised by any of internal subtitle
  14.254 +     * processor.
  14.255 +     */
  14.256 +    public Subtitles loadSubtitleFile() {
  14.257 +        String data;
  14.258 +        Subtitles newsubs = null;
  14.259 +        try {
  14.260 +            JFileChooser filedialog = jb.getFiledialog();
  14.261 +
  14.262 +            filedialog.setDialogTitle(_("Load Subtitles"));
  14.263 +            if (filedialog.showOpenDialog(jb) != JFileChooser.APPROVE_OPTION) {
  14.264 +                return null;
  14.265 +            }
  14.266 +            FileCommunicator.setDefaultDialogPath(filedialog);
  14.267 +            File f = filedialog.getSelectedFile();
  14.268 +
  14.269 +            /* Initialize Subtitles */
  14.270 +            newsubs = new Subtitles();
  14.271 +            newsubs.setCurrentFile(FileCommunicator.stripFileFromVideoExtension(f)); // getFPS requires it
  14.272 +
  14.273 +            /* Check if jb is an auto-load subtitle file */
  14.274 +            data = FileCommunicator.load(f, Jubler.prefs);
  14.275 +            if (data == null) {
  14.276 +                JIDialog.error(jb, _("Could not load file. Possibly an encoding error."), _("Error while loading file"));
  14.277 +                return null;
  14.278 +            }
  14.279 +
  14.280 +            /* Convert file into subtitle data */
  14.281 +            selectedFormatHandler = newsubs.populate(jb, f, data, Jubler.prefs.getLoadFPS());
  14.282 +            if (newsubs.size() == 0) {
  14.283 +                JIDialog.error(jb, _("File not recognized!"), _("Error while loading file"));
  14.284 +                return null;
  14.285 +            }
  14.286 +        } catch (Exception ex) {
  14.287 +            DEBUG.logger.log(Level.WARNING, ex.toString());
  14.288 +            return null;
  14.289 +        }//end try/catch
  14.290 +        return newsubs;
  14.291 +    }//end public Subtitles loadSubtitleFile()
  14.292 +
  14.293 +    /* This method is called when an item in the recent menu is clicked */
  14.294 +    public void recentMenuCallback(String filename) {
  14.295 +        Subtitles subs = jb.getSubtitles();
  14.296 +        if (filename == null) {
  14.297 +            Jubler jub = new Jubler(new Subtitles(subs));
  14.298 +            initNewFile(subs.getCurrentFile().getPath() + _("_clone"));
  14.299 +            /* The user wants to clone current file */
  14.300 +        } else {
  14.301 +            loadFileFromHere(new File(filename), false);
  14.302 +        }
  14.303 +    }
  14.304 +
  14.305 +    /**
  14.306 +     * @return the selectedFormatHandler
  14.307 +     */
  14.308 +    public SubFormat getSelectedFormatHandler() {
  14.309 +        return selectedFormatHandler;
  14.310 +    }
  14.311 +
  14.312 +    /**
  14.313 +     * @param selectedFormatHandler the selectedFormatHandler to set
  14.314 +     */
  14.315 +    public void setSelectedFormatHandler(SubFormat selectedFormatHandler) {
  14.316 +        this.selectedFormatHandler = selectedFormatHandler;
  14.317 +    }
  14.318 +    
  14.319 +}//end public class JublerFile
  14.320 +
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/com/panayotis/jubler/io/JublerFileChooser.java	Fri Oct 23 11:56:08 2009 +0100
    15.3 @@ -0,0 +1,142 @@
    15.4 +/*
    15.5 + *  JublerFileChooser.java
    15.6 + * 
    15.7 + *  Created on: 22-Oct-2009 at 19:38:34
    15.8 + * 
    15.9 + *  
   15.10 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   15.11 + * 
   15.12 + * This file is part of Jubler.
   15.13 + * 
   15.14 + * Jubler is free software; you can redistribute it and/or modify
   15.15 + * it under the terms of the GNU General Public License as published by
   15.16 + * the Free Software Foundation, version 2.
   15.17 + * 
   15.18 + * 
   15.19 + * Jubler is distributed in the hope that it will be useful,
   15.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15.22 + * GNU General Public License for more details.
   15.23 + * 
   15.24 + * You should have received a copy of the GNU General Public License
   15.25 + * along with Jubler; if not, write to the Free Software
   15.26 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   15.27 + * 
   15.28 + * Contributor(s):
   15.29 + * 
   15.30 + */
   15.31 +package com.panayotis.jubler.io;
   15.32 +
   15.33 +import com.panayotis.jubler.Jubler;
   15.34 +import com.panayotis.jubler.os.DEBUG;
   15.35 +import com.panayotis.jubler.os.FileCommunicator;
   15.36 +import com.panayotis.jubler.subs.loader.AvailSubFormats;
   15.37 +import com.panayotis.jubler.subs.loader.SubFileFilter;
   15.38 +import com.panayotis.jubler.subs.loader.SubFormat;
   15.39 +import java.util.Vector;
   15.40 +import java.util.logging.Level;
   15.41 +import javax.swing.JFileChooser;
   15.42 +import javax.swing.filechooser.FileFilter;
   15.43 +
   15.44 +/**
   15.45 + *
   15.46 + * @author hoang_tran <hoangduytran1960@googlemail.com>
   15.47 + */
   15.48 +public class JublerFileChooser extends JFileChooser {
   15.49 +
   15.50 +    private Jubler jb = null;
   15.51 +
   15.52 +    public JublerFileChooser(Jubler parent) {
   15.53 +        jb = parent;
   15.54 +        init();
   15.55 +    }
   15.56 +
   15.57 +    public void init() {
   15.58 +        /* Set JFileChooser properties */
   15.59 +        setMultiSelectionEnabled(false);
   15.60 +        setFileFilter(new SubFileFilter());
   15.61 +        addFilters(AvailSubFormats.Formats );
   15.62 +        FileCommunicator.getDefaultDialogPath(this);
   15.63 +    }//end public void init()
   15.64 +
   15.65 +    private SimpleFileFilter makeFilter(SubFormat format) {
   15.66 +        String desc = format.getDescription();
   15.67 +        String ext = format.getExtension();
   15.68 +        SimpleFileFilter filter = new SimpleFileFilter(ext, desc);
   15.69 +        return filter;
   15.70 +    }
   15.71 +
   15.72 +    public boolean setFilters(FileFilter[] list) {
   15.73 +        boolean ok = false;
   15.74 +        try {
   15.75 +            for (int i = 0; i < list.length; i++) {
   15.76 +                FileFilter fl = list[i];
   15.77 +                boolean is_first_item = (i == 0);
   15.78 +                if (is_first_item) {
   15.79 +                    setFileFilter(fl);
   15.80 +                } else {
   15.81 +                    addChoosableFileFilter(fl);
   15.82 +                }//end if
   15.83 +            }//end for(int i=0; i < list.length; i++)
   15.84 +        } catch (Exception ex) {
   15.85 +            DEBUG.logger.log(Level.WARNING, ex.toString());
   15.86 +        }
   15.87 +        return ok;
   15.88 +    }//public setFilters(FileFilter[] list)
   15.89 +
   15.90 +    public boolean setFilters(Vector<FileFilter> list) {
   15.91 +        boolean ok = false;
   15.92 +        try {
   15.93 +            int len = list.size();
   15.94 +            FileFilter[] array = list.toArray(new FileFilter[len]);
   15.95 +            ok = this.setFilters(array);
   15.96 +        } catch (Exception ex) {
   15.97 +            DEBUG.logger.log(Level.WARNING, ex.toString());
   15.98 +        }
   15.99 +        return ok;
  15.100 +    }//end public boolean setFilters(FileFilter[] list)
  15.101 +
  15.102 +    public boolean setFilters(SubFormat[] format_list) {
  15.103 +        boolean ok = false;
  15.104 +        Vector<FileFilter> vector = new Vector<FileFilter>();
  15.105 +        try {
  15.106 +            for (int i = 0; i < format_list.length; i++) {
  15.107 +                SubFormat format = format_list[i];
  15.108 +                SimpleFileFilter filter = makeFilter(format);
  15.109 +                vector.add(filter);
  15.110 +            }//end for(SubFormat format: format_list)
  15.111 +            ok = this.setFilters(vector);
  15.112 +        } catch (Exception ex) {
  15.113 +            DEBUG.logger.log(Level.WARNING, ex.toString());
  15.114 +        }
  15.115 +        return ok;
  15.116 +    }//end public boolean setFilter()
  15.117 +
  15.118 +    public boolean setFilter(SubFormat format) {
  15.119 +        boolean ok = false;
  15.120 +        try {
  15.121 +            SimpleFileFilter filter = makeFilter(format);
  15.122 +            this.setFileFilter(filter);
  15.123 +            ok = true;
  15.124 +        } catch (Exception ex) {
  15.125 +            DEBUG.logger.log(Level.WARNING, ex.toString());
  15.126 +        }
  15.127 +        return ok;
  15.128 +    }//end public boolean setFilter(SubFormat format)
  15.129 +
  15.130 +    public boolean addFilters(SubFormat[] format_list) {
  15.131 +        boolean ok = false;
  15.132 +        try {
  15.133 +            for (int i = 0; i < format_list.length; i++) {
  15.134 +                SubFormat format = format_list[i];
  15.135 +                SimpleFileFilter filter = makeFilter(format);
  15.136 +                addChoosableFileFilter(filter);
  15.137 +            }//end for(SubFormat format: format_list)
  15.138 +            ok = true;
  15.139 +        } catch (Exception ex) {
  15.140 +            DEBUG.logger.log(Level.WARNING, ex.toString());
  15.141 +        }
  15.142 +        return ok;
  15.143 +    }//end public boolean addFilters(SubFormat[] format)
  15.144 +}//end public class JublerFileChooser
  15.145 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/com/panayotis/jubler/io/SimpleFileFilter.java	Fri Oct 23 11:56:08 2009 +0100
    16.3 @@ -0,0 +1,59 @@
    16.4 +/*
    16.5 + *  SimpleFileFilter.java 
    16.6 + * 
    16.7 + *  Created on: 22-Oct-2009 at 20:42:12
    16.8 + * 
    16.9 + *  
   16.10 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   16.11 + * 
   16.12 + * This file is part of Jubler.
   16.13 + * 
   16.14 + * Jubler is free software; you can redistribute it and/or modify
   16.15 + * it under the terms of the GNU General Public License as published by
   16.16 + * the Free Software Foundation, version 2.
   16.17 + * 
   16.18 + * 
   16.19 + * Jubler is distributed in the hope that it will be useful,
   16.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16.22 + * GNU General Public License for more details.
   16.23 + * 
   16.24 + * You should have received a copy of the GNU General Public License
   16.25 + * along with Jubler; if not, write to the Free Software
   16.26 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16.27 + * 
   16.28 + * Contributor(s):
   16.29 + * 
   16.30 + */
   16.31 +package com.panayotis.jubler.io;
   16.32 +
   16.33 +import java.io.File;
   16.34 +
   16.35 +/**
   16.36 + *
   16.37 + * @author hoang_tran <hoangduytran1960@googlemail.com>
   16.38 + */
   16.39 +public class SimpleFileFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter {
   16.40 +
   16.41 +    String desc = null;
   16.42 +    String ext = null;
   16.43 +
   16.44 +    public SimpleFileFilter(String ext, String desc){
   16.45 +        this.desc = desc;
   16.46 +        this.ext = ext;
   16.47 +    }
   16.48 +    
   16.49 +    public boolean accept(File pathname) {
   16.50 +        if (pathname.isDirectory()) {
   16.51 +            return true;
   16.52 +        }
   16.53 +        String fname = pathname.getName().toLowerCase();
   16.54 +        boolean found = fname.endsWith(ext.toLowerCase());
   16.55 +        return found;
   16.56 +    }
   16.57 +
   16.58 +    public String getDescription() {
   16.59 +        return desc;
   16.60 +    }
   16.61 +}//end public class SimpleFileFilter
   16.62 +
    17.1 --- a/src/com/panayotis/jubler/media/preview/JSubPreview.java	Thu Oct 22 19:22:17 2009 +0100
    17.2 +++ b/src/com/panayotis/jubler/media/preview/JSubPreview.java	Fri Oct 23 11:56:08 2009 +0100
    17.3 @@ -37,6 +37,7 @@
    17.4  import java.awt.Point;
    17.5  import javax.swing.Icon;
    17.6  import javax.swing.ImageIcon;
    17.7 +import javax.swing.JSplitPane;
    17.8  
    17.9  /**
   17.10   *
   17.11 @@ -45,7 +46,7 @@
   17.12  public class JSubPreview extends javax.swing.JPanel {
   17.13  
   17.14      public final static Icon[] cursors;
   17.15 -    
   17.16 +    private javax.swing.JSplitPane SubSplitPane;
   17.17  
   17.18      static {
   17.19          cursors = new Icon[4];
   17.20 @@ -69,6 +70,7 @@
   17.21      public JSubPreview(Jubler parent) {
   17.22          initComponents();
   17.23  
   17.24 +        SubSplitPane = parent.getSubSplitPane();
   17.25          view = new ViewWindow();
   17.26          timecaption = new JRuler(view);
   17.27          timeline = new JSubTimeline(parent, view, this);
   17.28 @@ -188,11 +190,23 @@
   17.29          } else {
   17.30              MainPanel.add(frame, BorderLayout.NORTH);
   17.31          }
   17.32 -        parent.fn.setPreviewOrientation(horizontal);
   17.33 -        parent.fn.resetPreviewPanels();
   17.34 +        setPreviewOrientation(horizontal);
   17.35 +        resetPreviewPanels();
   17.36          AutoSaveOptions.setPreviewOrientation(horizontal);
   17.37      }
   17.38  
   17.39 +    public void resetPreviewPanels() {
   17.40 +        SubSplitPane.resetToPreferredSizes();
   17.41 +    }
   17.42 +
   17.43 +    public void setPreviewOrientation(boolean horizontal) {
   17.44 +        if (horizontal) {
   17.45 +            SubSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
   17.46 +        } else {
   17.47 +            SubSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
   17.48 +        }
   17.49 +    }
   17.50 +
   17.51      public Point getFrameLocation() {
   17.52          try {
   17.53              Point ret = frame.getLocationOnScreen();
   17.54 @@ -207,14 +221,14 @@
   17.55          VideoShow.setSelected(status);
   17.56          parent.VideoPreviewC.setSelected(status);
   17.57          frame.setEnabled(status);
   17.58 -        parent.fn.resetPreviewPanels();
   17.59 +        resetPreviewPanels();
   17.60      }
   17.61  
   17.62      public void setVideoZoom(boolean status) {
   17.63          VideoZoom.setSelected(status);
   17.64          parent.HalfSizeC.setSelected(status);
   17.65          frame.setResize(status ? 0.5f : 1f);
   17.66 -        parent.fn.resetPreviewPanels();
   17.67 +        resetPreviewPanels();
   17.68      }
   17.69  
   17.70      public void setAudioShow(boolean status) {
    18.1 --- a/src/com/panayotis/jubler/os/Dropper.java	Thu Oct 22 19:22:17 2009 +0100
    18.2 +++ b/src/com/panayotis/jubler/os/Dropper.java	Fri Oct 23 11:56:08 2009 +0100
    18.3 @@ -267,7 +267,7 @@
    18.4                  }
    18.5                  for (File f : files) {
    18.6                      if (f.isFile()) {
    18.7 -                        parent.fn.loadFile(f, false);
    18.8 +                        parent.getFileManager().loadFile(f, false);
    18.9                      }//end if (f.isFile())
   18.10                  }//end for (File f : files)
   18.11                  break;
    19.1 --- a/src/com/panayotis/jubler/os/SystemDependent.java	Thu Oct 22 19:22:17 2009 +0100
    19.2 +++ b/src/com/panayotis/jubler/os/SystemDependent.java	Fri Oct 23 11:56:08 2009 +0100
    19.3 @@ -83,7 +83,8 @@
    19.4                  .compareTo("16006")) >= 0;
    19.5          try {
    19.6             if (newjava || IS_WINDOWS || IS_MACOSX) {
    19.7 -                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    19.8 +                //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    19.9 +               UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
   19.10             }
   19.11          } catch ( ClassNotFoundException e ) {
   19.12          } catch ( InstantiationException e ) {