Small refactor for comming converters
This commit is contained in:
parent
75b3d5e0a0
commit
1c308a684a
178 changed files with 5865 additions and 1531 deletions
|
|
@ -0,0 +1,283 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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 THE COPYRIGHT HOLDERS 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
|
||||
* THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
|
||||
/**
|
||||
* SwingActionPanel renders some page and download actions.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 20, 2012
|
||||
*/
|
||||
public class SwingActionPanel extends JPanel implements VascEntryFrontendEventListener,ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -6935210323705891740L;
|
||||
private VascEntry vascEntry = null;
|
||||
private JTextField rowNumberField = null;
|
||||
private JComboBox gotoDirectPage = null;
|
||||
private JComboBox gotoDownload = null;
|
||||
private JLabel resultLabel = null;
|
||||
private boolean init = false;
|
||||
|
||||
public SwingActionPanel(VascEntry vascEntry) {
|
||||
|
||||
this.vascEntry=vascEntry;
|
||||
|
||||
JPanel result = this; //new JPanel();
|
||||
//result.setBackground(Color.pink);
|
||||
//result.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||
|
||||
result.add(new JLabel("Row Numbers: "));
|
||||
rowNumberField = new JTextField(6);
|
||||
rowNumberField.addActionListener(this);
|
||||
rowNumberField.setText(""+vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize());
|
||||
result.add(rowNumberField);
|
||||
result.add(new JLabel("Go to: "));
|
||||
gotoDirectPage = new JComboBox();
|
||||
gotoDirectPage.addActionListener(this);
|
||||
result.add(gotoDirectPage);
|
||||
result.add(new JLabel("Download: "));
|
||||
gotoDownload = new JComboBox();
|
||||
gotoDownload.addActionListener(this);
|
||||
gotoDownload.setRenderer(new DownloadListCellRenderer());
|
||||
result.add(gotoDownload);
|
||||
|
||||
resultLabel = new JLabel(" ");
|
||||
result.add(resultLabel);
|
||||
|
||||
//add(result);
|
||||
|
||||
vascEntry.getVascFrontendData().addVascEntryFrontendEventListener(this);
|
||||
}
|
||||
|
||||
class DownloadListCellRenderer extends JLabel implements ListCellRenderer {
|
||||
private static final long serialVersionUID = -2143588238414900498L;
|
||||
public Component getListCellRendererComponent(JList list, Object value,int index, boolean isSelected, boolean hasFocus) {
|
||||
if (value==null) {
|
||||
setText("null");
|
||||
} else {
|
||||
setText(((GlobalVascAction)value).getName());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (init) {
|
||||
return;
|
||||
}
|
||||
if (rowNumberField.equals(event.getSource())) {
|
||||
int pageSize = new Integer(rowNumberField.getText());
|
||||
vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(pageSize);
|
||||
vascEntry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
}
|
||||
if (gotoDirectPage.equals(event.getSource())) {
|
||||
if (gotoDirectPage.getSelectedIndex()==0) {
|
||||
return;
|
||||
}
|
||||
vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(gotoDirectPage.getSelectedIndex() - 1);
|
||||
gotoDirectPage.setSelectedIndex(0);
|
||||
}
|
||||
if (gotoDownload.equals(event.getSource())) {
|
||||
GlobalVascAction action = (GlobalVascAction)gotoDownload.getSelectedItem();
|
||||
if (action==null) {
|
||||
return;
|
||||
}
|
||||
String id = (String)action.getId();
|
||||
if (id==null) {
|
||||
return;
|
||||
}
|
||||
if ("null".equals(id)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
action.doGlobalAction(vascEntry);
|
||||
} catch (Exception e) {
|
||||
vascEntry.getVascFrontendData().getVascFrontendHelper().handleException(vascEntry, e);
|
||||
}
|
||||
|
||||
// restore normal view for next request.
|
||||
/*
|
||||
comp.setRenderFacetState("listView");
|
||||
VascEntryExporter ex = getSelectedExporter();
|
||||
|
||||
if (ex==null) {
|
||||
logger.fine("No exporter selected for download.");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
gotoDownload.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes()
|
||||
*/
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
|
||||
return result;
|
||||
}
|
||||
|
||||
public void vascEvent(VascEntry entry,Object dataNotUsed) {
|
||||
|
||||
init = true;
|
||||
|
||||
long pageSize = entry.getVascFrontendData().getVascFrontendPager().getPageSize();
|
||||
long pageStart = entry.getVascFrontendData().getVascFrontendPager().getPageStartCount();
|
||||
long pageStop = entry.getVascFrontendData().getVascFrontendPager().getPageStopCount();
|
||||
long pageTotalCount = entry.getVascFrontendData().getVascFrontendPager().getPageTotalRecordCount();
|
||||
String format = "Results %1$d-%2$d from %3$d rows";
|
||||
resultLabel.setText(String.format(format, pageStart, pageStop, pageTotalCount));
|
||||
rowNumberField.setText(""+pageSize);
|
||||
|
||||
gotoDirectPage.removeAllItems();
|
||||
gotoDirectPage.addItem("Goto...");
|
||||
|
||||
List<VascBackendPageNumber> pages = vascEntry.getVascFrontendData().getVascFrontendPager().getTablePagesFromBackend();
|
||||
int i=0;
|
||||
for (VascBackendPageNumber page:pages) {
|
||||
//pages.setRowIndex(i);
|
||||
//VascBackendPageNumber page = (VascBackendPageNumber)getTablePagesDataModel().getRowData();
|
||||
// = new SelectItem();
|
||||
//String name = i18nMap.get("generic.vasc.jsf.table.page.name");
|
||||
//String description = i18nMap.get("generic.vasc.jsf.table.page.description");
|
||||
/*
|
||||
s.setLabel(name+page.getPageNumber()+" "+(i*pageSize)+"-"+((i*pageSize)+pageSize));
|
||||
s.setDescription(description+page.getPageNumber());
|
||||
s.setValue(page.getPageNumber());
|
||||
result.add(s);
|
||||
*/
|
||||
//if (page.getSelected()) {
|
||||
// setSelectedItem(arg0)
|
||||
// }
|
||||
gotoDirectPage.addItem("page: "+page.getPageNumber()+" "+(i*pageSize)+"-"+((i*pageSize)+pageSize));
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SelectItem s = new SelectItem();
|
||||
s.setLabel(i18nMap.get("generic.vasc.jsf.table.export.select"));
|
||||
s.setDescription(i18nMap.get("generic.vasc.jsf.table.export.select.alt"));
|
||||
s.setValue("null");
|
||||
result.add(s);*/
|
||||
gotoDownload.removeAllItems();
|
||||
|
||||
GlobalVascAction empty = new GlobalVascAction() {
|
||||
|
||||
public void setName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setHelpId(String helpId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "...";
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getHelpId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void doGlobalAction(VascEntry vascEntry) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public GlobalVascAction clone() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
empty.setName("...");
|
||||
gotoDownload.addItem(empty);
|
||||
|
||||
for (GlobalVascAction a:entry.getGlobalActions()) {
|
||||
if (a.getId().contains("xport")) {
|
||||
//s = new SelectItem();
|
||||
//s.setLabel(i18nMap.get(a.getName()));
|
||||
//s.setDescription(i18nMap.get(a.getDescription()));
|
||||
//s.setValue(a.getId());
|
||||
//result.add(s);
|
||||
gotoDownload.addItem(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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 THE COPYRIGHT HOLDERS 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
|
||||
* THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
|
||||
/**
|
||||
* SwingPagerPanel renders dynamic pager for swing.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 21, 2012
|
||||
*/
|
||||
public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventListener,ActionListener {
|
||||
|
||||
private static final long serialVersionUID = 2651163640840746196L;
|
||||
private VascEntry vascEntry = null;
|
||||
private JPanel result = null;
|
||||
|
||||
public SwingPagerPanel(VascEntry vascEntry) {
|
||||
this.vascEntry=vascEntry;
|
||||
//result = this;
|
||||
result = new JPanel();
|
||||
// result.setBackground(Color.green);
|
||||
//result.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||
|
||||
|
||||
add(result);
|
||||
vascEntry.getVascFrontendData().addVascEntryFrontendEventListener(this);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() instanceof JButton) {
|
||||
JButton but = (JButton)e.getSource();
|
||||
Integer page = new Integer(but.getText());
|
||||
vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(page);
|
||||
}
|
||||
}
|
||||
|
||||
class NextAction implements ActionListener {
|
||||
boolean next = true;
|
||||
public NextAction(boolean next) {
|
||||
this.next=next;
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int pageIndex = vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||
if (next) {
|
||||
if (vascEntry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction()) {
|
||||
vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex+1);
|
||||
}
|
||||
} else {
|
||||
if (vascEntry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction()) {
|
||||
vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void vascEvent(VascEntry entry, Object data) {
|
||||
|
||||
for(Component c:result.getComponents()) {
|
||||
if (c instanceof JButton) {
|
||||
((JButton)c).removeActionListener(this);
|
||||
}
|
||||
}
|
||||
result.removeAll();
|
||||
|
||||
|
||||
if (entry.getVascFrontendData().getVascFrontendPager().getHasExtendedPageMode()) {
|
||||
JButton prev = new JButton("Previous");
|
||||
prev.addActionListener(new NextAction(false));
|
||||
prev.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction());
|
||||
result.add(prev);
|
||||
List<VascBackendPageNumber> pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedBegin();
|
||||
for(VascBackendPageNumber page:pages) {
|
||||
JButton but = new JButton(""+page.getPageNumber());
|
||||
but.addActionListener(this);
|
||||
if (page.getSelected()!=null && page.getSelected()) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
result.add(but);
|
||||
}
|
||||
result.add(new JLabel("..."));
|
||||
if (entry.getVascFrontendData().getVascFrontendPager().getHasExtendedPageModeCenter()) {
|
||||
pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedCenter();
|
||||
for(VascBackendPageNumber page:pages) {
|
||||
JButton but = new JButton(""+page.getPageNumber());
|
||||
but.addActionListener(this);
|
||||
if (page.getSelected()!=null && page.getSelected()) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
result.add(but);
|
||||
}
|
||||
result.add(new JLabel("..."));
|
||||
}
|
||||
pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedEnd();
|
||||
for(VascBackendPageNumber page:pages) {
|
||||
JButton but = new JButton(""+page.getPageNumber());
|
||||
but.addActionListener(this);
|
||||
if (page.getSelected()!=null && page.getSelected()) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
result.add(but);
|
||||
}
|
||||
JButton next = new JButton("Next");
|
||||
next.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction());
|
||||
next.addActionListener(new NextAction(true));
|
||||
result.add(next);
|
||||
} else {
|
||||
JButton prev = new JButton("Previous");
|
||||
prev.addActionListener(new NextAction(false));
|
||||
prev.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction());
|
||||
result.add(prev);
|
||||
List<VascBackendPageNumber> pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesNormal();
|
||||
for(VascBackendPageNumber page:pages) {
|
||||
JButton but = new JButton(""+page.getPageNumber());
|
||||
but.addActionListener(this);
|
||||
if (page.getSelected()!=null && page.getSelected()) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
result.add(but);
|
||||
}
|
||||
JButton next = new JButton("Next");
|
||||
next.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction());
|
||||
next.addActionListener(new NextAction(true));
|
||||
result.add(next);
|
||||
}
|
||||
}
|
||||
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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 THE COPYRIGHT HOLDERS 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
|
||||
* THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.ui.VascColumnValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
/**
|
||||
* SwingVascEditDialog renders vasc entry edit dialog
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class SwingVascEditDialog extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = 10L;
|
||||
private String headerText = null;
|
||||
private String headerTextValue = null;
|
||||
private Object result = null;
|
||||
private Object bean = null;
|
||||
private VascEntry entry = null;
|
||||
private SwingVascFrontend swingFrontend = null;
|
||||
|
||||
public SwingVascEditDialog(SwingVascFrontend swingFrontend,JComponent parent,VascEntry entry,Object bean,String beanValue) throws Exception {
|
||||
super();
|
||||
this.headerText = "vasc.dialog.edit.message";
|
||||
this.headerTextValue = beanValue;
|
||||
this.bean = bean;
|
||||
this.entry = entry;
|
||||
this.swingFrontend=swingFrontend;
|
||||
|
||||
setTitle(swingFrontend.i18n("vasc.dialog.edit.title"));
|
||||
setModal(true);
|
||||
|
||||
JPanel pane = new JPanel();
|
||||
pane.setLayout(new BorderLayout());
|
||||
|
||||
JPanel header = new JPanel();
|
||||
createHeader(header);
|
||||
pane.add(header,BorderLayout.NORTH);
|
||||
|
||||
JPanel body = new JPanel();
|
||||
createBody(body);
|
||||
pane.add(body,BorderLayout.CENTER);
|
||||
|
||||
JPanel footer = new JPanel();
|
||||
createFooter(footer);
|
||||
pane.add(footer,BorderLayout.SOUTH);
|
||||
|
||||
add(pane);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
//Ensure the text field always gets the first focus.
|
||||
//addComponentListener(new ComponentAdapter() {
|
||||
// public void componentShown(ComponentEvent ce) {
|
||||
// textField.requestFocusInWindow();
|
||||
// }
|
||||
/// });
|
||||
|
||||
pack();
|
||||
setLocationRelativeTo(parent);
|
||||
setResizable(false);
|
||||
}
|
||||
|
||||
|
||||
public Object openDialog() {
|
||||
setVisible(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void createHeader(JPanel header) {
|
||||
JLabel l = new JLabel();
|
||||
l.setText(swingFrontend.i18n(headerText,headerTextValue));
|
||||
l.setFont(new Font(null,Font.BOLD, 14));
|
||||
//l.setToolTipText(i18n(headerText));
|
||||
header.add(l);
|
||||
}
|
||||
|
||||
public void createBody(JPanel body) throws Exception {
|
||||
body.setLayout(new SpringLayout());
|
||||
int column = 0;
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.getEdit()==false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (c.isEditReadOnly()==true) {
|
||||
|
||||
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
|
||||
|
||||
VascUIComponent label = c.getVascEntryFieldType().provideLabelUIComponent(i,c);
|
||||
VascValueModel model = new VascValueModel();
|
||||
model.setValue(swingFrontend.i18n(c.getName()));
|
||||
label.createComponent(entry,c,model,body);
|
||||
|
||||
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
|
||||
model = new VascValueModel(c.getVascEntryFieldType().provideEditorVascValueModel(i,c));
|
||||
model.setValue(c.getVascEntryFieldValue().getValue(c, bean));
|
||||
model.addListener(new VascColumnValueModelListener(c,bean));
|
||||
Object g = editor.createComponent(entry,c,model,body);
|
||||
|
||||
column++;
|
||||
if (i==0) {
|
||||
entry.getVascFrontendData().addFieldVascUIComponents(c, editor,g);
|
||||
}
|
||||
}
|
||||
}
|
||||
//JComponent, rows, cols, initX, initY ,xPad, yPad
|
||||
SpringUtilities.makeCompactGrid(body, column,2, 6,6, 6,6);
|
||||
|
||||
}
|
||||
public void createFooter(JPanel footer) {
|
||||
|
||||
JButton saveButton = new JButton();
|
||||
saveButton.setIcon(swingFrontend.getImageIcon("vasc.dialog.save.image"));
|
||||
saveButton.setText(swingFrontend.i18n("vasc.dialog.save.name"));
|
||||
saveButton.setToolTipText(swingFrontend.i18n("vasc.dialog.save.tooltip"));
|
||||
saveButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
//if(entry.getVascFrontendData().getVascFrontendHelper().validateObject(entry, bean)) {
|
||||
// return;
|
||||
//}
|
||||
result = bean;
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
footer.add(saveButton);
|
||||
|
||||
JButton cancelButton = new JButton();
|
||||
cancelButton.setIcon(swingFrontend.getImageIcon("vasc.dialog.cancel.image"));
|
||||
cancelButton.setText(swingFrontend.i18n("vasc.dialog.cancel.name"));
|
||||
cancelButton.setToolTipText(swingFrontend.i18n("vasc.dialog.cancel.tooltip"));
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
result = null;
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
footer.add(cancelButton);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@
|
|||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Font;
|
||||
|
|
@ -33,44 +32,42 @@ import java.awt.event.MouseAdapter;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.Spring;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
|
||||
import net.forwardfire.vasc.core.AbstractVascFrontend;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascFrontendData;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.core.ui.VascColumnValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
import net.forwardfire.vasc.frontend.AbstractVascFrontend;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingBoolean;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingButton;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingColorChooser;
|
||||
|
|
@ -79,9 +76,8 @@ import net.forwardfire.vasc.frontends.swing.ui.SwingList;
|
|||
import net.forwardfire.vasc.frontends.swing.ui.SwingText;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingTextArea;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SwingVascFrontend renders vasc entries in a swing panel.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
|
|
@ -90,6 +86,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
private Logger logger = null;
|
||||
private JComponent parent = null;
|
||||
private boolean initOnce = true;
|
||||
|
||||
public SwingVascFrontend(JComponent parent) {
|
||||
logger = Logger.getLogger(SwingVascFrontend.class.getName());
|
||||
|
|
@ -97,7 +94,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#getFrontendType()
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontend#getFrontendType()
|
||||
*/
|
||||
public String getFrontendType() {
|
||||
return "swing";
|
||||
|
|
@ -169,7 +166,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
return;
|
||||
}
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result);
|
||||
entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry);
|
||||
entry.getVascFrontendData().getVascFrontendActions().mergeObject();
|
||||
}
|
||||
|
||||
public void renderDelete() throws Exception {
|
||||
|
|
@ -193,7 +190,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
, null // Default button's label
|
||||
);
|
||||
if (response==JOptionPane.YES_OPTION) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().deleteObject(entry);
|
||||
entry.getVascFrontendData().getVascFrontendActions().deleteObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +232,11 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
* @see net.forwardfire.vasc.core.VascViewRenderer#renderView(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void renderView() throws Exception {
|
||||
|
||||
|
||||
if (initOnce==false) {
|
||||
return;
|
||||
}
|
||||
|
||||
JPanel topPanel = new JPanel();
|
||||
topPanel.setLayout(new BorderLayout());
|
||||
//topPanel.setBackground(Color.PINK);
|
||||
|
|
@ -257,13 +258,15 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
//parent.setBackground(Color.CYAN);
|
||||
parent.setLayout(new BorderLayout());
|
||||
parent.add(topPanel);
|
||||
|
||||
initOnce = false;
|
||||
}
|
||||
|
||||
private void renderHeader(JComponent parent2) {
|
||||
|
||||
JPanel header = new JPanel();
|
||||
header.setLayout(new BorderLayout());
|
||||
header.setBackground(Color.WHITE);
|
||||
//header.setBackground(Color.WHITE);
|
||||
header.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
if(entry.getListImage()!=null) {
|
||||
|
|
@ -278,42 +281,78 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
if(entry.getName()!=null) {
|
||||
JLabel l = new JLabel(i18n(entry.getName()));
|
||||
l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
//l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
l.setFont(new Font(null,Font.BOLD, 18));
|
||||
if (entry.getListDescription()!=null) {
|
||||
l.setToolTipText(i18n(entry.getListDescription()));
|
||||
}
|
||||
header.add(l,BorderLayout.NORTH);
|
||||
}
|
||||
if (entry.getListDescription()!=null) {
|
||||
JLabel l = new JLabel(i18n(entry.getListDescription()));
|
||||
//l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
header.add(l,BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
JPanel top = new JPanel();
|
||||
//top.setBackground(Color.BLUE);
|
||||
for (GlobalVascAction action:entry.getGlobalActions()) {
|
||||
JButton but = new JButton();
|
||||
but.setText(i18n(action.getName()));
|
||||
but.setToolTipText(i18n(action.getDescription()));
|
||||
but.addActionListener(new GlobalActionListener(action));
|
||||
but.setIcon(getImageIcon(action.getImage()));
|
||||
top.add(but);
|
||||
}
|
||||
|
||||
|
||||
// create options
|
||||
JPanel optionPanel = new JPanel();
|
||||
//top.setBackground(Color.GREEN);
|
||||
//for(VascUserOption option:entry.getUserOptions()) {
|
||||
// option.createUserOptionRenderer(entry);
|
||||
//}
|
||||
|
||||
// create pager bar
|
||||
JPanel pagePanel = new JPanel();
|
||||
//optionPanel.setBackground(Color.GREEN);
|
||||
|
||||
JPanel body = optionPanel; //new JPanel();
|
||||
body.setLayout(new SpringLayout());
|
||||
int column = 0;
|
||||
try {
|
||||
for(VascEntryField c:entry.getListOptions()) {
|
||||
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
|
||||
|
||||
VascUIComponent label = c.getVascEntryFieldType().provideLabelUIComponent(i,c);
|
||||
VascValueModel model = new VascValueModel();
|
||||
model.setValue(i18n(c.getName()));
|
||||
label.createComponent(entry,c,model,body);
|
||||
|
||||
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
|
||||
model = new VascValueModel(c.getVascEntryFieldType().provideEditorVascValueModel(i,c));
|
||||
model.setValue(c.getDefaultValue());
|
||||
//model.addListener(new VascColumnValueModelListener(c,bean));
|
||||
Object g = editor.createComponent(entry,c,model,body);
|
||||
|
||||
column++;
|
||||
if (i==0) {
|
||||
entry.getVascFrontendData().addFieldVascUIComponents(c, editor,g);
|
||||
}
|
||||
body.add(new JLabel()); // fill :(
|
||||
}
|
||||
}
|
||||
|
||||
// add search
|
||||
column++;
|
||||
JLabel searchLabel = new JLabel("Search: ");
|
||||
body.add(searchLabel);
|
||||
final JTextField searchField = new JTextField();
|
||||
body.add(searchField);
|
||||
JButton searchButton = new JButton("Search");
|
||||
searchButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchField.getText());
|
||||
}
|
||||
});
|
||||
body.add(searchButton);
|
||||
|
||||
} catch (VascException ve) {
|
||||
throw new RuntimeException(ve);
|
||||
}
|
||||
SpringUtilities.makeCompactGrid(body, column,3, 6,6, 6,6);
|
||||
//optionPanel.add(body);
|
||||
|
||||
|
||||
// create pager bar
|
||||
JPanel bottomPanel = new JPanel();
|
||||
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.PAGE_AXIS));
|
||||
bottomPanel.add(new SwingPagerPanel(entry));
|
||||
bottomPanel.add(new SwingActionPanel(entry));
|
||||
|
||||
//top.add(header,BorderLayout.NORTH);
|
||||
parent2.setLayout(new BorderLayout());
|
||||
parent2.add(header,BorderLayout.NORTH);
|
||||
parent2.add(optionPanel,BorderLayout.CENTER);
|
||||
parent2.add(top,BorderLayout.EAST);
|
||||
parent2.add(pagePanel,BorderLayout.SOUTH);
|
||||
parent2.add(bottomPanel,BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
private void renderBody(JComponent parent2) {
|
||||
|
|
@ -328,6 +367,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
table.setModel(model);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
table.getTableHeader().addMouseListener(new ColumnListener(table));
|
||||
|
||||
// remove auto columns :(
|
||||
int cols = table.getColumnModel().getColumnCount();
|
||||
|
|
@ -376,6 +416,55 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
parent2.add(scrollPane);
|
||||
}
|
||||
class ColumnListener extends MouseAdapter {
|
||||
protected JTable table;
|
||||
private String sortField = null;
|
||||
private boolean sortOrder = true;
|
||||
|
||||
public ColumnListener(JTable t) {
|
||||
table = t;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
TableColumnModel colModel = table.getColumnModel();
|
||||
int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
|
||||
//int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex();
|
||||
/*
|
||||
if (modelIndex < 0)
|
||||
return;
|
||||
if (sortCol == modelIndex)
|
||||
isSortAsc = !isSortAsc;
|
||||
else
|
||||
sortCol = modelIndex;
|
||||
|
||||
for (int i = 0; i < columnsCount; i++) {
|
||||
TableColumn column = colModel.getColumn(i);
|
||||
column.setHeaderValue(getColumnName(column.getModelIndex()));
|
||||
}
|
||||
table.getTableHeader().repaint();
|
||||
*/
|
||||
|
||||
TableColumn tc = colModel.getColumn(columnModelIndex);
|
||||
VascEntryField field = (VascEntryField)tc.getHeaderValue();
|
||||
//VascEntry entry = comp.getVascEntry();
|
||||
//VascEntryField field = entry.getVascEntryFieldById(fieldIdString);
|
||||
|
||||
entry.getVascFrontendData().getVascFrontendActions().sortAction(field);
|
||||
|
||||
sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending();
|
||||
sortField = field.getId();
|
||||
|
||||
try {
|
||||
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, ee);
|
||||
}
|
||||
|
||||
//Collections.sort(vector,new MyComparator(isSortAsc));
|
||||
//table.tableChanged(new TableModelEvent(MyTableModel.this));
|
||||
table.repaint();
|
||||
}
|
||||
}
|
||||
class EntrySectionListener implements ListSelectionListener {
|
||||
JTable table;
|
||||
EntrySectionListener(JTable table) {
|
||||
|
|
@ -425,6 +514,13 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
|
||||
private void renderFooter(JComponent parent2) {
|
||||
|
||||
// create pager bar
|
||||
JPanel bottomPanel = new JPanel();
|
||||
bottomPanel.setLayout(new BorderLayout());
|
||||
bottomPanel.add(new SwingActionPanel(entry),BorderLayout.NORTH);
|
||||
bottomPanel.add(new SwingPagerPanel(entry),BorderLayout.CENTER);
|
||||
|
||||
logger.finest("Creating footer");
|
||||
JPanel panel = new JPanel();
|
||||
for(RowVascAction action:entry.getRowActions()) {
|
||||
|
|
@ -435,8 +531,11 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
but.addActionListener(new RowActionListener(action));
|
||||
panel.add(but);
|
||||
}
|
||||
parent2.setLayout(new BorderLayout());
|
||||
parent2.add(panel,BorderLayout.WEST);
|
||||
bottomPanel.add(panel,BorderLayout.SOUTH);
|
||||
|
||||
//parent2.setLayout(new BorderLayout());
|
||||
//parent2.add(bottomPanel,BorderLayout.WEST);
|
||||
parent2.add(bottomPanel);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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 THE COPYRIGHT HOLDERS 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
|
||||
* THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
|
||||
/**
|
||||
* SwingVascTableModel table model for gui component.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class SwingVascTableModel extends AbstractTableModel implements VascEntryFrontendEventListener {
|
||||
|
||||
private static final long serialVersionUID = -7046372314261802293L;
|
||||
private VascEntry entry = null;
|
||||
|
||||
public SwingVascTableModel(VascEntry entry) {
|
||||
this.entry=entry;
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(this);
|
||||
}
|
||||
|
||||
public void vascEvent(VascEntry entry,Object o) {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.entry.entryModel#getColumnCount()
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
int result = 0;
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.getList()==false) {
|
||||
continue;
|
||||
}
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.entry.entryModel#getRowCount()
|
||||
*/
|
||||
public int getRowCount() {
|
||||
if (entry.getVascFrontendData().getVascEntryState().getEntryDataList()==null) {
|
||||
return 0;
|
||||
}
|
||||
return entry.getVascFrontendData().getVascEntryState().getEntryDataList().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.entry.entryModel#getValueAt(int, int)
|
||||
*/
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Object bean = entry.getVascFrontendData().getVascEntryState().getEntryDataList().get(rowIndex);
|
||||
|
||||
// TODO: this is slowing....
|
||||
List<VascEntryField> list = new ArrayList<VascEntryField>();
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.getList()==false) {
|
||||
continue;
|
||||
|
||||
}
|
||||
list.add(c);
|
||||
}
|
||||
|
||||
VascEntryField vtc = list.get(columnIndex);
|
||||
try {
|
||||
//if (vtc.getVascColumnRenderer()!=null) {
|
||||
// return vtc.getVascColumnRenderer().rendererColumn(vtc,bean);
|
||||
//} else {
|
||||
return ""+vtc.getVascEntryFieldValue().getValue(vtc,bean);
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascFrontendEventType.POST_UPDATE,VascFrontendEventType.POST_READ};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -31,8 +31,12 @@ import javax.swing.JMenuBar;
|
|||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingVascFrontend;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelEntry;
|
||||
|
||||
|
||||
|
||||
|
|
@ -46,6 +50,8 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public class SwingTest extends TestCase {
|
||||
|
||||
private TestModelEntry entry = null;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
// enable all logs
|
||||
//InputStream loggingProperties = this.getClass().getResourceAsStream("META-INF/logging.properties");
|
||||
|
|
@ -62,19 +68,32 @@ public class SwingTest extends TestCase {
|
|||
}
|
||||
|
||||
public static void main(String[] argu){
|
||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
||||
try {
|
||||
VascEntry entry = TestTable.getVascTable();
|
||||
|
||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
||||
SwingTest s = new SwingTest();
|
||||
JFrame frame = s.viewEntry(entry);
|
||||
try {
|
||||
s.open();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void open() throws Exception {
|
||||
|
||||
entry = new TestModelEntry();
|
||||
VascController vc = entry.getTestVascController();
|
||||
|
||||
VascEntry ve = entry.createVascEntry(vc);
|
||||
|
||||
((VascEntryControllerLocal)vc.getVascEntryController()).addVascEntry(ve,vc);
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vc.getVascEntryController(), vc);
|
||||
|
||||
DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
|
||||
JFrame frame = viewEntry(ve);
|
||||
|
||||
while (frame.isVisible()) {
|
||||
Thread.sleep(100000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
public JFrame viewEntry(final VascEntry entry) throws Exception {
|
||||
|
|
@ -93,7 +112,7 @@ public class SwingTest extends TestCase {
|
|||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id);
|
||||
TestTable.fill(ee,entry.getVascFrontendData().getVascController());
|
||||
//TestModelEntry.fill(ee,entry.getVascFrontendData().getVascController());
|
||||
viewEntry(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
|
|
@ -116,7 +135,7 @@ public class SwingTest extends TestCase {
|
|||
render.renderView();
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
|
||||
// view
|
||||
frame.pack();
|
||||
|
|
|
|||
|
|
@ -1,163 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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 THE COPYRIGHT HOLDERS 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
|
||||
* THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import net.forwardfire.vasc.annotations.VascDefaultValue;
|
||||
import net.forwardfire.vasc.annotations.VascEntry;
|
||||
import net.forwardfire.vasc.annotations.VascI18n;
|
||||
import net.forwardfire.vasc.annotations.VascModelReference;
|
||||
import net.forwardfire.vasc.annotations.VascStyle;
|
||||
import net.forwardfire.vasc.validators.VascDateFuture;
|
||||
import net.forwardfire.vasc.validators.VascObjectNotNull;
|
||||
import net.forwardfire.vasc.validators.VascStringLength;
|
||||
|
||||
/**
|
||||
* TestModel
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2007
|
||||
*/
|
||||
@VascEntry(headerName="En een tooltip op het model")
|
||||
public class TestModel {
|
||||
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private Float price = null;
|
||||
private Boolean active = null;
|
||||
private Date date = null;
|
||||
private TestModel testModel = null;
|
||||
private String hexColor = null;
|
||||
//private Node nonEditorField = null;
|
||||
|
||||
/**
|
||||
* @return the date
|
||||
*/
|
||||
@VascDateFuture
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date the date to set
|
||||
*/
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
@VascI18n( name="omscheiving",
|
||||
description="De omscrijving",
|
||||
image="/resources/images/gabelfresser.gif",
|
||||
helpId="help.id")
|
||||
@VascDefaultValue(value="xxxxx")
|
||||
@VascStyle(sizeList=200)
|
||||
// @NotNull
|
||||
// @Max(value=10)
|
||||
@VascObjectNotNull
|
||||
@VascStringLength(max=10)
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the price
|
||||
*/
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param price the price to set
|
||||
*/
|
||||
public void setPrice(Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
|
||||
// @NotNull
|
||||
@VascObjectNotNull
|
||||
@VascModelReference
|
||||
@VascI18n(image="/resources/images/gabelfresser.gif")
|
||||
public TestModel getTestModel() {
|
||||
return testModel;
|
||||
}
|
||||
|
||||
public void setTestModel(TestModel testModel) {
|
||||
this.testModel = testModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active
|
||||
*/
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param active the active to set
|
||||
*/
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hexColor
|
||||
*/
|
||||
public String getHexColor() {
|
||||
return hexColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hexColor the hexColor to set
|
||||
*/
|
||||
public void setHexColor(String hexColor) {
|
||||
this.hexColor = hexColor;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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 THE COPYRIGHT HOLDERS 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
|
||||
* THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.core.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.core.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItem;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
|
||||
import net.forwardfire.vasc.impl.entry.BeanPropertyVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.impl.entry.BeanVascEntryRecordCreator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class TestModelVascDataSource extends AbstractVascBackend implements VascSelectItemModel {
|
||||
|
||||
private List<Object> testModels = null;
|
||||
private String nullLabel = null;
|
||||
private String nullKeyValue = null;
|
||||
|
||||
public TestModelVascDataSource() {
|
||||
testModels = new ArrayList<Object>(2);
|
||||
|
||||
TestModel t = new TestModel();
|
||||
t.setDate(new Date());
|
||||
t.setDescription("yoyo test");
|
||||
t.setName("this Name");
|
||||
t.setPrice(34.1f);
|
||||
t.setActive(true);
|
||||
t.setHexColor("#FF66EE");
|
||||
testModels.add(t);
|
||||
|
||||
t = new TestModel();
|
||||
t.setDate(new Date());
|
||||
t.setDescription("Model2 test");
|
||||
t.setName("BeanSourde");
|
||||
t.setPrice(19.2f);
|
||||
t.setActive(false);
|
||||
t.setTestModel((TestModel)testModels.get(0));
|
||||
testModels.add(t);
|
||||
}
|
||||
public TestModelVascDataSource(List<Object> testModels) {
|
||||
this.testModels=testModels;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
return testModels;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
testModels.add(object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
if(testModels.contains(object)==false) {
|
||||
testModels.add(object);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
testModels.remove(object);
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new BeanPropertyVascEntryFieldValue(field.getBackendName());
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new BeanVascEntryRecordCreator(TestModel.class);
|
||||
}
|
||||
|
||||
// --- VascSelectItemModel interface
|
||||
|
||||
public List<VascSelectItem> getVascSelectItems(VascEntry entry) {
|
||||
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
|
||||
for (Object o:testModels) {
|
||||
TestModel t = (TestModel)o;
|
||||
VascSelectItem i = new VascSelectItem(t.getName(),t);
|
||||
res.add(i);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nullLabel
|
||||
*/
|
||||
public String getNullLabel() {
|
||||
return nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullLabel the nullLabel to set
|
||||
*/
|
||||
public void setNullLabel(String nullLabel) {
|
||||
this.nullLabel = nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nullKeyValue
|
||||
*/
|
||||
public String getNullKeyValue() {
|
||||
return nullKeyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullKeyValue the nullKeyValue to set
|
||||
*/
|
||||
public void setNullKeyValue(String nullKeyValue) {
|
||||
this.nullKeyValue = nullKeyValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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 THE COPYRIGHT HOLDERS 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
|
||||
* THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.forwardfire.vasc.core.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascFrontendData;
|
||||
import net.forwardfire.vasc.impl.DefaultVascBackedEntryFinalizer;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFrontendData;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFrontendHelper;
|
||||
import net.forwardfire.vasc.impl.VascBackendProxyPaged;
|
||||
import net.forwardfire.vasc.impl.VascBackendProxySearch;
|
||||
import net.forwardfire.vasc.impl.VascBackendProxySort;
|
||||
import net.forwardfire.vasc.impl.actions.AddRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.CSVExportGlobalAction;
|
||||
import net.forwardfire.vasc.impl.actions.DeleteRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.EditRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.RefreshDataGlobalAction;
|
||||
import net.forwardfire.vasc.impl.actions.XMLExportGlobalAction;
|
||||
import net.forwardfire.vasc.impl.x4o.VascParser;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 2, 2007
|
||||
*/
|
||||
public class TestTable {
|
||||
|
||||
static VascController getDefaultVascController() throws Exception {
|
||||
VascController c = DefaultVascFactory.getDefaultVascController(1234L,"Nice UserName","user","role_admin");
|
||||
|
||||
// for test
|
||||
TestModelVascDataSource backend = new TestModelVascDataSource();
|
||||
backend.setId("testBackend1");
|
||||
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backend);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static public void fill(VascEntry entry,VascController vascController) {
|
||||
|
||||
|
||||
VascFrontendData frontendData = DefaultVascFactory.getDefaultVascFrontendData(null); //DefaultVascFactory.getDefaultVascFrontendData("i18n.vasc", Locale.getDefault());
|
||||
frontendData.setVascController(vascController);
|
||||
entry.setVascFrontendData(frontendData);
|
||||
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
||||
frontendData.getVascEntryState().setVascBackend(backend);
|
||||
frontendData.getVascEntryState().setVascEntry(entry);
|
||||
|
||||
|
||||
entry.addRowAction(new AddRowAction());
|
||||
entry.addRowAction(new EditRowAction());
|
||||
entry.addRowAction(new DeleteRowAction());
|
||||
|
||||
entry.addGlobalAction(new XMLExportGlobalAction());
|
||||
entry.addGlobalAction(new CSVExportGlobalAction());
|
||||
entry.addGlobalAction(new RefreshDataGlobalAction());
|
||||
|
||||
// hackje om deze manuale actions van i18n keys te voorzien;
|
||||
// this is temp untill x4o templaing
|
||||
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||
try {
|
||||
f.finalizeVascEntry(entry, vascController);
|
||||
} catch (VascException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static public VascEntry getVascTable() throws Exception {
|
||||
|
||||
VascController c = getDefaultVascController();
|
||||
|
||||
VascParser parser = new VascParser(c);
|
||||
File f = File.createTempFile("test-vasc", ".xml");
|
||||
parser.setDebugOutputStream(new FileOutputStream(f));
|
||||
parser.parseResource("net/forwardfire/vasc/tables.xml");
|
||||
|
||||
VascEntry entry = parser.getVascController().getVascEntryController().getVascEntryById("test1");
|
||||
fill(entry,c);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void printEntry(VascEntry e) throws Exception {
|
||||
|
||||
System.out.println("");
|
||||
System.out.println("=== Printing entry ===");
|
||||
System.out.println("");
|
||||
|
||||
for (Method m:e.getClass().getMethods()) {
|
||||
if (m.getName().startsWith("get")==false) { //a bit dirty
|
||||
continue;
|
||||
}
|
||||
if (m.getParameterTypes().length>0) {
|
||||
continue;
|
||||
}
|
||||
System.out.println("prop: "+m.getName()+" -> "+m.invoke(e));
|
||||
}
|
||||
|
||||
System.out.println("");
|
||||
System.out.println("=== Fields ===");
|
||||
for (VascEntryField vef:e.getVascEntryFields()) {
|
||||
|
||||
System.out.println("=== Field: "+vef.getId());
|
||||
|
||||
for (Method m:vef.getClass().getMethods()) {
|
||||
if (m.getName().startsWith("get")==false) { //a bit dirty
|
||||
continue;
|
||||
}
|
||||
if (m.getParameterTypes().length>0) {
|
||||
continue;
|
||||
}
|
||||
System.out.println("prop: "+m.getName()+" -> "+m.invoke(vef));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue