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.BorderLayout;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Objects; import java.util.Objects;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton; import javax.swing.JButton;
@ -129,11 +131,18 @@ public class SearchBoxPane extends TranslatedVisibleComponent
getContentPane().add(optionPanel, BorderLayout.NORTH); getContentPane().add(optionPanel, BorderLayout.NORTH);
getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER); 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)) //TODO right-click context menu
if (e.isMetaDown())
{
}
else if (e.getButton() == MouseEvent.BUTTON1)
{
if(!(tree.getLastSelectedPathComponent() instanceof LDCSearchTreeNodeResult))
return; return;
LDCSearchTreeNodeResult result = (LDCSearchTreeNodeResult) tree.getLastSelectedPathComponent(); LDCSearchTreeNodeResult result = (LDCSearchTreeNodeResult) tree.getLastSelectedPathComponent();
@ -142,9 +151,6 @@ public class SearchBoxPane extends TranslatedVisibleComponent
BytecodeViewer.viewer.workPane.addClassResource(result.container, name); BytecodeViewer.viewer.workPane.addClassResource(result.container, name);
} }
catch (Exception e)
{
e.printStackTrace();
} }
}); });