io.github.warnotte.obj2gui2.Plugins.tests.mainPluginTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of obj2gui2 Show documentation
Show all versions of obj2gui2 Show documentation
This library aimed to generated swing interface base on introspection and annotation of DTOs
/**
*
*/
package io.github.warnotte.obj2gui2.Plugins.tests;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import io.github.warnotte.obj2gui2.Binding;
import io.github.warnotte.obj2gui2.BindingEnum;
import io.github.warnotte.obj2gui2.JPanelMagique;
import io.github.warnotte.obj2gui2.Tests.Complex.A;
import io.github.warnotte.obj2gui2.Tests.Complex.B;
import io.github.warnotte.obj2gui2.Tests.Complex.cards;
import io.github.warnotte.obj2gui2.Tests.SimpleType.Material;
/**
* @author Warnotte Renaud
*
*/
public class mainPluginTest
{
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
final A a = new A();
List tps = new ArrayList<>();
tps.add(a);
// Pour la classe A on a besoin d'avoir une liste de reference...
List list_mats = new ArrayList();
list_mats.add(new Material(1, "SteelA"));
list_mats.add(new Material(5, "SteelB"));
list_mats.add(new Material(8, "SteelC"));
list_mats.add(new Material(9, "SteelD"));
list_mats.add(new Material(11, "SteelE"));
//JideDateExcomboboxPlug plugin1 = new JideDateExcomboboxPlug(manager);
//JideDateChooserPlug2 plugin2 = new JideDateChooserPlug2(manager);
io.github.warnotte.obj2gui2.Plugins.tests.JTextAreaFieldPlug plugin3 = new io.github.warnotte.obj2gui2.Plugins.tests.JTextAreaFieldPlug();
//GuiGenerator.Plugins.tests.Vector2DPlugin plugin4 = new GuiGenerator.Plugins.tests.Vector2DPlugin();
//JPanelMagique.registerPlugin(plugin2);
JPanelMagique.registerPlugin(plugin3);
//JPanelMagique.registerPlugin(plugin4);
//JPanelMagique.registerPlugin(plugin1);
// This will help OBJ2GUI to assign an Object (from a list of Identifiable) to the value.
final ArrayList binds = new ArrayList();
binds.add(new Binding(list_mats, B.class, "material_id"));
// This will help OBJ2GUI to assign an enumeration value to a "long" or "int" ordinal value setted in a variable.
final ArrayList bindsEnum = new ArrayList();
BindingEnum bindE = new BindingEnum(cards.values(), B.class, "Id_card_reference");
bindE.setIndexoffset(0);
bindsEnum.add(bindE);
JPanelMagique jp = JPanelMagique.GenerateJPanelFromSelectionAndBindings(tps, binds, bindsEnum);
JFrame frame = JPanelMagique.embbedInFrame(jp);
frame.setVisible(true);
JButton button = new JButton("DEBUG");
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0)
{
System.err.println(""+a);
}
});
frame.add(button, BorderLayout.SOUTH);
}
}