KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > console > views > ConfigurationsViewActionGroup


1 /*
2  * Created on 2004-10-29 by max
3  *
4  */

5 package org.hibernate.eclipse.console.views;
6
7 import org.eclipse.jface.action.Action;
8 import org.eclipse.jface.action.IMenuManager;
9 import org.eclipse.jface.action.Separator;
10 import org.eclipse.jface.viewers.IStructuredSelection;
11 import org.eclipse.jface.viewers.StructuredViewer;
12 import org.eclipse.ui.IActionBars;
13 import org.eclipse.ui.IViewPart;
14 import org.eclipse.ui.actions.ActionFactory;
15 import org.eclipse.ui.actions.ActionGroup;
16 import org.eclipse.ui.actions.SelectionListenerAction;
17 import org.hibernate.console.ConsoleConfiguration;
18 import org.hibernate.eclipse.console.actions.AddConfigurationAction;
19 import org.hibernate.eclipse.console.actions.BuildSessionFactoryAction;
20 import org.hibernate.eclipse.console.actions.DeleteConfigurationAction;
21 import org.hibernate.eclipse.console.actions.EditConsoleConfiguration;
22 import org.hibernate.eclipse.console.actions.RefreshAction;
23 import org.hibernate.tool.hbm2ddl.SchemaExport;
24
25 /**
26  * @author max
27  *
28  */

29 public class ConfigurationsViewActionGroup extends ActionGroup {
30
31     private Action addConfigurationAction;
32     private SelectionListenerAction deleteConfigurationAction;
33     private SelectionListenerAction refreshAction;
34     private SelectionListenerAction connectAction;
35     private SelectionListenerAction schemaExportAction;
36     private EditConsoleConfiguration editConfigurationAction;
37
38     public ConfigurationsViewActionGroup(IViewPart part, StructuredViewer selectionProvider) {
39         
40         addConfigurationAction = new AddConfigurationAction(part);
41         
42         deleteConfigurationAction = new DeleteConfigurationAction();
43         selectionProvider.addSelectionChangedListener(deleteConfigurationAction);
44         IActionBars actionBars= part.getViewSite().getActionBars();
45            actionBars.setGlobalActionHandler(
46               ActionFactory.DELETE.getId(),
47               deleteConfigurationAction);
48            
49         refreshAction = new RefreshAction(selectionProvider);
50         selectionProvider.addSelectionChangedListener(refreshAction);
51         
52         connectAction = new BuildSessionFactoryAction(selectionProvider);
53         selectionProvider.addSelectionChangedListener(connectAction);
54         /*IMenuManager manager = part.getViewSite().getActionBars().getMenuManager();
55         manager.add(addConfigurationAction);*/

56         
57         schemaExportAction = new SchemaExportAction(selectionProvider);
58         selectionProvider.addSelectionChangedListener(schemaExportAction);
59         
60         editConfigurationAction = new EditConsoleConfiguration();
61         selectionProvider.addSelectionChangedListener(editConfigurationAction);
62         
63     }
64
65     public void fillContextMenu(IMenuManager menu) {
66     
67         menu.add(connectAction);
68         menu.add(refreshAction);
69         menu.add(new Separator());
70         menu.add(addConfigurationAction);
71         menu.add(editConfigurationAction);
72         menu.add(deleteConfigurationAction);
73         menu.add(new Separator());
74         menu.add(schemaExportAction);
75         
76     }
77     
78     public void fillActionBars(IActionBars actionBars) {
79         
80         actionBars.getToolBarManager().add(addConfigurationAction);
81     }
82 }
83
Popular Tags