Exemplo n.º 1
0
        protected override void PageLoadedCore(PageLoadedDirection direction)
        {
            if (direction == PageLoadedDirection.Forward)
            {
                if (SummaryRetreiver == null)
                {
                    return;
                }

                var entries = SummaryRetreiver.Invoke();
                m_dataGridView.Rows.Clear();

                foreach (var pair in entries)
                {
                    var row = new DataGridViewRow();
                    row.Cells.AddRange(new DataGridViewTextBoxCell {
                        Value = pair.Key
                    },
                                       new DataGridViewTextBoxCell {
                        Value = pair.Value
                    });
                    m_dataGridView.Rows.Add(row);
                }

                HelpersGUI.ResizeGridViewColumnToAllCells(Column2);//set properly the width of the last column
            }
        }
Exemplo n.º 2
0
 public override void PopulatePage()
 {
     m_dataGridView.Rows.Clear();
     SetButtonNextEnabled(true);
     FillTableRows();
     HelpersGUI.ResizeGridViewColumnToAllCells(m_colTargetNet);//set properly the width of the last column
 }
        public override void PopulatePage()
        {
            if (templatesOnly)
            {
                if (selectionCount > 1)
                {
                    m_labelIntro.Text = Messages.CPM_WIZARD_FINISH_PAGE_INTRO_COPY_TEMPLATE;
                }
                else
                {
                    m_labelIntro.Text = Messages.CPM_WIZARD_FINISH_PAGE_INTRO_COPY_SINGLE_TEMPLATE;
                }
            }
            else
            {
                if (selectionCount > 1)
                {
                    m_labelIntro.Text = wizardMode == WizardMode.Copy ? Messages.CPM_WIZARD_FINISH_PAGE_INTRO_COPY : Messages.CPM_WIZARD_FINISH_PAGE_INTRO;
                }
                else
                {
                    m_labelIntro.Text = wizardMode == WizardMode.Copy ? Messages.CPM_WIZARD_FINISH_PAGE_INTRO_COPY_SINGLE : Messages.CPM_WIZARD_FINISH_PAGE_INTRO_SINGLE;
                }
            }

            if (SummaryRetreiver == null)
            {
                return;
            }

            var entries = SummaryRetreiver.Invoke();

            m_dataGridView.Rows.Clear();
            panelErrorsFound.Visible = false;

            foreach (var pair in entries)
            {
                var row = new DataGridViewRow();

                DataGridViewTextBoxCell valueCell = new DataGridViewTextBoxCell()
                {
                    Value = pair.Value
                };
                if (pair.Errors)
                {
                    valueCell.Style.Font     = new Font(m_dataGridView.Font, FontStyle.Bold);
                    panelErrorsFound.Visible = true;
                }

                row.Cells.AddRange(new DataGridViewTextBoxCell {
                    Value = pair.Key
                }, valueCell);
                m_dataGridView.Rows.Add(row);
            }

            HelpersGUI.ResizeGridViewColumnToAllCells(Column2);//set properly the width of the last column
        }
Exemplo n.º 4
0
        public override void PopulatePage()
        {
            m_dataGridView.Rows.Clear();
            SetButtonNextEnabled(false);

            if (LoadsRemoteData)
            {
                m_buttonRefresh.Enabled       = false;
                pictureBoxError.Image         = Images.StaticImages.ajax_loader;
                labelError.Text               = Messages.CONVERSION_NETWORK_PAGE_QUERYING_NETWORKS;
                tableLayoutPanelError.Visible = true;
                backgroundWorker1.RunWorkerAsync();
            }
            else
            {
                FillTableRows();
                HelpersGUI.ResizeGridViewColumnToAllCells(m_colTargetNet);//set properly the width of the last column
            }
        }
Exemplo n.º 5
0
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                tableLayoutPanelError.Visible = false;
                return;
            }
            else if (e.Error != null)
            {
                pictureBoxError.Image = Images.StaticImages._000_error_h32bit_16;
                labelError.Text       = Messages.CONVERSION_NETWORK_PAGE_QUERYING_NETWORKS_FAILURE;
            }
            else
            {
                tableLayoutPanelError.Visible = false;
                FillTableRows();
                HelpersGUI.ResizeGridViewColumnToAllCells(m_colTargetNet);//set properly the width of the last column
            }

            m_buttonRefresh.Enabled = true;
        }
Exemplo n.º 6
0
        public override void PopulatePage()
        {
            if (SummaryRetriever == null)
            {
                return;
            }

            var entries = SummaryRetriever.Invoke();

            m_dataGridView.Rows.Clear();

            foreach (var pair in entries)
            {
                var row = new DataGridViewRow();
                row.Cells.AddRange(new DataGridViewTextBoxCell {
                    Value = pair.Key
                }, new DataGridViewTextBoxCell {
                    Value = pair.Value
                });
                m_dataGridView.Rows.Add(row);
            }

            HelpersGUI.ResizeGridViewColumnToAllCells(Column2);//set properly the width of the last column
        }
        private void PopulateDataGridView(IEnableableXenObjectComboBoxItem selectedItem)
        {
            Program.AssertOnEventThread();

            updatingHomeServerList = true;
            try
            {
                var target = m_comboBoxConnection.SelectedItem as DelayLoadingOptionComboBoxItem;

                m_dataGridView.SuspendLayout();

                ClearDataGridView();

                var hasPoolSharedStorage = target != null && HasPoolSharedStorage(target.Item.Connection);

                foreach (var kvp in m_vmMappings)
                {
                    var tb = new DataGridViewTextBoxCell {
                        Value = kvp.Value.VmNameLabel, Tag = kvp.Key
                    };
                    var cb = new DataGridViewEnableableComboBoxCell {
                        FlatStyle = FlatStyle.Flat
                    };
                    var homeserverFilters = CreateTargetServerFilterList(selectedItem, new List <string> {
                        kvp.Key
                    });

                    if (target != null)
                    {
                        if (hasPoolSharedStorage)
                        {
                            foreach (var pool in target.Item.Connection.Cache.Pools)
                            {
                                var item = new NoTargetServerPoolItem(pool);
                                cb.Items.Add(item);

                                if ((m_selectedObject != null && m_selectedObject.opaque_ref == pool.opaque_ref) ||
                                    (target.Item.opaque_ref == pool.opaque_ref))
                                {
                                    cb.Value = item;
                                }

                                break; //there exists one pool per connection
                            }
                        }

                        var sortedHosts = new List <Host>(target.Item.Connection.Cache.Hosts);
                        sortedHosts.Sort();

                        foreach (var host in sortedHosts)
                        {
                            var item = new DelayLoadingOptionComboBoxItem(host, homeserverFilters);
                            item.LoadSync();
                            cb.Items.Add(item);
                            if (item.Enabled && ((m_selectedObject != null && m_selectedObject.opaque_ref == host.opaque_ref) ||
                                                 (target.Item.opaque_ref == host.opaque_ref)))
                            {
                                cb.Value = item;
                            }
                        }
                    }

                    SetComboBoxPreSelection(cb);

                    var row = new DataGridViewRow();
                    row.Cells.AddRange(tb, cb);
                    m_dataGridView.Rows.Add(row);
                }

                HelpersGUI.ResizeGridViewColumnToAllCells(m_colTarget); //set properly the width of the last column

                if (restoreGridHomeServerSelection)
                {
                    RestoreGridHomeServerSelectionFromMapping();
                    restoreGridHomeServerSelection = false;
                }
            }
            finally
            {
                updatingHomeServerList = false;
                m_dataGridView.ResumeLayout();
            }
        }
Exemplo n.º 8
0
 public void Expand()
 {
     ValueColumn.MinimumWidth = 5;
     HelpersGUI.ResizeGridViewColumnToAllCells(ValueColumn);
     ToggleExpandedState(true);
 }
        public override void PopulatePage()
        {
            m_dataGridView.Rows.Clear();
            m_ctrlError.HideError();
            bool checkSpaceRequirements = true;

            var targetRefs = new List <object>();

            foreach (var mapping in m_vmMappings.Values.Where(mapping => !targetRefs.Contains(mapping.XenRef)))
            {
                targetRefs.Add(mapping.XenRef);
            }

            var commonSRs = new List <ToStringWrapper <SR> >();

            foreach (var kvp in m_vmMappings)
            {
                string sysId     = kvp.Key;
                var    vmMapping = kvp.Value;

                int i = 0;
                foreach (IStorageResource resourceData in ResourceData(sysId))
                {
                    if (!resourceData.TryCalcRequiredDiskCapacity(out _))
                    {
                        continue;
                    }

                    string disklabel = !string.IsNullOrEmpty(resourceData.DiskLabel)
                                        ? string.Format("{0} - {1}", vmMapping.VmNameLabel, resourceData.DiskLabel)
                                                                : string.Format("{0} - {1} {2}", vmMapping.VmNameLabel, Messages.STORAGE_DISK, i);

                    var cellVmDisk = new DataGridViewTextBoxCell
                    {
                        Tag = new StorageDetail
                        {
                            SysId = sysId, ResourceData = resourceData
                        },
                        Value = FormatDiskValueText(resourceData, disklabel)
                    };

                    DataGridViewRow row = new DataGridViewRow();
                    row.Cells.AddRange(cellVmDisk);

                    var cb = FillGridComboBox(vmMapping.XenRef, targetRefs, resourceData, ref commonSRs);

                    if (cb.Items.Count > 0)
                    {
                        cb.DisplayMember = ToStringWrapper <SR> .DisplayMember;
                        cb.ValueMember   = ToStringWrapper <SR> .ValueMember;
                        if (cb.Value == null)
                        {
                            cb.Value = cb.Items[0];
                        }
                        cb.Tag = resourceData.Tag;
                        row.Cells.Add(cb);
                    }
                    else
                    {
                        var cellError = new DataGridViewTextBoxCell {
                            Value = Messages.IMPORT_SELECT_STORAGE_PAGE_ERROR_NO_SR_AVAILABLE
                        };
                        row.Cells.Add(cellError);
                        cellError.ReadOnly = true;                         //this has to be set after the cell is added to a row
                        SetButtonNextEnabled(false);
                        checkSpaceRequirements = false;
                    }

                    m_dataGridView.Rows.Add(row);
                    i++;
                }
            }
            HelpersGUI.ResizeGridViewColumnToAllCells(m_colStorage);//set properly the width of the last column

            m_comboBoxSr.Items.Clear();

            PopulateSrComboBox(commonSRs);

            if (m_comboBoxSr.Items.Count == 0)
            {
                m_comboBoxSr.Items.Add(Messages.IMPORT_SELECT_STORAGE_PAGE_ERROR_NO_COMMON_SR_AVAILABLE);
                SetButtonNextEnabled(false);
                checkSpaceRequirements   = false;
                m_radioSpecifySr.Checked = true;
            }
            else
            {
                m_radioAllOnSameSr.Checked = true;
            }

            m_comboBoxSr.SelectedItem = m_comboBoxSr.Items[DetermineDefaultSrPositionInComboBox()];

            if (checkSpaceRequirements)
            {
                PerformCheck(CheckStorageRequirements);
            }
        }
Exemplo n.º 10
0
        private void RepopulateListBox()
        {
            Program.AssertOnEventThread();

            if (!GridViewSubjectList.Enabled)
            {
                return;
            }

            Dictionary <string, bool> selectedSubjectUuids = new Dictionary <string, bool>();
            Dictionary <string, bool> expandedSubjectUuids = new Dictionary <string, bool>();
            bool   rootExpanded = false;
            string topSubject   = "";

            if (GridViewSubjectList.FirstDisplayedScrollingRowIndex > 0)
            {
                AdSubjectRow topRow = GridViewSubjectList.Rows[GridViewSubjectList.FirstDisplayedScrollingRowIndex] as AdSubjectRow;
                if (topRow != null && topRow.subject != null)
                {
                    topSubject = topRow.subject.uuid;
                }
            }

            if (GridViewSubjectList.SelectedRows.Count > 0)
            {
                foreach (AdSubjectRow r in GridViewSubjectList.SelectedRows)
                {
                    if (r.subject != null)
                    {
                        selectedSubjectUuids.Add(r.subject.uuid, true);
                    }
                }
            }
            foreach (AdSubjectRow row in GridViewSubjectList.Rows)
            {
                if (row.Expanded)
                {
                    if (row.subject == null)
                    {
                        rootExpanded = true;
                    }
                    else
                    {
                        expandedSubjectUuids.Add(row.subject.uuid, true);
                    }
                }
            }

            try
            {
                _updateInProgress = true;
                GridViewSubjectList.SuspendLayout();

                foreach (AdSubjectRow row in GridViewSubjectList.Rows)
                {
                    if (row.IsLocalRootRow)
                    {
                        continue;
                    }
                    row.subject.PropertyChanged -= subject_PropertyChanged;
                }

                GridViewSubjectList.Rows.Clear();

                var rows = new List <DataGridViewRow> {
                    new AdSubjectRow(null)
                };                                                      //local root account

                foreach (Subject subject in _connection.Cache.Subjects) //all other subjects in the pool
                {
                    subject.PropertyChanged += subject_PropertyChanged;
                    rows.Add(new AdSubjectRow(subject));
                }
                GridViewSubjectList.Rows.AddRange(rows.ToArray());

                GridViewSubjectList.Sort(GridViewSubjectList.SortedColumn ?? ColumnSubject,
                                         GridViewSubjectList.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending);

                // restore old selection, old expansion state and top row
                foreach (AdSubjectRow r in GridViewSubjectList.Rows)
                {
                    r.Selected = !r.IsLocalRootRow && selectedSubjectUuids.ContainsKey(r.subject.uuid);
                    r.Expanded = r.IsLocalRootRow ? rootExpanded : expandedSubjectUuids.ContainsKey(r.subject.uuid);

                    if (!r.IsLocalRootRow && topSubject == r.subject.uuid)
                    {
                        GridViewSubjectList.FirstDisplayedScrollingRowIndex = r.Index;
                    }
                }
                if (GridViewSubjectList.SelectedRows.Count == 0)
                {
                    GridViewSubjectList.Rows[0].Selected = true;
                }

                HelpersGUI.ResizeGridViewColumnToAllCells(ColumnSubject);
                HelpersGUI.ResizeGridViewColumnToAllCells(ColumnRoles);
                HelpersGUI.ResizeGridViewColumnToAllCells(ColumnStatus);
            }
            finally
            {
                GridViewSubjectList.ResumeLayout();
                _updateInProgress = false;
                EnableButtons();
            }
        }
Exemplo n.º 11
0
        private void BuildList()
        {
            Program.AssertOnEventThread();
            if (!this.Visible)
            {
                return;
            }
            try
            {
                dataGridViewStorage.SuspendLayout();
                DataGridViewSelectedRowCollection vbdSavedItems = dataGridViewStorage.SelectedRows;

                dataGridViewStorage.Rows.Clear();

                if (vm == null)
                {
                    return;
                }

                bool storageLinkColumnVisible = false;

                List <bool> devices_in_use = new List <bool>();
                foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs))
                {
                    vbd.PropertyChanged -= new PropertyChangedEventHandler(vbd_PropertyChanged);
                    vbd.PropertyChanged += new PropertyChangedEventHandler(vbd_PropertyChanged);

                    if (!vbd.IsCDROM() && !vbd.IsFloppyDrive())
                    {
                        VDI vdi = vm.Connection.Resolve(vbd.VDI);
                        if (vdi == null || !vdi.Show(Properties.Settings.Default.ShowHiddenVMs))
                        {
                            continue;
                        }

                        SR sr = vm.Connection.Resolve(vdi.SR);
                        if (sr == null || sr.IsToolsSR())
                        {
                            continue;
                        }

                        storageLinkColumnVisible = vdi.sm_config.ContainsKey("SVID");

                        vdi.PropertyChanged -= new PropertyChangedEventHandler(vdi_PropertyChanged);
                        vdi.PropertyChanged += new PropertyChangedEventHandler(vdi_PropertyChanged);

                        dataGridViewStorage.Rows.Add(new VBDRow(vbd, vdi, sr));

                        int i;
                        if (int.TryParse(vbd.userdevice, out i))
                        {
                            while (devices_in_use.Count <= i)
                            {
                                devices_in_use.Add(false);
                            }
                            devices_in_use[i] = true;
                        }
                    }

                    //CA-47050: the dnsColumn should be autosized to Fill, but should not become smaller than a minimum
                    //width, which is chosen to be the column's contents (including header) width. To find what this is
                    //set temporarily the column's autosize mode to AllCells.
                    HelpersGUI.ResizeGridViewColumnToAllCells(ColumnDevicePath);
                }


                storageLinkColumn.Visible = storageLinkColumnVisible;
                dataGridViewStorage.Sort(dataGridViewStorage.SortedColumn, dataGridViewStorage.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending);

                IEnumerable <VBD> vbdsSelected = from VBDRow row in vbdSavedItems select row.VBD;
                foreach (VBDRow row in dataGridViewStorage.Rows)
                {
                    row.Selected = vbdsSelected.Contains(row.VBD);
                }
            }
            catch (Exception e)
            {
                log.ErrorFormat("Exception building VM storage list: {0}", e.Message);
            }
            finally
            {
                dataGridViewStorage.ResumeLayout();
            }
            UpdateButtons();
        }