}
return null;
}
});
objectTemplateComboViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if(e1 instanceof ObjectTemplate && e2 instanceof ObjectTemplate) {
return ((ObjectTemplate)e1).getName().compareTo(((ObjectTemplate)e2).getName());
}
return 0;
}
});
objectTemplateComboViewer.setInput(objectInstance.getCampaign());
label = new Label(comp, SWT.RIGHT);
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
label.setText(Messages.getString("campaign.manager.ui.dialog.object_instance.builder.owner.label"));
label.setToolTipText(Messages.getString("campaign.manager.ui.dialog.object_instance.builder.owner.tooltip"));
ownerCombo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
ownerCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
ownerCombo.setToolTipText(Messages
.getString("campaign.manager.ui.dialog.object_instance.builder.owner.tooltip"));
ownerComboViewer = new ComboViewer(ownerCombo);
ownerComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
logger.debug("selection changed: " + event);
ISelection selection = event.getSelection();
logger.trace("selection: " + selection);
if(selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection)selection;
logger.trace("ss: " + ss);
Object obj = ss.getFirstElement();
logger.trace("obj: " + obj);
if(obj instanceof Participant) {
owner = (Participant)obj;
updateDialogButtons();
}
}
}
});
ownerComboViewer.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object parent) {
return objectInstance.getCampaign().getParticipants().toArray();
}
});
ownerComboViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if(element instanceof Participant) {
return ((Participant)element).getLabel();
}
return null;
}
});
ownerComboViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if(e1 instanceof Participant && e2 instanceof Participant) {
return ((Participant)e1).getName().compareTo(((Participant)e2).getName());
}