예제 #1
0
 public OpenResourceForm(PluginMain plugin)
 {
     this.plugin = plugin;
     this.InitializeComponent();
     this.InitializeLocalization();
     this.Font = PluginBase.Settings.DefaultFont;
     this.FormGuid = "8e4e0a95-0aff-422c-b8f5-ad9bc8affabb";
 }
예제 #2
0
        /// <summary>
        /// Creates a plugin panel for the plugin
        /// </summary>
        public void CreateNewProject(Object sender, System.EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.DefaultExt = "as3rsx";
            dialog.Filter     = "AS3 Resource Project (*.as3rsx)|*.as3rsx";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Console.WriteLine(dialog.FileName);
                if (dialog.FileName != "")
                {
                    String     template = (String)TemplateGenerator.ProjectSettings.Clone();
                    FileInfo   fi       = new FileInfo(@dialog.FileName);
                    FileStream fs       = fi.OpenWrite();
                    fs.WriteByte(0xEF);
                    fs.WriteByte(0xBB);
                    fs.WriteByte(0xBF);
                    UTF8Encoding enc   = new UTF8Encoding();
                    byte[]       bytes = enc.GetBytes(template);
                    fs.Write(bytes, 0, bytes.Length);
                    fs.Close();
                    DirectoryInfo di = new DirectoryInfo(Path.Combine(fi.Directory.FullName, "rsx"));
                    if (!di.Exists)
                    {
                        try
                        {
                            di.Create();
                        }
                        catch
                        {
                            Console.WriteLine("Failed to create project folder");
                            // TODO: Need an alert here
                            return;
                        }
                    }
                    fi = new FileInfo(Path.Combine(di.FullName, "Assets.mxml"));
                    if (!fi.Exists)
                    {
                        fs       = fi.OpenWrite();
                        template = (String)TemplateGenerator.ProjectTemplate.Clone();
                        bytes    = enc.GetBytes(template);
                        fs.Write(bytes, 0, bytes.Length);
                        fs.Close();
                    }
                    project = new RSXProject(di.FullName);
                    ProjectManager.PluginMain pm = (ProjectManager.PluginMain)PluginBase.MainForm.FindPlugin("30018864-fadd-1122-b2a5-779832cbbf23");
                    //ProjectManager.Projects.AS3.AS3Project
                }
            }
        }
예제 #3
0
        public PluginUI(PluginMain plugin, FDMenus menus, FileActions fileActions, ProjectActions projectActions)
        {
            this.menus           = menus;
            this.AutoKeyHandling = true;
            this.Text            = TextHelper.GetString("Title.PluginPanel");

            #region Build TreeView and Toolbar

            menu = new ProjectContextMenu();
            menu.Rename.Click += RenameNode;

            treeBar = new TreeBar(menus, menu);

            tree                    = new ProjectTreeView();
            tree.BorderStyle        = BorderStyle.None;
            tree.Dock               = DockStyle.Fill;
            tree.ImageIndex         = 0;
            tree.ImageList          = Icons.ImageList;
            tree.LabelEdit          = true;
            tree.SelectedImageIndex = 0;
            tree.ShowRootLines      = false;
            tree.HideSelection      = false;
            tree.ContextMenuStrip   = menu;
            tree.AfterLabelEdit    += tree_AfterLabelEdit;
            tree.BeforeLabelEdit   += tree_BeforeLabelEdit;
            tree.BeforeSelect      += tree_BeforeSelect;
            tree.AfterSelect       += tree_AfterSelect;

            Panel panel = new Panel();
            panel.Dock = DockStyle.Fill;
            panel.Controls.Add(tree);
            panel.Controls.Add(treeBar);

            menu.ProjectTree = tree;
            ScrollBarEx.Attach(tree);

            #endregion

            #region Instructions

            help = new LinkLabel();
            string[] helpParts   = String.Format(TextHelper.GetString("Info.NoProjectsOpenLink"), "\n").Split('|');
            string[] helpActions = { "create", "open", "import" };
            string   helpText    = "";
            int[]    linkStart   = { 0, 0, 0 };
            int[]    linkLength  = { 0, 0, 0 };
            for (int i = 0; i < 3; i++)
            {
                if (helpParts.Length > i * 2)
                {
                    helpText     += helpParts[i * 2];
                    linkStart[i]  = helpText.Length;
                    helpText     += helpParts[i * 2 + 1];
                    linkLength[i] = helpParts[i * 2 + 1].Length;
                }
            }
            help.Text = helpText + helpParts[helpParts.Length - 1];
            for (int i = 0; i < 3; i++)
            {
                help.Links.Add(linkStart[i], linkLength[i], helpActions[i]);
            }
            help.LinkClicked += link_LinkClicked;
            help.Dock         = DockStyle.Fill;
            help.TextAlign    = ContentAlignment.MiddleCenter;
            help.ContextMenu  = new ContextMenu();

            #endregion

            this.Controls.Add(help);
            this.Controls.Add(panel);

            #region Events

            fileActions.FileCreated        += NewFileCreated;
            fileActions.ProjectModified    += ProjectModified;
            projectActions.ProjectModified += ProjectModified;

            #endregion
        }
예제 #4
0
        public PluginUI(PluginMain plugin, FDMenus menus, FileActions fileActions, ProjectActions projectActions)
        {
            this.menus = menus;
            this.plugin = plugin;
            this.Text = TextHelper.GetString("Title.PluginPanel");

            #region Build TreeView and Toolbar

            menu = new ProjectContextMenu();
            menu.Rename.Click += RenameNode;

            treeBar = new TreeBar(menus, menu);

            tree = new ProjectTreeView();
            tree.BorderStyle = BorderStyle.None;
            tree.Dock = DockStyle.Fill;
            tree.ImageIndex = 0;
            tree.ImageList = Icons.ImageList;
            tree.LabelEdit = true;
            tree.SelectedImageIndex = 0;
            tree.ShowRootLines = false;
            tree.HideSelection = false;
            tree.ContextMenuStrip = menu;
            tree.AfterLabelEdit += tree_AfterLabelEdit;
            tree.BeforeLabelEdit += tree_BeforeLabelEdit;
            tree.BeforeSelect += tree_BeforeSelect;
            tree.AfterSelect += tree_AfterSelect;

            Panel panel = new Panel();
            panel.Dock = DockStyle.Fill;
            panel.Controls.Add(tree);
            panel.Controls.Add(treeBar);

            menu.ProjectTree = tree;

            #endregion

            #region Instructions

            help = new LinkLabel();
            string[] helpParts = String.Format(TextHelper.GetString("Info.NoProjectsOpenLink"), "\n").Split('|');
            string[] helpActions = { "create", "open", "import" };
            string helpText = "";
            int[] linkStart = { 0, 0, 0 };
            int[] linkLength = { 0, 0, 0 };
            for (int i = 0; i < 3; i++)
            {
                if (helpParts.Length > i * 2)
                {
                    helpText += helpParts[i * 2];
                    linkStart[i] = helpText.Length;
                    helpText += helpParts[i * 2 + 1];
                    linkLength[i] = helpParts[i * 2 + 1].Length;
                }
            }
            help.Text = helpText + helpParts[helpParts.Length - 1];
            for (int i = 0; i < 3; i++)
            {
                help.Links.Add(linkStart[i], linkLength[i], helpActions[i]);
            }
            help.LinkClicked += link_LinkClicked;
            help.Dock = DockStyle.Fill;
            help.TextAlign = ContentAlignment.MiddleCenter;
            help.ContextMenu = new ContextMenu();

            #endregion

            this.Controls.Add(help);
            this.Controls.Add(panel);

            #region Events

            fileActions.FileCreated += NewFileCreated;
            fileActions.ProjectModified += ProjectModified;
            projectActions.ProjectModified += ProjectModified;

            #endregion
        }
예제 #5
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            TextEvent       te       = e as TextEvent;
            DataEvent       de       = e as DataEvent;
            ITabbedDocument document = PluginBase.MainForm.CurrentDocument;

            //BxmlDesigner designer = document != null && designers.ContainsKey(document) ? designers[document] : null;

            // TODO: we need to handle these too:
            //ProjectManagerEvents.BuildComplete;
            //ProjectManagerEvents.BuildFailed;
            //ProjectManagerEvents.BuildProject;
            //ProjectManagerEvents.CreateProject;
            //ProjectManagerEvents.FileMoved;
            //ProjectManagerEvents.FilePasted;
            //ProjectManagerEvents.OpenVirtualFile;
            //ProjectManagerEvents.ProjectCreated;
            if (e.Type == EventType.Command && de.Action == ProjectManagerEvents.FileMapping)
            {
                ProjectFileMapper.Map((FileMappingRequest)de.Data);
                return;
            }

            // our first priority is getting a non-null Project, otherwise
            // we can't do anything

            if (e.Type == EventType.Command && de.Action == ProjectManagerEvents.Project)
            {
                // the projectexplorer plugin is telling us what project we're working with
                this.asproject = de.Data as ProjectManager.Projects.Project;
                Console.WriteLine("We found a project " + this.asproject + " : " + de.Data + " : " + (de.Data is ProjectManager.Projects.Project));
                //return;
            }

            // we need a project and context to handle these events
            if (e.Type == EventType.FileOpen)
            {
                if (this.IsNfxMxml(document))
                {
                    Console.WriteLine("MXML file opened");
                    PluginBase.MainForm.CallCommand("ChangeSyntax", "xml");

                    //    var timer = new Timer { Interval = 1, Enabled = true };
                    //    timer.Tick += (o, evt) =>
                    //    {
                    //        timer.Enabled = false;

                    // create the design surface
                    //if (GetProjectAndContext())
                    //{
                    //    if (project.AbsoluteClasspaths.GetClosestParent(document.FileName) != null)
                    //    {
                    //        designer = new BxmlDesigner(document, project, GetDesignerSwfPath());
                    //        designers.Add(document, designer);
                    //        //Compile(document, designer);
                    //    }
                    //    else
                    //        SendErrorToResults(document.FileName, "Cannot design this file because the classpath could not be determined.");
                    //}
                    //else SendErrorToResults(document.FileName, "Could not start up the Bent Designer - no project loaded or AS3 completion plugin not loaded.");
                    //    };
                }
            }
            else if (e.Type == EventType.FileClose)
            {
                Console.WriteLine("MXML file closed");
                // TODO: Recompile code behind here
                //if (designers.ContainsKey(document))
                //    designers.Remove(document);
            }
            else if (e.Type == EventType.Command)
            {
                switch (de.Action)
                {
                case ProjectManagerEvents.BuildComplete:

                    // TODO: Not sure we need this
                    //if (!GetProjectAndContext()) return;
                    //if (!File.Exists(project.OutputPathAbsolute)) return;
                    //if (!CheckIsBentApplication()) return;

                    //BuildDesignerSwf();

                    //foreach (BxmlDesigner d in designers.Values)
                    //    d.SwfOutdated = true;

                    //if (designer != null)
                    //    designer.ReloadSwf();

                    break;

                case "XMLCompletion.Element":

                    // TODO: Not yet...
                    //if (!IsBxml(document) || !GetProjectAndContext()) return;
                    //if (designer == null) return;

                    ////DateTime started = DateTime.Now;
                    //completion.HandleElement(designer, (XMLContextTag)de.Data);
                    //TraceManager.Add("Took " + (DateTime.Now - started).TotalMilliseconds + "ms.");
                    //e.Handled = true;
                    break;

                case "XMLCompletion.CloseElement":

                    // TODO: We would try to rely on FD own autocompletion better...
                    //if (!IsBxml(document) || !GetProjectAndContext()) return;
                    //if (designer == null) return;

                    //string ending = completion.HandleCloseElement(designer, (XMLContextTag)de.Data);
                    //if (ending != null)
                    //{
                    //    if (ending != ">")
                    //    {
                    //        ScintillaNet.ScintillaControl sci = document.SciControl;
                    //        int position = sci.CurrentPos;
                    //        sci.SetSel(position - 1, position);
                    //        sci.ReplaceSel(ending);
                    //        sci.SetSel(position + 1, position + 1);
                    //    }
                    //    e.Handled = true;
                    //}

                    break;

                case "XMLCompletion.Attribute":

                    // TODO: We would try to rely on FD own autocompletion better...
                    //if (!IsBxml(document) || !GetProjectAndContext()) return;
                    //if (designer == null) return;

                    //object[] o = de.Data as object[];
                    ////started = DateTime.Now;
                    //completion.HandleAttribute(designer, (XMLContextTag)o[0], o[1] as string);
                    ////TraceManager.Add("Took " + (DateTime.Now - started).TotalMilliseconds + "ms.");
                    //e.Handled = true;
                    break;
                }
            }
            else if (e.Type == EventType.FileSave && this.IsNfxMxml(document))
            {
                Console.WriteLine("MXML file saved " + document.FileName);
                if (String.IsNullOrEmpty(this.preprocessorLocation))
                {
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.CheckFileExists = true;
                    dialog.Filter          = "JAR files (*.jar)|*.jar";
                    DialogResult dr = dialog.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        this.preprocessorLocation         =
                            this.settingObject.ParserPath = dialog.FileNames[0];
                    }
                    else
                    {
                        return;
                    }
                }

                this.context = ASCompletion.Context.ASContext.GetLanguageContext("as3");
                string classpath = this.asproject.AbsoluteClasspaths.GetClosestParent(document.FileName);
                Console.WriteLine("Our classpath: " + classpath);
                ASCompletion.Model.PathModel pathModel =
                    context.Classpath.Find(pm => pm.Path == classpath);
                Hashtable ht = new Hashtable();
                ht.Add("-source", document.FileName);
                ht.Add("-source-dir", classpath);
                NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);
                EventManager.DispatchEvent(this, ne);
                PluginCore.Managers.EventManager.DispatchEvent(
                    this, new DataEvent(EventType.Command, "ResultsPanel.ClearResults", null));

                // TEST: trying to remove sci from our generated AS file so we won't get an update message
                ITabbedDocument[] documents    = FlashDevelop.Globals.MainForm.Documents;
                ITabbedDocument   current      = FlashDevelop.Globals.MainForm.CurrentDocument;
                Boolean           designerOpen = false;
                Char[]            splitter     = new Char[] { '.' };
                foreach (ITabbedDocument doc in documents)
                {
                    Console.WriteLine("doc.FileName " + doc.FileName + " document " + document.FileName);
                    if (doc.FileName.Split(splitter)[0] ==
                        document.FileName.Split(splitter)[0])
                    {
                        // Our designer AS file is open now
                        designerOpen = true;
                        this.lastDesignerFileName = doc.FileName;
                        this.tempRemovedSci       = doc.SciControl;
                        //((Form)doc).Controls.Remove(doc.SciControl);
                        break;
                    }
                }
                if (designerOpen)
                {
                    if (this.restoreDesigner == null)
                    {
                        this.restoreDesigner          = new Timer();
                        this.restoreDesigner.Interval = 50;
                        this.restoreDesigner.Tick    += new EventHandler(restoreDesigner_Tick);
                    }
                    this.restoreDesigner.Enabled = true;
                }
                NFXShell.Run(new FileInfo(document.FileName), this.preprocessorLocation, null, ht);
                // TODO: we should only handle our projects
                // TODO: not really sure this will be needed as those files should be picked up by ASCompletion anyway.
                //string classpath = this.project.AbsoluteClasspaths.GetClosestParent(document.FileName);

                this.TellASCompletionAbout(document.FileName, pathModel);
            }
            else if (e.Type == EventType.FileSwitch)
            {
                // TODO: think we don't need this
                //if (!GetProjectAndContext()) return;

                //// if this flash is marked as "dirty" we'll need to reload it
                //if (designer != null && designer.SwfOutdated)
                //    designer.ReloadSwf();
            }
            else if (e.Type == EventType.UIStarted)
            {
                // TODO: Not sure what this does... we'll see later
                this.projectManager =
                    (ProjectManager.PluginMain)PluginBase.MainForm.FindPlugin(
                        "30018864-fadd-1122-b2a5-779832cbbf23");
                //ProjectManager.Controls.TreeView.FileNode.FileAssociations.Add(".nxml", NFXNode.Create);
                //Timer timer = new Timer();
                //timer.Interval = 100;
                //timer.Tick += delegate { GetProjectAndContext(); timer.Stop(); };
                //timer.Start();
            }
        }