Hi Prasanta,

I sent you two snippets.

The First: modification of your UIExtendedTable
-------------------------------------------------

In this we modified the UIExtendedTable class to have a method  that sets
custom table header. We call this method from restoreState() initially. We
also want to invoke this method after we do fireTableStructureChanged() on
the server side. So to invoke this method on the client side from the server
we need to send a message from the server to the client. This we do in the
ULCExtendedTable.setCustomHeader() method where we send a message
sendUI("setCustomHeaders"). On the client-side in UIExtendedTable you need
to handle this message so we override UITable's handleRequest method and
check if message is setCustomHeaders then call setCustomHeaders() method.

Make sure that you separate out the client and server side classes when you
run your ULC client and ULC app in different JVMs e.g. as in jnlp & servlet
mode.

ULCExtendedTable should be on the class path of your server side ULC
application. Its typeString() method should return the fully qualified class
name of UIExtendedTable class:
"com.hp.gdic.scmas.ulc.util.model.authorized.SCMASTable.UIExtendedTable"

UIExtendedTable should be on the class path of your ULC client.

The second: Using ULCLabel as HeaderRenderer and setting multiline text on
it by using HTML
----------------------------------------------------------------------------
---------------
Can you tell me why is this solution not acceptable to you?

I hope this helps.

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Behera,
>Prasanta Kumar
>Sent: Monday, July 31, 2006 11:15 AM
>To: [EMAIL PROTECTED] Com
>Subject: RE: [ULC-developer] Is it possible to get hold of the
>underlying Swing table from ULCTable?
>
>
>Hi Janak,
>
>The code snippet that you have provided below did work for me. Could you
>please explain the code snippet? Also please do let me know the
>sequence.
>
>Thanks & Regards
>Prasanta
>
>-----Original Message-----
>From: Janak Mulani [mailto:[EMAIL PROTECTED]
>Sent: Friday, July 28, 2006 4:08 PM
>To: Behera, Prasanta Kumar
>Cc: [EMAIL PROTECTED] Com
>Subject: RE: [ULC-developer] Is it possible to get hold of the
>underlying Swing table from ULCTable?
>
>Hi Prasanta,
>
>First of all, you can  set header renderer on ULCTableColumn using
>setHeaderRenderer(ITableCellRenderer headerRenderer). Renderers and
>Editors can be set on columns on the server side.
>
>Having said the above, I looked at your old correspondence with Marc
>Hermann where in he had suggested a ULCTable extension to set a custom
>header renderer that handles wrapping of header text. In his opinion
>this was an easier option than implementing a renderer based on
>ULCTextArea.
>
>However there is an alternative which does not require any extension.
>ULCTable uses ULCLabel as DefaultTableHeaderCellRenderer. On ULCLabel
>you can set HTML text in which you can have multiple line breaks. Please
>see the snippet at the end of this mail which demonstrates multiline
>header and cells. Let me know if this works for you or otherwise.
>
>If the above solution is not good for you, then you need to change your
>existing code as follows:
>
>1. In restoreState() extract the code for setting custom header renderer
>into a separate method of UIExtendedTable:
>
>  public void setCustomHeaderRenderer() {
>   JWordWrapTableHeader headerRenderer = new JWordWrapTableHeader();
>
>   for (Enumeration enumeration =
>getBasicTable().getColumnModel().getColumns();
>enumeration.hasMoreElements();) {
>        TableColumn column = (TableColumn) enumeration.nextElement();
>        column.setHeaderRenderer(headerRenderer);
>    }
>  }
>
>2. call this method in restoreState() after calling
>super.restoreState().
>
>3. In ULCExtendedTable introduce a method:
>
>   public void setCustomHeaderRenderer() {
>        sendUI("setCustomHeaderRenderer");
>   }
>
>4. In UIExtendedTable override handleRequest method as follows:
>
>       public void handleRequest(String request, Anything args) {
>        if (request.equals("setCustomHeaderRenderer")) {
>            setCustomHeaderRenderer();
>        } else {
>          super.handleRequest(request, args);
>        }
>    }
>
>5. In your ULC application, invoke setCustomHeaderRenderer() after you
>have invoked fireTableStructureChanged().
>
>I hope this helps.
>
>Thanks and regards,
>
>Janak
>
>
>>-----Original Message-----
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] Behalf Of Behera,
>>Prasanta Kumar
>>Sent: Friday, July 28, 2006 8:20 AM
>>To: [EMAIL PROTECTED] Com
>>Cc: [email protected]
>>Subject: RE: [ULC-developer] Is it possible to get hold of the
>>underlying Swing table from ULCTable?
>>
>>
>>Hi Janak,
>>
>>If you check my code snippet(given below) I am setting the renderer in
>>the column header of the underlying swing table. This I am doing in
>>order to achieve word wrapping in the column header of the table.
>>In order to set renderers on the columns again immediately after
>>calling
>>fireTableStructureChanged() method I need to get the renderer. So my
>>question is how do I get the renderer which is set to the column header
>
>>of the underlying swing table?
>>
>>Thanks & Regards
>>Prasanta
>>
>>-----Original Message-----
>>From: Janak Mulani [mailto:[EMAIL PROTECTED]
>>Sent: Thursday, July 27, 2006 7:26 PM
>>To: Behera, Prasanta Kumar
>>Cc: [email protected]
>>Subject: RE: [ULC-developer] Is it possible to get hold of the
>>underlying Swing table from ULCTable?
>>
>>Hi Prasanta,
>>
>>First of all you should never invoke restoreState() method in your
>>code, it is invoked by ULC while managing the life cycle of the client
>>side half object.
>>
>>>But our project has an additional requirement. Our project has
>>>something called a field chooser utility. When a user clicks on the
>>>field chooser he gets a list of columns. The user can select any
>>>number
>>
>>>of columns that he would like to view and the table is refreshed with
>>>the selected columns. While refreshing the table I am using
>>>fireTableStructureChanged() method. When I call
>>>fireTableStructureChanged() method it is removing the effect of word
>>>wrapping in the column header. I am not very sure why it is behaving
>>>in
>>
>>>such a fashion.
>>
>>When you do fireTableStructureChanged() all columns of the table are
>>recreated if you have autoCreateColumnsFromModel set to true. This is
>>the reason why all renderers including those for headers are lost.
>>
>>There are two solutions:
>>
>>1. Set renderers on the columns again immediately after you do
>>fireTableStructureChanged().
>>
>>Or
>>
>>2. Set autoCreateColumnsFromModel to false and create and add columns
>>to the table programmatically. Add your renderers to these columns.
>>Keep this set of columns in a collection. Subsequently in your field
>>chooser utility you can selectively add or remove columns to your table
>
>>from this collection.
>>
>>I hope this helps.
>>
>>Thanks and regards,
>>
>>Janak
>>
>>
>>-----Original Message-----
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] Behalf Of Behera,
>>Prasanta Kumar
>>Sent: Wednesday, July 26, 2006 7:42 AM
>>To: [email protected]
>>Subject: [ULC-developer] Is it possible to get hold of the underlying
>>Swing table from ULCTable?
>>
>>
>>Hi All,
>>
>>Is it possible to get hold of the underlying swing table from the
>>ULCTable?
>>
>>In order to achieve wrapping in the column header I have done the
>>following:
>>Created both extended ULCTable and UITable class.
>>The ULC class just overrides typeString() and the UI class
>>restoreState().
>>The text area renderer component is eventually set on the underlying
>>Swing table in the restoreState() method after calling super().
>>Code Snippet is as given below:
>>
>> protected String typeString() {
>>  // works only in development mode; to be replaced by a full-qualified
>
>>package string
>>  return UIExtendedTable.class.getName();  }
>>
>> public static class UIExtendedTable extends UITable {  public void
>> restoreState(Anything args) {
>>   super.restoreState(args);
>>
>>   JWordWrapTableHeader headerRenderer = new JWordWrapTableHeader();
>>
>>   for (Enumeration enumeration = getBasicTable().getColumnModel()
>>     .getColumns(); enumeration.hasMoreElements();) {
>>    TableColumn column = (TableColumn) enumeration.nextElement();
>>    column.setHeaderRenderer(headerRenderer);
>>   }
>>  }
>>
>>  private static class JWordWrapTableHeader extends JTextArea
>>implements TableCellRenderer {
>>   public JWordWrapTableHeader() {
>>    setLineWrap(true);
>>    setWrapStyleWord(true);
>>    setBackground(new Color(223, 235, 252));
>>    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
>>   }
>>
>>   public Component getTableCellRendererComponent(JTable table,
>>     Object value, boolean isSelected, boolean hasFocus, int row,
>>     int column) {
>>    setText((String) value);
>>    setSize(table.getColumnModel().getColumn(column).getWidth(),
>>      getPreferredSize().height);
>>    return this;
>>   }
>>  }
>> }
>>
>>But my project has an additional requirement. My project has something
>>called a field chooser utility. When a user clicks on the field chooser
>
>>he gets a list of columns. The user can select any number of columns
>>that he would like to view and the table is refreshed with the selected
>
>>columns.
>>While refreshing the table I am using fireTableStructureChanged()
>>method.
>>When I call fireTableStructureChanged() method it is removing the
>>effect of word wrapping in the column header. I need to set the
>>renderer again on the underlying Swing table.
>>Is it possible to get hold of the underlying Swing table from ULCTable?
>>If this is possible I can again set the renderer on the underlying
>>Swing table after calling fireTableStructureChanged() method? If this
>>is not possible is there a way to set the renderer again after calling
>>fireTableStructureChanged() method?
>>Thanks & Regards
>>Prasanta
>
>-----------------------
>
>import com.ulcjava.base.application.AbstractApplication;
>import com.ulcjava.base.application.ULCBoxPane;
>import com.ulcjava.base.application.ULCFrame;
>import com.ulcjava.base.application.ULCScrollPane;
>import com.ulcjava.base.application.ULCTable;
>import com.ulcjava.base.application.table.AbstractTableModel;
>import com.ulcjava.base.application.table.DefaultTableCellRenderer;
>import
>com.ulcjava.base.application.table.DefaultTableHeaderCellRenderer;
>import com.ulcjava.base.development.DevelopmentRunner;
>
>public class WrapCellSnippet extends AbstractApplication {
>    public void start() {
>        ULCTable table = new ULCTable(new AbstractTableModel() {
>            public int getColumnCount() {
>                return 3;
>            }
>
>            public int getRowCount() {
>                return 10;
>            }
>
>            public Object getValueAt(int rowIndex, int columnIndex) {
>                return "<html><b>Row:</b> " + rowIndex +
>"<br><b>Column:</b>" + columnIndex + "</html>";
>            }
>
>            public String getColumnName(int column) {
>                return "<html><b>Column</b><br>" + column + "</html>" ;
>            }
>        });
>
>        for (int i = 0; i < table.getColumnCount(); i++) {
>            table.getColumnModel().getColumn(i).setCellRenderer(new
>DefaultTableCellRenderer());
>            table.getColumnModel().getColumn(i).setHeaderRenderer(new
>DefaultTableHeaderCellRenderer());
>        }
>        table.setRowHeight(2 * table.getRowHeight());
>
>        ULCBoxPane contentPane = new ULCBoxPane(1, 0);
>        contentPane.add(ULCBoxPane.BOX_EXPAND_EXPAND, new
>ULCScrollPane(table));
>
>
>        ULCFrame frame = new ULCFrame("WrapCellSnippet");
>        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
>        frame.add(contentPane);
>        frame.setVisible(true);
>    }
>
>    public static void main(String[] args) {
>        DevelopmentRunner.setApplicationClass(WrapCellSnippet.class);
>        DevelopmentRunner.main(args);
>    }
>}
>
>_______________________________________________
>ULC-developer mailing list
>[email protected]
>http://lists.canoo.com/mailman/listinfo/ulc-developer

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to