/// <summary> /// Update Widget Sensitivity /// </summary> private void UpdateWidgetSensitivity() { if (curDomains.Count > 0) { TreeSelection tSelect = AccTreeView.Selection; if (tSelect == null) { MigrateButton.Sensitive = false; DetailsButton.Sensitive = false; } if (tSelect.CountSelectedRows() == 1) { MigrateButton.Sensitive = true; DetailsButton.Sensitive = true; } else { // Nothing is selected //AddButton.Sensitive = false; MigrateButton.Sensitive = false; DetailsButton.Sensitive = false; } } else { MigrateButton.Sensitive = false; DetailsButton.Sensitive = false; } }
private void OnMigrateAccount(object o, EventArgs args) { TreeSelection tSelect = AccTreeView.Selection; if (tSelect.CountSelectedRows() == 1) { TreeModel tModel; TreeIter iter; tSelect.GetSelected(out tModel, out iter); // string id = (string) tModel.GetValue(iter, 0); MigrationWizard migratewiz = null; //new MigrationWizard(GetName(id), GetHomeLocation(id), ifws, this); migratewiz.TransientFor = topLevelWindow; if (!Util.RegisterModalWindow(migratewiz)) { try { Util.CurrentModalWindow.Present(); } catch {} migratewiz.Destroy(); return; } migratewiz.ShowAll(); /* * if(curDomains.Count == 0) * { * this.Hide(); * this.Destroy(); * } */ } }
protected void onBnFace2Remove(object sender, EventArgs e) { TreeSelection selection = treeviewFace2.Selection; TreeModel model; TreeIter iter; if (selection.CountSelectedRows() == 1) { TreePath tp = selection.GetSelectedRows()[0]; int iPlace = tp.Indices[0]; if (selection.GetSelected(out model, out iter)) { // get the face1 list // Dictionary <String, String> cardDefinition = CardGeneratorDB.Instance.getRowFromTable(CardGeneratorDB.TABLECardDefinitions, "FaceCardName", _SelectedCardTypeName); List <CardDefinitions.CardDefClass> face1 = CardDefinitions.faceCardStructureFromJSONString(cardDefinition["Face2"]); face1.RemoveAt(iPlace); String face1JSONString = CardDefinitions.JSONStringFromfaceCardStructure(face1); CardGeneratorDB.Instance.updateRowField(CardGeneratorDB.TABLECardDefinitions, CardGeneratorDB.COLUMNCardDefinitionID, cardDefinition[CardGeneratorDB.COLUMNCardDefinitionID], "Face2", face1JSONString); SelectCardType(_SelectedCardTypeName); } } }
//never used /// <summary> /// Event Handler for Cancel Button Clicked Event /// </summary> /* private void OnCancelClicked(object o, EventArgs args) * { * this.Destroy(); * this.MergePath = null; * this.Cancelled = true; * }*/ /// <summary> /// Event Handler on MIgrate Account event /// </summary> private void OnMigrateAccount(object o, EventArgs args) { TreeSelection tSelect = AccTreeView.Selection; if (tSelect.CountSelectedRows() == 1) { TreeModel tModel; TreeIter iter; tSelect.GetSelected(out tModel, out iter); string id = (string)tModel.GetValue(iter, 0); /* string status = GetEncryptionStatus(id); * bool stat = false;; * if( status == null) * stat = false; * else if( status == "BLWF") * stat = true; * else * stat = false;*/ String Location = GetHomeLocation(id); this.UserName = GetName(id); DirectoryInfo dir = new DirectoryInfo(Location); if (dir.Exists == true && dir.Name != this.iFolderName) { // Prompt for renaming... iFolderMsgDialog dlg = new iFolderMsgDialog(null, iFolderMsgDialog.DialogType.Info, iFolderMsgDialog.ButtonSet.YesNo, Util.GS("Migration Alert"), Util.GS("The name of the iFolder on the server and on your local machine are different."), Util.GS("Do you want to rename the iFolder on the server to the name of iFolder on your local machine?")); int res = dlg.Run(); dlg.Hide(); dlg.Destroy(); if (res == (int)ResponseType.No) { this.MergePath = null; this.Cancelled = true; } else { // Move this to the name as that on the server... this.MergePath = System.IO.Path.Combine(dir.Parent.FullName, this.iFolderName); try { dir.MoveTo(this.MergePath); } catch (Exception ex) { iFolderMsgDialog dlg1 = new iFolderMsgDialog(null, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, Util.GS("Migration Alert"), Util.GS("The folder cannot be renamed"), Util.GS("Error: " + ex.Message)); dlg1.Run(); dlg1.Hide(); dlg1.Destroy(); this.MergePath = null; } } } else { this.MergePath = GetHomeLocation(id); } } }
void OnSelectionChanged(object o, EventArgs args) { TreeIter iter; TreeModel model; TreeSelection treeSelection = o as TreeSelection; int count = treeSelection.CountSelectedRows(); if (count == 0 || count > 1) { changesetDetailView.Clear(); changesetDiffView.Clear(); return; } TreePath[] paths = treeSelection.GetSelectedRows(out model); foreach (TreePath path in paths) { model.GetIter(out iter, path); currentCid = Convert.ToInt32(model.GetValue(iter, 0)); } IChangesetViewChild child = viewChildren.CurrentPageWidget as IChangesetViewChild; UpdateChildCid(child); }
/// <summary> /// To handle if the selection is changed in conflict tree display /// </summary> /// <param name="o"></param> /// <param name="args"></param> private void OnEnhancedConflictSelectionChanged(object o, EventArgs args) { bool bHasFileConflict = false; OnConflictSelectionChanged(o, args); TreeSelection tSelect = ConflictTreeView.Selection; int selectedRows = tSelect.CountSelectedRows(); if (selectedRows > 0) { EnableEnhancedConflictControls(); TreeModel tModel; ConflictHolder ch = null; Array treePaths = tSelect.GetSelectedRows(out tModel); foreach (TreePath tPath in treePaths) { TreeIter iter; if (ConflictTreeStore.GetIter(out iter, tPath)) { ch = (ConflictHolder)tModel.GetValue(iter, 0); if (!ch.IsNameConflict) { bHasFileConflict = true; } } } if (selectedRows == 1) { if (bHasFileConflict) { EnableEnhancedConflictControls(); } else { ActionFrame.Sensitive = false; } } else { // We're dealing with multiple selections here if (bHasFileConflict) { EnableEnhancedConflictControls(); } else { ActionFrame.Sensitive = false; } } } }
/// <summary> /// Update Widget Sensitivity /// </summary> private void UpdateWidgetSensitivity() { TreeSelection tSelect = AccTreeView.Selection; // Nothing is selected AddButton.Sensitive = true; RemoveButton.Sensitive = false; DetailsButton.Sensitive = false; if (tSelect != null) { if (tSelect.CountSelectedRows() == 1) { TreeModel tModel; TreeIter iter; tSelect.GetSelected(out tModel, out iter); string domainID = (string)tModel.GetValue(iter, 0); DomainInformation dom = domainController.GetDomain(domainID); if (dom == null) { return; // Prevent null pointer } IDomainProviderUI provider = domainProviderUI.GetProviderForID(domainID); if (provider != null) { if (provider.CanDelete) { RemoveButton.Sensitive = true; } else { RemoveButton.Sensitive = false; } if (provider.HasDetails) { DetailsButton.Sensitive = true; } else { DetailsButton.Sensitive = false; } } else { RemoveButton.Sensitive = true; DetailsButton.Sensitive = true; } // Set the control states AddButton.Sensitive = true; } } }
private void OnUserTreeViewRowActivated(object o, RowActivatedArgs args) { TreeSelection tSelect = UserTreeView.Selection; if (tSelect.CountSelectedRows() == 1) { if (ifolder.CurrentUserRights == "Admin" && !SelectionHasOwnerOrCurrent()) { OnAccessClicked(null, null); } } }
/// <summary> /// Event Handler for On Selected User Selection Changed /// </summary> public void OnSelUserSelectionChanged(object o, EventArgs args) { TreeSelection tSelect = SelTreeView.Selection; if (tSelect.CountSelectedRows() > 0) { UserDelButton.Sensitive = true; } else { UserDelButton.Sensitive = false; } }
/// <summary> /// Event Handler for Remove Account /// </summary> private void OnRemoveAccount(object o, EventArgs args) { TreeSelection tSelect = AccTreeView.Selection; if (tSelect.CountSelectedRows() == 1) { TreeModel tModel; TreeIter iter; tSelect.GetSelected(out tModel, out iter); string domainID = (string)tModel.GetValue(iter, 0); DomainInformation dom = domainController.GetDomain(domainID); RemoveAccountDialog rad = new RemoveAccountDialog(dom); rad.TransientFor = topLevelWindow; int rc = rad.Run(); rad.Hide(); if ((ResponseType)rc == ResponseType.Yes) { try { removedDomains[dom.ID] = dom.ID; domainController.RemoveDomain(dom.ID, rad.RemoveiFoldersFromServer); RemoveDomain(dom.ID); } catch (Exception e) { if (removedDomains.ContainsKey(dom.ID)) { removedDomains.Remove(dom.ID); } iFolderExceptionDialog ied = new iFolderExceptionDialog(topLevelWindow, e); ied.Run(); ied.Hide(); ied.Destroy(); rad.Destroy(); // Clean up before bailing return; } AddButton.Sensitive = true; RemoveButton.Sensitive = false; DetailsButton.Sensitive = false; } rad.Destroy(); } }
protected void onCardTypeCursorChanged(object sender, EventArgs e) { TreeSelection selection = (sender as TreeView).Selection; TreeModel model; TreeIter iter; String selID = null; if (selection.CountSelectedRows() == 1) { if (selection.GetSelected(out model, out iter)) { selID = model.GetValue(iter, 0).ToString(); } } SelectCardType(selID); }
protected void SaveNote() { Note newNote = MakeNote(); TreeSelection selection = (treeviewNotes as TreeView).Selection; TreeModel model; TreeIter iter; if (selection.CountSelectedRows() == 1 && selection.GetSelected(out model, out iter)) { Note oldNote = model.GetValue(iter, (int)NotesModel.NoteCols.NoteRef) as Note; notes.Update(oldNote, newNote); } else { notes.Add(newNote); } }
/// <summary> /// Event Handler for Details Clicked /// </summary> private void OnDetailsClicked(object o, EventArgs args) { TreeSelection tSelect = AccTreeView.Selection; if (tSelect.CountSelectedRows() == 1) { TreeModel tModel; TreeIter iter; tSelect.GetSelected(out tModel, out iter); string domainID = (string)tModel.GetValue(iter, 0); DomainInformation dom = domainController.GetDomain(domainID); AccountDialog accDialog = null; if (detailsDialogs.ContainsKey(domainID)) { accDialog = (AccountDialog)detailsDialogs[domainID]; accDialog.Present(); } else { IDomainProviderUI provider = domainProviderUI.GetProviderForID(domainID); if (provider != null) { accDialog = provider.CreateAccountDialog(topLevelWindow, dom); } else { accDialog = new EnterpriseAccountDialog(topLevelWindow, dom); } if (accDialog != null) { detailsDialogs[domainID] = accDialog; accDialog.SetPosition(WindowPosition.Center); accDialog.Destroyed += new EventHandler(OnAccountDialogDestroyedEvent); accDialog.ShowAll(); } } } }
void OnSelectionChanged(object o, EventArgs args) { TreeIter iter; TreeModel model; TreeSelection treeSelection = o as TreeSelection; int count = treeSelection.CountSelectedRows(); if (count == 0 || count > 1) { return; } TreePath[] paths = treeSelection.GetSelectedRows(out model); foreach (TreePath path in paths) { model.GetIter(out iter, path); currentCid = Convert.ToInt32(model.GetValue(iter, 0)); } }
private void OnMigrateAccount(object o, EventArgs args) { TreeSelection tSelect = AccTreeView.Selection; if (tSelect.CountSelectedRows() == 1) { TreeModel tModel; TreeIter iter; tSelect.GetSelected(out tModel, out iter); string id = (string)tModel.GetValue(iter, 0); string status = GetEncryptionStatus(id); bool stat = false;; if (status == null) { stat = false; } else if (status == "BLWF") { stat = true; } else { stat = false; } MigrationWizard migratewiz = new MigrationWizard(GetName(id), GetHomeLocation(id), ifws, simws, this, stat); // migratewiz.TransientFor = topLevelWindow; if (!Util.RegisterModalWindow(migratewiz)) { try { Util.CurrentModalWindow.Present(); } catch {} migratewiz.Destroy(); return; } migratewiz.ShowAll(); } }
protected void onBnCardTypeRemove(object sender, EventArgs e) { // remove the selected from treeviewCardType TreeSelection selection = treeviewCardType.Selection; TreeModel model; TreeIter iter; String selID = null; if (selection.CountSelectedRows() == 1) { if (selection.GetSelected(out model, out iter)) { selID = model.GetValue(iter, 0).ToString(); CardGeneratorDB.Instance.removeRowFromTable(CardGeneratorDB.TABLECardDefinitions, CardGeneratorDB.COLUMNCardDefinitionName, selID); SelectCardType(null); RebuildCardTypeTable(); } } }
/// <summary> /// Event Handler for User Selection Changed /// </summary> private void OnUserSelectionChanged(object o, EventArgs args) { if (ifolder.CurrentUserRights != "Admin") { AddButton.Sensitive = false; RemoveButton.Sensitive = false; AccessButton.Sensitive = false; } else { if (!ifolder.IsWorkgroup) { AddButton.Sensitive = true; } else { AddButton.Sensitive = false; } TreeSelection tSelect = UserTreeView.Selection; if ((tSelect.CountSelectedRows() < 1) || SelectionHasOwnerOrCurrent()) { RemoveButton.Sensitive = false; AccessButton.Sensitive = false; } else { RemoveButton.Sensitive = true; AccessButton.Sensitive = true; } } if (this.ifolder.encryptionAlgorithm != null && this.ifolder.encryptionAlgorithm != "") { this.AddButton.Sensitive = false; } }
protected virtual void OnRowSelected(object o, EventArgs args) { if (ElementUpdated == null) { return; } TreeIter tIter; TreeSelection selection = this.Selection; if (selection == null || (selection != null && selection.CountSelectedRows() == 0)) { return; } selection.GetSelected(out tIter); IElement element = model.GetValue(tIter, 2) as IElement; if (element != null) { ElementUpdated(this, new ElementUpdatedEventArgs(element)); } }
/// <summary> /// Event Handler for Remove User /// </summary> private void OnRemoveUser(object o, EventArgs args) { TreeModel tModel; TreeSelection tSelect = UserTreeView.Selection; if (tSelect.CountSelectedRows() > 0) { iFolderMsgDialog dialog = new iFolderMsgDialog( topLevelWindow, iFolderMsgDialog.DialogType.Question, iFolderMsgDialog.ButtonSet.YesNo, "", Util.GS("Remove the selected users?"), Util.GS("This will remove the selected users from this iFolder. They will no longer be able to synchronize files with this iFolder.")); int rc = dialog.Run(); dialog.Hide(); dialog.Destroy(); if (rc == -8) { Queue iterQueue; Array treePaths = tSelect.GetSelectedRows(out tModel); iterQueue = new Queue(); foreach (TreePath tPath in treePaths) { TreeIter iter; if (UserTreeStore.GetIter(out iter, tPath)) { iterQueue.Enqueue(iter); } } // Now that we have all of the TreeIters, loop and // remove them all while (iterQueue.Count > 0) { TreeIter iter = (TreeIter)iterQueue.Dequeue(); iFolderUser user = (iFolderUser)tModel.GetValue(iter, 0); try { ifws.RemoveiFolderUser(ifolder.ID, user.UserID); UserTreeStore.Remove(ref iter); curUsers.Remove(user.UserID); } catch (Exception e) { iFolderExceptionDialog ied = new iFolderExceptionDialog( topLevelWindow, e); ied.Run(); ied.Hide(); ied.Destroy(); ied = null; } } } } }
private void HandleAdvSelectionChanged(object sender, EventArgs args) { TreeSelection selection = sender as TreeSelection; UpdateAdvButtons(selection.CountSelectedRows()); }
/// <summary> /// Event Handler for Rename Event Handler /// </summary> protected void RenameFileHandler(object o, EventArgs args) { string newFileName = nameConflictEntry.Text; TreeModel tModel; ConflictHolder ch = null; TreeSelection tSelect = ConflictTreeView.Selection; if (tSelect.CountSelectedRows() == 1) { Array treePaths = tSelect.GetSelectedRows(out tModel); TreeIter iter; if (ConflictTreeStore.GetIter(out iter, (TreePath)treePaths.GetValue(0))) { ch = (ConflictHolder)tModel.GetValue(iter, 0); Conflict lnc = ch.LocalNameConflict; Conflict snc = ch.ServerNameConflict; try { if (snc != null && ifolder.CurrentUserRights == "ReadOnly") { ifws.RenameAndResolveConflict(snc.iFolderID, snc.ConflictID, newFileName); } else { if (lnc != null) { //server file rename is not certified so we are not allowing the local file renamed to same name // this is a work around later we will fix the sever rename as well if (newFileName == oldFileName) { iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", Util.GS("Name Already Exists"), Util.GS("The specified name already exists. Please choose a different name."), null); dg.Run(); dg.Hide(); dg.Destroy(); return; } Conflict[] conflictList = ifws.GetiFolderConflicts(lnc.iFolderID); ifws.ResolveNameConflict(lnc.iFolderID, lnc.ConflictID, newFileName); foreach (Conflict con in conflictList) { if (con.IsNameConflict && con.ServerName != null) { if (String.Compare(lnc.LocalFullPath, con.ServerFullPath, true) == 0) { if (ifolder.CurrentUserRights == "ReadOnly") { ifws.RenameAndResolveConflict(con.iFolderID, con.ConflictID, con.ServerName); break; } else { ifws.ResolveNameConflict(con.iFolderID, con.ConflictID, con.ServerName); break; } } } } ifws.SynciFolderNow(lnc.iFolderID); } // If this is a name conflict because of case-sensitivity // on Linux, there won't be a conflict on the server. if (snc != null) { //server file rename is not certified so we are not allowing the server file rename, rather rename to the same name // this is a work around later we will fix the sever rename as well if (newFileName != oldFileName) { iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", Util.GS("Name Already Exists"), Util.GS("The specified name already exists. Please choose a different name."), null); dg.Run(); dg.Hide(); dg.Destroy(); return; } ifws.ResolveNameConflict(snc.iFolderID, snc.ConflictID, ch.Name); } } ConflictTreeStore.Remove(ref iter); } catch (Exception e) { bool bKnownError = true; string headerText = Util.GS("iFolder Conflict Error"); string errText = Util.GS("An error was encountered while resolving the conflict."); if (e.Message.IndexOf("Malformed") >= 0) { headerText = Util.GS("Invalid Characters in Name"); errText = string.Format(Util.GS("The specified name contains invalid characters. Please choose a different name and try again.\n\nNames must not contain any of these characters: {0}"), simws.GetInvalidSyncFilenameChars()); } else if (e.Message.IndexOf("already exists") >= 0) { headerText = Util.GS("Name Already Exists"); errText = Util.GS("The specified name already exists. Please choose a different name."); } else { //bKnownError = false; } iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", headerText, errText, bKnownError ? null : e.Message); dg.Run(); dg.Hide(); dg.Destroy(); tSelect.SelectIter(iter); // FIXME: Figure out why if the user clicks the "Save" button the focus doesn't return back to the entry text box. (i.e., the next line of code isn't really doing anything) this.FocusChild = nameConflictEntry; return; } UpdateFields(null, false); } } }
/// <summary> /// Event Handler for OnConflictSelectionChanged event /// </summary> protected void OnConflictSelectionChanged(object o, EventArgs args) { bool bHasNameConflict = false; bool bHasFileConflict = false; TreeSelection tSelect = ConflictTreeView.Selection; int selectedRows = tSelect.CountSelectedRows(); if (selectedRows > 0) { EnableConflictControls(true); TreeModel tModel; ConflictHolder ch = null; Array treePaths = tSelect.GetSelectedRows(out tModel); foreach (TreePath tPath in treePaths) { TreeIter iter; if (ConflictTreeStore.GetIter(out iter, tPath)) { ch = (ConflictHolder)tModel.GetValue(iter, 0); if (ch.IsNameConflict) { bHasNameConflict = true; } else { bHasFileConflict = true; } } } if (selectedRows == 1) { if (bHasNameConflict) { nameConflictSummary.Text = Util.GS("Enter a new name and click Rename to resolve the conflict."); // This is a name conflict nameConflictBox.Visible = true; fileConflictBox.Visible = false; // Prefill the entry with the filename and auto-select // the text on the left-hand side of the extension. nameConflictEntry.Text = ch.Name; oldFileName = nameConflictEntry.Text; this.FocusChild = nameConflictEntry; /* FIXME: Get GrabFocus() and preselection of filename working * nameConflictEntry.GrabFocus(); * * if (ch.Name.Length > 0) * { * int lastDotPos = ch.Name.LastIndexOf('.'); * if (lastDotPos > 1) * nameConflictEntry.SelectRegion(0, lastDotPos); * else * nameConflictEntry.SelectRegion(0, ch.Name.Length); * } */ } else { // This is a file conflict fileConflictBox.Visible = true; nameConflictBox.Visible = false; } UpdateFields(ch, false); } else { // We're dealing with multiple selections here if (bHasFileConflict) { // Allow name conflicts to be multi-selected with file conflicts fileConflictBox.Visible = true; nameConflictBox.Visible = false; UpdateFields(ch, true); } else { // There are multiple name conflicts selected nameConflictBox.Visible = true; fileConflictBox.Visible = false; nameConflictSummary.Text = Util.GS("Name conflicts must be resolved individually."); nameConflictEntry.Text = ""; EnableConflictControls(false); } } } }
public void OnUserTreeViewButtonPressed(object obj, ButtonPressEventArgs args) { switch (args.Event.Button) { case 1: // first mouse button break; case 2: // second mouse button break; case 3: // third mouse button { TreePath tPath = null; TreeViewColumn tColumn = null; if (UserTreeView.GetPathAtPos((int)args.Event.X, (int)args.Event.Y, out tPath, out tColumn) == true) { TreeSelection tSelect = UserTreeView.Selection; if (tSelect.CountSelectedRows() > 0) { Menu rightsMenu = new Menu(); RadioMenuItem adminItem = new RadioMenuItem(Util.GS("Full Control")); rightsMenu.Append(adminItem); RadioMenuItem rwItem = new RadioMenuItem(adminItem.Group, Util.GS("Read/Write")); rightsMenu.Append(rwItem); RadioMenuItem roItem = new RadioMenuItem(adminItem.Group, Util.GS("Read Only")); rightsMenu.Append(roItem); if (ifolder.CurrentUserRights != "Admin" || SelectionHasOwnerOrCurrent()) { adminItem.Sensitive = false; rwItem.Sensitive = false; roItem.Sensitive = false; } // Get the Value of the actual user selected TreeIter iter; if (UserTreeStore.GetIter(out iter, tPath)) { iFolderUser user = (iFolderUser) UserTreeStore.GetValue(iter, 0); if (user.Rights == "ReadWrite") { rwItem.Active = true; } else if (user.Rights == "Admin") { adminItem.Active = true; } else { roItem.Active = true; } } adminItem.Activated += new EventHandler( OnAdminRightsMenu); rwItem.Activated += new EventHandler( OnRWRightsMenu); roItem.Activated += new EventHandler( OnRORightsMenu); rightsMenu.ShowAll(); rightsMenu.Popup(null, null, null, 3, Gtk.Global.CurrentEventTime); } } break; } } }
/// <summary> /// Event handler for Access Clicked /// </summary> private void OnAccessClicked(object o, EventArgs args) { TreeModel tModel; iFolderAccessDialog accDialog = null; string defaultRights = "ReadWrite"; string userName = null; bool allowOwner = false; TreeSelection tSelect = UserTreeView.Selection; // only allow the changing of the owner if the current // user is the owner and if the selected users are members if (tSelect.CountSelectedRows() == 1) { Array treePaths = tSelect.GetSelectedRows(out tModel); foreach (TreePath tPath in treePaths) { TreeIter iter; if (UserTreeStore.GetIter(out iter, tPath)) { iFolderUser user = (iFolderUser)tModel.GetValue(iter, 0); if (user.FN != null) { userName = user.FN; } else { userName = user.Name; } defaultRights = user.Rights; if ((ifolder.CurrentUserID == ifolder.OwnerID) && (user.State == "Member")) { allowOwner = true; } } break; } } accDialog = new iFolderAccessDialog( topLevelWindow, userName, defaultRights, allowOwner); int rc = accDialog.Run(); accDialog.Hide(); if (rc == -5) { string newrights = accDialog.Rights; string oldOwnerID; Array treePaths = tSelect.GetSelectedRows(out tModel); foreach (TreePath tPath in treePaths) { TreeIter iter; if (UserTreeStore.GetIter(out iter, tPath)) { iFolderUser user = (iFolderUser)tModel.GetValue(iter, 0); try { ifws.SetUserRights(ifolder.ID, user.UserID, newrights); user.Rights = newrights; // if the user selected to make this // use the owner set that right now if (accDialog.IsOwner) { if (ifws.CanOwnerBeChanged(user.UserID, ifolder.DomainID)) { ifws.ChangeOwner(ifolder.ID, user.UserID, "Admin"); // update the objects here instead of // re-reading them, that's expensive! oldOwnerID = ifolder.OwnerID; user.Rights = "Admin"; ifolder.Owner = user.Name; ifolder.OwnerID = user.UserID; // now loop through the users, find // the current owner, and set him to // not be the owner any more TreeIter ownIter; if (UserTreeStore.GetIterFirst(out ownIter)) { do { iFolderUser ownUser = (iFolderUser) UserTreeStore.GetValue(ownIter, 0); if (oldOwnerID == ownUser.UserID) { ownUser.Rights = "Admin"; tModel.SetValue(ownIter, 0, ownUser); break; } }while(UserTreeStore.IterNext(ref ownIter)); } } else { iFolderMsgDialog messdialog = new iFolderMsgDialog( null, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, Util.GS("Policy Violation"), String.Format(Util.GS("Ownership of the iFolder {0} could not be transferred to {1} as it is violating the limit of iFolders set by the Administrator."), ifolder.Name, user.Name), Util.GS(" ")); messdialog.Run(); messdialog.Hide(); messdialog.Destroy(); } } tModel.SetValue(iter, 0, user); } catch (Exception e) { iFolderExceptionDialog ied = new iFolderExceptionDialog( topLevelWindow, e); ied.Run(); ied.Hide(); ied.Destroy(); ied = null; } } } } accDialog.Destroy(); accDialog = null; }
private void OnSelectionChanged(object o, EventArgs args) { TreeSelection selection = (o as TreeSelection); buttonRemove.Sensitive = (selection.CountSelectedRows() > 0); }