dev-ui.qwc-arc-beans.js Maven / Gradle / Ivy
import { LitElement, html, css} from 'lit';
import { columnBodyRenderer } from '@vaadin/grid/lit.js';
import { beans } from 'build-time-data';
import { beanIdsWithDependencyGraphs } from 'build-time-data';
import '@vaadin/grid';
import '@vaadin/vertical-layout';
import 'qui-badge';
import 'qui-ide-link';
import '@vaadin/icon';
import './qwc-arc-bean-graph.js';
/**
* This component shows the Arc Beans
*/
export class QwcArcBeans extends LitElement {
static styles = css`
.arctable {
height: 100%;
padding-bottom: 10px;
}
code {
font-size: 85%;
}
.annotation {
color: var(--lumo-contrast-50pct);
}
.producer {
color: var(--lumo-primary-text-color);
}
.graph-icon {
font-size: small;
color: var(--lumo-contrast-50pct);
cursor: pointer;
}
.graph {
display: flex;
flex-direction: column;
overflow: hidden;
height: 100%;
}
`;
static properties = {
_beans: {state: true},
_beanIdsWithDependencyGraphs: {state: true},
_selectedBean: {state: true}
};
constructor() {
super();
this._beans = beans;
this._beanIdsWithDependencyGraphs = beanIdsWithDependencyGraphs;
this._selectedBean = null;
}
render() {
if (this._beans) {
if(this._selectedBean){
return this._renderBeanGraph();
}else{
return this._renderBeanList();
}
} else {
return html`No beans found`;
}
}
_renderBeanList(){
return html`
`;
}
_renderBeanGraph(){
return html` `;
}
_beanRenderer(bean) {
return html`
@${bean.scope.simpleName}
${bean.nonDefaultQualifiers.map(qualifier =>
html`${this._qualifierRenderer(qualifier)}`
)}
${bean.providerType.name}
`;
}
_kindRenderer(bean) {
return html`
${this._kindBadgeRenderer(bean)}
${this._kindClassRenderer(bean)}
`;
}
_kindBadgeRenderer(bean){
let kind = this._camelize(bean.kind);
let level = null;
if(bean.kind.toLowerCase() === "field"){
kind = "Producer field";
level = "success";
}else if(bean.kind.toLowerCase() === "method"){
kind = "Producer method";
level = "success";
}else if(bean.kind.toLowerCase() === "synthetic"){
level = "contrast";
}
return html`
${level
? html`${kind} `
: html`${kind} `
}`;
}
_kindClassRenderer(bean){
return html`
${bean.declaringClass
? html`${bean.declaringClass.simpleName}.${bean.memberName}()
`
: html`${bean.memberName}
`
}`;
}
_interceptorsRenderer(bean) {
if (bean.interceptors && bean.interceptors.length > 0) {
return html`
${bean.interceptorInfos.map(interceptor =>
html`
${interceptor.interceptorClass.name}
${interceptor.priority}
`
)}
`;
}
}
_qualifierRenderer(qualifier) {
return html`${qualifier.simpleName}
`;
}
_graphIconRenderer(bean){
if(this._beanIdsWithDependencyGraphs.includes(bean.id)){
return html` this._showGraph(bean)}> `;
}
}
_showGraph(bean){
this._selectedBean = bean;
}
_showBeanList(){
this._selectedBean = null;
}
_camelize(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
if (+match === 0)
return "";
return index === 0 ? match.toUpperCase() : match.toLowerCase();
});
}
}
customElements.define('qwc-arc-beans', QwcArcBeans);