Hallo,
ich habe die Schwierigkeit mein GUI mit dem GUIBinding (Controller) zu binden.
Mein GUIBinding-Klasse sieht so aus:
und mein Person-Klasse:
und mein GUI-Abschnitt für den Namen:
Und das Problem beim mir, wie ich den "gespeicherterPerson.getName()" der GUIBinding mit dem GUI "nameText_1" verbinde und die "uebermittelterPerson.getName()" mit dem "nameText_2" verbinde.
Im GUI habe ich schon die Definition:
m_bindingContext = initDataBindings();
und dem Code:
Ich bitte um Hilfe, wie die Anbindung gehen würde? Oder andere Vorschläge wie man das lösen könnte?
ich habe die Schwierigkeit mein GUI mit dem GUIBinding (Controller) zu binden.
Mein GUIBinding-Klasse sieht so aus:
Code:
package presentation;
import java.sql.SQLException;
import java.util.logging.Logger;
import databaseConnection.OracleConnUtils;
import modell.Person;
public class GUIBinding extends Binding {
public Person gespeicherterPerson;
public Person uebermittelterPerson;
static protected final Logger logger = Logger.getLogger(GUIBinding.class.getName());
/**
* constructor
*
* @param binding
* @throws SQLException
*/
public GUIBinding(GeneralBinding binding) {
super(binding);
try {
init();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* clear method
*/
@Override
public void clear() {
// TODO Auto-generated method stub
}
@Override
protected void init() throws SQLException {
gespeicherterPerson= OracleConnUtils.getPersonDaten(new String("1276"), 1386, false);
uebermittelterPerson= OracleConnUtils.getPersonDaten(new String("1276"), 1386, true);
}
}
und mein Person-Klasse:
Code:
package modell;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Person{
/** The property change support. */
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
private String name;
private String vorname;
private String gebdatum;
/**
* Gets the property change support.
*
* @return the property change support
*/
public PropertyChangeSupport getPropertyChangeSupport() {
return propertyChangeSupport;
}
/**
* Sets the property change support.
*
* @param propertyChangeSupport the new property change support
*/
public void setPropertyChangeSupport(PropertyChangeSupport propertyChangeSupport) {
this.propertyChangeSupport = propertyChangeSupport;
}
/**
* Adds the property change listener.
*
* @param propertyName the property name
* @param listener the listener
*/
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
}
/**
* Removes the property change listener.
*
* @param listener the listener
*/
public void removePropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener);
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
propertyChangeSupport.firePropertyChange("name", this.name, this.name = name);
}
/**
* Gets the vorname.
*
* @return the vorname
*/
public String getVorname() {
return vorname;
}
/**
* Sets the vorname.
*
* @param vorname the new vorname
*/
public void setVorname(String vorname) {
propertyChangeSupport.firePropertyChange("vorname", this.vorname, this.vorname = vorname);
}
/**
* Gets the gebdatum.
*
* @return the gebdatum
*/
public String getGebdatum() {
return gebdatum;
}
/**
* Sets the gebdatum.
*
* @param gebdatum the new gebdatum
*/
public void setGebdatum(String gebdatum) {
propertyChangeSupport.firePropertyChange("gebdatum", this.gebdatum, this.gebdatum = gebdatum);
}
}
und mein GUI-Abschnitt für den Namen:
Code:
Label lblName = new Label(composite, SWT.NONE);
lblName.setText("Name:");
Composite composite_3 = new Composite(composite, SWT.FILL);
composite_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
GridLayout gl_composite3 = new GridLayout();
gl_composite3.numColumns = 6;
composite_3.setLayout(gl_composite3);
Button btnRadioButton_4 = new Button(composite_3, SWT.RADIO);
btnRadioButton_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
nameText_1 = new Text(composite_3, SWT.BORDER);
nameText_1.setEditable(false);
nameText_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(composite_3, SWT.NONE);
Button nameRadioButton_2 = new Button(composite_3, SWT.RADIO);
nameRadioButton_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
nameText_2 = new Text(composite_3, SWT.BORDER);
nameText_2.setEditable(false);
nameText_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(composite_3, SWT.NONE);
Im GUI habe ich schon die Definition:
m_bindingContext = initDataBindings();
und dem Code:
Code:
protected DataBindingContext initDataBindings() {
DataBindingContext bindingContext = new DataBindingContext();
return bindingContext;
}