2007-03-22 00:01:07 +00:00
/ *
* 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.swt ;
2007-04-27 23:13:29 +00:00
import java.util.logging.Level ;
2007-03-22 00:01:07 +00:00
import java.util.logging.Logger ;
2007-04-28 15:59:11 +00:00
import org.eclipse.jface.resource.ImageDescriptor ;
2007-03-25 23:20:47 +00:00
import org.eclipse.jface.viewers.ILabelProviderListener ;
import org.eclipse.jface.viewers.IStructuredContentProvider ;
import org.eclipse.jface.viewers.ITableLabelProvider ;
2007-03-22 00:01:07 +00:00
import org.eclipse.jface.viewers.TableViewer ;
2007-03-25 23:20:47 +00:00
import org.eclipse.jface.viewers.Viewer ;
2007-03-22 00:01:07 +00:00
import org.eclipse.swt.SWT ;
2007-04-27 23:13:29 +00:00
import org.eclipse.swt.events.SelectionAdapter ;
import org.eclipse.swt.events.SelectionEvent ;
import org.eclipse.swt.events.SelectionListener ;
2007-03-22 00:01:07 +00:00
import org.eclipse.swt.graphics.Color ;
import org.eclipse.swt.graphics.Font ;
2007-03-25 23:20:47 +00:00
import org.eclipse.swt.graphics.Image ;
2007-04-27 23:13:29 +00:00
import org.eclipse.swt.layout.FillLayout ;
2007-03-22 00:01:07 +00:00
import org.eclipse.swt.layout.GridData ;
import org.eclipse.swt.layout.GridLayout ;
import org.eclipse.swt.widgets.Button ;
import org.eclipse.swt.widgets.Composite ;
2007-04-27 23:13:29 +00:00
import org.eclipse.swt.widgets.Dialog ;
import org.eclipse.swt.widgets.Display ;
2007-03-22 00:01:07 +00:00
import org.eclipse.swt.widgets.Event ;
import org.eclipse.swt.widgets.Label ;
import org.eclipse.swt.widgets.Listener ;
2007-04-27 23:13:29 +00:00
import org.eclipse.swt.widgets.Shell ;
2007-03-22 00:01:07 +00:00
import org.eclipse.swt.widgets.Table ;
import org.eclipse.swt.widgets.TableColumn ;
2007-04-27 23:13:29 +00:00
import org.eclipse.swt.widgets.ToolBar ;
import org.eclipse.swt.widgets.ToolItem ;
2007-03-22 00:01:07 +00:00
import com.idcanet.vasc.core.VascTable ;
import com.idcanet.vasc.core.VascUserOption ;
import com.idcanet.vasc.core.VascViewRenderer ;
2007-04-27 23:13:29 +00:00
import com.idcanet.vasc.core.actions.GlobalVascAction ;
2007-03-22 00:01:07 +00:00
import com.idcanet.vasc.core.actions.RowVascAction ;
import com.idcanet.vasc.core.column.VascTableColumn ;
/ * *
*
* @author Willem Cazander
* @version 1 . 0 Mar 21 , 2007
* /
public class SwtVascViewRenderer implements VascViewRenderer {
private Logger logger = null ;
private Composite parent = null ;
private VascTable table = null ;
public SwtVascViewRenderer ( Composite parent ) {
logger = Logger . getLogger ( SwtVascViewRenderer . class . getName ( ) ) ;
this . parent = parent ;
}
2007-04-28 15:59:11 +00:00
public void renderEdit ( VascTable table , Object object ) throws Exception {
2007-04-27 23:13:29 +00:00
logger . info ( " Rending Edit View " ) ;
if ( object = = null ) {
try {
object = table . getVascRecordCreator ( ) . newRecord ( table ) ;
logger . finest ( " created: " + object ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
//logger.log(Level.WARNING,"Error while creating new: "+crudTable.getRecordClass());
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);
} finally {
//crudTable.getCrudTableDataSource().fillCrudDataList(crudTable);
}
}
2007-04-28 15:59:11 +00:00
public ImageDescriptor getImageDescriptor ( String path ) {
try {
logger . info ( " Loading image: " + path ) ;
//System.out.println("==== 1");
ImageDescriptor result = ImageDescriptor . createFromFile ( path . getClass ( ) , path ) ;
if ( result = = null ) {
// try load fff
//.out.println("==== 2");
//result = ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource(path));
}
//System.out.println("==== 3");
if ( result = = null ) {
throw new NullPointerException ( " Can't load resource: " + path ) ;
}
//System.out.println("==== 4 "+result.getImageData().height+" w:"+result.getImageData().width);
return result ;
} catch ( Exception e ) {
logger . warning ( " Could not load image from path: ' " + path + " ' " ) ;
try {
ImageDescriptor result = null ; //ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource("/META-INF/images/silk/png/bomb.png"));
if ( result = = null ) {
throw new NullPointerException ( " Can't load resource: " + path ) ;
}
return result ;
} catch ( Exception e2 ) {
return ImageDescriptor . getMissingImageDescriptor ( ) ; // default swt missing image fall back
}
}
}
2007-04-27 23:13:29 +00:00
public class SwtVascEditDialog extends Dialog {
private Shell shell = null ;
private String headerText = null ;
private String title = null ;
private Object result = null ;
private Object bean = null ;
public SwtVascEditDialog ( Shell parent , VascTable table , Object bean , String title , String headerText ) {
super ( parent , 0 ) ;
this . headerText = headerText ;
this . title = title ;
this . bean = bean ;
}
public Object open ( ) {
shell = new Shell ( getParent ( ) , SWT . TITLE | SWT . BORDER | SWT . APPLICATION_MODAL ) ;
shell . setText ( title ) ;
GridLayout layout = new GridLayout ( ) ;
layout . marginHeight = 0 ;
layout . marginWidth = 0 ;
shell . setLayout ( layout ) ;
Composite header = new Composite ( shell , SWT . NONE ) ;
GridLayout headerLayout = new GridLayout ( ) ;
headerLayout . numColumns = 6 ;
header . setLayout ( headerLayout ) ;
header . setLayoutData ( new GridData ( GridData . FILL_BOTH ) ) ;
Composite body = new Composite ( shell , SWT . NONE ) ;
GridLayout bodyLayout = new GridLayout ( ) ;
bodyLayout . numColumns = 1 ;
body . setLayout ( bodyLayout ) ;
body . setLayoutData ( new GridData ( GridData . FILL_BOTH ) ) ;
Composite footer = new Composite ( shell , SWT . NONE ) ;
GridLayout footerLayout = new GridLayout ( ) ;
footerLayout . numColumns = 6 ;
footer . setLayout ( footerLayout ) ;
footer . setLayoutData ( new GridData ( SWT . NONE ) ) ;
//createHeader(header);
createBody ( body ) ;
//createFooter(footer);
// should be last
partCreated ( ) ;
shell . pack ( ) ;
shell . open ( ) ;
Display display = shell . getDisplay ( ) ;
while ( ! shell . isDisposed ( ) ) {
if ( ! display . readAndDispatch ( ) ) {
display . sleep ( ) ;
}
}
//image.dispose();
//closeDialog();
return result ;
}
public void createBody ( Composite body ) {
body . setLayout ( new GridLayout ( 2 , true ) ) ;
body . setLayoutData ( new GridData ( GridData . FILL_BOTH ) ) ;
for ( VascTableColumn c : table . getTableColumns ( ) ) {
Label l = new Label ( body , SWT . WRAP ) ;
l . setText ( c . getName ( ) ) ;
if ( c . getToolTip ( ) ! = null ) {
l . setToolTipText ( c . getToolTip ( ) ) ;
}
if ( c . getVascColumnEditor ( ) = = null ) {
Label valueLabel = new Label ( body , SWT . WRAP ) ;
valueLabel . setText ( " " + c . getVascColumnValue ( ) . getValue ( c , bean ) ) ;
} else {
c . getVascColumnEditor ( ) . createColumnEditor ( c ) ;
}
// SWTComponentFactory.createLabel(body,ba.getValueModel(c.getObjectProperty()),SWT.WRAP);
// continue;
//}
//ValueModel vm = ba.getValueModel(c.getObjectProperty());
//c.getVascColumnEditor().createColumnEditor(c);
// set the default value before creating property
/ *
if ( vm . getValue ( ) = = null & c . getDefaultValue ( ) ! = null ) {
try {
logger . finer ( " Setting default value for: " + c . getName ( ) + " def: " + c . getDefaultValue ( ) ) ;
vm . setValue ( c . getDefaultValue ( ) ) ;
} catch ( Exception e ) {
logger . log ( Level . WARNING , " Error in setting default value: ' " + c . getDefaultValue ( ) + " ' error: " + e . getMessage ( ) , e ) ;
}
}
* /
//Control editor = c.getPropertyEditor().createPropertyEditor(body,vm);
GridData gridData = new GridData ( ) ;
gridData . grabExcessHorizontalSpace = true ;
gridData . grabExcessVerticalSpace = true ;
gridData . horizontalAlignment = GridData . FILL ;
gridData . verticalAlignment = GridData . FILL ;
//editor.setLayoutData(gridData);
//c.setTempObjectPropertyControl(editor);
}
// create some spaceing , should replace by seperator
new Label ( body , SWT . WRAP ) ;
new Label ( body , SWT . WRAP ) ;
Button saveButton = new Button ( body , SWT . NONE ) ;
2007-04-28 15:59:11 +00:00
saveButton . setImage ( getImageDescriptor ( " icons/fam/tick.png " ) . createImage ( ) ) ;
2007-04-27 23:13:29 +00:00
saveButton . setText ( " generic.save " ) ;
saveButton . addSelectionListener ( new SelectionAdapter ( ) {
public void widgetSelected ( SelectionEvent e ) {
//if(hasRecordError()) {
// return;
//}
//result = bean;
shell . dispose ( ) ;
}
} ) ;
Button cancelButton = new Button ( body , SWT . NONE ) ;
2007-04-28 15:59:11 +00:00
cancelButton . setImage ( getImageDescriptor ( " icons/fam/cancel.png " ) . createImage ( ) ) ;
2007-04-27 23:13:29 +00:00
cancelButton . setText ( " generic.cancel " ) ;
cancelButton . addSelectionListener ( new SelectionAdapter ( ) {
public void widgetSelected ( SelectionEvent e ) {
result = null ;
shell . dispose ( ) ;
}
} ) ;
}
}
2007-04-28 15:59:11 +00:00
public void renderView ( VascTable table ) throws Exception {
table . getVascTableController ( ) . finalizeVascColumns ( table ) ;
table . getVascTableController ( ) . finalizeVascTable ( table ) ;
table . getVascTableController ( ) . refreshData ( table ) ;
2007-03-25 23:20:47 +00:00
2007-03-22 00:01:07 +00:00
this . table = table ;
GridLayout layout = new GridLayout ( ) ;
layout . marginHeight = 0 ;
layout . marginWidth = 0 ;
parent . setLayout ( layout ) ;
Composite header = new Composite ( parent , SWT . NONE ) ;
GridLayout headerLayout = new GridLayout ( ) ;
headerLayout . numColumns = 6 ;
header . setLayout ( headerLayout ) ;
header . setLayoutData ( new GridData ( SWT . NONE ) ) ;
Composite body = new Composite ( parent , SWT . NONE ) ;
GridLayout bodyLayout = new GridLayout ( ) ;
bodyLayout . numColumns = 1 ;
body . setLayout ( bodyLayout ) ;
body . setLayoutData ( new GridData ( GridData . FILL_BOTH ) ) ;
Composite footer = new Composite ( parent , SWT . NONE ) ;
GridLayout footerLayout = new GridLayout ( ) ;
footerLayout . numColumns = 6 ;
footer . setLayout ( footerLayout ) ;
footer . setLayoutData ( new GridData ( SWT . NONE ) ) ;
createHeader ( header ) ;
createBody ( body ) ;
createFooter ( footer ) ;
// should be last
partCreated ( ) ;
}
public void createHeader ( Composite header ) {
logger . finest ( " Creating header " ) ;
2007-04-27 23:13:29 +00:00
GridLayout layout = new GridLayout ( ) ;
layout . marginHeight = 0 ;
layout . marginWidth = 0 ;
header . setLayout ( layout ) ;
2007-03-22 00:01:07 +00:00
header . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ;
2007-04-27 23:13:29 +00:00
Composite headerBar = new Composite ( header , SWT . NONE ) ;
//GridLayout headerLayout = new GridLayout();
//headerLayout.numColumns = 1;
headerBar . setLayout ( new FillLayout ( ) ) ;
//headerBar.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite headerName = new Composite ( header , SWT . NONE ) ;
GridLayout bodyLayout = new GridLayout ( ) ;
bodyLayout . numColumns = 1 ;
headerName . setLayout ( bodyLayout ) ;
headerName . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ;
//headerName.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite headerOptions = new Composite ( header , SWT . NONE ) ;
GridLayout footerLayout = new GridLayout ( ) ;
footerLayout . numColumns = 1 ;
headerOptions . setLayout ( footerLayout ) ;
//headerOptions.setLayoutData(new GridData(SWT.NONE));
headerOptions . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ;
2007-03-22 00:01:07 +00:00
2007-04-27 23:13:29 +00:00
ToolBar toolBar = new ToolBar ( headerBar , SWT . NONE ) ;
for ( GlobalVascAction action : table . getGlobalActions ( ) ) {
ToolItem item = new ToolItem ( toolBar , SWT . PUSH ) ;
item . setText ( action . getName ( ) ) ;
item . setToolTipText ( action . getToolTip ( ) ) ;
item . addSelectionListener ( new GlobalActionListener ( action ) ) ;
}
Color c = new Color ( header . getDisplay ( ) , 255 , 255 , 255 ) ;
headerName . setBackground ( c ) ;
2007-03-22 00:01:07 +00:00
if ( table . getHeaderName ( ) ! = null ) {
Font headerFont = new Font ( header . getDisplay ( ) , " verdana " , 16 , SWT . BOLD ) ;
2007-04-27 23:13:29 +00:00
Label l = new Label ( headerName , SWT . CENTER ) ;
2007-03-22 00:01:07 +00:00
l . setFont ( headerFont ) ;
l . setText ( table . getVascTextValue ( ) . getTextValue ( table . getHeaderName ( ) ) ) ;
l . setBackground ( c ) ;
}
// create options
for ( VascUserOption option : table . getUserOptions ( ) ) {
/ *
if ( option . getLabelText ( ) ! = null ) {
Label l = new Label ( header , SWT . WRAP ) ;
l . setText ( crudTable . i18n ( cpo . getLabelText ( ) ) ) ;
l . setBackground ( c ) ;
}
// create ValueHolder
cpo . setValueHolder ( new ValueHolder ( null ) ) ;
// create control
cpo . setTempObjectPropertyControl ( cpo . getPropertyEditor ( ) . createPropertyEditor ( header , cpo . getValueHolder ( ) ) ) ;
cpo . getValueHolder ( ) . addPropertyChangeListener ( this ) ;
* /
}
}
2007-04-27 23:13:29 +00:00
class GlobalActionListener extends SelectionAdapter {
private GlobalVascAction action = null ;
public GlobalActionListener ( GlobalVascAction action ) {
this . action = action ;
}
/ * *
* @see org . eclipse . swt . events . SelectionAdapter # widgetSelected ( org . eclipse . swt . events . SelectionEvent )
* /
@Override
public void widgetSelected ( SelectionEvent event ) {
logger . info ( " Global Action " ) ;
2007-04-28 15:59:11 +00:00
try {
action . doGlobalAction ( table ) ;
} catch ( Exception e ) {
table . getVascTableController ( ) . handleException ( e , table ) ;
}
2007-04-27 23:13:29 +00:00
}
}
2007-03-22 00:01:07 +00:00
public void createBody ( Composite body ) {
logger . finer ( " Creating body " ) ;
2007-03-25 23:20:47 +00:00
// Create the table viewer to display the players
final TableViewer tableViewer = new TableViewer ( body ) ;
2007-03-22 00:01:07 +00:00
final Table table2 = tableViewer . getTable ( ) ;
table2 . setLayoutData ( new GridData ( GridData . FILL_BOTH ) ) ;
table2 . setHeaderVisible ( true ) ;
table2 . setLinesVisible ( true ) ;
2007-04-27 23:13:29 +00:00
table2 . addSelectionListener ( new SelectionListener ( ) {
/ * *
* @see org . eclipse . swt . events . SelectionListener # widgetDefaultSelected ( org . eclipse . swt . events . SelectionEvent )
* /
public void widgetDefaultSelected ( SelectionEvent e ) {
}
/ * *
* @see org . eclipse . swt . events . SelectionListener # widgetSelected ( org . eclipse . swt . events . SelectionEvent )
* /
public void widgetSelected ( SelectionEvent e ) {
Object data = e . item . getData ( ) ;
logger . info ( " Slecting data: " + data ) ;
table . setSelectedObject ( data ) ;
}
} ) ;
2007-03-22 00:01:07 +00:00
2007-03-25 23:20:47 +00:00
// 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 ) ;
}
2007-03-22 00:01:07 +00:00
//Add sort indicator and sort data when column selected
Listener sortListener = new Listener ( ) {
public void handleEvent ( Event e ) {
// determine new sort column and direction
TableColumn sortColumn = table2 . getSortColumn ( ) ;
TableColumn currentColumn = ( TableColumn ) e . widget ;
int dir = table2 . getSortDirection ( ) ;
if ( sortColumn = = currentColumn ) {
dir = dir = = SWT . UP ? SWT . DOWN : SWT . UP ;
} else {
table2 . setSortColumn ( currentColumn ) ;
dir = SWT . UP ;
}
// sort the data based on column and direction
2007-04-27 23:13:29 +00:00
//String prop = (String)currentColumn.getData("PROP");
2007-03-22 00:01:07 +00:00
2007-04-27 23:13:29 +00:00
//List l = new ArrayList(10);
2007-03-22 00:01:07 +00:00
/ *
for ( int i = 0 ; i < crudTable . getSelectionInList ( ) . getSize ( ) ; i + + ) {
l . add ( crudTable . getSelectionInList ( ) . getElementAt ( i ) ) ;
}
BeanPropertyComparator c = new BeanPropertyComparator ( ) ;
c . setAscending ( dir ! = SWT . DOWN ) ;
c . setProperty ( prop ) ;
Collections . sort ( l , c ) ;
crudTable . getSelectionInList ( ) . setList ( l ) ;
* /
}
} ;
2007-04-28 15:59:11 +00:00
Integer totalSize = table . getVascTableController ( ) . getTotalColumnsWidth ( table ) ;
2007-03-22 00:01:07 +00:00
logger . finer ( " Total size: " + totalSize ) ;
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 ) ;
* /
}
}
logger . fine ( " Table with columns created: " + table2 . getColumnCount ( ) ) ;
2007-03-28 17:16:40 +00:00
tableViewer . setInput ( table ) ;
2007-03-22 00:01:07 +00:00
}
public void createFooter ( Composite footer ) {
logger . finest ( " Creating footer " ) ;
for ( RowVascAction action : table . getRowActions ( ) ) {
//action.createActionObject(table);
2007-04-27 23:13:29 +00:00
Button actionButton = new Button ( footer , SWT . NONE ) ;
actionButton . setText ( action . getName ( ) ) ;
actionButton . setToolTipText ( action . getToolTip ( ) ) ;
2007-04-28 15:59:11 +00:00
actionButton . setImage ( getImageDescriptor ( action . getImage ( ) ) . createImage ( ) ) ;
2007-04-27 23:13:29 +00:00
actionButton . addSelectionListener ( new ActionListener ( action ) ) ;
2007-03-22 00:01:07 +00:00
}
}
2007-04-27 23:13:29 +00:00
class ActionListener extends SelectionAdapter {
private RowVascAction action = null ;
public ActionListener ( RowVascAction action ) {
this . action = action ;
}
/ * *
* @see org . eclipse . swt . events . SelectionAdapter # widgetSelected ( org . eclipse . swt . events . SelectionEvent )
* /
@Override
public void widgetSelected ( SelectionEvent event ) {
logger . info ( " Row Action " ) ;
2007-04-28 15:59:11 +00:00
try {
action . doRowAction ( table , table . getSelectedObject ( ) ) ;
} catch ( Exception e ) {
table . getVascTableController ( ) . handleException ( e , table ) ;
}
2007-04-27 23:13:29 +00:00
}
}
2007-03-22 00:01:07 +00:00
/ * *
* Is called when all createPartControl is done with creating Parts
* /
public void partCreated ( ) {
2007-03-25 23:20:47 +00:00
}
class DefaultLabelProvider implements ITableLabelProvider {
private VascTable table = null ;
public DefaultLabelProvider ( VascTable table ) {
this . table = table ;
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . ITableLabelProvider # getColumnImage ( java . lang . Object , int )
* /
public Image getColumnImage ( Object arg0 , int arg1 ) {
return null ;
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @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 {
return " " + vtc . getVascColumnValue ( ) . getValue ( vtc , bean ) ;
}
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . IBaseLabelProvider # addListener ( org . eclipse . jface . viewers . ILabelProviderListener )
* /
public void addListener ( ILabelProviderListener arg0 ) {
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . IBaseLabelProvider # dispose ( )
* /
public void dispose ( ) {
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . IBaseLabelProvider # isLabelProperty ( java . lang . Object , java . lang . String )
* /
public boolean isLabelProperty ( Object arg0 , String arg1 ) {
return false ;
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . IBaseLabelProvider # removeListener ( org . eclipse . jface . viewers . ILabelProviderListener )
* /
public void removeListener ( ILabelProviderListener arg0 ) {
}
}
class ListConverterContentProvider implements IStructuredContentProvider {
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . IStructuredContentProvider # getElements ( java . lang . Object )
* /
public Object [ ] getElements ( Object obj ) {
return ( ( VascTable ) obj ) . getTableData ( ) . toArray ( ) ;
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . IContentProvider # dispose ( )
* /
public void dispose ( ) {
}
2007-04-27 23:13:29 +00:00
/ * *
2007-03-25 23:20:47 +00:00
* @see org . eclipse . jface . viewers . IContentProvider # inputChanged ( org . eclipse . jface . viewers . Viewer , java . lang . Object , java . lang . Object )
* /
public void inputChanged ( Viewer arg0 , Object arg1 , Object arg2 ) {
}
2007-03-22 00:01:07 +00:00
}
}