@Override public void setProperty(String name, String value) { if (name.equals(ATTACHMENT_ID) || name.equals(MIME_TYPE) || name.equals(ATTACHMENT_URL) || name.equals(DATA)) { throw new IllegalArgumentException(name + " can not be changed."); } super.setProperty(name, value); }
/** * Inserts an inline blip at the given position. * * @param position the index to insert the inline blip at. This has to be * greater than 0. * @return an instance of {@link Blip} that represents the new inline blip. */ public Blip insertInlineBlip(int position) { if (position <= 0 || position > content.length()) { throw new IllegalArgumentException("Illegal inline blip position: " + position + ". Position has to be greater than 0 and less than or equal to length."); } // Shift the elements. shift(position, 1); content = content.substring(0, position) + " " + content.substring(position); // Generate the operation. Blip inlineBlip = operationQueue.insertInlineBlipToDocument(this, position); // Insert the inline blip element. Element element = new Element(ElementType.INLINE_BLIP); element.setProperty(INLINE_BLIP_ELEMENT_ID_KEY, inlineBlip.getBlipId()); elements.put(position, element); return inlineBlip; }
updatedElements.add(new Element(existingElement.getType(), properties)); for (Entry<String, String> entry : properties.entrySet()) { existingElement.setProperty(entry.getKey(), entry.getValue());
inlineBlipElement.setProperty("id", firstInlineBlip.getId()); OperationRequest operation = operationRequest( OperationType.DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT, rootBlipId,
inlineBlipElement.setProperty("id", firstInlineBlip.getId()); OperationRequest operation = operationRequest( OperationType.DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT, rootBlipId,
public void testLocateElement() { Document document = BasicFactories.documentProvider().parse( LineContainers.debugContainerWrap("01234567890123456789")); ApiView api = new ApiView(document, mock(Wavelet.class)); api.insert(3, new FormElement(ElementType.BUTTON, "buttonName")); FormElement button1 = new FormElement(ElementType.BUTTON, "buttonName"); assertEquals(3, api.locateElement(button1)); FormElement button2 = new FormElement(ElementType.BUTTON, "notInDocument"); assertEquals(-1, api.locateElement(button2)); api.insert(4, new Gadget("http://test.com")); Gadget gadget1 = new Gadget("http://test.com"); assertEquals(4, api.locateElement(gadget1)); Gadget gadget2 = new Gadget("http://test.com/something"); assertEquals(-1, api.locateElement(gadget2)); assertInSync(document, api); Element inlineBlip = new Element(ElementType.INLINE_BLIP); inlineBlip.setProperty("id", "b+1234"); api.insert(5, inlineBlip); assertEquals(5, api.locateElement(inlineBlip)); }
public void testLocateElement() { Document document = BasicFactories.documentProvider().parse( LineContainers.debugContainerWrap("01234567890123456789")); ApiView api = new ApiView(document, mock(Wavelet.class)); api.insert(3, new FormElement(ElementType.BUTTON, "buttonName")); FormElement button1 = new FormElement(ElementType.BUTTON, "buttonName"); assertEquals(3, api.locateElement(button1)); FormElement button2 = new FormElement(ElementType.BUTTON, "notInDocument"); assertEquals(-1, api.locateElement(button2)); api.insert(4, new Gadget("http://test.com")); Gadget gadget1 = new Gadget("http://test.com"); assertEquals(4, api.locateElement(gadget1)); Gadget gadget2 = new Gadget("http://test.com/something"); assertEquals(-1, api.locateElement(gadget2)); assertInSync(document, api); Element inlineBlip = new Element(ElementType.INLINE_BLIP); inlineBlip.setProperty("id", "b+1234"); api.insert(5, inlineBlip); assertEquals(5, api.locateElement(inlineBlip)); }