Home » Modeling » GMF (Graphical Modeling Framework) » changing connection color programtically
changing connection color programtically [message #70857] |
Fri, 27 October 2006 10:02  |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
Hi all! =)
im able to call a created Action by popup menu, but i want to know how
to change EditPart's attributes such as colors of connections, for example.
Any hint?
tks
Julia
|
|
| | |
Re: changing connection color programtically [message #71664 is a reply to message #71535] |
Mon, 30 October 2006 11:02   |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
To see how those features you need are called, look in ShapeEditPart:
protected void handleNotificationEvent(Notification notification) {
Object feature = notification.getFeature();
if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
|| NotationPackage.eINSTANCE.getSize_Height().equals(feature)
|| NotationPackage.eINSTANCE.getLocation_X().equals(feature)
|| NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
refreshBounds();
}
else if (NotationPackage.eINSTANCE.getFillStyle_FillColor().equals(f eature)) {
Integer c = (Integer) notification.getNewValue();
setBackgroundColor(DiagramColorRegistry.getInstance().getCol or(c));
}
else if (NotationPackage.eINSTANCE.getLineStyle_LineColor().equals(f eature)) {
Integer c = (Integer) notification.getNewValue();
setForegroundColor(DiagramColorRegistry.getInstance().getCol or(c));
}
else if (NotationPackage.eINSTANCE.getFontStyle().isInstance(notific ation.getNotifier()))
refreshFont();
And finally, here's a snippet:
SetBoundsCommand comm = new SetBoundsCommand(
getEditingDomain(), "Relocate X position",
new EObjectAdapter(view), bounds.getTopLeft());
try {
OperationHistoryFactory.getOperationHistory()
.execute(comm, new NullProgressMonitor(),
null);
} catch (ExecutionException e) {
// nada
}
You need to use SetRequest and SetValueCommand, instead.
vlad
On Mon, 30 Oct 2006 10:59:46 -0300, Julia Sartori wrote:
> Thanks Mohammed, do you have some snippet?
> i searched all over..
>
> Thanks again!
>
> Mohammed Mostafa wrote:
>> Hi Julia;
>> Visual attributes (like color, line width , ... ) are attributes of
>> the figure, and they usually reflect styles on the Notation view
>>
>> To change the line color on a view you can use the LineStyle (from
>> the notation meta model). LineStyle had setLineColor method that allows
>> you to change the line color.
>>
>> For examples on how to change styles check SetPropertyCommand and
>> ColorPropertyContributionItem
>>
>>
>>
>>
>> Julia Sartori wrote:
>>> Hi all! =)
>>> im able to call a created Action by popup menu, but i want to know how
>>> to change EditPart's attributes such as colors of connections, for
>>> example.
>>> Any hint?
>>>
>>> tks
>>> Julia
|
|
|
Re: changing connection color programtically [message #71719 is a reply to message #71535] |
Mon, 30 October 2006 13:39   |
Eclipse User |
|
|
|
Here is one of the ways to do it
First you create a change property request like this
ChangePropertyValueRequest req = new ChangePropertyValueRequest(
StringStatics.BLANK,Properties.ID_LINECOLOR,
FigureUtilities.colorToInteger(DiagramColorConstants.red));
you will notice that I'm passing the line color as the property ID, and
Red as the value
Now, we can call get command on the edit part, passing it the request
we just created
final Command cmd = editPart.getCommand(req);
Then execute the returned command (should check for null before trying
to execute) like this :
AbstractEMFOperation operation = new
AbstractEMFOperation(((IGraphicalEditPart) editPart).getEditingDomain(),
StringStatics.BLANK, null) {
protected IStatus doExecute(IProgressMonitor monitor,
IAdaptable info)throws ExecutionException {
cmd.execute();
return Status.OK_STATUS;
}
};
try {
operation.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
// nothing to do here
}
this should change the line color to red
Julia Sartori wrote:
> Thanks Mohammed, do you have some snippet?
> i searched all over..
>
> Thanks again!
>
> Mohammed Mostafa wrote:
>> Hi Julia;
>> Visual attributes (like color, line width , ... ) are attributes
>> of the figure, and they usually reflect styles on the Notation view
>>
>> To change the line color on a view you can use the LineStyle (from
>> the notation meta model). LineStyle had setLineColor method that
>> allows you to change the line color.
>>
>> For examples on how to change styles check SetPropertyCommand and
>> ColorPropertyContributionItem
>>
>>
>>
>>
>> Julia Sartori wrote:
>>> Hi all! =)
>>> im able to call a created Action by popup menu, but i want to know
>>> how to change EditPart's attributes such as colors of connections,
>>> for example.
>>> Any hint?
>>>
>>> tks
>>> Julia
|
|
|
Re: changing connection color programtically [message #71738 is a reply to message #71664] |
Mon, 30 October 2006 14:06   |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
Hi Vlad! Thank you so much ^^
here is my code:
public void run(IAction action) {
SetRequest request = new SetRequest(
selectedElement.getEditingDomain(),
(EObject)selectedElement.getModel(),
NotationPackage.eINSTANCE.getLineStyle_LineColor(),
DiagramColorRegistry.getInstance().getColor(new RGB(200,20,0)));
SetValueCommand c = new SetValueCommand(request);
try {
OperationHistoryFactory.getOperationHistory()
.execute(c, new NullProgressMonitor(),
null);
} catch (ExecutionException e) {
// nada
}
I tried this, but im doing something wrong, because it doesnt work. =(
Besides, there are any way to execute an action (maybe an IAction, not
an IObjectActionDelegate, like this one) and call this "color changing"
by there?
Because when i call this action (by right-click, im using an extension
for popup menu on the diagram) the popup menu just shows up once! 0o
after the action is called, the popup dont come up again..
so is much better if i can execute this by a simple menu.
Thank you so much for your(both) help.
and sorry about my bad english, im brazilian. =D
Vlad Ciubotariu wrote:
> To see how those features you need are called, look in ShapeEditPart:
>
> protected void handleNotificationEvent(Notification notification) {
> Object feature = notification.getFeature();
> if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
> || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
> || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
> || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
> refreshBounds();
> }
> else if (NotationPackage.eINSTANCE.getFillStyle_FillColor().equals(f eature)) {
> Integer c = (Integer) notification.getNewValue();
> setBackgroundColor(DiagramColorRegistry.getInstance().getCol or(c));
> }
> else if (NotationPackage.eINSTANCE.getLineStyle_LineColor().equals(f eature)) {
> Integer c = (Integer) notification.getNewValue();
> setForegroundColor(DiagramColorRegistry.getInstance().getCol or(c));
> }
> else if (NotationPackage.eINSTANCE.getFontStyle().isInstance(notific ation.getNotifier()))
> refreshFont();
>
> And finally, here's a snippet:
>
> SetBoundsCommand comm = new SetBoundsCommand(
> getEditingDomain(), "Relocate X position",
> new EObjectAdapter(view), bounds.getTopLeft());
> try {
> OperationHistoryFactory.getOperationHistory()
> .execute(comm, new NullProgressMonitor(),
> null);
> } catch (ExecutionException e) {
> // nada
> }
>
> You need to use SetRequest and SetValueCommand, instead.
>
> vlad
>
>
>
> On Mon, 30 Oct 2006 10:59:46 -0300, Julia Sartori wrote:
>
>> Thanks Mohammed, do you have some snippet?
>> i searched all over..
>>
>> Thanks again!
>>
>> Mohammed Mostafa wrote:
>>> Hi Julia;
>>> Visual attributes (like color, line width , ... ) are attributes of
>>> the figure, and they usually reflect styles on the Notation view
>>>
>>> To change the line color on a view you can use the LineStyle (from
>>> the notation meta model). LineStyle had setLineColor method that allows
>>> you to change the line color.
>>>
>>> For examples on how to change styles check SetPropertyCommand and
>>> ColorPropertyContributionItem
>>>
>>>
>>>
>>>
>>> Julia Sartori wrote:
>>>> Hi all! =)
>>>> im able to call a created Action by popup menu, but i want to know how
>>>> to change EditPart's attributes such as colors of connections, for
>>>> example.
>>>> Any hint?
>>>>
>>>> tks
>>>> Julia
>
|
|
|
Re: changing connection color programtically [message #71757 is a reply to message #71719] |
Mon, 30 October 2006 14:14   |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
Thanks mohammed, that worked!! yey!
=)
now can i execute an IAction and get the editpart(the diagram) on the
current view?
because the popup menu just shows up once (??)
Thank you so much!!
Mohammed Mostafa wrote:
> Here is one of the ways to do it
>
> First you create a change property request like this
>
> ChangePropertyValueRequest req = new ChangePropertyValueRequest(
> StringStatics.BLANK,Properties.ID_LINECOLOR,
> FigureUtilities.colorToInteger(DiagramColorConstants.red));
>
> you will notice that I'm passing the line color as the property ID, and
> Red as the value
> Now, we can call get command on the edit part, passing it the
> request we just created
>
> final Command cmd = editPart.getCommand(req);
>
>
> Then execute the returned command (should check for null before
> trying to execute) like this :
>
> AbstractEMFOperation operation = new
> AbstractEMFOperation(((IGraphicalEditPart) editPart).getEditingDomain(),
> StringStatics.BLANK, null) {
> protected IStatus doExecute(IProgressMonitor monitor,
> IAdaptable info)throws ExecutionException {
> cmd.execute();
> return Status.OK_STATUS;
> }
> };
> try {
> operation.execute(new NullProgressMonitor(), null);
> } catch (ExecutionException e) {
> // nothing to do here
> }
>
> this should change the line color to red
>
> Julia Sartori wrote:
>> Thanks Mohammed, do you have some snippet?
>> i searched all over..
>>
>> Thanks again!
>>
>> Mohammed Mostafa wrote:
>>> Hi Julia;
>>> Visual attributes (like color, line width , ... ) are attributes
>>> of the figure, and they usually reflect styles on the Notation view
>>>
>>> To change the line color on a view you can use the LineStyle
>>> (from the notation meta model). LineStyle had setLineColor method
>>> that allows you to change the line color.
>>>
>>> For examples on how to change styles check SetPropertyCommand and
>>> ColorPropertyContributionItem
>>>
>>>
>>>
>>>
>>> Julia Sartori wrote:
>>>> Hi all! =)
>>>> im able to call a created Action by popup menu, but i want to know
>>>> how to change EditPart's attributes such as colors of connections,
>>>> for example.
>>>> Any hint?
>>>>
>>>> tks
>>>> Julia
|
|
|
Re: changing connection color programtically [message #71776 is a reply to message #71757] |
Mon, 30 October 2006 14:40   |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
Is there some exception thrown in selectionChanged in your Action? That
might make the popup show only once ...
To get to the diagram do smth like this:
View parentView = (View) someEditPart.getModel();
Diagram diagram = (Diagram) EMFCoreUtil.getContainer(parentView,
NotationPackage.eINSTANCE.getDiagram());
vlad
On Mon, 30 Oct 2006 16:14:20 -0300, Julia Sartori wrote:
> Thanks mohammed, that worked!! yey!
> =)
>
> now can i execute an IAction and get the editpart(the diagram) on the
> current view?
> because the popup menu just shows up once (??)
>
> Thank you so much!!
>
>
> Mohammed Mostafa wrote:
>> Here is one of the ways to do it
>>
>> First you create a change property request like this
>>
>> ChangePropertyValueRequest req = new ChangePropertyValueRequest(
>> StringStatics.BLANK,Properties.ID_LINECOLOR,
>> FigureUtilities.colorToInteger(DiagramColorConstants.red));
>>
>> you will notice that I'm passing the line color as the property ID, and
>> Red as the value
>> Now, we can call get command on the edit part, passing it the
>> request we just created
>>
>> final Command cmd = editPart.getCommand(req);
>>
>>
>> Then execute the returned command (should check for null before
>> trying to execute) like this :
>>
>> AbstractEMFOperation operation = new
>> AbstractEMFOperation(((IGraphicalEditPart) editPart).getEditingDomain(),
>> StringStatics.BLANK, null) {
>> protected IStatus doExecute(IProgressMonitor monitor,
>> IAdaptable info)throws ExecutionException {
>> cmd.execute();
>> return Status.OK_STATUS;
>> }
>> };
>> try {
>> operation.execute(new NullProgressMonitor(), null);
>> } catch (ExecutionException e) {
>> // nothing to do here
>> }
>>
>> this should change the line color to red
>>
>> Julia Sartori wrote:
>>> Thanks Mohammed, do you have some snippet?
>>> i searched all over..
>>>
>>> Thanks again!
>>>
>>> Mohammed Mostafa wrote:
>>>> Hi Julia;
>>>> Visual attributes (like color, line width , ... ) are attributes
>>>> of the figure, and they usually reflect styles on the Notation view
>>>>
>>>> To change the line color on a view you can use the LineStyle
>>>> (from the notation meta model). LineStyle had setLineColor method
>>>> that allows you to change the line color.
>>>>
>>>> For examples on how to change styles check SetPropertyCommand and
>>>> ColorPropertyContributionItem
>>>>
>>>>
>>>>
>>>>
>>>> Julia Sartori wrote:
>>>>> Hi all! =)
>>>>> im able to call a created Action by popup menu, but i want to know
>>>>> how to change EditPart's attributes such as colors of connections,
>>>>> for example.
>>>>> Any hint?
>>>>>
>>>>> tks
>>>>> Julia
|
|
|
Re: changing connection color programtically [message #71794 is a reply to message #71776] |
Mon, 30 October 2006 14:55   |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
Hi Vlad,
i meant, when i have this on an IAction:
MultiPageEditorPart editor = (MultiPageEditorPart)
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
how can i get the Diagram or the RootEditPart or the EditPart being showed?
got me?
Thanks!
Vlad Ciubotariu wrote:
> Is there some exception thrown in selectionChanged in your Action? That
> might make the popup show only once ...
>
> To get to the diagram do smth like this:
>
> View parentView = (View) someEditPart.getModel();
> Diagram diagram = (Diagram) EMFCoreUtil.getContainer(parentView,
> NotationPackage.eINSTANCE.getDiagram());
>
> vlad
>
> On Mon, 30 Oct 2006 16:14:20 -0300, Julia Sartori wrote:
>
>> Thanks mohammed, that worked!! yey!
>> =)
>>
>> now can i execute an IAction and get the editpart(the diagram) on the
>> current view?
>> because the popup menu just shows up once (??)
>>
>> Thank you so much!!
>>
>>
>> Mohammed Mostafa wrote:
>>> Here is one of the ways to do it
>>>
>>> First you create a change property request like this
>>>
>>> ChangePropertyValueRequest req = new ChangePropertyValueRequest(
>>> StringStatics.BLANK,Properties.ID_LINECOLOR,
>>> FigureUtilities.colorToInteger(DiagramColorConstants.red));
>>>
>>> you will notice that I'm passing the line color as the property ID, and
>>> Red as the value
>>> Now, we can call get command on the edit part, passing it the
>>> request we just created
>>>
>>> final Command cmd = editPart.getCommand(req);
>>>
>>>
>>> Then execute the returned command (should check for null before
>>> trying to execute) like this :
>>>
>>> AbstractEMFOperation operation = new
>>> AbstractEMFOperation(((IGraphicalEditPart) editPart).getEditingDomain(),
>>> StringStatics.BLANK, null) {
>>> protected IStatus doExecute(IProgressMonitor monitor,
>>> IAdaptable info)throws ExecutionException {
>>> cmd.execute();
>>> return Status.OK_STATUS;
>>> }
>>> };
>>> try {
>>> operation.execute(new NullProgressMonitor(), null);
>>> } catch (ExecutionException e) {
>>> // nothing to do here
>>> }
>>>
>>> this should change the line color to red
>>>
>>> Julia Sartori wrote:
>>>> Thanks Mohammed, do you have some snippet?
>>>> i searched all over..
>>>>
>>>> Thanks again!
>>>>
>>>> Mohammed Mostafa wrote:
>>>>> Hi Julia;
>>>>> Visual attributes (like color, line width , ... ) are attributes
>>>>> of the figure, and they usually reflect styles on the Notation view
>>>>>
>>>>> To change the line color on a view you can use the LineStyle
>>>>> (from the notation meta model). LineStyle had setLineColor method
>>>>> that allows you to change the line color.
>>>>>
>>>>> For examples on how to change styles check SetPropertyCommand and
>>>>> ColorPropertyContributionItem
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Julia Sartori wrote:
>>>>>> Hi all! =)
>>>>>> im able to call a created Action by popup menu, but i want to know
>>>>>> how to change EditPart's attributes such as colors of connections,
>>>>>> for example.
>>>>>> Any hint?
>>>>>>
>>>>>> tks
>>>>>> Julia
>
|
|
|
Re: changing connection color programtically [message #71813 is a reply to message #71794] |
Mon, 30 October 2006 15:32   |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
Cast your editor part to a gef GraphicalEditor.
You need GraphicalEditor#getGraphicalViewer().getContents().getModel( )
vlad
On Mon, 30 Oct 2006 16:55:48 -0300, Julia Sartori wrote:
> Hi Vlad,
> i meant, when i have this on an IAction:
> MultiPageEditorPart editor = (MultiPageEditorPart)
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
>
> how can i get the Diagram or the RootEditPart or the EditPart being showed?
>
> got me?
>
> Thanks!
>
>
> Vlad Ciubotariu wrote:
>> Is there some exception thrown in selectionChanged in your Action? That
>> might make the popup show only once ...
>>
>> To get to the diagram do smth like this:
>>
>> View parentView = (View) someEditPart.getModel();
>> Diagram diagram = (Diagram) EMFCoreUtil.getContainer(parentView,
>> NotationPackage.eINSTANCE.getDiagram());
>>
>> vlad
>>
>> On Mon, 30 Oct 2006 16:14:20 -0300, Julia Sartori wrote:
>>
>>> Thanks mohammed, that worked!! yey!
>>> =)
>>>
>>> now can i execute an IAction and get the editpart(the diagram) on the
>>> current view?
>>> because the popup menu just shows up once (??)
>>>
>>> Thank you so much!!
>>>
>>>
>>> Mohammed Mostafa wrote:
>>>> Here is one of the ways to do it
>>>>
>>>> First you create a change property request like this
>>>>
>>>> ChangePropertyValueRequest req = new ChangePropertyValueRequest(
>>>> StringStatics.BLANK,Properties.ID_LINECOLOR,
>>>> FigureUtilities.colorToInteger(DiagramColorConstants.red));
>>>>
>>>> you will notice that I'm passing the line color as the property ID, and
>>>> Red as the value
>>>> Now, we can call get command on the edit part, passing it the
>>>> request we just created
>>>>
>>>> final Command cmd = editPart.getCommand(req);
>>>>
>>>>
>>>> Then execute the returned command (should check for null before
>>>> trying to execute) like this :
>>>>
>>>> AbstractEMFOperation operation = new
>>>> AbstractEMFOperation(((IGraphicalEditPart) editPart).getEditingDomain(),
>>>> StringStatics.BLANK, null) {
>>>> protected IStatus doExecute(IProgressMonitor monitor,
>>>> IAdaptable info)throws ExecutionException {
>>>> cmd.execute();
>>>> return Status.OK_STATUS;
>>>> }
>>>> };
>>>> try {
>>>> operation.execute(new NullProgressMonitor(), null);
>>>> } catch (ExecutionException e) {
>>>> // nothing to do here
>>>> }
>>>>
>>>> this should change the line color to red
>>>>
>>>> Julia Sartori wrote:
>>>>> Thanks Mohammed, do you have some snippet?
>>>>> i searched all over..
>>>>>
>>>>> Thanks again!
>>>>>
>>>>> Mohammed Mostafa wrote:
>>>>>> Hi Julia;
>>>>>> Visual attributes (like color, line width , ... ) are attributes
>>>>>> of the figure, and they usually reflect styles on the Notation view
>>>>>>
>>>>>> To change the line color on a view you can use the LineStyle
>>>>>> (from the notation meta model). LineStyle had setLineColor method
>>>>>> that allows you to change the line color.
>>>>>>
>>>>>> For examples on how to change styles check SetPropertyCommand and
>>>>>> ColorPropertyContributionItem
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Julia Sartori wrote:
>>>>>>> Hi all! =)
>>>>>>> im able to call a created Action by popup menu, but i want to know
>>>>>>> how to change EditPart's attributes such as colors of connections,
>>>>>>> for example.
>>>>>>> Any hint?
>>>>>>>
>>>>>>> tks
>>>>>>> Julia
>>
|
|
|
Re: changing connection color programtically [message #71920 is a reply to message #71813] |
Tue, 31 October 2006 07:27   |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
Hey Vlad, thanks, but see:
GraphicalEditor editor =
(GraphicalEditor)PlatformUI.getWorkbench().getActiveWorkbenc hWindow().getActivePage().getActiveEditor();
editor.getGraphicalViewer().getContents().getModel();
the GraphicalEditor doesnt have the getGraphicalViewer() method
what do i have to do?
Vlad Ciubotariu wrote:
> Cast your editor part to a gef GraphicalEditor.
>
> You need GraphicalEditor#getGraphicalViewer().getContents().getModel( )
>
> vlad
>
>
> On Mon, 30 Oct 2006 16:55:48 -0300, Julia Sartori wrote:
>
>> Hi Vlad,
>> i meant, when i have this on an IAction:
>> MultiPageEditorPart editor = (MultiPageEditorPart)
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
>>
>> how can i get the Diagram or the RootEditPart or the EditPart being showed?
>>
>> got me?
>>
>> Thanks!
>>
>>
>> Vlad Ciubotariu wrote:
>>> Is there some exception thrown in selectionChanged in your Action? That
>>> might make the popup show only once ...
>>>
>>> To get to the diagram do smth like this:
>>>
>>> View parentView = (View) someEditPart.getModel();
>>> Diagram diagram = (Diagram) EMFCoreUtil.getContainer(parentView,
>>> NotationPackage.eINSTANCE.getDiagram());
>>>
>>> vlad
>>>
>>> On Mon, 30 Oct 2006 16:14:20 -0300, Julia Sartori wrote:
>>>
>>>> Thanks mohammed, that worked!! yey!
>>>> =)
>>>>
>>>> now can i execute an IAction and get the editpart(the diagram) on the
>>>> current view?
>>>> because the popup menu just shows up once (??)
>>>>
>>>> Thank you so much!!
>>>>
>>>>
>>>> Mohammed Mostafa wrote:
>>>>> Here is one of the ways to do it
>>>>>
>>>>> First you create a change property request like this
>>>>>
>>>>> ChangePropertyValueRequest req = new ChangePropertyValueRequest(
>>>>> StringStatics.BLANK,Properties.ID_LINECOLOR,
>>>>> FigureUtilities.colorToInteger(DiagramColorConstants.red));
>>>>>
>>>>> you will notice that I'm passing the line color as the property ID, and
>>>>> Red as the value
>>>>> Now, we can call get command on the edit part, passing it the
>>>>> request we just created
>>>>>
>>>>> final Command cmd = editPart.getCommand(req);
>>>>>
>>>>>
>>>>> Then execute the returned command (should check for null before
>>>>> trying to execute) like this :
>>>>>
>>>>> AbstractEMFOperation operation = new
>>>>> AbstractEMFOperation(((IGraphicalEditPart) editPart).getEditingDomain(),
>>>>> StringStatics.BLANK, null) {
>>>>> protected IStatus doExecute(IProgressMonitor monitor,
>>>>> IAdaptable info)throws ExecutionException {
>>>>> cmd.execute();
>>>>> return Status.OK_STATUS;
>>>>> }
>>>>> };
>>>>> try {
>>>>> operation.execute(new NullProgressMonitor(), null);
>>>>> } catch (ExecutionException e) {
>>>>> // nothing to do here
>>>>> }
>>>>>
>>>>> this should change the line color to red
>>>>>
>>>>> Julia Sartori wrote:
>>>>>> Thanks Mohammed, do you have some snippet?
>>>>>> i searched all over..
>>>>>>
>>>>>> Thanks again!
>>>>>>
>>>>>> Mohammed Mostafa wrote:
>>>>>>> Hi Julia;
>>>>>>> Visual attributes (like color, line width , ... ) are attributes
>>>>>>> of the figure, and they usually reflect styles on the Notation view
>>>>>>>
>>>>>>> To change the line color on a view you can use the LineStyle
>>>>>>> (from the notation meta model). LineStyle had setLineColor method
>>>>>>> that allows you to change the line color.
>>>>>>>
>>>>>>> For examples on how to change styles check SetPropertyCommand and
>>>>>>> ColorPropertyContributionItem
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Julia Sartori wrote:
>>>>>>>> Hi all! =)
>>>>>>>> im able to call a created Action by popup menu, but i want to know
>>>>>>>> how to change EditPart's attributes such as colors of connections,
>>>>>>>> for example.
>>>>>>>> Any hint?
>>>>>>>>
>>>>>>>> tks
>>>>>>>> Julia
>
|
|
|
Re: changing connection color programtically [message #72090 is a reply to message #71920] |
Tue, 31 October 2006 09:34  |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
i got it..
editor.getDiagramEditPart()..XXX
Thanks a lot for your help!! ^^
(do you know how to put the EMF properties view instead of the GMF one?)
Julia Sartori wrote:
> Hey Vlad, thanks, but see:
>
> GraphicalEditor editor =
> (GraphicalEditor)PlatformUI.getWorkbench().getActiveWorkbenc hWindow().getActivePage().getActiveEditor();
>
> editor.getGraphicalViewer().getContents().getModel();
>
> the GraphicalEditor doesnt have the getGraphicalViewer() method
>
> what do i have to do?
>
>
>
> Vlad Ciubotariu wrote:
>> Cast your editor part to a gef GraphicalEditor.
>>
>> You need GraphicalEditor#getGraphicalViewer().getContents().getModel( )
>> vlad
>>
>>
>> On Mon, 30 Oct 2006 16:55:48 -0300, Julia Sartori wrote:
>>
>>> Hi Vlad,
>>> i meant, when i have this on an IAction:
>>> MultiPageEditorPart editor = (MultiPageEditorPart)
>>> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
>>>
>>>
>>> how can i get the Diagram or the RootEditPart or the EditPart being
>>> showed?
>>>
>>> got me?
>>>
>>> Thanks!
>>>
>>>
>>> Vlad Ciubotariu wrote:
>>>> Is there some exception thrown in selectionChanged in your Action? That
>>>> might make the popup show only once ...
>>>>
>>>> To get to the diagram do smth like this:
>>>>
>>>> View parentView = (View) someEditPart.getModel();
>>>> Diagram diagram = (Diagram)
>>>> EMFCoreUtil.getContainer(parentView,
>>>> NotationPackage.eINSTANCE.getDiagram());
>>>>
>>>> vlad
>>>>
>>>> On Mon, 30 Oct 2006 16:14:20 -0300, Julia Sartori wrote:
>>>>
>>>>> Thanks mohammed, that worked!! yey!
>>>>> =)
>>>>>
>>>>> now can i execute an IAction and get the editpart(the diagram) on
>>>>> the current view?
>>>>> because the popup menu just shows up once (??)
>>>>>
>>>>> Thank you so much!!
>>>>>
>>>>>
>>>>> Mohammed Mostafa wrote:
>>>>>> Here is one of the ways to do it
>>>>>>
>>>>>> First you create a change property request like this
>>>>>>
>>>>>> ChangePropertyValueRequest req = new ChangePropertyValueRequest(
>>>>>> StringStatics.BLANK,Properties.ID_LINECOLOR,
>>>>>> FigureUtilities.colorToInteger(DiagramColorConstants.red));
>>>>>>
>>>>>> you will notice that I'm passing the line color as the property
>>>>>> ID, and Red as the value
>>>>>> Now, we can call get command on the edit part, passing it the
>>>>>> request we just created
>>>>>>
>>>>>> final Command cmd = editPart.getCommand(req);
>>>>>>
>>>>>>
>>>>>> Then execute the returned command (should check for null
>>>>>> before trying to execute) like this :
>>>>>>
>>>>>> AbstractEMFOperation operation = new
>>>>>> AbstractEMFOperation(((IGraphicalEditPart)
>>>>>> editPart).getEditingDomain(),
>>>>>> StringStatics.BLANK, null) {
>>>>>> protected IStatus doExecute(IProgressMonitor monitor,
>>>>>> IAdaptable info)throws ExecutionException {
>>>>>> cmd.execute();
>>>>>> return Status.OK_STATUS;
>>>>>> }
>>>>>> };
>>>>>> try {
>>>>>> operation.execute(new NullProgressMonitor(), null);
>>>>>> } catch (ExecutionException e) {
>>>>>> // nothing to do here
>>>>>> }
>>>>>>
>>>>>> this should change the line color to red
>>>>>>
>>>>>> Julia Sartori wrote:
>>>>>>> Thanks Mohammed, do you have some snippet?
>>>>>>> i searched all over..
>>>>>>>
>>>>>>> Thanks again!
>>>>>>>
>>>>>>> Mohammed Mostafa wrote:
>>>>>>>> Hi Julia;
>>>>>>>> Visual attributes (like color, line width , ... ) are
>>>>>>>> attributes of the figure, and they usually reflect styles on the
>>>>>>>> Notation view
>>>>>>>>
>>>>>>>> To change the line color on a view you can use the LineStyle
>>>>>>>> (from the notation meta model). LineStyle had setLineColor
>>>>>>>> method that allows you to change the line color.
>>>>>>>>
>>>>>>>> For examples on how to change styles check
>>>>>>>> SetPropertyCommand and ColorPropertyContributionItem
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Julia Sartori wrote:
>>>>>>>>> Hi all! =)
>>>>>>>>> im able to call a created Action by popup menu, but i want to
>>>>>>>>> know how to change EditPart's attributes such as colors of
>>>>>>>>> connections, for example.
>>>>>>>>> Any hint?
>>>>>>>>>
>>>>>>>>> tks
>>>>>>>>> Julia
>>
|
|
|
Goto Forum:
Current Time: Sat May 10 17:15:16 EDT 2025
Powered by FUDForum. Page generated in 0.05201 seconds
|