Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Markers for each EditPart?
Markers for each EditPart? [message #139208] Tue, 22 June 2004 07:57 Go to next message
Eclipse UserFriend
Originally posted by: bbdaffy.hotmail.com

Hi,

Trying to do something like the following, but dun really know where to
start.

I would like to create something like the Task View, (or maybe make use of
the existing Task View) to display TODO items for each individual Figure.
Say, I create a new Figure on the editor, it will automatically generate a
list of TODO items. When I select this figure, the TODO list will be
displayed in a View (eg. Task View?). Double clicking on each TODO item
will trigger some action (say, bring up a dialog for user input eg.), and
once the user has completed the task, the changes will be updated to the
editpart and to the model.

Is there an article I can read or some advice as to how to go about this?
Thanks...

Regards,
Lee
Re: Markers for each EditPart? [message #139257 is a reply to message #139208] Tue, 22 June 2004 08:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: g.wagenknecht.planet-wagenknecht.de

Nicole wrote:
> Is there an article I can read or some advice as to how to go about
> this? Thanks...

Not sure but should find suitable information in the help. Look at IMarker,
ther marker extension point and how attach markers to resources. In general
marker changes are fired as/with regular resource change events.

You just need a mechanism to create/update figures when marker changes are
fired.

Cu, Gunnar
Re: Markers for each EditPart? [message #139285 is a reply to message #139257] Tue, 22 June 2004 09:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bbdaffy.hotmail.com

Hi,

Does that mean my models must each implement the IResource interface?

Regards,
Lee


Gunnar Wagenknecht wrote:

> Nicole wrote:
> > Is there an article I can read or some advice as to how to go about
> > this? Thanks...

> Not sure but should find suitable information in the help. Look at IMarker,
> ther marker extension point and how attach markers to resources. In general
> marker changes are fired as/with regular resource change events.

> You just need a mechanism to create/update figures when marker changes are
> fired.

> Cu, Gunnar
Re: Markers for each EditPart? [message #139624 is a reply to message #139285] Wed, 23 June 2004 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: g.wagenknecht.planet-wagenknecht.de

Nicole wrote:
> Does that mean my models must each implement the IResource interface?

No. Simply attach markers for your model to the workspace root if you model
doesn't have resources.

Cu, Gunnar
Re: Markers for each EditPart? [message #139858 is a reply to message #139285] Thu, 24 June 2004 12:38 Go to previous messageGo to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi Nicole,
I have solved this issue in my project so here is a sample code to show
you how to deal with markers :

1) You should implement the gotoMarker method in your editor:

class MyEditor extends GraphicalEditorWithPalette implements
org.eclipse.ui.ide.IGotoMarker{


public void gotoMarker(IMarker marker_p) {
try {
String nmsObjectID = (String)
marker_p.getAttribute("objectID");
_
// The keys are model objects and we are looking for the rigth
editPart
Map editPartRegistry =
getGraphicalViewer().getEditPartRegistry();
Iterator iteratorOnKeys = editPartRegistry.keySet().iterator();

boolean found = false;
ArrayList selectedPart = new ArrayList();
while (iteratorOnKeys.hasNext() && !found) {
TopologyElement subPart = null;
Object object = null;
// Be careful, some keys are not model object but ????
try {
object = iteratorOnKeys.next();
if (object instanceof TopologyElement)
subPart = (TopologyElement) object;
} catch (ClassCastException e) {
}
if (null != subPart) {
ModelElement element = subPart.getModelObject();

if (null != element) {
String elementID = element.getID();
if (elementID.equals(nmsObjectID)) {
found = true;
AbstractEditPart editPart = (AbstractEditPart)
editPartRegistry.get(subPart);
selectedPart.add(editPart);
}
}
}
}

// let's show the retrieved editPart
if (!selectedPart.isEmpty()) {
StructuredSelection selection = new
StructuredSelection(selectedPart);
getGraphicalViewer().setSelection(selection);
}

} catch (CoreException e_p) {
_logger.error("TopologyEditor.gotoMarker()", e_p);
}
}
}

2) Defining your marker in your plugin.xml associated to your editor, to
be able to retrieve objects
<extension
id="myProblemMarker"
name="%problemName"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<attribute
name="objectID">
</attribute>
</extension>


3) Save the IFile as a IResource from MyEditor.setInput(IEditorInput
input){
IFile file = ((IFileEditorInput) input).getFile();
IResource resource = file;
}

4) call the method below with the rigth parameter when your code detects
an error. (your checkMethod may be called in your listener class for
instance in LogicalEditPart when a object's attribute changes)

/**
* Create a Problem Marker
* @param resource_p The resource_p for which we are creating a new
Marker
* @param severity_p the severity for this problem
* @param priority_p the priority to fix the problem
* @param objectID_p the object's id producing the error
* @param message_p a user friendly string describing the problem
*/
public void createProblem(IResource resource_p, int severity_p, int
priority_p, String objectID_p, String message_p) {
try {

IMarker marker =
resource_p.createMarker("org.testmarker.myexemple.myProblemMarker ");
marker.setAttribute(IMarker.SEVERITY, severity_p);
marker.setAttribute(IMarker.MESSAGE, message_p);
marker.setAttribute(IMarker.PRIORITY, priority_p);
marker.setAttribute("userEditable", false);
marker.setAttribute("objectID", objectID_p);
} catch (CoreException e) {
_logger.warn("MarkerHandler.createProblem(),", e);
}
}


Stephane

Nicole wrote:

> Hi,

> Does that mean my models must each implement the IResource interface?

> Regards,
> Lee


> Gunnar Wagenknecht wrote:

> > Nicole wrote:
> > > Is there an article I can read or some advice as to how to go about
> > > this? Thanks...

> > Not sure but should find suitable information in the help. Look at IMarker,
> > ther marker extension point and how attach markers to resources. In general
> > marker changes are fired as/with regular resource change events.

> > You just need a mechanism to create/update figures when marker changes are
> > fired.

> > Cu, Gunnar
Re: Markers for each EditPart? [message #139951 is a reply to message #139858] Fri, 25 June 2004 02:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bbdaffy.hotmail.com

Hi,

Wow... Thanks. This is definitely very helpful... :) Appreciate it.

Regards,
Lee


Stephane wrote:

> Hi Nicole,
> I have solved this issue in my project so here is a sample code to show
> you how to deal with markers :

> 1) You should implement the gotoMarker method in your editor:

> class MyEditor extends GraphicalEditorWithPalette implements
> org.eclipse.ui.ide.IGotoMarker{


> public void gotoMarker(IMarker marker_p) {
> try {
> String nmsObjectID = (String)
> marker_p.getAttribute("objectID");
> _
> // The keys are model objects and we are looking for the rigth
> editPart
> Map editPartRegistry =
> getGraphicalViewer().getEditPartRegistry();
> Iterator iteratorOnKeys = editPartRegistry.keySet().iterator();

> boolean found = false;
> ArrayList selectedPart = new ArrayList();
> while (iteratorOnKeys.hasNext() && !found) {
> TopologyElement subPart = null;
> Object object = null;
> // Be careful, some keys are not model object but ????
> try {
> object = iteratorOnKeys.next();
> if (object instanceof TopologyElement)
> subPart = (TopologyElement) object;
> } catch (ClassCastException e) {
> }
> if (null != subPart) {
> ModelElement element = subPart.getModelObject();

> if (null != element) {
> String elementID = element.getID();
> if (elementID.equals(nmsObjectID)) {
> found = true;
> AbstractEditPart editPart = (AbstractEditPart)
> editPartRegistry.get(subPart);
> selectedPart.add(editPart);
> }
> }
> }
> }

> // let's show the retrieved editPart
> if (!selectedPart.isEmpty()) {
> StructuredSelection selection = new
> StructuredSelection(selectedPart);
> getGraphicalViewer().setSelection(selection);
> }

> } catch (CoreException e_p) {
> _logger.error("TopologyEditor.gotoMarker()", e_p);
> }
> }
> }

> 2) Defining your marker in your plugin.xml associated to your editor, to
> be able to retrieve objects
> <extension
> id="myProblemMarker"
> name="%problemName"
> point="org.eclipse.core.resources.markers">
> <super
> type="org.eclipse.core.resources.problemmarker">
> </super>
> <attribute
> name="objectID">
> </attribute>
> </extension>


> 3) Save the IFile as a IResource from MyEditor.setInput(IEditorInput
> input){
> IFile file = ((IFileEditorInput) input).getFile();
> IResource resource = file;
> }

> 4) call the method below with the rigth parameter when your code detects
> an error. (your checkMethod may be called in your listener class for
> instance in LogicalEditPart when a object's attribute changes)

> /**
> * Create a Problem Marker
> * @param resource_p The resource_p for which we are creating a new
> Marker
> * @param severity_p the severity for this problem
> * @param priority_p the priority to fix the problem
> * @param objectID_p the object's id producing the error
> * @param message_p a user friendly string describing the problem
> */
> public void createProblem(IResource resource_p, int severity_p, int
> priority_p, String objectID_p, String message_p) {
> try {

> IMarker marker =
> resource_p.createMarker("org.testmarker.myexemple.myProblemMarker ");
> marker.setAttribute(IMarker.SEVERITY, severity_p);
> marker.setAttribute(IMarker.MESSAGE, message_p);
> marker.setAttribute(IMarker.PRIORITY, priority_p);
> marker.setAttribute("userEditable", false);
> marker.setAttribute("objectID", objectID_p);
> } catch (CoreException e) {
> _logger.warn("MarkerHandler.createProblem(),", e);
> }
> }


> Stephane

> Nicole wrote:

> > Hi,

> > Does that mean my models must each implement the IResource interface?

> > Regards,
> > Lee


> > Gunnar Wagenknecht wrote:

> > > Nicole wrote:
> > > > Is there an article I can read or some advice as to how to go about
> > > > this? Thanks...

> > > Not sure but should find suitable information in the help. Look at
IMarker,
> > > ther marker extension point and how attach markers to resources. In
general
> > > marker changes are fired as/with regular resource change events.

> > > You just need a mechanism to create/update figures when marker changes
are
> > > fired.

> > > Cu, Gunnar
Re: Markers for each EditPart? [message #724000 is a reply to message #139951] Sat, 10 September 2011 09:21 Go to previous message
premkumar  is currently offline premkumar Friend
Messages: 5
Registered: July 2011
Junior Member
Hi

I have implemented the IGotoMarker Interface in myEditor (Graphical Editor) and written the implementation code for the gotoMarker Method, but when i click the problem displayed in the problemview, the gotoMarker method is not called.

I have added the following code in the getAdapter() of my Editor

if( type.equals( IGotoMarker.class ) )
{
return this;
}

Kindly let me know what can be done for this problem.
Previous Topic:Full-width child figures in a ScalableRootEditPart.
Next Topic:placing child and parent to same dimension and simultaneously placing childrens on both layers
Goto Forum:
  


Current Time: Tue Apr 23 06:19:47 GMT 2024

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

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

Back to the top