Permalink
Browse files

projector sample

  • Loading branch information...
hendrikebbers committed Apr 6, 2018
1 parent ebea3fa commit f0df41407c6cf504c0a77d86439801559ef47203
Showing with 346 additions and 171 deletions.
  1. +2 −3 ....java → platform-examples/projector-sample/projector-sample-client/projector-sample-client.gradle
  2. +36 −0 ...le/projector-sample-client/src/main/java/com/canoo/projection/sample/client/ProjectionClient.java
  3. +4 −21 ....java → platform-examples/projector-sample/projector-sample-server/projector-sample-server.gradle
  4. +15 −0 ...le/projector-sample-server/src/main/java/com/canoo/projection/sample/server/ProjectionServer.java
  5. +109 −0 ...mple-server/src/main/java/com/canoo/projection/sample/server/controller/SimpleFormController.java
  6. +48 −0 ...or-sample/projector-sample-server/src/main/java/com/canoo/projection/sample/server/data/User.java
  7. +55 −0 ...le/projector-sample-server/src/main/java/com/canoo/projection/sample/server/data/UserService.java
  8. +0 −91 ...tform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/gantt/ActivityBean.java
  9. +0 −46 ...n-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/gantt/RowBean.java
  10. +44 −7 ...server/src/main/java/com/canoo/dp/impl/platform/projector/server/projection/FormFieldBuilder.java
  11. +27 −0 ...jector-server/src/main/java/com/canoo/dp/impl/platform/projector/server/update/UpdateHandler.java
  12. +1 −2 ...m-remoting-common/src/main/java/com/canoo/dp/impl/remoting/converters}/ClassConverterFactory.java
  13. +2 −1 ...n/src/main/resources/META-INF/services/com.canoo.platform.remoting.spi.converter.ConverterFactory
  14. +3 −0 settings.gradle
@@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.canoo.dp.impl.platform.projector.gantt;
public enum BarType {
BASE, PARENT;
dependencies {
compile project(':dolphin-platform-projector-client')
}
@@ -0,0 +1,36 @@
package com.canoo.projection.sample.client;
import com.canoo.dp.impl.platform.projector.client.base.ClientActionSupport;
import com.canoo.dp.impl.platform.projector.client.base.DefaultClientActionSupport;
import com.canoo.dp.impl.platform.projector.client.projection.Projector;
import com.canoo.platform.remoting.client.ClientContext;
import com.canoo.platform.remoting.client.javafx.DolphinPlatformApplication;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.net.MalformedURLException;
import java.net.URL;
public class ProjectionClient extends DolphinPlatformApplication {
@Override
protected URL getServerEndpoint() throws MalformedURLException {
return new URL("http://localhost:8080/dolphin");
}
@Override
protected void start(final Stage primaryStage, final ClientContext clientContext) throws Exception {
ClientActionSupport actionSupport = new DefaultClientActionSupport();
Projector projector = new Projector(clientContext, actionSupport);
projector.create("SimpleFormController").handle((p, e) -> {
if(e != null) {
e.printStackTrace();
}
if(p != null) {
Platform.runLater(() -> primaryStage.setScene(new Scene(p)));
primaryStage.show();
}
return null;
});
}
}
@@ -13,26 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.canoo.dp.impl.platform.projector.gantt;
import com.canoo.dp.impl.platform.projector.base.AbstractProjectableBean;
import com.canoo.platform.remoting.Property;
import com.canoo.platform.remoting.RemotingBean;
@RemotingBean
public class GanttBean extends AbstractProjectableBean {
private Property<RowBean> root;
public Property<RowBean> rootProperty() {
return root;
}
public RowBean getRoot() {
return rootProperty().get();
}
public void setRoot(RowBean root) {
rootProperty().set(root);
}
dependencies {
compile project(':dolphin-platform-projector-server')
compile project(':dolphin-platform-data')
compile project(':dolphin-platform-remoting-server-spring')
}
@@ -0,0 +1,15 @@
package com.canoo.projection.sample.server;
import com.canoo.platform.remoting.server.spring.EnableRemoting;
import com.canoo.platform.server.spring.DolphinPlatformApplication;
import org.springframework.boot.SpringApplication;
@DolphinPlatformApplication
@EnableRemoting
public class ProjectionServer {
public static void main(String[] args) {
SpringApplication.run(ProjectionServer.class);
}
}
@@ -0,0 +1,109 @@
package com.canoo.projection.sample.server.controller;
import com.canoo.dp.impl.platform.projector.action.DefaultServerActionBean;
import com.canoo.dp.impl.platform.projector.base.ViewBean;
import com.canoo.dp.impl.platform.projector.form.Form;
import com.canoo.dp.impl.platform.projector.form.FormField;
import com.canoo.dp.impl.platform.projector.form.FormSection;
import com.canoo.dp.impl.platform.projector.server.projection.FormBuilder;
import com.canoo.dp.impl.platform.projector.server.projection.FormFieldBuilder;
import com.canoo.dp.impl.platform.projector.server.projection.FormSectionBuilder;
import com.canoo.dp.impl.platform.projector.server.update.UpdateHandler;
import com.canoo.platform.remoting.BeanManager;
import com.canoo.platform.remoting.server.RemotingAction;
import com.canoo.platform.remoting.server.RemotingController;
import com.canoo.platform.remoting.server.RemotingModel;
import com.canoo.projection.sample.server.data.User;
import com.canoo.projection.sample.server.data.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PostConstruct;
@RemotingController("SimpleFormController")
public class SimpleFormController {
@RemotingModel
private ViewBean model;
@Autowired
private BeanManager beanManager;
@Autowired
private UserService service;
private User user;
private final UpdateHandler<User> updateHandler = new UpdateHandler<>();
@PostConstruct
public void init() {
user = service.createNewInstance();
final DefaultServerActionBean saveAction = beanManager.create(DefaultServerActionBean.class);
saveAction.setTitle("save");
saveAction.setDescription("saves the user");
saveAction.setBlockUi(true);
saveAction.setActionName("save");
final DefaultServerActionBean resetAction = beanManager.create(DefaultServerActionBean.class);
resetAction.setTitle("reset");
resetAction.setDescription("resets the user");
resetAction.setBlockUi(true);
resetAction.setActionName("reset");
final FormField IdField = FormFieldBuilder.createStringField(beanManager)
.withTitle("Id")
.withDescription("The id of the user")
.withEditableFlag(false)
.withDisabledFlag(true)
.withUpdateHandler(updateHandler, u -> u.getId(), v -> user.setId(v))
.build();
final FormField firstNameField = FormFieldBuilder.createStringField(beanManager)
.withTitle("first name")
.withDescription("The first name of the user")
.withUpdateHandler(updateHandler, u -> u.getFirstName(), v -> user.setFirstName(v))
.build();
final FormField lastNameField = FormFieldBuilder.createStringField(beanManager)
.withTitle("last name")
.withDescription("The last name of the user")
.withUpdateHandler(updateHandler, u -> u.getLastName(), v -> user.setLastName(v))
.build();
final FormField activeField = FormFieldBuilder.createBooleanField(beanManager)
.withTitle("active")
.withDescription("Defines is the user is active")
.withUpdateHandler(updateHandler, u -> u.isActive(), v -> user.setActive(v))
.build();
final FormSection section = FormSectionBuilder.create(beanManager)
.withField(IdField)
.withField(firstNameField)
.withField(lastNameField)
.withField(activeField)
.build();
final Form formBean = FormBuilder.create(beanManager)
.withTitle("User Detail View")
.withDescription("The detail information of a user")
.withAction(saveAction)
.withAction(resetAction)
.withSection(section)
.build();
model.getContent().addAll(formBean);
}
@RemotingAction
public void save() {
user = service.save(user);
updateHandler.update(user);
}
@RemotingAction
public void reset() {
user = service.reset(user);
updateHandler.update(user);
}
}
@@ -0,0 +1,48 @@
package com.canoo.projection.sample.server.data;
import com.canoo.dp.impl.platform.data.EntityWithId;
public class User implements EntityWithId<String> {
private String id;
private String firstName;
private String lastName;
private boolean active;
public String getFirstName() {
return firstName;
}
public void setFirstName(final String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(final String lastName) {
this.lastName = lastName;
}
public boolean isActive() {
return active;
}
public void setActive(final boolean active) {
this.active = active;
}
@Override
public String getId() {
return id;
}
@Override
public void setId(final String id) {
this.id = id;
}
}
@@ -0,0 +1,55 @@
package com.canoo.projection.sample.server.data;
import com.canoo.dp.impl.platform.data.CrudService;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Service
public class UserService implements CrudService<String, User> {
@Override
public User createNewInstance() {
return new User();
}
@Override
public List<User> findAll() {
return Collections.emptyList();
}
@Override
public User findById(final String s) {
return null;
}
@Override
public Optional<User> byId(final String s) {
return Optional.empty();
}
@Override
public Class<User> getDataClass() {
return User.class;
}
@Override
public User reset(final User entity) {
entity.setActive(false);
entity.setLastName(null);
entity.setFirstName(null);
return entity;
}
@Override
public User save(final User toSave) {
toSave.setId(UUID.randomUUID().toString());
return toSave;
}
@Override
public void delete(final User toDelete) {}
}
Oops, something went wrong.

0 comments on commit f0df414

Please sign in to comment.