ToolWindow Help pls...

Hey gang, it's been a while since I wrote my last plugin and am looking for a bit of a refresher.

How can I read keyboard input from/in a ToolWindow and how can I dump text output back to my ToolWindow?

Don't need an entire code sample but if someone could point me in the right direction (code fragment) or APIs to look at I'd be very grateful.

Thanks much,

Happy

2 comments

Hi
SimpleToolWindow from plugin development bundle. getComponent gives you full control on any ToolWidnow interanl activities.

Dmitry.

0

Add a component to a tool window by first creating the data to be dispalyed in a table and add to a component ..see below
JTable jtable = new JTable(dataModel);
TableColumnModel tcm= jtable.getColumnModel();
for(int iCount=0;iCount<jtable.getColumnCount();iCount++)
{
TableColumn tc=tcm.getColumn(iCount);
if(iCount==0)
{
tc.setPreferredWidth(25);
}
else if(iCount==1 || iCount==3)
{

tc.setPreferredWidth(50);//370
}else
{
tc.setPreferredWidth(100);//370
}

}
jtable.repaint();
jtable.validate();

jtable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jtable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN );
jtable.setRowSelectionAllowed(true);
int currentSize = 15;
int currentStyle = Font.BOLD;
String currentFontName = "Arial";

Font font = new Font(currentFontName, currentStyle, currentSize);
jtable.getTableHeader().setFont(font);
jtable.setAutoscrolls(true);

JScrollPane component = new JScrollPane(jtable);
jtable.setPreferredScrollableViewportSize(new Dimension(500, 70));
component.setBackground(Color.white);
component.setBounds(50,50,500,500);
component.setFocusable(true);
component.setAutoscrolls(true);
component.setHorizontalScrollBar(new JScrollBar());
component.setEnabled(true);
component.setSize(100,100);

Now create a toolwindow and add this component to the toolWindow

CodeReviewerProjectComponent myProject = new CodeReviewerProjectComponent(currentProject);
ToolWindowManager newToolWindowMgr=ToolWindowManager.getInstance(currentProject);
newToolWindowMgr.registerToolWindow("NAME",component, ToolWindowAnchor.RIGHT);
ToolWindow newToolWindow = newToolWindowMgr.getToolWindow("NAME");
newToolWindow.setTitle(getCurrentOpenedFile(currentProject));
newToolWindow.setAnchor(ToolWindowAnchor.RIGHT,null);
newToolWindow.setAvailable(true,null);
newToolWindow.setType(ToolWindowType.DOCKED,null);

This will display the jTable in the toolwindow.

0

Please sign in to leave a comment.