How can you create a simple dialog box in Dynamics AX? - x++

How can you create a simple dialog box in Dynamics ax?

static void DialogSampleCode(Args _args)
{
Dialog dialog;
DialogField field;
;
dialog = new Dialog("My Dialog");
dialog.addText("Select your favorite customer:");
field = dialog.addField(typeid(CustAccount));
dialog.run();
if (dialog.closedOk())
{
info(field.value());
}
}

for really simple dialog boxes, use the Box Class:
Box::info("your message");
or
Box::warning("your message");
or
if (Box::okCancel("continue?", DialogButton::Cancel) == DialogButton::Ok)
{
// pressed OK
...
or one of the other static methods (infoOnce, yesNo, yesNoCancel, yesAllNoAllCancel, ...)

DAX 2012 does not have "typeid" as a method. But you can use extendedTypeStr and then pass in either a known EDT or use the built in string length versions:
str getStringFromUser(str _prompt, str _title)
{
str userResponse = "";
Dialog dlg = new Dialog(_title);
DialogField dlgUserResponse = dlg.addField(extendedTypeStr(String15), _prompt);
// This prompts the dialog
if (dlg.run())
{
try
{
userResponse = dlgUserResponse.value();
}
catch(Exception::Error)
{
error("An error occurred. Please try again.");
}
}
return userResponse;
}

Related

How to automate a Toast message in Appium without taking screen shot?

I want to test a Toast message without taking screen shot. Is there any other way to automate the Toast message?
You can get toast message and define Success/Fail operation:
By toastContainer = By.xpath("//div[#id='toast-container']//*");
By toastMessageDA = By.xpath("//div[#class='toast-message']");
public String toastUtility() throws Exception {
toast_container_flag = false;
try {
if (driver.findElement(toastContainer).isEnabled()) {
toast_container_flag = true;
List<WebElement> findData = driver.findElements(toastContainer);
for (WebElement element : findData) {
if (element.getAttribute("class").toString().contains("toast toast")) {
toast_success_fail = element.getAttribute("class").toString();
}
}
validationMessage = "Toast: " + driver.findElement(toastMessageDA).getText();
js.executeScript("arguments[0].click();", driver.findElement(toastMessageDA));
if (toastr_success_fail.equals("toast toast-success")) {
System.out.println("Success Message");
} else if (toastr_success_fail.equals("toast toast-error")) {
System.out.println("Fail Message");
} else {
System.out.println("Other Message");
}
System.out.println(validationMessage);
testResult = validationMessage;
}
} catch (Exception e2) {
testResult = "Toast message is not generated.";
testlog.info(testResult);
System.out.println(testResult);
}
return testResult;
}
Retrieval of toast messages is already supported for Android. Please look at the below release notes for Android.
https://github.com/appium/appium/releases/tag/v1.6.3
You need to use UIAutomator2 to work with toast messages in Android.
Hope this helps.
This works excellent for me in python.
control = False
xmlFormat = self.driver.page_source
if xmlFormat.find("your toast message") != -1:
control = True
self.assertEqual(True,control)

Firefox SDK: How to make trigger for certain domain

I need to catch requests on sites with URLs *.net and take some actions (stop request and put HTML code from disk, but this I can do). How do I catch these requests?
I tried to use progress listeners, but something is wrong:
const STATE_START = Ci.nsIWebProgressListener.STATE_START;
var myListener = {
QueryInterface: XPCOMUtils.generateQI(["nsIWebProgressListener",
"nsISupportsWeakReference"]),
onStateChange: function(aWebProgress, aRequest, aFlag, aStatus) {
if (aFlag & STATE_START) {
// actions
}
}
use nsIHTTPChannel and observer service. copy paste it. however .net can be included in resources like javascript things, if you want to test if its specfically a window you have to check for some load flags of LOAD_INITIAL_DOCUMENT_URI, also will want to chec
Cu.import('resource://gre/modules/Services.jsm');
var httpRequestObserver = {
observe: function (subject, topic, data) {
var httpChannel, requestURL;
if (topic == "http-on-modify-request") {
httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
requestURL = httpChannel.URI.spec;
var newRequestURL, i;
if (httpChannel.loadFlags & httpChannel.LOAD_INITIAL_DOCUMENT_URI) {
//ok continue because loadFlags is a document
} else {
//its not a document, probably a resource like a js file image or css or something, but maybe could be ajax call
return;
}
if (requestURL.indexOf('.net')) {
var goodies = loadContextGoodies(httpChannel);
if (goodies) {
httpChannel.cancel(Cr.NS_BINDING_ABORTED);
goodies.contentWindow.location = self.data.url('pages/test.html');
} else {
//dont do anything as there is no contentWindow associated with the httpChannel, liekly a google ad is loading or some ajax call or something, so this is not an error
}
}
return;
}
}
};
Services.obs.addObserver(httpRequestObserver, "http-on-modify-request", false);
//this function gets the contentWindow and other good stuff from loadContext of httpChannel
function loadContextGoodies(httpChannel) {
//httpChannel must be the subject of http-on-modify-request QI'ed to nsiHTTPChannel as is done on line 8 "httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);"
//start loadContext stuff
var loadContext;
try {
var interfaceRequestor = httpChannel.notificationCallbacks.QueryInterface(Ci.nsIInterfaceRequestor);
//var DOMWindow = interfaceRequestor.getInterface(Components.interfaces.nsIDOMWindow); //not to be done anymore because: https://developer.mozilla.org/en-US/docs/Updating_extensions_for_Firefox_3.5#Getting_a_load_context_from_a_request //instead do the loadContext stuff below
try {
loadContext = interfaceRequestor.getInterface(Ci.nsILoadContext);
} catch (ex) {
try {
loadContext = subject.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
} catch (ex2) {}
}
} catch (ex0) {}
if (!loadContext) {
//no load context so dont do anything although you can run this, which is your old code
//this probably means that its loading an ajax call or like a google ad thing
return null;
} else {
var contentWindow = loadContext.associatedWindow;
if (!contentWindow) {
//this channel does not have a window, its probably loading a resource
//this probably means that its loading an ajax call or like a google ad thing
return null;
} else {
var aDOMWindow = contentWindow.top.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
var gBrowser = aDOMWindow.gBrowser;
var aTab = gBrowser._getTabForContentWindow(contentWindow.top); //this is the clickable tab xul element, the one found in the tab strip of the firefox window, aTab.linkedBrowser is same as browser var above //can stylize tab like aTab.style.backgroundColor = 'blue'; //can stylize the tab like aTab.style.fontColor = 'red';
if (aTab == null) {
return null;
}
else {
var browser = aTab.linkedBrowser; //this is the browser within the tab //this is where the example in the previous section ends
return {
aDOMWindow: aDOMWindow,
gBrowser: gBrowser,
aTab: aTab,
browser: browser,
contentWindow: contentWindow
};
}
}
//end loadContext stuff
}

How to catch the deselection event in Add-on SDK in Firefox

I use the Add-on Builder & SDK to develop Firefox add-on. I catch the event when users select a piece of text by the snippet:
var selection = require("sdk/selection");
selection.on('select', function () {
//Doing something
});
However, what I want also is to do other things when users does not select that text anymore, but I can not figure it out how to do it. Anyone can help me with this? Thank you very much.
I am not aware if there are events on Deselection of a text.
However, you could register for Mouse click event on body or div containing that text and then in the callback function of the event, you could check if last selected texts is currently selected or not.
var selection = require("sdk/selection");
var lastText;
function addSelection(){
var selection = false;
var body = document.body;
if(!selection.text){
//deselection
//remove DOM listeners
body.removeListener('click', addSelection);
}
if (!selection.isContiguous) {
for (var subselection in selection) {
if(subselection.text == lastText){
selection = true;
}
}
} else if(selection.text && selection.text == lastText){
selection = true;
}
if(!selection){
//deselected
//remove DOM listeners
}
}
selection.on('select', function () {
var body;
if(lastText !== selection.text){
//deselected
//remove listeners
};
lastText = selection.text;
body = document.body;
//add DOM listeners like click - that can potentially remove selection
body.addEventListener('click', addSelection);
});

XNA Controls Settings

I have a huge problem with editing controls for my game.. I have an ingame button and when you click it. The "Choose your key.." text appears, but I don't know how to actually set it up..
I have made a "waiting for input" bool.. THIS IS NOT THE REAL CODE IT'S HOW I IMAGINE IT TO BE
if (buttonIsClicked) waitinForInput = true;
while(waitingForInput)
{
kbState = Keyboard.GetState();
somehow convert it to Keys.(STH);
if (Keys.STH != defaultKeys)
{
defaultKeys = Keys.STH;
waitingForInput = false;
}
}
Is there a way to do this.. Simpliest as I can? And sorry for my bad english.. Made this in a hurry and not my native language..
Thanks for any help.. :-)
Something like this:
KeyboardState currentKeyboardState = new KeyBoardState();
KeyboardState previousKeyboardState = new KeyBoardState();
Keys jumpKey = Keys.Space;
public void handleInput()
{
lastKeyboardState = currentKeyboardState;
currentKeyboardState = Keyboard.GetState(PlayerIndex.One);
bool waitingForKey = false;
if(currentKeyboardState.IsKeyDown(Keys.A) && waitingForKey == false)
{
waitingForKey = true;
}
if(waitingForKey == true)
{
//currentKeyboardState.GetPressedKeys() returns a list of pressed keys,
//So, currentKeyboardState.GetPressedKeys()[0] returns the first pressed key
if(currentKeyboardState.GetPressedKeys().Count() > 0)
{
jumpKey = currentKeyboardState.GetPressedKeys()[0];
waitingForKey = false;
}
}
}

initiateCall option not working on blackberry device

I've used below code for call option when use hit ok button.
it working on simulator and goes to calling option, but when i check on device nothg happn. my device model is 9800.
String[] buttons = { "CALL" ,"CANCEL" };
Dialog dialog = new Dialog("Are you sure want to call "+number+" ?", buttons, null, 1, Bitmap.getPredefinedBitmap(Bitmap.INFORMATION));
if (dialog.doModal() == 0)
{
try
{
String numbers = StringUtils.replaceAll(number, "-", "");
Phone.initiateCall(Phone.getLineIds()[0],numbers);
}
catch (RadioException e)
{
}
}
try this -
PhoneArguments callArgs = new PhoneArguments(PhoneArguments.ARG_CALL,numbers);
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, callArgs);

Resources