What about adding a method to the JMeterComponentModel: isRemovable()
Since most components inherit from AbstractConfigElement, or 
GenericController, etc, a mimimum of files would have to be modified.  I 
think it's also makes for more self-documenting code - it informs developers 
they have to answer this question about their new component.  Perhaps 
Saveable should have been done this way?

-Mike

On Friday 28 September 2001 05:27, you wrote:
> Hi,
>
> I am trying to find the best way to keep a user from removing the Root,
> TestPlan, and WorkBench nodes.  Looking at
> org.apache.jmeter.gui.tree.JMeterTreeListener.generatePopupMenu(), I see
> that the REMOVE menu item is always added to the popup.  I want to add
> logic that determines if we need to add a REMOVE menu item.  I have though
> of several ways and there's one I like
>
> Please give me your feedback on what you think.  Because of the number of
> classses that would need to be updated, I am waiting to hear from you guys
> before going any further with this solution.
>
> PROPOSED SOLUTION
> Nodes that can be saved implement the Saveable interface.  I could create a
> new interface named, "Removable".  Then, use the same "instanceof"
> technique (see code below) that we are using to determine if we display the
> SAVE menu item.  Since all elements except the three special ones noted
> above would need to implement this new interface, that's a lot of classes
> to change. Long-term, this is OK though.
>
> [new version]
>
>  private void generatePopupMenu(JMeterComponentModel comp, int x, int y) {
>   pop = new JPopupMenu();
>   pop.setInvoker(tree);
>   getAddMenu(comp);
>   pop.addSeparator();
>
>   // SAVE menu item
>   if (comp instanceof Saveable) {
>    addSaveMenu(pop);
>   }
>
>   // LOAD menu item
>   addLoadItem(pop);
>
>   // REMOVE menu item  [NEW!!]
>   if (comp instanceof Removable) {
>    addRemoveMenu(pop);
>   }
>
>   pop.validate();
>   pop.setPopupSize(pop.getPreferredSize());
>   pop.show(tree, x, y);
>   pop.setVisible(true);
>   pop.requestFocus();
>  }
>
>
> Thanks,
> kevin
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Mike Stover
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to