@Override
public void createPartControl(Composite parent)
{
this.shell = parent.getShell();
toolkit = new FormToolkit(parent.getDisplay());
ScrolledForm form = toolkit.createScrolledForm(parent);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
form.getBody().setLayout(layout);
Composite inputcomp = toolkit.createComposite(form.getBody());
createNameArea(inputcomp);
createEMailTable(inputcomp);
createTelefonTable(inputcomp);
layout = new GridLayout();
layout.numColumns = 1;
inputcomp.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
inputcomp.setLayoutData(gridData);
createBemerkungArea(form.getBody());
}
private void createBemerkungArea(Composite parent)
{
Section bemerkungsection = toolkit.createSection(parent, Section.TITLE_BAR);
bemerkungsection.setText("Bemerkung");
GridData gridData = new GridData(GridData.FILL_BOTH);
bemerkungsection.setLayoutData(gridData);
Composite bemerkungcomposite = toolkit.createComposite(bemerkungsection);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
bemerkungcomposite.setLayout(layout);
this.bemerkung = new Text(bemerkungcomposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
bemerkung.addModifyListener(ml);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
bemerkung.setLayoutData(gridData);
if (kunde.getBemerkung() == null)bemerkung.setText("");
else bemerkung.setText(kunde.getBemerkung());
bemerkungsection.setClient(bemerkungcomposite);
}
private void createEMailTable(Composite parent)
{
Section emailsection = toolkit.createSection(parent, Section.TITLE_BAR);
emailsection.setText("E-Mail Adressen");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
emailsection.setLayoutData(gridData);
Composite emailcomposite = toolkit.createComposite(emailsection);
Composite table = toolkit.createComposite(emailcomposite, SWT.SCROLL_PAGE);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
emailcomposite.setLayout(layout);
layout = new GridLayout();
layout.numColumns = 1;
table.setLayout(layout);
Table t = toolkit.createTable(table, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 70;
gd.widthHint = 100;
t.setLayoutData(gd);
toolkit.paintBordersFor(table);
//section.setClient(parent);
emailViewer = new StorableTableViewer(t,"Kundenemails");
emailContentProvider = new DefaultContentProvider(emailViewer);
emailViewer.setContentProvider(emailContentProvider);
CustomizableLabelProvider lprov = new CustomizableLabelProvider(TOKundenemail.class);
TableHeading[] heads = lprov.getHeadings();
CellEditor[] editor = new CellEditor[heads.length];
String[] headingnames = new String[heads.length];
int i = 0;
for ( TableHeading th : heads )
{
if ( th.heading.equalsIgnoreCase("Typ"))editor[i] = new ComboBoxCellEditor(t,new String[]{"Geschäftlich","Privat"} , SWT.READ_ONLY);
else if ( th.heading.equalsIgnoreCase("E-Mail Adresse"))editor[i] = new TextCellEditor(t);
else if ( th.heading.equalsIgnoreCase("Bemerkung"))
{
editor[i] = new TextCellEditor(t);
((Text)editor[i].getControl()).setTextLimit(100);
}
headingnames[i] = th.heading;
i++;
}
emailViewer.createHeaders(heads);
emailViewer.setCellEditors(editor);
emailViewer.setColumnProperties(headingnames);
emailViewer.setCellModifier(emailmodifier);
emailViewer.setLabelProvider(lprov);
Vector<TOKundenemail> mailvec = new Vector<TOKundenemail>();
for (TOKundenemail mail : this.kunde.getKundenemails())mailvec.add(mail);
emailViewer.setInput(mailvec);
emailsection.setClient(emailcomposite);
Composite buttonComposite = toolkit.createComposite(emailcomposite);
layout = new GridLayout();
layout.numColumns = 1;
buttonComposite.setLayout(layout);
Button addTel = toolkit.createButton(buttonComposite, "+", SWT.BORDER);
gd = new GridData();
gd.widthHint = 30;
gd.heightHint = 30;
addTel.setLayoutData(gd);
addTel.addSelectionListener(new SelectionListener()
{
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
TOKundenemail mail = new TOKundenemail();
mail.setAdresse("a@b.de");
mail.setTyp((byte) 0);
emailContentProvider.add(mail);
changed=true;
firePropertyChange(PROP_DIRTY);
}
@Override
public void widgetSelected(SelectionEvent e) {
TOKundenemail mail = new TOKundenemail();
mail.setAdresse("a@b.de");
mail.setTyp((byte) 0);
emailContentProvider.add(mail);
changed=true;
firePropertyChange(PROP_DIRTY);
}
});
Button remTel = toolkit.createButton(buttonComposite, "-", SWT.BORDER);
remTel.setLayoutData(gd);
remTel.addSelectionListener(new SelectionListener()
{
@SuppressWarnings("unchecked")
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
ISelection sel = emailViewer.getSelection();
if ( sel instanceof IStructuredSelection)
{
IStructuredSelection ssel = (IStructuredSelection)sel;
Iterator it = ssel.iterator();
while ( it.hasNext() )
{
emailContentProvider.remove((TOBasic) it.next());
}
changed=true;
firePropertyChange(PROP_DIRTY);
}
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
ISelection sel = emailViewer.getSelection();
if ( sel instanceof IStructuredSelection)
{
IStructuredSelection ssel = (IStructuredSelection)sel;
Iterator it = ssel.iterator();
while ( it.hasNext() )
{
emailContentProvider.remove((TOBasic) it.next());
}
changed=true;
firePropertyChange(PROP_DIRTY);
}
}
});
}
private void createTelefonTable(Composite parent)
{
Section telefonsection = toolkit.createSection(parent, Section.TITLE_BAR);
telefonsection.setText("Telefonnummern");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
telefonsection.setLayoutData(gridData);
Composite telefoncomposite = toolkit.createComposite(telefonsection);
Composite table = toolkit.createComposite(telefoncomposite, SWT.SCROLL_PAGE);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
telefoncomposite.setLayout(layout);
layout = new GridLayout();
layout.numColumns = 1;
table.setLayout(layout);
Table t = toolkit.createTable(table, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 70;
gd.widthHint = 100;
t.setLayoutData(gd);
toolkit.paintBordersFor(table);
//section.setClient(parent);
telefonviewer = new StorableTableViewer(t,"Kundentelefon");
telefonContentProvider = new DefaultContentProvider(telefonviewer);
telefonviewer.setContentProvider(telefonContentProvider);
CustomizableLabelProvider lprov = new CustomizableLabelProvider(TOKundentelefon.class);
TableHeading[] heads = lprov.getHeadings();
CellEditor[] editor = new CellEditor[heads.length];
String[] headingnames = new String[heads.length];
int i = 0;
for ( TableHeading th : heads )
{
if ( th.heading.equalsIgnoreCase("Typ"))editor[i] = new ComboBoxCellEditor(t,new String[]{"Festnetz","Geschäftlich","Handy","Fax","Sonstige"} , SWT.READ_ONLY);
else if ( th.heading.equalsIgnoreCase("Nummer"))editor[i] = new TextCellEditor(t);
else if ( th.heading.equalsIgnoreCase("Bemerkung"))
{
editor[i] = new TextCellEditor(t);
((Text)editor[i].getControl()).setTextLimit(100);
}
headingnames[i] = th.heading;
i++;
}
telefonviewer.createHeaders(heads);
telefonviewer.setCellEditors(editor);
telefonviewer.setColumnProperties(headingnames);
telefonviewer.setCellModifier(kundetelefonmodifier);
telefonviewer.setLabelProvider(lprov);
Vector<TOKundentelefon> telvec = new Vector<TOKundentelefon>();
for (TOKundentelefon tel : this.kunde.getKundentelefons())telvec.add(tel);
telefonviewer.setInput(telvec);
telefonsection.setClient(telefoncomposite);
Composite buttonComposite = toolkit.createComposite(telefoncomposite);
layout = new GridLayout();
layout.numColumns = 1;
buttonComposite.setLayout(layout);
Button addTel = toolkit.createButton(buttonComposite, "+", SWT.BORDER);
gd = new GridData();
gd.widthHint = 30;
gd.heightHint = 30;
addTel.setLayoutData(gd);
addTel.addSelectionListener(new SelectionListener()
{
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
TOKundentelefon tel = new TOKundentelefon();
tel.setNummer("(00000) 00000");
tel.setTyp((byte) 0);
telefonContentProvider.add(tel);
changed=true;
firePropertyChange(PROP_DIRTY);
}
@Override
public void widgetSelected(SelectionEvent e) {
TOKundentelefon tel = new TOKundentelefon();
tel.setNummer("(00000) 00000");
tel.setTyp((byte) 0);
telefonContentProvider.add(tel);
changed=true;
firePropertyChange(PROP_DIRTY);
}
});
Button remTel = toolkit.createButton(buttonComposite, "-", SWT.BORDER);
remTel.setLayoutData(gd);
remTel.addSelectionListener(new SelectionListener()
{
@SuppressWarnings("unchecked")
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
ISelection sel = telefonviewer.getSelection();
if ( sel instanceof IStructuredSelection)
{
IStructuredSelection ssel = (IStructuredSelection)sel;
Iterator it = ssel.iterator();
while ( it.hasNext() )
{
telefonContentProvider.remove((TOBasic) it.next());
}
changed=true;
firePropertyChange(PROP_DIRTY);
}
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
ISelection sel = telefonviewer.getSelection();
if ( sel instanceof IStructuredSelection)
{
IStructuredSelection ssel = (IStructuredSelection)sel;
Iterator it = ssel.iterator();
while ( it.hasNext() )
{
telefonContentProvider.remove((TOBasic) it.next());
}
changed=true;
firePropertyChange(PROP_DIRTY);
}
}
});
}