Ignore:
Timestamp:
03/10/10 11:23:27 (2 years ago)
Author:
erikroos
Message:

Added basic saving and loading of animal selections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molgenis4animaldb/handwritten/java/plugin/listplugin/ListPlugin.java

    r2689 r2698  
    88package plugin.listplugin; 
    99 
     10import java.io.FileInputStream; 
     11import java.io.FileOutputStream; 
     12import java.io.ObjectInputStream; 
     13import java.io.ObjectOutputStream; 
    1014import java.text.ParseException; 
    1115import java.util.ArrayList; 
     
    150154                                if (tmpList.get(j) == 0) { 
    151155                                        vis = 0; 
     156                                        break; 
    152157                                } 
    153158                        } 
     
    219224                                reload(db); 
    220225                        } 
     226                         
     227                        if (action.equals("save")) { 
     228                                List<Integer> saveList = new ArrayList<Integer>(); 
     229                                for (int i = 0; i < animalList.size(); i++) { 
     230                                        if (animalVisibilityList.get(i) == 1) { 
     231                                                saveList.add(animalList.get(i).getId()); 
     232                                        } 
     233                                } 
     234                                ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("animaldb.sav")); 
     235                                output.writeObject(saveList); 
     236                                output.close(); 
     237                        } 
     238                         
     239                        if (action.equals("load")) { 
     240                                ObjectInputStream input = new ObjectInputStream(new FileInputStream("animaldb.sav")); 
     241                                List<Integer> saveList = (ArrayList<Integer>) input.readObject(); 
     242                                input.close(); 
     243                                for (int i = 0; i < animalList.size(); i++) { 
     244                                        valueVisibilityMatrix.get(i).set(0, 0); 
     245                                        for (int j = 0; j < saveList.size(); j++) { 
     246                                                if (animalList.get(i).getId().equals(saveList.get(j))) { 
     247                                                        valueVisibilityMatrix.get(i).set(0, 1); 
     248                                                        break; 
     249                                                } 
     250                                        } 
     251                                } 
     252                                recalculateAnimalVisibilityList(); 
     253                        } 
    221254                 
    222255                } catch (Exception e) { 
     
    228261                if (firstTime) { 
    229262                        firstTime = false; 
     263                         
    230264                        // Populate animal list 
    231265                        Query q = db.query(Eventtype.class); 
Note: See TracChangeset for help on using the changeset viewer.