Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mdt-uml2tools.dev] Modifying class diagram editor popup menus

Hello,

Sure, it will work. As a side effect though, it will add this popup
menu not only to all elements of all Uml2Tools diagrams (say, to
UseCase diagram actors or to Activity' pins) but also to ANY GMF-based
diagram that will be available in the same workspace. Say, ships,
routes and harbors at the GMF standard sample Taipan will be also
affected.

May be its not a problem, just wanted to make a note :)

Regards,
Michael

On Feb 19, 2008 8:54 AM, Ogechi Nnadi <ogechi.nnadi@xxxxxxxxxx> wrote:
> Thanks, Michael, for your detailed response. Through some
> experimentation, I also found that I could attach a popup menu item to
> all the UML diagram items by simply extending
> org.eclipse.ui.popupMenus and using org.eclipse.gef.EditPart as the
> objectClass of the objectContribution. This obviated the need for
> writing a policy class. I've pasted the relevant fragment from my
> plugin.xml below.
>
> Again, thanks for your help.
>
> Ogechi Nnadi.
>
>
>    <extension
>          point="org.eclipse.ui.popupMenus">
>       <objectContribution
>             id="gmf-practice.objectContribution1"
>             objectClass="org.eclipse.gef.EditPart">
>          <menu
>                id="menu"
>                label="labeleroo"
>                path="additions">
>          </menu>
>          <action
>                class="gmfpractice.Action1"
>                id="gmf-practice.action1"
>                label="contained"
>                menubarPath="menu">
>          </action>
>       </objectContribution>
>    </extension>
>
> 2008/2/14, mdt-uml2tools.dev-request@xxxxxxxxxxx
> <mdt-uml2tools.dev-request@xxxxxxxxxxx>:
> > Send mdt-uml2tools.dev mailing list submissions to
> >         mdt-uml2tools.dev@xxxxxxxxxxx
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://dev.eclipse.org/mailman/listinfo/mdt-uml2tools.dev
> > or, via email, send a message with subject or body 'help' to
> >         mdt-uml2tools.dev-request@xxxxxxxxxxx
> >
> > You can reach the person managing the list at
> >         mdt-uml2tools.dev-owner@xxxxxxxxxxx
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of mdt-uml2tools.dev digest..."
> >
> >
> > Today's Topics:
> >
> >    1. Modifying class diagram editor popup menus (Ogechi Nnadi)
> >    2. Re: Modifying class diagram editor popup menus (Borlander)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Wed, 13 Feb 2008 13:10:42 +0900
> > From: "Ogechi Nnadi" <ogechi.nnadi@xxxxxxxxxx>
> > Subject: [mdt-uml2tools.dev] Modifying class diagram editor popup
> >         menus
> > To: mdt-uml2tools.dev@xxxxxxxxxxx
> > Message-ID:
> >         <13690c9c0802122010g4a3e3679u4ecc9632dc15e654@xxxxxxxxxxxxxx>
> > Content-Type: text/plain; charset=UTF-8
> >
> > Hi,
> >
> > I'm writing an application that adds a popup menu item to the
> > UML2tools class diagram editor so that once you click on the popup
> > menu item, it sends the URI (or the name) of the selected object to
> > the console. Please tell me what extension point to extend from so
> > that I can add the same menu item to the popup menu of all UML
> > objects.
> >
> > In the archives of this list
> > (http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.uml2tools/msg00275.html),
> > a similar question was answered but it didn't say what class the
> > popupStructuredContributionCriteria should inherit from, and what
> > methods needed to be modified.
> >
> > Thanks,
> >
> > Ogechi Nnadi.
> >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Wed, 13 Feb 2008 15:05:30 +0100
> > From: Borlander <borlander@xxxxxxxxx>
> > Subject: Re: [mdt-uml2tools.dev] Modifying class diagram editor popup
> >         menus
> > To: "MDT UML2 Tools mailing list" <mdt-uml2tools.dev@xxxxxxxxxxx>
> > Message-ID:
> >         <606be38e0802130605u7db335e8gdbb01c4dc96abe01@xxxxxxxxxxxxxx>
> > Content-Type: text/plain; charset=ISO-8859-1
>
> >
> > Hello,
> >
> > The structure of the
> > org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders
> > extension point is well defined here:
> > http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/common/ui/services/action/contributionitem/package-summary.html
> >
> > In your case, you may either use the objectClass="<fqn of selected
> > editpart>"' form of this, enumerating the all editpart's classes you
> > want to have the popup. In this case there will be a lot of
> > <contributionItemProviders> elements in your plugin.xml, with
> > objectClass="[oeu2d].clazz.Class2EditPart",
> > objectClass="[oeu2d].clazz.Class3EditPart" and so on. This is probably
> > boring but this way allow you to modify applicability rules without
> > recompilation.
> >
> > If you want this popup to appear for all and any editparts in the
> > class diagram, you have to add approximately 140+ snippets in the
> > plugin.xml, so it does not seem to be a practical way.
> >
> > Thus, I believe that you have to use
> > policyClass="<fqn-of-your-brand-new-class-that-implements-policy-interface>"
> > way.
> > Just write class that implements IPopupMenuContributionPolicy
> > interface, and in the only interface method returns true for selection
> > from class diagram and false otherwise.
> >
> > While implementing the policy you have to do something like the code below
> >
> > public class AllSelectedIsFromClassDiagramPolicy implements
> > IPopupMenuContributionPolicy {
> >
> >         public boolean appliesTo(ISelection selection, IConfigurationElement
> > configuration) {
> >                 if (false == selection instanceof IStructuredSelection){
> >                         return false;
> >                 }
> >                 IStructuredSelection sSel = (IStructuredSelection)selection;
> >                 if (sSel.isEmpty()){
> >                         return false;
> >                 }
> >                 for (Iterator it = sSel.iterator(); it.hasNext();){
> >                         Object next = it.next();
> >                         if (false == next instanceof IGraphicalEditPart){
> >                                 return false;
> >                         }
> >                         IGraphicalEditPart editPart = (IGraphicalEditPart)next;
> >                         if (!isFromClassDiagram(editPart)){
> >                                 return false;
> >                         }
> >                 }
> >                 return true;
> >         }
> >
> >         private static boolean isFromClassDiagram(IGraphicalEditPart ep){
> >                 View notation = ep.getNotationView();
> >                 if (notation == null){
> >                         //strange
> >                         return false;
> >                 }
> >                 return PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(notation));
> >         }
> >
> > }
> >
> > Hope it helps,
> > Regards, ,
> > Michael
> >
> > On Feb 13, 2008 5:10 AM, Ogechi Nnadi <ogechi.nnadi@xxxxxxxxxx> wrote:
> > > Hi,
> > >
> > > I'm writing an application that adds a popup menu item to the
> > > UML2tools class diagram editor so that once you click on the popup
> > > menu item, it sends the URI (or the name) of the selected object to
> > > the console. Please tell me what extension point to extend from so
> > > that I can add the same menu item to the popup menu of all UML
> > > objects.
> > >
> > > In the archives of this list
> > > (http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.uml2tools/msg00275.html),
> > > a similar question was answered but it didn't say what class the
> > > popupStructuredContributionCriteria should inherit from, and what
> > > methods needed to be modified.
> > >
> > > Thanks,
> > >
> > > Ogechi Nnadi.
> > > _______________________________________________
> > > mdt-uml2tools.dev mailing list
> > > mdt-uml2tools.dev@xxxxxxxxxxx
> > > https://dev.eclipse.org/mailman/listinfo/mdt-uml2tools.dev
> > >
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > mdt-uml2tools.dev mailing list
> > mdt-uml2tools.dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/mdt-uml2tools.dev
> >
> >
> > End of mdt-uml2tools.dev Digest, Vol 6, Issue 1
> > ***********************************************
>
> >
> _______________________________________________
> mdt-uml2tools.dev mailing list
> mdt-uml2tools.dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/mdt-uml2tools.dev
>


Back to the top