(List<List<Handle>> handles)
| 1839 | |
| 1840 | |
| 1841 | protected void stopTweakMode(List<List<Handle>> handles) { |
| 1842 | tweakClient.shutdown(); |
| 1843 | getJavaTextArea().stopTweakMode(); |
| 1844 | |
| 1845 | // remove space from the code (before and after) |
| 1846 | //removeSpacesFromCode(); |
| 1847 | |
| 1848 | // check which tabs were modified |
| 1849 | boolean[] tweakedTabs = getTweakedTabs(handles); |
| 1850 | boolean modified = anythingTrue(tweakedTabs); |
| 1851 | |
| 1852 | if (modified) { |
| 1853 | // ask to keep the values |
| 1854 | if (Messages.showYesNoQuestion(this, Language.text("tweak_mode"), |
| 1855 | Language.text("tweak_mode.keep_changes.line1"), |
| 1856 | Language.text("tweak_mode.keep_changes.line2")) == JOptionPane.YES_OPTION) { |
| 1857 | for (int i = 0; i < sketch.getCodeCount(); i++) { |
| 1858 | if (tweakedTabs[i]) { |
| 1859 | sketch.getCode(i).setModified(true); |
| 1860 | |
| 1861 | } else { |
| 1862 | // load the saved code of tabs that didn't change |
| 1863 | // (there might be formatting changes that should not be saved) |
| 1864 | sketch.getCode(i).setProgram(sketch.getCode(i).getSavedProgram()); |
| 1865 | /* Wild Hack: set document to null so the text editor will refresh |
| 1866 | the program contents when the document tab is being clicked */ |
| 1867 | sketch.getCode(i).setDocument(null); |
| 1868 | |
| 1869 | if (i == sketch.getCurrentCodeIndex()) { |
| 1870 | // this will update the current code |
| 1871 | setCode(sketch.getCurrentCode()); |
| 1872 | } |
| 1873 | } |
| 1874 | } |
| 1875 | |
| 1876 | // save the sketch |
| 1877 | try { |
| 1878 | sketch.save(); |
| 1879 | } catch (IOException e) { |
| 1880 | Messages.showWarning("Error", "Could not save the modified sketch.", e); |
| 1881 | } |
| 1882 | |
| 1883 | // repaint the editor header (show the modified tabs) |
| 1884 | header.repaint(); |
| 1885 | textarea.invalidate(); |
| 1886 | |
| 1887 | } else { // no or canceled = don't keep changes |
| 1888 | loadSavedCode(); |
| 1889 | // update the painter to draw the saved (old) code |
| 1890 | textarea.invalidate(); |
| 1891 | } |
| 1892 | } else { |
| 1893 | // number values were not modified, but we need to load |
| 1894 | // the saved code because of some formatting changes |
| 1895 | loadSavedCode(); |
| 1896 | textarea.invalidate(); |
| 1897 | } |
| 1898 | } |
no test coverage detected