[svn r250] fixed annotations , added fff , added more images properties
This commit is contained in:
parent
d88cb26330
commit
1c47fbffa3
|
@ -13,5 +13,6 @@
|
|||
<classpathentry kind="con" path="SWT_CONTAINER/JFACE/PLATFORM"/>
|
||||
<classpathentry kind="lib" path="lib/idcanet-jmx-bin.jar"/>
|
||||
<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"/>
|
||||
</classpath>
|
||||
|
|
BIN
lib/idcanet-fff-bin.jar
Normal file
BIN
lib/idcanet-fff-bin.jar
Normal file
Binary file not shown.
|
@ -175,31 +175,32 @@ public class VascAnnotationParser {
|
|||
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)) {
|
||||
VascName l = (VascName)a;
|
||||
VascName l = (VascName)b;
|
||||
if("".equals(l.key()) | "null".equals(l.key())) {
|
||||
return null;
|
||||
}
|
||||
return l.key();
|
||||
}
|
||||
if (a.equals(VascToolTip.class)) {
|
||||
VascToolTip t = (VascToolTip)a;
|
||||
VascToolTip t = (VascToolTip)b;
|
||||
if("".equals(t.key()) | "null".equals(t.key())) {
|
||||
return null;
|
||||
}
|
||||
return t.key();
|
||||
}
|
||||
if (a.equals(VascHelpId.class)) {
|
||||
VascHelpId h = (VascHelpId)a;
|
||||
VascHelpId h = (VascHelpId)b;
|
||||
if("".equals(h.helpId()) | "null".equals(h.helpId())) {
|
||||
return null;
|
||||
}
|
||||
return h.helpId();
|
||||
}
|
||||
if (a.equals(VascDefaultValue.class)) {
|
||||
VascDefaultValue v = (VascDefaultValue)a;
|
||||
VascDefaultValue v = (VascDefaultValue)b;
|
||||
if (v.defaultValue()==null) {
|
||||
return null; // error ??
|
||||
}
|
||||
|
@ -210,7 +211,7 @@ public class VascAnnotationParser {
|
|||
}
|
||||
}
|
||||
if (a.equals(VascColumnWidth.class)) {
|
||||
VascColumnWidth c = (VascColumnWidth)a;
|
||||
VascColumnWidth c = (VascColumnWidth)b;
|
||||
return c.width();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
package com.idcanet.vasc.core.column;
|
||||
|
||||
import com.idcanet.vasc.core.VascTable;
|
||||
|
||||
|
||||
/**
|
||||
* Defines an VascTableColumn
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
|
@ -41,6 +41,7 @@ public class VascTableColumn {
|
|||
private Object defaultValue = null;
|
||||
private Integer width = null;
|
||||
private String helpId = null;
|
||||
private String image = null;
|
||||
|
||||
private VascColumnValue vascColumnValue = null;
|
||||
private VascColumnRenderer vascColumnRenderer = null;
|
||||
|
@ -168,10 +169,25 @@ public class VascTableColumn {
|
|||
public String getHelpId() {
|
||||
return helpId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param helpId the helpId to set
|
||||
*/
|
||||
public void setHelpId(String 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;
|
||||
}
|
||||
}
|
|
@ -75,6 +75,9 @@ public class DefaultVascTableController implements VascTableController {
|
|||
if (c.getVascColumnValue()==null) {
|
||||
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()) {
|
||||
if(c.getWidth()==null) {
|
||||
Logger.getLogger(VascTable.class.getName()).finer("Column no size: "+c.getName());
|
||||
return null;
|
||||
} else {
|
||||
result+=c.getWidth();
|
||||
}
|
||||
result=+c.getWidth();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction {
|
|||
public AddRowAction() {
|
||||
setName("generic.crud.add");
|
||||
setToolTip("generic.toolTip");
|
||||
setImage("/META-INF/images/silk/png/table_add.png");
|
||||
}
|
||||
|
||||
public void doRowAction(VascTable table,Object rowObject) throws Exception {
|
||||
|
|
|
@ -38,8 +38,9 @@ import com.idcanet.vasc.core.actions.RowVascAction;
|
|||
public class DeleteRowAction extends AbstractVascAction implements RowVascAction {
|
||||
|
||||
public DeleteRowAction() {
|
||||
setName("generic.crud.delete");
|
||||
setToolTip("generic.toolTip");
|
||||
setName("generic.crud.delete.name");
|
||||
setToolTip("generic.crud.delete.tooltip");
|
||||
setImage("/META-INF/images/silk/png/table_delete.png");
|
||||
}
|
||||
|
||||
public void doRowAction(VascTable table,Object rowObject) throws Exception {
|
||||
|
|
|
@ -39,7 +39,8 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
|
|||
|
||||
public EditRowAction() {
|
||||
setName("generic.crud.edit");
|
||||
setToolTip("generic.toolTip");
|
||||
setToolTip("generic.crud.edit.toolTip");
|
||||
setImage("/META-INF/images/silk/png/table_edit.png");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RefreshDataGlobalAction extends AbstractVascAction implements Globa
|
|||
public RefreshDataGlobalAction() {
|
||||
setName("generic.refresh");
|
||||
setToolTip("generic.crud.refresh.tooltip");
|
||||
setImage("icons/fam/table_refresh.png");
|
||||
setImage("/META-INF/images/silk/png/table_refresh.png");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
|
|||
public XMLExportGlobalAction() {
|
||||
setName("generic.crud.export.xml.name");
|
||||
setToolTip("generic.crud.export.xml.tooltip");
|
||||
setImage("icons/fam/page_white_excel.png");
|
||||
setImage("/META-INF/images/silk/png/page_white_excel.png");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.eclipse.swt.widgets.TableColumn;
|
|||
import org.eclipse.swt.widgets.ToolBar;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
|
||||
import com.idcanet.fff.SwingImageHelper;
|
||||
import com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.VascUserOption;
|
||||
import com.idcanet.vasc.core.VascViewRenderer;
|
||||
|
@ -90,25 +91,22 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
object = table.getVascRecordCreator().newRecord(table);
|
||||
logger.finest("created: "+object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//logger.log(Level.WARNING,"Error while creating new: "+crudTable.getRecordClass());
|
||||
table.getVascTableController().handleException(e, table);
|
||||
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");
|
||||
Object result = dialog.open();
|
||||
if(result==null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
result = table.getVascDataSource().merge(object);
|
||||
//FlowstatsPlugin.getDefault().fireModelUpdateListeners(result);
|
||||
|
||||
result = table.getVascDataSource().merge(object);
|
||||
//table.getVascTableController().fireModelUpdateListeners(result);
|
||||
} 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);
|
||||
//System.out.println("==== 1");
|
||||
ImageDescriptor result = ImageDescriptor.createFromFile(path.getClass(), path);
|
||||
result = ImageDescriptor.createFromFile(SwingImageHelper.class, path);
|
||||
if(result==null) {
|
||||
// try load fff
|
||||
//.out.println("==== 2");
|
||||
|
||||
//result = ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource(path));
|
||||
}
|
||||
//System.out.println("==== 3");
|
||||
|
@ -256,7 +256,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
new Label(body, SWT.WRAP);
|
||||
|
||||
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.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
@ -268,7 +268,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
}
|
||||
});
|
||||
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.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
@ -282,6 +282,14 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
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().finalizeVascTable(table);
|
||||
table.getVascTableController().refreshData(table);
|
||||
|
@ -353,6 +361,9 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
|
||||
item.setText(action.getName());
|
||||
item.setToolTipText(action.getToolTip());
|
||||
if (action.getImage()!=null) {
|
||||
item.setImage(getImageDescriptor(action.getImage()).createImage());
|
||||
}
|
||||
item.addSelectionListener(new GlobalActionListener(action));
|
||||
}
|
||||
|
||||
|
@ -418,7 +429,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
logger.finer("Creating body");
|
||||
|
||||
// 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();
|
||||
table2.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
table2.setHeaderVisible(true);
|
||||
|
@ -446,15 +457,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
// Set the content and label providers
|
||||
tableViewer.setContentProvider(new ListConverterContentProvider());
|
||||
tableViewer.setLabelProvider(new DefaultLabelProvider(table));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//TODO: add renderer support
|
||||
|
||||
//Add sort indicator and sort data when column selected
|
||||
Listener sortListener = new Listener() {
|
||||
|
@ -474,6 +477,8 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
//List l = new ArrayList(10);
|
||||
/*
|
||||
* //columns[i].setData("PROP",table.getTableColumns().get(i)....);
|
||||
*
|
||||
for(int i=0;i<crudTable.getSelectionInList().getSize();i++) {
|
||||
l.add(crudTable.getSelectionInList().getElementAt(i));
|
||||
}
|
||||
|
@ -485,24 +490,36 @@ 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();
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
columns[i].pack();
|
||||
columns[i].setMoveable(true);
|
||||
columns[i].setResizable(true);
|
||||
columns[i].addListener(SWT.Selection, sortListener);
|
||||
//columns[i].setData("PROP",table.getTableColumns().get(i)....);
|
||||
if(totalSize!=null) {
|
||||
Integer cWidth = table.getTableColumns().get(i).getWidth();
|
||||
columns[i].setWidth(cWidth);
|
||||
/*
|
||||
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);
|
||||
*/
|
||||
}
|
||||
Integer cWidth = table.getTableColumns().get(i).getWidth();
|
||||
if (cWidth==null) {
|
||||
break;
|
||||
}
|
||||
//int w = (int)((double)totalSize/(double)totalSize)*cWidth;
|
||||
columns[i].setWidth(cWidth);
|
||||
columns[i].pack();
|
||||
//logger.finest("Setting column width: "+w+" total: "+totalSize+" c: "+cWidth+" of column: "+i);
|
||||
}
|
||||
logger.fine("Table with columns created: "+table2.getColumnCount());
|
||||
|
||||
|
@ -512,14 +529,13 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
public void createFooter(Composite footer) {
|
||||
logger.finest("Creating footer");
|
||||
for(RowVascAction action:table.getRowActions()) {
|
||||
|
||||
//action.createActionObject(table);
|
||||
|
||||
for(RowVascAction action:table.getRowActions()) {
|
||||
Button actionButton = new Button(footer, SWT.NONE);
|
||||
actionButton.setText(action.getName());
|
||||
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));
|
||||
|
||||
}
|
||||
|
@ -571,15 +587,12 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||
*/
|
||||
public String getColumnText(Object bean, int columnNumber) {
|
||||
System.out.println("Rending column; "+columnNumber+" bean: "+bean);
|
||||
VascTableColumn vtc = table.getTableColumns().get(columnNumber);
|
||||
if (vtc.getColumnRenderer()!=null) {
|
||||
//do iets
|
||||
return "RENDER";
|
||||
} else {
|
||||
if (vtc.getColumnRenderer()==null) {
|
||||
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
||||
}
|
||||
|
||||
// see custem column renderer, so this code will never be called
|
||||
return "CUSTEM_RENDER";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,10 +84,7 @@ public class SWTTest extends TestCase {
|
|||
parser.parseResource("/META-INF/xtes/tests.xml");
|
||||
TemplateStore store = XTESParser.getTemplateStore(parser.getElementContext());
|
||||
Query query = store.getQuery("testUsers2");
|
||||
|
||||
// define redering
|
||||
SwtVascViewRenderer render = new SwtVascViewRenderer(shell);
|
||||
|
||||
|
||||
// config table
|
||||
VascTable table = new VascTable();
|
||||
table.setName("Testje");
|
||||
|
@ -98,7 +95,6 @@ public class SWTTest extends TestCase {
|
|||
table.setVascTableController(new DefaultVascTableController());
|
||||
table.setVascDataSource(new TestModelVascDataSource());
|
||||
table.setVascTextValue(new DefaultVascTextValue());
|
||||
table.setVascViewRenderer(render);
|
||||
table.setQuery(query);
|
||||
table.setVascRecordCreator(new BeanVascRecordCreator(TestModel.class));
|
||||
table.addRowActions(new AddRowAction());
|
||||
|
@ -119,28 +115,20 @@ public class SWTTest extends TestCase {
|
|||
column.setToolTip("tooltip");
|
||||
column.setDefaultValue("DEFFFFFF");
|
||||
column.setHelpId("helpColumnKey");
|
||||
column.setWidth(200);
|
||||
//column.setVascColumnEditor(vascColumnEditor);
|
||||
column.setWidth(400);
|
||||
//column.setVascColumnEditor(new AutoVascColumnEditor("name"));
|
||||
//column.setVascColumnRenderer(vascColumnRenderer);
|
||||
column.setVascColumnValue(new BeanPropertyVascColumnValue("name"));
|
||||
table.addTableColumns(column);
|
||||
|
||||
column = new VascAnnotationTableColumn("description");
|
||||
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);
|
||||
|
||||
|
||||
// view
|
||||
shell.open();
|
||||
// Set up the event loop.
|
||||
|
|
Loading…
Reference in a new issue