
package cz.karry.dop.nbmodule.dbg.breakpoints;

import org.netbeans.api.debugger.Breakpoint;
import cz.karry.dop.nbmodule.dbg.DebugSession;


/**
 * @author ads
 *
 */
public abstract class AbstractBreakpoint extends Breakpoint {
    
    protected AbstractBreakpoint() {
        isEnabled = true;
    }
    
    public abstract boolean isSessionRelated( DebugSession session );
    
    /*
     * Method is called from debugger manager listener when breakpoint is removed.
     * It is allowed to provide clear actions.
     * This method should be implemented in sublasses if needed.
     */
    public void removed(){
    }

    /* (non-Javadoc)
     * @see org.netbeans.api.debugger.Breakpoint#disable()
     */
    @Override
    public void disable() {
        if(!isEnabled) {
            return;
        }

        isEnabled = false;
        firePropertyChange(PROP_ENABLED, Boolean.TRUE, Boolean.FALSE);
    }

    /* (non-Javadoc)
     * @see org.netbeans.api.debugger.Breakpoint#enable()
     */
    @Override
    public void enable() {
        if(isEnabled) {
            return;
        }

        isEnabled = true;
        firePropertyChange(PROP_ENABLED, Boolean.FALSE, Boolean.TRUE);
    }

    /* (non-Javadoc)
     * @see org.netbeans.api.debugger.Breakpoint#isEnabled()
     */
    @Override
    public boolean isEnabled() {
        return isEnabled;
    }
    
    public int isTemp() {
        return 0;
    }
    
    public void setBreakpointId( String id ) {
        myId = id ;
    }
    
    public String getBreakpointId() {
        return myId;
    }
    
    private String myId;
    
    private boolean isEnabled;

}
