Search in sources :

Example 1 with TreeViewModel

use of net.sourceforge.usbdm.deviceEditor.model.TreeViewModel 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);
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) CTabItem(org.eclipse.swt.custom.CTabItem) BaseModel(net.sourceforge.usbdm.deviceEditor.model.BaseModel) SectionModel(net.sourceforge.usbdm.deviceEditor.model.SectionModel) TreeViewModel(net.sourceforge.usbdm.deviceEditor.model.TreeViewModel)

Example 2 with TreeViewModel

use of net.sourceforge.usbdm.deviceEditor.model.TreeViewModel 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);
        }
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) Control(org.eclipse.swt.widgets.Control) BaseModel(net.sourceforge.usbdm.deviceEditor.model.BaseModel) GridData(org.eclipse.swt.layout.GridData) TreeViewModel(net.sourceforge.usbdm.deviceEditor.model.TreeViewModel) TabModel(net.sourceforge.usbdm.deviceEditor.model.TabModel)

Aggregations

BaseModel (net.sourceforge.usbdm.deviceEditor.model.BaseModel)2 TreeViewModel (net.sourceforge.usbdm.deviceEditor.model.TreeViewModel)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 SectionModel (net.sourceforge.usbdm.deviceEditor.model.SectionModel)1 TabModel (net.sourceforge.usbdm.deviceEditor.model.TabModel)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 GridData (org.eclipse.swt.layout.GridData)1 Control (org.eclipse.swt.widgets.Control)1