Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Prompting user for textual input
Prompting user for textual input [message #1766369] Tue, 20 June 2017 16:57 Go to next message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
Is there a way to prompt the user for some textual input?
I am aware of "Select Model Element Variables" but this is to prompt for information that already exists in the model.
For example, I would like to ask the user for an entity name, before I can process and validate it. Only then, I can create an element in the model.

I found this thread that seems to create a java extension to do (I think) what is needed.
https://www.eclipse.org/forums/index.php/t/1078774/

Is it really that complicated to prompt for a String?
Re: Prompting user for textual input [message #1766431 is a reply to message #1766369] Wed, 21 June 2017 11:57 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi,

No it's not that complicated, you can write a simple Java service method which uses JFace's InputDialog and invoke it from your tool. Something like this:

    public String askStringFromUser(EObject self, String title, String message, String initialValue) {
        InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), title, message, initialValue, null);
        if (dlg.open() == Window.OK) {
            return dlg.getValue();
        } else {
            return null;
        }
    }


Regards,
Pierre-Charles David


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Prompting user for textual input [message #1767535 is a reply to message #1766431] Thu, 06 July 2017 22:56 Go to previous message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
After creating the java class, I was getting the error message "Cannot find operation askStringFromUser" when I tried to use the query in my model.

My solution was to:
First, wrap the service as an Acceleo query module according to https://wiki.eclipse.org/Acceleo/Getting_Started#Java_services_wrappers.
Second, I had to export the package where the java class and acceleo module resided, as instructed here https://www.eclipse.org/forums/index.php/t/261459/

Thanks for the tips!
Previous Topic:Runtime no longer opens .odesigns from newer specification version
Next Topic:Call External Java Action from source code
Goto Forum:
  


Current Time: Fri Apr 19 20:17:12 GMT 2024

Powered by FUDForum. Page generated in 0.02817 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top