Ejemplo n.º 1
0
        void LoadDesigner()
        {
            groupInfo = project.GetActionGroup(groupName);
            if (groupInfo == null)
            {
                // Group not found
                return;
            }

            group             = (Stetic.ActionGroupComponent)groupInfo.Component;
            project.Unloaded += OnDisposeProject;

            designer = project.SteticProject.CreateActionGroupDesigner(groupInfo, false);
            designer.AllowActionBinding = project.Project.UsePartialTypes;
            designer.BindField         += new EventHandler(OnBindField);

            ActionGroupPage actionsPage = new ActionGroupPage();

            actionsPage.PackStart(designer, true, true, 0);
            actionsPage.ShowAll();

            AddButton(GettextCatalog.GetString("Actions"), actionsPage);

            designer.ModifiedChanged      += OnGroupModified;
            designer.SignalAdded          += OnSignalAdded;
            designer.SignalChanged        += OnSignalChanged;
            designer.RootComponentChanged += OnRootComponentChanged;

            codeBinder = new CodeBinder(project.Project, new OpenDocumentFileProvider(), designer.RootComponent);
        }
Ejemplo n.º 2
0
        public override async void ActivateItem()
        {
            GuiBuilderWindow w = (GuiBuilderWindow)CurrentNode.GetParentDataItem(typeof(GuiBuilderWindow), false);

            if (w != null)
            {
                if (w.SourceCodeFile == FilePath.Null && !w.BindToClass())
                {
                    return;
                }

                Document doc = await IdeApp.Workbench.OpenDocument(w.SourceCodeFile, null, true);

                if (doc != null)
                {
                    GuiBuilderView view = doc.GetContent <GuiBuilderView> ();
                    if (view != null)
                    {
                        view.ShowActionDesignerView(((Stetic.ActionGroupInfo)CurrentNode.DataItem).Name);
                    }
                }
            }
            else
            {
                Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), false);
                Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo)CurrentNode.DataItem;
                await GuiBuilderService.OpenActionGroup(project, group);
            }
        }
Ejemplo n.º 3
0
        public static GtkComponentType GetComponentType(this ProjectFile pf)
        {
            GtkDesignInfo  info = GtkDesignInfo.FromProject(pf.Project);
            ParsedDocument doc  = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(pf.Project), pf.Name);

            //ParsedDocument doc = ProjectDomService.ParseFile (ProjectDomService.GetProjectDom (pf.Project), pf.FilePath.ToString ());
            if (doc != null && doc.CompilationUnit != null)
            {
                foreach (IType t in doc.CompilationUnit.Types)
                {
                    string className = t.FullName;
                    if (className != null)
                    {
                        GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass(className);
                        if (win != null)
                        {
                            return(win.RootWidget.IsWindow ? GtkComponentType.Dialog : GtkComponentType.Widget);
                        }

                        Stetic.ActionGroupInfo action = info.GuiBuilderProject.GetActionGroup(className);
                        if (action != null)
                        {
                            return(GtkComponentType.ActionGroup);
                        }
                    }
                }
            }
            if (pf.Name.Contains("IconFactory.gtkx"))
            {
                return(GtkComponentType.IconFactory);
            }

            return(GtkComponentType.None);
        }
Ejemplo n.º 4
0
		void LoadDesigner ()
		{
			groupInfo = project.GetActionGroup (groupName);
			if (groupInfo == null)
				// Group not found
				return;
			
			group = (Stetic.ActionGroupComponent) groupInfo.Component;
			project.Unloaded += OnDisposeProject;
			
			designer = project.SteticProject.CreateActionGroupDesigner (groupInfo, false);
			designer.AllowActionBinding = project.Project.UsePartialTypes;
			designer.BindField += new EventHandler (OnBindField);
			
			ActionGroupPage actionsPage = new ActionGroupPage ();
			actionsPage.PackStart (designer, true, true, 0);
			actionsPage.ShowAll ();
			
			AddButton (GettextCatalog.GetString ("Actions"), actionsPage);
			
			designer.ModifiedChanged += OnGroupModified;
			designer.SignalAdded += OnSignalAdded;
			designer.SignalChanged += OnSignalChanged;
			designer.RootComponentChanged += OnRootComponentChanged;

			codeBinder = new CodeBinder (project.Project, new OpenDocumentFileProvider (), designer.RootComponent);
		}
Ejemplo n.º 5
0
        internal static string BindToClass(Project project, Stetic.ActionGroupInfo group)
        {
            GuiBuilderProject gproject = GtkDesignInfo.FromProject(project).GuiBuilderProject;
            string            file     = gproject.GetSourceCodeFile(group);

            if (file != null)
            {
                return(file);
            }

            // Find the classes that could be bound to this design

            ArrayList list = new ArrayList();
            var       ctx  = gproject.GetParserContext();

            foreach (var cls in ctx.MainAssembly.GetAllTypeDefinitions())
            {
                if (IsValidClass(cls))
                {
                    list.Add(cls.FullName);
                }
            }

            // Ask what to do

            using (BindDesignDialog dialog = new BindDesignDialog(group.Name, list, project.BaseDirectory))
            {
                if (!dialog.Run())
                {
                    return(null);
                }

                if (dialog.CreateNew)
                {
                    CreateClass(project, (Stetic.ActionGroupComponent)group.Component, dialog.ClassName, dialog.Namespace, dialog.Folder);
                }

                string fullName = dialog.Namespace.Length > 0 ? dialog.Namespace + "." + dialog.ClassName : dialog.ClassName;
                group.Name = fullName;
            }
            return(gproject.GetSourceCodeFile(group));
        }
Ejemplo n.º 6
0
        void OnFileRemoved(object sender, ProjectFileEventArgs args)
        {
            ArrayList toDelete       = new ArrayList();
            ArrayList toDeleteGroups = new ArrayList();

            ParsedDocument doc = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(args.Project), args.ProjectFile.Name);

            if (doc == null || doc.CompilationUnit == null)
            {
                return;
            }

            foreach (IType t in doc.CompilationUnit.Types)
            {
                GuiBuilderWindow win = GetWindowForClass(t.FullName);
                if (win != null)
                {
                    toDelete.Add(win);
                    continue;
                }

                Stetic.ActionGroupInfo group = GetActionGroup(t.FullName);
                if (group != null)
                {
                    toDeleteGroups.Add(group);
                }
            }

            foreach (GuiBuilderWindow win in toDelete)
            {
                Remove(win);
            }

            foreach (Stetic.ActionGroupInfo group in toDeleteGroups)
            {
                RemoveActionGroup(group);
            }
        }
Ejemplo n.º 7
0
        public static async Task <ActionGroupView> OpenActionGroup(Project project, Stetic.ActionGroupInfo group)
        {
            GuiBuilderProject p    = GtkDesignInfo.FromProject(project).GuiBuilderProject;
            string            file = p != null?p.GetSourceCodeFile(group) : null;

            if (file == null)
            {
                file = ActionGroupDisplayBinding.BindToClass(project, group);
            }

            Document doc = await IdeApp.Workbench.OpenDocument(file, null, true);

            if (doc != null)
            {
                ActionGroupView view = doc.GetContent <ActionGroupView> ();
                if (view != null)
                {
                    view.ShowDesignerView();
                    return(view);
                }
            }
            return(null);
        }
        public override void DeleteItem()
        {
            // Don't allow deleting action groups local to a window
            GuiBuilderWindow w = (GuiBuilderWindow)CurrentNode.GetParentDataItem(typeof(GuiBuilderWindow), false);

            if (w != null)
            {
                return;
            }

            Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), false);

            Stetic.ActionGroupInfo group    = (Stetic.ActionGroupInfo)CurrentNode.DataItem;
            GuiBuilderProject      gproject = GtkDesignInfo.FromProject(project).GuiBuilderProject;
            string sfile = gproject.GetSourceCodeFile(group);

            if (sfile != null)
            {
                using (ConfirmWindowDeleteDialog dialog = new ConfirmWindowDeleteDialog(group.Name, sfile, group))
                {
                    if (dialog.Run() == (int)Gtk.ResponseType.Yes)
                    {
                        if (dialog.DeleteFile)
                        {
                            ProjectFile file = project.GetProjectFile(sfile);
                            if (file != null)
                            {
                                project.Files.Remove(file);
                            }
                        }
                        gproject.RemoveActionGroup(group);
                        gproject.SaveProject(false);
                        IdeApp.ProjectOperations.Save(project);
                    }
                }
            }
        }
Ejemplo n.º 9
0
 public void RemoveActionGroup(Stetic.ActionGroupInfo group)
 {
     gproject.RemoveActionGroup(group);
 }
Ejemplo n.º 10
0
 public ActionGroupView(IViewContent content, Stetic.ActionGroupInfo group, GuiBuilderProject project) : base(content)
 {
     groupName    = group.Name;
     this.project = project;
     LoadDesigner();
 }
Ejemplo n.º 11
0
 public override void OnNodeRemoved(object dataObject)
 {
     Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo)dataObject;
     group.Changed -= new EventHandler(OnChanged);
 }
Ejemplo n.º 12
0
 public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
 {
     Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo)dataObject;
     nodeInfo.Label = group.Name;
     nodeInfo.Icon  = Context.GetIcon("md-gtkcore-actiongroup");
 }
Ejemplo n.º 13
0
 public override string GetNodeName(ITreeNavigator thisNode, object dataObject)
 {
     Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo)dataObject;
     return(group.Name);
 }
 public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
 {
     Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo)dataObject;
     label = group.Name;
     icon  = ImageService.GetPixbuf("md-gtkcore-actiongroup", Gtk.IconSize.Menu);
 }
Ejemplo n.º 15
0
 public ActionGroupView(Stetic.ActionGroupInfo group, GuiBuilderProject project)
 {
     groupName    = group.Name;
     this.project = project;
     LoadDesigner();
 }