|
Re: How to change the method selectionChanged(IAction action, ISelection selection) [message #1014801 is a reply to message #1014744] |
Tue, 26 February 2013 13:36 |
|
Hi,
Command handlers get the selection from the HandlerUtil utility API.
For example,
ISelection HandlerUtil::getCurrentSelection(ExecutionEvent event)
Is this what you're asking?
Christian
On 2013-02-26 11:35:32 +0000, Mariem Makni said:
> Hi,
>
> I'm doing a project using the Plug-in papyrus Marte in eclipse, I add a
> popup menu
> named "named import platform" using commands and Handlers in the view
> of the Model
> Explorer when creating a papyrus Model.
>
> I want to change the method selectionChanged(IAction action, ISelection
> selection) to
> be used by commands and handlers not with actions.
>
> public void selectionChanged(IAction action, ISelection selection) {
>
> // the action is enabled only on UML packages stereotyped
> // GaAnalysisContext
> action.setEnabled(false);
>
> // set the current selection
> IStructuredSelection sselection = (IStructuredSelection) selection;
> mySelection = sselection;
>
> // look for selected Element
> Object e = ((IStructuredSelection) selection).getFirstElement();
>
> // set the editing domain
> editDomain = EditorUtils.getTransactionalEditingDomain();
> System.err.println(editDomain);
>
> if (e instanceof IUMLNamedElementEditPart) {
> Element element = ((IUMLNamedElementEditPart) e).getUMLElement();
> if (element instanceof Package
> && element
> .isStereotypeApplied(((Package) element)
>
> .getApplicableStereotype("MARTE::MARTE_AnalysisModel::GQAM::GaAnalysisContext")))
> {
> if ((Package) element.getEAnnotation("annotation") != null) {
> action.setEnabled(true);
> selectedPackage = (Package) element;
> }
> }
> }
>
> else if (e instanceof ModelElementItem) {
> EObject eObj = ((ModelElementItem) e).getEObject();
> if (eObj instanceof Package
> && ((Package) eObj)
> .isStereotypeApplied(((Package) eObj)
>
> .getApplicableStereotype("MARTE::MARTE_AnalysisModel::GQAM::GaAnalysisContext")))
> {
> // if (((Package)eObj).getEAnnotation("annotation")!=null){
> action.setEnabled(true);
> selectedPackage = (Package) eObj;
> // }
> }
> }
> }
>
> If you have some link or if you can advise me I would appreciate.
>
> Thanks in advance.
>
> Best Regards
|
|
|
Powered by
FUDForum. Page generated in 0.02709 seconds