public void agendaChanged() { synchronized(AgendaPanel.this) { List his = agenda.getHistory(); activations_clone = agenda.getActivations().toArray(); history_clone = his!=null? his.toArray(): new Object[0]; next = agenda.getNextActivation(); } if(!invoked) { invoked = true; SwingUtilities.invokeLater(new Runnable() { public void run() { invoked = false; synchronized(AgendaPanel.this) { AgendaPanel.this.activations_clone = activations_clone; AgendaPanel.this.history_clone = history_clone; AgendaPanel.this.next = next; } updateList(); } }); } } };
public void valueChanged(ListSelectionEvent e) { if(!e.getValueIsAdjusting()) { int i = -1; if(next!=null) { for(i=0;i<amodel.getSize(); i++) { if(next.equals(amodel.getElementAt(i))) break; } } // Hack!!! Should use agent.invokeLater if(activations.getSelectedIndex()!=-1 && activations.getSelectedIndex()!=i && activations.getSelectedIndex()<agenda.getActivations().size()) agenda.setNextActivation((Activation)amodel.getElementAt(activations.getSelectedIndex())); } } });
Iterator it = rulesystem.getAgenda().getActivations().iterator(); while(it.hasNext()) rulesystem.getAgenda().fireRule(); rulesystem.getState().expungeStaleObjects(); rulesystem.getState().notifyEventListeners(); return !rulesystem.getAgenda().isEmpty() && !isStepmode();
Activation act = rulesystem.getAgenda().getLastActivation(); state.getProfiler().start(IProfiler.TYPE_RULE, act!=null?act.getRule():null); state.expungeStaleObjects(); state.getProfiler().stop(IProfiler.TYPE_RULE, act!=null?act.getRule():null); if(!rulesystem.getAgenda().isEmpty()) rulesystem.getAgenda().fireRule(); act = rulesystem.getAgenda().getLastActivation(); return !rulesystem.getAgenda().isEmpty();
this.history = new JList(hmodel); agenda.setHistoryEnabled(true); // Todo: Disable history on close? activations_clone = agenda.getActivations().toArray(); history_clone = agenda.getHistory().toArray(); next = agenda.getNextActivation(); this.listener = new IAgendaListener() agenda.addAgendaListener(listener);
step.setEnabled(steppable.isStepmode() && !system.getAgenda().isEmpty()); final JCheckBox stepmode = new JCheckBox("Step Mode", steppable.isStepmode()); stepmode.addActionListener(new ActionListener() system.getAgenda().addAgendaListener(agendalistener); followact.addActionListener(new ActionListener() if(followact.isSelected()) Activation act = system.getAgenda().getNextActivation(); if(act!=null && followact.isSelected())
public void actionPerformed(ActionEvent e) { steppable.setStepmode(stepmode.isSelected()); step.setEnabled(steppable.isStepmode() && !system.getAgenda().isEmpty()); } });
/** * Test if the component's execution is currently at one of the * given breakpoints. If yes, the component will be suspended by * the platform. * @param breakpoints An array of breakpoints. * @return True, when some breakpoint is triggered. */ public boolean isAtBreakpoint(String[] breakpoints) { // assert isAgentThread(); assert !getAgentAdapter().isExternalThread(); boolean isatbreakpoint = false; Object cs = state.getAttributeValue(ragent, OAVBDIRuntimeModel.agent_has_state); if(cs!=null && !OAVBDIRuntimeModel.AGENTLIFECYCLESTATE_TERMINATED.equals(cs)) { Set bps = new HashSet(Arrays.asList(breakpoints)); // Todo: cache set across invocations for speed? Iterator it = getRuleSystem().getAgenda().getActivations().iterator(); while(!isatbreakpoint && it.hasNext()) { IRule rule = ((Activation)it.next()).getRule(); isatbreakpoint = bps.contains(rule.getName()); } } // else still in init return isatbreakpoint; }
public void actionPerformed(ActionEvent e) { // todo: invoke on agent thread with invoke later // works because history is synchronized. List his = agenda.getHistory(); if(his!=null) { his.clear(); history_clone = new Object[0]; history.repaint(); } } });
Iterator it = rulesystem.getAgenda().getActivations().iterator(); while(it.hasNext()) rulesystem.getAgenda().fireRule(); rulesystem.getState().expungeStaleObjects(); rulesystem.getState().notifyEventListeners(); return !rulesystem.getAgenda().isEmpty() && !isStepmode();