Plugin Development Questions

So in learning how to write IDEA plugins, I ended up with a few questions I
could not find answers to in either docs, posts or other plugin sources..
So I will ask them in one go and then add response to the WiKi

1. If I have a ToolWindow plugin how do I create and action that can make
the toolwindow visible (I did figure this out) but get the toolwindow to
run an operation once it is made visible

2. Can I define Actions that will appear in the toolbar but ALSO be used
inside a ToolWindow

3. Style Question: When building plugins that are say ToolWindows's but also
have a Configurable panel for the Project Properties, what is the prefered
implementation.. Once plugin that implement all the interfaces (inclduing
JDOMExternalizable and Configurable)

M

0

I think I can answer a couple.

Mark Lussier wrote:


2. Can I define Actions that will appear in the toolbar but ALSO be used
inside a ToolWindow


Well, a single action can be in multiple different menus, groups,
toolbars, etc.
The ActionPlace will usually be enough of a hint as to where it is being
invoked from.
It is not a requirement that an action have only one "parent".
But there should only be one instance of an action created (as in
"new SomeAction()") if you are doing it programmatically. In
Plugin.xml you define the action once and then add multiple references
to it.


3. Style Question: When building plugins that are say ToolWindows's but also
have a Configurable panel for the Project Properties, what is the prefered
implementation.. Once plugin that implement all the interfaces (inclduing
JDOMExternalizable and Configurable)


Well, definitely one plugin. If you are asking if one class should
implement multiple interfaces... the usual principle for programming in
general is to be modular, but it depends on the situation. I wrote a
VCS plugin where one class implements both ProjectComponent and
AbstractVcs (well, also JDomExternalizable) because it just seemed to
work for me.


M



--

Erb

==============================================================
"The only time I like in the morning is afternoon."
- Russell D. Cooper

"If you do everything, then you're all done."
- Melissa F. Cooper

"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

0

Erb wrote:

Well, definitely one plugin. If you are asking if one class should
implement multiple interfaces...


I was asking purely from a plugin standpoint (not general CS). ie: the clean
way to build plugins with various facets (toolwindows, actions,
configuration, etc)

I had done it all in one class (as opposed to multiple project components)

m

0

I'm not about to make any sort of claims that I did things the "right" way,
but if you want some code to look at, check out the Workspaces and
ToolbarManager plugins:

http://www.intellij.org/twiki/bin/view/Main/WorkspacesPlugin
http://www.intellij.org/twiki/bin/view/Main/ToolbarManager

2. Can I define Actions that will appear in the toolbar but ALSO be used
inside a ToolWindow


As Erb said, yes. The Workspaces plugin has a couple actions (e.g. "Close
All Workspaces") that appear in both the main menu and in a popup menu
(which appears upon right-clicking an item in the tool window). There are
also some actions that appear in the tool window as a button and also in the
right-click menu (and you'll see how I make use of ActionPlaces to determine
whether or not to show an icon in the presentation).

3. Style Question: When building plugins that are say ToolWindows's but

also

have a Configurable panel for the Project Properties, what is the prefered
implementation.. Once plugin that implement all the interfaces (inclduing
JDOMExternalizable and Configurable)


The Workspaces plugin has a tool window and also a configurable panel. It's
a bit different in that there are both application and project components,
but it's at least some code to look at.

Again, though, I'm not promising correctness, but rather just one approach
that works. :D

chris

"Mark Lussier" <mark@ironhide.com> wrote in message
news:aqp6r7$37l$2@is.intellij.net...

Erb wrote:

>

Well, definitely one plugin. If you are asking if one class should
implement multiple interfaces...

>

I was asking purely from a plugin standpoint (not general CS). ie: the

clean

way to build plugins with various facets (toolwindows, actions,
configuration, etc)

>

I had done it all in one class (as opposed to multiple project components)

>

m



0

请先登录再写评论。