Exemple #1
0
        public void Convert(string guiFolderName, bool makeBackup)
        {
            GtkDesignInfo info = GtkDesignInfo.FromProject(project);

            Stetic.Project gproject = GuiBuilderService.SteticApp.CreateProject(info);
            //Stetic.Project does not implement IDisposable
            try {
                string newGuiFolderName = project.BaseDirectory.Combine(guiFolderName);
                gproject.ConvertProject(info.SteticFile, newGuiFolderName);
                info.ConvertGtkFolder(guiFolderName, makeBackup);
                info.UpdateGtkFolder();
                folderName = newGuiFolderName;
                IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor();
                try {
                    ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration;
                    Generator             generator     = new Generator();
                    generator.Run(monitor, project, configuration);
                    monitor.ReportSuccess("Converting was succesfull");
                } finally {
                    monitor.Dispose();
                }
            } finally {
                gproject.Dispose();
            }
        }
        public INamedTypeSymbol FindClass(string className, bool getUserClass)
        {
            FilePath gui_folder = GtkDesignInfo.FromProject(project).GtkGuiFolder;
            var      ctx        = GetParserContext();

            if (ctx == null)
            {
                return(null);
            }
            foreach (var cls in ctx.GetAllTypesInMainAssembly())
            {
                if (cls.GetFullName() == className)
                {
                    if (getUserClass)
                    {
                        // Return this class only if it is declared outside the gtk-gui
                        // folder. Generated partial classes will be ignored.
                        foreach (var part in cls.Locations)
                        {
                            var filePath = part.SourceTree.FilePath;
                            if (!string.IsNullOrEmpty(filePath) && !((FilePath)filePath).IsChildPathOf(gui_folder))
                            {
                                return(cls);
                            }
                        }
                        continue;
                    }
                    return(cls);
                }
            }
            return(null);
        }
        public FeatureSupportLevel GetSupportLevel(SolutionFolder parentCombine, SolutionItem entry)
        {
            if (!(entry is DotNetProject) || !GtkDesignInfo.SupportsRefactoring(entry as DotNetProject))
            {
                return(FeatureSupportLevel.NotSupported);
            }

            ReferenceManager refmgr = new ReferenceManager((DotNetProject)entry);

            if (refmgr.SupportedGtkVersions.Count == 0)
            {
                return(FeatureSupportLevel.NotSupported);
            }

            if (GtkDesignInfo.SupportsDesigner((Project)entry))
            {
                return(FeatureSupportLevel.Enabled);
            }
            else if (entry is DotNetAssemblyProject)
            {
                return(FeatureSupportLevel.SupportedByDefault);
            }
            else
            {
                return(FeatureSupportLevel.Supported);
            }
        }
 public override void BuildChildNodes(ITreeBuilder builder, object dataObject)
 {
     if (GtkDesignInfo.HasDesignedObjects((Project)dataObject))
     {
         builder.AddChild(new WindowsFolder((Project)dataObject));
     }
 }
Exemple #5
0
        static void OnProjectCompiled(object s, BuildEventArgs args)
        {
            if (args.Success)
            {
                // Unload stetic projects which are not currently
                // being used by the IDE. This will avoid unnecessary updates.
                if (IdeApp.Workspace.IsOpen)
                {
                    foreach (Project prj in IdeApp.Workspace.GetAllProjects())
                    {
                        GtkDesignInfo info = GtkDesignInfo.FromProject(prj);
                        if (!HasOpenDesigners(prj, false))
                        {
                            info.ReloadGuiBuilderProject();
                        }
                    }
                }

                SteticApp.UpdateWidgetLibraries(false);
            }
            else
            {
                // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel
                if (Runtime.SystemAssemblyService.DefaultAssemblyContext.GetPackage("gtk-sharp-2.0") == null)
                {
                    string msg = GettextCatalog.GetString("ERROR: MonoDevelop could not find the Gtk# 2.0 development package. Compilation of projects depending on Gtk# libraries will fail. You may need to install development packages for gtk-sharp-2.0.");
                    args.ProgressMonitor.Log.WriteLine();
                    args.ProgressMonitor.Log.WriteLine(msg);
                }
            }
        }
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
        {
            Project project = dataObject as Project;

            if (project is DotNetProject)
            {
                GtkDesignInfo info = GtkDesignInfo.FromProject(project);

                if (info.NeedsConversion)
                {
                    ProjectConversionDialog dialog = new ProjectConversionDialog(project, info.SteticFolderName);

                    try
                    {
                        if (dialog.Run() == (int)ResponseType.Yes)
                        {
                            info.GuiBuilderProject.Convert(dialog.GuiFolderName, dialog.MakeBackup);
                            IdeApp.ProjectOperations.Save(project);
                        }
                    } finally {
                        dialog.Destroy();
                    }
                }

                project.FileAddedToProject += HandleProjectFileAddedToProject;
            }
        }
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            DotNetProject project = (DotNetProject)entry;
            GtkDesignInfo info    = GtkDesignInfo.FromProject(project);

            // The code generator must run in the GUI thread since it needs to
            // access to Gtk classes
            Generator gen = new Generator();

            lock (gen) {
                Gtk.Application.Invoke(delegate { gen.Run(monitor, project, configuration); });
                Monitor.Wait(gen);
            }

            BuildResult res = base.Build(monitor, entry, configuration);

            if (gen.Messages != null)
            {
                foreach (string s in gen.Messages)
                {
                    res.AddWarning(info.GuiBuilderProject.File, 0, 0, null, s);
                }

                if (gen.Messages.Length > 0)
                {
                    info.ForceCodeGenerationOnBuild();
                }
            }
            return(res);
        }
        public override async Task <DocumentController> CreateController(FileDescriptor file, DocumentControllerDescription controllerDescription)
        {
            var info = GtkDesignInfo.FromProject((DotNetProject)file.Owner);
            var view = new ActionGroupView(GetActionGroup(file.FilePath), info.GuiBuilderProject);

            return(view);
        }
Exemple #9
0
        public override bool CanCreateContentForUri(string fileName)
        {
            Project       project = IdeApp.Workspace.GetProjectContainingFile(fileName);
            GtkDesignInfo info    = GtkDesignInfo.FromProject((DotNetProject)project);

            if (excludeThis)
            {
                return(false);
            }

            if (fileName.Contains(info.BuildFileExtension))
            {
                return(false);
            }

            if (!IdeApp.Workspace.IsOpen)
            {
                return(false);
            }

            if (GetActionGroup(fileName) == null)
            {
                return(false);
            }


            excludeThis = true;
            var db = DisplayBindingService.GetDefaultBindingForUri(fileName);

            excludeThis = false;
            return(db != null);
        }
Exemple #10
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);
        }
        public WindowsFolder(Project project)
        {
            this.project = project;
            GtkDesignInfo info = GtkDesignInfo.FromProject(project);

            gproject          = info.GuiBuilderProject;
            gproject.Changed += OnUpdateFiles;
        }
        protected void OnGenerateCode()
        {
            ProjectFile       pf       = CurrentNode.DataItem as ProjectFile;
            Project           project  = CurrentNode.GetParentDataItem(typeof(Project), true) as Project;
            GtkDesignInfo     info     = GtkDesignInfo.FromProject(project);
            GuiBuilderProject gproject = info.GuiBuilderProject;

            gproject.GenerateCode(pf.FilePath);
        }
        void AttachWindow(GuiBuilderWindow window)
        {
            gproject = window.Project;
            GtkDesignInfo info = GtkDesignInfo.FromProject(gproject.Project);

            gproject.SteticProject.ImagesRootPath = FileService.AbsoluteToRelativePath(info.GtkGuiFolder, gproject.Project.BaseDirectory);
            gproject.UpdateLibraries();
            LoadDesigner();
        }
Exemple #14
0
        public CodeBinder(MonoDevelop.Projects.Project project, ITextFileProvider textFileProvider, Stetic.Component targetObject)
        {
            this.project          = project;
            this.textFileProvider = textFileProvider;

            gproject = GtkDesignInfo.FromProject(project).GuiBuilderProject;

            TargetObject = targetObject;
        }
        protected void OnEditIcons()
        {
            Project           project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project;
            GuiBuilderProject gp      = GtkDesignInfo.FromProject(project).GuiBuilderProject;

            Stetic.Project sp = gp.SteticProject;
            sp.EditIcons();
            gp.SaveProject(true);
        }
        public override void RenameItem(string newName)
        {
            Project       project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project;
            GtkDesignInfo info    = GtkDesignInfo.FromProject(project);

            info.SteticFolderName = newName;

            base.RenameItem(newName);
        }
            public WidgetBuilderOptionPanelWidget(Project project) : base(false, 6)
            {
                this.project = project as DotNetProject;

                Gtk.HBox  box = new Gtk.HBox(false, 3);
                Gtk.Label lbl = new Gtk.Label(GettextCatalog.GetString("Target Gtk# version:"));
                box.PackStart(lbl, false, false, 0);
                comboVersions = ComboBox.NewText();
                ReferenceManager refmgr = new ReferenceManager(project as DotNetProject);

                foreach (string v in refmgr.SupportedGtkVersions)
                {
                    comboVersions.AppendText(v);
                }
                comboVersions.Active = refmgr.SupportedGtkVersions.IndexOf(refmgr.GtkPackageVersion);
                refmgr.Dispose();
                box.PackStart(comboVersions, false, false, 0);
                box.ShowAll();
                PackStart(box, false, false, 0);

                HSeparator sep = new HSeparator();

                sep.Show();
                PackStart(sep, false, false, 0);

                if (!GtkDesignInfo.HasDesignedObjects(project))
                {
                    return;
                }

                GtkDesignInfo designInfo = GtkDesignInfo.FromProject(project);

                checkGettext        = new CheckButton(GettextCatalog.GetString("Enable gettext support"));
                checkGettext.Active = designInfo.GenerateGettext;
                checkGettext.Show();
                PackStart(checkGettext, false, false, 0);
                box = new Gtk.HBox(false, 3);
                box.PackStart(new Label(GettextCatalog.GetString("Gettext class:")), false, false, 0);
                entryGettext           = new Gtk.Entry();
                entryGettext.Text      = designInfo.GettextClass;
                entryGettext.Sensitive = checkGettext.Active;
                box.PackStart(entryGettext, false, false, 0);
                box.ShowAll();
                PackStart(box, false, false, 0);

                checkGettext.Clicked += delegate
                {
                    box.Sensitive = checkGettext.Active;
                    if (checkGettext.Active)
                    {
                        entryGettext.Text = "Mono.Unix.Catalog";
                    }
                };
            }
        public override bool SupportsItem(IBuildTarget item)
        {
            if (!IdeApp.IsInitialized)
            {
                return(false);
            }

            DotNetProject project = item as DotNetProject;

            return(project != null && GtkDesignInfo.HasDesignedObjects(project));
        }
        Stetic.ActionGroupInfo GetActionGroup(string file)
        {
            var project = IdeApp.Workspace.GetProjectsContainingFile(file).FirstOrDefault();

            if (!GtkDesignInfo.HasDesignedObjects(project))
            {
                return(null);
            }

            return(GtkDesignInfo.FromProject(project).GuiBuilderProject.GetActionGroupForFile(file));
        }
        public override void BuildChildNodes(ITreeBuilder builder, object dataObject)
        {
            Project       project = (Project)dataObject;
            GtkDesignInfo info    = GtkDesignInfo.FromProject(project);

            if (GtkDesignInfo.HasDesignedObjects(project))
            {
                GuiProjectFolder folder = new GuiProjectFolder(info.SteticFolder.FullPath, project, null);
                builder.AddChild(folder);
            }
        }
Exemple #21
0
        public override void BuildChildNodes(ITreeBuilder builder, object dataObject)
        {
            Project       p    = ((WindowsFolder)dataObject).Project;
            GtkDesignInfo info = GtkDesignInfo.FromProject(p);

            if (!info.GuiBuilderProject.HasError)
            {
                builder.AddChild(new StockIconsNode(p));
                builder.AddChildren(info.GuiBuilderProject.Windows);
                builder.AddChildren(info.GuiBuilderProject.SteticProject.ActionGroups);
            }
        }
        public IViewContent CreateContent(FilePath fileName, string mimeType, Project ownerProject)
        {
            excludeThis = true;
            var           db   = DisplayBindingService.GetDefaultViewBinding(fileName, mimeType, ownerProject);
            GtkDesignInfo info = GtkDesignInfo.FromProject((DotNetProject)ownerProject);

            var             content = db.CreateContent(fileName, mimeType, ownerProject);
            ActionGroupView view    = new ActionGroupView(content, GetActionGroup(fileName), info.GuiBuilderProject);

            excludeThis = false;
            return(view);
        }
Exemple #23
0
        void Load()
        {
            if (gproject != null || disposed || fileName == null)
            {
                return;
            }

            gproject  = GuiBuilderService.SteticApp.CreateProject();
            formInfos = new List <GuiBuilderWindow> ();

            if (!System.IO.File.Exists(fileName))
            {
                // Regenerate the gtk-gui folder if the stetic project
                // doesn't exist.
                GtkDesignInfo.FromProject(project).UpdateGtkFolder();
            }

            try
            {
                gproject.Load(fileName);
            }
            catch (Exception ex)
            {
                MessageService.ShowException(ex, GettextCatalog.GetString("The GUI designer project file '{0}' could not be loaded.", fileName));
                hasError = true;
            }

            Counters.SteticProjectsLoaded++;
            gproject.ResourceProvider            = GtkDesignInfo.FromProject(project).ResourceProvider;
            gproject.WidgetAdded                += OnAddWidget;
            gproject.WidgetRemoved              += OnRemoveWidget;
            gproject.ActionGroupsChanged        += OnGroupsChanged;
            project.FileAddedToProject          += OnFileAdded;
            project.FileRemovedFromProject      += OnFileRemoved;
            project.ReferenceAddedToProject     += OnReferenceAdded;
            project.ReferenceRemovedFromProject += OnReferenceRemoved;

            foreach (Stetic.WidgetInfo ob in gproject.Widgets)
            {
                RegisterWindow(ob, false);
            }

            // Monitor changes in the file
            lastSaveTime = System.IO.File.GetLastWriteTime(fileName);
            watcher      = new FileSystemWatcher();
            if (System.IO.File.Exists(fileName))
            {
                watcher.Path                = Path.GetDirectoryName(fileName);
                watcher.Filter              = Path.GetFileName(fileName);
                watcher.Changed            += (FileSystemEventHandler)DispatchService.GuiDispatch(new FileSystemEventHandler(OnSteticFileChanged));
                watcher.EnableRaisingEvents = true;
            }
        }
Exemple #24
0
        public override IViewContent CreateContentForUri(string fileName)
        {
            excludeThis = true;
            var db = DisplayBindingService.GetDefaultBindingForUri(fileName);

            Project       project = IdeApp.Workspace.GetProjectContainingFile(fileName);
            GtkDesignInfo info    = GtkDesignInfo.FromProject((DotNetProject)project);

            ActionGroupView view = new ActionGroupView(db.CreateContentForUri(fileName), GetActionGroup(fileName), info.GuiBuilderProject);

            excludeThis = false;
            return(view);
        }
        internal static GuiBuilderWindow GetWindow(string file, Project project)
        {
            if (!IdeApp.Workspace.IsOpen)
            {
                return(null);
            }
            if (!GtkDesignInfo.HasDesignedObjects(project))
            {
                return(null);
            }
            GtkDesignInfo info = GtkDesignInfo.FromProject(project);

            if (file.StartsWith(info.GtkGuiFolder))
            {
                return(null);
            }
            var docId = IdeApp.TypeSystemService.GetDocumentId(project, file);

            if (docId == null)
            {
                return(null);
            }
            var doc = IdeApp.TypeSystemService.GetCodeAnalysisDocument(docId);

            if (doc == null)
            {
                return(null);
            }
            Microsoft.CodeAnalysis.SemanticModel semanticModel;
            try {
                semanticModel = doc.GetSemanticModelAsync().Result;
            } catch {
                return(null);
            }
            if (semanticModel == null)
            {
                return(null);
            }
            var root = semanticModel.SyntaxTree.GetRoot();

            foreach (var classDeclaration in root.DescendantNodesAndSelf(child => !(child is BaseTypeDeclarationSyntax)).OfType <ClassDeclarationSyntax> ())
            {
                var c = semanticModel.GetDeclaredSymbol(classDeclaration);
                GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass(c.ToDisplayString(Microsoft.CodeAnalysis.SymbolDisplayFormat.CSharpErrorMessageFormat));
                if (win != null)
                {
                    return(win);
                }
            }
            return(null);
        }
        protected async override Task <BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
        {
            if (Project.References.Count == 0 || !GtkDesignInfo.HasDesignedObjects(Project))
            {
                return(await base.OnBuild(monitor, configuration, operationContext));
            }

            Generator gen = new Generator();

            if (!await gen.Run(monitor, Project, configuration))
            {
                BuildResult gr = new BuildResult();
                foreach (string s in gen.Messages)
                {
                    gr.AddError(DesignInfo.GuiBuilderProject.File, 0, 0, null, s);
                }
                return(gr);
            }

            BuildResult res = await base.OnBuild(monitor, configuration, operationContext);

            if (gen.Messages != null)
            {
                foreach (string s in gen.Messages)
                {
                    res.AddWarning(DesignInfo.GuiBuilderProject.File, 0, 0, null, s);
                }

                if (gen.Messages.Length > 0)
                {
                    DesignInfo.ForceCodeGenerationOnBuild();
                }
            }

            if (res.Failed && !Platform.IsWindows && !Platform.IsMac)
            {
                // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel
                if (Project.AssemblyContext.GetPackage("gtk-sharp-2.0") == null)
                {
                    string msg = GettextCatalog.GetString(
                        "ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " +
                        "Compilation of projects depending on Gtk# libraries will fail. " +
                        "You may need to install development packages for gtk-sharp-2.0.");
                    monitor.Log.WriteLine();
                    monitor.Log.WriteLine(BrandingService.BrandApplicationName(msg));
                }
            }

            return(res);
        }
        public override void ActivateItem()
        {
            StockIconsNode    node = (StockIconsNode)CurrentNode.DataItem;
            GtkDesignInfo     info = GtkDesignInfo.FromProject(node.Project);
            GuiBuilderProject gp   = info.GuiBuilderProject;

            Stetic.Project sp = gp.SteticProject;
            sp.ImagesRootPath     = FileService.AbsoluteToRelativePath(info.GtkGuiFolder, gp.Project.BaseDirectory);
            sp.ImportFileCallback = delegate(string file) {
                return(GuiBuilderService.ImportFile(gp.Project, file));
            };
            sp.EditIcons();
            gp.Save(true);
        }
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            DotNetProject project = (DotNetProject)entry;
            GtkDesignInfo info    = GtkDesignInfo.FromProject(project);

            // The code generator must run in the GUI thread since it needs to
            // access to Gtk classes
            Generator gen = new Generator();

            lock (gen)
            {
                Gtk.Application.Invoke(delegate
                {
                    gen.Run(monitor, project, configuration);
                });
                Monitor.Wait(gen);
            }

            BuildResult res = base.Build(monitor, entry, configuration);

            if (gen.Messages != null)
            {
                foreach (string s in gen.Messages)
                {
                    res.AddWarning(info.GuiBuilderProject.File, 0, 0, null, s);
                }

                if (gen.Messages.Length > 0)
                {
                    info.ForceCodeGenerationOnBuild();
                }
            }

            if (res.Failed && !Platform.IsWindows && !Platform.IsMac)
            {
                // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel
                if (project.AssemblyContext.GetPackage("gtk-sharp-2.0") == null)
                {
                    string msg = GettextCatalog.GetString(
                        "ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " +
                        "Compilation of projects depending on Gtk# libraries will fail. " +
                        "You may need to install development packages for gtk-sharp-2.0.");
                    monitor.Log.WriteLine();
                    monitor.Log.WriteLine(msg);
                }
            }

            return(res);
        }
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
        {
            Project       p    = ((WindowsFolder)dataObject).Project;
            GtkDesignInfo info = GtkDesignInfo.FromProject(p);

            if (info.GuiBuilderProject.HasError)
            {
                label = GettextCatalog.GetString("User Interface (GUI project load failed)");
            }
            else
            {
                label = GettextCatalog.GetString("User Interface");
            }
            icon       = Context.GetIcon(Stock.OpenResourceFolder);
            closedIcon = Context.GetIcon(Stock.ClosedResourceFolder);
        }
        public override void RenameItem(string newName)
        {
            base.RenameItem(newName);

            Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project;

            if (project != null)
            {
                ProjectFile pf = CurrentNode.DataItem as ProjectFile;
                if (pf.IsComponentFile())
                {
                    GtkDesignInfo info = GtkDesignInfo.FromProject(project);
                    info.RenameComponentFile(pf);
                }
            }
        }
		public Stetic.CodeGenerationResult GenerateCode (ArrayList projectFolders, bool useGettext, string gettextClass, bool usePartialClasses, GtkDesignInfo info)
		{
			Gtk.Application.Init ();
			
			Stetic.Application app = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
			
			Stetic.Project[] projects = new Stetic.Project [projectFolders.Count];
			for (int n=0; n < projectFolders.Count; n++) {
				projects [n] = app.CreateProject (info);
				projects [n].Load ((string) projectFolders [n]);
			}
			
			Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
			options.UseGettext = useGettext;
			options.GettextClass = gettextClass;
			
			return app.GenerateProjectCode (options, projects);
		}
Exemple #32
0
		public static GtkDesignInfo FromProject (Project project)
		{
			if (project == null)
				return null;

			var info = project.ExtendedProperties ["GtkDesignInfo"] as GtkDesignInfo;
			if (info == null)
				info = new GtkDesignInfo (project);
			else
				info.Project = project;
			return info;
		}