package edu.wustl.cab2b.client.ui.mainframe;

import static edu.wustl.cab2b.client.ui.util.ApplicationResourceConstants.MAIN_FRAME_TITLE;

import java.awt.Color;
import java.awt.Dimension;
import java.io.IOException;
import java.net.MalformedURLException;

import javax.swing.BoxLayout;
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;

import edu.wustl.cab2b.client.ui.MainSearchPanel;
import edu.wustl.cab2b.client.ui.SaveDatalistPanel;
import edu.wustl.cab2b.client.ui.WindowUtilities;
import edu.wustl.cab2b.client.ui.controls.Cab2bPanel;
import edu.wustl.cab2b.client.ui.controls.Cab2bStandardFonts;
import edu.wustl.cab2b.client.ui.util.ApplicationResourceConstants;
import edu.wustl.cab2b.client.ui.util.CommonUtils;
import edu.wustl.common.util.global.ApplicationProperties;

/**
 * Loads a html page from the local file system and shows it in the editor pane.
 * 
 * @author chetan_bh
 */
public class NewWelcomePanel extends Cab2bPanel {

    private static final long serialVersionUID = 1L;

    private JEditorPane welcomePageEditorPane;

    public static MainFrame mainFrame;

    public NewWelcomePanel(MainFrame newMainFrame) {
        mainFrame = newMainFrame;
        initGUI();
    }

    private void initGUI() {
        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        this.setBackground(Color.WHITE);
        welcomePageEditorPane = createEditorPane();
        welcomePageEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
        welcomePageEditorPane.setFont(Cab2bStandardFonts.ARIAL_PLAIN_12);
        welcomePageEditorPane.addHyperlinkListener(new HyperlinkListener() {
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    String className = e.getDescription();
                    if (className.equalsIgnoreCase("MainSearchPanel")) {

                        GlobalNavigationPanel.mainSearchPanel = new MainSearchPanel();
                        Dimension dimension = MainFrame.mainframeScreenDimesion;

                        //reset DataList Save status
                        SaveDatalistPanel.isDataListSaved = false;

                        WindowUtilities.showInDialog(mainFrame, GlobalNavigationPanel.mainSearchPanel,
                                                     ApplicationProperties.getValue(ApplicationResourceConstants.SEARCH_FRAME_TITLE), new Dimension((int) (dimension.width * 0.90),
                                                             (int) (dimension.height * 0.85)), true, true);
                    } else {
                        JOptionPane.showMessageDialog(mainFrame, "Yet to Implement");
                    }
                }
            }
        });

        JScrollPane scrollPane = new JScrollPane(welcomePageEditorPane);
        scrollPane.setBorder(null);
        this.add(scrollPane);
    }

    private JEditorPane createEditorPane() {
        JEditorPane editorPane = new JEditorPane();
        editorPane.setEditable(false);
        try {
            java.net.URL helpURL = this.getClass().getClassLoader().getResource("welcomepage.html");
            editorPane.setPage(helpURL);
        } catch (MalformedURLException malExp) {
            CommonUtils.handleException(malExp, mainFrame, true, true, false, false);
        } catch (IOException e) {
            CommonUtils.handleException(e, mainFrame, true, true, false, false);
        }
        return editorPane;
    }
}
@@ -2882,24 +2882,104 @@
 e, %22
-Yet to I
+This link will take you to Analyze and Visualize Data screen.%5CnThis feature is not yet i
 mplement
 %22);%0D
@@ -2974,16 +2974,19 @@
 mplement
+ed.
 %22);%0D%0A   

Modified the INFO message