Permalink
Browse files

Updating to the new form handling code from Helium.

  • Loading branch information...
1 parent e91b591 commit 4870ba985e6607faa5b2d44a98c12b34f14ad6f4 @zyxist committed May 8, 2012
@@ -53,7 +53,7 @@ public void initializePresenters() throws PresenterConfigurationException {
public void createWelcomeScreen() throws PresenterConfigurationException {
CardPresenter cardPresenter = this.app.getLifecycleManager().getPresenter(CardPresenter.class);
- for(int i = 0; i < 20; i++) {
+ for(int i = 0; i < 3; i++) {
cardPresenter.createCard(this.app.getLifecycleManager().getPresenter(WelcomePresenter.class, "id"+Integer.toString(i)));
}
} // end createWelcomeScreen();
@@ -18,13 +18,17 @@
package org.invenzzia.opentrans.client.presenter.project;
import java.awt.Component;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.invenzzia.helium.application.Application;
+import org.invenzzia.helium.forms.DefinitionManager;
+import org.invenzzia.helium.forms.Form;
+import org.invenzzia.helium.forms.IFormFactory;
+import org.invenzzia.helium.forms.exception.FormException;
import org.invenzzia.helium.gui.BaseLeafPresenter;
import org.invenzzia.helium.gui.LifecycleManager;
import org.invenzzia.helium.gui.annotations.Dialog;
import org.invenzzia.helium.gui.exception.PresenterConfigurationException;
-import org.invenzzia.helium.gui.forms.Form;
import org.invenzzia.helium.gui.presenter.dialog.DialogPresenter;
import org.invenzzia.helium.gui.presenter.dialog.IDialogPresenter;
import org.invenzzia.opentrans.visitons.VisitonsProject;
@@ -41,21 +45,23 @@
)
public class ProjectPresenter extends BaseLeafPresenter implements IDialogPresenter {
private JPanel view;
+ private Form form;
public ProjectPresenter(Application application, LifecycleManager manager, String name) throws PresenterConfigurationException {
super(application, manager, name);
} // end ProjectPresenter();
@Override
protected boolean doStartup() {
- Form form = this.application.getContainer().as(Characteristics.NO_CACHE).getComponent(Form.class);
-
- VisitonsProject project = new VisitonsProject();
- form.setBean(project);
try {
- this.view = form.render();
+ this.form = this.application.getContainer().getComponent(IFormFactory.class).createForm("forms/NewProjectForm.xml");
+
+ VisitonsProject project = new VisitonsProject();
+ this.form.setBean(project);
+ this.view = this.form.render();
return true;
- } catch(Exception exception) {
+ } catch(FormException exception) {
+ JOptionPane.showMessageDialog(null, exception.getMessage());
return false;
}
}
@@ -66,7 +72,14 @@ protected boolean doShutdown() {
}
@Override
- public void confirm() {
+ public boolean confirm() {
+ if(this.form.validate()) {
+ this.form.populate();
+ return true;
+ } else {
+ this.form.refresh(this.view);
+ return false;
+ }
}
@Override
@@ -0,0 +1,31 @@
+<?xml version="1.0" ?>
+<definition>
+ <heading>New project</heading>
+ <groups>
+ <group>
+ <fields>
+ <field>
+ <name>Project name</name>
+ <property>name</property>
+ </field>
+ <field>
+ <name>Author</name>
+ <property>author</property>
+ <toolTip>Your name and surname</toolTip>
+ <floating>LEFT</floating>
+ </field>
+ <field>
+ <name>Website</name>
+ <property>website</property>
+ <toolTip>The website of the simulation or your personal website</toolTip>
+ <floating>RIGHT</floating>
+ </field>
+ <field>
+ <name>Notes</name>
+ <property>notes</property>
+ <toolTip>Extra information about this project</toolTip>
+ </field>
+ </fields>
+ </group>
+ </groups>
+</definition>
View
@@ -61,6 +61,11 @@
</dependency>
<dependency>
<groupId>org.invenzzia</groupId>
+ <artifactId>helium-forms</artifactId>
+ <version>${helium.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.invenzzia</groupId>
<artifactId>helium-gui</artifactId>
<version>${helium.version}</version>
</dependency>

0 comments on commit 4870ba9

Please sign in to comment.