Commit b50abc58 authored by michael.simon's avatar michael.simon
Browse files

visuals for attribute source

parent e2a0fde0
......@@ -76,4 +76,20 @@ public class AttributeSourceEntity extends AbstractBaseEntity {
public void setAsClass(String asClass) {
this.asClass = asClass;
}
public Boolean getUserSource() {
return userSource;
}
public void setUserSource(Boolean userSource) {
this.userSource = userSource;
}
public Boolean getServiceSource() {
return serviceSource;
}
public void setServiceSource(Boolean serviceSource) {
this.serviceSource = serviceSource;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.as;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.JobClassEntity;
import edu.kit.scc.webreg.entity.as.AttributeSourceEntity;
import edu.kit.scc.webreg.service.AttributeSourceService;
import edu.kit.scc.webreg.service.JobClassService;
import edu.kit.scc.webreg.util.ViewIds;
@ManagedBean
@ViewScoped
public class EditAttributeSourceBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private AttributeSourceService service;
private AttributeSourceEntity entity;
private Map<String, String> propertyMap;
private String newKey, newValue;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
if (entity == null) {
entity = service.findById(id);
propertyMap = new HashMap<String, String>(entity.getAsProps());
}
}
public String save() {
entity.setAsProps(propertyMap);
entity = service.save(entity);
return ViewIds.SHOW_ATTRIBUTE_SOURCE + "?faces-redirect=true&id=" + entity.getId();
}
public String cancel() {
return ViewIds.SHOW_ATTRIBUTE_SOURCE + "?faces-redirect=true&id=" + entity.getId();
}
public void removeProp(String key) {
setNewKey(key);
setNewValue(propertyMap.get(key));
propertyMap.remove(key);
}
public void addProp() {
if (newKey != null && newValue != null) {
propertyMap.put(newKey, newValue);
setNewKey(null);
setNewValue(null);
}
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Map<String, String> getPropertyMap() {
return propertyMap;
}
public void setPropertyMap(Map<String, String> propertyMap) {
this.propertyMap = propertyMap;
}
public String getNewKey() {
return newKey;
}
public void setNewKey(String newKey) {
this.newKey = newKey;
}
public String getNewValue() {
return newValue;
}
public void setNewValue(String newValue) {
this.newValue = newValue;
}
public AttributeSourceEntity getEntity() {
return entity;
}
public void setEntity(AttributeSourceEntity entity) {
this.entity = entity;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.as;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.as.AttributeSourceEntity;
import edu.kit.scc.webreg.service.AttributeSourceService;
@Named("showAttributeSourceBean")
@RequestScoped
public class ShowAttributeSourceBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private AttributeSourceService service;
private AttributeSourceEntity entity;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
entity = service.findById(id);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public AttributeSourceEntity getEntity() {
return entity;
}
public void setEntity(AttributeSourceEntity entity) {
this.entity = entity;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{editAttributeSourceBean.id}"/>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{editAttributeSourceBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{messages.schedule}: #{editAttributeSourceBean.entity.name}"/></h2>
<div class="panel">
<p:panel header="#{messages.schedule}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:" />
<h:outputText value="#{editAttributeSourceBean.entity.id}" />
<bw:inputText id="nameField" label="#{messages.name}"
value="#{editAttributeSourceBean.entity.name}" required="true" />
<bw:inputText id="classField" label="#{messages.job_class}"
value="#{editAttributeSourceBean.entity.asClass}" required="true"/>
<h:outputText value="#{messages.service_source}:" />
<p:selectBooleanButton onLabel="#{messages.yes}" offLabel="#{messages.no}"
value="#{editAttributeSourceBean.entity.serviceSource}" />
<h:outputText value="#{messages.user_source}:" />
<p:selectBooleanButton onLabel="#{messages.yes}" offLabel="#{messages.no}"
value="#{editAttributeSourceBean.entity.userSource}" />
<h:outputText value="#{messages.properties}:"/>
<p:dataTable id="propTable" var="key" style="min-width: 500px;"
value="#{editAttributeSourceBean.propertyMap.keySet().toArray()}">
<p:column>
<f:facet name="header">
<h:outputText value="#{messages.key}" />
</f:facet>
<h:outputText value="#{key}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{messages.value}" />
</f:facet>
<h:outputText value="#{editAttributeSourceBean.propertyMap[key]}" />
</p:column>
<p:column>
<h:commandLink value="#{messages.delete}" action="#{editAttributeSourceBean.removeProp(key)}">
<f:ajax render="@form" />
</h:commandLink>
</p:column>
</p:dataTable>
<h:outputText value="#{messages.new_property}:"/>
<h:panelGrid id="newPropTable" columns="3" columnClasses="labelColumn, elementColumn">
<h:inputText id="key_input" value="#{editAttributeSourceBean.newKey}"/>
<h:inputText id="value_input" value="#{editAttributeSourceBean.newValue}"/>
<h:commandLink value="#{messages.add}" action="#{editAttributeSourceBean.addProp()}">
<f:ajax execute="form" render="form" />
</h:commandLink>
</h:panelGrid>
</p:panelGrid>
<p:commandButton id="save" action="#{editAttributeSourceBean.save}" value="#{messages.save}"/>
<p:commandButton id="cancel" action="#{editAttributeSourceBean.cancel}" value="#{messages.cancel}" immediate="true"/>
</p:panel>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{showAttributeSourceBean.id}"/>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{showAttributeSourceBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{messages.job_class}: #{showAttributeSourceBean.entity.name}"/></h2>
<div class="panel">
<p:panel header="#{messages.job_class}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:" />
<h:outputText value="#{showAttributeSourceBean.entity.id}" />
<h:outputText value="#{messages.name}:" />
<h:outputText value="#{showAttributeSourceBean.entity.name}" />
<h:outputText value="#{messages.job_class}:" />
<h:outputText value="#{showAttributeSourceBean.entity.asClass}" />
<h:outputText value="#{messages.service_source}:" />
<h:outputText value="#{showAttributeSourceBean.entity.serviceSource}" />
<h:outputText value="#{messages.user_source}:" />
<h:outputText value="#{showAttributeSourceBean.entity.userSource}" />
<h:outputText value="#{messages.properties}:" />
<p:dataTable id="propTable" var="key" style="min-width: 400px;"
value="#{showAttributeSourceBean.entity.asProps.keySet().toArray()}">
<p:column>
<f:facet name="header">
<h:outputText value="#{messages.key}" />
</f:facet>
<h:outputText value="#{key}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{messages.value}" />
</f:facet>
<h:outputText value="#{showAttributeSourceBean.entity.asProps[key]}" />
</p:column>
</p:dataTable>
</p:panelGrid>
<h:link outcome="edit-attribute-source.xhtml" value="#{messages.edit}">
<f:param name="id" value="#{showAttributeSourceBean.entity.id}" />
</h:link>
</p:panel>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment