www.pudn.com > 20061029005.rar > ApplicationController.java


// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov. 
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html 
// Decompiler options: packimports(3) fieldsfirst ansi  
 
package org.cesar.inmotion.util; 
 
import java.util.Hashtable; 
import javax.microedition.lcdui.*; 
 
// Referenced classes of package org.cesar.inmotion.util: 
//            AbstractMIDlet 
 
public abstract class ApplicationController 
{ 
 
    public static final int PRESENTATION_SCREEN = -10; 
    public static final int MAIN_MENU_SCREEN = -11; 
    public static final int NO_SCREEN = -12; 
    private Hashtable screenTable; 
    private int currentScreen; 
    private static ApplicationController instance; 
 
    public ApplicationController() 
    { 
        screenTable = new Hashtable(); 
        currentScreen = -12; 
    } 
 
    public void setPresentation(Displayable displayable) 
    { 
        screenTable.put(new Integer(-10), displayable); 
    } 
 
    public void setMainMenu(Displayable displayable) 
    { 
        screenTable.put(new Integer(-11), displayable); 
    } 
 
    public void addScreen(int i, Displayable displayable) 
        throws IllegalArgumentException 
    { 
        if(i != -10 && i != -11) 
            screenTable.put(new Integer(i), displayable); 
        else 
            throw new IllegalArgumentException(); 
    } 
 
    public void removeScreen(int i) 
    { 
        screenTable.remove(getScreen(i)); 
    } 
 
    public Displayable getScreen(int i) 
        throws IllegalArgumentException 
    { 
        return (Displayable)screenTable.get(new Integer(i)); 
    } 
 
    public void changeScreen(int i) 
    { 
        Displayable displayable = (Displayable)screenTable.get(new Integer(i)); 
        if(displayable != null) 
        { 
            AbstractMIDlet.getDisplay().setCurrent(displayable); 
            currentScreen = i; 
        } 
    } 
 
    public static ApplicationController getInstance(String s) 
    { 
        if(instance == null) 
            try 
            { 
                instance = (ApplicationController)Class.forName(s).newInstance(); 
            } 
            catch(ClassNotFoundException classnotfoundexception) 
            { 
                classnotfoundexception.printStackTrace(); 
            } 
            catch(Exception exception) 
            { 
                exception.printStackTrace(); 
            } 
        return instance; 
    } 
 
    public abstract void paintScreen(String s, Graphics g); 
 
    public abstract void startAppAction(); 
 
    public abstract void processAction(int i); 
 
    public int getCurrentScreen() 
    { 
        return currentScreen; 
    } 
}