Ejemplo n.º 1
0
  void addImage() {
    ArrayList<String> fileList = new ArrayList<String>();
    for (String file : peer.getOriginalFiles()) {
      if (false == peer.modifiedFileExists(file)) {
        if (ZipManager.isImage(file)) {
          fileList.add(file);
        }
      }
    }
    for (String file : peer.getModifiedFileNames()) {
      if (ZipManager.isImage(file)) {
        fileList.add(file);
      }
    }
    Object[] files = fileList.toArray();
    String s =
        (String)
            JOptionPane.showInputDialog(
                null,
                "File to use:",
                "New Photo",
                JOptionPane.PLAIN_MESSAGE,
                null,
                files,
                files[0]);

    if ((s != null) && (s.length() > 0)) {
      getCurrentExhibit().addPhoto(new ExhibitPhoto(s, null));
      exhibitPhotosModel.notifyChange();
      peer.makeChange();
    }
  }
Ejemplo n.º 2
0
 void addContent() {
   String newName = JOptionPane.showInputDialog("Name of new content:");
   if (newName != null && ZipManager.localPathPattern.matcher(newName).matches()) {
     getCurrentExhibit().setContent(newName, peer.getOriginalFiles()[0]);
     contentListModel.notifyChange();
     peer.makeChange();
   } else {
     System.out.println("Invalid tag name " + newName);
   }
 }
Ejemplo n.º 3
0
 private String[] getAllContentList() {
   ArrayList<String> list = new ArrayList<String>();
   for (String s : peer.getOriginalFiles()) {
     if (false == peer.modifiedFileExists(s)) {
       if (ZipManager.isImage(s) == false) {
         list.add(s);
       }
     }
   }
   for (String s : peer.getModifiedFileNames()) {
     if (ZipManager.isImage(s) == false) {
       list.add(s);
     }
   }
   return list.toArray(new String[0]);
 }
Ejemplo n.º 4
0
 void addExhibit() {
   String newName = JOptionPane.showInputDialog("Name of new exhibit:");
   if (newName != null && ZipManager.exhibitNamePattern.matcher(newName).matches()) {
     String newContentName = JOptionPane.showInputDialog("Name of first new content:");
     if (newContentName != null && ZipManager.localPathPattern.matcher(newContentName).matches()) {
       ExhibitInfo newE = new ExhibitInfo(newName, 0, 0, null, null);
       newE.setContent(newContentName, peer.getOriginalFiles()[0]);
       peer.getLoader().getExhibits().add(newE);
       exhibitNameModel.notifyChange();
       contentListModel.notifyChange();
       peer.makeChange();
     } else {
       System.out.println("Invalid tag name " + newContentName);
     }
   } else {
     System.out.println("Invalid exhibit name " + newName);
   }
 }
Ejemplo n.º 5
0
 void viewFile() {
   String filename = peer.getOriginalFiles()[originalFilesList.getSelectedIndex()];
   String ext = filename.substring(filename.lastIndexOf('.') + 1);
   try {
     File f = new File(".tmp" + new Random().nextInt() + "." + ext);
     OutputStream outStream = new FileOutputStream(f);
     InputStream stream = peer.getFileInputStream("assets/" + filename);
     for (int result = stream.read(); result != -1; result = stream.read()) {
       outStream.write(result);
     }
     outStream.close();
     String[] exec = {"cmd.exe", "/C", f.getPath()};
     try {
       Runtime.getRuntime().exec(exec);
     } catch (IOException e) {
       e.printStackTrace();
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
 }