Skip to content

Commit 6669338

Browse files
committed
#11 DEX format - parse items
1 parent 3267f70 commit 6669338

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1149
-537
lines changed

BinaryInternalsViewer/src/main/java/org/freeinternals/biv/JDialogPlugins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static class PluginsModel extends AbstractTableModel {
125125

126126
@Override
127127
public int getRowCount() {
128-
return this.rowData.size() + 2;
128+
return this.rowData.size() + 1;
129129
}
130130

131131
@Override

CommonLib/src/main/java/org/freeinternals/commonlib/ui/UITool.java

Lines changed: 109 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public final class UITool {
2828
* Size ratio of the pop-up window and its parent.
2929
*/
3030
public static final float POPUP_RATIO = 0.8f;
31+
/**
32+
* Max length for tree node string.
33+
*
34+
* @see #left(String)
35+
*/
36+
public static final int TREENODE_STRING_MAXLEN = 30;
3137

3238
private UITool() {
3339
}
@@ -59,7 +65,8 @@ public static void generateTreeNodeDiff(
5965
diffStr)));
6066
}
6167

62-
private static final Map<String, Icon> iconCache = new HashMap<>();
68+
private static final Map<String, Icon> iconCache = new HashMap<>();
69+
6370
private static Icon icon(String url) {
6471
return iconCache.computeIfAbsent(url, k -> new ImageIcon(UITool.class.getResource(url)));
6572
}
@@ -68,27 +75,19 @@ private static Icon icon(String url) {
6875
* Icon for binary file.
6976
*
7077
* @return Icon for binary file
71-
* @see <a href="https://icons8.com/icon/38992/binary-file">Binary File</a> icon by <a href="https://icons8.com">Icons8</a>
78+
* @see <a href="https://icons8.com/icon/38992/binary-file">Binary File</a>
79+
* icon by <a href="https://icons8.com">Icons8</a>
7280
*/
7381
public static Icon icon4BinaryFile() {
7482
return icon("/image/icons8-binary-file-20.png");
7583
}
7684

77-
/**
78-
* Icon for bytes.
79-
*
80-
* @return Icon for bytes
81-
* @see <a href="https://icons8.com/icon/62371/scart">Scart</a> icon by <a href="https://icons8.com">Icons8</a>
82-
*/
83-
public static Icon icon4Bytes() {
84-
return icon("/image/icons8-scart-16.png");
85-
}
86-
8785
/**
8886
* Icon for checksum.
8987
*
9088
* @return Icon for checksum
91-
* @see <a href="https://icons8.com/icon/sz8cPVwzLrMP/check-mark">Check Mark</a> icon by <a href="https://icons8.com">Icons8</a>
89+
* @see <a href="https://icons8.com/icon/sz8cPVwzLrMP/check-mark">Check
90+
* Mark</a> icon by <a href="https://icons8.com">Icons8</a>
9291
*/
9392
public static Icon icon4Checksum() {
9493
return icon("/image/icons8-check-mark-16.png");
@@ -98,27 +97,40 @@ public static Icon icon4Checksum() {
9897
* Icon for counter.
9998
*
10099
* @return Icon for counter
101-
* @see <a href="https://icons8.com/icon/2U6ROkjIrXIA/abacus">Abacus</a> icon by <a href="https://icons8.com">Icons8</a>
100+
* @see <a href="https://icons8.com/icon/2U6ROkjIrXIA/abacus">Abacus</a>
101+
* icon by <a href="https://icons8.com">Icons8</a>
102102
*/
103103
public static Icon icon4Counter() {
104104
return icon("/image/icons8-abacus-16.png");
105105
}
106+
107+
/**
108+
* Icon for raw Data.
109+
*
110+
* @return Icon for raw data
111+
* @see <a href="https://icons8.com/icon/84736/blockchain-technology">Blockchain Technology</a> icon by <a href="https://icons8.com">Icons8</a>
112+
*/
113+
public static Icon icon4Data() {
114+
return icon("/image/icons8-blockchain-technology-16.png");
115+
}
106116

107117
/**
108118
* Icon for DEX file.
109119
*
110120
* @return Icon for dex file
111-
* @see <a href="https://icons8.com/icon/38933/apk">APK</a> icon by <a href="https://icons8.com">Icons8</a>
121+
* @see <a href="https://icons8.com/icon/38933/apk">APK</a> icon by
122+
* <a href="https://icons8.com">Icons8</a>
112123
*/
113124
public static Icon icon4Dex() {
114125
return icon("/image/icons8-apk-20.png");
115126
}
116-
127+
117128
/**
118129
* Icon for endian.
119130
*
120131
* @return Icon for endian
121-
* @see <a href="https://icons8.com/icon/Xf1Gx1HbxVsm/up-down-arrow">Up Down Arrow</a> icon by <a href="https://icons8.com">Icons8</a>
132+
* @see <a href="https://icons8.com/icon/Xf1Gx1HbxVsm/up-down-arrow">Up Down
133+
* Arrow</a> icon by <a href="https://icons8.com">Icons8</a>
122134
*/
123135
public static Icon icon4Endian() {
124136
return icon("/image/icons8-up-down-arrow-16.png");
@@ -128,12 +140,23 @@ public static Icon icon4Endian() {
128140
* Icon for length.
129141
*
130142
* @return Icon for length
131-
* @see <a href="https://icons8.com/icon/44699/length">Length</a> icon by <a href="https://icons8.com">Icons8</a>
143+
* @see <a href="https://icons8.com/icon/44699/length">Length</a> icon by
144+
* <a href="https://icons8.com">Icons8</a>
132145
*/
133146
public static Icon icon4Length() {
134147
return icon("/image/icons8-length-16.png");
135148
}
136149

150+
/**
151+
* Icon for Index.
152+
*
153+
* @return Icon for Index
154+
* @see <a href="https://icons8.com/icon/79485/one-finger">One Finger</a> icon by <a href="https://icons8.com">Icons8</a>
155+
*/
156+
public static Icon icon4Index() {
157+
return icon("/image/icons8-one-finger-16.png");
158+
}
159+
137160
/**
138161
* Icon for Java.
139162
*
@@ -142,34 +165,56 @@ public static Icon icon4Length() {
142165
public static Icon icon4Java() {
143166
return icon("/image/icons8-java-20.png");
144167
}
145-
168+
146169
/**
147170
* Icon for Offset / Location / Index.
148171
*
149172
* @return Icon for Offset
150-
* @see <a href="https://icons8.com/icon/2gsR2g07AQvu/map-pin">Map Pin</a> icon by <a href="https://icons8.com">Icons8</a>
173+
* @see <a href="https://icons8.com/icon/2gsR2g07AQvu/map-pin">Map Pin</a>
174+
* icon by <a href="https://icons8.com">Icons8</a>
151175
*/
152176
public static Icon icon4Offset() {
153177
return icon("/image/icons8-map-pin-16.png");
154178
}
155179

180+
/**
181+
* Icon for parameter, of a method.
182+
*
183+
* @return Icon for Offset
184+
* @see <a href="https://icons8.com/icon/Pohj4RQVOJYd/filter">Filter</a> icon by <a href="https://icons8.com">Icons8</a>
185+
*/
186+
public static Icon icon4Parameter() {
187+
return icon("/image/icons8-filter-16.png");
188+
}
189+
156190
/**
157191
* Icon for magic number.
158192
*
159193
* @return Icon for magic number
160-
* @see <a href="https://icons8.com/icon/q8t3iE9rg6YF/magic-wand">Magic Wand</a> icon by <a href="https://icons8.com">Icons8</a>
194+
* @see <a href="https://icons8.com/icon/q8t3iE9rg6YF/magic-wand">Magic
195+
* Wand</a> icon by <a href="https://icons8.com">Icons8</a>
161196
*/
162197
public static Icon icon4Magic() {
163198
return icon("/image/icons8-magic-wand-16.png");
164199
}
165200

201+
/**
202+
* Icon for return type, of a method.
203+
*
204+
* @return return type icon
205+
*
206+
* @see <a href="https://icons8.com/icon/13107/return">Return</a> icon by <a href="https://icons8.com">Icons8</a>
207+
*/
208+
public static Icon icon4Return() {
209+
return icon("/image/icons8-return-16.png");
210+
}
211+
166212
/**
167213
* Icon for shortcut.
168214
*
169215
* @return Shortcut icon
170216
*
171-
* @see <a href="https://icons8.com/icon/78265/shortcut">Shortcut</a> icon
172-
* by <a href="https://icons8.com">Icons8</a>
217+
* @see <a href="https://icons8.com/icon/i1z7pQ2orcJk/shortcut">Shortcut</a> icon by <a href="https://icons8.com">Icons8</a>
173218
*/
174219
public static Icon icon4Shortcut() {
175220
return icon("/image/icons8-shortcut-16.png");
@@ -179,28 +224,31 @@ public static Icon icon4Shortcut() {
179224
* Icon for signature.
180225
*
181226
* @return Icon for signature
182-
* @see <a href="https://icons8.com/icon/bmicUxC0XDNt/signature">Signature</a> icon by <a href="https://icons8.com">Icons8</a>
227+
* @see
228+
* <a href="https://icons8.com/icon/bmicUxC0XDNt/signature">Signature</a>
229+
* icon by <a href="https://icons8.com">Icons8</a>
183230
*/
184231
public static Icon icon4Signature() {
185232
return icon("/image/icons8-signature-16.png");
186233
}
187-
234+
188235
/**
189236
* Icon for Size.
190-
*
237+
*
191238
* @return Shortcut icon
192-
* @see <a href="https://icons8.com/icon/d8VomliGByyY/page-size">Page Size</a> icon by <a href="https://icons8.com">Icons8</a>
239+
* @see <a href="https://icons8.com/icon/d8VomliGByyY/page-size">Page
240+
* Size</a> icon by <a href="https://icons8.com">Icons8</a>
193241
*/
194242
public static Icon icon4Size() {
195243
return icon("/image/icons8-page-size-16.png");
196244
}
197245

198-
199246
/**
200247
* Icon for tag.
201-
*
248+
*
202249
* @return tag icon
203-
* @see <a href="https://icons8.com/icon/pmzH4rF8Lrv9/tag">Tag</a> icon by <a href="https://icons8.com">Icons8</a>
250+
* @see <a href="https://icons8.com/icon/pmzH4rF8Lrv9/tag">Tag</a> icon by
251+
* <a href="https://icons8.com">Icons8</a>
204252
*/
205253
public static Icon icon4Tag() {
206254
return icon("/image/icons8-tag-16.png");
@@ -210,13 +258,42 @@ public static Icon icon4Tag() {
210258
* Icon for version.
211259
*
212260
* @return Icon for versions
213-
* @see <a href="https://icons8.com/icon/21933/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
214-
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
261+
* @see <a href="https://icons8.com/icon/21933/versions">Versions</a> icon
262+
* by <a href="https://icons8.com">Icons8</a>
263+
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon
264+
* by <a href="https://icons8.com">Icons8</a>
215265
*/
216266
public static Icon icon4Versions() {
217267
return icon("/image/icons8-versions-16.png");
218268
}
219269

270+
/**
271+
* Get left part of string for tree node.
272+
*
273+
* @param s The String to get left part
274+
* @return Left part of string
275+
*/
276+
public static String left(String s) {
277+
return left(s, TREENODE_STRING_MAXLEN);
278+
}
279+
280+
/**
281+
* Get left part of string.
282+
*
283+
* @param s The String to get left part
284+
* @param length Length to get
285+
* @return Left part of string
286+
*/
287+
public static String left(String s, int length) {
288+
if (s == null) {
289+
return s;
290+
} else if (s.length() < length) {
291+
return s;
292+
} else {
293+
return s.substring(0, length - 1) + " ...";
294+
}
295+
}
296+
220297
/**
221298
* Show a popup window with given message.
222299
*
Loading
Loading
Loading
Loading
Binary file not shown.
Loading

FormatCLASS/src/main/java/org/freeinternals/format/classfile/GenerateClassfileTreeNode.java renamed to FormatCLASS/src/main/java/org/freeinternals/format/classfile/GenerateTreeNodeClassFile.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* GenerateClassfileTreeNode.java September 07, 2019, 21:22
2+
* GenerateTreeNodeClassFile.java September 07, 2019, 21:22
33
*
44
* Copyright 2019, FreeInternals.org. All rights reserved.
55
* Use is subject to license terms.
@@ -12,12 +12,13 @@
1212
import javax.swing.tree.DefaultMutableTreeNode;
1313

1414
/**
15+
* Interface for generating tree node for {@link ClassFile}.
1516
*
1617
* @author Amos Shi
1718
*/
18-
public interface GenerateClassfileTreeNode {
19+
public interface GenerateTreeNodeClassFile {
1920

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

2223
void generateTreeNode(final DefaultMutableTreeNode parentNode, ClassFile classFile);
2324

0 commit comments

Comments
 (0)