Created
May 11, 2012 07:07
-
-
Save cellfusion/2658046 to your computer and use it in GitHub Desktop.
FDT SWFBridge ActionPlugin の簡単な説明
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import fdt.FdtTextEdit; | |
import swf.bridge.FdtEditorContext; | |
import swf.bridge.IFdtActionBridge; | |
import swf.plugin.ISwfActionPlugin; | |
import flash.display.Sprite; | |
import flash.utils.Dictionary; | |
[FdtSwfPlugin(name="DemoActionPlugin", pluginType="action", toolTip="Some tooltip")] | |
public class Main extends Sprite implements ISwfActionPlugin | |
{ | |
[Embed(source="../assets/PluginIcon.gif", mimeType="application/octet-stream")] | |
private var TestImage:Class; | |
private var _bridge:IFdtActionBridge; | |
public function Main() | |
{ | |
FdtSwfPluginIcon; | |
} | |
public function callEntryAction(entryId:String):void | |
{ | |
} | |
/** | |
* 初期化 | |
* 画像などを登録したり | |
*/ | |
public function init(bridge:IFdtActionBridge):void | |
{ | |
trace("init"); | |
// 画像の登録 | |
bridge.ui.registerImage("testImage", new TestImage()).sendTo(this, null); | |
_bridge = bridge; | |
} | |
/** | |
* Cmd + 2 で呼び出される | |
* ここで条件を調べたりして IFdtActionBridge.offerProposal でどれを実行するのか選択できるようにする | |
*/ | |
public function createProposals(ec:FdtEditorContext):void | |
{ | |
trace("createProposals"); | |
// offerProposal するとダイアログにやった分だけ出てくるここで登録するメソッドは選択した際に実行される | |
_bridge.offerProposal("test", "testImage", "test", "test offerProposal", applyChanges); | |
_bridge.offerProposal("hoge", "testImage", "test2", "test offerProposal", fuga); | |
} | |
/** | |
* 実行 | |
*/ | |
public function applyChanges(id:String, ec:FdtEditorContext):void | |
{ | |
trace("applyChanges"); | |
// 現在の行を書き換え | |
var textEdits:Vector.<FdtTextEdit> = new Vector.<FdtTextEdit>(); | |
// FdtTextEdit で書き換え範囲の指定と文字列を指定 | |
textEdits.push(new FdtTextEdit(ec.currentLineOffset, ec.currentLine.length, "hoge")); | |
// 現在のファイルを Vector.<FdtTextEdit> の指定した分変更する | |
// 同時に複数の行も変更可能? | |
_bridge.model.fileDocumentModify(ec.currentFile, textEdits).sendTo(this, null); | |
} | |
public function fuga(id:String, ec:FdtEditorContext):void | |
{ | |
trace("fuga", id); | |
} | |
/** | |
* ActionPlugin だと特に使わない? | |
*/ | |
public function dialogClosed(dialogInstanceId:String, result:String):void | |
{ | |
trace("dialogClose"); | |
} | |
/** | |
* | |
*/ | |
public function setOptions(options:Dictionary):void | |
{ | |
trace("setOptions"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment