Esempio n. 1
0
        public void RefreshXML(bool refreshFromServer)
        {
            int cursorPos      = getLineNumberOfCaret();
            int selectionStart = fctbItemXml.SelectionStart;

            if (refreshFromServer)
            {
                try
                {
                    mainForm.login();
                    equellaClient = mainForm.equellaClient;

                    string unindentedItemXML = equellaClient.getItem(itemID, itemVersion, "");

                    equellaClient.logout();

                    // load the filtered and unfiltered XML
                    itemXMLDoc.LoadXml(unindentedItemXML);
                    updateFilteredXmlfromUnfiltered(true);
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message, "Error retrieving item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            StringWriter  sw = new StringWriter();
            XmlTextWriter xw = new XmlTextWriter(sw);

            xw.Formatting = Formatting.Indented;

            if (chkHideSystemMetadata.Checked)
            {
                itemXMLFilteredDoc.WriteTo(xw);
            }
            else
            {
                itemXMLDoc.WriteTo(xw);
            }

            string indentedItemXMLString = sw.ToString();

            fctbItemXml.Text           = indentedItemXMLString;
            fctbItemXml.SelectionStart = cursorPos;

            fctbItemXml.Navigate(cursorPos);
            fctbItemXml.SelectionStart = selectionStart;
        }
Esempio n. 2
0
        private void btnEditSave_Click(object sender, EventArgs e)
        {
            if (!editModeEnabled)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    // set form to edit mode
                    this.Text              = "Editing " + itemID + "/" + itemVersion.ToString();
                    fctbItemXml.ReadOnly   = false;
                    fctbItemXml.AcceptsTab = true;
                    btnEditSave.Text       = "Save";
                    btnClose.Text          = "Cancel";
                    editModeEnabled        = true;
                    btnRefresh.Enabled     = false;
                    fctbItemXml.Focus();

                    // start item editing session
                    mainForm.login();
                    equellaClient = mainForm.equellaClient;
                    equellaClient.unlock(itemID, itemVersion);
                    string itemEditingXml = equellaClient.editItem(itemID, itemVersion, copyToStaging);
                    itemXMLDoc.LoadXml(itemEditingXml);
                    updateFilteredXmlfromUnfiltered(true);
                    RefreshXML(false);
                    btnGoDown.Enabled               = false;
                    btnGoUp.Enabled                 = false;
                    dirtyUI                         = false;
                    toolStripViewXml.BackColor      = Color.Pink;
                    chkHideSystemMetadata.BackColor = toolStripViewXml.BackColor;
                    this.Cursor                     = Cursors.Arrow;
                }
                catch (Exception err)
                {
                    this.Cursor = Cursors.Arrow;
                    MessageBox.Show(err.Message, "Error editing item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                try
                {
                    this.Cursor  = Cursors.WaitCursor;
                    this.Enabled = false;

                    // save item
                    saveItem();

                    // refresh XML
                    RefreshXML(true);
                    dirtyUI = false;

                    // reload the datagrid row
                    mainForm.updateDataGridResultsRow(itemID, itemVersion, itemXMLDoc.FirstChild);

                    // reset form to read-only mode
                    this.Text                       = "Viewing " + itemID + "/" + itemVersion.ToString();
                    fctbItemXml.ReadOnly            = true;
                    fctbItemXml.AcceptsTab          = false;
                    btnEditSave.Text                = "Edit";
                    btnClose.Text                   = "Close";
                    editModeEnabled                 = false;
                    btnRefresh.Enabled              = true;
                    btnGoDown.Enabled               = true;
                    btnGoUp.Enabled                 = true;
                    this.Enabled                    = true;
                    toolStripViewXml.BackColor      = SystemColors.Control;
                    chkHideSystemMetadata.BackColor = toolStripViewXml.BackColor;
                    this.Cursor                     = Cursors.Arrow;
                }
                catch (Exception err)
                {
                    this.Enabled = true;
                    this.Cursor  = Cursors.Arrow;
                    MessageBox.Show(err.Message, "Error saving item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }