KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > welcome > ui > ArticlesAndNews


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.welcome.ui;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.GridBagConstraints JavaDoc;
24 import java.awt.GridBagLayout JavaDoc;
25 import java.awt.Insets JavaDoc;
26 import java.util.prefs.Preferences JavaDoc;
27 import javax.swing.JComponent JavaDoc;
28 import javax.swing.JLabel JavaDoc;
29 import javax.swing.JPanel JavaDoc;
30 import org.netbeans.modules.welcome.WelcomeOptions;
31 import org.netbeans.modules.welcome.content.BundleSupport;
32 import org.netbeans.modules.welcome.content.CombinationRSSFeed;
33 import org.netbeans.modules.welcome.content.RSSFeed;
34 import org.netbeans.modules.welcome.content.RSSFeedReaderPanel;
35 import org.netbeans.modules.welcome.content.WebLink;
36 import org.openide.util.NbPreferences;
37
38 /**
39  *
40  * @author S. Aubrecht
41  */

42 public class ArticlesAndNews extends RSSFeedReaderPanel {
43
44     private RSSFeed feed;
45
46     private static final boolean firstTimeStart = WelcomeOptions.getDefault().isFirstTimeStart();
47
48     public ArticlesAndNews() {
49         super( "ArticlesAndNews", true ); // NOI18N
50

51         WelcomeOptions.getDefault().setFirstTimeStart( false );
52
53         setBottomContent( buildBottomContent() );
54     }
55
56     protected JComponent JavaDoc buildContent(String JavaDoc url, boolean showProxyButton) {
57         final Preferences JavaDoc p = NbPreferences.root().node("/org/netbeans/modules/autoupdate"); // NOI18N
58
if( null != p ) {
59             String JavaDoc ideId = p.get ("ideIdentity", null); // NOI18N
60
if( null != ideId && ideId.length() > 0 ) {
61                 url += "?unique=" + ideId; // NOI18N
62
}
63         }
64         feed = new ArticlesAndNewsRSSFeed( url, BundleSupport.getURL("News"), showProxyButton ); // NOI18N
65
feed.addPropertyChangeListener( RSSFeed.FEED_CONTENT_PROPERTY, this );
66         return feed;
67     }
68     
69     protected JComponent JavaDoc buildBottomContent() {
70         WebLink news = new WebLink( "AllNews", false ); // NOI18N
71
news.setFont( HEADER_FONT );
72         BundleSupport.setAccessibilityProperties( news, "AllNews" ); //NOI18N
73

74         WebLink articles = new WebLink( "AllArticles", false ); // NOI18N
75
articles.setFont( HEADER_FONT );
76         BundleSupport.setAccessibilityProperties( articles, "AllArticles" ); //NOI18N
77

78         JPanel JavaDoc panel = new JPanel JavaDoc( new GridBagLayout JavaDoc() );
79         panel.setOpaque( false );
80
81         panel.add( news, new GridBagConstraints JavaDoc(0,1,1,1,0.0,0.0,
82                 GridBagConstraints.SOUTHWEST,GridBagConstraints.HORIZONTAL,
83                 new Insets JavaDoc(5,5,0,5),0,0) );
84         panel.add( new JLabel JavaDoc(), new GridBagConstraints JavaDoc(1,1,1,1,1.0,0.0,
85                 GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,
86                 new Insets JavaDoc(0,0,0,0),0,0) );
87         panel.add( articles, new GridBagConstraints JavaDoc(2,1,1,1,0.0,0.0,
88                 GridBagConstraints.SOUTHEAST,GridBagConstraints.HORIZONTAL,
89                 new Insets JavaDoc(5,5,0,5),0,0) );
90
91         return panel;
92     }
93
94     private boolean firstTimeLoad = true;
95     protected void feedContentLoaded() {
96         if( firstTimeLoad ) {
97             firstTimeLoad = false;
98
99             requestAttention();
100         }
101     }
102
103     private class ArticlesAndNewsRSSFeed extends CombinationRSSFeed {
104         private JPanel JavaDoc contentHeader;
105         public ArticlesAndNewsRSSFeed( String JavaDoc url1, String JavaDoc url2, boolean showProxyButton ) {
106             super( url1, url2, showProxyButton );
107         }
108
109         protected Component JavaDoc getContentHeader() {
110             if( firstTimeStart ) {
111                 if( null == contentHeader ) {
112                     contentHeader = new JPanel JavaDoc( new GridBagLayout JavaDoc() );
113                     contentHeader.setOpaque( false );
114
115                     JLabel JavaDoc lblHeader = new JLabel JavaDoc( BundleSupport.getLabel( "FirstTimeHeader" ) ); // NOI18N
116
lblHeader.setFont( WELCOME_HEADER_FONT );
117
118                     JLabel JavaDoc lblDescription = new JLabel JavaDoc( BundleSupport.getLabel( "FirstTimeDescription" ) ); // NOI18N
119
lblDescription.setFont( WELCOME_DESCRIPTION_FONT );
120
121                     contentHeader.add( lblHeader, new GridBagConstraints JavaDoc(0,0,1,1,1.0,1.0,
122                             GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH,
123                             new Insets JavaDoc(15,TEXT_INSETS_LEFT,5,TEXT_INSETS_RIGHT),0,0 ) );
124                     contentHeader.add( lblDescription, new GridBagConstraints JavaDoc(0,1,1,1,1.0,1.0,
125                             GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH,
126                             new Insets JavaDoc(0,TEXT_INSETS_LEFT,25,TEXT_INSETS_RIGHT),0,0 ) );
127                 }
128                 return contentHeader;
129             }
130             return null;
131         }
132     }
133 }
134
Popular Tags