Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Swing Table to SWT Table
Swing Table to SWT Table [message #446953] Tue, 07 December 2004 04:17 Go to next message
Eclipse UserFriend
Originally posted by: diana.joseph.gmail.com

Hi all,
if someone could help me?
What is the SWT equivalents for the following Swing codes

public JTable rawTable;
static int entry_pos=0;
int division;


1) rawTable.setRowSelectionInterval(entry_pos,entry_pos);

2) rawTable.getValueAt(entry_pos,division);

3) rawTable.getCellRect(entry_pos,entry_pos, true);

4) rawTable.scrollRectToVisible(a);


heres the exact Swing code:
public int selectTable(String SelData, int rCount,int division)
{
for(;entry_pos < rCount;entry_pos++)
{
if(SelData.equals(rawTable.getValueAt(entry_pos,division).to String().trim()))
{
rawTable.setRowSelectionInterval(entry_pos,entry_pos);
Rectangle a = rawTable.getCellRect(entry_pos,entry_pos, true);
rawTable.scrollRectToVisible(a);
repaint();
return entry_pos++;
}
}
entry_pos = 0;
return entry_pos;
}

public void setTableIndex ()
{
entry_pos = 0;
}
Re: Swing Table to SWT Table [message #447014 is a reply to message #446953] Tue, 07 December 2004 21:30 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Please read the javadoc for Table, TableItem and TableColumn. All of these
are pretty well doccumented:

http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/Table.html
http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/TableColumn.html
http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/TableItem.html

1) rawTable.setRowSelectionInterval(entry_pos,entry_pos);

Table.select(int start, int end) or Table.select(int[] indices) or
Table.setSelection(TableItem[])

2) rawTable.getValueAt(entry_pos,division);

TableItem.getText(int index);
TableItem.getImage(int index);

3) rawTable.getCellRect(entry_pos,entry_pos, true);

TableItem.getBounds(int index) TableItem.getImageBounds(int index)

4) rawTable.scrollRectToVisible(a);

Table.setTopIndex(int index) or Table.showItem(int index) and/or
Table.showColumn(TableCOlumn)

"Anaida" <diana.joseph@gmail.com> wrote in message
news:cp3ass$uiq$1@www.eclipse.org...
> Hi all,
> if someone could help me?
> What is the SWT equivalents for the following Swing codes
>
> public JTable rawTable;
> static int entry_pos=0;
> int division;
>
>
> 1) rawTable.setRowSelectionInterval(entry_pos,entry_pos);
>
> 2) rawTable.getValueAt(entry_pos,division);
> 3) rawTable.getCellRect(entry_pos,entry_pos, true);
>
> 4) rawTable.scrollRectToVisible(a);
>
> heres the exact Swing code:
> public int selectTable(String SelData, int rCount,int division)
> {
> for(;entry_pos < rCount;entry_pos++)
> {
> if(SelData.equals(rawTable.getValueAt(entry_pos,division).to String().trim()))
> {
> rawTable.setRowSelectionInterval(entry_pos,entry_pos);
> Rectangle a = rawTable.getCellRect(entry_pos,entry_pos, true);
> rawTable.scrollRectToVisible(a);
> repaint();
> return entry_pos++; }
> }
> entry_pos = 0;
> return entry_pos;
> }
>
> public void setTableIndex ()
> {
> entry_pos = 0;
> }
>
Re: Swing Table to SWT Table [message #447019 is a reply to message #447014] Wed, 08 December 2004 02:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: diana.joseph.gmail.com

i tried all of this but theres still somethin missing
thanx anyway for ur links...
still trying
Veronika Irvine wrote:

> Please read the javadoc for Table, TableItem and TableColumn. All of these
> are pretty well doccumented:

>
http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/Table.html
>
http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/TableColumn.html
>
http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/TableItem.html

> 1) rawTable.setRowSelectionInterval(entry_pos,entry_pos);

> Table.select(int start, int end) or Table.select(int[] indices) or
> Table.setSelection(TableItem[])

> 2) rawTable.getValueAt(entry_pos,division);

> TableItem.getText(int index);
> TableItem.getImage(int index);

> 3) rawTable.getCellRect(entry_pos,entry_pos, true);

> TableItem.getBounds(int index) TableItem.getImageBounds(int index)

> 4) rawTable.scrollRectToVisible(a);

> Table.setTopIndex(int index) or Table.showItem(int index) and/or
> Table.showColumn(TableCOlumn)

> "Anaida" <diana.joseph@gmail.com> wrote in message
> news:cp3ass$uiq$1@www.eclipse.org...
>> Hi all,
>> if someone could help me?
>> What is the SWT equivalents for the following Swing codes
>>
>> public JTable rawTable;
>> static int entry_pos=0;
>> int division;
>>
>>
>> 1) rawTable.setRowSelectionInterval(entry_pos,entry_pos);
>>
>> 2) rawTable.getValueAt(entry_pos,division);
>> 3) rawTable.getCellRect(entry_pos,entry_pos, true);
>>
>> 4) rawTable.scrollRectToVisible(a);
>>
>> heres the exact Swing code:
>> public int selectTable(String SelData, int rCount,int division)
>> {
>> for(;entry_pos < rCount;entry_pos++)
>> {
>>
if(SelData.equals(rawTable.getValueAt(entry_pos,division).to String().trim()))
>> {
>> rawTable.setRowSelectionInterval(entry_pos,entry_pos);
>> Rectangle a = rawTable.getCellRect(entry_pos,entry_pos, true);
>> rawTable.scrollRectToVisible(a);
>> repaint();
>> return entry_pos++; }
>> }
>> entry_pos = 0;
>> return entry_pos;
>> }
>>
>> public void setTableIndex ()
>> {
>> entry_pos = 0;
>> }
>>
Re: Swing Table to SWT Table [message #447068 is a reply to message #447019] Wed, 08 December 2004 11:38 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Can you be more specific about what is still missing?

"anaida" <diana.joseph@gmail.com> wrote in message
news:cp5po0$i2l$1@www.eclipse.org...
>i tried all of this but theres still somethin missing
> thanx anyway for ur links...
> still trying
> Veronika Irvine wrote:
>
>> Please read the javadoc for Table, TableItem and TableColumn. All of
>> these are pretty well doccumented:
>
>>
> http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/Table.html
>>
> http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/TableColumn.html
>>
> http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/swt/widgets/TableItem.html
>
>> 1) rawTable.setRowSelectionInterval(entry_pos,entry_pos);
>
>> Table.select(int start, int end) or Table.select(int[] indices) or
>> Table.setSelection(TableItem[])
>
>> 2) rawTable.getValueAt(entry_pos,division);
>
>> TableItem.getText(int index);
>> TableItem.getImage(int index);
>
>> 3) rawTable.getCellRect(entry_pos,entry_pos, true);
>
>> TableItem.getBounds(int index) TableItem.getImageBounds(int index)
>
>> 4) rawTable.scrollRectToVisible(a);
>
>> Table.setTopIndex(int index) or Table.showItem(int index) and/or
>> Table.showColumn(TableCOlumn)
>
>> "Anaida" <diana.joseph@gmail.com> wrote in message
>> news:cp3ass$uiq$1@www.eclipse.org...
>>> Hi all,
>>> if someone could help me?
>>> What is the SWT equivalents for the following Swing codes
>>>
>>> public JTable rawTable;
>>> static int entry_pos=0;
>>> int division;
>>>
>>>
>>> 1) rawTable.setRowSelectionInterval(entry_pos,entry_pos);
>>>
>>> 2) rawTable.getValueAt(entry_pos,division);
>>> 3) rawTable.getCellRect(entry_pos,entry_pos, true);
>>>
>>> 4) rawTable.scrollRectToVisible(a);
>>>
>>> heres the exact Swing code:
>>> public int selectTable(String SelData, int rCount,int division)
>>> {
>>> for(;entry_pos < rCount;entry_pos++)
>>> {
>>>
> if(SelData.equals(rawTable.getValueAt(entry_pos,division).to String().trim()))
>>> {
>>> rawTable.setRowSelectionInterval(entry_pos,entry_pos);
>>> Rectangle a = rawTable.getCellRect(entry_pos,entry_pos, true);
>>> rawTable.scrollRectToVisible(a);
>>> repaint();
>>> return entry_pos++; }
>>> }
>>> entry_pos = 0;
>>> return entry_pos;
>>> }
>>>
>>> public void setTableIndex ()
>>> {
>>> entry_pos = 0;
>>> }
>>>
>
>
Re: Swing Table to SWT Table [message #447149 is a reply to message #447068] Thu, 09 December 2004 06:56 Go to previous message
Eclipse UserFriend
Originally posted by: dn.hotmail.com

yeah sure,
I'm now programming for the search of a specific SWT TABLE row using an
SWT InputDialog which is again opened by using the eclipse view pull Down
menuitem.
I am actually converting an entire Swing version of this part to SWT.here
goes the Swing code of which is to be converted to SWT.

/***********************************/

public class TracerMain extends JFrame implements ActionListener{

JRadioButton[] b = new JRadioButton[5];
JTextField[] tfield = new JTextField[4];
JComboBox box;
private int rowCount;
private int division = 0;
private String r="";
static int item_index =0;


protected int getSelectedItem()
{
if( b[0].isSelected()) return 0;
if( b[1].isSelected()) return 1;
if( b[2].isSelected()) return 3;
if( b[3].isSelected()) return 4;

return 5;
}

protected String getItemTextField()
{
final String Item2[] = {"Trace start","Syscall entry","Syscall
exit","Trap entry","Trap exit","IRQ entry",
"IRQ exit","Sched change","Kernel timer","Soft
IRQ","Process","File system",
"Timer","Memory","Socket","IPC",
"Network","Event creation","Custom event"};
switch( division )
{
case 0 : if(!(r.equals(tfield[0].getText().trim())))
tab.setTableIndex();
r = tfield[0].getText();
break;
case 1 : if(item_index != box.getSelectedIndex()) tab.setTableIndex();
item_index = box.getSelectedIndex();
r = Item2[item_index];
break;
case 3 : if(!(r.equals(tfield[1].getText().trim())))
tab.setTableIndex();
r = tfield[1].getText();
break;
case 4 : if(!(r.equals(tfield[2].getText().trim())))
tab.setTableIndex();
r = tfield[2].getText();
break;
case 5 : if(!(r.equals(tfield[3].getText().trim())))
tab.setTableIndex();
r = tfield[3].getText();
break;
}

return r;
}

protected JPanel createGoToEvent(){//go to the event dialog žžµé±â
JPanel main = new JPanel();
main.setLayout(new GridLayout(1,3));
ButtonGroup group = new ButtonGroup();


b[0] = new JRadioButton("CPU ID: ", false);
group.add(b[0]);
tfield[0] = new JTextField();

b[1] = new JRadioButton("Event type: ", false);
group.add(b[1]);
final String Item[] = {"Trace start","System call entry","System call
exit","Trap entry","Trap exit","IRQ entry",
"IRQ exit","Schedule change","Kernel timer","Soft IRQ","Process
management","File system management",
"Timer management","Memory management","Socket
communication","Inter-process communication",
"Network communication","Creation of custom event","Custom event
occurrence"};

box = new JComboBox(Item);
box.setSelectedIndex(item_index);

b[2] = new JRadioButton("PID: ", false);
group.add(b[2]);
tfield[1] = new JTextField();

b[3] = new JRadioButton("Entry Length: ", false);
group.add(b[3]);
tfield[2] = new JTextField();

b[4] = new JRadioButton("Event Description: ", false);
group.add(b[4]);
tfield[3] = new JTextField();

JPanel upPanel = new JPanel(false);
upPanel.setLayout(new GridLayout(0,1));
upPanel.add(b[0]);
upPanel.add(b[1]);
upPanel.add(b[2]);
upPanel.add(b[3]);
upPanel.add(b[4]);

JPanel fieldPanel = new JPanel(false);
fieldPanel.setLayout(new GridLayout(0,1));
fieldPanel.add(tfield[0]);
fieldPanel.add(box);
fieldPanel.add(tfield[1]);
fieldPanel.add(tfield[2]);
fieldPanel.add(tfield[3]);


switch( division )
{
case 0 : b[0].setSelected(true);
break;
case 1 : b[1].setSelected(true);
break;
case 3 : b[2].setSelected(true);
break;
case 4 : b[3].setSelected(true);
break;
case 5 : b[4].setSelected(true);
break;
}

main.add(upPanel);
main.add(fieldPanel);

return main;
}

public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("Go to Event"))
{
if(rowCount != 0)
{
String option[] = {"Find","Close"};
JPanel p = createGoToEvent();
while(true)
{
if(JOptionPane.showOptionDialog(this, p, "Go to Event",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null,
option, option[0]) == 0)
{
division = getSelectedItem();
SelectItem = getItemTextField();
tab.selectTable(SelectItem,rowCount,division);
}
else break;
}
}
public int selectTable(String SelData, int rCount,int division)
{
for(;entry_pos < rCount;entry_pos++)
{

if(SelData.equals(rawTable.getValueAt(entry_pos,division).to String().trim()))
{
rawTable.setRowSelectionInterval(entry_pos,entry_pos);
Rectangle a = rawTable.getCellRect(entry_pos,entry_pos, true);
rawTable.scrollRectToVisible(a);

repaint();

return entry_pos++;

}
}
entry_pos = 0;
return entry_pos;
}

public void setTableIndex ()
{
entry_pos = 0;
}

}


/***************************/

hope this is sufficient
thanx in advance
Previous Topic:displaying HTML in dialog
Next Topic:Table Cell Selection
Goto Forum:
  


Current Time: Sat Oct 24 21:32:21 GMT 2020

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

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

Back to the top