KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > console > views > properties > HibernatePropertySourceProvider


1 /*
2  * Created on 22-Mar-2005
3  *
4  */

5 package org.hibernate.eclipse.console.views.properties;
6
7 import org.eclipse.ui.views.properties.IPropertySource;
8 import org.eclipse.ui.views.properties.IPropertySourceProvider;
9 import org.hibernate.Session;
10 import org.hibernate.console.ConsoleConfiguration;
11 import org.hibernate.console.QueryPage;
12 import org.hibernate.eclipse.console.views.QueryPageTabView;
13
14 import com.l2fprod.common.propertysheet.Property;
15
16 public class HibernatePropertySourceProvider implements IPropertySourceProvider
17 {
18     // TODO: refactor to be some interface that can provide currentsession and currentconfiguration
19
private final QueryPageTabView view;
20
21     public HibernatePropertySourceProvider(QueryPageTabView view) {
22         this.view = view;
23     }
24
25     public IPropertySource getPropertySource(Object JavaDoc object) {
26         if (object instanceof QueryPage)
27         {
28             return new QueryPagePropertySource((QueryPage)object);
29         }
30         else if (object instanceof Property)
31         {
32             return new HibernatePropertySource(object);
33         }
34         else {
35             // maybe we should be hooked up with the queryview to get this ?
36
Session currentSession = view.getSelectedQueryPage().getSession();
37             ConsoleConfiguration currentConfiguration = view.getSelectedQueryPage().getConsoleConfiguration();
38             if(currentSession.contains(object)) {
39                 return new EntityPropertySource(object, currentSession, currentConfiguration);
40             } else {
41                 return null;
42             }
43             
44         }
45         
46     }
47 }
Popular Tags