Exemple #1
0
        internal void BuildPlan(string sameType)
        {
            PanelPlan plan = GetPlan(PanelViewMode.AlternativeFull);
            if (plan == null)
                plan = new PanelPlan();

            // choose columns
            if (sameType == null)
            {
                //! The long "Index" clashes to sort order mark, use the short "##"
                plan.Columns = new FarColumn[]
                {
                new SetColumn() { Kind = "S", Name = "##"},
                new SetColumn() { Kind = "N", Name = "Value"},
                new SetColumn() { Kind = "Z", Name = "Type"}
                };
            }
            else
            {
                plan.Columns = new FarColumn[]
                {
                new SetColumn() { Kind = "N", Name = sameType }
                };
            }

            SetPlan(PanelViewMode.AlternativeFull, plan);
        }
Exemple #2
0
        internal ListPanel(Explorer explorer)
            : base(explorer)
        {
            PostName(_lastCurrentName);

            // 090411 Use custom Descriptions mode
            PanelPlan plan = new PanelPlan();
            plan.Columns = new FarColumn[]
            {
                new SetColumn() { Kind = "N", Name = "Name" },
                new SetColumn() { Kind = "Z", Name = "Value" }
            };
            SetPlan(PanelViewMode.AlternativeFull, plan);

            InvokingCommand += OnInvokingCommand;
        }
Exemple #3
0
        /// <summary>
        /// New tree panel with the explorer.
        /// </summary>
        /// <param name="explorer">The panel explorer.</param>
        public TreePanel(TreeExplorer explorer)
            : base(explorer)
        {
            IgnoreDirectoryFlag = true; // _090810_180151

            SortMode = PanelSortMode.Unsorted;

            // columns
            SetColumn cO = new SetColumn() { Kind = "O", Name = "Name" };
            SetColumn cZ = new SetColumn() { Kind = "Z", Name = "Description" };

            // mode: tree and description columns
            PanelPlan plan0 = new PanelPlan();
            plan0.Columns = new FarColumn[] { cO, cZ };
            SetPlan((PanelViewMode)0, plan0);

            // mode: tree column and description status
            PanelPlan plan1 = new PanelPlan();
            plan1.Columns = new FarColumn[] { cO };
            plan1.StatusColumns = new FarColumn[] { cZ };
            SetPlan((PanelViewMode)1, plan1);
        }
Exemple #4
0
 /// <summary>
 /// Sets the panel plan.
 /// </summary>
 /// <param name="mode">View mode to set the plan for.</param>
 /// <param name="plan">The plan. If it has no columns then a column "Name" is assumed.</param>
 public void SetPlan(PanelViewMode mode, PanelPlan plan)
 {
     _Panel.SetPlan(mode, plan);
 }
Exemple #5
0
 /// <summary>
 /// Sets the panel plan.
 /// </summary>
 /// <param name="mode">View mode to set the plan for.</param>
 /// <param name="plan">The plan. If it has no columns then a column "Name" is assumed.</param>
 public void SetPlan(PanelViewMode mode, PanelPlan plan)
 {
     _Panel.SetPlan(mode, plan);
 }
Exemple #6
0
        /// <inheritdoc/>
        public override IList<FarFile> DoGetFiles(GetFilesEventArgs args)
        {
            if (args == null) return null;

            var panel = args.Parameter as FormatPanel;

            // call the worker
            // _090408_232925 If we throw then FarNet returns false and Far closes the panel.
            object data;
            try
            {
                data = GetData(args);
            }
            catch (RuntimeException ex)
            {
                if (args.UI)
                    Far.Api.ShowError(Res.Me, ex);

                data = new List<FarFile>();
            }

            // if the data are files just use them, assume all is done
            IList<FarFile> readyFiles = data as IList<FarFile>;
            if (readyFiles != null)
            {
                Cache = readyFiles;
                return Cache;
            }

            // PS objects
            Collection<PSObject> values = (Collection<PSObject>)data;

            // empty?
            if (values.Count == 0)
            {
                // drop files in any case
                Cache.Clear();

                // no panel, no job
                if (panel == null)
                    return Cache;

                // respect custom columns
                if (Columns != null)
                    return Cache;

                // is it already <empty>?
                PanelPlan plan = panel.GetPlan(PanelViewMode.AlternativeFull);
                if (plan == null)
                    plan = new PanelPlan();
                else if (plan.Columns.Length == 1 && plan.Columns[0].Name == "<empty>")
                    return Cache;

                // reuse the mode: reset columns, keep other data intact
                plan.Columns = new FarColumn[] { new SetColumn() { Kind = "N", Name = "<empty>" } };
                panel.SetPlan(PanelViewMode.AlternativeFull, plan);
                return Cache;
            }

            // not empty; values has to be removed in any case
            try
            {
                // custom
                if (Columns != null)
                {
                    BuildFiles(values);
                    return Cache;
                }

                // Check some special cases and try to get the common type.
                // _100309_121508 Linear type case
                Type theType;
                if (Converter.IsLinearType(values[0].BaseObject.GetType()) ||
                    values[0].BaseObject is System.Collections.IEnumerable ||
                    null == (theType = A.FindCommonType(values)))
                {
                    // use index, value, type mode
                    if (panel != null)
                        panel.BuildPlan(Format.BuildFilesMixed(Cache, values));
                    return Cache;
                }

                Meta[] metas = null;

                // try to get format
                if (theType != typeof(PSCustomObject))
                    metas = Format.TryFormatByTableControl(values[0], panel == null ? 80 : panel.Window.Width); //???? avoid formatting at all

                // use members
                if (metas == null)
                    metas = Format.TryFormatByMembers(values, theType != null && theType == values[0].BaseObject.GetType());

                if (metas == null)
                {
                    if (panel != null)
                        panel.BuildPlan(Format.BuildFilesMixed(Cache, values));
                }
                else
                {
                    MakeMap(metas);
                    if (panel != null)
                        panel.SetPlan(PanelViewMode.AlternativeFull, Format.SetupPanelMode(Metas));

                    BuildFiles(values);
                }
            }
            finally
            {
                values.Clear();
            }

            return Cache;
        }
Exemple #7
0
        /// <summary>
        /// Gets meta objects for columns.
        /// </summary>
        /// <returns>Meta objects ready for column mapping.</returns>
        internal static PanelPlan SetupPanelMode(IList<Meta> metas)
        {
            PanelPlan r = new PanelPlan();

            r.Columns = new FarColumn[metas.Count];
            for (int i = 0; i < metas.Count; ++i)
                r.Columns[i] = metas[i];

            return r;
        }