Back to index

wims  3.65+svn20090927
Classes | Public Member Functions | Package Attributes | Private Member Functions | Private Attributes | Static Private Attributes
SharpTools.FileOp Class Reference

Handles the saving and opening of files, and the updating of the table model appropriately. More...

Inheritance diagram for SharpTools.FileOp:
Inheritance graph
[legend]
Collaboration diagram for SharpTools.FileOp:
Collaboration graph
[legend]

List of all members.

Classes

class  SharpFileFilter

Public Member Functions

 FileOp (SharpTools gui)
 This contructor creates a FileOperations object with reference SharpTableModel; the file of the TableModel is extracted.
int queryForSave ()
 Confirm dialog box that queries whether user wishes to save current document or not.
void newFile ()
 Menu and button wrapper that handles interactive process of creating new document.
void saveFile ()
 Menu and button wrapper that handles interactive process of saving current file as itself.
void saveAsFile ()
 Menu and button wrapper that handles interactive process of saving current file.
void openFile ()
 Opens document.
boolean closeFile ()
 Closes program but checks to see if document is modified and prompts for save.
void saveTableModel (File aFile)
 Saves table model to specified file cell by cell in tab-delimited format.
void saveTableModel ()
 Overloaded save function that takes the current filename as default.
void openTableModel (File aFile)
 Opens table model data from file.
void createRecentFilesMenu (JMenu menu)
 construct the recent file list from Config
void printData ()
int print (Graphics pg, PageFormat pageFormat, int pageIndex) throws PrinterException
File getFile ()
 returns the file
boolean hasPassword ()
 has password?
void setPassword ()
 Set Password Dialog.
void actionPerformed (ActionEvent e)
 This method is activated on the Keystrokes we are listening to in this implementation.
void openDb ()
 Opens document.

Package Attributes

final ImageIcon newIcon = new ImageIcon(getClass().getResource("/images/new32.gif"))
final ImageIcon openIcon = new ImageIcon(getClass().getResource("/images/open.gif"))
final ImageIcon saveIcon = new ImageIcon(getClass().getResource("/images/save32.gif"))

Private Member Functions

String getRecentFile (int index)
 Get the file name from the recent list by index.
void setRecentFile (int index, String s)
 Set the file name in the recent list by index.
void moveToFront (int index)
 Move an item from the specified index to the first one.
void addRecentFile (File file)
void setPasswordValue (String newPassword)
boolean verifyPassword (String password)
 Verify Password Dialog.
void fileOpError (String op, String error)
 a function to display error messages

Private Attributes

int openType = UNNAMED
int maxNumPage = 1
boolean columnOverflow
StringTokenizer tokenizer
PrintStream out
BufferedReader in
SharpTools sharp
JTable table
SharpTableModel tableModel
File file
String password
JFileChooser fileChooser

Static Private Attributes

static final int UNNAMED = 0
static final int FILE = 1
static final int DATABASE = 2
static SharpFileFilter filter
final static String extname = ".csv"

Detailed Description

Handles the saving and opening of files, and the updating of the table model appropriately.

Author:
Daniel Goldberg, Hua Zhong, Shiraz Kanga (openDb)
Version:
Revision:
1.84

Definition at line 29 of file FileOp.java.


Constructor & Destructor Documentation

This contructor creates a FileOperations object with reference SharpTableModel; the file of the TableModel is extracted.

Parameters:
tableModelcalling table model is referenced in

Definition at line 80 of file FileOp.java.

                                  {
       sharp = gui;
       table = gui.getTable();
       tableModel = gui.getTableModel();
       fileChooser = new JFileChooser(new File("."));
       filter = new SharpFileFilter();
       fileChooser.addChoosableFileFilter(filter);
       sharp.setTitle(SharpTools.translation.getProperty("Untitled_-_Sharp_Tools_Spreadsheet"));

        columnOverflow = false;

       // below define key shortcuts

       table.registerKeyboardAction
           (this,SharpTools.translation.getProperty("New"),
            KeyStroke.getKeyStroke
            (KeyEvent.VK_N,ActionEvent.CTRL_MASK,false),
            JComponent.WHEN_FOCUSED);
       
       table.registerKeyboardAction
           (this,SharpTools.translation.getProperty("OpenFile"),
            KeyStroke.getKeyStroke
            (KeyEvent.VK_O,ActionEvent.CTRL_MASK,false),
            JComponent.WHEN_FOCUSED);

       table.registerKeyboardAction
           (this,SharpTools.translation.getProperty("OpenDb"),
            KeyStroke.getKeyStroke
            (KeyEvent.VK_D,ActionEvent.CTRL_MASK,false),
            JComponent.WHEN_FOCUSED);
       
       table.registerKeyboardAction
           (this,SharpTools.translation.getProperty("Save"),
            KeyStroke.getKeyStroke
            (KeyEvent.VK_S,ActionEvent.CTRL_MASK,false),
            JComponent.WHEN_FOCUSED);

       table.registerKeyboardAction
           (this,SharpTools.translation.getProperty("Print"),
            KeyStroke.getKeyStroke
            (KeyEvent.VK_P,ActionEvent.CTRL_MASK,false),
            JComponent.WHEN_FOCUSED);
       
       table.registerKeyboardAction
           (this,SharpTools.translation.getProperty("Exit"),
            KeyStroke.getKeyStroke
            (KeyEvent.VK_E,ActionEvent.CTRL_MASK,false),
            JComponent.WHEN_FOCUSED);          
    }

Member Function Documentation

void SharpTools.FileOp.actionPerformed ( ActionEvent  e) [inline]

This method is activated on the Keystrokes we are listening to in this implementation.

Here it listens for keystroke ActionCommands.

Without this listener, when we press certain keys the individual cell will be activated into editing mode in addition to the effect of the key accelerators we defined with menu items. With this key listener, we avoid this side effect.

Definition at line 799 of file FileOp.java.

                                               {

       if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("New"))==0) {
           newFile();
       }
       else if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("OpenFile"))==0) {
           openFile();
       }
       else if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("OpenDb"))==0) {
           openDb();
       }      
       else if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("Save"))==0) {
           saveFile();
       }      
       else if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("Print"))==0) {
           printData();
       }
       else if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("Exit"))==0) {
           sharp.exit();
       }
    }

Here is the call graph for this function:

void SharpTools.FileOp.addRecentFile ( File  file) [inline, private]

Definition at line 497 of file FileOp.java.

                                          {
       try {
           String filename = file.getCanonicalPath();
           int total = SharpTools.getConfig().getInt("RECENTFILELIST");
           for (int i = 0; i < total; i++) {
              if (filename.equals(getRecentFile(i))) {
                  moveToFront(i);
                  return;
              }
           }
           
           // now we push it
           setRecentFile(total-1, filename);
           moveToFront(total-1);
       }
       catch (Exception e) {
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Closes program but checks to see if document is modified and prompts for save.

Saves or not depending on user's choice. Then exits. Queries for save if modified, and uses switch to parse choice.

Returns:
whether the file is closed; user can cancel and return false

Definition at line 321 of file FileOp.java.

                               {
       int choice;
       
       if(tableModel.isModified())
           choice = queryForSave();
       else
           choice = JOptionPane.NO_OPTION;
       
       switch(choice) {
       case JOptionPane.CANCEL_OPTION:
           return false;
       case JOptionPane.YES_OPTION:
           // if user chooses yes in dialog box, save document first
           // before exiting.
           saveFile();
       default:
           //     System.exit( 0 );
           return true;
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.createRecentFilesMenu ( JMenu  menu) [inline]

construct the recent file list from Config

Parameters:
menuthe menu item to insert file list in

Definition at line 522 of file FileOp.java.

                                                  {
        Config config = SharpTools.getConfig();
       menu.removeAll();
       
       try {
           for (int i = 0; i < config.getInt("RECENTFILELIST"); i++) {
              String filename = getRecentFile(i);
              if (filename.length() > 0) {
                  File file = new File(filename);
                  JMenuItem item = new JMenuItem(file.getName(), openIcon);
                  item.addActionListener(new RecentFileListener(file, this));
                  menu.add(item);
              }
           }
           
       }
       catch (Exception e) {}

    }    

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.fileOpError ( String  op,
String  error 
) [inline, private]

a function to display error messages

Parameters:
opthe operation that caused this error
errorthe error message

Definition at line 783 of file FileOp.java.

                                                      {    
        SharpOptionPane.showMessageDialog(sharp, error, op,
                                     JOptionPane.ERROR_MESSAGE, null);
       table.requestFocus();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

File SharpTools.FileOp.getFile ( ) [inline]

returns the file

Returns:
the file

Definition at line 736 of file FileOp.java.

                          {
       return file;
    }

Here is the caller graph for this function:

String SharpTools.FileOp.getRecentFile ( int  index) [inline, private]

Get the file name from the recent list by index.

Parameters:
indexthe index in the list (also the menu)
Returns:
file name

Definition at line 465 of file FileOp.java.

                                            {
       Config config = SharpTools.getConfig();
       return config.get("RECENTFILE"+String.valueOf(index));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

has password?

  

Definition at line 745 of file FileOp.java.

                                 {
       return password != null && password.length() > 0;
    }

Here is the caller graph for this function:

void SharpTools.FileOp.moveToFront ( int  index) [inline, private]

Move an item from the specified index to the first one.

Parameters:
indexthe index in the list (also the menu)

Definition at line 486 of file FileOp.java.

                                        {
       if (index <= 0)
           return;
       
       String frontName = getRecentFile(index);
       for (int i = index; i >0; i--)
           setRecentFile(i, getRecentFile(i-1));
       
       setRecentFile(0, frontName);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.newFile ( ) [inline]

Menu and button wrapper that handles interactive process of creating new document.

queryForSave returns choice, which determines action action performed according to entry point in switch block.

Definition at line 159 of file FileOp.java.

                          {
       int choice;

        // pop up querySave box (yes, no, cancel) and save choice
       // if table modified state is modified, else set choice
       // to JOptionPane.NO_OPTION which clears cells without
       if(tableModel.isModified())
           choice = queryForSave();
       else
           choice = JOptionPane.NO_OPTION;
       
       switch(choice) {
       case JOptionPane.YES_OPTION:
           // if user chooses yes in dialog box, save document first
           // before executing clear range
           saveFile();
       case JOptionPane.NO_OPTION:

           Config config = sharp.getConfig();

           NewFileDialog dialog = new NewFileDialog(sharp,
                                               config.getInt("ROWS"),
                                               config.getInt("COLUMNS"));
           dialog.setLocationRelativeTo(sharp);
           dialog.setVisible(true);

           if (dialog.isCancelled())
              return;

           int row = dialog.getRows();
           int col = dialog.getColumns();

           // range of cells is cleared, the filename is set to untitled
           // and the modified state is set to unmodified.
           //     file = new File("Untitled");
           file = null;
           sharp.setTitle(SharpTools.translation.getProperty("Untitled_-_Sharp_Tools_Spreadsheet"));
           sharp.newTableModel(row, col);
           tableModel = sharp.getTableModel();

           // reset password
           setPasswordValue(password);

       default:
           // break out of loop for all choices.  action depends
           // on entry point.
           break;
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.openDb ( ) [inline]

Opens document.

Queries user to save if modified state is modified. Uses switch statement on user's choice to choose path of execution.

Author:
Shiraz Kanga

Definition at line 827 of file FileOp.java.

    {
       int choice;

       // pop up querySave box (yes, no, cancel) and save choice
       // if table modified state is modified, else set choice
       // to JOptionPane.NO_OPTION which clears cells without
       if (tableModel.isModified ())
           choice = queryForSave ();
       else
           choice = JOptionPane.NO_OPTION;
       
       switch (choice) {
       case JOptionPane.YES_OPTION:
           // if user chooses yes in dialog box, save document first
           // before executing clear range
           saveFile ();
       case JOptionPane.NO_OPTION:
           Database db = new Database(sharp);
           db.connectDb();
                             
       default:
           // break out of loop for all choices.  action depends
           // on entry point.
           break;
       }
    }        

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.openFile ( ) [inline]

Opens document.

Queries user to save if modified state is modified. Uses switch statement on user's choice to choose path of execution.

Definition at line 278 of file FileOp.java.

                           {
       int choice;

        // pop up querySave box (yes, no, cancel) and save choice
       // if table modified state is modified, else set choice
       // to JOptionPane.NO_OPTION which clears cells without
       if(tableModel.isModified())
           choice = queryForSave();
       else
           choice = JOptionPane.NO_OPTION;
       
       switch(choice) {
         case JOptionPane.YES_OPTION:
             // if user chooses yes in dialog box, save document first
             // before executing clear range
             saveFile();
         case JOptionPane.NO_OPTION:
             // open dialog from filechooser and save user choice
             int userChoice = fileChooser.showOpenDialog(sharp);
             // if user chooses file, call openTableModel on new
             // FileOperations object, else go to break in default
             if(userChoice == JFileChooser.APPROVE_OPTION) {
                File selectedfile = fileChooser.getSelectedFile();
                fileChooser = new JFileChooser(selectedfile.getParentFile());
                fileChooser.addChoosableFileFilter(filter);

                openTableModel(selectedfile);

             }
         default:
             // break out of loop for all choices.  action depends
             // on entry point.
             break;
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.openTableModel ( File  aFile) [inline]

Opens table model data from file.

Parameters:
aFilefile name from which to open

Definition at line 398 of file FileOp.java.

                                           {

       StringBuffer textBuf = new StringBuffer();
       String line;
       String password = null;
       try {
           in =  new BufferedReader(new FileReader(aFile));
           line = in.readLine();
           if (line.indexOf('\t') == -1 &&
              line.startsWith("Password: ")) {
              // password defined
              password = line.substring(10);
              if (!verifyPassword(password)) {
                  return;
              }
           }
           else {
              textBuf.append(line);
              textBuf.append("\n");
           }
              
           while ((line = in.readLine()) != null) {
              textBuf.append(line);
              textBuf.append("\n");
           }

           // reset password
           setPasswordValue(password);

           String text = textBuf.toString();
           // create new table model
           CellPoint size = SharpTableModel.getSize(text);
           //     System.out.println(size);
           sharp.newTableModel(size.getRow(), size.getCol());
           tableModel = sharp.getTableModel();
           tableModel.fromString(text, 0, 0,
                              new CellRange(SharpTools.baseRow,
                                          size.getRow(),
                                          SharpTools.baseCol,
                                          size.getCol()));
           file = aFile;
           //     tableModel.setModified(false);
           // set new title for spreadsheet
           String title = file.getName();
           if (title.endsWith(extname))
              title = title.substring(0, title.length()-4);

           sharp.setTitle(title+" - "+SharpTools.translation.getProperty("Sharp_Tools_Spreadsheet"));

           // update recent files
           addRecentFile(file);
           
       } catch (FileNotFoundException e) {
           fileOpError(SharpTools.translation.getProperty("Open"),SharpTools.translation.getProperty("File_not_found")+" : "+aFile.getName());
       } catch (IOException e) {
           fileOpError(SharpTools.translation.getProperty("Open"), SharpTools.translation.getProperty("IO_error_in_opening")+" : "+aFile.getName());
       } catch (Exception e) {
            e.printStackTrace();
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

int SharpTools.FileOp.print ( Graphics  pg,
PageFormat  pageFormat,
int  pageIndex 
) throws PrinterException [inline]

Definition at line 599 of file FileOp.java.

                                                          {
       // if pageIndex is beyond maximum page number, then
       // don't return
       if (pageIndex >= maxNumPage)
           return NO_SUCH_PAGE;

       // set Graphics object to printed cartesian origin
       pg.translate((int)pageFormat.getImageableX(), 
                   (int)pageFormat.getImageableY());

       // get printable width and height of page
       int wPage = 0;
       int hPage = 0;
       if (pageFormat.getOrientation() == pageFormat.PORTRAIT) {
           wPage = (int)pageFormat.getImageableWidth();
           hPage = (int)pageFormat.getImageableHeight();

           wPage = 550;
           hPage = 950;
       }
       else {
           wPage = (int)pageFormat.getImageableWidth();
           wPage += wPage/2;
           hPage = (int)pageFormat.getImageableHeight();
           
           wPage = 950;
           hPage = 550;

           pg.setClip(0,0,wPage,hPage);
       }

       // testcode
       //     Debug.println(wPage);
       //     Debug.println(hPage);

       // create int to keep track of vertical distance
       int y = 0;

       // set particular font and color for printing title of file
       pg.setColor(Color.black);
       Font fn = pg.getFont().deriveFont(Font.BOLD);
       FontMetrics fm = pg.getFontMetrics();

       // increment height for title
       y += fm.getAscent();

       // if file has no name, then print hard coded string
       if(getFile() == null)
           pg.drawString("Untitled File", 0, y);
       else
           pg.drawString(getFile().getName(), 0, y);

       y += 20; // space between title and table headers

//     Font headerFont = table.getFont().deriveFont(Font.BOLD);
//     pg.setFont(headerFont);
//     fm = pg.getFontMetrics();

       TableColumnModel colModel = table.getColumnModel();
       int nColumns = colModel.getColumnCount();
       int x[] = new int[nColumns];
       x[0] = 0;
        
       int h = fm.getAscent();
       y += h; // add ascent of header font because of baseline
       // positioning (see figure 2.10)
 
       int nRow, nCol;

       // define widths of each column
       for (nCol=1; nCol<nColumns; nCol++) {
           TableColumn tk = colModel.getColumn(nCol);
           int width = tk.getWidth();
           // check if table width is within print width
           if (x[nCol] + width > wPage) {
              nColumns = nCol;
              
              // show error one time if table width exceeds print width
              if(!columnOverflow) {
                  fileOpError(SharpTools.translation.getProperty("Print"), SharpTools.translation.getProperty("Table_width_exceeds_printed_width"));
                  columnOverflow = true;
              }

              break;
           }
           if (nCol+1<nColumns)
              x[nCol+1] = x[nCol] + width;
           String title = (String)tk.getIdentifier();
           //pg.drawString(title, x[nCol], y);
       }
       pg.setFont(table.getFont());
       fm = pg.getFontMetrics();
        
       // find out number of rows that can be printed on current page
       int header = y;
       h = fm.getHeight();
       int rowH = Math.max((int)(h*1.5), 10);
       int rowPerPage = (hPage-header)/rowH;
       maxNumPage = Math.max((int)Math.ceil(table.getRowCount()/
                                        (double)rowPerPage), 1);

       // calculate initial and final rows for current page
       int iniRow = pageIndex*rowPerPage;
       int endRow = Math.min(table.getRowCount(), 
                           iniRow+rowPerPage);
        
       // iterate through each rows for this page
       for (nRow=iniRow+1; nRow<endRow; nRow++) {

           y += h; // space between each row

           // iterate through each column on the row, getting data of each
           // cell and calling drawString with the data
           for (nCol=1; nCol<nColumns; nCol++) {
              int col = table.getColumnModel().getColumn(nCol).getModelIndex();
              String str = tableModel.getCellAt(nRow, nCol).getValue().toString();
              // testcode
//            System.out.println(str);
              
              pg.setColor(Color.black);
              pg.drawString(str, x[nCol], y);
           }
       }
       
       // explicit call on garbage collector to flush all temporary data
       // used, such as graphics objects
       System.gc();
       return PAGE_EXISTS;
    }

Here is the call graph for this function:

void SharpTools.FileOp.printData ( ) [inline]

Definition at line 559 of file FileOp.java.

                            {
       
       // create temporary object that contains this FileOp object
       // and reset columnOverflow to false
       FileOp fileOp = this;
       columnOverflow = false;

       try {
           PrinterJob prnJob = PrinterJob.getPrinterJob();

           prnJob.setPrintable(fileOp);
           
           // opens print dialog, and if user doesn't cancel the dialog
           // it calls print()
           if (!prnJob.printDialog())
              return;
           maxNumPage = 1;

           prnJob.print();
       }
       catch (PrinterException e) {
           e.printStackTrace();
           fileOpError(SharpTools.translation.getProperty("Print"), SharpTools.translation.getProperty("Printing_error")+" : "+e.toString());
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Confirm dialog box that queries whether user wishes to save current document or not.

Returns:
true to save, false otherwise

Definition at line 136 of file FileOp.java.

                              {
       // show confirm dialog box from static JOptionPane method
       String filename = "Untitled";
       if (file != null)
           filename = file.getName();
       
       int choice =
           SharpOptionPane.showOptionDialog
           (sharp,
            "Do you want to save the changes you made to \""+filename+"\"?",
            "Save",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            saveIcon);
       // return user's choice
       return choice;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.saveAsFile ( ) [inline]

Menu and button wrapper that handles interactive process of saving current file.

Definition at line 230 of file FileOp.java.

                             {
       // open save dialog and save user input
       int choice = fileChooser.showSaveDialog(sharp);
       
       // if user clicks ok, then procede with save, otherwise do nothing
       if(choice == JFileChooser.APPROVE_OPTION) {
           // get selected file to save to
           File selectedfile = fileChooser.getSelectedFile();

           fileChooser = new JFileChooser(selectedfile.getParentFile());
           fileChooser.addChoosableFileFilter(filter);

           // enforce the extension name
           String path;

           try {
              path = selectedfile.getCanonicalPath();
           }
           catch (IOException e) {
              fileOpError(SharpTools.translation.getProperty("Save"), SharpTools.translation.getProperty("Unexpected_error"));
              return;
           }

           if (!path.endsWith(extname))
              selectedfile = new File(path+extname);

           // check the existence of the file
           if (selectedfile.exists()) {
              choice =
                  SharpOptionPane.showOptionDialog
                  (sharp,
                   SharpTools.translation.getProperty("File_already_exists")+"  ("+selectedfile.getName()+")\n\n"+SharpTools.translation.getProperty("Do_you_want_to_overwrite_it"),
                   SharpTools.translation.getProperty("Save"),
                   JOptionPane.YES_NO_OPTION,
                   JOptionPane.WARNING_MESSAGE,
                   saveIcon, 1);
              if (choice != JOptionPane.YES_OPTION)
                  return;
           }
           
           saveTableModel(selectedfile);
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.saveFile ( ) [inline]

Menu and button wrapper that handles interactive process of saving current file as itself.

Definition at line 214 of file FileOp.java.

                           {
       if(tableModel.isModified()) {
           //     if(file.getName().equals("Untitled")) {
           if (file == null) {
              saveAsFile();
           } else {
              saveTableModel();
           }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.saveTableModel ( File  aFile) [inline]

Saves table model to specified file cell by cell in tab-delimited format.

Parameters:
aFilethe file name to save to

Definition at line 349 of file FileOp.java.

                                           {

       try {
           
           // initialize output

           out = new PrintStream(new FileOutputStream(aFile));
           
           int rowCount = tableModel.getRowCount();
           int colCount = tableModel.getColumnCount();
           // print out number of columns and rows
           //     out.println(rowCount+"\t"+colCount);
           if (password != null && password.length() > 0)
              out.println("Password: "+password);
           
           out.print(tableModel.toString());
           out.flush();
           
           file = aFile;
           // set modified to false
           tableModel.setPasswordModified(false);
           tableModel.setModified(false);

           // update recent files
           addRecentFile(file);
           
           String title = file.getName();
           if (title.endsWith(extname))
              title = title.substring(0, title.length()-4);
           sharp.setTitle(title+"   "+SharpTools.translation.getProperty("Sharp_Tools_Spreadsheet"));
       } catch (FileNotFoundException e) {
           fileOpError(SharpTools.translation.getProperty("Save"), SharpTools.translation.getProperty("File_cannot_be_created")+"  : "+aFile.getName());
       } catch (IOException e) {
           fileOpError(SharpTools.translation.getProperty("Save"), SharpTools.translation.getProperty("IO_error_in_saving"+"  : "+aFile.getName()+" !"));
       }
    }

Here is the call graph for this function:

Overloaded save function that takes the current filename as default.

Definition at line 389 of file FileOp.java.

Here is the caller graph for this function:

void SharpTools.FileOp.setPassword ( ) [inline]

Set Password Dialog.

Definition at line 752 of file FileOp.java.

                              {
       PasswordDialog passwordDialog = new PasswordDialog(sharp, null);
       passwordDialog.setVisible(true);
       String text = passwordDialog.getValidatedText();
       if (text != null) {
           setPasswordValue(text);
           tableModel.setPasswordModified(true);
       }
       table.requestFocus();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.setPasswordValue ( String  newPassword) [inline, private]

Definition at line 546 of file FileOp.java.

                                                      {
       password = newPassword;
       sharp.checkPasswordState();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.FileOp.setRecentFile ( int  index,
String  s 
) [inline, private]

Set the file name in the recent list by index.

Parameters:
indexthe index in the list (also the menu)
sfile name

Definition at line 476 of file FileOp.java.

                                                    {
       Config config = SharpTools.getConfig();   
       config.set("RECENTFILE"+String.valueOf(index), s);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean SharpTools.FileOp.verifyPassword ( String  password) [inline, private]

Verify Password Dialog.

Definition at line 766 of file FileOp.java.

                                                    {

       PasswordDialog passwordDialog = new PasswordDialog(sharp, password);
       passwordDialog.pack();
       passwordDialog.setLocationRelativeTo(sharp);
       passwordDialog.setVisible(true);
       String text = passwordDialog.getValidatedText();
       table.requestFocus();
       return text != null;
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 38 of file FileOp.java.

final int SharpTools.FileOp.DATABASE = 2 [static, private]

Definition at line 33 of file FileOp.java.

final static String SharpTools.FileOp.extname = ".csv" [static, private]

Definition at line 59 of file FileOp.java.

final int SharpTools.FileOp.FILE = 1 [static, private]

Definition at line 32 of file FileOp.java.

File SharpTools.FileOp.file [private]

Definition at line 48 of file FileOp.java.

JFileChooser SharpTools.FileOp.fileChooser [private]

Definition at line 51 of file FileOp.java.

Definition at line 52 of file FileOp.java.

BufferedReader SharpTools.FileOp.in [private]

Definition at line 42 of file FileOp.java.

int SharpTools.FileOp.maxNumPage = 1 [private]

Definition at line 37 of file FileOp.java.

final ImageIcon SharpTools.FileOp.newIcon = new ImageIcon(getClass().getResource("/images/new32.gif")) [package]

Definition at line 53 of file FileOp.java.

final ImageIcon SharpTools.FileOp.openIcon = new ImageIcon(getClass().getResource("/images/open.gif")) [package]

Definition at line 54 of file FileOp.java.

Definition at line 35 of file FileOp.java.

PrintStream SharpTools.FileOp.out [private]

Definition at line 41 of file FileOp.java.

String SharpTools.FileOp.password [private]

Definition at line 49 of file FileOp.java.

final ImageIcon SharpTools.FileOp.saveIcon = new ImageIcon(getClass().getResource("/images/save32.gif")) [package]

Definition at line 55 of file FileOp.java.

Definition at line 44 of file FileOp.java.

JTable SharpTools.FileOp.table [private]

Definition at line 45 of file FileOp.java.

Definition at line 46 of file FileOp.java.

StringTokenizer SharpTools.FileOp.tokenizer [private]

Definition at line 40 of file FileOp.java.

final int SharpTools.FileOp.UNNAMED = 0 [static, private]

Definition at line 31 of file FileOp.java.


The documentation for this class was generated from the following file: