Skip to content

Commit

Permalink
Added Multiselect for adding folders
Browse files Browse the repository at this point in the history
Fixes #10
  • Loading branch information
james2432 committed Nov 22, 2016
1 parent caa7b5e commit 0d3ea3a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion OSVUploadr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.osmcanada</groupId>
<artifactId>OSVUploadr</artifactId>
<version>0.1.2.2.1-ALPHA</version>
<version>0.1.2.2.2-ALPHA</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
Expand Down
46 changes: 29 additions & 17 deletions OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,29 +871,41 @@ private void jbAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
if(!last_dir.isEmpty()){
fc.setCurrentDirectory(new java.io.File(last_dir)); // start at application current directory
}
fc.setMultiSelectionEnabled(true);
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showSaveDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
int response = JOptionPane.showConfirmDialog(null, new String(r.getString("immediate_sub_folders").getBytes(),"UTF-8"), new String(r.getString("add_subfolders").getBytes(),"UTF-8"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(response == JOptionPane.NO_OPTION){
File folder = fc.getSelectedFile();
listDir.add(folder.getPath());
last_dir=folder.getPath();
if(fc.getSelectedFiles().length==1){
int response = JOptionPane.showConfirmDialog(null, new String(r.getString("immediate_sub_folders").getBytes(),"UTF-8"), new String(r.getString("add_subfolders").getBytes(),"UTF-8"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(response == JOptionPane.NO_OPTION){
File folder = fc.getSelectedFile();
listDir.add(folder.getPath());
last_dir=folder.getPath();
}
else if (response == JOptionPane.YES_OPTION)
{
//Get a list of subdirectories
String[] subDirs = fc.getSelectedFile().list(new FilenameFilter(){
@Override
public boolean accept(File current, String name){
return new File(current,name).isDirectory();
}
});

for(String subDir: subDirs){
listDir.add(new File(fc.getSelectedFile() + "/" +subDir).getPath());
}
}
}
else if (response == JOptionPane.YES_OPTION)
else if(fc.getSelectedFiles().length > 1)
{
//Get a list of subdirectories
String[] subDirs = fc.getSelectedFile().list(new FilenameFilter(){
@Override
public boolean accept(File current, String name){
return new File(current,name).isDirectory();
}
});

for(String subDir: subDirs){
listDir.add(new File(fc.getSelectedFile() + "/" +subDir).getPath());
}
File[] folders = fc.getSelectedFiles();
for(File folder:folders){
listDir.add(folder.getPath());
last_dir=folder.getPath();
}
}

}
}
catch(UnsupportedEncodingException ex)
Expand Down

0 comments on commit 0d3ea3a

Please sign in to comment.