コード例 #1
0
  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");
    }
  }
コード例 #2
0
  /** Saves the multi-page editor's document. */
  public void doSave(IProgressMonitor monitor) {
    saving = true;
    boolean dirtyflag = isDirty();
    /*
     * Save all editors
     */
    Utils.getMonitor(monitor).beginTask("Saving content to CMS", 100);

    for (int i = 0; i < getPageCount(); i++) {
      getEditor(i).doSave(monitor);
    }
    Utils.getMonitor(monitor).worked(25);
    InfoglueEditorInput input = getInfoglueEditorInput();
    input.getContent().doSave(monitor);

    try {
      InfoglueCMS.saveContentVersion(
          input.getContent().getContentVersion(), input.getContent().getConnection(), monitor);
    } catch (ConcurrentModificationException e) {
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "The content was updated on the server, the local version is not the latest and synchronization/update feature is still not implemented. Please close the editor and open it again to get the latest version");
    } catch (IllegalStateException e) {
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "The content is not in a working state, automatic working change is not yet implemented, sorry");
    } catch (InvalidVersionException e) {
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "The content you are trying to save is not the active version at the server. Someone has create a new active version, sorry");
    } catch (Exception e) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.printStackTrace(pw);
      // TODO: display the stacktrace in the details.
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "We recieved the following from the server: " + e.getMessage() + "\n\n" + sw.toString());
    }

    Utils.getMonitor(monitor).worked(100);
    Utils.getMonitor(monitor).done();

    saving = false;
  }