AutoCompletionComboBox won't gain focus as a cell editor

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

AutoCompletionComboBox won't gain focus as a cell editor

Postby Hewlett » Tue Oct 02, 2012 5:10 am

How can I get AutoCompletionComboBox to automatically select it's editor text content when used within a table cell editor?

I've tried adding focus listeners to EVERYTHING, however none of them seem to fire...

Any suggestions?

This code doesn't have any logic for cell editor selection, however I have included it in the hope that someone can suggest something to make this Use Case work:

Code: Select all
import java.awt.BorderLayout;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import com.jidesoft.grid.JideTable;
import com.jidesoft.swing.AutoCompletionComboBox;

public class Tester {

  public static void main(String[] args) {
   
    String[] items = {"AAA", "BBB", "CCC", "DDD", "EEE"};
    AutoCompletionComboBox autoCompletionComboBox = new AutoCompletionComboBox(items);
    TableCellEditor cellEditor = new DefaultCellEditor(autoCompletionComboBox);   
    String[] columnNames = {"A", "B", "C"};
    DefaultTableModel tableModel = new DefaultTableModel(columnNames, 5);
    JideTable jTable = new JideTable(tableModel);
    jTable.getColumn("A").setCellEditor(cellEditor);
    jTable.setAutoStartCellEditing(true);
   
    /* TODO: Find a way to automatically select the auto completion combo box
     * text whenever the editor becomes active... */
   
    JFrame jFrame = new JFrame();
    JButton jButton = new JButton("I'm only here to gain focus");
    jFrame.add(BorderLayout.NORTH, jTable);
    jFrame.add(jButton);
    jFrame.setBounds(300, 200, 200, 100);
    jFrame.setVisible(true);
  }
}
Hewlett
 
Posts: 3
Joined: Wed Sep 22, 2010 6:33 pm

Re: AutoCompletionComboBox won't gain focus as a cell editor

Postby JIDE Support » Tue Oct 02, 2012 4:52 pm

Please give the modified test case a try.
Code: Select all
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.JTextComponent;

import com.jidesoft.combobox.ListExComboBox;
import com.jidesoft.grid.JideTable;
import com.jidesoft.grid.ListComboBoxCellEditor;
import com.jidesoft.swing.AutoCompletion;

public class Tester {

    public static void main(String[] args) {

        String[] items = {"AAA", "BBB", "CCC", "DDD", "EEE"};
        ListComboBoxCellEditor cellEditor = new ListComboBoxCellEditor(items){
            @Override
            protected ListExComboBox createListComboBox(ComboBoxModel model, Class<?> type) {
                ListExComboBox listComboBox = super.createListComboBox(model, type);
                listComboBox.setEditable(true);
                setupListComboBox(listComboBox);
                return listComboBox;
            }

            protected void setupListComboBox(ListExComboBox listComboBox) {
                Component editorComponent = listComboBox.getEditor().getEditorComponent();
                if (editorComponent instanceof JTextComponent) {
                    List<Object> list = new ArrayList<Object>();
                    for (int i = 0; i < listComboBox.getModel().getSize(); i++) {
                        Object object = listComboBox.getModel().getElementAt(i);
                        list.add(object);
                    }
                    new AutoCompletion(((JTextComponent) editorComponent), list);
                }
            }
        };
        String[] columnNames = {"A", "B", "C"};
        DefaultTableModel tableModel = new DefaultTableModel(columnNames, 5){
            @Override
            public Object getValueAt(int row, int column) {
                return super.getValueAt(row, column);
            }
        };
        JideTable jTable = new JideTable(tableModel);
        jTable.getColumn("A").setCellEditor(cellEditor);
        jTable.setAutoStartCellEditing(true);

        /* TODO: Find a way to automatically select the auto completion combo box
 * text whenever the editor becomes active... */

        JFrame jFrame = new JFrame();
        JButton jButton = new JButton("I'm only here to gain focus");
        jFrame.add(BorderLayout.NORTH, jTable);
        jFrame.add(jButton);
        jFrame.setBounds(300, 200, 200, 100);
        jFrame.setVisible(true);
    }
}


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

Re: AutoCompletionComboBox won't gain focus as a cell editor

Postby Hewlett » Thu Oct 04, 2012 5:38 pm

Hi Guys,

Thanks for the quick response. Unfortunately when I tried your code it didn't work.

Here is my Use Case:

  • Run, select the first column in the second row and select "CCC" from the list.
  • Select any cell in the first row.
  • Tab through the cells until the first column on the third row is selected.
  • Note that the combo box editor's content IS NOT SELECTED (the text content of the editor should be selected with the cursor flashing ready for input).
Any other suggestions because I'm really stuck and this is affecting the project schedule...
Hewlett
 
Posts: 3
Joined: Wed Sep 22, 2010 6:33 pm

Re: AutoCompletionComboBox won't gain focus as a cell editor

Postby JIDE Support » Fri Oct 05, 2012 9:52 am

For this specific issue, please invoke JideTable#setAlwaysRequestFocusForEditor(true) to alter the default behavior.

From my point of view, the issue you described is in the different area with the previous one you reported. The first issue you reported should have been addressed successfully with the test case I posted. I understand that everyone has pressure on his/her project, especially those tight-scheduled ones. In the meantime, I do appreciate your kindness and respect to my job.

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

Re: AutoCompletionComboBox won't gain focus as a cell editor

Postby Hewlett » Fri Oct 05, 2012 2:46 pm

Jide Admin,

I mean no disrespect, however the first line of my original post was:

How can I get AutoCompletionComboBox to automatically select it's editor text content when used within a table cell editor?

I don't understand the miscommunication because I believe that single sentence accurately describes my issue.

Perhaps you misread the issue? I understand we are all human...

...however I will need to give a progress update at my team meeting on Monday. I've continuously explored this issue but have been unable to get the Jide AutoCompletionComboBox to function as expected when used for table editing.

Can you please let me know if Jide Support no longer interested in this issue?
Hewlett
 
Posts: 3
Joined: Wed Sep 22, 2010 6:33 pm

Re: AutoCompletionComboBox won't gain focus as a cell editor

Postby JIDE Support » Fri Oct 05, 2012 2:59 pm

Will make AutoCompletionComboBox work as well in next regular release. I believe our first two posts were distracted by the editing stopped issue. Thanks for your patience.

The focus issue could be solved by JideTable#setAlwaysRequestFocusForEditor(true). The stand-alone test case is posted below FYI and the screencast is uploaded at http://screencast.com/t/b4GbXWkMdnCm just in case there is more miscommunication.
Code: Select all
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.JTextComponent;

import com.jidesoft.combobox.ListExComboBox;
import com.jidesoft.grid.JideTable;
import com.jidesoft.grid.ListComboBoxCellEditor;
import com.jidesoft.swing.AutoCompletion;

public class Tester {

    public static void main(String[] args) {

        String[] items = {"AAA", "BBB", "CCC", "DDD", "EEE"};
        ListComboBoxCellEditor cellEditor = new ListComboBoxCellEditor(items){
            @Override
            protected ListExComboBox createListComboBox(ComboBoxModel model, Class<?> type) {
                ListExComboBox listComboBox = super.createListComboBox(model, type);
                listComboBox.setEditable(true);
                setupListComboBox(listComboBox);
                return listComboBox;
            }

            protected void setupListComboBox(ListExComboBox listComboBox) {
                Component editorComponent = listComboBox.getEditor().getEditorComponent();
                if (editorComponent instanceof JTextComponent) {
                    List<Object> list = new ArrayList<Object>();
                    for (int i = 0; i < listComboBox.getModel().getSize(); i++) {
                        Object object = listComboBox.getModel().getElementAt(i);
                        list.add(object);
                    }
                    new AutoCompletion(((JTextComponent) editorComponent), list);
                }
            }
        };
        String[] columnNames = {"A", "B", "C"};
        DefaultTableModel tableModel = new DefaultTableModel(columnNames, 5){
            @Override
            public Object getValueAt(int row, int column) {
                return super.getValueAt(row, column);
            }
        };
        JideTable jTable = new JideTable(tableModel);
        jTable.getColumn("A").setCellEditor(cellEditor);
        jTable.setAutoStartCellEditing(true);
        jTable.setAlwaysRequestFocusForEditor(true);

        /* TODO: Find a way to automatically select the auto completion combo box
 * text whenever the editor becomes active... */

        JFrame jFrame = new JFrame();
        JButton jButton = new JButton("I'm only here to gain focus");
        jFrame.add(BorderLayout.NORTH, jTable);
        jFrame.add(jButton);
        jFrame.setBounds(300, 200, 200, 100);
        jFrame.setVisible(true);
    }
}

B.T.W., since the solution eventually needs JideTable, which is not a component inside the open source project, this post will be moved to the "Pre-sale support" forum.

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

Re: AutoCompletionComboBox won't gain focus as a cell editor

Postby JIDE Support » Tue Oct 16, 2012 5:35 pm

Just so you know, this is fixed in 3.4.8 just released.

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


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 7 guests