2
0
Fork 0

[svn r250] fixed annotations , added fff , added more images properties

This commit is contained in:
willemc 2007-04-29 20:16:20 +02:00
parent d88cb26330
commit 1c47fbffa3
12 changed files with 106 additions and 81 deletions

View file

@ -13,5 +13,6 @@
<classpathentry kind="con" path="SWT_CONTAINER/JFACE/PLATFORM"/> <classpathentry kind="con" path="SWT_CONTAINER/JFACE/PLATFORM"/>
<classpathentry kind="lib" path="lib/idcanet-jmx-bin.jar"/> <classpathentry kind="lib" path="lib/idcanet-jmx-bin.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/idcanet-fff-bin.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

BIN
lib/idcanet-fff-bin.jar Normal file

Binary file not shown.

View file

@ -175,31 +175,32 @@ public class VascAnnotationParser {
return beanClass.getName()+"."+property+"."+annotationType.getSimpleName(); return beanClass.getName()+"."+property+"."+annotationType.getSimpleName();
} }
private Object doAnnotation(Annotation a) { private Object doAnnotation(Annotation b) {
Class a = b.annotationType();
if (a.equals(VascName.class)) { if (a.equals(VascName.class)) {
VascName l = (VascName)a; VascName l = (VascName)b;
if("".equals(l.key()) | "null".equals(l.key())) { if("".equals(l.key()) | "null".equals(l.key())) {
return null; return null;
} }
return l.key(); return l.key();
} }
if (a.equals(VascToolTip.class)) { if (a.equals(VascToolTip.class)) {
VascToolTip t = (VascToolTip)a; VascToolTip t = (VascToolTip)b;
if("".equals(t.key()) | "null".equals(t.key())) { if("".equals(t.key()) | "null".equals(t.key())) {
return null; return null;
} }
return t.key(); return t.key();
} }
if (a.equals(VascHelpId.class)) { if (a.equals(VascHelpId.class)) {
VascHelpId h = (VascHelpId)a; VascHelpId h = (VascHelpId)b;
if("".equals(h.helpId()) | "null".equals(h.helpId())) { if("".equals(h.helpId()) | "null".equals(h.helpId())) {
return null; return null;
} }
return h.helpId(); return h.helpId();
} }
if (a.equals(VascDefaultValue.class)) { if (a.equals(VascDefaultValue.class)) {
VascDefaultValue v = (VascDefaultValue)a; VascDefaultValue v = (VascDefaultValue)b;
if (v.defaultValue()==null) { if (v.defaultValue()==null) {
return null; // error ?? return null; // error ??
} }
@ -210,7 +211,7 @@ public class VascAnnotationParser {
} }
} }
if (a.equals(VascColumnWidth.class)) { if (a.equals(VascColumnWidth.class)) {
VascColumnWidth c = (VascColumnWidth)a; VascColumnWidth c = (VascColumnWidth)b;
return c.width(); return c.width();
} }
return null; return null;

View file

@ -26,10 +26,10 @@
package com.idcanet.vasc.core.column; package com.idcanet.vasc.core.column;
import com.idcanet.vasc.core.VascTable;
/** /**
* Defines an VascTableColumn
*
*
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Mar 21, 2007 * @version 1.0 Mar 21, 2007
@ -41,6 +41,7 @@ public class VascTableColumn {
private Object defaultValue = null; private Object defaultValue = null;
private Integer width = null; private Integer width = null;
private String helpId = null; private String helpId = null;
private String image = null;
private VascColumnValue vascColumnValue = null; private VascColumnValue vascColumnValue = null;
private VascColumnRenderer vascColumnRenderer = null; private VascColumnRenderer vascColumnRenderer = null;
@ -168,10 +169,25 @@ public class VascTableColumn {
public String getHelpId() { public String getHelpId() {
return helpId; return helpId;
} }
/** /**
* @param helpId the helpId to set * @param helpId the helpId to set
*/ */
public void setHelpId(String helpId) { public void setHelpId(String helpId) {
this.helpId = helpId; this.helpId = helpId;
} }
/**
* @return the image
*/
public String getImage() {
return image;
}
/**
* @param image the image to set
*/
public void setImage(String image) {
this.image = image;
}
} }

View file

@ -75,6 +75,9 @@ public class DefaultVascTableController implements VascTableController {
if (c.getVascColumnValue()==null) { if (c.getVascColumnValue()==null) {
c.setVascColumnValue(new BeanPropertyVascColumnValue(column.getBeanProperty())); c.setVascColumnValue(new BeanPropertyVascColumnValue(column.getBeanProperty()));
} }
if (c.getVascColumnEditor()==null) {
//c.setVascColumnEditor(new AutoVascColumnEditor(column.getBeanProperty()));
}
} }
} }
} }
@ -93,9 +96,9 @@ public class DefaultVascTableController implements VascTableController {
for(VascTableColumn c:table.getTableColumns()) { for(VascTableColumn c:table.getTableColumns()) {
if(c.getWidth()==null) { if(c.getWidth()==null) {
Logger.getLogger(VascTable.class.getName()).finer("Column no size: "+c.getName()); Logger.getLogger(VascTable.class.getName()).finer("Column no size: "+c.getName());
return null; } else {
result+=c.getWidth();
} }
result=+c.getWidth();
} }
return result; return result;
} }

View file

@ -40,6 +40,7 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction {
public AddRowAction() { public AddRowAction() {
setName("generic.crud.add"); setName("generic.crud.add");
setToolTip("generic.toolTip"); setToolTip("generic.toolTip");
setImage("/META-INF/images/silk/png/table_add.png");
} }
public void doRowAction(VascTable table,Object rowObject) throws Exception { public void doRowAction(VascTable table,Object rowObject) throws Exception {

View file

@ -38,8 +38,9 @@ import com.idcanet.vasc.core.actions.RowVascAction;
public class DeleteRowAction extends AbstractVascAction implements RowVascAction { public class DeleteRowAction extends AbstractVascAction implements RowVascAction {
public DeleteRowAction() { public DeleteRowAction() {
setName("generic.crud.delete"); setName("generic.crud.delete.name");
setToolTip("generic.toolTip"); setToolTip("generic.crud.delete.tooltip");
setImage("/META-INF/images/silk/png/table_delete.png");
} }
public void doRowAction(VascTable table,Object rowObject) throws Exception { public void doRowAction(VascTable table,Object rowObject) throws Exception {

View file

@ -39,7 +39,8 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
public EditRowAction() { public EditRowAction() {
setName("generic.crud.edit"); setName("generic.crud.edit");
setToolTip("generic.toolTip"); setToolTip("generic.crud.edit.toolTip");
setImage("/META-INF/images/silk/png/table_edit.png");
} }

View file

@ -40,7 +40,7 @@ public class RefreshDataGlobalAction extends AbstractVascAction implements Globa
public RefreshDataGlobalAction() { public RefreshDataGlobalAction() {
setName("generic.refresh"); setName("generic.refresh");
setToolTip("generic.crud.refresh.tooltip"); setToolTip("generic.crud.refresh.tooltip");
setImage("icons/fam/table_refresh.png"); setImage("/META-INF/images/silk/png/table_refresh.png");
} }

View file

@ -40,7 +40,7 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
public XMLExportGlobalAction() { public XMLExportGlobalAction() {
setName("generic.crud.export.xml.name"); setName("generic.crud.export.xml.name");
setToolTip("generic.crud.export.xml.tooltip"); setToolTip("generic.crud.export.xml.tooltip");
setImage("icons/fam/page_white_excel.png"); setImage("/META-INF/images/silk/png/page_white_excel.png");
} }

View file

@ -58,6 +58,7 @@ import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.ToolBar; 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.vasc.core.VascTable; import com.idcanet.vasc.core.VascTable;
import com.idcanet.vasc.core.VascUserOption; import com.idcanet.vasc.core.VascUserOption;
import com.idcanet.vasc.core.VascViewRenderer; import com.idcanet.vasc.core.VascViewRenderer;
@ -90,14 +91,11 @@ public class SwtVascViewRenderer implements VascViewRenderer {
object = table.getVascRecordCreator().newRecord(table); object = table.getVascRecordCreator().newRecord(table);
logger.finest("created: "+object); logger.finest("created: "+object);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); table.getVascTableController().handleException(e, table);
//logger.log(Level.WARNING,"Error while creating new: "+crudTable.getRecordClass());
return; return;
} }
} }
//CrudEditDialog editDialog = new CrudEditDialog(event.display.getActiveShell(),crudTable,element,crudTable.i18n("crud.event.add.title"),crudTable.i18n("crud.event.add.title"));
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Edit","TOITO"); SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Edit","TOITO");
Object result = dialog.open(); Object result = dialog.open();
if(result==null) { if(result==null) {
@ -105,10 +103,10 @@ public class SwtVascViewRenderer implements VascViewRenderer {
} }
try { try {
result = table.getVascDataSource().merge(object); result = table.getVascDataSource().merge(object);
//FlowstatsPlugin.getDefault().fireModelUpdateListeners(result); //table.getVascTableController().fireModelUpdateListeners(result);
} finally { } finally {
//crudTable.getCrudTableDataSource().fillCrudDataList(crudTable); //TODO: or merge into table == faster
table.getVascTableController().refreshData(table);
} }
} }
@ -117,9 +115,11 @@ public class SwtVascViewRenderer implements VascViewRenderer {
logger.info("Loading image: "+path); logger.info("Loading image: "+path);
//System.out.println("==== 1"); //System.out.println("==== 1");
ImageDescriptor result = ImageDescriptor.createFromFile(path.getClass(), path); ImageDescriptor result = ImageDescriptor.createFromFile(path.getClass(), path);
result = ImageDescriptor.createFromFile(SwingImageHelper.class, path);
if(result==null) { if(result==null) {
// try load fff // try load fff
//.out.println("==== 2"); //.out.println("==== 2");
//result = ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource(path)); //result = ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource(path));
} }
//System.out.println("==== 3"); //System.out.println("==== 3");
@ -256,7 +256,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
new Label(body, SWT.WRAP); new Label(body, SWT.WRAP);
Button saveButton = new Button(body, SWT.NONE); Button saveButton = new Button(body, SWT.NONE);
saveButton.setImage(getImageDescriptor("icons/fam/tick.png").createImage()); saveButton.setImage(getImageDescriptor("/META-INF/images/silk/png/tick.png").createImage());
saveButton.setText("generic.save"); saveButton.setText("generic.save");
saveButton.addSelectionListener(new SelectionAdapter() { saveButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -268,7 +268,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
} }
}); });
Button cancelButton = new Button(body, SWT.NONE); Button cancelButton = new Button(body, SWT.NONE);
cancelButton.setImage(getImageDescriptor("icons/fam/cancel.png").createImage()); cancelButton.setImage(getImageDescriptor("/META-INF/images/silk/png/cancel.png").createImage());
cancelButton.setText("generic.cancel"); cancelButton.setText("generic.cancel");
cancelButton.addSelectionListener(new SelectionAdapter() { cancelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -282,6 +282,14 @@ public class SwtVascViewRenderer implements VascViewRenderer {
public void renderView(VascTable table) throws Exception { public void renderView(VascTable table) throws Exception {
if (table.getVascViewRenderer()==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().finalizeVascColumns(table);
table.getVascTableController().finalizeVascTable(table); table.getVascTableController().finalizeVascTable(table);
table.getVascTableController().refreshData(table); table.getVascTableController().refreshData(table);
@ -353,6 +361,9 @@ public class SwtVascViewRenderer implements VascViewRenderer {
ToolItem item = new ToolItem(toolBar, SWT.PUSH); ToolItem item = new ToolItem(toolBar, SWT.PUSH);
item.setText(action.getName()); item.setText(action.getName());
item.setToolTipText(action.getToolTip()); item.setToolTipText(action.getToolTip());
if (action.getImage()!=null) {
item.setImage(getImageDescriptor(action.getImage()).createImage());
}
item.addSelectionListener(new GlobalActionListener(action)); item.addSelectionListener(new GlobalActionListener(action));
} }
@ -418,7 +429,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
logger.finer("Creating body"); logger.finer("Creating body");
// Create the table viewer to display the players // Create the table viewer to display the players
final TableViewer tableViewer = new TableViewer(body); final TableViewer tableViewer = new TableViewer(body, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Table table2 = tableViewer.getTable(); final Table table2 = tableViewer.getTable();
table2.setLayoutData(new GridData(GridData.FILL_BOTH)); table2.setLayoutData(new GridData(GridData.FILL_BOTH));
table2.setHeaderVisible(true); table2.setHeaderVisible(true);
@ -446,15 +457,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
// 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(table));
//TODO: add renderer support
for(VascTableColumn c:table.getTableColumns()) {
TableColumn tc = new TableColumn(table2, SWT.LEFT);
tc.setText(c.getName());
tc.setToolTipText(c.getToolTip());
tc.setMoveable(false);
tc.setResizable(true);
}
//Add sort indicator and sort data when column selected //Add sort indicator and sort data when column selected
Listener sortListener = new Listener() { Listener sortListener = new Listener() {
@ -474,6 +477,8 @@ public class SwtVascViewRenderer implements VascViewRenderer {
//List l = new ArrayList(10); //List l = new ArrayList(10);
/* /*
* //columns[i].setData("PROP",table.getTableColumns().get(i)....);
*
for(int i=0;i<crudTable.getSelectionInList().getSize();i++) { for(int i=0;i<crudTable.getSelectionInList().getSize();i++) {
l.add(crudTable.getSelectionInList().getElementAt(i)); l.add(crudTable.getSelectionInList().getElementAt(i));
} }
@ -486,23 +491,35 @@ public class SwtVascViewRenderer implements VascViewRenderer {
} }
}; };
Integer totalSize = table.getVascTableController().getTotalColumnsWidth(table);
logger.finer("Total size: "+totalSize);
for(VascTableColumn c:table.getTableColumns()) {
TableColumn tc = new TableColumn(table2, SWT.LEFT);
tc.setText(c.getName());
tc.setToolTipText(c.getToolTip());
if (c.getImage()!=null) {
tc.setImage(getImageDescriptor(c.getImage()).createImage());
}
tc.addListener(SWT.Selection, sortListener);
tc.setMoveable(false);
tc.setResizable(true);
}
int totalWidth = table.getVascTableController().getTotalColumnsWidth(table);
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++) {
columns[i].pack(); Integer cWidth = table.getTableColumns().get(i).getWidth();
columns[i].setMoveable(true); if (cWidth==null) {
columns[i].setResizable(true); break;
columns[i].addListener(SWT.Selection, sortListener); }
//columns[i].setData("PROP",table.getTableColumns().get(i)....); //int w = (int)((double)totalSize/(double)totalSize)*cWidth;
if(totalSize!=null) { columns[i].setWidth(cWidth);
Integer cWidth = table.getTableColumns().get(i).getWidth(); columns[i].pack();
columns[i].setWidth(cWidth); //logger.finest("Setting column width: "+w+" total: "+totalSize+" c: "+cWidth+" of column: "+i);
/*
columns[i].setWidth((int)((double)tableWidth/(double)totalSize)*cWidth);
logger.finest("Setting column width: "+(int)((double)tableWidth/(double)totalSize)*cWidth+" total: "+totalSize+" c: "+cWidth+" of column: "+i);
*/
}
} }
logger.fine("Table with columns created: "+table2.getColumnCount()); logger.fine("Table with columns created: "+table2.getColumnCount());
@ -513,13 +530,12 @@ public class SwtVascViewRenderer implements VascViewRenderer {
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:table.getRowActions()) {
//action.createActionObject(table);
Button actionButton = new Button(footer, SWT.NONE); Button actionButton = new Button(footer, SWT.NONE);
actionButton.setText(action.getName()); actionButton.setText(action.getName());
actionButton.setToolTipText(action.getToolTip()); actionButton.setToolTipText(action.getToolTip());
actionButton.setImage(getImageDescriptor(action.getImage()).createImage()); if (action.getImage()!=null) {
actionButton.setImage(getImageDescriptor(action.getImage()).createImage());
}
actionButton.addSelectionListener(new ActionListener(action)); actionButton.addSelectionListener(new ActionListener(action));
} }
@ -571,15 +587,12 @@ public class SwtVascViewRenderer implements VascViewRenderer {
* @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) {
System.out.println("Rending column; "+columnNumber+" bean: "+bean);
VascTableColumn vtc = table.getTableColumns().get(columnNumber); VascTableColumn vtc = table.getTableColumns().get(columnNumber);
if (vtc.getColumnRenderer()!=null) { if (vtc.getColumnRenderer()==null) {
//do iets
return "RENDER";
} else {
return ""+vtc.getVascColumnValue().getValue(vtc,bean); return ""+vtc.getVascColumnValue().getValue(vtc,bean);
} }
// see custem column renderer, so this code will never be called
return "CUSTEM_RENDER";
} }
/** /**

View file

@ -85,9 +85,6 @@ public class SWTTest extends TestCase {
TemplateStore store = XTESParser.getTemplateStore(parser.getElementContext()); TemplateStore store = XTESParser.getTemplateStore(parser.getElementContext());
Query query = store.getQuery("testUsers2"); Query query = store.getQuery("testUsers2");
// define redering
SwtVascViewRenderer render = new SwtVascViewRenderer(shell);
// config table // config table
VascTable table = new VascTable(); VascTable table = new VascTable();
table.setName("Testje"); table.setName("Testje");
@ -98,7 +95,6 @@ public class SWTTest extends TestCase {
table.setVascTableController(new DefaultVascTableController()); table.setVascTableController(new DefaultVascTableController());
table.setVascDataSource(new TestModelVascDataSource()); table.setVascDataSource(new TestModelVascDataSource());
table.setVascTextValue(new DefaultVascTextValue()); table.setVascTextValue(new DefaultVascTextValue());
table.setVascViewRenderer(render);
table.setQuery(query); table.setQuery(query);
table.setVascRecordCreator(new BeanVascRecordCreator(TestModel.class)); table.setVascRecordCreator(new BeanVascRecordCreator(TestModel.class));
table.addRowActions(new AddRowAction()); table.addRowActions(new AddRowAction());
@ -119,26 +115,18 @@ public class SWTTest extends TestCase {
column.setToolTip("tooltip"); column.setToolTip("tooltip");
column.setDefaultValue("DEFFFFFF"); column.setDefaultValue("DEFFFFFF");
column.setHelpId("helpColumnKey"); column.setHelpId("helpColumnKey");
column.setWidth(200); column.setWidth(400);
//column.setVascColumnEditor(vascColumnEditor); //column.setVascColumnEditor(new AutoVascColumnEditor("name"));
//column.setVascColumnRenderer(vascColumnRenderer); //column.setVascColumnRenderer(vascColumnRenderer);
column.setVascColumnValue(new BeanPropertyVascColumnValue("name")); column.setVascColumnValue(new BeanPropertyVascColumnValue("name"));
table.addTableColumns(column); table.addTableColumns(column);
column = new VascAnnotationTableColumn("description"); column = new VascAnnotationTableColumn("description");
table.addTableColumns(column); table.addTableColumns(column);
/*
column = new VascTableColumn();
column.setName("test2");
column.setToolTip("tooltip2");
column.setDefaultValue("DEFF2FFFF");
column.setHelpId("helpColum2nKey");
column.setWidth(200);
column.setVascColumnValue(new BeanPropertyVascColumnValue("description"));
table.addTableColumns(column);
*/
// render
// define redering and render
SwtVascViewRenderer render = new SwtVascViewRenderer(shell);
render.renderView(table); render.renderView(table);
// view // view