public void onEvent(Iterator<? extends IEvent<IModelReference<Node>>> event) { if (!active) { active = true; try { IModel<Node> nodeModel = getEditorModel(modelReference.getModel()); if (nodeModel != null && nodeModel.getObject() != null) { IEditor<Node> editor = editorMgr.getEditor(nodeModel); if (editor == null) { editor = editorMgr.openPreview(nodeModel); } editor.focus(); } } catch (ServiceException ex) { log.error("could not open preview", ex); } catch (RepositoryException ex) { log.error("could not open preview", ex); } finally { active = false; } } }
@Override public void onSelect(IModel model) { Revision revision = (Revision) model.getObject(); IModel<Node> docModel = revision.getDocument(); IEditor editor = editorMgr.getEditor(docModel); if (editor == null) { try { editorMgr.openPreview(docModel); } catch (ServiceException ex) { log.error("Could not open editor for " + docModel, ex); error("Could not open editor"); return; // don't close dialog } } else { editor.focus(); } closeDialog(); } });
protected IEditor<Node> createEditor(final IModel<Node> model, IEditor.Mode mode) throws ServiceException { try { IEditor<Node> editor = editorFactory.newEditor(new IEditorContext() { public IEditorManager getEditorManager() { return EditorManagerPlugin.this; } public void onClose() { EditorManagerPlugin.this.onClose(model); } public void onFocus() { EditorManagerPlugin.this.onFocus(model); } }, model, mode, getPluginConfig().getPluginConfig("cluster.options")); editors.add(editor); editor.focus(); focusBrowser(model); return editor; } catch (EditorException ex) { log.error(ex.getMessage()); throw new ServiceException("Initialization failed", ex); } }
private void openDocumentEditor(final String documentHandleUuid, final IEditor.Mode mode) { final IEditorManager editorManager = context.getService(editorManagerServiceId, IEditorManager.class); try { final Node documentHandle = UserSession.get().getJcrSession().getNodeByIdentifier(documentHandleUuid); final JcrNodeModel documentHandleModel = new JcrNodeModel(documentHandle); IEditor<?> editor = editorManager.getEditor(documentHandleModel); if (editor == null) { editor = editorManager.openEditor(documentHandleModel); } if (mode == IEditor.Mode.EDIT && editor.getMode() != IEditor.Mode.EDIT) { editor.setMode(mode); } editor.focus(); } catch (ItemNotFoundException e) { ChannelEditor.log.warn("Could not find document with uuid '{}'", documentHandleUuid, e); } catch (EditorException|RepositoryException|ServiceException e) { ChannelEditor.log.warn("Failed to open editor in '{}' mode for document with uuid '{}'", mode, documentHandleUuid, e); } } }