| |
---|
| | protected double minimumEditorScale = DEFAULT_MINIMUM_EDITOR_SCALE; |
---|
| | protected int minimumWidth = DEFAULT_MIN_WIDTH; |
---|
| | protected int minimumHeight = DEFAULT_MIN_HEIGHT; |
---|
| | |
---|
| | private SimulatorWindow window; |
---|
| | private Object editingCell; |
---|
| | private EventObject trigger; |
---|
| | private JComboBox<String> comboBox; |
---|
| | private mxGraphComponent graphComponent; |
---|
| |
---|
| | private JComboBox<String> pulldownMenu; |
---|
| | private Editor editor; |
---|
| | private boolean bReflectingArchitectureModel = false; |
---|
| | |
---|
| | public InputEventCellEditor(mxGraphComponent graphComponent, Simulator simulator, Editor editor) { |
---|
| | this.graphComponent = graphComponent; |
---|
| | public InputEventCellEditor(SimulatorWindow window, mxGraphComponent graphComponent, Simulator simulator, Editor editor) { this.graphComponent = graphComponent; |
---|
| | this.window = window; |
---|
| | this.simulator = simulator; |
---|
| | this.editor = editor; |
---|
| | } |
---|
| | |
---|
| |
---|
| | ArrayList<String> messages = new ArrayList<>();//ADLmessage |
---|
| | ArrayList<Expression> eventMessages = new ArrayList<>();//messageList |
---|
| | ResourcePath eventResPath = null; |
---|
| | |
---|
| | for(Channel ch : simulator.getModel().getInputChannels()) {//all channel |
---|
| | if(((DataTransferChannel)ch).getInputResources().size()== 0) {//ioch Or normalch |
---|
| | for(ChannelMember out: ((DataTransferChannel)ch).getOutputChannelMembers()) { |
---|
| | ResourcePath resPath = out.getResource(); |
---|
| | if(resId.isInstanceOf(resPath)) {//account.uid == acounts.123 |
---|
| | eventResPath = resPath; |
---|
| | eventChs.add(((DataTransferChannel)ch)); |
---|
| | String message = null; |
---|
| | Expression mesExp = out.getStateTransition().getMessageExpression();//sync(a,b) |
---|
| | eventMessages.add(mesExp); |
---|
| | if(mesExp instanceof Term) { |
---|
| | message = ((Term) mesExp).getSymbol().toString();//sync |
---|
| | }else if(mesExp instanceof Variable) { |
---|
| | message = ((Variable) mesExp).getName();//x,y,z.. |
---|
| | } |
---|
| | messages.add(message);//pulldown |
---|
| | |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | for (Channel ch: simulator.getModel().getInputChannels()) {//all channel |
---|
| | eventResPath = getSelectableMessages(ch, resId, eventChs, messages, eventMessages, eventResPath); |
---|
| | } |
---|
| | |
---|
| | if(messages.isEmpty()) { |
---|
| | return; |
---|
| |
---|
| | |
---|
| | JPanel eventChoice = new JPanel(); |
---|
| | eventChoice.add(event);//FirstEventChoice |
---|
| | |
---|
| | int ret = JOptionPane.showConfirmDialog(null, eventChoice, "Event Choice", JOptionPane.OK_CANCEL_OPTION); |
---|
| | int ret = JOptionPane.showConfirmDialog(window, eventChoice, "Event Choice", JOptionPane.OK_CANCEL_OPTION); |
---|
| | if (ret == JOptionPane.OK_OPTION) { |
---|
| | |
---|
| | JPanel inputEvent = new JPanel(); |
---|
| | int i , eventNum; |
---|
| |
---|
| | |
---|
| | JTextArea textArea = new JTextArea(eventMessages.get(eventNum).toString(), 10, 30);//EventInput |
---|
| | inputEvent.add(textArea); |
---|
| | |
---|
| | int approve = JOptionPane.showConfirmDialog(null, inputEvent, "Event Code", JOptionPane.OK_CANCEL_OPTION); |
---|
| | int approve = JOptionPane.showConfirmDialog(window, inputEvent, "Event Code", JOptionPane.OK_CANCEL_OPTION); |
---|
| | if (approve == JOptionPane.OK_OPTION) { |
---|
| | try { |
---|
| | |
---|
| | TokenStream stream = new Parser.TokenStream(); |
---|
| | Parser parser = new Parser(stream); |
---|
| | stream.addLine(textArea.getText()); |
---|
| | Expression eventMessage = parser.parseTerm(stream,simulator.getModel()); |
---|
| | |
---|
| | Event newEvent = new Event(eventChs.get(eventNum), eventMessage, eventResPath, simulator.getCurState().getResource(resId)); |
---|
| | simulator.transition(newEvent); |
---|
| | |
---|
| | // SimulationLayout layout = new SimulationLayout(simulator.getCurState()); |
---|
| | // layout.constructSimulateGraph(graph, simulator); |
---|
| | |
---|
| | graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, simulator, this.editor)); |
---|
| | TokenStream stream = new Parser.TokenStream(); |
---|
| | Parser parser = new Parser(stream); |
---|
| | stream.addLine(textArea.getText()); |
---|
| | Expression eventMessage = parser.parseTerm(stream,simulator.getModel()); |
---|
| | |
---|
| | Event newEvent = new Event(eventChs.get(eventNum), eventMessage, eventResPath, simulator.getCurState().getResource(resId)); |
---|
| | simulator.transition(newEvent); |
---|
| | |
---|
| | // SimulationLayout layout = new SimulationLayout(simulator.getCurState()); |
---|
| | // layout.constructSimulateGraph(graph, simulator); |
---|
| | |
---|
| | graphComponent.setCellEditor(new InputEventCellEditor(window, graphComponent, simulator, this.editor)); |
---|
| | |
---|
| | } catch (ParameterizedIdentifierIsFutureWork | ResolvingMultipleDefinitionIsFutureWork |
---|
| | | InvalidMessage | UnificationFailed | ValueUndefined | ExpectedRightBracket | WrongJsonExpression | ExpectedColon | ExpectedDoubleQuotation e) { |
---|
| | e.printStackTrace(); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | //resource |
---|
| | return; |
---|
| | } |
---|
| | |
---|
| | mxCellState state = graphComponent.getGraph().getView().getState(cell); |
---|
| | if (state != null && state.getLabel() != null && !state.getLabel().equals("")) { |
---|
| |
---|
| | comboBox.updateUI(); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | |
---|
| | private ResourcePath getSelectableMessages(Channel ch, ResourceIdentifier resId, |
---|
| | ArrayList<DataTransferChannel> eventChs, ArrayList<String> messages, ArrayList<Expression> eventMessages, |
---|
| | ResourcePath eventResPath) { |
---|
| | if (((DataTransferChannel)ch).getInputResources().size() == 0) {//ioch Or normalch |
---|
| | for (ChannelMember out: ((DataTransferChannel)ch).getOutputChannelMembers()) { |
---|
| | ResourcePath resPath = out.getResource(); |
---|
| | if (resId.isInstanceOf(resPath)) {//account.uid == acounts.123 |
---|
| | eventResPath = resPath; |
---|
| | eventChs.add(((DataTransferChannel)ch)); |
---|
| | String message = null; |
---|
| | Expression mesExp = out.getStateTransition().getMessageExpression();//sync(a,b) |
---|
| | eventMessages.add(mesExp); |
---|
| | if (mesExp instanceof Term) { |
---|
| | message = ((Term) mesExp).getSymbol().toString();//sync |
---|
| | } else if(mesExp instanceof Variable) { |
---|
| | message = ((Variable) mesExp).getName();//x,y,z.. |
---|
| | } |
---|
| | messages.add(message);//pulldown |
---|
| | } |
---|
| | } |
---|
| | for (Channel childCh: ch.getChildren()) { |
---|
| | eventResPath = getSelectableMessages(childCh, resId, eventChs, messages, eventMessages, eventResPath); |
---|
| | } |
---|
| | } |
---|
| | return eventResPath; |
---|
| | } |
---|
| | |
---|
| | // private mxGraph constructNextSimulateGraph(Set<Resource> simulateRes, DataTransferModel model,DataFlowGraph dataFlowGraph, mxGraph nextGraph) { |
---|
| | // bReflectingArchitectureModel = true; |
---|
| | // ((mxGraphModel) nextGraph.getModel()).clear(); |
---|
| | // Object parent = nextGraph.getDefaultParent(); |
---|
| |
---|
| | |