KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > localhistory > LocalHistoryVCSAnnotator


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.localhistory;
20
21 import java.awt.Image JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24 import javax.swing.Action JavaDoc;
25 import org.netbeans.modules.localhistory.ui.actions.RevertDeletedAction;
26 import org.netbeans.modules.localhistory.ui.revert.RevertToAction;
27 import org.netbeans.modules.localhistory.ui.view.ShowLocalHistoryAction;
28 import org.netbeans.modules.versioning.spi.VCSAnnotator;
29 import org.netbeans.modules.versioning.spi.VCSContext;
30 import org.netbeans.modules.versioning.util.SystemActionBridge;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
33 import org.openide.util.actions.SystemAction;
34 import org.openide.util.lookup.Lookups;
35
36 /**
37  *
38  * Provides the Local History Actions to the IDE
39  *
40  * @author Tomas Stupka
41  */

42 public class LocalHistoryVCSAnnotator extends VCSAnnotator {
43     
44     /** Creates a new instance of LocalHistoryVCSAnnotator */
45     public LocalHistoryVCSAnnotator() {
46     }
47  
48     public Image JavaDoc annotateIcon(Image JavaDoc icon, VCSContext context) {
49         // not supported yet
50
return super.annotateIcon(icon, context);
51     }
52             
53     public String JavaDoc annotateName(String JavaDoc name, VCSContext context) {
54         // not supported yet
55
return super.annotateName(name, context);
56     }
57     
58     public Action JavaDoc[] getActions(VCSContext ctx, VCSAnnotator.ActionDestination destination) {
59         Lookup context = Lookups.fixed(ctx.getNodes());
60         List JavaDoc<Action JavaDoc> actions = new ArrayList JavaDoc<Action JavaDoc>();
61         if (destination == VCSAnnotator.ActionDestination.MainMenu) {
62             actions.add(SystemAction.get(ShowLocalHistoryAction.class));
63             actions.add(SystemAction.get(RevertDeletedAction.class));
64             actions.add(SystemAction.get(RevertToAction.class));
65         } else {
66             actions.add(SystemActionBridge.createAction(
67                                             SystemAction.get(ShowLocalHistoryAction.class),
68                                             NbBundle.getMessage(LocalHistoryVCSAnnotator.class, "CTL_PopupMenuItem_ShowLocalHistory"), // XXX get it from action
69
context));
70             actions.add(SystemActionBridge.createAction(
71                                             SystemAction.get(RevertDeletedAction.class),
72                                             NbBundle.getMessage(LocalHistoryVCSAnnotator.class, "CTL_PopupMenuItem_RevertDeleted"), // XXX get it from action
73
context));
74             actions.add(SystemActionBridge.createAction(
75                                             SystemAction.get(RevertToAction.class),
76                                             RevertToAction.getMenuName(),
77                                             context));
78         }
79         return actions.toArray(new Action JavaDoc[actions.size()]);
80     }
81     
82 }
83
Popular Tags