Ejemplo n.º 1
0
std::unique_ptr<Project> JsonImporter::ImportProject(FileManager& fileManager, const filesystem::path& projectFile)
{
    auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), projectFile);

    if (internal::IsValidProject(json))
    {
        auto project = std::make_unique<Project>();

        project->SetName(json["project"]);
        project->SetFile(projectFile);

        for (auto& config : json["configs"])
        {
            project->AddConfiguration(internal::ImportConfig(config));
        }

        for (auto& filePath : json["files"])
        {
            project->AddFile(fileManager.GetOrCreateFile(filePath));
        }

        return project;
    }

    return nullptr;
}
Ejemplo n.º 2
0
void WeatherRouting::GenerateBatch()
{
    RouteMapOverlay *routemapoverlay = CurrentRouteMap(true);
    if(!routemapoverlay)
    {
        wxMessageDialog mdlg(this, _("Must select a configuration to generate from"),
                             _("Weather Routing"), wxOK | wxICON_ERROR);
        mdlg.ShowModal();
        return;
    }

    RouteMapConfiguration configuration = routemapoverlay->GetConfiguration();
    ConfigurationBatchDialog &dlg = m_ConfigurationBatchDialog;

    wxTimeSpan StartSpan, StartSpacingSpan;
    double days, hours;

    dlg.m_tStartDays->GetValue().ToDouble(&days);
    StartSpan = wxTimeSpan::Days(days);

    dlg.m_tStartHours->GetValue().ToDouble(&hours);
    StartSpan += wxTimeSpan::Hours(hours);

    dlg.m_tStartSpacingDays->GetValue().ToDouble(&days);
    StartSpacingSpan = wxTimeSpan::Days(days);

    dlg.m_tStartSpacingHours->GetValue().ToDouble(&hours);
    StartSpacingSpan += wxTimeSpan::Hours(hours);

    wxDateTime EndTime = configuration.StartTime+StartSpan;
    for(; configuration.StartTime <= EndTime; configuration.StartTime += StartSpacingSpan)
    {
        for(std::vector<BatchSource*>::iterator it = dlg.sources.begin();
            it != dlg.sources.end(); it++)
        {
            configuration.Start = (*it)->Name;

            for(std::list<BatchDestination*>::iterator it2 = (*it)->destinations.begin();
                it2 != (*it)->destinations.end(); it2++)
            {
                configuration.End = (*it2)->Name;

                for(unsigned int boatindex = 0; boatindex < dlg.m_lBoats->GetCount(); boatindex++)
                {
                    configuration.boatFileName = dlg.m_lBoats->GetString(boatindex);
                    AddConfiguration(configuration);
                }
            }
        }
    }
    DeleteRouteMap(routemapoverlay);
}
Ejemplo n.º 3
0
void WeatherRouting::OnNew( wxCommandEvent& event )
{
    RouteMapConfiguration configuration;
    if(CurrentRouteMap())
        configuration = CurrentRouteMap()->GetConfiguration();
    else
        configuration = DefaultConfiguration();

#if 0 /* to have a unique name */
    for(int idx = 0;;idx++)
    {
        wxString name = configuration.Name;
        wxString n1 = name.BeforeLast('-'), n2 = name.AfterLast('-');
        long l;
        if(n1.size() && n2.ToLong(&l))
            name = n1;

        if(idx > 0)
            name += wxString::Format(_T("-%d"), idx);
        for(int i=0; i<m_lWeatherRoutes->GetItemCount(); i++)
        {
            WeatherRoute *weatherroute =
                reinterpret_cast<WeatherRoute*>(wxUIntToPtr(m_lWeatherRoutes->GetItemData(i)));
            RouteMapConfiguration c = weatherroute->routemapoverlay->GetConfiguration();
            if(c.Name == name)
                goto outer_continue;
        }
        configuration.Name = name;
        break;
outer_continue:
    }
#endif

    AddConfiguration(configuration);

    m_lWeatherRoutes->SetItemState(m_lWeatherRoutes->GetItemCount() - 1,
                                   wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);

    OnEditConfiguration();
}

void WeatherRouting::OnBatch( wxCommandEvent& event )
{
    m_ConfigurationBatchDialog.Reset();
    m_ConfigurationBatchDialog.Show();
}
Ejemplo n.º 4
0
bool VcImporter::ConvertProject(VcProjectData& data)
{
    wxXmlDocument doc(data.filepath);
    if(!doc.IsOk()) {
        return false;
    }

    // to create a project skeleton, we need the project type
    // since VS allows each configuration to be of different
    // type, while LE allows single type for all configurations
    // we use the first configuration type that we find
    wxXmlNode* configs = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("Configurations"));
    if(!configs) {
        return false;
    }

    // find the first configuration node
    wxXmlNode* config = XmlUtils::FindFirstByTagName(configs, wxT("Configuration"));
    if(!config) return false;
    // read the configuration type, default is set to Executeable
    long type = XmlUtils::ReadLong(config, wxT("ConfigurationType"), 1);
    wxString projectType;
    wxString errMsg;
    switch(type) {
    case 2: // dll
        projectType = Project::DYNAMIC_LIBRARY;
        break;
    case 4: // static library
        projectType = Project::STATIC_LIBRARY;
        break;
    case 1: // exe
    default:
        projectType = Project::EXECUTABLE;
        break;
    }
    // now we can create the project
    wxFileName fn(data.filepath);
    fn.MakeAbsolute();
    if(!WorkspaceST::Get()->CreateProject(data.name, fn.GetPath(), projectType, true, errMsg)) {
        return false;
    }

    // get the new project instance
    ProjectPtr proj = WorkspaceST::Get()->FindProjectByName(data.name, errMsg);
    ProjectSettingsPtr le_settings(new ProjectSettings(NULL));
    // remove the default 'Debug' configuration
    le_settings->RemoveConfiguration(wxT("Debug"));
    le_settings->SetProjectType(projectType);

    while(config) {
        if(config->GetName() == wxT("Configuration")) {
            AddConfiguration(le_settings, config);
        }
        config = config->GetNext();
    }
    proj->SetSettings(le_settings);
    // add all virtual folders
    wxXmlNode* files = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("Files"));
    if(files) {
        proj->BeginTranscation();
        CreateFiles(files, wxEmptyString, proj);
        proj->CommitTranscation();
    }
    return true;
}