Changeset 529

Show
Ignore:
Timestamp:
01/21/10 00:03:11 (3 years ago)
Author:
joerg
Message:

saving new files

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/JLatexEditorJFrame.java

    r505 r529  
    2222import util.updater.ProgramUpdater; 
    2323 
     24import javax.annotation.Resource; 
    2425import javax.swing.*; 
    2526import javax.swing.event.ChangeEvent; 
    2627import javax.swing.event.ChangeListener; 
     28import javax.swing.plaf.basic.BasicTabbedPaneUI; 
    2729import java.awt.*; 
    2830import java.awt.event.*; 
     
    477479    if (resource instanceof UntitledDoc) { 
    478480      UntitledDoc untitledDoc = (UntitledDoc) resource; 
    479       // TODO call save file dialog to assign a file to this new document 
    480       JOptionPane.showMessageDialog(this, "Saving new files not implemented yet."); 
    481       return false; 
     481 
     482      openDialog.showDialog(this, "Save"); 
     483      file = openDialog.getSelectedFile(); 
     484      if(file == null) return false; 
     485 
     486      if(file.exists()) { 
     487        int choice = JOptionPane.showOptionDialog( 
     488                this, 
     489                "The file exists! Do you want to overwrite the file?", 
     490                "File Exists", 
     491                JOptionPane.WARNING_MESSAGE, 
     492                JOptionPane.YES_NO_OPTION, 
     493                null, 
     494                new Object[] {"Overwrite", "Cancel"}, 
     495                2 
     496        ); 
     497        if(choice == 1) return false; 
     498      } 
     499 
     500      TabLabel tabLabel = (TabLabel) tabbedPane.getTabComponentAt(getTab(resource)); 
     501      resource = new FileDoc(file); 
     502      tabLabel.setResource(resource); 
     503      editor.setResource(resource); 
    482504    } else 
    483505    if (resource instanceof FileDoc) { 
     
    884906    } 
    885907 
     908    public AbstractResource getResource() { 
     909      return resource; 
     910    } 
     911 
     912    public void setResource(AbstractResource resource) { 
     913      this.resource = resource; 
     914      label.setText(resource.getName()); 
     915    } 
     916 
    886917    public boolean contains(int x, int y) { 
    887918      return x >= -4 && x <= getWidth() + 4 && y >= -2 && y <= getHeight() + 2;