Opened 9 years ago

Closed 5 years ago

Last modified 5 years ago

#3776 closed enhancement (fixed)

Copy & paste in OMEdit

Reported by: anonymous Owned by: adeas31
Priority: high Milestone: 1.14.0
Component: OMEdit Version:
Keywords: Cc: tobias.bellmann@…, Andrea.Bartolini

Description

It looks like in diagram view of OMEdit it is not possible to do common copy/cut & paste operations.

I think it would be very useful to have them to copy/cut & paste models both inside the same diagram and across different diagrams (e.g. those that are open in different tabs)

Change History (34)

comment:1 Changed 8 years ago by anonymous

We have the command "duplicate", which is good as a substitute for copy/paste within the same model.
We still miss a way to copying parts of a model from a model into another, using diagram view.

Will copy/paste across models be implemented in the near future?
It would increase productivity with OMEdit a lot.

comment:2 Changed 8 years ago by janK

I think this is a very important feature. The Copy&Paste feature should also include graphical elements in IconView and DiagramView like a connector or a line annotation.

comment:3 Changed 7 years ago by bthiele

  • Cc tobias.bellmann@… added

I agree that the feature is very important. I just got some user feedback about OMEdit in which this feature was asked for, too. I also use copy/paste on the diagram layers a lot when working with another tool.

comment:4 Changed 6 years ago by ceraolo

  • Milestone changed from 2.0.0 to 1.14.0

This old ticket is still in the new state.
I also think that new copy/paste across diagrams is very needed. I suppose it should not be hard to add, since it should just imply copying/pasting lines of code without adjustments (except for removing annotations).
Maybe, in this case the current "duplicate" command can be dropped since the same effect can be obtained by a copy/paste pair.

I propose to move the milestone to 1.4.0

Last edited 6 years ago by ceraolo (previous) (diff)

comment:5 Changed 6 years ago by casella

Agreed, let's give it a try

comment:6 Changed 6 years ago by ceraolo

May I ask whether there are plans to address this ticket in the coming weeks?
It impacts my plans for the OM version I will use with the students.
I mean, copy/paste across tabs.

comment:7 Changed 5 years ago by adeas31

  • Resolution set to fixed
  • Status changed from new to closed

comment:8 Changed 5 years ago by ceraolo

Great! I'll try this tomorrow

comment:9 Changed 5 years ago by ceraolo

I found two glitches on this fix:

1) if I copy something from a model, I cannot paste using CTRL+V: I must use the menu; only once I've pasted the first time through menu, I can make further pastes with CTRL+V

2) in some cases a redundant red error occurs. For instance

-open Modelica.Electrical.Analog.Examples.rectifier.
-Select a box containing SineVoltage1, Inductor1 and the line connecting their two positive pins
-copy the selected area and paste it into a new model. The following red error message appears, which I think should be suppressed:

[1] 07:37:39 Scripting Error
Unable to find component SineVoltage2.n while parsing connection {SineVoltage1.n,SineVoltage2.n,}.
Last edited 5 years ago by ceraolo (previous) (diff)

comment:10 follow-up: Changed 5 years ago by adeas31

The first issue should not happen. It always works for me with shortcut. Maybe its because the view is active and when you use the context menu the view gets the focus and becomes active.

I will take a look at both points.

comment:11 Changed 5 years ago by casella

  • Cc Andrea.Bartolini added

Andrea, would you like to try that out as soon as the Linux nightly is back from the dead? I see Martin is working on that, I hope it doesn't take too much time.

comment:12 in reply to: ↑ 10 Changed 5 years ago by ceraolo

Replying to adeas31:

The first issue should not happen.

I can be more precise. If I have two open tabs and copy something from a model in the first tab, then I click on the tab header to select the second tab, CRTL+V does not work.
If instead, after having selected the second tab I first click on the diagram sheet, CRTL+V works as expected.
It is a minor glitch, but I suppose it is worthwhile fixing it.

comment:13 follow-up: Changed 5 years ago by Andrea.Bartolini

I confirm the behavior in the last comment of Ceraolo.
I think that the clik inside the diagram to get focus is the normal behavior of the QT...

comment:14 in reply to: ↑ 13 Changed 5 years ago by ceraolo

Replying to Andrea.Bartolini:

I confirm the behavior in the last comment of Ceraolo.
I think that the clik inside the diagram to get focus is the normal behavior of the QT...

Yes, but focus can be forced. In this case when the tab is selected

comment:15 follow-up: Changed 5 years ago by ceraolo

Another issue is that copying text from a tab and pasting into another produces a wrong result

comment:16 in reply to: ↑ 15 ; follow-up: Changed 5 years ago by adeas31

Replying to ceraolo:

Another issue is that copying text from a tab and pasting into another produces a wrong result

You have a test case for it?

comment:17 in reply to: ↑ 16 Changed 5 years ago by ceraolo

You have a test case for it?

A simple procedure to reproduce the issue:
1) create a blank model (say model "a")
2) create in a new tab a second model ("say "b")
3) write some text in "a" for instance "this is some text" and copy it
4) click on "b" tab; using mouse and context menu paste
=> instead of the correct text only a single red square is displayed.

comment:18 Changed 5 years ago by adeas31

Thanks. I also discovered it yesterday and already have a fix for it in my working copy. This is a bit different problem but it just surfaced using the copy paste functionality.

comment:19 follow-up: Changed 5 years ago by adeas31

I have now fixed the focus issue and the text copying issue. See 7aa92c1/OpenModelica.

As for the red error message I expect this message to occur because when you select a box containing SineVoltage1, Inductor1 and the line connecting their two positive pins from Modelica.Electrical.Analog.Examples.rectifier the connection between SineVoltage1 and SineVoltage2 also got copied. So when you paste it you see the error message because in the pasting model it fails to find SineVoltage2 that is why pasting of the connection is dropped. I actually like the error message because it tells you exactly what has happened.

Last edited 5 years ago by adeas31 (previous) (diff)

comment:20 in reply to: ↑ 19 Changed 5 years ago by ceraolo

Replying to adeas31:

I have now fixed the focus issue and the text copying issue. See 7aa92c1/OpenModelica.

thanks a lot.

As for the red error message I expect this message to occur because when you select a box containing SineVoltage1, Inductor1 and the line connecting their two positive pins from Modelica.Electrical.Analog.Examples.rectifier the connection between SineVoltage1 and SineVoltage2 also got copied. So when you paste it you see the error message because in the pasting model it fails to find SineVoltage2 that is why pasting of the connection is dropped. I actually like the error message because it tells you exactly what has happened.

I understand this. From a programmer's point of view is perfect. From a user's perspective, I'm not sure: if the user selects two components and the connecting line, he expects that connections between this stuff and the rest of the circuit are dropped silently.
So, I'm personally in favour of removing this message. Maybe for programmers this can be enabled with some esoteric flag.

comment:21 follow-up: Changed 5 years ago by adeas31

if the user selects two components and the connecting line

Precisely that's the problem. The user doesn't know but has selected another connection as well. Perhaps using shift+click for selection is better in such cases.

Anyways one idea to solve this problem is to drop such connections where both start and end components are not selected.

comment:22 in reply to: ↑ 21 Changed 5 years ago by ceraolo

Anyways one idea to solve this problem is to drop such connections where both start and end components are not selected.

I think this is the best solution from the user point of view.
This would better Dymola's way: Dymola in these cases includes dangling lines that should be then manually dropped.

In case implementing this solution requires a too large effort, or it is preferred for any other reason, another fix (for me worse, but still acceptable) is to convert the messages that presently are issued from errors into notifications.

Using shift+click is a good alternative, but not always advantageous: one might have to select a rather large portion of a diagram, which would imply several, tedious, clicks.

Last edited 5 years ago by ceraolo (previous) (diff)

comment:23 Changed 5 years ago by adeas31

comment:24 follow-up: Changed 5 years ago by ceraolo

I could not check the latest improvements since there is not today's nightly. However, I've found two other glitches regarding copy-paste.

1) context menu item "paste" is never greyed. Is it possible to grey it when the clipboard is empty?

2) Once a text box is created, it appears selected (it has small red squares around), but indeed it is not: if I click CTRL-V, it is not copied into the clipboard

comment:25 Changed 5 years ago by casella

@adrpo is apparently trying to get the Windows nightly back again. The Linux nightly is also broken, I have sent a message to @sjoelund.se about that.

comment:26 in reply to: ↑ 24 Changed 5 years ago by adeas31

Replying to ceraolo:

I could not check the latest improvements since there is not today's nightly. However, I've found two other glitches regarding copy-paste.

1) context menu item "paste" is never greyed. Is it possible to grey it when the clipboard is empty?

2) Once a text box is created, it appears selected (it has small red squares around), but indeed it is not: if I click CTRL-V, it is not copied into the clipboard

Fixed both points mentioned above. Please test again tomorrow.

comment:27 Changed 5 years ago by ceraolo

It seems to me that everything in copying/pasting across tabs works as expected.

Only, implementation of point 1 in comment 25 is not smooth.

If OMEdit is started from a freshly booted PC, paste is greyed.

But consider the following sequence:

  • load OMEdit, create a model "a"
  • and create a text box in "a" and copy it
  • close OMEdit, and load it again
  • create a model "a"

At this point, paste (on "a") in not greyed, but CRTL-V does nothing.

comment:28 follow-up: Changed 5 years ago by adeas31

Yes that is because we put things on clipboard and closed the OMEdit session. Next time it reads from clipboard and finds that there is data. But the reason that nothing happens is because the data is not valid anymore since it belongs to the last session.

I thought about clearing the clipboard when user quits OMEdit but I m not sure whethere we should do that or not.

comment:29 Changed 5 years ago by ceraolo

I understand that this is not the biggest problem to address... However, maybe some thought might help.

What about graying the icon upon loading OMEdit if the clipboard is invalid? This could be extended keeping greyed (or greying) the icon also in case clipboard is filled by other applications with contents OMEdit cannot interpret (and therefore paste).

comment:30 in reply to: ↑ 28 Changed 5 years ago by casella

Replying to adeas31:

I thought about clearing the clipboard when user quits OMEdit but I m not sure whethere we should do that or not.

If that data is no reusable in the next session, clearing it seems the only reasonable thing to do. In fact one may want to paste elsewhere (e.g. in a text editor) after closing OMEdit, but that seems quite a corner case to me.

comment:31 Changed 5 years ago by adeas31

In fact one may want to paste elsewhere (e.g. in a text editor) after closing OMEdit, but that seems quite a corner case to me.

Precisely the reason why I decided not to clear it.

Well I can also check if the data is valid. It is a bit expensive operation depending on the size of the data but is affordable since you only need to check it when creating the context menu.

comment:32 Changed 5 years ago by adeas31

Checking for the validity of data was much simpler than what I expected.
Should work fine with 98f34a4/OpenModelica.

comment:33 Changed 5 years ago by ceraolo

Wow. Half a row of code!

comment:34 Changed 5 years ago by ceraolo

I think it works very well now.

It is also good for me that the Duplicate command has been left in place. In fact, it operates differently from a Copy-Paste pair: it slightly displaces the duplicated object(s), while copy/paste does not.

Note: See TracTickets for help on using tickets.