Removed last version of dnd. Added dnd support from weisJ theme. Also, I fixed a problem not being able to scroll when a class is open and switching themes. Not sure if it was happening to just me or not.
This commit is contained in:
parent
e6cdd92bae
commit
c932596d1a
|
@ -116,7 +116,7 @@ public class MainViewerGUI extends JFrame
|
||||||
public final SearchBoxPane searchBoxPane = new SearchBoxPane();
|
public final SearchBoxPane searchBoxPane = new SearchBoxPane();
|
||||||
public JSplitPane splitPane1;
|
public JSplitPane splitPane1;
|
||||||
public JSplitPane splitPane2;
|
public JSplitPane splitPane2;
|
||||||
|
|
||||||
//the root menu bar
|
//the root menu bar
|
||||||
public final JMenuBar rootMenu = new JMenuBar();
|
public final JMenuBar rootMenu = new JMenuBar();
|
||||||
|
|
||||||
|
@ -351,9 +351,12 @@ public class MainViewerGUI extends JFrame
|
||||||
searchBoxPane.setPreferredSize(new Dimension(200, 50));
|
searchBoxPane.setPreferredSize(new Dimension(200, 50));
|
||||||
searchBoxPane.setMinimumSize(new Dimension(200, 50));
|
searchBoxPane.setMinimumSize(new Dimension(200, 50));
|
||||||
searchBoxPane.setMaximumSize(new Dimension(200, 2147483647));
|
searchBoxPane.setMaximumSize(new Dimension(200, 2147483647));
|
||||||
|
|
||||||
|
workPane.setPreferredSize(new Dimension(1500, 1000));
|
||||||
|
|
||||||
splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, resourcePane, searchBoxPane);
|
splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, resourcePane, searchBoxPane);
|
||||||
splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane1, workPane);
|
splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane1, workPane);
|
||||||
|
|
||||||
getContentPane().add(splitPane2);
|
getContentPane().add(splitPane2);
|
||||||
splitPane2.setResizeWeight(0.05);
|
splitPane2.setResizeWeight(0.05);
|
||||||
splitPane1.setResizeWeight(0.5);
|
splitPane1.setResizeWeight(0.5);
|
||||||
|
@ -361,6 +364,7 @@ public class MainViewerGUI extends JFrame
|
||||||
uiComponents.add(resourcePane);
|
uiComponents.add(resourcePane);
|
||||||
uiComponents.add(searchBoxPane);
|
uiComponents.add(searchBoxPane);
|
||||||
uiComponents.add(workPane);
|
uiComponents.add(workPane);
|
||||||
|
// uiComponents.add(hierarchy);
|
||||||
|
|
||||||
viewPane1.setDefault();
|
viewPane1.setDefault();
|
||||||
viewPane2.setDefault();
|
viewPane2.setDefault();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseWheelEvent;
|
||||||
import java.awt.event.MouseWheelListener;
|
import java.awt.event.MouseWheelListener;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
@ -13,6 +14,7 @@ import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
|
|
||||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
|
@ -50,9 +52,9 @@ import the.bytecode.club.bytecodeviewer.util.JTextAreaUtils;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @since 6/25/2021
|
* @since 6/25/2021
|
||||||
*/
|
*/
|
||||||
public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
public class SearchableRSyntaxTextArea extends RSyntaxTextArea {
|
||||||
{
|
|
||||||
private final RTextScrollPane scrollPane = new RTextScrollPane(this);
|
private RTextScrollPane scrollPane = new RTextScrollPane(this);
|
||||||
private final JPanel searchPanel = new JPanel(new BorderLayout());
|
private final JPanel searchPanel = new JPanel(new BorderLayout());
|
||||||
private final JTextField searchInput = new JTextField();
|
private final JTextField searchInput = new JTextField();
|
||||||
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
|
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
|
||||||
|
@ -62,30 +64,26 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
||||||
private final Color blackScrollBackground = new Color(0x232323);
|
private final Color blackScrollBackground = new Color(0x232323);
|
||||||
private final Color blackScrollForeground = new Color(0x575859);
|
private final Color blackScrollForeground = new Color(0x575859);
|
||||||
private Runnable onCtrlS;
|
private Runnable onCtrlS;
|
||||||
|
|
||||||
public SearchableRSyntaxTextArea()
|
public SearchableRSyntaxTextArea() {
|
||||||
{
|
if (Configuration.lafTheme == LAFTheme.HIGH_CONTRAST_DARK) {
|
||||||
if(Configuration.lafTheme == LAFTheme.HIGH_CONTRAST_DARK)
|
|
||||||
{
|
|
||||||
//this fixes the white border on the jScrollBar panes
|
//this fixes the white border on the jScrollBar panes
|
||||||
scrollPane.getHorizontalScrollBar().setBackground(blackScrollBackground);
|
scrollPane.getHorizontalScrollBar().setBackground(blackScrollBackground);
|
||||||
scrollPane.getHorizontalScrollBar().setForeground(blackScrollForeground);
|
scrollPane.getHorizontalScrollBar().setForeground(blackScrollForeground);
|
||||||
scrollPane.getVerticalScrollBar().setBackground(blackScrollBackground);
|
scrollPane.getVerticalScrollBar().setBackground(blackScrollBackground);
|
||||||
scrollPane.getVerticalScrollBar().setForeground(blackScrollForeground);
|
scrollPane.getVerticalScrollBar().setForeground(blackScrollForeground);
|
||||||
}
|
} else if (Configuration.lafTheme.isDark()) {
|
||||||
else if(Configuration.lafTheme.isDark())
|
|
||||||
{
|
|
||||||
//this fixes the white border on the jScrollBar panes
|
//this fixes the white border on the jScrollBar panes
|
||||||
scrollPane.getHorizontalScrollBar().setBackground(darkScrollBackground);
|
scrollPane.getHorizontalScrollBar().setBackground(darkScrollBackground);
|
||||||
scrollPane.getHorizontalScrollBar().setForeground(darkScrollForeground);
|
scrollPane.getHorizontalScrollBar().setForeground(darkScrollForeground);
|
||||||
scrollPane.getVerticalScrollBar().setBackground(darkScrollBackground);
|
scrollPane.getVerticalScrollBar().setBackground(darkScrollBackground);
|
||||||
scrollPane.getVerticalScrollBar().setForeground(darkScrollForeground);
|
scrollPane.getVerticalScrollBar().setForeground(darkScrollForeground);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAntiAliasingEnabled(true);
|
setAntiAliasingEnabled(true);
|
||||||
|
|
||||||
scrollPane.setColumnHeaderView(searchPanel);
|
scrollPane.setColumnHeaderView(searchPanel);
|
||||||
|
|
||||||
JButton searchNext = new JButton();
|
JButton searchNext = new JButton();
|
||||||
JButton searchPrev = new JButton();
|
JButton searchPrev = new JButton();
|
||||||
JPanel buttonPane = new JPanel(new BorderLayout());
|
JPanel buttonPane = new JPanel(new BorderLayout());
|
||||||
|
@ -96,90 +94,84 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
||||||
searchPanel.add(buttonPane, BorderLayout.WEST);
|
searchPanel.add(buttonPane, BorderLayout.WEST);
|
||||||
searchPanel.add(searchInput, BorderLayout.CENTER);
|
searchPanel.add(searchInput, BorderLayout.CENTER);
|
||||||
searchPanel.add(caseSensitiveSearch, BorderLayout.EAST);
|
searchPanel.add(caseSensitiveSearch, BorderLayout.EAST);
|
||||||
|
|
||||||
searchNext.addActionListener(arg0 -> search(searchInput.getText(), true, caseSensitiveSearch.isSelected()));
|
searchNext.addActionListener(arg0 -> search(searchInput.getText(), true, caseSensitiveSearch.isSelected()));
|
||||||
searchPrev.addActionListener(arg0 -> search(searchInput.getText(), false, caseSensitiveSearch.isSelected()));
|
searchPrev.addActionListener(arg0 -> search(searchInput.getText(), false, caseSensitiveSearch.isSelected()));
|
||||||
|
|
||||||
searchInput.addKeyListener(new ReleaseKeyListener(keyEvent ->
|
searchInput.addKeyListener(new ReleaseKeyListener(keyEvent ->
|
||||||
{
|
{
|
||||||
if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER)
|
if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER)
|
||||||
search(searchInput.getText(), true, caseSensitiveSearch.isSelected());
|
search(searchInput.getText(), true, caseSensitiveSearch.isSelected());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
addKeyListener(new PressKeyListener(keyEvent ->
|
addKeyListener(new PressKeyListener(keyEvent ->
|
||||||
{
|
{
|
||||||
if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
|
if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
|
||||||
searchInput.requestFocus();
|
searchInput.requestFocus();
|
||||||
|
|
||||||
if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
|
if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) {
|
||||||
{
|
|
||||||
onCtrlS.run();
|
onCtrlS.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalHotKeys.keyPressed(keyEvent);
|
GlobalHotKeys.keyPressed(keyEvent);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
final Font newFont = getFont().deriveFont((float) BytecodeViewer.viewer.getFontSize());
|
final Font newFont = getFont().deriveFont((float) BytecodeViewer.viewer.getFontSize());
|
||||||
|
|
||||||
//set number-bar font
|
//set number-bar font
|
||||||
setFont(newFont);
|
setFont(newFont);
|
||||||
|
|
||||||
SwingUtilities.invokeLater(()-> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
//attach CTRL + Mouse Wheel Zoom
|
//attach CTRL + Mouse Wheel Zoom
|
||||||
attachCtrlMouseWheelZoom();
|
attachCtrlMouseWheelZoom();
|
||||||
|
|
||||||
//set text font
|
//set text font
|
||||||
setFont(newFont);
|
setFont(newFont);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void search(String search, boolean forwardSearchDirection, boolean caseSensitiveSearch)
|
public void search(String search, boolean forwardSearchDirection, boolean caseSensitiveSearch) {
|
||||||
{
|
|
||||||
JTextAreaUtils.search(this, search, forwardSearchDirection, caseSensitiveSearch);
|
JTextAreaUtils.search(this, search, forwardSearchDirection, caseSensitiveSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void highlight(String pattern, boolean caseSensitiveSearch)
|
public void highlight(String pattern, boolean caseSensitiveSearch) {
|
||||||
{
|
|
||||||
JTextAreaUtils.highlight(this, pattern, caseSensitiveSearch);
|
JTextAreaUtils.highlight(this, pattern, caseSensitiveSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCtrlMouseWheelZoom()
|
public void attachCtrlMouseWheelZoom() {
|
||||||
{
|
scrollPane.addMouseWheelListener(e -> {
|
||||||
//get the existing scroll event
|
if (getText().isEmpty()) return;
|
||||||
MouseWheelListener ogListener = scrollPane.getMouseWheelListeners().length > 0 ?
|
if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
|
||||||
scrollPane.getMouseWheelListeners()[0] : null;
|
|
||||||
|
|
||||||
//remove the existing event
|
|
||||||
if(ogListener != null)
|
|
||||||
scrollPane.removeMouseWheelListener(ogListener);
|
|
||||||
|
|
||||||
//add a new event
|
|
||||||
scrollPane.addMouseWheelListener(e ->
|
|
||||||
{
|
|
||||||
if (getText().isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0)
|
|
||||||
{
|
|
||||||
Font font = getFont();
|
Font font = getFont();
|
||||||
int size = font.getSize();
|
int size = font.getSize();
|
||||||
|
if (e.getWheelRotation() > 0)
|
||||||
if (e.getWheelRotation() > 0) //Up
|
|
||||||
setFont(new Font(font.getName(), font.getStyle(), --size >= 2 ? --size : 2));
|
setFont(new Font(font.getName(), font.getStyle(), --size >= 2 ? --size : 2));
|
||||||
else //Down
|
else
|
||||||
setFont(new Font(font.getName(), font.getStyle(), ++size));
|
setFont(new Font(font.getName(), font.getStyle(), ++size));
|
||||||
|
|
||||||
e.consume();
|
e.consume();
|
||||||
}
|
}
|
||||||
else if(ogListener != null)
|
|
||||||
{
|
|
||||||
ogListener.mouseWheelMoved(e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scrollPane = new RTextScrollPane() {
|
||||||
|
@Override
|
||||||
|
protected void processMouseWheelEvent(MouseWheelEvent event) {
|
||||||
|
if (!isWheelScrollingEnabled()) {
|
||||||
|
if (getParent() != null) {
|
||||||
|
getParent().dispatchEvent(SwingUtilities.convertMouseEvent(this, event, getParent()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.processMouseWheelEvent(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
scrollPane.setWheelScrollingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLineText(int line) {
|
public String getLineText(int line) {
|
||||||
try {
|
try {
|
||||||
if (line < getLineCount()) {
|
if (line < getLineCount()) {
|
||||||
|
@ -187,42 +179,36 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
||||||
int end = getLineEndOffset(line);
|
int end = getLineEndOffset(line);
|
||||||
return getText(start, end - start).trim();
|
return getText(start, end - start).trim();
|
||||||
}
|
}
|
||||||
} catch (BadLocationException ignored) { }
|
} catch (BadLocationException ignored) {
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnCtrlS(Runnable onCtrlS)
|
public void setOnCtrlS(Runnable onCtrlS) {
|
||||||
{
|
|
||||||
this.onCtrlS = onCtrlS;
|
this.onCtrlS = onCtrlS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RTextScrollPane getScrollPane()
|
public RTextScrollPane getScrollPane() {
|
||||||
{
|
|
||||||
return scrollPane;
|
return scrollPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getSearchPanel()
|
public JPanel getSearchPanel() {
|
||||||
{
|
|
||||||
return searchPanel;
|
return searchPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JTextField getSearchInput()
|
public JTextField getSearchInput() {
|
||||||
{
|
|
||||||
return searchInput;
|
return searchInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JCheckBox getCaseSensitiveSearch()
|
public JCheckBox getCaseSensitiveSearch() {
|
||||||
{
|
|
||||||
return caseSensitiveSearch;
|
return caseSensitiveSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JLabel getTitleHeader()
|
public JLabel getTitleHeader() {
|
||||||
{
|
|
||||||
return titleHeader;
|
return titleHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Runnable getOnCtrlS()
|
public Runnable getOnCtrlS() {
|
||||||
{
|
|
||||||
return onCtrlS;
|
return onCtrlS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue