Saves the displayed text.
()
| 224 | * Saves the displayed text. |
| 225 | */ |
| 226 | private void save() { |
| 227 | final BaseXFileChooser fc = new BaseXFileChooser(gui, |
| 228 | SAVE_AS, gui.gopts.get(GUIOptions.WORKPATH)).suffix(IO.XMLSUFFIX); |
| 229 | |
| 230 | final IOFile file = fc.select(Mode.FSAVE); |
| 231 | if(file == null) return; |
| 232 | gui.gopts.setFile(GUIOptions.WORKPATH, file.parent()); |
| 233 | |
| 234 | gui.cursor(CURSORWAIT, true); |
| 235 | try(PrintOutput out = new PrintOutput(file)) { |
| 236 | final Context context = gui.context; |
| 237 | if(cachedCmd != null) { |
| 238 | cachedCmd.execute(context, out); |
| 239 | } else if(cachedNodes != null) { |
| 240 | cachedNodes.serialize(Serializer.get(out, context.options.get(MainOptions.SERIALIZER))); |
| 241 | } else { |
| 242 | out.write(text.getText()); |
| 243 | } |
| 244 | } catch(final IOException ex) { |
| 245 | Util.debug(ex); |
| 246 | BaseXDialog.error(gui, Util.info(FILE_NOT_SAVED_X, file)); |
| 247 | } finally { |
| 248 | gui.cursor(CURSORARROW, true); |
| 249 | } |
| 250 | } |
| 251 | } |