KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > refactoring > ui > j > ui > SafeDeletePanel


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.refactoring.ui.j.ui;
20 import java.awt.Component JavaDoc;
21 import java.awt.Dimension JavaDoc;
22 import java.text.MessageFormat JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24 import javax.swing.SwingUtilities JavaDoc;
25 import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
26 import org.netbeans.modules.xml.xam.NamedReferenceable;
27 import org.openide.util.NbBundle;
28
29
30 /**
31  * Subclass of CustomRefactoringPanel representing the
32  * Safe Delete refactoring UI
33  * @author Bharath Ravikumar
34  */

35 public class SafeDeletePanel extends JPanel JavaDoc implements CustomRefactoringPanel {
36
37     private final transient NamedReferenceable target;
38     /**
39      * Creates new form RenamePanelName
40      * @param refactoring The SafeDelete refactoring used by this panel
41      * @param selectedElements A Collection of selected elements
42      */

43     public SafeDeletePanel(NamedReferenceable target) {
44         assert target != null:"Nameable target required.";
45         setName(NbBundle.getMessage(SafeDeletePanel.class,"LBL_SafeDel")); // NOI18N
46
this.target = target;
47         initComponents();
48     }
49     
50     private boolean initialized = false;
51     /**
52      * Initialization method. Creates appropriate labels in the panel.
53      */

54     public void initialize() {
55         
56         if (initialized) return;
57         final String JavaDoc labelText;
58        
59         
60         SwingUtilities.invokeLater(new Runnable JavaDoc() {
61             public void run() {
62                 System.out.println("INIT CALLED");
63                 label.setText(MessageFormat.format(NbBundle.getMessage(
64                         SafeDeletePanel.class, "LBL_Delete_BOLD"),
65                         new Object JavaDoc[]{target.getName()}));
66                 validate();
67             }
68         });
69         initialized = true;
70     }
71     
72     public void requestFocus() {
73         super.requestFocus();
74     }
75     
76     /** This method is called from within the constructor to
77      * initialize the form.
78      * WARNING: Do NOT modify this code. The content of this method is
79      * always regenerated by the Form Editor.
80      */

81     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
82
private void initComponents() {
83         buttonGroup = new javax.swing.ButtonGroup JavaDoc();
84         jPanel3 = new javax.swing.JPanel JavaDoc();
85         label = new javax.swing.JLabel JavaDoc();
86
87         setLayout(new java.awt.BorderLayout JavaDoc());
88
89         jPanel3.setLayout(new java.awt.BorderLayout JavaDoc());
90
91         org.openide.awt.Mnemonics.setLocalizedText(label, "Delete myGlobalComponent");
92         jPanel3.add(label, java.awt.BorderLayout.NORTH);
93
94         add(jPanel3, java.awt.BorderLayout.NORTH);
95
96     }// </editor-fold>//GEN-END:initComponents
97

98     // Variables declaration - do not modify//GEN-BEGIN:variables
99
private javax.swing.ButtonGroup JavaDoc buttonGroup;
100     private javax.swing.JPanel JavaDoc jPanel3;
101     private javax.swing.JLabel JavaDoc label;
102     // End of variables declaration//GEN-END:variables
103

104     
105     public Dimension JavaDoc getPreferredSize() {
106         Dimension JavaDoc orig = super.getPreferredSize();
107         return new Dimension JavaDoc(orig.width + 30 , orig.height + 30);
108     }
109     
110     
111     
112 //--public utility methods--
113

114     //This method has been made public so that another class might be able to reuse this.
115
//This should be moved to a common utility class.
116
/**
117      * Returns the formatted string corresponding to the declaration
118      * of a CallableFeature(a {@link org.netbeans.jmi.javamodel.Method}
119      * or a {@link org.netbeans.jmi.javamodel.Constructor})
120      * Copied from {@link org.netbeans.modules.refactoring.ui.WhereUsedPanel}
121      */

122 // public String getHeader(CallableFeature call) {
123
// if (((CallableFeatureImpl) call).getParser() == null) {
124
// if (call instanceof Method) {
125
// return ((Method) call).getName();
126
// } else if (call instanceof Constructor) {
127
// return getSimpleName(call.getDeclaringClass());
128
// }
129
// return "";
130
// }
131
// int s = ((MetadataElement) call).getPartStartOffset(ElementPartKindEnum.HEADER);
132
// int element = ((MetadataElement) call).getPartEndOffset(ElementPartKindEnum.HEADER);
133
// String result = call.getResource().getSourceText().substring(s,element);
134
// if (result.length() > 50) {
135
// result = result.substring(0,49) + "..."; // NOI18N
136
// }
137
// return CheckUtils.htmlize(result);
138
// }
139

140     
141     public Component JavaDoc getComponent(){
142         return this;
143     }
144     
145 }
146
147
Popular Tags