Attached is some test code that doesn't invoke an editor from a double click. All my code uses a database as the data source so I didn't know what to do other than use JSON table data. Hopefully that isn't stopping the editor from being invoked in this case. I have implemented a basic row editor just to see if it is being called, which it isn't.
I haven't updated from SVN for a couple of days. On Tue, 8 Sep 2009 11:47:11 am Todd Volkert wrote: > I know the table view's select mode must *not* beTableView.SelectMode.NONE. > Other than that, it should work out of the box. If it still doesn't work, > can you post a simple test case so we can have a look? > > Oh, one other thing that should have been in the previous email: > TableViewRowEditor uses data binding to populate the individual cell editor > components. It defaults them all to text inputs and sets their text key to > the column name. But you can change any cell's editor by putting the > desired editor component into the cell editors dictionary > (TableViewRowEditor.getCellEditors()). It's then your responsibility to > set that component's bind key so it gets populated correctly when the > editor opens. This is done in the row editor demo. > > Thanks, > -T > > On Mon, Sep 7, 2009 at 9:14 PM, Scott Lanham <[email protected]> wrote: > > Thanks Todd thats excellent. > > > > I can't get the TableView to go into edit mode using double click. I have > > set > > rowEditor with a TableViewRowEditor but nothing happens. Do I need to set > > a property somewhere to get it to work? > > > > On Tue, 8 Sep 2009 11:00:39 am Todd Volkert wrote: > > > Yep - this type of behavior is supported via the TableView.RowEditor > > > interface. There are two stock editors available for you to use, or > > > you can implement your own. The two stock ones are > > > org.apache.pivot.wtk.content.TableViewRowEditor and > > > org.apache.pivot.wtk.content.TableViewCellEditor. > > > > > > This isn't covered in the tutorials yet, so I'll do my best to describe > > > > how > > > > > it works here... > > > > > > You set a row editor on a table view using TableView.setRowEditor(). > > > > When > > > > > a row editor has been set, the table view's skin will respond to "edit > > > gestures" by invoking the edit() method of the editor. Right now, the > > > > skin > > > > > responds to a double-click on the row. Once the editor has been called > > > > to > > > > > edit, it is responsible for knowing when it should save() or cancel(). > > > Note that you can register key press listeners on the table view and > > > call into the editor yourself if you want keyboard gestures to invoke > > > the > > > > editor > > > > > as well. > > > > > > Now as to what the editor does behind the scenes... > > > > > > The table view isn't a container, so it can't contain list buttons or > > > the like -- and renderer's don't receive input. So generally, editors > > > will open a popup over an individual cell or the entire row that makes > > > it look like the content of the row changed to input components. Then > > > when the user finishes their edit, the editor closes the popup and > > > updates the > > > > model > > > > > of the table view (tableView.getTableData().update(...)). > > > > > > The stock TableViewRowEditor opens a popup over the entire row in which > > > > the > > > > > user can edit all the cells before saving. Each cell's editor > > > component > > > > is > > > > > configurable (you can use a ListButton in one, a Spinner in another, > > > > etc.). > > > > > In fact, you can even set up some cells to use Labels (or disabled > > > TextInputs) if you don't want them to be editable. You can see an > > > > example > > > > > of this editor in action by running the table view row editor demo > > > (org.apache.pivot.demos.roweditor.RowEditorDemo). > > > > > > The stock TableViewCellEditor opens a popup over an individual cell, > > > and that popup always contains a TextInput. It's not as versatile as > > > TableViewRowEditor, but it's lighter and satisfies the common use case > > > of simple TextInput-based edits. > > > > > > If neither of these satisfied your needs and you had to write your own, > > > > I'd > > > > > study the two stock editors, because a lot of what you'd have to do > > > would be copy/paste from them :) > > > > > > Let me know if you have any more questions, > > > -T > > > > > > On Mon, Sep 7, 2009 at 8:37 PM, Scott Lanham <[email protected]> wrote: > > > > Hi, > > > > > > > > I am getting a little lost in how to do in place editing in a > > > > TableView. > > > > > > When > > > > a row is selected I need a ListButton to appear in some of the cells > > > > in place > > > > of the text that was being displayed. The ListButton is used to edit > > > > the > > > > > > cell. > > > > Is this possible? > > > > > > > > Thanks, > > > > > > > > Scott.
package calvinoFranchisee;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.TableView;
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtkx.WTKXSerializer;
public class testing implements Application
{
private Window appWindow = null;
private TableView view = null;
public static void main(String[] args)
{
DesktopApplicationContext.main( testing.class, args );
}
public void startup( Display display, Map<String, String> properties ) throws Exception
{
WTKXSerializer serial = new WTKXSerializer();
appWindow = (Window) serial.readObject( this, "testing.xml" );
view = (TableView) serial.get( "view" );
view.setRowEditor( new testRowEditor() );
appWindow.open(display);
}
public boolean shutdown( boolean optional ) throws Exception
{
if ( appWindow != null )
appWindow.close();
return false;
}
public void suspend() throws Exception
{
}
public void resume() throws Exception
{
}
}
testing.xml
Description: XML document
package calvinoFranchisee;
import org.apache.pivot.wtk.TableView;
public class testRowEditor implements TableView.RowEditor
{
public void edit( TableView arg0, int arg1, int arg2 )
{
throw new UnsupportedOperationException( "Not supported yet." );
}
public boolean isEditing()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
public void save()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
public void cancel()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
}
