KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > progress > module > ProgressListAction


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.progress.module;
21
22 import javax.swing.AbstractAction JavaDoc;
23 import javax.swing.SwingUtilities JavaDoc;
24 import javax.swing.event.ListDataListener JavaDoc;
25 import org.netbeans.progress.spi.ProgressUIWorkerWithModel;
26 import org.openide.util.NbBundle;
27
28 /**
29  *
30  * @author mkleint
31  */

32 public class ProgressListAction extends AbstractAction JavaDoc implements ListDataListener JavaDoc, Runnable JavaDoc {
33
34     /** Creates a new instance of ProcessListAction */
35     public ProgressListAction() {
36         this(NbBundle.getMessage(ProgressListAction.class, "CTL_ProcessListAction"));
37     }
38     
39     public ProgressListAction(String JavaDoc name) {
40         putValue(NAME, name);
41 // putValue(MNEMONIC_KEY, new Integer((int)NbBundle.getMessage(ProgressListAction.class, "ProcessListAction.mnemonic").charAt(0)));
42
Controller.getDefault().getModel().addListDataListener(this);
43         updateEnabled();
44     }
45     
46     /** Perform the action. Sets/unsets maximzed mode. */
47     public void actionPerformed(java.awt.event.ActionEvent JavaDoc ev) {
48        //need to invoke later becauseotherwise the awtlistener possibly catches a mouse event
49
SwingUtilities.invokeLater(this);
50     }
51     
52     public void run() {
53         ((ProgressUIWorkerWithModel)Controller.getDefault().getVisualComponent()).showPopup();
54     }
55
56     private void updateEnabled() {
57         setEnabled(Controller.getDefault().getModel().getSize() != 0);
58     }
59
60     public void contentsChanged(javax.swing.event.ListDataEvent JavaDoc listDataEvent) {
61         updateEnabled();
62     }
63
64     public void intervalAdded(javax.swing.event.ListDataEvent JavaDoc listDataEvent) {
65         updateEnabled();
66     }
67
68     public void intervalRemoved(javax.swing.event.ListDataEvent JavaDoc listDataEvent) {
69         updateEnabled();
70     }
71     
72     
73 }
74
Popular Tags