Wednesday, July 27, 2016

MiniTool Partition Wizard

This a great tool for disk partition. you can easily create a new partition , merge two partition, extend a partition even if it is a system partition.

try it !
https://www.partitionwizard.com/



 

Sunday, June 26, 2016

“Java heap space” error in eclipse (Windows 7)

Little background : I am currently working in a project based on Eclipse RCP.  In this project whenever i need to setup a new work-space or dependency of my project change i need to resolve the target.

During resolving the target i was getting the  “Java heap space error in eclipse" frequently : i have tried different solution from web but i it never worked. specially changing the JVM argument in the eclipse.ini file never worked for me.

Fist of all i did not know how to check  current JVM min and max heap size. after googling i have found this nice tool which come by-default with JDK .

JConsole : 
Using JConsole you can check the current minimum and maximum head size alocated in the JVM for a program or process:

Please check the below link for details
http://docs.oracle.com/javase/7/docs/technotes/guides/management/jconsole.html



Now i know how much heap size is allocated currently: so i need to increase the heap size.
For increasing the heap size i have done the following  :

Try setting a Windows System Environment variable called _JAVA_OPTIONS with the heap size you want. Java should be able to find it and act accordingly.






 setting windows  system  env variable _JAVA_OPTIONS as -Xms2048m -Xmx4096m -XX:MaxPermSize=1024m


works for me  :)



Wednesday, March 30, 2016

How to select an item in a Jface TableViewer after a dialog becomes activated

Scenario : We have a Jface Dialog and a TableViewer or a TreeViewer on that dialog. after the dialog become active we want to select an item and want to fire the TableViewers selection listener.


Step 1. Add a selection listener to the TableViewer :

Note : You should do this in createDialogArea() method.

  getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {  
   @Override  
   public void selectionChanged(SelectionChangedEvent event) {  
   final Object selection = getSingleSelection(event.getSelection());  
   if (selection instanceof SomeObject) {  
    DoSomething();  
   }  
   }  
  });  
  }  


Step 2. Add a Shell Listner :(again in createDialogArea() method)

  getShell().addShellListener(new ShellAdapter()  
  {  
   @Override  
   public void shellActivated(ShellEvent e) {    
   super.shellActivated(e);  
   if (getLines().size()>0) {  
    getViewer().getControl().setFocus();  
    getTableViewer().setSelection(new StructuredSelection(get.getElementAt(0)),true);  
   }  
   }  
  });  



You are done ! now after the shell become active the first item of the TableViews will be selected and a selection listner will be fired . Enjoy!


Sunday, October 4, 2015

Css Stying in E4 Compatibility Layer

I can apply Css Styling  in my Eclipse 3.x plugin using following steps:


Step 1. Configuring CSS Stylesheets:


1.1 add a css file





1.2 add a theme using theme extension point






1.3






Step 2. add css id/class to your swt control:
final Composite composite = new Composite(parent, SWT.NONE);
composite.setData("org.eclipse.e4.ui.css.id","MyCSSTagForLabel");

Step 3. add the folowing block to your default.css file:

#MyCSSTagForLabel{
  color: black;
  background: #99b4d1;
  swt-corner-radius: 20;
}

Done!

Thursday, September 10, 2015

Eclipse RCP : How to check state(toggle) of a menu items or toolbar items inside handlers

In Eclipse RCP there are at-least two different ways we  can check the state of a menu item or  a toolbar item inside a handlers execute method :

Option 1 :


ICommandService service =(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = service.getCommand("org.eclipse.example.command.toggle");
State state = command.getState("org.eclipse.example.command.toggleState");
System.out.println(state.getValue());

//state.setValue(!(Boolean) state.getValue());



Option 2:


   @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
   
   
        Event selEvent = (Event) event.getTrigger();
        Widget widget =  selEvent.widget;
        if (widget instanceof ToolItem) {        
        isSelected = ((ToolItem)widget).getSelection();
}else {
isSelected = ((MenuItem)widget).getSelection();
}
}


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.

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...