create link : ICommandProxy not executed ! [message #149114] |
Wed, 05 September 2007 12:23 |
Eclipse User |
|
|
|
Originally posted by: briandwilliam.hotmail.com
hi,
I try to create a connection between two node in the same command. there are
many problems !
see the jpg
when I bind the port to the interface :
- I rename the port : ok
- I create as much child in the compartment of the port than there is of
child in the interface : ok
- I set the attribut name of the new element, but the last of the list
is ok ???
- same manner I create children in the compartment 0perations of the
node parent(desc1) : ok
- now I want to connect the elements created in the compartment of the
port to the elements created in the compartment operation !
I try with this :
CreateConnectionViewAndElementRequest reqLink= new
CreateConnectionViewAndElementRequest(DescripteurElementType s.DescripteurPor
tSynchroneAccesseur_4002,
((IHintedType)
DescripteurElementTypes.DescripteurPortSynchroneAccesseur_40 02).getSemanticH
int(), root.getDiagramPreferencesHint());
System.out.println("reqLink="+reqLink);
ICommand createLinkCmd = new DeferredCreateConnectionViewAndElementCommand(
reqLink ,
portSynchroneViewAdapter,
operationViewAdapter, selectedElement.getViewer());
System.out.println("createLinkCmd="+createLinkCmd);
ccOp.add(new ICommandProxy(createLinkCmd));
there is a problem with this code !
#####################################
the complete code is :
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
if (!canExecute()) {
throw new ExecutionException(
"Invalid arguments in create link command"); //$NON-NLS-1$
}
if (getSource() != null && getTarget() != null) {
getSource().getRedefinitionRefDesc().add(getTarget());
getSource().setNomDescripteurPort("R_"+getTarget().getNomService());
monWB = PlatformUI.getWorkbench();
monWBwindow = monWB.getActiveWorkbenchWindow();
page = monWBwindow.getActivePage();
//System.out.println("input="+input);
editeur = page.getActiveEditor();
graphicalViewer = editeur.getAdapter(GraphicalViewer.class);
//Iterator it= ((EditPartViewer) graphicalViewer).getSelectedEditParts()
Iterator it= ((EditPartViewer)
graphicalViewer).getRootEditPart().getChildren().iterator();
for (Iterator iterator = it; iterator.hasNext();) {
root = (RacineDocumentEditPart) iterator.next();
//System.out.println("------------ root =" +root);
String D =
DescripteurVisualIDRegistry.getType(DescripteurRepresentatio nEditPart.VISUAL
_ID);
//System.out.println("------------ D=" +D);
//System.out.println("------------ p=" +p);
List pp = root.getChildBySemanticHint(D).getChildren();
//System.out.println("------------ pp=" +pp);
for (Iterator iter = pp.iterator(); iter.hasNext();) {
//System.out.println("------------ iter=" +iter.next());
Object part = iter.next();
if (part instanceof DescripteurPortFournisRepresentationEditPart) {
selectedElement = (DescripteurPortFournisRepresentationEditPart) part;
}
}
}
//((EditPartViewer) graphicalViewer).getEditPartRegistry().get(getSource());
if (selectedElement != null) {
//System.out.println("------------
selectedElement="+selectedElement.toString());
//
String compartmentSemanticHint = DescripteurVisualIDRegistry
..getType(DescripteurPortFournisRepresentationCompDescPortSy nchroneFourniEdit
Part.VISUAL_ID);
DescripteurPortFournisRepresentationCompDescPortSynchroneFou rniEditPart
modulesCompartment =
(DescripteurPortFournisRepresentationCompDescPortSynchroneFo urniEditPart)sel
ectedElement
..getChildBySemanticHint(compartmentSemanticHint);
IElementType type = DescripteurElementTypes.DescripteurPortSynchrone_3010;
//type of new node
ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor(
new CreateElementRequestAdapter(
new CreateElementRequest(type)),
Node.class,
((IHintedType) type).getSemanticHint(),
((IGraphicalEditPart) selectedElement).getDiagramPreferencesHint());
CreateViewAndElementRequest req = new
CreateViewAndElementRequest(viewDescriptor);
CompoundCommand cmd = new CompoundCommand("create item");
ArrayList<String> listService = new ArrayList<String>();
//
CompoundCommand ccOp = new CompoundCommand("Create operation");
IElementType typeOp = DescripteurElementTypes.Operation_3011; //type of new
node
ViewAndElementDescriptor viewDescriptorOp = new ViewAndElementDescriptor(
new CreateElementRequestAdapter(
new CreateElementRequest(typeOp)),
Node.class,
((IHintedType) typeOp).getSemanticHint(),
((IGraphicalEditPart) selectedElement).getDiagramPreferencesHint());
CreateViewAndElementRequest request = new
CreateViewAndElementRequest(viewDescriptorOp);
Command comOp = selectedElement.getParent().getCommand(request);
//
for (Iterator iterator = getTarget().getContenu().iterator();
iterator.hasNext();) {
Interface name = (Interface) iterator.next();
cmd.add(modulesCompartment.getCommand(req));
listService.add(name.getNomService());
//System.out.println("--- interface synchrone="+name.getNomService());
ccOp.add(comOp);
}
//System.out.println("------------ complete create link " + getSource());
// cr
Attachment: example.JPG
(Size: 17.56KB, Downloaded 156 times)
|
|
|
Powered by
FUDForum. Page generated in 0.03008 seconds