Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to create a "log-file"?
How to create a "log-file"? [message #653674] Thu, 10 February 2011 11:17 Go to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
I want to create a log-file inside the workspace which has the same name like my diagram file.
In this log-file I want to log the added components from my diagram.
To log those things is not a big deal. Since I'm not so familiar with the eclipse structure I don't really know where the diagram-file is created. I also don't treally know when the changes in the diagram like a new node or so a written to the file.

I hope you understand what I want.

1.) Create the "log-file" when the diagram-file is created
2.) Add an entry to my log everytime when there are changes to my diagram-file (like add a new node).
3.) Not a must, but would be nice. Delete the log when the diagram-file is also deleted.

Hope you can give me a hint.
Re: How to create a "log-file"? [message #654114 is a reply to message #653674] Mon, 14 February 2011 04:27 Go to previous messageGo to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
No one with an idea, or is this a question wich shold be asked in a
other subforum like the Plugin Development?

Am 10.02.2011 17:17, schrieb akoeck@gmx.de:
> I want to create a log-file inside the workspace which has the same name
> like my diagram file.
> In this log-file I want to log the added components from my diagram.
> To log those things is not a big deal. Since I'm not so familiar with
> the eclipse structure I don't really know where the diagram-file is
> created. I also don't treally know when the changes in the diagram like
> a new node or so a written to the file.
>
> I hope you understand what I want.
>
> 1.) Create the "log-file" when the diagram-file is created
> 2.) Add an entry to my log everytime when there are changes to my
> diagram-file (like add a new node).
> 3.) Not a must, but would be nice. Delete the log when the diagram-file
> is also deleted.
>
> Hope you can give me a hint.
Re: How to create a "log-file"? [message #655729 is a reply to message #654114] Tue, 22 February 2011 08:54 Go to previous messageGo to next message
akoeck is currently offline 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 08: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 09:38 Go to previous message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 914
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());
}
}
}

}
Previous Topic:Place nodes into specific regions of the canvas based on their types
Next Topic:gmf editor selection change events
Goto Forum:
  


Current Time: Thu Aug 28 05:25:34 EDT 2014

Powered by FUDForum. Page generated in 0.02560 seconds