Permalink
Browse files

fixed to last version

  • Loading branch information...
1 parent 865c428 commit 6093d716e99d10b827d68bf382e3f54cea4271fb @PsychoI3oy committed May 19, 2010
Binary file not shown.
Binary file not shown.
@@ -12,23 +12,23 @@
public class PropEditor {
static private String pFileName = "";
- static private String sFileName = "SuggestionFile.txt";
+
private PropFile pF;
private SuggestionFile sF;
- public PropEditor(String fName, String sFName){
+ public PropEditor(String fName, BufferedReader sFile){
if (fName.substring(fName.lastIndexOf('.')+1,fName.length()).equals("prop")){
pFileName = fName;
PropFile pFile = openPropFile(pFileName);
if( pFile != null){
// System.out.println("Opened prop file");
this.pF = pFile;
- openSugFile(sFileName);
+ openSugFile(sFile);
}
}else{
if(loadSession(fName)){
- openSugFile(sFileName);
+ openSugFile(sFile);
}
}
@@ -49,11 +49,10 @@ public void closePropFile(){
pF = null;
}
-
- public void openSugFile(String sugFileName){
+ public void openSugFile(BufferedReader sugFile){
SuggestionFile sF ;
try {
- sF = new SuggestionFile(sugFileName);
+ sF = new SuggestionFile(sugFile);
this.sF = sF;
} catch (Exception e) {
e.printStackTrace();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,7 +15,7 @@
import java.io.*;
-public class PropFileView extends JFrame{
+public class PropFileView extends JApplet{
/**
*
*/
@@ -279,23 +279,6 @@ public void start(){
}
- public static void main (String[] args){
- if (args.length >= 1){
- pFileName = args[0];
- }else if (args.length >= 2){
- sFileName = args[1];
- }
-
- PropFileView pV = new PropFileView();
-
- pV.setVisible(true);
-
- }
-
-
-
-
-
//---------------------begin inner event listener/handler classes
class SaveHandler implements ActionListener{
public void actionPerformed(ActionEvent e) {
@@ -329,7 +312,9 @@ public void actionPerformed(ActionEvent e) {
openFile.getName().length()).equals("prop"));
if(openFile.canRead() && isProp){
pFileName = openFile.getAbsolutePath();
- pE = new PropEditor(pFileName, sFileName);
+ InputStream is = getClass().getResourceAsStream(sFileName);
+ BufferedReader sFile= new BufferedReader(new InputStreamReader(is));
+ pE = new PropEditor(pFileName, sFile);
if(pE.getPropFile() == null){
JOptionPane.showMessageDialog(jpMain, "Failed to open prop file");
}else if(pE.getSugFile() == null){
@@ -347,7 +332,9 @@ public void actionPerformed(ActionEvent e) {
File openFile = myFileChooser.getSelectedFile();
if(openFile.canRead()){
pFileName = openFile.getAbsolutePath();
- pE = new PropEditor(pFileName, sFileName);
+ InputStream is = getClass().getResourceAsStream(sFileName);
+ BufferedReader sFile= new BufferedReader(new InputStreamReader(is));
+ pE = new PropEditor(pFileName, sFile);
if(pE.getPropFile() == null){
JOptionPane.showMessageDialog(jpMain, "Failed to open prop file");
}else if(pE.getSugFile() == null){
Binary file not shown.
@@ -13,21 +13,15 @@
public class SuggestionFile {
- static private String sugFileName = "SuggestionFile.txt";
private Hashtable<String,ArrayList<String>> sugList;
/**
*
*/
- public SuggestionFile() throws FileNotFoundException,IOException {
- this(sugFileName);
- }
- public SuggestionFile(String sFN) throws FileNotFoundException, IOException {
- sugFileName = sFN;
- FileReader fh = new FileReader(sFN);
+ public SuggestionFile(BufferedReader fh) throws FileNotFoundException, IOException {
sugList = parseFile(fh);
fh.close();
}
- public Hashtable<String,ArrayList<String>> parseFile(FileReader sFile) throws FileNotFoundException,IOException{
+ public Hashtable<String,ArrayList<String>> parseFile(BufferedReader sFile) throws FileNotFoundException,IOException{
Hashtable<String,ArrayList<String>> sList = new Hashtable<String,ArrayList<String>>();
Scanner scanner = new Scanner(sFile);

0 comments on commit 6093d71

Please sign in to comment.