-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
526 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
CommonLib/src/main/java/org/freeinternals/commonlib/ui/GenerateTreeNodeFileFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* GenerateTreeNodeFileFormat.java August 29, 2021, 23:44 | ||
* | ||
* Copyright 2021, FreeInternals.org. All rights reserved. | ||
* Use is subject to license terms. | ||
*/ | ||
package org.freeinternals.commonlib.ui; | ||
|
||
import java.util.ResourceBundle; | ||
import javax.swing.Icon; | ||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import org.freeinternals.commonlib.core.FileFormat; | ||
|
||
/** | ||
* Interface for generating children tree nodes. | ||
* | ||
* @author Amos Shi | ||
*/ | ||
public interface GenerateTreeNodeFileFormat { | ||
|
||
void generateTreeNode(final DefaultMutableTreeNode parentNode, FileFormat fileFormat); | ||
|
||
/** | ||
* Get the messages resource of current file format. | ||
* | ||
* @return {@link ResourceBundle} for messages, or <code>null</code> if not | ||
* exist | ||
*/ | ||
ResourceBundle getMessages(); | ||
|
||
default DefaultMutableTreeNode addNode(DefaultMutableTreeNode parentNode, int startPos, int len, String fieldName, Object value, String msgkey, Icon icon) { | ||
JTreeNodeFileComponent fileComp = new JTreeNodeFileComponent( | ||
startPos, | ||
len, | ||
fieldName + ": " + value.toString() | ||
); | ||
if (msgkey != null) { | ||
fileComp.setDescription(getMessages().getString(msgkey)); | ||
} | ||
fileComp.setIcon(icon); | ||
|
||
DefaultMutableTreeNode node = new DefaultMutableTreeNode(fileComp); | ||
parentNode.add(node); | ||
return node; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.