Commit 02e0b003 authored by Patrik Meijer's avatar Patrik Meijer
Browse files

Initial work on pointer-creation

parent 035fdb89
...@@ -12,12 +12,12 @@ import MenuItem from '@material-ui/core/MenuItem'; ...@@ -12,12 +12,12 @@ import MenuItem from '@material-ui/core/MenuItem';
export default class ContextMenu extends Component { export default class ContextMenu extends Component {
static propTypes = { static propTypes = {
gmeClient: PropTypes.object.isRequired, gmeClient: PropTypes.object.isRequired,
data: PropTypes.object.isRequired,
nodeId: PropTypes.string.isRequired, // FIXME: should be nodeIds nodeId: PropTypes.string.isRequired, // FIXME: should be nodeIds
eventX: PropTypes.number.isRequired, eventX: PropTypes.number.isRequired,
eventY: PropTypes.number.isRequired, eventY: PropTypes.number.isRequired,
onClose: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired,
setActiveNode: PropTypes.func.isRequired, setActiveNode: PropTypes.func.isRequired,
createPointer: PropTypes.func.isRequired,
readOnly: PropTypes.bool, readOnly: PropTypes.bool,
}; };
...@@ -41,6 +41,13 @@ export default class ContextMenu extends Component { ...@@ -41,6 +41,13 @@ export default class ContextMenu extends Component {
onClose(); onClose();
} }
getCreatePointerFunc = (ptrName) => {
const {createPointer, nodeId} = this.props;
return () => {
createPointer(nodeId, ptrName);
};
}
render() { render() {
const { const {
gmeClient, gmeClient,
...@@ -48,63 +55,32 @@ export default class ContextMenu extends Component { ...@@ -48,63 +55,32 @@ export default class ContextMenu extends Component {
eventX, eventX,
eventY, eventY,
readOnly, readOnly,
data, onClose,
} = this.props; } = this.props;
// console.log(data); // console.log(data);
const menuItems = []; const menuItems = [];
const nodeObj = gmeClient.getNode(nodeId); const nodeObj = gmeClient.getNode(nodeId);
if (false) { const metaNodeObj = gmeClient.getNode(nodeObj.getMetaTypeId());
const metaNodeObj = gmeClient.getNode(nodeObj.getMetaTypeId());
menuItems.push(( const pointerNames = metaNodeObj.getValidPointerNames();
<MenuItem key="meta-type" onClick={this.props.onClose} disabled={readOnly}>
{`<<${metaNodeObj.getAttribute('name')}>>`}
</MenuItem>));
if (metaNodeObj.getAttribute('name') === 'System') { menuItems.push((
menuItems.push(( <MenuItem key="meta-type" onClick={onClose} disabled={readOnly}>
<MenuItem key="open-sub-system" onClick={this.setActiveNode} > {`<<${metaNodeObj.getAttribute('name')}>>`}
Open Subsystem ... </MenuItem>));
</MenuItem>));
} menuItems.push((
} else if (data.memberAttrs && data.memberAttrs.length > 0) { <MenuItem key="open-sub-system" onClick={this.setActiveNode} >
let args; Open Subsystem ...
data.memberAttrs.forEach((memAttr) => { </MenuItem>));
if (memAttr.name === 'args') {
args = memAttr.value ? `(${memAttr.value})` : '()'; pointerNames.forEach((ptr) => {
}
});
if (args) {
menuItems.push((
<MenuItem key="invocation-args" onClick={this.props.onClose}>
Invocation arguments: {args}
</MenuItem>));
}
} else if (data.pointerName === 'post' || data.pointerName === 'pre') {
const methodNode = gmeClient.getNode(data.source);
const modeNode = gmeClient.getNode(data.target);
if (methodNode && modeNode) {
// const parentName = gmeClient.getNode(modeNode.getParentId()).getAttribute('name');
// const modeName = modeNode.getAttribute('name');
const methodName = methodNode.getAttribute('name');
menuItems.push((
<MenuItem key="pre-post-condition" onClick={this.props.onClose}>
{`${data.pointerName}-condition for ${methodName}`}
</MenuItem>));
}
} else if (data.setName === 'network-nodes') {
menuItems.push(( menuItems.push((
<MenuItem key="cell-network-nodes" onClick={this.props.onClose}> <MenuItem key={`create-pointer-${ptr}`} onClick={this.getCreatePointerFunc(ptr)} >
{`${data.setName}`} {`Create pointer ${ptr} from here ...`}
</MenuItem>)); </MenuItem>));
} });
if (menuItems.length === 0) {
this.props.onClose();
return <div/>;
}
return ( return (
<Menu <Menu
...@@ -116,7 +92,7 @@ export default class ContextMenu extends Component { ...@@ -116,7 +92,7 @@ export default class ContextMenu extends Component {
left: eventX, left: eventX,
}} }}
open open
onClose={this.props.onClose} onClose={onClose}
> >
{menuItems} {menuItems}
</Menu> </Menu>
......
...@@ -34,73 +34,79 @@ export default class FilterSelector extends Component { ...@@ -34,73 +34,79 @@ export default class FilterSelector extends Component {
static defaultProps = { static defaultProps = {
open: true, open: true,
} };
render() { render() {
const {validItems, activeItems} = this.props; const {
validItems,
activeItems,
handleToggle,
open,
onClose,
} = this.props;
const lists = []; const lists = [];
Object.keys(validItems).forEach((groupName) => { Object.keys(validItems)
const items = []; .forEach((groupName) => {
validItems[groupName].forEach((item) => { const items = [];
if (item.hidden) { validItems[groupName].forEach((item) => {
return; if (item.hidden) {
} return;
}
const itemId = `${groupName}$${item.name}`; const itemId = `${groupName}$${item.name}`;
let icon; let icon;
switch (groupName) { switch (groupName) {
case 'pointers': case 'pointers':
icon = <TrendingFlatIcon style={{color: 'rgb(85, 123, 139)'}}/>; icon = <TrendingFlatIcon style={{color: 'rgb(85, 123, 139)'}}/>;
break; break;
case 'sets': case 'sets':
icon = (item.name === 'network-nodes') ? icon = (item.name === 'network-nodes')
<MoreHorizIcon/> : ? <MoreHorizIcon/> : <CallSplitIcon className="rotate-90"/>;
<CallSplitIcon className="rotate-90"/>; break;
break; case 'nodes':
case 'nodes': icon = item.isConnection ? <RemoveIcon/> : <FiberManualRecordIcon/>;
icon = item.isConnection ? <RemoveIcon/> : <FiberManualRecordIcon/>; break;
break; default:
default: icon = <FiberManualRecordIcon/>;
icon = <FiberManualRecordIcon/>; break;
break; }
}
items.push(( items.push((
<ListItem key={itemId}> <ListItem key={itemId}>
<ListItemIcon> <ListItemIcon>
{icon} {icon}
</ListItemIcon> </ListItemIcon>
<ListItemText primary={item.name} style={{marginRight: 24}}/> <ListItemText primary={item.name} style={{marginRight: 24}}/>
<ListItemSecondaryAction> <ListItemSecondaryAction>
<Switch <Switch
onChange={() => { onChange={() => {
this.props.handleToggle(itemId); handleToggle(itemId);
}} }}
checked={activeItems[itemId]} checked={activeItems[itemId]}
/> />
</ListItemSecondaryAction> </ListItemSecondaryAction>
</ListItem>)); </ListItem>));
}); });
if (items.length > 0) { if (items.length > 0) {
lists.push(( lists.push((
<div key={groupName} > <div key={groupName}>
<Typography variant="subheading"> <Typography variant="subheading">
{groupName.toUpperCase()} {groupName.toUpperCase()}
</Typography> </Typography>
<List> <List>
{items} {items}
</List> </List>
<Divider/> <Divider/>
</div> </div>
)); ));
} }
}); });
return ( return (
<Dialog open={this.props.open} onClose={this.props.onClose}> <Dialog open={open} onClose={onClose}>
<DialogTitle id="filter-dialog-title">Apply Filters</DialogTitle> <DialogTitle id="filter-dialog-title">Apply Filters</DialogTitle>
<DialogContent> <DialogContent>
{lists} {lists}
......
This diff is collapsed.
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