@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvDp.getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
DataPath dp = (DataPath) obj;
int[] tabImpacted = Application.getDataStore().getDataPathUsage(dp);
int nbref = 0;
StringBuffer str = new StringBuffer(256);
for (AttrType at : AttrType.values())
{
if (at.extended)
{
if (tabImpacted[at.ordinal()] > 0)
{
nbref += tabImpacted[at.ordinal()];
str.append("Type ").append(at).append(" : ").append(tabImpacted[at.ordinal()]);
}
}
}
if (nbref > 0)
{
// Deletion not possible when
MessageDialog.openWarning(_tabvDp.getControl().getShell(), "Delete DataPath", "Deletion of Datapath:"
+ dp.getName() + "impossible due to\n" + str.toString() + "\nUse Replace before");
}
else
{
// Get confirmation
boolean rb = MessageDialog.openConfirm(_tabvDp.getControl().getShell(), "Delete DataPath",
"Do you confirm the deletion of Datapath:" + dp.getName());
if (rb)
{
// Execute the deletion
Application.getDataStore().remove(dp);
_tabvDp.refresh();
}
}
}
});
_tabvDp.createMMI();
// Replace the default content provider by a filtered one
// Must be done after the createMMI
_tabvDp.setContentProvider(new IStructuredContentProvider()
{
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement)
{
List<DataPath> ldp = (List<DataPath>) inputElement;
List<DataPath> ldpf = new ArrayList<DataPath>(ldp.size());
for (DataPath dp : ldp)
{
if (dp.getStatus() != StatusCycle.DELETED)
{
ldpf.add(dp);
}
}