public void onTransactionCreate(final TransactionBuildUpEvent<BaseSipMessage> event) { assert SIP_REINVITE_CLIENT == event.getTransaction().getTransactionType(); Dialog dialog = (Dialog) event.getEntity(); final Transaction<Boolean, BaseSipMessage> transaction = event.getTransaction(); // DIALOG.putCustomParameter(Dialog.ParamKey.REINVITE_IN_PROGRESS, Boolean.TRUE); dialog.markReInviteInProgress(InitiateParty.LOCAL); // listener will un-subscribe automatically on transaction complete transaction.addListener(new AuthChallengeListener<BaseSipMessage>(transaction, dialog)); // listener will un-subscribe automatically on transaction complete transaction.addListener( new MiddleManForClientMessageBuildingSupport<BaseSipMessage>(transaction, dialog)); // listener will un-subscribe automatically on transaction complete transaction.addListener( new ReInviteStateMiddleMan<BaseSipMessage>( transaction, dialog, dialogStateListenerHolder) { protected void onDialogCleanUp(final Dialog dialog) { getStackContext().getDialogStorage().cleanUpDialog(dialog); } }); // listener will un-subscribe automatically on transaction complete transaction.addListener( new ReinviteInProgressListener<BaseSipMessage>( transaction, dialog, InitiateParty.LOCAL)); }
public void showGotoDialog(final KeyEventBlocker blocker) { Dialog dialog = createGotoDialog(); if (dialog == null) { // already visible // TODO:beep() return; } dialog.setVisible(true); gotoPanel.popupNotify(blocker); WindowAdapter winAdapt = new WindowAdapter() { public @Override void windowClosing(WindowEvent evt) { disposeGotoDialog(); } public @Override void windowClosed(WindowEvent evt) { SwingUtilities.invokeLater( new Runnable() { public void run() { if (blocker != null) { blocker.stopBlocking(false); } // Utilities.returnFocus(); } }); } }; dialog.addWindowListener(winAdapt); }
public void handleIncomingUpdate(Request msg) throws DialogStateException { assert TransactionUtils.isTransactionExecutionThread() : "Code run in wrong thread. Must be run in TransactionThread. Now in " + Thread.currentThread(); assert !done.get(); if (!done.get()) { Logger.log("Remote party has sent update"); final Dialog dialog = getStackContext().getDialogStorage().findDialogForMessage(msg); assert dialog != null; checkUpdatePreconditions(dialog, msg); Logger.log(TAG, "mark dialog as update in progress"); dialog.markUpdateInProgress(InitiateParty.REMOTE); // TransactionType<InviteSrvTransaction, ? extends ServerCommonInviteTransaction> // transactionType = SIP_REINVITE_SERVER; TransactionType<UpdateSrvTransaction, UpdateServerTransaction> transactionType = SIP_UPDATE_SERVER; doHandleIncomingUpdate(msg, dialog, transactionType); } }
/** * Creates and sends a SUBSCRIBE request to the subscription <tt>Address</tt>/Request URI of a * specific <tt>Subscription</tt> in order to request receiving event notifications and adds the * specified <tt>Subscription</tt> to the list of subscriptions managed by this instance. The * added <tt>Subscription</tt> may later receive notifications to process the <tt>Request</tt>s * and/or <tt>Response</tt>s which constitute the signaling session associated with it. If the * attempt to create and send the SUBSCRIBE request fails, the specified <tt>Subscription</tt> is * not added to the list of subscriptions managed by this instance. * * @param subscription a <tt>Subscription</tt> which specifies the properties of the SUBSCRIBE * request to be created and sent, to be added to the list of subscriptions managed by this * instance * @throws OperationFailedException if we fail constructing or sending the subscription request. */ public void subscribe(Subscription subscription) throws OperationFailedException { Dialog dialog = subscription.getDialog(); if ((dialog != null) && DialogState.TERMINATED.equals(dialog.getState())) dialog = null; // create the subscription ClientTransaction subscribeTransaction = null; try { subscribeTransaction = (dialog == null) ? createSubscription(subscription, subscriptionDuration) : createSubscription(subscription, dialog, subscriptionDuration); } catch (OperationFailedException ex) { ProtocolProviderServiceSipImpl.throwOperationFailedException( "Failed to create the subscription", OperationFailedException.INTERNAL_ERROR, ex, logger); } // we register the contact to find him when the OK will arrive CallIdHeader callIdHeader = (CallIdHeader) subscribeTransaction.getRequest().getHeader(CallIdHeader.NAME); String callId = callIdHeader.getCallId(); addSubscription(callId, subscription); // send the message try { if (dialog == null) subscribeTransaction.sendRequest(); else dialog.sendRequest(subscribeTransaction); } catch (SipException ex) { // this contact will never been accepted or rejected removeSubscription(callId, subscription); ProtocolProviderServiceSipImpl.throwOperationFailedException( "Failed to send the subscription", OperationFailedException.NETWORK_FAILURE, ex, logger); } }
public void setMitjas(String tipus, double result, String unitats) { mitjas.setHeaderText("Càlcul de la mitja de la " + tipus); Label label1 = new Label(String.format("%.2f", result) + " " + unitats); GridPane grid = new GridPane(); grid.add(label1, 1, 1); mitjas.getDialogPane().setContent(grid); }
public void downloadActiveModule() { if (isInvalidModuleName(activeModule)) return; saveActiveModule(); Module module = modules.get(activeModule); // do not run two downloads at once, it makes the log look ugly if (moduleDownloader.isRunning()) { // should never occur, because the button should be disabled dialog.logMessage( "Fehler: Ein anderer Download ist bereits aktiv!\n" + "Download von Modul \"" + module.getName() + "\" abgebrochen.\n"); return; } // check if module is active if (!module.isActive()) { dialog.logMessage( "Achtung: Das Modul \"" + module.getName() + "\" ist nicht aktiv!\n" + "Download von Modul \"" + module.getName() + "\" abgebrochen.\n"); return; } List<Module> moduleList = new ArrayList<Module>(); moduleList.add(module); // overwrite old ModuleDownloader moduleDownloader = new ModuleDownloader(moduleList, dialog); Thread moduleDownloaderThread = new Thread(moduleDownloader); moduleDownloaderThread.start(); }
private ModuleManager() { Dialog.setLookAndFeel(); dialog = new Dialog(this); loadLoginData(); loadModuleConfigs(); dialog.setVisible(true); }
/** * Handles server noninvite message * * @param msg - noninvite message */ public void handleIncomingBye(final Request msg) { assert TransactionUtils.isTransactionExecutionThread() : "Code run in wrong thread. Must be run in TransactionThread. Now in " + Thread.currentThread(); assert !done.get(); assert msg != null && MessageType.SIP_BYE == MessageType.parse(msg.getMethod()); Logger.log("Remote party has sent noninvite"); if (!done.get()) { final Dialog dialog = getStackContext().getDialogStorage().findDialogForMessage(msg); assert dialog != null; assert STATED == dialog.getState(); dialog.getMessageHistory().addMessage(msg, true); final TransactionManager transactionManager = getTransactionManager(); transactionManager.addListener( new FirstMessageResolver(SIP_BYE_SERVER.getName(), dialog, msg, transactionManager)); final Transaction transaction = transactionManager.lookUpTransaction(dialog, null, SIP_BYE_SERVER); runAsynchronously(transaction, TRANSACTION_TIMEOUT); } }
/** Process the invite request. */ public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); Request request = requestEvent.getRequest(); try { System.out.println("b2bua: got an Invite sending Trying"); ServerTransaction st = requestEvent.getServerTransaction(); if (st == null) { st = sipProvider.getNewServerTransaction(request); } Dialog dialog = st.getDialog(); ToHeader to = (ToHeader) request.getHeader(ToHeader.NAME); SipURI toUri = (SipURI) to.getAddress().getURI(); SipURI target = registrar.get(toUri.getUser()); if (target == null) { System.out.println("User " + toUri + " is not registered."); throw new RuntimeException("User not registered " + toUri); } else { ClientTransaction otherLeg = call(target); otherLeg.setApplicationData(st); st.setApplicationData(otherLeg); dialog.setApplicationData(otherLeg.getDialog()); otherLeg.getDialog().setApplicationData(dialog); } } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
public void mouseMoved(MouseEvent ev) { JRootPane root = getRootPane(); if (root.getWindowDecorationStyle() == JRootPane.NONE) { return; } Window w = (Window) ev.getSource(); Frame f = null; Dialog d = null; if (w instanceof Frame) { f = (Frame) w; } else if (w instanceof Dialog) { d = (Dialog) w; } // Update the cursor int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY())); if (cursor != 0 && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0)) || (d != null && d.isResizable()))) { w.setCursor(Cursor.getPredefinedCursor(cursor)); } else { w.setCursor(lastCursor); } }
/** * Show dialog * * @see Dialog#show(android.support.v4.app.FragmentActivity) */ public void showDialog(String content, String apkUrl) { Dialog d = new Dialog(); Bundle args = new Bundle(); args.putString(Constants.APK_UPDATE_CONTENT, content); args.putString(Constants.APK_DOWNLOAD_URL, apkUrl); d.setArguments(args); d.show(mContext.getSupportFragmentManager(), null); }
private void TL_messages_StatedMessage(TL.Object obj) { setUpdate(-1, obj.getInt("pts"), obj.getInt("seq")); User.addUsers(obj.getVector("users")); TL.Object message = obj.getObject("message"); Dialog d = Dialog.getDialog(message.getInt("from_id"), message.getObject("to_id"), true); Dialog.newMessage(message, Dialog.MSG_INCOMING); }
public Object invoke(Object obj, Object[] args) throws Exception { // input = (email address, subject, body, full attachment path) String email = (String) args[0].toString(); String subject = (String) args[1].toString(); String body = (String) args[2].toString(); String attachment = (String) args[3].toString(); String fName = attachment; byte[] data = null; FileConnection fconn = null; DataInputStream is = null; try { fconn = (FileConnection) Connector.open(fName, Connector.READ_WRITE); is = fconn.openDataInputStream(); data = IOUtilities.streamToBytes(is); is.close(); fconn.close(); } catch (Exception ex) { Dialog.inform("Error in file path: " + ex.toString()); return new Boolean(false); } // create a multipart Multipart mp = new Multipart(); // create the file SupportedAttachmentPart sap = new SupportedAttachmentPart(mp, "application/x-example", attachment, data); TextBodyPart tbp = new TextBodyPart(mp, body); // add the file to the multipart mp.addBodyPart(tbp); mp.addBodyPart(sap); // create a message in the sent items folder Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT); Message message = new Message(folders[0]); Address toAdd = new Address(email, "my email"); Address toAdds[] = new Address[1]; toAdds[0] = toAdd; message.addRecipients(Message.RecipientType.TO, toAdds); message.setSubject(subject); message.setContent(mp); Session session = Session.getDefaultInstance(); Transport trans = session.getTransport(); // add recipients to the message and send boolean sent = false; try { trans.send(message); sent = true; } catch (Exception e) { Dialog.inform("Error while sending: " + e.toString()); } return new Boolean(sent); }
/** Process the invite request. */ public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); Request request = requestEvent.getRequest(); try { logger.info("shootme: got an Invite sending Trying"); // logger.info("shootme: " + request); ServerTransaction st = requestEvent.getServerTransaction(); if (st == null) { logger.info("null server tx -- getting a new one"); st = sipProvider.getNewServerTransaction(request); } logger.info("getNewServerTransaction : " + st); String txId = ((ViaHeader) request.getHeader(ViaHeader.NAME)).getBranch(); this.serverTxTable.put(txId, st); // Create the 100 Trying response. Response response = protocolObjects.messageFactory.createResponse(Response.TRYING, request); ListeningPoint lp = sipProvider.getListeningPoint(protocolObjects.transport); int myPort = lp.getPort(); Address address = protocolObjects.addressFactory.createAddress( "Shootme <sip:" + myAddress + ":" + myPort + ">"); // Add a random sleep to stagger the two OK's for the benifit of implementations // that may not be too good about handling re-entrancy. int timeToSleep = (int) (Math.random() * 1000); Thread.sleep(timeToSleep); st.sendResponse(response); Response ringingResponse = protocolObjects.messageFactory.createResponse(Response.RINGING, request); ContactHeader contactHeader = protocolObjects.headerFactory.createContactHeader(address); response.addHeader(contactHeader); ToHeader toHeader = (ToHeader) ringingResponse.getHeader(ToHeader.NAME); String toTag = actAsNonRFC3261UAS ? null : new Integer((int) (Math.random() * 10000)).toString(); if (!actAsNonRFC3261UAS) toHeader.setTag(toTag); // Application is supposed to set. ringingResponse.addHeader(contactHeader); st.sendResponse(ringingResponse); Dialog dialog = st.getDialog(); dialog.setApplicationData(st); this.inviteSeen = true; new Timer().schedule(new MyTimerTask(requestEvent, st /*,toTag*/), 1000); } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
protected synchronized void disposeGotoDialog() { if (gotoDialog != null) { EditorState.put(BOUNDS_KEY, gotoDialog.getBounds()); gotoDialog.dispose(); Utilities.returnFocus(); } gotoDialog = null; }
public void updateDialog(Dialog d) { contents = ""; for (int i = 0; i < d.getContents().size(); i++) { contents += d.getContents().get(i) + "\n"; } dlgTA.setText(contents); }
/** Launch the application. */ public static void main(String[] args) { try { Dialog dialog = new Dialog(); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
private void loadModuleConfigs() { if (!SettingsManager.loadModuleConfigs(modules)) dialog.logMessage( "Fehler: Konnte Module nicht laden.\n" + "Bitte überprüfe die Datei \"" + SettingsManager.modulesFile + "\".\n\n"); updateModuleList(); dialog.displayAnyModule(); }
@Override public TowerWindow show() { super.show(); progressDialog.show(); progressDialog.clearActions(); progressDialog.getColor().a = 1f; return this; }
private void checkUpdatePreconditions(final Dialog dialog, final Request msg) throws DialogStateException { if (STATED == dialog.getState()) { throw new DialogStateException( dialog, UPDATE_FOR_STATED_DIALOG, msg, "Can not update DIALOG. Dialog is stated already. "); } if (dialog.isUpdateInProgress()) { throw new DialogStateException( dialog, UPDATE_DURING_PREVIOUS_UPDATE, msg, "Can not update DIALOG. Previous update still in progress."); } /** * A UAS that receives an UPDATE before it has generated a final response to a previous UPDATE * on the same dialog MUST return a 500 response to the new UPDATE, and MUST include a * Retry-After HEADER field with a randomly chosen value between 0 and 10 seconds. * * <p>If an UPDATE is received that contains an offer, and the UAS has generated an offer (in an * UPDATE, PRACK or INVITE) to which it has not yet received an answer, the UAS MUST reject the * UPDATE with a 491 response. Similarly, if an UPDATE is received that contains an offer, and * the UAS has received an offer (in an UPDATE, PRACK, or INVITE) to which it has not yet * generated an answer, the UAS MUST reject the UPDATE with a 500 response, and MUST include a * Retry-After HEADER field with a randomly chosen value between 0 and 10 seconds. * * <p>If a UA receives an UPDATE for an existing dialog, it MUST check any version identifiers * in the SESSION description or, if there are no version identifiers, the content of the * SESSION description to see if it has changed. If the SESSION description has changed, the UAS * MUST adjust the SESSION parameters accordingly and generate an answer in the 2xx response. * However, unlike a re-INVITE, the UPDATE MUST be responded to promptly, and therefore the USER * cannot generally be prompted to approve the SESSION changes. If the UAS cannot change the * SESSION parameters without prompting the USER, it SHOULD reject the request with a 504 * response. If the new SESSION description is not acceptable, the UAS can reject it by * returning a 488 (Not Acceptable Here) response for the UPDATE. This response SHOULD include a * Warning HEADER field. * * <p>If a UAC receives a 491 response to a UPDATE, it SHOULD start a timer with a value T * chosen as follows: * * <p>1. If the UAC is the owner of the Call-ID of the dialog ID (meaning it generated the * value), T has a randomly chosen value between 2.1 and 4 seconds in units of 10 ms. * * <p>2. If the UAC is not the owner of the Call-ID of the dialog ID, T has a randomly chosen * value between 0 and 2 seconds in units of 10 ms. * * <p>When the timer fires, the UAC SHOULD attempt the UPDATE once more, if it still desires for * that SESSION modification to take place. For example, if the call was already hung up with a * BYE, the UPDATE would not take place. */ }
private void TL_messages_StatedMessages(TL.Object obj) { setUpdate(-1, obj.getInt("pts"), obj.getInt("seq")); User.addUsers(obj.getVector("users")); TL.Vector messages = obj.getVector("messages"); for (int i = 0; i < messages.count; i++) { TL.Object message = messages.getObject(i); Dialog d = Dialog.getDialog(message.getInt("from_id"), message.getObject("to_id"), true); Dialog.newMessage(message, Dialog.MSG_INCOMING); } }
@Override public void setModalBlocked(Dialog blocker, boolean blocked) { synchronized (getPeerTreeLock()) { if (blocked && blocker.getPeer() instanceof LWWindowPeer) { this.blocker = (LWWindowPeer) blocker.getPeer(); } else { this.blocker = null; } } platformWindow.setModalBlocked(blocked); }
/** * This method initiates SIP_BYE for established DIALOG * * @param dialog - DIALOG to terminate */ public void bye(final Dialog dialog) { assert TransactionUtils.isTransactionExecutionThread() : "Code run in wrong thread. Must be run in TransactionThread. Now in " + Thread.currentThread(); assert !done.get(); if (!done.get()) { assert STATED == dialog.getState() : "Wrong dialog state. Must be " + STATED + " now is " + dialog.getState(); doBye(dialog, TRANSACTION_TIMEOUT); } }
public void processResponse(ResponseEvent responseReceivedEvent) { System.out.println("Got a response"); Response response = (Response) responseReceivedEvent.getResponse(); Transaction tid = responseReceivedEvent.getClientTransaction(); System.out.println( "Response received with client transaction id " + tid + ":\n" + response.getStatusCode()); if (tid == null) { System.out.println("Stray response -- dropping "); return; } System.out.println("transaction state is " + tid.getState()); System.out.println("Dialog = " + tid.getDialog()); System.out.println("Dialog State is " + tid.getDialog().getState()); try { if (response.getStatusCode() == Response.OK && ((CSeqHeader) response.getHeader(CSeqHeader.NAME)) .getMethod() .equals(Request.INVITE)) { // Request cancel = inviteTid.createCancel(); // ClientTransaction ct = // sipProvider.getNewClientTransaction(cancel); // ct.sendRequest(); Dialog dialog = tid.getDialog(); CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME); Request ackRequest = dialog.createAck(cseq.getSeqNumber()); System.out.println("Sending ACK"); dialog.sendAck(ackRequest); // Send a Re INVITE but this time force it // to use UDP as the transport. Else, it will // Use whatever transport was used to create // the dialog. if (reInviteCount == 0) { Request inviteRequest = dialog.createRequest(Request.INVITE); ((SipURI) inviteRequest.getRequestURI()).removeParameter("transport"); ((ViaHeader) inviteRequest.getHeader(ViaHeader.NAME)).setTransport("udp"); inviteRequest.addHeader(contactHeader); try { Thread.sleep(100); } catch (Exception ex) { } ClientTransaction ct = udpProvider.getNewClientTransaction(inviteRequest); dialog.sendRequest(ct); reInviteCount++; } } } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
/** Process the ACK request. Send the bye and complete the call flow. */ public void processAck(RequestEvent requestEvent, ServerTransaction serverTransaction) { SipProvider sipProvider = (SipProvider) requestEvent.getSource(); try { // System.out.println("*** shootme: got an ACK " // + requestEvent.getRequest()); if (serverTransaction == null) { System.out.println("null server transaction -- ignoring the ACK!"); return; } Dialog dialog = serverTransaction.getDialog(); this.createdCount++; System.out.println( "Dialog Created = " + dialog.getDialogId() + " createdCount " + this.createdCount + " Dialog State = " + dialog.getState()); if (this.dialogIds.contains(dialog.getDialogId())) { System.out.println("OOPS ! I already saw " + dialog.getDialogId()); } else { this.dialogIds.add(dialog.getDialogId()); } Request byeRequest = dialog.createRequest(Request.BYE); ClientTransaction tr = sipProvider.getNewClientTransaction(byeRequest); // System.out.println("shootme: got an ACK -- sending bye! "); dialog.sendRequest(tr); } catch (Exception ex) { ex.printStackTrace(); System.exit(0); } }
public void onTransactionCreate(final TransactionBuildUpEvent<BaseSipMessage> event) { assert SIP_REINVITE_SERVER == event.getTransaction().getTransactionType(); Dialog dialog = (Dialog) event.getEntity(); final Transaction<Boolean, BaseSipMessage> transaction = event.getTransaction(); // DIALOG.putCustomParameter(Dialog.ParamKey.REINVITE_IN_PROGRESS, Boolean.TRUE); // TODo reinvire is used for update too // dialog.markReInviteInProgress(InitiateParty.REMOTE); // listener will un-subscribe automatically on transaction complete transaction.addListener( new IncomingReInviteListener<BaseSipMessage>( dialog, createSafeInviteAcceptable(dialog), transaction, incomingCallListenerHolder)); // listener will un-subscribe automatically on transaction complete transaction.addListener( new MiddleManForServerMessageBuildingSupport(transaction, dialog)); // listener will un-subscribe automatically on transaction complete transaction.addListener( new ReInviteStateMiddleMan<BaseSipMessage>( transaction, dialog, dialogStateListenerHolder) { protected void onDialogCleanUp(final Dialog dialog) { getStackContext().getDialogStorage().cleanUpDialog(dialog); } }); // listener will un-subscribe automatically on transaction complete // TODO change if (dialog.isUpdateInProgress()) { transaction.addListener( new UpdateInProgressListener<BaseSipMessage>( transaction, dialog, InitiateParty.REMOTE)); } else { transaction.addListener( new ReinviteInProgressListener<BaseSipMessage>( transaction, dialog, InitiateParty.REMOTE)); } // listener will un-subscribe automatically on transaction complete transaction.addListener( new DialogCleanUpListener<BaseSipMessage>(transaction, dialog, false) { protected void onDialogCleanUp(final Dialog dialog) { getStackContext().getDialogStorage().cleanUpDialog(dialog); } }); }
public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) { Dialog dialog = dialogTerminatedEvent.getDialog(); this.terminatedCount++; System.out.println( "Dialog Terminated Event " + dialog.getDialogId() + " terminatedCount = " + terminatedCount); if (!this.dialogIds.contains(dialog.getDialogId())) { System.out.println("Saw a terminated event for an unknown dialog id"); } else { this.dialogIds.remove(dialog.getDialogId()); } }
@Override public Dialog show() { Dialog picker = super.show(); myTimer.start(); // it seems like it's the lowest value for opacity for mouse events to be processed correctly WindowManager.getInstance().setAlphaModeRatio(picker, SystemInfo.isMac ? 0.95f : 0.99f); if (SystemInfo.isJavaVersionAtLeast("1.7")) { Area area = new Area(new Rectangle(0, 0, DIALOG_SIZE, DIALOG_SIZE)); area.subtract(new Area(new Rectangle(SIZE / 2 - 1, SIZE / 2 - 1, 3, 3))); picker.setShape(area); } return picker; }
/** * Test method for {@link * org.jvoicexml.interpreter.ObjectExecutorThread#execute(org.jvoicexml.interpreter.VoiceXmlInterpreterContext, * org.jvoicexml.interpreter.VoiceXmlInterpreter, * org.jvoicexml.interpreter.FormInterpretationAlgorithm, * org.jvoicexml.interpreter.formitem.ObjectFormItem)} . * * @exception Exception Test failed. * @exception JVoiceXMLEvent Test failed. */ @Test public void testExecute() throws Exception, JVoiceXMLEvent { final VoiceXmlDocument doc = new VoiceXmlDocument(); final Vxml vxml = doc.getVxml(); final Form form = vxml.appendChild(Form.class); final Subdialog subdialog = form.appendChild(Subdialog.class); subdialog.setName("test"); final Form subform = vxml.appendChild(Form.class); subform.setId("subid"); final Var var = subform.appendChild(Var.class); var.setName("testparam"); final Block block = subform.appendChild(Block.class); final Assign assign = block.appendChild(Assign.class); assign.setName("testparam"); assign.setExpr("testparam * 2"); final Return ret = block.appendChild(Return.class); ret.setNamelist("testparam"); final SubdialogFormItem item = new SubdialogFormItem(context, subdialog); final Dialog dialog = new ExecutablePlainForm(); dialog.setNode(form); final FormInterpretationAlgorithm fia = new FormInterpretationAlgorithm(context, null, dialog); final EventHandler handler = new org.jvoicexml.interpreter.event.JVoiceXmlEventHandler(null, null); final EventBus eventbus = context.getEventBus(); eventbus.subscribe("", handler); handler.collect(context, null, fia, item); final URI uri = new URI("#subid"); final Map<String, Object> params = new java.util.HashMap<String, Object>(); params.put("testparam", new Integer(4)); final JVoiceXmlApplication application = new JVoiceXmlApplication(null); application.addDocument(new URI("test"), doc); final SubdialogExecutorThread executor = new SubdialogExecutorThread(uri, context, application, params, eventbus); executor.start(); executor.join(); ReturnEvent event = null; try { handler.processEvent(item); } catch (ReturnEvent e) { event = e; } Assert.assertNotNull(event); final Map<String, Object> variables = event.getVariables(); Assert.assertEquals(1, variables.size()); Assert.assertEquals(8, variables.get("testparam")); }
private boolean existsOtherDialog() { Frame ancestor = (Frame) JOptionUtils.centeringComp().getTopLevelAncestor(); Window[] ownedWindows = ancestor.getOwnedWindows(); for (Window window : ownedWindows) { if (window instanceof Dialog && !(window == getStopDialog()) && !(window == getOwner())) { Dialog dialog = (Dialog) window; if (dialog.isVisible()) { return true; } } } return false; }