Exemple #1
0
        /// <summary>
        /// Opens the file member panel.
        /// </summary>
        /// <remarks>
        /// The base method propagates lookup openers.
        /// </remarks>
        internal virtual MemberPanel OpenFileMembers(FarFile file)
        {
            //??? _090610_071700, + $panel.SetOpen({ @ Test-Panel-Tree-.ps1
            object target = file.Data == null ? file : file.Data;

            MemberPanel panel = new MemberPanel(new MemberExplorer(target));

            panel._LookupOpeners = _LookupOpeners;

            var tablePanel = Far.Api.Panel as TablePanel;

            if (tablePanel != null)
            {
                if (!string.IsNullOrEmpty(tablePanel.ExcludeMemberPattern))
                {
                    panel.Explorer.ExcludeMemberPattern = tablePanel.ExcludeMemberPattern;
                }

                if (!string.IsNullOrEmpty(tablePanel.HideMemberPattern))
                {
                    panel.Explorer.HideMemberPattern = tablePanel.HideMemberPattern;
                }
            }

            //! use null as parent: this panel can be not open now
            panel.OpenChild(null);
            return(panel);
        }
Exemple #2
0
        /// <inheritdoc/>
        public override void UICreateFile(CreateFileEventArgs args)
        {
            if (args == null)
            {
                return;
            }

            // skip data panel
            if (Parent is DataPanel)
            {
                args.Result = JobResult.Ignore;
                return;
            }

            // call
            Explorer.CreateFile(args);
            if (args.Result != JobResult.Done)
            {
                return;
            }

            // update that panel if the instance is the same
            MemberPanel that = TargetPanel as MemberPanel;

            if (that != null && that.Target == Target)
            {
                that.UpdateRedraw(true);
            }
        }
Exemple #3
0
        /// <inheritdoc/>
        public override void DeleteFiles(DeleteFilesEventArgs args)
        {
            if (args == null)
            {
                return;
            }

            // skip not default modes
            if (MemberMode != 0)
            {
                args.Result = JobResult.Ignore;
                return;
            }

            // ask
            if (args.UI && 0 != (long)Far.Api.GetSetting(FarSetting.Confirmations, "Delete"))
            {
                if (Far.Api.Message("Delete selected members", Res.Delete, MessageOptions.None, new string[] { Res.Delete, Res.Cancel }) != 0)
                {
                    args.Result = JobResult.Ignore;
                    return;
                }
            }

            try
            {
                int count1 = Value.Properties.Count();

                foreach (FarFile file in args.Files)
                {
                    PSPropertyInfo pi = file.Data as PSPropertyInfo;
                    if (pi == null)
                    {
                        continue;
                    }

                    Value.Properties.Remove(pi.Name);
                }

                int count2 = Value.Properties.Count();
                if (count1 - args.Files.Count != count2)
                {
                    args.Result = JobResult.Incomplete;
                }
            }
            finally
            {
                // update always, some members can be deleted, don't leave them
                MemberPanel.WhenMemberChanged(Value);                 //????? will it be 2 times for THIS panel?
            }
        }
Exemple #4
0
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            if (!(file.Data is PSPropertyInfo pi))
            {
                return(null);
            }
            if (pi.Value == null)
            {
                return(null);
            }
            MemberPanel r = new MemberPanel(new MemberExplorer(pi.Value));

            r.OpenChild(this);
            return(r);
        }
Exemple #5
0
        ///
        protected override bool CanCloseChild()
        {
            MemberPanel mp = Child as MemberPanel;

            if (mp == null)
            {
                return(true);
            }

            DataRow dr = mp.Value.BaseObject as DataRow;

            if (dr == null)
            {
                return(true);
            }

            var xRowState = dr.RowState;

            if (0 == (xRowState & (DataRowState.Added | DataRowState.Deleted | DataRowState.Modified)))
            {
                return(true);
            }

            switch (Far.Api.Message(Res.AskSaveModified, "Save", MessageOptions.YesNoCancel))
            {
            case 0:
                // save data, update the table
                var result = SaveData();

                // now we can add a new file for the new record
                if (xRowState == DataRowState.Added)                         //_110330_175246
                {
                    DataRowFile file = new DataRowFile(dr, Map);
                    Explorer.Cache.Add(file);
                    PostFile(file);
                    ToUpdateData = true;
                }

                return(result);

            case 1:
                dr.RejectChanges();
                return(true);

            default:
                return(false);
            }
        }
Exemple #6
0
        /// <summary>
        /// Opens <see cref="MemberPanel"/> for a file.
        /// File <c>Data</c> must not be null.
        /// </summary>
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            // get data
            TreeFile t = (TreeFile)file;

            if (t.Data == null)
            {
                return(null);
            }

            //! use null as parent: this panel can be not open now
            MemberPanel r = new MemberPanel(new MemberExplorer(t.Data));

            r.OpenChild(null);
            return(r);
        }
Exemple #7
0
        internal static void SetPropertyFromTextUI(object target, PSPropertyInfo pi, string text)
        {
            bool   isPSObject;
            object value;
            string type;

            if (pi.Value is PSObject && (pi.Value as PSObject).BaseObject != null)
            {
                isPSObject = true;
                type       = (pi.Value as PSObject).BaseObject.GetType().FullName;
            }
            else
            {
                isPSObject = false;
                type       = pi.TypeNameOfValue;
            }

            if (type == "System.Collections.ArrayList" || type.EndsWith("]", StringComparison.Ordinal))
            {
                ArrayList lines = new ArrayList();
                foreach (var line in FarNet.Works.Kit.SplitLines(text))
                {
                    lines.Add(line);
                }
                value = lines;
            }
            else
            {
                value = text;
            }

            if (isPSObject)
            {
                value = PSObject.AsPSObject(value);
            }

            try
            {
                pi.Value = value;
                MemberPanel.WhenMemberChanged(target);
            }
            catch (RuntimeException ex)
            {
                Far.Api.Message(ex.Message, "Setting property");
            }
        }
Exemple #8
0
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            PSObject o          = PSObject.AsPSObject(file.Data);
            string   memberType = o.Properties["MemberType"].Value.ToString();

            if (!memberType.EndsWith("Property", StringComparison.Ordinal))             //??
            {
                return(null);
            }

            string name     = o.Properties[Word.Name].Value.ToString();
            object instance = Target.Properties[name].Value;

            if (instance == null)
            {
                return(null);
            }

            MemberPanel r = new MemberPanel(new MemberExplorer(instance));

            r.OpenChild(this);
            return(r);
        }
Exemple #9
0
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            PSObject o = PSObject.AsPSObject(file.Data);
            string memberType = o.Properties["MemberType"].Value.ToString();
            if (!memberType.EndsWith("Property", StringComparison.Ordinal)) //??
                return null;

            string name = o.Properties[Word.Name].Value.ToString();
            object instance = Target.Properties[name].Value;
            if (instance == null)
                return null;

            MemberPanel r = new MemberPanel(new MemberExplorer(instance));
            r.OpenChild(this);
            return r;
        }
Exemple #10
0
        /// <summary>
        /// Opens <see cref="MemberPanel"/> for a file.
        /// File <c>Data</c> must not be null.
        /// </summary>
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            // get data
            TreeFile t = (TreeFile)file;
            if (t.Data == null)
                return null;

            //! use null as parent: this panel can be not open now
            MemberPanel r = new MemberPanel(new MemberExplorer(t.Data));
            r.OpenChild(null);
            return r;
        }
Exemple #11
0
        /// <summary>
        /// Opens the file member panel.
        /// </summary>
        /// <remarks>
        /// The base method propagates lookup openers.
        /// </remarks>
        internal virtual MemberPanel OpenFileMembers(FarFile file)
        {
            //??? _090610_071700, + $panel.SetOpen({ @ Test-Panel-Tree-.ps1
            object target = file.Data == null ? file : file.Data;

            MemberPanel panel = new MemberPanel(new MemberExplorer(target));
            panel._LookupOpeners = _LookupOpeners;

            var tablePanel = Far.Api.Panel as TablePanel;
            if (tablePanel != null)
            {
                if (!string.IsNullOrEmpty(tablePanel.ExcludeMemberPattern))
                    panel.Explorer.ExcludeMemberPattern = tablePanel.ExcludeMemberPattern;

                if (!string.IsNullOrEmpty(tablePanel.HideMemberPattern))
                    panel.Explorer.HideMemberPattern = tablePanel.HideMemberPattern;
            }

            //! use null as parent: this panel can be not open now
            panel.OpenChild(null);
            return panel;
        }
Exemple #12
0
 internal override MemberPanel OpenFileMembers(FarFile file)
 {
     PSPropertyInfo pi = file.Data as PSPropertyInfo;
     if (pi == null)
         return null;
     if (pi.Value == null)
         return null;
     MemberPanel r = new MemberPanel(new MemberExplorer(pi.Value));
     r.OpenChild(this);
     return r;
 }