Changeset 1057

Show
Ignore:
Timestamp:
01/24/12 23:48:01 (4 months ago)
Author:
ke
Message:

Step counter in main window title is now slightly less hacky, is updated correctly when a session is loaded.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/org/kahina/core/KahinaInstance.java

    r1049 r1057  
    128128                if (state != null) 
    129129                { 
    130                         state.reset(); 
     130                        state.initialize(); 
    131131                } else 
    132132                { 
     
    228228                        gui.displayMainViews(); 
    229229                        KahinaRunner.processEvent(new KahinaSelectionEvent(state.getSelectedStepID())); 
     230                        KahinaRunner.processEvent(new KahinaSystemEvent(KahinaSystemEvent.NODE_COUNT, state.getStepCount())); 
    230231                } catch (Exception e) 
    231232                { 
  • trunk/src/org/kahina/core/KahinaState.java

    r1049 r1057  
    5050    public KahinaState() 
    5151    { 
    52         consoleMessages = new KahinaTextModel(); 
    53         consoleLines = new HashMap<Integer,Set<KahinaLineReference>>(); 
    54         warnThresholdByBreakpoint = new HashMap<KahinaBreakpoint, Integer>(); 
    55         matchCountByBreakpoint = new HashMap<KahinaBreakpoint, Integer>(); 
     52        initialize(); 
    5653        KahinaRunner.getControl().registerListener(KahinaEventTypes.SELECTION, this); 
    5754    } 
    5855     
    59         public void reset()  
     56        public void initialize()  
    6057        { 
     58                selectedStepID = -1; 
     59                nextStepID = 1; 
    6160                //console is refilled for each new process 
    6261                //TODO: think about an additional console for global events (warnings etc.) 
     
    7473        } 
    7574        return nextStepID++; 
     75    } 
     76     
     77    public int getStepCount() 
     78    { 
     79        return nextStepID - 1; 
    7680    } 
    7781     
  • trunk/src/org/kahina/core/control/KahinaSystemEvent.java

    r1049 r1057  
    99    public static final int QUIT = 0; 
    1010    public static final int APPLY_BREAKPOINTS = 1; 
     11    public static final int NODE_COUNT = 2; 
    1112     
    1213    public KahinaSystemEvent(int systemEventType) 
  • trunk/src/org/kahina/core/gui/windows/KahinaMainWindow.java

    r1050 r1057  
    33import java.awt.Container; 
    44import java.awt.dnd.DropTarget; 
    5 import java.awt.event.WindowAdapter; 
    6 import java.awt.event.WindowEvent; 
    75 
    86import javax.swing.JMenuBar; 
    97 
    10 import org.kahina.core.KahinaRunner; 
    118import org.kahina.core.control.KahinaEvent; 
    129import org.kahina.core.control.KahinaEventTypes; 
    1310import org.kahina.core.control.KahinaListener; 
    14 import org.kahina.core.control.KahinaSessionEvent; 
    1511import org.kahina.core.control.KahinaSystemEvent; 
    16 import org.kahina.core.data.tree.KahinaTreeEvent; 
    17 import org.kahina.core.data.tree.KahinaTreeEventType; 
    1812import org.kahina.core.gui.KahinaSessionMenu; 
    1913import org.kahina.core.gui.KahinaWindowManager; 
     
    4842        { 
    4943                this.setTitle("Kahina"); 
    50                 wm.getControl().registerListener(KahinaEventTypes.TREE, this); 
    5144                // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    5245                // Uncomment this in order to be able to profile using JRat. 
     
    6457 
    6558                wm.getControl().registerListener(KahinaEventTypes.SYSTEM, this); 
    66                 wm.getControl().registerListener(KahinaEventTypes.SESSION, this); 
    6759        } 
    6860 
     
    148140        public void processEvent(KahinaEvent event) 
    149141        { 
    150                 if (event instanceof KahinaTreeEvent) 
    151                 { 
    152                         processTreeEvent((KahinaTreeEvent) event); 
    153                 } else if (event instanceof KahinaSystemEvent) 
     142                if (event instanceof KahinaSystemEvent) 
    154143                { 
    155144                        processSystemEvent((KahinaSystemEvent) event); 
    156                 } else if (event instanceof KahinaSessionEvent) 
    157                 { 
    158                         processSessionEvent((KahinaSessionEvent) event); 
    159                 } 
    160         } 
    161  
    162         private void processSessionEvent(KahinaSessionEvent event) 
    163         { 
    164                 if (event.getSessionEventType() == KahinaSessionEvent.LOAD_SESSION) 
    165                 { 
    166                         // TODO This is a kludge, see below. 
    167                         setTitle("Kahina"); 
    168                 } 
    169         } 
    170  
    171         private void processTreeEvent(KahinaTreeEvent event) 
    172         { 
    173                 if (event.getTreeEventType() == KahinaTreeEventType.NEW_NODE) 
    174                 { 
    175                         // TODO This is a kludge, we should synchronize the step 
    176                         // count with the state. But first, the architecture needs to be 
    177                         // changed to allow access to the state. 
    178                         setTitle("Kahina (" + event.getFirstID() + ")"); 
    179145                } 
    180146        } 
     
    182148        private void processSystemEvent(KahinaSystemEvent event) 
    183149        { 
    184                 if (event.getSystemEventType() == KahinaSystemEvent.QUIT) 
     150                if (event.getSystemEventType() == KahinaSystemEvent.NODE_COUNT) 
     151                { 
     152                        setTitle("Kahina (" + event.getIntContent() + ")"); 
     153                } else if (event.getSystemEventType() == KahinaSystemEvent.QUIT) 
    185154                { 
    186155                        disposeAllWindows(); 
  • trunk/src/org/kahina/core/gui/windows/KahinaWindow.java

    r1054 r1057  
    150150    public void setTitle(String title) 
    151151    { 
    152         System.err.println(this + ".setTitle(" + title + ")"); 
     152        if (VERBOSE) 
     153        { 
     154                System.err.println(this + ".setTitle(" + title + ")"); 
     155        } 
    153156        super.setTitle(title); 
    154157        mainPanel.setTitle(title); 
  • trunk/src/org/kahina/lp/LogicProgrammingState.java

    r1049 r1057  
    6363    } 
    6464     
    65         public void reset()  
    66         { 
    67         super.reset(); 
     65        public void initialize()  
     66        { 
     67        super.initialize(); 
    6868        stepTree = new KahinaMemTree(); 
    6969        secondaryStepTree = new KahinaMemTree(); 
  • trunk/src/org/kahina/lp/bridge/LogicProgrammingBridge.java

    r1049 r1057  
    247247                        KahinaRunner.processEvent(new LogicProgrammingBridgeEvent(LogicProgrammingBridgeEventType.STEP_CALL, stepID, parentCandidateID)); 
    248248                        // used by node counter: 
    249                         KahinaRunner.processEvent(new KahinaTreeEvent(KahinaTreeEventType.NEW_NODE, stepID, parentCandidateID)); 
     249                        KahinaRunner.processEvent(new KahinaSystemEvent(KahinaSystemEvent.NODE_COUNT, stepID)); 
    250250                        currentID = stepID; 
    251251                        parentCandidateID = stepID; 
  • trunk/src/org/kahina/tralesld/TraleSLDState.java

    r865 r1057  
    3838        } 
    3939         
    40         public void reset() 
     40        public void initialize() 
    4141        { 
    42                 super.reset(); 
     42                super.initialize(); 
    4343                //keep signature and auxiliary instance (constant across parses) 
    4444                chart = new KahinaMemChart();