Esempio n. 1
0
 protected override void InitializeContext(ExtensionContext extensionContext)
 {
     base.InitializeContext(extensionContext);
     extensionContext.RegisterCondition("ItemType", new ItemTypeCondition(DataObject.GetType()));
     extensionContext.RegisterCondition("ActiveLanguage", new ProjectLanguageCondition(DataObject));
     if (DataObject is Project)
     {
         extensionContext.RegisterCondition("SupportsTarget", new SupportsTargetCondition((Project)DataObject));
     }
 }
Esempio n. 2
0
        internal ProjectServiceExtension GetExtensionChain(IBuildTarget target)
        {
            ProjectServiceExtension chain;

            if (target != null)
            {
                lock (target) {
                    ExtensionChainInfo einfo = (ExtensionChainInfo)target.ExtendedProperties [typeof(ExtensionChainInfo)];
                    if (einfo == null)
                    {
                        einfo = new ExtensionChainInfo();
                        ExtensionContext ctx = AddinManager.CreateExtensionContext();
                        einfo.ExtensionContext         = ctx;
                        einfo.ItemTypeCondition        = new ItemTypeCondition(target.GetType());
                        einfo.ProjectLanguageCondition = new ProjectLanguageCondition(target);
                        ctx.RegisterCondition("ItemType", einfo.ItemTypeCondition);
                        ctx.RegisterCondition("ProjectLanguage", einfo.ProjectLanguageCondition);
                        target.ExtendedProperties [typeof(ExtensionChainInfo)] = einfo;
                    }
                    else
                    {
                        einfo.ItemTypeCondition.ObjType = target.GetType();
                        einfo.ProjectLanguageCondition.TargetProject = target;
                    }
                    ProjectServiceExtension[] extensions = einfo.ExtensionContext.GetExtensionObjects <ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions");
                    chain = CreateExtensionChain(extensions);

                    // After creating the chain there is no need to keep the reference to the target
                    einfo.ProjectLanguageCondition.TargetProject = null;
                }
            }
            else
            {
                if (defaultExtensionChain == null)
                {
                    ExtensionContext ctx = AddinManager.CreateExtensionContext();
                    ctx.RegisterCondition("ItemType", new ItemTypeCondition(typeof(UnknownItem)));
                    ctx.RegisterCondition("ProjectLanguage", new ProjectLanguageCondition(UnknownItem.Instance));
                    ProjectServiceExtension[] extensions = ctx.GetExtensionObjects <ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions");
                    defaultExtensionChain = CreateExtensionChain(extensions);
                }
                chain  = defaultExtensionChain;
                target = UnknownItem.Instance;
            }

            if (chain.SupportsItem(target))
            {
                return(chain);
            }
            else
            {
                return(chain.GetNext(target));
            }
        }
Esempio n. 3
0
        public ProjectServiceExtension GetExtensionChain(IBuildTarget target)
        {
            ProjectServiceExtension chain;

            if (target != null)
            {
                ExtensionChainInfo einfo = (ExtensionChainInfo)Thread.GetData(extensionChainSlot);
                if (einfo == null)
                {
                    einfo = new ExtensionChainInfo();
                    ExtensionContext ctx = AddinManager.CreateExtensionContext();
                    einfo.ExtensionContext         = ctx;
                    einfo.ItemTypeCondition        = new ItemTypeCondition(target.GetType());
                    einfo.ProjectLanguageCondition = new ProjectLanguageCondition(target);
                    ctx.RegisterCondition("ItemType", einfo.ItemTypeCondition);
                    ctx.RegisterCondition("ProjectLanguage", einfo.ProjectLanguageCondition);
                    Thread.SetData(extensionChainSlot, einfo);
                }
                else
                {
                    einfo.ItemTypeCondition.ObjType = target.GetType();
                    einfo.ProjectLanguageCondition.TargetProject = target;
                }
                ProjectServiceExtension[] extensions = (ProjectServiceExtension[])einfo.ExtensionContext.GetExtensionObjects("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension));
                chain = CreateExtensionChain(extensions);
            }
            else
            {
                if (defaultExtensionChain == null)
                {
                    ExtensionContext ctx = AddinManager.CreateExtensionContext();
                    ctx.RegisterCondition("ItemType", new ItemTypeCondition(typeof(UnknownItem)));
                    ctx.RegisterCondition("ProjectLanguage", new ProjectLanguageCondition(UnknownItem.Instance));
                    ProjectServiceExtension[] extensions = (ProjectServiceExtension[])ctx.GetExtensionObjects("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension));
                    defaultExtensionChain = CreateExtensionChain(extensions);
                }
                chain  = defaultExtensionChain;
                target = UnknownItem.Instance;
            }

            if (chain.SupportsItem(target))
            {
                return(chain);
            }
            else
            {
                return(chain.GetNext(target));
            }
        }
Esempio n. 4
0
        public SdiWorkspaceWindow(DefaultWorkbench workbench, ViewContent content, DockNotebook tabControl, DockNotebookTab tabLabel) : base()
        {
            this.workbench  = workbench;
            this.tabControl = tabControl;
            this.content    = content;
            this.tab        = tabLabel;
            this.tabPage    = content.Control;

            fileTypeCondition.SetFileName(content.ContentName ?? content.UntitledName);
            extensionContext = AddinManager.CreateExtensionContext();
            extensionContext.RegisterCondition("FileType", fileTypeCondition);

            box = new VBox();

            viewContents.Add(content);

            //this fires an event that the content uses to access this object's ExtensionContext
            content.WorkbenchWindow = this;

            // The previous WorkbenchWindow property assignement may end with a call to AttachViewContent,
            // which will add the content control to the subview notebook. In that case, we don't need to add it to box
            if (subViewNotebook == null)
            {
                box.PackStart(content.Control);
            }

            content.ContentNameChanged += new EventHandler(SetTitleEvent);
            content.DirtyChanged       += HandleDirtyChanged;
            box.Show();
            Add(box);

            SetTitleEvent(null, null);
        }
Esempio n. 5
0
        public SdiWorkspaceWindow(DefaultWorkbench workbench, IViewContent content, Notebook tabControl, TabLabel tabLabel) : base()
        {
            this.workbench  = workbench;
            this.tabControl = tabControl;
            this.content    = content;
            this.tabLabel   = tabLabel;
            this.tabPage    = content.Control;

            ShadowType = ShadowType.None;
            box        = new VBox();
            Add(box);
            box.PackStart(content.Control);

            fileTypeCondition.SetFileName(content.ContentName ?? content.UntitledName);
            extensionContext = AddinManager.CreateExtensionContext();
            extensionContext.RegisterCondition("FileType", fileTypeCondition);

            content.WorkbenchWindow = this;

            content.ContentNameChanged += new EventHandler(SetTitleEvent);
            content.DirtyChanged       += new EventHandler(SetTitleEvent);
            content.BeforeSave         += new EventHandler(BeforeSave);
            content.ContentChanged     += new EventHandler(OnContentChanged);

            box.Show();

            SetTitleEvent(null, null);

            commandHandler = new ViewCommandHandlers(this);
            Show();
        }
Esempio n. 6
0
        public override void Setup()
        {
            base.Setup();

            pinfo       = new ParameterInfoCondition();
            pinfo.Value = "res";
            GlobalInfoCondition.Value = "res";

            ctx = AddinManager.CreateExtensionContext();
            ctx.RegisterCondition("InputParameter", pinfo);
        }
Esempio n. 7
0
 protected override void InitializeContext(ExtensionContext extensionContext)
 {
     base.InitializeContext(extensionContext);
     extensionContext.RegisterCondition("ItemType", new ItemTypeCondition(DataObject.GetType()));
     extensionContext.RegisterCondition("ActiveLanguage", new ProjectLanguageCondition(DataObject));
     if (DataObject is Project)
     {
         extensionContext.RegisterCondition("AppliesTo", new AppliesToCondition((Project)DataObject));
         extensionContext.RegisterCondition("FlavorType", new FlavorTypeCondition((Project)DataObject));
         extensionContext.RegisterCondition("ProjectTypeId", new ProjectTypeIdCondition((Project)DataObject));
         extensionContext.RegisterCondition("SupportsTarget", new SupportsTargetCondition((Project)DataObject));
     }
     else
     {
         extensionContext.RegisterCondition("AppliesTo", FalseCondition.Instance);
         extensionContext.RegisterCondition("FlavorType", FalseCondition.Instance);
         extensionContext.RegisterCondition("ProjectTypeId", FalseCondition.Instance);
     }
 }
Esempio n. 8
0
        internal void EnsureInitialized()
        {
            if (!initializeCalled)
            {
                initializeCalled = true;

                extensionContext = AddinManager.CreateExtensionContext();
                extensionContext.RegisterCondition("ItemType", new ItemTypeCondition(GetType()));

                OnInitialize();
                InitializeExtensionChain();
                OnExtensionChainInitialized();
            }
        }
        internal TextEditor(ITextEditorImpl textEditorImpl, TextEditorType textEditorType)
        {
            if (textEditorImpl == null)
            {
                throw new ArgumentNullException(nameof(textEditorImpl));
            }
            this.textEditorImpl = textEditorImpl;
            this.TextEditorType = textEditorType;
            commandRouter       = new InternalCommandRouter(this);
            fileTypeCondition.SetFileName(FileName);
            ExtensionContext = AddinManager.CreateExtensionContext();
            ExtensionContext.RegisterCondition("FileType", fileTypeCondition);

            FileNameChanged += TextEditor_FileNameChanged;
            MimeTypeChanged += TextEditor_MimeTypeChanged;
        }
Esempio n. 10
0
        public WriterManager(string[] flags)
        {
            // Create a new extension context
            ctx = AddinManager.CreateExtensionContext();

            // Register the flags condition in the new context
            FlagsCondition condition = new FlagsCondition(flags);

            ctx.RegisterCondition("HasFlag", condition);

            ctx.AddExtensionNodeHandler("/WriterService/Writers", delegate {
                if (Changed != null)
                {
                    Changed(this, EventArgs.Empty);
                }
            });
        }
Esempio n. 11
0
        public void TestExtensionContextEvents()
        {
            AddinManager.Registry.EnableAddin("SimpleApp.SystemInfoExtension,0.1.0");

            counters [0] = new Counter();
            counters [1] = new Counter();
            counters [2] = new Counter();

            GlobalInfoCondition.Value = "";

            ExtensionContext c1 = AddinManager.CreateExtensionContext();
            ExtensionContext c2 = AddinManager.CreateExtensionContext();

            ParameterInfoCondition pinfo1 = new ParameterInfoCondition();
            ParameterInfoCondition pinfo2 = new ParameterInfoCondition();

            pinfo1.Value = "";
            pinfo2.Value = "";

            c1.RegisterCondition("InputParameter", pinfo1);
            c2.RegisterCondition("InputParameter", pinfo2);

            // Test registering

            c1.GetExtensionNode("/SimpleApp/ExtraWriters").ExtensionNodeChanged += NodeListener_1;
            c2.AddExtensionNodeHandler("/SimpleApp/ExtraWriters", NodeListener_2);
            AddinManager.AddExtensionNodeHandler("/SimpleApp/Writers2", NodeListener_g);

            counters[0].Check("t1.0", 2, 2, 0, 0);
            counters[1].Check("t1.1", 2, 2, 0, 0);
            counters[2].Check("t1.2", 2, 2, 0, 0);

            c1.AddExtensionNodeHandler("/SimpleApp/Writers2", NodeListener_1);
            c2.AddExtensionNodeHandler("/SimpleApp/Writers2", NodeListener_2);

            counters[1].Check("t2.1", 2, 2, 0, 0);
            counters[2].Check("t2.2", 2, 2, 0, 0);

            c1.ExtensionChanged           += ExtensionListener_1;
            c2.ExtensionChanged           += ExtensionListener_2;
            AddinManager.ExtensionChanged += ExtensionListener_g;

            counters[0].Check("t3.0", 0, 0, 0, 0);
            counters[1].Check("t3.1", 0, 0, 0, 0);
            counters[2].Check("t3.2", 0, 0, 0, 0);

            CheckWriters("t4.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t4.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t4.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t4.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
            CheckWriters("t4.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test change global var

            GlobalInfoCondition.Value = "yes2";

            counters[0].Check("t5.0", 2, 2, 0, 1);
            counters[1].Check("t5.1", 2, 2, 0, 1);
            counters[2].Check("t5.2", 2, 2, 0, 1);

            CheckWriters("t6.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
            CheckWriters("t6.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
            CheckWriters("t6.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
            CheckWriters("t6.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
            CheckWriters("t6.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test change global var

            GlobalInfoCondition.Value = "no";

            counters[0].Check("t7.0", 2, 0, 2, 1);
            counters[1].Check("t7.1", 5, 3, 2, 2);
            counters[2].Check("t7.2", 5, 3, 2, 2);

            CheckWriters("t7.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t7.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t7.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t7.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:cn1", "cmd:cn2", "cmd:cn3");
            CheckWriters("t7.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:cn1", "cmd:cn2", "cmd:cn3");

            // Test reset global var

            GlobalInfoCondition.Value = "";

            counters[0].Check("t8.0", 0, 0, 0, 0);
            counters[1].Check("t8.1", 3, 0, 3, 1);
            counters[2].Check("t8.2", 3, 0, 3, 1);

            CheckWriters("t8.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t8.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t8.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t8.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
            CheckWriters("t8.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test local var

            pinfo1.Value = "simple";

            counters[0].Check("t9.0", 0, 0, 0, 0);
            counters[1].Check("t9.1", 2, 2, 0, 1);
            counters[2].Check("t9.2", 0, 0, 0, 0);

            CheckWriters("t9.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t9.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t9.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t9.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters("t9.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test local var

            pinfo2.Value = "simple";

            counters[0].Check("t10.0", 0, 0, 0, 0);
            counters[1].Check("t10.1", 0, 0, 0, 0);
            counters[2].Check("t10.2", 2, 2, 0, 1);

            CheckWriters("t10.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t10.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t10.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t10.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters("t10.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");

            // Test unset local var

            pinfo2.Value = "";

            counters[0].Check("t10.0", 0, 0, 0, 0);
            counters[1].Check("t10.1", 0, 0, 0, 0);
            counters[2].Check("t10.2", 2, 0, 2, 1);

            CheckWriters("t10.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t10.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t10.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t10.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters("t10.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Combined global/local var change

            GlobalInfoCondition.Value = "yes1";
            pinfo2.Value = "x1";

            counters[0].Check("t11.0", 0, 0, 0, 0);
            counters[1].Check("t11.1", 0, 0, 0, 0);
            counters[2].Check("t11.2", 2, 2, 0, 1);

            CheckWriters("t11.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t11.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t11.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters("t11.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters("t11.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:c3 x1 and yes1", "cmd:c4 x1 and yes1");

            GlobalInfoCondition.Value = "";
        }