1 /*
2  * Diese Datei ist Teil des GDialog Projektes:
3  * "Gigaset-Erweiterung f�r ProjectX"
4  *
5  * Das GDialog Projekt ist freigegeben unter
6  * der GNU Public Licence (GPL), deren Text sich in
7  * dem Quellen-Verzeichnis befindet. Ist er dort nicht
8  * mehr vorhanden, so kann er unter http://www.gnu.org/licenses/gpl.html
9  * eingesehen werden.
10  */
11 package de.m740.projectx.gigaset;
12 
13 import java.awt.BorderLayout;
14 import java.awt.Color;
15 import java.awt.Component;
16 import java.awt.Container;
17 import java.awt.Cursor;
18 import java.awt.Dimension;
19 import java.awt.GridBagConstraints;
20 import java.awt.GridBagLayout;
21 import java.awt.GridLayout;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.io.File;
25 import java.io.IOException;
26 import java.io.RandomAccessFile;
27 import java.text.SimpleDateFormat;
28 import java.util.Calendar;
29 import java.util.Date;
30 import java.util.GregorianCalendar;
31 import java.util.List;
32 
33 import javax.swing.JButton;
34 import javax.swing.JCheckBoxMenuItem;
35 import javax.swing.JFileChooser;
36 import javax.swing.JFrame;
37 import javax.swing.JLabel;
38 import javax.swing.JMenu;
39 import javax.swing.JMenuBar;
40 import javax.swing.JMenuItem;
41 import javax.swing.JPanel;
42 import javax.swing.JScrollPane;
43 import javax.swing.JSplitPane;
44 import javax.swing.JTabbedPane;
45 import javax.swing.JTextArea;
46 import javax.swing.event.ChangeEvent;
47 import javax.swing.event.ChangeListener;
48 
49 import net.sourceforge.dvb.projectx.common.Common;
50 import net.sourceforge.dvb.projectx.common.JobCollection;
51 import net.sourceforge.dvb.projectx.common.Keys;
52 import net.sourceforge.dvb.projectx.common.Resource;
53 import net.sourceforge.dvb.projectx.common.Settings;
54 import net.sourceforge.dvb.projectx.gui.CommonGui;
55 import net.sourceforge.dvb.projectx.gui.MainFrame;
56 import net.sourceforge.dvb.projectx.xinput.StreamInfo;
57 import net.sourceforge.dvb.projectx.xinput.XInputFile;
58 
59 /**
60  * 26.01.2005
61  *
62  * @author truels
63  *
64  */
65 public class GDialog extends JFrame {
66     /**
67      *
68      */
69     private static final long serialVersionUID = 1L;
70 
71     // ---------------------------------------------------------------
72 
73     static final String PROPERTY_SELECTED_TAB1 = "gigaset.selected.tab1";
74 
75     static final String PROPERTY_PANEL_HOEHE = "gigaset.dialog.height";
76 
77     static final String PROPERTY_PANEL1_BREITE = "gigaset.dialog.width1";
78 
79     static final String PROPERTY_PANEL2_BREITE = "gigaset.dialog.width2";
80 
81     static final String PROPERTY_AUTO_EPG = "gigaset.option.autoepg";
82 
83     static final String PROPERTY_DATE_ALL = "gigaset.option.dateall";
84 
85     static final String PROPERTY_DATE_DOUBLES = "gigaset.option.datedoubles";
86 
87     static final String PROPERTY_DATE_FORMAT = "gigaset.option.dateformat";
88 
89     static final String PROPERTY_DEFAULT_DATFMT = " (yyyy-MM-dd HH.mm)";
90 
91     static final String PROPERTY_DATE_FORMAT2 = "gigaset.option.dateformat2";
92 
93     static final String PROPERTY_DEFAULT_DATFMT2 = "";
94 
95     static final String PROPERTY_MPGS_ONDEMAND = "gigaset.option.mpgsdemand";
96 
97     static final String PROPERTY_FTP_AUTOCONNECT = "gigaset.option.autoconnect";
98 
99     static final String PROPERTY_KILL_CLIENT = "FtpPanel.killFtpClient";
100 
101     static final String FN_AUFNAHME_VERZEICHNIS = "gigaset-aufnahme-verzeichnis.txt";
102 
103     static final String FN_PLAYER_LOCATION = "mpc-location.txt";
104 
105     protected static SimpleDateFormat aSimpleDateFormat1 = null;
106 
107     protected static SimpleDateFormat aSimpleDateFormat2 = null;
108 
109     protected boolean aufnameGewaehlt = false;
110 
111     protected JButton btnAuswaehlen = new JButton(GStrings
112             .getString("gdialog.select"));
113 
114     protected JMenuItem aItemAuswaehlen = new JMenuItem(GStrings
115             .getString("gdialog.record.ok"));
116 
117     protected JButton btnHinzufuegen = new JButton(CommonGui.loadIcon("addleft.gif"));
118 
119     protected JMenuItem aItemHinzufuegen = new JMenuItem(GStrings
120             .getString("gdialog.record.add"));
121 
122     protected JButton btnAbbrechen = new JButton(GStrings
123             .getString("gdialog.cancel"));
124 
125     protected JMenuItem aItemAbbrechen = new JMenuItem(GStrings
126             .getString("gdialog.cancel"));
127 
128     private JSplitPane aSplitPane = null;
129 
130     private JPanel pnlAufnahme = new JPanel();
131 
132     private JLabel aLabelSender1 = new JLabel(GStrings.getString("gdialog.sender"));
133 
134     private JLabel aLabelSender2 = new JLabel();
135 
136     private JLabel lblStart = new JLabel(GStrings.getString("gdialog.starting"));
137 
138     private JLabel lblStartzeit = new JLabel();
139 
140     private JLabel lblEnde = new JLabel(GStrings.getString("gdialog.ending"));
141 
142     private JLabel lblEndezeit = new JLabel();
143 
144     private JLabel lblLaenge = new JLabel(GStrings.getString("gdialog.length"));
145 
146     private JLabel lblLaengeString = new JLabel();
147 
148     private JLabel lblGesehen = new JLabel(GStrings.getString("gdialog.seen"));
149 
150     private JLabel lblGesehenString = new JLabel();
151 
152     private JLabel lblGroesse = new JLabel(GStrings.getString("gdialog.size"));
153 
154     private JLabel lblGroesseString = new JLabel();
155 
156     private JLabel lblFiles = new JLabel(GStrings.getString("gdialog.files"));
157 
158     private JLabel lblFilesString = new JLabel();
159 
160     private JLabel lblStatus = new JLabel(GStrings.getString("gdialog.status"));
161 
162     private JLabel lblStatusString = new JLabel();
163 
164     private JLabel lblInfo = new JLabel(GStrings.getString("gdialog.info"));
165 
166     private JLabel lblInfoString = new JLabel();
167 
168     private JLabel lblInhalt = new JLabel(GStrings.getString("gdialog.content"));
169 
170     private JTextArea taInhalt = new JTextArea();
171 
172     private JScrollPane spInhalt = new JScrollPane(taInhalt);
173 
174     protected JButton btnPrintEPG = new JButton(GStrings
175             .getString("gdialog.printepg"));
176 
177     protected JMenuItem aItemPlayMPC = new JMenuItem(GStrings
178             .getString("gdialog.play"));
179 
180     protected JMenuItem aItemLoeschen = new JMenuItem(GStrings
181             .getString("gdialog.delete"));
182 
183     protected JMenuItem aItemReread = new JMenuItem(GStrings
184             .getString("gdialog.reread"));
185 
186     protected String aFNPlayer = "mplayerc.exe";
187 
188     protected JTabbedPane aTabsAufnahmen = null;
189 
190     /** the callback function */
191     protected ActionListener aActionListener = null;
192 
193     protected MainFrame aMainFrame = null;
194 
addComponent(Container cont, GridBagLayout gbl, Component c, int x, int y, int width, int height, double weightx, double weighty)195     void addComponent(Container cont, GridBagLayout gbl, Component c, int x,
196             int y, int width, int height, double weightx, double weighty) {
197         GridBagConstraints gbc = new GridBagConstraints();
198         gbc.fill = GridBagConstraints.BOTH;
199         gbc.gridx = x;
200         gbc.gridy = y;
201         gbc.gridwidth = width;
202         gbc.gridheight = height;
203         gbc.weightx = weightx;
204         gbc.weighty = weighty;
205         gbl.setConstraints(c, gbc);
206         cont.add(c);
207     }
208 
formatSeconds(int i)209     String formatSeconds(int i) {
210         // if (i < 0) i *= -1;
211 
212         int sekunden = Math.abs(i % 60);
213         int minuten = Math.abs((i / 60) % 60);
214         int stunden = Math.abs(i / 3600);
215 
216         return (i < 0 ? "-" : "") + stunden + (minuten < 10 ? ":0" : ":")
217                 + minuten + (sekunden < 10 ? ":0" : ":") + sekunden;
218     }
219 
f(int i)220     static String f(int i) {
221         String result = "" + i;
222         if (i < 100)
223             result = "0" + result;
224         if (i < 10)
225             result = "0" + result;
226         return result;
227     }
228 
wochenTag(int i)229     String wochenTag(int i) {
230         return GStrings.getString("GDialog." + (i - 1));
231     }
232 
GDialog()233     public GDialog() {
234         super();
235         setTitle(GStrings.getString("gdialog.titel") + " 24.02.2007");
236         Container cHaupt = this.getContentPane();
237         GridBagLayout gbl = new GridBagLayout();
238         pnlAufnahme.setLayout(gbl);
239         taInhalt.setLineWrap(true);
240         taInhalt.setWrapStyleWord(true);
241         taInhalt.setEditable(false);
242         btnAuswaehlen.setEnabled(false);
243         aItemAuswaehlen.setEnabled(false);
244         btnHinzufuegen.setEnabled(false);
245         aItemHinzufuegen.setEnabled(false);
246         btnPrintEPG.setEnabled(false);
247         aItemPlayMPC.setEnabled(false);
248         aItemLoeschen.setEnabled(false);
249         aItemReread.setEnabled(false);
250         aFNPlayer = readPlayerLocation();
251 
252         // spInhalt.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
253         // x y w h wx wy
254         int y = 0;
255         addComponent(pnlAufnahme, gbl, aLabelSender1, 0, y, 1, 1, 0, 0);
256         addComponent(pnlAufnahme, gbl, aLabelSender2, 1, y++, 1, 1, 0, 0);
257         addComponent(pnlAufnahme, gbl, lblStart, 0, y, 1, 1, 0, 0);
258         addComponent(pnlAufnahme, gbl, lblStartzeit, 1, y++, 1, 1, 0, 0);
259         addComponent(pnlAufnahme, gbl, lblEnde, 0, y, 1, 1, 0, 0);
260         addComponent(pnlAufnahme, gbl, lblEndezeit, 1, y++, 1, 1, 0, 0);
261         addComponent(pnlAufnahme, gbl, lblLaenge, 0, y, 1, 1, 0, 0);
262         addComponent(pnlAufnahme, gbl, lblLaengeString, 1, y++, 1, 1, 0, 0);
263         addComponent(pnlAufnahme, gbl, lblGesehen, 0, y, 1, 1, 0, 0);
264         addComponent(pnlAufnahme, gbl, lblGesehenString, 1, y++, 1, 1, 0, 0);
265         addComponent(pnlAufnahme, gbl, lblFiles, 0, y, 1, 1, 0, 0);
266         addComponent(pnlAufnahme, gbl, lblFilesString, 1, y++, 1, 1, 0, 0);
267         addComponent(pnlAufnahme, gbl, lblGroesse, 0, y, 1, 1, 0, 0);
268         addComponent(pnlAufnahme, gbl, lblGroesseString, 1, y++, 1, 1, 0, 0);
269         addComponent(pnlAufnahme, gbl, lblStatus, 0, y, 1, 1, 0, 0);
270         addComponent(pnlAufnahme, gbl, lblStatusString, 1, y++, 1, 1, 0, 0);
271         addComponent(pnlAufnahme, gbl, lblInfo, 0, y, 1, 1, 0, 0);
272         addComponent(pnlAufnahme, gbl, lblInfoString, 1, y++, 1, 1, 0, 0);
273         addComponent(pnlAufnahme, gbl, lblInhalt, 0, y, 1, 1, 0, 0);
274         addComponent(pnlAufnahme, gbl, spInhalt, 1, y++, 1, 1, 1.0, 1.0);
275 
276         // "Info"
277         JPanel tmpPanelInfo = new JPanel(new BorderLayout());
278         tmpPanelInfo.add(pnlAufnahme, BorderLayout.CENTER);
279         tmpPanelInfo.add(btnPrintEPG, BorderLayout.SOUTH);
280         final JTabbedPane tmpTabbedPane = new JTabbedPane();
281         tmpTabbedPane.addTab(GStrings.getString("gdialog.tab.info"), null,
282                 tmpPanelInfo, GStrings.getString("gdialog.info.tip"));
283         // lost+found
284         GPanelLost tmpPanelLost = new GPanelLost(this);
285         tmpTabbedPane.addTab(GStrings.getString("gdialog.tab.lost"), null,
286                 tmpPanelLost, GStrings.getString("gdialog.lost.tip"));
287         // Console
288         GConsole tmpConsole = GConsole.getInstance();
289         tmpTabbedPane.addTab(GStrings.getString("gdialog.tab.console"), null,
290                 tmpConsole, GStrings.getString("gdialog.console.tip"));
291 
292         JPanel tmpPanelLeft = new JPanel(new BorderLayout());
293         // Local
294         final GPanelLocal tmpPanelLocal = new GPanelLocal(this);
295         // FTP
296         GPanelFTP tmpPanelFTP = new GPanelFTP(this);
297         // Aufnahmen
298         final JTabbedPane tmpTabsAufnahmen = new JTabbedPane();
299         setTabsAufnahmen(tmpTabsAufnahmen);
300         String tmpString = GStrings.getString("gdialog.tab.local");
301         tmpTabsAufnahmen.addTab(tmpString, null, tmpPanelLocal, GStrings
302                 .getString("gdialog.local.tip"));
303         tmpString = GStrings.getString("gdialog.tab.ftp");
304         tmpTabsAufnahmen.addTab(tmpString, null, tmpPanelFTP, GStrings
305                 .getString("gdialog.ftp.tip"));
306         tmpPanelLeft.add(tmpTabsAufnahmen, BorderLayout.CENTER);
307         // Buttons unten
308         JPanel tmpPanelBottom = new JPanel(new GridLayout(1, 3));
309         btnAuswaehlen.setToolTipText(GStrings.getString("gdialog.record.ok"));
310         tmpPanelBottom.add(btnAuswaehlen);
311         btnHinzufuegen.setToolTipText(GStrings.getString("gdialog.record.add"));
312         tmpPanelBottom.add(btnHinzufuegen);
313         tmpPanelBottom.add(btnAbbrechen);
314         tmpPanelLeft.add(tmpPanelBottom, BorderLayout.SOUTH);
315         //
316         Settings tmpSettings = Common.getSettings();
317         int width = (tmpSettings == null) ? 300 : tmpSettings.getIntProperty(PROPERTY_PANEL1_BREITE, 300);
318         int heigth = (tmpSettings == null) ? 400 : tmpSettings.getIntProperty(PROPERTY_PANEL_HOEHE, 400);
319         Dimension tmpDim = new Dimension(width, heigth);
320         tmpPanelLeft.setPreferredSize(tmpDim);
321         width = (tmpSettings == null) ? 300 : tmpSettings.getIntProperty(PROPERTY_PANEL2_BREITE, 300);
322         tmpDim = new Dimension(width, heigth);
323         tmpTabbedPane.setPreferredSize(tmpDim);
324         tmpDim = new Dimension(20, 120);
325         tmpPanelLeft.setMinimumSize(tmpDim);
326         tmpTabbedPane.setMinimumSize(tmpDim);
327         //
328         JSplitPane tmpSplitPane = getSplitPane();
329         // tmpSplitPane.setOneTouchExpandable(true);
330         tmpSplitPane.setLeftComponent(tmpPanelLeft);
331         tmpSplitPane.setRightComponent(tmpTabbedPane);
332         cHaupt.setLayout(new BorderLayout());
333         cHaupt.add(tmpSplitPane, BorderLayout.CENTER);
334         //
335         // MenuBar
336         JMenuBar tmpMenuBar = new JMenuBar();
337         //
338         // Menu Auswahl
339         JMenu tmpMenu = new JMenu(GStrings.getString("gdialog.menu.selection"));
340         tmpMenu.add(aItemAuswaehlen);
341         aItemHinzufuegen.setIcon(CommonGui.loadIcon("addleft.gif"));
342         tmpMenu.add(aItemHinzufuegen);
343         tmpMenu.addSeparator();
344         tmpMenu.add(aItemAbbrechen);
345         //
346         tmpMenuBar.add(tmpMenu);
347         //
348         // Menu Sort
349         tmpMenu = new JMenu(GStrings.getString("gdialog.menu.sort"));
350         JMenuItem tmpMenuItem = new JMenuItem(GStrings.getString("gdialog.menu.sortaz"));
351         tmpMenuItem.addActionListener(new ActionListener() {
352             public void actionPerformed(ActionEvent inpE) {
353                 sortiereAufnahmen(GPanelTableIF.SORT_FILES_AZ);
354             }
355 
356         });
357         tmpMenu.add(tmpMenuItem);
358         tmpMenuItem = new JMenuItem(GStrings.getString("gdialog.menu.sortza"));
359         tmpMenuItem.addActionListener(new ActionListener() {
360             public void actionPerformed(ActionEvent inpE) {
361                 sortiereAufnahmen(GPanelTableIF.SORT_FILES_ZA);
362             }
363 
364         });
365         tmpMenu.add(tmpMenuItem);
366         tmpMenuItem = new JMenuItem(GStrings.getString("gdialog.menu.sortno"));
367         tmpMenuItem.addActionListener(new ActionListener() {
368             public void actionPerformed(ActionEvent inpE) {
369                 sortiereAufnahmen(GPanelTableIF.SORT_FILES_NO);
370             }
371 
372         });
373         tmpMenu.add(tmpMenuItem);
374         tmpMenu.add(tmpMenuItem);
375         tmpMenuItem = new JMenuItem(GStrings.getString("gdialog.menu.sorton"));
376         tmpMenuItem.addActionListener(new ActionListener() {
377             public void actionPerformed(ActionEvent inpE) {
378                 sortiereAufnahmen(GPanelTableIF.SORT_FILES_ON);
379             }
380 
381         });
382         tmpMenu.add(tmpMenuItem);
383         tmpMenuBar.add(tmpMenu);
384         //
385         // Menu Einstellungen
386         tmpMenu = new JMenu(GStrings.getString("gdialog.menu.options"));
387         final JCheckBoxMenuItem tmpItemAutoEPG = new JCheckBoxMenuItem(GStrings
388                 .getString("gdialog.options.autoepg"));
389         boolean ok = tmpSettings.getBooleanProperty(PROPERTY_AUTO_EPG, false);
390         tmpItemAutoEPG.setSelected(ok);
391         tmpMenu.add(tmpItemAutoEPG);
392         tmpMenu.addSeparator();
393         final JCheckBoxMenuItem tmpItemDateAll = new JCheckBoxMenuItem(GStrings
394                 .getString("gdialog.options.date.all"));
395         ok = tmpSettings.getBooleanProperty(PROPERTY_DATE_ALL, false);
396         tmpItemDateAll.setSelected(ok);
397         tmpMenu.add(tmpItemDateAll);
398         final JCheckBoxMenuItem tmpItemDateDbl = new JCheckBoxMenuItem(GStrings
399                 .getString("gdialog.options.date.dbl"));
400         ok = tmpSettings.getBooleanProperty(PROPERTY_DATE_DOUBLES, false);
401         tmpItemDateDbl.setSelected(ok);
402         tmpMenu.add(tmpItemDateDbl);
403         //
404         JMenuItem tmpItemDateFmt1 = new JMenuItem(GStrings.getString("gdialog.settings.datefmt1"));
405         tmpMenu.add(tmpItemDateFmt1);
406         JMenuItem tmpItemDateFmt2 = new JMenuItem(GStrings.getString("gdialog.settings.datefmt2"));
407         tmpMenu.add(tmpItemDateFmt2);
408         tmpMenu.addSeparator();
409         final JCheckBoxMenuItem tmpItemAutoConnect = new JCheckBoxMenuItem(
410                 GStrings.getString("gdialog.options.ftp.autoconnect"));
411         ok = tmpSettings.getBooleanProperty(PROPERTY_FTP_AUTOCONNECT, false);
412         tmpItemAutoConnect.setSelected(ok);
413         tmpMenu.add(tmpItemAutoConnect);
414         final JCheckBoxMenuItem tmpItemOnDemand = new JCheckBoxMenuItem(
415                 GStrings.getString("gdialog.options.mpgs.ondemand"));
416         ok = tmpSettings.getBooleanProperty(PROPERTY_MPGS_ONDEMAND, false);
417         tmpItemOnDemand.setSelected(ok);
418         tmpMenu.add(tmpItemOnDemand);
419         final JCheckBoxMenuItem tmpItemKillClient = new JCheckBoxMenuItem(
420                 "FTP: "+ Resource.getString("FtpPanel.killFtpClient"));
421         ok = tmpSettings.getBooleanProperty(Keys.KEY_killFtpClient);
422         tmpItemKillClient.setSelected(ok);
423         tmpMenu.add(tmpItemKillClient);
424         tmpMenu.addSeparator();
425         JMenuItem tmpItemSavePreferences = new JMenuItem(GStrings
426                 .getString("gdialog.settings.SaveAs"));
427         tmpMenu.add(tmpItemSavePreferences);
428         //
429         tmpMenuBar.add(tmpMenu);
430         //
431         // Menu Extra
432         tmpMenu = new JMenu(GStrings.getString("gdialog.menu.extra"));
433         tmpMenu.setToolTipText(GStrings.getString("gdialog.extra.tip"));
434         // play MPC
435         tmpMenu.add(aItemPlayMPC);
436         aItemPlayMPC.addActionListener(new ActionListener() {
437             public void actionPerformed(ActionEvent e) {
438                 playMPC();
439             }
440         });
441         tmpMenu.addSeparator();
442         // delete file
443         aItemLoeschen.setToolTipText(GStrings.getString("gdialog.delete.crid.tip"));
444         tmpMenu.add(aItemLoeschen);
445         aItemLoeschen.addActionListener(new ActionListener() {
446             public void actionPerformed(ActionEvent e) {
447                 GPanelTableIF tmpChooser = getActiveChooser();
448                 if (tmpChooser != null) {
449                     tmpChooser.deleteSelectedAufnahme();
450                 }
451             }
452         });
453         tmpMenu.addSeparator();
454         // reread file
455         aItemReread.setToolTipText(GStrings.getString("gdialog.reread.tip"));
456         tmpMenu.add(aItemReread);
457         aItemReread.addActionListener(new ActionListener() {
458             public void actionPerformed(ActionEvent e) {
459                 GPanelTableIF tmpChooser = getActiveChooser();
460                 if (tmpChooser != null) {
461                     int nr = tmpChooser.readSelectedAufnahme();
462                     zeigeInfos(nr);
463                 }
464             }
465         });
466         //
467         tmpMenuBar.add(tmpMenu);
468         //
469         setJMenuBar(tmpMenuBar);
470         // ------------
471         tmpPanelLocal.addChangeListener(tmpPanelLost.getChangeListener());
472         tmpPanelFTP.addChangeListener(tmpPanelLost.getChangeListener());
473         // Auswaehlen
474         ActionListener tmpAliAuswaehlen = new ActionListener() {
475             public void actionPerformed(ActionEvent e) {
476                 actionDone(true, true);
477             }
478         };
479         aItemAuswaehlen.addActionListener(tmpAliAuswaehlen);
480         btnAuswaehlen.addActionListener(tmpAliAuswaehlen);
481         // Hinzufuegen
482         ActionListener tmpAliHinzufuegen = new ActionListener() {
483             public void actionPerformed(ActionEvent e) {
484                 actionDone(true, false);
485             }
486         };
487         aItemHinzufuegen.addActionListener(tmpAliHinzufuegen);
488         btnHinzufuegen.addActionListener(tmpAliHinzufuegen);
489         // Abbrechen
490         ActionListener tmpAliAbbrechen = new ActionListener() {
491             public void actionPerformed(ActionEvent e) {
492                 actionDone(false, true);
493             }
494         };
495         aItemAbbrechen.addActionListener(tmpAliAbbrechen);
496         btnAbbrechen.addActionListener(tmpAliAbbrechen);
497         // Auto EPG
498         tmpItemAutoEPG.addActionListener(new ActionListener() {
499             public void actionPerformed(ActionEvent inpE) {
500                 Common.getSettings().setBooleanProperty(PROPERTY_AUTO_EPG,
501                         tmpItemAutoEPG.isSelected());
502                 update(getGraphics());
503             }
504         });
505         // alle mit Datum
506         tmpItemDateAll.addActionListener(new ActionListener() {
507             public void actionPerformed(ActionEvent inpE) {
508                 Common.getSettings().setBooleanProperty(PROPERTY_DATE_ALL,
509                         tmpItemDateAll.isSelected());
510                 update(getGraphics());
511             }
512         });
513         // Doubles mit Datum
514         tmpItemDateDbl.addActionListener(new ActionListener() {
515             public void actionPerformed(ActionEvent inpE) {
516                 Common.getSettings().setBooleanProperty(PROPERTY_DATE_DOUBLES,
517                         tmpItemDateDbl.isSelected());
518                 update(getGraphics());
519             }
520         });
521         // Date format 1
522         tmpItemDateFmt1.addActionListener(new ActionListener() {
523             public void actionPerformed(ActionEvent inpE) {
524                 String tmpTitel = GStrings.getString("gdialog.datefmt1.titel");
525                 String tmpPrompt = GStrings.getString("gdialog.datefmt1.prompt");
526                 String tmpFmt = CommonGui.getUserInput(GDialog.this, tmpPrompt, tmpTitel,
527                         getDateFormat1());
528                 if (tmpFmt != null && tmpFmt.length() > 0) {
529                     Common.getSettings().setProperty(PROPERTY_DATE_FORMAT, tmpFmt);
530                     setSimpleDateFormat1(null);
531                 }
532                 update(getGraphics());
533             }
534         });
535         // Date format 2
536         tmpItemDateFmt2.addActionListener(new ActionListener() {
537             public void actionPerformed(ActionEvent inpE) {
538                 String tmpTitel = GStrings.getString("gdialog.datefmt2.titel");
539                 String tmpPrompt = GStrings.getString("gdialog.datefmt2.prompt");
540                 String tmpFmt = CommonGui.getUserInput(null, tmpPrompt, tmpTitel,
541                         getDateFormat2());
542                 if (tmpFmt != null && tmpFmt.length() > 0) {
543                     Common.getSettings().setProperty(PROPERTY_DATE_FORMAT2, tmpFmt);
544                     setSimpleDateFormat2(null);
545                 }
546                 update(getGraphics());
547             }
548         });
549         // ftp auto connect
550         tmpItemAutoConnect.addActionListener(new ActionListener() {
551             public void actionPerformed(ActionEvent inpE) {
552                 Common.getSettings().setBooleanProperty(PROPERTY_FTP_AUTOCONNECT,
553                         tmpItemAutoConnect.isSelected());
554             }
555 
556         });
557         // mpgs on demand
558         tmpItemOnDemand.addActionListener(new ActionListener() {
559             public void actionPerformed(ActionEvent inpE) {
560                 Common.getSettings().setBooleanProperty(PROPERTY_MPGS_ONDEMAND,
561                         tmpItemOnDemand.isSelected());
562             }
563 
564         });
565         // kill ftp client
566         tmpItemKillClient.addActionListener(new ActionListener() {
567             public void actionPerformed(ActionEvent inpE) {
568                 Common.getSettings().setBooleanProperty(PROPERTY_KILL_CLIENT,
569                         tmpItemKillClient.isSelected());
570             }
571 
572         });
573         // save preferences
574         tmpItemSavePreferences.addActionListener(new ActionListener() {
575             public void actionPerformed(ActionEvent e) {
576                 savePreferences();
577             }
578         });
579         //
580         tmpTabsAufnahmen.addChangeListener(new ChangeListener() {
581             public void stateChanged(ChangeEvent e) {
582                 // boolean enable = (tmpTabsAufnahmen.getSelectedComponent() ==
583                 // tmpPanelLocal);
584                 // tmpTabbedPane.setEnabledAt(2, enable);
585             }
586         });
587         //
588         tmpTabsAufnahmen.addChangeListener(new ChangeListener() {
589             public void stateChanged(ChangeEvent e) {
590                 GPanelTableIF tmpChooser = getActiveChooser();
591                 if (tmpChooser != null) {
592                     tmpChooser.doEnabled();
593                 }
594             }
595         });
596         //
597         btnPrintEPG.setToolTipText(GStrings.getString("gdialog.printepg.Tip"));
598         lblStartzeit.setText("1234567_10_234567_20_234567_30_123456");
599         pack();
600         lblStartzeit.setText("");
601 
602         btnPrintEPG.addActionListener(new ActionListener() {
603             public void actionPerformed(ActionEvent e) {
604                 saveEPG();
605             }
606         });
607 
608         //
609         int select = tmpSettings.getIntProperty(PROPERTY_SELECTED_TAB1, 0);
610         getTabsAufnahmen().setSelectedIndex(select);
611         if (select == 0) {
612             tmpPanelLocal.sucheAufnahmen();
613         }
614         else if (select == 1) {
615             if (tmpPanelFTP.isAutoConnectOn()) {
616                 tmpTabbedPane.setSelectedIndex(2); // console
617                 tmpPanelFTP.autoConnect();
618             }
619         }
620     }
621 
622     /**
623      *
624      */
actionDone(boolean inpOK, boolean close)625     protected void actionDone(boolean inpOK, boolean close) {
626         aufnameGewaehlt = inpOK;
627         pushProperties();
628         if (Common.getSettings().getBooleanProperty(PROPERTY_AUTO_EPG, false)) {
629             saveEPG();
630         }
631         if (inpOK && getActionListener() != null) {
632             ActionEvent tmpActionEvent = new ActionEvent(this, close ? 0 : 1, "apply");
633             aActionListener.actionPerformed(tmpActionEvent);
634         }
635         if (close) {
636             this.dispose();
637         }
638     }
639 
640     /**
641      * push properties
642      */
pushProperties()643     protected void pushProperties() {
644         try {
645             JSplitPane tmpSplitPane = getSplitPane();
646             int heigth = tmpSplitPane.getHeight();
647             int width = tmpSplitPane.getWidth();
648             int divloc = tmpSplitPane.getDividerLocation();
649             Settings tmpSettings = Common.getSettings();
650             tmpSettings.setIntProperty(PROPERTY_PANEL_HOEHE, heigth);
651             tmpSettings.setIntProperty(PROPERTY_PANEL1_BREITE, divloc);
652             int width2 = width - divloc;
653             tmpSettings.setIntProperty(PROPERTY_PANEL2_BREITE, width2);
654             int tab = getTabsAufnahmen().getSelectedIndex();
655             tmpSettings.setIntProperty(PROPERTY_SELECTED_TAB1, tab);
656         } catch (Exception e) {
657             GConsole.setErrorMessage(e);
658         }
659     }
660 
661     /**
662      * @return
663      */
readPlayerLocation()664     private String readPlayerLocation() {
665         String tmpFN = null;
666         try {
667             RandomAccessFile konfDatei = new RandomAccessFile(
668                     FN_PLAYER_LOCATION, "r");
669             tmpFN = konfDatei.readLine();
670             konfDatei.close();
671             File tmpFile = new File(tmpFN);
672             if (!tmpFile.exists()) {
673                 tmpFN = null;
674             }
675         } catch (IOException e) {
676             tmpFN = null;
677         }
678         return tmpFN;
679     }
680 
681     /**
682      * @return
683      */
choosePlayerLocation()684     private String choosePlayerLocation() {
685         String tmpFN = null;
686         try {
687             JFileChooser tmpFC = new JFileChooser();
688             tmpFC.setDialogTitle(GStrings.getString("gdialog.searchplayer"));
689             tmpFC.setFileSelectionMode(JFileChooser.FILES_ONLY);
690             if (tmpFC.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
691                 File tmpFile = tmpFC.getSelectedFile();
692                 tmpFN = tmpFile.getAbsolutePath();
693                 RandomAccessFile konfDatei = new RandomAccessFile(
694                         FN_PLAYER_LOCATION, "rw");
695                 konfDatei.setLength(0);
696                 konfDatei.writeBytes(tmpFN.toString());
697                 konfDatei.close();
698             }
699         } catch (Exception e) {
700             GConsole.setErrorMessage(e);
701         }
702         return tmpFN;
703     }
704 
705     /**
706      *
707      */
saveEPG()708     protected void saveEPG() {
709         try {
710             GAufnahmeIF tmpAufnahme = getSelectedAufnahme();
711             if (tmpAufnahme == null) {
712                 return;
713             }
714             String tmpTitel = tmpAufnahme.getTitel();
715             if (tmpTitel == null) {
716                 return;
717             }
718             String tmpFN = Utils.legalFilename(tmpTitel) + ".txt"; // file name
719             String tmpDir = getOutputDirectory();
720             if (tmpDir == null || tmpDir.length() == 0) {
721                 File tmpFile = new File(System.getProperty("user.dir"));
722                 if (tmpFile != null) {
723                     tmpDir = tmpFile.getAbsolutePath();
724                 }
725             }
726             if (tmpDir != null) {
727                 String tmpSep = File.separator;
728                 if (!tmpDir.endsWith(tmpSep)) {
729                     tmpDir += tmpSep;
730                 }
731                 tmpFN = tmpDir + tmpFN;
732             }
733             File tmpFile = new File(tmpFN);
734             if (tmpFile.exists()) {
735                 tmpFile.delete();
736             }
737             if (!tmpFile.createNewFile()) {
738                 return;
739             }
740             RandomAccessFile tmpRAF = new RandomAccessFile(tmpFile, "rw");
741             //
742             String tmpLF = System.getProperty("line.separator"); // new line
743             if (tmpLF == null) {
744                 tmpLF = "\n"; // wenigstens das
745             }
746             byte[] tmpNL = tmpLF.getBytes();
747             // Titel
748             tmpRAF.writeBytes(tmpTitel);
749             tmpRAF.write(tmpNL);
750             String tmpStr = tmpAufnahme.getInfo();
751             if (tmpStr != null && tmpStr.length() > 0
752                     && !tmpStr.equals(tmpTitel)) {
753                 tmpRAF.writeBytes(tmpStr);
754                 tmpRAF.write(tmpNL);
755             }
756             tmpRAF.write(tmpNL);
757             String tmpSender = tmpAufnahme.getSender();
758             StringBuffer tmpBuf = new StringBuffer((tmpSender == null) ? "" : tmpSender + " ");
759             int start = tmpAufnahme.getStartzeit();
760             int ende = tmpAufnahme.getEndezeit();
761             int dauer = ende - start;
762             Date dtStart = new Date((long) start * 1000);
763             GregorianCalendar tmpGreg = new GregorianCalendar();
764             tmpGreg.setTime(dtStart);
765             String strStart = wochenTag(tmpGreg.get(Calendar.DAY_OF_WEEK)) + ", "
766             + calToString(tmpGreg);
767             tmpBuf.append(strStart);
768             dauer /= 60;
769             int m = dauer % 60;
770             dauer /= 60;
771             int h = dauer % 60;
772             tmpBuf.append(" (");
773             tmpBuf.append(h);
774             tmpBuf.append(':');
775             if (m < 10) {
776                 tmpBuf.append('0');
777             }
778             tmpBuf.append(m);
779             tmpBuf.append('\'');
780             tmpBuf.append(')');
781             tmpRAF.writeBytes(tmpBuf.toString());
782             tmpRAF.write(tmpNL);
783             tmpRAF.write(tmpNL);
784             tmpStr = tmpAufnahme.getInhalt();
785             if (tmpStr != null) {
786                 tmpStr = tmpStr.replaceAll("\n", tmpLF);
787                 tmpRAF.writeBytes(tmpStr);
788                 tmpRAF.write(tmpNL);
789             }
790             //
791             tmpRAF.close();
792         } catch (Exception e) {
793             GConsole.setErrorMessage(e);
794         }
795     }
796 
797     /**
798      *
799      */
savePreferences()800     protected void savePreferences() {
801         pushProperties();
802         String str = CommonGui.getUserInput(this, "save ini", "save inifile",
803                 Common.getSettings().getInifile());
804         if (str != null && str.length() > 0)
805             Common.saveSettings(str);
806     }
807 
808     /**
809      *
810      */
playMPC()811     protected void playMPC() {
812         try {
813             if (aFNPlayer == null) {
814                 aFNPlayer = choosePlayerLocation();
815                 if (aFNPlayer == null) {
816                     return;
817                 }
818             }
819             aufnameGewaehlt = true;
820             List tmpList = getSelectedRecording();
821             if (tmpList == null || tmpList.size() < 1) {
822                 return;
823             }
824             Object tmpObject = tmpList.get(0);
825             if (!(tmpObject instanceof XInputFile)) {
826                 return;
827             }
828             XInputFile tmpFile = (XInputFile) tmpObject;
829             String tmpPath = tmpFile.getName();
830             int x = tmpPath.indexOf(".000.mpg");
831             if (x >= 0) {
832                 tmpPath = tmpPath.substring(0, x) + ".*.mpg";
833             }
834             Runtime tmpRuntime = Runtime.getRuntime();
835             String tmpCmd = aFNPlayer + " \"" + tmpPath + "\"";
836             tmpRuntime.exec(tmpCmd);
837         } catch (Exception e) {
838             GConsole.setErrorMessage(e);
839         }
840     }
841 
zeigeInfos(int nr)842     protected void zeigeInfos(int nr) {
843         GAufnahmeIF tmpAufnahme = getSelectedAufnahme();
844         if (tmpAufnahme == null || nr < 0) {
845             aLabelSender2.setText("");
846             lblStartzeit.setText("");
847             lblEndezeit.setText("");
848             lblLaengeString.setText("");
849             lblGesehenString.setText("");
850             lblFilesString.setText("");
851             lblGroesseString.setText("");
852             lblStatusString.setText("");
853             lblInfoString.setText("");
854             taInhalt.setText("");
855             return;
856         }
857         String tmpSender = tmpAufnahme.getSender();
858         aLabelSender2.setText((tmpSender == null) ? "?" : tmpSender);
859         int start = tmpAufnahme.getStartzeit();
860         int versatz = tmpAufnahme.getAufnahmeBeginn() - start;
861         int ende = tmpAufnahme.getEndezeit();
862         Date dtStart = new Date((long) start * 1000);
863         Date dtEnde = new Date((long) ende * 1000);
864         GregorianCalendar tmpGreg = new GregorianCalendar();
865         tmpGreg.setTime(dtStart);
866         String strStart = wochenTag(tmpGreg.get(Calendar.DAY_OF_WEEK)) + ", "
867                 + calToString(tmpGreg);
868         tmpGreg.setTime(dtEnde);
869         String strEnde = wochenTag(tmpGreg.get(Calendar.DAY_OF_WEEK)) + ", "
870                 + calToString(tmpGreg);
871         lblStartzeit.setText(strStart + " (" + formatSeconds(versatz) + ")");
872         lblEndezeit.setText(strEnde);
873         lblLaengeString.setText(formatSeconds(ende - start));
874         int gesehenBis = tmpAufnahme.getGesehenBis();
875         if (gesehenBis == 0)
876             lblGesehenString
877                     .setText(GStrings.getString("gdialog.seen.nothing"));
878         else
879             lblGesehenString.setText(formatSeconds(gesehenBis + versatz));
880         // Anzahl Bytes
881         long tmpSize = tmpAufnahme.getByte();
882         String tmpStr = (tmpSize < 0) ? "?" : ((tmpSize / 1024 / 1024) + " MB");
883         lblGroesseString.setForeground((tmpSize == 0) ? Color.red
884                 : lblGesehenString.getForeground());
885         lblGroesseString.setText(tmpStr);
886         // (F)MPGs erwartet / gefunden
887         int tmpFMPGs1 = tmpAufnahme.getAnzahlFMPGsErwartet();
888         int tmpMPGs1 = tmpAufnahme.getAnzahlMPGsErwartet();
889         int tmpFMPGs2 = tmpAufnahme.getAnzahlFMPGsVorhanden();
890         int tmpMPGs2 = tmpAufnahme.getAnzahlMPGsVorhanden();
891         StringBuffer tmpBuf = new StringBuffer();
892         // das ist jetzt unsere Referenz f�r normale Farbe
893         Color tmpColor = lblGesehenString.getForeground();
894         if (tmpSize < 0) {
895             tmpBuf.append('?');
896         } else {
897             tmpBuf.append(tmpFMPGs1);
898             tmpBuf.append(" + ");
899             tmpBuf.append(tmpMPGs1);
900             tmpBuf.append(' ');
901             String tmpStr1 = GStrings.getString("gdialog.files.expected");
902             tmpBuf.append(tmpStr1);
903             tmpBuf.append(" / ");
904             tmpBuf.append(tmpFMPGs2);
905             tmpBuf.append(" + ");
906             tmpBuf.append(tmpMPGs2);
907             tmpBuf.append(' ');
908             String tmpStr2 = GStrings.getString("gdialog.files.found");
909             tmpBuf.append(tmpStr2);
910             if (tmpFMPGs1 != tmpFMPGs2 || tmpMPGs1 != tmpMPGs2) {
911                 tmpColor = Color.red;
912             }
913         }
914         lblFilesString.setForeground(tmpColor);
915         lblFilesString.setText(tmpBuf.toString());
916         // Status
917         int status = tmpAufnahme.getStatus();
918         String strStatus = GStrings.getString("gdialog.status0");
919         switch (status) {
920         case 1: // geplant
921         case 2: // lauft ==> rote Schrift!
922         case 3: // ok
923         case 4: // error
924         case 5: // abgebrochen
925             strStatus = GStrings.getString("gdialog.status" + status);
926             break;
927         }
928         tmpColor = tmpAufnahme.isLaufend() ? Color.red : lblGesehenString.getForeground();
929         boolean lock = tmpAufnahme.istGesperrt();
930         if (lock) {
931             strStatus += " (" + GStrings.getString("gdialog.locked") + ")";
932         }
933         lblStatusString.setForeground(tmpColor);
934         lblStatusString.setText(strStatus);
935         lblInfoString.setText(tmpAufnahme.getInfo());
936         taInhalt.setText(tmpAufnahme.getInhalt());
937         // read on demand
938         if (tmpSize < 0) {
939             readMpgsOnDemand(tmpAufnahme, nr);
940         }
941     }
942 
943     /**
944      *
945      * @param inpAufnahme
946      */
readMpgsOnDemand(final GAufnahmeIF inpAufnahme, final int inpRow)947     private void readMpgsOnDemand(final GAufnahmeIF inpAufnahme, final int inpRow) {
948         try {
949             boolean ok = Common.getSettings().getBooleanProperty(
950                     PROPERTY_MPGS_ONDEMAND, false);
951             if (!ok) {
952                 return;
953             }
954             Runnable tmpRunnable = new Runnable() {
955                 public void run() {
956                     try {
957                         inpAufnahme.getMpgFiles();
958                     } catch (RuntimeException exc) {
959                         GConsole.setErrorMessage(exc);
960                     }
961                 }
962             };
963             new Thread(tmpRunnable).start();
964         } catch (Exception e) {
965             GConsole.setErrorMessage(e);
966         }
967     }
968 
getSelectedRecording()969     public List getSelectedRecording() {
970         try {
971             if (aufnameGewaehlt) {
972                 aufnameGewaehlt = false;
973                 GPanelTableIF tmpChooser = getActiveChooser();
974                 if (tmpChooser != null) {
975                     return tmpChooser.getSelectedRecording();
976                 }
977             }
978         } catch (Exception e) {
979             GConsole.setErrorMessage(e);
980         }
981         return null;
982     }
983 
getSelectedTitel()984     public String getSelectedTitel() {
985         try {
986             GPanelTableIF tmpChooser = getActiveChooser();
987             if (tmpChooser != null) {
988                 return tmpChooser.getSelectedTitel();
989             }
990         } catch (Exception e) {
991             GConsole.setErrorMessage(e);
992         }
993         return null;
994     }
995 
getSelectedExtension()996     public String getSelectedExtension() {
997         try {
998             GPanelTableIF tmpChooser = getActiveChooser();
999             if (tmpChooser != null) {
1000                 return tmpChooser.getSelectedExtension();
1001             }
1002         } catch (Exception e) {
1003             GConsole.setErrorMessage(e);
1004         }
1005         return null;
1006     }
1007 
getSelectedOutname()1008     public String getSelectedOutname() {
1009         String tmpString = getSelectedTitel();
1010         // wenn ein Punkt im Titel ist,
1011         // dann noch die Extension anh�ngen,
1012         // weil sonst PjX den letzten Teil abschneidet
1013         if (tmpString != null && tmpString.indexOf('.') >= 0) {
1014             String tmpString2 = getSelectedExtension();
1015             if (tmpString2 != null) {
1016                 tmpString += tmpString2;
1017             }
1018         }
1019         return tmpString;
1020     }
1021 
1022     /**
1023      * arno 02.10.05
1024      *
1025      * @return Returns the outputDirectory.
1026      */
getOutputDirectory()1027     private String getOutputDirectory() {
1028         try {
1029             // we need at least one collection
1030             Common.addCollection(false);
1031             JobCollection tmpCollection = Common.getCollection();
1032             String tmpOutdir = (tmpCollection != null) ? tmpCollection
1033                     .getOutputDirectory() : null;
1034             if (tmpOutdir == null) {
1035                 tmpOutdir = Common.getSettings().getProperty(
1036                         Keys.KEY_OutputDirectory);
1037             }
1038             return tmpOutdir;
1039         } catch (Exception exc) {
1040             // daran soll's nicht scheitern
1041             GConsole.setErrorMessage(exc);
1042         }
1043         return null;
1044     }
1045 
calToString(Calendar inpDate)1046     private String calToString(Calendar inpDate) {
1047         if (inpDate == null) {
1048             return "";
1049         }
1050         String tmpString = inpDate.get(Calendar.DATE) + ".";
1051         tmpString += inpDate.get(Calendar.MONTH) + 1;
1052         tmpString += ".";
1053         tmpString += inpDate.get(Calendar.YEAR);
1054         tmpString += " ";
1055         tmpString += inpDate.get(Calendar.HOUR_OF_DAY);
1056         tmpString += ":";
1057         int min = inpDate.get(Calendar.MINUTE);
1058         if (min < 10) {
1059             tmpString += "0";
1060         }
1061         tmpString += min;
1062         tmpString += ":";
1063         min = inpDate.get(Calendar.SECOND);
1064         if (min < 10) {
1065             tmpString += "0";
1066         }
1067         tmpString += min;
1068         return tmpString;
1069     }
1070 
shortPathOf(String inpPath)1071     protected String shortPathOf(String inpPath) {
1072         if (inpPath == null) {
1073             return "";
1074         }
1075         char tmpC = File.separatorChar;
1076         int x1 = inpPath.indexOf(tmpC);
1077         String tmpString = "";
1078         if (x1 > 0) {
1079             int len = inpPath.length();
1080             tmpString += inpPath.substring(0, x1 + 1);
1081             inpPath = (len - 1 == x1) ? "" : inpPath.substring(x1 + 1);
1082         }
1083         int x2 = inpPath.lastIndexOf(File.separatorChar);
1084         tmpString += (x2 == x1 || x2 < 0) ? inpPath : "..."
1085                 + inpPath.substring(x2);
1086         return tmpString;
1087     }
1088 
getTabsAufnahmen()1089     protected JTabbedPane getTabsAufnahmen() {
1090         return aTabsAufnahmen;
1091     }
1092 
setTabsAufnahmen(JTabbedPane inpTabsAufnahmen)1093     protected void setTabsAufnahmen(JTabbedPane inpTabsAufnahmen) {
1094         aTabsAufnahmen = inpTabsAufnahmen;
1095     }
1096 
getActiveChooser()1097     protected GPanelTableIF getActiveChooser() {
1098         GPanelTableIF tmpChooser = null;
1099         try {
1100             Component tmpComponent = getTabsAufnahmen().getSelectedComponent();
1101             if (tmpComponent instanceof GPanelTableIF) {
1102                 tmpChooser = (GPanelTableIF) tmpComponent;
1103             }
1104         } catch (Exception e) {
1105             GConsole.setErrorMessage(e);
1106         }
1107         return tmpChooser;
1108     }
1109 
getSelectedAufnahme()1110     protected GAufnahmeIF getSelectedAufnahme() {
1111         GAufnahmeIF tmpAufnahme = null;
1112         try {
1113             GPanelTableIF tmpChooser = getActiveChooser();
1114             if (tmpChooser != null) {
1115                 tmpAufnahme = tmpChooser.getSelectedAufnahme();
1116             }
1117         } catch (Exception e) {
1118             GConsole.setErrorMessage(e);
1119         }
1120         return tmpAufnahme;
1121     }
1122 
1123     /**
1124      *
1125      * @return List of File (fmpg-directories)
1126      */
getUsedRecDirectories()1127     public List getUsedRecDirectories() {
1128         try {
1129             GPanelTableIF tmpPanel = getActiveChooser();
1130             if (tmpPanel != null) {
1131                 return tmpPanel.getUsedRecDirectories();
1132             }
1133         } catch (Exception e) {
1134             GConsole.setErrorMessage(e);
1135         }
1136         return null;
1137     }
1138 
1139     /**
1140      *
1141      */
sortiereAufnahmen(int selector)1142     protected void sortiereAufnahmen(int selector) {
1143         try {
1144             GPanelTableIF tmpPanel = getActiveChooser();
1145             if (tmpPanel instanceof GPanelAbstract) {
1146                 ((GPanelAbstract)tmpPanel).sortiereAufnahmen(selector);
1147             }
1148         } catch (Exception e) {
1149             GConsole.setErrorMessage(e);
1150         }
1151     }
1152 
1153     /**
1154      *
1155      * @param inpList
1156      * @return Object of File or XInputDirectory
1157      */
getLostRecDirectories(List inpList)1158     public Object getLostRecDirectories(List inpList) {
1159         try {
1160             GPanelTableIF tmpPanel = getActiveChooser();
1161             if (tmpPanel != null) {
1162                 return tmpPanel.getLostDirectories(inpList);
1163             }
1164         } catch (Exception e) {
1165             GConsole.setErrorMessage(e);
1166         }
1167         return null;
1168     }
1169 
1170     /**
1171      *
1172      * @return File (crid-directory)
1173      */
getFlAufnahmeOrdner()1174     public File getFlAufnahmeOrdner() {
1175         try {
1176             Component tmpComponent = getTabsAufnahmen().getComponentAt(0);
1177             if (tmpComponent instanceof GPanelLocal) {
1178                 GPanelLocal tmpPanel = (GPanelLocal) tmpComponent;
1179                 return tmpPanel.getFlAufnahmeOrdner();
1180             }
1181         } catch (Exception e) {
1182             GConsole.setErrorMessage(e);
1183         }
1184         return null; // error
1185     }
1186 
1187     /**
1188      * @return splitPane
1189      */
getSplitPane()1190     protected JSplitPane getSplitPane() {
1191         if (aSplitPane == null) {
1192             aSplitPane = new JSplitPane();
1193         }
1194         return aSplitPane;
1195     }
1196 
getDateFormat1()1197     protected static String getDateFormat1() {
1198         return Common.getSettings().getProperty(PROPERTY_DATE_FORMAT,
1199                 PROPERTY_DEFAULT_DATFMT);
1200     }
1201 
1202     /**
1203      * @return simpleDateFormat
1204      */
getSimpleDateFormat1()1205     public static SimpleDateFormat getSimpleDateFormat1() {
1206         if (aSimpleDateFormat1 == null) {
1207             aSimpleDateFormat1 = new SimpleDateFormat(getDateFormat1());
1208         }
1209         return aSimpleDateFormat1;
1210     }
1211 
1212     /**
1213      * @param inpSimpleDateFormat Festzulegender simpleDateFormat
1214      */
setSimpleDateFormat1(SimpleDateFormat inpSimpleDateFormat)1215     protected static void setSimpleDateFormat1(SimpleDateFormat inpSimpleDateFormat) {
1216         aSimpleDateFormat1 = inpSimpleDateFormat;
1217     }
1218 
getDateFormat2()1219     protected static String getDateFormat2() {
1220         return Common.getSettings().getProperty(PROPERTY_DATE_FORMAT2,
1221                 PROPERTY_DEFAULT_DATFMT2);
1222     }
1223 
1224     /**
1225      * @return simpleDateFormat2
1226      */
getSimpleDateFormat2()1227     protected static SimpleDateFormat getSimpleDateFormat2() {
1228         if (aSimpleDateFormat2 == null) {
1229             aSimpleDateFormat2 = new SimpleDateFormat(getDateFormat2());
1230         }
1231         return aSimpleDateFormat2;
1232     }
1233 
1234     /**
1235      * @param inpSimpleDateFormat2 Festzulegender simpleDateFormat2
1236      */
setSimpleDateFormat2(SimpleDateFormat inpSimpleDateFormat2)1237     protected static void setSimpleDateFormat2(SimpleDateFormat inpSimpleDateFormat2) {
1238         aSimpleDateFormat2 = inpSimpleDateFormat2;
1239     }
1240 
1241     /**
1242      * @return actionListener
1243      */
getActionListener()1244     public ActionListener getActionListener() {
1245         if (aActionListener == null) {
1246             aActionListener = new ActionListener() {
1247                 public void actionPerformed(ActionEvent inpE) {
1248                     insertBoxFiles(inpE);
1249                 }
1250 
1251             };
1252         }
1253         return aActionListener;
1254     }
1255 
1256     /**
1257      * @param inpActionListener Festzulegender actionListener
1258      */
setActionListener(ActionListener inpActionListener)1259     public void setActionListener(ActionListener inpActionListener) {
1260         aActionListener = inpActionListener;
1261     }
1262 
1263     /**
1264      * @return mainFrame
1265      */
getMainFrame()1266     protected MainFrame getMainFrame() {
1267         return aMainFrame;
1268     }
1269 
1270     /**
1271      * @param inpMainFrame Festzulegender mainFrame
1272      */
setMainFrame(MainFrame inpMainFrame)1273     protected void setMainFrame(MainFrame inpMainFrame) {
1274         aMainFrame = inpMainFrame;
1275     }
1276 
insertBoxFiles(ActionEvent inpEvent)1277     protected void insertBoxFiles(ActionEvent inpEvent) {
1278         try {
1279             final int tmpID = inpEvent.getID();
1280             Object tmpSource = inpEvent.getSource();
1281             GPanelLost tmpPanelLost = (tmpSource instanceof GPanelLost) ? (GPanelLost)tmpSource : null;
1282             final List tmpList = (tmpPanelLost != null) ? tmpPanelLost.getSelectedLostMPGs() : getSelectedRecording();
1283             if (tmpList == null || tmpList.size() == 0)
1284                 return;
1285             Runnable tmpRunnable = new Runnable() {
1286 
1287                 /*
1288                  * (Kein Javadoc)
1289                  *
1290                  * @see java.lang.Runnable#run()
1291                  */
1292                 public void run() {
1293                     insertBoxFiles(tmpList, tmpID);
1294                 }
1295 
1296             };
1297             new Thread(tmpRunnable).start();
1298         } catch (Exception exc) {
1299             exc.printStackTrace();
1300         }
1301     }
1302 
1303     /**
1304      * gigaset 22.10.2006
1305      * @param inpDialog
1306      * @param inpFiles
1307      */
insertBoxFiles(List inpFileList, int inpID)1308     protected void insertBoxFiles(List inpFileList, int inpID) {
1309         if (inpFileList == null || inpFileList.size() < 1) {
1310             return;
1311         }
1312         Cursor tmpCursor = null;
1313         String tmpStatus = null;
1314         try {
1315             tmpCursor = null;//getCursor();
1316             //setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1317             tmpStatus = Common.getStatusString();
1318             Common.setStatusString(GStrings
1319                     .getString("gdialog.status.transfer"));
1320             JobCollection tmpCollection = Common.getCollection();
1321             if (inpID > 0 && tmpCollection != null && tmpCollection.getAllSizes() != 0){
1322                 Common.addCollection(true);
1323             }
1324             else {
1325                 Common.addCollection(false);
1326             }
1327             JobCollection collection = Common.getCollection();
1328             List tmpFileList = collection.getInputFilesAsList();
1329             int primaryFilesCount = (tmpFileList == null) ? 0 : tmpFileList.size(); // at least one file is primary
1330             StreamInfo tmpStreamInfo = null;
1331             int anz = inpFileList.size();
1332             for (int i = 0; i < anz; i++) {
1333                 Object tmpObject = inpFileList.get(i);
1334                 if (tmpObject instanceof XInputFile) {
1335                     XInputFile tmpXFile = (XInputFile) tmpObject;
1336                     if (tmpXFile.exists()) {
1337                         if (tmpStreamInfo == null) {
1338                             tmpXFile.setStreamInfo(null);
1339                             if (tmpStreamInfo == null) {
1340                                 Common.getScanClass().getStreamInfo(tmpXFile);
1341                                 tmpStreamInfo = tmpXFile.getStreamInfo();
1342                             }
1343                         } else {
1344                             tmpXFile.setStreamInfo(tmpStreamInfo);
1345                         }
1346                         tmpFileList.add(tmpXFile);
1347                         primaryFilesCount++;
1348                     }
1349                 }
1350             } // for i
1351             collection.setPrimaryInputFileSegments(primaryFilesCount);
1352             MainFrame tmpMainFrame = getMainFrame();
1353             tmpMainFrame.updateCollectionTable(collection.getCollectionAsTable());
1354             MainFrame.updateCollectionPanel(Common.getActiveCollection());
1355             // change output-name to movie-name
1356             String newoutname = getSelectedOutname();
1357             if (newoutname != null) {
1358                 collection.setOutputName(Utils.legalFilename(newoutname));
1359                 tmpMainFrame.updateOutputField(collection);
1360                 tmpMainFrame.updateCollectionTable(collection.getCollectionAsTable());
1361             }
1362         } catch (Exception exc) {
1363             exc.printStackTrace();
1364         } finally {
1365             if (tmpStatus != null) {
1366                 Common.setStatusString(tmpStatus);
1367             }
1368             if (tmpCursor != null) {
1369                 setCursor(tmpCursor);
1370             }
1371             if (inpID == 1) {
1372                 this.toFront();
1373             }
1374         }
1375     }
1376 
1377     /* (Kein Javadoc)
1378      * @see java.awt.Window#setLocationRelativeTo(java.awt.Component)
1379      */
setLocationRelativeTo(Component inpC)1380     public void setLocationRelativeTo(Component inpC) {
1381         // dirty trick ;-))
1382         if (inpC instanceof MainFrame) {
1383             setMainFrame((MainFrame)inpC);
1384         }
1385         super.setLocationRelativeTo(inpC);
1386     }
1387 
1388 } // Ende von class GDialog
1389