how to prevent direct editing of a cell in property table

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

how to prevent direct editing of a cell in property table

Postby dpsmails » Mon Mar 12, 2007 10:46 pm

I have used my own cell editor for some property.
The value is displayed in the cell of the property table and besides this editable value, a drop down appears.
Now the value of the property can be changed by directly editing the cell and also via the drop down.
I dont want to allow the user to directly edit the contents of the cell.
i.e. user should be able to change the property only by using the editor, which comes through drop down.
If i set the editable attribute to false, drop down also disappears.
Please help!!
dpsmails
 
Posts: 7
Joined: Thu Jan 04, 2007 11:10 pm

Postby JIDE Support » Tue Mar 13, 2007 10:30 am

What is your own cell editor? In the case of cell editor based on AbstractComboBox orJComboBox, setEditable(false) will still allow user to click on the drop down button to show popup.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby dpsmails » Wed Mar 14, 2007 1:46 am

Thanks for the reply.
I have gone through my code again and checked if everything is fine.
Inspite of exteding AbstractComboBox, I am unalble to find the popup button if use Property.setEnabled(false).
I have found similar pice of code in examples (DirectionChooserDemo).

In following code, After I do property.setEditable(false) for "Direction 1" property (highlighted in bold), I am not getting the popup button.


/*
* @(#)CustomizePropertyPaneDemo.java 4/6/2005
*
* Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
*/

import com.jidesoft.converter.ConverterContext;
import com.jidesoft.converter.ObjectConverterManager;
import com.jidesoft.grid.*;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.utils.Lm;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;

/**
* Demoed Component: {@link com.jidesoft.grid.PropertyPane}, {@link com.jidesoft.grid.PropertyTable}
* <br>
* Required jar files: jide-common.jar, jide-grids.jar
* <br>
* Required L&F: Jide L&F extension required
*/
public class DirectionPropertyPaneDemo extends AbstractDemo {

private static PropertyTable _table;

public DirectionPropertyPaneDemo() {
CellEditorManager.registerEditor(Integer.class, new CellEditorFactory() {
public CellEditor create() {
return new DirectionCellEditor();
}
}, DirectionCellEditor.CONTEXT);
DirectionCellRenderer cellRenderer = new DirectionCellRenderer();
CellRendererManager.registerRenderer(Integer.class, cellRenderer, DirectionCellEditor.CONTEXT);
}

public String getDescription() {
return "This is a demo of creating a customized cell editor in PropertyTable. \n" +
"\n" +
"Demoed classes:\n" +
"com.jidesoft.grid.PropertyPane\n" +
"com.jidesoft.grid.PropertyTable\n" +
"com.jidesoft.grid.PropertyTableModel\n" +
"com.jidesoft.grid.Property\n" +
"com.jidesoft.grid.CellEditorManager\n" +
"com.jidesoft.grid.CellRendererManager\n" +
"com.jidesoft.converter.ObjectConverterManager";
}

public String getDemoFolder() {
return "G13. DirectionChooserDemo";
}

public String[] getDemoSource() {
return new String[]{"DirectionChooserDemo.java", "DirectionConverter.java", "DirectionChooserPanel.java", "DirectionComboBox.java", "DirectionSplitButton.java"};
}

public static void main(String[] args) {
LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
showAsFrame(new DirectionPropertyPaneDemo());
}

public String getName() {
return "PropertyPane Demo (Customized Cell Editor)";
}

public String getProduct() {
return PRODUCT_NAME_GRIDS;
}

public Component getDemoPanel() {
JPanel panel = new JPanel(new BorderLayout());
_table = createTable();
PropertyPane propertyPane = new PropertyPane(_table);
panel.add(propertyPane, BorderLayout.CENTER);
return panel;
}

// create property table
private PropertyTable createTable() {
ArrayList list = new ArrayList();

SampleProperty property = null;

property = new SampleProperty("Direction 1", "A direction cell editor.", Integer.class, "Direction");
property.setConverterContext(DirectionConverter.CONTEXT);
property.setEditorContext(DirectionCellEditor.CONTEXT);
property.setEditable(false);
list.add(property);

property = new SampleProperty("Direction 2", "A direction cell editor.", Integer.class, "Direction");
property.setConverterContext(DirectionConverter.CONTEXT);
property.setEditorContext(DirectionCellEditor.CONTEXT);
list.add(property);

PropertyTableModel model = new PropertyTableModel(list);
PropertyTable table = new PropertyTable(model);
table.expandFirstLevel();

return table;
}

static HashMap map = new HashMap();

static {
map.put("Direction 1", new Integer(SwingConstants.WEST));
map.put("Direction 2", new Integer(SwingConstants.EAST));
}

static class SampleProperty extends Property {
public SampleProperty(String name, String description, Class type, String category, ConverterContext context, java.util.List childProperties) {
super(name, description, type, category, context, childProperties);
}

public SampleProperty(String name, String description, Class type, String category, ConverterContext context) {
super(name, description, type, category, context);
}

public SampleProperty(String name, String description, Class type, String category) {
super(name, description, type, category);
}

public SampleProperty(String name, String description, Class type) {
super(name, description, type);
}

public SampleProperty(String name, String description) {
super(name, description);
}

public SampleProperty(String name) {
super(name);
}

public void setValue(Object value) {
if (Lm.PG_DEBUG) {
System.out.println("(BeanProperty) Set value " + ObjectConverterManager.toString(value) + " of type " + (value != null ? value.getClass().getName() : "null"));
}
map.put(getFullName(), value);
}

public Object getValue() {
Object value = map.get(getFullName());
if (Lm.PG_DEBUG) {
System.out.println("(BeanProperty) Get value " + ObjectConverterManager.toString(value));
}
return value;
}

public boolean hasValue() {
return map.get(getFullName()) != null;
}
}
}


I hope i am doing the right thing.. If not, please suggest how to accomplish this.
Thanks a lot,
Divakar.
dpsmails
 
Posts: 7
Joined: Thu Jan 04, 2007 11:10 pm

Postby JIDE Support » Wed Mar 14, 2007 7:52 am

I didn't know you set Property to editable(false). If a Property is not editable, it will of course not enter editing mode, not to mention the drop down button. What you need to do is to make Property still editable and call AbstractComboBox#setEditable(false). AbstractComboBox is the component of the cell editor.

Thanks,

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby dpsmails » Wed Mar 14, 2007 8:04 pm

Thanks a ton!
I got it working.
dpsmails
 
Posts: 7
Joined: Thu Jan 04, 2007 11:10 pm


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 12 guests