1 19 20 package org.netbeans.modules.welcome.ui; 21 22 import java.awt.Component ; 23 import java.awt.GridBagConstraints ; 24 import java.awt.GridBagLayout ; 25 import java.awt.Insets ; 26 import java.util.prefs.Preferences ; 27 import javax.swing.JComponent ; 28 import javax.swing.JLabel ; 29 import javax.swing.JPanel ; 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 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 ); 51 WelcomeOptions.getDefault().setFirstTimeStart( false ); 52 53 setBottomContent( buildBottomContent() ); 54 } 55 56 protected JComponent buildContent(String url, boolean showProxyButton) { 57 final Preferences p = NbPreferences.root().node("/org/netbeans/modules/autoupdate"); if( null != p ) { 59 String ideId = p.get ("ideIdentity", null); if( null != ideId && ideId.length() > 0 ) { 61 url += "?unique=" + ideId; } 63 } 64 feed = new ArticlesAndNewsRSSFeed( url, BundleSupport.getURL("News"), showProxyButton ); feed.addPropertyChangeListener( RSSFeed.FEED_CONTENT_PROPERTY, this ); 66 return feed; 67 } 68 69 protected JComponent buildBottomContent() { 70 WebLink news = new WebLink( "AllNews", false ); news.setFont( HEADER_FONT ); 72 BundleSupport.setAccessibilityProperties( news, "AllNews" ); 74 WebLink articles = new WebLink( "AllArticles", false ); articles.setFont( HEADER_FONT ); 76 BundleSupport.setAccessibilityProperties( articles, "AllArticles" ); 78 JPanel panel = new JPanel ( new GridBagLayout () ); 79 panel.setOpaque( false ); 80 81 panel.add( news, new GridBagConstraints (0,1,1,1,0.0,0.0, 82 GridBagConstraints.SOUTHWEST,GridBagConstraints.HORIZONTAL, 83 new Insets (5,5,0,5),0,0) ); 84 panel.add( new JLabel (), new GridBagConstraints (1,1,1,1,1.0,0.0, 85 GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL, 86 new Insets (0,0,0,0),0,0) ); 87 panel.add( articles, new GridBagConstraints (2,1,1,1,0.0,0.0, 88 GridBagConstraints.SOUTHEAST,GridBagConstraints.HORIZONTAL, 89 new Insets (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 contentHeader; 105 public ArticlesAndNewsRSSFeed( String url1, String url2, boolean showProxyButton ) { 106 super( url1, url2, showProxyButton ); 107 } 108 109 protected Component getContentHeader() { 110 if( firstTimeStart ) { 111 if( null == contentHeader ) { 112 contentHeader = new JPanel ( new GridBagLayout () ); 113 contentHeader.setOpaque( false ); 114 115 JLabel lblHeader = new JLabel ( BundleSupport.getLabel( "FirstTimeHeader" ) ); lblHeader.setFont( WELCOME_HEADER_FONT ); 117 118 JLabel lblDescription = new JLabel ( BundleSupport.getLabel( "FirstTimeDescription" ) ); lblDescription.setFont( WELCOME_DESCRIPTION_FONT ); 120 121 contentHeader.add( lblHeader, new GridBagConstraints (0,0,1,1,1.0,1.0, 122 GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH, 123 new Insets (15,TEXT_INSETS_LEFT,5,TEXT_INSETS_RIGHT),0,0 ) ); 124 contentHeader.add( lblDescription, new GridBagConstraints (0,1,1,1,1.0,1.0, 125 GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH, 126 new Insets (0,TEXT_INSETS_LEFT,25,TEXT_INSETS_RIGHT),0,0 ) ); 127 } 128 return contentHeader; 129 } 130 return null; 131 } 132 } 133 } 134 | Popular Tags |