Search in sources :

Example 11 with FieldEntity

use of org.gsonformat.intellij.entity.FieldEntity in project GsonFormat by zzz40500.

the class FieldsDialog method createDataNode.

private void createDataNode(DefaultMutableTreeTableNode root, ClassEntity innerClassEntity) {
    for (FieldEntity field : innerClassEntity.getFields()) {
        DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(field);
        root.add(node);
        defaultMutableTreeTableNodeList.add(node);
    }
    for (ClassEntity classEntity : innerClassEntity.getInnerClasss()) {
        DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(classEntity);
        root.add(node);
        createDataNode(node, classEntity);
    }
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity) FieldEntity(org.gsonformat.intellij.entity.FieldEntity) DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)

Example 12 with FieldEntity

use of org.gsonformat.intellij.entity.FieldEntity in project GsonFormat by zzz40500.

the class ConvertBridge method listTypeByValue.

private FieldEntity listTypeByValue(ClassEntity parentClass, String key, Object type, int deep) {
    FieldEntity item = null;
    if (type instanceof JSONObject) {
        ClassEntity classEntity = existDeclareClass((JSONObject) type);
        if (classEntity == null) {
            IterableFieldEntity iterableFieldEntity = new IterableFieldEntity();
            ClassEntity innerClassEntity = createInnerClass(createSubClassName(key, type), (JSONObject) type, parentClass);
            iterableFieldEntity.setKey(key);
            iterableFieldEntity.setDeep(deep);
            iterableFieldEntity.setTargetClass(innerClassEntity);
            item = iterableFieldEntity;
        } else {
            IterableFieldEntity fieldEntity = new IterableFieldEntity();
            fieldEntity.setKey(key);
            fieldEntity.setTargetClass(classEntity);
            fieldEntity.setType(classEntity.getQualifiedName());
            fieldEntity.setDeep(deep);
            item = fieldEntity;
        }
    } else if (type instanceof JSONArray) {
        FieldEntity fieldEntity = handleJSONArray(parentClass, (JSONArray) type, key, ++deep);
        fieldEntity.setKey(key);
        item = fieldEntity;
    } else {
        IterableFieldEntity fieldEntity = new IterableFieldEntity();
        fieldEntity.setKey(key);
        fieldEntity.setType(type.getClass().getSimpleName());
        fieldEntity.setDeep(deep);
        item = fieldEntity;
    }
    return item;
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity) IterableFieldEntity(org.gsonformat.intellij.entity.IterableFieldEntity) JSONObject(org.json.JSONObject) FieldEntity(org.gsonformat.intellij.entity.FieldEntity) IterableFieldEntity(org.gsonformat.intellij.entity.IterableFieldEntity) JSONArray(org.json.JSONArray)

Example 13 with FieldEntity

use of org.gsonformat.intellij.entity.FieldEntity in project GsonFormat by zzz40500.

the class CheckTreeCellProvider method format.

@Override
protected void format(CellContext arg0) {
    //  从CellContext获取tree中的文字和图标
    JTree tree = (JTree) arg0.getComponent();
    DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) arg0.getValue();
    Object obj = node.getUserObject();
    if (obj instanceof FieldEntity) {
        _label.setText(((FieldEntity) obj).getKey());
        _checkBox.setSelector((FieldEntity) obj);
    } else if (obj instanceof ClassEntity) {
        _label.setText(((ClassEntity) obj).getClassName());
        _checkBox.setSelector((ClassEntity) obj);
    }
    //        _label.setIcon(arg0.getIcon());
    //  根据selectionModel中的状态来绘制TristateCheckBox的外观
    TreePath path = tree.getPathForRow(arg0.getRow());
    if (path != null) {
        if (selectionModel.isPathSelected(path, true)) {
            _checkBox.setState(Boolean.TRUE);
        } else if (selectionModel.isPartiallySelected(path)) {
            //  注意“部分选中”状态的API
            _checkBox.setState(null);
        } else {
            _checkBox.setState(Boolean.FALSE);
        }
    }
    //  使用BorderLayout布局,依次放置TristateCheckBox和JLabel
    rendererComponent.setLayout(new BorderLayout());
    rendererComponent.add(_checkBox);
    rendererComponent.add(_label, BorderLayout.LINE_END);
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) BorderLayout(java.awt.BorderLayout) FieldEntity(org.gsonformat.intellij.entity.FieldEntity) DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)

Example 14 with FieldEntity

use of org.gsonformat.intellij.entity.FieldEntity in project GsonFormat by zzz40500.

the class ConvertBridge method typeByValue.

private FieldEntity typeByValue(ClassEntity parentClass, String key, Object type) {
    FieldEntity result;
    if (type instanceof JSONObject) {
        ClassEntity classEntity = existDeclareClass((JSONObject) type);
        if (classEntity == null) {
            FieldEntity fieldEntity = new FieldEntity();
            ClassEntity innerClassEntity = createInnerClass(createSubClassName(key, type), (JSONObject) type, parentClass);
            fieldEntity.setKey(key);
            fieldEntity.setTargetClass(innerClassEntity);
            result = fieldEntity;
        } else {
            FieldEntity fieldEntity = new FieldEntity();
            fieldEntity.setKey(key);
            fieldEntity.setTargetClass(classEntity);
            result = fieldEntity;
        }
    } else if (type instanceof JSONArray) {
        result = handleJSONArray(parentClass, (JSONArray) type, key, 1);
    } else {
        FieldEntity fieldEntity = new FieldEntity();
        fieldEntity.setKey(key);
        fieldEntity.setType(DataType.typeOfObject(type).getValue());
        result = fieldEntity;
        if (type != null) {
            result.setValue(type.toString());
        }
    }
    result.setKey(key);
    return result;
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity) JSONObject(org.json.JSONObject) FieldEntity(org.gsonformat.intellij.entity.FieldEntity) IterableFieldEntity(org.gsonformat.intellij.entity.IterableFieldEntity) JSONArray(org.json.JSONArray)

Aggregations

FieldEntity (org.gsonformat.intellij.entity.FieldEntity)14 IterableFieldEntity (org.gsonformat.intellij.entity.IterableFieldEntity)10 ClassEntity (org.gsonformat.intellij.entity.ClassEntity)9 JSONObject (org.json.JSONObject)6 JSONArray (org.json.JSONArray)3 DefaultMutableTreeTableNode (org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)2 PsiClassReferenceType (com.intellij.psi.impl.source.PsiClassReferenceType)1 BorderLayout (java.awt.BorderLayout)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 JTree (javax.swing.JTree)1 TreePath (javax.swing.tree.TreePath)1