~haakan/do-plugins/sshfix

« back to all changes in this revision

Viewing changes to Launchpad/src/LaunchpadAction.cs

  • Committer: David Siegel
  • Date: 2008-12-23 21:35:54 UTC
  • Revision ID: david@david-desktop-20081223213554-f26d06t4ujmtjwja
Launchpad plugin needs a rewrite; dropped from the build (not updated).

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        /// </summary>
34
34
        class LaunchpadAction : Act
35
35
        {
 
36
 
 
37
                static readonly IEnumerable<LaunchpadItem> LaunchpadItems = new LaunchpadItem [] {
 
38
                        new LaunchpadAnswerSearchItem(),
 
39
                        new LaunchpadProjectAnswersItem(),
 
40
                        new LaunchpadBlueprintsItem(),
 
41
                        new LaunchpadBlueprintSearchItem(),
 
42
                        new LaunchpadBlueprintsRegisterItem(),
 
43
                        new LaunchpadBugNumberItem(),
 
44
                        new LaunchpadBugReportItem(),
 
45
                        new LaunchpadPackageBugsItem(),
 
46
                        new LaunchpadBugSearchItem(),
 
47
                        new LaunchpadCodeOverviewItem(),
 
48
                        new LaunchpadRegisterItem(),
 
49
                        new LaunchpadTranslationSearchItem(),
 
50
                        new LaunchpadTranslationReleaseItem(),
 
51
                        new LaunchpadProjectPageItem(),
 
52
                        new LaunchpadUserPageItem(),
 
53
                        new LaunchpadUserSearchItem()
 
54
                };
 
55
                        
36
56
                public override string Name
37
57
                {
38
58
                        get { return Catalog.GetString ("Launchpad"); }
48
68
                        get { return "Launchpad.png@" + GetType ().Assembly.FullName; }
49
69
                }
50
70
 
51
 
                public override IEnumerable<Type> SupportedItemTypes
52
 
                {
53
 
                        get
54
 
                        {
55
 
                                return new Type[] {
56
 
                                        typeof (ITextItem)
57
 
                                };
58
 
                        }
 
71
                public override IEnumerable<Type> SupportedItemTypes {
 
72
                        get { yield return typeof (ITextItem); }
59
73
                }
60
74
 
61
 
    public override bool ModifierItemsOptional { get { return false; } }
62
 
 
63
75
                public override bool SupportsModifierItemForItems (IEnumerable<Item> items, Item modItem)
64
76
                {
65
 
                        return (modItem as LaunchpadItem).SupportsItems(items.ToArray ());
 
77
                        return (modItem as LaunchpadItem).SupportsItems (items.OfType<ITextItem> ());
66
78
                }
67
79
 
68
 
                public override IEnumerable<Type> SupportedModifierItemTypes
69
 
                {
70
 
                        get
71
 
                        {
72
 
                                return new Type[] {
73
 
                                        typeof(LaunchpadItem)
74
 
                                };
75
 
                        }
 
80
                public override IEnumerable<Type> SupportedModifierItemTypes {
 
81
                        get { yield return typeof (LaunchpadItem);}
76
82
                }
77
83
 
78
84
                public override IEnumerable<Item> DynamicModifierItemsForItem (Item item)
79
85
                {
80
 
                        return new Item[] {
81
 
                                new LaunchpadAnswerSearchItem(),
82
 
                                        new LaunchpadProjectAnswersItem(),
83
 
                                        new LaunchpadBlueprintsItem(),
84
 
                                        new LaunchpadBlueprintSearchItem(),
85
 
                                        new LaunchpadBlueprintsRegisterItem(),
86
 
                                        new LaunchpadBugNumberItem(),
87
 
                                        new LaunchpadBugReportItem(),
88
 
                                        new LaunchpadPackageBugsItem(),
89
 
                                        new LaunchpadBugSearchItem(),
90
 
                                        new LaunchpadCodeOverviewItem(),
91
 
                                        new LaunchpadRegisterItem(),
92
 
                                        new LaunchpadTranslationSearchItem(),
93
 
                                        new LaunchpadTranslationReleaseItem(),
94
 
                                        new LaunchpadProjectPageItem(),
95
 
                                        new LaunchpadUserPageItem(),
96
 
                                        new LaunchpadUserSearchItem()
97
 
                        };
 
86
                        return LaunchpadItems.OfType<Item> ();
98
87
                }
99
88
 
100
 
    public override bool SupportsItem (Item item)
101
 
    {
102
 
        return true;
103
 
    }
104
 
 
105
 
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) {
106
 
                        if (modItems.Any ()) {
107
 
                                (modItems.First () as LaunchpadItem).Perform(items.First ());
108
 
                        }
109
 
                        return null;
 
89
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
 
90
                {
 
91
                        foreach (LaunchpadItem lp in modItems)
 
92
                                lp.Perform (items.OfType<ITextItem> ());
 
93
                        
 
94
                        yield break;
110
95
                }
111
96
        }
112
97
 
118
103
        /// They are meant to behave just like Actions, but they need to be Items
119
104
        /// to be listed in the right-hand box.
120
105
        /// </summary>
121
 
        interface LaunchpadItem : Item
 
106
        public abstract class LaunchpadItem : Item
122
107
        {
123
 
                bool SupportsItems(Item[] items);
124
 
                void Perform (Item item);
 
108
                public abstract bool SupportsItems (IEnumerable<ITextItem> items);
 
109
                public abstract void Perform (IEnumerable<ITextItem> items);
125
110
        }
126
111
}