1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.actions.tag; 21 22 import org.openide.util.NbBundle; 23 import org.openide.util.HelpCtx; 24 import org.openide.DialogDisplayer; 25 import org.openide.DialogDescriptor; 26 import org.openide.nodes.Node; 27 import org.netbeans.modules.versioning.system.cvss.CvsVersioningSystem; 28 import org.netbeans.modules.versioning.system.cvss.FileInformation; 29 import org.netbeans.modules.versioning.system.cvss.ExecutorGroup; 30 import org.netbeans.modules.versioning.system.cvss.ui.actions.AbstractSystemAction; 31 import org.netbeans.lib.cvsclient.command.tag.TagCommand; 32 33 import javax.swing.*; 34 import java.awt.Dialog ; 35 import java.io.File ; 36 import java.text.MessageFormat ; 37 38 43 public class TagAction extends AbstractSystemAction { 44 45 private static TagCommand commandTemplate = new TagCommand(); 46 private static final int enabledForStatus = FileInformation.STATUS_VERSIONED_MERGE 47 | FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY 48 | FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY 49 | FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY 50 | FileInformation.STATUS_VERSIONED_UPTODATE; 51 52 53 protected String getBaseName(Node [] activatedNodes) { 54 return "CTL_MenuItem_Tag"; } 56 57 protected int getFileEnabledStatus() { 58 return enabledForStatus; 59 } 60 61 protected int getDirectoryEnabledStatus() { 62 return FileInformation.STATUS_MANAGED & ~FileInformation.STATUS_NOTVERSIONED_EXCLUDED & ~FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY; 63 } 64 65 public void performCvsAction(Node[] nodes) { 66 File [] roots = getContext(nodes).getFiles(); 67 68 TagCommand cmd = new TagCommand(); 69 copy (cmd, commandTemplate); 70 71 String title = MessageFormat.format(NbBundle.getBundle(TagAction.class).getString("CTL_TagDialog_Title"), getContextDisplayName(nodes)); 72 73 TagSettings settings = new TagSettings(roots); 74 settings.setCommand(cmd); 75 76 JButton tag = new JButton(NbBundle.getMessage(TagAction.class, "CTL_TagDialog_Action_Tag")); 77 settings.putClientProperty("OKButton", tag); 78 settings.refreshComponents(); 79 tag.setToolTipText(NbBundle.getMessage(TagAction.class, "TT_TagDialog_Action_Tag")); 80 DialogDescriptor descriptor = new DialogDescriptor( 81 settings, 82 title, 83 true, 84 new Object [] { tag, DialogDescriptor.CANCEL_OPTION }, 85 tag, 86 DialogDescriptor.DEFAULT_ALIGN, 87 new HelpCtx(TagAction.class), 88 null); 89 descriptor.setClosingOptions(null); 90 Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor); 91 dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TagAction.class, "ACSD_TagDialog")); 92 dialog.setVisible(true); 93 if (descriptor.getValue() != tag) return; 94 95 settings.updateCommand(cmd); 96 copy(commandTemplate, cmd); 97 cmd.setFiles(roots); 98 99 ExecutorGroup group = new ExecutorGroup(getRunningName(nodes)); 100 group.addExecutors(TagExecutor.splitCommand(cmd, CvsVersioningSystem.getInstance(), null)); 101 group.execute(); 102 } 103 104 protected boolean asynchronous() { 105 return false; 106 } 107 108 private void copy(TagCommand c1, TagCommand c2) { 109 c1.setTag(c2.getTag()); 110 c1.setCheckThatUnmodified(c2.isCheckThatUnmodified()); 111 c1.setDeleteTag(c2.isDeleteTag()); 112 c1.setOverrideExistingTag(c2.isOverrideExistingTag()); 113 } 114 } 115 | Popular Tags |