1 19 20 package org.netbeans.modules.dbschema.jdbcimpl; 21 22 import java.util.ResourceBundle ; 23 24 import org.openide.loaders.*; 25 import org.openide.nodes.Node; 26 import org.openide.util.actions.*; 27 import org.openide.util.HelpCtx; 28 import org.openide.util.NbBundle; 29 import org.openide.windows.WindowManager; 30 31 public class CaptureSchemaAction extends CallableSystemAction { 32 33 private ResourceBundle bundle = NbBundle.getBundle("org.netbeans.modules.dbschema.jdbcimpl.resources.Bundle"); 35 36 public CaptureSchemaAction() { 37 } 38 39 40 public String getName () { 41 return bundle.getString("ActionName"); } 43 44 45 public HelpCtx getHelpCtx () { 46 return new HelpCtx("dbschema_ctxhelp_wizard"); } 48 49 protected String iconResource () { 50 return "org/netbeans/modules/dbschema/jdbcimpl/DBschemaDataIcon.gif"; } 52 53 public void performAction() { 54 try { 55 TemplateWizard wizard = new TemplateWizard(); 56 57 DataObject templateDirs[] = wizard.getTemplatesFolder().getChildren(); 58 for (int i = 0; i < templateDirs.length; i++) 59 if (templateDirs[i].getName().equals("Databases")) { DataObject templates[] = ((DataFolder) templateDirs[i]).getChildren(); 61 for (int j = 0; j < templates.length; j++) 62 if (templates[j].getName().equals("Database Schema")) { Node n[] = WindowManager.getDefault().getRegistry().getActivatedNodes(); 64 int nId = -1; 65 for (int k = 0; k < n.length; k++) 66 if (n[k].getCookie(DataFolder.class) instanceof DataFolder) { 67 nId = k; 68 break; 69 } 70 71 wizard.putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); wizard.putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); wizard.putProperty("WizardPanel_contentNumbered", Boolean.TRUE); String [] prop = (String []) wizard.getProperty("WizardPanel_contentData"); String [] stepsNames = new String [] { 76 wizard.targetChooser().getClass().toString().trim().equalsIgnoreCase("class org.openide.loaders.TemplateWizard2") ? bundle.getString("TargetLocation") : 77 prop[0], 78 bundle.getString("TargetLocation"), 79 bundle.getString("ConnectionChooser"), 80 bundle.getString("TablesChooser") 81 }; 82 wizard.putProperty("WizardPanel_contentData", stepsNames); wizard.setTitle(bundle.getString("WizardTitleName")); 84 85 if(nId >= 0) { 86 wizard.setTargetFolder((DataFolder) n[nId].getCookie(DataFolder.class)); 87 wizard.instantiate(templates[j]); 88 } else 89 wizard.instantiate(templates[j]); 90 91 break; 92 } 93 break; 94 } 95 } catch(Exception exc) { 96 exc.printStackTrace(); 97 } 98 } 99 } 100 | Popular Tags |