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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue