Tuesday, December 8, 2015

Suppress warnings for non-nls string literals

@SuppressWarnings("nls") suppress warnings relative to non-nls string literals

Example:
@SuppressWarnings("nls")
private static final String[] PLATFORMS = { "iphone", "ipad", "windows", "android" };


Complete list:


The list of tokens that can be used inside a SuppressWarnings annotation is:
  • all to suppress all warnings
  • boxing to suppress warnings relative to boxing/unboxing operations
  • cast to suppress warnings relative to cast operations
  • dep-ann to suppress warnings relative to deprecated annotation
  • deprecation to suppress warnings relative to deprecation
  • fallthrough to suppress warnings relative to missing breaks in switch statements
  • finally to suppress warnings relative to finally block that don't return
  • hiding to suppress warnings relative to locals that hide variable
  • incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)
  • javadoc to suppress warnings relative to javadoc warnings
  • nls to suppress warnings relative to non-nls string literals
  • null to suppress warnings relative to null analysis
  • rawtypes to suppress warnings relative to usage of raw types
  • resource to suppress warnings relative to usage of resources of type Closeable
  • restriction to suppress warnings relative to usage of discouraged or forbidden references
  • serial to suppress warnings relative to missing serialVersionUID field for a serializable class
  • static-access to suppress warnings relative to incorrect static access
  • static-method to suppress warnings relative to methods that could be declared as static
  • super to suppress warnings relative to overriding a method without super invocations
  • synthetic-access to suppress warnings relative to unoptimized access from inner classes
  • sync-override to suppress warnings because of missing synchronize when overriding a synchronized method
  • unchecked to suppress warnings relative to unchecked operations
  • unqualified-field-access to suppress warnings relative to field access unqualified
  • unused to suppress warnings relative to unused code and dead code

Sunday, December 6, 2015

Fragments in OSGI - Eclipse


A Bundle fragment, or simply a fragment, is a bundle whose contents are made available to another bundle (the fragment host). Importantly, fragments share the classloader of their parent bundle. One notable difference is that fragments do not participate in the lifecycle of the bundle, and therefore cannot have an Bundle-Activator.


Example:
These are 2 plugins which does not have any activator classes.
org.eclipse.epp.logging.aeri.ui
org.eclipse.epp.logging.aeri.ide - Host Plugin

And, In org.eclipse.epp.logging.aeri.ide plugin MANIFEST.MF file, you can find below section:
Fragment-Host: org.eclipse.epp.logging.aeri.ui;bundle-version="1.0.0"


At runtime the fragment is merged with its host plug-in and for the runtime both projects are just one. Fragments are always optional for their host plug-in and the host plug-in doesn't even know that it exists.

Thursday, December 3, 2015

"No repository found containing: osgi.bundle" error message during the Eclipse udpate

Below trick helped me to resolve the problem.

Help>Install new software>Uncheck "Contact all update sites during install to find required software"

Tuesday, December 1, 2015

How to identify whether you working in development or debug mode in eclipse RCP

Being a eclipse plugin development programmer, we need to perform certain operations based on the mode you working on.

Eclipse provides a way to identify whether your eclipse is running in debug mode or development mode.

if (Platform.inDevelopmentMode()) //it will look for osgi.dev property
{
  //you are running in development mode.
}

if (Platform.inDebugMode()) //it will look for osgi.debug property
{
  //you are running in debug mode.
}


Monday, November 30, 2015

Git stash save with name and re-apply with the name

To save your changes with name "xxx"
git stash save "xxx"

Apply whenever you want it back.
git stash apply stash^{/xxx}


Lot of other solutions @
http://stackoverflow.com/questions/11269256/how-to-name-a-stash-in-git


Thursday, November 26, 2015

Managing node.js with nvm

Managing node.js with nvm

Run below command to install nvm
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
You'll see some output fly by, and then nvm will be installed. You will see a line that says:
=> Close and reopen your terminal to start using NVM
It's not actually necessary to log out, we just need to make sure that the changes nvm made to your path are actually reflected, so just do:
source ~/.profile
Alternatively, run the command suggested in the output of the script. Now type:
nvm ls-remote
Should you see the error, -bash: nvm: command not found it may be because git is not installed.
Go ahead and install git and rerun the script:
apt-get install git
And you will be shown a list of all the available versions of node.js. You can always find out the latest stable release by heading to the node.js website, where it's printed in the center of the page.
To install version 0.10.13 (the latest as of this writing) type:
nvm install 0.10.13
If you type:
node --version
You will now see that node v0.10.13 is installed and active. If you had an older node app that only works with node v0.8.16, and wanted to downgrade, then you would input:
nvm install v0.8.16
to install and switch to v0.8.16.
When you're done and want to switch back to v0.10.13, you can do so with nvm's use command:
nvm use v0.10.13
Nvm is great and makes switching between node versions easy and convenient. However, there's one caveat. If you type:
which node
you will see something interesting. Nvm installs node.js inside your user's home directory. This is fine for development, but if you want to actually host node applications, you don't want to install the latest new version of node via nvm and discover that you've inadvertently caused your production node app (which can be incompatible with the latest node.js) to stop working. It's best to install one copy of node globally so that other users can access it, and use nvm to switch between your development versions.
To do this, run the following command (entering your user's password at the prompt):
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
The above command is a bit complicated, but all it's doing is copying whatever version of node you have active via nvm into the /usr/local/ directory (where user installed global files should live on a linux VPS) and setting the permissions so that all users can access them.
If you ever want to change the version of node that's installed system wide, just do another nvm use vXX.XX.XX to switch your user's node to the version you want, and then re-run the above command to copy it to the system directory. 
To check that it works, become the root user and do another which command to make sure that node is now installed to /usr/local/bin:
sudo -s
which node
You should see:
/usr/local/bin/node
Congrats! Node.js is now installed and ready for use. Enjoy!
UPDATE:
Use below to change the default version for a shell.
nvm alias default 0.12.7

Thursday, November 19, 2015

How to control eclipse Java formatter on or off

This you can be controlled from Eclipse preferences.

Eclipse preferences: Java > Code Style > Formatter. Click on "Edit" button, "Off/On Tags", check off "Enable Off/On tags".

How to use in the code:
// @formatter:off
...your code here won't be formatted
// @formatter:on