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