@Test public void testRemovePagelet() { try { page.removePagelet("xxx", 0); fail("Should not be able to remove from non-existing composer"); } catch (IndexOutOfBoundsException e) { } try { page.removePagelet(composer, 1); fail("Should not be able to remove non-existing pagelet"); } catch (IndexOutOfBoundsException e) { } page.removePagelet(composer, 0); assertEquals(0, page.getPagelets(composer).length); }
public Pagelet removePagelet(String composer, int position) { List<Pagelet> pagelets = composers.get(composer); if (pagelets == null || pagelets.size() < position) throw new IndexOutOfBoundsException("No pagelet found at position " + position); Pagelet pagelet = pagelets.remove(position); for (int i = position; i < pagelets.size(); i++) { pagelets.get(i).getURI().setPosition(i); } return pagelet; }
PageImpl extends ResourceImpl<ResourceContent> implements Page { public Pagelet removePagelet(String composer, int position) { List<Pagelet> pagelets = composers.get(composer); if (pagelets == null || pagelets.size() < position) throw new IndexOutOfBoundsException("No pagelet found at position " + position); Pagelet pagelet = pagelets.remove(position); for (int i = position; i < pagelets.size(); i++) { pagelets.get(i).getURI().setPosition(i); } return pagelet; } }
PageImpl extends ResourceImpl<ResourceContent> implements Page { public Pagelet removePagelet(String composer, int position) { List<Pagelet> pagelets = composers.get(composer); if (pagelets == null || pagelets.size() < position) throw new IndexOutOfBoundsException("No pagelet found at position " + position); Pagelet pagelet = pagelets.remove(position); for (int i = position; i < pagelets.size(); i++) { pagelets.get(i).getURI().setPosition(i); } return pagelet; } PageImpl(ResourceURI uri); }
PageImpl extends ResourceImpl<ResourceContent> implements Page { public Pagelet removePagelet(String composer, int position) { List<Pagelet> pagelets = composers.get(composer); if (pagelets == null || pagelets.size() < position) throw new IndexOutOfBoundsException("No pagelet found at position " + position); Pagelet pagelet = pagelets.remove(position); for (int i = position; i < pagelets.size(); i++) { pagelets.get(i).getURI().setPosition(i); } return pagelet; } PageImpl(ResourceURI uri); @Override boolean supportsContentLanguage(Language language); String getLayout(); void setLayout(String layout); String getTemplate(); void setTemplate(String template); void setStationary(boolean stationary); boolean isStationary(); Composer getComposer(String composerId); Composer getStage(); Composer[] getComposers(); Pagelet addPagelet(Pagelet pagelet, String composer); Pagelet addPagelet(Pagelet pagelet, String composer, int position); Pagelet[] getPagelets(); Pagelet[] getPagelets(String composer); Pagelet[] getPagelets(String composer, String module, String id); Pagelet removePagelet(String composer, int position); Pagelet[] getPreview(); void addPageContentListener(PageContentListener listener); void removePageContentListener(PageContentListener listener); }
PageImpl extends ResourceImpl<ResourceContent> implements Page { public Pagelet removePagelet(String composer, int position) { List<Pagelet> pagelets = composers.get(composer); if (pagelets == null || pagelets.size() < position) throw new IndexOutOfBoundsException("No pagelet found at position " + position); Pagelet pagelet = pagelets.remove(position); for (int i = position; i < pagelets.size(); i++) { pagelets.get(i).getURI().setPosition(i); } return pagelet; } PageImpl(ResourceURI uri); @Override boolean supportsContentLanguage(Language language); String getLayout(); void setLayout(String layout); String getTemplate(); void setTemplate(String template); void setStationary(boolean stationary); boolean isStationary(); Composer getComposer(String composerId); Composer getStage(); Composer[] getComposers(); Pagelet addPagelet(Pagelet pagelet, String composer); Pagelet addPagelet(Pagelet pagelet, String composer, int position); Pagelet[] getPagelets(); Pagelet[] getPagelets(String composer); Pagelet[] getPagelets(String composer, String module, String id); Pagelet removePagelet(String composer, int position); Pagelet[] getPreview(); void addPageContentListener(PageContentListener listener); void removePageContentListener(PageContentListener listener);  }