Upgrade to Pro — share decks privately, control downloads, hide ads and more …

IntelliJ Plugin 開発で実装したこと

IntelliJ Plugin 開発で実装したこと

IntelliJ Plugin開発をしている中で学んだことをまとめました

Takahiro Shimokawa

September 15, 2015
Tweet

More Decks by Takahiro Shimokawa

Other Decks in Programming

Transcript

  1. ToolWindow)*)extensions plugin.xml <idea-plugin version="2"> <extensions defaultExtensionNs="com.intellij"> <!-- Add your extensions

    here --> <toolWindow anchor="right" canCloseContents="true" id="DrawableViewer" factoryClass="xxx.AndroidDrawableViewerToolWindowFactory" /> ... </extensions> ...
  2. ToolWindow)*)ToolWindowFactory AndroidDrawableViewerToolWindowFactory public class AndroidDrawableViewerToolWindowFactory implements ToolWindowFactory { @Override public

    void createToolWindowContent(Project project, ToolWindow toolWindow) { DrawableViewer viewer = new DrawableViewer(project); final ContentManager contentManager = toolWindow.getContentManager(); final Content content = contentManager.getFactory().createContent(viewer, null, false); contentManager.addContent(content); } }
  3. ToolWindow)*)SimpleToolWindowPanel DrawableViewer public class DrawableViewer extends SimpleToolWindowPanel implements ActionListener {

    public DrawableViewer(final Project project) { super(true, true); ... setToolbar(createToolbarPanel()); setContent(createContentPanel()); } ...
  4. ToolWindow)*)setToolbar(JComponent) private JComponent createToolbarPanel() { final DefaultActionGroup actionGroup = new

    DefaultActionGroup(); actionGroup.add(new EditTargetResDirAction()); final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar( "AndroidDrawableViewer", actionGroup, true); return actionToolbar.getComponent(); }
  5. ToolWindow)*)refresh? Se#ngsDialog @Override protected void doOKAction() { super.doOKAction(); ... resetContent(project);

    } private void resetContent(Project project) { DrawableViewer drawableViewer = new DrawableViewer(project); ContentManager contentManager = ToolWindowManager.getInstance(project) .getToolWindow(Constants.TOOL_WINDOW_ID).getContentManager(); Content content = contentManager.getFactory().createContent(drawableViewer, null, false); contentManager.removeAllContents(true); contentManager.addContent(content); } ...