Пример #1
0
        public void InitView(P4ScmProvider _scm, IList <string> files, IList <object> fields)
        {
            listItemMap = new Dictionary <string, P4ObjectTreeListViewItem>();

            IList <P4.FileSpec> fs = P4.FileSpec.LocalSpecList(files.ToArray());

            Files  = _scm.GetFileMetaData(fs, null);
            Fields = fields;

            foreach (P4.FileMetaData file in Files)
            {
                P4FileTreeListViewItem it = new P4FileTreeListViewItem(null, file, (IList <object>)Fields);
                listItemMap.Add(file.DepotPath.Path, it);
                this.Items.Add(it);
            }
        }
Пример #2
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            try
            {
                DepotPathDlg dlg = new DepotPathDlg(_scm.SccService, Resources.GetRevisionDlg_AddFilesFoldersPrompt, false);


                if (DialogResult.OK == dlg.ShowDialog())
                {
                    string depotPath = null;
                    if (dlg.SelectedFile != null)
                    {
                        depotPath = dlg.SelectedFile;
                    }

                    P4.FileMetaData f = new P4.FileMetaData();
                    f.DepotPath = new P4.DepotPath(depotPath);
                    IList <P4.FileMetaData> fmd    = null;
                    IList <object>          fields = new List <object>();
                    fields.Add(P4FileTreeListViewItem.SubItemFlag.DepotFullPath);
                    P4FileTreeListViewItem lvi = new P4FileTreeListViewItem(null, f, fields);

                    if (depotPath != null && depotPath.EndsWith("/..."))
                    {
                        try
                        {
                            P4.Options options = new P4.Options();
                            //options["Op"] = null;
                            options["-m"] = "1";

                            fmd = _scm.GetFileMetaData(options, depotPath);
                        }
                        catch (P4Exception ex)
                        {
                            if (!(ex.ErrorCode == P4ClientError.MsgDb_NotUnderRoot))
                            {
                                MessageBox.Show(ex.Message, Resources.P4VS);
                                return;
                            }
                        }



                        //lvi.Text = depotPath;


                        foreach (ListViewItem item in filesListView.Items)
                        {
                            if (item.Text.Equals(lvi.Text))
                            {
                                return;
                            }
                        }

                        filesListView.Items.Add(lvi);
                    }

                    else
                    {
                        P4.FileMetaData file = null;
                        {
                            try
                            {
                                file = _scm.GetFileMetaData(depotPath);
                            }
                            catch (P4.P4Exception ex)
                            {
                                if ((ex.ErrorCode == P4.P4ClientError.MsgDb_NotUnderRoot) ||
                                    (ex.ErrorCode == P4.P4ClientError.MsgDb_NotUnderClient))
                                {
                                }
                                else
                                {
                                    MessageBox.Show(ex.Message, Resources.P4VS);
                                    //LogExeption(ex);

                                    return;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, Resources.P4VS);
                                return;
                            }

                            if (file != null && file.LocalPath != null)
                            {
                                lvi.Text = file.LocalPath.Path;
                            }
                            else
                            {
                                if (file != null && file.DepotPath != null)
                                {
                                    lvi.Text = file.DepotPath.Path;
                                }
                            }


                            foreach (ListViewItem item in filesListView.Items)
                            {
                                if (item.Text.Equals(lvi.Text))
                                {
                                    return;
                                }
                            }

                            filesListView.Items.Add(lvi);
                        }
                    }
                    filesListView.Refresh();

                    newOKBtn.Enabled = filesListView.Items.Count > 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.P4VS);
                this.DialogResult = DialogResult.Cancel;
            }
        }
Пример #3
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;
                }
            }
        }