Fixed Search Tree Selection

The search box tree selection now functions the same as the resource list tree
This commit is contained in:
Konloch 2021-07-29 19:37:05 -07:00
parent f4c0e71475
commit d95b9d0158

View file

@ -3,6 +3,8 @@ package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Objects;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
@ -129,22 +131,26 @@ public class SearchBoxPane extends TranslatedVisibleComponent
getContentPane().add(optionPanel, BorderLayout.NORTH);
getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
this.tree.addTreeSelectionListener(selectionEvent ->
tree.addMouseListener(new MouseAdapter()
{
try
@Override
public void mouseReleased(MouseEvent e)
{
if (selectionEvent.getPath().getPathComponent(0).equals(TranslatedStrings.RESULTS))
return;
//TODO right-click context menu
if (e.isMetaDown())
{
}
else if (e.getButton() == MouseEvent.BUTTON1)
{
if(!(tree.getLastSelectedPathComponent() instanceof LDCSearchTreeNodeResult))
return;
LDCSearchTreeNodeResult result = (LDCSearchTreeNodeResult) tree.getLastSelectedPathComponent();
LDCSearchTreeNodeResult result = (LDCSearchTreeNodeResult) tree.getLastSelectedPathComponent();
final String name = result.resourceWorkingName;
final String name = result.resourceWorkingName;
BytecodeViewer.viewer.workPane.addClassResource(result.container, name);
}
catch (Exception e)
{
e.printStackTrace();
BytecodeViewer.viewer.workPane.addClassResource(result.container, name);
}
}
});