for (String selected : selectionResult)
{
//search among all sourceAddedEntities
for (int j = 0 ; j < sourceAddedEntities.size() ; j++)
{
EntityHolder entity = sourceAddedEntities.get(j);
//if corresponding entity is found
if (selected != null && selected.equals(entity.getName()))
{
//remove entity from sourceAddedEntities ArrayList
sourceAddedEntities.remove(j);
//remove entity keyName from source entity list
entityList.remove(selected);
}
}
}
}
});
//Target add button
targetAddButton = new Button(shell, SWT.NONE);
targetAddButton.setText("Add...");
gridData = new GridData(GridData.END, GridData.BEGINNING, true, false);
gridData.minimumWidth = 100;
gridData.horizontalIndent = 5;
targetAddButton.setLayoutData(gridData);
targetAddButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent arg0)
{
//new addEntityDialog
AddEntityDialog addEntity =
new AddEntityDialog(new Shell(), allEntities);
//open dialog
boolean addPressed = addEntity.open();
//if add button is pressed
if (addPressed)
{
//for each selected entity
for (EntityHolder entity : addEntity.getSelectedEntities())
{
//check if entity has been added before
if (!previouslyAdded(entity, targetAddedEntities))
{
//add entity keyName to target entity list
targetEntityList.add(entity.getName());
//add entity to targetAddedEntities ArrayList
targetAddedEntities.add(entity);
}
}
}
}
});
//Target remove button
targetRemoveButton = new Button(shell, SWT.NONE);
targetRemoveButton.setText("Remove");
gridData = new GridData(GridData.BEGINNING, GridData.BEGINNING,
true, false);
gridData.horizontalIndent = 5;
gridData.minimumWidth = 100;
targetRemoveButton.setLayoutData(gridData);
targetRemoveButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent arg0)
{
String[] selectionResult = targetEntityList.getSelection();
//for each selected string
for (String selected : selectionResult)
{
//search among all targetAddedEntities
for (int j = 0 ; j < targetAddedEntities.size() ; j++)
{
EntityHolder entity = targetAddedEntities.get(j);
//if corresponding entity is found
if (selected != null &&
selected.equals(entity.getName()))
{
//remove entity from targetAddedEntities ArrayList
targetAddedEntities.remove(j);
//remove entity keyName from target entity list