MetadataHelper.cs #1

  • //
  • guest/
  • christoph_leithner/
  • piper/
  • main/
  • windows/
  • R1.1/
  • Perforce/
  • Helper/
  • MetadataHelper.cs
  • View
  • Commits
  • Open Download .zip Download (2 KB)
//
// Copyright 2014 Perforce Software Inc.
//

using Perforce.Model;
using Perforce.P4;

namespace Perforce.Helper {
    public class MetadataHelper {

        public static bool CanEdit(string path) {
            bool editable = false;
            if (!string.IsNullOrEmpty(path)) {
                var helper = Utility.GetPerforceHelper();
                helper.RunFstat(path);
            }
            return editable;
        }

        public static bool CanEdit(ListingItem item) {
            if (item is FileItem) {
                return CanEdit(item as FileItem);
            } else {
                return CanEdit(item as FolderItem);
            }
        }

        public static bool CanEdit(FolderItem folder) {
            var editable = false;
            if (folder.IsMapped) {
            }
            return editable;
        }

        public static bool CanEdit(FileItem file) {
            var editable = false;
            if (file.IsMapped) {
                editable = CanEdit(file.Metadata);
            }
            return editable;
        }

        public static bool CanEdit(FileMetaData metadata) {
            var editable = false;
            if (metadata != null && metadata.IsMapped) {
                var serverLock = false;
                if (metadata.Type.Modifiers.HasFlag(FileTypeModifier.ExclusiveOpen)) {
                    if (metadata.OtherActions != null && metadata.OtherActions.Count > 0) {
                        serverLock = true;
                    }
                }
                if (!metadata.OtherLock && !serverLock) {
                    editable = true;
                }
            }
            return editable;
        }

        public static bool IsOpen(FileMetaData metadata) {
            var openable = false;

            return openable;
        }


        // check if a file can be reverted. in this case, only if the current user 
        // is editing, adding or deleting the file
        public static bool CanRevert(FileItem file) {
            var revertable = false;
            if (file.IsMapped) {
                var md = file.Metadata;
                if (md != null) {
                    if (md.Action.Equals(FileAction.Edit) ||
                        md.Action.Equals(FileAction.Add) ||
                        md.Action.Equals(FileAction.Delete)) {
                        revertable = true;
                    }
                }
            }
            return revertable;
        }

    }
}
# Change User Description Committed
#1 16817 christoph_leithner "Forking branch Main of perforce-software-piper to christoph_leithner-piper."
//guest/perforce_software/piper/main/windows/R1.1/Perforce/Helper/MetadataHelper.cs
#1 16507 perforce_software Move to main branch.
//guest/perforce_software/piper/windows/R1.1/Perforce/Helper/MetadataHelper.cs
#2 16474 Robert Cowham Bring up-to-date with //guest/perforce_software/piper/windows/main/...@16473
#1 11256 alan_petersen Populate //guest/perforce_software/piper/windows/R1.1/...
from //guest/perforce_software/piper/windows/main/....
//guest/perforce_software/piper/windows/main/Perforce/Helper/MetadataHelper.cs
#1 11255 alan_petersen Rename/move file(s)
//guest/perforce_software/piper/windows/Perforce/Helper/MetadataHelper.cs
#4 10804 alan_petersen UPDATE:
- some code cleanup
- submit now catches errors more intelligently and displays them
- connection failures in background processes now display dialog indicating connection failure
    - this stops the background process (this will avoid the endless dialog boxes seen in the Mac version!)
    - currently, dismissing the dialog exits the application -- this may change once I get the 'change connection' feature working
#3 10800 alan_petersen UPDATE:
- Various fixes   
    - fixed bug in which double-click would not work on files locked by the user
    - fixed bug in helper application dialog
    - added 'reconcile files' to context menu in Workspace view
    - updated submit dialog to display error message if submit fails
#2 10794 alan_petersen Various updates....
       - made main exception caught (happens if application cannot initialize, for example) more explicit in the message box (was "test" :)
       - CTRL-F now moves focus to search box
       - fixed double-click warning message when item is already locked
       - better thumbnail handling
       - general cleanup
#1 10778 alan_petersen Some updates to logic that looks for locked files...
exclusively locked files do not show up as locked in fstat (doh!) so I had to do a little massaging (basically, looking at the file type and if it is +l and there is an otheraction then there must be an exclusive lock)