1 19 20 package org.netbeans.modules.subversion.ui.history; 21 22 import org.netbeans.modules.subversion.ui.actions.ContextAction; 23 import org.netbeans.modules.subversion.FileInformation; 24 import org.netbeans.modules.subversion.util.Context; 25 import org.netbeans.modules.subversion.util.SvnUtils; 26 import org.netbeans.modules.versioning.util.Utils; 27 import org.netbeans.api.project.Project; 28 import org.netbeans.api.project.ui.OpenProjects; 29 import org.openide.nodes.Node; 30 import org.openide.util.NbBundle; 31 import org.tigris.subversion.svnclientadapter.SVNUrl; 32 33 import javax.swing.*; 34 import java.io.File ; 35 import java.util.*; 36 37 42 public class SearchHistoryAction extends ContextAction { 43 44 protected String getBaseName(Node [] activatedNodes) { 45 return "CTL_MenuItem_SearchHistory"; } 47 48 protected int getFileEnabledStatus() { 49 return FileInformation.STATUS_IN_REPOSITORY; 50 } 51 52 protected int getDirectoryEnabledStatus() { 53 return FileInformation.STATUS_MANAGED & ~FileInformation.STATUS_NOTVERSIONED_EXCLUDED & ~FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY; 54 } 55 56 protected boolean asynchronous() { 57 return false; 58 } 59 60 protected void performContextAction(Node[] nodes) { 61 String title = NbBundle.getMessage(SearchHistoryAction.class, "CTL_SearchHistory_Title", getContextDisplayName(nodes)); openHistory(getContext(nodes), title); 63 } 64 65 private void openHistory(final Context context, final String title) { 66 SwingUtilities.invokeLater(new Runnable () { 67 public void run() { 68 SearchHistoryTopComponent tc = new SearchHistoryTopComponent(context); 69 tc.setDisplayName(title); 70 tc.open(); 71 tc.requestActive(); 72 File [] files = context.getFiles(); 73 if (Utils.shareCommonDataObject(files)) { 74 tc.search(); 75 } 76 } 77 }); 78 } 79 80 89 public static void openSearch(String title, String commitMessage, String username, Date date) { 90 openSearch(getDefaultContext(), title, commitMessage, username, date); 91 } 92 93 public static void openSearch(Context context, String title, String commitMessage, String username, Date date) { 94 Calendar c = Calendar.getInstance(); 95 c.setTime(date); 96 c.add(Calendar.DATE, 1); 98 Date to = c.getTime(); 99 c.setTime(date); 100 c.add(Calendar.DATE, -1); 101 Date from = c.getTime(); 102 103 if (commitMessage != null && commitMessage.indexOf('\n') != -1) { 104 commitMessage = commitMessage.substring(0, commitMessage.indexOf('\n')); 105 } 106 SearchHistoryTopComponent tc = new SearchHistoryTopComponent(context, commitMessage, username, from, to); 107 String tcTitle = NbBundle.getMessage(SearchHistoryAction.class, "CTL_SearchHistory_Title", title); tc.setDisplayName(tcTitle); 109 tc.open(); 110 tc.requestActive(); 111 tc.search(); 112 } 113 114 private static Context getDefaultContext() { 115 Project [] projects = OpenProjects.getDefault().getOpenProjects(); 116 return SvnUtils.getProjectsContext(projects); 117 } 118 119 126 public static void openSearch(SVNUrl repositoryUrl, File localRoot, long revision) { 127 SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repositoryUrl, localRoot, revision); 128 String tcTitle = NbBundle.getMessage(SearchHistoryAction.class, "CTL_SearchHistory_Title", repositoryUrl); tc.setDisplayName(tcTitle); 130 tc.open(); 131 tc.requestActive(); 132 tc.search(); 133 } 134 } 135 | Popular Tags |