Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Super Dev Mode from within GWT app

I guess the title says it all:

Is there some kind of flag that allows my GWT app to check whether it is currently running in Super Dev Mode (something along the lines of GWT.isProdMode(), maybe)?

like image 227
Markus A. Avatar asked Dec 12 '22 02:12

Markus A.


1 Answers

As it was already mentioned, there is a superdevmode property that you can use.

Here is a real-life example:

  1. Create a class containing a method that tells that we are not in SuperDevMode:

    public class SuperDevModeIndicator {
        public boolean isSuperDevMode() {
            return false;
        }
    }
    
  2. Extend previous class and override a method to tell that we are in SuperDevMode:

    public class SuperDevModeIndicatorTrue extends SuperDevModeIndicator {
        @Override
        public boolean isSuperDevMode() {
            return true;
        }
    }
    
  3. Use only one, appropriate class depending on a superdevmode property - use deferred binding - put this in your *.gwt.xml:

    <!-- deferred binding for Super Dev Mode indicator -->
    <replace-with class="com.adam.project.client.SuperDevModeIndicatorTrue">
      <when-type-is class="com.adam.project.client.SuperDevModeIndicator"/>
      <when-property-is name="superdevmode" value="on" />
    </replace-with>
    
  4. Instantiate SuperDevModeIndicator class via deferred binding:

    SuperDevModeIndicator superDevModeIndicator = GWT.create(SuperDevModeIndicator.class);
    
  5. Use it to check whether you are in SuperDevMode or not:

    superDevModeIndicator.isSuperDevMode();
    

Voila!

Here you will find documentation on Deferred binding.

like image 93
Adam Avatar answered Dec 13 '22 16:12

Adam