Changeset 132 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder


Ignore:
Timestamp:
10/23/2017 02:47:32 PM (9 years ago)
Author:
bmcguffin
Message:

Name of current working file is now visible in the title bar of the main window. If the user is working on a new file, "untitled1.xml" is displayed.

Default save file name for new files is "untitled1.xml". If the user names a file such that it doesn't end in .xml, the ".xml" suffix is added automatically.

Location:
trunk/src/scriptbuilder/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/IncidentPaletteFrame.java

    r128 r132  
    126126    private ArrayList<ScriptIncident> loadIncidentsFromFiles(String directoryName) 
    127127    { 
    128  
     128        String fs = System.getProperty("file.separator"); 
    129129        ArrayList<ScriptIncident> newList = new ArrayList<ScriptIncident>(); 
    130         File folder = new File(directoryName); 
     130        File folder = new File(""+System.getProperty("user.dir")+fs+directoryName); 
    131131 
    132132        File[] incidentFiles; 
  • trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java

    r129 r132  
    162162         */ 
    163163        // Set listener for scroll pane 
     164        String t = "Script Builder: "; 
     165        if (script.saveFile == null) 
     166        { 
     167            t += "untitled1.xml"; 
     168        } 
     169        else 
     170        { 
     171            t += script.saveFile.getName(); 
     172        } 
     173        this.setTitle(t); 
    164174        AdjustmentListener listener = new MyAdjustmentListener(); 
    165175        timelinesScrollPane.getHorizontalScrollBar().addAdjustmentListener(listener); 
    166176        timelinesScrollPane.getVerticalScrollBar().addAdjustmentListener(listener); 
    167177        repaint(); 
     178 
    168179    } 
    169180 
     
    260271                / Math.max(script.absoluteLength(), ScriptBuilderGuiConstants.TICK_TIMELINE_SMALLEST_LENGTH)); 
    261272        zoomSlider.setMaximum(zoomSlider.getMinimum() + 20); 
     273        String t = "Script Builder: "; 
     274        if (script.saveFile == null) 
     275        { 
     276            t += "untitled1.xml"; 
     277        } 
     278        else 
     279        { 
     280            t += script.saveFile.getName(); 
     281        } 
     282        this.setTitle(t); 
    262283        repaint(); 
    263284    } 
     
    17001721    private void fileSaveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSaveAsActionPerformed 
    17011722        JFileChooser fc = new JFileChooser(); 
    1702  
     1723        boolean wasNull = false; 
     1724        if (script.saveFile == null) 
     1725        { 
     1726            wasNull = true; 
     1727            String fName = "untitled"; 
     1728            int untitledCount = 1; 
     1729            while (new File("" + fName + untitledCount + ".xml").exists()) 
     1730            { 
     1731                untitledCount++; 
     1732            } 
     1733            script.saveFile = new File("" + fName + untitledCount + ".xml"); 
     1734        } 
     1735 
     1736        fc.setSelectedFile(script.saveFile); 
    17031737        fc.setFileFilter(new ExtensionFileFilter("Simulation Script XML (.xml)", 
    17041738                new String[] 
     
    17091743        if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) 
    17101744        { 
    1711             script.saveScriptToFile(fc.getSelectedFile()); 
    1712             script.saveFile = fc.getSelectedFile(); 
    1713         } 
     1745            String filename = fc.getSelectedFile().toString(); 
     1746            if (!filename.endsWith(".xml")) 
     1747            { 
     1748                filename += ".xml"; 
     1749 
     1750            } 
     1751            script.saveScriptToFile(new File(filename)); 
     1752            script.saveFile = new File(filename); 
     1753        } 
     1754        else 
     1755        { 
     1756            if (wasNull) 
     1757            { 
     1758                script.saveFile = null; 
     1759            } 
     1760        } 
     1761        this.update(script, 0); 
    17141762    }//GEN-LAST:event_fileSaveAsActionPerformed 
    17151763 
     
    18851933        } 
    18861934 
     1935        String fs = System.getProperty("file.separator"); 
    18871936        //Pick the file to save it to 
    18881937        JFileChooser fc = new JFileChooser(); 
     1938        fc.setSelectedFile(new File("" + System.getProperty("user.dir") + fs + "Incidents" + fs + "inc_" + inc.number + ".xml")); 
    18891939        fc.setFileFilter(new ExtensionFileFilter("Script Incident (.xml)", new String[] 
    18901940        { 
     
    18931943        if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) 
    18941944        { 
    1895             inc.saveIncidentToFile(fc.getSelectedFile()); 
     1945            String filename = fc.getSelectedFile().toString(); 
     1946            if (!filename.endsWith(".xml")) 
     1947            { 
     1948                filename += ".xml"; 
     1949 
     1950            } 
     1951            inc.saveIncidentToFile(new File(filename)); 
    18961952        } 
    18971953    }//GEN-LAST:event_saveIncidentActionPerformed 
Note: See TracChangeset for help on using the changeset viewer.