Improved Tab Titles

This commit is contained in:
Konloch 2021-06-25 20:33:06 -07:00
parent 357067b8de
commit f5f510a2e0
24 changed files with 328 additions and 241 deletions

View file

@ -645,6 +645,8 @@ public class MainViewerGUI extends JFrame {
showFileInTabTitle.setSelected(false); showFileInTabTitle.setSelected(false);
showClassMethods.setSelected(false); showClassMethods.setSelected(false);
simplifyNameInTabTitle.setEnabled(true);
moveAllClassesIntoRoot.setEnabled(false); moveAllClassesIntoRoot.setEnabled(false);
controlFlow.setEnabled(false); controlFlow.setEnabled(false);
junkCode.setEnabled(false); junkCode.setEnabled(false);

View file

@ -5,6 +5,24 @@ import java.awt.*;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/25/2021 * @since 6/25/2021

View file

@ -4,6 +4,24 @@ import the.bytecode.club.bytecodeviewer.util.RefreshWorkPane;
import javax.swing.*; import javax.swing.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/21/2021 * @since 6/21/2021

View file

@ -3,6 +3,24 @@ package the.bytecode.club.bytecodeviewer.gui.components;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* Display an image on a JLabel element * Display an image on a JLabel element
* *

View file

@ -5,6 +5,24 @@ import the.bytecode.club.bytecodeviewer.Resources;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* A simple swing JFrame console * A simple swing JFrame console
* *

View file

@ -4,6 +4,24 @@ import java.io.PrintStream;
import static the.bytecode.club.bytecodeviewer.Constants.nl; import static the.bytecode.club.bytecodeviewer.Constants.nl;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* A swing console that can print out from PrintStreams * A swing console that can print out from PrintStreams
* *

View file

@ -4,6 +4,24 @@ import javax.swing.*;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/21/2021 * @since 6/21/2021

View file

@ -3,6 +3,24 @@ package the.bytecode.club.bytecodeviewer.gui.components;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/25/2021 * @since 6/25/2021

View file

@ -6,6 +6,24 @@ import the.bytecode.club.bytecodeviewer.util.MethodParser;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @author Waterwolf * @author Waterwolf

View file

@ -10,6 +10,24 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* Searching on a JTextArea using swing highlighting * Searching on a JTextArea using swing highlighting
* *

View file

@ -12,6 +12,24 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* Searching on an RSyntaxTextArea using swing highlighting * Searching on an RSyntaxTextArea using swing highlighting
* *

View file

@ -1,26 +1,5 @@
package the.bytecode.club.bytecodeviewer.gui.components; package the.bytecode.club.bytecodeviewer.gui.components;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.PrintStream;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import static the.bytecode.club.bytecodeviewer.Constants.*;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *

View file

@ -1,8 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.components; package the.bytecode.club.bytecodeviewer.gui.components;
import javax.swing.JInternalFrame; import javax.swing.JInternalFrame;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.util.FileContainer;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -28,6 +26,7 @@ import the.bytecode.club.bytecodeviewer.util.FileContainer;
* @author Konloch * @author Konloch
* @author WaterWolf * @author WaterWolf
*/ */
public abstract class VisibleComponent extends JInternalFrame public abstract class VisibleComponent extends JInternalFrame
{ {
private static final long serialVersionUID = -6453413772343643526L; private static final long serialVersionUID = -6453413772343643526L;

View file

@ -2,6 +2,24 @@ package the.bytecode.club.bytecodeviewer.gui.components.listeners;
import java.awt.event.*; import java.awt.event.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/25/2021 * @since 6/25/2021

View file

@ -3,6 +3,24 @@ package the.bytecode.club.bytecodeviewer.gui.components.listeners;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/25/2021 * @since 6/25/2021

View file

@ -3,6 +3,24 @@ package the.bytecode.club.bytecodeviewer.gui.components.listeners;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/25/2021 * @since 6/25/2021

View file

@ -13,6 +13,24 @@ import the.bytecode.club.bytecodeviewer.gui.util.PaneUpdaterThread;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/24/2021 * @since 6/24/2021

View file

@ -161,11 +161,6 @@ public class WorkPaneMainComponent extends VisibleComponent
{ {
String workingName = container.name + ">" + name; String workingName = container.name + ">" + name;
if (Configuration.simplifiedTabNames)
name = MiscUtils.getChildFromPath(name);
if (Configuration.displayParentInTab)
name = container.name + ">" + name;
if (!workingOn.containsKey(workingName)) if (!workingOn.containsKey(workingName))
{ {
final ClassViewer tabComp = new ClassViewer(container, name, cn, workingName); final ClassViewer tabComp = new ClassViewer(container, name, cn, workingName);
@ -191,10 +186,10 @@ public class WorkPaneMainComponent extends VisibleComponent
final String workingName = container.name + ">" + name; final String workingName = container.name + ">" + name;
if (Configuration.simplifiedTabNames) /*if (Configuration.simplifiedTabNames)
name = MiscUtils.getChildFromPath(name); name = MiscUtils.getChildFromPath(name);
if (Configuration.displayParentInTab) if (Configuration.displayParentInTab)
name = container.name + ">" + name; name = container.name + ">" + name;*/
if (!workingOn.containsKey(workingName)) if (!workingOn.containsKey(workingName))
{ {

View file

@ -5,8 +5,6 @@ import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourceViewPanel;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane;
import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor; import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Point; import java.awt.Point;
@ -22,12 +20,8 @@ import javax.swing.JSplitPane;
import javax.swing.JViewport; import javax.swing.JViewport;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rtextarea.RTextScrollPane;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -65,8 +59,6 @@ import static the.bytecode.club.bytecodeviewer.util.MethodParser.Method;
public class ClassViewer extends ResourceViewer public class ClassViewer extends ResourceViewer
{ {
private static final long serialVersionUID = -8650495368920680024L;
public String name;
public JSplitPane sp; public JSplitPane sp;
public JSplitPane sp2; public JSplitPane sp2;
public TabbedPane tabbedPane; public TabbedPane tabbedPane;
@ -78,183 +70,6 @@ public class ClassViewer extends ResourceViewer
public ClassViewer THIS = this; public ClassViewer THIS = this;
public List<MethodParser> methods = Arrays.asList(new MethodParser(), new MethodParser(), new MethodParser()); public List<MethodParser> methods = Arrays.asList(new MethodParser(), new MethodParser(), new MethodParser());
public final String workingName; public final String workingName;
private final DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255, 62, 150));
/**
* This was really interesting to write.
*
* @author Konloch
*/
public void search(int pane, String search, boolean next)
{
try
{
Component[] com = null;
if (pane == 0) // bytecode
com = resourceViewPanel1.panel.getComponents();
else if (pane == 1)
com = resourceViewPanel2.panel.getComponents();
else if (pane == 2)
com = resourceViewPanel3.panel.getComponents();
if (com == null) // someone fucked up, lets prevent a nullpointer.
return;
for (Component c : com)
{
if (c instanceof RTextScrollPane)
{
RSyntaxTextArea area = (RSyntaxTextArea) ((RTextScrollPane) c).getViewport().getComponent(0);
if (search.isEmpty())
{
highlight(pane, area, "");
return;
}
int startLine = area.getDocument().getDefaultRootElement()
.getElementIndex(area.getCaretPosition()) + 1;
int currentLine = 1;
boolean canSearch = false;
String[] test = (area.getText().split("\n").length >= 2
? area.getText().split("\n")
: area.getText().split("\r"));
int lastGoodLine = -1;
int firstPos = -1;
boolean found = false;
if (next)
{
for (String s : test)
{
if (pane == 0 && !resourceViewPanel1.textArea.getCaseSensitiveSearch().isSelected() ||
pane == 1 && !resourceViewPanel2.textArea.getCaseSensitiveSearch().isSelected())
{
//TODO should pane2 be here? - look into this later
s = s.toLowerCase();
search = search.toLowerCase();
}
if (currentLine == startLine)
{
canSearch = true;
}
else if (s.contains(search))
{
if (canSearch)
{
area.setCaretPosition(area.getDocument()
.getDefaultRootElement()
.getElement(currentLine - 1)
.getStartOffset());
canSearch = false;
found = true;
}
if (firstPos == -1)
firstPos = currentLine;
}
currentLine++;
}
if (!found && firstPos != -1)
{
area.setCaretPosition(area.getDocument()
.getDefaultRootElement()
.getElement(firstPos - 1).getStartOffset());
}
}
else
{
canSearch = true;
for (String s : test)
{
if (pane == 0 && !resourceViewPanel1.textArea.getCaseSensitiveSearch().isSelected() || pane == 1
&& !resourceViewPanel2.textArea.getCaseSensitiveSearch().isSelected() || pane == 2
&& !resourceViewPanel3.textArea.getCaseSensitiveSearch().isSelected())
{
s = s.toLowerCase();
search = search.toLowerCase();
}
if (s.contains(search))
{
if (lastGoodLine != -1 && canSearch)
area.setCaretPosition(area.getDocument()
.getDefaultRootElement()
.getElement(lastGoodLine - 1)
.getStartOffset());
lastGoodLine = currentLine;
if (currentLine >= startLine)
canSearch = false;
}
currentLine++;
}
if (lastGoodLine != -1
&& area.getDocument()
.getDefaultRootElement()
.getElementIndex(area.getCaretPosition()) + 1 == startLine)
{
area.setCaretPosition(area.getDocument()
.getDefaultRootElement()
.getElement(lastGoodLine - 1)
.getStartOffset());
}
}
highlight(pane, area, search);
}
}
}
catch (Exception e)
{
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
public void highlight(int pane, JTextComponent textComp, String pattern)
{
if (pattern.isEmpty())
{
textComp.getHighlighter().removeAllHighlights();
return;
}
try
{
Highlighter hilite = textComp.getHighlighter();
hilite.removeAllHighlights();
javax.swing.text.Document doc = textComp.getDocument();
String text = doc.getText(0, doc.getLength());
int pos = 0;
if ((pane == 0 && !resourceViewPanel1.textArea.getCaseSensitiveSearch().isSelected()) || pane == 1
&& !resourceViewPanel2.textArea.getCaseSensitiveSearch().isSelected() || pane == 2
&& !resourceViewPanel3.textArea.getCaseSensitiveSearch().isSelected())
{
pattern = pattern.toLowerCase();
text = text.toLowerCase();
}
// Search for pattern
while ((pos = text.indexOf(pattern, pos)) >= 0)
{
// Create highlighter using private painter and apply around
// pattern
hilite.addHighlight(pos, pos + pattern.length(), painter);
pos += pattern.length();
}
}
catch (Exception e)
{
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
public ClassViewer(final FileContainer container, final String name, final ClassNode cn, String workingName) public ClassViewer(final FileContainer container, final String name, final ClassNode cn, String workingName)
{ {
@ -285,7 +100,8 @@ public class ClassViewer extends ResourceViewer
}); });
} }
public void resetDivider() { public void resetDivider()
{
SwingUtilities.invokeLater(() -> SwingUtilities.invokeLater(() ->
{ {
sp.setResizeWeight(0.5); sp.setResizeWeight(0.5);
@ -323,6 +139,8 @@ public class ClassViewer extends ResourceViewer
this.cn = BytecodeViewer.getClassNode(container, cn.name); //update the classnode this.cn = BytecodeViewer.getClassNode(container, cn.name); //update the classnode
setPanes(); setPanes();
refreshTitle();
resourceViewPanel1.createPane(this); resourceViewPanel1.createPane(this);
resourceViewPanel2.createPane(this); resourceViewPanel2.createPane(this);
resourceViewPanel3.createPane(this); resourceViewPanel3.createPane(this);
@ -386,7 +204,15 @@ public class ClassViewer extends ResourceViewer
} }
} }
public Object[] getSmali() { @Override
public void refreshTitle()
{
if(tabbedPane != null)
tabbedPane.label.setText(getTabName());
}
public Object[] getSmali()
{
if (resourceViewPanel1.compileMode == ResourcePanelCompileMode.SMALI_ASSEMBLY) if (resourceViewPanel1.compileMode == ResourcePanelCompileMode.SMALI_ASSEMBLY)
return new Object[]{cn, resourceViewPanel1.textArea.getText()}; return new Object[]{cn, resourceViewPanel1.textArea.getText()};
if (resourceViewPanel2.compileMode == ResourcePanelCompileMode.SMALI_ASSEMBLY) if (resourceViewPanel2.compileMode == ResourcePanelCompileMode.SMALI_ASSEMBLY)
@ -397,7 +223,8 @@ public class ClassViewer extends ResourceViewer
return null; return null;
} }
public Object[] getKrakatau() { public Object[] getKrakatau()
{
if (resourceViewPanel1.compileMode == ResourcePanelCompileMode.KRAKATAU_ASSEMBLY) if (resourceViewPanel1.compileMode == ResourcePanelCompileMode.KRAKATAU_ASSEMBLY)
return new Object[]{cn, resourceViewPanel1.textArea.getText()}; return new Object[]{cn, resourceViewPanel1.textArea.getText()};
if (resourceViewPanel2.compileMode == ResourcePanelCompileMode.KRAKATAU_ASSEMBLY) if (resourceViewPanel2.compileMode == ResourcePanelCompileMode.KRAKATAU_ASSEMBLY)
@ -408,7 +235,8 @@ public class ClassViewer extends ResourceViewer
return null; return null;
} }
public Object[] getJava() { public Object[] getJava()
{
if (resourceViewPanel1.textArea != null) if (resourceViewPanel1.textArea != null)
return new Object[]{cn, resourceViewPanel1.textArea.getText()}; return new Object[]{cn, resourceViewPanel1.textArea.getText()};
if (resourceViewPanel2.textArea != null) if (resourceViewPanel2.textArea != null)
@ -566,4 +394,6 @@ public class ClassViewer extends ResourceViewer
area.setCaretPosition(area.getLineStartOffset(line)); area.setCaretPosition(area.getLineStartOffset(line));
} catch (BadLocationException ignored) { } } catch (BadLocationException ignored) { }
} }
private static final long serialVersionUID = -8650495368920680024L;
} }

View file

@ -82,6 +82,8 @@ public class FileViewer extends ResourceViewer
final String nameLowerCase = this.name.toLowerCase(); final String nameLowerCase = this.name.toLowerCase();
final String contentsAsString = new String(contents); final String contentsAsString = new String(contents);
refreshTitle();
//image viewer //image viewer
if (!MiscUtils.isPureAscii(contentsAsString)) if (!MiscUtils.isPureAscii(contentsAsString))
{ {
@ -126,6 +128,13 @@ public class FileViewer extends ResourceViewer
mainPanel.add(textArea.getScrollPane()); mainPanel.add(textArea.getScrollPane());
} }
@Override
public void refreshTitle()
{
if(tabbedPane != null)
tabbedPane.label.setText(getTabName());
}
public void refresh(JButton src) public void refresh(JButton src)
{ {
if (!canRefresh) if (!canRefresh)
@ -142,6 +151,8 @@ public class FileViewer extends ResourceViewer
mainPanel.add(label, BorderLayout.CENTER); mainPanel.add(label, BorderLayout.CENTER);
mainPanel.updateUI(); mainPanel.updateUI();
refreshTitle();
src.setEnabled(true); src.setEnabled(true);
} }

View file

@ -2,7 +2,9 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer;
import javax.swing.JPanel; import javax.swing.JPanel;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.util.FileContainer; import the.bytecode.club.bytecodeviewer.util.FileContainer;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -25,8 +27,23 @@ import the.bytecode.club.bytecodeviewer.util.FileContainer;
public abstract class ResourceViewer extends JPanel public abstract class ResourceViewer extends JPanel
{ {
public ClassNode cn; public ClassNode cn;
public String originalName;
public String name; public String name;
public FileContainer container; public FileContainer container;
public String getTabName()
{
String tabName = name;
if (Configuration.simplifiedTabNames)
tabName = MiscUtils.getChildFromPath(tabName);
if (Configuration.displayParentInTab)
tabName = container.name + ">" + tabName;
return tabName;
}
public abstract void refreshTitle();
private static final long serialVersionUID = -2965538493489119191L; private static final long serialVersionUID = -2965538493489119191L;
} }

View file

@ -1,23 +1,5 @@
package the.bytecode.club.bytecodeviewer.gui.util; package the.bytecode.club.bytecodeviewer.gui.util;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Font; import java.awt.Font;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
@ -40,6 +22,24 @@ import the.bytecode.club.bytecodeviewer.util.MethodParser;
import static the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane.BLANK_COLOR; import static the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane.BLANK_COLOR;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* Allows us to run a background thread * Allows us to run a background thread
* *

View file

@ -4,6 +4,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.Configuration;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -48,7 +49,8 @@ public class FileContainer {
public HashMap<String, byte[]> files = new HashMap<>(); public HashMap<String, byte[]> files = new HashMap<>();
public ArrayList<ClassNode> classes = new ArrayList<>(); public ArrayList<ClassNode> classes = new ArrayList<>();
public ClassNode getClassNode(String name) { public ClassNode getClassNode(String name)
{
for (ClassNode c : classes) for (ClassNode c : classes)
if (c.name.equals(name)) if (c.name.equals(name))
return c; return c;

View file

@ -216,7 +216,7 @@ public class MiscUtils
public static String getChildFromPath(String path) public static String getChildFromPath(String path)
{ {
if (path.contains("/")) if (path != null && path.contains("/"))
{ {
String[] pathParts = StringUtils.split(path, "/"); String[] pathParts = StringUtils.split(path, "/");
return pathParts[pathParts.length-1]; return pathParts[pathParts.length-1];