Better resource importing

This commit is contained in:
Konloch 2021-06-26 05:33:42 -07:00
parent e25d6179f3
commit c90b1d45a6

AI 샘플 코드 생성 중입니다

Loading...
4 changed files with 26 additions and 38 deletions

View File

@ -156,17 +156,34 @@ 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);
TabbedPane tabbedPane = new TabbedPane(tabIndex, workingName, container.name, name, tabs, resourceView); TabbedPane tabbedPane = new TabbedPane(tabIndex, workingName, container.name, name, tabs, resourceView);
resourceView.tabbedPane = tabbedPane; resourceView.tabbedPane = tabbedPane;
tabs.setTabComponentAt(tabIndex, tabbedPane); tabs.setTabComponentAt(tabIndex, tabbedPane);
@ -176,39 +193,10 @@ public class WorkPaneMainComponent extends VisibleComponent
else else
{ {
tabs.setSelectedIndex(workingOn.get(workingName)); tabs.setSelectedIndex(workingOn.get(workingName));
}
} // TODO: need to look into if this exception is actually needed
// removing it for now, but keeping it incase this causes issues
//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
{
try { try {
tabs.setSelectedIndex(workingOn.get(workingName));
} catch (Exception e) { } catch (Exception e) {
//workingOn.remove(workingName); //workingOn.remove(workingName);
e.printStackTrace(); e.printStackTrace();

View File

@ -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);

View File

@ -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;

View File

@ -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();