KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > console > actions > EditConsoleConfiguration


1 /*
2  * Created on 15-Dec-2004
3  *
4  */

5 package org.hibernate.eclipse.console.actions;
6
7 import java.util.Iterator JavaDoc;
8
9 import org.eclipse.jface.viewers.StructuredSelection;
10 import org.eclipse.jface.wizard.WizardDialog;
11 import org.eclipse.ui.IWorkbenchWindow;
12 import org.eclipse.ui.PlatformUI;
13 import org.hibernate.HibernateException;
14 import org.hibernate.console.ConsoleConfiguration;
15 import org.hibernate.console.node.BaseNode;
16 import org.hibernate.eclipse.console.HibernateConsolePlugin;
17 import org.hibernate.eclipse.console.wizards.ConsoleConfigurationCreationWizard;
18
19 /**
20  * @author max
21  *
22  */

23 public class EditConsoleConfiguration extends ConsoleConfigurationBasedAction {
24
25     /**
26      * @param text
27      */

28     public EditConsoleConfiguration() {
29         super("Edit Configuration");
30     }
31
32     protected void doRun() {
33         for (Iterator JavaDoc i = getSelectedNonResources().iterator(); i.hasNext();) {
34             try {
35                 BaseNode node = ((BaseNode) i.next());
36                 final ConsoleConfiguration config = node.getConsoleConfiguration();
37                 ConsoleConfigurationCreationWizard wizard = new ConsoleConfigurationCreationWizard();
38                 wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(config));
39                 IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
40                 
41                 WizardDialog dialog = new WizardDialog(win.getShell(), wizard);
42                 dialog.open(); // This opens a dialog
43
} catch(HibernateException he) {
44                 HibernateConsolePlugin.getDefault().showError(null, "Exception while trying to edit configuration", he);
45             }
46         }
47     }
48
49     protected boolean updateState(ConsoleConfiguration consoleConfiguration) {
50         return true;
51     }
52 }
53
Popular Tags