package Templates.API_Support.Window_System_API;

import org.openide.util.NbBundle;
import org.openide.windows.*;

/**
 * An openable window available to the IDE's window manager.
 * @author __USER__
 */
public class __NAME__ extends TopComponent /* or CloneableTopComponent */ {

    // REMEMBER: You should have a public default constructor!
    // This is for externalization. If you have a nondefault
    // constructor for normal creation of the component, leave
    // in a default constructor that will put the component into
    // a consistent but unconfigured state, and make sure readExternal
    // initializes it properly. Or, be creative with writeReplace().
    public __NAME__() {
        initComponents();
        setCloseOperation(CLOSE_LAST); // or CLOSE_EACH
        // Display name of this window (not needed if you use the DataObject constructor):
        setName(NbBundle.getMessage(__NAME__.class, "LBL_component_name"));
        // You may set the icon, but often it is better to set the icon for an associated mode instead:
        // setIcon(Utilities.loadImage("__PACKAGE_AND_NAME_SLASHES__Icon.gif", true));
        // Use the Component Inspector to set tool-tip text. This will be saved
        // automatically. Other JComponent properties you may need to save yuorself.
        // At any time you can affect the node selection:
        // setActivatedNodes(new Node[] {...});
    }

    /*
    public HelpCtx getHelpCtx() {
	return new HelpCtx(__NAME__.class);
    }
    */

    /*
    // If you are using CloneableTopComponent, probably you should override:
    protected CloneableTopComponent createClonedObject() {
	return new __NAME__();
    }
    protected boolean closeLast() {
	// You might want to prompt the user first and maybe return false:
	return true;
    }
    */

    // APPEARANCE

    /** 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 FormEditor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        setLayout(new java.awt.BorderLayout());

    }//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

    // PERSISTENCE

    private static final long serialVersionUID = 1L;

    public int getPersistenceType() {
        return PERSISTENCE_ONLY_OPENED;
    }

    /*
    // If you wish to keep any state between IDE restarts, put it here:
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
	super.readExternal(in);
	setSomeState((SomeType)in.readObject());
    }
    public void writeExternal(ObjectOutput out) throws IOException {
	super.writeExternal(out);
	out.writeObject(getSomeState());
    }
    */

    /*
    // The above assumes that the SomeType is safely serializable, e.g. String or Date.
    // If it is some class of your own that might change incompatibly, use e.g.:
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
	super.readExternal(in);
	NbMarshalledObject read = (NbMarshalledObject)in.readObject();
	if (read != null) {
	    try {
		setSomeState((SomeType)read.get());
	    } catch (Exception e) {
		ErrorManager.getDefault().notify(e);
		// If the problem would make this component inconsistent, use:
		// throw new SafeException(e);
	    }
	}
    }
    public void writeExternal(ObjectOutput out) throws IOException {
	super.writeExternal(out);
	Object toWrite;
	try {
	    toWrite = new NbMarshalledObject(getSomeState());
	} catch (Exception e) {
	    ErrorManager.getDefault().notify(e);
	    toWrite = null;
	    // Again you may prefer to use:
	    // throw new SafeException(e);
	}
	out.writeObject(toWrite);
    }
    */

    /*
    // Use this to discard the component after restarts (make it nonpersistent):
    private Object readResolve() throws ObjectStreamException {
	return null;
	// If you wish to conditionally discard it, make readExternal set
	// or clear some flag acc. to the condition, then use:
	// return discardFlag ? null : this;
	// Singleton component using private static __NAME__ theInstance:
	// if (theInstance == null) theInstance = this;
	// return theInstance;
    }
    */

    // ACTIONS

    /*
    // If you wish to have extra actions appear in the window's
    // popup menu, they can go here:
    public Action[] getActions() {
	Action[] supe = super.getActions();
	Action[] mine = new Action[supe.length + 1];
	System.arraycopy(supe, 0, mine, 0, supe.length);
	mine[supe.length] = SystemAction.get(SomeActionOfMine.class);
	return mine;
    }
    */

    /*
    // To update Find, Copy, etc. actions, add to constructor:
    ActionMap map = getActionMap();
    Action findBinding = new MyFindAction(this);
    map.put(((CallbackSystemAction)SystemAction.get(FindAction.class)).getActionMapKey(), findBinding);
    */

    /*
    // If you want UndoAction and RedoAction to be enabled on this component:
    public UndoRedo getUndoRedo() {
	return new MyUndoRedo(this);
    }
    */

    // Printing, saving, compiling, etc.: use cookies on some appropriate node and
    // use this node as the node selection.

}
