Skip to main content



      Home
Home » Newcomers » Newcomers » Draw custom text on Table
Draw custom text on Table [message #264289] Mon, 15 September 2008 06:22 Go to next message
Eclipse UserFriend
Hello,
is it possible to draw custom text on the table?
I have Table and TableViewer and if there is not data to show, I would
like to display text with such message. I'd like the message to be in
first row, but go throw the more columns or to be in a special place (eg.
in the middle of control).

Agata
Re: Draw custom text on Table [message #264309 is a reply to message #264289] Mon, 15 September 2008 09:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Agata Vackova wrote:
> Hello,
> is it possible to draw custom text on the table?
> I have Table and TableViewer and if there is not data to show, I would
> like to display text with such message. I'd like the message to be in
> first row, but go throw the more columns or to be in a special place
> (eg. in the middle of control).

You can probably use the Owner Draw feature to do this. See some
examples on the Snippets page:
http://wiki.eclipse.org/index.php/JFaceSnippets

Hope this helps,
Eric
Re: Draw custom text on Table [message #264318 is a reply to message #264309] Mon, 15 September 2008 10:28 Go to previous messageGo to next message
Eclipse UserFriend
Owner Draw doesn't help here I guess because if there are no rows
there's no owner draw because it is bound to Table/TreeItem but a simple
SWT.Paint-Listener should do the trick.

Tom

Eric Rizzo schrieb:
> Agata Vackova wrote:
>> Hello,
>> is it possible to draw custom text on the table?
>> I have Table and TableViewer and if there is not data to show, I
>> would like to display text with such message. I'd like the message to
>> be in first row, but go throw the more columns or to be in a special
>> place (eg. in the middle of control).
>
> You can probably use the Owner Draw feature to do this. See some
> examples on the Snippets page:
> http://wiki.eclipse.org/index.php/JFaceSnippets
>
> Hope this helps,
> Eric


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Draw custom text on Table [message #264348 is a reply to message #264318] Tue, 16 September 2008 03:15 Go to previous messageGo to next message
Eclipse UserFriend
I tried to use paint listener (
table.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent e) {
e.gc.drawText("No data", 100, 100);
}
});
), but it doesn't work: method paintControl is not called at all.

Agata

Tom Schindl wrote:

> Owner Draw doesn't help here I guess because if there are no rows
> there's no owner draw because it is bound to Table/TreeItem but a simple
> SWT.Paint-Listener should do the trick.

> Tom

> Eric Rizzo schrieb:
>> Agata Vackova wrote:
>>> Hello,
>>> is it possible to draw custom text on the table?
>>> I have Table and TableViewer and if there is not data to show, I
>>> would like to display text with such message. I'd like the message to
>>> be in first row, but go throw the more columns or to be in a special
>>> place (eg. in the middle of control).
>>
>> You can probably use the Owner Draw feature to do this. See some
>> examples on the Snippets page:
>> http://wiki.eclipse.org/index.php/JFaceSnippets
>>
>> Hope this helps,
>> Eric
Re: Draw custom text on Table [message #264354 is a reply to message #264348] Tue, 16 September 2008 03:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi Agata,

Ok. Looks like SWT-Table doesn't support SWT-Paint :-( The only trick I
now see is that you are setting a background image which has the draw
back that it is rendered behind the Grid-Lines (you could turn them of
of course).

I've CC'ed the swt-newsgroup maybe some of the others has a better idea.

Tom

Agata Vackova schrieb:
> I tried to use paint listener (
> table.addPaintListener(new PaintListener(){
> public void paintControl(PaintEvent e) {
> e.gc.drawText("No data", 100, 100);
> }
> });
> ), but it doesn't work: method paintControl is not called at all.
>
> Agata
>
> Tom Schindl wrote:
>
>> Owner Draw doesn't help here I guess because if there are no rows
>> there's no owner draw because it is bound to Table/TreeItem but a simple
>> SWT.Paint-Listener should do the trick.
>
>> Tom
>
>> Eric Rizzo schrieb:
>>> Agata Vackova wrote:
>>>> Hello,
>>>> is it possible to draw custom text on the table?
>>>> I have Table and TableViewer and if there is not data to show, I
>>>> would like to display text with such message. I'd like the message to
>>>> be in first row, but go throw the more columns or to be in a special
>>>> place (eg. in the middle of control).
>>>
>>> You can probably use the Owner Draw feature to do this. See some
>>> examples on the Snippets page:
>>> http://wiki.eclipse.org/index.php/JFaceSnippets
>>>
>>> Hope this helps,
>>> Eric
>
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Draw custom text on Table [message #264357 is a reply to message #264309] Tue, 16 September 2008 04:14 Go to previous messageGo to next message
Eclipse UserFriend
Eric Rizzo wrote:

> Agata Vackova wrote:
>> Hello,
>> is it possible to draw custom text on the table?
>> I have Table and TableViewer and if there is not data to show, I would
>> like to display text with such message. I'd like the message to be in
>> first row, but go throw the more columns or to be in a special place
>> (eg. in the middle of control).

> You can probably use the Owner Draw feature to do this. See some
> examples on the Snippets page:
> http://wiki.eclipse.org/index.php/JFaceSnippets

Not exactly: with OwnerDrawLabelProvider I'm able to write something in
one column - so nothing more then with LabelProvider of TableViewer. I
would need something, which would be able to write/draw text through more
then one column or independently on columns.
Agata
Re: Draw custom text on Table [message #264552 is a reply to message #264354] Fri, 19 September 2008 14:26 Go to previous messageGo to next message
Eclipse UserFriend
Putting a Label on the Table should work, snippet:

public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
shell.setLayout(new FillLayout());
Table table = new Table(shell, SWT.NONE);
table.setLinesVisible(true);
table.setHeaderVisible(true);
shell.open();
Label label = new Label(table, SWT.CENTER);
label.setBackground(table.getBackground());
label.setBounds (5, table.getHeaderHeight(), table.getSize().x - 2 * 5,
table.getItemHeight());
label.setText("no items here");
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant


"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:gannqe$qk9$1@build.eclipse.org...
> Hi Agata,
>
> Ok. Looks like SWT-Table doesn't support SWT-Paint :-( The only trick I
> now see is that you are setting a background image which has the draw
> back that it is rendered behind the Grid-Lines (you could turn them of
> of course).
>
> I've CC'ed the swt-newsgroup maybe some of the others has a better idea.
>
> Tom
>
> Agata Vackova schrieb:
> > I tried to use paint listener (
> > table.addPaintListener(new PaintListener(){
> > public void paintControl(PaintEvent e) {
> > e.gc.drawText("No data", 100, 100);
> > }
> > });
> > ), but it doesn't work: method paintControl is not called at all.
> >
> > Agata
> >
> > Tom Schindl wrote:
> >
> >> Owner Draw doesn't help here I guess because if there are no rows
> >> there's no owner draw because it is bound to Table/TreeItem but a
simple
> >> SWT.Paint-Listener should do the trick.
> >
> >> Tom
> >
> >> Eric Rizzo schrieb:
> >>> Agata Vackova wrote:
> >>>> Hello,
> >>>> is it possible to draw custom text on the table?
> >>>> I have Table and TableViewer and if there is not data to show, I
> >>>> would like to display text with such message. I'd like the message to
> >>>> be in first row, but go throw the more columns or to be in a special
> >>>> place (eg. in the middle of control).
> >>>
> >>> You can probably use the Owner Draw feature to do this. See some
> >>> examples on the Snippets page:
> >>> http://wiki.eclipse.org/index.php/JFaceSnippets
> >>>
> >>> Hope this helps,
> >>> Eric
> >
> >
> >
> >
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Re: Draw custom text on Table [message #264580 is a reply to message #264552] Mon, 22 September 2008 04:38 Go to previous message
Eclipse UserFriend
Thank you, works fine (except the weight of the label - it it very short,
I'll have probably to hardcore the weight of the label)
Agata

Grant Gayed wrote:

> Putting a Label on the Table should work, snippet:

> public static void main(String[] args) {
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setBounds(10,10,200,200);
> shell.setLayout(new FillLayout());
> Table table = new Table(shell, SWT.NONE);
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
> shell.open();
> Label label = new Label(table, SWT.CENTER);
> label.setBackground(table.getBackground());
> label.setBounds (5, table.getHeaderHeight(), table.getSize().x - 2 * 5,
> table.getItemHeight());
> label.setText("no items here");
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
> }

> Grant


> "Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
> news:gannqe$qk9$1@build.eclipse.org...
>> Hi Agata,
>>
>> Ok. Looks like SWT-Table doesn't support SWT-Paint :-( The only trick I
>> now see is that you are setting a background image which has the draw
>> back that it is rendered behind the Grid-Lines (you could turn them of
>> of course).
>>
>> I've CC'ed the swt-newsgroup maybe some of the others has a better idea.
>>
>> Tom
>>
>> Agata Vackova schrieb:
>> > I tried to use paint listener (
>> > table.addPaintListener(new PaintListener(){
>> > public void paintControl(PaintEvent e) {
>> > e.gc.drawText("No data", 100, 100);
>> > }
>> > });
>> > ), but it doesn't work: method paintControl is not called at all.
>> >
>> > Agata
>> >
>> > Tom Schindl wrote:
>> >
>> >> Owner Draw doesn't help here I guess because if there are no rows
>> >> there's no owner draw because it is bound to Table/TreeItem but a
> simple
>> >> SWT.Paint-Listener should do the trick.
>> >
>> >> Tom
>> >
>> >> Eric Rizzo schrieb:
>> >>> Agata Vackova wrote:
>> >>>> Hello,
>> >>>> is it possible to draw custom text on the table?
>> >>>> I have Table and TableViewer and if there is not data to show, I
>> >>>> would like to display text with such message. I'd like the message to
>> >>>> be in first row, but go throw the more columns or to be in a special
>> >>>> place (eg. in the middle of control).
>> >>>
>> >>> You can probably use the Owner Draw feature to do this. See some
>> >>> examples on the Snippets page:
>> >>> http://wiki.eclipse.org/index.php/JFaceSnippets
>> >>>
>> >>> Hope this helps,
>> >>> Eric
>> >
>> >
>> >
>> >
>>
>>
>> --
>> B e s t S o l u t i o n . at
>> ------------------------------------------------------------ --------
>> Tom Schindl JFace-Committer
>> ------------------------------------------------------------ --------
Previous Topic:Show Advanced properties in Tabbed Properties
Next Topic:Unable to run package - the selection cannot be launched
Goto Forum:
  


Current Time: Sat May 10 03:32:47 EDT 2025

Powered by FUDForum. Page generated in 0.08661 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top