[svn r311] updated x4o for null value bug, and made sure exception come more to the front
This commit is contained in:
parent
6a2813f43d
commit
2cc86c0bfc
Binary file not shown.
|
@ -26,6 +26,9 @@
|
|||
|
||||
package com.idcanet.vasc.core.column;
|
||||
|
||||
import com.idcanet.x4o.element.ElementParameterException;
|
||||
import com.idcanet.x4o.element.ElementParameterNotFoundException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
|
@ -33,7 +36,7 @@ package com.idcanet.vasc.core.column;
|
|||
*/
|
||||
public interface VascColumnValue {
|
||||
|
||||
public Object getValue(VascTableColumn column,Object record) throws Exception;
|
||||
public Object getValue(VascTableColumn column,Object record) throws ElementParameterException,ElementParameterNotFoundException;
|
||||
|
||||
public void setValue(VascTableColumn column,Object record,Object value) throws Exception;
|
||||
public void setValue(VascTableColumn column,Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException;
|
||||
}
|
|
@ -27,6 +27,8 @@
|
|||
package com.idcanet.vasc.core.ui;
|
||||
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
import com.idcanet.x4o.element.ElementParameterException;
|
||||
import com.idcanet.x4o.element.ElementParameterNotFoundException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -46,7 +48,7 @@ public class VascColumnValueModelListener implements VascValueModelListener {
|
|||
setBean(bean);
|
||||
}
|
||||
|
||||
public void valueUpdate(VascValueModel model) throws Exception {
|
||||
public void valueUpdate(VascValueModel model) throws ElementParameterException,ElementParameterNotFoundException {
|
||||
vascTableColumn.getVascColumnValue().setValue(vascTableColumn, bean, model.getValue());
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.x4o.element.ElementParameterException;
|
||||
import com.idcanet.x4o.element.ElementParameterNotFoundException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -41,24 +43,20 @@ public class VascValueModel {
|
|||
|
||||
private Object value = null;
|
||||
private List<VascValueModelListener> listeners = null;
|
||||
private VascTable table = null;
|
||||
//private VascTable table = null;
|
||||
|
||||
public VascValueModel(VascTable table) {
|
||||
listeners = new ArrayList<VascValueModelListener>(2);
|
||||
this.table=table;
|
||||
//this.table=table;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
public void setValue(Object value) throws ElementParameterException,ElementParameterNotFoundException {
|
||||
this.value = value;
|
||||
try {
|
||||
fireListeners();
|
||||
} catch (Exception e) {
|
||||
table.getVascTableController().handleException(e, table);
|
||||
}
|
||||
fireListeners();
|
||||
}
|
||||
|
||||
public void addListener(VascValueModelListener l) {
|
||||
|
@ -67,7 +65,7 @@ public class VascValueModel {
|
|||
public void removeListener(VascValueModelListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
private void fireListeners() throws Exception {
|
||||
private void fireListeners() throws ElementParameterException,ElementParameterNotFoundException {
|
||||
for (VascValueModelListener l:listeners) {
|
||||
l.valueUpdate(this);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ package com.idcanet.vasc.core.ui;
|
|||
|
||||
import java.util.EventListener;
|
||||
|
||||
import com.idcanet.x4o.element.ElementParameterException;
|
||||
import com.idcanet.x4o.element.ElementParameterNotFoundException;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -36,5 +39,5 @@ import java.util.EventListener;
|
|||
*/
|
||||
public interface VascValueModelListener extends EventListener {
|
||||
|
||||
public void valueUpdate(VascValueModel model) throws Exception;
|
||||
public void valueUpdate(VascValueModel model) throws ElementParameterException,ElementParameterNotFoundException;
|
||||
}
|
|
@ -28,6 +28,8 @@ package com.idcanet.vasc.impl.column;
|
|||
|
||||
import com.idcanet.vasc.core.column.VascColumnValue;
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
import com.idcanet.x4o.element.ElementParameterException;
|
||||
import com.idcanet.x4o.element.ElementParameterNotFoundException;
|
||||
import com.idcanet.x4o.impl.DefaultElementParameterHelper;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +54,7 @@ public class BeanPropertyVascColumnValue implements VascColumnValue {
|
|||
/**
|
||||
* @see com.idcanet.vasc.core.column.VascColumnValue#getValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object)
|
||||
*/
|
||||
public Object getValue(VascTableColumn column,Object record) throws Exception {
|
||||
public Object getValue(VascTableColumn column,Object record) throws ElementParameterException,ElementParameterNotFoundException {
|
||||
if(getProperty()==null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -65,7 +67,7 @@ public class BeanPropertyVascColumnValue implements VascColumnValue {
|
|||
/**
|
||||
* @see com.idcanet.vasc.core.column.VascColumnValue#setValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void setValue(VascTableColumn column, Object record,Object value) throws Exception {
|
||||
public void setValue(VascTableColumn column, Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException {
|
||||
if(getProperty()==null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ package com.idcanet.vasc.impl.column;
|
|||
|
||||
import com.idcanet.vasc.core.column.VascColumnValue;
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
import com.idcanet.x4o.element.ElementParameterException;
|
||||
import com.idcanet.x4o.element.ElementParameterNotFoundException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,14 +41,14 @@ public class NullVascColumnValue implements VascColumnValue {
|
|||
/**
|
||||
* @see com.idcanet.vasc.core.column.VascColumnValue#getValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object)
|
||||
*/
|
||||
public Object getValue(VascTableColumn column, Object record) throws Exception {
|
||||
public Object getValue(VascTableColumn column, Object record) throws ElementParameterException,ElementParameterNotFoundException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.column.VascColumnValue#setValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void setValue(VascTableColumn column, Object record, Object value) throws Exception {
|
||||
public void setValue(VascTableColumn column, Object record, Object value) throws ElementParameterException,ElementParameterNotFoundException {
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -494,6 +494,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
// TODO: fix this
|
||||
table.getVascViewRenderer().renderEdit(o);
|
||||
} catch (Exception ee) {
|
||||
table.getVascTableController().handleException(ee, table);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SwingColorChooser extends AbstractVascUIComponent {
|
|||
JButton colorButton = new JButton("Color");
|
||||
orgBackgroundColor = colorButton.getBackground();
|
||||
((JComponent)gui).add(colorButton);
|
||||
colorButton.addActionListener(new SelectActionListener3(model,org.getHexSwingEncoding()));
|
||||
colorButton.addActionListener(new SelectActionListener3(model,org.getHexSwingEncoding(),table));
|
||||
return colorButton;
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,11 @@ class SelectActionListener3 implements ActionListener {
|
|||
|
||||
private VascValueModel model;
|
||||
private boolean hexEncoding = false;
|
||||
public SelectActionListener3(VascValueModel model,boolean hexEncoding) {
|
||||
private VascTable table = null;
|
||||
public SelectActionListener3(VascValueModel model,boolean hexEncoding,VascTable table) {
|
||||
this.model=model;
|
||||
this.hexEncoding=hexEncoding;
|
||||
this.table=table;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,7 +108,11 @@ class SelectActionListener3 implements ActionListener {
|
|||
cur = Color.YELLOW;
|
||||
}
|
||||
Color newColor = JColorChooser.showDialog(null,"Choose a color...",cur);
|
||||
model.setValue(newColor);
|
||||
try {
|
||||
model.setValue(newColor);
|
||||
} catch (Exception ee) {
|
||||
table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
} else {
|
||||
String cur = (String)model.getValue();
|
||||
Color c = Color.YELLOW;
|
||||
|
@ -118,7 +124,7 @@ class SelectActionListener3 implements ActionListener {
|
|||
String newColorString = "#"+Integer.toHexString( newColor.getRGB() & 0x00ffffff );
|
||||
model.setValue(newColorString);
|
||||
} catch (Exception ee) {
|
||||
|
||||
table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SwingDate extends AbstractVascUIComponent {
|
|||
orgBackgroundColor = datePicker.getBackground();
|
||||
datePicker.setDate((Date)model.getValue());
|
||||
((JComponent)gui).add(datePicker);
|
||||
datePicker.addActionListener(new SelectActionListener2(model));
|
||||
datePicker.addActionListener(new SelectActionListener2(model,table));
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,10 @@ public class SwingDate extends AbstractVascUIComponent {
|
|||
class SelectActionListener2 implements ActionListener {
|
||||
|
||||
private VascValueModel model;
|
||||
public SelectActionListener2(VascValueModel model) {
|
||||
private VascTable table = null;
|
||||
public SelectActionListener2(VascValueModel model,VascTable table) {
|
||||
this.model=model;
|
||||
this.table=table;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,6 +98,10 @@ class SelectActionListener2 implements ActionListener {
|
|||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Date value = ((DatePicker)e.getSource()).getDate();
|
||||
model.setValue(value);
|
||||
try {
|
||||
model.setValue(value);
|
||||
} catch (Exception ee) {
|
||||
table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ public class SwingList extends AbstractVascUIComponent {
|
|||
private JComboBox comboBox = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascTable table,final VascValueModel model,Object gui) throws Exception {
|
||||
public Object createComponent(final VascTable table,final VascValueModel model,Object gui) throws Exception {
|
||||
VascList l = (VascList)getWrapper();
|
||||
if (l.getVascSelectItemModel()==null) {
|
||||
comboBox = new JComboBox();
|
||||
|
@ -67,7 +67,11 @@ public class SwingList extends AbstractVascUIComponent {
|
|||
comboBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
VascSelectItem i = (VascSelectItem)((JComboBox)e.getSource()).getSelectedItem();
|
||||
model.setValue(i.getValue());
|
||||
try {
|
||||
model.setValue(i.getValue());
|
||||
} catch (Exception ee) {
|
||||
table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SwingTextField extends AbstractVascUIComponent {
|
|||
orgBackgroundColor = textField.getBackground();
|
||||
textField.setText(""+model.getValue());
|
||||
((JComponent)gui).add(textField);
|
||||
textField.getDocument().addDocumentListener(new TextListener(model,table));
|
||||
textField.getDocument().addDocumentListener(new TextListener(model,table,this));
|
||||
return textField;
|
||||
}
|
||||
|
||||
|
@ -86,11 +86,13 @@ public class SwingTextField extends AbstractVascUIComponent {
|
|||
class TextListener implements DocumentListener {
|
||||
|
||||
private VascValueModel model = null;
|
||||
private VascTable table = null;
|
||||
//private VascTable table = null;
|
||||
private SwingTextField textField = null;
|
||||
|
||||
public TextListener(VascValueModel model,VascTable table) {
|
||||
public TextListener(VascValueModel model,VascTable table,SwingTextField textField) {
|
||||
this.model=model;
|
||||
this.table=table;
|
||||
//this.table=table;
|
||||
this.textField=textField;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,8 +120,10 @@ class TextListener implements DocumentListener {
|
|||
try {
|
||||
String value = event.getDocument().getText(0, event.getDocument().getLength());
|
||||
model.setValue(value);
|
||||
textField.setErrorText(null);
|
||||
} catch (Exception ee) {
|
||||
table.getVascTableController().handleException(ee, table);
|
||||
textField.setErrorText(ee.getLocalizedMessage());
|
||||
//table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ public class SwingToggle extends AbstractVascUIComponent {
|
|||
orgBackgroundColor = checkBox.getBackground();
|
||||
checkBox.setSelected((Boolean)model.getValue());
|
||||
((JComponent)gui).add(checkBox);
|
||||
checkBox.addActionListener(new SelectActionListener(model));
|
||||
checkBox.addActionListener(new SelectActionListener(model,table));
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,10 @@ public class SwingToggle extends AbstractVascUIComponent {
|
|||
class SelectActionListener implements ActionListener {
|
||||
|
||||
private VascValueModel model;
|
||||
public SelectActionListener(VascValueModel model) {
|
||||
private VascTable table = null;
|
||||
public SelectActionListener(VascValueModel model,VascTable table) {
|
||||
this.model=model;
|
||||
this.table=table;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,6 +97,10 @@ class SelectActionListener implements ActionListener {
|
|||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean value = ((JCheckBox)e.getSource()).isSelected();
|
||||
model.setValue(value);
|
||||
try {
|
||||
model.setValue(value);
|
||||
} catch (Exception ee) {
|
||||
table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue