Skip to content

Commit

Permalink
#12 Zip format parser UI
Browse files Browse the repository at this point in the history
  • Loading branch information
amosshi committed Sep 22, 2021
1 parent dd4a44c commit d33cb15
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
19 changes: 13 additions & 6 deletions CommonLib/src/main/java/org/freeinternals/commonlib/ui/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public enum Icons {
BinaryFile("icons8-binary-file-20.png"),
/**
* Icon for Calendar / Date.
*
* @see <a href="https://icons8.com/icon/84997/calendar">Calendar</a> icon by <a href="https://icons8.com">Icons8</a>
*
* @see <a href="https://icons8.com/icon/84997/calendar">Calendar</a> icon
* by <a href="https://icons8.com">Icons8</a>
*/
Calendar("icons8-calendar-16.png"),

/**
* Icon for checksum.
*
Expand Down Expand Up @@ -198,11 +198,11 @@ public enum Icons {
* <a href="https://icons8.com">Icons8</a>
*/
Tag("icons8-tag-16.png"),

/**
* Icon for time.
*
* @see <a href="https://icons8.com/icon/HIiMyiiPLluy/time">Time</a> icon by <a href="https://icons8.com">Icons8</a>
* @see <a href="https://icons8.com/icon/HIiMyiiPLluy/time">Time</a> icon by
* <a href="https://icons8.com">Icons8</a>
*/
Time("icons8-time-16.png"),
/**
Expand All @@ -211,7 +211,14 @@ public enum Icons {
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon
* by <a href="https://icons8.com">Icons8</a>
*/
Versions("icons8-versions-16.png");
Versions("icons8-versions-16.png"),
/**
* Icon for zip file.
*
* @see <a href="https://icons8.com/icon/49013/zip">ZIP</a> icon by
* <a href="https://icons8.com">Icons8</a>
*/
ZIP("icons8-zip-16.png");

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

Expand Down
Binary file added CommonLib/src/main/resources/image/icons8-zip-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
Expand Up @@ -106,36 +106,52 @@ public void generateTreeNode(DefaultMutableTreeNode parent) {
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position += 4,
2,
String.format("number of this disk = %d", this.DiskNumber))));
String.format("number of this disk = %d", this.DiskNumber),
Icons.Counter
)));
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position += 2,
2,
String.format("number of the disk with the start of the central directory = %d", this.DiskNumberWithSCD))));
String.format("number of the disk with the start of the central directory = %d", this.DiskNumberWithSCD),
Icons.Counter
)));
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position += 2,
2,
String.format("total number of entries in the central directory on this disk = %d", this.EntryTotalNumberDisk))));
String.format("total number of entries in the central directory on this disk = %d", this.EntryTotalNumberDisk),
Icons.Counter
)));
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position += 2,
2,
String.format("total number of entries in the central directory = %d", this.EntryTotalNumber))));
String.format("total number of entries in the central directory = %d", this.EntryTotalNumber),
Icons.Counter
)));
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position += 2,
4,
String.format("size of the central directory = %d", this.CentralDirectorySize))));
String.format("size of the central directory = %d", this.CentralDirectorySize),
Icons.Size
)));
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position += 4,
4,
String.format("offset of start of central directory with respect to the starting disk number = %d", this.CentralDirectoryOffset))));
String.format("offset of start of central directory with respect to the starting disk number = 0x%08X", this.CentralDirectoryOffset),
Icons.Offset
)));
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position += 4,
2,
String.format(".ZIP file comment length = %d", this.ZipFileCommentLength))));
String.format(".ZIP file comment length = %d", this.ZipFileCommentLength),
Icons.Length
)));
if (this.ZipFileComment != null) {
nodeCDE.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
position + 2,
this.ZipFileComment.length,
".ZIP file comment")));
".ZIP file comment",
Icons.Annotations
)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.freeinternals.commonlib.core.PosByteArrayInputStream;
import org.freeinternals.commonlib.core.PosDataInputStream;
import org.freeinternals.commonlib.ui.GenerateTreeNode;
import org.freeinternals.commonlib.ui.Icons;

/**
*
Expand Down Expand Up @@ -121,6 +122,11 @@ public String getContentTabName() {
return "ZIP File";
}

@Override
public Icons getIcon() {
return Icons.ZIP;
}

@Override
public void generateTreeNode(DefaultMutableTreeNode root) {
int lastPos = 0;
Expand Down

0 comments on commit d33cb15

Please sign in to comment.