KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > actions > CopyProductInfoAction


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.core.actions;
21
22 import java.awt.datatransfer.Clipboard JavaDoc;
23 import java.awt.datatransfer.StringSelection JavaDoc;
24 import org.netbeans.core.ui.ProductInformationPanel;
25 import org.openide.util.HelpCtx;
26 import org.openide.util.NbBundle;
27 import org.openide.util.actions.CallableSystemAction;
28
29 /**
30  * This class decribes CopyProductInfoAction used by 'Copy Info'
31  * button inside 'Help|About' dialog
32  * @author Max Sauer
33  */

34 public class CopyProductInfoAction extends CallableSystemAction {
35     
36     public String JavaDoc getName() {
37         return NbBundle.getBundle(CopyProductInfoAction.class).getString("CopyProductInfo");
38     }
39     
40     public HelpCtx getHelpCtx() {
41         return HelpCtx.DEFAULT_HELP;
42         // If you will provide context help then use:
43
// return new HelpCtx(RSMEditorActionAction.class);
44
}
45     
46     protected String JavaDoc iconResource() {
47         return "org/netbeans/core/resources/copy.gif"; // NOI18N
48
}
49     
50     public CopyProductInfoAction() {
51         String JavaDoc tooltip = NbBundle.getMessage(ProductInformationPanel.class,
52                 "CTL_CopyButton_tooltip"); // NOI18N
53
putValue(javax.swing.Action.SHORT_DESCRIPTION, tooltip);
54         putValue("iconBase", iconResource());
55     }
56     
57     protected boolean asynchronous() {
58         return false;
59     }
60     
61     public void performAction() {
62         StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
63         sb.append(ProductInformationPanel.getProductVersionValue());
64         sb.append('\n');
65         sb.append(ProductInformationPanel.getJavaValue());
66         sb.append("; ");
67         sb.append(ProductInformationPanel.getVMValue());
68         sb.append('\n');
69         sb.append(ProductInformationPanel.getOperatingSystemValue());
70         sb.append('\n');
71         sb.append(ProductInformationPanel.getSystemLocaleValue());
72         sb.append("; ");
73         sb.append(ProductInformationPanel.getEncodingValue());
74         StringSelection JavaDoc stringSel = new StringSelection JavaDoc(sb.toString());
75         Clipboard JavaDoc cb = ProductInformationPanel.getExClipboard();
76         if (cb != null) {
77             cb.setContents(stringSel, null);
78         }
79     }
80     
81 }
82
Popular Tags