|
34 | 34 | import javax.swing.JDialog; |
35 | 35 | import javax.swing.JLabel; |
36 | 36 | import javax.swing.JTextArea; |
| 37 | +import javax.swing.filechooser.FileFilter; |
37 | 38 | import net.miginfocom.swing.MigLayout; |
38 | 39 | import org.mastodon.ui.util.FileChooser; |
39 | 40 |
|
@@ -80,9 +81,6 @@ public class BlenderSetupView extends JDialog |
80 | 81 |
|
81 | 82 | setLayout( new MigLayout("insets dialog, fill", "[][grow]") ); |
82 | 83 |
|
83 | | - // TODO: Allow to select directory. |
84 | | - // TODO: Make setup not modal |
85 | | - |
86 | 84 | final String introText = "<html><body>" |
87 | 85 | + "Mastodon can use Blender to visualise cell trackings in 3D. " |
88 | 86 | + "In order to achieve this, it is required to install " |
@@ -178,7 +176,32 @@ private JComponent setFonStyle( JComponent component, int style ) |
178 | 176 | private void onSelectPathClicked() |
179 | 177 | { |
180 | 178 | String selectedFile = blenderPath == null ? null : blenderPath.toString(); |
181 | | - File file = FileChooser.chooseFile( this, selectedFile, FileChooser.DialogType.LOAD ); |
| 179 | + FileFilter filenameFilter = new FileFilter() |
| 180 | + { |
| 181 | + @Override |
| 182 | + public boolean accept( File f ) |
| 183 | + { |
| 184 | + if ( f.isDirectory() ) |
| 185 | + return true; |
| 186 | + String name = f.getName(); |
| 187 | + return name.equals( "blender" ) |
| 188 | + || name.equals( "blender-softwaregl" ) |
| 189 | + || name.equals( "blender.exe" ) |
| 190 | + || name.equals( "Blender" ); |
| 191 | + } |
| 192 | + |
| 193 | + @Override |
| 194 | + public String getDescription() |
| 195 | + { |
| 196 | + return "Blender Binary (blender.exe etc.)"; |
| 197 | + } |
| 198 | + }; |
| 199 | + File file = FileChooser.chooseFile( this, |
| 200 | + selectedFile, |
| 201 | + filenameFilter, |
| 202 | + "Select Blender Installation", |
| 203 | + FileChooser.DialogType.LOAD, |
| 204 | + FileChooser.SelectionMode.FILES_AND_DIRECTORIES ); |
182 | 205 | if(file == null) |
183 | 206 | return; |
184 | 207 | listener.setBlenderPath( file.toPath() ); |
|
0 commit comments