Skip to content

Commit

Permalink
Merge pull request #11 from activey/#8-external-module-poc
Browse files Browse the repository at this point in the history
#8 - external module PoC
  • Loading branch information
activey authored Nov 9, 2016
2 parents ff31551 + f1206f1 commit 13412d6
Show file tree
Hide file tree
Showing 164 changed files with 2,806 additions and 2,278 deletions.
58 changes: 36 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
:construction: **Still in very alpha stage!** :construction:

![](https://rawgit.com/activey/licket/master/licket.svg)
![](https://raw.githubusercontent.com/activey/licket/master/licket.png)
# Licket baby!
Here it is, brand new sweets to make your life even sweeter than before. Yes you! my brave web developer ;)

What is Licket you ask? Licket is a Java based, Spring Boot driven a AngularJS 2 flavoured stack!
While being influenced a lot by Apache Wicket (http://wicket.apache.org, I love you guys...) introduces a little more Angularish way of living :P
What is Licket you ask? Licket is a Java based, Spring Boot driven and Vue.js flavoured stack!
While being influenced a lot by Apache Wicket (http://wicket.apache.org, I love you guys...) it brings Java/Javascript web development to a completely new level :)

## Step by step HOW-TO or how to get running NOW!

Expand Down Expand Up @@ -74,12 +74,17 @@ As mentioned in preface, Licket derives many concepts from Apache Wicket like lo
Then you can model out the components:

```java
public class ContactsAppRoot extends AbstractLicketContainer<Void> {

public ContactsAppRoot(String id,
@Autowired @Qualifier("contactsPanel") LicketComponentContainer contactsPanel) {
super(id, fromComponentContainerClass(ContactsAppRoot.class));
public class ContactsAppRoot extends AbstractLicketMultiContainer<Void> {

@Autowired
private ContactsPanel contactsPanel;

public ContactsAppRoot(String id, LicketComponentModelReloader modelReloader) {
super(id, Void.class, emptyComponentModel(), fromComponentClass(ContactsAppRoot.class), modelReloader);
}

@Override
protected void onInitializeContainer() {
add(contactsPanel);
}
}
Expand All @@ -91,25 +96,34 @@ public class ContactsPanel extends AbstractLicketContainer<Contacts> {

public ContactsPanel(String id) {
super(id, fromComponentContainerClass(ContactsPanel.class));

add(new ContactsList("contact", new LicketModel("contacts")));
}

@Override
protected void onInitializeContainer() {
readContacts();
add(new ContactsList("contact", new LicketComponentModel("contacts"), modelReloader()));
}

private void readContacts() {
setComponentModelObject(fromIterable(contactsService.getAllContacts()));
setComponentModel(ofModelObject(fromIterable(contactsService.getAllContacts())));
}
}

public ContactsList(String id, LicketModel<String> enclosingComponentPropertyModel) {
super(id, enclosingComponentPropertyModel, Contact.class);
public class ContactsList extends AbstractLicketList<Contact> {

add(new LicketLabel("name"));
add(new LicketLabel("description"));
public ContactsList(String id, LicketComponentModel<String> enclosingComponentPropertyModel,
LicketComponentModelReloader modelReloader) {
super(id, enclosingComponentPropertyModel, Contact.class, modelReloader);

add(new LicketLabel("name"));
add(new LicketLabel("description"));
add(new AbstractLicketList<EmailAddress>("email", ofString("emails"), EmailAddress.class, modelReloader) {

@Override
protected void onInitializeContainer() {
add(new LicketLabel("email"));
}
});
}
}
```

Expand All @@ -119,14 +133,14 @@ Next,coin your own Spring Boot configuration class and glue all together:
@Configuration
public class LicketConfiguration {

@LicketRootComponent
public LicketComponentContainer root() {
return new ContactsAppRoot("contacts-page", contactsPanel());
@LicketRootContainer
public ContactsAppRoot root(@Autowired LicketComponentModelReloader modelReloader) {
return new ContactsAppRoot("contacts-page", modelReloader);
}

@LicketComponent("contactsPanel")
public LicketComponentContainer contactsPanel() {
return new ContactsPanel("contacts-panel");
@LicketComponent
public ContactsPanel contactsPanel(@Autowired LicketComponentModelReloader modelReloader) {
return new ContactsPanel("contacts-panel", modelReloader);
}

@Bean
Expand Down
16 changes: 13 additions & 3 deletions licket-common/src/main/java/org/licket/core/id/CompositeId.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package org.licket.core.id;

import static com.google.common.base.CaseFormat.LOWER_HYPHEN;
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
import static com.google.common.base.Joiner.on;
import static com.google.common.collect.Iterables.toArray;
import static com.google.common.collect.ObjectArrays.concat;
import static java.util.Arrays.stream;

import com.google.common.base.CaseFormat;
import com.google.common.base.Splitter;
import com.google.common.collect.ObjectArrays;

import java.util.Arrays;

/**
* @author activey
Expand Down Expand Up @@ -42,19 +46,25 @@ public String getValue() {

public String getNormalizedValue() {
return on(SEPARATOR_NORMALIZED)
.join(stream(idParts).map(idPart -> LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, idPart)).toArray());
.join(stream(idParts).map(idPart -> LOWER_HYPHEN.to(UPPER_CAMEL, idPart)).toArray());
}

public boolean hasMore() {
return index + 1 < idParts.length;
}

public CompositeId forward() {
public void forward() {
index = index + 1;
return this;
}

public String current() {
return idParts[index];
}

public final CompositeId join(CompositeId compositeId) {
if (compositeId == null) {
return new CompositeId(idParts);
}
return new CompositeId(concat(idParts, compositeId.idParts, String.class));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.licket.core.common;
package org.licket.core.supplier;

import java.util.function.Supplier;

Expand Down
6 changes: 6 additions & 0 deletions licket-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<artifactId>javafaker</artifactId>
<version>0.10</version>
</dependency>

<dependency>
<groupId>org.licket</groupId>
<artifactId>licket-module-semanticui</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,47 +1,40 @@
package org.licket.demo.licket;

import org.licket.core.module.application.LicketComponentModelReloader;
import org.licket.core.resource.HeadParticipatingResource;
import org.licket.demo.view.AddContactPanel;
import org.licket.demo.view.ContactsAppRoot;
import org.licket.demo.view.ContactsPanel;
import org.licket.demo.view.semantic.JqueryLibraryResource;
import org.licket.demo.view.semantic.SemanticLibraryResource;
import org.licket.demo.view.semantic.SemanticStylesheetResource;
import org.licket.semantic.SemanticUIPluginConfiguration;
import org.licket.semantic.component.modal.ModalSettings;
import org.licket.semantic.component.modal.ModalSettingsBuilder;
import org.licket.spring.annotation.LicketComponent;
import org.licket.spring.annotation.LicketRootContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.context.annotation.Import;

import static org.licket.semantic.component.modal.ModalSettingsBuilder.builder;

@Configuration
@Import(SemanticUIPluginConfiguration.class)
public class LicketConfiguration {

@LicketRootContainer
public ContactsAppRoot root(@Autowired LicketComponentModelReloader modelReloader) {
return new ContactsAppRoot("contacts-page", contactsPanel(modelReloader), modelReloader);
return new ContactsAppRoot("contacts-page", modelReloader);
}

@LicketComponent
public ContactsPanel contactsPanel(LicketComponentModelReloader modelReloader) {
public ContactsPanel contactsPanel(@Autowired LicketComponentModelReloader modelReloader) {
return new ContactsPanel("contacts-panel", modelReloader);
}

@Bean
@Order(10)
public HeadParticipatingResource jqueryResource() {
return new JqueryLibraryResource();
}

@Bean
@Order(11)
public HeadParticipatingResource semanticLibrary() {
return new SemanticLibraryResource();
private ModalSettings modalDialogSettings() {
return builder().build();
}

@Bean
@Order(12)
public HeadParticipatingResource semanticStylesheet() {
return new SemanticStylesheetResource();
@LicketComponent
public AddContactPanel addContactPanel(@Autowired LicketComponentModelReloader modelReloader) {
return new AddContactPanel("add-contact-panel", modelReloader, modalDialogSettings());
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.licket.demo.view;

import static com.google.common.base.Preconditions.checkNotNull;
import static org.licket.core.model.LicketModel.ofModelObject;
import static org.licket.core.view.ComponentView.fromComponentContainerClass;
import static org.licket.core.model.LicketComponentModel.ofModelObject;
import static org.licket.core.view.LicketComponentView.fromComponentClass;
import static org.licket.core.view.LicketComponentView.internalTemplateView;
import org.licket.core.module.application.LicketComponentModelReloader;
import org.licket.core.module.application.LicketRemoteCommunication;
import org.licket.core.module.forms.component.AbstractLicketForm;
import org.licket.core.module.application.LicketRemote;
import org.licket.core.view.LicketComponentView;
import org.licket.core.view.form.AbstractLicketForm;
import org.licket.core.view.form.LicketInput;
import org.licket.core.view.link.LicketFormSubmitButton;
import org.licket.demo.model.Contact;
Expand All @@ -18,10 +20,9 @@ public class AddContactForm extends AbstractLicketForm<Contact> {

private final ContactsService contactsService;

public AddContactForm(String id, ContactsService contactsService, LicketRemoteCommunication remoteCommunication,
public AddContactForm(String id, ContactsService contactsService, LicketRemote remoteCommunication,
LicketComponentModelReloader modelReloader) {
super(id, Contact.class, ofModelObject(new Contact()), fromComponentContainerClass(AddContactForm.class),
remoteCommunication, modelReloader);
super(id, Contact.class, ofModelObject(new Contact()), internalTemplateView(), remoteCommunication, modelReloader);
this.contactsService = checkNotNull(contactsService, "Contacts service has to be not null!");

add(new LicketInput("name"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package org.licket.demo.view;

import org.licket.core.module.application.LicketComponentModelReloader;
import org.licket.core.module.application.LicketRemote;
import org.licket.core.view.container.AbstractLicketMultiContainer;
import org.licket.core.view.container.LicketInlineContainer;
import org.licket.core.view.link.AbstractLicketLink;
import org.licket.core.view.link.ComponentActionCallback;
import org.licket.core.view.link.ComponentFunctionCallback;
import org.licket.demo.model.Contact;
import org.licket.demo.service.ContactsService;
import org.licket.demo.view.modal.AddContactFormModalSection;
import org.licket.semantic.component.modal.AbstractSemanticUIModal;
import org.licket.semantic.component.modal.ModalSection;
import org.licket.semantic.component.modal.ModalSettings;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.function.BiConsumer;
import java.util.function.Consumer;

import static org.licket.core.model.LicketComponentModel.emptyComponentModel;
import static org.licket.core.view.LicketComponentView.internalTemplateView;

/**
* @author grabslu
*/
public class AddContactPanel extends AbstractLicketMultiContainer<Void> {

@Autowired
private ContactsService contactsService;

@Autowired
private LicketRemote remoteCommunication;

private final ModalSettings modalSettings;
private AbstractSemanticUIModal modal;
private BiConsumer<Contact, ComponentActionCallback> callback;

public AddContactPanel(String id, LicketComponentModelReloader modelReloader, ModalSettings modalSettings) {
super(id, Void.class, emptyComponentModel(), internalTemplateView(), modelReloader);
this.modalSettings = modalSettings;
}

public final void onContactAdded(BiConsumer<Contact, ComponentActionCallback> callback) {
this.callback = callback;
}

@Override
protected void onInitializeContainer() {
add(new AbstractLicketLink("add-contact") {
@Override
protected void onClick(ComponentFunctionCallback callback) {
callback.call(modal.callShow(this));
}
});

add(modal = new AbstractSemanticUIModal("form-modal", modalSettings, modelReloader()) {

@Override
protected void onInitializeBody(ModalSection bodySection, String contentId) {
bodySection.add(new AddContactFormModalSection(contentId, modelReloader()) {
@Override
protected void onInitializeContainer() {
add(new AddContactForm("new-contact-form", contactsService, remoteCommunication, modelReloader()) {

@Override
protected void onAfterSubmit(ComponentActionCallback componentActionCallback) {
if (callback != null) {
callback.accept(getComponentModel().get(), componentActionCallback);
}
onAfterContactAdded(componentActionCallback);
}
});
}
});
}

@Override
protected void onInitializeActions(ModalSection content, String contentId) {
content.add(new LicketInlineContainer<Void>(contentId, Void.class, modelReloader()) {
@Override
protected void onInitializeContainer() {
}
});
}
});

}

protected void onAfterContactAdded(ComponentActionCallback componentActionCallback) {}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
package org.licket.demo.view;

import static org.licket.core.model.LicketModel.emptyModel;
import static org.licket.core.view.ComponentView.fromComponentContainerClass;
import static org.licket.core.model.LicketComponentModel.emptyComponentModel;
import static org.licket.core.view.LicketComponentView.fromComponentClass;

import org.licket.core.module.application.LicketComponentModelReloader;
import org.licket.core.view.container.AbstractLicketContainer;
import org.licket.core.view.container.LicketComponentContainer;
import org.licket.core.view.container.AbstractLicketMultiContainer;
import org.springframework.beans.factory.annotation.Autowired;

public class ContactsAppRoot extends AbstractLicketContainer<Void> {
public class ContactsAppRoot extends AbstractLicketMultiContainer<Void> {

public ContactsAppRoot(String id, LicketComponentContainer contactsPanel, LicketComponentModelReloader modelReloader) {
super(id, Void.class, emptyModel(), fromComponentContainerClass(ContactsAppRoot.class), modelReloader);
@Autowired
private ContactsPanel contactsPanel;

@Autowired
private AddContactPanel addContactPanel;

public ContactsAppRoot(String id, LicketComponentModelReloader modelReloader) {
super(id, Void.class, emptyComponentModel(), fromComponentClass(ContactsAppRoot.class), modelReloader);
}

@Override
protected void onInitializeContainer() {
addContactPanel.onContactAdded((contact, componentActionCallback) -> {
contactsPanel.reloadList();
componentActionCallback.reload(contactsPanel);
});
add(contactsPanel);
add(addContactPanel);
}
}
Loading

0 comments on commit 13412d6

Please sign in to comment.