示例#1
0
        protected void ConflictTypeCellTextDataFunc(Gtk.TreeViewColumn col,
                                                    Gtk.CellRenderer cellRenderer,
                                                    Gtk.TreeModel model,
                                                    Gtk.TreeIter iter)
        {
            ConflictHolder conflictHolder = (ConflictHolder)model.GetValue(iter, 0);

            ((CellRendererText)cellRenderer).Text = conflictHolder.Type;
        }
示例#2
0
        /// <summary>
        /// Refresh Conflicts
        /// </summary>
        protected void RefreshConflictList()
        {
            conflictTable.Clear();

            try
            {
                Conflict[] conflictList = ifws.GetiFolderConflicts(ifolder.ID);
                foreach (Conflict con in conflictList)
                {
                    if (!con.IsNameConflict)
                    {
                        ConflictHolder ch = new ConflictHolder(con, ifolder.UnManagedPath);
                        ConflictTreeStore.AppendValues(ch);
                    }
                    else
                    {
                        String key = "";
                        if ((con.LocalFullPath != null) &&
                            (con.LocalFullPath.Length > 0))
                        {
                            key = con.LocalFullPath;
                        }
                        else
                        {
                            key = con.ServerFullPath;
                        }

//						Debug.PrintLine("Key = {0}", key);

                        if (conflictTable.ContainsKey(key))
                        {
//							Debug.PrintLine("Found key, adding to holder");
                            ConflictHolder ch =
                                (ConflictHolder)conflictTable[key];
                            ch.AddNameConflict(con);
                        }
                        else
                        {
//							Debug.PrintLine("No key, New holder");
                            ConflictHolder ch = new ConflictHolder(con, ifolder.UnManagedPath);
                            if (con.LocalFullPath != null)
                            {
                                ConflictTreeStore.AppendValues(ch);
                            }
                            conflictTable.Add(key, ch);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.PrintLine(ex.Message);
            }
        }
示例#3
0
        /// <summary>
        /// Resolve Selected Conflicts
        /// </summary>
        /// <param name="localChangesWin">true if localchanges</param>
        private void ResolveSelectedConflicts(bool localChangesWin)
        {
            TreeModel tModel;
            Queue     iterQueue;

            iterQueue = new Queue();
            TreeSelection tSelect   = ConflictTreeView.Selection;
            Array         treePaths = tSelect.GetSelectedRows(out tModel);

            // We can't remove anything while getting the iters
            // because it will change the paths and we'll remove
            // the wrong stuff.
            foreach (TreePath tPath in treePaths)
            {
                TreeIter iter;

                if (tModel.GetIter(out iter, tPath))
                {
                    iterQueue.Enqueue(iter);
                }
            }

            if (iterQueue.Count > 0)
            {
                // Now that we have all of the TreeIters, loop and
                // remove them all
                while (iterQueue.Count > 0)
                {
                    TreeIter iter = (TreeIter)iterQueue.Dequeue();

                    ConflictHolder ch = (ConflictHolder)tModel.GetValue(iter, 0);
                    if (!ch.IsNameConflict)
                    {
                        try
                        {
                            ifws.ResolveFileConflict(
                                ch.FileConflict.iFolderID,
                                ch.FileConflict.ConflictID,
                                localChangesWin);

                            ConflictTreeStore.Remove(ref iter);
                        }
                        catch
                        {}
                    }
                }
                UpdateFields(null, false);
            }
        }
 protected void UpdateFields(ConflictHolder ch, bool multiSelect)
 {
     if(ch == null)
        {
     EnableConflictControls(false);
     LocalNameValue.Text = "";
     LocalDateValue.Text = "";
     LocalSizeValue.Text = "";
     ServerNameValue.Text = "";
     ServerDateValue.Text = "";
     ServerSizeValue.Text = "";
     nameConflictEntry.Text = "";
     return;
        }
        if(multiSelect)
        {
     EnableConflictControls(true);
     LocalNameValue.Text = Util.GS("Multiple selected");
     LocalDateValue.Text = "";
     LocalSizeValue.Text = "";
     ServerNameValue.Text = Util.GS("Multiple selected");
     ServerDateValue.Text = "";
     ServerSizeValue.Text = "";
     if (ifolder.CurrentUserRights == "ReadOnly")
     {
             if( LocalSaveButton.Label == Stock.Save )
      LocalSaveButton.Sensitive = false;
     }
     return;
        }
        if(!ch.IsNameConflict)
        {
     EnableConflictControls(true);
     LocalNameValue.Text = ch.FileConflict.LocalName;
     LocalDateValue.Text = ch.FileConflict.LocalDate;
     LocalSizeValue.Text = ch.FileConflict.LocalSize;
     ServerNameValue.Text = ch.FileConflict.ServerName;
     ServerDateValue.Text = ch.FileConflict.ServerDate;
     ServerSizeValue.Text = ch.FileConflict.ServerSize;
     if (ifolder.CurrentUserRights == "ReadOnly")
     {
             if( LocalSaveButton.Label == Stock.Save )
      LocalSaveButton.Sensitive = false;
     }
     return;
        }
        EnableConflictControls(true);
 }
 protected void RefreshConflictList()
 {
     conflictTable.Clear();
        try
        {
     Conflict[] conflictList = ifws.GetiFolderConflicts(ifolder.ID);
     foreach(Conflict con in conflictList)
     {
      if(!con.IsNameConflict)
      {
       ConflictHolder ch = new ConflictHolder(con, ifolder.UnManagedPath);
       ConflictTreeStore.AppendValues(ch);
      }
      else
      {
       String key = "";
       if( (con.LocalFullPath != null) &&
        (con.LocalFullPath.Length > 0) )
        key = con.LocalFullPath;
       else
        key = con.ServerFullPath;
       if(conflictTable.ContainsKey(key))
       {
        ConflictHolder ch =
     (ConflictHolder)conflictTable[key];
        ch.AddNameConflict(con);
       }
       else
       {
        ConflictHolder ch = new ConflictHolder(con, ifolder.UnManagedPath);
        if(con.LocalFullPath != null)
     ConflictTreeStore.AppendValues(ch);
        conflictTable.Add(key, ch);
       }
      }
     }
        }
        catch(Exception ex)
        {
     Debug.PrintLine(ex.Message);
        }
 }
示例#6
0
        /// <summary>
        /// Update Files
        /// </summary>
        /// <param name="ch">Conflict Holder</param>
        /// <param name="multiSelect">true on multi select else false</param>
        protected void UpdateFields(ConflictHolder ch, bool multiSelect)
        {
            if (ch == null)
            {
                EnableConflictControls(false);
                LocalNameValue.Text = "";
                LocalDateValue.Text = "";
                LocalSizeValue.Text = "";

                ServerNameValue.Text = "";
                ServerDateValue.Text = "";
                ServerSizeValue.Text = "";

                nameConflictEntry.Text = "";

                return;
            }

            if (multiSelect)
            {
                EnableConflictControls(true);
                LocalNameValue.Text = Util.GS("Multiple selected");
                LocalDateValue.Text = "";
                LocalSizeValue.Text = "";

                ServerNameValue.Text = Util.GS("Multiple selected");
                ServerDateValue.Text = "";
                ServerSizeValue.Text = "";

                if (ifolder.CurrentUserRights == "ReadOnly")
                {
                    if (LocalSaveButton.Label == Stock.Save)
                    {
                        LocalSaveButton.Sensitive = false;
                    }
                }
                return;
            }

            if (!ch.IsNameConflict)
            {
                EnableConflictControls(true);
                LocalNameValue.Text = ch.FileConflict.LocalName;
                LocalDateValue.Text = ch.FileConflict.LocalDate;
                LocalSizeValue.Text = ch.FileConflict.LocalSize;

                ServerNameValue.Text = ch.FileConflict.ServerName;
                ServerDateValue.Text = ch.FileConflict.ServerDate;
                ServerSizeValue.Text = ch.FileConflict.ServerSize;

                if (ifolder.CurrentUserRights == "ReadOnly")
                {
                    if (LocalSaveButton.Label == Stock.Save)
                    {
                        LocalSaveButton.Sensitive = false;
                    }
                }
                return;
            }

            EnableConflictControls(true);

//			if(ch.LocalNameConflict != null)
//			{
//				LocalNameValue.Text = ch.LocalNameConflict.LocalName;
//				LocalDateValue.Text = ch.LocalNameConflict.LocalDate;
//				LocalSizeValue.Text = ch.LocalNameConflict.LocalSize;
//			}
//			else
//			{
//				LocalNameValue.Text = "";
//				LocalDateValue.Text = "";
//				LocalSizeValue.Text = "";
//				LocalSaveButton.Sensitive = false;
//			}
//
//			if(ch.ServerNameConflict != null)
//			{
//				ServerNameValue.Text = ch.ServerNameConflict.ServerName;
//				ServerDateValue.Text = ch.ServerNameConflict.ServerDate;
//				ServerSizeValue.Text = ch.ServerNameConflict.ServerSize;
//			}
//			else
//			{
//				ServerNameValue.Text = "";
//				ServerDateValue.Text = "";
//				ServerSizeValue.Text = "";
//				ServerSaveButton.Sensitive = false;
//			}
        }
示例#7
0
        /// <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);
                    }
                }
            }
        }
示例#8
0
        /// <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);
                }
            }
        }