KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > docscan > SourceTasksAction


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
20 package org.netbeans.modules.tasklist.docscan;
21
22 import javax.swing.*;
23
24 import org.openide.util.actions.CallableSystemAction;
25 import org.openide.util.*;
26 import org.netbeans.modules.tasklist.client.SuggestionManager;
27 import org.netbeans.modules.tasklist.suggestions.SuggestionManagerImpl;
28 import org.netbeans.modules.tasklist.suggestions.SuggestionsScanner;
29 import org.netbeans.modules.tasklist.suggestions.SuggestionsBroker;
30 import org.netbeans.modules.tasklist.core.TaskListView;
31 import org.netbeans.modules.tasklist.core.Background;
32
33 /**
34  * Opens window with scanned project source tasks.
35  *
36  * @author Petr Kuzel
37  */

38 public final class SourceTasksAction extends CallableSystemAction {
39
40     private static final long serialVersionUID = 1;
41
42     protected boolean asynchronous() {
43         return false;
44     }
45
46     public void performAction() {
47
48         SuggestionManagerImpl manager = (SuggestionManagerImpl)
49             SuggestionManager.getDefault();
50
51         if (false == manager.isEnabled(SourceTaskProvider.TYPE)) {
52             manager.setEnabled(SourceTaskProvider.TYPE, true, true);
53         }
54
55         TaskListView tlview = TaskListView.getTaskListView(SourceTasksView.CATEGORY);
56         if (tlview != null) {
57             tlview.showInMode();
58         } else {
59             if (openByDefaultAll()) {
60                 final SourceTasksList list = new SourceTasksList();
61                 final SourceTasksView view = new SourceTasksView(list);
62
63                 view.showInMode();
64                 RepaintManager.currentManager(view).paintDirtyRegions();
65                 Background back = SourceTasksScanner.scanTasksAsync(view); // delayed class loading
66
view.setBackground(back);
67             } else {
68                 TaskListView tlv = new SourceTasksView(SuggestionsBroker.getDefault().startBroker(new SourceTasksProviderAcceptor()));
69                 tlv.showInMode();
70             }
71         }
72     }
73
74     /** Access the setting defining action behaviour. */
75     private boolean openByDefaultAll() {
76         return false;
77     }
78
79
80     public String JavaDoc getName() {
81         return NbBundle.getMessage(SourceTasksAction.class, "BK0001");
82     }
83
84     public HelpCtx getHelpCtx() {
85         return new HelpCtx(SourceTasksAction.class);
86     }
87
88     protected String JavaDoc iconResource() {
89         return "org/netbeans/modules/tasklist/docscan/todosAction.gif"; // NOI18N
90
}
91
92     public static interface ScanProgressMonitor extends SuggestionsScanner.ScanProgress {
93
94         /**
95          * Returns number of found todos
96          * @thread AWT
97          * @param todos found
98          */

99         void statistics(int todos);
100     }
101
102
103 }
104
Popular Tags