Dacf; gridcontrol cell; put edits

To put all those discussion into a practical example and question...
I have a dacf grid control. The user can edit a part number ( 1 of 350,000 possible.. no list boxes ) that is one of the columns. I want to make sure that part number is valid via a lookup in the database..immediately on entry into the cell and pressing tab and return... if bad, I want to blank the cell and leave him/her in it.. and put an error message (NOT a error dialog) at the bottom of the screen in the status line.
How does one go about this?
Some options I see:
1. If I were a Java pro.. probably do something with a custom cell editor attached to the underlying tablemodel?
2. If I were a beginning BC4J person.. maybe put it in the EO setr with a exception event handler that somehow does the work. ( HOW? Where? I'm missing the conceptual links to accomplish this task... or comprehensive yet simple code examples)
3. If I were a little more involved with BC4J.. set up a DOMAIN with the the validation, set up the EO attribute on the domain... and follow through with 2 above???
4. If I were a traditional Oracle developer with little Java experience. Uh. Well, I'm fairly lost until I've had about 6 months of experience, 5 training classes.. read through several Java manuals, read more class docs than I cared to... and disjoint Help pages ( making the linkages myself ).
This is a very simple, common and necessary task in any UI... validating the entered value in a dacf gridcontrol cell at time of entry.
What is the BEST way to approach this? Does anyone have code examples?

Thanks for the code fragment Sathish... as always you have a practical direct solution.
I will try to implement a domain, an EO attribute on the domain, and your rowsetInfo (?) attributeInfo validationListener to see if I can make it hang together and work.
grin We're getting to the crux of a lot of the issues I have!
I suppose I missed this concept completely in the classes ( I heard and can find the pieces, but not how to use them to create a total end to end solution )... AND missed it completely in the documentation as an end to end solution? ( Show a person a clutch, a brake pad, a piston rod and a gallon of gas... it doesn't mean they know how to build a car from scratch! )
But my belief is that just about everyone outside of Oracle and those having direct contact with Oracle, or discovering this through this board... well... they are just floundering when they need the solution.
And really, I'd want most of my validation back at the DOMAIN level ( since it something like an SSN format check, or a valid part number check... is related to the DOMAIN..and global to everything, even supra-application module? I.E. Rule 1: protect database data integrity. ) to be picked up by the EO, and used by the the component, right? And all of this will happen at data entry, not commit, of course ( unless as Steve says, there are cross-attribute within the same row or rowset constraints )
Confusion ( on my part? ) is that if I put a ValidationListener on the attributeInfo that is it at the "wrong level" ( way, way up the food chain ), again? Or will this cleanly trap rules placed in the EOImpl setr.. and the Domain rules, as well, at time of entry?
Yet you are correct in that if I don't want some generic ERROR dialog box to pop up... I'd need something like the ValidationListener to "take control" and do what I want... is that correct?
Also, the validation Listener fires even when I'm setting the value programmatically directly from another table's value... even if I know for sure that the value is valid?
( Remember that I may be checking in a before insert trigger anyway since I'm protecting data integrity no matter what the source ).
One of the interesting effects I'm encountering in building the App is items like this... that EventListeners Fire seem to fire indiscriminatly... and I have to code the critter REAL careful to put in global flags or prechecks to tell it "NO, don't do it" so as to keep up the response time... and also that the Listener would need special code and custom properties on the UI component set up ( like "allow wildcard" ) that will affect the listener validation code.... uh... which in a generic listener requires more and more specialized exception code.
I.E. generic is starting to == slow and cumbersome and hard to set up, specialized == fast and efficient and easy to code and debug. This would not matter ( generic and slow is MSFT's design approach in most cases ) if not for the fact that actual user response time is a reality, and the JVM running on a <800mhz cpu with lots of databse access really does start to bog down.
Thanks
null

Similar Messages

  • How to disable/enable the cells for editing column wise in JTable in java?

    Hi All,
    Can any one tell me how to disable the cells for editing by column wise in JTable?
    Here depending upon the radio button selected, I need 2 disable some columns for editing
    and enable some columns for editing?
    how can I do tat using JAVA?
    Any sample code is of great help to me.
    Thanks in Advance

    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    ~

  • Protect the cell from editing (MS Project)

    is it possible to protect the cell from editing (Gantt Chart view)? 
    I try to do it through the event Application_ProjectBeforeTaskChange and setting Cancel to true 
    which method is called when the edit cell and press the ESC?

    Hi,
    Thanks for posting in MSDN forum.
    This forum is for developers discussing issues about
    apps for Office. Since the issue is more relative to Project developing, I would like to move it to
    Project Customization and Programming forum to get more effective response.
    Thanks for your understanding.
    Best regards
    Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Sales order(out put edit)

    dear all,
    hi, i would like to know about the out put edit in a sales order, after giving ba00(order confirmation), then i went for comunication method - its given as LPO1,
    but i wanted to give it as LOC1 and save the order.
    but after giving the LOC1 and after pressing on enter button, i got a caution device LOC1 doesn't exist.
    what i have to do to procced  further on, if some one knows about this do let me know.
    Regards,
    sushmitha.

    Hi,
    Are you using output determination or you are entering manually the output type BA00 in the sales order ?
    If you are entering manually the output type BA00 in the sales order than you should just go to "Communication method" button and select what printer you like. At this moment the save button is not active; you should press back and after that "Save".
    If you are using output determination and the BA00 output type is coming automatically in your sales order (if wrong printer) than check in transaction VV12 for output type BA00 what conditions are maintained and here you have to change the default printer.
    Regards,
    Valentin

  • I want to break up my hour long video in iMovie 11 into smaller 15 minute segements to upload to youtube. How can i put EDITED VIDEO in new projects in iMovie?

    I want to break up my hour long video in iMovie 11 into smaller 15 minute segements to upload to youtube. How can i put EDITED VIDEO in new projects in iMovie? (each 15 minute segment to iMovie)

    In iMovie's Project Library view (where all your projects are listed), click on the name of your project (don't double-click to open it, just single click to highlight it).
    From the Menu select File > Duplicate Project. A copy of your project will be placed in the Project Library. It will have the same name as the original, but with a number appended. You can rename it if desired - click on its name twice (not double-click) so that it is highlighted as light blue, then over-type it.
    Delete from the duplicate all the clips and other media (for example, photos, music and so forth) that you don't want included in the first of your 15 minute segments. In other words, delete all but the first 15 minutes.
    Continue creating duplicates of the original (and rename if necessary). Delete from each duplicate all the unrequired parts for each segment. So, for example, for the 2nd duplicate delete the first quarter (15 minutes) and the 3rd and 4th quarters.
    You should end up with 4 duplicates with separate names, each containing the required segment. You will also have kept intact the original one hour movie, which you may wish to use independently of YouTube (maybe for burning a DVD or playback through a Media Player).
    Note that duplicating the original project will not take up much extra space on your drive. Projects reference (link to) the associated Event (or Events) in the Event Library - they don't actually contain video as such. The project file also keeps track of titles, transitions, effects, music and so forth that you've added to the project.
    John
    Message was edited by: John Cogdell

  • Must double click JTable cell to edit - Why?

    Hi there,
    I have a custom JTable model, which overrides the isCellEditable method and returns true for the first column. All nice, only that column now gets editable - but why do I have to double click in the cell to be able to edit in it? I've seen swing gui's where the cell gets editable on single click/focus...
    Very thankful for any help in resolving this!
    Best regard,
    AC

    Add a mouselistener to your table and in the mousePressed() method set the editing cell:
    table.editCellAt(row, column);
    table.setEditingRow(row);
    table.setEditingColumn(column);
    table.repaint();

  • What's the quickest way to put edit points around a selection?

    In the timeline (TL) I have made a selection inside a clip (using the Range Selection tool):
    What is the quickest way to make this selection a separate clip (as below)?:
    PS Saying 'put edit points around' and 'make separate clip', I guess are always the same thing, so I have mixed my terms!?
    PS I have currently been using: CMD + X, CMD + V, but this is a hack, not a method, so there has to be a way, right?

    Thanks to you all for quick replies, especially Andy for quickly understanding me.
    Yup, I used the Range Selection tool. It's a great tool, when for e.g. you want to lift ambient room tone from a portion of an audio clip to paste elsewhere.
    Anyway, I am just experimenting thoroughly with all the tools and workflows, to find quickest ways of doing things. To answer your question(s): an example in which you would want to do what I mention above is if you wanted to quickly apply particular Effects/Parameters/Settings to a portion of a clip, like a sepia tint, and wanted to be able to easily click back to that portion later,  see e.g. below:
    Thanks again

  • JTable cell being edited after model changed.

    I have a fairly simple JTable, with a implementation of AbstractTableModel supplying the data. The cells are edited by using a JComboBox. I wrap these into a DefaultCellEditor. I have a KeyListener attached to the JTable listening for VK_DELETE, and when it finds one, instructs the model to delete the row represented by the selected row in the table.
    Everything works fine until I want to delete a row from the table. My scenario is:
    - I click in a cell, and the editor opens.
    - I select an entry in the list. The editor closes, the result is rendered, and the wee yellow box around the cell is shown
    - I hit the delete key.
    - My key listener picks up the event, and informs the model to delete the row. I remove the row from the model and invoke fireTableDataChanged().
    The result is that the row is deleted, but the table ends up with the cell editor deployed on the cell of the row below (which is now at the same row as the one I just deleted).
    My tracing shows that the isCellEditable is called on the model after the delete. I don't know why.
    Can anyone explain how to prevent this or what might be causing the table to think that the cell needs editing?
    Thanks, Andrew

    It will do whatever is the default. I wrap the JComboBox in a DefaultCellEditor. I can't see how the editor is involved at this point, or why the editor becomes involved after the row has been deleted.
    Remember, at the time that I hit the delete key, there is no editor rendered or visible. I have the JTable displayed, a row selected, and the yellow box around one of the (editable but not currently being edited) cells. This has been achieved by editing a cell (displaying the cell editor - a combo box) and selecting an entry. The editor is removed, and the cell displayed with the (default) cell renderer for the table.
    The delete action is caught by the listener on the table, the model is instructed to delete a row from its underlying data, which fires a fireTableDataChanged event.
    That is all I do. After that it is all swing. The table model starts getting asked about cells being editable after I have finished deleting the row. I'll post the relevant code below if that helps.
    The datamodel is of class ConstraintTableModel (see below) and the column model is of class DefaultTableColumnModel
    JTable table = new JTable( dataModel, columnModel );The column model is defined liike so:
    columnModel = new DefaultTableColumnModel();
    TableColumn labelColumn = new TableColumn(ConstraintTableModel.LABEL_COLUMN);
    labelColumn.setHeaderValue( dataModel.getColumnName(ConstraintTableModel.LABEL_COLUMN));
    labelColumn.setPreferredWidth( 5 );
    labelColumn.setMaxWidth( 5 );
    labelColumn.setResizable( false );
    TableColumn taskColumn = new TableColumn(ConstraintTableModel.TASK_COLUMN);
    taskColumn.setHeaderValue( dataModel.getColumnName(ConstraintTableModel.TASK_COLUMN));
    TableColumn typeColumn = new TableColumn(ConstraintTableModel.TYPE_COLUMN);
    typeColumn.setHeaderValue( dataModel.getColumnName(ConstraintTableModel.TYPE_COLUMN));
    columnModel.addColumn( labelColumn );
    columnModel.addColumn( taskColumn );
    columnModel.addColumn( typeColumn );I add the key listener like so:
    table.addKeyListener( new KeyAdapter()
        public void keyPressed( KeyEvent e )
          if( e.getKeyCode() == KeyEvent.VK_DELETE )
            log.debug("Delete pressed in listener attached to table ");
            JTable t = (JTable) e.getSource();
            int selectedRow = t.getSelectedRow();
            if( selectedRow >= 0 )
              log.debug("  Removing row " + selectedRow);
              ((ConstraintTableModel)t.getModel()).removeRow(selectedRow);
            log.debug("Finished with key press");
      } );The cell editor is created like this:
    JComboBox taskEditorComponent = new JComboBox( tasksModel );
    taskEditorComponent.setFont( GanttChart.tableFont );
    taskEditorComponent.setBackground( Color.WHITE );
    DefaultCellEditor taskEditor = new DefaultCellEditor(taskEditorComponent);
    taskEditor.setClickCountToStart( 1 );
    table.setDefaultEditor( GanttTask.class, taskEditor );The model is coded like so:
    class ConstraintTableModel extends AbstractTableModel
        // Constants
        public static final int LABEL_COLUMN = 0;
        public static final int TASK_COLUMN = 1;
        public static final int TYPE_COLUMN = 2;
        private Vector          columnNames;
        private ArrayList       dataRows;
        public ConstraintTableModel()
            super();
            this.buildDataVector();
            this.addPrimerRow();
         * Every row in the table is a GanttConstraint. Therefore when deciding what to
         * display in any particular column of the table, we need to determine what the
         * column is, and then use the informatino in the GanttConstraint to go out to the
         * lookup and get the relevant object, and value to display.
        public Object getValueAt( int row, int col )
            Object          returnObject = "";
            GanttConstraint aConstraint = (GanttConstraint) this.getDataRows().get( row );
            // We're rendering the task column. If there's no task id (partially filled in row)
            // return blank otherwise return the master task
            else if( col == ConstraintTableModel.TASK_COLUMN )
                if( aConstraint.getMasterId() != null )
                    GanttTask masterTask = (GanttTask) real.getLookup().get( aConstraint.getMasterId() );
                    returnObject = masterTask;
            // We're rendering the type column. If there's no type (partially filled in row)
            // return blank otherwise return the constraint type
            else if( col == ConstraintTableModel.TYPE_COLUMN )
                if( aConstraint.getType() != null )
                    GanttConstraintType constraintType = (GanttConstraintType) GanttConstraintType.getConstraintTypes()
                                                                                                     .get( aConstraint.getType()
                                                                                                                      .intValue() );
                    returnObject = constraintType;
            return returnObject;
         * When we receive this message, we are handed an object of the type specified in
         * getColumnClass. We need to take this object and place the relevant information into
         * the GanttConstraint row in the table model.
         * Depending on whether the row being modified is an existing row or a new row, set
         * the state of the constraint appropriately.
         * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
        public void setValueAt( Object value, int row, int col )
            log.debug( "+setValueAt (row/col) " + row + "/" + col );
            if ( value == null )
                log.debug( "  handed a null value. Returning" );
                return;
            GanttConstraint aConstraint = (GanttConstraint) this.getDataRows().get( row );
            // If we are modifying the primer row, add another primer row.
            if( row == ( this.getRowCount() - 1 ) ) // Last row is always the primer
                log.debug( "  adding a primer row" );
                this.addPrimerRow();
            // We're modifying the Task data. Get the GanttTask handed to us and place it
            // into the master slot in the constraint.
            if( col == ConstraintTableModel.TASK_COLUMN ) // Task
                log.debug( "  updating the master task" );
                GanttTask selectedTask = (GanttTask) value;
                aConstraint.setMaster( selectedTask );
            // We're modifying the Type data. Get the GanttConstraintType handed to us and place it
            // into the type slot in the constraint.
            if( col == ConstraintTableModel.TYPE_COLUMN ) // Constraint type
                log.debug( "  updating the constraint type" );
                GanttConstraintType selectedConstraintType = (GanttConstraintType) value;
                aConstraint.setType( selectedConstraintType.getType() );
            log.debug( "-setValueAt" );
        public Class getColumnClass( int col )
            Class columnClass = super.getColumnClass( col );
            if( col == ConstraintTableModel.LABEL_COLUMN )
                columnClass = String.class;
            if( col == ConstraintTableModel.TASK_COLUMN )
                columnClass = GanttTask.class;
            if( col == ConstraintTableModel.TYPE_COLUMN )
                columnClass = GanttConstraintType.class;
            return columnClass;
        // We are handing the data storage
        public void setDataRows( ArrayList dataRows )
            this.dataRows = dataRows;
        public boolean isCellEditable( int row, int col )
            log.debug( "+isCellEditable (row/col) " + row + "/" + col );
            if( !real.canEdit() )
                return false;
            if( ( col == ConstraintTableModel.TASK_COLUMN ) ||
                    ( col == ConstraintTableModel.TYPE_COLUMN ) )
                return true;
            else
                return false;
        // We are handing the data storage
        public ArrayList getDataRows()
            return this.dataRows;
        public String getColumnName( int column )
            return (String) this.getColumnNames().get( column );
         * Clean up rows that do not have both the master task and type set. Not interested in them
        public void removeDirtyRows()
            log.debug( "+removeDirtyRows" );
            Iterator dataIterator = this.getDataRows().iterator();
            while( dataIterator.hasNext() )
                GanttConstraint element = (GanttConstraint) dataIterator.next();
                if( ( element.getMasterId() == null ) || ( element.getType() == null ) )
                    element.setTransient();
                    dataIterator.remove();
            fireTableDataChanged();
            log.debug( "-removeDirtyRows" );
        public void removeRow( int row )
            log.debug( "+removeRow(" + row + ")" );
            if( row < this.getDataRows().size() )
                GanttConstraint aConstraint = (GanttConstraint) this.getDataRows().get( row );
                this.getDataRows().remove( row );
                if( aConstraint.isClone() )
                    aConstraint.setDeleted();
                else
                    aConstraint.setTransient();
                    getClone().removeConstraint( aConstraint );
                fireTableDataChanged();
            if( this.getRowCount() == 0 )
                this.addPrimerRow();
            log.debug( "-removeRow" );
        public void clearRow( int row )
            log.debug( "+clearRow(" + row + ")" );
            if( row < this.getDataRows().size() )
                GanttConstraint aConstraint = (GanttConstraint) this.getDataRows().get( row );
                aConstraint.setMasterId( null );
                aConstraint.setType( null );
                fireTableRowsUpdated( row, row );
            log.debug( "-clearRow" );
        public int getColumnCount()
            return getColumnNames().size();
        public int getRowCount()
            return dataRows.size();
         * The table will be filled with constraints relevant to 'clone'.
        private void buildDataVector()
            ArrayList  data = new ArrayList( 1 );
            Collection allConstraints = getClone().getStartConstraints();
            allConstraints.addAll( getClone().getEndConstraints() );
            Iterator constraintIter = allConstraints.iterator();
            while( constraintIter.hasNext() )
                GanttConstraint element = (GanttConstraint) constraintIter.next();
                if( element.getType().equals( GanttConstraint.START_SPECIFIED ) ||
                        element.getType().equals( GanttConstraint.FINISH_FROM_DURATION ) )
                    continue;
                else
                    data.add( element );
            this.setDataRows( data );
        private Vector getColumnNames()
            if( columnNames == null )
                columnNames = new Vector( 3 );
                columnNames.add( " " ); // Needs space otherwise all the headers disappear
                columnNames.add( "Task" );
                columnNames.add( "Constraint" );
            return columnNames;
        private void addPrimerRow()
            log.debug( "+addPrimerRow" );
            // Create a constraint for the 'clone' task. Set it as transient until validation
            // where we will deal with it if necessary.
            GanttConstraint primer = new GanttConstraint( real.getLookup() );
            primer.setObjectId( chart.getNextUniqueId() );
            primer.setTransient();
            primer.setSlave( getClone() );
            primer.setProject( getClone().getProject() );
            getClone().addConstraint( primer );
            this.getDataRows().add( primer );
            int lastRow = this.getRowCount() - 1;
            fireTableRowsInserted( lastRow, lastRow );
            log.debug( "-addPrimerRow" );

  • JTable cannot make cell non-editable

    I have create a JTable using the DefaultTablemodel. I want to make the cells non editable. I have overwritten the method isCellEditable with that shown below but when I double click any cell it still let me edit the cell. Someone please show me what is wrong.
    public boolean isCellEditable(int cellrow, int cellcol)
    return(false);
    // if (cellcol == 0)
    // return(false);
    // else
    // return(true);
    Regards
    pslloo

    Look at the tutorial! This sample works.
    Hope this help.
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.JScrollPane;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class TableDemo extends JFrame {
        private boolean DEBUG = true;
        public TableDemo() {
            super("TableDemo");
            MyTableModel myModel = new MyTableModel();
            JTable table = new JTable(myModel);
            table.setPreferredScrollableViewportSize(new Dimension(500, 70));
            //Create the scroll pane and add the table to it.
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this window.
            getContentPane().add(scrollPane, BorderLayout.CENTER);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
        class MyTableModel extends AbstractTableModel {
            final String[] columnNames = {"First Name",
                                          "Last Name",
                                          "Sport",
                                          "# of Years",
                                          "Vegetarian",
                                          "essai"};
            final Object[][] data = {
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false), new Integer(3)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true), new Integer(3)},
                {"Kathy", "Walrath",
                 "Chasing toddlers", new Integer(2), new Boolean(false), new Integer(3)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true), new Integer(3)},
                {"Angela", "Lih",
                 "Teaching high school", new Integer(4), new Boolean(false), new Integer(3)}
            public int getColumnCount() {
                return columnNames.length;
            public int getRowCount() {
                return data.length;
            public String getColumnName(int col) {
                return columnNames[col];
            public Object getValueAt(int row, int col) {
                return data[row][col];
             * JTable uses this method to determine the default renderer/
             * editor for each cell.  If we didn't implement this method,
             * then the last column would contain text ("true"/"false"),
             * rather than a check box.
            public Class getColumnClass(int c) {
                return getValueAt(0, c).getClass();
             * Don't need to implement this method unless your table's
             * editable.
            public boolean isCellEditable(int row, int col) {
                //Note that the data/cell address is constant,
                //no matter where the cell appears onscreen.
                if (col < 2) {
                    return false;
                } else {
                    return true;
             * Don't need to implement this method unless your table's
             * data can change.
            public void setValueAt(Object value, int row, int col) {
                if (DEBUG) {
                    System.out.println("Setting value at " + row + "," + col
                                       + " to " + value
                                       + " (an instance of "
                                       + value.getClass() + ")");
                if (data[0][col] instanceof Integer                       
                        && !(value instanceof Integer)) {                 
                    //With JFC/Swing 1.1 and JDK 1.2, we need to create   
                    //an Integer from the value; otherwise, the column    
                    //switches to contain Strings.  Starting with v 1.3,  
                    //the table automatically converts value to an Integer,
                    //so you only need the code in the 'else' part of this
                    //'if' block.                                         
                    //XXX: See TableEditDemo.java for a better solution!!!
                    try {
                        data[row][col] = new Integer(value.toString());
                        fireTableCellUpdated(row, col);
                    } catch (NumberFormatException e) {
                        JOptionPane.showMessageDialog(TableDemo.this,
                            "The \"" + getColumnName(col)
                            + "\" column accepts only integer values.");
                } else {
                    data[row][col] = value;
                    fireTableCellUpdated(row, col);
                if (DEBUG) {
                    System.out.println("New value of data:");
                    printDebugData();
            private void printDebugData() {
                int numRows = getRowCount();
                int numCols = getColumnCount();
                for (int i=0; i < numRows; i++) {
                    System.out.print("    row " + i + ":");
                    for (int j=0; j < numCols; j++) {
                        System.out.print("  " + data[i][j]);
                    System.out.println();
                System.out.println("--------------------------");
        public static void main(String[] args) {
            TableDemo frame = new TableDemo();
            frame.pack();
            frame.setVisible(true);
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Access to GridControl cells

    Hi all,
    I have several questions involving GridControl in JDeveloper 2.0:
    1) Can I change the value of a cell in a GridControl using java code (e.g. in a validation event).
    I have seen some code examples using a method called ImmediateAccess.getValueAsString. Is there a similar method for setting the value and does it always work?
    2) Can I put non-database fields in a
    GridControl (for example calculated fields)?
    3) Can I change the type of a cell (make it a combobox for example)?
    Thanks in advance,
    Theodore.

    1) The ImmediateAccess interface has a setValue method that sets the value of a simple DataItem. See the InfoBus reference documentation in the Online Help system for more information.
    2) The GridControl displays any attribute of a BC4J ViewObject whether the attribute is calculated or not. Calculated attributes should be coded at the ViewObject level.
    3) The GridControl is a composite of a JTable and InfoBus API's. The underlying JTable can be obtained using the getTable method. Once you have that object you can change cells of the JTable. See the online JavaDoc for more information.
    - PSW

  • JavaFX2.2 TableView:How to make a table cell be edited without mouse click?

    Hi,
    I've encounter a problem with editable table cells. I'm using the TableView in my project just as the Tutorial on Oracle (http://docs.oracle.com/javafx/2/ui_controls/table-view.htm).
    According to it, I use the setCellFactory method to reimplement the table cell as a text field with the help of the TextFieldTableCell class. However, I found the steps is a little complex to get to the point where the cell can be edited:
    1.Let the table cell be selected by using direction key.
    2.Press “Enter” to converts the cell to a text filed so that it is ready to be edited.
    3.Clicking in the text field allows the contents to be edited
    The problem is step 3, that you must use the mouse to click before you can input data in this table cell.
    So, is there a solution to avoid step 3? That is the text field allows the data inputting when you just press “Enter”(step 2).
    By the way, English is not my native language. Hope I have made myself clear.

    Hi,
    You need to pass the focus to the text field when the startEditing event occurs. In the class that extends TableCell you use for cellFactory:
    public void startEdit() {
    super.startEdit();
    createTextField();
    setText(null);
    setGraphic(textField);
    * put focus on the textfield so user can directly typed on it
    Runnable r = new Runnable() {
    @Override
    public void run() {
    getGraphic().requestFocus();
    Platform.runLater(r);
    }

  • Making cell non editable on mouseevent or a data in coumn

    hi friends
    i have a Jtable which is having a Productprice column which is editable by default
    when the Jtable is created from my custom model.
    and there is a boolean(check box)-LockPrice column and quoteDate column
    i want that when the value in the LockPrice of a particular row is set to true by mouse click or if the QuoteDate is entered then the value in the productprice cell of that row shud not be editable.
    any ideas wud be great help
    jags

    Simply make a sub class of DefaultTableModel in the following style and over ride the isCellEditable() method and pass class "TempDefaultTableModel " as a model of the table. Method inside working you can define in your own style.
    class TempDefaultTableModel extends DefaultTableModel{
    public TempDefaultTableModel(Object[] columnNames, int rows){
    super(columnNames, rows);
    public boolean isCellEditable(int row, int column) {
    return false;
    }

  • Table cells not editable in Contribute

    I have a date table (inside a CSS layout) which displays incorrectly in Contribute Edit mode.This is the URL http://www.greencs.co.uk/accreditations.html
    In Contribute Edit mode, the right hand column of the table (which contains the PDF certificates) is pushed far out to the right (beyond the rest of the layout) which makes it impossible for the cells in this column to be edited. This also happens in Dreamweaver; the table width is 598 pixels but the Display width (in parenthesis in Dreamweaver) is 1300 px. Does anyone know why the Display width, which I assume Contribute is using in Edit mode, is so wide..... and how I can constrain it.
    I have tried adding various table cell widths but to no avail. Help.....
    Many thanks

    This problem has been solved by placing the logo images in their own table cell instead of floating left. The float and adjacent text caused the problem. Thanks to Neil Gibson @cvwcreative who came up with the solution on Twitter.

  • How to get the row & col of the cell being edited?

    I have a reference to a editable JTable, and I want to know at any point in time, what cell the user is editing (specifically the row & col).
    You'd think you could just go:
    int col = table.getActiveCellColumn();
    int row = table.getActiveCellRow();
    Where the active cell is the one the user is typing in.
    I tried getting the rectangle of the permenant focus owner and using that to get a Point object, then testing the table using columnAtPoint and rowAtPoint, but sometimes the cell is returned as the foucs owner and sometimes the whole table is returned (which does not help). Any ideas?

    You'd think you could just go:
    int col = table.getActiveCellColumn();
    int row = table.getActiveCellRow();Or maybe:
    table.getEditingRow();
    table.getEditingColumn();

  • GridControl Cell rendered as either button or combobox depending on data

    I have worked out the following code. If the data has more than one row it will return the words <MORE> in the query. If there is only one row it will return text and if there are no rows the cell is blank.
    The following renders and takes care of the editor. So when you click on either a blank cell or a text cell it will display a comboboxcontrol. If you click on the cell that is a button it will return a joptionpane.
    I thought maybe somebody else would need this.
    Initial code taken from http://www2.gol.com/users/tame/swing/examples/JTableExamples2.html and tweeked for the button.
    package Samples;
    import javax.swing.table.*;
    import javax.swing.*;
    import java.awt.*;
    * A Class class.
    * <P>
    * @author Linda B. Rawson
    public class SampleNameRenderer extends DefaultTableCellRenderer {
    JCheckBox checkBox = new JCheckBox();
    JButton button = new JButton();
    * Constructor
    public SampleNameRenderer() {
    public Component getTableCellRendererComponent(
    JTable table, Object value,
    boolean isSelected, boolean hasFocus,
    int row, int column) {
    if (value instanceof Boolean) { // Boolean
    checkBox.setSelected(((Boolean)value).booleanValue());
    checkBox.setHorizontalAlignment(JLabel.CENTER);
    return checkBox;
    String str = (value == null) ? "" : value.toString();
    if (str.equals("<MORE>") ) {
    button.setText("< MORE >");
    return button;
    return super.getTableCellRendererComponent(
    table,str,isSelected,hasFocus,row,column);
    package Samples;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import oracle.dacf.control.swing.*;
    import javax.swing.event.*;
    import java.util.EventObject;
    import javax.infobus.*;
    * A Class SampleNameEditor class.
    * <P>
    * @author Linda B. Rawson
    public class SampleNameEditor implements TableCellEditor {
    private final static int COMBO = 0;
    private final static int BOOLEAN = 1;
    private final static int STRING = 2;
    private final static int NUM_EDITOR = 3;
    ComboBoxControl comboBox = new ComboBoxControl();
    JTextField textField = new JTextField();
    JCheckBox checkBox = new JCheckBox();
    JButton button = new JButton();
    private boolean isPushed;
    public String str = "";
    DefaultCellEditor[] cellEditors;
    int flg; // Default to String
    * Constructor
    public SampleNameEditor() {
    cellEditors = new DefaultCellEditor[NUM_EDITOR];
    // combo box editor
    comboBox = new ComboBoxControl();
    cellEditors[COMBO] = new DefaultCellEditor(comboBox);
    // Will not take button as an argument. Will only take checkbox.
    checkBox = new JCheckBox();
    checkBox.setOpaque( true );
    checkBox.setHorizontalAlignment(JLabel.CENTER);
    cellEditors[BOOLEAN] = new DefaultCellEditor(checkBox);
    cellEditors[STRING] = new DefaultCellEditor(textField);
    button = new JButton();
    isPushed = true;
    public Component getTableCellEditorComponent(JTable table, Object value,
    boolean isSelected, int row, int column) {
    if (value.toString().equals("<MORE>") ) {
    flg = BOOLEAN;
    if (isSelected) {
    button.setForeground(table.getSelectionForeground());
    button.setBackground(table.getSelectionBackground());
    } else{
    button.setForeground(table.getForeground());
    button.setBackground(table.getBackground());
    str = (value ==null) ? "" : value.toString();
    button.setText( str );
    button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (isPushed) {
    JOptionPane.showMessageDialog(button ,": Ouch! I am going to show you multiple samples");
    isPushed = false;
    cancelCellEditing();
    isPushed = true;
    return button;
    } else if (value instanceof String) { // ComboString
    flg = COMBO;
    comboBox. setFont(new Font("Dialog", 0, 12));
    comboBox.setListKeyDataItemName("infobus:/oracle/session1/rowSetSamples/SampleName");
    comboBox.setListValueDataItemName("infobus:/oracle/session1/rowSetSamples/SampleName");
    comboBox.setDataItemUsageMode(oracle.dacf.control.DualBindingControl.FOR_NAVIGATION);
    return comboBox;
    /* Use this if you ever desire a text field as well as a combo and button.
    } else if (value instanceof String) { // String
    flg = STRING;
    return cellEditors[STRING].getTableCellEditorComponent(
    table, value, isSelected, row, column);
    return null;
    public Object getCellEditorValue() {
    switch (flg) {
    case COMBO:
    str = ((ImmediateAccess)comboBox.getDataItem()).getValueAsString();
    return str;
    case BOOLEAN:
    case STRING:
    return cellEditors[flg].getCellEditorValue();
    default:
    return null;
    public Component getComponent() {
    return cellEditors[flg].getComponent();
    public boolean stopCellEditing() {
    return cellEditors[flg].stopCellEditing();
    public void cancelCellEditing() {
    cellEditors[flg].cancelCellEditing();
    public boolean isCellEditable(EventObject anEvent) {
    return cellEditors[flg].isCellEditable(anEvent);
    public boolean shouldSelectCell(EventObject anEvent) {
    return cellEditors[flg].shouldSelectCell(anEvent);
    public void addCellEditorListener(CellEditorListener l) {
    cellEditors[flg].addCellEditorListener(l);
    public void removeCellEditorListener(CellEditorListener l) {
    cellEditors[flg].removeCellEditorListener(l);
    public void setClickCountToStart(int n) {
    cellEditors[flg].setClickCountToStart(n);
    public int getClickCountToStart() {
    return cellEditors[flg].getClickCountToStart();
    Enjoy.
    Linda
    null

    Ok FYI Ive implemented a different solution which works fine.
    I have one class that contains a JPopupMenu and listens for a MouseEvent and displays the popup with the correct actions disabled/enabled as before. But I also register as a for PopupMenuListener on the Popup, and when it receives a PopupMenuIsBecomingInvisibleEvent , I enable all the actions in the associated table actionMap, this ensures that the action is always triggered from the keyboard shortcut
    When the action is triggered it checks the source of the ActionEvent, if it has come from the PopUp the action runs because we know it couldnt be triggered from the popup unless it was an enabled action. But if the source is a table we then perform the validation checks to see if it should run based on the cell contents, if it shouldnt it just returns without doing anything, if the validation is ok then it actaully does the action.

Maybe you are looking for