Index: /oup/current/FileClasses/_EmptyFile.pas
===================================================================
--- /oup/current/FileClasses/_EmptyFile.pas	(revision 237)
+++ /oup/current/FileClasses/_EmptyFile.pas	(revision 238)
@@ -8,20 +8,8 @@
 type
   TFile_Empty = class(TFile)
-    public
-      procedure InitDataFields; override;
   end;
 
 implementation
 
-uses
-  ConnectionManager, Math, Classes, TypeDefs, _DataTypes;
-
-procedure TFile_Empty.InitDataFields;
-begin
-  inherited;
-  FDataFields := TBlock.Create(Self, nil, 'Base', '', []);
-end;
-
-
 end.
 
Index: /oup/current/FileClasses/_FileTypes.pas
===================================================================
--- /oup/current/FileClasses/_FileTypes.pas	(revision 237)
+++ /oup/current/FileClasses/_FileTypes.pas	(revision 238)
@@ -66,14 +66,9 @@
   FChanged := False;
 
+  FDataFields := nil;
+  FEditor := nil;
+
   if not (Self is TFile_Empty) then
-  begin
-    FDataFields := nil;
     InitDataFields;
-    FEditor := nil;
-  end
-  else
-  begin
-    FEditor := nil;
-  end;
 end;
 
@@ -106,5 +101,7 @@
 begin
   if FDataFields <> nil then
-    Result := FDataFields.ChildCount;
+    Result := FDataFields.ChildCount
+  else
+    Result := 0;
 end;
 
Index: /oup/current/FileClasses/_TreeElement.pas
===================================================================
--- /oup/current/FileClasses/_TreeElement.pas	(revision 237)
+++ /oup/current/FileClasses/_TreeElement.pas	(revision 238)
@@ -11,4 +11,5 @@
     private
     public
+      property ConnectionID: Integer read FConnectionID;
       property ChildCount: Integer read GetChildCount;
       property Child[ID: Integer]: TTreeElement read GetChild;
Index: /oup/current/Tools/MetaEditor.dfm
===================================================================
--- /oup/current/Tools/MetaEditor.dfm	(revision 237)
+++ /oup/current/Tools/MetaEditor.dfm	(revision 238)
@@ -47,4 +47,5 @@
       OnGetText = VSTGetText
       OnPaintText = VSTPaintText
+      OnGetPopupMenu = VSTGetPopupMenu
       OnInitChildren = VSTInitChildren
       Columns = <
@@ -79,8 +80,4 @@
         Caption = 'Meta Edit'
         ImageIndex = 1
-        ExplicitLeft = 0
-        ExplicitTop = 0
-        ExplicitWidth = 0
-        ExplicitHeight = 0
       end
       object tab_hex: TTabSheet
@@ -313,3 +310,15 @@
     Top = 340
   end
+  object vst_popup: TPopupMenu
+    AutoHotkeys = maManual
+    Left = 80
+    Top = 204
+    object vst_newRoot: TMenuItem
+      Caption = 'Set as root element in new window'
+    end
+    object vst_setRoot: TMenuItem
+      Caption = 'Set as root element here'
+      OnClick = vst_setRootClick
+    end
+  end
 end
Index: /oup/current/Tools/MetaEditor.pas
===================================================================
--- /oup/current/Tools/MetaEditor.pas	(revision 237)
+++ /oup/current/Tools/MetaEditor.pas	(revision 238)
@@ -31,4 +31,7 @@
     btn_export: TButton;
     btn_import: TButton;
+    vst_popup: TPopupMenu;
+    vst_newRoot: TMenuItem;
+    vst_setRoot: TMenuItem;
     procedure FormCreate(Sender: TObject);
     procedure VSTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode;
@@ -45,8 +48,13 @@
       const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
       TextType: TVSTTextType);
+    procedure VSTGetPopupMenu(Sender: TBaseVirtualTree; Node: PVirtualNode;
+      Column: TColumnIndex; const P: TPoint; var AskParent: Boolean;
+      var PopupMenu: TPopupMenu);
+    procedure vst_setRootClick(Sender: TObject);
   private
     root: TTreeElement;
     procedure NewCon(ID: Integer);
   public
+    procedure SetRoot(TreeElem: TTreeElement);
   end;
 
@@ -76,28 +84,30 @@
 
 procedure TForm_Meta.NewCon(ID: Integer);
+begin
+  if ID >= 0 then
+    SetRoot(ConManager.Connection[FConnectionID].MetaData.Root);
+end;
+
+
+procedure TForm_Meta.SetRoot(TreeElem: TTreeElement);
 var
   i: Integer;
   data: TNodeData;
   node: PVirtualNode;
-  Meta: TMetaManager;
-  root: TTreeElement;
-begin
-  if ID >= 0 then
-  begin
-    //VST
-    VST.Clear;
-    VST.BeginUpdate;
-//    root := ConManager.Connection[FConnectionID].MetaData.Root;
-    root := ConManager.Connection[FConnectionID].MetaData.FileById[454];
-    for i := 0 to root.ChildCount - 1 do
-    begin
-      data.Field := root.Child[i];
-      node := AddVSTEntry(VST, nil, data);
+begin
+  if FConnectionID <> TreeElem.ConnectionID then
+    SelectConnection(TreeElem.ConnectionID);
+  root := TreeElem;
+  VST.Clear;
+  VST.BeginUpdate;
+  for i := 0 to root.ChildCount - 1 do
+  begin
+    data.Field := root.Child[i];
+    node := AddVSTEntry(VST, nil, data);
+    if data.Field.ChildCount > 0 then
       VST.HasChildren[node] := True;
-    end;
-    VST.EndUpdate;
-  end;
-end;
-
+  end;
+  VST.EndUpdate;
+end;
 
 procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree;
@@ -239,4 +249,36 @@
 
 
+procedure TForm_Meta.VSTGetPopupMenu(Sender: TBaseVirtualTree;
+  Node: PVirtualNode; Column: TColumnIndex; const P: TPoint;
+  var AskParent: Boolean; var PopupMenu: TPopupMenu);
+var
+  data: PNodeData;
+begin
+  inherited;
+  AskParent := False;
+  if Assigned(Node) then
+  begin
+    Sender.Selected[Node] := True;
+    Sender.FocusedNode := Node;
+    data := Sender.GetNodeData(Node);
+    if Column = 0 then
+    begin
+      if TTreeElement(data.Field).GetChildCount > 0 then
+        PopupMenu := vst_popup
+      else
+        PopupMenu := nil;
+    end;
+  end;
+end;
+
+procedure TForm_Meta.vst_setRootClick(Sender: TObject);
+var
+  data: PNodeData;
+begin
+  inherited;
+  data := VST.GetNodeData(VST.FocusedNode);
+  SetRoot(data.Field);
+end;
+
 procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction);
 begin
