Composite body = managedForm.getForm().getBody();
body.setLayout(FormLayoutFactory.createFormTableWrapLayout(true, 2));
Composite left = toolkit.createComposite(body);
left.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1));
left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
Section section = Parts.createStaticSection(toolkit, left, "Folders");
Composite container = toolkit.createComposite(section, SWT.NONE);
container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 2));
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
container.setLayoutData(data);
_tabvFolder = new ValuedInstanceTableViewer(container, SWT.SINGLE | SWT.FULL_SELECTION, _inpFd);
TableWrapData data_tabv = new TableWrapData(TableWrapData.FILL_GRAB);
data_tabv.grabVertical = true;
data_tabv.heightHint = 400;
_tabvFolder.getTable().setLayoutData(data_tabv);
_tabvFolder.addModifyListener(new ModifyListener()
{
@Override
public void modifyText(ModifyEvent e)
{
setDirty(true);
}
});
_tabvFolder.addSelectionChangedListener(new ISelectionChangedListener()
{
@Override
public void selectionChanged(SelectionChangedEvent event)
{
// Display the cards of the folder, when it is selected
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.createButton(containerBtn, "Add", SWT.PUSH);
Button btnRem = toolkit.createButton(containerBtn, "Delete", SWT.PUSH);
// Implement mass card import
Button btnMassImport = toolkit.createButton(containerBtn, "Import", SWT.PUSH);
_tabvFolder.createMMI();
btnAdd.addSelectionListener(new SelectionAdapter()
{
/**
* Add Folder Callback
*/
@Override
public void widgetSelected(SelectionEvent e)
{
// Create a new folder
_inpFdn.create();
setDirty(true);
_tabvFolder.refresh();
}
});
btnRem.addSelectionListener(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();
}
}
});
// Create the Mass Import Dialog
btnMassImport.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
ISelection selection = _tabvFolder.getSelection();
if (!selection.isEmpty())
{
Folder f = (Folder) ((IStructuredSelection) selection).getFirstElement();
// Open the mapping dialog
Attribut a1 = null;
for (Attribut a : _inpFd.getCardDescription().getAttributList())
{
if (a.getType() == AttrType.T_Image)
{
a1 = a;
break;
}
}
if (a1 != null)
{
DirectoryDialog dd = new DirectoryDialog(_tabvFolder.getControl().getShell());
String fndir = dd.open();
File fdir = new File(fndir);
File[] tabMMFile = fdir.listFiles();
CardImportMonitor op = new CardImportMonitor(f, a1, tabMMFile);
try
{
new ProgressMonitorDialog(_tabvFolder.getControl().getShell()).run(true, false, op);
}
catch (InvocationTargetException e1)
{
e1.printStackTrace();
}
catch (InterruptedException e1)
{
e1.printStackTrace();
}
if (op.res != C_ERROR)
{
setDirty(true);
_tabvFolder.refresh();
// Refresh the card table viewer too
_tabvCard.refresh();
}
}
else
{
MessageDialog.openError(_tabvFolder.getControl().getShell(), "Usage Error",
"No multimedia attribut in card description");
}
}
}
});
section.setClient(container);
// Create the card section, if the description has any card description
if (_inpFd.getAttributList().isEmpty())
{
_tabvCard = null;
}
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()