Better resource importing
This commit is contained in:
parent
e25d6179f3
commit
c90b1d45a6
4 changed files with 26 additions and 38 deletions
|
@ -156,13 +156,30 @@ public class WorkPaneMainComponent extends VisibleComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
//load class resources
|
//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))
|
if (!workingOn.containsKey(workingName))
|
||||||
{
|
{
|
||||||
final ClassViewer resourceView = new ClassViewer(container, name, cn, workingName);
|
|
||||||
tabs.add(resourceView);
|
tabs.add(resourceView);
|
||||||
final int tabIndex = tabs.indexOfComponent(resourceView);
|
final int tabIndex = tabs.indexOfComponent(resourceView);
|
||||||
workingOn.put(workingName, tabIndex);
|
workingOn.put(workingName, tabIndex);
|
||||||
|
@ -176,39 +193,10 @@ public class WorkPaneMainComponent extends VisibleComponent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tabs.setSelectedIndex(workingOn.get(workingName));
|
tabs.setSelectedIndex(workingOn.get(workingName));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Load file resources
|
// TODO: need to look into if this exception is actually needed
|
||||||
public void addFileResource(final FileContainer container, String name, byte[] contents)
|
// removing it for now, but keeping it incase this causes issues
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
tabs.setSelectedIndex(workingOn.get(workingName));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//workingOn.remove(workingName);
|
//workingOn.remove(workingName);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -61,7 +61,6 @@ public class ClassViewer extends ResourceViewer
|
||||||
{
|
{
|
||||||
public JSplitPane sp;
|
public JSplitPane sp;
|
||||||
public JSplitPane sp2;
|
public JSplitPane sp2;
|
||||||
public TabbedPane tabbedPane;
|
|
||||||
public ResourceViewPanel resourceViewPanel1 = new ResourceViewPanel(0);
|
public ResourceViewPanel resourceViewPanel1 = new ResourceViewPanel(0);
|
||||||
public ResourceViewPanel resourceViewPanel2 = new ResourceViewPanel(1);
|
public ResourceViewPanel resourceViewPanel2 = new ResourceViewPanel(1);
|
||||||
public ResourceViewPanel resourceViewPanel3 = new ResourceViewPanel(2);
|
public ResourceViewPanel resourceViewPanel3 = new ResourceViewPanel(2);
|
||||||
|
|
|
@ -58,7 +58,6 @@ public class FileViewer extends ResourceViewer
|
||||||
Configuration.rstaTheme.apply(new SearchableRSyntaxTextArea());
|
Configuration.rstaTheme.apply(new SearchableRSyntaxTextArea());
|
||||||
|
|
||||||
public final JPanel mainPanel = new JPanel(new BorderLayout());
|
public final JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
public TabbedPane tabbedPane;
|
|
||||||
public BufferedImage image;
|
public BufferedImage image;
|
||||||
public boolean canRefresh;
|
public boolean canRefresh;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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.Configuration;
|
||||||
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane;
|
||||||
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
||||||
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ public abstract class ResourceViewer extends JPanel
|
||||||
public ClassNode cn;
|
public ClassNode cn;
|
||||||
public String name;
|
public String name;
|
||||||
public FileContainer container;
|
public FileContainer container;
|
||||||
|
public TabbedPane tabbedPane;
|
||||||
|
|
||||||
public abstract void refreshTitle();
|
public abstract void refreshTitle();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue