~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormattingProfileDialog.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
        {
38
38
                Mono.TextEditor.TextEditor texteditor = new Mono.TextEditor.TextEditor ();
39
39
                CSharpFormattingPolicy profile;
40
 
                Gtk.TreeStore indentOptions, bacePositionOptions, newLineOptions, whiteSpaceOptions;
 
40
                Gtk.TreeStore indentOptions, bacePositionOptions, newLineOptions, whiteSpaceOptions, wrappingOptions;
41
41
                
42
42
                static Dictionary<Wrapping, string> arrayInitializerTranslationDictionary = new Dictionary<Wrapping, string> ();
43
43
                static Dictionary<BraceStyle, string> braceStyleTranslationDictionary = new Dictionary<BraceStyle, string> ();
44
 
                static Dictionary<BraceForcement, string> braceForcementTranslationDictionary = new Dictionary<BraceForcement, string> ();
 
44
                //static Dictionary<BraceForcement, string> braceForcementTranslationDictionary = new Dictionary<BraceForcement, string> ();
45
45
                static Dictionary<PropertyFormatting, string> propertyFormattingTranslationDictionary = new Dictionary<PropertyFormatting, string> ();
46
46
                static Dictionary<NewLinePlacement, string>  newLinePlacementTranslationDictionary = new Dictionary<NewLinePlacement, string> ();
47
47
                
55
55
                        braceStyleTranslationDictionary [BraceStyle.NextLineShifted2] = GettextCatalog.GetString ("Next line shifted2");
56
56
                        braceStyleTranslationDictionary [BraceStyle.BannerStyle] = GettextCatalog.GetString ("Banner style");
57
57
                        
58
 
                        braceForcementTranslationDictionary [BraceForcement.DoNotChange] = GettextCatalog.GetString ("Do not change");
59
 
                        braceForcementTranslationDictionary [BraceForcement.AddBraces] = GettextCatalog.GetString ("Add braces");
60
 
                        braceForcementTranslationDictionary [BraceForcement.RemoveBraces] = GettextCatalog.GetString ("Remove braces");
61
 
                        
62
58
                        propertyFormattingTranslationDictionary [PropertyFormatting.AllowOneLine] = GettextCatalog.GetString ("Allow one line");
63
59
                        propertyFormattingTranslationDictionary [PropertyFormatting.ForceOneLine] = GettextCatalog.GetString ("Force one line");
64
60
                        propertyFormattingTranslationDictionary [PropertyFormatting.ForceNewLine] = GettextCatalog.GetString ("Force new line");
77
73
                {
78
74
                        if (value is BraceStyle)
79
75
                                return braceStyleTranslationDictionary [(BraceStyle)value];
80
 
                        if (value is BraceForcement) 
81
 
                                return braceForcementTranslationDictionary [(BraceForcement)value];
 
76
//                      if (value is BraceForcement) 
 
77
//                              return braceForcementTranslationDictionary [(BraceForcement)value];
82
78
                        if (value is PropertyFormatting)
83
79
                                return propertyFormattingTranslationDictionary [(PropertyFormatting)value];
84
80
                        if (value is Wrapping)
92
88
                {
93
89
                        if (propertyType == typeof(BraceStyle))
94
90
                                return braceStyleTranslationDictionary.First (p => p.Value == newText).Key;
95
 
                        if (propertyType == typeof(BraceForcement)) 
96
 
                                return braceForcementTranslationDictionary.First (p => p.Value == newText).Key;
 
91
//                      if (propertyType == typeof(BraceForcement)) 
 
92
//                              return braceForcementTranslationDictionary.First (p => p.Value == newText).Key;
97
93
                        if (propertyType == typeof(PropertyFormatting)) 
98
94
                                return propertyFormattingTranslationDictionary.First (p => p.Value == newText).Key;
99
95
                        if (propertyType == typeof(Wrapping))
219
215
                        }
220
216
                }
221
217
        }";
222
 
                
 
218
                const string longMethodCall = @"class ClassDeclaration { 
 
219
                public void Test (int test)
 
220
                {
 
221
                        LongMethodCallInSameLine (""Hello"", 1, test);
 
222
                        LongMethodCallInMultiple (
 
223
""Hello"", 
 
224
                1, 
 
225
                test);
 
226
 
 
227
                LongMethodCallInMultipleCase2 (""Hello"", 
 
228
                                               1, 
 
229
                                               test);
 
230
        }
 
231
}";
 
232
                const string longMethodDeclaration = @"class ClassDeclaration { 
 
233
        public void LongMethodCallInSameLine (int test, string foo, double bar)
 
234
        {
 
235
        }
 
236
        public void LongMethodCallInMultiple (
 
237
int test,
 
238
string foo,
 
239
double bar)
 
240
        {
 
241
        }
 
242
        public void LongMethodCallInMultipleCase2 (int test,
 
243
string foo,
 
244
double bar)
 
245
        {
 
246
        }
 
247
}";
 
248
                const string longIndexerDeclaration = @"class ClassDeclaration { 
 
249
        public int this [int test, string foo, double bar]
 
250
        {
 
251
                get {}
 
252
        }
 
253
        public int this [
 
254
int test,
 
255
string foo,
 
256
double bar]
 
257
        {
 
258
                get {}
 
259
        }
 
260
        public int this [int test,
 
261
string foo,
 
262
double bar]
 
263
        {
 
264
                get {}
 
265
        }
 
266
}";
 
267
                const string longIndexer = @"class ClassDeclaration { 
 
268
                public void Test (int test)
 
269
                {
 
270
                        this [""Hello"", 1, test] = 0;
 
271
                        this [
 
272
""Hello"", 
 
273
                1, 
 
274
                test] = 0;
 
275
 
 
276
                this [""Hello"", 
 
277
                                               1, 
 
278
                                               test] = 0;
 
279
        }
 
280
}";
223
281
                const string simpleWhile = @"class ClassDeclaration { 
224
282
                public void Test ()
225
283
                {
390
448
                        comboboxCategories.AppendText (GettextCatalog.GetString ("Indentation"));
391
449
                        comboboxCategories.AppendText (GettextCatalog.GetString ("Braces"));
392
450
                        comboboxCategories.AppendText (GettextCatalog.GetString ("Blank lines"));
 
451
                        comboboxCategories.AppendText (GettextCatalog.GetString ("Wrapping"));
393
452
                        comboboxCategories.AppendText (GettextCatalog.GetString ("White Space"));
394
453
                        comboboxCategories.AppendText (GettextCatalog.GetString ("New Lines"));
395
454
                        comboboxCategories.Changed += delegate(object sender, EventArgs e) {
404
463
                        texteditor.Options.ShowFoldMargin = false;
405
464
                        texteditor.Options.ShowIconMargin = false;
406
465
                        texteditor.Options.ShowLineNumberMargin = false;
407
 
                        texteditor.Options.ShowInvalidLines = false;
408
466
                        texteditor.Document.ReadOnly = true;
409
467
                        texteditor.Document.MimeType = CSharpFormatter.MimeType;
410
468
                        scrolledwindow.Child = texteditor;
547
605
                        AddOption (bacePositionOptions, category, "EventRemoveBraceStyle", GettextCatalog.GetString ("Remove declaration"), eventExample);
548
606
                        AddOption (bacePositionOptions, category, "AllowEventRemoveBlockInline", GettextCatalog.GetString ("Allow one line remove"), eventExample);
549
607
                        
550
 
                        category = AddOption (bacePositionOptions, null, GettextCatalog.GetString ("Brace forcement"), null);
551
 
                        AddOption (bacePositionOptions, category, "IfElseBraceForcement", GettextCatalog.GetString ("'if...else' statement"), @"class ClassDeclaration { 
552
 
        public void Test ()
553
 
                {
554
 
                        if (true) {
555
 
                                Console.WriteLine (""Hello World!"");
556
 
                        }
557
 
                        if (true)
558
 
                                Console.WriteLine (""Hello World!"");
559
 
                }
560
 
        }");
561
 
                        AddOption (bacePositionOptions, category, "ForBraceForcement", GettextCatalog.GetString ("'for' statement"), @"class ClassDeclaration { 
562
 
                public void Test ()
563
 
                {
564
 
                        for (int i = 0; i < 10; i++) {
565
 
                                Console.WriteLine (""Hello World "" + i);
566
 
                        }
567
 
                        for (int i = 0; i < 10; i++)
568
 
                                Console.WriteLine (""Hello World "" + i);
569
 
                }
570
 
        }");
571
 
                        AddOption (bacePositionOptions, category, "WhileBraceForcement", GettextCatalog.GetString ("'while' statement"), @"class ClassDeclaration { 
572
 
                public void Test ()
573
 
                {
574
 
                        int i = 0;
575
 
                        while (i++ < 10) {
576
 
                                Console.WriteLine (""Hello World "" + i);
577
 
                        }
578
 
                        while (i++ < 20)
579
 
                                Console.WriteLine (""Hello World "" + i);
580
 
                }
581
 
        }");
582
 
                        AddOption (bacePositionOptions, category, "UsingBraceForcement", GettextCatalog.GetString ("'using' statement"), simpleUsingStatement);
583
 
                        AddOption (bacePositionOptions, category, "FixedBraceForcement", GettextCatalog.GetString ("'fixed' statement"), simpleFixedStatement);
584
608
                        treeviewBracePositions.ExpandAll ();
585
609
                        #endregion
586
610
                        
587
611
                        #region New line options
588
612
                        newLineOptions = new Gtk.TreeStore (typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));
589
 
                        
 
613
 
590
614
                        column = new TreeViewColumn ();
591
615
                        // pixbuf column
592
616
                        column.PackStart (pixbufCellRenderer, false);
593
617
                        column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
594
 
                        
 
618
 
595
619
                        // text column
596
620
                        cellRendererText.Ypad = 1;
597
621
                        column.PackStart (cellRendererText, true);
598
622
                        column.SetAttributes (cellRendererText, "text", 1);
599
 
                        
 
623
 
600
624
                        treeviewNewLines.Model = newLineOptions;
601
625
                        treeviewNewLines.HeadersVisible = false;
602
626
                        treeviewNewLines.Selection.Changed += TreeSelectionChanged;
603
627
                        treeviewNewLines.AppendColumn (column);
604
 
                        
 
628
 
605
629
                        column = new TreeViewColumn ();
606
630
                        cellRendererCombo = new CellRendererCombo ();
607
631
                        cellRendererCombo.Ypad = 1;
615
639
                        column.PackStart (cellRendererCombo, false);
616
640
                        column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
617
641
                        column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
618
 
                        
 
642
 
619
643
                        cellRendererToggle = new CellRendererToggle ();
620
644
                        cellRendererToggle.Activatable = !profile.IsBuiltIn;
621
645
                        cellRendererToggle.Ypad = 1;
623
647
                        column.PackStart (cellRendererToggle, false);
624
648
                        column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
625
649
                        column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
626
 
                        
 
650
 
627
651
                        treeviewNewLines.AppendColumn (column);
628
 
                        
 
652
 
629
653
                        AddOption (newLineOptions, "ElseNewLinePlacement", GettextCatalog.GetString ("Place 'else' on new line"), simpleIf);
630
654
                        AddOption (newLineOptions, "ElseIfNewLinePlacement", GettextCatalog.GetString ("Place 'else if' on new line"), simpleIf);
631
655
                        AddOption (newLineOptions, "CatchNewLinePlacement", GettextCatalog.GetString ("Place 'catch' on new line"), simpleCatch);
635
659
                        treeviewNewLines.ExpandAll ();
636
660
                        #endregion
637
661
                        
 
662
                        #region Wrapping options
 
663
                        wrappingOptions = new Gtk.TreeStore (typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));
 
664
 
 
665
                        column = new TreeViewColumn ();
 
666
                        // pixbuf column
 
667
                        column.PackStart (pixbufCellRenderer, false);
 
668
                        column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
 
669
 
 
670
                        // text column
 
671
                        cellRendererText.Ypad = 1;
 
672
                        column.PackStart (cellRendererText, true);
 
673
                        column.SetAttributes (cellRendererText, "text", 1);
 
674
 
 
675
 
 
676
                        treeviewWrappingCategory.Model = wrappingOptions;
 
677
                        treeviewWrappingCategory.HeadersVisible = false;
 
678
                        treeviewWrappingCategory.Selection.Changed += TreeSelectionChanged;
 
679
                        treeviewWrappingCategory.AppendColumn (column);
 
680
 
 
681
                        column = new TreeViewColumn ();
 
682
                        cellRendererCombo = new CellRendererCombo ();
 
683
                        cellRendererCombo.Ypad = 1;
 
684
                        cellRendererCombo.Mode = CellRendererMode.Editable;
 
685
                        cellRendererCombo.TextColumn = 1;
 
686
                        cellRendererCombo.Model = comboBoxStore;
 
687
                        cellRendererCombo.HasEntry = false;
 
688
                        cellRendererCombo.Editable = !profile.IsBuiltIn;
 
689
                        cellRendererCombo.Edited += new ComboboxEditedHandler (this, wrappingOptions).ComboboxEdited;
 
690
 
 
691
                        column.PackStart (cellRendererCombo, false);
 
692
                        column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
 
693
                        column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
 
694
 
 
695
                        cellRendererToggle = new CellRendererToggle ();
 
696
                        cellRendererToggle.Activatable = !profile.IsBuiltIn;
 
697
                        cellRendererToggle.Ypad = 1;
 
698
                        cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewNewLines, wrappingOptions).Toggled;
 
699
                        column.PackStart (cellRendererToggle, false);
 
700
                        column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
 
701
                        column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
 
702
 
 
703
                        treeviewWrappingCategory.AppendColumn (column);
 
704
 
 
705
                        category = AddOption (wrappingOptions, null, GettextCatalog.GetString ("Method declarations"), null);
 
706
                        AddOption (wrappingOptions, category, "MethodDeclarationParameterWrapping", GettextCatalog.GetString ("Parameters"), longMethodDeclaration);
 
707
                        AddOption (wrappingOptions, category, "NewLineAferMethodDeclarationOpenParentheses", GettextCatalog.GetString ("New line after open parentheses"), longMethodDeclaration);
 
708
                        AddOption (wrappingOptions, category, "MethodDeclarationClosingParenthesesOnNewLine", GettextCatalog.GetString ("New line before closing parentheses"), longMethodDeclaration);
 
709
                        AddOption (wrappingOptions, category, "AlignToFirstMethodDeclarationParameter", GettextCatalog.GetString ("Align to first parameter"), longMethodDeclaration);
 
710
 
 
711
                        category = AddOption (wrappingOptions, null, GettextCatalog.GetString ("Method calls"), null);
 
712
                        AddOption (wrappingOptions, category, "MethodCallArgumentWrapping", GettextCatalog.GetString ("Arguments"), longMethodCall);
 
713
                        AddOption (wrappingOptions, category, "NewLineAferMethodCallOpenParentheses", GettextCatalog.GetString ("New line after open parentheses"), longMethodCall);
 
714
                        AddOption (wrappingOptions, category, "MethodCallClosingParenthesesOnNewLine", GettextCatalog.GetString ("New line before closing parentheses"), longMethodCall);
 
715
                        AddOption (wrappingOptions, category, "AlignToFirstMethodCallArgument", GettextCatalog.GetString ("Align to first argument"), longMethodCall);
 
716
 
 
717
                        category = AddOption (wrappingOptions, null, GettextCatalog.GetString ("Indexer declarations"), null);
 
718
                        AddOption (wrappingOptions, category, "IndexerDeclarationParameterWrapping", GettextCatalog.GetString ("Parameters"), longIndexerDeclaration);
 
719
                        AddOption (wrappingOptions, category, "NewLineAferIndexerDeclarationOpenBracket", GettextCatalog.GetString ("New line after open parentheses"), longIndexerDeclaration);
 
720
                        AddOption (wrappingOptions, category, "IndexerDeclarationClosingBracketOnNewLine", GettextCatalog.GetString ("New line before closing parentheses"), longIndexerDeclaration);
 
721
                        AddOption (wrappingOptions, category, "AlignToFirstIndexerDeclarationParameter", GettextCatalog.GetString ("Align to first parameter"), longIndexerDeclaration);
 
722
 
 
723
                        category = AddOption (wrappingOptions, null, GettextCatalog.GetString ("Indexer usage"), null);
 
724
                        AddOption (wrappingOptions, category, "IndexerArgumentWrapping", GettextCatalog.GetString ("Arguments"), longIndexer);
 
725
                        AddOption (wrappingOptions, category, "NewLineAferIndexerOpenBracket", GettextCatalog.GetString ("New line after open bracket"), longIndexer);
 
726
                        AddOption (wrappingOptions, category, "IndexerClosingBracketOnNewLine", GettextCatalog.GetString ("New line before closing bracket"), longIndexer);
 
727
                        AddOption (wrappingOptions, category, "AlignToFirstIndexerArgument", GettextCatalog.GetString ("Align to first parameter"), longIndexer);
 
728
 
 
729
                        treeviewWrappingCategory.ExpandAll ();
 
730
                        #endregion
 
731
 
638
732
                        #region White space options
639
733
                        whiteSpaceOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool));
640
734