Eclipse Forum says it should be available in next Eclipse release or in Eclipse patch.
Tuesday, June 23, 2009
Eclipse RCP "Close Others" Right click option
The "Close Others" action on right click of mouse button which closes all the other editors except for the current one is only available for Editors but not for views yet in Eclipse Ganymede as shown below:

Eclipse Forum says it should be available in next Eclipse release or in Eclipse patch.
Eclipse Forum says it should be available in next Eclipse release or in Eclipse patch.
Monday, May 11, 2009
Java Time and Daylight Savings
I wanted to create a Java based clock which can show timings of London and Newyork. I got stuck at the point of handling DayLight savings. Searched over Google and found out that Java on its own is not handling DayLight Savings.
For ex:
Calendar londonCal = Calendar.getInstance(TimeZone.getTimeZone("Europe/London"));
String londonTime = londonCal.get(Calendar.HOUR_OF_DAY)+":"+londonCal.get(Calendar.MINUTE)+":"+londonCal.get(Calendar.SECOND);
Calendar newyorkCal = Calendar.getInstance(TimeZone.getTimeZone("US/Central"));
String newyorkTime = newyorkCal.get(Calendar.HOUR_OF_DAY)+":"+newyorkCal.get(Calendar.MINUTE)+":"+newyorkCal.get(Calendar.SECOND);
System.out.println("London: "+londonTime+"\nNewYork: "+newyorkTime);
I thought the above code would have handled DayLight savings but to my surprise i got below result in console:
London: 12:23:17
Newyork: 6:23:17
stating diff in time to be:6 hours
wherein currently its daylight savings so it should have been 5 hours and i should have got a result of
London: 12:23:17
Newyork: 7:23:17
hmm either i am not finding a way to get java calendar handle daylight saving or there isnt one which does tht?
For ex:
Calendar londonCal = Calendar.getInstance(TimeZone.getTimeZone("Europe/London"));
String londonTime = londonCal.get(Calendar.HOUR_OF_DAY)+":"+londonCal.get(Calendar.MINUTE)+":"+londonCal.get(Calendar.SECOND);
Calendar newyorkCal = Calendar.getInstance(TimeZone.getTimeZone("US/Central"));
String newyorkTime = newyorkCal.get(Calendar.HOUR_OF_DAY)+":"+newyorkCal.get(Calendar.MINUTE)+":"+newyorkCal.get(Calendar.SECOND);
System.out.println("London: "+londonTime+"\nNewYork: "+newyorkTime);
I thought the above code would have handled DayLight savings but to my surprise i got below result in console:
London: 12:23:17
Newyork: 6:23:17
stating diff in time to be:6 hours
wherein currently its daylight savings so it should have been 5 hours and i should have got a result of
London: 12:23:17
Newyork: 7:23:17
hmm either i am not finding a way to get java calendar handle daylight saving or there isnt one which does tht?
Wednesday, March 11, 2009
Ubuntu Eclipse Subverion Stored Password delete
In Ubuntu, To clear stored cached passwords.
1. If eclipse is running, close your eclipse instance.
2. sudo rm -rf /home/%user%/.subversion/auth
3. Open your eclipse installation.
4. Open Configurations.
5. Open org.eclipse.core.runtime folder.
6. ls -a
7. sudo rm -rf .keyring
8. sudo gedit /home/%user%/.subversion/config
9. Uncomment 'store-passwords' inside 'auth'.
10. modify store-passwords=yes.
11. Restart eclipse, add your repository location and see that you are prompted with user/password dialog box.
1. If eclipse is running, close your eclipse instance.
2. sudo rm -rf /home/%user%/.subversion/auth
3. Open your eclipse installation.
4. Open Configurations.
5. Open org.eclipse.core.runtime folder.
6. ls -a
7. sudo rm -rf .keyring
8. sudo gedit /home/%user%/.subversion/config
9. Uncomment 'store-passwords' inside 'auth'.
10. modify store-passwords=yes.
11. Restart eclipse, add your repository location and see that you are prompted with user/password dialog box.
Tuesday, May 20, 2008
Eclipse Plugins: A Common Library / jars Plugin
How to create a Plugin which holds all the libraries (jars) required by a RCP Application?
Plugin:
1. test.core.lib
2. testPluginA
Library: junit.jar
Procedure:
1. Create Plugin: test.core.lib - A non-UI contributing plugin. This plugin would have only one class: Activator.
2. Create folder:lib on test.core.lib project. Copy junit.jar to lib folder.
3. Modify Plugin.xml of test.core.lib, Open Runtime tab, add this jar in classpath and expose all the packages of this jar.
4. Create Plugin: testPluginA - A UI contributing plugin. This plugin would have a default view, perspective and application classes.
5. Modify Plugin.xml of testPluginA - Open Dependency tab, add dependency on test.core.lib plugin.
6. Create a ViewTest class which extends junit.framework.TestCase. Add a test method like :
public static void testMessageHelloWorld(){
System.out.println("Test Class invoked showing message: Hello World");
}
7. Open View class, call this method in View's createPartControl() method.
8. Run testPluginA as eclipse application.
9. The following message should be displayed in console:
"Test Class invoked showing message: Hello World".
Plugin:
1. test.core.lib
2. testPluginA
Library: junit.jar
Procedure:
1. Create Plugin: test.core.lib - A non-UI contributing plugin. This plugin would have only one class: Activator.
2. Create folder:lib on test.core.lib project. Copy junit.jar to lib folder.
3. Modify Plugin.xml of test.core.lib, Open Runtime tab, add this jar in classpath and expose all the packages of this jar.
4. Create Plugin: testPluginA - A UI contributing plugin. This plugin would have a default view, perspective and application classes.
5. Modify Plugin.xml of testPluginA - Open Dependency tab, add dependency on test.core.lib plugin.
6. Create a ViewTest class which extends junit.framework.TestCase. Add a test method like :
public static void testMessageHelloWorld(){
System.out.println("Test Class invoked showing message: Hello World");
}
7. Open View class, call this method in View's createPartControl() method.
8. Run testPluginA as eclipse application.
9. The following message should be displayed in console:
"Test Class invoked showing message: Hello World".
Thursday, May 15, 2008
Simple Steps to create and work with Eclipse Extension Point
Follwing is a sample extension point which shows simple steps to define and work with Extension Points/define custom Extension Points.
Requirement: A simple Hello World message display when an event is triggered.
Plugins:
testcore - defines a plugin extension point called eventhandler.
testplugin1 - contributes to the extension point - eventhandler.
testplugin2 - contributes to the extension point - eventhandler.
Step A: Create Extension Point: EventHandler
open plugin.xml of plugin:testcore.
1. Open Extension points tab, Click Add, which opens a New Extension Point Dialog, Give the following entries as shown in the below picture.
2. Click Enter and u will be opened eventhandler.exsd. Click on Definition tab and u should be opened with the below screen.
fig 2: ExtenionPoint eventhandler definition
fig 3: Extension Point Attribute: "id" definition

package testcore.eventhandler;
public interface IEventHandler {
public void handleEvent(String message);
}
2c) Open Runtime tab, Add testcore.eventhandler package for IEventHandler to be visible to other plugins
3. Open plugin.xml of Plugin: testplugin1.
3a) Open Dependencies tab, Add testcore plugin as a dependency.
3b) Open Extensions tab, Add testcore.eventhandler extension point. And edit id and class values for the event handler as shown in picture below:
3c) Create Plugin1EventHandler class in testplugin1.eventhandler package.
package testplugin1.eventhandler;
import testcore.eventhandler.IEventHandler;
public class Plugin1EventHandler implements IEventHandler {
public Plugin1EventHandler() {
// TODO Auto-generated constructor stub
}
public void handleEvent(String message) {
// TODO Auto-generated method stub
System.out.println("in Plugin1EventHandler:"+message);
}
}
4. Open plugin.xml of Plugin: testplugin2.
4a) Open Dependencies tab, Add testcore plugin as a dependency.
4b) Open Extensions tab, Add testcore.eventhandler extension point. And edit id and class values for the event handler as shown in picture below:
4c) Create Plugin2EventHandler class in testplugin1.eventhandler package.
package testplugin2.eventhandler;
import testcore.eventhandler.IEventHandler;
public class Plugin2EventHandler implements IEventHandler {
public Plugin2EventHandler() {
// TODO Auto-generated constructor stub
}
public void handleEvent(String message) {
// TODO Auto-generated method stub
System.out.println("in Plugin2EventHandler:"+message);
}
}
5. Open Activator class of testcore plugin and do the following in start method.
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint("testcore.eventhandler");
if (point == null) return;
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; i++){
IConfigurationElement[] configElements = extensions[i]
.getConfigurationElements();
for(IConfigurationElement configElement : configElements){
System.out.println(configElement.getAttribute("class"));
IEventHandler eventHandler = (IEventHandler) configElement
.createExecutableExtension("class");
eventHandler.handleEvent("Hello World");
}
}
}
6. Run testcore as Eclipse Application. Add testplugin1 and testplugin2 to its run time class path. You should see the following messages:
testplugin1.eventhandler.Plugin1EventHandler
in Plugin1EventHandler:Hello World
testplugin2.eventhandler.Plugin2EventHandler
in Plugin2EventHandler:Hello World
which shows the contributor plugins : testplugin1 and testplugin2 's EventHandler's getting called.
Requirement: A simple Hello World message display when an event is triggered.
Plugins:
testcore - defines a plugin extension point called eventhandler.
testplugin1 - contributes to the extension point - eventhandler.
testplugin2 - contributes to the extension point - eventhandler.
Step A: Create Extension Point: EventHandler
open plugin.xml of plugin:testcore.
1. Open Extension points tab, Click Add, which opens a New Extension Point Dialog, Give the following entries as shown in the below picture.
fig 4: Extension Point Attribute: "class" definition
2b. Create IEventHandler class in package testcore.eventhandler with following details:package testcore.eventhandler;
public interface IEventHandler {
public void handleEvent(String message);
}
2c) Open Runtime tab, Add testcore.eventhandler package for IEventHandler to be visible to other plugins
3. Open plugin.xml of Plugin: testplugin1.
3a) Open Dependencies tab, Add testcore plugin as a dependency.
3b) Open Extensions tab, Add testcore.eventhandler extension point. And edit id and class values for the event handler as shown in picture below:
3c) Create Plugin1EventHandler class in testplugin1.eventhandler package.
package testplugin1.eventhandler;
import testcore.eventhandler.IEventHandler;
public class Plugin1EventHandler implements IEventHandler {
public Plugin1EventHandler() {
// TODO Auto-generated constructor stub
}
public void handleEvent(String message) {
// TODO Auto-generated method stub
System.out.println("in Plugin1EventHandler:"+message);
}
}
4. Open plugin.xml of Plugin: testplugin2.
4a) Open Dependencies tab, Add testcore plugin as a dependency.
4b) Open Extensions tab, Add testcore.eventhandler extension point. And edit id and class values for the event handler as shown in picture below:
4c) Create Plugin2EventHandler class in testplugin1.eventhandler package.
package testplugin2.eventhandler;
import testcore.eventhandler.IEventHandler;
public class Plugin2EventHandler implements IEventHandler {
public Plugin2EventHandler() {
// TODO Auto-generated constructor stub
}
public void handleEvent(String message) {
// TODO Auto-generated method stub
System.out.println("in Plugin2EventHandler:"+message);
}
}
5. Open Activator class of testcore plugin and do the following in start method.
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint("testcore.eventhandler");
if (point == null) return;
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; i++){
IConfigurationElement[] configElements = extensions[i]
.getConfigurationElements();
for(IConfigurationElement configElement : configElements){
System.out.println(configElement.getAttribute("class"));
IEventHandler eventHandler = (IEventHandler) configElement
.createExecutableExtension("class");
eventHandler.handleEvent("Hello World");
}
}
}
6. Run testcore as Eclipse Application. Add testplugin1 and testplugin2 to its run time class path. You should see the following messages:
testplugin1.eventhandler.Plugin1EventHandler
in Plugin1EventHandler:Hello World
testplugin2.eventhandler.Plugin2EventHandler
in Plugin2EventHandler:Hello World
which shows the contributor plugins : testplugin1 and testplugin2 's EventHandler's getting called.
Tuesday, May 6, 2008
Basic Authentication in Sun AppServer
Follow the below steps to configure a particular user with https enabled web app:
1. In the sun-web.xml of the webapp:
<sun-web-app>
<context-root>/test</context-root>
<security-role-mapping>
<role-name>my-role</role-name>
<principal-name>user1</principal-name>
<group-name>my-group</group-name>
</security-role-mapping>
</sun-web-app>
2. In the web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Site</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>my-role</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>file</realm-name>
</login-config>
<security-role>
<role-name>my-role</role-name>
</security-role>
</web-app>
3. In Sun App Server admin console:
Under Configuration-->Security-->Realms-->File --> Manage Users
User: user1
Password: xxxx
Confirm Password: xxxx
Group List: my-role
Under Configuration-->Security-->Realms-->Certificate
Property: assign-groups : my-role
Under Configuration-->HTTP Listeners
Add new https listener with port 443 and enable all authentication and ssl'S in that.
Now launch your web app. It should pop up a username and pwd dialog box for basic authentication.
1. In the sun-web.xml of the webapp:
<sun-web-app>
<context-root>/test</context-root>
<security-role-mapping>
<role-name>my-role</role-name>
<principal-name>user1</principal-name>
<group-name>my-group</group-name>
</security-role-mapping>
</sun-web-app>
2. In the web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Site</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>my-role</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>file</realm-name>
</login-config>
<security-role>
<role-name>my-role</role-name>
</security-role>
</web-app>
3. In Sun App Server admin console:
Under Configuration-->Security-->Realms-->File --> Manage Users
User: user1
Password: xxxx
Confirm Password: xxxx
Group List: my-role
Under Configuration-->Security-->Realms-->Certificate
Property: assign-groups : my-role
Under Configuration-->HTTP Listeners
Add new https listener with port 443 and enable all authentication and ssl'S in that.
Now launch your web app. It should pop up a username and pwd dialog box for basic authentication.
Sunday, March 30, 2008
Easy Creation, Export and Import of SSL Certificates for Sun AppServer
Following are the easy steps to create, export and import SSL Certificates.
1. Open Command Prompt, Point to ${Sun_HOME}/AppServer9/Domains/Domain1/config folder.
2. Run: keytool -genkey -alias aliasname -keyalg RSA -keystore keystore.jks
2. Create "aliasname.cer" in Sun/AppServer9/Domains/Domain1/config folder.
3. Run: keytool -export -alias aliasname-file aliasname.cer -keystore keystore.jks
4. Run: keytool -import -v -trustcacerts -alias aliasname -file aliasname.cer -keystore cacerts.jks
Subscribe to:
Comments (Atom)