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
2 changed files with 75 additions and 85 deletions
|
@ -352,8 +352,11 @@ public class MainViewerGUI extends JFrame
|
|||
searchBoxPane.setMinimumSize(new Dimension(200, 50));
|
||||
searchBoxPane.setMaximumSize(new Dimension(200, 2147483647));
|
||||
|
||||
workPane.setPreferredSize(new Dimension(1500, 1000));
|
||||
|
||||
splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, resourcePane, searchBoxPane);
|
||||
splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane1, workPane);
|
||||
|
||||
getContentPane().add(splitPane2);
|
||||
splitPane2.setResizeWeight(0.05);
|
||||
splitPane1.setResizeWeight(0.5);
|
||||
|
@ -361,6 +364,7 @@ public class MainViewerGUI extends JFrame
|
|||
uiComponents.add(resourcePane);
|
||||
uiComponents.add(searchBoxPane);
|
||||
uiComponents.add(workPane);
|
||||
// uiComponents.add(hierarchy);
|
||||
|
||||
viewPane1.setDefault();
|
||||
viewPane2.setDefault();
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.awt.Color;
|
|||
import java.awt.Font;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
|
@ -13,6 +14,7 @@ import javax.swing.JPanel;
|
|||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.BadLocationException;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
|
@ -50,9 +52,9 @@ import the.bytecode.club.bytecodeviewer.util.JTextAreaUtils;
|
|||
* @author Konloch
|
||||
* @since 6/25/2021
|
||||
*/
|
||||
public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
||||
{
|
||||
private final RTextScrollPane scrollPane = new RTextScrollPane(this);
|
||||
public class SearchableRSyntaxTextArea extends RSyntaxTextArea {
|
||||
|
||||
private RTextScrollPane scrollPane = new RTextScrollPane(this);
|
||||
private final JPanel searchPanel = new JPanel(new BorderLayout());
|
||||
private final JTextField searchInput = new JTextField();
|
||||
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
|
||||
|
@ -63,18 +65,14 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
|||
private final Color blackScrollForeground = new Color(0x575859);
|
||||
private Runnable onCtrlS;
|
||||
|
||||
public SearchableRSyntaxTextArea()
|
||||
{
|
||||
if(Configuration.lafTheme == LAFTheme.HIGH_CONTRAST_DARK)
|
||||
{
|
||||
public SearchableRSyntaxTextArea() {
|
||||
if (Configuration.lafTheme == LAFTheme.HIGH_CONTRAST_DARK) {
|
||||
//this fixes the white border on the jScrollBar panes
|
||||
scrollPane.getHorizontalScrollBar().setBackground(blackScrollBackground);
|
||||
scrollPane.getHorizontalScrollBar().setForeground(blackScrollForeground);
|
||||
scrollPane.getVerticalScrollBar().setBackground(blackScrollBackground);
|
||||
scrollPane.getVerticalScrollBar().setForeground(blackScrollForeground);
|
||||
}
|
||||
else if(Configuration.lafTheme.isDark())
|
||||
{
|
||||
} else if (Configuration.lafTheme.isDark()) {
|
||||
//this fixes the white border on the jScrollBar panes
|
||||
scrollPane.getHorizontalScrollBar().setBackground(darkScrollBackground);
|
||||
scrollPane.getHorizontalScrollBar().setForeground(darkScrollForeground);
|
||||
|
@ -111,8 +109,7 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
|||
if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +122,7 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
|||
//set number-bar font
|
||||
setFont(newFont);
|
||||
|
||||
SwingUtilities.invokeLater(()-> {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
//attach CTRL + Mouse Wheel Zoom
|
||||
attachCtrlMouseWheelZoom();
|
||||
|
||||
|
@ -135,49 +132,44 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
|||
|
||||
}
|
||||
|
||||
public void search(String search, boolean forwardSearchDirection, boolean caseSensitiveSearch)
|
||||
{
|
||||
public void search(String search, boolean forwardSearchDirection, boolean 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);
|
||||
}
|
||||
|
||||
public void attachCtrlMouseWheelZoom()
|
||||
{
|
||||
//get the existing scroll event
|
||||
MouseWheelListener ogListener = scrollPane.getMouseWheelListeners().length > 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)
|
||||
{
|
||||
public void attachCtrlMouseWheelZoom() {
|
||||
scrollPane.addMouseWheelListener(e -> {
|
||||
if (getText().isEmpty()) return;
|
||||
if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
|
||||
Font font = getFont();
|
||||
int size = font.getSize();
|
||||
|
||||
if (e.getWheelRotation() > 0) //Up
|
||||
if (e.getWheelRotation() > 0)
|
||||
setFont(new Font(font.getName(), font.getStyle(), --size >= 2 ? --size : 2));
|
||||
else //Down
|
||||
else
|
||||
setFont(new Font(font.getName(), font.getStyle(), ++size));
|
||||
|
||||
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) {
|
||||
|
@ -187,42 +179,36 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
|||
int end = getLineEndOffset(line);
|
||||
return getText(start, end - start).trim();
|
||||
}
|
||||
} catch (BadLocationException ignored) { }
|
||||
} catch (BadLocationException ignored) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setOnCtrlS(Runnable onCtrlS)
|
||||
{
|
||||
public void setOnCtrlS(Runnable onCtrlS) {
|
||||
this.onCtrlS = onCtrlS;
|
||||
}
|
||||
|
||||
public RTextScrollPane getScrollPane()
|
||||
{
|
||||
public RTextScrollPane getScrollPane() {
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
public JPanel getSearchPanel()
|
||||
{
|
||||
public JPanel getSearchPanel() {
|
||||
return searchPanel;
|
||||
}
|
||||
|
||||
public JTextField getSearchInput()
|
||||
{
|
||||
public JTextField getSearchInput() {
|
||||
return searchInput;
|
||||
}
|
||||
|
||||
public JCheckBox getCaseSensitiveSearch()
|
||||
{
|
||||
public JCheckBox getCaseSensitiveSearch() {
|
||||
return caseSensitiveSearch;
|
||||
}
|
||||
|
||||
public JLabel getTitleHeader()
|
||||
{
|
||||
public JLabel getTitleHeader() {
|
||||
return titleHeader;
|
||||
}
|
||||
|
||||
public Runnable getOnCtrlS()
|
||||
{
|
||||
public Runnable getOnCtrlS() {
|
||||
return onCtrlS;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue