1 19 20 package org.netbeans.modules.db.explorer.actions; 21 22 import java.sql.*; 23 import java.text.MessageFormat ; 24 25 import org.netbeans.lib.ddl.impl.*; 26 import org.openide.*; 27 import org.openide.nodes.*; 28 import org.netbeans.modules.db.explorer.nodes.*; 29 import org.netbeans.modules.db.explorer.dlg.*; 30 import org.netbeans.modules.db.explorer.infos.*; 31 32 public class CreateViewAction extends DatabaseAction { 33 static final long serialVersionUID =-1640355770860785644L; 34 35 public void performAction(Node[] activatedNodes) { 36 Node node; 37 if (activatedNodes != null && activatedNodes.length>0) 38 node = activatedNodes[0]; 39 else 40 return; 41 42 try { 43 DatabaseNodeInfo info = (DatabaseNodeInfo)node.getCookie(DatabaseNodeInfo.class); 44 45 if (! info.getDriverSpecification().areViewsSupported()) { 46 String message = MessageFormat.format(bundle().getString("MSG_ViewsAreNotSupported"), new String [] {info.getConnection().getMetaData().getDatabaseProductName().trim()}); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.INFORMATION_MESSAGE)); 48 return; 49 } 50 51 ViewListNodeInfo nfo = (ViewListNodeInfo)info.getParent(nodename); 52 Specification spec = (Specification)nfo.getSpecification(); 53 54 AddViewDialog dlg = new AddViewDialog(spec, info); 56 if (dlg.run()) { 57 nfo.addView(dlg.getViewName()); 58 } 59 } catch(Exception exc) { 60 String message = MessageFormat.format(bundle().getString("ERR_UnableToPerformOperation"), new String [] {node.getName(), exc.getMessage()}); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE)); 62 } 63 } 64 } 65 | Popular Tags |