Search in sources :

Example 1 with DeviceDatabase

use of net.sourceforge.usbdm.deviceDatabase.DeviceDatabase in project usbdm-eclipse-plugins by podonoghue.

the class DeviceSelectorPanel method buildTreeModel.

/**
 * Build the model representing the device choices
 * @param pm
 *
 * @return
 * @throws InterruptedException
 */
void buildTreeModel(IProgressMonitor pm, BaseModel root) throws InterruptedException {
    fDeviceName = null;
    if ((fDeviceDatabase == null) || (fDeviceDatabase.getTargetType() != fTargetType)) {
        fDeviceDatabase = new DeviceDatabase(fTargetType);
    }
    if (!fDeviceDatabase.isValid()) {
        fDeviceText.setText("<Device database invalid>");
        return;
    }
    String currentFamily = null;
    BaseModel familyTree = null;
    String currentSubFamily = null;
    BaseModel subFamilyTree = null;
    for (Device device : fDeviceDatabase.getDeviceList()) {
        IProgressMonitor sub = new SubProgressMonitor(pm, 1);
        try {
            if (device.isHidden()) {
                continue;
            }
            String family = getFamilyName(device.getName());
            if ((familyTree == null) || (currentFamily == null) || !currentFamily.equalsIgnoreCase(family)) {
                familyTree = findCategoryNode(root, family);
            }
            if (familyTree == null) {
                currentFamily = family;
                familyTree = new CategoryModel(root, family);
                currentSubFamily = null;
                subFamilyTree = null;
            }
            String subFamily = getSubFamilyNamePrefix(device.getName());
            if ((subFamilyTree == null) || (currentSubFamily == null) || (!currentSubFamily.equalsIgnoreCase(subFamily))) {
                subFamilyTree = findCategoryNode(familyTree, subFamily);
            }
            if (subFamilyTree == null) {
                currentSubFamily = subFamily;
                subFamilyTree = new CategoryModel(familyTree, currentSubFamily);
            }
            if (device.getName().equalsIgnoreCase(currentSubFamily)) {
                continue;
            }
            new DeviceModel(subFamilyTree, device.getName());
            if (pm.isCanceled()) {
                throw new InterruptedException();
            }
        } finally {
            sub.done();
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DeviceDatabase(net.sourceforge.usbdm.deviceDatabase.DeviceDatabase) Device(net.sourceforge.usbdm.deviceDatabase.Device) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 2 with DeviceDatabase

use of net.sourceforge.usbdm.deviceDatabase.DeviceDatabase in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDynamicOptionPage_N method main.

// @Override
// public boolean canFlipToNextPage() {
// return isPageComplete();
// }
/**
 * Test main
 *
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Packages Available");
    shell.setLayout(new FillLayout());
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new FillLayout());
    String deviceName = "FRDM_K22F";
    // String deviceName = "FRDM_KL27Z";
    // String deviceName = "MKL27Z64M4";
    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("linkerFlashSize", "0x100");
    paramMap.put("linkerRamSize", "0x100");
    paramMap.put("outputType", "xxxxxProjectType.exe");
    paramMap.put("targetDevice", deviceName);
    // UsbdmDynamicOptionPage_N page = new UsbdmDynamicOptionPage_N(deviceName, paramMap, "usbdm-project-options-page");
    // UsbdmDynamicOptionPage_N page = new UsbdmDynamicOptionPage_N(deviceName, paramMap, "kinetis-CPP-abstraction-options-page");
    WizardPageInformation wizardPageInfo = new WizardPageInformation("kinetis-sdk-options-page", "Kinetis", "Kinetis description");
    DeviceDatabase deviceDatabase = new DeviceDatabase(TargetType.T_ARM);
    Device device = deviceDatabase.getDevice(deviceName);
    ProjectActionList projectActionList = device.getProjectActionList(paramMap);
    UsbdmDynamicOptionPage_N page = new UsbdmDynamicOptionPage_N(device, projectActionList, wizardPageInfo);
    page.createControl(composite);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    page.getPageData(paramMap);
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) DeviceDatabase(net.sourceforge.usbdm.deviceDatabase.DeviceDatabase) Device(net.sourceforge.usbdm.deviceDatabase.Device) ProjectActionList(net.sourceforge.usbdm.packageParser.ProjectActionList) FillLayout(org.eclipse.swt.layout.FillLayout) Display(org.eclipse.swt.widgets.Display) WizardPageInformation(net.sourceforge.usbdm.packageParser.WizardPageInformation)

Aggregations

Device (net.sourceforge.usbdm.deviceDatabase.Device)2 DeviceDatabase (net.sourceforge.usbdm.deviceDatabase.DeviceDatabase)2 HashMap (java.util.HashMap)1 ProjectActionList (net.sourceforge.usbdm.packageParser.ProjectActionList)1 WizardPageInformation (net.sourceforge.usbdm.packageParser.WizardPageInformation)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1