1 19 20 21 package org.netbeans.modules.properties; 22 23 24 import java.text.MessageFormat ; 25 26 import org.openide.actions.RenameAction; 27 import org.openide.nodes.Node; 28 import org.openide.NotifyDescriptor; 29 import org.openide.DialogDisplayer; 30 import org.openide.util.NbBundle; 31 32 33 41 public class LangRenameAction extends RenameAction { 42 43 44 static final long serialVersionUID =-6548687347804513177L; 45 46 47 48 protected void performAction (Node[] activatedNodes) { 49 Node n = activatedNodes[0]; Node.Cookie cake = n.getCookie(PropertiesLocaleNode.class); 51 PropertiesLocaleNode pln = (PropertiesLocaleNode)cake; 52 53 String lang = Util.getLocaleSuffix(pln.getFileEntry()); 54 if (lang.length() > 0) 55 if (lang.charAt(0) == PropertiesDataLoader.PRB_SEPARATOR_CHAR) 56 lang = lang.substring(1); 57 58 NotifyDescriptor.InputLine dlg = new NotifyDescriptor.InputLine( 59 NbBundle.getMessage(LangRenameAction.class, 60 "LBL_RenameLabel"), NbBundle.getMessage(LangRenameAction.class, 62 "LBL_RenameTitle")); 64 dlg.setInputText(lang); 65 if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(dlg))) { 66 try { 67 pln.setName(Util.assembleName (pln.getFileEntry().getDataObject().getPrimaryFile().getName(), dlg.getInputText())); 68 } 69 catch (IllegalArgumentException e) { 70 NotifyDescriptor.Message msg = new NotifyDescriptor.Message( 72 MessageFormat.format( 73 NbBundle.getBundle("org.openide.actions.Bundle").getString("MSG_BadFormat"), 74 new Object [] {pln.getName()}), 75 NotifyDescriptor.ERROR_MESSAGE); 76 77 DialogDisplayer.getDefault().notify(msg); 78 } 79 } 80 } 81 } 82 | Popular Tags |