Skip to main content



      Home
Home » Modeling » EMF » Ctrl-C/copy set dirty flag on editor
Ctrl-C/copy set dirty flag on editor [message #379789] Fri, 17 October 2003 04:47 Go to next message
Eclipse UserFriend
Hi,

pressing Ctrl-C on any EObject in the generated editor sets
the dirty flag. This should not be the case, since the model
is not altered.

How can I stop this behavior?
Re: Ctrl-C/copy set dirty flag on editor [message #379795 is a reply to message #379789] Fri, 17 October 2003 08:17 Go to previous messageGo to next message
Eclipse UserFriend
Daniel,

Yes, it's kind of unfortunate. Dirtiness in the generated editor
depends on the state of the command stack, i.e.,
BasicCommandStack.isSaveNeeded. It doesn't know about commands that
don't actually dirty the editor contents. The nice thing is that if you
undo back to the beginning (or save point), it shows as no longer dirty.

The other approach you can use for dirtiness is to use the
Resource.setModificationTracking(true) and to use Resource.isModified as
your indicator. It won't know that that you've undone back to the
beginning, but it won't detect copy as a modification either. You can
hook it up to isDirty in the generated editor...


Daniel Hirscher wrote:

> Hi,
>
> pressing Ctrl-C on any EObject in the generated editor sets
> the dirty flag. This should not be the case, since the model
> is not altered.
>
> How can I stop this behavior?
Re: Ctrl-C/copy set dirty flag on editor [message #379799 is a reply to message #379795] Fri, 17 October 2003 08:51 Go to previous messageGo to next message
Eclipse UserFriend
Ed,
In my model, I check for instanceofCopyCommand (I think it is called
CopyToClipboardCommand) to check whether the copy command is executed or not
and appropriately set the dirty flag. Is it a recommended approach?

Thanks
Balaji

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:3F8FDDC6.93C2FD12@ca.ibm.com...
> Daniel,
>
> Yes, it's kind of unfortunate. Dirtiness in the generated editor
> depends on the state of the command stack, i.e.,
> BasicCommandStack.isSaveNeeded. It doesn't know about commands that
> don't actually dirty the editor contents. The nice thing is that if you
> undo back to the beginning (or save point), it shows as no longer dirty.
>
> The other approach you can use for dirtiness is to use the
> Resource.setModificationTracking(true) and to use Resource.isModified as
> your indicator. It won't know that that you've undone back to the
> beginning, but it won't detect copy as a modification either. You can
> hook it up to isDirty in the generated editor...
>
>
> Daniel Hirscher wrote:
>
> > Hi,
> >
> > pressing Ctrl-C on any EObject in the generated editor sets
> > the dirty flag. This should not be the case, since the model
> > is not altered.
> >
> > How can I stop this behavior?
>
Re: Ctrl-C/copy set dirty flag on editor [message #379801 is a reply to message #379799] Fri, 17 October 2003 08:59 Go to previous messageGo to next message
Eclipse UserFriend
Balaji,

Yes, this is okay too, but in general, any command can be wrapped, and then you
won't know what kind it is.


Balaji wrote:

> Ed,
> In my model, I check for instanceofCopyCommand (I think it is called
> CopyToClipboardCommand) to check whether the copy command is executed or not
> and appropriately set the dirty flag. Is it a recommended approach?
>
> Thanks
> Balaji
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:3F8FDDC6.93C2FD12@ca.ibm.com...
> > Daniel,
> >
> > Yes, it's kind of unfortunate. Dirtiness in the generated editor
> > depends on the state of the command stack, i.e.,
> > BasicCommandStack.isSaveNeeded. It doesn't know about commands that
> > don't actually dirty the editor contents. The nice thing is that if you
> > undo back to the beginning (or save point), it shows as no longer dirty.
> >
> > The other approach you can use for dirtiness is to use the
> > Resource.setModificationTracking(true) and to use Resource.isModified as
> > your indicator. It won't know that that you've undone back to the
> > beginning, but it won't detect copy as a modification either. You can
> > hook it up to isDirty in the generated editor...
> >
> >
> > Daniel Hirscher wrote:
> >
> > > Hi,
> > >
> > > pressing Ctrl-C on any EObject in the generated editor sets
> > > the dirty flag. This should not be the case, since the model
> > > is not altered.
> > >
> > > How can I stop this behavior?
> >
Re: Ctrl-C/copy set dirty flag on editor [message #379804 is a reply to message #379801] Fri, 17 October 2003 13:21 Go to previous messageGo to next message
Eclipse UserFriend
I wonder if it would be better to have CopyAction override the run() method to just
execute the command:

command.execute();

instead of executing it on the stack:

domain.getCommandStack().execute(command);

Does it really matter if we don't undo the clipboard state? I noticed that other
editors do it that way. E.g., if I do the following in Emacs:

Cut "abc"
Paste
Copy "def"
Undo - this will undo the paste of "abc"
Paste - this will paste "def"

Frank.


Ed Merks wrote:

> Balaji,
>
> Yes, this is okay too, but in general, any command can be wrapped, and then you
> won't know what kind it is.
>
> Balaji wrote:
>
> > Ed,
> > In my model, I check for instanceofCopyCommand (I think it is called
> > CopyToClipboardCommand) to check whether the copy command is executed or not
> > and appropriately set the dirty flag. Is it a recommended approach?
> >
> > Thanks
> > Balaji
> >
> > "Ed Merks" <merks@ca.ibm.com> wrote in message
> > news:3F8FDDC6.93C2FD12@ca.ibm.com...
> > > Daniel,
> > >
> > > Yes, it's kind of unfortunate. Dirtiness in the generated editor
> > > depends on the state of the command stack, i.e.,
> > > BasicCommandStack.isSaveNeeded. It doesn't know about commands that
> > > don't actually dirty the editor contents. The nice thing is that if you
> > > undo back to the beginning (or save point), it shows as no longer dirty.
> > >
> > > The other approach you can use for dirtiness is to use the
> > > Resource.setModificationTracking(true) and to use Resource.isModified as
> > > your indicator. It won't know that that you've undone back to the
> > > beginning, but it won't detect copy as a modification either. You can
> > > hook it up to isDirty in the generated editor...
> > >
> > >
> > > Daniel Hirscher wrote:
> > >
> > > > Hi,
> > > >
> > > > pressing Ctrl-C on any EObject in the generated editor sets
> > > > the dirty flag. This should not be the case, since the model
> > > > is not altered.
> > > >
> > > > How can I stop this behavior?
> > >
Re: Ctrl-C/copy set dirty flag on editor [message #379806 is a reply to message #379804] Fri, 17 October 2003 14:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

That makes great sense. Copy has not changed the state of the document
at all. It simple took a piece of info out of it. It would mean that you
couldn't copy out of a read-only document then if it did.

--
Thanks, Rich Kulp

Re: Ctrl-C/copy set dirty flag on editor [message #379817 is a reply to message #379804] Mon, 20 October 2003 05:39 Go to previous messageGo to next message
Eclipse UserFriend
Frank Budinsky wrote:

> I wonder if it would be better to have CopyAction override the run() method to just
> execute the command:
>
> command.execute();
>
> instead of executing it on the stack:
>
> domain.getCommandStack().execute(command);

Will this be fixed/implemented in next EMF release?
Re: Ctrl-C/copy set dirty flag on editor [message #379818 is a reply to message #379817] Mon, 20 October 2003 07:47 Go to previous message
Eclipse UserFriend
--------------49E1208DA8EDCB47BE9DF663
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Daniel,

We have applications like the mapping editor that require every command to be seen by the
command stack, so that all commands can be recorded and played back. As such, I'm not
keen on creating loopholes in the base implementation as workarounds for other minor
issues. Since dirtiness can be tracked directly and exactly by the resource, that's a
good way to do it. Making the copy action not be an undoable command is a choice I'd
rather leave to the application writer. If we are going to improve the design, I'd
rather provide a more general way for a command to indicate that it has no effect on the
model. Or, if we are going to provide just a special case for copy, I'd rather
specialize BasicCommandStack.isSaveNeeded like this in the generated editor:

BasicCommandStack commandStack =
new BasicCommandStack()
{
public boolean isSaveNeeded()
{
if (saveIndex == -2)
{
return true;
}
else
{
for (int i = top; i > saveIndex; --i)
{
if (!(commandList.get(i) instanceof
org.eclipse.emf.edit.command.CopyToClipboardCommand))
{
return true;
}
}

return false;
}
}
};


Daniel Hirscher wrote:

> Frank Budinsky wrote:
>
> > I wonder if it would be better to have CopyAction override the run() method to just
> > execute the command:
> >
> > command.execute();
> >
> > instead of executing it on the stack:
> >
> > domain.getCommandStack().execute(command);
>
> Will this be fixed/implemented in next EMF release?

--------------49E1208DA8EDCB47BE9DF663
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Daniel,
<p>We have applications like the mapping editor that require every command
to be seen by the command stack, so that all commands can be recorded and
played back.&nbsp; As such, I'm not keen on creating loopholes in the base
implementation as workarounds for other minor issues.&nbsp; Since dirtiness
can be tracked directly and exactly by the resource, that's a good way
to do it.&nbsp; Making the copy action not be an undoable command is a
choice I'd rather leave to the application writer.&nbsp; If we are going
to improve the design, I'd rather provide a more general way for a command
to indicate that it has no effect on the model.&nbsp; Or, if we are going
to provide just a special case for copy, I'd rather specialize BasicCommandStack.isSaveNeeded
like this in the generated editor:
<p><tt>&nbsp;&nbsp;&nbsp; BasicCommandStack commandStack =</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new BasicCommandStack()</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; public boolean isSaveNeeded()</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (saveIndex
== -2)</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return true;</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for (int i = top; i > saveIndex; --i)</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
if (!(commandList.get(i) instanceof org.eclipse.emf.edit.command.CopyToClipboardCommand))</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
{</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
return true;</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
}</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</tt><tt></tt>
<p><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return false;</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };</tt>
<br>&nbsp;
<p>Daniel Hirscher wrote:
<blockquote TYPE=CITE>Frank Budinsky wrote:
<p>> I wonder if it would be better to have CopyAction override the run()
method to just
<br>> execute the command:
<br>>
<br>>&nbsp;&nbsp;&nbsp;&nbsp; command.execute();
<br>>
<br>> instead of executing it on the stack:
<br>>
<br>>&nbsp;&nbsp;&nbsp;&nbsp; domain.getCommandStack().execute(command);
<p>Will this be fixed/implemented in next EMF release?</blockquote>
</html>

--------------49E1208DA8EDCB47BE9DF663--
Previous Topic:Congratulations!
Next Topic:Editor issues
Goto Forum:
  


Current Time: Fri Sep 12 10:59:33 EDT 2025

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

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

Back to the top