Skip to content

Instantly share code, notes, and snippets.

@RemcoSchellekensNS
Created February 27, 2023 15:35
Show Gist options
  • Save RemcoSchellekensNS/3002d094a01c2136855ff9e1082c58d7 to your computer and use it in GitHub Desktop.
Save RemcoSchellekensNS/3002d094a01c2136855ff9e1082c58d7 to your computer and use it in GitHub Desktop.
This #jarchi script shows alternative MessageDialog windows with more options using Java "jface" dialogs
/*
* Example message dialogs via jface
*
*/
var MessageDialog= Java.type('org.eclipse.jface.dialogs.MessageDialog');
// Standard Error Message, with "ok" button and error icon
MessageDialog.openError(shell,"Error","your errortext");
// Standard Confirm Message, with "ok" and "cancel" button, will return true of false
var result=MessageDialog.openConfirm(shell,"Confirm","your confirmation request");
console.log(result);
// Standard Information Message, with "ok" button and information icon
MessageDialog.openInformation(shell,"Information","your information");
// Standard Question Message, with "yes" "no" buttons, returning "true"/"false"
result=MessageDialog.openQuestion(shell,"Question","your question");
console.log(result);
// Standard warning Message, with "ok" button and warning icon
MessageDialog.openWarning(shell,"Warning","your warningtext");
// more sophisticated one, you can provide your own buttons, and set the type of standard icon
// MessageDialog.NONE or .INFORMATION .QUESTION .WARNING .ERROR .CONFIRM
// returns index within array of button that has been clicked on
var buttons=["left","middle","right"];
owndialog = new MessageDialog(shell,"Own messagebox",null,"own messagebox info",MessageDialog.INFORMATION,buttons,0);
result=owndialog.open();
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment