org.apache.wicket.markup.MarkupStream Java Examples

The following examples show how to use org.apache.wicket.markup.MarkupStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectLayersPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Override
protected void populateItem(final ListItem<AnnotationLayer> item)
{
    item.add(new SelectOption<AnnotationLayer>("layer",
            new Model<>(item.getModelObject()))
    {
        private static final long serialVersionUID = 3095089418860168215L;

        @Override
        public void onComponentTagBody(MarkupStream markupStream,
                ComponentTag openTag)
        {
            replaceComponentTagBody(markupStream, openTag,
                    item.getModelObject().getUiName());
        }
    }.add(new AttributeModifier("style",
            "color:" + colors.get(item.getModelObject()) + ";")));
}
 
Example #2
Source File: ODateLabel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
    Date date = (Date) getDefaultModelObject();
    String formattedDate = "";
    if (date != null) {
    	if(convertTimeZone) {
         ZoneId zoneId = OrienteerWebSession.get().getClientZoneId();
         ZonedDateTime zonedDateTime = date.toInstant().atZone(zoneId);
         formattedDate = zonedDateTime.format(getFormatter(zoneId));
    	} else {
    		formattedDate = getFormatter(null).format(date.toInstant());
    	}
    }
    replaceComponentTagBody(markupStream, openTag, formattedDate);
}
 
Example #3
Source File: UploadIFrame.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public UploadIFrame(FieldValueModel fieldValueModel) {
  this.fieldValueModel = fieldValueModel;

  // add header contributor for stylesheet
  add(CSSPackageResource.getHeaderContribution(getStylesheet()));
  
  WebMarkupContainer container = new WebMarkupContainer("container");
  container.setOutputMarkupId(true);
  add(container);
  // add form
  container.add(new UploadForm("form", container));
  // add onUploaded method
  container.add(new WebComponent("onUploaded") {
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      if (uploaded) {
        replaceComponentTagBody(markupStream, openTag,
            "window.parent." + getOnUploadedCallback() + "('', '')");
        uploaded = false;
      }
    }            
  });
}
 
Example #4
Source File: UploadPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public UploadPanel(String id, FieldInstanceImageField parentField) {
  super(id);
  this.parentField = parentField;

  // add onUploaded behavior
  final OnUploadedBehavior onUploadBehavior = new OnUploadedBehavior();
  add(onUploadBehavior);
  add(new WebComponent("onUploaded") {
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      // calling it through setTimeout we ensure that the callback is called
      // in the proper execution context, that is the parent frame
      replaceComponentTagBody(markupStream, openTag,
          "function onUpload_" + UploadPanel.this.getMarkupId() +
          "(uploadedFile, clientFileName) {  window.setTimeout(function() { " + // window.location.reload(true); " +
          onUploadBehavior.getCallback() + "; }, 0 )}");
      } 
  });        
}
 
Example #5
Source File: VizigatorLinkFunctionBoxPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
@Override
protected Component getLink(String id) {
  PageParameters pageParameters = new PageParameters();
  pageParameters.put("topicMapId", getTopicMapId());
  pageParameters.put("topicId", getTopicId());
  
  return new BookmarkablePageLink<Page>(id, VizigatorPage.class, pageParameters) {
    @Override
    protected void onComponentTag(ComponentTag tag) {
      tag.setName("a");
      //tag.put("target", "_blank");
      super.onComponentTag(tag);
    }
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      replaceComponentTagBody(markupStream, openTag, new ResourceModel("vizigator.text2").getObject().toString());
    }
  };
}
 
Example #6
Source File: OAuth2ProviderVisualizer.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <V> Component createComponent(String id,
                                     DisplayMode mode,
                                     IModel<ODocument> documentModel,
                                     IModel<OProperty> propertyModel,
                                     IModel<V> valueModel) {
    if (mode == DisplayMode.EDIT) {
        return new Select2Choice<>(id, (IModel<String>) valueModel, createProvider());
    }

    return new Label(id, valueModel) {
        @Override
        public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            String name = (String) getDefaultModelObject();
            IOAuth2Provider provider = getProviderByName(name);
            String label = createProviderLabelModel(provider).getObject();
            replaceComponentTagBody(markupStream, openTag, label);
        }
    };
}
 
Example #7
Source File: DerAttrs.java    From syncope with Apache License 2.0 5 votes vote down vote up
public DerSchemas(
        final String id,
        final Map<String, DerSchemaTO> schemas,
        final IModel<List<Attr>> attrTOs) {
    super(id);

    add(new ListView<Attr>("schemas", attrTOs) {

        private static final long serialVersionUID = 9101744072914090143L;

        @Override
        public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
            super.onComponentTagBody(markupStream, openTag);
            openTag.put("class", "empty");
        }

        @Override
        protected void populateItem(final ListItem<Attr> item) {
            Attr attrTO = item.getModelObject();

            IModel<String> model;
            List<String> values = attrTO.getValues();
            if (values == null || values.isEmpty()) {
                model = new ResourceModel("derived.emptyvalue.message", StringUtils.EMPTY);
            } else {
                model = new Model<>(values.get(0));
            }

            AjaxTextFieldPanel panel = new AjaxTextFieldPanel(
                    "panel",
                    schemas.get(attrTO.getSchema()).getLabel(SyncopeConsoleSession.get().getLocale()),
                    model,
                    false);
            panel.setEnabled(false);
            panel.setRequired(true);
            panel.setOutputMarkupId(true);
            item.add(panel);
        }
    });
}
 
Example #8
Source File: OmTextLabel.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	final String vis = openTag.getAttribute(markupStream.getWicketNamespace() + WICKET_VISIBLE);
	if (vis != null && Boolean.FALSE.equals(Boolean.valueOf(vis))) {
		//skip the body
		return;
	}
	super.onComponentTagBody(markupStream, openTag);
}
 
Example #9
Source File: DateLabel.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
	Object o = getDefaultModelObject();
	String s = getDefaultModelObjectAsString();
	if (o == null) {
		// no-op
	} else if (o instanceof Date || o.getClass().isAssignableFrom(Date.class)) {
		s = fmt.format((Date)o);
	} else if (o instanceof Calendar || o.getClass().isAssignableFrom(Calendar.class)) {
		s = fmt.format((Calendar)o);
	}
	replaceComponentTagBody(markupStream, openTag, s);
}
 
Example #10
Source File: AdvancedFormComponentLabel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	super.onComponentTagBody(markupStream, openTag);

	FormComponent<?> fc = getFormComponent();
	if (fc.isRequired()) {
		fc.getResponse().write(new ResourceModel("required.indicator").getObject().toString());
	}			
}
 
Example #11
Source File: DerAttrs.java    From syncope with Apache License 2.0 5 votes vote down vote up
public DerSchemas(
        final String id,
        final Map<String, DerSchemaTO> schemas,
        final IModel<List<Attr>> attrTOs) {
    super(id);

    add(new ListView<Attr>("schemas", attrTOs) {

        private static final long serialVersionUID = 9101744072914090143L;

        @Override
        public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
            super.onComponentTagBody(markupStream, openTag);
            openTag.put("class", "empty");
        }

        @Override
        protected void populateItem(final ListItem<Attr> item) {
            Attr attrTO = item.getModelObject();

            IModel<String> model;
            List<String> values = attrTO.getValues();
            if (values == null || values.isEmpty()) {
                model = new ResourceModel("derived.emptyvalue.message", StringUtils.EMPTY);
            } else {
                model = new Model<>(values.get(0));
            }

            AjaxTextFieldPanel panel = new AjaxTextFieldPanel(
                    "panel",
                    schemas.get(attrTO.getSchema()).getLabel(SyncopeEnduserSession.get().getLocale()),
                    model,
                    false);
            panel.setEnabled(false);
            panel.setRequired(true);
            panel.setOutputMarkupId(true);
            item.add(panel);
        }
    });
}
 
Example #12
Source File: OntopolyBookmarkablePageLink.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
  if (label != null) {
    replaceComponentTagBody(markupStream, openTag, 
        "<span>" + Strings.escapeMarkup(label) + "</span>");
  }
}
 
Example #13
Source File: CustomLinkFunctionBoxPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
protected Label getLabel(String id) {
  return new Label(id) {
    @Override
    protected void onComponentTagBody(MarkupStream markupStream,
        ComponentTag openTag) {
      replaceComponentTagBody(markupStream, openTag, 
            getFirstResourceModel().getObject()
          + "<span class='emphasis'>"
          + getSecondResourceModel().getObject()
          + "</span>");
    }
  };
}
 
Example #14
Source File: TopicLink.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
  super.onComponentTagBody(markupStream, openTag);
  
  String label = getLabel();
  if (label != null)
    // escape label because there could be markup in the label (code injection)
    if (getEscapeLabel())
      replaceComponentTagBody(markupStream, openTag, Strings.escapeMarkup(label));
    else
      replaceComponentTagBody(markupStream, openTag, label);
}
 
Example #15
Source File: StylableSelectOptions.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	replaceComponentTagBody(markupStream, openTag, text);
}
 
Example #16
Source File: LabelLink.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	replaceComponentTagBody(markupStream, openTag, labelModel.getObject()
			.toString());
}
 
Example #17
Source File: WicketPropertyResolver.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
public Component resolve(MarkupContainer container,
		MarkupStream markupStream, ComponentTag tag) {
	if (tag instanceof WicketTag)
	{
		final WicketTag wTag = (WicketTag)tag;

		// If <wicket:property ...>
		if (PROPERTY.equalsIgnoreCase(wTag.getName()))
		{
			wTag.setAutoComponentTag(false);
			String oClassName = tag.getAttribute("class");
			
			String refComponent = tag.getAttribute("ref");
			IModel<?> model = container.getPage().getDefaultModel();
			if(!Strings.isEmpty(refComponent)) {
				Component component = container;
				if(refComponent.startsWith("/")) { //If starts from / - it means that path is absolute for a page
					component = container.getPage().get(refComponent.substring(1));
				} else if(refComponent.startsWith("#")) {  //Supports format like #element:suba:subb
					int subs = refComponent.indexOf(":");
					final String nameToFind = subs>0?refComponent.substring(1, subs):refComponent.substring(1);
					component = container.getPage().visitChildren((comp, visit) -> {if(comp.getId().equals(nameToFind)) visit.stop(comp);});
					if(subs>0) component = component.get(refComponent.substring(subs+1));
				} else {
					component = container.get(refComponent);
				}
				model = component.getDefaultModel();
			}
			
			String objectExpression = tag.getAttribute("object");
			if(!Strings.isEmpty(objectExpression)) model = new PropertyModel<ODocument>(model, objectExpression);
			
			DisplayMode mode = DisplayMode.parse(tag.getAttribute("mode"), DisplayMode.VIEW);
			String visualization = tag.getAttribute("visualization");
			
			String property = tag.getAttribute("property");
			if(Strings.isEmpty(property)) property = wTag.getId();
			
			
			if(Strings.isEmpty(oClassName)) {
				Object object = model.getObject();
				if(object instanceof OIdentifiable) {
					ODocument doc = ((OIdentifiable)object).getRecord();
					oClassName = doc.getSchemaClass().getName();
				}
			}
			IModel<OProperty> propertyModel = new OPropertyModel(oClassName, property);
			if(propertyModel.getObject()==null) throw new WicketRuntimeException("No such property '"+property+"' defined on class '"+oClassName+"'");
			else return new ODocumentMetaPanel<Object>(wTag.getId(), mode.asModel(), 
									(IModel<ODocument>)model, 
									propertyModel).setVisualization(visualization);
		}
	}

	// We were not able to handle the tag
	return null;
}
 
Example #18
Source File: SimpleLink.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	replaceComponentTagBody(markupStream, openTag, text);
}
 
Example #19
Source File: EmailLink.java    From onedev with MIT License 4 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	replaceComponentTagBody(markupStream, openTag, emailModel.getObject());
}
 
Example #20
Source File: WidgetTabTemplate.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void renderTable() {
	tableTd = new WebMarkupContainer("tableTd");
	createTable();
	if(!renderTable) {
		tableTd.setVisible(false);
	}else if(renderTable && !renderChart) {
		tableTd.add(AttributeModifier.replace("colspan", "2"));
	}
	tableLink = new StatelessLink("link") {
		private static final long	serialVersionUID	= 1L;
		@Override
		public void onClick() {
			ReportDef rd = null;
			if(useChartReportDefinitionForTable()) {
				rd = getChartReportDefinition();
			}else{
				rd = getTableReportDefinition();
			}
			String siteId = rd.getSiteId();
			ReportDefModel reportDefModel = new ReportDefModel(rd);
			setResponsePage(new ReportDataPage(reportDefModel, new PageParameters().set("siteId", siteId), getWebPage()));
		}					
	};
	tableLink.setOutputMarkupId(true);
	tableTd.add(tableLink);
	
	tableJs = new WebMarkupContainer("tableJs") {
		private static final long	serialVersionUID	= 1L;
		@Override
		public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
			StringBuilder js = new StringBuilder();
			js.append("jQuery('#");
			js.append(table.getMarkupId());
			js.append("').fadeIn();");
			js.append("jQuery('#");
			js.append(tableLink.getMarkupId());
			js.append("').fadeIn();");
			replaceComponentTagBody(markupStream, openTag, js.toString());
		}
	};
	tableJs.setOutputMarkupId(true);
	tableTd.add(tableJs);
	
	tableTd.setOutputMarkupId(true);
	add(tableTd);
}
 
Example #21
Source File: FieldInstanceHTMLArea.java    From ontopia with Apache License 2.0 4 votes vote down vote up
public FieldInstanceHTMLArea(String id, FieldValueModel _fieldValueModel) {
  super(id);
  this.fieldValueModel = _fieldValueModel;
  
  OccurrenceIF occ = (OccurrenceIF)fieldValueModel.getObject();
  this.oldValue = (occ == null ? null : occ.getValue());
  setDefaultModel(new Model<String>(oldValue));
  
  this.textArea = new TextArea<String>("field", new Model<String>(oldValue)) {      
    @Override
    protected void onComponentTag(ComponentTag tag) {
      tag.setName("textarea");
      tag.put("cols", cols);
      tag.put("rows", rows);
      tag.put("class", getMarkupId());
      super.onComponentTag(tag);
    }
    
    @Override
    protected void onModelChanged() {
      super.onModelChanged();
      String newValue = (String)getModelObject();
      if (Objects.equals(newValue, oldValue)) return;
      AbstractOntopolyPage page = (AbstractOntopolyPage)getPage();
      FieldInstance fieldInstance = fieldValueModel.getFieldInstanceModel().getFieldInstance();
      if (fieldValueModel.isExistingValue() && oldValue != null)
        fieldInstance.removeValue(oldValue, page.getListener());
      if (newValue != null && !newValue.equals("")) {
        fieldInstance.addValue(newValue, page.getListener());
        fieldValueModel.setExistingValue(newValue);
      }
      oldValue = newValue;
    }      
  };
  textArea.setOutputMarkupId(true);
  add(textArea);
  
  add(new WebComponent("fieldScript") {
    @Override
    protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
      StringBuilder sb = new StringBuilder();
      //sb.append("\ntinyMCE.onLoad();");
      sb.append("\ntinyMCE.execCommand('mceAddControl', true, '" + textArea.getMarkupId() + "');");

      // the next two lines are a work-around for issue 459
      // https://github.com/ontopia/ontopia/issues/459
      // motivated by this posting
      // http://apache-wicket.1842946.n4.nabble.com/tinymce-textarea-in-a-modal-window-not-letting-to-type-td1886534.html
      sb.append("\ntinyMCE.execCommand('mceRemoveControl', false, '" + textArea.getMarkupId() + "');");
      sb.append("\ntinyMCE.execCommand('mceAddControl', true, '" + textArea.getMarkupId() + "');");
      // end of workaround
      
      replaceComponentTagBody(markupStream, openTag, sb.toString());
    }
  });
}
 
Example #22
Source File: StylableSelectOptions.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	replaceComponentTagBody(markupStream, openTag, text);
}
 
Example #23
Source File: WidgetTabTemplate.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void renderTable() {
	tableTd = new WebMarkupContainer("tableTd");
	createTable();
	if(!renderTable) {
		tableTd.setVisible(false);
	}else if(renderTable && !renderChart) {
		tableTd.add(AttributeModifier.replace("colspan", "2"));
	}
	tableLink = new StatelessLink("link") {
		private static final long	serialVersionUID	= 1L;
		@Override
		public void onClick() {
			ReportDef rd = null;
			if(useChartReportDefinitionForTable()) {
				rd = getChartReportDefinition();
			}else{
				rd = getTableReportDefinition();
			}
			String siteId = rd.getSiteId();
			ReportDefModel reportDefModel = new ReportDefModel(rd);
			setResponsePage(new ReportDataPage(reportDefModel, new PageParameters().set("siteId", siteId), getWebPage()));
		}					
	};
	tableLink.setOutputMarkupId(true);
	tableTd.add(tableLink);
	
	tableJs = new WebMarkupContainer("tableJs") {
		private static final long	serialVersionUID	= 1L;
		@Override
		public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
			StringBuilder js = new StringBuilder();
			js.append("jQuery('#");
			js.append(table.getMarkupId());
			js.append("').fadeIn();");
			js.append("jQuery('#");
			js.append(tableLink.getMarkupId());
			js.append("').fadeIn();");
			replaceComponentTagBody(markupStream, openTag, js.toString());
		}
	};
	tableJs.setOutputMarkupId(true);
	tableTd.add(tableJs);
	
	tableTd.setOutputMarkupId(true);
	add(tableTd);
}
 
Example #24
Source File: YesNoLabel.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	boolean active = (boolean)getDefaultModelObject();
	String resourceKey = active ? "yes" : "no";
	replaceComponentTagBody(markupStream, openTag, getString(resourceKey));
}
 
Example #25
Source File: MultilineLabel.java    From onedev with MIT License 4 votes vote down vote up
@Override
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
	final CharSequence body = toMultilineMarkup(getDefaultModelObjectAsString());
	replaceComponentTagBody(markupStream, openTag, body);
}
 
Example #26
Source File: Tabbable.java    From onedev with MIT License 4 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	checkComponentTag(openTag, "ul");
}