MCPcopy Index your code
hub / github.com/processing/processing / autoSave

Method autoSave

java/src/processing/mode/java/JavaEditor.java:1863–1940  ·  view source on GitHub ↗

Displays a JDialog prompting the user to save when the user hits run/present/etc.

()

Source from the content-addressed store, hash-verified

1861 * run/present/etc.
1862 */
1863 protected void autoSave() {
1864 if (!JavaMode.autoSaveEnabled) {
1865 return;
1866 }
1867
1868 try {
1869 if (sketch.isModified() && !sketch.isUntitled()) {
1870 if (JavaMode.autoSavePromptEnabled) {
1871 final JDialog autoSaveDialog =
1872 new JDialog(base.getActiveEditor(), getSketch().getName(), true);
1873 Container container = autoSaveDialog.getContentPane();
1874
1875 JPanel panelMain = new JPanel();
1876 panelMain.setBorder(BorderFactory.createEmptyBorder(4, 0, 2, 2));
1877 panelMain.setLayout(new BoxLayout(panelMain, BoxLayout.PAGE_AXIS));
1878
1879 JPanel panelLabel = new JPanel(new FlowLayout(FlowLayout.LEFT));
1880 JLabel label = new JLabel("<html><body>&nbsp;There are unsaved"
1881 + " changes in your sketch.<br />"
1882 + "&nbsp;&nbsp;&nbsp; Do you want to save it before"
1883 + " running? </body></html>");
1884 label.setFont(new Font(label.getFont().getName(),
1885 Font.PLAIN, label.getFont().getSize() + 1));
1886 panelLabel.add(label);
1887 panelMain.add(panelLabel);
1888 final JCheckBox dontRedisplay = new JCheckBox("Remember this decision");
1889 JPanel panelButtons = new JPanel(new FlowLayout(FlowLayout.CENTER, 8, 2));
1890
1891 JButton btnRunSave = new JButton("Save and Run");
1892 btnRunSave.addActionListener(new ActionListener() {
1893 @Override
1894 public void actionPerformed(ActionEvent e) {
1895 handleSave(true);
1896 if (dontRedisplay.isSelected()) {
1897 JavaMode.autoSavePromptEnabled = !dontRedisplay.isSelected();
1898 JavaMode.defaultAutoSaveEnabled = true;
1899 jmode.savePreferences();
1900 }
1901 autoSaveDialog.dispose();
1902 }
1903 });
1904 panelButtons.add(btnRunSave);
1905
1906 JButton btnRunNoSave = new JButton("Run, Don't Save");
1907 btnRunNoSave.addActionListener(new ActionListener() {
1908 @Override
1909 public void actionPerformed(ActionEvent e) {
1910 if (dontRedisplay.isSelected()) {
1911 JavaMode.autoSavePromptEnabled = !dontRedisplay.isSelected();
1912 JavaMode.defaultAutoSaveEnabled = false;
1913 jmode.savePreferences();
1914 }
1915 autoSaveDialog.dispose();
1916 }
1917 });
1918 panelButtons.add(btnRunNoSave);
1919 panelMain.add(panelButtons);
1920

Callers 2

handleTweakMethod · 0.95
prepareRunMethod · 0.95

Calls 14

handleSaveMethod · 0.95
statusErrorMethod · 0.95
isUntitledMethod · 0.80
getActiveEditorMethod · 0.80
getSketchMethod · 0.80
setBorderMethod · 0.80
getSizeMethod · 0.80
setResizableMethod · 0.65
setVisibleMethod · 0.65
isModifiedMethod · 0.45
getNameMethod · 0.45
setLayoutMethod · 0.45

Tested by

no test coverage detected