Better resource importing
This commit is contained in:
parent
e25d6179f3
commit
c90b1d45a6
|
@ -156,13 +156,30 @@ public class WorkPaneMainComponent extends VisibleComponent
|
|||
}
|
||||
|
||||
//load class resources
|
||||
public void addClassResource(final FileContainer container, String name, final ClassNode cn)
|
||||
public void addClassResource(final FileContainer container, final String name, final ClassNode cn)
|
||||
{
|
||||
String workingName = container.name + ">" + name;
|
||||
final String workingName = container.name + ">" + name;
|
||||
|
||||
addResource(container, name, new ClassViewer(container, name, cn, workingName));
|
||||
}
|
||||
|
||||
//Load file resources
|
||||
public void addFileResource(final FileContainer container, final String name, byte[] contents)
|
||||
{
|
||||
if (contents == null) //a directory
|
||||
return;
|
||||
|
||||
final String workingName = container.name + ">" + name;
|
||||
|
||||
addResource(container, name, new FileViewer(container, name, contents, workingName));
|
||||
}
|
||||
|
||||
private void addResource(final FileContainer container, final String name, final ResourceViewer resourceView)
|
||||
{
|
||||
final String workingName = container.name + ">" + name;
|
||||
|
||||
if (!workingOn.containsKey(workingName))
|
||||
{
|
||||
final ClassViewer resourceView = new ClassViewer(container, name, cn, workingName);
|
||||
tabs.add(resourceView);
|
||||
final int tabIndex = tabs.indexOfComponent(resourceView);
|
||||
workingOn.put(workingName, tabIndex);
|
||||
|
@ -176,39 +193,10 @@ public class WorkPaneMainComponent extends VisibleComponent
|
|||
else
|
||||
{
|
||||
tabs.setSelectedIndex(workingOn.get(workingName));
|
||||
}
|
||||
}
|
||||
|
||||
//Load file resources
|
||||
public void addFileResource(final FileContainer container, String name, byte[] contents)
|
||||
{
|
||||
if (contents == null) //a directory
|
||||
return;
|
||||
|
||||
final String workingName = container.name + ">" + name;
|
||||
|
||||
/*if (Configuration.simplifiedTabNames)
|
||||
name = MiscUtils.getChildFromPath(name);
|
||||
if (Configuration.displayParentInTab)
|
||||
name = container.name + ">" + name;*/
|
||||
|
||||
if (!workingOn.containsKey(workingName))
|
||||
{
|
||||
final FileViewer resourceView = new FileViewer(container, name, contents, workingName);
|
||||
tabs.add(resourceView);
|
||||
final int tabIndex = tabs.indexOfComponent(resourceView);
|
||||
workingOn.put(workingName, tabIndex);
|
||||
|
||||
TabbedPane tabbedPane = new TabbedPane(tabIndex, workingName, container.name, name, tabs, resourceView);
|
||||
resourceView.tabbedPane = tabbedPane;
|
||||
tabs.setTabComponentAt(tabIndex, tabbedPane);
|
||||
tabs.setSelectedIndex(tabIndex);
|
||||
resourceView.refreshTitle();
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: need to look into if this exception is actually needed
|
||||
// removing it for now, but keeping it incase this causes issues
|
||||
try {
|
||||
tabs.setSelectedIndex(workingOn.get(workingName));
|
||||
} catch (Exception e) {
|
||||
//workingOn.remove(workingName);
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -61,7 +61,6 @@ public class ClassViewer extends ResourceViewer
|
|||
{
|
||||
public JSplitPane sp;
|
||||
public JSplitPane sp2;
|
||||
public TabbedPane tabbedPane;
|
||||
public ResourceViewPanel resourceViewPanel1 = new ResourceViewPanel(0);
|
||||
public ResourceViewPanel resourceViewPanel2 = new ResourceViewPanel(1);
|
||||
public ResourceViewPanel resourceViewPanel3 = new ResourceViewPanel(2);
|
||||
|
|
|
@ -58,7 +58,6 @@ public class FileViewer extends ResourceViewer
|
|||
Configuration.rstaTheme.apply(new SearchableRSyntaxTextArea());
|
||||
|
||||
public final JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
public TabbedPane tabbedPane;
|
||||
public BufferedImage image;
|
||||
public boolean canRefresh;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer;
|
|||
import javax.swing.JPanel;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane;
|
||||
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
||||
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||
|
||||
|
@ -35,6 +36,7 @@ public abstract class ResourceViewer extends JPanel
|
|||
public ClassNode cn;
|
||||
public String name;
|
||||
public FileContainer container;
|
||||
public TabbedPane tabbedPane;
|
||||
|
||||
public abstract void refreshTitle();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user