Ejemplo n.º 1
0
  /** Initializes this dialog properly */
  private void completeInitialization() {
    // title of archives list
    jPanel1.setBorder(
        new javax.swing.border.TitledBorder(
            new javax.swing.border.EtchedBorder(),
            NbBundle.getBundle(HistoryModel.class).getString("CTL_Archives")));

    historyData = JarPackagerOption.singleton().historyData();
    historyList.setModel(historyData);
    updateControlStates();
    // testing
    JarContent jc = new JarContent();
    jc.filteredContent();
  }
Ejemplo n.º 2
0
 /** Restores currently selected archive */
 boolean restoreArchive() {
   String archivePath = (String) historyList.getSelectedValue();
   if (archivePath == null) {
     TopManager.getDefault()
         .notify(
             new NotifyDescriptor.Message(
                 NbBundle.getBundle(HistoryPanel.class).getString("MSG_NoSelection"),
                 NotifyDescriptor.ERROR_MESSAGE));
     return false;
   }
   HistoryModel.HistoryEntry foundEntry = historyData.getEntry(archivePath);
   File contentFile = new File(foundEntry.contentPath);
   // return if content not found
   if (!contentFile.exists()) {
     TopManager.getDefault()
         .notify(
             new NotifyDescriptor.Message(
                 MessageFormat.format(
                     NbBundle.getBundle(HistoryPanel.class).getString("FMT_NotExist"),
                     new Object[] {archivePath}),
                 NotifyDescriptor.ERROR_MESSAGE));
     return false;
   }
   // read jar content, if it's possible
   JarContent jc = null;
   try {
     ObjectInputStream ois =
         new ObjectInputStream(new BufferedInputStream(new FileInputStream(contentFile)));
     try {
       jc = new JarContent();
       jc.readContent(ois);
     } finally {
       ois.close();
     }
   } catch (IOException exc) {
     exc.printStackTrace();
     return false;
   } catch (ClassNotFoundException exc) {
     exc.printStackTrace();
     return false;
   }
   // set the content if everything goes well
   PackagingView.getPackagingView().setJarContent(jc);
   return true;
 }