Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Graphiti API
Graphiti API [message #656252] Thu, 24 February 2011 12:11 Go to next message
Ali is currently offline Ali
Messages: 18
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------010300020507010708000601
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I'm trying to integrate Graphiti in my own workspace management. So, I
extended the DiagramEditor to override the save management behavior
(doSave & isDirty).

I'm facing the following issues:

- The DiagramEditorInternal instantiate the DiagramEditorBehavior in the
constructor which make it quite hard to change the behavior of the
DiagramEditor.

- DiagramEditorBehavior is internal and not intended to be subclassed by
client

Can we imagine to add a method to create the DiagramEditorBehavior where
I can override it in my editor to provider my custom behavior ??

And Can we have an interface like IDiagramEditorBehavior so that I can
implement it ??

I attached a patch.

code snippet:

/**
* Instantiates a new diagram editor.
*/
public DiagramEditorInternal() {
behavior = createDiagramEditorBehavior();
}

protected IDiagramEditorBehavior createDiagramEditorBehavior() {
return new DiagramEditorBehavior(this);
}
--------------------------------------------------
public interface IDiagramEditorBehavior extends
IEditingDomainProvider, IDisposable {

IUndoContext getUndoContext();

Resource[] doSave(IProgressMonitor progressMonitor);

boolean isDirty();

void init(IEditorSite site, IEditorInput editorInput, Runnable
dirtyStateUpdater);

void setFocus();
}

Thank you in advance,
Ali

--------------010300020507010708000601
Content-Type: text/plain;
name="graphiti"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="graphiti"

Index: src/org/eclipse/graphiti/ui/editor/IDiagramEditorBehavior.ja va
============================================================ =======
RCS file: src/org/eclipse/graphiti/ui/editor/IDiagramEditorBehavior.ja va
diff -N src/org/eclipse/graphiti/ui/editor/IDiagramEditorBehavior.ja va
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/graphiti/ui/editor/IDiagramEditorBehavior.ja va 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,22 @@
+package org.eclipse.graphiti.ui.editor;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.services.IDisposable;
+
+public interface IDiagramEditorBehavior extends IEditingDomainProvider, IDisposable {
+
+ IUndoContext getUndoContext();
+
+ Resource[] doSave(IProgressMonitor progressMonitor);
+
+ boolean isDirty();
+
+ void init(IEditorSite site, IEditorInput editorInput, Runnable dirtyStateUpdater);
+
+ void setFocus();
+}
Index: src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorBeh avior.java
============================================================ =======
RCS file: /cvsroot/modeling/org.eclipse.gmp/org.eclipse.gmp.graphiti/p lugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/i nternal/editor/DiagramEditorBehavior.java,v
retrieving revision 1.7
diff -u -r1.7 DiagramEditorBehavior.java
--- src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorBeh avior.java 10 Feb 2011 09:18:08 -0000 1.7
+++ src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorBeh avior.java 24 Feb 2011 17:06:25 -0000
@@ -54,6 +54,7 @@
import org.eclipse.emf.workspace.ResourceUndoContext;
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorBehavior;
import org.eclipse.graphiti.ui.internal.GraphitiUIPlugin;
import org.eclipse.graphiti.ui.internal.Messages;
import org.eclipse.graphiti.ui.internal.T;
@@ -75,7 +76,7 @@
* @noinstantiate This class is not intended to be instantiated by clients.
* @noextend This class is not intended to be subclassed by clients.
*/
-public class DiagramEditorBehavior extends PlatformObject implements IEditingDomainProvider, IOperationHistoryListener {
+public class DiagramEditorBehavior extends PlatformObject implements IDiagramEditorBehavior, IEditingDomainProvider, IOperationHistoryListener {

/**
* The part this model editor works on.
Index: src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorInt ernal.java
============================================================ =======
RCS file: /cvsroot/modeling/org.eclipse.gmp/org.eclipse.gmp.graphiti/p lugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/i nternal/editor/DiagramEditorInternal.java,v
retrieving revision 1.26
diff -u -r1.26 DiagramEditorInternal.java
--- src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorInt ernal.java 10 Feb 2011 09:18:08 -0000 1.26
+++ src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorInt ernal.java 24 Feb 2011 17:06:30 -0000
@@ -102,6 +102,7 @@
import org.eclipse.graphiti.ui.editor.DiagramEditorContextMenuProvi der;
import org.eclipse.graphiti.ui.editor.DiagramEditorFactory;
import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorBehavior;
import org.eclipse.graphiti.ui.internal.GraphitiUIPlugin;
import org.eclipse.graphiti.ui.internal.IResourceRegistry;
import org.eclipse.graphiti.ui.internal.IResourceRegistryHolder;
@@ -198,7 +199,7 @@
}
}

- private final DiagramEditorBehavior behavior;
+ private final IDiagramEditorBehavior behavior;
// As this may be called quite often, reuse the same instance of the
// runnable.
private final Runnable mDirtyFlagUpdater = new DirtyFlagUpdater();
@@ -269,7 +270,11 @@
* Instantiates a new diagram editor.
*/
public DiagramEditorInternal() {
- behavior = new DiagramEditorBehavior(this);
+ behavior = createDiagramEditorBehavior();
+ }
+
+ protected IDiagramEditorBehavior createDiagramEditorBehavior() {
+ return new DiagramEditorBehavior(this);
}

/**
@@ -554,7 +559,7 @@
resourceRegistry.dispose();
}

- DiagramEditorBehavior behavior = getBehavior();
+ IDiagramEditorBehavior behavior = getBehavior();
behavior.getEditingDomain().getCommandStack().removeCommandS tackListener(fwListener);
fwListener = null;
behavior.dispose();
@@ -596,7 +601,7 @@
}

// set editing domain
- TransactionalEditingDomain editingDomain = getBehavior().getEditingDomain();
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)getBehavior().getEditingDomain() ;
setTransactionalEditingDomain(editingDomain);

String providerId = diagramEditorInput.getProviderId();
@@ -1655,7 +1660,7 @@
*
* @return the model editor
*/
- private DiagramEditorBehavior getBehavior() {
+ private IDiagramEditorBehavior getBehavior() {
return behavior;
}


--------------010300020507010708000601--
Re: Graphiti API [message #656406 is a reply to message #656252] Fri, 25 February 2011 08:03 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1527
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Ali,

you' re right: the API of the DiagramEditor is not really as it should be.
There's already a bugzilla tracking this
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=336488).

On the other hand, the DiagramEditorBehavior class contains very specific
stuff, of which some parts are really essential to the Graphiti framework.
This is a class that we would rather not want to open up. If you have
specific use cases just let us know so that we can think of ways how to
enable them.

In your case in order to override doSave and isDirty behavior: you might do
that simply in your subclass of DiagramEditor (simply not delegating to
super). You will of course get the warnings regarding non-API usage, but
that will then be a topics for the above mentioned bugzilla and you may
ignore these warnings for now.

Michael


"Ali" wrote in message news:ik631q$6rv$1@news.eclipse.org...

Hi,

I'm trying to integrate Graphiti in my own workspace management. So, I
extended the DiagramEditor to override the save management behavior
(doSave & isDirty).

I'm facing the following issues:

- The DiagramEditorInternal instantiate the DiagramEditorBehavior in the
constructor which make it quite hard to change the behavior of the
DiagramEditor.

- DiagramEditorBehavior is internal and not intended to be subclassed by
client

Can we imagine to add a method to create the DiagramEditorBehavior where
I can override it in my editor to provider my custom behavior ??

And Can we have an interface like IDiagramEditorBehavior so that I can
implement it ??

I attached a patch.

code snippet:

/**
* Instantiates a new diagram editor.
*/
public DiagramEditorInternal() {
behavior = createDiagramEditorBehavior();
}

protected IDiagramEditorBehavior createDiagramEditorBehavior() {
return new DiagramEditorBehavior(this);
}
--------------------------------------------------
public interface IDiagramEditorBehavior extends
IEditingDomainProvider, IDisposable {

IUndoContext getUndoContext();

Resource[] doSave(IProgressMonitor progressMonitor);

boolean isDirty();

void init(IEditorSite site, IEditorInput editorInput, Runnable
dirtyStateUpdater);

void setFocus();
}

Thank you in advance,
Ali
Re: Graphiti API [message #656760 is a reply to message #656406] Mon, 28 February 2011 08:00 Go to previous messageGo to next message
Ali is currently offline Ali
Messages: 18
Registered: July 2009
Junior Member
Hi Michael,

Thank you for your answer.
For the save management, I can of course override methods in the editor
without delegating to the editor behavior, but I prefer to keep my code
as close as possible to Graphiti.

In my workspace, I have many models according to some scopes defined by
the user (e.g. ProjectScope), and each model has a global editing
domain.When calling
org.eclipse.graphiti.ui.internal.editor.DiagramEditorBehavio r#handleChangedResources()
all resources in my resource set are unloaded.
Same issue is also attaching a content adapter to the resource set which
leads in my case of performance issues.
(editingDomain.getResourceSet().eAdapters().add(problemIndic ationAdapter);)

It would be perfect when the editor manages only the owned resource (The
Graphiti resource).

You can keep the DiagramEditorBehavior in an internal package and don't
open it, but just change the way it's instantiated for the editor.

Ali

Le 25/02/2011 14:03, Michael Wenz a écrit :
> Ali,
>
> you' re right: the API of the DiagramEditor is not really as it should
> be. There's already a bugzilla tracking this
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=336488).
>
> On the other hand, the DiagramEditorBehavior class contains very
> specific stuff, of which some parts are really essential to the Graphiti
> framework. This is a class that we would rather not want to open up. If
> you have specific use cases just let us know so that we can think of
> ways how to enable them.
>
> In your case in order to override doSave and isDirty behavior: you might
> do that simply in your subclass of DiagramEditor (simply not delegating
> to super). You will of course get the warnings regarding non-API usage,
> but that will then be a topics for the above mentioned bugzilla and you
> may ignore these warnings for now.
>
> Michael
>
>
> "Ali" wrote in message news:ik631q$6rv$1@news.eclipse.org...
>
> Hi,
>
> I'm trying to integrate Graphiti in my own workspace management. So, I
> extended the DiagramEditor to override the save management behavior
> (doSave & isDirty).
>
> I'm facing the following issues:
>
> - The DiagramEditorInternal instantiate the DiagramEditorBehavior in the
> constructor which make it quite hard to change the behavior of the
> DiagramEditor.
>
> - DiagramEditorBehavior is internal and not intended to be subclassed by
> client
>
> Can we imagine to add a method to create the DiagramEditorBehavior where
> I can override it in my editor to provider my custom behavior ??
>
> And Can we have an interface like IDiagramEditorBehavior so that I can
> implement it ??
>
> I attached a patch.
>
> code snippet:
>
> /**
> * Instantiates a new diagram editor.
> */
> public DiagramEditorInternal() {
> behavior = createDiagramEditorBehavior();
> }
>
> protected IDiagramEditorBehavior createDiagramEditorBehavior() {
> return new DiagramEditorBehavior(this);
> }
> --------------------------------------------------
> public interface IDiagramEditorBehavior extends
> IEditingDomainProvider, IDisposable {
>
> IUndoContext getUndoContext();
>
> Resource[] doSave(IProgressMonitor progressMonitor);
>
> boolean isDirty();
>
> void init(IEditorSite site, IEditorInput editorInput, Runnable
> dirtyStateUpdater);
>
> void setFocus();
> }
>
> Thank you in advance,
> Ali
Re: Graphiti API [message #657316 is a reply to message #656760] Wed, 02 March 2011 07:13 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1527
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Ali,

I think it would be best to track this in the scope of the bugzilla for
opening up the editor API
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=336488), since it very much
affects what we have to make public inside the editor and what not. Could
you add this request as a comment to this bugzilla?

Thanks,
Michael


"Ali" wrote in message news:ikg5ri$f68$2@news.eclipse.org...

Hi Michael,

Thank you for your answer.
For the save management, I can of course override methods in the editor
without delegating to the editor behavior, but I prefer to keep my code
as close as possible to Graphiti.

In my workspace, I have many models according to some scopes defined by
the user (e.g. ProjectScope), and each model has a global editing
domain.When calling
org.eclipse.graphiti.ui.internal.editor.DiagramEditorBehavio r#handleChangedResources()
all resources in my resource set are unloaded.
Same issue is also attaching a content adapter to the resource set which
leads in my case of performance issues.
(editingDomain.getResourceSet().eAdapters().add(problemIndic ationAdapter);)

It would be perfect when the editor manages only the owned resource (The
Graphiti resource).

You can keep the DiagramEditorBehavior in an internal package and don't
open it, but just change the way it's instantiated for the editor.

Ali

Le 25/02/2011 14:03, Michael Wenz a écrit :
> Ali,
>
> you' re right: the API of the DiagramEditor is not really as it should
> be. There's already a bugzilla tracking this
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=336488).
>
> On the other hand, the DiagramEditorBehavior class contains very
> specific stuff, of which some parts are really essential to the Graphiti
> framework. This is a class that we would rather not want to open up. If
> you have specific use cases just let us know so that we can think of
> ways how to enable them.
>
> In your case in order to override doSave and isDirty behavior: you might
> do that simply in your subclass of DiagramEditor (simply not delegating
> to super). You will of course get the warnings regarding non-API usage,
> but that will then be a topics for the above mentioned bugzilla and you
> may ignore these warnings for now.
>
> Michael
>
>
> "Ali" wrote in message news:ik631q$6rv$1@news.eclipse.org...
>
> Hi,
>
> I'm trying to integrate Graphiti in my own workspace management. So, I
> extended the DiagramEditor to override the save management behavior
> (doSave & isDirty).
>
> I'm facing the following issues:
>
> - The DiagramEditorInternal instantiate the DiagramEditorBehavior in the
> constructor which make it quite hard to change the behavior of the
> DiagramEditor.
>
> - DiagramEditorBehavior is internal and not intended to be subclassed by
> client
>
> Can we imagine to add a method to create the DiagramEditorBehavior where
> I can override it in my editor to provider my custom behavior ??
>
> And Can we have an interface like IDiagramEditorBehavior so that I can
> implement it ??
>
> I attached a patch.
>
> code snippet:
>
> /**
> * Instantiates a new diagram editor.
> */
> public DiagramEditorInternal() {
> behavior = createDiagramEditorBehavior();
> }
>
> protected IDiagramEditorBehavior createDiagramEditorBehavior() {
> return new DiagramEditorBehavior(this);
> }
> --------------------------------------------------
> public interface IDiagramEditorBehavior extends
> IEditingDomainProvider, IDisposable {
>
> IUndoContext getUndoContext();
>
> Resource[] doSave(IProgressMonitor progressMonitor);
>
> boolean isDirty();
>
> void init(IEditorSite site, IEditorInput editorInput, Runnable
> dirtyStateUpdater);
>
> void setFocus();
> }
>
> Thank you in advance,
> Ali
Previous Topic:Send to Front or Back
Next Topic:Auto update when domain model changes
Goto Forum:
  


Current Time: Thu Apr 17 14:35:12 EDT 2014

Powered by FUDForum. Page generated in 0.02869 seconds