use of net.sourceforge.usbdm.deviceEditor.model.BaseModel 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.BaseModel in project usbdm-eclipse-plugins by podonoghue.
the class ParseMenuXML method parseChildModel.
/**
* Parse element containing: <ul>
* <li> <fragment> referencing only elements below
* <li> <intOption>
* <li> <bitmaskOption>
* <li> <floatOption>
* <li> <binaryOption>
* <li> <irqOption>
* <li> <choiceOption>
* <li> <stringOption>
* <li> <numericListOption>
* <li> <pinListOption>
* <li> <aliasOption>
* <li> <constant>
* <li> <section>
* <li> <signals>
* <li> Control items...
*</ul>
*
* Elements found are added as children of the parentModel
*
* @param parentModel Model to attach children to
* @param menuElement Menu element to parse
*
* @throws Exception
*/
void parseChildModel(BaseModel parentModel, Element element) throws Exception {
String tagName = element.getTagName();
String name = element.getAttribute("name");
String toolTip = getToolTip(element);
// System.err.println("parseChildModel(): " + tagName + ", " + element.getAttribute("name"));
if (tagName == "fragment") {
parseChildModels(parentModel, element);
} else if (tagName == "category") {
BaseModel model = new CategoryModel(parentModel, name, toolTip);
parseChildModels(model, element);
} else if (tagName == "indexedCategory") {
parseIndexedCategoryOption(parentModel, element);
} else if (tagName == "intOption") {
parseLongOption(parentModel, element);
} else if (tagName == "bitmaskOption") {
parseBitmaskOption(parentModel, element);
} else if (tagName == "floatOption") {
parseDoubleOption(parentModel, element);
} else if (tagName == "binaryOption") {
parseBinaryOption(parentModel, element);
} else if (tagName == "irqOption") {
parseIrqOption(parentModel, element);
} else if (tagName == "choiceOption") {
parseChoiceOption(parentModel, element);
} else if (tagName == "stringOption") {
parseStringOption(parentModel, element);
} else if (tagName == "numericListOption") {
parseNumericListOption(parentModel, element);
} else if (tagName == "pinListOption") {
parsePinListOption(parentModel, element);
} else if (tagName == "aliasOption") {
parseAliasOption(parentModel, element);
} else if (tagName == "constant") {
parseConstant(parentModel, element);
} else if (tagName == "section") {
BaseModel model = new ParametersModel(parentModel, name, toolTip);
parseChildModels(model, element);
} else if (tagName == "list") {
BaseModel model = new ListModel(parentModel, name);
parseSectionsOrOther(model, element);
} else if (tagName == "signals") {
parseSignalsOption(parentModel, element);
} else {
parseControlItem(element);
}
}
use of net.sourceforge.usbdm.deviceEditor.model.BaseModel in project usbdm-eclipse-plugins by podonoghue.
the class PeripheralWithState method getModels.
@Override
public void getModels(BaseModel parent) {
if (fMenuData == null) {
return;
}
createSignalModel();
BaseModel model = fMenuData.getRootModel();
if (model != null) {
model.setParent(parent);
}
}
use of net.sourceforge.usbdm.deviceEditor.model.BaseModel 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.BaseModel in project usbdm-eclipse-plugins by podonoghue.
the class BaseLabelProvider method getStyledText.
@Override
public StyledString getStyledText(Object element) {
if (!(element instanceof BaseModel)) {
return new StyledString("");
}
BaseModel baseModel = (BaseModel) element;
String text = getText(baseModel);
if ((text == null) || (text.length() == 0)) {
return new StyledString("");
}
if (!baseModel.isEnabled()) {
return new StyledString(text, DISABLED_STYLER);
}
if (baseModel.isError()) {
return new StyledString(text, ERROR_STYLER);
}
if (baseModel.isWarning()) {
return new StyledString(text, WARNING_STYLER);
}
if (baseModel.isUnassigned()) {
return new StyledString(text, DISABLED_STYLER);
}
if (baseModel.hasChildren()) {
return new StyledString(text, CATEGORY_STYLER);
}
return new StyledString(text, DEFAULT_STYLER);
}
Aggregations