2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.autoupdate.ui.wizards;
44
import javax.swing.event.HyperlinkEvent;
45
import javax.swing.event.HyperlinkEvent.EventType;
46
import javax.swing.event.HyperlinkListener;
47
import org.jdesktop.layout.GroupLayout;
48
import org.netbeans.modules.autoupdate.ui.Utilities;
52
* @author Jiri Rechtacek
54
public class OperationDescriptionPanel extends javax.swing.JPanel {
55
private String tpPrimaryTitleText;
56
private String tpPrimaryPluginsText;
57
private String tpDependingTitleText;
58
private String tpDependingPluginsText;
59
/** Creates new form OperationDescriptionPanel */
60
public OperationDescriptionPanel (String primary, String primaryU, String depending, String dependingU, boolean hasRequired) {
61
this.tpPrimaryTitleText = primary;
62
this.tpPrimaryPluginsText = primaryU;
63
this.tpDependingTitleText = depending;
64
this.tpDependingPluginsText = dependingU;
65
customInitComponents (hasRequired);
68
// XXX: cannot be designed by mattise
69
private void customInitComponents (boolean hasRequired) {
70
tpPrimaryTitle = new javax.swing.JTextPane();
71
tpPrimaryPlugins = new javax.swing.JTextPane();
72
tpDependingTitle = new javax.swing.JTextPane();
73
tpDependingPlugins = new javax.swing.JTextPane();
75
tpPrimaryTitle.setContentType("text/html"); // NOI18N
76
tpPrimaryTitle.setEditable(false);
77
tpPrimaryTitle.setOpaque (false);
79
tpPrimaryPlugins.setContentType ("text/html"); // NOI18N
80
tpPrimaryPlugins.setEditable(false);
81
tpPrimaryPlugins.setOpaque (false);
82
tpPrimaryPlugins.addHyperlinkListener(new HyperlinkListener() {
83
public void hyperlinkUpdate(HyperlinkEvent hlevt) {
84
if (EventType.ACTIVATED == hlevt.getEventType()) {
85
assert hlevt.getURL() != null;
86
Utilities.showURL(hlevt.getURL());
92
tpDependingTitle.setContentType ("text/html"); // NOI18N
93
tpDependingTitle.setEditable(false);
94
tpDependingTitle.setOpaque (false);
96
tpDependingPlugins.setContentType ("text/html"); // NOI18N
97
tpDependingPlugins.setEditable(false);
98
tpDependingPlugins.setOpaque (false);
100
tpPrimaryTitle.setText(tpPrimaryTitleText);
101
tpPrimaryPlugins.setText(tpPrimaryPluginsText);
102
tpDependingTitle.setText(tpDependingTitleText);
103
tpDependingPlugins.setText(tpDependingPluginsText);
104
boolean hasPrimary = tpPrimaryPluginsText.length () > 0 || tpPrimaryTitleText.length () > 0;
106
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
107
this.setLayout(layout);
108
layout.setHorizontalGroup (getHorizontalGroup (layout, hasPrimary, hasRequired));
109
layout.setVerticalGroup (getVerticalGroup (layout, hasPrimary, hasRequired));
112
private GroupLayout.ParallelGroup getVerticalGroup (GroupLayout layout, boolean hasPrimary, boolean hasRequired) {
113
GroupLayout.ParallelGroup res = layout.createParallelGroup (GroupLayout.PREFERRED_SIZE);
114
GroupLayout.SequentialGroup seq = layout.createSequentialGroup ();
116
seq.add (tpPrimaryTitle, GroupLayout.DEFAULT_SIZE, 40, 40)
117
.addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
118
.add (tpPrimaryPlugins, GroupLayout.PREFERRED_SIZE, tpPrimaryPlugins.getPreferredSize ().height, GroupLayout.PREFERRED_SIZE)
119
.addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
123
seq.add (tpDependingTitle, GroupLayout.DEFAULT_SIZE, 80, 80)
124
.addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
125
.add (tpDependingPlugins, GroupLayout.PREFERRED_SIZE, tpDependingPlugins.getPreferredSize ().height, GroupLayout.PREFERRED_SIZE)
126
.addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED);
132
private GroupLayout.ParallelGroup getHorizontalGroup (GroupLayout layout, boolean hasPrimary, boolean hasRequired) {
133
GroupLayout.ParallelGroup res = layout.createParallelGroup (GroupLayout.LEADING);
135
res.add (GroupLayout.TRAILING, layout.createSequentialGroup ()
136
.add (layout.createParallelGroup (GroupLayout.TRAILING)
137
.add (GroupLayout.LEADING, layout.createSequentialGroup ()
139
.add (tpPrimaryPlugins, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
140
.add (GroupLayout.LEADING, layout.createSequentialGroup ()
142
.add (tpPrimaryTitle, GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
143
.addContainerGap ());
146
res.add (GroupLayout.TRAILING, layout.createSequentialGroup ()
147
.add (layout.createParallelGroup (GroupLayout.TRAILING)
148
.add (GroupLayout.LEADING, layout.createSequentialGroup ()
150
.add (tpDependingPlugins, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
151
.add (GroupLayout.LEADING, layout.createSequentialGroup ()
153
.add (tpDependingTitle, GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
154
.addContainerGap ());
159
/** This method is called from within the constructor to
160
* initialize the form.
161
* WARNING: Do NOT modify this code. The content of this method is
162
* always regenerated by the Form Editor.
164
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
165
private void initComponents() {
167
tpPrimaryTitle = new javax.swing.JTextPane();
168
tpPrimaryPlugins = new javax.swing.JTextPane();
169
tpDependingTitle = new javax.swing.JTextPane();
170
tpDependingPlugins = new javax.swing.JTextPane();
172
tpPrimaryTitle.setContentType("text/html"); // NOI18N
173
tpPrimaryTitle.setEditable(false);
175
tpPrimaryPlugins.setContentType("text/html"); // NOI18N
176
tpPrimaryPlugins.setEditable(false);
178
tpDependingTitle.setContentType("text/html"); // NOI18N
179
tpDependingTitle.setEditable(false);
181
tpDependingPlugins.setContentType("text/html"); // NOI18N
182
tpDependingPlugins.setEditable(false);
184
tpPrimaryTitle.setText(tpPrimaryTitleText);
185
tpPrimaryPlugins.setText(tpPrimaryPluginsText);
186
tpDependingTitle.setText(tpDependingTitleText);
187
tpDependingPlugins.setText(tpDependingPluginsText);
189
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
190
this.setLayout(layout);
191
layout.setHorizontalGroup(
192
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
193
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
194
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
195
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
197
.add(tpDependingPlugins, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
198
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
200
.add(tpDependingTitle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE))
201
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
203
.add(tpPrimaryPlugins, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
204
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
206
.add(tpPrimaryTitle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
209
layout.setVerticalGroup(
210
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
211
.add(layout.createSequentialGroup()
213
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
214
.add(tpPrimaryPlugins)
215
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
216
.add(tpDependingTitle)
217
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
218
.add(tpDependingPlugins, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
221
}// </editor-fold>//GEN-END:initComponents
224
// Variables declaration - do not modify//GEN-BEGIN:variables
225
private javax.swing.JTextPane tpDependingPlugins;
226
private javax.swing.JTextPane tpDependingTitle;
227
private javax.swing.JTextPane tpPrimaryPlugins;
228
private javax.swing.JTextPane tpPrimaryTitle;
229
// End of variables declaration//GEN-END:variables