[svn r289] implemented annotation validators, and removed all info logging
This commit is contained in:
parent
78a76fa12e
commit
fdd0af9597
40
src/com/idcanet/vasc/core/VascExceptionListener.java
Normal file
40
src/com/idcanet/vasc/core/VascExceptionListener.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Aug 12, 2007
|
||||||
|
*/
|
||||||
|
public interface VascExceptionListener extends EventListener {
|
||||||
|
|
||||||
|
public void handleException(Exception e,VascTable table);
|
||||||
|
}
|
|
@ -35,7 +35,6 @@ import com.idcanet.vasc.core.actions.ColumnVascAction;
|
||||||
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.column.VascTableColumn;
|
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -62,7 +61,8 @@ public class VascTable {
|
||||||
private List<VascUserOption> userOptions = null;
|
private List<VascUserOption> userOptions = null;
|
||||||
private String helpId = null;
|
private String helpId = null;
|
||||||
private VascTableController vascTableController = null;
|
private VascTableController vascTableController = null;
|
||||||
private Map<Class,Class> uiComponents = null;
|
private Map<Class<?>,Class<?>> uiComponents = null;
|
||||||
|
private VascTableColumn UIIdentifierVascTableColomn = null;
|
||||||
|
|
||||||
public VascTable() {
|
public VascTable() {
|
||||||
tableColumns = new ArrayList<VascTableColumn>(6);
|
tableColumns = new ArrayList<VascTableColumn>(6);
|
||||||
|
@ -71,7 +71,7 @@ public class VascTable {
|
||||||
globalActions = new ArrayList<GlobalVascAction>(6);
|
globalActions = new ArrayList<GlobalVascAction>(6);
|
||||||
tableData = new ArrayList<Object>(6);
|
tableData = new ArrayList<Object>(6);
|
||||||
userOptions = new ArrayList<VascUserOption>(6);
|
userOptions = new ArrayList<VascUserOption>(6);
|
||||||
uiComponents = new HashMap<Class,Class>(6);
|
uiComponents = new HashMap<Class<?>,Class<?>>(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,10 +321,24 @@ public class VascTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Class getUIComponent(Class classType) {
|
public Class<?> getUIComponent(Class<?> classType) {
|
||||||
return uiComponents.get(classType);
|
return uiComponents.get(classType);
|
||||||
}
|
}
|
||||||
public void putUIComponent(Class classType,Class comp) {
|
public void putUIComponent(Class<?> classType,Class<?> comp) {
|
||||||
uiComponents.put(classType, comp);
|
uiComponents.put(classType, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the uiIdentifierVascTableColomn
|
||||||
|
*/
|
||||||
|
public VascTableColumn getUIIdentifierVascTableColomn() {
|
||||||
|
return UIIdentifierVascTableColomn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uiIdentifierVascTableColomn the uiIdentifierVascTableColomn to set
|
||||||
|
*/
|
||||||
|
public void setUIIdentifierVascTableColomn(VascTableColumn UIIdentifierVascTableColomn) {
|
||||||
|
this.UIIdentifierVascTableColomn = UIIdentifierVascTableColomn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,4 +55,9 @@ public interface VascTableController {
|
||||||
|
|
||||||
public void fireVascEvent(VascEventListener.VascEventType type,Object data);
|
public void fireVascEvent(VascEventListener.VascEventType type,Object data);
|
||||||
|
|
||||||
|
public boolean setUIComponentsBeanErrors(VascTable table,Object bean);
|
||||||
|
|
||||||
|
public void addExceptionListener(VascExceptionListener listener);
|
||||||
|
|
||||||
|
public void removeExceptionListener(VascExceptionListener listener);
|
||||||
}
|
}
|
|
@ -46,13 +46,8 @@ public class VascColumnValueModelListener implements VascValueModelListener {
|
||||||
setBean(bean);
|
setBean(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void valueUpdate(VascValueModel model) {
|
public void valueUpdate(VascValueModel model) throws Exception {
|
||||||
try {
|
vascTableColumn.getVascColumnValue().setValue(vascTableColumn, bean, model.getValue());
|
||||||
System.out.println("model bean updating: "+bean);
|
|
||||||
vascTableColumn.getVascColumnValue().setValue(vascTableColumn, bean, model.getValue());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,4 +40,6 @@ public interface VascUIComponent {
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception;
|
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception;
|
||||||
|
|
||||||
|
public void setErrorText(String text);
|
||||||
|
public String getErrorText();
|
||||||
}
|
}
|
|
@ -34,10 +34,33 @@ import com.idcanet.vasc.core.VascTable;
|
||||||
* @version 1.0 Aug 12, 2007
|
* @version 1.0 Aug 12, 2007
|
||||||
*/
|
*/
|
||||||
abstract public class VascUIComponentImplLoader extends AbstractVascUIComponent {
|
abstract public class VascUIComponentImplLoader extends AbstractVascUIComponent {
|
||||||
|
|
||||||
|
private VascUIComponent realComponent = null;
|
||||||
|
|
||||||
public Object loadAndCreateComponent(VascUIComponent wrapper,VascTable table,VascValueModel model,Object gui) throws Exception {
|
public Object loadAndCreateComponent(VascUIComponent wrapper,VascTable table,VascValueModel model,Object gui) throws Exception {
|
||||||
VascUIComponent comp = (VascUIComponent)table.getUIComponent(wrapper.getClass()).newInstance();
|
realComponent = (VascUIComponent)table.getUIComponent(wrapper.getClass()).newInstance();
|
||||||
comp.setWrapper(wrapper);
|
realComponent.setWrapper(wrapper);
|
||||||
return comp.createComponent(table, model, gui);
|
return realComponent.createComponent(table, model, gui);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||||
|
*/
|
||||||
|
public String getErrorText() {
|
||||||
|
if (realComponent==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return realComponent.getErrorText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setErrorText(String text) {
|
||||||
|
if (realComponent==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
realComponent.setErrorText(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,6 +29,8 @@ package com.idcanet.vasc.core.ui;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascTable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -39,9 +41,11 @@ public class VascValueModel {
|
||||||
|
|
||||||
private Object value = null;
|
private Object value = null;
|
||||||
private List<VascValueModelListener> listeners = null;
|
private List<VascValueModelListener> listeners = null;
|
||||||
|
private VascTable table = null;
|
||||||
|
|
||||||
public VascValueModel() {
|
public VascValueModel(VascTable table) {
|
||||||
listeners = new ArrayList<VascValueModelListener>(2);
|
listeners = new ArrayList<VascValueModelListener>(2);
|
||||||
|
this.table=table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
|
@ -50,7 +54,11 @@ public class VascValueModel {
|
||||||
|
|
||||||
public void setValue(Object value) {
|
public void setValue(Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
fireListeners();
|
try {
|
||||||
|
fireListeners();
|
||||||
|
} catch (Exception e) {
|
||||||
|
table.getVascTableController().handleException(e, table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(VascValueModelListener l) {
|
public void addListener(VascValueModelListener l) {
|
||||||
|
@ -59,7 +67,7 @@ public class VascValueModel {
|
||||||
public void removeListener(VascValueModelListener l) {
|
public void removeListener(VascValueModelListener l) {
|
||||||
listeners.remove(l);
|
listeners.remove(l);
|
||||||
}
|
}
|
||||||
private void fireListeners() {
|
private void fireListeners() throws Exception {
|
||||||
for (VascValueModelListener l:listeners) {
|
for (VascValueModelListener l:listeners) {
|
||||||
l.valueUpdate(this);
|
l.valueUpdate(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,15 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.core.ui;
|
package com.idcanet.vasc.core.ui;
|
||||||
|
|
||||||
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 12, 2007
|
* @version 1.0 Aug 12, 2007
|
||||||
*/
|
*/
|
||||||
public interface VascValueModelListener {
|
public interface VascValueModelListener extends EventListener {
|
||||||
|
|
||||||
|
public void valueUpdate(VascValueModel model) throws Exception;
|
||||||
public void valueUpdate(VascValueModel model);
|
|
||||||
}
|
}
|
|
@ -32,8 +32,12 @@ 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.annotations.VascAnnotationParser;
|
||||||
import com.idcanet.vasc.core.VascEventListener;
|
import com.idcanet.vasc.core.VascEventListener;
|
||||||
|
import com.idcanet.vasc.core.VascExceptionListener;
|
||||||
import com.idcanet.vasc.core.VascTable;
|
import com.idcanet.vasc.core.VascTable;
|
||||||
import com.idcanet.vasc.core.VascTableController;
|
import com.idcanet.vasc.core.VascTableController;
|
||||||
import com.idcanet.vasc.core.column.VascAnnotationTableColumn;
|
import com.idcanet.vasc.core.column.VascAnnotationTableColumn;
|
||||||
|
@ -51,9 +55,13 @@ import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue;
|
||||||
public class DefaultVascTableController implements VascTableController {
|
public class DefaultVascTableController implements VascTableController {
|
||||||
|
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
|
private List<VascEventListener> eventListeners = null;
|
||||||
|
private List<VascExceptionListener> exceptionListeners = null;
|
||||||
|
|
||||||
public DefaultVascTableController() {
|
public DefaultVascTableController() {
|
||||||
logger = Logger.getLogger(DefaultVascTableController.class.getName());
|
logger = Logger.getLogger(DefaultVascTableController.class.getName());
|
||||||
|
eventListeners = new ArrayList<VascEventListener>(2);
|
||||||
|
exceptionListeners = new ArrayList<VascExceptionListener>(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,12 +172,19 @@ public class DefaultVascTableController implements VascTableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleException(Exception e,VascTable table) {
|
public void handleException(Exception e,VascTable table) {
|
||||||
Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,e.getMessage(),e);
|
if (exceptionListeners.isEmpty()) {
|
||||||
|
Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,e.getMessage(),e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(VascExceptionListener ee:exceptionListeners) {
|
||||||
|
try {
|
||||||
|
ee.handleException(e, table);
|
||||||
|
} catch (Exception eee) {
|
||||||
|
Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,"Error in ExceptionListener: "+eee.getMessage(),eee);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<VascEventListener> eventListeners = new ArrayList<VascEventListener>(2);
|
|
||||||
|
|
||||||
public void addEventListener(VascEventListener e) {
|
public void addEventListener(VascEventListener e) {
|
||||||
eventListeners.add(e);
|
eventListeners.add(e);
|
||||||
}
|
}
|
||||||
|
@ -182,4 +197,52 @@ public class DefaultVascTableController implements VascTableController {
|
||||||
e.vascEvent(type, data);
|
e.vascEvent(type, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public boolean setUIComponentsBeanErrors(VascTable table,Object bean) {
|
||||||
|
boolean error = false;
|
||||||
|
if(bean==null) {
|
||||||
|
logger.finest("No bean to check.");
|
||||||
|
return true; // nothing to check
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassValidator val = new ClassValidator(bean.getClass());
|
||||||
|
InvalidValue[] ival = val.getInvalidValues(bean);
|
||||||
|
logger.fine("Got invaliled value: "+ival.length);
|
||||||
|
|
||||||
|
for(VascTableColumn col:table.getTableColumns()) {
|
||||||
|
if(col.getVascUIComponent()==null) {
|
||||||
|
continue; // we only DISPLAY user input errors !!
|
||||||
|
}
|
||||||
|
if (col instanceof VascAnnotationTableColumn) {
|
||||||
|
VascAnnotationTableColumn column = (VascAnnotationTableColumn)col;
|
||||||
|
|
||||||
|
InvalidValue iv = findInvalidValueByProperty(ival,column.getBeanProperty());
|
||||||
|
if(iv==null) {
|
||||||
|
column.getVascUIComponent().setErrorText(null);
|
||||||
|
continue; // no error on this property
|
||||||
|
}
|
||||||
|
error = true;
|
||||||
|
column.getVascUIComponent().setErrorText(iv.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.finest("Checked for errors: "+error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
private InvalidValue findInvalidValueByProperty(InvalidValue[] ival,String property) {
|
||||||
|
for(InvalidValue iv:ival) {
|
||||||
|
if(iv.getPropertyName().equals(property)) {
|
||||||
|
return iv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addExceptionListener(VascExceptionListener listener) {
|
||||||
|
exceptionListeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeExceptionListener(VascExceptionListener listener) {
|
||||||
|
exceptionListeners.remove(listener);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -67,7 +67,7 @@ public class Serv5HibernateVascDataSource extends AbstractVascDataSource {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
List data = q.list();
|
List data = q.list();
|
||||||
//logger.info("Query returned: "+data.size()+" of: "+crudTable.getQueryName());
|
//logger.fine("Query returned: "+data.size()+" of: "+crudTable.getQueryName());
|
||||||
return data;
|
return data;
|
||||||
} finally {
|
} finally {
|
||||||
Hibernate3Factory.getSession("flowstats").close(); // close session in threads
|
Hibernate3Factory.getSession("flowstats").close(); // close session in threads
|
||||||
|
|
|
@ -39,7 +39,6 @@ import java.io.FileOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
|
@ -126,7 +125,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
public ImageIcon getImageIcon(String imageResource) {
|
public ImageIcon getImageIcon(String imageResource) {
|
||||||
/// TODO hack beter
|
/// TODO hack beter
|
||||||
String key = table.getVascTextValue().getTextValue(imageResource);
|
String key = table.getVascTextValue().getTextValue(imageResource);
|
||||||
//logger.info("KEY======================="+key);
|
//logger.fine("KEY======================="+key);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -141,10 +140,21 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
* @see com.idcanet.vasc.core.VascViewRenderer#renderEdit(com.idcanet.vasc.core.VascTable, java.lang.Object)
|
* @see com.idcanet.vasc.core.VascViewRenderer#renderEdit(com.idcanet.vasc.core.VascTable, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void renderEdit(Object rowBean) throws Exception {
|
public void renderEdit(Object rowBean) throws Exception {
|
||||||
logger.info("Rending Edit View");
|
logger.fine("Rending Edit View");
|
||||||
table.getVascTableController().initEditObject(table, rowBean);
|
table.getVascTableController().initEditObject(table, rowBean);
|
||||||
|
String beanValue = rowBean.toString();
|
||||||
SwingEditDialog dialog = new SwingEditDialog(parent,table,rowBean,"Vasc Edit","Edit");
|
if (table.getUIIdentifierVascTableColomn()!=null) {
|
||||||
|
Object vv = table.getUIIdentifierVascTableColomn().getVascColumnValue().getValue(table.getUIIdentifierVascTableColomn(), rowBean);
|
||||||
|
if (vv==null) {
|
||||||
|
beanValue="";
|
||||||
|
} else {
|
||||||
|
beanValue=""+vv;
|
||||||
|
}
|
||||||
|
if (beanValue.length()>30) {
|
||||||
|
beanValue=beanValue.substring(0, 30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SwingEditDialog dialog = new SwingEditDialog(parent,table,rowBean,table.getVascTextValue().getTextValue("vasc.dialog.edit.title"),table.getVascTextValue().getTextValue("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) {
|
||||||
|
@ -163,10 +173,17 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderDelete(Object rowBean) throws Exception {
|
public void renderDelete(Object rowBean) throws Exception {
|
||||||
|
String beanValue = rowBean.toString();
|
||||||
|
if (table.getUIIdentifierVascTableColomn()!=null) {
|
||||||
|
beanValue = ""+table.getUIIdentifierVascTableColomn().getVascColumnValue().getValue(table.getUIIdentifierVascTableColomn(), rowBean);
|
||||||
|
if (beanValue.length()>30) {
|
||||||
|
beanValue=beanValue.substring(0, 30);
|
||||||
|
}
|
||||||
|
}
|
||||||
int response = JOptionPane.showOptionDialog(
|
int response = JOptionPane.showOptionDialog(
|
||||||
parent // Center in window.
|
parent // Center in window.
|
||||||
, "Delete "+rowBean // Message
|
, table.getVascTextValue().getTextValue("vasc.dialog.delete.message",beanValue) // Message
|
||||||
, "Delete" // Title in titlebar
|
, table.getVascTextValue().getTextValue("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)
|
||||||
|
@ -184,18 +201,16 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
|
|
||||||
class SwingEditDialog extends JDialog {
|
class SwingEditDialog extends JDialog {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 10L;
|
||||||
private String headerText = null;
|
private String headerText = null;
|
||||||
private String title = null;
|
|
||||||
private Object result = null;
|
private Object result = null;
|
||||||
private Object bean = null;
|
private Object bean = null;
|
||||||
|
|
||||||
public SwingEditDialog(JComponent parent,VascTable table,Object bean,String title,String headerText) throws Exception {
|
public SwingEditDialog(JComponent parent,VascTable table,Object bean,String title,String headerText) throws Exception {
|
||||||
super();
|
super();
|
||||||
this.headerText = headerText;
|
this.headerText = headerText;
|
||||||
this.title = title;
|
|
||||||
this.bean = bean;
|
this.bean = bean;
|
||||||
|
|
||||||
|
|
||||||
setTitle(table.getVascTextValue().getTextValue(title));
|
setTitle(table.getVascTextValue().getTextValue(title));
|
||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
||||||
|
@ -276,7 +291,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
body.add(valueLabel);
|
body.add(valueLabel);
|
||||||
} else {
|
} else {
|
||||||
VascUIComponent comp = c.getVascUIComponent();
|
VascUIComponent comp = c.getVascUIComponent();
|
||||||
VascValueModel model = new VascValueModel();
|
VascValueModel model = new VascValueModel(table);
|
||||||
model.setValue(c.getVascColumnValue().getValue(c, bean));
|
model.setValue(c.getVascColumnValue().getValue(c, bean));
|
||||||
model.addListener(new VascColumnValueModelListener(c,bean));
|
model.addListener(new VascColumnValueModelListener(c,bean));
|
||||||
comp.createComponent(table, model, body);
|
comp.createComponent(table, model, body);
|
||||||
|
@ -295,9 +310,9 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
saveButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.save.tooltip"));
|
saveButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.save.tooltip"));
|
||||||
saveButton.addActionListener(new ActionListener() {
|
saveButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
//if(hasRecordError()) {
|
if(table.getVascTableController().setUIComponentsBeanErrors(table, bean)) {
|
||||||
// return;
|
return;
|
||||||
//}
|
}
|
||||||
result = bean;
|
result = bean;
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -347,8 +362,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
try {
|
try {
|
||||||
exporter.doExport(out, table);
|
exporter.doExport(out, table);
|
||||||
} 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"));
|
table.getVascTableController().handleException(e, table);
|
||||||
logger.log(Level.WARNING,"Error: "+e.getMessage(),e);
|
|
||||||
} finally {
|
} finally {
|
||||||
if (out!=null) {
|
if (out!=null) {
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -427,7 +441,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
JPanel optionPanel = new JPanel();
|
JPanel optionPanel = new JPanel();
|
||||||
//top.setBackground(Color.GREEN);
|
//top.setBackground(Color.GREEN);
|
||||||
for(VascUserOption option:table.getUserOptions()) {
|
for(VascUserOption option:table.getUserOptions()) {
|
||||||
Object obj = option.createUserOptionRenderer(table);
|
option.createUserOptionRenderer(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
//top.add(header,BorderLayout.NORTH);
|
//top.add(header,BorderLayout.NORTH);
|
||||||
|
@ -489,6 +503,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class JComponentTableCellRenderer extends DefaultTableCellRenderer {
|
class JComponentTableCellRenderer extends DefaultTableCellRenderer {
|
||||||
|
private static final long serialVersionUID = 10L;
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
|
||||||
VascTableColumn c = (VascTableColumn)value;
|
VascTableColumn c = (VascTableColumn)value;
|
||||||
setText(c.getVascTable().getVascTextValue().getTextValue(c.getName()));
|
setText(c.getVascTable().getVascTextValue().getTextValue(c.getName()));
|
||||||
|
@ -508,7 +523,6 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
setFont(header.getFont());
|
setFont(header.getFont());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
|
||||||
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -540,7 +554,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
logger.info("Row Action");
|
logger.fine("Row Action");
|
||||||
try {
|
try {
|
||||||
action.doRowAction(table, table.getSelectedObject());
|
action.doRowAction(table, table.getSelectedObject());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -558,7 +572,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
logger.info("Global Action");
|
logger.fine("Global Action");
|
||||||
try {
|
try {
|
||||||
action.doGlobalAction(table);
|
action.doGlobalAction(table);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -568,6 +582,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
class VascColumnModel extends AbstractTableModel implements VascEventListener {
|
class VascColumnModel extends AbstractTableModel implements VascEventListener {
|
||||||
|
private static final long serialVersionUID = 10L;
|
||||||
|
|
||||||
public void vascEvent(VascEventType e,Object o) {
|
public void vascEvent(VascEventType e,Object o) {
|
||||||
if (e==VascEventType.DATA_UPDATE) {
|
if (e==VascEventType.DATA_UPDATE) {
|
||||||
|
@ -623,7 +638,6 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
return "Error";
|
return "Error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,15 +651,6 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SpringUtilities {
|
class SpringUtilities {
|
||||||
/**
|
|
||||||
* A debugging utility that prints to stdout the component's minimum,
|
|
||||||
* preferred, and maximum sizes.
|
|
||||||
*/
|
|
||||||
public static void printSizes(Component c) {
|
|
||||||
System.out.println("minimumSize = " + c.getMinimumSize());
|
|
||||||
System.out.println("preferredSize = " + c.getPreferredSize());
|
|
||||||
System.out.println("maximumSize = " + c.getMaximumSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aligns the first <code>rows</code>*<code>cols</code> components of
|
* Aligns the first <code>rows</code>*<code>cols</code> components of
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.impl.swing.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -46,12 +47,41 @@ import com.michaelbaranov.microba.calendar.DatePicker;
|
||||||
*/
|
*/
|
||||||
public class SwingDate extends AbstractVascUIComponent {
|
public class SwingDate extends AbstractVascUIComponent {
|
||||||
|
|
||||||
|
private DatePicker datePicker = null;
|
||||||
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
||||||
DatePicker def = new DatePicker();
|
datePicker = new DatePicker();
|
||||||
def.setDate((Date)model.getValue());
|
orgBackgroundColor = datePicker.getBackground();
|
||||||
((JComponent)gui).add(def);
|
datePicker.setDate((Date)model.getValue());
|
||||||
def.addActionListener(new SelectActionListener2(model));
|
((JComponent)gui).add(datePicker);
|
||||||
return def;
|
datePicker.addActionListener(new SelectActionListener2(model));
|
||||||
|
return datePicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||||
|
*/
|
||||||
|
public String getErrorText() {
|
||||||
|
if (datePicker==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return datePicker.getToolTipText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setErrorText(String text) {
|
||||||
|
if (datePicker==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
datePicker.setToolTipText(text);
|
||||||
|
if (text==null) {
|
||||||
|
datePicker.setBackground(orgBackgroundColor);
|
||||||
|
} else {
|
||||||
|
datePicker.setBackground(Color.RED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class SelectActionListener2 implements ActionListener {
|
class SelectActionListener2 implements ActionListener {
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.impl.swing.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
@ -50,44 +51,75 @@ import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
*/
|
*/
|
||||||
public class SwingList extends AbstractVascUIComponent {
|
public class SwingList extends AbstractVascUIComponent {
|
||||||
|
|
||||||
public Object createComponent(VascTable table,final VascValueModel model,Object gui) throws Exception {
|
private JComboBox comboBox = null;
|
||||||
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
|
public Object createComponent(VascTable table,final VascValueModel model,Object gui) throws Exception {
|
||||||
VascList l = (VascList)getWrapper();
|
VascList l = (VascList)getWrapper();
|
||||||
JComboBox def;
|
|
||||||
if (l.getVascSelectItemModel()==null) {
|
if (l.getVascSelectItemModel()==null) {
|
||||||
def = new JComboBox();
|
comboBox = new JComboBox();
|
||||||
} else {
|
} else {
|
||||||
def = new JComboBox(l.getVascSelectItemModel().getVascSelectItems().toArray());
|
comboBox = new JComboBox(l.getVascSelectItemModel().getVascSelectItems().toArray());
|
||||||
}
|
}
|
||||||
((JComponent)gui).add(def);
|
orgBackgroundColor = comboBox.getBackground();
|
||||||
def.setRenderer(new MyCellRenderer());
|
((JComponent)gui).add(comboBox);
|
||||||
def.addActionListener(new ActionListener() {
|
comboBox.setRenderer(new MyCellRenderer());
|
||||||
|
comboBox.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
VascSelectItem i = (VascSelectItem)((JComboBox)e.getSource()).getSelectedItem();
|
VascSelectItem i = (VascSelectItem)((JComboBox)e.getSource()).getSelectedItem();
|
||||||
model.setValue(i.getValue());
|
model.setValue(i.getValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (model.getValue()==null) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set default !!
|
// set default !!
|
||||||
for (int i=0;i<def.getModel().getSize();i++) {
|
if (model.getValue()!=null) {
|
||||||
Object o = def.getModel().getElementAt(i);
|
for (int i=0;i<comboBox.getModel().getSize();i++) {
|
||||||
VascSelectItem i2 = (VascSelectItem)o;
|
Object o = comboBox.getModel().getElementAt(i);
|
||||||
if ( model.getValue().equals(i2.getValue()) ) {
|
VascSelectItem i2 = (VascSelectItem)o;
|
||||||
def.setSelectedItem(i2);
|
if ( model.getValue().equals(i2.getValue()) ) {
|
||||||
return def;
|
comboBox.setSelectedItem(i2);
|
||||||
|
return comboBox;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (comboBox.getModel().getSize()>0) {
|
||||||
return def;
|
// else select the top one.
|
||||||
|
comboBox.setSelectedIndex(0);
|
||||||
|
}
|
||||||
|
return comboBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||||
|
*/
|
||||||
|
public String getErrorText() {
|
||||||
|
if (comboBox==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return comboBox.getToolTipText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setErrorText(String text) {
|
||||||
|
if (comboBox==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
comboBox.setToolTipText(text);
|
||||||
|
if (text==null) {
|
||||||
|
comboBox.setBackground(orgBackgroundColor);
|
||||||
|
} else {
|
||||||
|
comboBox.setBackground(Color.RED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyCellRenderer extends JLabel implements ListCellRenderer {
|
class MyCellRenderer extends JLabel implements ListCellRenderer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 10L;
|
||||||
|
|
||||||
public MyCellRenderer() {
|
public MyCellRenderer() {
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.impl.swing.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
|
@ -33,7 +35,6 @@ import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
import com.idcanet.vasc.core.VascTable;
|
import com.idcanet.vasc.core.VascTable;
|
||||||
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
import com.idcanet.vasc.core.ui.AbstractVascUIComponent;
|
||||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
|
||||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,22 +45,52 @@ import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
*/
|
*/
|
||||||
public class SwingTextField extends AbstractVascUIComponent {
|
public class SwingTextField extends AbstractVascUIComponent {
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
private JTextField textField = null;
|
||||||
JTextField def = new JTextField();
|
private Color orgBackgroundColor = null;
|
||||||
def.setText(""+model.getValue());
|
|
||||||
((JComponent)gui).add(def);
|
|
||||||
def.getDocument().addDocumentListener(new TextListener(model) );
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
||||||
|
textField = new JTextField();
|
||||||
|
orgBackgroundColor = textField.getBackground();
|
||||||
|
textField.setText(""+model.getValue());
|
||||||
|
((JComponent)gui).add(textField);
|
||||||
|
textField.getDocument().addDocumentListener(new TextListener(model,table));
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||||
|
*/
|
||||||
|
public String getErrorText() {
|
||||||
|
if (textField==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return textField.getToolTipText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setErrorText(String text) {
|
||||||
|
if (textField==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
textField.setToolTipText(text);
|
||||||
|
if (text==null) {
|
||||||
|
textField.setBackground(orgBackgroundColor);
|
||||||
|
} else {
|
||||||
|
textField.setBackground(Color.RED);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextListener implements DocumentListener {
|
class TextListener implements DocumentListener {
|
||||||
|
|
||||||
private VascValueModel model = null;
|
private VascValueModel model = null;
|
||||||
|
private VascTable table = null;
|
||||||
|
|
||||||
public TextListener(VascValueModel model) {
|
public TextListener(VascValueModel model,VascTable table) {
|
||||||
this.model=model;
|
this.model=model;
|
||||||
|
this.table=table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,10 +117,9 @@ class TextListener implements DocumentListener {
|
||||||
public void update(DocumentEvent event) {
|
public void update(DocumentEvent event) {
|
||||||
try {
|
try {
|
||||||
String value = event.getDocument().getText(0, event.getDocument().getLength());
|
String value = event.getDocument().getText(0, event.getDocument().getLength());
|
||||||
System.out.println("Setting value: "+value);
|
|
||||||
model.setValue(value);
|
model.setValue(value);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
ee.printStackTrace();
|
table.getVascTableController().handleException(ee, table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swing.ui;
|
package com.idcanet.vasc.impl.swing.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
@ -45,12 +46,41 @@ import com.idcanet.vasc.core.ui.VascValueModel;
|
||||||
*/
|
*/
|
||||||
public class SwingToggle extends AbstractVascUIComponent {
|
public class SwingToggle extends AbstractVascUIComponent {
|
||||||
|
|
||||||
|
private JCheckBox checkBox = null;
|
||||||
|
private Color orgBackgroundColor = null;
|
||||||
|
|
||||||
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
|
||||||
JCheckBox def = new JCheckBox();
|
checkBox = new JCheckBox();
|
||||||
def.setSelected((Boolean)model.getValue());
|
orgBackgroundColor = checkBox.getBackground();
|
||||||
((JComponent)gui).add(def);
|
checkBox.setSelected((Boolean)model.getValue());
|
||||||
def.addActionListener(new SelectActionListener(model));
|
((JComponent)gui).add(checkBox);
|
||||||
return def;
|
checkBox.addActionListener(new SelectActionListener(model));
|
||||||
|
return checkBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||||
|
*/
|
||||||
|
public String getErrorText() {
|
||||||
|
if (checkBox==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return checkBox.getToolTipText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setErrorText(String text) {
|
||||||
|
if (checkBox==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
checkBox.setToolTipText(text);
|
||||||
|
if (text==null) {
|
||||||
|
checkBox.setBackground(orgBackgroundColor);
|
||||||
|
} else {
|
||||||
|
checkBox.setBackground(Color.RED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class SelectActionListener implements ActionListener {
|
class SelectActionListener implements ActionListener {
|
||||||
|
|
|
@ -26,13 +26,11 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.impl.swt;
|
package com.idcanet.vasc.impl.swt;
|
||||||
|
|
||||||
import java.awt.TextField;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
|
@ -137,7 +135,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
||||||
|
|
||||||
public void renderEdit(Object object) throws Exception {
|
public void renderEdit(Object object) throws Exception {
|
||||||
|
|
||||||
logger.info("Rending Edit View");
|
logger.fine("Rending Edit View");
|
||||||
table.getVascTableController().initEditObject(table, object);
|
table.getVascTableController().initEditObject(table, object);
|
||||||
|
|
||||||
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Vasc Edit","Edit");
|
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Vasc Edit","Edit");
|
||||||
|
@ -159,21 +157,16 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
||||||
path = table.getVascTextValue().getTextValue(path);
|
path = table.getVascTextValue().getTextValue(path);
|
||||||
|
|
||||||
|
|
||||||
logger.info("Loading image: "+path);
|
logger.fine("Loading image: "+path);
|
||||||
//System.out.println("==== 1");
|
|
||||||
ImageDescriptor result = ImageDescriptor.createFromFile(path.getClass(), path);
|
ImageDescriptor result = ImageDescriptor.createFromFile(path.getClass(), path);
|
||||||
result = ImageDescriptor.createFromFile(SwingImageHelper.class, path);
|
result = ImageDescriptor.createFromFile(SwingImageHelper.class, path);
|
||||||
if(result==null) {
|
if(result==null) {
|
||||||
// try load fff
|
// try load fff
|
||||||
//.out.println("==== 2");
|
|
||||||
|
|
||||||
//result = ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource(path));
|
//result = ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource(path));
|
||||||
}
|
}
|
||||||
//System.out.println("==== 3");
|
|
||||||
if(result==null) {
|
if(result==null) {
|
||||||
throw new NullPointerException("Can't load resource: "+path);
|
throw new NullPointerException("Can't load resource: "+path);
|
||||||
}
|
}
|
||||||
//System.out.println("==== 4 "+result.getImageData().height+" w:"+result.getImageData().width);
|
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warning("Could not load image from path: '"+path+"'");
|
logger.warning("Could not load image from path: '"+path+"'");
|
||||||
|
@ -482,7 +475,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
logger.info("Global Action");
|
logger.fine("Global Action");
|
||||||
try {
|
try {
|
||||||
action.doGlobalAction(table);
|
action.doGlobalAction(table);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -521,7 +514,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
||||||
*/
|
*/
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
Object data = e.item.getData();
|
Object data = e.item.getData();
|
||||||
logger.info("Slecting data: "+data);
|
logger.fine("Slecting data: "+data);
|
||||||
table.setSelectedObject(data);
|
table.setSelectedObject(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,7 +618,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
logger.info("Row Action");
|
logger.fine("Row Action");
|
||||||
try {
|
try {
|
||||||
action.doRowAction(table, table.getSelectedObject());
|
action.doRowAction(table, table.getSelectedObject());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in a new issue