From 8dc813523fef660f4f2fa11acca3aa7c8fd3ce0b Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 1 Sep 2017 10:55:22 -0400 Subject: [PATCH] More verbose GUI and Adding folder optimization -Optimized adding folder: if there are no subdirectories then the folder is added without asking for subdirectories. #17 -Output on GUI when processing Bearing --- .../ca/osmcanada/osvuploadr/JPInfoBox.form | 6 +-- .../ca/osmcanada/osvuploadr/JPInfoBox.java | 6 +-- .../java/ca/osmcanada/osvuploadr/JPMain.java | 44 +++++++++++++------ 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form index 270af45..9ffcaeb 100644 --- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form +++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form @@ -25,7 +25,7 @@ - + @@ -35,10 +35,10 @@ - + - + diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java index be5fb68..ef9cd7c 100644 --- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java +++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java @@ -67,7 +67,7 @@ private void initComponents() { .addContainerGap() .addComponent(jlCurrentlyProc) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jlProcessing, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE) + .addComponent(jlProcessing, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( @@ -75,9 +75,9 @@ private void initComponents() { .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jlCurrentlyProc) + .addComponent(jlCurrentlyProc, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jlProcessing, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(78, Short.MAX_VALUE)) + .addContainerGap(97, Short.MAX_VALUE)) ); }// //GEN-END:initComponents diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java index 1c48f4c..8bf0541 100644 --- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java +++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java @@ -122,6 +122,9 @@ public void setBearing(){ if(bearing_offset==null){ return; } + JFMain topframe = (JFMain)SwingUtilities.getWindowAncestor(this); + topframe.showInfoBox(); + topframe.setInfoBoxText("Sorting items, please wait"); Thread t = new Thread(){ public void run(){ processBearing(dir,(int)bearing_offset); @@ -133,6 +136,7 @@ public void run(){ } public void processBearing(String directory, int Offset){ + JFMain topframe = (JFMain)SwingUtilities.getWindowAncestor(this); File dir_photos = new File(directory); //filter only .jpgs FilenameFilter fileNameFilter = new FilenameFilter() { @@ -163,9 +167,11 @@ public int compare(File f1, File f2) ImageProperties imTO = null; ImageProperties imFROM = null; for(int i=file_list.length-1;i>=0;i--){ + topframe.setInfoBoxText("Setting Bearing for:" + file_list[i]); if(i==0){ //TODO: set last bearing try{ + Helper.setBearing(file_list[i], last_bearing); } catch(IOException|ImageReadException|ImageWriteException ex){ @@ -184,6 +190,7 @@ public int compare(File f1, File f2) } last_bearing = (Helper.calc_bearing(imFROM.getLatitude(), imFROM.getLongitude(), imTO.getLatitude(), imTO.getLongitude())+ Offset) % 360.00; System.out.println("Calculated bearing (with offset) at: " + last_bearing); + topframe.setInfoBoxText("Setting Bearing for:" + file_list[i] + "
" + last_bearing + ""); try{ Helper.setBearing(file_list[i], last_bearing); } @@ -191,6 +198,7 @@ public int compare(File f1, File f2) Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "Error writing exif data", ex); } } + topframe.setInfoBoxText("Done"); } private void setUILang(){ @@ -974,25 +982,33 @@ private void jbAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e int returnVal = fc.showSaveDialog(this); if(returnVal == JFileChooser.APPROVE_OPTION) { if(fc.getSelectedFiles().length==1){ - int response = JOptionPane.showConfirmDialog(null, new String(r.getString("immediate_sub_folders").getBytes(), StandardCharsets.UTF_8), new String(r.getString("add_subfolders").getBytes(), StandardCharsets.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(){ + //Get a list of subdirectories + String[] subDirs = fc.getCurrentDirectory().list(new FilenameFilter(){ @Override public boolean accept(File current, String name){ return new File(current,name).isDirectory(); } - }); + }); + if(subDirs.length>0){ + int response = JOptionPane.showConfirmDialog(null, new String(r.getString("immediate_sub_folders").getBytes(), StandardCharsets.UTF_8), new String(r.getString("add_subfolders").getBytes(), StandardCharsets.UTF_8), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + if(response == JOptionPane.NO_OPTION){ + File folder = fc.getCurrentDirectory(); + listDir.add(folder.getPath()); + last_dir=folder.getPath(); + } + else if (response == JOptionPane.YES_OPTION) + { + - for(String subDir: subDirs){ - listDir.add(new File(fc.getSelectedFile() + File.separator + subDir).getPath()); - } + for(String subDir: subDirs){ + listDir.add(new File(fc.getSelectedFile() + File.separator + subDir).getPath()); + } + } + } + else{ + File folder = fc.getCurrentDirectory(); + listDir.add(folder.getPath()); + last_dir=folder.getPath(); } } else if(fc.getSelectedFiles().length > 1)