Skip to content

Commit

Permalink
#11 DEX format - parse items
Browse files Browse the repository at this point in the history
  • Loading branch information
amosshi committed Aug 20, 2021
1 parent 3267f70 commit 6669338
Show file tree
Hide file tree
Showing 47 changed files with 1,149 additions and 537 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static class PluginsModel extends AbstractTableModel {

@Override
public int getRowCount() {
return this.rowData.size() + 2;
return this.rowData.size() + 1;
}

@Override
Expand Down
141 changes: 109 additions & 32 deletions CommonLib/src/main/java/org/freeinternals/commonlib/ui/UITool.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public final class UITool {
* Size ratio of the pop-up window and its parent.
*/
public static final float POPUP_RATIO = 0.8f;
/**
* Max length for tree node string.
*
* @see #left(String)
*/
public static final int TREENODE_STRING_MAXLEN = 30;

private UITool() {
}
Expand Down Expand Up @@ -59,7 +65,8 @@ public static void generateTreeNodeDiff(
diffStr)));
}

private static final Map<String, Icon> iconCache = new HashMap<>();
private static final Map<String, Icon> iconCache = new HashMap<>();

private static Icon icon(String url) {
return iconCache.computeIfAbsent(url, k -> new ImageIcon(UITool.class.getResource(url)));
}
Expand All @@ -68,27 +75,19 @@ private static Icon icon(String url) {
* Icon for binary file.
*
* @return Icon for binary file
* @see <a href="https://icons8.com/icon/38992/binary-file">Binary File</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/38992/binary-file">Binary File</a>
* icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4BinaryFile() {
return icon("/image/icons8-binary-file-20.png");
}

/**
* Icon for bytes.
*
* @return Icon for bytes
* @see <a href="https://icons8.com/icon/62371/scart">Scart</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Bytes() {
return icon("/image/icons8-scart-16.png");
}

/**
* Icon for checksum.
*
* @return Icon for checksum
* @see <a href="https://icons8.com/icon/sz8cPVwzLrMP/check-mark">Check Mark</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/sz8cPVwzLrMP/check-mark">Check
* Mark</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Checksum() {
return icon("/image/icons8-check-mark-16.png");
Expand All @@ -98,27 +97,40 @@ public static Icon icon4Checksum() {
* Icon for counter.
*
* @return Icon for counter
* @see <a href="https://icons8.com/icon/2U6ROkjIrXIA/abacus">Abacus</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/2U6ROkjIrXIA/abacus">Abacus</a>
* icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Counter() {
return icon("/image/icons8-abacus-16.png");
}

/**
* Icon for raw Data.
*
* @return Icon for raw data
* @see <a href="https://icons8.com/icon/84736/blockchain-technology">Blockchain Technology</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Data() {
return icon("/image/icons8-blockchain-technology-16.png");
}

/**
* Icon for DEX file.
*
* @return Icon for dex file
* @see <a href="https://icons8.com/icon/38933/apk">APK</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/38933/apk">APK</a> icon by
* <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Dex() {
return icon("/image/icons8-apk-20.png");
}

/**
* Icon for endian.
*
* @return Icon for endian
* @see <a href="https://icons8.com/icon/Xf1Gx1HbxVsm/up-down-arrow">Up Down Arrow</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/Xf1Gx1HbxVsm/up-down-arrow">Up Down
* Arrow</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Endian() {
return icon("/image/icons8-up-down-arrow-16.png");
Expand All @@ -128,12 +140,23 @@ public static Icon icon4Endian() {
* Icon for length.
*
* @return Icon for length
* @see <a href="https://icons8.com/icon/44699/length">Length</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/44699/length">Length</a> icon by
* <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Length() {
return icon("/image/icons8-length-16.png");
}

/**
* Icon for Index.
*
* @return Icon for Index
* @see <a href="https://icons8.com/icon/79485/one-finger">One Finger</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Index() {
return icon("/image/icons8-one-finger-16.png");
}

/**
* Icon for Java.
*
Expand All @@ -142,34 +165,56 @@ public static Icon icon4Length() {
public static Icon icon4Java() {
return icon("/image/icons8-java-20.png");
}

/**
* Icon for Offset / Location / Index.
*
* @return Icon for Offset
* @see <a href="https://icons8.com/icon/2gsR2g07AQvu/map-pin">Map Pin</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/2gsR2g07AQvu/map-pin">Map Pin</a>
* icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Offset() {
return icon("/image/icons8-map-pin-16.png");
}

/**
* Icon for parameter, of a method.
*
* @return Icon for Offset
* @see <a href="https://icons8.com/icon/Pohj4RQVOJYd/filter">Filter</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Parameter() {
return icon("/image/icons8-filter-16.png");
}

/**
* Icon for magic number.
*
* @return Icon for magic number
* @see <a href="https://icons8.com/icon/q8t3iE9rg6YF/magic-wand">Magic Wand</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/q8t3iE9rg6YF/magic-wand">Magic
* Wand</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Magic() {
return icon("/image/icons8-magic-wand-16.png");
}

/**
* Icon for return type, of a method.
*
* @return return type icon
*
* @see <a href="https://icons8.com/icon/13107/return">Return</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Return() {
return icon("/image/icons8-return-16.png");
}

/**
* Icon for shortcut.
*
* @return Shortcut icon
*
* @see <a href="https://icons8.com/icon/78265/shortcut">Shortcut</a> icon
* by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/i1z7pQ2orcJk/shortcut">Shortcut</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Shortcut() {
return icon("/image/icons8-shortcut-16.png");
Expand All @@ -179,28 +224,31 @@ public static Icon icon4Shortcut() {
* Icon for signature.
*
* @return Icon for signature
* @see <a href="https://icons8.com/icon/bmicUxC0XDNt/signature">Signature</a> icon by <a href="https://icons8.com">Icons8</a>
* @see
* <a href="https://icons8.com/icon/bmicUxC0XDNt/signature">Signature</a>
* icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Signature() {
return icon("/image/icons8-signature-16.png");
}

/**
* Icon for Size.
*
*
* @return Shortcut icon
* @see <a href="https://icons8.com/icon/d8VomliGByyY/page-size">Page Size</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/d8VomliGByyY/page-size">Page
* Size</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Size() {
return icon("/image/icons8-page-size-16.png");
}


/**
* Icon for tag.
*
*
* @return tag icon
* @see <a href="https://icons8.com/icon/pmzH4rF8Lrv9/tag">Tag</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/pmzH4rF8Lrv9/tag">Tag</a> icon by
* <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Tag() {
return icon("/image/icons8-tag-16.png");
Expand All @@ -210,13 +258,42 @@ public static Icon icon4Tag() {
* Icon for version.
*
* @return Icon for versions
* @see <a href="https://icons8.com/icon/21933/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/21933/versions">Versions</a> icon
* by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon
* by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Versions() {
return icon("/image/icons8-versions-16.png");
}

/**
* Get left part of string for tree node.
*
* @param s The String to get left part
* @return Left part of string
*/
public static String left(String s) {
return left(s, TREENODE_STRING_MAXLEN);
}

/**
* Get left part of string.
*
* @param s The String to get left part
* @param length Length to get
* @return Left part of string
*/
public static String left(String s, int length) {
if (s == null) {
return s;
} else if (s.length() < length) {
return s;
} else {
return s.substring(0, length - 1) + " ...";
}
}

/**
* Show a popup window with given message.
*
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed CommonLib/src/main/resources/image/icons8-scart-16.png
Binary file not shown.
Binary file modified CommonLib/src/main/resources/image/icons8-shortcut-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* GenerateClassfileTreeNode.java September 07, 2019, 21:22
* GenerateTreeNodeClassFile.java September 07, 2019, 21:22
*
* Copyright 2019, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand All @@ -12,12 +12,13 @@
import javax.swing.tree.DefaultMutableTreeNode;

/**
* Interface for generating tree node for {@link ClassFile}.
*
* @author Amos Shi
*/
public interface GenerateClassfileTreeNode {
public interface GenerateTreeNodeClassFile {

ResourceBundle MESSAGES = ResourceBundle.getBundle(GenerateClassfileTreeNode.class.getPackageName() + ".MessagesBundle", Locale.ROOT);
ResourceBundle MESSAGES = ResourceBundle.getBundle(GenerateTreeNodeClassFile.class.getPackageName() + ".MessagesBundle", Locale.ROOT);

void generateTreeNode(final DefaultMutableTreeNode parentNode, ClassFile classFile);

Expand Down
Loading

0 comments on commit 6669338

Please sign in to comment.