Beispiel #1
0
 @Override
 public boolean accept(Map<String, Object> context) throws Exception {
   UIWikiPortlet wikiPortlet = (UIWikiPortlet) context.get(UIWikiPortlet.class.getName());
   UIWikiPageArea wikiPageArea = wikiPortlet.findFirstComponentOfType(UIWikiPageArea.class);
   UIWikiPageEditForm wikiPageEditForm =
       wikiPageArea.findFirstComponentOfType(UIWikiPageEditForm.class);
   UIWikiRichTextArea wikiRichTextArea =
       wikiPageEditForm.findFirstComponentOfType(UIWikiRichTextArea.class);
   return !wikiRichTextArea.isRendered();
 }
 @Override
 protected void processEvent(Event<PreviewPageActionComponent> event) throws Exception {
   UIWikiPortlet wikiPortlet = event.getSource().getAncestorOfType(UIWikiPortlet.class);
   WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
   ResourceBundle res = context.getApplicationResourceBundle();
   UIWikiMaskWorkspace uiMaskWS = wikiPortlet.getChild(UIWikiMaskWorkspace.class);
   UIWikiPageEditForm wikiPageEditForm =
       event.getSource().getAncestorOfType(UIWikiPageEditForm.class);
   UIWikiPagePreview wikiPagePreview =
       uiMaskWS.createUIComponent(UIWikiPagePreview.class, null, null);
   UIWikiRichTextArea wikiRichTextArea = wikiPageEditForm.getChild(UIWikiRichTextArea.class);
   UIWikiPageTitleControlArea wikiPageTitleArea =
       wikiPageEditForm.getChild(UIWikiPageTitleControlArea.class);
   String markupSyntax = Utils.getDefaultSyntax();
   boolean isRichTextRendered = wikiRichTextArea.isRendered();
   RenderingService renderingService =
       (RenderingService) PortalContainer.getComponent(RenderingService.class);
   String markup;
   if (isRichTextRendered) {
     String htmlContent = wikiRichTextArea.getUIFormTextAreaInput().getValue();
     markup =
         renderingService.render(
             htmlContent, Syntax.XHTML_1_0.toIdString(), markupSyntax, false);
     Utils.feedDataForWYSIWYGEditor(wikiPageEditForm, markup);
   } else {
     UIFormTextAreaInput markupInput =
         wikiPageEditForm.findComponentById(UIWikiPageEditForm.FIELD_CONTENT);
     markup = (markupInput.getValue() == null) ? "" : markupInput.getValue();
   }
   wikiPagePreview.renderWikiMarkup(markup, markupSyntax);
   String pageTitle = wikiPageTitleArea.getTitle();
   if (pageTitle != null) wikiPagePreview.setPageTitle(wikiPageTitleArea.getTitle());
   else {
     wikiPagePreview.setPageTitle(res.getString("UIWikiPageTitleControlArea.label.Untitled"));
   }
   uiMaskWS.setUIComponent(wikiPagePreview);
   uiMaskWS.setShow(true);
   uiMaskWS.setPopupTitle(res.getString("UIEditorTabs.action.PreviewPage"));
   event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWS);
   super.processEvent(event);
 }
 public void execute(Event<UISyntaxSettingForm> event) throws Exception {
   UIWikiPortlet wikiPortlet = event.getSource().getAncestorOfType(UIWikiPortlet.class);
   UIWikiSyntaxPreferences uiSyntaxPreferences =
       wikiPortlet.findComponentById(PREFERENCES_SYNTAX);
   UIFormSelectBox defaultSyntaxSelect =
       uiSyntaxPreferences.getChildById(UIWikiSyntaxPreferences.FIELD_SYNTAX);
   UIFormCheckBoxInput<Boolean> allowCheckBox =
       uiSyntaxPreferences.getChildById(UIWikiSyntaxPreferences.FIELD_ALLOW);
   WikiPreferences preferences = Utils.getCurrentPreferences();
   WikiPreferencesSyntax preferencesSyntax = preferences.getWikiPreferencesSyntax();
   preferencesSyntax.setAllowMultipleSyntaxes(allowCheckBox.isChecked());
   preferencesSyntax.setDefaultSyntax(defaultSyntaxSelect.getValue());
   event
       .getRequestContext()
       .getUIApplication()
       .addMessage(
           new ApplicationMessage(
               "UISyntaxSettingForm.msg.Save-syntax-setting-success",
               null,
               ApplicationMessage.INFO));
 }