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]

Reply via email to