Added
Link Here
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved. |
5 |
* |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
7 |
* Other names may be trademarks of their respective owners. |
8 |
* |
9 |
* The contents of this file are subject to the terms of either the GNU |
10 |
* General Public License Version 2 only ("GPL") or the Common |
11 |
* Development and Distribution License("CDDL") (collectively, the |
12 |
* "License"). You may not use this file except in compliance with the |
13 |
* License. You can obtain a copy of the License at |
14 |
* http://www.netbeans.org/cddl-gplv2.html |
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
16 |
* specific language governing permissions and limitations under the |
17 |
* License. When distributing the software, include this License Header |
18 |
* Notice in each file and include the License file at |
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
20 |
* particular file as subject to the "Classpath" exception as provided |
21 |
* by Oracle in the GPL Version 2 section of the License file that |
22 |
* accompanied this code. If applicable, add the following below the |
23 |
* License Header, with the fields enclosed by brackets [] replaced by |
24 |
* your own identifying information: |
25 |
* "Portions Copyrighted [year] [name of copyright owner]" |
26 |
* |
27 |
* Contributor(s): |
28 |
* |
29 |
* The Original Software is NetBeans. The Initial Developer of the Original |
30 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
31 |
* Microsystems, Inc. All Rights Reserved. |
32 |
* |
33 |
* If you wish your version of this file to be governed by only the CDDL |
34 |
* or only the GPL Version 2, indicate your decision by adding |
35 |
* "[Contributor] elects to include this software in this distribution |
36 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
37 |
* single choice of license, a recipient has the option to distribute |
38 |
* your version of this file under either the CDDL, the GPL Version 2 or |
39 |
* to extend the choice of license to its licensees as provided above. |
40 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
41 |
* Version 2 license, then the option applies only if the new code is |
42 |
* made subject to such option by the copyright holder. |
43 |
*/ |
44 |
package org.netbeans.core.windows.design; |
45 |
|
46 |
import org.openide.util.NbBundle; |
47 |
import org.openide.windows.Mode; |
48 |
import org.openide.windows.TopComponent; |
49 |
import org.netbeans.api.settings.ConvertAsProperties; |
50 |
import org.netbeans.core.windows.ModeImpl; |
51 |
import org.openide.windows.WindowManager; |
52 |
|
53 |
@ConvertAsProperties( |
54 |
dtd = "-//org.netbeans.core.windows.model//DesignViewComponent//EN", |
55 |
autostore = false |
56 |
) |
57 |
@TopComponent.Description(preferredID = "DesignViewComponentTopComponent", |
58 |
iconBase = "org/netbeans/core/windows/model/DesignView.png", |
59 |
persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED |
60 |
) |
61 |
final class DesignViewComponent extends TopComponent { |
62 |
DesignViewComponent() { |
63 |
initComponents(); |
64 |
setName(NbBundle.getMessage(DesignViewComponent.class, "CTL_DesignViewComponentTopComponent")); |
65 |
setToolTipText(NbBundle.getMessage(DesignViewComponent.class, "HINT_DesignViewComponentTopComponent")); |
66 |
putClientProperty("TopComponentAllowDockAnywhere", true); |
67 |
refresh(); |
68 |
} |
69 |
|
70 |
/** This method is called from within the constructor to |
71 |
* initialize the form. |
72 |
* WARNING: Do NOT modify this code. The content of this method is |
73 |
* always regenerated by the Form Editor. |
74 |
*/ |
75 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
76 |
private void initComponents() { |
77 |
|
78 |
modeName = new javax.swing.JTextField(); |
79 |
jPanel1 = new javax.swing.JPanel(); |
80 |
jPanel2 = new javax.swing.JPanel(); |
81 |
jLabel1 = new javax.swing.JLabel(); |
82 |
jButton1 = new javax.swing.JButton(); |
83 |
|
84 |
modeName.setText(org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.modeName.text", new Object[] {})); // NOI18N |
85 |
modeName.addActionListener(new java.awt.event.ActionListener() { |
86 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
87 |
modeNameActionPerformed(evt); |
88 |
} |
89 |
}); |
90 |
|
91 |
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); |
92 |
jPanel1.setLayout(jPanel1Layout); |
93 |
jPanel1Layout.setHorizontalGroup( |
94 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
95 |
.addGap(0, 500, Short.MAX_VALUE) |
96 |
); |
97 |
jPanel1Layout.setVerticalGroup( |
98 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
99 |
.addGap(0, 88, Short.MAX_VALUE) |
100 |
); |
101 |
|
102 |
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); |
103 |
jPanel2.setLayout(jPanel2Layout); |
104 |
jPanel2Layout.setHorizontalGroup( |
105 |
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
106 |
.addGap(0, 500, Short.MAX_VALUE) |
107 |
); |
108 |
jPanel2Layout.setVerticalGroup( |
109 |
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
110 |
.addGap(0, 63, Short.MAX_VALUE) |
111 |
); |
112 |
|
113 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.jLabel1.text", new Object[] {})); // NOI18N |
114 |
|
115 |
org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.jButton1.text", new Object[] {})); // NOI18N |
116 |
jButton1.addActionListener(new java.awt.event.ActionListener() { |
117 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
118 |
jButton1ActionPerformed(evt); |
119 |
} |
120 |
}); |
121 |
|
122 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
123 |
this.setLayout(layout); |
124 |
layout.setHorizontalGroup( |
125 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
126 |
.addGroup(layout.createSequentialGroup() |
127 |
.addContainerGap() |
128 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
129 |
.addComponent(jLabel1) |
130 |
.addComponent(modeName, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE) |
131 |
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
132 |
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
133 |
.addComponent(jButton1)) |
134 |
.addContainerGap()) |
135 |
); |
136 |
layout.setVerticalGroup( |
137 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
138 |
.addGroup(layout.createSequentialGroup() |
139 |
.addGap(9, 9, 9) |
140 |
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
141 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
142 |
.addComponent(jLabel1) |
143 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
144 |
.addComponent(modeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
145 |
.addGap(3, 3, 3) |
146 |
.addComponent(jButton1) |
147 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
148 |
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
149 |
.addContainerGap()) |
150 |
); |
151 |
}// </editor-fold>//GEN-END:initComponents |
152 |
|
153 |
private void refresh() { |
154 |
Mode mode = WindowManager.getDefault().findMode(this); |
155 |
if (mode != null) { |
156 |
modeName.setText(mode.getName()); |
157 |
setName(mode.getName()); |
158 |
} |
159 |
} |
160 |
|
161 |
private void modeNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modeNameActionPerformed |
162 |
Mode mode = WindowManager.getDefault().findMode(this); |
163 |
if (mode instanceof ModeImpl) { |
164 |
ModeImpl mi = (ModeImpl)mode; |
165 |
mi.setModeName(modeName.getText()); |
166 |
} |
167 |
|
168 |
for (TopComponent tc : mode.getTopComponents()) { |
169 |
if (tc instanceof DesignViewComponent) { |
170 |
DesignViewComponent dvc = (DesignViewComponent)tc; |
171 |
dvc.refresh(); |
172 |
} |
173 |
} |
174 |
}//GEN-LAST:event_modeNameActionPerformed |
175 |
|
176 |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed |
177 |
modeNameActionPerformed(evt); |
178 |
}//GEN-LAST:event_jButton1ActionPerformed |
179 |
|
180 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
181 |
private javax.swing.JButton jButton1; |
182 |
private javax.swing.JLabel jLabel1; |
183 |
private javax.swing.JPanel jPanel1; |
184 |
private javax.swing.JPanel jPanel2; |
185 |
private javax.swing.JTextField modeName; |
186 |
// End of variables declaration//GEN-END:variables |
187 |
|
188 |
@Override |
189 |
public void componentOpened() { |
190 |
refresh(); |
191 |
} |
192 |
|
193 |
@Override |
194 |
protected void componentActivated() { |
195 |
refresh(); |
196 |
} |
197 |
|
198 |
void writeProperties(java.util.Properties p) { |
199 |
// better to version settings since initial version as advocated at |
200 |
// http://wiki.apidesign.org/wiki/PropertyFiles |
201 |
p.setProperty("version", "1.0"); |
202 |
// TODO store your settings |
203 |
} |
204 |
|
205 |
void readProperties(java.util.Properties p) { |
206 |
String version = p.getProperty("version"); |
207 |
// TODO read your settings according to their version |
208 |
} |
209 |
} |