swingx
  1. swingx
  2. SWINGX-1304

ColumnHighlightPredicate could take Enum as columns integers

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.6.3
    • Component/s: Highlighter
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,304

      Description

      From http://forums.java.net/jive/message.jspa?messageID=396995#396995

      I know I'm not the only one to use Enums for the columns definition of a JXTable
      (But I think there is another way to setup the columns in swingx - anyway).
      Having to do ordinal() on each enum value is ugly;

      Could ColumnHighlightPredicate take Enum... and call ordinal() on them
      automatically ?
      I think this could be a good enhancement. Also maybe elsewhere where
      integers/columns are used in the package ?

      Example:
      Before : new ColumnHighlightPredicate(COLUMN_MILESTONE.ordinal(),
      COLUMN_FINISHED.ordinal(), COLUMN_OPEN.ordinal());

      After : new ColumnHighlightPredicate(COLUMN_MILESTONE, COLUMN_FINISHED,
      COLUMN_OPEN);

        Activity

        martinm1000 created issue -
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 1304 85564
        Karl Schaefer made changes -
        Affects Version/s 1.6.1 [ 13360 ]
        Affects Version/s 1.6++ [ 13359 ]
        Hide
        kleopatra added a comment -

        well, after looking into this (had it added already it turned out that the addition is not possible without formally breaking existing code: with a second constructor taking varargs

        new ColumnHighlightPredicate() wont compile

        While very uncommon - no column highlighted, that is always false - it might stand in the way somewhere. Plus it doesn't look (to me like a big deal to use a convenience method like:

        public static int[] createOrdinals(Enum<?>... values) {
        int[] cols = new int[values.length];
        for (int i = 0; i < values.length; i++)

        { cols[i] = values[i].ordinal(); }

        return cols;
        }

        and then you enum-enthusiasts can use it in client code like:

        new ColumnHighlightPredicate(createOrdinals(COLUMN_MILESTONE, COLUMN_FINISHED))

        we could add the static method somewhere in utilities, maybe in TableUtilities?

        Tend to close this issue as wontfix.

        Comments please?

        CU
        Jeanette

        Show
        kleopatra added a comment - well, after looking into this (had it added already it turned out that the addition is not possible without formally breaking existing code: with a second constructor taking varargs new ColumnHighlightPredicate() wont compile While very uncommon - no column highlighted, that is always false - it might stand in the way somewhere. Plus it doesn't look (to me like a big deal to use a convenience method like: public static int[] createOrdinals(Enum<?>... values) { int[] cols = new int [values.length] ; for (int i = 0; i < values.length; i++) { cols[i] = values[i].ordinal(); } return cols; } and then you enum-enthusiasts can use it in client code like: new ColumnHighlightPredicate(createOrdinals(COLUMN_MILESTONE, COLUMN_FINISHED)) we could add the static method somewhere in utilities, maybe in TableUtilities? Tend to close this issue as wontfix. Comments please? CU Jeanette
        Hide
        Karl Schaefer added a comment -

        You could do:

        ColumnHighlightPredicate()
        ColumnHighlightPredicate(int, int...)
        ColumnHighlightPredicate(Enum, Enum...)

        It would break existing code for people that did not use varargs notation in constructing the ColumnHighlightPredicate, such as:
        new ColumnHighlightPredicate(new int[]

        {1, 2, 3, 4,}

        )

        But who does that with ints?

        Karl

        Show
        Karl Schaefer added a comment - You could do: ColumnHighlightPredicate() ColumnHighlightPredicate(int, int...) ColumnHighlightPredicate(Enum, Enum...) It would break existing code for people that did not use varargs notation in constructing the ColumnHighlightPredicate, such as: new ColumnHighlightPredicate(new int[] {1, 2, 3, 4,} ) But who does that with ints? Karl
        Hide
        kleopatra added a comment -

        Without actually trying looks like: each and every code which constructs the array of ints somehow, such as

        int[] columnsToHighlight = lookupColumnsFor(myTable)
        new ColumnHighlightPredicate(columnsToHighlight);

        Don't think your suggestion is an option - it changes existing signature in a backward breaking manner. Nothing I want to do, especially not if it doesn't buy very much.

        Thanks anyway - always good to see your brain chunk out approaches I didn't think of

        Cheers
        Jeanette

        Show
        kleopatra added a comment - Without actually trying looks like: each and every code which constructs the array of ints somehow, such as int[] columnsToHighlight = lookupColumnsFor(myTable) new ColumnHighlightPredicate(columnsToHighlight); Don't think your suggestion is an option - it changes existing signature in a backward breaking manner. Nothing I want to do, especially not if it doesn't buy very much. Thanks anyway - always good to see your brain chunk out approaches I didn't think of Cheers Jeanette
        kleopatra made changes -
        Original Estimate 0 minutes [ 0 ]
        Remaining Estimate 0 minutes [ 0 ]
        Hide
        kleopatra added a comment -

        closing as wontfix. Added convenience method to TableUtilities

        Show
        kleopatra added a comment - closing as wontfix. Added convenience method to TableUtilities
        kleopatra made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]

          People

          • Assignee:
            kleopatra
            Reporter:
            martinm1000
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: