1 25 26 package net.killingar.actions; 27 28 29 30 public class ViewFile 31 extends ListDirectory { 33 35 String name; 37 String next; 38 String prev; 39 File file; 40 41 public void setName(String in) { name = in; } 43 44 public String getName() { return name; } 46 public File getFile() { return file; } 47 public String getNext() { return next; } 48 public String getPrev() { return prev; } 49 50 public String doExecute() 52 { 53 super.doExecute(); 54 55 try 56 { 57 for (int i = 0; i < files.length; i++) 58 { 59 String name = ((File)files[i]).getName(); 60 61 if (name.equalsIgnoreCase(this.name)) 62 { 63 file = (File)files[i]; 64 65 if (i == 0) 66 prev = ((File)files[files.length-1]).getName(); 67 else 68 prev = ((File)files[i-1]).getName(); 69 70 if (i == files.length-1) 71 next = ((File)files[0]).getName(); 72 else 73 next = ((File)files[i+1]).getName(); 74 } 75 } 76 } 77 catch (Exception e) 78 { 79 addErrorMessage("failed to display file at path "+realPath+" ("+e.toString()+")"); 80 81 StackTraceElement [] s = e.getStackTrace(); 82 for (int i = 0; i < s.length; i++) 83 addErrorMessage(s[i].toString()); 84 85 return ERROR; 86 } 87 88 return SUCCESS; 89 } 90 } | Popular Tags |