Renaming AppState.setActive() -> setEnabled()

For consistency, this patch renames setActive()/isActive() to setEnabled()/isEnabled()

http://hub.jmonkeyengine.org/groups/development-discussion-jme3/forum/topic/setactive-vs-setenabled/

[patch]

Index: src/core/com/jme3/cinematic/Cinematic.java

===================================================================

— src/core/com/jme3/cinematic/Cinematic.java (revision 7141)

+++ src/core/com/jme3/cinematic/Cinematic.java (working copy)

@@ -198,16 +198,33 @@

return initialized;

}


  • /**
  • * Use setEnabled() instead<br />
    
  • */<br />
    
  • @Deprecated

    public void setActive(boolean active) {
  •    if (active) {<br />
    
  •        play();<br />
    
  •    }<br />
    
  •    setEnabled(active);<br />
    

}


  • /**
  • * Use isEnabled() instead<br />
    
  • */<br />
    
  • @Deprecated

    public boolean isActive() {
  •    return isEnabled();<br />
    
  • }

    +
  • public void setEnabled(boolean enabled) {
  •    if (enabled) {<br />
    
  •        play();<br />
    
  •    }<br />
    
  • }

    +
  • public boolean isEnabled() {

    return playState == PlayState.Playing;

    }



    +

    public void stateAttached(AppStateManager stateManager) {

    }



    Index: src/core/com/jme3/app/state/AppState.java

    ===================================================================

    — src/core/com/jme3/app/state/AppState.java (revision 7141)

    +++ src/core/com/jme3/app/state/AppState.java (working copy)

    @@ -64,22 +64,41 @@

    public boolean isInitialized();



    /**
  • * Use setEnabled() instead.<br />
    
  • Activate or deactivate the functionality of the <code>AppState</code>.
  • The effect of this call depends on implementation. An
  • <code>AppState</code> starts as being active by default.

    *
  • @param active activate the AppState or not.

    */
  • @Deprecated

    public void setActive(boolean active);



    /**
  • * Use isEnabled() instead.<br />
    
  • @return True if the <code>AppState</code> is active, false otherwise.

    *
  • @see AppState#setActive(boolean)

    */
  • @Deprecated

    public boolean isActive();



    /**
  • * Enable or disable the functionality of the &lt;code&gt;AppState&lt;/code&gt;.<br />
    
  • * The effect of this call depends on implementation. An<br />
    
  • * &lt;code&gt;AppState&lt;/code&gt; starts as being enabled by default.<br />
    
  • *<br />
    
  • * @param active activate the AppState or not.<br />
    
  • */<br />
    
  • public void setEnabled(boolean active);

    +
  • /**
  • * @return True if the &lt;code&gt;AppState&lt;/code&gt; is enabled, false otherwise.<br />
    
  • *<br />
    
  • * @see AppState#setEnabled(boolean)<br />
    
  • */<br />
    
  • public boolean isEnabled();
  • /**
  • Called when the state was attached.

    *
  • @param stateManager State manager to which the state was attached to.

    Index: src/core/com/jme3/app/state/AbstractAppState.java

    ===================================================================

    — src/core/com/jme3/app/state/AbstractAppState.java (revision 7141)

    +++ src/core/com/jme3/app/state/AbstractAppState.java (working copy)

    @@ -49,7 +49,7 @@
  • is set back to false.

    */

    protected boolean initialized = false;
  • private boolean active = true;
  • private boolean enabled = true;



    public void initialize(AppStateManager stateManager, Application app) {

    initialized = true;

    @@ -59,12 +59,28 @@

    return initialized;

    }


  • /**
  • * Use setEnabled() instead<br />
    
  • */<br />
    
  • @Deprecated

    public void setActive(boolean active) {
  •    this.active = active;<br />
    
  •    setEnabled(active);<br />
    

}


  • /**
  • * Use isEnabled() instead<br />
    
  • */<br />
    
  • @Deprecated

    public boolean isActive() {
  •    return active;<br />
    
  •    return isEnabled();<br />
    
  • }

    +
  • public void setEnabled(boolean enabled) {
  •    this.enabled = enabled;<br />
    
  • }

    +
  • public boolean isEnabled() {
  •    return enabled;<br />
    

}



public void stateAttached(AppStateManager stateManager) {

Index: src/core/com/jme3/app/state/AppStateManager.java

===================================================================

— src/core/com/jme3/app/state/AppStateManager.java (revision 7141)

+++ src/core/com/jme3/app/state/AppStateManager.java (working copy)

@@ -139,7 +139,7 @@

if (!state.isInitialized())

state.initialize(this, app);


  •            if (state.isActive()) {<br />
    
  •            if (state.isEnabled()) {<br />
    

state.update(tpf);

}

}

@@ -158,7 +158,7 @@

if (!state.isInitialized())

state.initialize(this, app);


  •            if (state.isActive()) {<br />
    
  •            if (state.isEnabled()) {<br />
    

state.render(rm);

}

}

@@ -177,7 +177,7 @@

if (!state.isInitialized())

state.initialize(this, app);


  •            if (state.isActive()) {<br />
    
  •            if (state.isEnabled()) {<br />
    

state.postRender();

}

}

Index: src/test/jme3test/animation/TestCameraMotionPath.java

===================================================================

— src/test/jme3test/animation/TestCameraMotionPath.java (revision 7141)

+++ src/test/jme3test/animation/TestCameraMotionPath.java (working copy)

@@ -60,7 +60,7 @@

private MotionTrack cameraMotionControl;

private ChaseCamera chaser;

private CameraNode camNode;

-

+

public static void main(String[] args) {

TestCameraMotionPath app = new TestCameraMotionPath();

app.start();

Index: src/jbullet/com/jme3/bullet/BulletAppState.java

===================================================================

— src/jbullet/com/jme3/bullet/BulletAppState.java (revision 7141)

+++ src/jbullet/com/jme3/bullet/BulletAppState.java (working copy)

@@ -149,11 +149,27 @@

return initialized;

}


  • /**
  • * Use setEnabled() instead<br />
    
  • */<br />
    
  • @Deprecated

    public void setActive(boolean active) {
  •    this.active = active;<br />
    
  •    setEnabled(active);<br />
    

}


  • /**
  • * Use isEnabled() instead<br />
    
  • */<br />
    
  • @Deprecated

    public boolean isActive() {
  •    return isEnabled();<br />
    
  • }

    +
  • public void setEnabled(boolean enabled) {
  •    this.active = enabled;<br />
    
  • }

    +
  • public boolean isEnabled() {

    return active;

    }



    [/patch]
2 Likes

because It doesn’t break any existing code and nehon agreed,

I committed this in svn. rev.7143

If there is a problem, let me know. then I’ll revert this.

Thanks Mulova :wink:

Keeping the deprecated method in the AppState interface was not such a good idea, the users using that will have to change their code anyway and when you keep the deprecated method they have to change it a second time when we finally remove it, I changed that and only kept setActive in the AbstractAppState. Also, please download the whole trunk folder and run a complete sdk build before committing and at least tell me when the build breaks, because otherwise the people will not get any updates until I somehow recognize the build is broken.



Cheers,

Normen

I see. I’ll do as you said next time. :wink:

Have a nice weekend normen!

Also to add to what normen said, you should try running some of the relevant tests under jme3test before committing to make sure your changes did not break anything.

Oops, Maybe I did something wrong. :o

It was so obvious so I didn’t do that.

I’ll always run relevant test from now on.

Good day Momoko_Fan.