Friday, December 27, 2013

Friday, December 13, 2013

Fix Maven Error: JAVA_HOME is not defined correctly on Mac OSX 10.9 Mavericks

If your JAVA_HOME env.variable is set correctly then 100500% 
you have to hardcode the $M2_HOME/bin/mvn script!


Ok. Here is the error massege itself:
Error: JAVA_HOME is not defined correctly. We cannot execute /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java

Now Edit mvn script (it could be line 61):
Change the path of JAVA_HOME that starts with /System/... on your e.g. /Library/...
Change above the value of variable JAVA_VERSION on that you have e.g. jdk1.7_...

Why this issue took place is beacouse the path of JAVA_HOME in OSX 10.9 Maericks is different then it was in previous versions of OS. Before it was installed in /System... now it is in /Library.... BUT the maven script still sets the path of JAVA_HOME that starts in /System... Maybe in next version of Maven this will be changed. 

That's all.

Tuesday, December 10, 2013

UIBinder example

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:g='urn:import:com.google.gwt.user.client.ui'
             xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
             xmlns:tabs="urn:import:com.db.syndicate.html.common.gxtcomponents.tabs">
    <ui:style>
        .header{
            text-align: center;
            background-color: bisque;
            width: 100%;
        }
    </ui:style>
    <g:FlowPanel>
        <b:FluidContainer>
            <b:FluidRow width="100%">
                <b:Column size="12">
                    <!--<g:HTMLPanel addStyleNames="{style.header}">Header</g:HTMLPanel>-->
                    <g:FlowPanel ui:field="headerPanel"/>
                </b:Column>
            </b:FluidRow>
            <b:FluidRow>
                <b:Column size="3">
                    <b:FluidRow>
                        <b:Column size="12">
                            <!--menu-->
                            <g:FlowPanel width="100%" ui:field="menuPanel"/>
                        </b:Column>
                    </b:FluidRow>
                    <b:FluidRow>
                        <b:Column width="100%" size="12">
                            <!--filter-->
                            <g:FlowPanel ui:field="filterPanel"/>
                        </b:Column>
                    </b:FluidRow>
                </b:Column>
                <b:Column size="9">
                    <!--content-->
                    <g:FlowPanel width="100%" ui:field="contentPanel">
                        <tabs:TabBar header="true" ui:field="tabBar"/>
                    </g:FlowPanel>
                </b:Column>
            </b:FluidRow>
            <b:FluidRow>
                <!--Footer-->
            </b:FluidRow>
        </b:FluidContainer>
    </g:FlowPanel>
</ui:UiBinder>

Consider Errai Framework

Wednesday, December 4, 2013

Creating a Facebook-style Autocomplete with GWT in SmartGWT project

The example of how to Creat a Facebook-style Autocomplete with GWT http://raibledesigns.com/rd/entry/creating_a_facebook_style_autocomplete needs some additional coding and styling if you want to use it your SmartGWT project. Why and what you have to change:

1. There could be a wrong z-index for a PopupBox taht has list of suggestions for a SuggestBox.

  • In InputListWidget class create instance of DefaultSuggestionDisplay, set its default GWT style (e.g. all styles related to gwt-SuggestBoxPopup) and add proper z-index attribut to it. 
  • Then use another constructor for a SuggestBox that has additional parameter for DefaultSuggestionDisplay and pass to it the styled instance of DefaultSuggestionDisplay you have just created.


Example:
DefaultSuggestionDisplay defaultSuggestionDisplay = new DefaultSuggestionDisplay();
defaultSuggestionDisplay.setPopupStyleName("gwt-SuggestBoxPopup");

final SuggestBox box = new SuggestBox(getSuggestions(), itemBox, defaultSuggestionDisplay);

Example of CSS with styles for InputListWidget including gwt-SuggestBoxPopup:
.token-input-list-facebook {
list-style-type: none;
}

ul.token-input-list-facebook {
overflow: hidden; 
height: auto !important; 
height: 1%;
width: 400px;
border: 1px solid #8496ba;
cursor: text;
font-size: 12px;
font-family: Verdana, sans-serif;
min-height: 1px;
z-index: 999;
margin: 0;
padding: 0;
background-color: #fff;
list-style-type: none;
clear: left;
}

ul.token-input-list-facebook li input {

border: 0;
width: 100px;
padding: 3px 8px;
background-color: white;
margin: 2px 0;
-webkit-appearance: caret;

}

li.token-input-token-facebook {

overflow: hidden; 
height: auto !important; 
height: 15px;
margin: 3px;
padding: 1px 3px;
background-color: #eff2f7;
color: #000;
cursor: default;
border: 1px solid #ccd5e4;
font-size: 11px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
float: left;
white-space: nowrap;

}

li.token-input-token-facebook p {

display: inline;
padding: 0;
margin: 0;

}

li.token-input-token-facebook span {

color: #a6b3cf;
margin-left: 5px;
font-weight: bold;
cursor: pointer;

}

li.token-input-selected-token-facebook {

background-color: #5670a6;
border: 1px solid #3b5998;
color: #fff;

}

li.token-input-input-token-facebook {

float: left;
margin: 0;
padding: 0;
list-style-type: none;

}

.gwt-SuggestBoxPopup { 
   border: thin 1px solid green; 
   width: 200px;
   z-index: 999999 !important;
}
.gwt-SuggestBoxPopup.item { 
   color: red; 
}
.gwt-SuggestBoxPopup .item-selected { 
   color: gray;
}
.gwt-SuggestBoxPopup .suggestPopupTopLeft { 
   border: thin 1px solid green; 
}
.gwt-SuggestBoxPopup .suggestPopupTopLeftInner { 
   border: thin 1px solid green; 
}
.gwt-SuggestBoxPopup .suggestPopupTopCenter { 
   border: thin 1px solid green; 
}
.gwt-SuggestBoxPopup .suggestPopupTopCenterInner { 
   border: thin 1px solid green; 
}
.gwt-SuggestBoxPopup .suggestPopupTopRight {
   border: thin 1px solid green; 
}
.gwt-SuggestBoxPopup .suggestPopupTopRightInner {
   border: thin 1px solid green; 
}
.gwt-SuggestBoxPopup .suggestPopupMiddleLeft { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupMiddleLeftInner { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupMiddleCenter { 
   border: thin 1px solid green; width:200px;
}
.gwt-SuggestBoxPopup .suggestPopupMiddleCenterInner { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupMiddleRight { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupMiddleRightInner { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupBottomLeft {
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupBottomLeftInner { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupBottomCenter {
   border: thin 1px solid green;
 }
.gwt-SuggestBoxPopup .suggestPopupBottomCenterInner { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupBottomRight { 
   border: thin 1px solid green;
}
.gwt-SuggestBoxPopup .suggestPopupBottomRightInner { 
   border: thin 1px solid green;
}

2. The fix above will correct only style of PopupBox and its z-index, but there could be a wrong styling for other InputListWidget components as well if your project does not inherit any GWT skins.

  • So be sure to use proper inheritance of it in your *.gwt.xml file e.g.:
    <inherits name='com.google.gwt.user.theme.standard.Standard' />
  • Or add related missed styles to your CSS along with gwt-SuggestBoxPopup styles.









Wednesday, November 27, 2013

WebLogic Server env conflict resolving

Durring StartWeblogic.cmd there are PATH and CLASS_PATH that will be created. You can edit the way these pathes are configured. Where to check it?

In my case this was this script:
Oracle\Middleware_dst\wlserver_10.3\bin\commonEnv.cmd

Monday, November 25, 2013

Simple explanation of what is a Java Marshalling

Marshalling is the process of converting  a POJO (Plain Old Java Object) in memory into a format that can be written to disk or send via network, usually in text formats like XML or JSON. The reverse of this technique is called unmarshalling.

Marshalling is similar to Serialization in practice but the difference is that, Marshalling also saves the code of an object in addition to its state.

Here is the link on the post:
http://tech.deepumohan.com/2011/11/marshalling-in-java.html

Sunday, November 24, 2013

Spring Android Docs Reference

http://docs.spring.io/spring-android/docs/1.0.1.RELEASE/reference/htmlsingle/#d4e34

Friday, November 22, 2013

How to wrapp GWT component into SmartGWT

Suppouse that InputListWidget is a component that extends Composite GWT class. The rest of the code snippet is a SmartGWT.

//SmartGWT
Canvas inputListWidgetWrapper = new Canvas(); 
inputListWidgetWrapper.setWidth(360);
inputListWidgetWrapper.setHeight(70);
inputListWidgetWrapper.addChild(new InputListWidget());

DynamicForm form = new DynamicForm();        
form.addChild(inputListWidgetWrapper);

GWT AutoComplete howto link

Here is the link of howto AutoComplete in GWT
http://raibledesigns.com/rd/entry/creating_a_facebook_style_autocomplete

Wednesday, November 13, 2013

Run Android project generated by Maven archetype:generate from IDE by Maven commands

When you create an Android project by Maven e.g. mvn archetype:generate your new Project will be presented in IDE as a Java project, not the Android's one. So you can't run it from IDE as an Android project "out of the box". You should use Maven commands instead:

mvm android:deploy
mvm android:run

By default Maven will deploy your apk on all available deviсes including USB's ones and emulator. So if you want to use only USB devices change related setting in pom.xml of the project.

Understanding Memory Management

The summary from this link.

HEAP is shared among all THREADS.
The heap is the RUN-TIME DATA AREA from which memory for all class instances and arrays is allocated.

OBJECTS are kept in HEAP memory.

When HEAP is full the GARBAGE is COLLECTED.

Java METHODS, THREADS, NATIVE HANLES are allocated in other memory (methods_area, stack).

TWO AREAS OR GENERATIONS OF HEAP
HEAP is divided on two areas (generations):

YOUNG_SPACE (NURSERY) for a new OBJECTS.

When NURSERY is full garbage collector runs YOUNG_COLLECTION and moves some obj. to OLD_SPACE (all threads are stopped. it is called GENERATIOANL or PARALLEL GarbCol-on where the work is done in parallel using all available CPUs.)
When OLD_SPACE is full garbage is collected by process named OLD_COLLECTION

In NURSERY is a KEEP_AREA for a newly added objects that lives there until the next YOUNG_COLLECTION. This prevents objects from being promoted (moved) just because they were allocated right before a young collection started.

JVM distinguishes SMALL and LARGE OBJECTS. (depends of JVM version,  HEAP size, GC... )
LARGE size ~ 2 - 128 kB. See the docs for -XXtlaSize and -XXlargeObjectLimit

LARGE OBJECTS allocated in TLA (thread local area) that is reserved in HEAP.



GARBAGE COLLECTION MODELS
MARK and SWEEP models.
MARK - marks up all alive objects, SWEEP writes a gaps among'em in a free list for a new objects.

Its improved versions are CONCURRENT concurrent garbage collection or PARALLEL mark and sweep.

GARBAGE COLLECTION MODES
DYNAMIC automatically selects a garbage collection strategy to use:
throughput (default mode), pausetime, deterministic.

STATIC mode uses this major strategies:
singlepar, which is a single-generational parallel garbage collector (same as parallel)
genpar, which is a two-generational parallel garbage collector
singlecon, which is a single-generational mostly concurrent garbage collector
gencon, which is a two-generational mostly concurrent garbage collector

COMPACTION
To reduce fragmentation, the JRockit JVM compacts a part of the heap at every garbage collection JVM uses COMPACTION. Compaction is performed at the beginning of or during the SWEEP phase and while all Java THREADS are PAUSED.

TWO COMPACTION METHODS
EXTERNAL
moves the objects within the compaction area to free positions outside the compaction area and as far down in the heap as possible. 

INTERNAL
moves the objects within the compaction area as far down in the compaction area as possible, thus moving them closer together.

SLIDING WINDOW SCHEMES
Each sliding window moves a notch up or down in the heap at each garbage collection, until it reaches the other end of the heap or meets a sliding window that moves in the opposite direction, and starts over again. Thus the whole heap is eventually traversed by compaction over and over again.

COMPACTION AREA SIZING
Thus the compaction area will be smaller in parts of the heap where the object density is high or where the amount of references to the objects within the area is high. Typically the object density is higher near the bottom of the heap than at the top of the heap, except at the very top where the latest allocated objects are found. Thus the compaction areas are usually smaller near the bottom of the heap than in the top half of the heap.

Thursday, November 7, 2013

Play Market Google - how to start alpha testing of an app

1. Do registration on Google Play Developer Console, you should pay once $25.
2. Do all settings for your app project e.g. add screenshots, countries etc. e.g.
3. Create in Google Group the group for all those who will be alpha testers of your app
4. Upload your apk as for Alpha testing
5. Provide Google Group email of testers
6. Give to your testers the link of apk download e.g. see the lest paragraph of this screenshot:


7. When a tester will follow the link and accept invitation to become a tester he will see this e.g.:


8. When a tester click link of Download *** from the Play Store he will see this:




Tuesday, November 5, 2013

How to covert a Boolean object array to boolean primitive array

private boolean[] toPrimitiveArray(final List<Boolean> booleanList) {
        final boolean[] primitives = new boolean[booleanList.size()];
int index = 0;

for (Boolean object : booleanList) {
            primitives[index++] = object;
}

return primitives;
}

Monday, November 4, 2013

Parsing a String representation of Double with comma decimal separator in Android cause NumberFormatException

I've used the same code parsing a String representation of Double with comma decimal separator (e.g. "0,3") on different versions of Android (2.3 and 4.*). It is strange, but in Android 2.3 the code was executed without any Exception, but in Android 4.* I've got NumberFormatException with the message: Invalid Double: 0,3

I've fixed it by replacement of comma for a dot separator in String object of my Double:

DecimalFormat newFormat = new DecimalFormat("#.#");

double result = 0;
   try {
       String doubleString = newFormat.format(constancyPercentage);
        result = Double.parseDouble(doubleString.replace(",", "."));//0,3 -> 0.3
} catch (NumberFormatException e) {
//TODO show nothing
}

Monday, October 28, 2013

Android SDK installation issue - Peer not authenticated

In order to fix "Peer not authenticated" error just force Android SDK Manager to fetch all  https://...sources to be fetched using http://

1. Open Android SDK Manager (e.g. from Eclipse IDE)
2. Open from top menu Android SDK Manager/Settings
3. Check box Force https://...sources to be fetched using http://



How to install ANT on Mac OSX 10.9 and later


1. Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

2. Install Apache Ant via Homebrew by executing
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/ant.rb

Friday, October 25, 2013

Why maven doesn't downloads source and javadoc files

When you can not see any source code in your IDE such as Eclipse this most probably happen because your Maven (if you do use Maven) does not downloaded source jar file (e.g. filename-source.jar).

Maven does not downloads a source and javadoc jar files by default.

This option should be added to its settings file in ~/.m2/settings.xml file like this:

<profiles>
<profile>
    <id>downloadSources</id>
    <properties>
        <downloadSources>true</downloadSources>
        <downloadJavadocs>true</downloadJavadocs>           
    </properties>
</profile>
</profiles>

<activeProfiles>
  <activeProfile>downloadSources</activeProfile>
</activeProfiles>

Here is the link about this topic:
http://stackoverflow.com/questions/5780758/maven-always-download-sources-and-javadocs

How to enter on Apple Dev Site

https://daw.apple.com

Thursday, October 24, 2013

SHODANHQ


To get this info is a big deal, 
to know how to use it is the second one... 
and how many out there who knows it? 
)))

Thursday, September 26, 2013

How to Clean up Directory Service cache

If you can not resolve locally any domain name try to clean up Directory Service cache. Use with sudo this utility:

dscacheutil – gather information, statistics and initiate queries to the Directory Service cache.

Use it with the option:

flushcache – Flushes the entire cache.  This should only be used in extreme cases.  Validation information is used within the cache along with other techniques to ensure the OS has valid information available to it.

For example:

sudo dscacheutil -flushcache

Friday, August 16, 2013

How to add a variable to the the existed environment variable in a bash command

How to add a variable to the the existed environment variable in a bash command:

1. Let's suppose that you already have a some env.variable (check all variables that you have with command env). As an example we'll use REPO_B

2. Say you want to run svn check out from the branch repository and do check out the specific branch branchA.

3. The syntaxys is like this:
svn co REPO_B/branchA branchA

If you're a developer and have an iPad

If you're a developer and have an iPad sheck this link:
http://omz-software.com/editorial/

Thursday, July 18, 2013

How to set correctly current date on linux, mac, etc


How to set timezone on Linux:
Find out your timezone here /usr/share/zoneinfo/
e.g. for Ukraine, Kiev it would be:
/usr/share/zoneinfo/Europe/Kiev

To apply it you need first to remove "localtime" file from etc/localtime
Then create from /usr/share/zoneinfo/Europe/Kiev soft link at /etc/ and name it "localtime", e.g.:
ln -s /usr/share/zoneinfo/Europe/Kiev /etc/localtime

Check created link:
ls -l
... /etc/localtime -> /usr/share/zoneinfo/Europe/Kiev


Update current time on your OS with NTP server:
ntpdate -b pool.ntp.org


Check your current date:
date
Thu Jul 18 13:55:20 EEST 2013

That's it.

Monday, June 3, 2013

Thursday, March 21, 2013

How to change a HOSTNAME on mac

If you have to change a hostname of your Mac do this in Terminal:

1. Check your hostname with the one of these commands:
hostname
echo $HOSTNAME
uname -n

2. Set a new hostname:
sudo scutil --set HostName yourNewHostname