Skip to content

Commit

Permalink
Merge branch 'core-1.4.x' into console-1.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cretzel committed Apr 15, 2011
2 parents 74b5ffe + b853693 commit e33bfbf
Show file tree
Hide file tree
Showing 59 changed files with 4,012 additions and 849 deletions.
4 changes: 3 additions & 1 deletion changelog/release-message-core-1.4.x-next.txt
Expand Up @@ -31,7 +31,9 @@ Release Notes - WicketStuff Core - Version 1.4.x.y:
<artifactId>:
<list of key changes or bugfixes included in this release>


wicketstuff-minis:
- added ServerHostNameAndTimeFilter backport

The plan is to release a 1.4.x.y point release within one month from today. If you commit code and/or want a release sooner let me know as one month is the worst case target.

Regards,
Expand Down
13 changes: 12 additions & 1 deletion jdk-1.5-parent/console-parent/console-examples/pom.xml
Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.0.0</version>
<version>1.8.0.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand All @@ -67,6 +67,17 @@
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
<!-- Needed for JDK-1.5, JDK 6 includes these -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
</dependency>
</dependencies>

</project>
Expand Up @@ -48,7 +48,7 @@ public void init() {
.addAnnotatedClass(Book.class)
.setProperty("hibernate.dialect",
"org.hibernate.dialect.HSQLDialect")
.setProperty("hibernate.connection.driver_class ",
.setProperty("hibernate.connection.driver_class",
"org.hsqldb.jdbcDriver")
.setProperty("hibernate.connection.url",
"jdbc:hsqldb:mem:console")
Expand Down
@@ -0,0 +1,105 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wicketstuff.minis.filter;

import static org.apache.wicket.util.string.JavascriptUtils.SCRIPT_CLOSE_TAG;
import static org.apache.wicket.util.string.JavascriptUtils.SCRIPT_OPEN_TAG;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.apache.wicket.IResponseFilter;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.apache.wicket.util.string.Strings;
import org.apache.wicket.util.time.Duration;

/**
* Displays an server identifier (combination of host name, IP address and unique id) and the time
* it took to handle the request in the browser's status bar like this:
* <code>window.defaultStatus = 'Host: myhost/192.168.1.66/someid, handled in: 0.01s'</code>
*
* @author eelco hillenius
* @author David Bernard
* @author <a href="http://sebthom.de/">Sebastian Thomschke</a>
*/
public class ServerHostNameAndTimeFilter implements IResponseFilter
{
private String host;

/**
* Construct, trying system property 'hostid' for the server instance.
*/
public ServerHostNameAndTimeFilter()
{
this(System.getProperty("hostid"));
}

/**
* Construct with an id.
*
* @param hostId
* a unique id identifying this server instance
*/
public ServerHostNameAndTimeFilter(final String hostId)
{
try
{
final InetAddress localMachine = InetAddress.getLocalHost();
host = localMachine.getHostName() + "/" + localMachine.getHostAddress() + "/" +
(Strings.isEmpty(hostId) ? "<unknown>" : hostId);
}
catch (final UnknownHostException ex)
{
throw new WicketRuntimeException(ex);
}
}

protected void addJavaScript(final AppendingStringBuffer sb)
{
sb.append("window.defaultStatus='");
addMessage(sb);
sb.append("'");
}

protected void addMessage(final AppendingStringBuffer sb)
{
final long timeTaken = System.currentTimeMillis() - RequestCycle.get().getStartTime();
sb.append("Host: ")
.append(host)
.append(", handled in: ")
.append(Duration.milliseconds(timeTaken));
}

/**
* {@inheritDoc}
*/
public AppendingStringBuffer filter(final AppendingStringBuffer responseBuffer)
{
final int index = responseBuffer.indexOf("</head>");
if (index != -1)
{
final AppendingStringBuffer script = new AppendingStringBuffer(75);
script.append("\n").append(SCRIPT_OPEN_TAG);
addJavaScript(script);
script.append(";").append(SCRIPT_CLOSE_TAG);
responseBuffer.insert(index, script);
}
return responseBuffer;
}
}
Expand Up @@ -17,7 +17,6 @@
package org.wicketstuff.minis.reflection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.wicket.Component;
Expand All @@ -30,23 +29,23 @@
import org.apache.wicket.util.string.AppendingStringBuffer;

/**
* Behavior for adding reflections to an image. Uses reflection.js (v1.6),
* licensed under a MIT license.
* Behavior for adding reflections to an image. Uses reflection.js (v1.6), licensed under a MIT
* license.
* <p>
* Add this behavior to your image to generate a reflection. You can change the
* height and opacity of the reflection using the provided setters.
* Add this behavior to your image to generate a reflection. You can change the height and opacity
* of the reflection using the provided setters.
* <p>
* Ultimately the markup you attach this behavior to must be an image, but it
* need not be a Wicket {@link Image} component, a markup container will
* suffice, provided the tag is an img-tag.
* Ultimately the markup you attach this behavior to must be an image, but it need not be a Wicket
* {@link Image} component, a markup container will suffice, provided the tag is an img-tag.
* <p>
* You can also use this class to generate add and remove reflection scriptlets
* for use in Ajax request targets or any other place you want. All you need to
* do is ensure the reflection.js is added to the head of the document. You can
* use the {@link #REFLECTION_JS} resource reference for that.
* You can also use this class to generate add and remove reflection scriptlets for use in Ajax
* request targets or any other place you want. All you need to do is ensure the reflection.js is
* added to the head of the document. You can use the {@link #REFLECTION_JS} resource reference for
* that.
* <p>
* The reflection.js library and more documentation can be found here <a
* href="http://cow.neondragon.net/stuff/reflection/">http://cow.neondragon.net/stuff/reflection/</a>
* href="http://cow.neondragon.net/stuff/reflection/"
* >http://cow.neondragon.net/stuff/reflection/</a>
*
* @author Martijn Dashorst
*/
Expand Down
Expand Up @@ -42,7 +42,7 @@
public class StyleSwitcher extends AbstractBehavior
{
/**
* Javascript access methods
* JavaScript access methods
*
* @author Igor Vaynberg (ivaynberg at apache dot org)
*
Expand All @@ -67,32 +67,11 @@ private static class TitledResourceReferenceTuple implements IClusterable
private final String title;
private final ResourceReference reference;

/**
* @param name
* @param reference
*/
public TitledResourceReferenceTuple(final String name, final ResourceReference reference)
public TitledResourceReferenceTuple(final String title, final ResourceReference reference)
{
super();
title = name;
this.title = title;
this.reference = reference;
}

/**
* @return reference
*/
public ResourceReference getReference()
{
return reference;
}

/**
* @return title
*/
public String getTitle()
{
return title;
}
}

private static final long serialVersionUID = 1L;
Expand All @@ -102,15 +81,6 @@ public String getTitle()

private final List<TitledResourceReferenceTuple> stylesheets = new ArrayList<TitledResourceReferenceTuple>();

/**
* Construct.
*
*/
public StyleSwitcher()
{
super();
}

/**
* Adds stylesheet to this stylesheet switcher
*
Expand All @@ -125,22 +95,16 @@ public void addStylesheet(final String title, final ResourceReference reference)
}

/**
* @see org.apache.wicket.behavior.AbstractBehavior#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
* {@inheritDoc}
*/
@Override
public void renderHead(final IHeaderResponse response)
{
response.renderJavascriptReference(SS_JS);

for (final TitledResourceReferenceTuple stylesheet : stylesheets)
{
final StringBuilder link = new StringBuilder(128);
link.append("<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"");
link.append(RequestCycle.get().urlFor(stylesheet.getReference()));
link.append("\" title=\"");
link.append(stylesheet.getTitle());
link.append("\"/>");
response.renderString(link.toString());
}
response.renderString("<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"" +
RequestCycle.get().urlFor(stylesheet.reference, null) + "\" title=\"" +
stylesheet.title + "\"/>");
}
}
Expand Up @@ -25,6 +25,8 @@
*/
public class DisabledVeil extends Veil
{
private static final long serialVersionUID = 1L;

/**
* Constructor
*/
Expand All @@ -39,18 +41,17 @@ public DisabledVeil()
* @param cssClassName
* name of css class that will be used for the veil
*/
public DisabledVeil(String cssClassName)
public DisabledVeil(final String cssClassName)
{
super(cssClassName);
}

/**
* @see org.apache.wicket.behavior.AbstractBehavior#isEnabled(org.apache.wicket.Component)
* {@inheritDoc}
*/
public boolean isEnabled(Component component)
@Override
public boolean isEnabled(final Component component)
{
return super.isEnabled(component) && component.isEnabled() && component.isEnableAllowed();
}


}
Expand Up @@ -27,6 +27,8 @@
*/
public class Veil extends VeilResources
{
private static final long serialVersionUID = 1L;

private Component component;
private String cssClassName;

Expand All @@ -35,7 +37,7 @@ public class Veil extends VeilResources
*/
public Veil()
{

super();
}

/**
Expand All @@ -44,42 +46,39 @@ public Veil()
* @param cssClassName
* name of css class that will be used for the veil
*/
public Veil(String cssClassName)
public Veil(final String cssClassName)
{
if (!Strings.isEmpty(cssClassName))
{
this.cssClassName = cssClassName;
}

}

/**
* @see org.wicketstuff.minis.veil.VeilResources#bind(org.apache.wicket.Component)
* {@inheritDoc}
*/
public void bind(Component component)
@Override
public void bind(final Component component)
{
super.bind(component);
if (this.component != null)
{
throw new IllegalStateException(
"This behavior is already bound to component. An instance of this behavior cannot be reused between components. Bound component: "
+ this.component.toString());
}
"This behavior is already bound to component. An instance of this behavior cannot be reused between components. Bound component: " +
this.component.toString());
this.component = component;
}

private String getCssClassName()
{
return (cssClassName != null) ? cssClassName : VeilResources.DEFAULT_CSS_CLASS_NAME;
return cssClassName != null ? cssClassName : VeilResources.DEFAULT_CSS_CLASS_NAME;
}


/**
* @see org.wicketstuff.minis.veil.VeilResources#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
* {@inheritDoc}
*/
public void renderHead(IHeaderResponse response)
@Override
public void renderHead(final IHeaderResponse response)
{
super.renderHead(response);
response.renderOnDomReadyJavascript(VeilResources.Javascript.show(component));
}
}
}

0 comments on commit e33bfbf

Please sign in to comment.