1 19 20 package org.netbeans.modules.db.explorer.actions; 21 22 import java.text.MessageFormat ; 23 24 import org.openide.DialogDisplayer; 25 import org.openide.NotifyDescriptor; 26 import org.openide.nodes.Node; 27 import org.openide.util.NbBundle; 28 import org.openide.util.RequestProcessor; 29 30 import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo; 31 32 public class RefreshChildrenAction extends DatabaseAction { 33 static final long serialVersionUID =-2858583720506557569L; 34 35 protected boolean enable(Node[] activatedNodes) { 36 if (activatedNodes != null && activatedNodes.length == 1) 37 if (activatedNodes[0].getChildren().getNodesCount() == 1 && activatedNodes[0].getChildren().getNodes()[0].getName().equals(NbBundle.getBundle("org.netbeans.modules.db.resources.Bundle").getString("WaitNode"))) return false; 39 else 40 return true; 41 42 return false; 43 } 44 45 public void performAction (Node[] activatedNodes) { 46 final Node node; 47 if (activatedNodes != null && activatedNodes.length == 1) 48 node = activatedNodes[0]; 49 else 50 return; 51 52 RequestProcessor.getDefault().post(new Runnable () { 53 public void run () { 54 try { 55 DatabaseNodeInfo nfo = (DatabaseNodeInfo) node.getCookie(DatabaseNodeInfo.class); 56 if (nfo != null) 57 nfo.refreshChildren(); 58 } catch(Exception exc) { 59 String message = bundle().getString("RefreshChildrenErrorPrefix") + " " + MessageFormat.format(bundle().getString("EXC_ConnectionError"), new String [] {exc.getMessage()}); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE)); 61 } 62 } 63 }, 0); 64 } 65 } 66 | Popular Tags |