Java Code Examples for org.eclipse.swt.widgets.Table.addListener()

The following are Jave code examples for showing how to use addListener() of the org.eclipse.swt.widgets.Table class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Hydrograph   File: ViewDataUniqueIdDialog.java   View Source Code Vote up 4 votes
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.getShell().setText("ViewData Execution History");
	container.setLayout(new GridLayout(1, false));
	
	
	Composite composite1 = new Composite(container, SWT.BORDER);
	GridData gd_scrolledComposite1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_scrolledComposite1.heightHint = 236;
	gd_scrolledComposite1.widthHint = 844;
	composite1.setLayoutData(gd_scrolledComposite1);
	
	table = new Table(composite1, SWT.BORDER | SWT.Selection | SWT.FULL_SELECTION );
	table.setBounds(0, 0, 842, 234);
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	
    for (int i = 0; i < titles.length; i++) {
      TableColumn column = new TableColumn(table, SWT.NONE);
      column.setWidth(212);
      column.setText(titles[i]);
    }
	
    jobDetails.sort((job1, job2)-> job2.getUniqueJobID().compareTo(job1.getUniqueJobID()));
    
    for(JobDetails job : jobDetails){
   		String timeStamp = getTimeStamp(job.getUniqueJobID());
   		TableItem items = new TableItem(table, SWT.None);
   		items.setText(0, job.getUniqueJobID());
   		items.setText(1, timeStamp);
   		String mode = getJobExecutionMode(job.isRemote());
   		items.setText(2, mode);
   		items.setText(3, job.getJobStatus());
    }
    
    table.addListener(SWT.Selection, new Listener() {
		@Override
		public void handleEvent(Event event) {
			TableItem[] item = table.getSelection();
			 for (int i = 0; i < item.length; i++){
				 TableItem selectedItem = item[i];
				 selectedUniqueJobId = selectedItem.getText();
		      }
		}
	});
	return super.createDialogArea(parent);
}