Search in sources :

Example 1 with DeviceInfo

use of net.sourceforge.usbdm.deviceEditor.information.DeviceInfo in project usbdm-eclipse-plugins by podonoghue.

the class DeviceVariantModel method modelElementChanged.

@Override
public void modelElementChanged(ObservableModel model) {
    if (model instanceof DeviceInfo) {
        DeviceInfo deviceInfo = (DeviceInfo) model;
        String variantName = deviceInfo.getVariantName();
        setValueAsString(variantName);
    }
}
Also used : DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Example 2 with DeviceInfo

use of net.sourceforge.usbdm.deviceEditor.information.DeviceInfo in project usbdm-eclipse-plugins by podonoghue.

the class TestParseXML method main.

public static void main(String[] args) throws Exception {
    Path directory = Paths.get("");
    // Locate data output directory
    Path outputDirectory = directory.resolve("hardware2");
    // Create output directories if needed
    if (!outputDirectory.toFile().exists()) {
        Files.createDirectory(outputDirectory);
    }
    DirectoryStream<Path> folderStream = Files.newDirectoryStream(directory.resolve("hardware").toAbsolutePath(), sourceFilter);
    for (Path filePath : folderStream) {
        if (!Files.isRegularFile(filePath)) {
            continue;
        }
        /*
          * Process each input file
          */
        System.err.println("Processing " + filePath.getFileName() + " ======================== ");
        DeviceInfo deviceInfo = DeviceInfo.create(filePath);
        // report(deviceInfo);
        Path xmlFilePath = outputDirectory.resolve(filePath.getFileName());
        FamilyXmlWriter writer = new FamilyXmlWriter(deviceInfo);
        writer.writeXmlFile(xmlFilePath);
    }
}
Also used : Path(java.nio.file.Path) FamilyXmlWriter(net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Example 3 with DeviceInfo

use of net.sourceforge.usbdm.deviceEditor.information.DeviceInfo in project usbdm-eclipse-plugins by podonoghue.

the class DeviceEditor method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    SubMonitor.convert(monitor, 100);
    if (fFactory == null) {
        return;
    }
    DeviceInfo deviceInfo = fFactory.getDeviceInfo();
    if (deviceInfo == null) {
        return;
    }
    deviceInfo.saveSettings(fProject);
    Activator activator = Activator.getDefault();
    if (activator != null) {
        IDialogSettings dialogSettings = activator.getDialogSettings();
        if (dialogSettings != null) {
            dialogSettings.put("ActiveTab", fTabFolder.getSelectionIndex());
        }
    }
}
Also used : Activator(net.sourceforge.usbdm.deviceEditor.Activator) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Example 4 with DeviceInfo

use of net.sourceforge.usbdm.deviceEditor.information.DeviceInfo in project usbdm-eclipse-plugins by podonoghue.

the class DeviceEditor method doSaveAs.

@Override
public void doSaveAs() {
    FileDialog dialog = new FileDialog(getSite().getShell(), SWT.SAVE);
    dialog.setFilterExtensions(new String[] { "*" + DeviceInfo.PROJECT_FILE_EXTENSION });
    dialog.setFilterPath(fPath.getParent().toString());
    String result = dialog.open();
    if (result != null) {
        DeviceInfo deviceInfo = fFactory.getDeviceInfo();
        if (deviceInfo == null) {
            return;
        }
        Path path = FileSystems.getDefault().getPath(result);
        deviceInfo.saveSettingsAs(path, fProject);
    }
}
Also used : Path(java.nio.file.Path) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 5 with DeviceInfo

use of net.sourceforge.usbdm.deviceEditor.information.DeviceInfo in project usbdm-eclipse-plugins by podonoghue.

the class CreateHardwareFiles method main.

public static void main(String[] args) throws Exception {
    Path directory = Paths.get("");
    // Locate data output directory
    Path xmlDirectory = directory.resolve("hardware");
    // Create output directories if needed
    if (!xmlDirectory.toFile().exists()) {
        Files.createDirectory(xmlDirectory);
    }
    // Path to data folder - csv files describing the device
    DirectoryStream<Path> folderStream = Files.newDirectoryStream(directory.resolve("data").toAbsolutePath(), sourceFilter);
    for (Path filePath : folderStream) {
        if (!Files.isRegularFile(filePath)) {
            continue;
        }
        /*
          * Process each input file
          */
        System.err.println("Processing " + filePath.getFileName() + " ======================== ");
        String sourceName = filePath.getFileName().toString();
        String destinationName = sourceName.replaceAll("(^.*)" + Pattern.quote(DeviceInfo.HARDWARE_CSV_FILE_EXTENSION) + "$", "$1" + DeviceInfo.HARDWARE_FILE_EXTENSION);
        DeviceInfo deviceInfo = DeviceInfo.create(filePath);
        Path xmlFilePath = xmlDirectory.resolve(destinationName);
        FamilyXmlWriter writer = new FamilyXmlWriter(deviceInfo);
        writer.writeXmlFile(xmlFilePath);
    }
}
Also used : Path(java.nio.file.Path) FamilyXmlWriter(net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Aggregations

DeviceInfo (net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)7 Path (java.nio.file.Path)4 FamilyXmlWriter (net.sourceforge.usbdm.deviceEditor.peripherals.FamilyXmlWriter)2 Activator (net.sourceforge.usbdm.deviceEditor.Activator)1 WriteFamilyCpp (net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1