List of usage examples for org.apache.wicket.util.collections MiniMap MiniMap
@SuppressWarnings("unchecked") public MiniMap(final int maxEntries)
From source file:com.marc.lastweek.web.components.jquerytexteditor.JQueryTextEditor.java
License:Open Source License
private MiniMap getToolbarImageMap() { MiniMap images = new MiniMap(4); images.put("BOLD_IMG", getRequestCycle().urlFor(new ResourceReference(JQueryTextEditor.class, "images/bold.gif"))); images.put("ITALIC_IMG", getRequestCycle().urlFor(new ResourceReference(JQueryTextEditor.class, "images/italic.gif"))); images.put("LINK_IMG", getRequestCycle().urlFor(new ResourceReference(JQueryTextEditor.class, "images/link.png"))); images.put("UNORDERED_IMG", getRequestCycle().urlFor(new ResourceReference(JQueryTextEditor.class, "images/unordered.gif"))); return images; }
From source file:de.javakaffee.kryoserializers.wicket.MiniMapSerializer.java
License:Apache License
@Override public MiniMap<Object, Object> read(final Kryo kryo, final Input input, final Class<MiniMap<Object, Object>> type) { final int maxEntries = input.readInt(true); final MiniMap<Object, Object> result = new MiniMap<Object, Object>(maxEntries); final int size = input.readInt(true); for (int i = 0; i < size; i++) { final Object key = kryo.readClassAndObject(input); final Object value = kryo.readClassAndObject(input); result.put(key, value);/*from w ww. j av a 2 s . c o m*/ } return result; }
From source file:de.javakaffee.kryoserializers.wicket.MiniMapSerializerTest.java
License:Apache License
@Test(enabled = true) public void testMiniMapEmpty() { final MiniMap<?, ?> obj = new MiniMap<Object, Object>(0); final byte[] serialized = serialize(_kryo, obj); final MiniMap<?, ?> deserialized = deserialize(_kryo, serialized, MiniMap.class); Assert.assertEquals(deserialized.size(), obj.size()); }
From source file:de.javakaffee.kryoserializers.wicket.MiniMapSerializerTest.java
License:Apache License
@Test(enabled = true) public void testMiniMapExactNumberOfEntries() { final MiniMap<String, String> obj = new MiniMap<String, String>(1); obj.put("foo", "bar"); final byte[] serialized = serialize(_kryo, obj); final MiniMap<?, ?> deserialized = deserialize(_kryo, serialized, MiniMap.class); Assert.assertEquals(deserialized.size(), obj.size()); final Entry<?, ?> deserializedNext = deserialized.entrySet().iterator().next(); final Entry<?, ?> origNext = obj.entrySet().iterator().next(); Assert.assertEquals(deserializedNext.getKey(), origNext.getKey()); Assert.assertEquals(deserializedNext.getValue(), origNext.getValue()); }
From source file:de.javakaffee.kryoserializers.wicket.MiniMapSerializerTest.java
License:Apache License
@Test(enabled = true) public void testMiniMapLessThanMaxEntries() { final MiniMap<String, String> obj = new MiniMap<String, String>(2); obj.put("foo", "bar"); final byte[] serialized = serialize(_kryo, obj); final MiniMap<?, ?> deserialized = deserialize(_kryo, serialized, MiniMap.class); Assert.assertEquals(deserialized.size(), obj.size()); }
From source file:de.javakaffee.kryoserializers.wicket.MiniMapSerializerTest.java
License:Apache License
@SuppressWarnings("unchecked") @Test(enabled = true)// w w w . j a va 2 s . c o m public void testMiniMapAddEntriesAfterDeserialization() { final MiniMap<String, String> obj = new MiniMap<String, String>(2); obj.put("foo", "bar"); final byte[] serialized = serialize(_kryo, obj); final MiniMap<String, String> deserialized = deserialize(_kryo, serialized, MiniMap.class); Assert.assertEquals(deserialized.size(), obj.size()); deserialized.put("bar", "baz"); try { deserialized.put("this should", "fail"); Assert.fail("We told the orig MiniMap to accept 2 entries at max," + " therefore we should not be allowed to put more."); } catch (final RuntimeException e) { // this is expected - didn't use @Test.expectedExceptions // as this would tie us to the exactly thrown exception } }
From source file:org.devproof.portal.core.module.common.component.richtext.BasicRichTextArea.java
License:Apache License
@Override protected void onRender(MarkupStream markupStream) { super.onRender(markupStream); Map<String, Object> variables = new MiniMap<String, Object>(2); variables.put("defaultCss", PortalUtil.toUrl(baseStyle ? REF_BASE_CSS : CommonConstants.REF_DEFAULT_CSS, getRequest())); variables.put("markupId", getMarkupId()); String javascript = TextTemplateHeaderContributor.forJavaScript(FullRichTextArea.class, "BasicRichTextArea.js", new MapModel<String, Object>(variables)).toString(); getResponse().write(javascript);//from w w w . java2 s .c om }
From source file:org.devproof.portal.core.module.common.component.richtext.FullRichTextArea.java
License:Apache License
@Override protected void onRender(MarkupStream markupStream) { super.onRender(markupStream); Map<String, Object> variables = new MiniMap<String, Object>(2); variables.put("defaultCss", RequestUtils.toAbsolutePath(urlFor(CommonConstants.REF_DEFAULT_CSS).toString())); variables.put("markupId", getMarkupId()); String javascript = TextTemplateHeaderContributor.forJavaScript(FullRichTextArea.class, "FullRichTextArea.js", new MapModel<String, Object>(variables)).toString(); getResponse().write(javascript);/* ww w . j av a 2 s.co m*/ }
From source file:org.devproof.portal.core.module.common.component.ValidationDisplayBehaviour.java
License:Apache License
private void printErrorMessage(CharSequence msg, Component componentWithError) { PackagedTextTemplate template = new PackagedTextTemplate(ValidationDisplayBehaviour.class, "ValidationDisplayBehaviour.html"); Map<String, Object> variables = new MiniMap<String, Object>(4); variables.put("message", msg); variables.put("imageUrl", componentWithError.urlFor(ERRORHINT_IMAGE_REF)); variables.put("imageId", componentWithError.getMarkupId() + "Image"); variables.put("popupId", componentWithError.getMarkupId() + "Popup"); componentWithError.getResponse().write(template.asString(variables)); }
From source file:org.devproof.portal.core.module.common.util.PortalUtil.java
License:Apache License
public static void addSyntaxHightlighter(Component component, String theme) { component.add(JavascriptPackageResource.getHeaderContribution(CommonConstants.class, "js/SyntaxHighlighter/shCore.js")); component.add(JavascriptPackageResource.getHeaderContribution(CommonConstants.class, "js/SyntaxHighlighter/shAutoloader.js")); // component.add(CSSPackageResource.getHeaderContribution(CommonConstants.class, "css/SyntaxHighlighter/shCore.css")); component.add(CSSPackageResource.getHeaderContribution(CommonConstants.class, "css/SyntaxHighlighter/shCore" + theme + ".css")); // component.add(CSSPackageResource.getHeaderContribution(CommonConstants.class, "css/SyntaxHighlighter/shTheme" + theme + ".css")); Map<String, Object> values = new MiniMap<String, Object>(1); CharSequence urlWithShCore = RequestCycle.get().urlFor(CommonConstants.REF_SYNTAXHIGHLIGHTER_JS); CharSequence urlWithoutShCore = StringUtils.removeEnd(urlWithShCore.toString(), "shCore.js"); values.put("jsPath", urlWithoutShCore); component.add(TextTemplateHeaderContributor.forJavaScript(CommonConstants.class, "js/SyntaxHighlighter/SyntaxHighlighterCopy.js", new MapModel<String, Object>(values))); }