ryanqq / macwidgets

Automatically exported from code.google.com/p/macwidgets
0 stars 0 forks source link

Inline Edit Mode for SourceList #40

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've an idea for a cool enhancement.
(In fact this is missing in our app so far)

Is it possible to inline edit items in SourceList?

Like it works in iTunes... see screenshot attached.

Best,
Peter

Original issue reported on code.google.com by studp...@gmail.com on 30 Dec 2008 at 8:51

Attachments:

GoogleCodeExporter commented 9 years ago
Not yet, but this is a good idea.

Original comment by kenneth....@gmail.com on 31 Dec 2008 at 12:19

GoogleCodeExporter commented 9 years ago
You can edit items inline with just the SourceListTreeUI, but it doesn't quite 
work the way you expect it to work, because the 
indentation (corresponding to the the treepath depth) is missing.
This is caused by the way public Rectangle getPathBounds(JTree tree, TreePath 
path) is overwritten in SourceListTreeUI... the same 
Rectangle that is returned by this method is also used to figure out where to 
place the EditorComponent. The way it's overwritten, the 
component is always set to x=0.

You can hack around this problem by doing something like:

public class MyTreeCellEditor extends DefaultTreeCellEditor {

// I left some stuff out here...
// get editing path and icon from isCellEditable(event) call
// use icon in determineOffset(..) to get the offset right
[...]

    protected Container createContainer() {
        return new MacWidgetsEditingContainer();
    }

    private class MacWidgetsEditingContainer extends EditorContainer {

        public void setBounds(final int x, final int y, final int width, final int height) {
            final SourceListTreeUI treeUI = (SourceListTreeUI) tree.getUI();
            int realX = (treeUI.getLeftChildIndent() + treeUI.getRightChildIndent()) * (editingPath.getPath().length - 1);   
            super.setBounds(realX, y, width, height);
        }
    }
}

However, this is certainly not the way this should be done. Really hope that 
there will be a decent enhancement at some point.

Thanks.

Original comment by hendrik....@gmail.com on 7 Apr 2010 at 11:03