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 }
public void Initialize() { LoadSettings(); pluginImage = MainForm.FindImage("100"); pluginDesc = TextHelper.GetString("Info.Description"); openFileQueue = new Queue<String>(); Icons.Initialize(MainForm); EventManager.AddEventHandler(this, eventMask); showProjectClasspaths = Settings.ShowProjectClasspaths; showGlobalClasspaths = Settings.ShowGlobalClasspaths; #region Actions and Event Listeners menus = new FDMenus(MainForm); menus.ProjectMenu.ProjectItemsEnabled = false; menus.TestMovie.Enabled = false; menus.TestMovie.Click += delegate { TestMovie(); }; menus.BuildProject.Enabled = false; menus.BuildProject.Click += delegate { BuildProject(); }; menus.View.Click += delegate { OpenPanel(); }; menus.GlobalClasspaths.Click += delegate { OpenGlobalClasspaths(); }; menus.ConfigurationSelector.SelectedIndexChanged += delegate { bool isDebug = menus.ConfigurationSelector.Text == TextHelper.GetString("Info.Debug"); FlexCompilerShell.Cleanup(); pluginUI.IsTraceDisabled = !isDebug; Project project = activeProject; if (project != null) project.TraceEnabled = isDebug; }; menus.TargetBuildSelector.KeyDown += new KeyEventHandler(TargetBuildSelector_KeyDown); menus.TargetBuildSelector.SelectedIndexChanged += delegate { ApplyTargetBuild(); }; menus.TargetBuildSelector.LostFocus += delegate { ApplyTargetBuild(); }; menus.ProjectMenu.NewProject.Click += delegate { NewProject(); }; menus.ProjectMenu.OpenProject.Click += delegate { OpenProject(); }; menus.ProjectMenu.ImportProject.Click += delegate { ImportProject(); }; menus.ProjectMenu.CloseProject.Click += delegate { CloseProject(false); }; menus.ProjectMenu.OpenResource.Click += delegate { OpenResource(); }; menus.ProjectMenu.TestMovie.Click += delegate { TestMovie(); }; menus.ProjectMenu.RunProject.Click += delegate { RunProject(); }; menus.ProjectMenu.BuildProject.Click += delegate { BuildProject(); }; menus.ProjectMenu.CleanProject.Click += delegate { CleanProject(); }; menus.ProjectMenu.Properties.Click += delegate { OpenProjectProperties(); }; menus.RecentProjects.ProjectSelected += delegate(string projectPath) { OpenProjectSilent(projectPath); }; buildActions = new BuildActions(MainForm,menus); buildActions.BuildComplete += BuildComplete; buildActions.BuildFailed += BuildFailed; flashDevelopActions = new FlashDevelopActions(MainForm); fileActions = new FileActions(MainForm,flashDevelopActions); fileActions.OpenFile += OpenFile; fileActions.FileDeleted += FileDeleted; fileActions.FileMoved += FileMoved; fileActions.FileCopied += FilePasted; projectActions = new ProjectActions(pluginUI); pluginUI = new PluginUI(this, menus, fileActions, projectActions); pluginUI.NewProject += delegate { NewProject(); }; pluginUI.OpenProject += delegate { OpenProject(); }; pluginUI.ImportProject += delegate { ImportProject(); }; pluginUI.Rename += fileActions.Rename; pluginUI.TreeBar.ShowHidden.Click += delegate { ToggleShowHidden(); }; pluginUI.TreeBar.Synchronize.Click += delegate { TreeSyncToCurrentFile(); }; pluginUI.TreeBar.SynchronizeMain.Click += delegate { TreeSyncToMainFile(); }; pluginUI.TreeBar.ProjectProperties.Click += delegate { OpenProjectProperties(); }; pluginUI.TreeBar.RefreshSelected.Click += delegate { TreeRefreshSelectedNode(); }; pluginUI.TreeBar.ProjectTypes.Click += delegate { DataEvent de = new DataEvent(EventType.Command, "ASCompletion.TypesExplorer", null); EventManager.DispatchEvent(this, de); }; pluginUI.Menu.Open.Click += delegate { TreeOpenItems(); }; pluginUI.Menu.Execute.Click += delegate { TreeExecuteItems(); }; pluginUI.Menu.Insert.Click += delegate { TreeInsertItem(); }; pluginUI.Menu.AddLibrary.Click += delegate { TreeAddLibraryItems(); }; pluginUI.Menu.AlwaysCompile.Click += delegate { TreeAlwaysCompileItems(); }; pluginUI.Menu.SetDocumentClass.Click += delegate { TreeDocumentClass(); }; pluginUI.Menu.DocumentClass.Click += delegate { TreeDocumentClass(); }; pluginUI.Menu.Browse.Click += delegate { TreeBrowseItem(); }; pluginUI.Menu.Cut.Click += delegate { TreeCutItems(); }; pluginUI.Menu.Copy.Click += delegate { TreeCopyItems(); }; pluginUI.Menu.Paste.Click += delegate { TreePasteItems(); }; pluginUI.Menu.Delete.Click += delegate { TreeDeleteItems(); }; pluginUI.Menu.LibraryOptions.Click += delegate { TreeLibraryOptions(); }; pluginUI.Menu.HideItem.Click += delegate { TreeHideItems(); }; pluginUI.Menu.ShowHidden.Click += delegate { ToggleShowHidden(); }; pluginUI.Menu.AddFileFromTemplate += TreeAddFileFromTemplate; pluginUI.Menu.AddNewFolder.Click += delegate { TreeAddFolder(); }; pluginUI.Menu.AddLibraryAsset.Click += delegate { TreeAddAsset(); }; pluginUI.Menu.AddExistingFile.Click += delegate { TreeAddExistingFile(); }; pluginUI.Menu.TestMovie.Click += delegate { TestMovie(); }; pluginUI.Menu.BuildProject.Click += delegate { BuildProject(); }; pluginUI.Menu.CloseProject.Click += delegate { CloseProject(false); }; pluginUI.Menu.Properties.Click += delegate { OpenProjectProperties(); }; pluginUI.Menu.ShellMenu.Click += delegate { TreeShowShellMenu(); }; pluginUI.Menu.CommandPrompt.Click += delegate { TreeShowCommandPrompt(); }; pluginUI.Menu.BuildProjectFile.Click += delegate { BackgroundBuild(); }; pluginUI.Menu.BuildProjectFiles.Click += delegate { BackgroundBuild(); }; pluginUI.Menu.BuildAllProjects.Click += delegate { FullBuild(); }; pluginUI.Menu.TestAllProjects.Click += delegate { TestBuild(); }; pluginUI.Menu.FindAndReplace.Click += delegate { FindAndReplace(); }; pluginUI.Menu.FindInFiles.Click += delegate { FindInFiles(); }; pluginUI.Menu.CopyClassName.Click += delegate { CopyClassName(); }; pluginUI.Menu.AddSourcePath.Click += delegate { AddSourcePath(); }; pluginUI.Menu.RemoveSourcePath.Click += delegate { RemoveSourcePath(); }; pluginUI.Menu.Opening += new CancelEventHandler(this.MenuOpening); Tree.MovePath += fileActions.Move; Tree.CopyPath += fileActions.Copy; Tree.DoubleClick += delegate { TreeDoubleClick(); }; #endregion pluginPanel = MainForm.CreateDockablePanel(pluginUI, Guid, Icons.Project.Img, DockState.DockRight); buildQueue = new Queue<String>(); buildTimer = new Timer(); buildTimer.Interval = 500; buildTimer.Tick += new EventHandler(OnBuildTimerTick); buildingAll = false; runOutput = false; }
public static void Execute() { if ( Globals.SciControl == null ) return; ScintillaControl sci = Globals.SciControl; string selectStr = sci.SelText; if ( selectStr.Length < 1 ) { MessageBox.Show("クラスにするコマンドを選択してください","エラー",MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Project project = (Project) PluginBase.CurrentProject; if (project == null) return; MainForm mainForm = (MainForm) Globals.MainForm; FlashDevelopActions flashDevelopActions = new FlashDevelopActions(mainForm); FileActions fileActions = new FileActions(mainForm, flashDevelopActions); if (!File.Exists(TEMP_PATH)) { StreamWriter tmpWriter = new StreamWriter(TEMP_PATH, false, System.Text.Encoding.UTF8, 512); tmpWriter.Write(TMP_FILE); tmpWriter.Close(); } ITabbedDocument currentDocument = (ITabbedDocument) mainForm.CurrentDocument; String parentPath = System.IO.Path.GetDirectoryName(currentDocument.FileName); fileActions.AddFileFromTemplate(project,parentPath,TEMP_PATH); String fileName = fileActions.ProcessArgs(project, "$(FileName)"); String newFilePath = parentPath + "\\" + fileName + ".as"; if (!File.Exists(newFilePath)) { TraceManager.Add( "キャンセルされました" ); return; } StreamReader reader = new StreamReader(newFilePath); String value = reader.ReadToEnd(); reader.Close(); StreamWriter writer = new StreamWriter(newFilePath, false, System.Text.Encoding.UTF8, 512); writer.Write(fileActions.ProcessArgs(project, value)); writer.Close(); string insText = "new "+fileName+"()"; sci.BeginUndoAction(); sci.Clear(); sci.InsertText(sci.CurrentPos, insText); sci.SelectionStart = sci.CurrentPos; sci.SelectionEnd = sci.CurrentPos + insText.Length; sci.EndUndoAction(); TraceManager.Add( fileName + " が作成されました" ); }