[svn r343] WIP3
This commit is contained in:
parent
62f7881380
commit
4643057b7f
|
@ -228,9 +228,9 @@ public class VascAnnotationParser {
|
||||||
if (a.equals(VascDefaultValue.class)) {
|
if (a.equals(VascDefaultValue.class)) {
|
||||||
VascDefaultValue v = (VascDefaultValue)b;
|
VascDefaultValue v = (VascDefaultValue)b;
|
||||||
|
|
||||||
if(v.defaultValueClass().equals(Object.class)==false) {
|
if(v.defaultValue().equals(Object.class)==false) {
|
||||||
try {
|
try {
|
||||||
return v.defaultValueClass().newInstance();
|
//return v.defaultValue().newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new NullPointerException("Could not init defaultValueClass error: "+e.getMessage());
|
throw new NullPointerException("Could not init defaultValueClass error: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,10 @@ package com.idcanet.vasc.backends.jdbc;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.AbstractVascBackend;
|
import com.idcanet.vasc.core.AbstractVascBackend;
|
||||||
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
|
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||||
|
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -81,4 +85,18 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
||||||
*/
|
*/
|
||||||
public void delete(Object object) throws Exception {
|
public void delete(Object object) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
||||||
|
*/
|
||||||
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -35,6 +35,10 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.AbstractVascBackend;
|
import com.idcanet.vasc.core.AbstractVascBackend;
|
||||||
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
|
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||||
|
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||||
import com.idcanet.xtes.xpql.query.QueryParameterValue;
|
import com.idcanet.xtes.xpql.query.QueryParameterValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,4 +117,18 @@ public class JdbcXpqlVascBackend extends AbstractVascBackend {
|
||||||
*/
|
*/
|
||||||
public void delete(Object object) throws Exception {
|
public void delete(Object object) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
||||||
|
*/
|
||||||
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
74
src/com/idcanet/vasc/core/AbstractVascFrontend.java
Normal file
74
src/com/idcanet/vasc/core/AbstractVascFrontend.java
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||||
|
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Aug 2, 2007
|
||||||
|
*/
|
||||||
|
abstract public class AbstractVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
protected VascEntry entry = null;
|
||||||
|
|
||||||
|
protected String i18n(String key,Object...params) {
|
||||||
|
return entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,params);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VascEntry getVascEntry() {
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascFrontend#initEntry(com.idcanet.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public void initEntry(VascEntry entry) throws Exception {
|
||||||
|
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
||||||
|
entry.getVascFrontendData().setVascFrontend(this);
|
||||||
|
} else {
|
||||||
|
if (entry.getVascFrontendData().getVascFrontend()!=this) {
|
||||||
|
throw new IllegalArgumentException("VascEntry has already a differtent VascFrontend attected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.entry=entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascFrontend#getName()
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascFrontend#setName(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name=name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,5 +34,5 @@ package com.idcanet.vasc.core;
|
||||||
*/
|
*/
|
||||||
public interface VascEntryFinalizer {
|
public interface VascEntryFinalizer {
|
||||||
|
|
||||||
public void finalizeVascEntry(VascEntry table) throws Exception;
|
public VascEntry finalizeVascEntry(VascEntry entry) throws Exception;
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@ public interface VascFrontend {
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
public void initEntry(VascEntry table) throws Exception;
|
public void initEntry(VascEntry entry) throws Exception;
|
||||||
|
|
||||||
public void renderView() throws Exception;
|
public void renderView() throws Exception;
|
||||||
|
|
||||||
|
|
|
@ -67,15 +67,14 @@ import javax.swing.table.TableCellRenderer;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
|
|
||||||
import com.idcanet.fff.SwingImageHelper;
|
import com.idcanet.fff.SwingImageHelper;
|
||||||
|
import com.idcanet.vasc.core.AbstractVascFrontend;
|
||||||
import com.idcanet.vasc.core.VascEntry;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.VascEntryField;
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
import com.idcanet.vasc.core.VascFrontend;
|
|
||||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryExporter;
|
import com.idcanet.vasc.core.entry.VascEntryExporter;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
|
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
|
||||||
import com.idcanet.vasc.core.ui.VascColumnValueModelListener;
|
import com.idcanet.vasc.core.ui.VascColumnValueModelListener;
|
||||||
import com.idcanet.vasc.core.ui.VascList;
|
|
||||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
|
|
||||||
|
@ -84,27 +83,17 @@ import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Mar 21, 2007
|
* @version 1.0 Mar 21, 2007
|
||||||
*/
|
*/
|
||||||
public class SwingVascFrontend implements VascFrontend {
|
public class SwingVascFrontend extends AbstractVascFrontend {
|
||||||
|
|
||||||
private String name = null;
|
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
private JComponent parent = null;
|
private JComponent parent = null;
|
||||||
private VascEntry entry = null;
|
|
||||||
|
|
||||||
public SwingVascFrontend(JComponent parent) {
|
public SwingVascFrontend(JComponent parent) {
|
||||||
logger = Logger.getLogger(SwingVascFrontend.class.getName());
|
logger = Logger.getLogger(SwingVascFrontend.class.getName());
|
||||||
this.parent=parent;
|
this.parent=parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void initEntry(VascEntry entry) throws Exception {
|
public void initEntry(VascEntry entry) throws Exception {
|
||||||
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
||||||
entry.getVascFrontendData().setVascFrontend(this);
|
entry.getVascFrontendData().setVascFrontend(this);
|
||||||
|
@ -120,9 +109,10 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
entry.putUIComponent(VascToggle.class, SwingToggle.class);
|
entry.putUIComponent(VascToggle.class, SwingToggle.class);
|
||||||
entry.putUIComponent(VascDate.class, SwingDate.class);
|
entry.putUIComponent(VascDate.class, SwingDate.class);
|
||||||
entry.putUIComponent(VascColorChooser.class, SwingColorChooser.class);
|
entry.putUIComponent(VascColorChooser.class, SwingColorChooser.class);
|
||||||
*/
|
|
||||||
this.entry=entry;
|
this.entry=entry;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
public ImageIcon getImageIcon(String imageResource) {
|
public ImageIcon getImageIcon(String imageResource) {
|
||||||
|
@ -130,6 +120,10 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
String key = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(imageResource);
|
String key = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(imageResource);
|
||||||
//logger.fine("KEY======================="+key);
|
//logger.fine("KEY======================="+key);
|
||||||
|
|
||||||
|
if (key.startsWith("vasc.entry")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (key.indexOf("META-INF")>0 | key.indexOf("resource")>0) {
|
if (key.indexOf("META-INF")>0 | key.indexOf("resource")>0) {
|
||||||
return SwingImageHelper.getImageIcon(key);
|
return SwingImageHelper.getImageIcon(key);
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,7 +157,7 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
beanValue=beanValue.substring(0, 30);
|
beanValue=beanValue.substring(0, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SwingEditDialog dialog = new SwingEditDialog(parent,entry,rowBean,entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.edit.title"),entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.edit.message",beanValue));
|
SwingEditDialog dialog = new SwingEditDialog(parent,entry,rowBean,i18n("vasc.dialog.edit.title"),i18n("vasc.dialog.edit.message",beanValue));
|
||||||
Object result = dialog.openDialog();
|
Object result = dialog.openDialog();
|
||||||
logger.finest("OPEN closed : "+result);
|
logger.finest("OPEN closed : "+result);
|
||||||
if(result==null) {
|
if(result==null) {
|
||||||
|
@ -183,8 +177,8 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
}
|
}
|
||||||
int response = JOptionPane.showOptionDialog(
|
int response = JOptionPane.showOptionDialog(
|
||||||
parent // Center in window.
|
parent // Center in window.
|
||||||
, entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.message",beanValue) // Message
|
, i18n("vasc.dialog.delete.message",beanValue) // Message
|
||||||
, entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.title") // Title in titlebar
|
, i18n("vasc.dialog.delete.title") // Title in titlebar
|
||||||
, JOptionPane.YES_NO_OPTION // Option type
|
, JOptionPane.YES_NO_OPTION // Option type
|
||||||
, JOptionPane.PLAIN_MESSAGE // messageType
|
, JOptionPane.PLAIN_MESSAGE // messageType
|
||||||
, null // Icon (none)
|
, null // Icon (none)
|
||||||
|
@ -212,7 +206,7 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
this.headerText = headerText;
|
this.headerText = headerText;
|
||||||
this.bean = bean;
|
this.bean = bean;
|
||||||
|
|
||||||
setTitle(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(title));
|
setTitle(i18n(title));
|
||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
||||||
JPanel pane = new JPanel();
|
JPanel pane = new JPanel();
|
||||||
|
@ -252,9 +246,9 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
public void createHeader(JPanel header) {
|
public void createHeader(JPanel header) {
|
||||||
JLabel l = new JLabel();
|
JLabel l = new JLabel();
|
||||||
l.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(headerText));
|
l.setText(i18n(headerText));
|
||||||
l.setFont(new Font(null,Font.BOLD, 14));
|
l.setFont(new Font(null,Font.BOLD, 14));
|
||||||
//l.setToolTipText(entry.getVascTextValue().getTextValue(headerText));
|
//l.setToolTipText(i18n(headerText));
|
||||||
header.add(l);
|
header.add(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,9 +265,9 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
JLabel l = new JLabel();
|
JLabel l = new JLabel();
|
||||||
l.setHorizontalAlignment(JLabel.TRAILING);
|
l.setHorizontalAlignment(JLabel.TRAILING);
|
||||||
|
|
||||||
l.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getName()));
|
l.setText(i18n(c.getName()));
|
||||||
if(c.getDescription()!=null) {
|
if(c.getDescription()!=null) {
|
||||||
l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getDescription()));
|
l.setToolTipText(i18n(c.getDescription()));
|
||||||
}
|
}
|
||||||
body.add(l);
|
body.add(l);
|
||||||
|
|
||||||
|
@ -307,8 +301,8 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
JButton saveButton = new JButton();
|
JButton saveButton = new JButton();
|
||||||
saveButton.setIcon(getImageIcon("vasc.dialog.save.image"));
|
saveButton.setIcon(getImageIcon("vasc.dialog.save.image"));
|
||||||
saveButton.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.save.name"));
|
saveButton.setText(i18n("vasc.dialog.save.name"));
|
||||||
saveButton.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.save.tooltip"));
|
saveButton.setToolTipText(i18n("vasc.dialog.save.tooltip"));
|
||||||
saveButton.addActionListener(new ActionListener() {
|
saveButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
if(entry.getVascFrontendData().getVascFrontendHelper().setUIComponentsBeanErrors(entry, bean)) {
|
if(entry.getVascFrontendData().getVascFrontendHelper().setUIComponentsBeanErrors(entry, bean)) {
|
||||||
|
@ -322,8 +316,8 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
JButton cancelButton = new JButton();
|
JButton cancelButton = new JButton();
|
||||||
cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image"));
|
cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image"));
|
||||||
cancelButton.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.name"));
|
cancelButton.setText(i18n("vasc.dialog.cancel.name"));
|
||||||
cancelButton.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.tooltip"));
|
cancelButton.setToolTipText(i18n("vasc.dialog.cancel.tooltip"));
|
||||||
cancelButton.addActionListener(new ActionListener() {
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
result = null;
|
result = null;
|
||||||
|
@ -344,7 +338,6 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
String fileName = null;
|
String fileName = null;
|
||||||
JFileChooser c = new JFileChooser();
|
JFileChooser c = new JFileChooser();
|
||||||
// Demonstrate "Save" dialog:
|
|
||||||
int rVal = c.showSaveDialog(null);
|
int rVal = c.showSaveDialog(null);
|
||||||
if (rVal == JFileChooser.APPROVE_OPTION) {
|
if (rVal == JFileChooser.APPROVE_OPTION) {
|
||||||
fileName = c.getSelectedFile().getAbsolutePath();
|
fileName = c.getSelectedFile().getAbsolutePath();
|
||||||
|
@ -410,19 +403,19 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
if(entry.getHeaderImage()!=null) {
|
if(entry.getHeaderImage()!=null) {
|
||||||
JLabel l = new JLabel();
|
JLabel l = new JLabel();
|
||||||
// TODO: hack images working
|
// TODO: hack images working
|
||||||
l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(entry.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH)));
|
//l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(entry.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH)));
|
||||||
if (entry.getHeaderDescription()!=null) {
|
if (entry.getHeaderDescription()!=null) {
|
||||||
l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription()));
|
l.setToolTipText(i18n(entry.getHeaderDescription()));
|
||||||
}
|
}
|
||||||
header.add(l,BorderLayout.WEST);
|
header.add(l,BorderLayout.WEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entry.getHeaderName()!=null) {
|
if(entry.getHeaderName()!=null) {
|
||||||
JLabel l = new JLabel(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderName()));
|
JLabel l = new JLabel(i18n(entry.getHeaderName()));
|
||||||
l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||||
l.setFont(new Font(null,Font.BOLD, 18));
|
l.setFont(new Font(null,Font.BOLD, 18));
|
||||||
if (entry.getHeaderDescription()!=null) {
|
if (entry.getHeaderDescription()!=null) {
|
||||||
l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription()));
|
l.setToolTipText(i18n(entry.getHeaderDescription()));
|
||||||
}
|
}
|
||||||
header.add(l,BorderLayout.CENTER);
|
header.add(l,BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
@ -431,8 +424,8 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
//top.setBackground(Color.BLUE);
|
//top.setBackground(Color.BLUE);
|
||||||
for (GlobalVascAction action:entry.getGlobalActions()) {
|
for (GlobalVascAction action:entry.getGlobalActions()) {
|
||||||
JButton but = new JButton();
|
JButton but = new JButton();
|
||||||
but.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getName()));
|
but.setText(i18n(action.getName()));
|
||||||
but.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getToolTip()));
|
but.setToolTipText(i18n(action.getToolTip()));
|
||||||
but.addActionListener(new GlobalActionListener(action));
|
but.addActionListener(new GlobalActionListener(action));
|
||||||
but.setIcon(getImageIcon(action.getImage()));
|
but.setIcon(getImageIcon(action.getImage()));
|
||||||
top.add(but);
|
top.add(but);
|
||||||
|
@ -541,8 +534,8 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
private static final long serialVersionUID = 10L;
|
private static final long serialVersionUID = 10L;
|
||||||
public Component getentryCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
|
public Component getentryCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
|
||||||
VascEntryField c = (VascEntryField)value;
|
VascEntryField c = (VascEntryField)value;
|
||||||
setText(c.getVascEntry().getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getName()));
|
setText(i18n(c.getName()));
|
||||||
setToolTipText(c.getVascEntry().getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getDescription()));
|
setToolTipText(i18n(c.getDescription()));
|
||||||
|
|
||||||
if(c.getImage()!=null) {
|
if(c.getImage()!=null) {
|
||||||
setIcon(getImageIcon(c.getImage()));
|
setIcon(getImageIcon(c.getImage()));
|
||||||
|
@ -569,8 +562,8 @@ public class SwingVascFrontend implements VascFrontend {
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
for(RowVascAction action:entry.getRowActions()) {
|
for(RowVascAction action:entry.getRowActions()) {
|
||||||
JButton but = new JButton();
|
JButton but = new JButton();
|
||||||
but.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getName()));
|
but.setText(i18n(action.getName()));
|
||||||
but.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getToolTip()));
|
but.setToolTipText(i18n(action.getToolTip()));
|
||||||
but.setIcon(getImageIcon(action.getImage()));
|
but.setIcon(getImageIcon(action.getImage()));
|
||||||
but.addActionListener(new RowActionListener(action));
|
but.addActionListener(new RowActionListener(action));
|
||||||
panel.add(but);
|
panel.add(but);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.frontends.swing.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
@ -33,7 +33,7 @@ import java.awt.event.ActionListener;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.VascTable;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
||||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Sep 21, 2007
|
* @version 1.0 Sep 21, 2007
|
||||||
*/
|
*/
|
||||||
public class SwingToggle extends AbstractVascUIComponent {
|
public class SwingBoolean extends AbstractVascUIComponent {
|
||||||
|
|
||||||
private JCheckBox checkBox = null;
|
private JCheckBox checkBox = null;
|
||||||
private Color orgBackgroundColor = null;
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
public Object createComponent(VascEntry table,VascValueModel model,Object gui) throws Exception {
|
||||||
checkBox = new JCheckBox();
|
checkBox = new JCheckBox();
|
||||||
orgBackgroundColor = checkBox.getBackground();
|
orgBackgroundColor = checkBox.getBackground();
|
||||||
checkBox.setSelected((Boolean)model.getValue());
|
checkBox.setSelected((Boolean)model.getValue());
|
||||||
|
@ -86,8 +86,8 @@ public class SwingToggle extends AbstractVascUIComponent {
|
||||||
class SelectActionListener implements ActionListener {
|
class SelectActionListener implements ActionListener {
|
||||||
|
|
||||||
private VascValueModel model;
|
private VascValueModel model;
|
||||||
private VascTable table = null;
|
private VascEntry table = null;
|
||||||
public SelectActionListener(VascValueModel model,VascTable table) {
|
public SelectActionListener(VascValueModel model,VascEntry table) {
|
||||||
this.model=model;
|
this.model=model;
|
||||||
this.table=table;
|
this.table=table;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class SelectActionListener implements ActionListener {
|
||||||
try {
|
try {
|
||||||
model.setValue(value);
|
model.setValue(value);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
table.getVascTableController().handleException(ee, table);
|
table.getVascFrontendData().getVascFrontendHelper().handleException(ee, table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@
|
||||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.frontends.swing.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
@ -34,9 +34,8 @@ import javax.swing.JButton;
|
||||||
import javax.swing.JColorChooser;
|
import javax.swing.JColorChooser;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.VascTable;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
||||||
import com.idcanet.vasc.core.ui.VascColorChooser;
|
|
||||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,15 +49,11 @@ public class SwingColorChooser extends AbstractVascUIComponent {
|
||||||
private JButton colorButton = null;
|
private JButton colorButton = null;
|
||||||
private Color orgBackgroundColor = null;
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
public Object createComponent(VascEntry table,VascValueModel model,Object gui) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
VascColorChooser org = (VascColorChooser)getWrapper();
|
|
||||||
|
|
||||||
JButton colorButton = new JButton("Color");
|
JButton colorButton = new JButton("Color");
|
||||||
orgBackgroundColor = colorButton.getBackground();
|
orgBackgroundColor = colorButton.getBackground();
|
||||||
((JComponent)gui).add(colorButton);
|
((JComponent)gui).add(colorButton);
|
||||||
colorButton.addActionListener(new SelectActionListener3(model,org.getHexSwingEncoding(),table));
|
colorButton.addActionListener(new SelectActionListener3(model,true,table));
|
||||||
return colorButton;
|
return colorButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +86,8 @@ class SelectActionListener3 implements ActionListener {
|
||||||
|
|
||||||
private VascValueModel model;
|
private VascValueModel model;
|
||||||
private boolean hexEncoding = false;
|
private boolean hexEncoding = false;
|
||||||
private VascTable table = null;
|
private VascEntry table = null;
|
||||||
public SelectActionListener3(VascValueModel model,boolean hexEncoding,VascTable table) {
|
public SelectActionListener3(VascValueModel model,boolean hexEncoding,VascEntry table) {
|
||||||
this.model=model;
|
this.model=model;
|
||||||
this.hexEncoding=hexEncoding;
|
this.hexEncoding=hexEncoding;
|
||||||
this.table=table;
|
this.table=table;
|
||||||
|
@ -111,7 +106,7 @@ class SelectActionListener3 implements ActionListener {
|
||||||
try {
|
try {
|
||||||
model.setValue(newColor);
|
model.setValue(newColor);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
table.getVascTableController().handleException(ee, table);
|
table.getVascFrontendData().getVascFrontendHelper().handleException(ee, table);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String cur = (String)model.getValue();
|
String cur = (String)model.getValue();
|
||||||
|
@ -124,7 +119,7 @@ class SelectActionListener3 implements ActionListener {
|
||||||
String newColorString = "#"+Integer.toHexString( newColor.getRGB() & 0x00ffffff );
|
String newColorString = "#"+Integer.toHexString( newColor.getRGB() & 0x00ffffff );
|
||||||
model.setValue(newColorString);
|
model.setValue(newColorString);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
table.getVascTableController().handleException(ee, table);
|
table.getVascFrontendData().getVascFrontendHelper().handleException(ee, table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.frontends.swing.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
@ -33,7 +33,7 @@ import java.util.Date;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.VascTable;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
||||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
import com.michaelbaranov.microba.calendar.DatePicker;
|
import com.michaelbaranov.microba.calendar.DatePicker;
|
||||||
|
@ -50,7 +50,7 @@ public class SwingDate extends AbstractVascUIComponent {
|
||||||
private DatePicker datePicker = null;
|
private DatePicker datePicker = null;
|
||||||
private Color orgBackgroundColor = null;
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
public Object createComponent(VascEntry table,VascValueModel model,Object gui) throws Exception {
|
||||||
datePicker = new DatePicker();
|
datePicker = new DatePicker();
|
||||||
orgBackgroundColor = datePicker.getBackground();
|
orgBackgroundColor = datePicker.getBackground();
|
||||||
datePicker.setDate((Date)model.getValue());
|
datePicker.setDate((Date)model.getValue());
|
||||||
|
@ -87,8 +87,8 @@ public class SwingDate extends AbstractVascUIComponent {
|
||||||
class SelectActionListener2 implements ActionListener {
|
class SelectActionListener2 implements ActionListener {
|
||||||
|
|
||||||
private VascValueModel model;
|
private VascValueModel model;
|
||||||
private VascTable table = null;
|
private VascEntry table = null;
|
||||||
public SelectActionListener2(VascValueModel model,VascTable table) {
|
public SelectActionListener2(VascValueModel model,VascEntry table) {
|
||||||
this.model=model;
|
this.model=model;
|
||||||
this.table=table;
|
this.table=table;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ class SelectActionListener2 implements ActionListener {
|
||||||
try {
|
try {
|
||||||
model.setValue(value);
|
model.setValue(value);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
table.getVascTableController().handleException(ee, table);
|
table.getVascFrontendData().getVascFrontendHelper().handleException(ee, table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@
|
||||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.frontends.swing.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
@ -37,7 +37,7 @@ import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.ListCellRenderer;
|
import javax.swing.ListCellRenderer;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.VascTable;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
||||||
import com.idcanet.vasc.core.ui.VascList;
|
import com.idcanet.vasc.core.ui.VascList;
|
||||||
import com.idcanet.vasc.core.ui.VascSelectItem;
|
import com.idcanet.vasc.core.ui.VascSelectItem;
|
||||||
|
@ -54,7 +54,7 @@ public class SwingList extends AbstractVascUIComponent {
|
||||||
private JComboBox comboBox = null;
|
private JComboBox comboBox = null;
|
||||||
private Color orgBackgroundColor = null;
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
public Object createComponent(final VascTable table,final VascValueModel model,Object gui) throws Exception {
|
public Object createComponent(final VascEntry table,final VascValueModel model,Object gui) throws Exception {
|
||||||
VascList l = (VascList)getWrapper();
|
VascList l = (VascList)getWrapper();
|
||||||
if (l.getVascSelectItemModel()==null) {
|
if (l.getVascSelectItemModel()==null) {
|
||||||
comboBox = new JComboBox();
|
comboBox = new JComboBox();
|
||||||
|
@ -70,7 +70,7 @@ public class SwingList extends AbstractVascUIComponent {
|
||||||
try {
|
try {
|
||||||
model.setValue(i.getValue());
|
model.setValue(i.getValue());
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
table.getVascTableController().handleException(ee, table);
|
table.getVascFrontendData().getVascFrontendHelper().handleException(ee, table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.frontends.swing.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import javax.swing.JTextField;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.VascTable;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
||||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class SwingTextField extends AbstractVascUIComponent {
|
||||||
private JTextField textField = null;
|
private JTextField textField = null;
|
||||||
private Color orgBackgroundColor = null;
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
public Object createComponent(VascEntry table,VascValueModel model,Object gui) throws Exception {
|
||||||
textField = new JTextField();
|
textField = new JTextField();
|
||||||
orgBackgroundColor = textField.getBackground();
|
orgBackgroundColor = textField.getBackground();
|
||||||
textField.setText(""+model.getValue());
|
textField.setText(""+model.getValue());
|
||||||
|
@ -89,7 +89,7 @@ class TextListener implements DocumentListener {
|
||||||
//private VascTable table = null;
|
//private VascTable table = null;
|
||||||
private SwingTextField textField = null;
|
private SwingTextField textField = null;
|
||||||
|
|
||||||
public TextListener(VascValueModel model,VascTable table,SwingTextField textField) {
|
public TextListener(VascValueModel model,VascEntry table,SwingTextField textField) {
|
||||||
this.model=model;
|
this.model=model;
|
||||||
//this.table=table;
|
//this.table=table;
|
||||||
this.textField=textField;
|
this.textField=textField;
|
||||||
|
|
|
@ -64,41 +64,28 @@ import org.eclipse.swt.widgets.ToolBar;
|
||||||
import org.eclipse.swt.widgets.ToolItem;
|
import org.eclipse.swt.widgets.ToolItem;
|
||||||
|
|
||||||
import com.idcanet.fff.SwingImageHelper;
|
import com.idcanet.fff.SwingImageHelper;
|
||||||
|
import com.idcanet.vasc.core.AbstractVascFrontend;
|
||||||
import com.idcanet.vasc.core.VascEntry;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.VascFrontend;
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||||
|
import com.idcanet.vasc.core.entry.VascEntryExporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Mar 21, 2007
|
* @version 1.0 Mar 21, 2007
|
||||||
*/
|
*/
|
||||||
public class SwtVascFrontend implements VascFrontend {
|
public class SwtVascFrontend extends AbstractVascFrontend {
|
||||||
|
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
private Composite parent = null;
|
private Composite parent = null;
|
||||||
private VascEntry table = null;
|
|
||||||
|
|
||||||
public SwtVascFrontend(Composite parent) {
|
public SwtVascFrontend(Composite parent) {
|
||||||
logger = Logger.getLogger(SwtVascFrontend.class.getName());
|
logger = Logger.getLogger(SwtVascFrontend.class.getName());
|
||||||
this.parent=parent;
|
this.parent=parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initTable(VascEntry table) throws Exception {
|
|
||||||
if (table.VascEntry()==null) {
|
|
||||||
table.setVascViewRenderer(this);
|
|
||||||
} else {
|
|
||||||
if (table.getVascViewRenderer()!=this) {
|
|
||||||
throw new IllegalArgumentException("VascTable has already a differtent VascViewRenderer attected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
table.getVascTableController().finalizeVascColumns(table);
|
|
||||||
table.getVascTableController().finalizeVascTable(table);
|
|
||||||
table.getVascTableController().refreshData(table);
|
|
||||||
this.table=table;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String[] FILTER_NAMES = {
|
private static final String[] FILTER_NAMES = {
|
||||||
"All Files (*.*)",
|
"All Files (*.*)",
|
||||||
"Comma Separated Values Files (*.csv)",
|
"Comma Separated Values Files (*.csv)",
|
||||||
|
@ -107,11 +94,11 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
/** These filter extensions are used to filter which files are displayed. */
|
/** These filter extensions are used to filter which files are displayed. */
|
||||||
private static final String[] FILTER_EXTS = { "*.*","*.csv","*.xls" };
|
private static final String[] FILTER_EXTS = { "*.*","*.csv","*.xls" };
|
||||||
|
|
||||||
public void renderExport(VascDataExporter exporter) throws Exception {
|
public void renderExport(VascEntryExporter exporter) throws Exception {
|
||||||
FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
|
FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
|
||||||
dlg.setFilterNames(FILTER_NAMES);
|
dlg.setFilterNames(FILTER_NAMES);
|
||||||
dlg.setFilterExtensions(FILTER_EXTS);
|
dlg.setFilterExtensions(FILTER_EXTS);
|
||||||
dlg.setFileName(table.getHeaderName()+".csv");
|
dlg.setFileName(entry.getHeaderName()+".csv");
|
||||||
String fileName = dlg.open();
|
String fileName = dlg.open();
|
||||||
logger.fine("FileName: "+fileName);
|
logger.fine("FileName: "+fileName);
|
||||||
if (fileName == null) {
|
if (fileName == null) {
|
||||||
|
@ -119,7 +106,7 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
}
|
}
|
||||||
OutputStream out = new FileOutputStream(fileName);
|
OutputStream out = new FileOutputStream(fileName);
|
||||||
try {
|
try {
|
||||||
exporter.doExport(out, table);
|
exporter.doExport(out, entry);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//MessageDialog.openError(Display.getCurrent().getActiveShell(),crudTable.i18n("crud.event.export.error.title"),crudTable.i18n("crud.event.export.error.message"));
|
//MessageDialog.openError(Display.getCurrent().getActiveShell(),crudTable.i18n("crud.event.export.error.title"),crudTable.i18n("crud.event.export.error.message"));
|
||||||
logger.log(Level.WARNING,"Error: "+e.getMessage(),e);
|
logger.log(Level.WARNING,"Error: "+e.getMessage(),e);
|
||||||
|
@ -133,25 +120,27 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
public void renderEdit(Object object) throws Exception {
|
public void renderEdit(Object object) throws Exception {
|
||||||
|
|
||||||
logger.fine("Rending Edit View");
|
logger.fine("Rending Edit View");
|
||||||
table.getVascTableController().initEditObject(table, object);
|
entry.getVascFrontendData().getVascFrontendHelper().initEditObject(entry, object);
|
||||||
|
|
||||||
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Vasc Edit","Edit");
|
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),object,"Vasc Edit","Edit");
|
||||||
Object result = dialog.open();
|
Object result = dialog.open();
|
||||||
if(result==null) {
|
if(result==null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
result = table.getVascDataSource().merge(object);
|
result = entry.getVascDataSource().merge(object);
|
||||||
//table.getVascTableController().fireModelUpdateListeners(result);
|
//table.getVascTableController().fireModelUpdateListeners(result);
|
||||||
} finally {
|
} finally {
|
||||||
//TODO: or merge into table == faster
|
//TODO: or merge into table == faster
|
||||||
table.getVascTableController().refreshData(table);
|
entry.getVascTableController().refreshData(entry);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageDescriptor getImageDescriptor(String path) {
|
public ImageDescriptor getImageDescriptor(String path) {
|
||||||
try {
|
try {
|
||||||
path = table.getVascTextValue().getTextValue(path);
|
path = i18n(path);
|
||||||
|
|
||||||
|
|
||||||
logger.fine("Loading image: "+path);
|
logger.fine("Loading image: "+path);
|
||||||
|
@ -191,7 +180,7 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
private Object result = null;
|
private Object result = null;
|
||||||
private Object bean = null;
|
private Object bean = null;
|
||||||
|
|
||||||
public SwtVascEditDialog (Shell parent,VascTable table,Object bean,String title,String headerText) {
|
public SwtVascEditDialog (Shell parent,Object bean,String title,String headerText) {
|
||||||
super (parent, 0);
|
super (parent, 0);
|
||||||
///this.headerText = headerText;
|
///this.headerText = headerText;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -249,32 +238,31 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
body.setLayout(new GridLayout(2, true));
|
body.setLayout(new GridLayout(2, true));
|
||||||
body.setLayoutData(new GridData(GridData.FILL_BOTH));
|
body.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
|
||||||
for(VascTableColumn c:table.getTableColumns()) {
|
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||||
Label l = new Label(body, SWT.WRAP);
|
Label l = new Label(body, SWT.WRAP);
|
||||||
l.setText(c.getName());
|
l.setText(c.getName());
|
||||||
|
|
||||||
if(c.getToolTip()!=null) {
|
if(c.getDescription()!=null) {
|
||||||
l.setToolTipText(c.getToolTip());
|
l.setToolTipText(c.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
table.getVascTableController().initEditObjectColumn(c, bean);
|
entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean);
|
||||||
|
|
||||||
//if(c.getVascColumnEditor()==null) {
|
//if(c.getVascColumnEditor()==null) {
|
||||||
Label valueLabel = new Label(body, SWT.WRAP);
|
Label valueLabel = new Label(body, SWT.WRAP);
|
||||||
valueLabel.setText(""+c.getVascColumnValue().getValue(c, bean));
|
valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean));
|
||||||
c.setColumnEditor(valueLabel);
|
//c.setColumnEditor(valueLabel);
|
||||||
/*
|
/*
|
||||||
} else {
|
} else {
|
||||||
c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body));
|
c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.WARNING,"Error making column editor: '"+c.getVascColumnValue()+"' error: "+e.getMessage(),e);
|
logger.log(Level.WARNING,"Error making column editor: '"+c.getVascEntryFieldValue()+"' error: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if(c.getColumnEditor() instanceof Control) {
|
if(c.getColumnEditor() instanceof Control) {
|
||||||
Control editor = (Control)c.getColumnEditor();
|
Control editor = (Control)c.getColumnEditor();
|
||||||
GridData gridData = new GridData();
|
GridData gridData = new GridData();
|
||||||
|
@ -284,6 +272,7 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
gridData.verticalAlignment = GridData.FILL;
|
gridData.verticalAlignment = GridData.FILL;
|
||||||
editor.setLayoutData(gridData);
|
editor.setLayoutData(gridData);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// create some spaceing , should replace by seperator
|
// create some spaceing , should replace by seperator
|
||||||
|
@ -292,8 +281,8 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
Button saveButton = new Button(body, SWT.NONE);
|
Button saveButton = new Button(body, SWT.NONE);
|
||||||
saveButton.setImage(getImageDescriptor("vasc.dialog.save.image").createImage());
|
saveButton.setImage(getImageDescriptor("vasc.dialog.save.image").createImage());
|
||||||
saveButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.save.name"));
|
saveButton.setText(i18n("vasc.dialog.save.name"));
|
||||||
saveButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.save.tooltip"));
|
saveButton.setToolTipText(i18n("vasc.dialog.save.tooltip"));
|
||||||
saveButton.addSelectionListener(new SelectionAdapter() {
|
saveButton.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
//if(hasRecordError()) {
|
//if(hasRecordError()) {
|
||||||
|
@ -305,8 +294,8 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
});
|
});
|
||||||
Button cancelButton = new Button(body, SWT.NONE);
|
Button cancelButton = new Button(body, SWT.NONE);
|
||||||
cancelButton.setImage(getImageDescriptor("vasc.dialog.cancel.image").createImage());
|
cancelButton.setImage(getImageDescriptor("vasc.dialog.cancel.image").createImage());
|
||||||
cancelButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.name"));
|
cancelButton.setText(i18n("vasc.dialog.cancel.name"));
|
||||||
cancelButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.tooltip"));
|
cancelButton.setToolTipText(i18n("vasc.dialog.cancel.tooltip"));
|
||||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
result = null;
|
result = null;
|
||||||
|
@ -316,21 +305,21 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object defaultColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception {
|
public Object defaultColumnEditor(VascEntryField column,Object bean,Object gui) throws Exception {
|
||||||
|
|
||||||
Composite body = (Composite)gui;
|
Composite body = (Composite)gui;
|
||||||
Text text = new Text(body,SWT.SINGLE);
|
Text text = new Text(body,SWT.SINGLE);
|
||||||
text.addSelectionListener(new TextListener(column,bean));
|
text.addSelectionListener(new TextListener(column,bean));
|
||||||
text.setText(""+column.getVascColumnValue().getValue(column, bean));
|
text.setText(""+column.getVascEntryFieldValue().getValue(column, bean));
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextListener extends SelectionAdapter {
|
class TextListener extends SelectionAdapter {
|
||||||
|
|
||||||
private VascTableColumn column = null;
|
private VascEntryField column = null;
|
||||||
private Object bean = null;
|
private Object bean = null;
|
||||||
|
|
||||||
public TextListener(VascTableColumn column,Object bean) {
|
public TextListener(VascEntryField column,Object bean) {
|
||||||
this.column=column;
|
this.column=column;
|
||||||
this.bean=bean;
|
this.bean=bean;
|
||||||
}
|
}
|
||||||
|
@ -343,18 +332,13 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
Object value = e.data;
|
Object value = e.data;
|
||||||
logger.finer("Setting value: "+value);
|
logger.finer("Setting value: "+value);
|
||||||
try {
|
try {
|
||||||
column.getVascColumnValue().setValue(column, bean, value);
|
column.getVascEntryFieldValue().setValue(column, bean, value);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
ee.printStackTrace();
|
ee.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object defaultColumnRenderer(VascTableColumn column,Object gui) throws Exception {
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void renderView() throws Exception {
|
public void renderView() throws Exception {
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
|
@ -419,10 +403,10 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
headerOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
headerOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
|
||||||
ToolBar toolBar = new ToolBar(headerBar, SWT.NONE);
|
ToolBar toolBar = new ToolBar(headerBar, SWT.NONE);
|
||||||
for (GlobalVascAction action:table.getGlobalActions()) {
|
for (GlobalVascAction action:entry.getGlobalActions()) {
|
||||||
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
|
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
|
||||||
item.setText(table.getVascTextValue().getTextValue(action.getName()));
|
item.setText(i18n(action.getName()));
|
||||||
item.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip()));
|
item.setToolTipText(i18n(action.getToolTip()));
|
||||||
if (action.getImage()!=null) {
|
if (action.getImage()!=null) {
|
||||||
item.setImage(getImageDescriptor(action.getImage()).createImage());
|
item.setImage(getImageDescriptor(action.getImage()).createImage());
|
||||||
}
|
}
|
||||||
|
@ -432,12 +416,12 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
Color c = new Color(header.getDisplay(),255,255,255);
|
Color c = new Color(header.getDisplay(),255,255,255);
|
||||||
headerName.setBackground(c);
|
headerName.setBackground(c);
|
||||||
if(table.getHeaderName()!=null) {
|
if(entry.getHeaderName()!=null) {
|
||||||
Font headerFont = new Font(header.getDisplay(), "verdana", 16, SWT.BOLD);
|
Font headerFont = new Font(header.getDisplay(), "verdana", 16, SWT.BOLD);
|
||||||
Label l = new Label(headerName, SWT.CENTER);
|
Label l = new Label(headerName, SWT.CENTER);
|
||||||
l.setImage(getImageDescriptor(table.getHeaderImage()).createImage());
|
l.setImage(getImageDescriptor(entry.getHeaderImage()).createImage());
|
||||||
l.setFont(headerFont);
|
l.setFont(headerFont);
|
||||||
l.setText(table.getVascTextValue().getTextValue(table.getHeaderName()));
|
l.setText(i18n(entry.getHeaderName()));
|
||||||
l.setBackground(c);
|
l.setBackground(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,9 +458,9 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
logger.fine("Global Action");
|
logger.fine("Global Action");
|
||||||
try {
|
try {
|
||||||
action.doGlobalAction(table);
|
action.doGlobalAction(entry);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
table.getVascTableController().handleException(e, table);
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(e, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,14 +496,14 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
Object data = e.item.getData();
|
Object data = e.item.getData();
|
||||||
logger.fine("Slecting data: "+data);
|
logger.fine("Slecting data: "+data);
|
||||||
table.setSelectedObject(data);
|
entry.getVascFrontendData().setEntryDataObject(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set the content and label providers
|
// Set the content and label providers
|
||||||
tableViewer.setContentProvider(new ListConverterContentProvider());
|
tableViewer.setContentProvider(new ListConverterContentProvider());
|
||||||
tableViewer.setLabelProvider(new DefaultLabelProvider(table));
|
tableViewer.setLabelProvider(new DefaultLabelProvider(entry));
|
||||||
//TODO: add renderer support
|
//TODO: add renderer support
|
||||||
|
|
||||||
//Add sort indicator and sort data when column selected
|
//Add sort indicator and sort data when column selected
|
||||||
|
@ -556,10 +540,10 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(VascTableColumn c:table.getTableColumns()) {
|
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||||
TableColumn tc = new TableColumn(table2, SWT.LEFT);
|
TableColumn tc = new TableColumn(table2, SWT.LEFT);
|
||||||
tc.setText(c.getName());
|
tc.setText(c.getName());
|
||||||
tc.setToolTipText(c.getToolTip());
|
tc.setToolTipText(c.getDescription());
|
||||||
if (c.getImage()!=null) {
|
if (c.getImage()!=null) {
|
||||||
tc.setImage(getImageDescriptor(c.getImage()).createImage());
|
tc.setImage(getImageDescriptor(c.getImage()).createImage());
|
||||||
}
|
}
|
||||||
|
@ -568,14 +552,11 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
tc.setResizable(true);
|
tc.setResizable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int totalWidth = entry.getVascFrontendData().getVascFrontendHelper().getTotalColumnsWidth(entry);
|
||||||
|
|
||||||
|
|
||||||
int totalWidth = table.getVascTableController().getTotalColumnsWidth(table);
|
|
||||||
logger.finer("Total size: "+totalWidth);
|
logger.finer("Total size: "+totalWidth);
|
||||||
TableColumn[] columns = table2.getColumns();
|
TableColumn[] columns = table2.getColumns();
|
||||||
for (int i = 0; i < columns.length; i++) {
|
for (int i = 0; i < columns.length; i++) {
|
||||||
Integer cWidth = table.getTableColumns().get(i).getWidth();
|
Integer cWidth = entry.getVascEntryFields().get(i).getSizeEdit();
|
||||||
if (cWidth==null) {
|
if (cWidth==null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -586,16 +567,16 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
}
|
}
|
||||||
logger.fine("Table with columns created: "+table2.getColumnCount());
|
logger.fine("Table with columns created: "+table2.getColumnCount());
|
||||||
|
|
||||||
tableViewer.setInput(table);
|
tableViewer.setInput(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createFooter(Composite footer) {
|
public void createFooter(Composite footer) {
|
||||||
logger.finest("Creating footer");
|
logger.finest("Creating footer");
|
||||||
for(RowVascAction action:table.getRowActions()) {
|
for(RowVascAction action:entry.getRowActions()) {
|
||||||
Button actionButton = new Button(footer, SWT.NONE);
|
Button actionButton = new Button(footer, SWT.NONE);
|
||||||
actionButton.setText(table.getVascTextValue().getTextValue(action.getName()));
|
actionButton.setText(i18n(action.getName()));
|
||||||
actionButton.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip()));
|
actionButton.setToolTipText(i18n(action.getToolTip()));
|
||||||
if (action.getImage()!=null) {
|
if (action.getImage()!=null) {
|
||||||
actionButton.setImage(getImageDescriptor(action.getImage()).createImage());
|
actionButton.setImage(getImageDescriptor(action.getImage()).createImage());
|
||||||
}
|
}
|
||||||
|
@ -617,9 +598,9 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
logger.fine("Row Action");
|
logger.fine("Row Action");
|
||||||
try {
|
try {
|
||||||
action.doRowAction(table, table.getSelectedObject());
|
action.doRowAction(entry, entry.getVascFrontendData().getEntryDataObject());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
table.getVascTableController().handleException(e, table);
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(e, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -633,10 +614,10 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
|
|
||||||
class DefaultLabelProvider implements ITableLabelProvider {
|
class DefaultLabelProvider implements ITableLabelProvider {
|
||||||
|
|
||||||
private VascTable table = null;
|
private VascEntry entry = null;
|
||||||
|
|
||||||
public DefaultLabelProvider(VascTable table) {
|
public DefaultLabelProvider(VascEntry entry) {
|
||||||
this.table=table;
|
this.entry=entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -650,17 +631,17 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||||
*/
|
*/
|
||||||
public String getColumnText(Object bean, int columnNumber) {
|
public String getColumnText(Object bean, int columnNumber) {
|
||||||
VascTableColumn vtc = table.getTableColumns().get(columnNumber);
|
VascEntryField vtc = entry.getVascEntryFields().get(columnNumber);
|
||||||
if (vtc.getVascColumnRenderer()==null) {
|
//if (vtc.getVascColumnRenderer()==null) {
|
||||||
try {
|
try {
|
||||||
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
return ""+vtc.getVascEntryFieldValue().getValue(vtc,bean);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.WARNING,"Error in get value: '"+vtc.getVascColumnValue()+"' error: "+e.getMessage(),e);
|
logger.log(Level.WARNING,"Error in get value: '"+vtc.getVascEntryFieldValue()+"' error: "+e.getMessage(),e);
|
||||||
return "Err";
|
return "Err";
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
// see custem column renderer, so this code will never be called
|
// see custem column renderer, so this code will never be called
|
||||||
return "CUSTEM_RENDER";
|
//return "CUSTEM_RENDER";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -696,7 +677,7 @@ public class SwtVascFrontend implements VascFrontend {
|
||||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object[] getElements(Object obj) {
|
public Object[] getElements(Object obj) {
|
||||||
return ((VascTable)obj).getTableData().toArray();
|
return ((VascEntry)obj).getVascFrontendData().getEntryDataList().toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
212
src/com/idcanet/vasc/impl/DefaultVascBackedEntryFinalizer.java
Normal file
212
src/com/idcanet/vasc/impl/DefaultVascBackedEntryFinalizer.java
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||||
|
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.impl;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
|
import com.idcanet.vasc.core.VascEntryFieldSet;
|
||||||
|
import com.idcanet.vasc.core.VascEntryFinalizer;
|
||||||
|
import com.idcanet.vasc.core.VascLinkEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for minimal needed stuff
|
||||||
|
* and fills up the rest.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 14, 2008
|
||||||
|
*/
|
||||||
|
public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascEntryFinalizer#finalizeVascEntry(com.idcanet.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public VascEntry finalizeVascEntry(VascEntry entry) throws Exception {
|
||||||
|
|
||||||
|
// First Check if we all have ids
|
||||||
|
if (entry.getId()==null) {
|
||||||
|
throw new IllegalArgumentException("The VascEntry need an id.");
|
||||||
|
}
|
||||||
|
if (entry.getVascEntryFields().size()==0) {
|
||||||
|
throw new IllegalArgumentException("We need at least one VascEntryField.");
|
||||||
|
}
|
||||||
|
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||||
|
if (vef.getId()==null) {
|
||||||
|
throw new IllegalArgumentException("All VascEntryField need an id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill up all not field i18n keys
|
||||||
|
String id = entry.getId();
|
||||||
|
|
||||||
|
// header
|
||||||
|
if (entry.getHeaderName()==null) {
|
||||||
|
entry.setHeaderName("vasc.entry."+id+".headerName");
|
||||||
|
}
|
||||||
|
if (entry.getHeaderDescription()==null) {
|
||||||
|
entry.setHeaderDescription("vasc.entry."+id+".headerDescription");
|
||||||
|
}
|
||||||
|
if (entry.getHeaderImage()==null) {
|
||||||
|
entry.setHeaderImage("vasc.entry."+id+".headerImage");
|
||||||
|
}
|
||||||
|
|
||||||
|
// entry fields
|
||||||
|
if (entry.getName()==null) {
|
||||||
|
entry.setName("vasc.entry."+id+".name");
|
||||||
|
}
|
||||||
|
if (entry.getDescription()==null) {
|
||||||
|
entry.setDescription("vasc.entry."+id+".description");
|
||||||
|
}
|
||||||
|
if (entry.getImage()==null) {
|
||||||
|
entry.setImage("vasc.entry."+id+".image");
|
||||||
|
}
|
||||||
|
if (entry.getHelpId()==null) {
|
||||||
|
entry.setHelpId("vasc.entry."+id+".helpId");
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional field sets
|
||||||
|
for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) {
|
||||||
|
|
||||||
|
// check id
|
||||||
|
String sid = s.getId();
|
||||||
|
if (sid==null) {
|
||||||
|
throw new IllegalArgumentException("All VascEntryFieldSet need an id");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if refenced ids are avalible
|
||||||
|
for (String fid:s.getVascEntryFieldIds()) {
|
||||||
|
if (entry.getVascEntryFieldById(fid)==null) {
|
||||||
|
throw new IllegalArgumentException("VascEntryFieldSet "+sid+" has non excisting field id: "+fid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill up properties
|
||||||
|
if (s.getName()==null) {
|
||||||
|
s.setName("vasc.entry."+id+"."+sid+"name");
|
||||||
|
}
|
||||||
|
if (s.getDescription()==null) {
|
||||||
|
s.setDescription("vasc.entry."+id+"."+sid+".description");
|
||||||
|
}
|
||||||
|
if (s.getImage()==null) {
|
||||||
|
s.setImage("vasc.entry."+id+"."+sid+".image");
|
||||||
|
}
|
||||||
|
if (s.getHelpId()==null) {
|
||||||
|
s.setHelpId("vasc.entry."+id+"."+sid+".helpId");
|
||||||
|
}
|
||||||
|
if (s.getStyleEdit()==null) {
|
||||||
|
s.setStyleEdit("vasc.entry."+id+"."+sid+".styleEdit");
|
||||||
|
}
|
||||||
|
if (s.getStyleList()==null) {
|
||||||
|
s.setStyleList("vasc.entry."+id+"."+sid+".styleEdit");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set defaults field Id for key ad display
|
||||||
|
if (entry.getPrimaryKeyFieldId()==null) {
|
||||||
|
entry.setPrimaryKeyFieldId(entry.getVascEntryFields().get(0).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.getDisplayNameFieldId()==null) {
|
||||||
|
entry.setDisplayNameFieldId(entry.getVascEntryFields().get(0).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check fields
|
||||||
|
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||||
|
String vid = vef.getId();
|
||||||
|
|
||||||
|
// set manual stuff
|
||||||
|
if (vef.getBackendName()==null) {
|
||||||
|
vef.setBackendName(vid);
|
||||||
|
}
|
||||||
|
if (vef.getVascEntry()==null) {
|
||||||
|
vef.setVascEntry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill up properties
|
||||||
|
if (vef.getName()==null) {
|
||||||
|
vef.setName("vasc.entry."+id+"."+vid+"name");
|
||||||
|
}
|
||||||
|
if (vef.getDescription()==null) {
|
||||||
|
vef.setDescription("vasc.entry."+id+"."+vid+".description");
|
||||||
|
}
|
||||||
|
if (vef.getImage()==null) {
|
||||||
|
vef.setImage("vasc.entry."+id+"."+vid+".image");
|
||||||
|
}
|
||||||
|
if (vef.getHelpId()==null) {
|
||||||
|
vef.setHelpId("vasc.entry."+id+"."+vid+".helpId");
|
||||||
|
}
|
||||||
|
if (vef.getStyleEdit()==null) {
|
||||||
|
vef.setStyleEdit("vasc.entry."+id+"."+vid+".styleEdit");
|
||||||
|
}
|
||||||
|
if (vef.getStyleList()==null) {
|
||||||
|
vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (vef.getDefaultValue()==null) {
|
||||||
|
// vef.setDefaultValue("vasc.entry."+id+"."+vid+".defaultValue");
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
if (vef.getVascEntryFieldEventChannel()==null) {
|
||||||
|
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||||
|
}
|
||||||
|
if (vef.getVascEntryFieldValue()==null) {
|
||||||
|
//vef.setVascEntryFieldValue(entry.getVasc)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vef.getVascEntryFieldType()==null) {
|
||||||
|
if (vef.getDefaultValue() instanceof Boolean) {
|
||||||
|
///vef.setVascEntryFieldType(vascEntryFieldType);
|
||||||
|
} else if (vef.getDefaultValue() instanceof Date) {
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||||
|
}
|
||||||
|
|
||||||
|
//for (VascValidator vv:vef.getVascValidators()) {
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check if link entries excists
|
||||||
|
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||||
|
vle.getVascEntryName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ..
|
||||||
|
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -94,6 +94,11 @@ public class DefaultVascEntryField implements VascEntryField {
|
||||||
vascValidators = new ArrayList<VascValidator>(5);
|
vascValidators = new ArrayList<VascValidator>(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DefaultVascEntryField(String id) {
|
||||||
|
super();
|
||||||
|
setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
public VascEntry getVascEntry() {
|
public VascEntry getVascEntry() {
|
||||||
return vascEntry;
|
return vascEntry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||||
|
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.impl;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
import com.idcanet.vasc.core.VascEntryFinalizer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 14, 2008
|
||||||
|
*/
|
||||||
|
public class DefaultVascFrontendEntryFinalizer implements VascEntryFinalizer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascEntryFinalizer#finalizeVascEntry(com.idcanet.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public VascEntry finalizeVascEntry(VascEntry entry) throws Exception {
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,16 +26,9 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.impl;
|
package com.idcanet.vasc.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.hibernate.validator.ClassValidator;
|
|
||||||
import org.hibernate.validator.InvalidValue;
|
|
||||||
|
|
||||||
import com.idcanet.vasc.annotations.VascAnnotationParser;
|
|
||||||
import com.idcanet.vasc.core.VascEntry;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.VascEntryField;
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
import com.idcanet.vasc.core.VascFrontendHelper;
|
import com.idcanet.vasc.core.VascFrontendHelper;
|
||||||
|
@ -199,9 +192,9 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
return true; // nothing to check
|
return true; // nothing to check
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassValidator val = new ClassValidator(bean.getClass());
|
//ClassValidator val = new ClassValidator(bean.getClass());
|
||||||
InvalidValue[] ival = val.getInvalidValues(bean);
|
//InvalidValue[] ival = val.getInvalidValues(bean);
|
||||||
logger.fine("Got invaliled value: "+ival.length);
|
//logger.fine("Got invaliled value: "+ival.length);
|
||||||
|
|
||||||
for(VascEntryField col:entry.getVascEntryFields()) {
|
for(VascEntryField col:entry.getVascEntryFields()) {
|
||||||
/*
|
/*
|
||||||
|
@ -224,6 +217,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
logger.finest("Checked for errors: "+error);
|
logger.finest("Checked for errors: "+error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
private InvalidValue findInvalidValueByProperty(InvalidValue[] ival,String property) {
|
private InvalidValue findInvalidValueByProperty(InvalidValue[] ival,String property) {
|
||||||
for(InvalidValue iv:ival) {
|
for(InvalidValue iv:ival) {
|
||||||
if(iv.getPropertyName().equals(property)) {
|
if(iv.getPropertyName().equals(property)) {
|
||||||
|
@ -232,6 +226,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void finalizeVascColumns(VascTable table) throws Exception {
|
public void finalizeVascColumns(VascTable table) throws Exception {
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||||
|
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.impl.type;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascEntryFieldType;
|
||||||
|
import com.idcanet.vasc.core.VascEntryFieldTypeController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 14, 2008
|
||||||
|
*/
|
||||||
|
public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeController {
|
||||||
|
|
||||||
|
FieldTypeParser parser = null;
|
||||||
|
|
||||||
|
public DefaultVascEntryFieldTypeController() throws Exception {
|
||||||
|
parser = new FieldTypeParser();
|
||||||
|
parser.parseVascFieldTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldType(java.lang.String)
|
||||||
|
*/
|
||||||
|
public VascEntryFieldType getVascEntryFieldType(String name) {
|
||||||
|
for(VascEntryFieldType v:parser.getTypes()) {
|
||||||
|
if (v.getId().equals(name)) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Field not found: "+name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldTypeNames()
|
||||||
|
*/
|
||||||
|
public List<String> getVascEntryFieldTypeNames() {
|
||||||
|
List<String> result = new ArrayList<String>(5);
|
||||||
|
for(VascEntryFieldType v:parser.getTypes()) {
|
||||||
|
result.add(v.getId());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||||
|
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.impl.type;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascEntryFieldTypeController;
|
||||||
|
import com.idcanet.vasc.core.VascEntryFieldTypeControllerResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 14, 2008
|
||||||
|
*/
|
||||||
|
public class DefaultVascEntryFieldTypeControllerResolver implements VascEntryFieldTypeControllerResolver {
|
||||||
|
|
||||||
|
VascEntryFieldTypeController vascEntryFieldTypeController = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascEntryFieldTypeControllerResolver#getVascEntryFieldTypeController()
|
||||||
|
*/
|
||||||
|
public VascEntryFieldTypeController getVascEntryFieldTypeController() {
|
||||||
|
return vascEntryFieldTypeController;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param vascEntryFieldTypeController the vascEntryFieldTypeController to set
|
||||||
|
*/
|
||||||
|
public void setVascEntryFieldTypeController(VascEntryFieldTypeController vascEntryFieldTypeController) {
|
||||||
|
this.vascEntryFieldTypeController = vascEntryFieldTypeController;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -40,4 +42,18 @@ public class VascDateFutureValidator implements VascValidator {
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascDateFuture.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -40,4 +42,18 @@ public class VascDatePastValidator implements VascValidator {
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascDatePast.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -34,10 +36,69 @@ package com.idcanet.vasc.validators;
|
||||||
*/
|
*/
|
||||||
public class VascIntSizeValidator implements VascValidator {
|
public class VascIntSizeValidator implements VascValidator {
|
||||||
|
|
||||||
|
private int max = Integer.MAX_VALUE;
|
||||||
|
private int min = Integer.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
|
if ((object instanceof Integer)==false) {
|
||||||
|
return false; // only string can be matched.
|
||||||
|
}
|
||||||
|
Integer value = (Integer)object;
|
||||||
|
if (value > max) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (value < min) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascIntSizeValidator.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
VascIntSize a = VascIntSize.class.cast(annotation);
|
||||||
|
VascIntSizeValidator v = new VascIntSizeValidator();
|
||||||
|
v.setMin(a.min());
|
||||||
|
v.setMax(a.max());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the max
|
||||||
|
*/
|
||||||
|
public int getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param max the max to set
|
||||||
|
*/
|
||||||
|
public void setMax(int max) {
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the min
|
||||||
|
*/
|
||||||
|
public int getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param min the min to set
|
||||||
|
*/
|
||||||
|
public void setMin(int min) {
|
||||||
|
this.min = min;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -34,10 +36,69 @@ package com.idcanet.vasc.validators;
|
||||||
*/
|
*/
|
||||||
public class VascLongSizeValidator implements VascValidator {
|
public class VascLongSizeValidator implements VascValidator {
|
||||||
|
|
||||||
|
private long max = Long.MAX_VALUE;
|
||||||
|
private long min = Long.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
|
if ((object instanceof Long)==false) {
|
||||||
|
return false; // only string can be matched.
|
||||||
|
}
|
||||||
|
Long value = (Long)object;
|
||||||
|
if (value > max) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (value < min) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascLongSize.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
VascLongSize a = VascLongSize.class.cast(annotation);
|
||||||
|
VascLongSizeValidator v = new VascLongSizeValidator();
|
||||||
|
v.setMin(a.min());
|
||||||
|
v.setMax(a.max());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the max
|
||||||
|
*/
|
||||||
|
public long getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param max the max to set
|
||||||
|
*/
|
||||||
|
public void setMax(long max) {
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the min
|
||||||
|
*/
|
||||||
|
public long getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param min the min to set
|
||||||
|
*/
|
||||||
|
public void setMin(long min) {
|
||||||
|
this.min = min;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -38,6 +40,20 @@ public class VascObjectNotNullValidator implements VascValidator {
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
return false;
|
return object!=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascObjectNotNull.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
return new VascObjectNotNullValidator();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -38,6 +40,20 @@ public class VascObjectNullValidator implements VascValidator {
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
return false;
|
return object==null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascObjectNull.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
return new VascObjectNullValidator();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,12 +32,34 @@ package com.idcanet.vasc.validators;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Sep 5, 2008
|
* @version 1.0 Sep 5, 2008
|
||||||
*/
|
*/
|
||||||
public class VascStringEmailValidator implements VascValidator {
|
public class VascStringEmailValidator extends VascStringRegexValidator {
|
||||||
|
|
||||||
|
static private final String EMAIL_REGEX = "(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* The constructor which sets the regex for email validation
|
||||||
|
*/
|
||||||
|
public VascStringEmailValidator() {
|
||||||
|
setRegEx(EMAIL_REGEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascStringEmail.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.Class)
|
||||||
|
*/
|
||||||
|
public void initAnnotation(Class<?> annotationType) {
|
||||||
|
//VascStringEmail a = VascStringEmail.class.cast(annotationType);
|
||||||
|
/*
|
||||||
|
if (a.regex().equals("null")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setRegEx(a.regex());
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,17 +53,4 @@ public @interface VascStringLength {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int max() default 0;
|
int max() default 0;
|
||||||
|
|
||||||
static BB bb = new BB() {
|
|
||||||
public VascValidator getValidator(VascStringLength ano) {
|
|
||||||
VascStringLengthValidator v = new VascStringLengthValidator();
|
|
||||||
v.setMinLenght(ano.min());
|
|
||||||
v.setMaxLenght(ano.max());
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BB {
|
|
||||||
public VascValidator getValidator(VascStringLength ano);
|
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -41,8 +43,10 @@ public class VascStringLengthValidator implements VascValidator {
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
|
if ((object instanceof String)==false) {
|
||||||
|
return false; // only string can be matched.
|
||||||
|
}
|
||||||
String result = (String)object;
|
String result = (String)object;
|
||||||
|
|
||||||
if (getMinLenght()!=null && result.length()<getMinLenght()) {
|
if (getMinLenght()!=null && result.length()<getMinLenght()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -79,4 +83,19 @@ public class VascStringLengthValidator implements VascValidator {
|
||||||
public void setMaxLenght(Integer maxLenght) {
|
public void setMaxLenght(Integer maxLenght) {
|
||||||
this.maxLenght = maxLenght;
|
this.maxLenght = maxLenght;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascStringLength.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
VascStringLength a = VascStringLength.class.cast(annotation);
|
||||||
|
VascStringLengthValidator v = new VascStringLengthValidator();
|
||||||
|
v.setMinLenght(a.min());
|
||||||
|
v.setMaxLenght(a.max());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,10 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
@ -34,10 +38,55 @@ package com.idcanet.vasc.validators;
|
||||||
*/
|
*/
|
||||||
public class VascStringRegexValidator implements VascValidator {
|
public class VascStringRegexValidator implements VascValidator {
|
||||||
|
|
||||||
|
private Pattern pattern = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the regulare expression on which this object filters an String.<br>
|
||||||
|
* <br>
|
||||||
|
* When set to <code>Null</code> matching is disabled.<br>
|
||||||
|
*
|
||||||
|
* @param regex The regulare expression to match to.
|
||||||
|
*/
|
||||||
|
public void setRegEx(String regex) {
|
||||||
|
pattern = Pattern.compile(regex);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns the current regulare expression.
|
||||||
|
* @return The regulare expression.
|
||||||
|
*/
|
||||||
|
public String getRegEx() {
|
||||||
|
if(pattern==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return pattern.pattern();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public boolean isObjectValid(Object object) throws VascValidatorException {
|
||||||
return false;
|
if ((object instanceof String)==false) {
|
||||||
|
return false; // only string can be matched.
|
||||||
|
}
|
||||||
|
// test if regex matches
|
||||||
|
Matcher m = pattern.matcher((String)object);
|
||||||
|
return m.find();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascStringRegex.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
|
||||||
|
*/
|
||||||
|
public VascValidator initAnnotation(Annotation annotation) {
|
||||||
|
VascStringRegex a = VascStringRegex.class.cast(annotation);
|
||||||
|
VascStringRegexValidator v = new VascStringRegexValidator();
|
||||||
|
v.setRegEx(a.regex());
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,15 +29,51 @@ package com.idcanet.vasc.validators;
|
||||||
/**
|
/**
|
||||||
* Validates
|
* Validates
|
||||||
*
|
*
|
||||||
|
* TODO:
|
||||||
|
* #Japanese postal codes
|
||||||
|
* zipJP=^\d{3}-\d{4}$
|
||||||
|
* #US postal codes
|
||||||
|
* zipUS=^\d{5}\p{Punct}?\s?(?:\d{4})?$
|
||||||
|
* #Dutch postal code
|
||||||
|
* zipNL=^[0-9]{4}\s*[a-zA-Z]{2}$
|
||||||
|
* #Argentinean postal code
|
||||||
|
* zipAR=^\d{3}-\d{4}$
|
||||||
|
* #Swedish postal code
|
||||||
|
* zipSE=^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$
|
||||||
|
* #Canadian postal code
|
||||||
|
* zipCA=^([A-Z]\d[A-Z]\s\d[A-Z]\d)$
|
||||||
|
* #UK postal code
|
||||||
|
* zipUK=^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
|
||||||
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Sep 5, 2008
|
* @version 1.0 Sep 5, 2008
|
||||||
*/
|
*/
|
||||||
public class VascStringZipCodeValidator implements VascValidator {
|
public class VascStringZipCodeValidator extends VascStringRegexValidator {
|
||||||
|
|
||||||
|
static private final String ZIP_REGEX = "^[0-9]{4}\\s*[a-zA-Z]{2}$";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
|
* The constructor which sets the regex for email validation
|
||||||
*/
|
*/
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException {
|
public VascStringZipCodeValidator() {
|
||||||
return false;
|
setRegEx(ZIP_REGEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType() {
|
||||||
|
return VascStringZipCode.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.Class)
|
||||||
|
*/
|
||||||
|
public void initAnnotation(Class<?> annotationType) {
|
||||||
|
VascStringRegex a = VascStringRegex.class.cast(annotationType);
|
||||||
|
if (a.regex().equals("null")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setRegEx(a.regex());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.validators;
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The VascValidator interface
|
* The VascValidator interface
|
||||||
|
@ -36,4 +38,12 @@ package com.idcanet.vasc.validators;
|
||||||
public interface VascValidator {
|
public interface VascValidator {
|
||||||
|
|
||||||
public boolean isObjectValid(Object object) throws VascValidatorException;
|
public boolean isObjectValid(Object object) throws VascValidatorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* May return null for no annotation support
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Class<?> getAnnotationType();
|
||||||
|
|
||||||
|
public VascValidator initAnnotation(Annotation annotation);
|
||||||
}
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||||
|
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.validators;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The VascValidator interface
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 14, 2008
|
||||||
|
*/
|
||||||
|
public class VascValidatorClassParser {
|
||||||
|
|
||||||
|
private List<VascValidator> validators = null;
|
||||||
|
|
||||||
|
public VascValidatorClassParser() {
|
||||||
|
validators = new ArrayList<VascValidator>(20);
|
||||||
|
|
||||||
|
validators.add(new VascDateFutureValidator());
|
||||||
|
validators.add(new VascDatePastValidator());
|
||||||
|
validators.add(new VascIntSizeValidator());
|
||||||
|
validators.add(new VascLongSizeValidator());
|
||||||
|
validators.add(new VascObjectNotNullValidator());
|
||||||
|
validators.add(new VascObjectNullValidator());
|
||||||
|
validators.add(new VascStringEmailValidator());
|
||||||
|
validators.add(new VascStringLengthValidator());
|
||||||
|
validators.add(new VascStringRegexValidator());
|
||||||
|
validators.add(new VascStringZipCodeValidator());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VascValidator> getValidatorsByPropertyName(Class<?> parseClass,String propertyName) {
|
||||||
|
List<VascValidator> result = new ArrayList<VascValidator>(4);
|
||||||
|
|
||||||
|
for(Method method:parseClass.getMethods()) {
|
||||||
|
if (method.getName().equalsIgnoreCase("get"+propertyName)==false) { //a bit dirty
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (VascValidator v:validators) {
|
||||||
|
for (Annotation a:method.getAnnotations()) {
|
||||||
|
if (a.annotationType().equals(v.getAnnotationType())) {
|
||||||
|
VascValidator val = v.initAnnotation(a);
|
||||||
|
result.add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,7 +32,8 @@ import java.util.logging.LogManager;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
import com.idcanet.vasc.impl.swt.SwtVascViewRenderer;
|
import com.idcanet.vasc.frontends.swt.SwtVascFrontend;
|
||||||
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -64,8 +65,8 @@ public class SWTTest extends TestCase {
|
||||||
shell.setText("Vasc Test - Swt");
|
shell.setText("Vasc Test - Swt");
|
||||||
|
|
||||||
// define redering and render
|
// define redering and render
|
||||||
SwtVascViewRenderer render = new SwtVascViewRenderer(shell);
|
SwtVascFrontend render = new SwtVascFrontend(shell);
|
||||||
render.initTable(TestTable.getVascTable());
|
render.initEntry(TestTable.getVascTable());
|
||||||
render.renderView();
|
render.renderView();
|
||||||
|
|
||||||
// view
|
// view
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||||
import com.idcanet.vasc.core.ui.VascSelectItem;
|
import com.idcanet.vasc.core.ui.VascSelectItem;
|
||||||
import com.idcanet.vasc.core.ui.VascSelectItemModel;
|
import com.idcanet.vasc.core.ui.VascSelectItemModel;
|
||||||
|
import com.idcanet.vasc.impl.entry.BeanPropertyVascEntryFieldValue;
|
||||||
import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator;
|
import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator;
|
||||||
import com.idcanet.vasc.models.TestModel;
|
import com.idcanet.vasc.models.TestModel;
|
||||||
|
|
||||||
|
@ -89,6 +90,16 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc
|
||||||
testModels.remove(object);
|
testModels.remove(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
|
return new BeanPropertyVascEntryFieldValue(field.getBackendName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
|
return new BeanVascEntryRecordCreator(TestModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- VascSelectItemModel interface
|
||||||
|
|
||||||
public List<VascSelectItem> getVascSelectItems() {
|
public List<VascSelectItem> getVascSelectItems() {
|
||||||
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
|
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
|
||||||
for (Object o:testModels) {
|
for (Object o:testModels) {
|
||||||
|
@ -98,12 +109,4 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
|
||||||
return new BeanVascEntryRecordCreator(TestModel.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -26,15 +26,20 @@
|
||||||
|
|
||||||
package com.idcanet.vasc;
|
package com.idcanet.vasc;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.VascController;
|
import com.idcanet.vasc.core.VascController;
|
||||||
import com.idcanet.vasc.core.VascEntry;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.core.VascEntryField;
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
import com.idcanet.vasc.core.ui.VascList;
|
import com.idcanet.vasc.core.ui.VascList;
|
||||||
|
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
|
||||||
|
import com.idcanet.vasc.impl.DefaultVascFrontendEntryFinalizer;
|
||||||
import com.idcanet.vasc.impl.DefaultVascController;
|
import com.idcanet.vasc.impl.DefaultVascController;
|
||||||
import com.idcanet.vasc.impl.DefaultVascEntry;
|
import com.idcanet.vasc.impl.DefaultVascEntry;
|
||||||
import com.idcanet.vasc.impl.DefaultVascEntryField;
|
import com.idcanet.vasc.impl.DefaultVascEntryField;
|
||||||
|
import com.idcanet.vasc.impl.DefaultVascFrontendData;
|
||||||
|
import com.idcanet.vasc.impl.DefaultVascFrontendHelper;
|
||||||
import com.idcanet.vasc.impl.actions.AddRowAction;
|
import com.idcanet.vasc.impl.actions.AddRowAction;
|
||||||
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
|
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
|
||||||
import com.idcanet.vasc.impl.actions.DeleteRowAction;
|
import com.idcanet.vasc.impl.actions.DeleteRowAction;
|
||||||
|
@ -43,6 +48,9 @@ import com.idcanet.vasc.impl.actions.RefreshDataGlobalAction;
|
||||||
import com.idcanet.vasc.impl.actions.XMLExportGlobalAction;
|
import com.idcanet.vasc.impl.actions.XMLExportGlobalAction;
|
||||||
import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator;
|
import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator;
|
||||||
import com.idcanet.vasc.impl.entry.BeanPropertyVascEntryFieldValue;
|
import com.idcanet.vasc.impl.entry.BeanPropertyVascEntryFieldValue;
|
||||||
|
import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
||||||
|
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeController;
|
||||||
|
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeControllerResolver;
|
||||||
import com.idcanet.vasc.models.TestModel;
|
import com.idcanet.vasc.models.TestModel;
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,11 +61,25 @@ import com.idcanet.vasc.models.TestModel;
|
||||||
*/
|
*/
|
||||||
public class TestTable {
|
public class TestTable {
|
||||||
|
|
||||||
static VascController getDefaultVascController() {
|
static VascController getDefaultVascController() throws Exception {
|
||||||
|
|
||||||
DefaultVascController c = new DefaultVascController();
|
DefaultVascController c = new DefaultVascController();
|
||||||
|
|
||||||
|
|
||||||
//entry.setVascEntryResourceResolver(new VascI18nTextValue());
|
//DefaultVascBackendControllerResolver vascBackendControllerResolver = new DefaultVascBackendControllerResolver();
|
||||||
|
//c.setVascBackendControllerResolver(vascBackendControllerResolver);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//DefaultVascEntryControllerResolver vascEntryControllerResolver = new DefaultVascEntryControllerResolver();
|
||||||
|
//c.setVascEntryControllerResolver(vascEntryControllerResolver);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DefaultVascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = new DefaultVascEntryFieldTypeControllerResolver();
|
||||||
|
DefaultVascEntryFieldTypeController vascEntryFieldTypeController = new DefaultVascEntryFieldTypeController();
|
||||||
|
vascEntryFieldTypeControllerResolver.setVascEntryFieldTypeController(vascEntryFieldTypeController);
|
||||||
|
c.setVascEntryFieldTypeControllerResolver(vascEntryFieldTypeControllerResolver);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
|
@ -81,11 +103,18 @@ public class TestTable {
|
||||||
|
|
||||||
// config table
|
// config table
|
||||||
VascEntry entry = new DefaultVascEntry();
|
VascEntry entry = new DefaultVascEntry();
|
||||||
entry.setName("Testje");
|
|
||||||
entry.setHeaderName("Test Table enzo");
|
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData();
|
||||||
entry.setHeaderDescription("Met een hele coole tooltip");
|
vascFrontendData.setVascBackend(data);
|
||||||
entry.setHeaderImage("/resources/images/gabelfresser.gif");
|
|
||||||
entry.setHelpId("someKey");
|
DefaultVascEntryResourceResolver vascEntryResourceResolver = new DefaultVascEntryResourceResolver();
|
||||||
|
vascFrontendData.setVascEntryResourceResolver(vascEntryResourceResolver);
|
||||||
|
|
||||||
|
DefaultVascFrontendHelper vascFrontendHelper = new DefaultVascFrontendHelper();
|
||||||
|
vascFrontendData.setVascFrontendHelper(vascFrontendHelper);
|
||||||
|
|
||||||
|
entry.setVascFrontendData(vascFrontendData);
|
||||||
|
entry.setId("test1");
|
||||||
|
|
||||||
entry.addRowAction(new AddRowAction());
|
entry.addRowAction(new AddRowAction());
|
||||||
entry.addRowAction(new EditRowAction());
|
entry.addRowAction(new EditRowAction());
|
||||||
|
@ -98,11 +127,7 @@ public class TestTable {
|
||||||
//table.addUserOptions(userOption);
|
//table.addUserOptions(userOption);
|
||||||
//table.addColumnActions(new GraphColumnAction());
|
//table.addColumnActions(new GraphColumnAction());
|
||||||
|
|
||||||
VascEntryField field = new DefaultVascEntryField();
|
VascEntryField field = new DefaultVascEntryField("name");
|
||||||
field.setName("test");
|
|
||||||
field.setDescription("tooltip");
|
|
||||||
field.setDefaultValue("DEFFFFFF");
|
|
||||||
field.setHelpId("helpColumnKey");
|
|
||||||
field.setImage("/META-INF/images/silk/png/tick.png");
|
field.setImage("/META-INF/images/silk/png/tick.png");
|
||||||
try {
|
try {
|
||||||
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldType("TextField"));
|
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldType("TextField"));
|
||||||
|
@ -113,34 +138,77 @@ public class TestTable {
|
||||||
field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("name"));
|
field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("name"));
|
||||||
entry.addVascEntryField(field);
|
entry.addVascEntryField(field);
|
||||||
|
|
||||||
/*
|
|
||||||
field = new VascAnnotationTableColumn("description");
|
|
||||||
entry.addVascField(field);
|
|
||||||
|
|
||||||
field = new VascAnnotationTableColumn("active");
|
field = new DefaultVascEntryField("description");
|
||||||
|
field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("description"));
|
||||||
|
entry.addVascEntryField(field);
|
||||||
|
|
||||||
|
|
||||||
|
field = new DefaultVascEntryField("active");
|
||||||
field.setDefaultValue(true);
|
field.setDefaultValue(true);
|
||||||
entry.addVascField(field);
|
entry.addVascEntryField(field);
|
||||||
|
|
||||||
field = new VascAnnotationTableColumn("date");
|
field = new DefaultVascEntryField("date");
|
||||||
field.setDefaultValue(new Date());
|
field.setDefaultValue(new Date());
|
||||||
entry.addVascField(field);
|
entry.addVascEntryField(field);
|
||||||
|
|
||||||
field = new VascAnnotationTableColumn("testModel");
|
field = new DefaultVascEntryField("testModel");
|
||||||
VascList list = new VascList();
|
VascList list = new VascList();
|
||||||
list.setVascSelectItemModel(data);
|
list.setVascSelectItemModel(data);
|
||||||
field.setVascUIComponent(list);
|
//field.setVascUIComponent(list);
|
||||||
entry.addVascField(field);
|
entry.addVascEntryField(field);
|
||||||
|
|
||||||
|
|
||||||
field = new VascAnnotationTableColumn("hexColor");
|
field = new DefaultVascEntryField("hexColor");
|
||||||
field.setDefaultValue("#FF3355");
|
field.setDefaultValue("#FF3355");
|
||||||
//VascColorChooser ui = new VascColorChooser();
|
//VascColorChooser ui = new VascColorChooser();
|
||||||
//ui.setHexSwingEncoding(true);
|
//ui.setHexSwingEncoding(true);
|
||||||
//field.setVascUIComponent(ui);
|
//field.setVascUIComponent(ui);
|
||||||
entry.addVascField(field);
|
entry.addVascEntryField(field);
|
||||||
*/
|
|
||||||
|
printEntry(entry);
|
||||||
|
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||||
|
entry = f.finalizeVascEntry(entry);
|
||||||
|
printEntry(entry);
|
||||||
|
|
||||||
|
DefaultVascFrontendEntryFinalizer f2 = new DefaultVascFrontendEntryFinalizer();
|
||||||
|
entry = f2.finalizeVascEntry(entry);
|
||||||
|
//printEntry(entry);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void printEntry(VascEntry e) throws Exception {
|
||||||
|
|
||||||
|
System.out.println("");
|
||||||
|
System.out.println("=== Printing entry ===");
|
||||||
|
System.out.println("");
|
||||||
|
|
||||||
|
for (Method m:e.getClass().getMethods()) {
|
||||||
|
if (m.getName().startsWith("get")==false) { //a bit dirty
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m.getParameterTypes().length>0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
System.out.println("prop: "+m.getName()+" -> "+m.invoke(e, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("");
|
||||||
|
System.out.println("=== Fields ===");
|
||||||
|
for (VascEntryField vef:e.getVascEntryFields()) {
|
||||||
|
|
||||||
|
System.out.println("=== Field: "+vef.getId());
|
||||||
|
|
||||||
|
for (Method m:vef.getClass().getMethods()) {
|
||||||
|
if (m.getName().startsWith("get")==false) { //a bit dirty
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m.getParameterTypes().length>0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
System.out.println("prop: "+m.getName()+" -> "+m.invoke(vef, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue