use of net.sourceforge.usbdm.deviceEditor.model.BaseModel in project usbdm-eclipse-plugins by podonoghue.
the class SectionEditor method setModel.
public void setModel(BaseModel model) {
if (fSectionModel == model) {
return;
}
fSectionModel = (SectionModel) model;
for (Object child : fSectionModel.getChildren()) {
BaseModel pageModel = (BaseModel) child;
if (pageModel instanceof TreeViewModel) {
TreeEditor treeEditor = new TreeEditor() {
@Override
protected TreeColumnInformation[] getColumnInformation(TreeViewer viewer) {
final TreeColumnInformation[] fColumnInformation = { new TreeColumnInformation("Property", 350, new NameColumnLabelProvider(), null), new TreeColumnInformation("Value", 450, new ValueColumnLabelProvider(), new ValueColumnEditingSupport(viewer)), new TreeColumnInformation("Description", 550, new DescriptionColumnLabelProvider(), new DescriptionColumnEditingSupport(viewer)) };
return fColumnInformation;
}
};
Control treeControl = treeEditor.createControl(tabArea);
treeControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
treeEditor.setModel((TreeViewModel) pageModel);
} else if (pageModel instanceof TabModel) {
TabbedEditor tabEditor = new TabbedEditor();
Control treeControl = tabEditor.createControl(tabArea);
treeControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
tabEditor.setModel(pageModel);
}
}
}
use of net.sourceforge.usbdm.deviceEditor.model.BaseModel in project usbdm-eclipse-plugins by podonoghue.
the class ParseMenuXML method instantiateAliases.
/**
* Visits all nodes of the model and instantiates any aliases
*
* @param provider Provider to look up variables
* @param parent Root of the model tree to visit
*
* @throws Exception
*/
static void instantiateAliases(VariableProvider provider, BaseModel parent) throws Exception {
if ((parent == null) || (parent.getChildren() == null)) {
return;
}
ArrayList<Object> children = parent.getChildren();
ArrayList<Object> deletedChildren = new ArrayList<Object>();
for (int index = 0; index < children.size(); index++) {
Object model = children.get(index);
if (model instanceof AliasPlaceholderModel) {
BaseModel newModel = createModelFromAlias(provider, parent, (AliasPlaceholderModel) model);
if (newModel == null) {
// Variable not found and model is optional - delete placeholder
deletedChildren.add(model);
} else {
// Replace placeholder with new model
children.set(index, newModel);
newModel.setParentOnly(parent);
}
} else {
instantiateAliases(provider, (BaseModel) model);
}
}
// Remove deleted children
children.removeAll(deletedChildren);
}
use of net.sourceforge.usbdm.deviceEditor.model.BaseModel in project usbdm-eclipse-plugins by podonoghue.
the class ParseMenuXML method parseSectionsOrOtherContents.
/**
* Parse: <br>
* <peripheralPage><br>
* <list><br>
* <section><br>
* <fragment><br>
*
* @param menuElement
*
* @throws Exception
*/
private BaseModel parseSectionsOrOtherContents(BaseModel parent, Element topElement) throws Exception {
String name = topElement.getAttribute("name");
if (name.equalsIgnoreCase("_instance")) {
name = fProvider.getName();
}
// String tagName = topElement.getTagName();
// System.err.println("parseSectionsOrOther(<" + tagName + " name="+ name + ">)");
// String description = topElement.getAttribute("description");
String toolTip = getToolTip(topElement);
BaseModel model = null;
for (Node node = topElement.getFirstChild(); node != null; node = node.getNextSibling()) {
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element element = (Element) node;
String tagName = element.getTagName();
// System.err.println("AT " + element.getTagName());
if (tagName == "fragment") {
/*
* Parse fragment as if it was a continuation of the parent elements
*/
parseSectionsOrOtherContents(parent, element);
} else if (tagName == "section") {
if (model != null) {
throw new Exception("Multiple top-level elements found " + tagName);
}
model = new SectionModel(parent, name, toolTip);
parseSectionsOrOther(model, element);
} else if (tagName == "list") {
BaseModel tModel = new ListModel(parent, name);
parseSectionsOrOther(tModel, element);
parent.addChild(tModel);
} else {
parseChildModel(parent, element);
}
}
return model;
}
Aggregations