Wednesday, September 2, 2015

Eclipse RCP : How to check a view is currenlty visible


If we need to check whether a view currently available or visible we can use following code :

Boolean result = false;

IViewReference viewReferene =  PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findViewReference("my_view_id");


if (viewReferene != null) {
result = true;
}





How to Enable and Disable VNC server password authentication in cent os

You can switch between password and non password mode by:

# vi /etc/X11/xorg.conf  (enable password)
[..]
    #Option "SecurityTypes" "None"
    Option "SecurityTypes" "VncAuth"
    Option "UserPasswdVerifier" "VncAuth"
    Option "PasswordFile" "/root/.vnc/passwd"
[..]

# vi /etc/X11/xorg.conf  (disable password)
[..]
    Option "SecurityTypes" "None"
    #Option "SecurityTypes" "VncAuth"
    #Option "UserPasswdVerifier" "VncAuth"
    #Option "PasswordFile" "/root/.vnc/passwd"
[..]

Restart X for change to take effect:
# init 3   (wait a few seconds - )

# init 5



after enabling the password: 

You should be able to type ”vncpasswd” from the terminal as root. This will enable you to type in a new password for the VNC connection.

Sunday, August 30, 2015

Configure log4j properties file for logging both in file system and console



# Root logger option
log4j.rootLogger= DEBUG,errorLogger,stdout,



# Direct log messages to a log file
log4j.appender.errorLogger=org.apache.log4j.RollingFileAppender
log4j.appender.errorLogger.Threshold = ERROR
log4j.appender.errorLogger.File=.\\Log\\logging.log
log4j.appender.errorLogger.MaxFileSize=1MB
log4j.appender.errorLogger.MaxBackupIndex=1
log4j.appender.errorLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.errorLogger.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n






The above configuration will write only error log to file system and all the other log in console.
log4j.appender.errorLogger.Threshold = ERROR   does the trick.

Tuesday, January 13, 2015

Eclipse Jobs API : Perform something when job is done

When we need to do something for example notify user or cleaup someting after a JOB is finished we can user the  JobChangeListener to accomplish this. see the folowing code:


     final Job job = new Job("Long Running Job") {
        protected IStatus run(IProgressMonitor monitor) {
           try {
              while(hasMoreWorkToDo()) {
                 // do some work
                 // ...
              if (monitor.isCanceled()) return Status.CANCEL_STATUS;
             }
              return Status.OK_STATUS;
           } finally {
              schedule(60000); // start again in an hour
           }
        }
     };
  job.addJobChangeListener(new JobChangeAdapter() {
        public void done(IJobChangeEvent event) {
        if (event.getResult().isOK())
           postMessage("Job completed successfully");
           else
              postError("Job did not complete successfully");
        }
     });
  job.setSystem(true);
     job.schedule(); // start as soon as possible


See the details in following website:
https://eclipse.org/articles/Article-Concurrency/jobs-api.html





Monday, October 27, 2014

SocketTest




A java tool for socket testing. It can create both TCP and UDP client or server.
 It can be used to test any server or client that uses TCP or UDP protocol to communicate.

Can be downloaded from:
http://sockettest.sourceforge.net/



Monday, August 25, 2014

How to continue code review effectively


Code review is a common software engineering practice employed both in open source and industrial contexts. I will be writing this blog post regarding all aspect of code review:



Code Review Data Structure:

https://blog.jetbrains.com/upsource/2015/08/20/what-to-look-for-in-a-code-review-data-structures/ 
interesting blog post to read:



http://www.infoq.com/news/2008/03/code-review-antipatterns
http://server.dzone.com/articles/dont-waste-time-code-reviews


Code review tools for Eclipse:

FindBugs plug-in:

web: http://findbugs.cs.umd.edu/eclipse/
update site: http://findbugs.cs.umd.edu/eclipse


PMD:
web: http://pmd.sourceforge.net/
update site: http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/



Gerrit:
Gerrit is a web based code review system, facilitating online code reviews for projects using the Git version control system.



http://scn.sap.com/docs/DOC-42271
http://www.infoq.com/articles/Gerrit-jenkins-hudson


More Details :

https://blog.jetbrains.com/upsource/category/practices/

How to find a view in Eclipse RCP

The following technique can be used to get the currently active page and any view within that page.


IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = page.findView(MyView.ID);


The MyView.ID specified the ID of the view as declared in the plugin.xml file.

5 Strategies for Getting More Work Done in Less Time

Summary.    You’ve got more to do than could possibly get done with your current work style. You’ve prioritized. You’ve planned. You’ve dele...