Skip to content

Commit

Permalink
2.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
iamlinhui committed Jan 26, 2021
1 parent 1361042 commit bd1b247
Show file tree
Hide file tree
Showing 4 changed files with 400 additions and 24 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ json文本折叠代码和着色
修正null不显示

2.1.4
增加压缩按钮
增加压缩按钮

2.1.5
替换为弹窗
修复Mac下的背景色
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>hi.chyl</groupId>
<artifactId>json</artifactId>
<version>2.1.4</version>
<version>2.1.5</version>

<name>HiJson</name>

Expand Down
27 changes: 5 additions & 22 deletions src/main/java/hi/chyl/json/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import javax.swing.*;
import javax.swing.event.ListDataEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
Expand Down Expand Up @@ -179,7 +180,6 @@ public void actionPerformed(ActionEvent e) {
int selIndex = getTabIndex();
if (selIndex >= 0) {
tabDataModel.setText(selIndex, textField.getText());
System.out.println("Modify HashCode : " + getTree(selIndex).hashCode() + " . TabTitle : " + textField.getText() + " !");
}
}
});
Expand Down Expand Up @@ -396,6 +396,7 @@ private void initTabbedContainer() {
TabData tabData = newTabData("Welcome!", "This is a Tab!", null);
tabDataModel = new DefaultTabDataModel(new TabData[]{tabData});
tabbedContainer = new TabbedContainer(tabDataModel, TabbedContainer.TYPE_EDITOR);
tabbedContainer.setForeground(new Color(238,238,238));
tabbedContainer.getSelectionModel().setSelectedIndex(0);
tabbedContainer.setShowCloseButton(true);
tabDataModel.addComplexListDataListener(new ComplexListDataListener() {
Expand All @@ -419,7 +420,6 @@ public void intervalRemoved(ListDataEvent e) {
JTree tree = getTree(tbArr[0]);
if (tree != null) {
jsonEleTreeMap.remove(tree.hashCode());
System.out.println("Remove HashCode: " + tree.hashCode() + ". Close Tab: " + tbArr[0].getText() + " !");
}
}
}
Expand All @@ -430,7 +430,6 @@ public void contentsChanged(ListDataEvent e) {

tabbedContainer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//System.out.println("@@@:TabbedContainerActionCommand = "+e.getActionCommand());
if ("select".equalsIgnoreCase(e.getActionCommand())) {
treePathLst.clear();
}
Expand Down Expand Up @@ -536,14 +535,13 @@ private JTree newTree() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("o-JSON");
DefaultTreeModel model = new DefaultTreeModel(root);
JTree tree = new JTree(model);
tree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
treeSelection(getTree(), getTable());
}
});
setNodeIcon(tree);
tree.addMouseListener(new TreeMouseListener(tree));
System.out.println("New HashCode : " + tree.hashCode());
return tree;
}

Expand All @@ -562,7 +560,6 @@ private JTable newTable() {
private void treeSelection(JTree tree, JTable table) {
DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (selNode == null) {
//System.out.println("jTree1ValueChanged:selNode is null");
return;
}
String col[] = {"key", "value"};
Expand Down Expand Up @@ -682,7 +679,6 @@ private void formatJson() {

//创建树节点
JTree tree = getTree();
System.out.println("Put HashCode : " + tree.hashCode() + " . TabTitle : " + getTabTitle() + " !");
jsonEleTreeMap.put(tree.hashCode(), jsonEle);
DefaultMutableTreeNode root = Kit.objNode("JSON");
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
Expand Down Expand Up @@ -723,7 +719,6 @@ private void sortFormatJson() {

//创建树节点
JTree tree = getTree();
System.out.println("Put HashCode : " + tree.hashCode() + " . TabTitle : " + getTabTitle() + " !");
jsonEleTreeMap.put(tree.hashCode(), jsonEle);
DefaultMutableTreeNode root = Kit.objNode("JSON");
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
Expand Down Expand Up @@ -760,7 +755,6 @@ private void zipFormatJson() {

//创建树节点
JTree tree = getTree();
System.out.println("Put HashCode : " + tree.hashCode() + " . TabTitle : " + getTabTitle() + " !");
jsonEleTreeMap.put(tree.hashCode(), jsonEle);
DefaultMutableTreeNode root = Kit.objNode("JSON");
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
Expand Down Expand Up @@ -923,18 +917,8 @@ private void showMessageDialog(String title, String msg) {
if (index >= 0) {
msg = msg.substring(index + ex.length());
}
JDialog dlg = new JDialog(getFrame());
dlg.setTitle(title);
dlg.setMinimumSize(new Dimension(350, 160));
BorderLayout layout = new BorderLayout();
dlg.getContentPane().setLayout(layout);
dlg.getContentPane().add(new JLabel("异常信息:"), BorderLayout.NORTH);
JTextArea ta = new JTextArea();
ta.setLineWrap(true);
ta.setText(msg);
ta.setWrapStyleWord(true);
dlg.getContentPane().add(new JScrollPane(ta), BorderLayout.CENTER);
MainApp.getApplication().show(dlg);
ToolTips tip = new ToolTips();
tip.setToolTip(title + "\n异常信息:" + msg);
}

//[start]自动调列宽
Expand Down Expand Up @@ -1352,7 +1336,6 @@ public String copySimilarPathKeyValue(TreeNode treeNode) {
private String copyNodeContent(String path, boolean isFormat) {
String str = "";
String arr[] = StringUtils.split(path, String.valueOf(dot));
System.out.println("Get HashCode : " + tree.hashCode() + " . TabTitle : " + getTabTitle());
JsonElement obj = (JsonElement) jsonEleTreeMap.get(tree.hashCode());
if (arr.length > 1) {
for (int i = 1; i < arr.length; i++) {
Expand Down
Loading

0 comments on commit bd1b247

Please sign in to comment.