Fix [1772490] - Popup menu in VTreePanel finally works as expected
https://sourceforge.net/tracker/?func=detail&atid=879335&aid=1772490&group_id=176962 Thanks to igor_adempiere and felixmoeller
This commit is contained in:
parent
77bcd953c6
commit
2067987bcc
|
@ -317,6 +317,7 @@ public final class AMenu extends CFrame
|
||||||
mainLayout.setVgap(2);
|
mainLayout.setVgap(2);
|
||||||
//
|
//
|
||||||
treePanel.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
|
treePanel.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
|
||||||
|
treePanel.addPropertyChangeListener(VTreePanel.NODE_SELECTION_RIGHT, this);
|
||||||
//
|
//
|
||||||
infoPanel.setLayout(infoLayout);
|
infoPanel.setLayout(infoLayout);
|
||||||
infoLayout.setColumns(2);
|
infoLayout.setColumns(2);
|
||||||
|
@ -574,6 +575,12 @@ public final class AMenu extends CFrame
|
||||||
*/
|
*/
|
||||||
public void propertyChange(PropertyChangeEvent e)
|
public void propertyChange(PropertyChangeEvent e)
|
||||||
{
|
{
|
||||||
|
if(e.getPropertyName().equals(VTreePanel.NODE_SELECTION_RIGHT)){
|
||||||
|
MTreeNode nd = (MTreeNode)e.getNewValue();
|
||||||
|
progressBar.setString(nd.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MTreeNode nd = (MTreeNode)e.getNewValue();
|
MTreeNode nd = (MTreeNode)e.getNewValue();
|
||||||
log.info(nd.getNode_ID() + " - " + nd.toString());
|
log.info(nd.getNode_ID() + " - " + nd.toString());
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ import de.schaeffer.compiere.tools.DocumentSearch;
|
||||||
/**
|
/**
|
||||||
* Tree Panel displays trees.
|
* Tree Panel displays trees.
|
||||||
* <br>
|
* <br>
|
||||||
* When a node is selected, a propertyChange (NODE_SELECTION) event is fired
|
* When a node is selected by Left Click, a propertyChange (NODE_SELECTION) event is fired
|
||||||
* <pre>
|
* <pre>
|
||||||
* PropertyChangeListener -
|
* PropertyChangeListener -
|
||||||
* treePanel.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
|
* treePanel.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
|
||||||
|
@ -362,8 +362,10 @@ public final class VTreePanel extends CPanel
|
||||||
|
|
||||||
private JScrollPane barScrollPane;
|
private JScrollPane barScrollPane;
|
||||||
|
|
||||||
/** Property Listener NodeSelected */
|
/** Property Listener NodeSelected by Left Click */
|
||||||
public static final String NODE_SELECTION = "NodeSelected";
|
public static final String NODE_SELECTION = "NodeSelected";
|
||||||
|
/** Property Listener NodeSelected by Right Click */
|
||||||
|
public static final String NODE_SELECTION_RIGHT = "NodeSelectedRight";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static Component initialization.
|
* Static Component initialization.
|
||||||
|
@ -443,8 +445,10 @@ public final class VTreePanel extends CPanel
|
||||||
//
|
//
|
||||||
popMenuTree.setLightWeightPopupEnabled(false);
|
popMenuTree.setLightWeightPopupEnabled(false);
|
||||||
popMenuTree.add(mBarAdd);
|
popMenuTree.add(mBarAdd);
|
||||||
popMenuTree.addSeparator();
|
|
||||||
popMenuTree.add(mFrom);
|
popMenuTree.add(mFrom);
|
||||||
|
if(!m_hasBar){
|
||||||
|
popMenuTree.addSeparator();
|
||||||
|
}
|
||||||
popMenuTree.add(mTo);
|
popMenuTree.add(mTo);
|
||||||
popMenuBar.setLightWeightPopupEnabled(false);
|
popMenuBar.setLightWeightPopupEnabled(false);
|
||||||
popMenuBar.add(mBarRemove);
|
popMenuBar.add(mBarRemove);
|
||||||
|
@ -811,11 +815,21 @@ public final class VTreePanel extends CPanel
|
||||||
&& SwingUtilities.isRightMouseButton(e)
|
&& SwingUtilities.isRightMouseButton(e)
|
||||||
&& tree.getSelectionPath() != null) // need select first
|
&& tree.getSelectionPath() != null) // need select first
|
||||||
{
|
{
|
||||||
// MTreeNode nd = (MTreeNode)tree.getSelectionPath().getLastPathComponent();
|
int selRow = tree.getRowForLocation(e.getX(), e.getY());
|
||||||
// if (nd.isLeaf()) // only leaves
|
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
|
||||||
{
|
if(selRow != -1){
|
||||||
|
tree.setSelectionPath(selPath);
|
||||||
|
|
||||||
Rectangle r = tree.getPathBounds(tree.getSelectionPath());
|
Rectangle r = tree.getPathBounds(tree.getSelectionPath());
|
||||||
|
if(r!=null){
|
||||||
popMenuTree.show(tree, (int)r.getMaxX(), (int)r.getY());
|
popMenuTree.show(tree, (int)r.getMaxX(), (int)r.getY());
|
||||||
|
}else{
|
||||||
|
popMenuTree.show(tree, e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
if(m_hasBar){
|
||||||
|
MTreeNode nd = (MTreeNode)tree.getSelectionPath().getLastPathComponent();
|
||||||
|
firePropertyChange(NODE_SELECTION_RIGHT, null, nd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // JTree
|
} // JTree
|
||||||
|
|
Loading…
Reference in New Issue