public GenusAvailableNameControl(TaxonViewModel taxon, User user)
            : base(taxon, user, "GenusAvailableNames")
        {
            InitializeComponent();

            txtReference.BindUser(user, LookupType.Reference);
            txtNameStatus.BindUser(user, PickListType.Phrase, "GAN Name Status", TraitCategoryType.Taxon);
            txtFixationMethod.BindUser(user, PickListType.Phrase, "Fixation Method", TraitCategoryType.Taxon);

            var data = Service.GetGenusAvailableName(taxon.TaxaID.Value);
            if (data == null) {
                data = new GenusAvailableName();
                data.BiotaID = taxon.TaxaID.Value;
            }
            _model = new GenusAvailableNameViewModel(data);

            this.DataContext = _model;
            _model.DataChanged += new DataChangedHandler((vm) => {
                RegisterUniquePendingChange(new UpdateGenusAvailableNameCommand(_model.Model));
                EnableTabs();
            });

            LoadIncludedSpeciesModel();

            EnableTabs();

            // The "insert included species" stored proc does not return the new identity for the
            // included species record, so we need to reload the model on update to get the ids...
            this.ChangesCommitted += new PendingChangesCommittedHandler((s) => {
                LoadIncludedSpeciesModel();
            });
        }
Пример #2
0
        public DistributionControl(TaxaPlugin plugin, Data.User user, TaxonViewModel taxon)
            : base(user, String.Format("Taxon::DistributionControl::{0}", taxon.TaxaID.Value))
        {
            InitializeComponent();

            this.AllowDrop = true;

            this.Taxon  = taxon;
            this.Plugin = plugin;
            txtDistribution.DataContext = taxon;

            var list = Service.GetDistribution(taxon.TaxaID);

            list.Sort((a, b) => {
                return(a.DistRegionFullPath.CompareTo(b.DistRegionFullPath));
            });

            _model = CreateModelFromList(list);
            tvwDist.ItemsSource = _model;
            ExpandAll(_model);
            grpDist.IsEnabled = false;

            taxon.DataChanged += new DataChangedHandler((t) => {
                RegisterUniquePendingChange(new UpdateDistQualDatabaseCommand(taxon.Taxon));
            });

            this.PreviewDragEnter += new DragEventHandler(DistributionControl_PreviewDrag);
            this.PreviewDragOver  += new DragEventHandler(DistributionControl_PreviewDrag);

            this.Drop += new DragEventHandler(DistributionControl_Drop);
        }
        /// <summary>
        /// Return the elemType of the first child that is not "unplaced", including available names, species inquirenda and incertae sedis
        /// </summary>
        /// <param name="current"></param>
        /// <returns></returns>
        public TaxonRank GetChildElementType(TaxonViewModel parent)
        {
            if (!parent.IsExpanded)
            {
                parent.IsExpanded = true; // This will load the children, if they are not already loaded...
            }

            foreach (TaxonViewModel child in parent.Children)
            {
                if (String.IsNullOrEmpty(child.ElemType))
                {
                    continue;
                }

                if (child.AvailableName.GetValueOrDefault(false) || child.LiteratureName.GetValueOrDefault(false))
                {
                    continue;
                }

                if (child.ElemType == TaxaService.SPECIES_INQUIRENDA || child.ElemType == TaxaService.INCERTAE_SEDIS)
                {
                    continue;
                }

                return(TaxaPlugin.Service.GetTaxonRank(child.Taxon));
            }

            return(null);
        }
Пример #4
0
 public TaxonMenuFactory(TaxonViewModel taxon, TaxonExplorer explorer, MessageFormatterFunc formatter)
 {
     this.Taxon = taxon;
     this.Explorer = explorer;
     this.FormatterFunc = formatter;
     _builder = new MenuItemBuilder(formatter);
 }
Пример #5
0
 public TaxonMenuFactory(TaxonViewModel taxon, TaxonExplorer explorer, MessageFormatterFunc formatter)
 {
     this.Taxon         = taxon;
     this.Explorer      = explorer;
     this.FormatterFunc = formatter;
     _builder           = new MenuItemBuilder(formatter);
 }
 protected void Move(TaxonViewModel source, TaxonViewModel target)
 {
     source.Parent.Children.Remove(source);
     target.Children.Add(source);
     source.Parent       = target;
     source.TaxaParentID = target.TaxaID;
 }
Пример #7
0
        public GenusAvailableNameControl(TaxonViewModel taxon, User user) : base(taxon, user, "GenusAvailableNames")
        {
            InitializeComponent();

            txtReference.BindUser(user, LookupType.Reference);
            txtNameStatus.BindUser(user, PickListType.Phrase, "GAN Name Status", TraitCategoryType.Taxon);
            txtFixationMethod.BindUser(user, PickListType.Phrase, "Fixation Method", TraitCategoryType.Taxon);

            var data = Service.GetGenusAvailableName(taxon.TaxaID.Value);

            if (data == null)
            {
                data         = new GenusAvailableName();
                data.BiotaID = taxon.TaxaID.Value;
            }
            _model = new GenusAvailableNameViewModel(data);

            this.DataContext    = _model;
            _model.DataChanged += new DataChangedHandler((vm) => {
                RegisterUniquePendingChange(new UpdateGenusAvailableNameCommand(_model.Model));
                EnableTabs();
            });

            LoadIncludedSpeciesModel();

            EnableTabs();

            // The "insert included species" stored proc does not return the new identity for the
            // included species record, so we need to reload the model on update to get the ids...
            this.ChangesCommitted += new PendingChangesCommittedHandler((s) => {
                LoadIncludedSpeciesModel();
            });
        }
Пример #8
0
 public TaxonStatisticsReport(User user, TaxonViewModel taxon)
     : base(user, taxon)
 {
     RegisterViewer(new TabularDataViewerSource());
     DefineColumn("Category");
     DefineColumn("Count");
 }
Пример #9
0
        public DistributionControl(TaxaPlugin plugin, Data.User user, TaxonViewModel taxon)
            : base(user, String.Format("Taxon::DistributionControl::{0}", taxon.TaxaID.Value))
        {
            InitializeComponent();

            this.AllowDrop = true;

            this.Taxon = taxon;
            this.Plugin = plugin;
            txtDistribution.DataContext = taxon;

            var list = Service.GetDistribution(taxon.TaxaID);
            list.Sort((a, b) => {
                return a.DistRegionFullPath.CompareTo(b.DistRegionFullPath);
            });

            _model = CreateModelFromList(list);
            tvwDist.ItemsSource = _model;
            ExpandAll(_model);
            grpDist.IsEnabled = false;

            taxon.DataChanged += new DataChangedHandler((t) => {
                RegisterUniquePendingChange(new UpdateDistQualDatabaseCommand(taxon.Taxon));
            });

            this.PreviewDragEnter += new DragEventHandler(DistributionControl_PreviewDrag);
            this.PreviewDragOver += new DragEventHandler(DistributionControl_PreviewDrag);

            this.Drop += new DragEventHandler(DistributionControl_Drop);
        }
Пример #10
0
        public CommonNamesControl(TaxonViewModel taxon, User user)
            : base(taxon, user, "CommonNames")
        {
            InitializeComponent();

            txtReference.BindUser(user, LookupType.Reference);
            lstNames.SelectionChanged += new SelectionChangedEventHandler(lstNames_SelectionChanged);

            ChangesCommitted += new PendingChangesCommittedHandler(CommonNamesControl_ChangesCommitted);
        }
Пример #11
0
        public CommonNamesControl(TaxonViewModel taxon, User user)
            : base(taxon, user, "CommonNames")
        {
            InitializeComponent();

            txtReference.BindUser(user, LookupType.Reference);
            lstNames.SelectionChanged += new SelectionChangedEventHandler(lstNames_SelectionChanged);

            ChangesCommitted += new PendingChangesCommittedHandler(CommonNamesControl_ChangesCommitted);
        }
Пример #12
0
 public TaxonDropContext(TaxonViewModel source, TaxonViewModel target, TaxaPlugin plugin)
 {
     this.TaxaPlugin = plugin;
     this.Source = source;
     this.Target = target;
     this.SourceRank = TaxaPlugin.Service.GetTaxonRank(source.Taxon);
     this.TargetRank = TaxaPlugin.Service.GetTaxonRank(target.Taxon);
     this.SourceChildRank = GetChildElementType(source);
     this.TargetChildRank = GetChildElementType(target);
 }
 public TaxonDropContext(TaxonViewModel source, TaxonViewModel target, TaxaPlugin plugin)
 {
     this.TaxaPlugin      = plugin;
     this.Source          = source;
     this.Target          = target;
     this.SourceRank      = TaxaPlugin.Service.GetTaxonRank(source.Taxon);
     this.TargetRank      = TaxaPlugin.Service.GetTaxonRank(target.Taxon);
     this.SourceChildRank = GetChildElementType(source);
     this.TargetChildRank = GetChildElementType(target);
 }
 public MaterialForTaxonReport(User user, TaxonViewModel taxon)
     : base(user, taxon)
 {
     RegisterViewer(new TabularDataViewerSource());
     DefineColumn("BiotaFullName", "Taxa");
     DefineColumn("FullRegion", "Region");
     DefineColumn("Local", "Locality");
     DefineColumn("FormattedLatLong", "Lat/Long");
     DefineColumn("Collectors");
     DefineColumn("Dates");
     DefineColumn("AccessionNo", "Accession No.");
 }
Пример #15
0
 public MaterialForTaxonReport(User user, TaxonViewModel taxon)
     : base(user, taxon)
 {
     RegisterViewer(new TabularDataViewerSource());
     DefineColumn("BiotaFullName", "Taxa");
     DefineColumn("FullRegion", "Region");
     DefineColumn("Local", "Locality");
     DefineColumn("FormattedLatLong", "Lat/Long");
     DefineColumn("Collectors");
     DefineColumn("Dates");
     DefineColumn("AccessionNo", "Accession No.");
 }
        protected override void ProcessImpl(User user)
        {
            var service = new TaxaService(user);

            service.InsertTaxon(Taxon.Taxon);
            // The service will have updated the new taxon with its database identity.
            // If this taxon has any children we can update their identity too.
            foreach (HierarchicalViewModelBase child in Taxon.Children)
            {
                TaxonViewModel tvm = child as TaxonViewModel;
                tvm.TaxaParentID = Taxon.Taxon.TaxaID;
            }
        }
        public void BulkAddChildren(List <Taxon> taxa, TaxonLabelGenerator labelGenerator)
        {
            if (Children.Count == 1 && Children[0] is ViewModelPlaceholder)
            {
                Children.Clear();
            }

            foreach (Taxon taxon in taxa)
            {
                TaxonViewModel model = new TaxonViewModel(this, taxon, labelGenerator);
                Children.Add(model);
            }
        }
Пример #18
0
        public ChangeRankWindow(User user, TaxonViewModel taxon, List<TaxonRank> validRanks)
        {
            InitializeComponent();

            this.User = user;
            this.ViewModel = taxon;

            cmbTypes.ItemsSource = validRanks;
            optValidType.IsEnabled = (validRanks != null && validRanks.Count > 0);
            cmbTypes.SelectedIndex = 0;

            if (string.IsNullOrEmpty(taxon.KingdomCode)) {
                gridWarning.Visibility = System.Windows.Visibility.Visible;
                lblWarning.Text = "The list of available ranks cannot be determined because the selected taxon does not belong to a kingdom.";
            }
        }
Пример #19
0
        public ChecklistReportOptions(User user, TaxonViewModel taxon)
        {
            InitializeComponent();
            this.User = user;
            txtTaxon.BindUser(user, LookupType.Taxon);
            txtTaxon.ObjectID = taxon.TaxaID.Value;
            txtTaxon.Text     = taxon.TaxaFullName;

            var ranknames = Service.GetOrderedRanks();

            _rankModel = new ObservableCollection <SelectableRankName>(ranknames.Select((n) => {
                return(new SelectableRankName(n, true));
            }));

            lstRanks.ItemsSource = _rankModel;
        }
        public ChangeRankWindow(User user, TaxonViewModel taxon, List <TaxonRank> validRanks)
        {
            InitializeComponent();

            this.User      = user;
            this.ViewModel = taxon;

            cmbTypes.ItemsSource   = validRanks;
            optValidType.IsEnabled = (validRanks != null && validRanks.Count > 0);
            cmbTypes.SelectedIndex = 0;

            if (string.IsNullOrEmpty(taxon.KingdomCode))
            {
                gridWarning.Visibility = System.Windows.Visibility.Visible;
                lblWarning.Text        = "The list of available ranks cannot be determined because the selected taxon does not belong to a kingdom.";
            }
        }
        internal void AddToFavorites(TaxonViewModel Taxon, bool global)
        {
            TaxonFavorite model = new TaxonFavorite();

            model.IsGroup          = false;
            model.ChgComb          = Taxon.ChgComb ?? false;
            model.ElemType         = Taxon.ElemType;
            model.Epithet          = Taxon.Epithet;
            model.FavoriteID       = -1;
            model.FavoriteParentID = 0;
            model.IsGlobal         = global;
            model.KingdomCode      = Taxon.KingdomCode;
            model.NameStatus       = Taxon.NameStatus;
            model.Rank             = Taxon.Rank;
            model.TaxaFullName     = Taxon.TaxaFullName;
            model.TaxaID           = Taxon.TaxaID ?? -1;
            model.TaxaParentID     = Taxon.TaxaParentID ?? -1;
            model.Unplaced         = Taxon.Unplaced ?? false;
            model.Unverified       = Taxon.Unverified ?? false;
            model.Username         = User.Username;
            model.YearOfPub        = Taxon.YearOfPub;

            LoadFavorites();

            TaxonFavoriteViewModel viewModel = new TaxonFavoriteViewModel(model);

            if (global)
            {
                _globalRoot.IsExpanded = true;
                _globalRoot.Children.Add(viewModel);
                viewModel.Parent = _globalRoot;
            }
            else
            {
                _userRoot.IsExpanded = true;
                _userRoot.Children.Add(viewModel);
                viewModel.Parent = _userRoot;
            }

            viewModel.IsSelected = true;

            RegisterPendingChange(new InsertTaxonFavoriteCommand(viewModel.Model));
        }
Пример #22
0
        public TaxonDetails(TaxaPlugin plugin, TaxonViewModel taxon, User user, Action<TaxonViewModel> committedAction, bool readOnly)
            : base(user, "TaxonDetails::" + taxon.TaxaID.Value)
        {
            InitializeComponent();

            this.Plugin = plugin;
            _committedAction = committedAction;

            tabControl.AddTabItem("General", new TaxonNameDetails(taxon.TaxaID, User, committedAction) { IsReadOnly = readOnly });

            if (taxon.IsAvailableOrLiteratureName) {
                TaxonRank rank = Service.GetTaxonRank(taxon.Taxon);
                switch (rank.Category.ToLower()) {
                    case "g":
                        tabControl.AddTabItem("Available Name", new GenusAvailableNameControl(taxon, user) { IsReadOnly = readOnly });
                        break;
                    case "s":
                        tabControl.AddTabItem("Available Name", new SpeciesAvailableNameControl(taxon, user) { IsReadOnly = readOnly });
                        break;
                    default:
                        tabControl.AddTabItem("Available Name", new AvailableNameControl(taxon, user) { IsReadOnly = readOnly });
                        break;
                }
            } else {
                tabControl.AddTabItem("Common Names", new CommonNamesControl(taxon, user) { IsReadOnly = readOnly });
            }

            tabControl.AddTabItem("References", new ReferencesControl(user, TraitCategoryType.Taxon, taxon.TaxaID) { IsReadOnly = readOnly });

            if ((!taxon.AvailableName.ValueOrFalse() && !taxon.LiteratureName.ValueOrFalse())) {
                tabControl.AddTabItem("Distribution", new DistributionControl(Plugin, user, taxon) { IsReadOnly = readOnly });
            }

            tabControl.AddTabItem("Multimedia", new MultimediaControl(User, TraitCategoryType.Taxon, taxon) { IsReadOnly = readOnly });
            tabControl.AddTabItem("Associates", new OneToManyControl(new AssociatesOneToManyController(User, TraitCategoryType.Taxon, taxon)) { IsReadOnly = readOnly });
            tabControl.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Taxon, taxon) { IsReadOnly = readOnly });
            tabControl.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Taxon, taxon) { IsReadOnly = readOnly });
            tabControl.AddTabItem("Ownership", new OwnershipDetails(taxon.Taxon));

            this.Taxon = taxon;

            this.ChangesCommitted += new PendingChangesCommittedHandler(TaxonDetails_ChangesCommitted);
        }
        private void BuildTaxaChildrenViewModel(HierarchicalViewModelBase item, int taxaID)
        {
            // The model node is a Taxon favorites, so we can get the 'real' taxon children for it...
            item.Children.Clear();

            var          taxaService = new TaxaService(User);
            List <Taxon> taxa        = taxaService.GetTaxaForParent(taxaID);

            foreach (Taxon taxon in taxa)
            {
                TaxonViewModel child = new TaxonViewModel(item, taxon, null);
                if (child.NumChildren > 0)
                {
                    child.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren);
                    child.Children.Add(new ViewModelPlaceholder("Loading..."));
                }
                item.Children.Add(child);
            }
        }
Пример #24
0
        public BiotaPermissions(User user, TaxonViewModel taxon, bool readOnlyMode) : base(user, "BiotaPermission:" + taxon.TaxaID.Value)
        {
            InitializeComponent();
            this.Taxon = taxon;

            Loaded += new RoutedEventHandler(BiotaPermissions_Loaded);
            lvw.SelectionChanged += new SelectionChangedEventHandler(lvw_SelectionChanged);

            optModify.Checked    += new RoutedEventHandler(UpdatePermissions);
            optOwnership.Checked += new RoutedEventHandler(UpdatePermissions);
            optReadOnly.Checked  += new RoutedEventHandler(UpdatePermissions);
            chkDelete.Checked    += new RoutedEventHandler(UpdatePermissions);
            chkDelete.Unchecked  += new RoutedEventHandler(UpdatePermissions);
            chkInsert.Checked    += new RoutedEventHandler(UpdatePermissions);
            chkInsert.Unchecked  += new RoutedEventHandler(UpdatePermissions);
            chkUpdate.Checked    += new RoutedEventHandler(UpdatePermissions);
            chkUpdate.Unchecked  += new RoutedEventHandler(UpdatePermissions);

            detailsGrid.IsEnabled = !readOnlyMode;
        }
Пример #25
0
        public BiotaPermissions(User user, TaxonViewModel taxon, bool readOnlyMode)
            : base(user, "BiotaPermission:" + taxon.TaxaID.Value)
        {
            InitializeComponent();
            this.Taxon = taxon;

            Loaded += new RoutedEventHandler(BiotaPermissions_Loaded);
            lvw.SelectionChanged += new SelectionChangedEventHandler(lvw_SelectionChanged);

            optModify.Checked += new RoutedEventHandler(UpdatePermissions);
            optOwnership.Checked += new RoutedEventHandler(UpdatePermissions);
            optReadOnly.Checked += new RoutedEventHandler(UpdatePermissions);
            chkDelete.Checked += new RoutedEventHandler(UpdatePermissions);
            chkDelete.Unchecked += new RoutedEventHandler(UpdatePermissions);
            chkInsert.Checked +=new RoutedEventHandler(UpdatePermissions);
            chkInsert.Unchecked +=new RoutedEventHandler(UpdatePermissions);
            chkUpdate.Checked +=new RoutedEventHandler(UpdatePermissions);
            chkUpdate.Unchecked +=new RoutedEventHandler(UpdatePermissions);

            detailsGrid.IsEnabled = !readOnlyMode;
        }
Пример #26
0
        public AvailableNameControl(TaxonViewModel taxon, User user) : base(taxon, user, "AvailableNames")
        {
            InitializeComponent();
            txtReference.BindUser(user, LookupType.Reference);
            txtNameStatus.BindUser(user, PickListType.Phrase, "ALN Name Status", TraitCategoryType.Taxon);


            var name = new TaxaService(user).GetAvailableName(taxon.TaxaID.Value);

            if (name == null)
            {
                name         = new AvailableName();
                name.BiotaID = taxon.TaxaID.Value;
            }

            _model           = new AvailableNameViewModel(name);
            this.DataContext = _model;

            _model.DataChanged += new DataChangedHandler((vm) => {
                RegisterUniquePendingChange(new UpdateAvailableNameCommand(_model.Model));
            });
        }
        public override ViewModelBase CreatePinnableViewModel(PinnableObject pinnable)
        {
            if (pinnable != null && pinnable.LookupType == LookupType.Taxon)
            {
                Taxon t = Service.GetTaxon(pinnable.ObjectID);
                if (t != null)
                {
                    var m = new TaxonViewModel(null, t, tt => tt.TaxaFullName);
                    return(m);
                }
            }

            if (pinnable != null && pinnable.LookupType == LookupType.DistributionRegion)
            {
                var service = new SupportService(User);
                var region  = service.GetDistributionRegion(pinnable.ObjectID);
                if (region != null)
                {
                    return(new DistributionRegionViewModel(region));
                }
            }

            return(null);
        }
 public DeleteTaxonDatabaseCommand(TaxonViewModel taxon)
 {
     this.Taxon = taxon;
 }
 public InsertTaxonDatabaseCommand(TaxonViewModel taxon)
 {
     this.Taxon = taxon;
 }
Пример #30
0
 public DarwinCoreReportForTaxon(User user, TaxonViewModel taxon)
     : base(user, taxon)
 {
     RegisterViewer(new TabularDataViewerSource());
 }
Пример #31
0
 public NameControlBase(TaxonViewModel taxon, User user, string controlId)
     : base(user, String.Format("Taxon::{0}::{1}", controlId, taxon.TaxaID.Value))
 {
     this.Taxon = taxon;
 }
Пример #32
0
 public TaxonReportBase(User user, TaxonViewModel taxon)
 {
     this.Service = new TaxaService(user);
     this.Taxon   = taxon;
 }
Пример #33
0
        internal void DeleteTaxon(TaxonViewModel taxon)
        {
            if (this.Question(_R("TaxonExplorer.prompt.DeleteTaxon", taxon.DisplayLabel), _R("TaxonExplorer.prompt.DeleteTaxon.Caption"))) {
                // Check to see if the taxon is safe to delete.

                // schedule the database bit...
                RegisterPendingChange(new DeleteTaxonDatabaseCommand(taxon), this);
                // and the update the UI
                MarkItemAsDeleted(taxon);
            }
        }
Пример #34
0
 internal void ShiftTaxonUp(TaxonViewModel taxon)
 {
     ShiftTaxon(taxon, (oldindex) => { return oldindex - 1; });
 }
Пример #35
0
        internal void RenameTaxon(TaxonViewModel taxon)
        {
            if (!User.HasBiotaPermission(taxon.TaxaID.Value, PERMISSION_MASK.UPDATE)) {
                ErrorMessage.Show("You do not have permission to rename '" + taxon.TaxaFullName + "'!");
                return;
            }

            taxon.IsSelected = true;
            taxon.IsRenaming = true;
        }
Пример #36
0
        internal void ChangeRank(TaxonViewModel taxon)
        {
            if (!User.HasBiotaPermission(taxon.TaxaID.Value, PERMISSION_MASK.UPDATE)) {
                ErrorMessage.Show("You do not have sufficient priviledges to perform this operation!");
                return;
            }

            var validTypes = GetValidChildren(taxon);

            var frm = new ChangeRankWindow(User, taxon, validTypes);
            frm.Owner = this.FindParentWindow();
            if (frm.ShowDialog() == true) {
                var selectedRank = frm.SelectedRank == null ? "" : frm.SelectedRank.Code;
                if (selectedRank != taxon.ElemType) {
                    taxon.ElemType = selectedRank; // should trigger a change!
                    InsertUniquePendingUpdate(taxon);
                }
            }
        }
Пример #37
0
        internal void EditTaxonName(TaxonViewModel viewModel)
        {
            if (viewModel.TaxaID.Value < 0) {
                ErrorMessage.Show("You must save your changes before proceeding");
                return;
            }

            var readOnly = !User.HasBiotaPermission(viewModel.TaxaID.Value, PERMISSION_MASK.UPDATE);

            TaxonNameDetails details = new TaxonNameDetails(viewModel.TaxaID, User, (nameDetails) => {
                RegenerateLabel(nameDetails);
            }) { IsReadOnly = readOnly };
            PluginManager.Instance.AddNonDockableContent(this.Owner, details, "Taxon name details",SizeToContent.WidthAndHeight);
        }
Пример #38
0
        internal void EditTaxonDetails(int? taxonId)
        {
            if (taxonId.HasValue) {

                if (taxonId.Value < 0) {
                    ErrorMessage.Show("You must save your changes before proceeding");
                    return;
                }

                Taxon fullDetails = Service.GetTaxon(taxonId.Value);
                TaxonViewModel model = new TaxonViewModel(null, fullDetails, null);

                var readOnly = !User.HasBiotaPermission(taxonId.Value, PERMISSION_MASK.UPDATE);
                TaxonDetails control = new TaxonDetails(Owner, model, User, (changedModel) => {
                    RegenerateLabel(changedModel);
                }, readOnly);

                TaxonRank taxonRank = Service.GetTaxonRank(model.Taxon);

                String title = String.Format("Taxon Detail: {0} ({1}) [{2}] {3}", model.TaxaFullName, taxonRank == null ? "Unranked" : taxonRank.GetElementTypeLongName(model.Taxon), model.TaxaID, readOnly ? "(Read Only)" : "");

                PluginManager.Instance.AddNonDockableContent(Owner, control, title, SizeToContent.Manual);
            }
        }
Пример #39
0
        internal void EditBiotaPermissions(TaxonViewModel taxon)
        {
            if (!taxon.TaxaID.HasValue || taxon.TaxaID.Value < 0) {
                ErrorMessage.Show("You must save apply changes before you can proceed.");
                return;
            }

            bool readOnly = !User.HasBiotaPermission(taxon.TaxaID.Value, PERMISSION_MASK.OWNER);

            if (!readOnly) {
                PluginManager.Instance.AddNonDockableContent(Owner, new BiotaPermissions(User, taxon, readOnly), "Taxon Permissions for '" + taxon.TaxaFullName + (readOnly ? "' (Read Only)" : "'"), SizeToContent.Manual);
            } else {
                // Display a readonly version of the permissions...
                var permStr = "";
                string strOwners = "";
                using (new OverrideCursor(Cursors.Wait)) {
                    var service = new SupportService(User);
                    var perms = service.GetBiotaPermissions(User.Username, taxon.TaxaID.Value);
                    var owners = service.getBiotaOwners(taxon.TaxaID.Value);

                    if ((perms.PermMask1 & (int) PERMISSION_MASK.OWNER) != 0) {
                        permStr= "Owner";
                    } else if ((perms.PermMask1 & (int) PERMISSION_MASK.WRITE) != 0) {
                        var rights = new List<String>();
                        if ((perms.PermMask1 & (int) PERMISSION_MASK.INSERT) != 0) {
                            rights.Add("Insert");
                        }
                        if ((perms.PermMask1 & (int) PERMISSION_MASK.UPDATE) != 0) {
                            rights.Add("Update");
                        }
                        if ((perms.PermMask1 & (int) PERMISSION_MASK.DELETE) != 0) {
                            rights.Add("Delete");
                        }
                        permStr = rights.Join(", ");
                    } else {
                        permStr = "Read Only";
                    }

                    var ownerNames = new List<string>();
                    foreach (BiotaOwner owner in owners) {
                        if (!string.IsNullOrWhiteSpace(owner.Name)) {
                            ownerNames.Add(string.Format("{0} ({1})", owner.Name, owner.FullName));
                        }
                    }

                    strOwners = ownerNames.Join(", ");
                    if (string.IsNullOrWhiteSpace(strOwners)) {
                        strOwners = "sa (System Administrator)";
                    }
                }

                InfoBox.Show(string.Format("Permissions: {0}\n\nOwners: {1}", permStr, strOwners), "Permissions for " + taxon.TaxaFullName, this);
            }
        }
 public MergeTaxonDatabaseCommand(TaxonViewModel source, TaxonViewModel target, bool createNewIDRecord)
 {
     this.Source            = source;
     this.Target            = target;
     this.CreateNewIDRecord = createNewIDRecord;
 }
Пример #41
0
 protected void Move(TaxonViewModel source, TaxonViewModel target)
 {
     source.Parent.Children.Remove(source);
     target.Children.Add(source);
     source.Parent = target;
     source.TaxaParentID = target.TaxaID;
 }
Пример #42
0
        public SpeciesAvailableNameControl(TaxonViewModel taxon, User user) : base(taxon, user, "SpeciesAvailabeNames::")
        {
            InitializeComponent();

            txtReference.BindUser(user, LookupType.Reference);
            txtNameStatus.BindUser(user, PickListType.Phrase, "SAN Name Status", TraitCategoryType.Taxon);
            txtInstitution.BindUser(user, PickListType.Phrase, "Institution", TraitCategoryType.Taxon);
            txtSpecimen.BindUser(user, LookupType.Material);


            int taxaId = taxon.TaxaID.GetValueOrDefault(-1);
            SpeciesAvailableName data = Service.GetSpeciesAvailableName(taxaId) ?? new SpeciesAvailableName {
                BiotaID = taxaId
            };

            _model = new SpeciesAvailableNameViewModel(data);

            _model.DataChanged += changed => RegisterUniquePendingChange(new UpdateSanDatabaseCommand(_model.Model));

            cmbPrimaryType.SelectionChanged += (source, e) => {
                var tstr = cmbPrimaryType.SelectedItem as string;
                if (tstr != null && _SANTypeDataTypes.ContainsKey(tstr))
                {
                    var typedata = _SANTypeDataTypes[tstr];
                    cmbSecondaryType.ItemsSource = typedata.SecondaryTypes;
                }
            };

            if (taxon.TaxaID != null)
            {
                List <SANTypeDataType> santypes = Service.GetSANTypeDataTypes(taxon.TaxaID.Value);
                foreach (SANTypeDataType type in santypes)
                {
                    _SANTypeDataTypes[type.PrimaryType] = type;
                }

                cmbPrimaryType.ItemsSource = santypes.ConvertAll(st => st.PrimaryType);
            }

            var tdlist = Service.GetSANTypeData(taxaId);

            _typeData = new ObservableCollection <SANTypeDataViewModel>(tdlist.ConvertAll(d => {
                var viewmodel          = new SANTypeDataViewModel(d);
                viewmodel.DataChanged += changed => {
                    if (viewmodel.SANTypeDataID >= 0)
                    {
                        RegisterUniquePendingChange(new UpdateSANTypeDataCommand(viewmodel.Model));
                    }
                };
                return(viewmodel);
            }));
            lstTypeData.ItemsSource = _typeData;

            lstTypeData.SelectionChanged += (source, e) => {
                gridTypeData.IsEnabled = lstTypeData.SelectedItem != null;

                var availableTypes = new List <string> {
                    cmbPrimaryType.Text
                };
                var secondaries = cmbSecondaryType.ItemsSource as IEnumerable <string>;

                if (secondaries != null)
                {
                    availableTypes.AddRange(secondaries);
                }

                cmbType.ItemsSource      = availableTypes;
                gridTypeData.DataContext = lstTypeData.SelectedItem;
            };

            DataContext = _model;

            gridTypeData.IsEnabled = false;


            this.BackgroundInvoke(() => {
                if (_typeData.Count > 0)
                {
                    lstTypeData.SelectedIndex = 0;
                }
            });
        }
Пример #43
0
        internal void AddUnrankedValid(TaxonViewModel taxon)
        {
            AddNewTaxon(taxon, "", (child) => {

            });
        }
Пример #44
0
        public void BulkAddChildren(List<Taxon> taxa, TaxonLabelGenerator labelGenerator)
        {
            if (Children.Count == 1 && Children[0] is ViewModelPlaceholder) {
                Children.Clear();
            }

            foreach (Taxon taxon in taxa) {
                TaxonViewModel model = new TaxonViewModel(this, taxon, labelGenerator);
                Children.Add(model);
            }
        }
Пример #45
0
 public ChecklistReport(User user, TaxonViewModel taxon)
     : base(user, taxon)
 {
     RegisterViewer(new RTFReportViewerSource());
 }
Пример #46
0
 public MergeTaxonDatabaseCommand(TaxonViewModel source, TaxonViewModel target, bool createNewIDRecord)
 {
     this.Source = source;
     this.Target = target;
     this.CreateNewIDRecord = createNewIDRecord;
 }
Пример #47
0
        /// <summary>
        /// Return the elemType of the first child that is not "unplaced", including available names, species inquirenda and incertae sedis
        /// </summary>
        /// <param name="current"></param>
        /// <returns></returns>
        public TaxonRank GetChildElementType(TaxonViewModel parent)
        {
            if (!parent.IsExpanded) {
                parent.IsExpanded = true; // This will load the children, if they are not already loaded...
            }

            foreach (TaxonViewModel child in parent.Children) {

                if (String.IsNullOrEmpty(child.ElemType)) {
                    continue;
                }

                if (child.AvailableName.GetValueOrDefault(false) || child.LiteratureName.GetValueOrDefault(false)) {
                    continue;
                }

                if (child.ElemType == TaxaService.SPECIES_INQUIRENDA || child.ElemType == TaxaService.INCERTAE_SEDIS) {
                    continue;
                }

                return TaxaPlugin.Service.GetTaxonRank(child.Taxon);
            }

            return null;
        }
Пример #48
0
 public MoveTaxonDatabaseCommand(TaxonViewModel taxon, TaxonViewModel newParent)
 {
     this.Taxon = taxon;
     this.NewParent = newParent;
 }
 public MoveTaxonDatabaseCommand(TaxonViewModel taxon, TaxonViewModel newParent)
 {
     this.Taxon     = taxon;
     this.NewParent = newParent;
 }
Пример #50
0
 public DeleteTaxonDatabaseCommand(TaxonViewModel taxon)
 {
     this.Taxon = taxon;
 }
Пример #51
0
 public SiteForTaxaReport(User user, TaxonViewModel taxon) : base(user, taxon)
 {
     RegisterViewer(new RTFReportViewerSource());
 }
Пример #52
0
 public InsertTaxonDatabaseCommand(TaxonViewModel taxon)
 {
     this.Taxon = taxon;
 }
Пример #53
0
 public TypeListReport(User user, TaxonViewModel taxon) : base(user, taxon)
 {
     RegisterViewer(new TabularDataViewerSource());
 }
        public SpeciesAvailableNameControl(TaxonViewModel taxon, User user)
            : base(taxon, user, "SpeciesAvailabeNames::")
        {
            InitializeComponent();

            txtReference.BindUser(user, LookupType.Reference);
            txtNameStatus.BindUser(user, PickListType.Phrase, "SAN Name Status", TraitCategoryType.Taxon);
            txtInstitution.BindUser(user, PickListType.Phrase, "Institution", TraitCategoryType.Taxon);
            txtSpecimen.BindUser(user, LookupType.Material);

            int taxaId = taxon.TaxaID.GetValueOrDefault(-1);
            SpeciesAvailableName data = Service.GetSpeciesAvailableName(taxaId) ?? new SpeciesAvailableName { BiotaID = taxaId };

            _model = new SpeciesAvailableNameViewModel(data);

            _model.DataChanged += changed => RegisterUniquePendingChange(new UpdateSanDatabaseCommand(_model.Model));

            cmbPrimaryType.SelectionChanged += (source, e) => {
                                                   var tstr = cmbPrimaryType.SelectedItem as string;
                                                   if (tstr != null && _SANTypeDataTypes.ContainsKey(tstr)) {
                                                       var typedata = _SANTypeDataTypes[tstr];
                                                       cmbSecondaryType.ItemsSource = typedata.SecondaryTypes;
                                                   }
                                               };

            if (taxon.TaxaID != null) {
                List<SANTypeDataType> santypes = Service.GetSANTypeDataTypes(taxon.TaxaID.Value);
                foreach (SANTypeDataType type in santypes) {
                    _SANTypeDataTypes[type.PrimaryType] = type;
                }

                cmbPrimaryType.ItemsSource = santypes.ConvertAll(st=>st.PrimaryType);
            }

            var tdlist = Service.GetSANTypeData(taxaId);
            _typeData = new ObservableCollection<SANTypeDataViewModel>(tdlist.ConvertAll(d => {
                var viewmodel = new SANTypeDataViewModel(d);
                viewmodel.DataChanged +=changed => {
                                            if (viewmodel.SANTypeDataID >= 0) {
                                                RegisterUniquePendingChange(new UpdateSANTypeDataCommand(viewmodel.Model));
                                            }
                                        };
                return viewmodel;
            }));
            lstTypeData.ItemsSource = _typeData;

            lstTypeData.SelectionChanged +=(source, e) => {

                gridTypeData.IsEnabled = lstTypeData.SelectedItem != null;

                var availableTypes = new List<string> {cmbPrimaryType.Text};
                var secondaries = cmbSecondaryType.ItemsSource as IEnumerable<string>;

                if (secondaries != null) {
                    availableTypes.AddRange(secondaries);
                }

                cmbType.ItemsSource = availableTypes;
                gridTypeData.DataContext = lstTypeData.SelectedItem;
            };

            DataContext = _model;

            gridTypeData.IsEnabled = false;

            this.BackgroundInvoke(() => {
                if (_typeData.Count > 0) {
                    lstTypeData.SelectedIndex = 0;
                }
            });
        }
 public TaxonStatisticsReport(User user, TaxonViewModel taxon) : base(user, taxon)
 {
     RegisterViewer(new TabularDataViewerSource());
     DefineColumn("Category");
     DefineColumn("Count");
 }
Пример #56
0
 public ChecklistReport(User user, TaxonViewModel taxon) : base(user, taxon)
 {
     RegisterViewer(new RTFReportViewerSource());
 }
        private void TreeViewItem_MouseRightButtonDown(object sender, MouseEventArgs e)
        {
            TreeViewItem item = sender as TreeViewItem;

            if (item == null)
            {
                return;
            }

            item.Focus();
            e.Handled = true;

            var model = tvwFavorites.SelectedItem as HierarchicalViewModelBase;

            Debug.Assert(model != null);

            int?favoriteId = null;

            TaxonViewModel tvm = null;


            bool isGroup = false;

            if (model is TaxonFavoriteViewModel)
            {
                var fav = model as TaxonFavoriteViewModel;
                favoriteId = fav.FavoriteID;
                if (!fav.IsGroup)
                {
                    var taxon = new TaxaService(User).GetTaxon(fav.TaxaID);
                    tvm = new TaxonViewModel(null, taxon, TaxonExplorer.GenerateTaxonDisplayLabel);
                }
                else
                {
                    isGroup = true;
                }
            }
            else if (model is TaxonViewModel)
            {
                tvm = model as TaxonViewModel;
            }

            if (tvm != null)
            {
                TaxonMenuFactory f = new TaxonMenuFactory(tvm, TaxonExplorer, TaxonExplorer._R);
                tvwFavorites.ContextMenu = f.BuildFavoritesMenu(model);
            }
            else
            {
                var builder = new ContextMenuBuilder(null);

                builder.New("Add favorite group").Handler(() => { AddFavoriteGroup(model); }).End();
                if (isGroup)
                {
                    builder.New("Rename group").Handler(() => { RenameFavoriteGroup(model as TaxonFavoriteViewModel); }).End();
                    builder.New("Remove favorite group").Handler(() => { DeleteFavoriteGroup(model); }).End();
                }

                tvwFavorites.ContextMenu = builder.ContextMenu;
            }
        }
Пример #58
0
        internal void ChangeAvailable(TaxonViewModel taxon)
        {
            if (taxon == null) {
                return;
            }

            if (!User.HasBiotaPermission(taxon.TaxaID.Value, PERMISSION_MASK.UPDATE)) {
                ErrorMessage.Show("You do not have sufficient priviledges to perform this operation!");
                return;
            }

            var rankCategory = Service.GetTaxonRank(taxon.Taxon).Category ?? "";

            string auxMsg = "";

            if (taxon.AvailableName == true) {

                switch (rankCategory.ToUpper()) {
                    case "G":
                        auxMsg = "WARNING: Changing to Literature Name will result in the permanent loss of any Type Species Designation information.\n\n";
                        break;
                    case "S":
                        auxMsg = "WARNING: Changing to Literature Name will result in the permanent loss of any Type Data information.\n\n";
                        break;
                }

                if (this.Question(auxMsg + "Are you sure you wish to change this Available Name to a Literature Name?", "Change to Literature Name?")) {
                    taxon.LiteratureName = true;
                    taxon.AvailableName = false;
                    InsertUniquePendingUpdate(taxon);
                }
            } else if (taxon.LiteratureName == true) {

                if (this.Question("Are you sure you wish to change this Literature Name to an Available Name?", "Change to Available Name?")) {
                    taxon.LiteratureName = false;
                    taxon.AvailableName = true;
                    InsertUniquePendingUpdate(taxon);
                }

            }
        }
Пример #59
0
        internal void ExpandChildren(TaxonViewModel taxon, List<Taxon> remaining = null)
        {
            if (remaining == null) {
                remaining = Service.GetExpandFullTree(taxon.TaxaID.Value);
            }
            if (!taxon.IsExpanded) {
                // BringModelToView(tvwAllTaxa, taxon);
                taxon.BulkAddChildren(remaining.FindAll((elem) => { return elem.TaxaParentID == taxon.TaxaID; }), GenerateTaxonDisplayLabel);
                remaining.RemoveAll((elem) => { return elem.TaxaParentID == taxon.TaxaID; });
                taxon.IsExpanded = true;

            }

            foreach (HierarchicalViewModelBase child in taxon.Children) {
                ExpandChildren(child as TaxonViewModel, remaining);
            }
        }
Пример #60
0
        internal void DeleteLevel(TaxonViewModel taxon)
        {
            if (taxon == null) {
                return;
            }

            if (!User.HasBiotaPermission(taxon.TaxaID.Value, PERMISSION_MASK.DELETE)) {
                ErrorMessage.Show("You do not have sufficient priviledges to perform this operation!");
                return;
            }

            var parent = taxon.Parent as TaxonViewModel;
            if (parent == null) {
                ErrorMessage.Show("You cannot remove the top level!");
                return;
            }

            // Prompt the user to continue.
            if (!this.Question("Are you sure you would like to remove all the valid names in the level of which '" + taxon.TaxaFullName + "' is a member.", "Delete Level?")) {
                return;
            }

            // Create a list of children that need to be moved to the parent....
            taxon.IsExpanded = true;
            var parentRank = Service.GetTaxonRank(parent.Taxon);

            var deleteList = new List<TaxonViewModel>();
            foreach (TaxonViewModel sibling in parent.Children) {
                if (!sibling.ElemType.Equals(TaxonRank.INCERTAE_SEDIS) && !sibling.ElemType.Equals(TaxonRank.SPECIES_INQUIRENDA) && !sibling.IsAvailableOrLiteratureName) {
                    deleteList.Add(sibling);
                }
            }

            var childList = new List<TaxonViewModel>();
            string childType = "";
            foreach (TaxonViewModel sibling in deleteList) {
                // Determine from the examination of the current child if the process can continue.
                sibling.IsExpanded = true;

                string strCurrentSiblingElemType = GetChildElementType(sibling);
                var siblingChildRank = Service.GetTaxonRank(strCurrentSiblingElemType, sibling.KingdomCode);

                if (string.IsNullOrEmpty(childType)) {
                    childType = strCurrentSiblingElemType;
                    if (!string.IsNullOrEmpty(strCurrentSiblingElemType)) {
                        // If the child type cannot exist under the new parent type, then exit
                        if (!Service.IsValidChild(siblingChildRank, parentRank)) {
                            ErrorMessage.Show("Delete Level Failed: Items of type '" + siblingChildRank.LongName + "' cannot exist as children of a '" + parentRank.LongName + "' item!");
                            return;
                        }
                    }
                } else {
                    if (!string.IsNullOrEmpty(strCurrentSiblingElemType) && !sibling.ElemType.Equals(childType)) {
                        // tell the user that the children of the level being removed are mixed.
                        ErrorMessage.Show("Delete Level Failed: The subitems of the level being removed must be of the same type!");
                        return;
                    }
                }

                foreach (TaxonViewModel child in sibling.Children) {
                    childList.Add(child);
                }
            }

            // Go through the collection and convert the available names if required, and move each element...
            foreach (TaxonViewModel child in childList) {
                if (child.IsAvailableOrLiteratureName) {
                    child.ElemType = parent.ElemType;
                }
                Move(child, parent);
                InsertUniquePendingUpdate(child);
            }

            foreach (TaxonViewModel sibling in deleteList) {
                // schedule the database bit...
                RegisterPendingChange(new DeleteTaxonDatabaseCommand(sibling), this);
                // and the update the UI
                MarkItemAsDeleted(sibling);
            }
        }