IDEMPIERE-2205 - Ask for secret input from within a process (#1501)

This commit is contained in:
Diego Ruiz 2022-09-26 13:46:09 +02:00 committed by GitHub
parent 0173bbd296
commit 8a51fb8f4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 0 deletions

View File

@ -81,6 +81,14 @@ public interface IProcessUI {
public void ask(String message, Callback<Boolean> callback); public void ask(String message, Callback<Boolean> callback);
public void askForInput(String message, Callback<String> callback); public void askForInput(String message, Callback<String> callback);
/**
* Prompt for user secret input.
*
* @param title
* @param callback
*/
public void askForSecretInput(String message, Callback<String> callback);
/** /**
* Prompt user for input with a configurable DisplayType (String, Number, TableDir or Search) * Prompt user for input with a configurable DisplayType (String, Number, TableDir or Search)

View File

@ -1266,6 +1266,16 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
} }
} }
} }
@Override
public void askForSecretInput(final String message, final Callback<String> callback) {
Executions.schedule(getDesktop(), new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Dialog.askForSecretInput(m_WindowNo, message, callback);
}
}, new Event("onAskForInput"));
}
@Override @Override
public void askForInput(final String message, final Callback<String> callback) { public void askForInput(final String message, final Callback<String> callback) {

View File

@ -674,4 +674,14 @@ public class WPaySelect extends PaySelect
} }
}, new Event("onAskForInput")); }, new Event("onAskForInput"));
} }
@Override
public void askForSecretInput(final String message, final Callback<String> callback) {
Executions.schedule(form.getDesktop(), new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Dialog.askForSecretInput(m_WindowNo, message, callback);
}
}, new Event("onAskForInput"));
}
} // VPaySelect } // VPaySelect

View File

@ -27,6 +27,14 @@ import org.compiere.model.GridField;
*/ */
public class WPasswordEditor extends WStringEditor public class WPasswordEditor extends WStringEditor
{ {
public WPasswordEditor()
{
super();
super.setTypePassword(true);
setChangeEventWhenEditing(false);
}
/** /**
* *
* @param gridField * @param gridField

View File

@ -34,6 +34,7 @@ import org.adempiere.webui.editor.WChosenboxListEditor;
import org.adempiere.webui.editor.WChosenboxSearchEditor; import org.adempiere.webui.editor.WChosenboxSearchEditor;
import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WNumberEditor; import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.editor.WPasswordEditor;
import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.editor.WSearchEditor;
import org.adempiere.webui.editor.WStringEditor; import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.editor.WTableDirEditor;
@ -405,6 +406,25 @@ public final class Dialog {
Messagebox.showDialog(message, dialogTitle, Messagebox.showDialog(message, dialogTitle,
Messagebox.OK | Messagebox.INPUT, Messagebox.QUESTION, msgCallback, (msgCallback == null)); Messagebox.OK | Messagebox.INPUT, Messagebox.QUESTION, msgCallback, (msgCallback == null));
} }
public static void askForSecretInput(int windowNo, String adMessage, final Callback<String> callback) {
Callback<String> msgCallback = null;
if (callback != null)
{
msgCallback = new Callback<String>() {
@Override
public void onCallback(String result) {
callback.onCallback(result);
}
};
}
String dialogTitle = getDialogTitle("", windowNo);
String message = constructMessage(adMessage, null);
message = formatDialogMessage(message);
Messagebox.showDialog(message, dialogTitle,
Messagebox.OK | Messagebox.INPUT, Messagebox.QUESTION, new WPasswordEditor(), msgCallback, (msgCallback == null));
}
/** /**
* Confirmation dialog before deleting the records. * Confirmation dialog before deleting the records.