2017 up to now  | 2016 | 2015 | 2014 | 2013 | 2012 | 2011 | 2010 | 2009 | 2008 | 2007

(older archive entries before 2007 are not shown here, but included in the onsite-search)

Mailing List - Entries of 2012


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] Resolving JTable with the same values in cells.


  • Subject: Re: [QF-Test] Resolving JTable with the same values in cells.
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: Fri, 14 Dec 2012 10:03:13 +0100

Hello Oleg,

looks like you're quickly becoming an expert in writing QF-Test
resolvers.

Though this sounds like a common question, I haven't really had to
answer it before. But it's interesting and I've come up with an idea I
haven't used before.

Following is an ItemNameResolver2 in Jython that will append :2, :3,
... to the second, third, ... occurrence of the same item in a column:


def getName(table, item, name):
    print table, item, name
    col, row = item
    if row >= 0:
        # target cell value
        val = str(table.getValueAt(row, col))
        # look for identical entries in the rows above
        matches = 0
        for i in range(row):
            if str(table.getValueAt(i, col)) == val:
                matches += 1
        if matches > 0:
            val = "%s:%d" % (val, matches + 1)
        return val
resolvers.addItemNameResolver2("makeunique", getName, "javax.swing.JTable")


The great thing about the ItemNameResolver2 API is that it only
changes the cell's index, not its value, so check values or fetch text
should not be affected.

You may need to tweak it a bit in case getValueAt is not sufficient to
get the cell's String value and of course you way want to register it
for a custom class instead of JTable.

Best regards,
    Greg


"Rayskiy, Oleg" <Oleg.Rayskiy@?.com> writes:

> I have a different problem now, I'm trying to resolve the table inside the JInternalFrame and at the moment I cannot see a way of getting the item's index except by row and column.
> The problem here is that if the row before the requested row has the same value then that row is returned for index, therefore if for example I have 10 rows and after second row all cells in that column have the same value, then for any row I try to select/check after the second row always return the first row with that value.
> The only way I can see how I can get the actual row I need is by using the JTable's rowAtPoint function and getting the point through MouseMovementListener, trying to implement this way I hit the rock at not knowing where I can add the listener to my JTable as during records/checks it returns NullPointerException  but after I stop recording it starts returning actual values.
>
> If there's an easier way of implementing that can you please tell me how, if not can you please explain how I can add the MouseMovementListener so It works during recording.
>
> Thanks, Oleg.

--
Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH                     http://www.qfs.de
Tulpenstr. 41                               Tel: +49 8171 38648-0
DE-82538 Geretsried                         Fax: +49 8171 3864816
GF: Gregor Schmid, Karlheinz Kellerer          HRB München 140833