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.GridBagLayout;
045: import java.awt.BorderLayout;
046: import java.awt.GridBagConstraints;
047: import java.awt.Insets;
048: import java.awt.Point;
049: import java.awt.Rectangle;
050: import javax.swing.JComponent;
051: import javax.swing.JPanel;
052: import javax.swing.SwingConstants;
053: import javax.swing.SwingUtilities;
054: import org.netbeans.modules.welcome.content.BundleSupport;
055: import org.netbeans.modules.welcome.content.ContentSection;
056: import org.netbeans.modules.welcome.content.RecentProjectsPanel;
057:
058: /**
059: *
060: * @author S. Aubrecht
061: */
062: class MyNetBeansTab extends AbstractTab {
063:
064: private ContentSection recentProjectsSection;
065: private ContentSection blogsSection;
066: private JComponent bottomBar;
067:
068: protected void buildContent() {
069: JPanel main = new JPanel(new GridBagLayout());
070: main.setOpaque(false);
071: add(main, BorderLayout.CENTER);
072:
073: main.add(new Stripe(true), new GridBagConstraints(0, 0, 2, 1,
074: 1.0, 1.0, GridBagConstraints.CENTER,
075: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
076:
077: JComponent c = new RecentProjectsPanel();
078: recentProjectsSection = new ContentSection(BundleSupport
079: .getLabel("SectionRecentProjects"), //NOI18N
080: SwingConstants.NORTH_WEST, c, false);
081: main.add(recentProjectsSection, new GridBagConstraints(0, 1, 1,
082: 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST,
083: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
084:
085: c = new ArticlesAndNews();
086: main.add(new ContentSection(BundleSupport
087: .getLabel("SectionNewsAndTutorials"), //NOI18N
088: SwingConstants.NORTH_EAST, c, true),
089: new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
090: GridBagConstraints.SOUTHWEST,
091: GridBagConstraints.BOTH,
092: new Insets(0, 0, 0, 0), 0, 0));
093:
094: c = new DemoPanel();
095: main.add(new ContentSection(BundleSupport
096: .getLabel("SectionDemo"), //NOI18N
097: SwingConstants.SOUTH_WEST, c, true),
098: new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
099: GridBagConstraints.NORTHEAST,
100: GridBagConstraints.BOTH,
101: new Insets(0, 0, 0, 0), 0, 0));
102:
103: c = new Blogs();
104: blogsSection = new ContentSection(BundleSupport
105: .getLabel("SectionBlogs"), //NOI18N
106: SwingConstants.SOUTH_EAST, c, true);
107: main.add(blogsSection, new GridBagConstraints(1, 2, 1, 1, 1.0,
108: 0.0, GridBagConstraints.NORTHWEST,
109: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
110:
111: bottomBar = new BottomBar();
112: main.add(bottomBar, new GridBagConstraints(0, 3, 2, 1, 1.0,
113: 0.0, GridBagConstraints.CENTER,
114: GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0),
115: 0, 0));
116:
117: main.add(new Stripe(false), new GridBagConstraints(0, 4, 2, 1,
118: 1.0, 1.0, GridBagConstraints.CENTER,
119: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
120: }
121:
122: protected Point getTopStripOrigin() {
123: Point p;
124: if (null == recentProjectsSection) {
125: p = new Point(0, 0);
126: } else {
127: Rectangle r = recentProjectsSection.getTitleBounds();
128: p = r.getLocation();
129: p.y += r.getHeight();
130: p.x += r.getWidth() / 2;
131: p = SwingUtilities.convertPoint(recentProjectsSection, p,
132: this );
133: }
134: return p;
135: }
136:
137: protected Point getMiddleStripOrigin() {
138: Point p;
139: if (null == blogsSection) {
140: p = new Point(0, 0);
141: } else {
142: Rectangle r = blogsSection.getTitleBounds();
143: p = r.getLocation();
144: p.y += r.getHeight();
145: p.x += r.getWidth();
146: p = SwingUtilities.convertPoint(blogsSection, p, this );
147: }
148: return p;
149: }
150:
151: protected Point getBottomStripOrigin() {
152: Point p;
153: if (null == bottomBar) {
154: p = new Point(0, 0);
155: } else {
156: Rectangle r = bottomBar.getBounds();
157: p = r.getLocation();
158: p.y += r.getHeight();
159: p.x += r.getWidth();
160: }
161: return p;
162: }
163: }
|