I'd like the ability to extend the SidekickCompletionPopup class so that I can display
additional information about the completion, as in the screenshot attached (from eclipse).
It can be done in many ways, here one possible implementation: the SidekickParser
could have a getCompletionPopup class like this:
public CompletionPopup getCompletionPopup( View view, int caretPosition, SideKickCompletion
complete, boolean active){
return new SideKickCompletionPopup(view, this,
caretPosition, complete, active){
/** forget reference to this popup when it is disposed */
public void dispose()
{
super.dispose();
popup = null;
}
};
}
}
Submitted | rfrancois - 2009-04-02 - 08:30:40z | Assigned | nobody |
---|---|---|---|
Priority | 5 | Category | None |
Status | Open | Group | None |
Resolution | None | Visibility | No |
2009-04-02 - 08:38:47z rfrancois |
Sorry, I pressed "Add artifact" too soon. AFAICS, the only place where a CompletionPopup is created in sidekick is in the SidekickActions class, so the call : popup = new SideKickCompletionPopup(view, parser, textArea.getCaretPosition(), complete, active) { /** forget reference to this popup when it is disposed */ public void dispose() { super.dispose(); popup = null; } }; coulld be replaced by : popup = parser.getCompletionPopup( view, extArea.getCaretPosition(), complete, active) ; |
---|---|
2009-04-02 - 12:59:28z rfrancois |
With the proposed "design", I've achieved the Screenshot attached by extending slightly
the SideKickCompletionPopup associated with my parser. I would be happy to send a
formal patch if needed. The component on the right is a JEditorPane that shows an html page, but we could imagine other things, such as for example a jedit text area showing the surroundings of where the current variable is created, ... |
2009-04-02 - 13:49:44z shlomy |
How did you achieve that? Did you create your own Candidates implementation and use the renderer to find the selected item? |
2009-04-02 - 14:04:25z rfrancois |
Almost. Sidekick defines the Candidates interface as a private class within SidekickCompletion,
so there is a little I can do with it from outside, but I took inspiration from this
approach. However, the SideKickCompletion class offers the possibility to override the getRenderer method, responsible to render __one__ completion, I believe this is passed to the Candidates interface eventually. So you write a custom renderer (in my case using a JTable as the component): see this (http://www.velocityreviews.com/forums/t149702-jtable-in-jcombobox.html) for example. My getListCellRendererComponent method looks like this: public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { // update the editor pane here } } For the component that extends SidekickCompletionPopup, I took your TagCompletionPopup (in CtagsInterface) as a starting point, and did something like this in the constructor { super( view, parser, caret, complete, active ) ; editor = new JEditorPane( "text/plain", "" ) ; editor.setSize( 400, editor.getFontMetrics(editor.getFont()).getHeight() * Math.max(10, complete.size() + 2) ) ; Container left = getContentPane(); JPanel p = new JPanel( new VariableGridLayout(VariableGridLayout.FIXED_NUM_ROWS, 1) ); p.add(left ); JScrollPane pane = new JScrollPane(editor) ; p.add(pane); setContentPane(p); } |
2009-04-02 - 08:30:40z rfrancois |
Screenshot.png |
---|---|
2009-04-02 - 12:54:58z rfrancois |
Screenshot-2.png |
2009-04-02 - 19:06:18z rfrancois |
sidekick.diff |