public void doReload(ContentNode node, ContentVersion updated) throws Exception { if (updated .getMod() .equals(getInfoglueEditorInput().getContent().getContentVersion().getMod())) { System.out.println("This version seem to be up to date."); return; } if (!isDirty() || MessageDialog.openQuestion( PlatformUI.getWorkbench().getDisplay().getActiveShell(), "CMS Message", "The content " + getInfoglueEditorInput().getContent().getName() + " was changed remotely by user: "******". Do you want to reload the changed content?")) { // Only save the editors to remove dirty flag, not the editorinput (sent to cms) // TODO: ?????? for (int i = 0; i < getPageCount(); i++) { getEditor(i).doSave(null); } IFolder tmp = ProjectHelper.getProject(node).getFolder("WebContent"); setInput(InfoglueCMS.openContentVersion(node)); } else if (isDirty()) { MessageDialog.openInformation( this.getActiveEditor().getSite().getShell(), "Unhandled situation", "The content was updated on the server, the local version is not the latest and synchronization/update feature is still not implemented. Your changes might not get saved to CMS"); } }
/* * @see org.infoglue.igide.helper.NotificationListener#recieveNotification(org.infoglue.igide.cms.NotificationMessage) */ public void recieveCMSNotification(NotificationMessage message) { ContentVersion version = getInfoglueEditorInput().getContent().getContentVersion(); ContentNode node = getInfoglueEditorInput().getContent().getNode(); Integer activeVersion = version.getId(); /* * ContentVersion updates, someone has saved the same version. */ if (!saving && message.getClassName().indexOf("ContentVersionImpl") > -1) { try { Integer objectId = new Integer((String) message.getObjectId()); if (objectId.equals(activeVersion)) { synchronized (getInfoglueEditorInput().getContent().getContentVersion()) { ContentVersion updated = getProxy().fetchContentVersionHead(version.getId()); doReload(node, updated); } } } catch (Exception e) { e.printStackTrace(); } } /* * Content updates, some has changed the content. Maybe published??, or deleted version * I think the reload responsibility maybe belong in class ViewContentProvider. Just make * a note in the log here for now... */ if (message.getClassName().indexOf("ContentImpl") > -1) { System.out.println("Editor: contentChange:" + message); try { Integer objectId = new Integer((String) message.getObjectId()); Integer oldState = node.getActiveVersionStateId(); if (objectId.equals(node.getId())) { System.out.println("Its this content"); Content content = getProxy().fetchContent(node.getId()); if (!content.getActiveVersion().equals(node.getActiveVersion())) { // ContentVersion updated = // getProxy().fetchContentVersionHead(content.getActiveVersion()); if (!oldState.equals(content.getActiveVersionStateId())) { System.out.println( "This version is not active any more, the new version has state: " + content.getActiveVersionStateId() + " and it was modified by " + content.getActiveVersionModifier()); } } } } catch (Exception e) { e.printStackTrace(); } } }