1 19 package org.netbeans.modules.localhistory.ui.view; 20 import org.netbeans.modules.localhistory.ui.actions.*; 21 import org.netbeans.modules.localhistory.ui.revert.*; 22 import org.netbeans.modules.localhistory.store.StoreEntry; 23 import org.netbeans.modules.localhistory.utils.Utils; 24 import org.openide.LifecycleManager; 25 import org.openide.nodes.Node; 26 import org.openide.util.HelpCtx; 27 import org.openide.util.NbBundle; 28 import org.openide.util.RequestProcessor; 29 import org.openide.util.actions.NodeAction; 30 31 35 public class RevertFileAction extends NodeAction { 36 37 public RevertFileAction() { 38 setIcon(null); 39 putValue("noIconInMenu", Boolean.TRUE); } 41 42 public HelpCtx getHelpCtx() { 43 return new HelpCtx(getClass()); 44 } 45 46 protected void performAction(final Node[] activatedNodes) { 47 LifecycleManager.getDefault().saveAll(); 52 53 RequestProcessor.getDefault().post(new Runnable () { 55 public void run() { 56 Utils.revert(activatedNodes); 57 } 58 }); 59 } 61 62 protected boolean enable(Node[] activatedNodes) { 63 if(activatedNodes == null || activatedNodes.length != 1) { 64 return false; 65 } 66 for(Node node : activatedNodes) { 67 StoreEntry se = node.getLookup().lookup(StoreEntry.class); 68 if(se == null) { 69 return false; 70 } 71 } 72 return true; 73 } 74 75 public String getName() { 76 return NbBundle.getMessage(RevertFileAction.class, "LBL_RevertFileAction"); 77 } 78 } 79 | Popular Tags |