Esempio n. 1
0
        public GetRevisionDlg(IList <P4.FileSpec> files, string specifier, string value, P4ScmProvider scm, bool isSolutionIncluded)
        {
            PreferenceKey = "GetRevisionDlg";

            _scm   = scm;
            _files = files;
            _isSolutionIncluded = isSolutionIncluded;

            InitializeComponent();

            this.Icon = Images.icon_p4vs_16px;
            // adding a header with header style set to none so that this
            // behaves as a single column list.
            ColumnHeader h = new ColumnHeader();

            h.Width = -2;
            filesListView.Columns.Add(h);
            IList <P4.FileMetaData> mdl = new List <P4.FileMetaData>();

            if (files != null)
            {
                foreach (FileSpec fs in files)
                {
                    // if LocalPath is null, it is likely that this was
                    // launched from somewhere only providing depot paths
                    // in that case, assume all LocalPaths for files will
                    // be null and break.
                    if (fs.LocalPath == null)
                    {
                        break;
                    }
                    if (fs.LocalPath.Path.EndsWith("..."))
                    {
                        mdl.Add(fs);
                    }
                    else
                    {
                        FileMetaData fmd = _scm.GetCachedFile(fs.LocalPath.Path);
                        if (fmd == null)
                        {
                            fmd = _scm.UpdateFileInCache(fs.LocalPath.Path, true);
                        }
                        // if it is still null, it is likely not in Perforce
                        if (fmd != null)
                        {
                            mdl.Add(fmd);
                        }
                    }
                }
                if (mdl.Count == 0)
                {
                    mdl = scm.GetFileMetaData(files, null);
                }
            }
            IList <object> fields = new List <object>();

            fields.Add(P4FileTreeListViewItem.SubItemFlag.DepotFullPath);

            if ((mdl != null) && (mdl.Count > 0))
            {
                foreach (P4.FileMetaData file in mdl)
                {
                    P4FileTreeListViewItem item = new P4FileTreeListViewItem(null, file, fields);
                    P4FileTreeListViewItem dupe = (P4FileTreeListViewItem)filesListView.FindItemWithText(item.Text);
                    if (dupe != item)
                    {
                        item.Tag      = file;
                        item.FileData = file;

                        filesListView.Items.Add(item);
                    }
                }
            }

            // dialog called from workspace tool window
            if (specifier == "workspace")
            {
                specifierCB.SelectedIndex = 4;
                specifierRB.Checked       = true;
                if (value != null)
                {
                    ValueTB.Text = value;
                }
            }

            // dialog called from solution explorer or VS menu
            if (specifier == "revision" ||
                specifier == "explorer")
            {
                specifierCB.SelectedIndex = 0;
                getLatestRB.Checked       = true;
            }

            // dialog called from submitted changelists tool window
            if (specifier == "changelist")
            {
                specifierCB.SelectedIndex  = 1;
                specifierRB.Checked        = true;
                changelistFilesChk.Enabled = true;
                if (value != null)
                {
                    ValueTB.Text = value;
                }
            }

            // dialog called from labels tool window
            if (specifier == "label")
            {
                specifierCB.SelectedIndex = 3;
                specifierRB.Checked       = true;
                removeChk.Enabled         = true;
                if (value != null)
                {
                    ValueTB.Text = value;
                }
            }
        }