001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.welcome.ui;
043:
044: import java.awt.BorderLayout;
045: import java.awt.Color;
046: import java.awt.GridBagConstraints;
047: import java.awt.GridBagLayout;
048: import java.awt.Insets;
049: import java.awt.Point;
050: import java.awt.Rectangle;
051: import javax.swing.JComponent;
052: import javax.swing.JPanel;
053: import javax.swing.SwingConstants;
054: import javax.swing.SwingUtilities;
055: import org.netbeans.modules.welcome.content.BundleSupport;
056: import org.netbeans.modules.welcome.content.ContentSection;
057:
058: /**
059: * 'Welcome' tab of the Start Page
060: *
061: * @author S. Aubrecht
062: */
063: class WelcomeTab extends AbstractTab {
064:
065: private ContentSection getStartedSection;
066: private ContentSection learnMoreSection;
067: private JComponent bottomBar;
068:
069: protected void buildContent() {
070: JPanel main = new JPanel(new GridBagLayout());
071: main.setOpaque(false);
072: add(main, BorderLayout.CENTER);
073:
074: JPanel upperSpace = new Stripe(true);
075: upperSpace.setBackground(Color.red);
076: main.add(upperSpace, new GridBagConstraints(0, 0, 2, 1, 1.0,
077: 1.0, GridBagConstraints.CENTER,
078: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
079:
080: JComponent c = new GetStarted();
081: getStartedSection = new ContentSection(BundleSupport
082: .getLabel("SectionGetStarted"), //NOI18N
083: SwingConstants.NORTH_WEST, c, false);
084: main.add(getStartedSection, new GridBagConstraints(0, 1, 1, 1,
085: 1.0, 0.0, GridBagConstraints.SOUTHEAST,
086: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
087:
088: c = new Samples();
089: main.add(new ContentSection(BundleSupport
090: .getLabel("SectionSamples"), //NOI18N
091: SwingConstants.NORTH_EAST, c, false),
092: new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
093: GridBagConstraints.SOUTHWEST,
094: GridBagConstraints.BOTH,
095: new Insets(0, 0, 0, 0), 0, 0));
096:
097: c = new PluginsPanel();
098: main.add(new ContentSection(BundleSupport
099: .getLabel("SectionPlugins"), //NOI18N
100: SwingConstants.SOUTH_WEST, c, false),
101: new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
102: GridBagConstraints.NORTHEAST,
103: GridBagConstraints.BOTH,
104: new Insets(0, 0, 0, 0), 0, 0));
105:
106: c = new LearnMore();
107: learnMoreSection = new ContentSection(BundleSupport
108: .getLabel("SectionLearnMore"), //NOI18N
109: SwingConstants.SOUTH_EAST, c, false);
110: main.add(learnMoreSection, new GridBagConstraints(1, 2, 1, 1,
111: 1.0, 0.0, GridBagConstraints.NORTHWEST,
112: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
113:
114: bottomBar = new BottomBar();
115: main.add(bottomBar, new GridBagConstraints(0, 3, 2, 1, 1.0,
116: 0.0, GridBagConstraints.CENTER,
117: GridBagConstraints.HORIZONTAL, new Insets(0, 0, 2, 0),
118: 0, 0));
119:
120: JPanel bottomSpace = new Stripe(false);
121: bottomSpace.setBackground(Color.red);
122: main.add(bottomSpace, new GridBagConstraints(0, 4, 2, 1, 1.0,
123: 1.0, GridBagConstraints.CENTER,
124: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
125: }
126:
127: protected Point getTopStripOrigin() {
128: Point p;
129: if (null == getStartedSection) {
130: p = new Point(0, 0);
131: } else {
132: Rectangle r = getStartedSection.getTitleBounds();
133: p = r.getLocation();
134: p.y += r.getHeight();
135: p = SwingUtilities.convertPoint(getStartedSection, p, this );
136: }
137: return p;
138: }
139:
140: protected Point getMiddleStripOrigin() {
141: Point p;
142: if (null == learnMoreSection) {
143: p = new Point(0, 0);
144: } else {
145: Rectangle r = learnMoreSection.getTitleBounds();
146: p = r.getLocation();
147: p.y += r.getHeight();
148: p.x += r.getWidth();
149: p = SwingUtilities.convertPoint(learnMoreSection, p, this );
150: }
151: return p;
152: }
153:
154: protected Point getBottomStripOrigin() {
155: Point p;
156: if (null == bottomBar) {
157: p = new Point(0, 0);
158: } else {
159: Rectangle r = bottomBar.getBounds();
160: p = r.getLocation();
161: p.y += r.getHeight();
162: p.x += r.getWidth();
163: }
164: return p;
165: }
166: }
|