~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to autoupdate/ui/src/org/netbeans/modules/autoupdate/ui/wizards/OperationDescriptionPanel.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
3
 *
 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
5
 *
 
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]"
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
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.
 
29
 *
 
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.
 
40
 */
 
41
 
 
42
package org.netbeans.modules.autoupdate.ui.wizards;
 
43
 
 
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;
 
49
 
 
50
/**
 
51
 *
 
52
 * @author  Jiri Rechtacek
 
53
 */
 
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);
 
66
    }
 
67
    
 
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();
 
74
 
 
75
        tpPrimaryTitle.setContentType("text/html"); // NOI18N
 
76
        tpPrimaryTitle.setEditable(false);
 
77
        tpPrimaryTitle.setOpaque (false);
 
78
 
 
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());
 
87
                }
 
88
            }
 
89
        });
 
90
 
 
91
 
 
92
        tpDependingTitle.setContentType ("text/html"); // NOI18N
 
93
        tpDependingTitle.setEditable(false);
 
94
        tpDependingTitle.setOpaque (false);
 
95
 
 
96
        tpDependingPlugins.setContentType ("text/html"); // NOI18N
 
97
        tpDependingPlugins.setEditable(false);
 
98
        tpDependingPlugins.setOpaque (false);
 
99
 
 
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;
 
105
        
 
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));
 
110
    }
 
111
    
 
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 ();
 
115
        if (hasPrimary) {
 
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)
 
120
                .add (0, 30, 30);
 
121
        }
 
122
        if (hasRequired) {
 
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);
 
127
        }
 
128
        res.add (seq);
 
129
        return res;
 
130
    }
 
131
    
 
132
    private GroupLayout.ParallelGroup getHorizontalGroup (GroupLayout layout, boolean hasPrimary, boolean hasRequired) {
 
133
        GroupLayout.ParallelGroup res = layout.createParallelGroup (GroupLayout.LEADING);
 
134
        if (hasPrimary) {
 
135
            res.add (GroupLayout.TRAILING, layout.createSequentialGroup ()
 
136
                    .add (layout.createParallelGroup (GroupLayout.TRAILING)
 
137
                    .add (GroupLayout.LEADING, layout.createSequentialGroup ()
 
138
                    .add (49, 49, 49)
 
139
                    .add (tpPrimaryPlugins, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
 
140
                    .add (GroupLayout.LEADING, layout.createSequentialGroup ()
 
141
                    .addContainerGap ()
 
142
                    .add (tpPrimaryTitle, GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
 
143
                    .addContainerGap ());
 
144
        }
 
145
        if (hasRequired) {
 
146
            res.add (GroupLayout.TRAILING, layout.createSequentialGroup ()
 
147
                    .add (layout.createParallelGroup (GroupLayout.TRAILING)
 
148
                    .add (GroupLayout.LEADING, layout.createSequentialGroup ()
 
149
                    .add (49, 49, 49)
 
150
                    .add (tpDependingPlugins, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
 
151
                    .add (GroupLayout.LEADING, layout.createSequentialGroup ()
 
152
                    .addContainerGap ()
 
153
                    .add (tpDependingTitle, GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
 
154
                    .addContainerGap ());
 
155
        }
 
156
        return res;
 
157
    }
 
158
    
 
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.
 
163
     */
 
164
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 
165
    private void initComponents() {
 
166
 
 
167
        tpPrimaryTitle = new javax.swing.JTextPane();
 
168
        tpPrimaryPlugins = new javax.swing.JTextPane();
 
169
        tpDependingTitle = new javax.swing.JTextPane();
 
170
        tpDependingPlugins = new javax.swing.JTextPane();
 
171
 
 
172
        tpPrimaryTitle.setContentType("text/html"); // NOI18N
 
173
        tpPrimaryTitle.setEditable(false);
 
174
 
 
175
        tpPrimaryPlugins.setContentType("text/html"); // NOI18N
 
176
        tpPrimaryPlugins.setEditable(false);
 
177
 
 
178
        tpDependingTitle.setContentType("text/html"); // NOI18N
 
179
        tpDependingTitle.setEditable(false);
 
180
 
 
181
        tpDependingPlugins.setContentType("text/html"); // NOI18N
 
182
        tpDependingPlugins.setEditable(false);
 
183
 
 
184
        tpPrimaryTitle.setText(tpPrimaryTitleText);
 
185
        tpPrimaryPlugins.setText(tpPrimaryPluginsText);
 
186
        tpDependingTitle.setText(tpDependingTitleText);
 
187
        tpDependingPlugins.setText(tpDependingPluginsText);
 
188
 
 
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()
 
196
                        .add(49, 49, 49)
 
197
                        .add(tpDependingPlugins, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
 
198
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
 
199
                        .addContainerGap()
 
200
                        .add(tpDependingTitle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE))
 
201
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
 
202
                        .add(49, 49, 49)
 
203
                        .add(tpPrimaryPlugins, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
 
204
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
 
205
                        .addContainerGap()
 
206
                        .add(tpPrimaryTitle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
 
207
                .addContainerGap())
 
208
        );
 
209
        layout.setVerticalGroup(
 
210
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
 
211
            .add(layout.createSequentialGroup()
 
212
                .add(tpPrimaryTitle)
 
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)
 
219
                .add(90, 90, 90))
 
220
        );
 
221
    }// </editor-fold>//GEN-END:initComponents
 
222
    
 
223
    
 
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
 
230
    
 
231
}