private void jMenuItemLoadProjectActionPerformed( java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemLoadProjectActionPerformed { // GEN-HEADEREND:event_jMenuItemLoadProjectActionPerformed JFileChooser jfc = new JFileChooser(); if (lastPath != null) { jfc.setCurrentDirectory(lastPath); } int fileDialogReturnVal = jfc.showOpenDialog(this); if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) { try { File inputFile = jfc.getSelectedFile(); FileInputStream fis = new FileInputStream(inputFile); ObjectInputStream ois = new ObjectInputStream(fis); this.theProject = (Project) ois.readObject(); this.currentResults = (LSAResults) ois.readObject(); lastPath = new File(jfc.getSelectedFile().getPath()); } catch (IOException e) { if (this.theProject == null) { log.log(Log.ERROR, "Failed to load project"); } if (this.currentResults == null) { log.log(Log.WARNING, "Failed to load results"); } log.log(Log.WARNING, e.getMessage()); } catch (ClassNotFoundException e) { log.log(Log.ERROR, "Class not found error, version mismatch"); } } if (this.theProject != null) { jMenuItemViewDocuments.setEnabled(true); jMenuItemSaveProject.setEnabled(true); this.setTitle(theProject.getProjectName()); log.log(Log.INFO, "Project Loaded"); } if (this.currentResults != null) { log.log(Log.INFO, "Results loaded"); } } // GEN-LAST:event_jMenuItemLoadProjectActionPerformed
private void jMenuItemSaveLSAResultsActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemSaveLSAResultsActionPerformed if (this.currentResults != null) { JFileChooser jfc = new JFileChooser(); int fileDialogReturnVal = jfc.showSaveDialog(this); if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) { try { File outputFile = jfc.getSelectedFile(); FileOutputStream fos = new FileOutputStream(outputFile); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(this.currentResults); } catch (IOException e) { System.out.println("IOexception"); System.out.println(e.getMessage()); } } } } // GEN-LAST:event_jMenuItemSaveLSAResultsActionPerformed
private void jMenuItemLoadLSAResultsActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemLoadLSAResultsActionPerformed JFileChooser jfc = new JFileChooser(); int fileDialogReturnVal = jfc.showOpenDialog(this); if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) { try { File inputFile = jfc.getSelectedFile(); FileInputStream fis = new FileInputStream(inputFile); ObjectInputStream ois = new ObjectInputStream(fis); this.currentResults = (LSAResults) ois.readObject(); } catch (IOException e) { log.log(Log.ERROR, "Failed to load LSA results\n" + e.getMessage()); } catch (ClassNotFoundException e) { log.log(Log.ERROR, "Class not found : Error loading LSA results due to version mismatch"); } System.out.println(currentResults == null); } } // GEN-LAST:event_jMenuItemLoadLSAResultsActionPerformed
private void jMenuItemImportActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemImportActionPerformed JFileChooser jfc = new JFileChooser(); jfc.setMultiSelectionEnabled(true); if (lastPath != null) { jfc.setCurrentDirectory(lastPath); } int fileDialogReturnVal = jfc.showOpenDialog(this); // now select the file if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) { // add code here to allow selection of a document class DocumentClassDialog d = DocumentClassDialog.showClassDialog(this, this.theProject); DocumentClass selectedClass = d.getSelectedDocumentClass(); File[] selected = jfc.getSelectedFiles(); for (int i = 0; i < selected.length; i++) { theProject.addNewDocument(selected[i], 1.0f, selected[i].toString(), selectedClass); } docFrameTableModel.fireTableDataChanged(); lastPath = new File(jfc.getSelectedFile().getPath()); } } // GEN-LAST:event_jMenuItemImportActionPerformed
private void jMenuItemSaveProjectActionPerformed( java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemSaveProjectActionPerformed { // GEN-HEADEREND:event_jMenuItemSaveProjectActionPerformed if (this.theProject != null) { JFileChooser jfc = new JFileChooser(); int fileDialogReturnVal = jfc.showSaveDialog(this); if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) { try { File outputFile = jfc.getSelectedFile(); FileOutputStream fos = new FileOutputStream(outputFile); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(this.theProject); if (this.currentResults != null) { oos.writeObject(this.currentResults); } } catch (IOException e) { log.log(Log.ERROR, "Failed to save file\n" + e.getMessage()); } } } } // GEN-LAST:event_jMenuItemSaveProjectActionPerformed