~ubuntu-branches/ubuntu/trusty/mediathekview/trusty

« back to all changes in this revision

Viewing changes to src/mediathek/gui/dialogEinstellungen/DialogZiel.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany, 6ba46ec
  • Date: 2013-05-06 18:04:44 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20130506180444-oe1knj8kfeshvd8x
Tags: 3.2.1-2
[6ba46ec] Add Build-with-libjgoodies-forms-java-1.6 patch.
This patch fixes a compatibility issue with libjgoodies-forms-java 1.6. The
former class FormFactory has been renamed to FormSpecs which rendered
MediathekView unusable. (Closes: #706925)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
package mediathek.gui.dialogEinstellungen;
21
21
 
 
22
import java.awt.Component;
 
23
import java.awt.FileDialog;
22
24
import java.awt.event.ActionEvent;
23
25
import java.awt.event.ActionListener;
24
26
import java.io.File;
25
27
import javax.swing.JFileChooser;
26
28
import javax.swing.JOptionPane;
 
29
 
 
30
import com.jidesoft.utils.SystemInfo;
 
31
import mediathek.daten.DDaten;
27
32
import mediathek.tool.EscBeenden;
 
33
import mediathek.tool.Funktionen;
28
34
import mediathek.tool.GuiFunktionen;
29
35
import mediathek.tool.Log;
30
36
 
32
38
 
33
39
    public boolean ok = false;
34
40
    public String ziel = "";
 
41
    private Component parentComponent = null;
 
42
    private DDaten ddaten = null;
35
43
 
36
44
    /**
37
45
     *
38
46
     * @param parent
39
47
     * @param modal
40
 
     * @param d
 
48
     * @param dd
41
49
     * @param pfad
42
50
     * @param name
43
51
     */
44
 
    public DialogZiel(java.awt.Frame parent, boolean modal, String pfad, String name) {
 
52
    public DialogZiel(java.awt.Frame parent, DDaten dd, boolean modal, String pfad, String name) {
45
53
        super(parent, modal);
 
54
        parentComponent = parent;
 
55
        ddaten = dd;
46
56
        initComponents();
47
57
        jButtonOk.addActionListener(new OkBeobachter());
48
58
        jButtonZiel.addActionListener(new ZielBeobachter());
51
61
        }
52
62
        jTextFieldPfad.setText(GuiFunktionen.addsPfad(pfad.equals("") ? GuiFunktionen.getHomePath() : pfad, name));
53
63
        new EscBeenden(this) {
54
 
 
55
64
            @Override
56
65
            public void beenden_() {
57
66
                ok = false;
63
72
    private boolean check() {
64
73
        String pfad = jTextFieldPfad.getText();
65
74
        if (pfad.equals("")) {
66
 
            JOptionPane.showMessageDialog(null, "Pfad ist leer", "Fehlerhafter Pfad!", JOptionPane.ERROR_MESSAGE);
 
75
            JOptionPane.showMessageDialog(parentComponent, "Pfad ist leer", "Fehlerhafter Pfad!", JOptionPane.ERROR_MESSAGE);
67
76
            return false;
68
77
        }
69
78
        if (new File(pfad).exists()) {
70
 
            if (JOptionPane.showConfirmDialog(this, "Die Datei existiert schon!", "Überschreiben?", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
 
79
            if (JOptionPane.showConfirmDialog(parentComponent, "Die Datei existiert schon!", "Überschreiben?", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
71
80
                return false;
72
81
            }
73
82
        }
154
163
 
155
164
        pack();
156
165
    }// </editor-fold>//GEN-END:initComponents
157
 
    /**
158
 
     * @param args the command line arguments
159
 
     */
160
166
    // Variables declaration - do not modify//GEN-BEGIN:variables
161
167
    private javax.swing.JButton jButtonOk;
162
168
    private javax.swing.JButton jButtonZiel;
180
186
 
181
187
        @Override
182
188
        public void actionPerformed(ActionEvent e) {
183
 
            int returnVal;
184
 
            JFileChooser chooser = new JFileChooser();
185
 
            if (!jTextFieldPfad.getText().equals("")) {
186
 
                String pfad = jTextFieldPfad.getText();
187
 
                if (pfad.contains(File.separator)) {
188
 
                    pfad = pfad.substring(0, pfad.lastIndexOf(File.separator));
189
 
                    chooser.setCurrentDirectory(new File(pfad));
190
 
                } else {
191
 
                    chooser.setCurrentDirectory(new File(jTextFieldPfad.getText()));
192
 
                }
193
 
            }
194
 
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
195
 
            chooser.setFileHidingEnabled(false);
196
 
            returnVal = chooser.showOpenDialog(null);
197
 
            if (returnVal == JFileChooser.APPROVE_OPTION) {
198
 
                try {
199
 
                    jTextFieldPfad.setText(chooser.getSelectedFile().getAbsolutePath());
200
 
                } catch (Exception ex) {
201
 
                    Log.fehlerMeldung(362259105,Log.FEHLER_ART_PROG,"DialogZielDatei.ZielBeobachter", ex);
 
189
            //we can use native chooser on Mac...
 
190
            if (SystemInfo.isMacOSX()) {
 
191
                FileDialog chooser = new FileDialog(ddaten.mediathekGui, "Logdatei speichern");
 
192
                chooser.setMode(FileDialog.SAVE);
 
193
                chooser.setVisible(true);
 
194
                if (chooser.getFile() != null) {
 
195
                    try {
 
196
                        File destination = new File(chooser.getDirectory()+chooser.getFile());
 
197
                        jTextFieldPfad.setText(destination.getAbsolutePath());
 
198
                    } catch (Exception ex) {
 
199
                        Log.fehlerMeldung(639874637, Log.FEHLER_ART_PROG, "DialogZielDatei.ZielBeobachter", ex);
 
200
                    }
 
201
                }
 
202
            } else {
 
203
                int returnVal;
 
204
                JFileChooser chooser = new JFileChooser();
 
205
                if (!jTextFieldPfad.getText().equals("")) {
 
206
                    String pfad = jTextFieldPfad.getText();
 
207
                    if (pfad.contains(File.separator)) {
 
208
                        pfad = pfad.substring(0, pfad.lastIndexOf(File.separator));
 
209
                        chooser.setCurrentDirectory(new File(pfad));
 
210
                    } else {
 
211
                        chooser.setCurrentDirectory(new File(jTextFieldPfad.getText()));
 
212
                    }
 
213
                }
 
214
                chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 
215
                chooser.setFileHidingEnabled(false);
 
216
                returnVal = chooser.showOpenDialog(null);
 
217
                if (returnVal == JFileChooser.APPROVE_OPTION) {
 
218
                    try {
 
219
                        jTextFieldPfad.setText(chooser.getSelectedFile().getAbsolutePath());
 
220
                    } catch (Exception ex) {
 
221
                        Log.fehlerMeldung(362259105, Log.FEHLER_ART_PROG, "DialogZielDatei.ZielBeobachter", ex);
 
222
                    }
202
223
                }
203
224
            }
204
225
        }