Skip to content
Permalink
Browse files

Merge pull request #900 from canoo/projector-model

Some refactorings of the projector model
  • Loading branch information...
hendrikebbers committed Apr 17, 2018
2 parents c0f6dc2 + f0df414 commit d399d2a056700254869d8df9101d776093f25109
Showing with 471 additions and 313 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. +21 −0 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. +1 −1 ...client/src/main/java/com/canoo/dp/impl/platform/projector/client/action/AbstractActionButton.java
  9. +1 −1 ...ctor-client/src/main/java/com/canoo/dp/impl/platform/projector/client/action/SimpleActionBar.java
  10. +1 −1 ...jector-client/src/main/java/com/canoo/dp/impl/platform/projector/client/projection/Projector.java
  11. +1 −1 ...ctor-client/src/main/java/com/canoo/dp/impl/platform/projector/client/projection/ViewFactory.java
  12. +1 −0 ...form-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/action/ClientAction.java
  13. +1 −0 ...tor-common/src/main/java/com/canoo/dp/impl/platform/projector/action/DefaultServerActionBean.java
  14. +1 −0 ...form-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/action/ServerAction.java
  15. +1 −0 ...ctor-common/src/main/java/com/canoo/dp/impl/platform/projector/action/StringClientActionBean.java
  16. +0 −28 ...ector-common/src/main/java/com/canoo/dp/impl/platform/projector/annotations/ReadOnlyAtClient.java
  17. +2 −3 ...common/src/main/java/com/canoo/dp/impl/platform/projector/{action → base}/AbstractActionBean.java
  18. +6 −14 ...a/com/canoo/dp/impl/platform/projector/{gantt/GanttBean.java → base/AbstractProjectableBean.java}
  19. +1 −6 ...m-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/{action → base}/Action.java
  20. +1 −1 ...n-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/IconBean.java
  21. +12 −0 ...latform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/Projectable.java
  22. +4 −8 .../main/java/com/canoo/dp/impl/platform/projector/{action/DefaultActionQueue.java → base/View.java}
  23. +2 −4 ...m-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/{view → base}/ViewBean.java
  24. +13 −10 .../java/com/canoo/dp/impl/platform/projector/{annotations/OnlyOnServer.java → base/WithAction.java}
  25. +2 −4 .../main/java/com/canoo/dp/impl/platform/projector/{action/ActionQueue.java → base/WithActions.java}
  26. +1 −1 ...orm-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithDescription.java
  27. +1 −1 ...n-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithIcon.java
  28. +1 −1 ...-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithLayoutMetadata.java
  29. +1 −1 ...orm-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithMultiResult.java
  30. +1 −1 ...-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithMultiSelection.java
  31. +1 −1 ...platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithResult.java
  32. +1 −1 ...tform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithSelection.java
  33. +1 −1 ...-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/base/WithTitle.java
  34. +2 −1 ...form-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/chat/ChatThreadBean.java
  35. +2 −1 ...ojector-common/src/main/java/com/canoo/dp/impl/platform/projector/form/AbstractFormFieldBean.java
  36. +2 −4 ...lphin-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/form/Form.java
  37. +3 −2 ...n-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/form/FormBean.java
  38. +2 −1 ...orm-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/form/FormSectionBean.java
  39. +0 −91 ...tform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/gantt/ActivityBean.java
  40. +0 −46 ...n-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/gantt/RowBean.java
  41. +2 −1 ...form-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/graph/GraphDataBean.java
  42. +2 −1 ...rojector-common/src/main/java/com/canoo/dp/impl/platform/projector/lazy/AbstractLazyListBean.java
  43. +2 −1 ...hin-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/media/Media.java
  44. +10 −1 ...platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/media/MediaBean.java
  45. +2 −1 ...tor-common/src/main/java/com/canoo/dp/impl/platform/projector/notifications/NotificationBean.java
  46. +2 −1 ...ojector-common/src/main/java/com/canoo/dp/impl/platform/projector/{base → progress}/Progress.java
  47. +3 −13 ...tform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/table/ActionColumn.java
  48. +5 −4 ...m-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/table/ActionColumnBean.java
  49. +2 −1 ...projector-common/src/main/java/com/canoo/dp/impl/platform/projector/table/PropertyColumnBean.java
  50. +2 −5 ...platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/toolbar/Toolbar.java
  51. +3 −2 ...form-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/toolbar/ToolbarBean.java
  52. +0 −31 ...lphin-platform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/view/View.java
  53. +1 −0 ...atform-projector-common/src/main/java/com/canoo/dp/impl/platform/projector/view/ViewMetadata.java
  54. +1 −1 ...or-server/src/main/java/com/canoo/dp/impl/platform/projector/server/projection/ActionBuilder.java
  55. +1 −1 ...ctor-server/src/main/java/com/canoo/dp/impl/platform/projector/server/projection/FormBuilder.java
  56. +44 −7 ...server/src/main/java/com/canoo/dp/impl/platform/projector/server/projection/FormFieldBuilder.java
  57. +27 −0 ...jector-server/src/main/java/com/canoo/dp/impl/platform/projector/server/update/UpdateHandler.java
  58. +1 −2 ...m-remoting-common/src/main/java/com/canoo/dp/impl/remoting/converters}/ClassConverterFactory.java
  59. +2 −1 ...n/src/main/resources/META-INF/services/com.canoo.platform.remoting.spi.converter.ConverterFactory
  60. +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;
});
}
}
@@ -0,0 +1,21 @@
/*
* Copyright 2015-2018 Canoo Engineering AG.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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) {}
}
@@ -15,7 +15,7 @@
*/
package com.canoo.dp.impl.platform.projector.client.action;

import com.canoo.dp.impl.platform.projector.action.Action;
import com.canoo.dp.impl.platform.projector.base.Action;
import com.canoo.platform.remoting.client.javafx.FXBinder;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
@@ -15,7 +15,7 @@
*/
package com.canoo.dp.impl.platform.projector.client.action;

import com.canoo.dp.impl.platform.projector.action.Action;
import com.canoo.dp.impl.platform.projector.base.Action;
import com.canoo.dp.impl.platform.projector.client.projection.Projector;
import com.canoo.platform.remoting.ObservableList;
import com.canoo.platform.remoting.client.ControllerProxy;
@@ -22,7 +22,7 @@
import com.canoo.dp.impl.platform.projector.form.Form;
import com.canoo.dp.impl.platform.projector.graph.GraphDataBean;
import com.canoo.dp.impl.platform.projector.lazy.concrete.MediaLazyListBean;
import com.canoo.dp.impl.platform.projector.view.View;
import com.canoo.dp.impl.platform.projector.base.View;
import com.canoo.platform.remoting.client.ClientContext;
import com.canoo.platform.remoting.client.ControllerProxy;
import javafx.application.Platform;
@@ -17,7 +17,7 @@

import com.canoo.dp.impl.platform.projector.base.WithLayoutMetadata;
import com.canoo.dp.impl.platform.projector.metadata.MetadataUtilities;
import com.canoo.dp.impl.platform.projector.view.View;
import com.canoo.dp.impl.platform.projector.base.View;
import com.canoo.dp.impl.platform.projector.view.ViewMetadata;
import com.canoo.platform.remoting.client.ClientContext;
import com.canoo.platform.remoting.client.ControllerProxy;
@@ -15,6 +15,7 @@
*/
package com.canoo.dp.impl.platform.projector.action;

import com.canoo.dp.impl.platform.projector.base.Action;
import com.canoo.dp.impl.platform.projector.base.WithResult;
import com.canoo.platform.remoting.Property;
import com.canoo.platform.remoting.RemotingBean;
@@ -15,6 +15,7 @@
*/
package com.canoo.dp.impl.platform.projector.action;

import com.canoo.dp.impl.platform.projector.base.AbstractActionBean;
import com.canoo.platform.remoting.Property;
import com.canoo.platform.remoting.RemotingBean;

@@ -15,6 +15,7 @@
*/
package com.canoo.dp.impl.platform.projector.action;

import com.canoo.dp.impl.platform.projector.base.Action;
import com.canoo.platform.remoting.Property;
import com.canoo.platform.remoting.RemotingBean;

@@ -15,6 +15,7 @@
*/
package com.canoo.dp.impl.platform.projector.action;

import com.canoo.dp.impl.platform.projector.base.AbstractActionBean;
import com.canoo.platform.remoting.Property;
import com.canoo.platform.remoting.RemotingBean;

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit d399d2a

Please sign in to comment.
You can’t perform that action at this time.