public void close() { try { editor.close(); } catch (EditorException ex) { log.error(ex.getMessage()); } } }, editor.isValid(), (JcrNodeModel) editor.getModel(), editor.getMode());
/** * Closes the tab if it is unmodified and the editor is not in Edit mode. * * @param tab The tab to close * @param target AjaxRequestTarget */ void onCloseUnmodified(Tab tab, AjaxRequestTarget target) { final IEditor editor = tab.getEditor(); try { if (editor != null && !editor.getMode().equals(IEditor.Mode.EDIT)) { editor.close(); } } catch (EditorException e) { log.warn("Unable to save the document in the editor", e); throw new RuntimeException("Unable to save the document in the editor", e); } }
void closeEditor() { IEditor editor = getPluginContext().getService(getPluginConfig().getString("editor.id"), IEditor.class); try { editor.close(); } catch (EditorException e) { log.error("Could not close editor", e); } }
@Override protected void onSubmit(AjaxRequestTarget target, Form form) { final Consumer<Tab> saveAndClose = currentTab -> { final IEditor editor = currentTab.getEditor(); if (editor != null){ try { if (editor.isModified()) { editor.done(); //save the document and switch to VIEW mode } editor.close(); } catch (EditorException e) { log.error("Unable to save the document {}", e.getMessage()); } } }; processAllTabs(saveAndClose); updateDialog(target); } });
@Override protected void onSubmit(AjaxRequestTarget target, Form form) { final Consumer<Tab> discardAndClose = currentTab -> { final IEditor editor = currentTab.getEditor(); if (editor != null) { try { if (editor.isModified()) { editor.discard(); ///discard the document and switch to VIEW mode } editor.close(); } catch (EditorException e) { log.error("Unable to discard/close the document {}", e.getMessage()); } } }; processAllTabs(discardAndClose); updateDialog(target); } });
private boolean closeDocumentEditor(final String documentHandleUuid) { final IEditorManager editorManager = context.getService(editorManagerServiceId, IEditorManager.class); try { final Node documentHandle = UserSession.get().getJcrSession().getNodeByIdentifier(documentHandleUuid); final JcrNodeModel documentHandleModel = new JcrNodeModel(documentHandle); final IEditor<?> editor = editorManager.getEditor(documentHandleModel); if (editor == null) { return true; } if (editor.isValid()) { editor.close(); return true; } } catch (ItemNotFoundException e) { ChannelEditor.log.warn("Could not find document with uuid '{}'", documentHandleUuid, e); return true; } catch (EditorException | RepositoryException e) { ChannelEditor.log.warn("Failed to close editor for document with uuid '{}'", documentHandleUuid, e); } return false; }
editor.close(); return null;
editor.discard(); editor.close();
editor.close(); return null;