]> O.S.I.I.S - jp/crowedit.git/commitdiff
iml locations
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 22 Jul 2025 06:33:10 +0000 (08:33 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 22 Jul 2025 06:33:10 +0000 (08:33 +0200)
plugins/CECrowPlugin/src/CrowService.cs
plugins/CECrowPlugin/src/ForeignWidgetContainer.cs
plugins/CECrowPlugin/src/PropertyContainer.cs
plugins/CECrowPlugin/ui/winProperties.crow

index d06bf00c6fee83de8b5353c92ba4d87c02db0113..52a3a272ffcc72f4a51eca5a0ba6f2ce3255a3b8 100644 (file)
@@ -364,7 +364,7 @@ namespace CECrowPlugin
                        if (IsRunning)
                                delUnlockRenderMutex();
                }
-               
+
                bool dirtyState = false;
                bool DirtyState {
                        get {
@@ -619,6 +619,7 @@ namespace CECrowPlugin
                        fiWidget_design_id = typeWidget.GetField("design_id");
                        fiWidget_design_style_values = typeWidget.GetField("design_style_values");
                        fiWidget_design_style_locations = typeWidget.GetField("design_style_locations");
+                       fiWidget_design_iml_locations = typeWidget.GetField("design_iml_locations");
                        fiWidget_design_iml_values = typeWidget.GetField("design_iml_values");
                        fiWidget_design_line = typeWidget.GetField("design_line");
                        fiWidget_design_column = typeWidget.GetField("design_column");
@@ -645,7 +646,6 @@ namespace CECrowPlugin
                public Project CurrentSolution {
                        get => currentSolution;
                        set {
-                               //CERoslynPlugin.SolutionProject sol = value as CERoslynPlugin.SolutionProject;
                                if (currentSolution == value)
                                        return;
                                currentSolution = value;
@@ -655,15 +655,10 @@ namespace CECrowPlugin
                public Document CurrentDocument {
                        get => currentDocument;
                        set {
-                               //CERoslynPlugin.SolutionProject sol = value as CERoslynPlugin.SolutionProject;
                                if (currentDocument == value)
                                        return;
                                currentDocument = value;
                                NotifyValueChanged (currentDocument);
-
-                               /*if (currentDocument is ImlDocument iml) {
-                                       LoadIML(iml.source.ToString());
-                               }*/
                        }
                }
                
index fca86187776ec525c27cf16fdeb60a6db0929660..a5d474eff7af1dd5c44fc19551e1e2e8420990f0 100644 (file)
@@ -19,7 +19,9 @@ namespace CECrowPlugin
        public class ForeignWidgetContainer : CrowEditComponent {
                internal static Type typeWidget;//, typeGroup, typeContainer, typeTemplatedContainer, typeTemplatedGroup;
                //design mode members, present only if crow compiled with DESIGN_MODE enabled
-               internal static FieldInfo fiWidget_design_id, fiWidget_design_style_values,     fiWidget_design_iml_values, fiWidget_design_style_locations,
+               internal static FieldInfo fiWidget_design_id,
+                                                                       fiWidget_design_style_values, fiWidget_design_iml_values,
+                                                                       fiWidget_design_style_locations, fiWidget_design_iml_locations,
                                                                        fiWidget_design_line, fiWidget_design_column, fiWidget_design_imlPath,
                                                                        fiWidget_slot;
                Func<string> delGetName;
@@ -44,7 +46,7 @@ namespace CECrowPlugin
                        designColumn = (int)fiWidget_design_column?.GetValue(instance);
                        designImlPath = (string)fiWidget_design_imlPath?.GetValue(instance);
 
-                       //Console.WriteLine($"new ForeignWidgetContainer: {this} {parent}");
+                       //onsole.WriteLine($"new ForeignWidgetContainer: {this} {parent} {designImlPath}");
                }
 
 
@@ -101,6 +103,7 @@ namespace CECrowPlugin
                public Dictionary<string,string> ImlValues => fiWidget_design_iml_values.GetValue(instance) as Dictionary<string,string>;
                public Dictionary<string,string> StyleValues => fiWidget_design_style_values.GetValue(instance) as Dictionary<string,string>;
                public Dictionary<string,FileLocation> StyleLocation => fiWidget_design_style_locations.GetValue(instance) as Dictionary<string,FileLocation>;
+               public Dictionary<string,FileLocation> ImlLocation => fiWidget_design_iml_locations.GetValue(instance) as Dictionary<string,FileLocation>;
 
                public virtual bool IsExpanded {
                        get => isExpanded;
index 3c40b7d33aaa426d49033a1d347fb1bd7fe0a4e5..62459505d5f684c335fbf7f4942e0805ebd83f5a 100644 (file)
@@ -23,7 +23,7 @@ namespace CECrowPlugin
                ForeignWidgetContainer host;
                PropertyInfo pi;
 
-               Command cmdReset, cmdGoToStyle;
+               Command cmdReset, cmdGoToStyle, cmdGoToIml;
                public CommandGroup Commands;
 
                #region CTOR
@@ -33,15 +33,16 @@ namespace CECrowPlugin
 
                        cmdReset = new ActionCommand ("Reset to default", Reset, "", HasStyling | IsSetByIML);
                        cmdGoToStyle = new ActionCommand ("Goto style", GotoStyle, "#icons.edit.svg", HasStyling);
+                       cmdGoToIml = new ActionCommand ("Goto Iml", GotoIml, "#icons.edit.svg", HasImlLocation);
 
-                       Commands = new CommandGroup (cmdReset, cmdGoToStyle);
+                       Commands = new CommandGroup (cmdReset, cmdGoToStyle, cmdGoToIml);
                }
                #endregion
 
                public string DesignCategory {
                        get {
                                DesignCategory dca = (DesignCategory)pi.GetCustomAttribute (typeof(DesignCategory));
-                               return dca == null ? "Divers" : dca.Name;                                       
+                               return dca == null ? "Divers" : dca.Name;
                        }
                }
                public string Name => pi.Name;
@@ -78,6 +79,7 @@ namespace CECrowPlugin
                /// return true if current value comes from IML attributes
                /// </summary>
                public bool IsSetByIML => host.ImlValues.ContainsKey (Name);
+               public bool HasImlLocation => host.ImlLocation.ContainsKey(Name);
                /// <summary>
                /// return true if member default value comes from style
                /// </summary>
@@ -116,7 +118,7 @@ namespace CECrowPlugin
                        if (srv.CurrentSolution.TryGetFile(fl.FilePath, out IFileNode node)) {
                                if (App.OpenFile(node.FullPath) is TextDocument doc) {
                                        doc.IsSelected = true;
-                                       doc.SetLocation(new CharLocation(fl.Line, fl.Column));
+                                       doc.SetLocation(new CharLocation(fl.Line, fl.Column + doc.GetLineText(fl.Line).CountLeadingWhiteSpaces()));
                                }
                        }
                        
@@ -133,8 +135,26 @@ namespace CECrowPlugin
                        pf.IsSelected = true;*/
 
                }
+               public void GotoIml(){
+                       if (!HasImlLocation)
+                               return;
+                       FileLocation fl = host.ImlLocation[Name];
+                       Debug.WriteLine($"goto iml: {fl.FilePath}");
 
+                       CrowService srv = App.GetService<CrowService> ();
+                       if (srv.CurrentDocument is ImlDocument iml) {
+                               iml.SetLocation(new CharLocation(fl.Line, fl.Column + iml.GetLineText(fl.Line).CountLeadingWhiteSpaces()));
+                       }
+               }
                public override string ToString () => $"{Name} = {Value}";
+        public override bool IsSelected {
+                       get => base.IsSelected;
+                       set {
+                               base.IsSelected = value;
+                               if (isSelected && HasImlLocation)
+                                       GotoIml();
+                       }
+               }
        }
 }
 
index fb80901bf6f733e8eef81e73ff4543bcb2a5bfaa..1e5ecaecebaf46770e543a4d3d8215fbcae8dd4f 100644 (file)
@@ -13,7 +13,7 @@
                         <Label Text="{DesignPath}" />
                         <Label Text="{DesignLine}" />
                         <Label Text="{DesignColumn}" />
-                    </HorizontalStack>                    
+                    </HorizontalStack>
                     <HorizontalStack Margin="1">
                         <Scroller Name="ItemsScroller" Margin="2">
                             <VerticalStack Height="Fit" MinimumSize="10,10"
@@ -35,7 +35,7 @@
                         <TextBox Margin="1" Text="{²Value}" Height="Fit" Foreground="{LabForeground}" Font="mono, 12"/>
                     </HorizontalStack>
                 </ListItem>
-            </ItemTemplate>    
+            </ItemTemplate>
         </ListBox>
     </VerticalStack>
 </DockWindow>