|
|
Re: How to create a "log-file"? [message #655729 is a reply to message #654114] |
Tue, 22 February 2011 13:54 |
akoeck Messages: 62 Registered: December 2010 |
Member |
|
|
Is there really no one that could tell me where exactly the diagram file is created and where the changes are written to the file?
I'm searching for the class or better the method in the class, where those actions are performed. Because at creation of my diagram-file I also want to create my "log". And I also want to write down the changes to my "log" whenever the changes were written to the diagram-file.
[Updated on: Tue, 22 February 2011 13:54] Report message to a moderator
|
|
|
Re: How to create a "log-file"? [message #658705 is a reply to message #655729] |
Wed, 09 March 2011 14:38 |
Christophe Bouhier Messages: 937 Registered: July 2009 |
Senior Member |
|
|
On 22-02-11 14:54, akoeck@gmx.de wrote:
> Is there really no one that could tell me where exactly the diagram file
> is created and where the changes are written to the file?
>
> I'm searching for the class or better the method in the class, where
> those actions are performed. Because at creation of my diagram-file I
> also want to create my "log". And I also want to write down the changes
> to my "log" whenever the changes were written to the diagram-file.
One idea, is to hook into the CommandStack of the editing domain.
You will be notified of every command executed within GMF. As most
activities in GMF is through commands, you will see a lot of stuff.
From this you would write your log.
To get the CommandStack, see your generated DiagramEditor,
getEditingDomain().getCommandStack().addCommandStackListener ()
Note, that GMF, also nicely hooks into the OperationsHistory of the
framework. This is done, by using specialized Commands.
So you could also do this: (But you would see all platform operations).
OperationHistoryFactory.getOperationHistory()
.addOperationHistoryListener(
new TransactionsOperationListener());
public class TransactionsOperationListener implements
IOperationHistoryListener {
public TransactionsOperationListener() {
}
@Override
public void historyNotification(OperationHistoryEvent event) {
StringBuffer buf = new StringBuffer();
buf.append(event.getOperation().getLabel() + "\n");
IUndoContext[] contexts = event.getOperation().getContexts();
for (int i = 0; i < contexts.length; i++) {
buf.append(contexts[i].toString() + "\n");
}
switch (event.getEventType()) {
case OperationHistoryEvent.ABOUT_TO_EXECUTE: {
// Don't log this.
}
break;
case OperationHistoryEvent.DONE: {
// Activator.logInfo("Operation Done: " + buf.toString());
}
break;
case OperationHistoryEvent.OPERATION_CHANGED: {
// Activator.logInfo("Operation Changed: " + buf.toString());
}
break;
case OperationHistoryEvent.REDONE: {
// Activator.logInfo("Operation Redone " + buf.toString());
}
case OperationHistoryEvent.UNDONE: {
// Activator.logInfo("Operation Undone: " + buf.toString());
}
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02852 seconds