KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > history > SearchHistoryTopComponent


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.subversion.ui.history;
20
21 import org.openide.windows.TopComponent;
22 import org.openide.util.NbBundle;
23 import org.openide.util.HelpCtx;
24 import org.netbeans.modules.subversion.util.Context;
25 import org.netbeans.modules.subversion.ui.diff.DiffSetupSource;
26 import org.tigris.subversion.svnclientadapter.SVNUrl;
27
28 import java.util.*;
29 import java.io.File JavaDoc;
30 import java.awt.BorderLayout JavaDoc;
31
32 /**
33  * @author Maros Sandor
34  */

35 public class SearchHistoryTopComponent extends TopComponent implements DiffSetupSource {
36
37     private SearchHistoryPanel shp;
38
39     public SearchHistoryTopComponent() {
40         getAccessibleContext().setAccessibleName(NbBundle.getMessage(SearchHistoryTopComponent.class, "ACSN_SearchHistoryT_Top_Component")); // NOI18N
41
getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SearchHistoryTopComponent.class, "ACSD_SearchHistoryT_Top_Component")); // NOI18N
42
}
43     
44     public SearchHistoryTopComponent(Context context) {
45         this(context, null, null, null, null);
46     }
47
48     public SearchHistoryTopComponent(Context context, String JavaDoc commitMessage, String JavaDoc username, Date from, Date to) {
49         this();
50         initComponents(context.getRootFiles(), commitMessage, username, from, to);
51     }
52
53     public SearchHistoryTopComponent(SVNUrl repositoryUrl, File JavaDoc localRoot, long revision) {
54         this();
55         initComponents(repositoryUrl, localRoot, revision);
56     }
57
58     public void search() {
59         shp.executeSearch();
60     }
61     
62     private void initComponents(SVNUrl repositoryUrl, File JavaDoc localRoot, long revision) {
63         setLayout(new BorderLayout JavaDoc());
64         SearchCriteriaPanel scp = new SearchCriteriaPanel(repositoryUrl);
65         scp.setFrom(Long.toString(revision));
66         scp.setTo(Long.toString(revision));
67         shp = new SearchHistoryPanel(repositoryUrl, localRoot, scp);
68         add(shp);
69     }
70
71     private void initComponents(File JavaDoc[] roots, String JavaDoc commitMessage, String JavaDoc username, Date from, Date to) {
72         setLayout(new BorderLayout JavaDoc());
73         SearchCriteriaPanel scp = new SearchCriteriaPanel(roots);
74         scp.setCommitMessage(commitMessage);
75         scp.setUsername(username);
76         if (from != null) scp.setFrom(SearchExecutor.simpleDateFormat.format(from));
77         if (to != null) scp.setTo(SearchExecutor.simpleDateFormat.format(to));
78         shp = new SearchHistoryPanel(roots, scp);
79         add(shp);
80     }
81
82     public int getPersistenceType(){
83        return TopComponent.PERSISTENCE_NEVER;
84     }
85     
86     protected void componentClosed() {
87 // ((DiffMainPanel) getComponent(0)).componentClosed();
88
super.componentClosed();
89     }
90     
91     protected String JavaDoc preferredID(){
92        return "Svn.SearchHistoryTopComponent"; // NOI18N
93
}
94
95     public HelpCtx getHelpCtx() {
96         return new HelpCtx(getClass());
97     }
98
99     public Collection getSetups() {
100         return shp.getSetups();
101     }
102
103     public String JavaDoc getSetupDisplayName() {
104         return getDisplayName();
105     }
106 }
107
Popular Tags