use of net.sourceforge.usbdm.deviceEditor.model.SectionModel in project usbdm-eclipse-plugins by podonoghue.
the class ParseMenuXML method parseSectionsOrOther.
/**
* Parse: <br>
* <peripheralPage><br>
* <list><br>
* <section><br>
* <fragment><br>
*
* @param menuElement
*
* @throws Exception
*/
private BaseModel parseSectionsOrOther(BaseModel parent, Element element) throws Exception {
String name = element.getAttribute("name");
if (name.equalsIgnoreCase("_instance")) {
name = fProvider.getName();
}
// String description = element.getAttribute("description");
String toolTip = getToolTip(element);
BaseModel model = null;
if (element.getTagName() == "fragment") {
/*
* Parse fragment as if it was a continuation of the parent elements
* This handles fragments that just include a href= include a <peripheralPage>
*/
for (Node subNode = element.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
if (subNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
model = parseSectionsOrOther(parent, (Element) subNode);
}
} else if (element.getTagName() == "section") {
model = new SectionModel(parent, name, toolTip);
parseSectionsOrOtherContents(model, element);
} else if (element.getTagName() == "list") {
BaseModel tModel = new ListModel(parent, name);
parseSectionsOrOtherContents(tModel, element);
parent.addChild(tModel);
} else {
throw new Exception("Expected <section> or <list>, found = \'" + element.getTagName() + "\'");
}
return model;
}
use of net.sourceforge.usbdm.deviceEditor.model.SectionModel in project usbdm-eclipse-plugins by podonoghue.
the class TabbedEditor method setModel.
public void setModel(BaseModel model) {
if (fPeripheralPageModel == model) {
return;
}
fPeripheralPageModel = (TabModel) model;
fTabFolder.setToolTipText(fPeripheralPageModel.getToolTip());
for (CTabItem c : fTabFolder.getItems()) {
c.dispose();
}
ArrayList<Object> children = fPeripheralPageModel.getChildren();
if ((children.size() == 1) && (children.get(0) instanceof TreeViewModel)) {
}
for (Object child : fPeripheralPageModel.getChildren()) {
BaseModel pageModel = (BaseModel) child;
CTabItem tabItem = new CTabItem(fTabFolder, SWT.NONE);
tabItem.setText(pageModel.getName());
tabItem.setToolTipText(pageModel.getToolTip());
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", 500, new DescriptionColumnLabelProvider(), new DescriptionColumnEditingSupport(viewer)) };
return fColumnInformation;
}
};
tabItem.setControl(treeEditor.createControl(fTabFolder));
treeEditor.setModel((TreeViewModel) pageModel);
} else if (pageModel instanceof SectionModel) {
SectionEditor sectionEditor = new SectionEditor();
tabItem.setControl(sectionEditor.createControl(fTabFolder));
sectionEditor.setModel(pageModel);
} else {
System.err.println("other");
}
}
fTabFolder.setSelection(0);
}
use of net.sourceforge.usbdm.deviceEditor.model.SectionModel 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