Changeset 2170


Ignore:
Timestamp:
10/28/08 19:02:38 (11 years ago)
Author:
julien-quint
Message:

Fixes #266 (Silent phrase should not get deleted when we delete unused phrase.) There is now an option to delete silence phrases or not.

But there seems to be something wrong with undo in some cases; phrases are not readded in the right order?

Location:
trunk/Obi/Obi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Obi/Obi/ProjectView/ProjectView.cs

    r2168 r2170  
    476476        /// <summary> 
    477477        /// Delete all unused nodes. 
     478        /// Ask before deleting silence phrases (unless they are in unused sections...) 
    478479        /// </summary> 
    479480        public void DeleteUnused() 
    480481        { 
    481482            CompositeCommand command = mPresentation.CreateCompositeCommand(Localizer.Message("delete_unused")); 
     483            // Collect silence node deletion commands separately in case the user wants to keep them. 
     484            List<ICommand> silence = new List<ICommand>(); 
    482485            mPresentation.RootNode.acceptDepthFirst( 
    483486                delegate(urakawa.core.TreeNode node) 
     
    485488                    if (node is ObiNode && !((ObiNode)node).Used) 
    486489                    { 
    487                         command.append(new Commands.Node.Delete(this, (ObiNode)node)); 
     490                        Commands.Node.Delete delete = new Commands.Node.Delete(this, (ObiNode)node, false); 
     491                        if (node is PhraseNode && ((PhraseNode)node).Role_ == EmptyNode.Role.Silence) 
     492                        { 
     493                            silence.Add(delete); 
     494                        } 
     495                        else 
     496                        { 
     497                            command.insert(delete, 0); 
     498                        } 
    488499                        return false; 
    489500                    } 
     
    491502                }, delegate(urakawa.core.TreeNode node) { } 
    492503            ); 
     504            if (silence.Count > 0) 
     505            { 
     506                if (MessageBox.Show(Localizer.Message("delete_silence_phrases"), 
     507                    Localizer.Message("delete_silence_phrases_caption"), MessageBoxButtons.YesNo, 
     508                    MessageBoxIcon.Question) == DialogResult.Yes) 
     509                { 
     510                    foreach (ICommand c in silence) command.append(c); 
     511                } 
     512            } 
    493513            if (command.getCount() > 0) mPresentation.getUndoRedoManager().execute(command); 
    494514        } 
  • trunk/Obi/Obi/messages.Designer.cs

    r2163 r2170  
    812812         
    813813        /// <summary> 
     814        ///   Looks up a localized string similar to Your project has silence phrases. Do you want to delete them as well as the other unused phrases and sections?. 
     815        /// </summary> 
     816        internal static string delete_silence_phrases { 
     817            get { 
     818                return ResourceManager.GetString("delete_silence_phrases", resourceCulture); 
     819            } 
     820        } 
     821         
     822        /// <summary> 
     823        ///   Looks up a localized string similar to Delete silence phrases?. 
     824        /// </summary> 
     825        internal static string delete_silence_phrases_caption { 
     826            get { 
     827                return ResourceManager.GetString("delete_silence_phrases_caption", resourceCulture); 
     828            } 
     829        } 
     830         
     831        /// <summary> 
    814832        ///   Looks up a localized string similar to delete unused data. 
    815833        /// </summary> 
  • trunk/Obi/Obi/messages.resx

    r2163 r2170  
    12951295    <comment>Progress dialog title</comment> 
    12961296  </data> 
     1297  <data name="delete_silence_phrases" xml:space="preserve"> 
     1298    <value>Your project has silence phrases. Do you want to delete them as well as the other unused phrases and sections?</value> 
     1299  </data> 
     1300  <data name="delete_silence_phrases_caption" xml:space="preserve"> 
     1301    <value>Delete silence phrases?</value> 
     1302  </data> 
    12971303</root> 
Note: See TracChangeset for help on using the changeset viewer.