public override void Run() { var wb = Workbench.Instance; var svc = ServiceRegistry.GetService <ServerConnectionManager>(); var omgr = ServiceRegistry.GetService <OpenResourceManager>(); var exp = wb.ActiveSiteExplorer; if (exp != null) { var conn = svc.GetConnection(exp.ConnectionName); var resSvc = conn.ResourceService; var items = exp.SelectedItems; if (items.Length > 0) { //Ascertain the parent connection that requires refresh post-delete string connName = items.First().ConnectionName; var dependentResourceIds = CollectDependentResources(items, svc); if (Confirm(dependentResourceIds)) { if (ConfirmDeleteOpenResources(items, omgr.OpenEditors)) { //Close any open editors on these resources before deleting them foreach (var i in items) { omgr.CloseEditors(conn, i.ResourceId, true); foreach (var ed in omgr.OpenEditors) { if (i.IsFolder && ed.EditorService.ResourceID.StartsWith(i.ResourceId)) { ed.Close(true); } } } DoDelete(wb, resSvc, items); } else { return; } } else { return; } //Refresh the parent. Multi-select is only allowed from same parent //so we should get the same result var parent = ResourceIdentifier.GetParentFolder(items[0].ResourceId); if (parent == null) //root? { exp.RefreshModel(connName); } else { exp.RefreshModel(connName, parent); } } } }
private void btnRefresh_Click(object sender, EventArgs e) { var item = repoView.SelectedItem; if (item.IsFolder) { repoView.RefreshModel(item.ResourceId); } else { var parent = ResourceIdentifier.GetParentFolder(item.ResourceId); repoView.RefreshModel(parent); } }
private void btnUpOneLevel_Click(object sender, EventArgs e) { var item = repoView.SelectedItem; if (item != null) { string folderId = ResourceIdentifier.GetParentFolder(item.ResourceId); if (folderId != item.ResourceId) { repoView.NavigateTo(folderId); UpdateDocumentList(); } } }
private void btnBrowse_Click(object sender, EventArgs e) { using (var picker = new ResourcePicker(_conn, this.ResourceType, ResourcePickerMode.OpenResource)) { if (string.IsNullOrEmpty(LastSelectedFolder.FolderId)) { picker.SetStartingPoint(ResourceIdentifier.GetParentFolder(this.Source)); } if (picker.ShowDialog() == DialogResult.OK) { txtTarget.Text = picker.ResourceID; btnOK.Enabled = !string.IsNullOrEmpty(txtSource.Text) && !string.IsNullOrEmpty(txtTarget.Text) && lstAffectedResources.Items.Count > 0 && txtSource.Text != txtTarget.Text; } } }
private void btnTarget_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.Source)) { MessageBox.Show(Strings.SelectSourceResource); return; } var resType = ResourceIdentifier.GetResourceTypeAsString(this.Source); using (var picker = new ResourcePicker(_conn, resType, ResourcePickerMode.OpenResource)) { picker.SetStartingPoint(ResourceIdentifier.GetParentFolder(this.Source)); if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtTarget.Text = picker.ResourceID; } } }
public void RefreshModel(string connectionName, string resId) { if (!string.IsNullOrEmpty(resId)) { var rid = new ResourceIdentifier(resId); if (!rid.IsFolder) { resId = rid.ParentFolder; } //If this node is not initially expanded, we get NRE on refresh ExpandNode(connectionName, resId); var path = _model.GetPathFromResourceId(connectionName, resId); while (path == null) { resId = ResourceIdentifier.GetParentFolder(resId); path = _model.GetPathFromResourceId(connectionName, resId); } var node = trvResources.FindNode(path, true); if (node != null) { //Walk back up until node has children. We want to refresh from this node down while (node.Children.Count == 0 && node != trvResources.Root) { node = node.Parent; } } try { trvResources.SelectedNode = node; } catch { } } _model.Refresh(); if (!string.IsNullOrEmpty(resId)) { SelectNode(connectionName, resId); } //trvResources.Root.Children[0].Expand(); }
private void btnOK_Click(object sender, EventArgs e) { if (_mode == ResourcePickerMode.OpenResource) { if (!_conn.ResourceService.ResourceExists(txtResourceId.Text)) { MessageBox.Show(Strings.ResourceDoesntExist); return; } } else if (_mode == ResourcePickerMode.SaveResource) { if (ResourceIdentifier.IsFolderResource(txtResourceId.Text)) { MessageBox.Show(Strings.InvalidResourceIdFolder); return; } else { if (!ResourceIdentifier.Validate(txtResourceId.Text)) { MessageBox.Show(Strings.InvalidResourceId); return; } else { if (ResourceIdentifier.GetResourceTypeAsString(txtResourceId.Text) != cmbResourceFilter.SelectedItem.ToString()) { MessageBox.Show(Strings.InvalidResourceIdNotSpecifiedType); return; } } if (_conn.ResourceService.ResourceExists(txtResourceId.Text)) { if (MessageBox.Show(Strings.OverwriteResource, Strings.SaveResource, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } } } if (ResourceIdentifier.IsFolderResource(txtResourceId.Text)) { LastSelectedFolder.FolderId = txtResourceId.Text; } else { LastSelectedFolder.FolderId = (txtResourceId.Text != StringConstants.RootIdentifier) ? ResourceIdentifier.GetParentFolder(txtResourceId.Text) : StringConstants.RootIdentifier; } this.DialogResult = DialogResult.OK; }
public override void Run() { var wb = Workbench.Instance; var exp = wb.ActiveSiteExplorer; var omgr = ServiceRegistry.GetService <OpenResourceManager>(); var connMgr = ServiceRegistry.GetService <ServerConnectionManager>(); var conn = connMgr.GetConnection(exp.ConnectionName); if (exp.SelectedItems.Length == 1) { var current = exp.SelectedItems[0]; var parent = current.Parent; List <string> names = new List <string>(); foreach (var item in parent.Children) { if (item != exp.SelectedItems[0]) { names.Add(item.Name); } } if (!current.IsFolder && omgr.IsOpen(current.ResourceId, conn)) { MessageService.ShowMessage(Strings.CannotRenameAlreadyOpenedResource); return; } var dlg = new RenameItemDialog(current.Name, names); if (dlg.ShowDialog(wb) == System.Windows.Forms.DialogResult.OK) { string oldid = string.Empty; string newid = string.Empty; if (current.IsFolder) { oldid = $"{parent.ResourceId + current.Name}/"; //NOXLATE newid = $"{parent.ResourceId + dlg.NewName}/"; //NOXLATE } else { oldid = $"{parent.ResourceId + current.Name}.{current.ResourceType}"; //NOXLATE newid = $"{parent.ResourceId + dlg.NewName}.{current.ResourceType}"; //NOXLATE } if (omgr.IsOpen(newid, conn)) { MessageService.ShowMessage(string.Format(Strings.CannotRenameToResourceAlreadyOpened, newid)); return; } var prog = new ProgressDialog(); prog.RunOperationAsync(wb, (worker, e, args) => { LengthyOperationProgressCallBack cb = (s, cbArgs) => { worker.ReportProgress(cbArgs.Progress, cbArgs.StatusMessage); }; //Perform the operation if (dlg.UpdateReferences) { conn.ResourceService.MoveResourceWithReferences(oldid, newid, null, cb); } else { conn.ResourceService.MoveResource(oldid, newid, true); // dlg.Overwrite); } /* * if (current.IsFolder) * { * if (dlg.UpdateReferences) * conn.ResourceService.MoveFolderWithReferences(oldid, newid, null, cb); * else * conn.ResourceService.MoveFolder(oldid, newid, dlg.Overwrite); * } * else * { * if (dlg.UpdateReferences) * { * conn.ResourceService.MoveResourceWithReferences(oldid, newid, null, cb); * } * else * conn.ResourceService.MoveResource(oldid, newid, dlg.Overwrite); * }*/ current.Name = dlg.NewName; return(true); }); //Need to refresh the model because it still is called by the old name var folder = ResourceIdentifier.GetParentFolder(oldid); exp.RefreshModel(conn.DisplayName, folder); } } }