Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Problems with SWTWorkbench Essential Data

Hi

First of all I want to apologize for possible mistakes, but English isn't my
native language. I'm quite new in using Java and Eclipse, but I have some
experience in Delphi, so I've decided to try programming in Java. Lately I
have been look for tool that help me in validating users input and I found
Essential Data. I've been surprised so that wonderful set of tools exists
somewhere and I have of course install this package in my Eclipse platform
(ver. 3.1M7-win32). Next I've done all examples from Essential Data Web Site
and everything was OK (by the way is it possible to build an application not
like in the example as a plug-in but as a standard SWT Application - by
including some JAR's into project's build path?). Any way I've decided to
try using Essential Data in my simple application. And I've received
following messages on my Console View:
Exception in thread "main" java.lang.IllegalArgumentException: Property:
num_los not supported on this object
	at com.swtworkbench.ed.reflect.Property.getMethods(Property.java:98)
	at com.swtworkbench.ed.reflect.Property.<init>(Property.java:72)
	at
com.swtworkbench.ed.aware.adapters.pojo.POJOFieldAdapter.forceInput(POJOFiel
dAdapter.java:245)
	at
com.swtworkbench.ed.aware.adapters.pojo.POJOFieldAdapter.<init>(POJOFieldAda
pter.java:90)
	at lotto.com.tanu.View.initButtons(View.java:263)
	at lotto.com.tanu.View.setupUI(View.java:90)
	at
com.swtworkbench.swtutils.framework.SWTSnippet.<init>(SWTSnippet.java:59)
	at
com.swtworkbench.swtutils.framework.SWTApplication.<init>(SWTApplication.jav
a:52)
	at lotto.com.tanu.View.<init>(View.java:22)
	at lotto.com.tanu.View.main(View.java:417)

My code look as follow (1-st my Data Model object called daneLosowania):
package lotto.com.tanu;

import java.util.Calendar;

public class daneLosowania {

	private int			num_los = 1;

	private Calendar	dat_los = Calendar.getInstance();

	private byte		n1 = 1;
	private byte		n2 = 2;
	private byte 		n3 = 3;
	private byte		n4 = 4;
	private byte 		n5 = 5;
	private byte		n6 = 6;

	/**
	 * @return Returns the data_los.
	 */
	public Calendar getDat_los() {
		return dat_los;
	}

	/**
	 * @param data_los The data_los to set.
	 */
	public void setDat_los(Calendar data_los) {
		this.dat_los = data_los;
	}

	/**
	 * @return Returns the n1.
	 */
	public byte getN1() {
		return n1;
	}

	/**
	 * @param n1 The n1 to set.
	 */
	public void setN1(byte n1) {
		this.n1 = n1;
	}

	/**
	 * @return Returns the n2.
	 */
	public byte getN2() {
		return n2;
	}

	/**
	 * @param n2 The n2 to set.
	 */
	public void setN2(byte n2) {
		this.n2 = n2;
	}

	/**
	 * @return Returns the n3.
	 */
	public byte getN3() {
		return n3;
	}

	/**
	 * @param n3 The n3 to set.
	 */
	public void setN3(byte n3) {
		this.n3 = n3;
	}

	/**
	 * @return Returns the n4.
	 */
	public byte getN4() {
		return n4;
	}

	/**
	 * @param n4 The n4 to set.
	 */
	public void setN4(byte n4) {
		this.n4 = n4;
	}

	/**
	 * @return Returns the n5.
	 */
	public byte getN5() {
		return n5;
	}

	/**
	 * @param n5 The n5 to set.
	 */
	public void setN5(byte n5) {
		this.n5 = n5;
	}

	/**
	 * @return Returns the n6.
	 */
	public byte getN6() {
		return n6;
	}

	/**
	 * @param n6 The n6 to set.
	 */
	public void setN6(byte n6) {
		this.n6 = n6;
	}

	/**
	 * @return Returns the numer_los.
	 */
	public int getNum_los() {
		return num_los;
	}

	/**
	 * @param numer_los The numer_los to set.
	 */
	public void setNum_los(int numer_los) {
		this.num_los = numer_los;
	}

}

And main View called simply View:

package lotto.com.tanu;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.swtworkbench.ed.aware.adapters.pojo.POJOFieldAdapter;
import com.swtworkbench.swtutils.framework.SWTApplication;

public class View extends SWTApplication {

	private daneLosowania dL;
	private CTabFolder	ctabFolder;
	private CTabItem	ctabItem;
	private Group	group;
	private FormLayout	formLayout;
	private Button	btnPolacz;
	private Label	lblPolacz;
	private Button	btnWyswietl;
	private Button	btnGeneruj;
	private Button	btnExit;
	private Label	lblDatLos;
	private Text	data_los;
	private Label	lblNrLos;
	private Text	numer_los;
	private Label	Podaj;
	private Label	lbl1;
	private Text	n1;
	private Label	lbl2;
	private Text	n2;
	private Label	lbl3;
	private Text	n3;
	private Label	lbl4;
	private Text	n4;
	private Label	lbl5;
	private Text	n5;
	private Label	lbl6;
	private Text	n6;
	
	@Override
	protected void setupUI(Shell shell) {
		// TODO Auto-generated method stub
		dL = new daneLosowania();
		shell.setSize(550,235);
		shell.setBounds(50, 50, 550, 235);
		shell.setText("Aplikacja do generowania liczb dla Dużego
Lotka.");
		ctabFolder = new CTabFolder(shell, SWT.BORDER | SWT.TOP);
		ctabFolder.setSize(544, 200);
		
		ctabItem = initTabs(" Main ");
		group = new Group(ctabFolder, SWT.SHADOW_IN);
		formLayout = new FormLayout();
		group.setLayout(formLayout);
		
		initButtons(group, true);
		ctabItem.setControl(group);
		
		ctabItem = initTabs(" Dane ");
		
		shell.layout();
	}

	private void initButtons( Group grp, boolean start ) {
			
		btnPolacz = new Button(grp, SWT.PUSH);
		btnPolacz.setText("   &Połącz   ");
		FormData frmData = new FormData();
		frmData.left = new FormAttachment(0, 5);
		frmData.top = new FormAttachment(0, 5);
		btnPolacz.setLayoutData(frmData);
		
		lblPolacz = new Label(grp, SWT.LEFT);
		lblPolacz.setText("Nie połączony z bazą danych!");
		frmData = new FormData();
		frmData.left = new FormAttachment(btnPolacz, 10);
		frmData.top = new FormAttachment(btnPolacz, 0, SWT.CENTER);
		lblPolacz.setLayoutData(frmData);
		
		btnWyswietl = new Button(grp, SWT.PUSH);
		btnWyswietl.setText(" &Wyświetl ");
		frmData = new FormData();
		frmData.top = new FormAttachment(btnPolacz, 5);
		frmData.left = new FormAttachment(0, 5);
		btnWyswietl.setLayoutData(frmData);
		
		btnGeneruj = new Button(grp, SWT.PUSH);
		btnGeneruj.setText(" &Generuj  ");
		frmData = new FormData();
		frmData.top = new FormAttachment(btnWyswietl, 5);
		frmData.left = new FormAttachment(0, 5);
		btnGeneruj.setLayoutData(frmData);
		
		btnExit = new Button(grp, SWT.PUSH);
		btnExit.setText(" &Zakończ  ");
		frmData = new FormData();
		frmData.top = new FormAttachment(btnGeneruj, 5);
		frmData.left = new FormAttachment(0, 5);
		btnExit.setLayoutData(frmData);
		
		lblDatLos = new Label(grp, SWT.LEFT);
		lblDatLos.setText("Podaj datę losowania: (rrrr-mm-dd) ");
		frmData = new FormData();
		frmData.left = new FormAttachment(lblPolacz, 20);
		frmData.top = new FormAttachment(lblPolacz, 0, SWT.CENTER);
		lblDatLos.setLayoutData(frmData);
		
		data_los = new Text(group, SWT.BORDER | SWT.SINGLE);
		// data_los.setText("    -  -  ");
		// data_los.setTextLimit(10);
		frmData = new FormData();
		frmData.left = new FormAttachment(lblDatLos, 5);
		frmData.top = new FormAttachment(lblDatLos, 0, SWT.CENTER);
		frmData.width = 45;
		data_los.setLayoutData(frmData);
		
		lblNrLos = new Label(grp, SWT.LEFT);
		lblNrLos.setText("Podaj numer losowania: (4 cyfry) ");
		frmData = new FormData();
		frmData.left = new FormAttachment(lblPolacz, 20);
		frmData.top = new FormAttachment(lblDatLos, 10);
		lblNrLos.setLayoutData(frmData);
		
		numer_los = new Text(group, SWT.BORDER | SWT.SINGLE);
		// numer_los.setTextLimit(4);
		frmData = new FormData();
		frmData.top = new FormAttachment(lblNrLos, 0, SWT.CENTER);
		frmData.left = new FormAttachment(lblNrLos, 15);
		frmData.width = 25;
		numer_los.setLayoutData(frmData);
		
		Podaj = new Label(grp, SWT.LEFT);
		Podaj.setText("Podaj Wylosowane numery :");
		frmData = new FormData();
		frmData.left = new FormAttachment(lblPolacz, 20);
		frmData.top = new FormAttachment(lblNrLos, 10);
		Podaj.setLayoutData(frmData);
		
		lbl1 = new Label(grp, SWT.LEFT);
		lbl1.setText("Nr 1");
		frmData = new FormData();
		frmData.left = new FormAttachment(lblPolacz, 21);
		frmData.top = new FormAttachment(Podaj, 5);
		lbl1.setLayoutData(frmData);
		
		n1 = new Text(group, SWT.BORDER | SWT.SINGLE);
		// n1.setTextLimit(2);
		frmData = new FormData();
		frmData.left = new FormAttachment(lblPolacz, 20);
		frmData.top = new FormAttachment(lbl1, 5);
		frmData.width = 13;
		n1.setLayoutData(frmData);
		
		lbl2 = new Label(grp, SWT.LEFT);
		lbl2.setText("Nr 2");
		frmData = new FormData();
		frmData.left = new FormAttachment(lbl1, 19);
		frmData.top = new FormAttachment(Podaj, 5);
		lbl2.setLayoutData(frmData);
		
		n2 = new Text(group, SWT.BORDER | SWT.SINGLE);
		// n2.setTextLimit(2);
		frmData = new FormData();
		frmData.left = new FormAttachment(n1, 12);
		frmData.top = new FormAttachment(lbl1, 5);
		frmData.width = 13;
		n2.setLayoutData(frmData);

		lbl3 = new Label(grp, SWT.LEFT);
		lbl3.setText("Nr 3");
		frmData = new FormData();
		frmData.left = new FormAttachment(lbl2, 17);
		frmData.top = new FormAttachment(Podaj, 5);
		lbl3.setLayoutData(frmData);
		
		n3 = new Text(group, SWT.BORDER | SWT.SINGLE);
		// n3.setTextLimit(2);
		frmData = new FormData();
		frmData.left = new FormAttachment(n2, 12);
		frmData.top = new FormAttachment(lbl2, 5);
		frmData.width = 13;
		n3.setLayoutData(frmData);

		lbl4 = new Label(grp, SWT.LEFT);
		lbl4.setText("Nr 4");
		frmData = new FormData();
		frmData.left = new FormAttachment(lbl3, 17);
		frmData.top = new FormAttachment(Podaj, 5);
		lbl4.setLayoutData(frmData);
		
		n4 = new Text(group, SWT.BORDER | SWT.SINGLE);
		// n4.setTextLimit(2);
		frmData = new FormData();
		frmData.left = new FormAttachment(n3, 12);
		frmData.top = new FormAttachment(lbl4, 5);
		frmData.width = 13;
		n4.setLayoutData(frmData);

		lbl5 = new Label(grp, SWT.LEFT);
		lbl5.setText("Nr 5");
		frmData = new FormData();
		frmData.left = new FormAttachment(lbl4, 17);
		frmData.top = new FormAttachment(Podaj, 5);
		lbl5.setLayoutData(frmData);
		
		n5 = new Text(group, SWT.BORDER | SWT.SINGLE);
		// n5.setTextLimit(2);
		frmData = new FormData();
		frmData.left = new FormAttachment(n4, 12);
		frmData.top = new FormAttachment(lbl5, 5);
		frmData.width = 13;
		n5.setLayoutData(frmData);

		lbl6 = new Label(grp, SWT.LEFT);
		lbl6.setText("Nr 6");
		frmData = new FormData();
		frmData.left = new FormAttachment(lbl5, 17);
		frmData.top = new FormAttachment(Podaj, 5);
		lbl6.setLayoutData(frmData);
		
		n6 = new Text(group, SWT.BORDER | SWT.SINGLE);
		// n6.setTextLimit(2);
		frmData = new FormData();
		frmData.left = new FormAttachment(n5, 12);
		frmData.top = new FormAttachment(lbl6, 5);
		frmData.width = 13;
		n6.setLayoutData(frmData);
		
		new POJOFieldAdapter(numer_los, "num_los", dL);
	    new POJOFieldAdapter(data_los, "dat_los", dL);
	    new POJOFieldAdapter(n1, "n1", dL);
	    new POJOFieldAdapter(n2, "n2", dL);
	    new POJOFieldAdapter(n3, "n3", dL);
	    new POJOFieldAdapter(n4, "n4", dL);
	    new POJOFieldAdapter(n5, "n5", dL);
	    new POJOFieldAdapter(n6, "n6", dL);
}

Does anyone can help me? Exception points to the FIRST new POJOFieldAdapter
(num_los is of type int), after I've comment out this line the same
exceptions pointed to the second new POJOFieldAdapter and so on. Please give
me ANY answer what am I doing wrong ?

Best Regards

Thomas Anus (PL);




Back to the top