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);
}
}
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;
}
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);
}
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;
}
Aggregations