[svn r380] added all kinds of objects
This commit is contained in:
parent
a9520b3804
commit
37fdf22282
140 changed files with 7679 additions and 901 deletions
650
src/test/java/com/idcanet/vasc/SWTTableViewerTest.java
Normal file
650
src/test/java/com/idcanet/vasc/SWTTableViewerTest.java
Normal file
|
|
@ -0,0 +1,650 @@
|
|||
/*
|
||||
* Copyright 2004-2006 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;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.CheckboxCellEditor;
|
||||
import org.eclipse.jface.viewers.ColorCellEditor;
|
||||
import org.eclipse.jface.viewers.ComboBoxCellEditor;
|
||||
import org.eclipse.jface.viewers.ICellModifier;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.TextCellEditor;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.window.ApplicationWindow;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Item;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.frontends.swt.SwtVascFrontend;
|
||||
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests a simple x4o xml language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class SWTTableViewerTest extends TestCase {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
// enable all logs
|
||||
InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties");
|
||||
LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||
loggingProperties.close();
|
||||
|
||||
// load xtes queries
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new PersonEditor().run();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
/*
|
||||
public void testTable() throws Exception {
|
||||
|
||||
// get GUI
|
||||
Display display = new Display();
|
||||
Shell shell = new Shell(display);
|
||||
shell.setText("Vasc Test - Swt");
|
||||
|
||||
// define redering and render
|
||||
SwtVascFrontend render = new SwtVascFrontend(shell);
|
||||
|
||||
|
||||
VascEntry entry = TestTable.getVascTable();
|
||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
// view
|
||||
shell.open();
|
||||
// Set up the event loop.
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
// If no more entries in event queue
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
display.dispose();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
class PersonEditor extends ApplicationWindow {
|
||||
// Table column names/properties
|
||||
public static final String NAME = "Name";
|
||||
|
||||
public static final String MALE = "Male?";
|
||||
|
||||
public static final String AGE = "Age Range";
|
||||
|
||||
public static final String SHIRT_COLOR = "Shirt Color";
|
||||
|
||||
public static final String[] PROPS = { NAME, MALE, AGE, SHIRT_COLOR };
|
||||
|
||||
// The data model
|
||||
private java.util.List people;
|
||||
|
||||
/**
|
||||
* Constructs a PersonEditor
|
||||
*/
|
||||
public PersonEditor() {
|
||||
super(null);
|
||||
people = new ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the application
|
||||
*/
|
||||
public void run() {
|
||||
// Don't return from open() until window closes
|
||||
setBlockOnOpen(true);
|
||||
|
||||
// Open the main window
|
||||
open();
|
||||
|
||||
// Dispose the display
|
||||
Display.getCurrent().dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the shell
|
||||
*
|
||||
* @param shell
|
||||
* the shell
|
||||
*/
|
||||
protected void configureShell(Shell shell) {
|
||||
super.configureShell(shell);
|
||||
shell.setText("Person Editor");
|
||||
shell.setSize(400, 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the main window's contents
|
||||
*
|
||||
* @param parent
|
||||
* the main window
|
||||
* @return Control
|
||||
*/
|
||||
protected Control createContents(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
composite.setLayout(new GridLayout(1, false));
|
||||
|
||||
// Add a button to create the new person
|
||||
Button newPerson = new Button(composite, SWT.PUSH);
|
||||
newPerson.setText("Create New Person");
|
||||
|
||||
// Add the TableViewer
|
||||
final TableViewer tv = new TableViewer(composite, SWT.FULL_SELECTION);
|
||||
tv.setContentProvider(new PersonContentProvider());
|
||||
tv.setLabelProvider(new PersonLabelProvider());
|
||||
tv.setInput(people);
|
||||
|
||||
// Set up the table
|
||||
Table table = tv.getTable();
|
||||
table.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
new TableColumn(table, SWT.CENTER).setText(NAME);
|
||||
new TableColumn(table, SWT.CENTER).setText(MALE);
|
||||
new TableColumn(table, SWT.CENTER).setText(AGE);
|
||||
new TableColumn(table, SWT.CENTER).setText(SHIRT_COLOR);
|
||||
|
||||
for (int i = 0, n = table.getColumnCount(); i < n; i++) {
|
||||
table.getColumn(i).pack();
|
||||
}
|
||||
|
||||
table.setHeaderVisible(true);
|
||||
table.setLinesVisible(true);
|
||||
|
||||
// Add a new person when the user clicks button
|
||||
newPerson.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
Person p = new Person();
|
||||
p.setName("Name");
|
||||
p.setMale(true);
|
||||
p.setAgeRange(Integer.valueOf("0"));
|
||||
p.setShirtColor(new RGB(255, 0, 0));
|
||||
people.add(p);
|
||||
tv.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
// Create the cell editors
|
||||
CellEditor[] editors = new CellEditor[4];
|
||||
editors[0] = new TextCellEditor(table);
|
||||
editors[1] = new CheckboxCellEditor(table);
|
||||
editors[2] = new ComboBoxCellEditor(table, AgeRange.INSTANCES,
|
||||
SWT.READ_ONLY);
|
||||
editors[3] = new ColorCellEditor(table);
|
||||
|
||||
// Set the editors, cell modifier, and column properties
|
||||
tv.setColumnProperties(PROPS);
|
||||
tv.setCellModifier(new PersonCellModifier(tv));
|
||||
tv.setCellEditors(editors);
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* The application entry point
|
||||
*
|
||||
* @param args
|
||||
* the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new PersonEditor().run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides the content for the person table
|
||||
*/
|
||||
|
||||
class PersonContentProvider implements IStructuredContentProvider {
|
||||
/**
|
||||
* Returns the Person objects
|
||||
*/
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((List) inputElement).toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes any created resources
|
||||
*/
|
||||
public void dispose() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the input changes
|
||||
*/
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides the content for the FoodList application
|
||||
*/
|
||||
|
||||
class FoodContentProvider implements IStructuredContentProvider {
|
||||
/**
|
||||
* Gets the food items for the list
|
||||
*
|
||||
* @param arg0
|
||||
* the data model
|
||||
* @return Object[]
|
||||
*/
|
||||
public Object[] getElements(Object arg0) {
|
||||
return ((GroceryList) arg0).getFoods().toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes any created resources
|
||||
*/
|
||||
public void dispose() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the input changes
|
||||
*
|
||||
* @param arg0
|
||||
* the viewer
|
||||
* @param arg1
|
||||
* the old input
|
||||
* @param arg2
|
||||
* the new input
|
||||
*/
|
||||
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class represents the cell modifier for the PersonEditor program
|
||||
*/
|
||||
|
||||
class PersonCellModifier implements ICellModifier {
|
||||
private Viewer viewer;
|
||||
|
||||
public PersonCellModifier(Viewer viewer) {
|
||||
this.viewer = viewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the property can be modified
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @param property
|
||||
* the property
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean canModify(Object element, String property) {
|
||||
// Allow editing of all values
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for the property
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @param property
|
||||
* the property
|
||||
* @return Object
|
||||
*/
|
||||
public Object getValue(Object element, String property) {
|
||||
Person p = (Person) element;
|
||||
if (PersonEditor.NAME.equals(property))
|
||||
return p.getName();
|
||||
else if (PersonEditor.MALE.equals(property))
|
||||
return Boolean.valueOf(p.isMale());
|
||||
else if (PersonEditor.AGE.equals(property))
|
||||
return p.getAgeRange();
|
||||
else if (PersonEditor.SHIRT_COLOR.equals(property))
|
||||
return p.getShirtColor();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the element
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @param property
|
||||
* the property
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void modify(Object element, String property, Object value) {
|
||||
if (element instanceof Item)
|
||||
element = ((Item) element).getData();
|
||||
|
||||
Person p = (Person) element;
|
||||
if (PersonEditor.NAME.equals(property))
|
||||
p.setName((String) value);
|
||||
else if (PersonEditor.MALE.equals(property))
|
||||
p.setMale(((Boolean) value).booleanValue());
|
||||
else if (PersonEditor.AGE.equals(property))
|
||||
p.setAgeRange((Integer) value);
|
||||
else if (PersonEditor.SHIRT_COLOR.equals(property))
|
||||
p.setShirtColor((RGB) value);
|
||||
|
||||
// Force the viewer to refresh
|
||||
viewer.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class represents a person
|
||||
*/
|
||||
|
||||
class Person {
|
||||
private String name;
|
||||
|
||||
private boolean male;
|
||||
|
||||
private Integer ageRange;
|
||||
|
||||
private RGB shirtColor;
|
||||
|
||||
/**
|
||||
* @return Returns the ageRange.
|
||||
*/
|
||||
public Integer getAgeRange() {
|
||||
return ageRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ageRange
|
||||
* The ageRange to set.
|
||||
*/
|
||||
public void setAgeRange(Integer ageRange) {
|
||||
this.ageRange = ageRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the male.
|
||||
*/
|
||||
public boolean isMale() {
|
||||
return male;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param male
|
||||
* The male to set.
|
||||
*/
|
||||
public void setMale(boolean male) {
|
||||
this.male = male;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* The name to set.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the shirtColor.
|
||||
*/
|
||||
public RGB getShirtColor() {
|
||||
return shirtColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shirtColor
|
||||
* The shirtColor to set.
|
||||
*/
|
||||
public void setShirtColor(RGB shirtColor) {
|
||||
this.shirtColor = shirtColor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class contains all the foods on the "grocery list"
|
||||
*/
|
||||
|
||||
class GroceryList {
|
||||
// Holds the foods
|
||||
private List foods;
|
||||
|
||||
/**
|
||||
* Constructs a grocery list
|
||||
*/
|
||||
public GroceryList() {
|
||||
foods = new ArrayList();
|
||||
|
||||
// Add some foods
|
||||
foods.add(new Food("Broccoli", true));
|
||||
foods.add(new Food("Bundt Cake", false));
|
||||
foods.add(new Food("Cabbage", true));
|
||||
foods.add(new Food("Candy Canes", false));
|
||||
foods.add(new Food("Eggs", true));
|
||||
foods.add(new Food("Potato Chips", false));
|
||||
foods.add(new Food("Milk", true));
|
||||
foods.add(new Food("Soda", false));
|
||||
foods.add(new Food("Chicken", true));
|
||||
foods.add(new Food("Cinnamon Rolls", false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the foods in this grocery list
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
public List getFoods() {
|
||||
return Collections.unmodifiableList(foods);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class represents a type of food
|
||||
*/
|
||||
|
||||
class Food {
|
||||
// The name of the food
|
||||
private String name;
|
||||
|
||||
// Is it healthy?
|
||||
private boolean healthy;
|
||||
|
||||
/**
|
||||
* Food constructor
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param healthy
|
||||
* whether or not it's healthy
|
||||
*/
|
||||
public Food(String name, boolean healthy) {
|
||||
this.name = name;
|
||||
this.healthy = healthy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this is healthy
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isHealthy() {
|
||||
return healthy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides the labels for the person table
|
||||
*/
|
||||
|
||||
class PersonLabelProvider implements ITableLabelProvider {
|
||||
/**
|
||||
* Returns the image
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @param columnIndex
|
||||
* the column index
|
||||
* @return Image
|
||||
*/
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column text
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @param columnIndex
|
||||
* the column index
|
||||
* @return String
|
||||
*/
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
Person person = (Person) element;
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return person.getName();
|
||||
case 1:
|
||||
return Boolean.toString(person.isMale());
|
||||
case 2:
|
||||
return AgeRange.INSTANCES[person.getAgeRange().intValue()];
|
||||
case 3:
|
||||
return person.getShirtColor().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
*/
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
// Ignore it
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes any created resources
|
||||
*/
|
||||
public void dispose() {
|
||||
// Nothing to dispose
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether altering this property on this element will affect the
|
||||
* label
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @param property
|
||||
* the property
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a listener
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
*/
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This class encapsulates age ranges
|
||||
*/
|
||||
|
||||
class AgeRange {
|
||||
public static final String NONE = "";
|
||||
|
||||
public static final String BABY = "0 - 3";
|
||||
|
||||
public static final String TODDLER = "4 - 7";
|
||||
|
||||
public static final String CHILD = "8 - 12";
|
||||
|
||||
public static final String TEENAGER = "13 - 19";
|
||||
|
||||
public static final String ADULT = "20 - ?";
|
||||
|
||||
public static final String[] INSTANCES = { NONE, BABY, TODDLER, CHILD,
|
||||
TEENAGER, ADULT };
|
||||
}
|
||||
|
|
@ -29,6 +29,10 @@ package com.idcanet.vasc;
|
|||
import java.io.InputStream;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.frontends.swt.SwtVascFrontend;
|
||||
|
||||
|
||||
|
|
@ -53,18 +57,21 @@ public class SWTTest extends TestCase {
|
|||
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/*
|
||||
public void testAll() throws Exception {
|
||||
|
||||
// get GUI
|
||||
/*
|
||||
Display display = new Display();
|
||||
Shell shell = new Shell(display);
|
||||
shell.setText("Vasc Test - Swt");
|
||||
|
||||
// define redering and render
|
||||
SwtVascFrontend render = new SwtVascFrontend(shell);
|
||||
render.initEntry(TestTable.getVascTable());
|
||||
|
||||
|
||||
VascEntry entry = TestTable.getVascTable();
|
||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
// view
|
||||
|
|
@ -77,10 +84,8 @@ public class SWTTest extends TestCase {
|
|||
}
|
||||
}
|
||||
display.dispose();
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -28,8 +28,6 @@ package com.idcanet.vasc;
|
|||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
|
|
@ -52,14 +50,15 @@ public class SwingTest extends TestCase {
|
|||
|
||||
public void setUp() throws Exception {
|
||||
// enable all logs
|
||||
InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties");
|
||||
LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||
loggingProperties.close();
|
||||
//InputStream loggingProperties = this.getClass().getResourceAsStream("META-INF/logging.properties");
|
||||
//LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||
//loggingProperties.close();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/*
|
||||
public void testAll() throws Exception {
|
||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
||||
VascEntry entry = TestTable.getVascTable();
|
||||
|
|
@ -69,11 +68,12 @@ public class SwingTest extends TestCase {
|
|||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public JFrame viewEntry(final VascEntry entry) throws Exception {
|
||||
// get GUI
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Test - Swing - "+entry.getName());
|
||||
frame.setTitle("Vasc Test - Swing - "+entry.getHeaderName());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc
|
|||
|
||||
// --- VascSelectItemModel interface
|
||||
|
||||
public List<VascSelectItem> getVascSelectItems() {
|
||||
public List<VascSelectItem> getVascSelectItems(VascEntry entry) {
|
||||
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
|
||||
for (Object o:testModels) {
|
||||
TestModel t = (TestModel)o;
|
||||
|
|
|
|||
|
|
@ -26,23 +26,22 @@
|
|||
|
||||
package com.idcanet.vasc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
import com.idcanet.vasc.core.VascController;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
|
||||
import com.idcanet.vasc.impl.DefaultVascBackendController;
|
||||
import com.idcanet.vasc.impl.DefaultVascBackendControllerResolver;
|
||||
import com.idcanet.vasc.impl.DefaultVascEntryController;
|
||||
import com.idcanet.vasc.impl.DefaultVascEntryControllerResolver;
|
||||
import com.idcanet.vasc.impl.DefaultVascFrontendEntryFinalizer;
|
||||
import com.idcanet.vasc.impl.DefaultVascController;
|
||||
import com.idcanet.vasc.impl.DefaultVascEntry;
|
||||
import com.idcanet.vasc.impl.DefaultVascEntryField;
|
||||
import com.idcanet.vasc.impl.DefaultVascFrontendData;
|
||||
import com.idcanet.vasc.impl.DefaultVascFrontendHelper;
|
||||
import com.idcanet.vasc.impl.DefaultVascUserRoleController;
|
||||
import com.idcanet.vasc.impl.DefaultVascUserRoleControllerResolver;
|
||||
import com.idcanet.vasc.impl.actions.AddRowAction;
|
||||
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
|
||||
import com.idcanet.vasc.impl.actions.DeleteRowAction;
|
||||
|
|
@ -87,11 +86,20 @@ public class TestTable {
|
|||
vascEntryFieldTypeControllerResolver.setVascEntryFieldTypeController(vascEntryFieldTypeController);
|
||||
c.setVascEntryFieldTypeControllerResolver(vascEntryFieldTypeControllerResolver);
|
||||
|
||||
|
||||
DefaultVascUserRoleControllerResolver vascUserRoleControllerResolver = new DefaultVascUserRoleControllerResolver();
|
||||
DefaultVascUserRoleController vascUserRoleController = new DefaultVascUserRoleController(2288L,"idca.nl","user","admin");
|
||||
vascUserRoleControllerResolver.setVascUserRoleController(vascUserRoleController);
|
||||
c.setVascUserRoleControllerResolver(vascUserRoleControllerResolver);
|
||||
|
||||
return c;
|
||||
|
||||
}
|
||||
|
||||
static public void fill(VascEntry entry,VascController c) {
|
||||
|
||||
|
||||
|
||||
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData();
|
||||
vascFrontendData.setVascController(c);
|
||||
|
||||
|
|
@ -101,8 +109,16 @@ public class TestTable {
|
|||
DefaultVascFrontendHelper vascFrontendHelper = new DefaultVascFrontendHelper();
|
||||
vascFrontendData.setVascFrontendHelper(vascFrontendHelper);
|
||||
|
||||
entry.setVascFrontendData(vascFrontendData);
|
||||
|
||||
// hack
|
||||
if (entry.getVascFrontendData()!=null) {
|
||||
entry.setVascFrontendData(vascFrontendData);
|
||||
return;
|
||||
} else {
|
||||
entry.setVascFrontendData(vascFrontendData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
entry.addRowAction(new AddRowAction());
|
||||
entry.addRowAction(new EditRowAction());
|
||||
entry.addRowAction(new DeleteRowAction());
|
||||
|
|
@ -117,61 +133,13 @@ public class TestTable {
|
|||
VascController c = getDefaultVascController();
|
||||
|
||||
VascParser parser = new VascParser(c);
|
||||
File f = File.createTempFile("test-vasc", ".xml");
|
||||
parser.setDebugOutputStream(new FileOutputStream(f));
|
||||
parser.parseResource("vasc/tables.xml");
|
||||
|
||||
VascEntry entry = parser.getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById("test1");
|
||||
fill(entry,c);
|
||||
|
||||
|
||||
// config table
|
||||
|
||||
//VascEntry entry = new DefaultVascEntry();
|
||||
//entry.setId("test1");
|
||||
//entry.setBackendId("testBackend");
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//table.addUserOptions(userOption);
|
||||
//table.addColumnActions(new GraphColumnAction());
|
||||
|
||||
VascEntryField field = new DefaultVascEntryField("name");
|
||||
field.setImage("/META-INF/images/silk/png/tick.png");
|
||||
entry.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField("description");
|
||||
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("EmailField"));
|
||||
entry.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField("active");
|
||||
field.setDefaultValue(true);
|
||||
entry.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField("date");
|
||||
field.setDefaultValue(new Date());
|
||||
entry.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField("testModel");
|
||||
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField"));
|
||||
field.getVascEntryFieldType().setDataObject(c.getVascBackendControllerResolver().getVascBackendController().getVascBackendById("testBackend"));
|
||||
entry.addVascEntryField(field);
|
||||
|
||||
|
||||
field = new DefaultVascEntryField("hexColor");
|
||||
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ColorField"));
|
||||
field.setDefaultValue("#FF3355");
|
||||
entry.addVascEntryField(field);
|
||||
|
||||
printEntry(entry);
|
||||
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||
entry = f.finalizeVascEntry(entry,c);
|
||||
printEntry(entry);
|
||||
|
||||
DefaultVascFrontendEntryFinalizer f2 = new DefaultVascFrontendEntryFinalizer();
|
||||
entry = f2.finalizeVascEntry(entry,c);
|
||||
//printEntry(entry);
|
||||
*/
|
||||
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +156,7 @@ public class TestTable {
|
|||
if (m.getParameterTypes().length>0) {
|
||||
continue;
|
||||
}
|
||||
System.out.println("prop: "+m.getName()+" -> "+m.invoke(e, null));
|
||||
System.out.println("prop: "+m.getName()+" -> "+m.invoke(e));
|
||||
}
|
||||
|
||||
System.out.println("");
|
||||
|
|
@ -204,7 +172,7 @@ public class TestTable {
|
|||
if (m.getParameterTypes().length>0) {
|
||||
continue;
|
||||
}
|
||||
System.out.println("prop: "+m.getName()+" -> "+m.invoke(vef, null));
|
||||
System.out.println("prop: "+m.getName()+" -> "+m.invoke(vef));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,15 +31,12 @@ import java.util.Date;
|
|||
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.hibernate.validator.Max;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.idcanet.vasc.annotations.VascColumnWidth;
|
||||
import com.idcanet.vasc.annotations.VascEntry;
|
||||
import com.idcanet.vasc.annotations.VascStyle;
|
||||
import com.idcanet.vasc.annotations.VascDefaultValue;
|
||||
import com.idcanet.vasc.annotations.VascHelpId;
|
||||
import com.idcanet.vasc.annotations.VascImage;
|
||||
import com.idcanet.vasc.annotations.VascModelReference;
|
||||
import com.idcanet.vasc.annotations.VascName;
|
||||
import com.idcanet.vasc.annotations.VascDescription;
|
||||
import com.idcanet.vasc.annotations.VascI18nModelReference;
|
||||
import com.idcanet.vasc.annotations.VascI18n;
|
||||
import com.idcanet.vasc.validators.VascDateFuture;
|
||||
import com.idcanet.vasc.validators.VascObjectNotNull;
|
||||
import com.idcanet.vasc.validators.VascStringLength;
|
||||
|
|
@ -51,7 +48,7 @@ import com.idcanet.vasc.validators.VascStringLength;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2007
|
||||
*/
|
||||
@VascDescription(key="En een tooltip op het model")
|
||||
@VascEntry(headerName="En een tooltip op het model")
|
||||
public class TestModel {
|
||||
|
||||
private String name = null;
|
||||
|
|
@ -61,7 +58,7 @@ public class TestModel {
|
|||
private Date date = null;
|
||||
private TestModel testModel = null;
|
||||
private String hexColor = null;
|
||||
private Node nonEditorField = null;
|
||||
//private Node nonEditorField = null;
|
||||
|
||||
/**
|
||||
* @return the date
|
||||
|
|
@ -81,12 +78,12 @@ public class TestModel {
|
|||
/**
|
||||
* @return the description
|
||||
*/
|
||||
@VascName(key="omscheiving")
|
||||
@VascDescription(key="De omscheiving")
|
||||
@VascHelpId(helpId="help.id")
|
||||
@VascI18n( name="omscheiving",
|
||||
description="De omscrijving",
|
||||
image="/resources/images/gabelfresser.gif",
|
||||
helpId="help.id")
|
||||
@VascDefaultValue(defaultValue="xxxxx")
|
||||
@VascColumnWidth(width=200)
|
||||
@VascImage(image="/resources/images/gabelfresser.gif")
|
||||
@VascStyle(sizeList=200)
|
||||
@NotNull
|
||||
@Max(value=10)
|
||||
@VascObjectNotNull
|
||||
|
|
@ -130,10 +127,11 @@ public class TestModel {
|
|||
this.price = price;
|
||||
}
|
||||
|
||||
@VascImage(image="/resources/images/gabelfresser.gif")
|
||||
@VascModelReference
|
||||
|
||||
@NotNull
|
||||
@VascObjectNotNull
|
||||
@VascI18nModelReference
|
||||
@VascI18n(image="/resources/images/gabelfresser.gif")
|
||||
public TestModel getTestModel() {
|
||||
return testModel;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue