Changeset 400
- Timestamp:
- 08/10/10 22:21:21 (1 year ago)
- Files:
-
- kahina/trunk/src/org/kahina/core/KahinaInstance.java (modified) (1 diff)
- kahina/trunk/src/org/kahina/core/LogicProgrammingInstance.java (added)
- kahina/trunk/src/org/kahina/core/behavior/KahinaTreeBehavior.java (modified) (1 diff)
- kahina/trunk/src/org/kahina/core/event/KahinaDialogEvent.java (modified) (1 diff)
- kahina/trunk/src/org/kahina/core/gui/KahinaGUI.java (modified) (2 diffs)
- kahina/trunk/src/org/kahina/core/gui/KahinaMainWindow.java (modified) (1 diff)
- kahina/trunk/src/org/kahina/core/gui/profiler/KahinaProfilerMenu.java (modified) (2 diffs)
- kahina/trunk/src/org/kahina/lp/LogicProgrammingState.java (modified) (5 diffs)
- kahina/trunk/src/org/kahina/lp/LogicProgrammingStep.java (modified) (3 diffs)
- kahina/trunk/src/org/kahina/lp/bridge/LogicProgrammingBridge.java (modified) (2 diffs)
- kahina/trunk/src/org/kahina/lp/gui/LogicProgrammingGUI.java (modified) (3 diffs)
- kahina/trunk/src/org/kahina/lp/gui/profiler (added)
- kahina/trunk/src/org/kahina/lp/gui/profiler/LogicProgrammingProfileWindow.java (added)
- kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfile.java (modified) (2 diffs)
- kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfiler.java (modified) (3 diffs)
- kahina/trunk/src/org/kahina/tralesld/TraleSLDInstance.java (modified) (6 diffs)
- kahina/trunk/src/org/kahina/tralesld/bridge/TraleSLDBridge.java (modified) (1 diff)
- kahina/trunk/src/org/kahina/tralesld/gui/TraleSLDGUI.java (modified) (3 diffs)
- kahina/trunk/src/org/kahina/tralesld/profiler/TraleSLDProfiler.java (moved) (moved from kahina/trunk/src/org/kahina/lp/profiler/TraleSLDProfiler.java) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
kahina/trunk/src/org/kahina/core/KahinaInstance.java
r399 r400 30 30 import org.kahina.core.io.magazine.ObjectMagazine; 31 31 import org.kahina.core.util.FileUtilities; 32 import org.kahina.core.util.KahinaSwingUtilities; 32 33 import org.kahina.core.util.ProgressMonitorWrapper; 33 import org.kahina.core.util.KahinaSwingUtilities;34 34 import org.kahina.core.visual.KahinaDefaultView; 35 35 import org.kahina.core.visual.source.KahinaSourceCodeView; kahina/trunk/src/org/kahina/core/behavior/KahinaTreeBehavior.java
r397 r400 2 2 3 3 import org.kahina.core.KahinaInstance; 4 import org.kahina.core.KahinaRunner;5 4 import org.kahina.core.control.KahinaListener; 6 5 import org.kahina.core.data.tree.KahinaTree; kahina/trunk/src/org/kahina/core/event/KahinaDialogEvent.java
r371 r400 13 13 public static final int CREEP_POINTS = 7; 14 14 public static final int FAIL_POINTS = 8; 15 public static final int FULL_PROFILE = 9; 16 public static final int CALL_SUBTREE_PROFILE = 10; 17 public static final int SEARCH_SUBTREE_PROFILE = 11; 18 public static final int EDIT_WARNINGS = 12; 15 19 16 20 public KahinaDialogEvent(int dialogEventType) kahina/trunk/src/org/kahina/core/gui/KahinaGUI.java
r390 r400 106 106 System.err.println("Generating views for step fields:"); 107 107 } 108 Field[] fields = stepType.getFields(); 108 109 for (Field field : stepType.getFields()) 109 110 { … … 150 151 if (view1 == null || view2 == null) 151 152 { 152 System.err.println("Error integrating views: " + var1 + " and " + var2);153 throw new RuntimeException("Error integrating views: " + var1 + " and " + var2); 153 154 } 154 155 else kahina/trunk/src/org/kahina/core/gui/KahinaMainWindow.java
r399 r400 37 37 JMenuBar menuBar = new JMenuBar(); 38 38 menuBar.add(new KahinaSessionMenu()); 39 40 // TODO these three menus are specific to logic programming or TraleSLD, should be added dynamically 39 41 menuBar.add(new KahinaParseMenu()); 40 42 menuBar.add(new KahinaBreakpointMenu()); 41 43 menuBar.add(new KahinaProfilerMenu()); 44 42 45 menuBar.add(new KahinaHelpMenu()); 43 46 this.setJMenuBar(menuBar); kahina/trunk/src/org/kahina/core/gui/profiler/KahinaProfilerMenu.java
r399 r400 6 6 import javax.swing.JMenu; 7 7 8 import org.kahina.core.KahinaRunner; 9 import org.kahina.core.event.KahinaDialogEvent; 8 10 import org.kahina.core.util.KahinaSwingUtilities; 9 11 … … 26 28 public void actionPerformed(ActionEvent e) 27 29 { 28 // TODO Auto-generated method stub 29 30 String command = e.getActionCommand(); 31 if (command.equals("fullProfile")) 32 { 33 KahinaRunner.processEvent(new KahinaDialogEvent(KahinaDialogEvent.FULL_PROFILE)); 34 } else if (command.equals("callSubtreeProfile")) 35 { 36 KahinaRunner.processEvent(new KahinaDialogEvent(KahinaDialogEvent.CALL_SUBTREE_PROFILE)); 37 } else if (command.equals("searchSubtreeProfile")) 38 { 39 KahinaRunner.processEvent(new KahinaDialogEvent(KahinaDialogEvent.SEARCH_SUBTREE_PROFILE)); 40 } else if (command.equals("editWarnings")) 41 { 42 KahinaRunner.processEvent(new KahinaDialogEvent(KahinaDialogEvent.EDIT_WARNINGS)); 43 } 30 44 } 31 45 kahina/trunk/src/org/kahina/lp/LogicProgrammingState.java
r384 r400 17 17 import org.kahina.core.event.KahinaMessageEvent; 18 18 import org.kahina.lp.data.text.LogicProgrammingLineReference; 19 import org.kahina.lp.profiler.LogicProgrammingProfile; 19 20 20 21 public class LogicProgrammingState extends KahinaState … … 38 39 protected List<KahinaBreakpoint> failPoints; 39 40 41 protected LogicProgrammingProfile profile; 42 40 43 public LogicProgrammingState() 41 44 { … … 52 55 failPoints = new ArrayList<KahinaBreakpoint>(); 53 56 54 //database variant turned out to be too slow 55 /* switch (dataHandlingMethod) 56 { 57 case KahinaDataHandlingMethod.DATABASE: 58 { 59 stepTree = new KahinaDbTree(KahinaRunner.getDatabaseHandler()); 60 secondaryStepTree = new KahinaDbTree(KahinaRunner.getDatabaseHandler()); 61 break; 62 } 63 case KahinaDataHandlingMethod.MEMORY: 64 { 65 stepTree = new KahinaMemTree(); 66 secondaryStepTree = new KahinaMemTree(); 67 break; 68 } 69 }*/ 57 profile = new LogicProgrammingProfile(); 70 58 } 71 59 … … 88 76 } 89 77 refs.add(ref); 90 //ref.store();91 78 KahinaRunner.processEvent(new KahinaMessageEvent(ref)); 92 79 } … … 173 160 return Collections.unmodifiableList(result); 174 161 } 162 163 public LogicProgrammingProfile getFullProfile() 164 { 165 return profile; 166 } 175 167 176 168 } kahina/trunk/src/org/kahina/lp/LogicProgrammingStep.java
r383 r400 18 18 public KahinaSourceCodeLocation codeLocation; 19 19 20 public boolean redone; 21 20 22 public LogicProgrammingStep copy() 21 23 { … … 24 26 copy.externalID = externalID; 25 27 copy.codeLocation = codeLocation; 28 copy.redone = redone; 26 29 return copy; 27 30 } … … 61 64 return KahinaRunner.retrieve(LogicProgrammingStep.class, id); 62 65 } 66 67 public void setRedone(boolean redone) 68 { 69 this.redone = redone; 70 } 71 72 public boolean isRedone() 73 { 74 return redone; 75 } 63 76 } kahina/trunk/src/org/kahina/lp/bridge/LogicProgrammingBridge.java
r397 r400 90 90 LogicProgrammingStep step = LogicProgrammingStep.get(stepID); 91 91 step.setGoalDesc(nodeLabel); 92 step.setRedone(false); 92 93 step.setSourceCodeLocation(LogicProgrammingStep.get(currentID).getSourceCodeLocation()); 93 94 KahinaRunner.store(stepID, step); … … 159 160 LogicProgrammingStep lastStep = LogicProgrammingStep.get(lastStepID); 160 161 LogicProgrammingStep newStep = lastStep.copy(); 162 newStep.setRedone(true); 161 163 int newStepID = state.nextStepID(); 162 164 KahinaRunner.store(newStepID, newStep); kahina/trunk/src/org/kahina/lp/gui/LogicProgrammingGUI.java
r384 r400 4 4 import java.awt.event.KeyEvent; 5 5 6 import javax.swing.JFrame; 7 6 8 import org.kahina.core.KahinaInstance; 7 9 import org.kahina.core.KahinaRunner; 8 10 import org.kahina.core.KahinaStep; 11 import org.kahina.core.LogicProgrammingInstance; 9 12 import org.kahina.core.breakpoint.KahinaBreakpointType; 10 13 import org.kahina.core.control.KahinaController; … … 13 16 import org.kahina.core.gui.KahinaGUI; 14 17 import org.kahina.core.gui.breakpoint.BreakpointEditorWindow; 18 import org.kahina.core.profiler.DefaultProfileEntryMapper; 19 import org.kahina.core.profiler.ProfileEntry; 20 import org.kahina.core.util.Mapper; 15 21 import org.kahina.core.visual.tree.KahinaLayeredTreeView; 16 22 import org.kahina.lp.LogicProgrammingState; 17 23 import org.kahina.lp.LogicProgrammingStepType; 24 import org.kahina.lp.gui.profiler.LogicProgrammingProfileWindow; 18 25 19 26 public class LogicProgrammingGUI extends KahinaGUI … … 108 115 break; 109 116 } 117 case KahinaDialogEvent.FULL_PROFILE: 118 { 119 JFrame window = new LogicProgrammingProfileWindow(((LogicProgrammingState) kahina.getState()).getFullProfile()); 120 window.setTitle("Full profile"); 121 window.setVisible(true); 122 break; 123 } 124 case KahinaDialogEvent.CALL_SUBTREE_PROFILE: 125 { 126 LogicProgrammingState state = (LogicProgrammingState) kahina.getState(); 127 JFrame window = new LogicProgrammingProfileWindow(((LogicProgrammingInstance<?, ?, ?>) kahina).getProfiler().profileSubtree(state.getSecondaryStepTree(), state.getSelectedStepID())); 128 window.setTitle("Call subtree profile"); 129 window.setVisible(true); 130 break; 131 } 132 case KahinaDialogEvent.SEARCH_SUBTREE_PROFILE: 133 { 134 LogicProgrammingState state = (LogicProgrammingState) kahina.getState(); 135 JFrame window = new LogicProgrammingProfileWindow(((LogicProgrammingInstance<?, ?, ?>) kahina).getProfiler().profileSubtree(state.getStepTree(), state.getSelectedStepID())); 136 window.setTitle("Search subtree profile"); 137 window.setVisible(true); 138 break; 139 } 110 140 } 111 141 } 142 143 protected Mapper<String, ProfileEntry> getProfileEntryMapper() 144 { 145 return new DefaultProfileEntryMapper(); 146 } 112 147 } kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfile.java
r398 r400 1 1 package org.kahina.lp.profiler; 2 2 3 import java.io.Serializable; 3 4 import java.util.HashMap; 4 5 import java.util.Map; … … 6 7 import org.kahina.core.profiler.ProfileEntry; 7 8 8 public class LogicProgrammingProfile 9 public class LogicProgrammingProfile implements Serializable 9 10 { 11 /** 12 * 13 */ 14 private static final long serialVersionUID = 4869556554829662187L; 15 10 16 private final Map<ProfileEntry, Integer> callsByEntry = new HashMap<ProfileEntry, Integer>(); 11 17 kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfiler.java
r398 r400 1 1 package org.kahina.lp.profiler; 2 3 import java.util.HashSet; 4 import java.util.Set; 2 5 3 6 import org.kahina.core.KahinaRunner; 4 7 import org.kahina.core.control.KahinaListener; 8 import org.kahina.core.data.tree.KahinaTree; 5 9 import org.kahina.core.event.KahinaEvent; 6 10 import org.kahina.core.profiler.ProfileEntry; 7 11 import org.kahina.core.util.Mapper; 8 12 import org.kahina.lp.LogicProgrammingStep; 13 import org.kahina.lp.LogicProgrammingStepType; 9 14 import org.kahina.lp.event.LogicProgrammingBridgeEvent; 10 15 import org.kahina.lp.event.LogicProgrammingBridgeEventType; … … 15 20 private final Mapper<String, ProfileEntry> mapper; 16 21 17 private final LogicProgrammingProfile profile = new LogicProgrammingProfile();22 private final LogicProgrammingProfile profile; 18 23 19 public LogicProgrammingProfiler(Mapper<String, ProfileEntry> mapper )24 public LogicProgrammingProfiler(Mapper<String, ProfileEntry> mapper, LogicProgrammingProfile profile) 20 25 { 21 26 this.mapper = mapper; 27 this.profile = profile; 22 28 KahinaRunner.getControl().registerListener("logic programming bridge", this); 23 29 } … … 83 89 } 84 90 91 public LogicProgrammingProfile profileSubtree(KahinaTree tree, int subtreeRootID) 92 { 93 LogicProgrammingProfile result = new LogicProgrammingProfile(); 94 profileSubtree(tree, subtreeRootID, result, new HashSet<Integer>()); 95 return result; 96 } 97 98 private void profileSubtree(KahinaTree tree, int stepID, LogicProgrammingProfile profile, Set<Integer> externalIDs) 99 { 100 profileNode(tree, stepID, profile, externalIDs); 101 for (int childID : tree.getChildren(stepID)) 102 { 103 profileSubtree(tree, childID, profile, externalIDs); 104 } 105 } 106 107 protected void profileNode(KahinaTree tree, int stepID, LogicProgrammingProfile profile, Set<Integer> externalIDs) 108 { 109 LogicProgrammingStep step = KahinaRunner.retrieve(LogicProgrammingStep.class, stepID); 110 profileNode(step, tree, stepID, profile, externalIDs); 111 } 112 113 protected void profileNode(LogicProgrammingStep step, KahinaTree tree, int stepID, LogicProgrammingProfile profile, Set<Integer> externalIDs) 114 { 115 ProfileEntry entry = mapper.map(step.getGoalDesc()); 116 profileNode(entry, step, tree, stepID, profile, externalIDs); 117 } 118 119 protected void profileNode(ProfileEntry entry, LogicProgrammingStep step, KahinaTree tree, int stepID, LogicProgrammingProfile profile2, Set<Integer> externalIDs) 120 { 121 if (step.isRedone()) 122 { 123 profile.redo(entry); 124 } else 125 { 126 profile.call(entry); 127 } 128 int status = tree.getNodeStatus(stepID); 129 if (status == LogicProgrammingStepType.DET_EXIT || status == LogicProgrammingStepType.EXIT) 130 { 131 profile.exit(entry); 132 } else if (status == LogicProgrammingStepType.FAIL) 133 { 134 profile.fail(entry); 135 } 136 } 137 85 138 } kahina/trunk/src/org/kahina/tralesld/TraleSLDInstance.java
r381 r400 1 1 package org.kahina.tralesld; 2 2 3 import org.kahina.core.KahinaInstance;4 3 import org.kahina.core.KahinaRunner; 4 import org.kahina.core.LogicProgrammingInstance; 5 5 import org.kahina.core.event.KahinaEvent; 6 6 import org.kahina.core.gui.KahinaViewRegistry; … … 9 9 import org.kahina.core.gui.event.KahinaSelectionEvent; 10 10 import org.kahina.core.gui.event.KahinaUpdateEvent; 11 import org.kahina.lp.profiler.LogicProgrammingProfiler; 11 12 import org.kahina.tralesld.behavior.TraleSLDTreeBehavior; 12 13 import org.kahina.tralesld.bridge.TraleSLDBridge; … … 14 15 import org.kahina.tralesld.data.fs.TraleSLDVariableBindingSet; 15 16 import org.kahina.tralesld.gui.TraleSLDGUI; 17 import org.kahina.tralesld.profiler.TraleSLDProfiler; 16 18 import org.kahina.tralesld.visual.fs.TraleSLDFeatureStructureView; 17 19 import org.kahina.tralesld.visual.fs.TraleSLDVariableBindingSetView; 18 20 19 public class TraleSLDInstance extends KahinaInstance<TraleSLDState, TraleSLDGUI, TraleSLDBridge>21 public class TraleSLDInstance extends LogicProgrammingInstance<TraleSLDState, TraleSLDGUI, TraleSLDBridge> 20 22 { 23 24 private final TraleSLDProfiler profiler; 21 25 22 26 public TraleSLDInstance() … … 24 28 // TODO: this reeks a wee bit of Bad Software Design 25 29 new TraleSLDTreeBehavior(state.getStepTree(), this, state.getSecondaryStepTree()); 30 profiler = new TraleSLDProfiler(state.getFullProfile()); 26 31 // gui = new TraleSLDGUI(TraleSLDStep.class, this); 27 32 // bridge = new TraleSLDBridge(this, gui); … … 33 38 { 34 39 super(state); 40 profiler = new TraleSLDProfiler(state.getFullProfile()); 35 41 KahinaRunner.getControl().registerListener("edge select", this); 36 42 KahinaRunner.getControl().registerListener("update", this); … … 103 109 } 104 110 } 111 112 @Override 113 public LogicProgrammingProfiler getProfiler() 114 { 115 return profiler; 116 } 105 117 } kahina/trunk/src/org/kahina/tralesld/bridge/TraleSLDBridge.java
r396 r400 218 218 final TraleSLDStep newStep = generateStep(); 219 219 newStep.setGoalDesc("rule(" + ruleName + ")"); 220 newStep.setRedone(false); 220 221 newStep.setExternalID(extID); 221 222 int newStepID = state.nextStepID(); kahina/trunk/src/org/kahina/tralesld/gui/TraleSLDGUI.java
r329 r400 5 5 import org.kahina.core.KahinaStep; 6 6 import org.kahina.core.gui.KahinaViewIntegrationType; 7 import org.kahina.core.profiler.ProfileEntry; 8 import org.kahina.core.util.Mapper; 7 9 import org.kahina.core.visual.chart.KahinaChartView; 8 10 import org.kahina.lp.gui.LogicProgrammingGUI; … … 11 13 import org.kahina.tralesld.data.chart.TraleSLDChartEdgeStatus; 12 14 import org.kahina.tralesld.data.tree.TraleSLDLayerDecider; 15 import org.kahina.tralesld.profiler.TraleSLDProfileEntryMapper; 13 16 import org.kahina.tralesld.visual.chart.TraleSLDChartEdgeDisplayDecider; 14 17 … … 72 75 getWindowForVarName("chart").setLocation(0, 150); 73 76 } 77 78 @Override 79 protected Mapper<String, ProfileEntry> getProfileEntryMapper() 80 { 81 return new TraleSLDProfileEntryMapper(); 82 } 74 83 } kahina/trunk/src/org/kahina/tralesld/profiler/TraleSLDProfiler.java
r398 r400 1 package org.kahina.lp.profiler; 1 package org.kahina.tralesld.profiler; 2 3 import java.util.Set; 2 4 3 5 import org.kahina.core.KahinaRunner; 6 import org.kahina.core.data.tree.KahinaTree; 4 7 import org.kahina.core.event.KahinaEvent; 8 import org.kahina.core.profiler.ProfileEntry; 9 import org.kahina.lp.LogicProgrammingStep; 10 import org.kahina.lp.profiler.LogicProgrammingProfile; 11 import org.kahina.lp.profiler.LogicProgrammingProfiler; 12 import org.kahina.tralesld.TraleSLDStep; 13 import org.kahina.tralesld.TraleSLDStepType; 5 14 import org.kahina.tralesld.control.event.TraleSLDBridgeEvent; 6 15 import org.kahina.tralesld.control.event.TraleSLDBridgeEventType; 7 import org.kahina.tralesld.profiler.TraleSLDProfileEntryMapper;8 16 9 17 public class TraleSLDProfiler extends LogicProgrammingProfiler 10 18 { 11 19 12 public TraleSLDProfiler( )20 public TraleSLDProfiler(LogicProgrammingProfile profile) 13 21 { 14 super(new TraleSLDProfileEntryMapper() );22 super(new TraleSLDProfileEntryMapper(), profile); 15 23 KahinaRunner.getControl().registerListener("traleSLD bridge", this); 16 24 } … … 33 41 } 34 42 } 43 44 @Override 45 protected void profileNode(KahinaTree tree, int stepID, LogicProgrammingProfile profile, Set<Integer> externalIDs) 46 { 47 TraleSLDStep step = KahinaRunner.retrieve(TraleSLDStep.class, stepID); 48 profileNode(step, tree, stepID, profile, externalIDs); 49 } 50 51 @Override 52 protected void profileNode(ProfileEntry entry, LogicProgrammingStep step, KahinaTree tree, int stepID, LogicProgrammingProfile profile, Set<Integer> externalIDs) 53 { 54 super.profileNode(step, tree, stepID, profile, externalIDs); 55 if (tree.getNodeStatus(stepID) == TraleSLDStepType.FINISHED) 56 { 57 profile.fail(entry); 58 } 59 } 35 60 36 61 }
