diff --git a/packages/project-editor/core/objectAdapter.ts b/packages/project-editor/core/objectAdapter.ts index 91c7ec12..1bfbd65c 100644 --- a/packages/project-editor/core/objectAdapter.ts +++ b/packages/project-editor/core/objectAdapter.ts @@ -1616,10 +1616,22 @@ export class ListAdapter implements ITreeAdapter { const DocumentStore = getDocumentStore(this.object); + let aNewObject: IEezObject | undefined; + if (dropPosition == DropPosition.DROP_POSITION_BEFORE) { - DocumentStore.insertObjectBefore(dropItem.object, object); + aNewObject = DocumentStore.insertObjectBefore( + dropItem.object, + object + ); } else if (dropPosition == DropPosition.DROP_POSITION_AFTER) { - DocumentStore.insertObjectAfter(dropItem.object, object); + aNewObject = DocumentStore.insertObjectAfter( + dropItem.object, + object + ); + } + + if (aNewObject) { + this.selectObject(aNewObject); } } diff --git a/packages/project-editor/features/variable/variable.tsx b/packages/project-editor/features/variable/variable.tsx index e9baf788..38fe7d6a 100644 --- a/packages/project-editor/features/variable/variable.tsx +++ b/packages/project-editor/features/variable/variable.tsx @@ -862,6 +862,19 @@ export class StructureField extends EezObject { }, variableTypeProperty ], + check: (structureField: StructureField) => { + let messages: Message[] = []; + + if (!structureField.name) { + messages.push(propertyNotSetMessage(structureField, "name")); + } + + if (!structureField.type) { + messages.push(propertyNotSetMessage(structureField, "type")); + } + + return messages; + }, beforeLoadHook: (object: Variable, objectJS: any) => { migrateType(objectJS); }, @@ -1040,6 +1053,19 @@ export class EnumMember extends EezObject { type: PropertyType.Number } ], + check: (enumMember: EnumMember) => { + let messages: Message[] = []; + + if (!enumMember.name) { + messages.push(propertyNotSetMessage(enumMember, "name")); + } + + if (enumMember.value == undefined) { + messages.push(propertyNotSetMessage(enumMember, "value")); + } + + return messages; + }, defaultValue: {}, newItem: (parent: IEezObject) => { return showGenericDialog({ diff --git a/packages/project-editor/project/PropertiesPanel.tsx b/packages/project-editor/project/PropertiesPanel.tsx index ec4da0eb..ac5d6fcc 100644 --- a/packages/project-editor/project/PropertiesPanel.tsx +++ b/packages/project-editor/project/PropertiesPanel.tsx @@ -68,10 +68,13 @@ export class PropertiesPanel extends React.Component<{ render() { let title; - if (this.objects.length == 0) { + + const objects = this.objects.filter(object => object != undefined); + + if (objects.length == 0) { title = "Properties"; - } else if (this.objects.length == 1) { - let object = this.objects[0]; + } else if (objects.length == 1) { + let object = objects[0]; if (object instanceof EezValueObject) { object = getParent(object); } @@ -86,7 +89,7 @@ export class PropertiesPanel extends React.Component<{ title={title} body={ }