~andreas-kuehntopf/streamtastic/main

« back to all changes in this revision

Viewing changes to src/org/kuehntopf/streamtastic/StreamtasticApp.java

  • Committer: Andreas Kuehntopf
  • Date: 2008-09-16 09:08:04 UTC
  • Revision ID: akuehntopf@helios-20080916090804-wkm4zlvr5o3k6dgp
introduced selection dialog choice if streamripper was not found

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
package org.kuehntopf.streamtastic;
22
22
 
 
23
import java.io.File;
 
24
import javax.swing.JFileChooser;
 
25
import javax.swing.JOptionPane;
23
26
import javax.swing.SwingUtilities;
24
27
import javax.swing.UIManager;
25
28
import javax.swing.UnsupportedLookAndFeelException;
 
29
import javax.swing.filechooser.FileFilter;
26
30
import org.jvnet.substance.SubstanceDefaultLookAndFeel;
27
31
import org.jvnet.substance.button.ClassicButtonShaper;
28
32
import org.jvnet.substance.theme.SubstanceOrangeTheme;
70
74
        switch (srStatus)
71
75
        {
72
76
            case NOTAVAILABLE:
73
 
                Utilities.showLocalizedError("STREAMRIPPER_NOT_INSTALLED");
74
 
                System.exit(1);
 
77
                // Ask if the User wants to select it manually
 
78
                int ret = JOptionPane.showConfirmDialog(null, 
 
79
                        Utilities.getString("STREAMRIPPER_NOT_INSTALLED"),
 
80
                        Utilities.getString("ERROR"),
 
81
                        JOptionPane.ERROR_MESSAGE,
 
82
                        JOptionPane.YES_NO_OPTION);
 
83
 
 
84
                switch (ret)
 
85
                {
 
86
                    case JOptionPane.YES_OPTION:
 
87
                        JFileChooser chooser = new JFileChooser();
 
88
                        chooser.setFileFilter(new FileFilter() {
 
89
 
 
90
                        @Override
 
91
                        public boolean accept(File arg0) {
 
92
                            if (arg0.isDirectory() || (arg0.getName().contains("streamripper")) && arg0.canExecute())
 
93
                                return true;
 
94
                            else
 
95
                                return false;
 
96
                        }
 
97
 
 
98
                        @Override
 
99
                        public String getDescription() {
 
100
                            return "Streamripper Program";
 
101
                        }
 
102
                        });
 
103
                        
 
104
                        chooser.showOpenDialog(null);
 
105
 
 
106
                        // Check if "Cancel" was pressed
 
107
                        if (chooser.getSelectedFile() == null)
 
108
                        {
 
109
                            System.exit(1);
 
110
                        }
 
111
                        else
 
112
                        {
 
113
                            // Save new Streamripper Command
 
114
                            Config.getInstance().setProperty("STREAMRIPPER_CMD",
 
115
                                   chooser.getSelectedFile().getPath());
 
116
                            Config.getInstance().saveProperties();
 
117
 
 
118
                            // Redo checks (should also check version)
 
119
                            checkStreamripperAvailable();
 
120
                            return;
 
121
                        }
 
122
                        break;
 
123
                    case JOptionPane.NO_OPTION:
 
124
                        System.exit(1);
 
125
                }
 
126
                
75
127
            case NOTSUPPORTED:
76
128
                Utilities.showLocalizedError("STREAMRIPPER_VERSION_UNSUPPORTED");
77
129
                System.exit(1);