Exemplo n.º 1
0
        internal int AddWidgets(LexEntry entry, int insertAtRow)
        {
            DetailList.SuspendLayout();
            Debug.Assert(DetailList.RowCount == 0);
            Debug.Assert(DetailList.ColumnCount == 3);
            Debug.Assert(DetailList.RowStyles.Count == 0);
            FirstRow = 0;
            int   rowCount = 0;
            Field field    = ActiveViewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString());

            if (field != null && field.GetDoShow(entry.LexicalForm, ShowNormallyHiddenFields))
            {
                Control formControl = MakeBoundControl(entry.LexicalForm, field);
                DetailList.AddWidgetRow(StringCatalog.Get(field.DisplayName),
                                        true,
                                        formControl,
                                        insertAtRow,
                                        false);
                insertAtRow = DetailList.GetRow(formControl);
                ++rowCount;
            }
            rowCount += AddCustomFields(entry, insertAtRow + rowCount);

            var rowCountBeforeSenses = rowCount;

            LastRow = insertAtRow + rowCount;
            foreach (var lexSense in entry.Senses)
            {
                var layouter = new LexSenseLayouter(
                    DetailList,
                    rowCount,
                    ActiveViewTemplate,
                    RecordListManager,
                    _serviceProvider,
                    lexSense
                    )
                {
                    ShowNormallyHiddenFields = ShowNormallyHiddenFields,
                    Deletable             = _sensesAreDeletable,
                    ShowMinorMeaningLabel = ShowMinorMeaningLabel,
                    ParentLayouter        = this
                };
                layouter.DeleteClicked += OnSenseDeleteClicked;
                rowCount += AddChildrenWidgets(layouter, lexSense, rowCount);
                ChildLayouts.Add(layouter);
            }

            //see: WS-1120 Add option to limit "add meanings" task to the ones that have a semantic domain
            //also: WS-639 ([email protected]) In Add meanings, don't show extra meaning slots just because a sense was created for the semantic domain
            var ghostingRule = ActiveViewTemplate.GetGhostingRuleForField(LexEntry.WellKnownProperties.Sense);

            if (rowCountBeforeSenses == rowCount || ghostingRule.ShowGhost)
            {
                AddSenseGhost(entry, rowCount);
                rowCount++;
            }

            DetailList.ResumeLayout(false);
            return(rowCount);
        }
Exemplo n.º 2
0
        protected int AddCustomFields(PalasoDataObject target, int insertAtRow)
        {
            int rowCount = 0;

            foreach (Field customField in ActiveViewTemplate.GetCustomFields(target.GetType().Name))
            {
#if GlossMeaning
#else
                if (customField.FieldName == LexSense.WellKnownProperties.Definition)
                {
                    continue;                     //already put this in next to "Meaning"
                }
#endif
                rowCount = AddOneCustomField(target,
                                             customField,
                                             insertAtRow + rowCount /*changed feb 2008*/,
                                             rowCount);
            }

            //grab any basetype class (to just one level). E.g., 'Note'
            foreach (Field customField in
                     ActiveViewTemplate.GetCustomFields(target.GetType().BaseType.Name))
            {
                if (target is LexExampleSentence &&
                    customField.FieldName == PalasoDataObject.WellKnownProperties.Note)
                {
                    continue;                     //note actually isn't allowed at the moment
                }
                rowCount = AddOneCustomField(target,
                                             customField,
                                             insertAtRow + rowCount /*changed feb 2008*/,
                                             rowCount);
            }
            return(rowCount);
        }
Exemplo n.º 3
0
        internal override int AddWidgets(PalasoDataObject wsdo, int insertAtRow)
        {
            LexExampleSentence example = (LexExampleSentence)wsdo;

            FirstRow = insertAtRow;

            DetailList.SuspendLayout();
            int rowCount = 0;

            try
            {
                Field field =
                    ActiveViewTemplate.GetField(Field.FieldNames.ExampleSentence.ToString());
                if (field != null && field.GetDoShow(example.Sentence, ShowNormallyHiddenFields))
                {
                    Control control = MakeBoundControl(example.Sentence, field);
                    DetailList.AddWidgetRow(
                        StringCatalog.Get("~Example",
                                          "This is the field containing an example sentence of a sense of a word."),
                        false,
                        control,
                        insertAtRow,
                        false);
                    ++rowCount;
                    insertAtRow = DetailList.GetRow(control);
                }

                field = ActiveViewTemplate.GetField(Field.FieldNames.ExampleTranslation.ToString());
                if (field != null && field.GetDoShow(example.Translation, ShowNormallyHiddenFields))
                {
                    Control entry = MakeBoundControl(example.Translation, field);
                    DetailList.AddWidgetRow(
                        StringCatalog.Get("~Translation",
                                          "This is the field for putting in a translation of an example sentence."),
                        false,
                        entry,
                        insertAtRow + rowCount,
                        false);
                    ++rowCount;
                }

                rowCount += AddCustomFields(example, insertAtRow + rowCount);
            }
            catch (ConfigurationException e)
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
            }

            DetailList.ResumeLayout(false);
            LastRow = insertAtRow + rowCount - 1;               // want index of last row owned, not a limit value
            return(rowCount);
        }
Exemplo n.º 4
0
        protected int MakeGhostWidget <T>(PalasoDataObject parent,
                                          IList <T> list,
                                          string fieldName,
                                          string label,
                                          string propertyName,
                                          bool isHeading,
                                          int row) where T : PalasoDataObject, new()
        {
            Field field = ActiveViewTemplate.GetField(fieldName);

            if (field != null && field.Enabled &&
                field.Visibility == CommonEnumerations.VisibilitySetting.Visible)
            {
                DetailList.SuspendLayout();
                MultiTextControl m = new MultiTextControl(field.WritingSystemIds,
                                                          new MultiText(),
                                                          fieldName + "_ghost",
                                                          false,
                                                          BasilProject.Project.WritingSystems,
                                                          field.Visibility,
                                                          field.IsSpellCheckingEnabled, false, _serviceProvider);
                if (_columnWidths != null && _columnWidths.Length == 3)
                {
                    m.Width = _columnWidths[1];
                }

                Control refWidget = DetailList.AddWidgetRow(label,
                                                            isHeading,
                                                            m,
                                                            row,
                                                            true);

                foreach (IControlThatKnowsWritingSystem box in m.TextBoxes)
                {
                    var tb = box as IWeSayTextBox;
                    if (tb != null)
                    {
                        GhostBinding <T> g = MakeGhostBinding(parent, list, propertyName, box.WritingSystem, tb);
                        g.ReferenceControl = refWidget;
                    }
                }
                DetailList.ResumeLayout(false);
                return(1);
            }
            else
            {
                return(0);                //didn't add a row
            }
        }
Exemplo n.º 5
0
        internal void OnSenseDeleteClicked(object sender, EventArgs e)
        {
            var            sendingLayouter          = (Layouter)sender;
            var            sense                    = (LexSense)sendingLayouter.PdoToLayout;
            IConfirmDelete confirmation             = _confirmDeleteFactory();
            var            deletionStringToLocalize = StringCatalog.Get("This will permanently remove the meaning");

            confirmation.Message = String.Format("{0} {1}.", deletionStringToLocalize,
                                                 sense.Definition.GetBestAlternative(ActiveViewTemplate.GetDefaultWritingSystemForField(LexSense.WellKnownProperties.Definition).Id));
            if (!confirmation.DeleteConfirmed)
            {
                return;
            }
            DetailList.SuspendLayout();
            Entry.Senses.Remove(sense);
            DetailList.Clear();
            //for now just relayout the whole thing as the meaning numbers will change etc.
            AddWidgets();
            DetailList.ResumeLayout();
            // For Linux/Mono, merely resuming layout doesn't work -- the display doesn't redraw properly.
            ForceLayoutAndRefresh();
        }
Exemplo n.º 6
0
        internal override int AddWidgets(PalasoDataObject wsdo, int insertAtRow)
        {
            LexSense sense = (LexSense)wsdo;

            FirstRow = insertAtRow;
            int rowCount = 0;

            DetailList.SuspendLayout();
            try
            {
#if GlossMeaning
                Field field = ActiveViewTemplate.GetField(Field.FieldNames.SenseGloss.ToString());
                if (field != null && field.GetDoShow(sense.Gloss, this.ShowNormallyHiddenFields))
                {
                    Control meaningControl = MakeBoundControl(sense.Gloss, field);
#else
                Field field = ActiveViewTemplate.GetField(LexSense.WellKnownProperties.Definition);
                if (field != null && field.GetDoShow(sense.Definition, ShowNormallyHiddenFields))
                {
                    Control meaningControl = MakeBoundControl(sense.Definition, field);
#endif
                    //NB: http://jira.palaso.org/issues/browse/WS-33937 describes how this makes it hard to change this in English (but not other languages)
                    string   label = StringCatalog.Get("~Meaning");
                    LexEntry entry = sense.Parent as LexEntry;
                    if (entry != null)                     // && entry.Senses.Count > 1)
                    {
                        label += " " + (entry.Senses.IndexOf(sense) + 1);
                    }
                    DetailList.AddWidgetRow(label, true, meaningControl, insertAtRow, false);
                    rowCount++;
                }

                rowCount += AddCustomFields(sense, insertAtRow + rowCount);

                foreach (var lexExampleSentence in sense.ExampleSentences)
                {
                    var exampleLayouter =
                        new LexExampleSentenceLayouter(DetailList, rowCount, ActiveViewTemplate, _serviceProvider, lexExampleSentence)
                    {
                        ShowNormallyHiddenFields = ShowNormallyHiddenFields,
                        Deletable      = false,
                        ParentLayouter = this
                    };
                    rowCount += AddChildrenWidgets(exampleLayouter, lexExampleSentence, insertAtRow + rowCount);
                    ChildLayouts.Add(exampleLayouter);
                }


                //add a ghost for another example if we don't have one or we're in the "show all" mode
                //removed because of its effect on the Add Examples task, where
                //we'd like to be able to add more than one
                //if (ShowNormallyHiddenFields || sense.ExampleSentences.Count == 0)
                {
                    AddExampleSentenceGhost(sense, insertAtRow + rowCount);
                    rowCount++;
                }
                LastRow = insertAtRow + rowCount - 1;                   // want index of last row owned, not a limit
                FixDeleteButtonPosition();
            }
            catch (ConfigurationException e)
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
            }
            DetailList.ResumeLayout(false);
            return(rowCount);
        }