/*-------------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved.
-------------------------------------------------------------------------------*/

package com.togethersoft.modules.tutorial;

import com.togethersoft.openapi.ide.IdeContext;
import com.togethersoft.openapi.ide.IdeScript;
import com.togethersoft.openapi.ide.message.IdeMessageManager;
import com.togethersoft.openapi.ide.message.IdeMessageManagerAccess;
import com.togethersoft.openapi.ide.message.IdeMessageType;

/**
 * This module shows how to make Together's message pane visible/invisible.
 * It is a very simple module, but it can be used as a template for modules
 * dealing with the visibility of a message pane.
 * In the next lesson you will learn how to add new pages to the message pane.
 *
 * @author TogetherSoft
 */
public class Lesson09 implements IdeScript
{
   /**
    * Runs this module.
    *
    * @param context the IdeContext instance containing
    * the selection information at the moment the module was called.
    */
    public void run(IdeContext context)
    {
        // printing information message
        IdeMessageManagerAccess.printMessage
            (IdeMessageType.INFORMATION, "Lesson09 module: started");

        // getting message manager
        messageManager = IdeMessageManagerAccess.getMessageManager();

        // if message pane is already visible
        if (messageManager.isPaneVisible())
        {
            makeInvisible("Currently message pane is visible. Now we will make it invisible.");
            makeVisible("Ok, message pane is invisible. Now we will make it visible again.");
        }
        else
        {
            makeVisible("Currently message pane is invisible. Now we will make it visible.");
            makeInvisible("Ok, message pane is visible. Now we will make it invisible again.");
        }

        // printing final message
        IdeMessageManagerAccess.printMessage
            (IdeMessageType.INFORMATION, "Lesson09 module: finished");
    }

    /**
     * Shows modal window with specified message and makes
     * message pane visible.
     *
     * @param text message text
     */
    private void makeVisible(String text)
    {
        IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION_MODAL, text);
        messageManager.setPaneVisible(true);
    }

    /**
     * Shows modal window with specified message and makes
     * message pane invisible.
     *
     * @param text message text
     */
    private void makeInvisible(String text)
    {
        IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION_MODAL, text);
        messageManager.setPaneVisible(false);
    }

    private IdeMessageManager messageManager; // message manager

}




