eu.agrosense.client.worker.NewWorkerView Maven / Gradle / Ivy
/**
* Copyright (C) 2008-2013 LimeTri. All rights reserved.
*
* AgroSense is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* There are special exceptions to the terms and conditions of the GPLv3 as it
* is applied to this software, see the FLOSS License Exception
* .
*
* AgroSense is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* AgroSense. If not, see .
*/
package eu.agrosense.client.worker;
import eu.agrosense.api.style.StyleManager;
import eu.agrosense.client.model.Model;
import static eu.agrosense.client.util.javafx.CrudPanel.SCENE_HEIGHT;
import static eu.agrosense.client.util.javafx.CrudPanel.SCENE_WIDTH;
import eu.agrosense.client.util.javafx.FieldSets;
import eu.agrosense.shared.model.Worker;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javax.swing.JPanel;
import org.apache.commons.lang.Validate;
import org.opendolphin.binding.JFXBinder;
import org.opendolphin.core.PresentationModel;
import org.openide.util.NbBundle;
import org.tbee.javafx.scene.layout.MigPane;
/**
*
* @author johan
*/
@NbBundle.Messages({
"new worker view label name=Name:",})
public class NewWorkerView extends JPanel {
private final JFXPanel fxPanel;
private static final int SCENE_WIDTH = 300;
private static final int SCENE_HEIGHT = 300;
public NewWorkerView(PresentationModel model) {
Validate.notNull(model);
setLayout(new BorderLayout());
fxPanel = new JFXPanel();
//Scene dimensions not used by Dialog as it is created later, set on fxPanel as well:
fxPanel.setPreferredSize(new Dimension(SCENE_WIDTH, SCENE_HEIGHT));
Platform.setImplicitExit(false);
// create JavaFX scene
Platform.runLater(new SceneInitializer(model));
add(fxPanel, BorderLayout.CENTER);
}
private class SceneInitializer implements Runnable {
private final PresentationModel model;
public SceneInitializer(PresentationModel model) {
this.model = model;
}
@Override
public void run() {
MigPane root = new MigPane("wrap 2");
//
// adding name label and field
//
Label nameLabel = new Label(Bundle.new_worker_view_label_name());
root.add(nameLabel);
TextField nameField = new TextField();
nameField.setPrefWidth(150.0d);
root.add(nameField);
JFXBinder.bind("text").of(nameField).to(Worker.PROP_NAME).of(Model.withAt(model, Worker.PROP_NAME));
FieldSets.addNaturalPersonFieldSet(root, model);
FieldSets.addAddressFieldSet(root, model);
Scene scene = new Scene(root, SCENE_WIDTH, SCENE_HEIGHT);
StyleManager.Default.applyFormStyle(scene);
fxPanel.setScene(scene);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy