GWT how to set gwt.imageResource.maxBundleSize? (or any System Property's to Integer) - gwt

I need to change the system property
gwt.imageResource.maxBundleSize
to 1000.
How would I do this?
The property exists as I see it here;
https://code.google.com/p/google-web-toolkit/source/browse/releases/2.5/user/src/com/google/gwt/resources/rg/ImageBundleBuilder.java#471
Yet I cant figure out how to set this in the GWT.XML:
<set-property name="gwt.imageResource.maxBundleSize" value="1000" />
results in;
[ERROR] Property 'gwt.imageResource.maxBundleSize' not found
so I tried creating the property;
<define-property name="gwt.imageResource.maxBundleSize" values="1000" />
but that gets me;
[ERROR] Invalid property value '1000'
In fact, any numerical values results in this error. The only things it accepts are strings starting with letters.....but thats obviously useless as Googles code is;
private static final int IMAGE_MAX_SIZE = Integer.getInteger(
"gwt.imageResource.maxBundleSize", 256);
So I am stumped how I am supposed to set this property.

<define-property name="gwt.imageResource.maxBundleSize" values="1000" />
You are creating a new property here, not assigning a value to an existing property. I don't know why the error is happening, but rest assured that even if the error wasn't happening, you'd still not be setting the value you are trying to set. Because...
private static final int IMAGE_MAX_SIZE = Integer.getInteger(
"gwt.imageResource.maxBundleSize", 256);
that code doesn't read from your gwt.xml file. From the javadoc for Integer.getInteger:
/**
* Determines the integer value of the system property with the
* specified name.
According to this, you should be setting a system property when you run the compiler (or dev mode). Adding this to the JVM args might look something like this:
-Dgwt.imageResource.maxBundleSize=1000

Related

Scala checkstyle - Ignoring specific files for check

I've got a scalastyle_config.xml file with the following check, among others:
<check class="org.scalastyle.scalariform.ClassNamesChecker" level="warning" enabled="false">
<parameters>
<parameter name="regex"><![CDATA[^[A-Z][A-Za-z]*$]]></parameter>
</parameters>
</check>
I want this to be applied to all files, except for two:
-FooK3.java
-FooK3Something.java
Is there any way to add an exception for those files? Can't see anything in the documentation
I don't know any way to exclude specific files from that checker, and I've been using scalastyle for a while, so I assume there isn't such a way at the moment.
What can be done, is turning off scalastyle exactly where you don't want it. And then it will work on the rest of the file. For example where you define Class FooK3, you can do either:
class FooK3 { // scalastyle:ignore
Or:
// scalastyle:off
public class FooK3 {
// scalastyle:on
int x = 5;
}
Then the check will pass. A good practice is the add to the comment the name of the rule you want to bypass, such that if one day someone fixes it, scalastyle will be returned.
Official docs can be found here.

ArangoDB "Spring Data Demo" Tutorial outdated?

Like the title says, is it possible the tutorial at https://www.arangodb.com/tutorials/spring-data/ is outdated? I'm having several problems, but don't know how to workaround the last one:
Part 2, "Save and read an entity"
I get an error: method getId() is undefined.
Workaround: I added a getter in class Character.
Also in "Save and read an entity"
final Character foundNed = repository.findOne(nedStark.getId());
The method findOne(Example) in the type QueryByExampleExecutor is not applicable for the arguments (String)
Workaround: I used find by example:
final Optional<Person> foundNed = repository.findOne(Example.of(nedStark));
Part 1, "Create a Configuration class"
public class DemoConfiguration extends AbstractArangoConfiguration {
Gives me an error:
"No constructor with 1 argument defined in class 'com.arangodb.springframework.repository.ArangoRepositoryFactoryBean'"
Workaround: ?
Can anyone point me in the right direction?
I found the demo project on github: https://github.com/arangodb/spring-data-demo
Number 1: They use a getter too.
Number 2: Was my fault, I did try ArangoRepository (of Character, Integer) but forgot that Id is a string.
Number 3: They don't seem use any Configuration (AbstractArangoConfiguration) class in the source at all although it is still mentioned in that tutorial. I think now the config and connection is handled by spring autoconfigure. Though I would like to know how the Arango driver is set, all I could find that may point further is ArangoOperations.
Anyway it works now, maybe this helps somebody else who is having the same problems.

How to copy properties from source node to destination node in cq

I want to get Some Property from Source Node Using getProperties() and setProperty in another Destination Node. How can i check that property is protected or not.As if i copy all the property in destination it gives me ConstraintViolationException
You'd need to get the definition of the property:
PropertyDefinition propDefinition = node.getProperty("/yourprop").getDefinition();
on the definition you can call isProtected():
Boolean isPropertyProtected = propDefinition.isProtected();
or just inline it:
node.getProperty("/yourprop").getDefinition().isProtected();
for further reading I suggest:
http://www.day.com/specs/jcr/2.0/16_Access_Control_Management.html;
Chapter 16.3.12 Interaction with Protected Properties
And the JCR documentation on node types:
http://jackrabbit.apache.org/jcr/node-types.html
This is probably because you are trying to copy all properties which includes cq:primaryType as well. If you see in crx, these basic properties are not editable.
For copy you can take a specific property and set a specific property, instead of copying and pasting all the properties.

Can I "fix" wrong Resharper annotations?

I love Resharper, but sometimes it gives incorrect warnings, probably because the built-in annotations for BCL types are wrong. For instance, in this code:
private static string GetDescription(T value)
{
Type type = typeof(T);
string name = Enum.GetName(type, value);
if (name != null)
{
...
It gives me a warning on the if statement: "Expression is always true". But Enum.GetName can return null:
string name = Enum.GetName(typeof(DayOfWeek), (DayOfWeek)42); // null
I assume this is because there is a [NotNull] annotation for Enum.GetName. Is there a way to fix that so I don't get the warning?
Note: I'm using Resharper 5.1; perhaps that issue is fixed in version 6, but I'm not willing to upgrade right now.
OK, I got it. The built-in annotations are defined in XML files in the Resharper installation directory (C:\Program Files (x86)\JetBrains\ReSharper\v5.1\Bin\ExternalAnnotations\ on my machine). The solution is to edit the appropriate file to remove or fix the incorrect annotations.
In the case of Enum.GetName, the file to change is mscorlib\mscorlib.[version].Contracts.xml. I just commented this annotation:
<member name="M:System.Enum.GetName(System.Type,System.Object)">
<attribute ctor="M:JetBrains.Annotations.NotNullAttribute.#ctor" />
</member>
And restarted Visual Studio, and now the warning is gone :)
Just an update to Thomas's answer, they seem to have moved things around in the last couple of years.
For Resharper 8.2.3, the above file now resides in:
C:\Users\YOUR_USER_NAME\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.ExternalAnnotations.8.2.3001\ReSharper\vAny\annotations\.NETFramework\mscorlib\...
so, if you're trying to do that, you can search that path (or one up, for non mscorlib files).

Deferred binding not working after compilation

I have a weird problem with deferred binding. I have defined the following module:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Defines the usercategory property and its provider function. -->
<module>
<define-property name="usercategory" values="c00,c01,c02" />
<collapse-property name="usercategory" values="*" />
<property-provider name="usercategory"><![CDATA[
// Look for the usercategory cookie
var cs = document.cookie.split(';');
for (var i = 0; i < cs.length; i++) {
var name = cs[i].substr(0, cs[i].indexOf("="));
var value = cs[i].substr(cs[i].indexOf("=") + 1);
name = name.replace(/^\s+|\s+$/g,"");
if (name == "usercategory") {
return unescape(value);
}
}
return "c00";
]]></property-provider>
</module>
which sets the property usercategory by looking at the value of a cookie named usercategory.
I use this property application.gwt.xml to defer binding of some classes, for example:
<inherits name="com.example.UserCategory"/>
<replace-with class="com.example.client.ui.menu.MainMenuView01">
<when-type-is class="com.example.client.ui.menu.MainMenuView"/>
<when-property-is name="usercategory" value="c01"/>
</replace-with>
This works like a charm when I'm in development mode (i.e. when running my app from within Eclipse). However, if I compile the app and deploy it (in Jetty, but I don't this this is the problem), then deferred binding does not seem to work, and the expected classes are not loaded. I've checked and the cookie is set up properly with the correct value c01, but class com.example.client.ui.menu.MainMenuView01 is not loaded.
Am I missing something? Am I doing something wrong?
Thank you in advance!
There are two possibilities. You are doing something wrong, or there is another bug in GWT compiler. I've tried to implement a case like your and it was working when compiled without any problems. So most likely there can be some error on your side. So what i recommend to do is to compile app with -style PRETTY and see how it was compiled. find function named com_example_client_ui_menu_MainMenuView(), and see if it able to create MainMenuView01, try to debug it and etc. Anyway this kind of stuff should be working without any problems.
Also try to debug your property provider (and use vars $doc and $wnd in property provider instead of window)
Another possible case is that the cookie might be not readable from JS
I figured out what the problem was, and I'm writing it here in case others might be interested.
The module that I defined (see code in my question) defines a property whose value is taken from a cookie, that is generated after the user logs in the application.
Originally I had a GWT Place for the login, and when the user successfully authenticated the application moved to another Place. In this case when the user enter the application, and the GWT Javascript is downloaded to the browser, the cookie is not set yet (because the user has not performed login yet). Therefore the deferred binding does not work, and the expected classes (like com.example.client.ui.menu.MainMenuView01) are not loaded.
I have no idea why this works correctly when run in development mode. Anyway. the solution that I implemented is to move the login phase outside of the GWT application, and when the login is successful, I add the cookie and the redirect the user to the actual GWT application.