Android Studioの使用の過程で、含まれるプラグインの一部がプロジェクトの実際のニーズを満たすことができないことがわかりました。そのため、対応するプラグインを自分で開発し始めました。以下は私の開発プラグインプロセスの記録であり、引き続きあなたと共有します。
共有1:プロジェクトの作成メニューを右クリックします
1.プロジェクトウィザードに従って、デモプロジェクトを段階的に作成すると、もう紹介しません。この記事を参照できます//www.vevb.com/article/135535.htm
2。アクションを作成すると、プラグイン構成ファイルに表示されます
<action id = "firstaction" text = "firstaction" description = "右クリックaction"> <add-to-group-id = "projectviewpopupmenu" anchor = "after" relative-to-action = "fackinginpath"/> </action>
3。実行後、IDEは別のIDE(Genymotionに似た容器で包まれています)を開きます。効果が非常に馴染みがあるかどうかに依存します。はい、これは一般的に使用されるプロジェクトの右クリックメニューです。
4.トリガーされたファイルタイプに従って、アクションの隠された表示を動的に制御する
@Override public void Update(AnactionEvent Event){//このアクション文字列拡張子を非表示に表示= getFileExtension(event.getDatacontext()); this.getTemplatePresentation()。setEnabled(endix!= null && "jar" .equals(extension)); }完全なコード:
com.intellij.openapi.actionsystem。*; com.intellij.openapi.project.projectをインポートします。 com.intellij.openapi.ui.messagesをインポートします。 com.intellij.openapi.vfs.virtualfileをインポートします。 /*** 16/8/17にABCによって作成されました。 */ public class firstactionはAnactionを拡張します{private Project mproject; @Override public void ActionPerformed(anactionEvent event){mproject = event.getData(PlatformDatakeys.Project); dataContext dataContext = event.getDatacontext(); if( "jar" .equals(getFileExtension(dataContext))))){//拡張機能に基づいて次の処理を守る//選択したファイルvirtualfile file = datakeys.virtual_file.getData(event.getDatacontext()); if(file!= null){message.showmessageialog(mproject、file.getName()、 "select file"、messages.getInformationicon()); }}} @Override public void Update(AnactionEvent Event){//アクションが表示される前に、選択したファイル拡張子に基づいてこのアクションが表示されるかどうかを判断します。文字列拡張= getFileExtension(event.getDatacontext()); this.getTemplatePresentation()。setEnabled(endix!= null && "jar" .equals(extension)); } public static string getFileExtension(dataContext dataContext){virtualfile file = datakayys.virtual_file.getData(dataContext); file == nullを返しますか? null:file.getExtension(); }}上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。また、誰もがwulin.comをもっとサポートすることを願っています