Search in sources :

Example 1 with InterfaceType

use of net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType in project usbdm-eclipse-plugins by podonoghue.

the class CDTProjectManager method createUSBDMProject.

/**
 * Create USBDM CDT project
 *
 * @param paramMap      Parameters for project (from Wizard dialogue)
 * @param monitor       Progress monitor
 *
 * @return  Created project
 *
 * @throws Exception
 */
public IProject createUSBDMProject(Map<String, String> paramMap, IProgressMonitor progressMonitor) throws Exception {
    SubMonitor monitor = SubMonitor.convert(progressMonitor);
    // Create model project and accompanied descriptions
    IProject project;
    try {
        monitor.beginTask("Create configuration", 100);
        String projectName = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_NAME_KEY), paramMap);
        String directoryPath = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_HOME_PATH_KEY), paramMap);
        String projectType = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_OUTPUT_TYPE_KEY), paramMap);
        InterfaceType interfaceType = InterfaceType.valueOf(paramMap.get(UsbdmConstants.INTERFACE_TYPE_KEY));
        boolean hasCCNature = Boolean.valueOf(paramMap.get(UsbdmConstants.HAS_CC_NATURE_KEY));
        String artifactName = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_ARTIFACT_KEY), paramMap);
        if ((artifactName == null) || (artifactName.length() == 0)) {
            artifactName = "${ProjName}";
        }
        project = createProject(projectName, directoryPath, hasCCNature, monitor.newChild(70));
        CoreModel coreModel = CoreModel.getDefault();
        // Create project description
        ICProjectDescription projectDescription = coreModel.createProjectDescription(project, false);
        Assert.isNotNull(projectDescription, "createProjectDescription returned null");
        // Create one configuration description
        ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
        IProjectType type = ManagedBuildManager.getProjectType(projectType);
        Assert.isNotNull(type, "project type not found");
        ManagedProject mProj = new ManagedProject(project, type);
        info.setManagedProject(mProj);
        IConfiguration[] cfgs = type.getConfigurations();
        Assert.isNotNull(cfgs, "configurations not found");
        Assert.isTrue(cfgs.length > 0, "no configurations found in the project type");
        String configurationName = null;
        String os = System.getProperty("os.name");
        switch(interfaceType) {
            case T_ARM:
                configurationName = ARM_CONFIGURATION_ID;
                break;
            case T_CFV1:
            case T_CFVX:
                configurationName = COLDFIRE_CONFIGURATION_ID;
                break;
        }
        for (IConfiguration configuration : cfgs) {
            String configId = configuration.getId();
            if (!configId.startsWith(configurationName)) {
                continue;
            }
            String id = ManagedBuildManager.calculateChildId(configuration.getId(), null);
            Configuration config = new Configuration(mProj, (Configuration) configuration, id, false, true, false);
            config.setArtifactName(artifactName);
            CConfigurationData data = config.getConfigurationData();
            Assert.isNotNull(data, "data is null for created configuration");
            projectDescription.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
        }
        Assert.isTrue(projectDescription.getConfigurations().length > 0, "No Configurations!");
        coreModel.setProjectDescription(project, projectDescription);
        // }
        if (!(hasCCNature && !project.hasNature(CCProjectNature.CC_NATURE_ID))) {
            CCProjectNature.addCCNature(project, monitor.newChild(5));
        }
        CoreModel.getDefault().updateProjectDescriptions(new IProject[] { project }, monitor);
        if (!(hasCCNature && !project.hasNature(CCProjectNature.CC_NATURE_ID))) {
            CCProjectNature.addCCNature(project, monitor.newChild(5));
        }
    } finally {
        monitor.done();
    }
    return project;
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) Configuration(org.eclipse.cdt.managedbuilder.internal.core.Configuration) IProjectType(org.eclipse.cdt.managedbuilder.core.IProjectType) SubMonitor(org.eclipse.core.runtime.SubMonitor) CConfigurationData(org.eclipse.cdt.core.settings.model.extension.CConfigurationData) IProject(org.eclipse.core.resources.IProject) InterfaceType(net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType) CoreModel(org.eclipse.cdt.core.model.CoreModel) ManagedBuildInfo(org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo) ManagedProject(org.eclipse.cdt.managedbuilder.internal.core.ManagedProject) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration)

Example 2 with InterfaceType

use of net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDebuggerPanel method initializeFrom.

/**
 * Initialises this panel's controls with values from the given launch
 * configuration. This method is called when a configuration is selected to
 * view or edit, after this tab's control has been created.
 *
 * @param configuration
 *           launch configuration
 * @throws Exception
 */
public void initializeFrom(ILaunchConfiguration configuration) throws Exception {
    try {
        // Get interface type from settings
        InterfaceType interfaceType = null;
        ToolInformationData toolInformationData = null;
        if (configuration != null) {
            // System.err.println("UsbdmDebuggerPanel.initializeFrom() #1 "+configuration);
            String interfaceTypeName = configuration.getAttribute(USBDM_GDB_INTERFACE_TYPE_KEY, (String) null);
            if (interfaceTypeName != null) {
                interfaceType = InterfaceType.valueOf(interfaceTypeName);
            // System.err.println("Setting interface to launch saved value = "+interfaceType.toString());
            }
            // Try to get tool information from project via configuration
            toolInformationData = getToolInformationDataFromConfig(configuration);
        }
        Boolean discardSettings = (configuration == null);
        if ((interfaceType == null) || ((toolInformationData != null) && !toolInformationData.applicableTo(interfaceType))) {
            // Interface type not set or incompatible - reset settings
            // System.err.println("UsbdmDebuggerPanel.initializeFrom() #2 "+configuration);
            discardSettings = true;
            // Interface type not set or incompatible - reset
            if (toolInformationData == null) {
                // Use ARM as default
                interfaceType = InterfaceType.T_ARM;
            // System.err.println("Setting interface to default =
            // "+interfaceType.toString());
            } else {
                // Use tool default
                interfaceType = toolInformationData.getPreferredInterfaceType();
            // System.err.println("Setting interface to tool default =
            // "+interfaceType.toString());
            }
        }
        // System.err.println("Interface = "+interfaceType.toString());
        // Populate & set the initial interface
        populateInterfaceTypes(interfaceType);
        // Load default settings for this target
        // System.err.println("UsbdmDebuggerPanel.initializeFrom() new fGdbServerParameters");
        setGdbServerParameters(GdbServerParameters.getDefaultServerParameters(interfaceType));
        // Update from configuration (if appropriate)
        if (!discardSettings) {
            // Only load if appropriate to current interface
            // System.err.println("Loading fGdbServerParameters from settings");
            fGdbServerParameters.initializeFrom(configuration, USBDM_LAUNCH_ATTRIBUTE_KEY);
        }
        // Load GDB Server parameters into controls
        // System.err.println("Loading fGdbServerParameters into controls");
        loadGdbServerParameters();
        if (!discardSettings) {
            // Only load settings if appropriate to interface
            fTextGdbBinPath.setText(configuration.getAttribute(USBDM_GDB_BIN_PATH_KEY, ""));
            fTextGdbCommand.setText(configuration.getAttribute(USBDM_GDB_COMMAND_KEY, ""));
            String buildToolId = configuration.getAttribute(USBDM_BUILD_TOOL_KEY, "");
            ToolInformationData toolInfo = ToolInformationData.get(buildToolId);
            if (toolInfo != null) {
                fComboBuildTool.setText(ToolInformationData.get(buildToolId).getDescription());
            } else {
                fComboBuildTool.select(0);
            }
            buildToolSelectionChanged();
        // boolean verboseModeAttr = false; // configuration.getAttribute(
        // // ATTR_DEBUGGER_VERBOSE_MODE,
        // // false);
        // btnVerboseMode.setSelection(verboseModeAttr);
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
Also used : InterfaceType(net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType) ToolInformationData(net.sourceforge.usbdm.constants.ToolInformationData) CoreException(org.eclipse.core.runtime.CoreException)

Example 3 with InterfaceType

use of net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDebuggerPanel method populateGdbServerControls.

/**
 * Populate multiple fields from the fGdbServerParameters<br>
 *
 * It will update fGdbServerParameters to default if incompatible with current
 * interface type
 *
 * @throws Exception
 */
private void populateGdbServerControls() throws Exception {
    InterfaceType interfaceType = getInterfaceType();
    if ((fGdbServerParameters == null) || (fGdbServerParameters.getInterfaceType() != interfaceType)) {
        // Make GDB server parameters consistent with interface
        setGdbServerParameters(GdbServerParameters.getDefaultServerParameters(interfaceType));
    }
    loadGdbServerParameters();
}
Also used : InterfaceType(net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType)

Example 4 with InterfaceType

use of net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType in project usbdm-eclipse-plugins by podonoghue.

the class GdbServerParameters method getInitializedServerParameters.

/**
 * Create a GdbServerParameters from a map of launch settings
 *
 * @param attributes Map to load settings from
 *
 * @return GdbServerParameters or null on error
 */
public static GdbServerParameters getInitializedServerParameters(Map<String, Object> attributes) {
    if (attributes == null) {
        return null;
    }
    String interfaceName = null;
    interfaceName = CDebugUtils.getAttribute(attributes, UsbdmDebuggerPanel.USBDM_GDB_INTERFACE_TYPE_KEY, "");
    if (interfaceName.isEmpty()) {
        return null;
    }
    GdbServerParameters gdbServerParameters = null;
    try {
        InterfaceType interfaceType = InterfaceType.valueOf(interfaceName);
        if (interfaceType == null) {
            return null;
        }
        gdbServerParameters = GdbServerParameters.getDefaultServerParameters(interfaceType);
        gdbServerParameters.initializeFrom(attributes, UsbdmDebuggerPanel.USBDM_LAUNCH_ATTRIBUTE_KEY);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return gdbServerParameters;
}
Also used : InterfaceType(net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType) UsbdmException(net.sourceforge.usbdm.jni.UsbdmException) CoreException(org.eclipse.core.runtime.CoreException)

Example 5 with InterfaceType

use of net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDebuggerPanel method createUsbdmParametersGroup.

/**
 * Create USBDM Parameters selection Group
 *
 * @param parent Parent of group
 */
protected void createUsbdmParametersGroup(Composite parent) {
    // System.err.println("createUsbdmControl()");
    Group group = new Group(parent, SWT.NONE);
    group.setText("USBDM Parameters");
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    RowLayout layout = new RowLayout();
    layout.center = true;
    layout.spacing = 10;
    layout.wrap = false;
    group.setLayout(layout);
    // 
    // Create Combo for interface
    // 
    Label label = new Label(group, SWT.NONE);
    // $NON-NLS-1$
    label.setText("Interface:");
    fComboInterfaceType = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
    fInterfaceTypes = new InterfaceType[InterfaceType.values().length];
    fComboInterfaceType.select(0);
    // 
    // Create Device selection group
    // 
    label = new Label(group, SWT.NONE);
    label.setText("Target Device:");
    fTextTargetDeviceName = new Text(group, SWT.BORDER | SWT.READ_ONLY | SWT.CENTER);
    fTextTargetDeviceName.setLayoutData(new RowData(200, SWT.DEFAULT));
    fButtonTargetDeviceSelect = new Button(group, SWT.NONE);
    fButtonTargetDeviceSelect.setText("Device...");
    fButtonTargetDeviceSelect.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            InterfaceType interfaceType = getInterfaceType();
            DeviceSelector ds = new DeviceSelector(getShell(), interfaceType.targetType, fTextTargetDeviceName.getText());
            if (ds.open() == Window.OK) {
                fTextTargetDeviceName.setText(ds.getText());
                Device device = ds.getDevice();
                if (device != null) {
                    fSuspendUpdate++;
                    fClockType = device.getClockType();
                    fGdbServerParameters.setClockTrimFrequency(device.getDefaultClockTrimFreq());
                    fGdbServerParameters.setNvmClockTrimLocation(device.getDefaultClockTrimNVAddress());
                    populateTrim();
                    fSuspendUpdate--;
                    doUpdate();
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) DeviceSelector(net.sourceforge.usbdm.deviceDatabase.ui.DeviceSelector) Device(net.sourceforge.usbdm.deviceDatabase.Device) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) RowData(org.eclipse.swt.layout.RowData) InterfaceType(net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

InterfaceType (net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType)6 CoreException (org.eclipse.core.runtime.CoreException)3 ToolInformationData (net.sourceforge.usbdm.constants.ToolInformationData)1 Device (net.sourceforge.usbdm.deviceDatabase.Device)1 DeviceSelector (net.sourceforge.usbdm.deviceDatabase.ui.DeviceSelector)1 UsbdmException (net.sourceforge.usbdm.jni.UsbdmException)1 CoreModel (org.eclipse.cdt.core.model.CoreModel)1 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)1 CConfigurationData (org.eclipse.cdt.core.settings.model.extension.CConfigurationData)1 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)1 IProjectType (org.eclipse.cdt.managedbuilder.core.IProjectType)1 Configuration (org.eclipse.cdt.managedbuilder.internal.core.Configuration)1 ManagedBuildInfo (org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo)1 ManagedProject (org.eclipse.cdt.managedbuilder.internal.core.ManagedProject)1 IProject (org.eclipse.core.resources.IProject)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1