moved to sub projects
This commit is contained in:
parent
a523cc9122
commit
dff60035cf
182 changed files with 251 additions and 46 deletions
11
vasc-frontends/vasc-frontend-swing/.classpath
Normal file
11
vasc-frontends/vasc-frontend-swing/.classpath
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
23
vasc-frontends/vasc-frontend-swing/.project
Normal file
23
vasc-frontends/vasc-frontend-swing/.project
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>vasc-frontend-swing</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#Sun Dec 25 17:29:07 CET 2011
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#Mon Aug 30 21:56:01 CEST 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#Sun Dec 25 17:29:02 CET 2011
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#Mon Aug 30 21:56:00 CEST 2010
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
fullBuildGoals=process-test-resources
|
||||
includeModules=false
|
||||
resolveWorkspaceProjects=true
|
||||
resourceFilterGoals=process-resources resources\:testResources
|
||||
skipCompilerPlugin=true
|
||||
version=1
|
||||
40
vasc-frontends/vasc-frontend-swing/pom.xml
Normal file
40
vasc-frontends/vasc-frontend-swing/pom.xml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-frontends</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<version>0.3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-frontend-swing</artifactId>
|
||||
<version>0.3.5-SNAPSHOT</version>
|
||||
<name>vasc-frontend-swing</name>
|
||||
<description>vasc-frontend-swing</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- FFF depency
|
||||
<dependency>
|
||||
<groupId>com.idcanet.fff</groupId>
|
||||
<artifactId>fff-main</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
-->
|
||||
<!-- Swing date editor depency -->
|
||||
<dependency>
|
||||
<groupId>com.michaelbaranov</groupId>
|
||||
<artifactId>microba</artifactId>
|
||||
<version>0.4.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.odysseus.juel</groupId>
|
||||
<artifactId>juel</artifactId>
|
||||
<version>${juel.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,845 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package 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;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
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.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.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 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.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.frontends.swing.ui.SwingBoolean;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingButton;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingColorChooser;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingLabel;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingList;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingText;
|
||||
import net.forwardfire.vasc.frontends.swing.ui.SwingTextArea;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class SwingVascFrontend extends AbstractVascFrontend {
|
||||
|
||||
private Logger logger = null;
|
||||
private JComponent parent = null;
|
||||
|
||||
public SwingVascFrontend(JComponent parent) {
|
||||
logger = Logger.getLogger(SwingVascFrontend.class.getName());
|
||||
this.parent=parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#getFrontendType()
|
||||
*/
|
||||
public String getFrontendType() {
|
||||
return "swing";
|
||||
}
|
||||
|
||||
/**
|
||||
* Add swing implmented ui components
|
||||
*/
|
||||
protected void addUiComponents() {
|
||||
VascFrontendData vfd = getVascEntry().getVascFrontendData();
|
||||
|
||||
// required UI components
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_LABEL,SwingLabel.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXT, SwingText.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_LIST, SwingList.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_BUTTON, SwingButton.class.getName());
|
||||
|
||||
// optional UI components
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_BOOLEAN , SwingBoolean.class.getName());
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_DATE , SwingDate.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXTAREA, SwingTextArea.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_COLOR, SwingColorChooser.class.getName());
|
||||
}
|
||||
|
||||
public ImageIcon getImageIcon(String imageResource) {
|
||||
/// TODO hack beter
|
||||
String key = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(imageResource);
|
||||
//logger.fine("KEY======================="+key);
|
||||
|
||||
if (key.startsWith("vasc.entry")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (key.indexOf("META-INF")>0 | key.indexOf("resource")>0) {
|
||||
return null;
|
||||
//return SwingImageHelper.getImageIcon(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascViewRenderer#renderEdit(net.forwardfire.vasc.core.VascEntry, java.lang.Object)
|
||||
*/
|
||||
public void renderEdit() throws Exception {
|
||||
logger.fine("Rending Edit View");
|
||||
|
||||
Object rowBean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
||||
String beanValue = rowBean.toString();
|
||||
if (entry.getDisplayNameFieldId()!=null) {
|
||||
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
|
||||
|
||||
Object vv = v.getVascEntryFieldValue().getValue(v, rowBean);
|
||||
if (vv==null) {
|
||||
beanValue="";
|
||||
} else {
|
||||
beanValue=""+vv;
|
||||
}
|
||||
if (beanValue.length()>30) {
|
||||
beanValue=beanValue.substring(0, 30);
|
||||
}
|
||||
}
|
||||
SwingEditDialog dialog = new SwingEditDialog(parent,entry,rowBean,i18n("vasc.dialog.edit.title"),i18n("vasc.dialog.edit.message",beanValue));
|
||||
Object result = dialog.openDialog();
|
||||
logger.finest("OPEN closed : "+result);
|
||||
if(result==null) {
|
||||
return;
|
||||
}
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result);
|
||||
entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry);
|
||||
}
|
||||
|
||||
public void renderDelete() throws Exception {
|
||||
Object rowBean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
||||
String beanValue = rowBean.toString();
|
||||
|
||||
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
|
||||
beanValue = ""+v.getVascEntryFieldValue().getValue(v, rowBean);
|
||||
if (beanValue.length()>30) {
|
||||
beanValue=beanValue.substring(0, 30);
|
||||
}
|
||||
|
||||
int response = JOptionPane.showOptionDialog(
|
||||
parent // Center in window.
|
||||
, i18n("vasc.dialog.delete.message",beanValue) // Message
|
||||
, i18n("vasc.dialog.delete.title") // Title in titlebar
|
||||
, JOptionPane.YES_NO_OPTION // Option type
|
||||
, JOptionPane.PLAIN_MESSAGE // messageType
|
||||
, null // Icon (none)
|
||||
, null // Button text as above.
|
||||
, null // Default button's label
|
||||
);
|
||||
if (response==JOptionPane.YES_OPTION) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().deleteObject(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SwingEditDialog extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = 10L;
|
||||
private String headerText = null;
|
||||
private Object result = null;
|
||||
private Object bean = null;
|
||||
|
||||
public SwingEditDialog(JComponent parent,VascEntry entry,Object bean,String title,String headerText) throws Exception {
|
||||
super();
|
||||
this.headerText = headerText;
|
||||
this.bean = bean;
|
||||
|
||||
setTitle(i18n(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);
|
||||
}
|
||||
|
||||
|
||||
public Object openDialog() {
|
||||
setVisible(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void createHeader(JPanel header) {
|
||||
JLabel l = new JLabel();
|
||||
l.setText(i18n(headerText));
|
||||
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(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(getImageIcon("vasc.dialog.save.image"));
|
||||
saveButton.setText(i18n("vasc.dialog.save.name"));
|
||||
saveButton.setToolTipText(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(getImageIcon("vasc.dialog.cancel.image"));
|
||||
cancelButton.setText(i18n("vasc.dialog.cancel.name"));
|
||||
cancelButton.setToolTipText(i18n("vasc.dialog.cancel.tooltip"));
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
result = null;
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
footer.add(cancelButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascViewRenderer#renderExport(net.forwardfire.vasc.core.VascEntry, net.forwardfire.vasc.core.VascDataExporter)
|
||||
*/
|
||||
public void renderExport(VascEntryExporter exporter) throws Exception {
|
||||
|
||||
String fileName = null;
|
||||
JFileChooser c = new JFileChooser();
|
||||
int rVal = c.showSaveDialog(null);
|
||||
if (rVal == JFileChooser.APPROVE_OPTION) {
|
||||
fileName = c.getSelectedFile().getAbsolutePath();
|
||||
// filename.setText(c.getSelectedFile().getName());
|
||||
//dir.setText(c.getCurrentDirectory().toString());
|
||||
}
|
||||
if (rVal == JFileChooser.CANCEL_OPTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.fine("FileName: "+fileName);
|
||||
if (fileName == null) {
|
||||
return;
|
||||
}
|
||||
OutputStream out = new FileOutputStream(fileName);
|
||||
try {
|
||||
exporter.doExport(out, entry);
|
||||
} catch (Exception e) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||
} finally {
|
||||
if (out!=null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascViewRenderer#renderView(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void renderView() throws Exception {
|
||||
|
||||
JPanel topPanel = new JPanel();
|
||||
topPanel.setLayout(new BorderLayout());
|
||||
//topPanel.setBackground(Color.PINK);
|
||||
|
||||
JPanel n = new JPanel();
|
||||
topPanel.add(n,BorderLayout.NORTH);
|
||||
renderHeader(n);
|
||||
|
||||
JPanel c = new JPanel();
|
||||
c.setLayout(new BorderLayout());
|
||||
topPanel.add(c,BorderLayout.CENTER);
|
||||
renderBody(c);
|
||||
|
||||
JPanel f = new JPanel();
|
||||
//f.setBackground(Color.BLUE);
|
||||
topPanel.add(f,BorderLayout.SOUTH);
|
||||
renderFooter(f);
|
||||
|
||||
//parent.setBackground(Color.CYAN);
|
||||
parent.setLayout(new BorderLayout());
|
||||
parent.add(topPanel);
|
||||
}
|
||||
|
||||
private void renderHeader(JComponent parent2) {
|
||||
|
||||
JPanel header = new JPanel();
|
||||
header.setLayout(new BorderLayout());
|
||||
header.setBackground(Color.WHITE);
|
||||
header.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
if(entry.getListImage()!=null) {
|
||||
JLabel l = new JLabel();
|
||||
// TODO: hack images working
|
||||
//l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(entry.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH)));
|
||||
if (entry.getListDescription()!=null) {
|
||||
l.setToolTipText(i18n(entry.getListDescription()));
|
||||
}
|
||||
header.add(l,BorderLayout.WEST);
|
||||
}
|
||||
|
||||
if(entry.getName()!=null) {
|
||||
JLabel l = new JLabel(i18n(entry.getName()));
|
||||
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.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);
|
||||
//}
|
||||
|
||||
//top.add(header,BorderLayout.NORTH);
|
||||
parent2.setLayout(new BorderLayout());
|
||||
parent2.add(header,BorderLayout.NORTH);
|
||||
parent2.add(optionPanel,BorderLayout.CENTER);
|
||||
parent2.add(top,BorderLayout.EAST);
|
||||
}
|
||||
|
||||
private void renderBody(JComponent parent2) {
|
||||
|
||||
VascColumnModel model = new VascColumnModel();
|
||||
//TODO: entry.getVascEntryController().addEventListener(model);
|
||||
|
||||
JTable table = new JTable();
|
||||
// this regs the listeners for the sorting
|
||||
//tableSorter.setTableHeader(table.getTableHeader());
|
||||
//tableSorter.setTableModel(model);
|
||||
|
||||
table.setModel(model);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
|
||||
// remove auto columns :(
|
||||
int cols = table.getColumnModel().getColumnCount();
|
||||
for (int i=0;i<cols;i++) {
|
||||
TableColumn c = table.getColumnModel().getColumn(0); // idd, just remove index 0 every time
|
||||
table.removeColumn(c);
|
||||
}
|
||||
table.revalidate();
|
||||
|
||||
TableCellRenderer renderer = new JComponentTableHeaderCellRenderer();
|
||||
int counter=0;
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.getList()==false) {
|
||||
continue;
|
||||
}
|
||||
TableColumn t = new TableColumn();
|
||||
if (c.getSizeList()!=null) {
|
||||
t.setPreferredWidth(c.getSizeList());
|
||||
} else {
|
||||
t.setPreferredWidth(200);
|
||||
}
|
||||
t.setHeaderValue(c);
|
||||
t.setHeaderRenderer(renderer);
|
||||
t.setModelIndex(counter);
|
||||
table.addColumn(t);
|
||||
counter++;
|
||||
}
|
||||
table.getSelectionModel().addListSelectionListener(new EntrySectionListener(table));
|
||||
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
Object o = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
||||
if (o==null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// todo: fix
|
||||
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
parent2.add(scrollPane);
|
||||
}
|
||||
class EntrySectionListener implements ListSelectionListener {
|
||||
JTable table;
|
||||
EntrySectionListener(JTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting()) {
|
||||
return;
|
||||
}
|
||||
int rowIndex = table.getSelectedRow();
|
||||
if (rowIndex!=-1) {
|
||||
// temp; gets index by sorter
|
||||
//rowIndex = tableSorter.modelIndex(rowIndex);
|
||||
Object data = entry.getVascFrontendData().getVascEntryState().getEntryDataList().get(rowIndex);
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(data);
|
||||
} else {
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
class JComponentTableHeaderCellRenderer extends DefaultTableCellRenderer {
|
||||
private static final long serialVersionUID = 10L;
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
|
||||
VascEntryField c = (VascEntryField)value;
|
||||
setText(i18n(c.getName()));
|
||||
setToolTipText(i18n(c.getDescription()));
|
||||
|
||||
if(c.getImage()!=null) {
|
||||
setIcon(getImageIcon(c.getImage()));
|
||||
} else {
|
||||
setIcon(null);
|
||||
}
|
||||
|
||||
if (entry != null) {
|
||||
JTableHeader header = table.getTableHeader();
|
||||
if (header != null) {
|
||||
setForeground(header.getForeground());
|
||||
setBackground(header.getBackground());
|
||||
setFont(header.getFont());
|
||||
}
|
||||
}
|
||||
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderFooter(JComponent parent2) {
|
||||
logger.finest("Creating footer");
|
||||
JPanel panel = new JPanel();
|
||||
for(RowVascAction action:entry.getRowActions()) {
|
||||
JButton but = new JButton();
|
||||
but.setText(i18n(action.getName()));
|
||||
but.setToolTipText(i18n(action.getDescription()));
|
||||
but.setIcon(getImageIcon(action.getImage()));
|
||||
but.addActionListener(new RowActionListener(action));
|
||||
panel.add(but);
|
||||
}
|
||||
parent2.setLayout(new BorderLayout());
|
||||
parent2.add(panel,BorderLayout.WEST);
|
||||
}
|
||||
|
||||
|
||||
class RowActionListener implements ActionListener {
|
||||
|
||||
private RowVascAction action = null;
|
||||
|
||||
public RowActionListener(RowVascAction action) {
|
||||
this.action=action;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
logger.fine("Row Action");
|
||||
try {
|
||||
action.doRowAction(entry, entry.getVascFrontendData().getVascEntryState().getEntryDataObject());
|
||||
} catch (Exception e) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GlobalActionListener implements ActionListener {
|
||||
|
||||
private GlobalVascAction action = null;
|
||||
|
||||
public GlobalActionListener(GlobalVascAction action) {
|
||||
this.action=action;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
logger.fine("Global Action");
|
||||
try {
|
||||
action.doGlobalAction(entry);
|
||||
} catch (Exception e) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VascColumnModel extends AbstractTableModel implements VascEntryFrontendEventListener {
|
||||
private static final long serialVersionUID = 10L;
|
||||
|
||||
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);
|
||||
logger.finer("Rending column; "+columnIndex+" bean: "+bean);
|
||||
|
||||
// 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};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A 1.4 file that provides utility methods for creating form- or grid-style
|
||||
* layouts with SpringLayout. These utilities are used by several programs, such
|
||||
* as SpringBox and SpringCompactGrid.
|
||||
*/
|
||||
|
||||
class SpringUtilities {
|
||||
|
||||
/**
|
||||
* Aligns the first <code>rows</code>*<code>cols</code> components of
|
||||
* <code>parent</code> in a grid. Each component is as big as the maximum
|
||||
* preferred width and height of the components. The parent is made just big
|
||||
* enough to fit them all.
|
||||
*
|
||||
* @param rows
|
||||
* number of rows
|
||||
* @param cols
|
||||
* number of columns
|
||||
* @param initialX
|
||||
* x location to start the grid at
|
||||
* @param initialY
|
||||
* y location to start the grid at
|
||||
* @param xPad
|
||||
* x padding between cells
|
||||
* @param yPad
|
||||
* y padding between cells
|
||||
*/
|
||||
public static void makeGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
|
||||
SpringLayout layout;
|
||||
try {
|
||||
layout = (SpringLayout) parent.getLayout();
|
||||
} catch (ClassCastException exc) {
|
||||
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
|
||||
}
|
||||
|
||||
Spring xPadSpring = Spring.constant(xPad);
|
||||
Spring yPadSpring = Spring.constant(yPad);
|
||||
Spring initialXSpring = Spring.constant(initialX);
|
||||
Spring initialYSpring = Spring.constant(initialY);
|
||||
int max = rows * cols;
|
||||
|
||||
//Calculate Springs that are the max of the width/height so that all
|
||||
//cells have the same size.
|
||||
Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0))
|
||||
.getWidth();
|
||||
Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0))
|
||||
.getWidth();
|
||||
for (int i = 1; i < max; i++) {
|
||||
SpringLayout.Constraints cons = layout.getConstraints(parent
|
||||
.getComponent(i));
|
||||
|
||||
maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
|
||||
maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
|
||||
}
|
||||
|
||||
//Apply the new width/height Spring. This forces all the
|
||||
//components to have the same size.
|
||||
for (int i = 0; i < max; i++) {
|
||||
SpringLayout.Constraints cons = layout.getConstraints(parent
|
||||
.getComponent(i));
|
||||
|
||||
cons.setWidth(maxWidthSpring);
|
||||
cons.setHeight(maxHeightSpring);
|
||||
}
|
||||
|
||||
//Then adjust the x/y constraints of all the cells so that they
|
||||
//are aligned in a grid.
|
||||
SpringLayout.Constraints lastCons = null;
|
||||
SpringLayout.Constraints lastRowCons = null;
|
||||
for (int i = 0; i < max; i++) {
|
||||
SpringLayout.Constraints cons = layout.getConstraints(parent
|
||||
.getComponent(i));
|
||||
if (i % cols == 0) { //start of new row
|
||||
lastRowCons = lastCons;
|
||||
cons.setX(initialXSpring);
|
||||
} else { //x position depends on previous component
|
||||
cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
|
||||
xPadSpring));
|
||||
}
|
||||
|
||||
if (i / cols == 0) { //first row
|
||||
cons.setY(initialYSpring);
|
||||
} else { //y position depends on previous row
|
||||
cons.setY(Spring.sum(lastRowCons
|
||||
.getConstraint(SpringLayout.SOUTH), yPadSpring));
|
||||
}
|
||||
lastCons = cons;
|
||||
}
|
||||
|
||||
//Set the parent's size.
|
||||
SpringLayout.Constraints pCons = layout.getConstraints(parent);
|
||||
pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring
|
||||
.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
|
||||
pCons.setConstraint(SpringLayout.EAST, Spring.sum(
|
||||
Spring.constant(xPad), lastCons
|
||||
.getConstraint(SpringLayout.EAST)));
|
||||
}
|
||||
|
||||
/* Used by makeCompactGrid. */
|
||||
private static SpringLayout.Constraints getConstraintsForCell(int row,
|
||||
int col, Container parent, int cols) {
|
||||
SpringLayout layout = (SpringLayout) parent.getLayout();
|
||||
Component c = parent.getComponent(row * cols + col);
|
||||
return layout.getConstraints(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aligns the first <code>rows</code>*<code>cols</code> components of
|
||||
* <code>parent</code> in a grid. Each component in a column is as wide as
|
||||
* the maximum preferred width of the components in that column; height is
|
||||
* similarly determined for each row. The parent is made just big enough to
|
||||
* fit them all.
|
||||
*
|
||||
* @param rows
|
||||
* number of rows
|
||||
* @param cols
|
||||
* number of columns
|
||||
* @param initialX
|
||||
* x location to start the grid at
|
||||
* @param initialY
|
||||
* y location to start the grid at
|
||||
* @param xPad
|
||||
* x padding between cells
|
||||
* @param yPad
|
||||
* y padding between cells
|
||||
*/
|
||||
public static void makeCompactGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
|
||||
SpringLayout layout;
|
||||
try {
|
||||
layout = (SpringLayout) parent.getLayout();
|
||||
} catch (ClassCastException exc) {
|
||||
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
|
||||
}
|
||||
|
||||
//Align all cells in each column and make them the same width.
|
||||
Spring x = Spring.constant(initialX);
|
||||
for (int c = 0; c < cols; c++) {
|
||||
Spring width = Spring.constant(0);
|
||||
for (int r = 0; r < rows; r++) {
|
||||
width = Spring.max(width, getConstraintsForCell(r, c, parent,
|
||||
cols).getWidth());
|
||||
}
|
||||
for (int r = 0; r < rows; r++) {
|
||||
SpringLayout.Constraints constraints = getConstraintsForCell(r,
|
||||
c, parent, cols);
|
||||
constraints.setX(x);
|
||||
constraints.setWidth(width);
|
||||
}
|
||||
x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
|
||||
}
|
||||
|
||||
//Align all cells in each row and make them the same height.
|
||||
Spring y = Spring.constant(initialY);
|
||||
for (int r = 0; r < rows; r++) {
|
||||
Spring height = Spring.constant(0);
|
||||
for (int c = 0; c < cols; c++) {
|
||||
height = Spring.max(height, getConstraintsForCell(r, c, parent,
|
||||
cols).getHeight());
|
||||
}
|
||||
for (int c = 0; c < cols; c++) {
|
||||
SpringLayout.Constraints constraints = getConstraintsForCell(r,
|
||||
c, parent, cols);
|
||||
constraints.setY(y);
|
||||
constraints.setHeight(height);
|
||||
}
|
||||
y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
|
||||
}
|
||||
|
||||
//Set the parent's size.
|
||||
SpringLayout.Constraints pCons = layout.getConstraints(parent);
|
||||
pCons.setConstraint(SpringLayout.SOUTH, y);
|
||||
pCons.setConstraint(SpringLayout.EAST, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 21, 2007
|
||||
*/
|
||||
public class SwingBoolean implements VascUIComponent {
|
||||
|
||||
private JCheckBox checkBox = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
checkBox = new JCheckBox();
|
||||
orgBackgroundColor = checkBox.getBackground();
|
||||
checkBox.setSelected(new Boolean(model.getValue().toString()));
|
||||
((JComponent)gui).add(checkBox);
|
||||
checkBox.addActionListener(new SelectActionListener(model,table));
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (checkBox==null) {
|
||||
return null;
|
||||
}
|
||||
return checkBox.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (checkBox==null) {
|
||||
return;
|
||||
}
|
||||
checkBox.setToolTipText(text);
|
||||
if (text==null) {
|
||||
checkBox.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
checkBox.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !checkBox.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
checkBox.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return checkBox.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
checkBox.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
class SelectActionListener implements ActionListener {
|
||||
|
||||
private VascValueModel model;
|
||||
private VascEntry entry = null;
|
||||
public SelectActionListener(VascValueModel model,VascEntry entry) {
|
||||
this.model=model;
|
||||
this.entry=entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean value = ((JCheckBox)e.getSource()).isSelected();
|
||||
try {
|
||||
model.setValue(value);
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 18, 2008
|
||||
*/
|
||||
public class SwingButton implements VascUIComponent {
|
||||
|
||||
private JButton vascButton = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
vascButton = new JButton("Color");
|
||||
orgBackgroundColor = vascButton.getBackground();
|
||||
((JComponent)gui).add(vascButton);
|
||||
//vascButton.addActionListener(new SelectActionListener3(model,true,table));
|
||||
return vascButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (vascButton==null) {
|
||||
return null;
|
||||
}
|
||||
return vascButton.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (vascButton==null) {
|
||||
return;
|
||||
}
|
||||
vascButton.setToolTipText(text);
|
||||
if (text==null) {
|
||||
vascButton.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
vascButton.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !vascButton.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
vascButton.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return vascButton.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
vascButton.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 25, 2007
|
||||
*/
|
||||
public class SwingColorChooser implements VascUIComponent {
|
||||
|
||||
private JButton colorButton = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
JButton colorButton = new JButton("Color");
|
||||
orgBackgroundColor = colorButton.getBackground();
|
||||
((JComponent)gui).add(colorButton);
|
||||
colorButton.addActionListener(new SelectActionListener3(model,true,table));
|
||||
return colorButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (colorButton==null) {
|
||||
return null;
|
||||
}
|
||||
return colorButton.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (colorButton==null) {
|
||||
return;
|
||||
}
|
||||
colorButton.setToolTipText(text);
|
||||
if (text==null) {
|
||||
colorButton.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
colorButton.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !colorButton.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
colorButton.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return colorButton.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
colorButton.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
class SelectActionListener3 implements ActionListener {
|
||||
|
||||
private VascValueModel model;
|
||||
private boolean hexEncoding = false;
|
||||
private VascEntry entry = null;
|
||||
public SelectActionListener3(VascValueModel model,boolean hexEncoding,VascEntry entry) {
|
||||
this.model=model;
|
||||
this.hexEncoding=hexEncoding;
|
||||
this.entry=entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (hexEncoding==false) {
|
||||
Color cur=null;
|
||||
try {
|
||||
cur = (Color)model.getValue();
|
||||
} catch (VascException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (cur==null) {
|
||||
cur = Color.YELLOW;
|
||||
}
|
||||
Color newColor = JColorChooser.showDialog(null,"Choose a color...",cur);
|
||||
try {
|
||||
model.setValue(newColor);
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee);
|
||||
}
|
||||
} else {
|
||||
String cur=null;
|
||||
try {
|
||||
cur = (String)model.getValue();
|
||||
} catch (VascException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
Color c = Color.YELLOW;
|
||||
try {
|
||||
if (cur!=null) {
|
||||
c = Color.decode(cur);
|
||||
}
|
||||
Color newColor = JColorChooser.showDialog(null,"Choose a color...",c);
|
||||
String newColorString = "#"+Integer.toHexString( newColor.getRGB() & 0x00ffffff );
|
||||
model.setValue(newColorString);
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
import com.michaelbaranov.microba.calendar.DatePicker;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 21, 2007
|
||||
*/
|
||||
public class SwingDate implements VascUIComponent {
|
||||
|
||||
private DatePicker datePicker = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
datePicker = new DatePicker();
|
||||
orgBackgroundColor = datePicker.getBackground();
|
||||
try {
|
||||
datePicker.setDate((Date)model.getValue());
|
||||
} catch (PropertyVetoException e) {
|
||||
throw new VascException(new VascException(e));
|
||||
}
|
||||
((JComponent)gui).add(datePicker);
|
||||
datePicker.addActionListener(new SelectActionListener2(model,table));
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (datePicker==null) {
|
||||
return null;
|
||||
}
|
||||
return datePicker.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (datePicker==null) {
|
||||
return;
|
||||
}
|
||||
datePicker.setToolTipText(text);
|
||||
if (text==null) {
|
||||
datePicker.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
datePicker.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !datePicker.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
datePicker.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return datePicker.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
datePicker.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
class SelectActionListener2 implements ActionListener {
|
||||
|
||||
private VascValueModel model;
|
||||
private VascEntry entry = null;
|
||||
public SelectActionListener2(VascValueModel model,VascEntry entry) {
|
||||
this.model=model;
|
||||
this.entry=entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Date value = ((DatePicker)e.getSource()).getDate();
|
||||
try {
|
||||
model.setValue(value);
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 21, 2008
|
||||
*/
|
||||
public class SwingLabel implements VascUIComponent {
|
||||
|
||||
private JLabel label = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
label = new JLabel();
|
||||
label.setHorizontalAlignment(JLabel.TRAILING);
|
||||
orgBackgroundColor = label.getBackground();
|
||||
label.setText(""+model.getValue());
|
||||
((JComponent)gui).add(label);
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (label==null) {
|
||||
return null;
|
||||
}
|
||||
return label.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (label==null) {
|
||||
return;
|
||||
}
|
||||
label.setToolTipText(text);
|
||||
if (text==null) {
|
||||
label.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
label.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !label.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
label.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return label.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
label.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItem;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 12, 2007
|
||||
*/
|
||||
public class SwingList implements VascUIComponent {
|
||||
|
||||
private JComboBox comboBox = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(final VascEntry entry,VascEntryField entryField,final VascValueModel model,Object gui) throws VascException {
|
||||
VascSelectItemModel items = (VascSelectItemModel)entryField.getVascEntryFieldType().getDataObject();
|
||||
if (items==null) {
|
||||
comboBox = new JComboBox();
|
||||
} else {
|
||||
comboBox = new JComboBox(items.getVascSelectItems(entry).toArray());
|
||||
}
|
||||
orgBackgroundColor = comboBox.getBackground();
|
||||
((JComponent)gui).add(comboBox);
|
||||
comboBox.setRenderer(new MyCellRenderer());
|
||||
comboBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
VascSelectItem i = (VascSelectItem)((JComboBox)e.getSource()).getSelectedItem();
|
||||
try {
|
||||
model.setValue(i.getValue());
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// set default !!
|
||||
if (model.getValue()!=null) {
|
||||
for (int i=0;i<comboBox.getModel().getSize();i++) {
|
||||
Object o = comboBox.getModel().getElementAt(i);
|
||||
VascSelectItem i2 = (VascSelectItem)o;
|
||||
if ( model.getValue().equals(i2.getValue()) ) {
|
||||
comboBox.setSelectedItem(i2);
|
||||
return comboBox;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (comboBox.getModel().getSize()>0) {
|
||||
// else select the top one.
|
||||
comboBox.setSelectedIndex(0);
|
||||
}
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (comboBox==null) {
|
||||
return null;
|
||||
}
|
||||
return comboBox.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (comboBox==null) {
|
||||
return;
|
||||
}
|
||||
comboBox.setToolTipText(text);
|
||||
if (text==null) {
|
||||
comboBox.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
comboBox.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !comboBox.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
comboBox.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return comboBox.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
comboBox.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
|
||||
class MyCellRenderer extends JLabel implements ListCellRenderer {
|
||||
|
||||
private static final long serialVersionUID = 10L;
|
||||
|
||||
public MyCellRenderer() {
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) {
|
||||
VascSelectItem i = (VascSelectItem)value;
|
||||
if (i!=null) {
|
||||
setText(i.getLabel());
|
||||
} else {
|
||||
setText("Error");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 12, 2007
|
||||
*/
|
||||
public class SwingText implements VascUIComponent {
|
||||
|
||||
private JTextField textField = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
textField = new JTextField();
|
||||
orgBackgroundColor = textField.getBackground();
|
||||
textField.setText(""+model.getValue());
|
||||
((JComponent)gui).add(textField);
|
||||
textField.getDocument().addDocumentListener(new TextListener(model,table,this));
|
||||
return textField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (textField==null) {
|
||||
return null;
|
||||
}
|
||||
return textField.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (textField==null) {
|
||||
return;
|
||||
}
|
||||
textField.setToolTipText(text);
|
||||
if (text==null) {
|
||||
textField.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
textField.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !textField.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
textField.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return textField.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
textField.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
|
||||
class TextListener implements DocumentListener {
|
||||
|
||||
private VascValueModel model = null;
|
||||
//private VascTable table = null;
|
||||
private SwingText textField = null;
|
||||
|
||||
public TextListener(VascValueModel model,VascEntry table,SwingText textField) {
|
||||
this.model=model;
|
||||
//this.table=table;
|
||||
this.textField=textField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
public void update(DocumentEvent event) {
|
||||
try {
|
||||
String value = event.getDocument().getText(0, event.getDocument().getLength());
|
||||
model.setValue(value);
|
||||
textField.setErrorText(null);
|
||||
} catch (Exception ee) {
|
||||
textField.setErrorText(ee.getLocalizedMessage());
|
||||
//table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 21, 2008
|
||||
*/
|
||||
public class SwingTextArea implements VascUIComponent {
|
||||
|
||||
private JTextArea textArea = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
public Object createComponent(VascEntry entry,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
textArea = new JTextArea();
|
||||
textArea.setBorder(BorderFactory.createEtchedBorder());
|
||||
textArea.setRows(8);
|
||||
|
||||
//entryField.getVascEntryFieldType().getProperty(name)
|
||||
|
||||
//textArea.setRows(rows);
|
||||
//textArea.setColumns(columns);
|
||||
|
||||
orgBackgroundColor = textArea.getBackground();
|
||||
textArea.setText(""+model.getValue());
|
||||
((JComponent)gui).add(textArea);
|
||||
textArea.getDocument().addDocumentListener(new TextAreaListener(model,entry,this));
|
||||
return textArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (textArea==null) {
|
||||
return null;
|
||||
}
|
||||
return textArea.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (textArea==null) {
|
||||
return;
|
||||
}
|
||||
textArea.setToolTipText(text);
|
||||
if (text==null) {
|
||||
textArea.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
textArea.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return !textArea.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
textArea.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
return textArea.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
textArea.setVisible(rendered);
|
||||
}
|
||||
}
|
||||
|
||||
class TextAreaListener implements DocumentListener {
|
||||
|
||||
private VascValueModel model = null;
|
||||
private SwingTextArea textArea = null;
|
||||
|
||||
public TextAreaListener(VascValueModel model,VascEntry entry,SwingTextArea textArea) {
|
||||
this.model=model;
|
||||
this.textArea=textArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
public void update(DocumentEvent event) {
|
||||
try {
|
||||
String value = event.getDocument().getText(0, event.getDocument().getLength());
|
||||
model.setValue(value);
|
||||
textArea.setErrorText(null);
|
||||
} catch (Exception ee) {
|
||||
textArea.setErrorText(ee.getLocalizedMessage());
|
||||
//table.getVascTableController().handleException(ee, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingVascFrontend;
|
||||
|
||||
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests a simple x4o xml language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class SwingTest extends TestCase {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
// enable all logs
|
||||
//InputStream loggingProperties = this.getClass().getResourceAsStream("META-INF/logging.properties");
|
||||
//LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||
//loggingProperties.close();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public void testNull() throws Exception {
|
||||
assertEquals(true, true);
|
||||
//main(new String[] {});
|
||||
}
|
||||
|
||||
public static void main(String[] argu){
|
||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
||||
try {
|
||||
VascEntry entry = TestTable.getVascTable();
|
||||
|
||||
SwingTest s = new SwingTest();
|
||||
JFrame frame = s.viewEntry(entry);
|
||||
|
||||
while (frame.isVisible()) {
|
||||
Thread.sleep(100000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public JFrame viewEntry(final VascEntry entry) throws Exception {
|
||||
// get GUI
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Test - Swing - "+entry.getName());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Vasc Entries");
|
||||
|
||||
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id);
|
||||
TestTable.fill(ee,entry.getVascFrontendData().getVascController());
|
||||
viewEntry(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
|
||||
// define redering
|
||||
JPanel panel = new JPanel();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel);
|
||||
frame.add(panel);
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
||||
|
||||
// view
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
|
||||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package 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;
|
||||
|
||||
|
||||
//import org.hibernate.validator.NotNull;
|
||||
//import org.hibernate.validator.Max;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package 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(2288L,"idca.nl","user","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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<x4o:root xmlns:v="http://vasc.idcanet.com/eld/vasc-lang.eld"
|
||||
xmlns:x4o="http://eld.x4o.org/eld/x4o-lang.eld"
|
||||
>
|
||||
<!--
|
||||
<v:simpleJdbcConnectionProvider
|
||||
el.id="dbDatafeeds"
|
||||
driverClassName="org.postgresql.Driver"
|
||||
dbUrl="jdbc:postgresql://db0.dev.lan.mbuyu.nl/datafeeds_dev"
|
||||
dbUser="mbuyu"
|
||||
dbPassword="eephoh2O"
|
||||
/>
|
||||
<v:jdbcBackend
|
||||
id="dbStreams"
|
||||
jdbcConnectionProvider="${dbDatafeeds}"
|
||||
idColumnName="id"
|
||||
sqlList="SELECT * FROM stream LIMIT 100"
|
||||
sqlDelete="DELETE FROM stream WHERE id = ?0"
|
||||
sqlPersist="INSERT INTO stream (name,url,importing,etc) VALUES (?0,?1,?2,?3,?4)"
|
||||
sqlMerge="UPDATE stream (name,url) VALUE (?0,?1)"
|
||||
/>
|
||||
|
||||
<v:entry id="streams" backendId="dbStreams">
|
||||
<v:field id="id" readOnly="true"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="url"/>
|
||||
<v:field id="importing" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="last_parsed" vascEntryFieldType="DateField" />
|
||||
<v:field id="last_checked" vascEntryFieldType="DateField"/>
|
||||
|
||||
<v:field id="parser_locale" list="false"/>
|
||||
<v:field id="column_mapping" list="false"/>
|
||||
</v:entry>
|
||||
|
||||
|
||||
|
||||
<v:simpleLdapConnectionProvider
|
||||
el.id="ldapSudoers"
|
||||
ldapHost="ldap2.lan.mbuyu.nl"
|
||||
bindUser="uid=admin-sudo,ou=services,dc=m4n,dc=nl"
|
||||
bindPass="adminSudo"
|
||||
/>
|
||||
<v:ldapBackend
|
||||
id="ldapBackendSudoers"
|
||||
ldapConnectionProvider="${ldapSudoers}"
|
||||
baseDN="ou=sudoers,dc=m4n,dc=nl"
|
||||
keyAttribute="cn"
|
||||
ldapFilter="(&(objectClass=sudoRole))"
|
||||
/>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<v:entry id="sudoers" backendId="ldapBackendSudoers">
|
||||
<v:field id="user" backendName="cn" readOnly="true"/>
|
||||
<v:field id="description" rolesEdit="admin" rolesList="all"/>
|
||||
<v:field id="sudoCommand" vascEntryFieldType="MultiTextField"/>
|
||||
<v:field id="sudoHost" vascEntryFieldType="MultiTextField"/>
|
||||
<v:field id="sudoUser" vascEntryFieldType="MultiTextField"/>
|
||||
|
||||
|
||||
<v:ldapNextIdFunction name="nextUidNumber" ldapFilter="(&(objectClass=posixGroup))" ldapAttribute="gidnumber"/>
|
||||
|
||||
<v:listeners hook="post_create">
|
||||
<etc:loginToFtpServer/>
|
||||
</v:listeners>
|
||||
|
||||
<v:link fieldName="user" viewController="ldapUsers" parameterName="user_cn"/>
|
||||
<v:link fieldName="gidNumber" viewController="ldapGroups" parameterName="group_key,${baseDn}"/>
|
||||
|
||||
<v:detail fieldName="gidNumber" detailController="${ldapGroups}"/>
|
||||
</v:entry>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<v:simpleLdapConnectionProvider
|
||||
el.id="ldapUsers"
|
||||
ldapHost="ldap2.lan.mbuyu.nl"
|
||||
bindUser="uid=admin-users,ou=services,dc=m4n,dc=nl"
|
||||
bindPass="superAU"
|
||||
/>
|
||||
<v:ldapBackend
|
||||
id="ldapBackendUsers"
|
||||
ldapConnectionProvider="${ldapUsers}"
|
||||
baseDN="ou=users,dc=m4n,dc=nl"
|
||||
keyAttribute="uid"
|
||||
ldapFilter="(&(objectClass=posixAccount))"
|
||||
/>
|
||||
<v:entry id="users" backendId="ldapBackendUsers">
|
||||
<v:field id="uid" />
|
||||
<v:field id="uidNumber" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="gidNumber" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="loginShell" list="false"/>
|
||||
<v:field id="homeDirectory" list="false"/>
|
||||
<v:field id="cn" list="false"/>
|
||||
<v:field id="givenName" />
|
||||
<v:field id="sn" />
|
||||
<v:field id="mailbox" list="false"/>
|
||||
<v:field id="mail" vascEntryFieldType="EmailField"/>
|
||||
<v:field id="mailActive" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="alias" vascEntryFieldType="MultiTextField" list="false"/>
|
||||
|
||||
<v:field id="autoResponseActive" vascEntryFieldType="BooleanField" />
|
||||
<v:field id="autoresponseMessage" vascEntryFieldType="TextAreaField" list="false"/>
|
||||
<v:field id="sambaAcctFlags" list="false"/>
|
||||
<v:field id="sambaPrimaryGroupSID" list="false"/>
|
||||
<v:field id="sambaSID" list="false"/>
|
||||
|
||||
<v:field id="m4nVPNActive" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="m4nDateInService" />
|
||||
<v:field id="m4nDateOutService" />
|
||||
<v:field id="m4nUserId" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="m4nHosts" vascEntryFieldType="MultiTextField"/>
|
||||
</v:entry>
|
||||
|
||||
|
||||
<v:simpleLdapConnectionProvider
|
||||
el.id="ldapMachines"
|
||||
ldapHost="ldap2.lan.mbuyu.nl"
|
||||
bindUser="uid=samba,ou=services,dc=m4n,dc=nl"
|
||||
bindPass="superS"
|
||||
/>
|
||||
<v:ldapBackend
|
||||
id="ldapBackendMachines"
|
||||
ldapConnectionProvider="${ldapMachines}"
|
||||
baseDN="ou=machines,dc=m4n,dc=nl"
|
||||
keyAttribute="uid"
|
||||
ldapFilter="(&(objectClass=sambaSamAccount))"
|
||||
/>
|
||||
<v:entry id="machines" backendId="ldapBackendMachines">
|
||||
<v:field id="uid" />
|
||||
<v:field id="sambaAcctFlags"/>
|
||||
<v:field id="sambaSID" />
|
||||
<v:field id="uidNumber" />
|
||||
</v:entry>
|
||||
-->
|
||||
|
||||
|
||||
<v:entry id="test1" backendId="testBackend1">
|
||||
<v:field id="name" defaultValue=""/>
|
||||
<v:field id="description" vascEntryFieldType="EmailField" defaultValue="email@address.nl"/>
|
||||
<v:field id="active" defaultValue="true"/>
|
||||
<v:field id="date" vascEntryFieldType="DateField" defaultValue=""/>
|
||||
<v:field id="hexColor" vascEntryFieldType="ColorField" defaultValue="#FF3355"/>
|
||||
<v:field id="testModel" vascEntryFieldType="ListField" dataObject="$myBean.testBackend1"
|
||||
vascEntryFieldType.dataObject="#{vascController.vascBackendControllerResolver.vascBackendController.vascBackendById('testBackend1')}"
|
||||
/>
|
||||
</v:entry>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
- View
|
||||
- States
|
||||
- Tables
|
||||
- Columns
|
||||
|
||||
|
||||
|
||||
Master
|
||||
- Details
|
||||
|
||||
-->
|
||||
<!--
|
||||
<x4o:bean el.id="dataSource" bean.class="com.id.."/>
|
||||
<x4o:bean el.id="tableController" bean.class="com.id.."/>
|
||||
|
||||
|
||||
<v:vascView name="test1">
|
||||
<v:vascTableController>
|
||||
</v:vascTableController>
|
||||
<v:vascBackendController>
|
||||
<v:vascJDBCQueryController>
|
||||
<x4o:property name="list">select id,name,blog_status_id,description,slug from blog_post</x4o:property>
|
||||
<x4o:property name="update">update (id,name,blog_status_id,description,slug) values(?,?,?,?,?) from blog_post where id=?</x4o:property>
|
||||
<x4o:property name="create">instert into (id,name,blog_status_id,description,slug) values(?,?,?,?,?) from blog_post where id=?</x4o:property>
|
||||
<x4o:property name="delete">delete from blog_post where id=?</x4o:property>
|
||||
</v:vascJDBCQueryController>
|
||||
</v:vascBackendController>
|
||||
|
||||
<v:vascField name="">
|
||||
<v:vascFieldOptions/>
|
||||
<v:vascFieldChoises/>
|
||||
</v:vascField>
|
||||
<v:vascField name="">
|
||||
<v:vascUserRoles list="admin"/>
|
||||
</v:vascField>
|
||||
|
||||
</v:vascView>
|
||||
|
||||
<x4o:template el.id="ldapServerTemplate">
|
||||
<v:ldapConnection name="main">
|
||||
<x4o:property name="connectionUrl" value="ldaps://ldap.office.mbuyu.nl"/>
|
||||
</v:ldapConnection>
|
||||
</x4o:template>
|
||||
|
||||
<v:ldapConnection el.id="sudoers" x4o.templates="ldapServerTemplate">
|
||||
<x4o:property name="user" value="uid=admin-sudo,ou=services,dc=m4n,dc=nl"/>
|
||||
<x4o:property name="pass" value="adminSudo"/>
|
||||
<x4o:property name="baseDn" value="ou=sudoers,dc=m4n,dc=nl"/>
|
||||
</v:ldapConnection>
|
||||
|
||||
<x4o:template el.id="sudoTemplate">
|
||||
<v:field name="user" backendName="cn" readOnly="true"/>
|
||||
<v:field name="description" backendName="description"/>
|
||||
<v:field name="sudoCommand" fieldEditor="listField"/>
|
||||
<v:field name="sudoHost" fieldEditor="listField"/>
|
||||
<v:field name="sudoUser" fieldEditor="listField"/>
|
||||
</x4o:template>
|
||||
|
||||
<x4o:template el.id="sambaUserSchema">
|
||||
<v:field name="sambaSID" fieldEditor="textField" edit="false" list="false" view="false" create="false" defaultValue="S-1-5-21-1200182392-965607725-1867741125-514"/>
|
||||
<v:field name="sambaGroupType" v.defaultValue="2"/>
|
||||
</x4o:template>
|
||||
|
||||
<v:viewController name="ldapUsers" primaryKey="user">
|
||||
<x4o:templateTag template="${posixUserSchema}"/>
|
||||
<x4o:templateTag template="${sambaUserSchema}">
|
||||
<v:field name="sambaGroupType" v.defaultValue="3"/>
|
||||
</x4o:templateTag>
|
||||
<v:field name="sambaGroupType" v.defaultValue="4"/>
|
||||
</v:viewController>
|
||||
|
||||
<vasc:fieldType name="EmailField2">
|
||||
<vasc:fieldHint key="validate" default="true"/>
|
||||
<vasc:fieldHint key="timeout" default="200"/>
|
||||
</vasc:fieldType>
|
||||
|
||||
<vasc:fieldType name="listField">
|
||||
<vasc:fieldHint key="validate" default="true"/>
|
||||
<vasc:fieldHint key="timeout" default="200"/>
|
||||
</vasc:fieldType>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<v:entry id="test2" backendId="testBackend1">
|
||||
<v:field id="name"/>
|
||||
<v:field id="description"/>
|
||||
<v:field id="active"/>
|
||||
<v:field id="testModel" vascEntryFieldType="ListField"/>
|
||||
</v:entry>
|
||||
|
||||
<v:entry
|
||||
id="test3"
|
||||
helpId="someHelpKey"
|
||||
image="imsdf"
|
||||
|
||||
headerName="sdf"
|
||||
headerDescription="sdfsdf"
|
||||
headerImage="sdfsdfsd"
|
||||
|
||||
primaryKeyFieldId="name"
|
||||
displayNameFieldId="name"
|
||||
|
||||
vascDisplayOnly="false"
|
||||
vascAdminList="true"
|
||||
vascAdminEdit="true"
|
||||
vascAdminCreate="true"
|
||||
vascAdminDelete="true"
|
||||
|
||||
backendId="testBackend1"
|
||||
>
|
||||
<v:field id="name"/>
|
||||
<v:field
|
||||
id="active"
|
||||
backendName="active"
|
||||
name="active"
|
||||
description="active"
|
||||
helpId="active"
|
||||
image="active"
|
||||
|
||||
defaultValue="true"
|
||||
|
||||
sizeList="100"
|
||||
sizeEdit="80"
|
||||
styleList="styleClass"
|
||||
styleEdit="styleClass"
|
||||
|
||||
choices=""
|
||||
choicesAsRadio="false"
|
||||
view="true"
|
||||
optional="false"
|
||||
|
||||
create="true"
|
||||
edit="true"
|
||||
editReadOnly="false"
|
||||
editBlank="false"
|
||||
list="true"
|
||||
|
||||
rolesCreate="admin|manager"
|
||||
rolesEdit=""
|
||||
rolesEditReadOnly=""
|
||||
rolesList=""
|
||||
|
||||
vascEntryFieldType=""
|
||||
vascEntryFieldEventChannel=""
|
||||
>
|
||||
<v:intSizeValidator min="20"/>
|
||||
</v:field>
|
||||
|
||||
<v:fieldSet
|
||||
id="set1"
|
||||
vascEntryFieldIds="name,active"
|
||||
|
||||
name="set1"
|
||||
description="set1"
|
||||
helpId="set1"
|
||||
image="set1"
|
||||
|
||||
styleList="styleClass"
|
||||
styleEdit="styleClass"
|
||||
|
||||
collapsed="false"
|
||||
optional="false"
|
||||
/>
|
||||
</v:entry>
|
||||
|
||||
</x4o:root>
|
||||
Loading…
Add table
Add a link
Reference in a new issue