/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package feuille.welcome;
import com.sun.syndication.io.FeedException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import feuille.lib.Language;
/**
*
* @author The Wingate 2940
*/
public class WelcomePanel extends javax.swing.JPanel {
private Language localeLanguage = feuille.MainFrame.getLanguage();
/**
* Creates new form WelcomePanel
*/
public WelcomePanel() {
initComponents();
String category = Language.getDefaultISO_3166()==Language.ISO_3166.France ? "Feuille French" : "Feuille English";
AtomRSS ar = null;
try {
ar = new AtomRSS("http://redaffaire.wordpress.com/feed/", category);
} catch (MalformedURLException ex) {
} catch (IOException ex) {
} catch (IllegalArgumentException | FeedException ex) {
}
if(ar!=null){
JPanel pan = new JPanel(new GridLayout(10, 1));
int x = 0, y = 0;
List<Map<AtomRSS.InfoType, String>> entries = ar.getEntries();
for(Map<AtomRSS.InfoType, String> sub_entries : entries){
RSSPanel rssp = new RSSPanel(
sub_entries.get(AtomRSS.InfoType.TITLE),
sub_entries.get(AtomRSS.InfoType.DESCRIPTION),
sub_entries.get(AtomRSS.InfoType.LINK),
sub_entries.get(AtomRSS.InfoType.AUTHOR),
sub_entries.get(AtomRSS.InfoType.DATE));
rssp.setLocation(x, y);
rssp.setBackground(Color.white);
rssp.setOpaque(true);
rssp.setSize(600, 250);
rssp.setPreferredSize(new Dimension(600, 250));
pan.add(rssp);
y += rssp.getHeight();
}
pan.setSize(600, y);
jScrollPane1.setViewportView(pan);
}
ar = null;
try {
ar = new AtomRSS("http://code.google.com/feeds/p/feuille/downloads/basic.html", null);
} catch (MalformedURLException ex) {
} catch (IOException ex) {
} catch (IllegalArgumentException | FeedException ex) {
}
if(ar!=null){
JPanel pan = new JPanel(new GridLayout(5, 1));
int x = 0, y = 0;
List<Map<AtomRSS.InfoType, String>> entries = ar.getEntries();
for(Map<AtomRSS.InfoType, String> sub_entries : entries){
AtomMiniPanel atom = new AtomMiniPanel(
sub_entries.get(AtomRSS.InfoType.TITLE),
sub_entries.get(AtomRSS.InfoType.LINK));
atom.setLocation(x, y);
atom.setBackground(Color.white);
atom.setOpaque(true);
atom.setSize(600, 70);
atom.setPreferredSize(new Dimension(600, 70));
pan.add(atom);
y += atom.getHeight();
}
pan.setSize(600, y);
jScrollPane2.setViewportView(pan);
}
if(localeLanguage.getValueOf("ifrWelcome")!=null){
ifrWelcome.setTitle(localeLanguage.getValueOf("ifrWelcome"));}
if(localeLanguage.getValueOf("labelWelcomeNews")!=null){
jLabel1.setText(localeLanguage.getValueOf("labelWelcomeNews"));}
if(localeLanguage.getValueOf("labelWelcomeDL")!=null){
jLabel2.setText(localeLanguage.getValueOf("labelWelcomeDL"));}
}
public JInternalFrame getWelcome(){
return ifrWelcome;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jDesktopPane1 = new javax.swing.JDesktopPane();
ifrWelcome = new javax.swing.JInternalFrame();
jScrollPane1 = new javax.swing.JScrollPane();
jScrollPane2 = new javax.swing.JScrollPane();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
ifrWelcome.setIconifiable(true);
ifrWelcome.setMaximizable(true);
ifrWelcome.setResizable(true);
ifrWelcome.setTitle("Welcome");
ifrWelcome.setVisible(true);
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setForeground(new java.awt.Color(0, 102, 0));
jLabel1.setText(" News :");
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, 102, 0));
jLabel2.setText("Downloads :");
javax.swing.GroupLayout ifrWelcomeLayout = new javax.swing.GroupLayout(ifrWelcome.getContentPane());
ifrWelcome.getContentPane().setLayout(ifrWelcomeLayout);
ifrWelcomeLayout.setHorizontalGroup(
ifrWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE)
.addComponent(jScrollPane2)
);
ifrWelcomeLayout.setVerticalGroup(
ifrWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ifrWelcomeLayout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE))
);
jDesktopPane1.add(ifrWelcome);
ifrWelcome.setBounds(10, 10, 750, 500);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 665, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JInternalFrame ifrWelcome;
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
// End of variables declaration//GEN-END:variables
}