Skip to main content


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 16:17 Go to next message
akoeck is currently offline akoeckFriend
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 09:27 Go to previous messageGo to next message
akoeck is currently offline akoeckFriend
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 13:54 Go to previous messageGo to next message
akoeck is currently offline akoeckFriend
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 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
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());
}
}
}

}
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: Wed Dec 04 07:16:22 GMT 2024

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

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

Back to the top