Opened 7 years ago

Closed 6 years ago

#4799 closed defect (fixed)

Duplicate of packages is not working if not saved in one file

Reported by: Christian Kral <dr.christian.kral@…> Owned by: Adeel Asghar
Priority: high Milestone: 1.14.0
Component: OMEdit Version: v1.13.0-dev-nightly
Keywords: Cc: Per Östlund

Description

Please consider the following example. In OMEdit make a right click on Modelica.UsersGuide and pick Duplicate.

Name: UsersGuide
Path: (blank)
Uncheck: "Save contents in one file" in order to save folders and files.

Make a double click on the duplicate UsersGuide. When hitting CTRL+S to store the duplicated UsersGuide, nothing happens. One can even not select save from the File menu. By applying a right click on the duplicate UsersGuide, you can select save and that then saves UsersGuide. Select a directory to store the files...

After saving the UsersGuide, have a look at the stored code:

  • In package.mo all underlying classes are stored (which was not intended by unchecking "Save contents in one file")
  • In addition, folders and files have been created, mapping the structure of UsersGuide

Note: If the same procedure is performed when keeping "Save contents in one file" checked, the file seems to be stored correctly, but the following behavior remains...

Some more strange effects (which may be related to the fact that Modelica is a read only System Library and the duplicate may be assumed the be read only as well):

  • Switch to Modeling with the intention to see Modelica code -- but there is no Text View to see the code of the duplicate UsersGuide...
  • Make a right click on the duplicate UsersGuide and pick "View Text". Then the Text View of UsersGuide appears.
  • Now try to edit code line in the Text View of UsersGuide. You get then the message: Warning: You are changing a read-only class.

Attachments (2)

P.zip (1.0 KB ) - added by Adeel Asghar 6 years ago.
KeepStructure.png (13.2 KB ) - added by Christian Kral <dr.christian.kral@…> 6 years ago.
Keep structure causes not all icons to be shown

Download all attachments as: .zip

Change History (12)

comment:1 by Christian Kral <dr.christian.kral@…>, 7 years ago

Version: v1.13.0-dev-nightly

This issue applies to

OMEdit 1.13.0~dev-106-g36aa34a
Connected to OpenModelica 1.13.0~dev-747-g0c1336f

on a 64 bit Linux machine.

comment:2 by Francesco Casella, 6 years ago

Milestone: Future2.0.0

comment:3 by Adeel Asghar, 6 years ago

Cc: Per Östlund added

by Adeel Asghar, 6 years ago

Attachment: P.zip added

comment:4 by Adeel Asghar, 6 years ago

I have tried to make a small example of the problem.

It seems the issue is when making a copy of the class the directory structure is not maintained.

comment:5 by Adeel Asghar, 6 years ago

Milestone: 2.0.01.14.0
Resolution: fixed
Status: newclosed

Fixed in ed41047/OMEdit.

comment:6 by Christian Kral <dr.christian.kral@…>, 6 years ago

I have two additional comment to make on this ticket:

Issue 1

I duplicated Modelica.UsersGuide selecting the option Directories for all. After the copy UsersGuide is created I can save the package by making a right click on the package and picking Save.

When performing a double click on the copy of UsersGuide Save is disabled from the file menu and the save button is disabled as well.

Tested on

OMEdit 1.14.0~dev-56-ge76522f
Connected to OpenModelica 1.14.0~dev-387-g16b0256
Connected to OMSimulator unknown-linux

Issue 2

If I pick Keep structure when applying the copy, then some of the icons of the copied Modelica classes are not shown (see attachment), even thought the class names are all correct.

One more comment here: I am not sure if I understand Keep structure in this context correctly. What does that mean? If I make a copy then I will get a working copy which I can check with no errors, such that all class names are adapted, where necessary? If so, why is this Keep structure an alternative to

  • One file,
  • Directory and
  • Directories for all?

In other words: Why can the user not pick whether he wants to store the copy in a directory structure or as a single file, if the structure is maintained?

This issue seems to be related with #5346.

by Christian Kral <dr.christian.kral@…>, 6 years ago

Attachment: KeepStructure.png added

Keep structure causes not all icons to be shown

comment:7 by Christian Kral <dr.christian.kral@…>, 6 years ago

Resolution: fixed
Status: closedreopened

in reply to:  6 comment:8 by Adeel Asghar, 6 years ago

Replying to Christian Kral <dr.christian.kral@…>:

I have two additional comment to make on this ticket:

Issue 1

I duplicated Modelica.UsersGuide selecting the option Directories for all. After the copy UsersGuide is created I can save the package by making a right click on the package and picking Save.

When performing a double click on the copy of UsersGuide Save is disabled from the file menu and the save button is disabled as well.

Tested on

OMEdit 1.14.0~dev-56-ge76522f
Connected to OpenModelica 1.14.0~dev-387-g16b0256
Connected to OMSimulator unknown-linux

This issue is related to #5337. It has nothing to do with the duplicate functionality. Double clicking on UsersGuide will only show the documentation and doesn't open the class that is why the save buttons are disabled.

Issue 2

If I pick Keep structure when applying the copy, then some of the icons of the copied Modelica classes are not shown (see attachment), even thought the class names are all correct.

This issue will only happen when you first duplicate using Directories for all and then unload the class and duplicate again with Keep structure. It works fine if you restart OMEdit and duplicate with Keep structure. Anyway I have fixed the issue in 888930a/OMEdit so it should work with the new nightly.

One more comment here: I am not sure if I understand Keep structure in this context correctly. What does that mean? If I make a copy then I will get a working copy which I can check with no errors, such that all class names are adapted, where necessary? If so, why is this Keep structure an alternative to

  • One file,
  • Directory and
  • Directories for all?

In other words: Why can the user not pick whether he wants to store the copy in a directory structure or as a single file, if the structure is maintained?

This issue seems to be related with #5346.

Keep structure maintains the file type (one file or directory) recursively. Consider the following package to understand it,

Package P => saved in P/package.mo
  Model M => saved in P/M.mo
  Package P1 => saved in P/P1.mo
  Model M1 => saved in P/P1.mo

If you choose Keep structure you will get the same save structure.

If you choose Directories for all when duplicating P you will get,

Package P => saved in P/package.mo
  Model M => saved in P/M.mo
  Package P1 => saved in P/P1/package.mo
  Model M1 => saved in P/P1/M1.mo

comment:9 by Christian Kral <dr.christian.kral@…>, 6 years ago

Thanks for clarifying my questions. I also tested the icon issue and this is working OK now. So I think we can close this ticket.

comment:10 by Adeel Asghar, 6 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.