Providing User Feedback

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Providing User Feedback

Postby Kristina Hildebrand » Fri Oct 28, 2005 10:44 am

Hi,

My plugin spends quite a long time (20-30 seconds, I would guess)
importing data from an external file into a new Model, and during this
time, Magic Draw appears to freeze. I have tried using a Java
ProgressMonitor, but it freezes along with everything else. I've looked
through the javadoc for the classes in the OpenAPI, as well as the
OpenAPI user guide and I can't find what I'm looking for.

Is there a way to access something like the "Loading..." dialog that
appears when you load a project in Magic Draw, through the API?

Thank you,
Kristina Hildebrand
Kristina Hildebrand
 
Posts Rating:

Re: Providing User Feedback

Postby Donatas Simkunas » Wed Nov 02, 2005 5:10 am

Hello Kristina,

We do not provide API to display progress. So you need to create standard swing progress bar and use
Application.getInstance().getMainFrame().getDialogParent() for parent of progress dialog.

Regards

--
Donatas Simkunas
Senior Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363, LT 49425 Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
WWW: http://www.magicdraw.com

Donatas Simkunas
 
Posts Rating:

Re: Providing User Feedback

Postby Kristina Hildebrand » Mon Nov 07, 2005 8:59 am

Donatas Simkunas wrote:
> We do not provide API to display progress. So you need to create standard swing progress bar and use
> Application.getInstance().getMainFrame().getDialogParent() for parent of progress dialog.


Thanks for the reply. Is there a way to access the "Messages Window"?
As I said, the majority of the GUI appears to freeze up when I'm
importing data, and I'd like to try to provide some sort of user
feedback during this time.

Thanks,
Kristina
Kristina Hildebrand
 
Posts Rating:

Re: Providing User Feedback

Postby Thomas Höbinger » Mon Nov 07, 2005 9:05 am

Hello Kristina

accessing message window:

Application.getInstance().getGUILog().log(traceText);

greetings
thomas

"Kristina Hildebrand" <kdhildeb> wrote in message
news:dknq48$eh4$1...
> Donatas Simkunas wrote:
> > We do not provide API to display progress. So you need to create
standard swing progress bar and use
> > Application.getInstance().getMainFrame().getDialogParent() for parent of
progress dialog.
>
>
> Thanks for the reply. Is there a way to access the "Messages Window"?
> As I said, the majority of the GUI appears to freeze up when I'm
> importing data, and I'd like to try to provide some sort of user
> feedback during this time.
>
> Thanks,
> Kristina


Thomas Höbinger
 
Posts Rating:

Re: Providing User Feedback

Postby Kristina Hildebrand » Mon Nov 07, 2005 3:27 pm

Thank-you. I don't know why, but the GUI still freezes before the
Messages Window will even open. All of the messages show up when the
import is finished, 30 or so seconds later (given that I'm
importing/converting something like a 1.5 MB file, I understand that it
takes some time, but it would be nice to be able to let the user know
that something's actually happening). There must be something I'm not
calling properly, I guess. Here's hoping that 10 works better with
this, when I get my licence for it. On a semi-related note, why is it
that some methods show up in my IDE and aren't listed in the openapi
javadoc? For example, GUILog has writeLogText(String, boolean), whereas
the only method listed in the javadoc for GUILog is log(String).

Thanks.

Thomas Höbinger wrote:
> Hello Kristina
>
> accessing message window:
>
> Application.getInstance().getGUILog().log(traceText);
>
> greetings
Kristina Hildebrand
 
Posts Rating:

Re: Providing User Feedback

Postby Donatas Simkunas » Fri Nov 11, 2005 1:39 am

Hello,

About javadoc for methods. We provide javadoc for methods which are marked as "openapi" methods. This means that
not all public methods are openapi. We recommend to use only openapi methods since other can be renamed, moved or
changes without any notice.

About GUI freezing. Could you write sequence of actions you are doing and when you get this freezing ?

Regards

--
Donatas Simkunas
Senior Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363, LT 49425 Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
WWW: http://www.magicdraw.com

Donatas Simkunas
 
Posts Rating:

Re: Providing User Feedback

Postby Kristina Hildebrand » Fri Nov 11, 2005 1:45 pm

Hello,

Basically, my plugin is designed to import a model from a file that is
in another format (for anyone interested, it's the TA format documented
at http://swag.uwaterloo.ca/~nsynytskyy/grokdoc/ta_rsf.html). Here is
the general structure of the actionPerformed() method in my MenuAction,
with relevant lines of code left intact:

-------------------------

ProjectsManager pm = Application.getInstance().getProjectsManager();
Project project = pm.createProject();
ElementsFactory ef =
Application.getInstance().getProject().getElementsFactory();
SessionManager.getInstance().createSession("Import TA file");

Application.getInstance().getGUILog().openLog();
Application.getInstance().getGUILog().log("Created Root Model...");

//read external file

Application.getInstance().getGUILog().log("Reading Subsystems...");

Model rootModel = project.getModel();
rootModel.setName(modelName);
Package rootPackage = ef.createPackageInstance();
rootPackage.setName(Constants.MODEL_ROOT);
ModelElementsManager.getInstance().addElement(rootPackage, rootModel);

Package p = ef.createPackageInstance();
p.setName(Util.nameFromPath(packageNames[0]));
ModelElementsManager.getInstance().addElement(p, rootPackage);

Application.getInstance().getGUILog().log("Adding packages & classes...");
//loop through all subsystems read from the external file, adding the
children (packages or classes) into each package, using the
ElementsFactory to add them

Application.getInstance().getGUILog().log("Adding Class Members...");
//loop through all classes read from the external file, adding the
children (properties and operations) into each class

Application.getInstance().getGUILog().log("Adding Dependencies...");
//loop through all calls relationships, adding them as dependencies.

Application.getInstance().getGUILog().log("Finished Importing Model from
TA file. Use the menu options to create diagrams.");
SessionManager.getInstance().closeSession();

-------------------------

The whole process works (mostly, anyway - I still have a few bugs to
work out since moving to 10 as of yesterday), but it won't show anything
in the Application log (or even open it) until it the whole process is
complete (or an exception happens), 20 or 30 seconds after choosing the
file to import the data from. The information logged to the application
log does show up, but only after the process is complete. Is there
something I should be calling to force it to stop and update the GUI
during the import?

Thank you,
Kristina

Donatas Simkunas wrote:
> Hello,
>
> About javadoc for methods. We provide javadoc for methods which are marked as "openapi" methods. This means that
> not all public methods are openapi. We recommend to use only openapi methods since other can be renamed, moved or
> changes without any notice.
>
> About GUI freezing. Could you write sequence of actions you are doing and when you get this freezing ?
>
> Regards
>
Kristina Hildebrand
 
Posts Rating:

RE: Providing User Feedback

Postby Tomas Pugzlys » Tue Nov 15, 2005 12:49 am

Hello,

The solution for freezing GUI problem would be to perform your task on new
thread.
Your 20-30 second task is performed on Swing dispatcher thread and GUI can
not update until task is not finished.

Try something like this:
//class MenuAction
public void actionPerformed(ActionEvent e)
{
Runnable runnable = new Runnable()
{
public void run()
{
doEverything();
}
};

Thread thread = new Thread(runnable);
thread.start();
}
private void doEverything()
{
ProjectsManager pm = Application.getInstance().getProjectsManager();
Project project = pm.createProject();
ElementsFactory ef =
Application.getInstance().getProject().getElementsFactory();
SessionManager.getInstance().createSession("Import TA file");
Application.getInstance().getGUILog().openLog();
Application.getInstance().getGUILog().log("Created Root Model...");
....................
}

Regards,
--
Tomas Pugzlys
Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363, LT-49425, Kaunas
P.O. box 2166, LT-44011, Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
e-mail : tomasp
WWW: http://www.magicdraw.com

Tomas Pugzlys
 
Posts Rating:

Re: Providing User Feedback

Postby Kristina Hildebrand » Thu Nov 17, 2005 3:45 pm

Thank you very much. This fixed my problem. It's been quite a while
since I did any serious Java (or any language, really) GUI programming,
and I entirely forgot about this issue.

~Kristina
Kristina Hildebrand
 
Posts Rating:


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests