Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » WB Bindings Not Working Properly(After updating to WB 1.1.0 ... and SWT Designer 1.1.0 ...)
WB Bindings Not Working Properly [message #735067] Mon, 10 October 2011 20:10 Go to next message
Eric  is currently offline Eric Friend
Messages: 3
Registered: February 2010
Junior Member
Hi,

I have an RCP application with multiple plugins running for the last six months without any problems. We update our Eclipse 3.6.2 with the WB 1.1.0 ... and SWT Designer 1.1.0 ... and the binding in our viewer starting to behave strangely.

We have multiple Views with a tableviewer and a few text boxes each. We binded the tableviewer so when selecting a row on the table the data selected shows in the text boxes. This worked for the last six months. Now we updated to version 1.1.0 ... (WB and SWT Designer) and ran the application, now when we select a row in the said table for the first time the data is shown in the text boxes; if we select another row, the text boxes are no longer updating to the new selected values.

What is wrong? It worked before (verion 1.0.0 ...) but now is different. I have not found anything different in the documentation. I am sure that I am missing something with the new version, but I cannot figure out what it is.

Any help will be appreciated.

Thanks,

eric
Re: WB Bindings Not Working Properly [message #735083 is a reply to message #735067] Mon, 10 October 2011 21:39 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
You didn't provide a test case, but you seem to be describing runtime behavior rather than anything to do with WindowBuilder itself.

Did the code for your app change? If so, what exactly changed?

Did you change your Eclipse version at all?
Re: WB Bindings Not Working Properly [message #735445 is a reply to message #735083] Tue, 11 October 2011 20:23 Go to previous messageGo to next message
Eric  is currently offline Eric Friend
Messages: 3
Registered: February 2010
Junior Member
Hi Eric,

Thank you for your response.

Quote:
Did the code for your app change? If so, what exactly changed?

Nothing changed, I just upgraded and recompiled.

Quote:
Did you change your Eclipse version at all?

Same version.

Here is my code:

Database access through Annotations and Hibernate (Its own plugin)
package edu.unmc.cns.condb.model.hibernate.db;



import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;


import edu.unmc.cns.condb.model.AbstractModelObject;

/**
 * AbstractDistributionType entity provides the base persistence definition of
 * the DistributionType entity. 
 * @author eric
 */
@MappedSuperclass
public abstract class AbstractDistributionType extends AbstractModelObject implements java.io.Serializable {

	// Fields

	private Integer distributionTypeID;
	private String distributionType;
	private String description;

	// Constructors

	/** default constructor */
	public AbstractDistributionType() {
	}

	/** minimal constructor */
	public AbstractDistributionType(String distributionType) {
		this.distributionType = distributionType;
	}


	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "distributiontype_id", unique = true, nullable = false, updatable = false)
	public Integer getDistributionTypeID() {
		return this.distributionTypeID;
	}

	public void setDistributionTypeID(Integer distributionTypeID) {
		this.distributionTypeID = distributionTypeID;
	}

	@Column(name = "distributiontype", unique = true, nullable = false, length = 50, updatable = false)
	public String getDistributionType() {
		return this.distributionType;
	}

	public void setDistributionType(String distributionType) {
		this.distributionType = distributionType;
	}

	@Column(name = "description", length = 50, updatable = false)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	@Override
	public String toString(){
		return this.distributionType;
	}

}




package edu.unmc.cns.condb.model.hibernate.db;


import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * DistributionType entity. 
 * @author eric
 */
@Entity
@Table(name = "tbldistributiontypes", schema = "public")
public class DistributionType extends AbstractDistributionType implements java.io.Serializable {

	// Constructors

	/** default constructor */
	public DistributionType() {
	}

	/** minimal constructor */
	public DistributionType(String distributionType) {
		super(distributionType);
	}


}



Distribution Plugin...

Model for the bindings.
package edu.unmc.cns.mcnp.distribution.model;

import java.util.ArrayList;
import java.util.List;

import edu.unmc.cns.condb.model.hibernate.db.DistributionType;

/**
 * @author eric
 * 
 */
public class DistributionTypes extends AbstractModelObject {

	private List<DistributionType> distributionTypes = new ArrayList<DistributionType>();

	/**
	 * 
	 */
	public DistributionTypes() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @return the distributionTypes
	 */
	public List<DistributionType> getDistributionTypes() {
		return distributionTypes;
	}

	/**
	 * @param distributionTypes
	 *            the distributionTypes to set
	 */
	public void setDistributionTypes(List<DistributionType> distributionTypes) {
		this.distributionTypes = distributionTypes;
		firePropertyChange("distributionTypes", null, distributionTypes);
	}

	public void addDistributionType(DistributionType dtype) {
		this.distributionTypes.add(dtype);
		firePropertyChange("distributionTypes", null, distributionTypes);
	}

	public void removeDistributionType(DistributionType dtype) {
		this.distributionTypes.remove(dtype);
		firePropertyChange("distributionTypes", null, distributionTypes);
	}

}




package edu.unmc.cns.mcnp.distribution.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/**
 * @author eric
 * 
 */
public class AbstractModelObject {

	private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		propertyChangeSupport.addPropertyChangeListener(listener);
	}

	public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
		propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		propertyChangeSupport.removePropertyChangeListener(listener);
	}

	public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
		propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
	}

	protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
		propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
	}

}



The view part and a controller.


package edu.unmc.cns.mcnp.distribution.view;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

import com.swtdesigner.SWTResourceManager;

import edu.unmc.cns.mcnp.distribution.view.controller.DistributionTypeViewController;

public class DistributionTypeView extends ViewPart {

	public static final String ID = "edu.unmc.cns.mcnp.distribution.view.DistributionTypeView_ID"; //$NON-NLS-1$

	private Group grpDistributionTypeList;
	private Label lblManageDistributionType;
	private Table tbldistrotype;
	private TableViewer tableViewer;
	private TableColumn tblclmnId;
	private TableViewerColumn tableViewerColumn;
	private TableColumn tblclmnType;
	private TableViewerColumn tableViewerColumn_1;
	private TableColumn tblclmnDescription;
	private TableViewerColumn tableViewerColumn_2;
	private TableColumn tblclmnLastUpdated;
	private TableViewerColumn tableViewerColumn_3;
	private Group grpEditDistributionType;
	private Label lblDistributionType;
	private Text txtDistributiontype;
	private Label lblDescription;
	private Text txtDescription;
	private Composite composite;
	private Label label;
	private Label label_1;
	private Button btnSave;
	private Label label_2;
	private Button btnClear;

	private boolean newrecord = true;

	private DistributionTypeViewController m_controller;

	public DistributionTypeView() {
	}

	/**
	 * Create contents of the view part.
	 * 
	 * @param parent
	 */
	@Override
	public void createPartControl(Composite parent) {
		Composite container = new Composite(parent, SWT.NONE);
		container.setLayout(new FormLayout());

		this.grpDistributionTypeList = new Group(container, SWT.NONE);
		this.grpDistributionTypeList.setText("Distribution Type List");
		this.grpDistributionTypeList.setLayout(new GridLayout(1, false));
		FormData fd_grpDistributionTypeList = new FormData();
		fd_grpDistributionTypeList.bottom = new FormAttachment(50);
		fd_grpDistributionTypeList.right = new FormAttachment(100, -10);
		fd_grpDistributionTypeList.top = new FormAttachment(0, 10);
		fd_grpDistributionTypeList.left = new FormAttachment(0, 10);
		this.grpDistributionTypeList.setLayoutData(fd_grpDistributionTypeList);

		this.lblManageDistributionType = new Label(this.grpDistributionTypeList, SWT.NONE);
		this.lblManageDistributionType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		this.lblManageDistributionType.setText("Manage Distribution Type");
		this.lblManageDistributionType.setFont(SWTResourceManager.getFont("Tahoma", 12, SWT.BOLD));

		tableViewer = new TableViewer(this.grpDistributionTypeList, SWT.BORDER | SWT.FULL_SELECTION);

		this.tbldistrotype = tableViewer.getTable();
		this.tbldistrotype.setLinesVisible(true);
		this.tbldistrotype.setHeaderVisible(true);
		this.tbldistrotype.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		tableViewerColumn = new TableViewerColumn(this.tableViewer, SWT.NONE);
		this.tblclmnId = tableViewerColumn.getColumn();
		this.tblclmnId.setWidth(50);
		this.tblclmnId.setText("ID");

		tableViewerColumn_1 = new TableViewerColumn(this.tableViewer, SWT.NONE);
		this.tblclmnType = tableViewerColumn_1.getColumn();
		this.tblclmnType.setWidth(150);
		this.tblclmnType.setText("Type");

		tableViewerColumn_2 = new TableViewerColumn(this.tableViewer, SWT.NONE);
		this.tblclmnDescription = tableViewerColumn_2.getColumn();
		this.tblclmnDescription.setWidth(200);
		this.tblclmnDescription.setText("Description");

		tableViewerColumn_3 = new TableViewerColumn(this.tableViewer, SWT.NONE);
		this.tblclmnLastUpdated = tableViewerColumn_3.getColumn();
		this.tblclmnLastUpdated.setWidth(100);
		this.tblclmnLastUpdated.setText("Last Updated");

		this.grpEditDistributionType = new Group(container, SWT.NONE);
		this.grpEditDistributionType.setText("Edit Distribution Type");
		this.grpEditDistributionType.setLayout(new GridLayout(2, false));
		FormData fd_grpEditDistributionType = new FormData();
		fd_grpEditDistributionType.bottom = new FormAttachment(100, -10);
		fd_grpEditDistributionType.right = new FormAttachment(this.grpDistributionTypeList, 0, SWT.RIGHT);
		fd_grpEditDistributionType.top = new FormAttachment(this.grpDistributionTypeList, 5);
		fd_grpEditDistributionType.left = new FormAttachment(this.grpDistributionTypeList, 0, SWT.LEFT);
		this.grpEditDistributionType.setLayoutData(fd_grpEditDistributionType);

		this.lblDistributionType = new Label(this.grpEditDistributionType, SWT.NONE);
		this.lblDistributionType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		this.lblDistributionType.setText("Distribution Type");

		this.txtDistributiontype = new Text(this.grpEditDistributionType, SWT.BORDER);

		this.txtDistributiontype.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		this.lblDescription = new Label(this.grpEditDistributionType, SWT.NONE);
		this.lblDescription.setText("Description");

		this.txtDescription = new Text(this.grpEditDistributionType, SWT.BORDER);
		this.txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		new Label(this.grpEditDistributionType, SWT.NONE);
		new Label(this.grpEditDistributionType, SWT.NONE);
		new Label(this.grpEditDistributionType, SWT.NONE);

		this.composite = new Composite(this.grpEditDistributionType, SWT.NONE);
		this.composite.setLayout(new FillLayout(SWT.HORIZONTAL));
		GridData gd_composite = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		gd_composite.heightHint = 32;
		this.composite.setLayoutData(gd_composite);

		this.label = new Label(this.composite, SWT.NONE);

		this.label_1 = new Label(this.composite, SWT.NONE);

		this.btnSave = new Button(this.composite, SWT.NONE);
		this.btnSave.setText("Save");
		this.btnSave.setEnabled(false);

		this.label_2 = new Label(this.composite, SWT.NONE);

		this.btnClear = new Button(this.composite, SWT.NONE);
		this.btnClear.setText("Clear");

		m_controller = new DistributionTypeViewController(this);

		createActions();
		initializeToolBar();
		initializeMenu();
	}

	/**
	 * Create the actions.
	 */
	private void createActions() {
		// Create the actions
	}

	/**
	 * Initialize the toolbar.
	 */
	private void initializeToolBar() {
		IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
	}

	/**
	 * Initialize the menu.
	 */
	private void initializeMenu() {
		IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
	}

	@Override
	public void setFocus() {
		// Set the focus
	}

	public TableViewer getTableViewer() {
		return tableViewer;
	}

	public Text getTxtDistributiontype() {
		return txtDistributiontype;
	}

	public Text getTxtDescription() {
		return txtDescription;
	}

}


package edu.unmc.cns.mcnp.distribution.view.controller;

import java.util.List;

import edu.unmc.cns.condb.model.hibernate.db.DistributionType;
import edu.unmc.cns.condb.model.hibernate.db.dao.DistributionTypeDAO;
import edu.unmc.cns.mcnp.distribution.model.DistributionTypes;
import edu.unmc.cns.mcnp.distribution.view.DistributionTypeView;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;

/**
 * @author eric
 * 
 */
public class DistributionTypeViewController {
	private DataBindingContext m_bindingContext;

	private DistributionTypeView m_distributionTypeView = null;
	private DistributionType m_distributionType = new DistributionType();
	private DistributionTypes m_distributiontypes = new DistributionTypes();

	/**
	 * 
	 */
	public DistributionTypeViewController(DistributionTypeView m_distributionTypeView) {
		this.m_distributionTypeView = m_distributionTypeView;
		initializeData();
		m_bindingContext = initDataBindings();
	}

	private void initializeData() {
		DistributionTypeDAO dao = new DistributionTypeDAO();

		List<DistributionType> types = dao.findAll();

		for (DistributionType dtype : types) {
			this.m_distributiontypes.addDistributionType(dtype);
		}
	}

	/**
	 * @param m_distributionTypeView
	 *            the m_distributionTypeView to set
	 */
	public void setM_distributionTypeView(DistributionTypeView m_distributionTypeView) {
		this.m_distributionTypeView = m_distributionTypeView;
	}

	/**
	 * @return the m_distributionTypeView
	 */
	public DistributionTypeView getM_distributionTypeView() {
		return m_distributionTypeView;
	}

	/**
	 * @param m_distributiontypes
	 *            the m_distributiontypes to set
	 */
	public void setM_distributiontypes(DistributionTypes m_distributiontypes) {
		this.m_distributiontypes = m_distributiontypes;
	}

	/**
	 * @return the m_distributiontypes
	 */
	public DistributionTypes getM_distributiontypes() {
		return m_distributiontypes;
	}
	protected DataBindingContext initDataBindings() {
		DataBindingContext bindingContext = new DataBindingContext();
		//
		ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
		m_distributionTypeView.getTableViewer().setContentProvider(listContentProvider);
		//
		IObservableMap[] observeMaps = BeansObservables.observeMaps(listContentProvider.getKnownElements(), DistributionType.class, new String[]{"distributionTypeID", "distributionType", "description", "ctlUpdDTTM"});
		m_distributionTypeView.getTableViewer().setLabelProvider(new ObservableMapLabelProvider(observeMaps));
		//
		IObservableList distributiontypesDistributionTypesObserveList = BeansObservables.observeList(Realm.getDefault(), m_distributiontypes, "distributionTypes");
		m_distributionTypeView.getTableViewer().setInput(distributiontypesDistributionTypesObserveList);
		//
		IObservableValue distributionTypeViewgetTxtDistributiontypeObserveTextObserveWidget = SWTObservables.observeText(m_distributionTypeView.getTxtDistributiontype(), SWT.Modify);
		IObservableValue distributionTypeViewgetTableViewerObserveSingleSelection = ViewersObservables.observeSingleSelection(m_distributionTypeView.getTableViewer());
		IObservableValue distributionTypeViewgetTableViewerDistributionTypeObserveDetailValue = BeansObservables.observeDetailValue(distributionTypeViewgetTableViewerObserveSingleSelection, DistributionType.class, "distributionType", String.class);
		bindingContext.bindValue(distributionTypeViewgetTxtDistributiontypeObserveTextObserveWidget, distributionTypeViewgetTableViewerDistributionTypeObserveDetailValue, null, null);
		//
		IObservableValue distributionTypeViewgetTxtDescriptionObserveTextObserveWidget = SWTObservables.observeText(m_distributionTypeView.getTxtDescription(), SWT.Modify);
		IObservableValue distributionTypeViewgetTableViewerObserveSingleSelection_1 = ViewersObservables.observeSingleSelection(m_distributionTypeView.getTableViewer());
		IObservableValue distributionTypeViewgetTableViewerDescriptionObserveDetailValue = BeansObservables.observeDetailValue(distributionTypeViewgetTableViewerObserveSingleSelection_1, DistributionType.class, "description", String.class);
		bindingContext.bindValue(distributionTypeViewgetTxtDescriptionObserveTextObserveWidget, distributionTypeViewgetTableViewerDescriptionObserveDetailValue, null, null);
		//
		return bindingContext;
	}
}




Like I stated before, this has been working for the last six months. There has been no changes to the code nor we have updated the Eclipse version.

Hope this help.

Thanks again for your help.

eric
Re: WB Bindings Not Working Properly [message #735449 is a reply to message #735445] Tue, 11 October 2011 20:39 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
This does not appear to be a WindowBuilder issue of any kind. You are describing a runtime problem and WB is a design time tool. There are no WB dependencies in your code, so it would not have any effect either way. The Eclipse JFace forum would be the best place to ask questions about the Eclipse DB framework itself.

What do you mean when you say that you "upgraded and recompiled"? You said your code was unchanged so, what was recompiled and why? Are you using the exact same version of the Eclipse DB jars?

If your code has not changed and you are now seeing different behavior, something in your dependency chain must have changed.
Re: WB Bindings Not Working Properly [message #735653 is a reply to message #735449] Wed, 12 October 2011 13:35 Go to previous messageGo to next message
Eric  is currently offline Eric Friend
Messages: 3
Registered: February 2010
Junior Member
Hi Eric,

Thank you again for your reply.

What I mean with the upgrade is I removed WB and SWT Designer 1.0 and updated to WB 1.1 and SWT Designer 1.1. By recompiled, after the said update I recompile the source code with the new version (1.1).

Thanks for taking the time and I will take your advice and take it to the Eclipse JFace forum.

Once again, thank you for your support.

eric
Re: WB Bindings Not Working Properly [message #735658 is a reply to message #735653] Wed, 12 October 2011 13:45 Go to previous message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
I'm not sure what you mean by "I recompile the source code with the new version (1.1)." Upgrading WindowBuilder would not cause a recompile and would have no effect on recompilation if triggered manually. WindowBuilder is a development tool, so it would not appear on your classpath and would not be a dependency for your project.

Did you use WindowBuilder to modify the source code in some way. You stated that your source code had not changed which implies that WindowBuilder did nothing to it to alter its behavior. Something does not add up here. Either your source code has changed or something on your classpath has changed. Posting your project classpath might help.
Previous Topic:Cant install SWT designer on eclipse 3.7
Next Topic:What is the purpose of WindowBuilder XML Core feature?
Goto Forum:
  


Current Time: Sat Apr 20 01:34:00 GMT 2024

Powered by FUDForum. Page generated in 0.03681 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top