示例#1
0
  public BrowseService(
      final IPluginContext context, final IPluginConfig config, JcrNodeModel document) {

    document = findDocument(document);

    context.registerService(
        this, config.getString(IBrowseService.BROWSER_ID, BrowseService.class.getName()));
    context.registerService(this, IRefreshable.class.getName());

    documentService = new DocumentModelService(config, document);
    documentService.init(context);

    folderService = new FolderModelService(config, folder);
    folderService.init(context);
  }
示例#2
0
  public AbstractCmsEditor(
      IEditorContext editorContext,
      IPluginContext context,
      IPluginConfig parameters,
      IModel<T> model,
      Mode mode)
      throws EditorException {
    this.editorContext = editorContext;
    this.model = model;
    this.context = context;
    this.parameters = parameters;
    this.mode = mode;

    editorId = getClass().getName() + "." + (editorCount++);
    wicketId = parameters.getString(RenderService.WICKET_ID);
    JavaPluginConfig renderConfig = new JavaPluginConfig();
    renderConfig.put(RenderService.WICKET_ID, wicketId);
    renderConfig.put("editor", editorId);
    renderer = new EditorWrapper(context, renderConfig);
  }
示例#3
0
 FolderModelService(IPluginConfig config, JcrNodeModel document) {
   super(config.getString("model.folder"), document);
 }
示例#4
0
    public ServicingTestPlugin(IPluginContext context, IPluginConfig config) {
      super(context, config);

      context.registerService(new IClusterable() {}, config.getString("test.id"));
    }
示例#5
0
  protected MultiFileUploadDialog(IPluginContext pluginContext, IPluginConfig pluginConfig) {
    setOutputMarkupId(true);

    setMultiPart(true);
    setOkEnabled(false);
    setOkVisible(false);

    ajaxButton =
        new AjaxButton(DialogConstants.BUTTON, new Model<String>("Ok")) {

          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (widget.isFlashUpload()) {
              target.appendJavaScript(widget.getStartAjaxUploadScript());
            } else {
              handleSubmit();
              target.add(MultiFileUploadDialog.this);
            }
          }

          @Override
          protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            final List<IAjaxCallListener> ajaxCallListeners = attributes.getAjaxCallListeners();
            ajaxCallListeners.add(new EventStoppingDecorator());
            ajaxCallListeners.add(
                new AjaxCallListener() {

                  @Override
                  public CharSequence getBeforeHandler(final Component component) {
                    return "if (" + widget.hasFileSelectedScript() + ") { this.disabled = true; }";
                  }

                  @Override
                  public CharSequence getPrecondition(Component component) {
                    return widget.hasFileSelectedScript();
                  }

                  @Override
                  public CharSequence getSuccessHandler(Component component) {
                    return "if (Wicket.$('"
                        + getMarkupId()
                        + "') != null) { Wicket.$('"
                        + getMarkupId()
                        + "').disabled = true; }";
                  }

                  @Override
                  public CharSequence getFailureHandler(Component component) {
                    return "if (Wicket.$('"
                        + getMarkupId()
                        + "') != null) { Wicket.$('"
                        + getMarkupId()
                        + "').disabled = false; }";
                  }
                });
          }
        };
    ajaxButton.setEnabled(true);
    ajaxButton.setVisible(true);
    ajaxButton.add(new InputBehavior(new KeyType[] {KeyType.Enter}, EventType.click));
    addButton(ajaxButton);

    closeButton =
        new AjaxButton(DialogConstants.BUTTON, new Model<String>("Close")) {

          @Override
          protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            closeDialog();
          }
        };
    closeButton.setEnabled(false);
    closeButton.setVisible(false);
    closeButton.add(new InputBehavior(new KeyType[] {KeyType.Escape}, EventType.click));
    addButton(closeButton);

    String serviceId = pluginConfig.getString(FileUploadValidationService.VALIDATE_ID);
    FileUploadValidationService validator =
        pluginContext.getService(serviceId, FileUploadValidationService.class);

    FileUploadWidgetSettings settings = new FileUploadWidgetSettings(pluginConfig);
    widget =
        new FileUploadWidget("uploadWidget", settings, validator) {

          @Override
          protected void onFileUpload(FileUpload file) {
            try {
              MultiFileUploadDialog.this.handleUploadItem(file);
            } catch (FileUploadException e) {
              Throwable t = e.getCause();
              String message = t.getLocalizedMessage();
              if (t.getCause() != null) {
                message += "<br/>" + t.getCause();
                log.error("FileUploadException caught", t);
              }
              errors.add(message);
            }
          }

          @Override
          public void onFinishHtmlUpload() {
            super.onFinishHtmlUpload();
            handleErrors();

            if (hasFeedbackMessage() || MultiFileUploadDialog.this.hasFeedbackMessage()) {
              transformIntoErrorDialog(RequestCycle.get().find(AjaxRequestTarget.class));
            }
          }

          @Override
          protected void onFinishAjaxUpload(AjaxRequestTarget target) {
            super.onFinishAjaxUpload(target);
            handleErrors();

            if (hasFeedbackMessage() || MultiFileUploadDialog.this.hasFeedbackMessage()) {
              transformIntoErrorDialog(target);
            } else {
              MultiFileUploadDialog.super.handleSubmit();
            }
            target.appendJavaScript(widget.getAjaxIndicatorStopScript());
          }
        };
    add(widget);

    // The feedbackPanel of the AbstractDialog does not render messages when using the flashUpload.
    // To work around
    // this use a local feedbackPanel in the case of a flash upload.
    Panel fp =
        new FeedbackPanel("feedbackPanel") {
          @Override
          public boolean isEnabled() {
            return widget.isFlashUpload();
          }

          @Override
          public boolean isVisible() {
            return widget.isFlashUpload();
          }
        };
    fp.setEscapeModelStrings(false);
    fp.add(new AttributeAppender("class", true, new Model<String>("hippo-modal-feedback"), " "));
    fp.add(new AttributeAppender("class", true, new Model<String>("upload-feedback-panel"), " "));
    add(fp);
  }