Updating properties from an IAction [message #185350] |
Mon, 05 May 2008 10:53 |
Eclipse User |
|
|
|
Originally posted by: john.blutarsky.hotmail.com
Hello everyone,
I am trying to update properties through an IAction but I'm not having
much success. What I want to do is right click on the Canvas and select a
menu option I have created to get to a SWT interface.
All good until I try to update the properties of Canvas from the SWT
interface.
What I have so far is below.
I notice if I do canvaser.setName("Example"); just after the SWT code the
update takes place but does not occur until the selection has changed.
What I need is for the update to occur straight away after the SWT window
closes. It could be that I have implemented the public void
selectionChanged... in a questionable way as I don't fully understand what
is going on.
I have also tried AbstractTransactionalCommand setPropCommand... (as might
be used from an OpenEditPolicy) but I'm not sure how this might work as I
don't know how to call the command as it would normally be part of the
return command of the OpenEditPolicy.
Im sure its just something small, possibly I need to change the
selectionChanged
part to something else?
Thanks for your help,
John
public class NewCanvasActionTest implements IObjectActionDelegate {
private CanvasEditPart editParter;
private Canvas canvas;
public void run(IAction action) {
final IGraphicalEditPart editPart = (IGraphicalEditPart) editParter;
EObject modelElement = editPart.resolveSemanticElement();
final Canvas canvaser = (Canvas) modelElement;
TransactionalEditingDomain editingDomain =
TransactionUtil.getEditingDomain(modelElement);
//-------- SWT START -------------
final Shell s = new
Shell(SWT.CLOSE|SWT.RESIZE|SWT.APPLICATION_MODAL);
s.setSize(200, 200);
s.setMinimumSize(200, 200);
s.setText("Properties");
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
s.setLayout(gridLayout);
Text temp = new Text(s, SWT.NULL);
temp.setText(canvaser.getName());
s.open();
Display dp = s.getDisplay();
while (!s.isDisposed()) {
if (!dp.readAndDispatch()) {
dp.sleep();
}
}
//-------- SWT FINISH -------------
canvaser.setName("Yes, this does update the property but I have to
change the selection before the update occurs");
}
public void selectionChanged(IAction action, ISelection selection) {
editParter = null;
canvas = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection)
selection;
if (structuredSelection.getFirstElement() instanceof CanvasEditPart)
{
editParter = (CanvasEditPart) structuredSelection.getFirstElement();
canvas = (Canvas) editParter.getPrimaryView().getElement();
}
}
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
}
}
|
|
|
.... still haven't fixed this?????? [message #186649 is a reply to message #185350] |
Tue, 13 May 2008 13:45 |
Eclipse User |
|
|
|
Originally posted by: john.blutarsky.hotmail.com
Hi,
I've tried a few other things but keep getting the same results. Would
someone be able to assist me. I'm sure it's just a line I'm missing.
Thanks,
John
|
|
|
Powered by
FUDForum. Page generated in 0.02895 seconds