ISelection selection = _tabvFolder.getSelection();
if ((_tabvCard != null) && !selection.isEmpty())
{
Object obj = ((IStructuredSelection) selection).getFirstElement();
Folder f = (Folder) obj;
// System.out.println("Selection Changed on _tabvFolder : " + f.getID());
_tabvCard.setInput(f.getLstCard());
_tabvCard.refresh();
}
}
});
Composite containerBtn = toolkit.createComposite(container, SWT.NONE);
containerBtn.setLayout(FormLayoutFactory.createClearGridLayout(true, 1));
/* Button btnAdd = */toolkit.createGridButton(containerBtn, "Add", new SelectionAdapter()
{
/**
* Add Folder Callback
*/
@Override
public void widgetSelected(SelectionEvent e)
{
// Create a new folder
_inpFdn.create();
setDirty(true);
_tabvFolder.refresh();
}
});
/* Button btnRem = */toolkit.createGridButton(containerBtn, "Delete", new SelectionAdapter()
{
/**
* Remove Folder Callback
*/
@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Object obj = ((IStructuredSelection) selection).getFirstElement();
Folder f = (Folder) obj;
_inpFdn.remove(f);
setDirty(true);
_tabvFolder.refresh();
}
}
});
Button btnBrwCard = toolkit.createGridButton(containerBtn, "Browse", new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Folder f = (Folder) ((IStructuredSelection) selection).getFirstElement();
HIDB2Toolkit.BrowseCard(_tabvCard.getControl().getShell(), f);
}
}
});
/* Button btnCheckCard = */toolkit.createGridButton(containerBtn, "Check", new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Folder f = (Folder) ((IStructuredSelection) selection).getFirstElement();
HIDB2Toolkit.checkFiles(_tabvCard.getControl().getShell(), f);
}
}
});
// Check all images attributs of a folder with regard to the files of a directory
/* Button btnCheckCardDir = */toolkit.createGridButton(containerBtn, "Check Dir", new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Folder f = (Folder) ((IStructuredSelection) selection).getFirstElement();
int res = HIDB2Toolkit.checkCardDir(_tabvCard.getControl().getShell(), f);
if (res != C_ERROR)
{
setDirty(true);
_tabvFolder.refresh();
// Refresh the card table viewer too
_tabvCard.refresh();
}
}
}
});
// Implement mass card import
/* Button btnMassImport = */toolkit.createGridButton(containerBtn, "Import", new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Folder f = (Folder) ((IStructuredSelection) selection).getFirstElement();
int res = HIDB2Toolkit.massImport(_tabvFolder.getControl().getShell(), f);
if (res != C_ERROR)
{
setDirty(true);
_tabvFolder.refresh();
// Refresh the card table viewer too
_tabvCard.refresh();
}
}
}
});
_tabvFolder.createMMI();
section.setClient(container);
// Create the card section, if the description has any card description
if (_inpFd.getAttributList().isEmpty())
{
_tabvCard = null;
btnBrwCard.setEnabled(false);
}
else
{
Composite right = toolkit.createComposite(body);
right.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1));
right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
Section sectionR = Parts.createStaticSection(toolkit, right, "Cards");
Composite containerR = toolkit.createComposite(sectionR, SWT.NONE);
containerR.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 2));
TableWrapData dataR = new TableWrapData(TableWrapData.FILL_GRAB);
container.setLayoutData(dataR);
// Create Card table
_tabvCard = new ValuedInstanceTableViewer(containerR, SWT.SINGLE | SWT.FULL_SELECTION, _inpFd
.getCardDescription());
TableWrapData data_tabv2 = new TableWrapData(TableWrapData.FILL_GRAB);
data_tabv2.grabVertical = true;
data_tabv2.heightHint = 400;
_tabvCard.getTable().setLayoutData(data_tabv2);
_tabvCard.addModifyListener(new ModifyListener()
{
@Override
public void modifyText(ModifyEvent e)
{
setDirty(true);
}
});
Composite containerBtnCard = toolkit.createComposite(containerR, SWT.NONE);
containerBtnCard.setLayout(FormLayoutFactory.createClearGridLayout(true, 1));
Button btnAddCard = toolkit.createButton(containerBtnCard, "Add", SWT.PUSH);
Button btnRemCard = toolkit.createButton(containerBtnCard, "Delete", SWT.PUSH);
btnAddCard.addSelectionListener(new SelectionAdapter()
{
/**
* Add Callback
*/
@Override
public void widgetSelected(SelectionEvent e)
{
// Create a new card in the selected folder
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Folder f = (Folder) ((IStructuredSelection) selection).getFirstElement();
// Create the Card
Application.getDataStore().createCard(f);
setDirty(true);
_tabvCard.refresh();
}
}
});
btnRemCard.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Folder f = (Folder) ((IStructuredSelection) selection).getFirstElement();
ISelection selCard = _tabvCard.getSelection();
if (!selCard.isEmpty())
{
Card crd = (Card) ((IStructuredSelection) selCard).getFirstElement();