-
Notifications
You must be signed in to change notification settings - Fork 45
WIP VOWL notation for owl #78
base: master
Are you sure you want to change the base?
Changes from 14 commits
c7385b8
e911164
4de3a56
373a7af
c270701
943985e
6b3809e
539dfb9
497c495
2333451
f30038b
ca0166b
0ea5e59
733ad20
7e853f0
e67ebbe
968cd58
517f58e
8850feb
e17fb56
18bfa7a
504eb09
e0b6ef4
ec65573
31caaf5
3862ae3
12ce8a2
a2d7123
26b1010
8965c51
1f87b6c
0d445c6
eac5133
ebdd46e
ae6ecd9
2e6571d
ca0af3d
70f04e3
09857e9
afcd1ff
29093da
e8df5ee
bf2bb2e
91248ae
dea0aad
676a908
9f0dfd5
413109a
dbec30c
7c704f2
334206a
a2ed2e1
97c7138
9f49263
79e0cb8
11682ae
ef83da8
4c3b9c3
eb4e550
e7d1c1c
df4cc15
9a97996
43413e4
cbdf339
9cc1228
e5a6d71
6fcee50
c3a5c1b
5f16dfe
cf2e16d
6a7c308
101dde8
b30fb6c
d842e88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { createElement, ClassAttributes } from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
|
||
import { Workspace, WorkspaceProps, DemoDataProvider, LinkTemplate } from '../index'; | ||
|
||
import { onPageLoad, tryLoadLayoutFromLocalStorage, saveLayoutToLocalStorage } from './common'; | ||
|
||
require('jointjs/css/layout.css'); | ||
require('jointjs/css/themes/default.css'); | ||
|
||
const CUSTOM_LINK_TEMPLATE_SUBCLASSOF: LinkTemplate = { | ||
renderLink: () => ({ | ||
connection: { | ||
stroke: 'black', | ||
'stroke-width': 2, | ||
'stroke-dasharray':'5,5', | ||
}, | ||
label: { | ||
attrs: {text: {fill: 'black'}}, | ||
}, | ||
}), | ||
}; | ||
const CUSTOM_LINK_TEMPLATE: LinkTemplate = { | ||
renderLink: () => ({ | ||
connection: { | ||
stroke: 'black', | ||
'stroke-width': 2, | ||
}, | ||
label: { | ||
attrs: {text: {fill: 'black'}}, | ||
}, | ||
}), | ||
}; | ||
function onWorkspaceMounted(workspace: Workspace) { | ||
if (!workspace) { return; } | ||
|
||
const model = workspace.getModel(); | ||
model.graph.on('action:iriClick', (iri: string) => console.log(iri)); | ||
|
||
const layoutData = tryLoadLayoutFromLocalStorage(); | ||
model.importLayout({layoutData, dataProvider: new DemoDataProvider(), validateLinks: true}); | ||
} | ||
|
||
const props: WorkspaceProps & ClassAttributes<Workspace> = { | ||
ref: onWorkspaceMounted, | ||
onSaveDiagram: workspace => { | ||
const {layoutData} = workspace.getModel().exportLayout(); | ||
window.location.hash = saveLayoutToLocalStorage(layoutData); | ||
window.location.reload(); | ||
}, | ||
viewOptions: { | ||
linkTemplateResolvers: [ | ||
type => { | ||
if ( type.indexOf('subClassOf') !== -1 ) | ||
return CUSTOM_LINK_TEMPLATE_SUBCLASSOF; | ||
else | ||
return CUSTOM_LINK_TEMPLATE; | ||
} | ||
], | ||
}, | ||
}; | ||
|
||
onPageLoad(container => ReactDOM.render(createElement(Workspace, props), container)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import * as React from 'react'; | ||
import { Component } from 'react'; | ||
|
||
import { CrossOriginImage } from '../../viewUtils/crossOriginImage'; | ||
|
||
import { TemplateProps } from '../props'; | ||
|
||
const CLASS_NAME = 'ontodia-big-icon-owl_template'; | ||
|
||
export class BigIconTemplateOwl extends Component<TemplateProps, {}> { | ||
render() { | ||
const {color, imgUrl, icon, types, label, isExpanded, iri, propsAsList} = this.props; | ||
return ( | ||
<div className={CLASS_NAME}> | ||
<div className={`${CLASS_NAME}__main-part`}> | ||
<div className='ontodia-big-icon-owl_template_body'> | ||
<div style={{flexGrow: 1, overflow: 'hidden', textOverflow: 'ellipsis'}}> | ||
<span title={label} className='ontodia-big-icon-owl_template_body__label'> | ||
{label} | ||
</span> | ||
<div title={types} className='ontodia-big-icon-owl_template_body_type-container'> | ||
<div className='ontodia-big-icon-owl_template_body_type-container__type'>{types}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{isExpanded ? ( | ||
<div className='ontodia-big-icon-owl_template_property' | ||
style={{borderColor: 'black'}}> | ||
{imgUrl ? ( | ||
<CrossOriginImage className={`${CLASS_NAME}__picture`} | ||
style={{borderColor: 'black'}} | ||
imageProps={{src: imgUrl, className: `${CLASS_NAME}__picture-image`}} | ||
/> | ||
) : null} | ||
<div className='ontodia-big-icon-owl_template_property_content'> | ||
<div className='ontodia-big-icon-owl_template_property_content_iri-line'> | ||
<div className='ontodia-big-icon-owl_template_property_content_iri-line__label'> | ||
IRI: | ||
</div> | ||
<div className='ontodia-big-icon-owl_template_property_content_iri-line__iri'> | ||
<a href={iri} title={iri}>{iri}</a> | ||
</div> | ||
</div> | ||
|
||
<hr className='ontodia-big-icon-owl_template_property_content__hr' | ||
style={{borderTop:'solid', borderWidth:'1px', borderTopColor:'black'}}/> | ||
{propsAsList.length ? ( | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table'> | ||
{propsAsList.map(({name, id, property}) => ( | ||
<div key={id} className='ontodia-big-icon-owl_template_property_content_property-table_row'> | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table_row__key' | ||
title={name + ' ' + id}> | ||
{name} | ||
</div> | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table_row_key_values'> | ||
{property.values.map(({text}, index) => ( | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table_row_key_values__value' | ||
key={index} title={text}> | ||
{text} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
) : 'no properties'} | ||
</div> | ||
</div> | ||
) : null} | ||
</div>); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import * as React from 'react'; | ||
|
||
import { CrossOriginImage } from '../../viewUtils/crossOriginImage'; | ||
|
||
import { TemplateProps } from '../props'; | ||
|
||
const CLASS_NAME = 'ontodia-default-owl_template'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
export class DefaultElementTemplateOwl extends React.Component<TemplateProps, {}> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
public SetColor(types: any) : string { | ||
if ( types.indexOf("Datatype") != -1 ) | ||
return '#fc3'; | ||
else if (types.indexOf("AnnotationProperty") != -1) | ||
return '#ccc'; | ||
else if (types.indexOf("Property") != -1) | ||
return '#0588f9fc'; | ||
else if (types.indexOf("Ontology") != -1) | ||
return '#c9c'; | ||
else return undefined; | ||
} | ||
public ItIsThing(types: any) : boolean { | ||
if ( types.indexOf("Datatype") != -1 || | ||
types.indexOf("Property") != -1 || | ||
types.indexOf("Ontology") != -1 | ||
) | ||
return false; | ||
else return true; | ||
} | ||
|
||
render() { | ||
const props = this.props; | ||
const {color, imgUrl, icon, types, label, isExpanded, iri, propsAsList} = this.props; | ||
|
||
const image = props.imgUrl ? ( | ||
<CrossOriginImage className={`${CLASS_NAME}__thumbnail`} | ||
imageProps={{src: props.imgUrl}} /> | ||
) : undefined; | ||
|
||
let propertyTable: React.ReactElement<any>; | ||
if (props.propsAsList && props.propsAsList.length > 0) { | ||
propertyTable = <div className='ontodia-default-owl_template_body_expander_property-table'> | ||
{props.propsAsList.map(prop => { | ||
const values = prop.property.values.map(({text}, index) => ( | ||
<div className='ontodia-default-owl_template_body_expander_property-table_row_key_values__value' | ||
key={index} title={text}> | ||
{text} | ||
</div> | ||
)); | ||
return ( | ||
<div key={prop.id} className='ontodia-default-owl_template_body_expander_property-table_row'> | ||
<div title={prop.name + ' (' + prop.id + ')'} | ||
className='ontodia-default-owl_template_body_expander_property-table_row__key'> | ||
{prop.name} | ||
</div> | ||
<div className='ontodia-default-owl_template_body_expander_property-table_row_key_values'> | ||
{values} | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div>; | ||
} else { | ||
propertyTable = <div>no properties</div>; | ||
} | ||
|
||
const expander = props.isExpanded ? ( | ||
<div className='ontodia-big-icon-owl_template_property' | ||
style={{borderColor: 'black'}}> | ||
{imgUrl ? ( | ||
<CrossOriginImage className={`${CLASS_NAME}__picture`} | ||
style={{borderColor: 'black'}} | ||
imageProps={{src: imgUrl, className: `${CLASS_NAME}__picture-image`}} | ||
/> | ||
) : null} | ||
<div className='ontodia-big-icon-owl_template_property_content'> | ||
<div className='ontodia-big-icon-owl_template_property_content_iri-line'> | ||
<div className='ontodia-big-icon-owl_template_property_content_iri-line__label'> | ||
IRI: | ||
</div> | ||
<div className='ontodia-big-icon-owl_template_property_content_iri-line__iri'> | ||
<a href={iri} title={iri}>{iri}</a> | ||
</div> | ||
</div> | ||
|
||
<hr className='ontodia-big-icon-owl_template_property_content__hr' | ||
style={{borderTop:'solid', borderWidth:'1px', borderTopColor:'black'}}/> | ||
{propsAsList.length ? ( | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table'> | ||
{propsAsList.map(({name, id, property}) => ( | ||
<div key={id} className='ontodia-big-icon-owl_template_property_content_property-table_row'> | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table_row__key' | ||
title={name + ' ' + id}> | ||
{name} | ||
</div> | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table_row_key_values'> | ||
{property.values.map(({text}, index) => ( | ||
<div className='ontodia-big-icon-owl_template_property_content_property-table_row_key_values__value' | ||
key={index} title={text}> | ||
{text} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
) : 'no properties'} | ||
</div> | ||
</div> | ||
) : undefined; | ||
|
||
if ( !this.ItIsThing(this.props.types) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove extra spaces around Also something is wrong with indentation in this block (opening and closing brace indentation level doesn't match). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
return ( | ||
<div> | ||
<div> | ||
<div className='ontodia-default-owl_template' | ||
style={{ borderColor: "black", backgroundColor:this.SetColor(this.props.types)}} | ||
data-expanded={this.props.isExpanded}> | ||
{image} | ||
<div className='ontodia-default-owl_template_body'> | ||
<label className='ontodia-default-owl_template_body__label' title={props.label}> | ||
{props.label} | ||
<div title={props.types} className='ontodia-big-icon-owl_template_body_type-container'> | ||
<div className='ontodia-big-icon-owl_template_body_type-container__type'>{props.types}</div> | ||
</div> | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
{expander} | ||
</div> | ||
); | ||
} | ||
else { | ||
return ( | ||
<div className='ontodia-default-owl_thing_template' | ||
data-expanded={this.props.isExpanded}> | ||
{image} | ||
<div className='ontodia-default-owl_thing_template_body'> | ||
<label className='ontodia-default-owl_thing_template_body__label' title={props.label}> | ||
{props.label} | ||
<div title={props.types} className='ontodia-big-icon-owl_template_body_type-container'> | ||
<div className='ontodia-big-icon-owl_template_body_type-container__type'>{props.types}</div> | ||
</div> | ||
</label> | ||
</div> | ||
{expander} | ||
</div> | ||
); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're providing templates for OWL/VOWL notation please name templates and files appropriately. For example, VOWLClassTemplate, VOWLPropertyTemplate, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed