Ejemplo n.º 1
0
void KPrHtmlExportDialog::delSelectedTemplateFromFavorite()
{
    QString templatePath(ui.kcombobox->itemData(ui.kcombobox->currentIndex()).toString());
    QFile::remove(templatePath);
    // Update list
    ui.kcombobox->removeItem(ui.kcombobox->currentIndex());
}
Ejemplo n.º 2
0
GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface,
                                             const SkDescriptor* desc,
                                             const SkStrokeRec& stroke) {
    if (NULL != desc || !caps().glyphLoadingSupport) {
        return GrPathRendering::createGlyphs(typeface, desc, stroke);
    }

    if (NULL == typeface) {
        typeface = SkTypeface::GetDefaultTypeface();
        SkASSERT(NULL != typeface);
    }

    int faceIndex;
    SkAutoTDelete<SkStream> fontStream(typeface->openStream(&faceIndex));

    const size_t fontDataLength = fontStream->getLength();
    if (0 == fontDataLength) {
        return GrPathRendering::createGlyphs(typeface, NULL, stroke);
    }

    SkTArray<uint8_t> fontTempBuffer;
    const void* fontData = fontStream->getMemoryBase();
    if (NULL == fontData) {
        // TODO: Find a more efficient way to pass the font data (e.g. open file descriptor).
        fontTempBuffer.reset(SkToInt(fontDataLength));
        fontStream->read(&fontTempBuffer.front(), fontDataLength);
        fontData = &fontTempBuffer.front();
    }

    const int numPaths = typeface->countGlyphs();
    const GrGLuint basePathID = this->genPaths(numPaths);
    SkAutoTUnref<GrGLPath> templatePath(SkNEW_ARGS(GrGLPath, (fGpu, SkPath(), stroke)));

    GrGLenum status;
    GL_CALL_RET(status, PathMemoryGlyphIndexArray(basePathID, GR_GL_STANDARD_FONT_FORMAT,
                                                  fontDataLength, fontData, faceIndex, 0,
                                                  numPaths, templatePath->pathID(),
                                                  SkPaint::kCanonicalTextSizeForPaths));

    if (GR_GL_FONT_GLYPHS_AVAILABLE != status) {
        this->deletePaths(basePathID, numPaths);
        return GrPathRendering::createGlyphs(typeface, NULL, stroke);
    }

    // This is a crude approximation. We may want to consider giving this class
    // a pseudo PathGenerator whose sole purpose is to track the approximate gpu
    // memory size.
    const size_t gpuMemorySize = fontDataLength / 4;
    return SkNEW_ARGS(GrGLPathRange, (fGpu, basePathID, numPaths, gpuMemorySize, stroke));
}
Ejemplo n.º 3
0
bool KPrHtmlExportDialog::selectedTemplateIsSystemFavorite()
{
    QString templatePath(ui.kcombobox->itemData(ui.kcombobox->currentIndex()).toString());
    QString dir;

    QStringList dirs(KStandardDirs().findDirs("data", "stage/templates/exportHTML"));
    for (QStringList::ConstIterator path=dirs.constBegin(); path!=dirs.constEnd(); ++path) {
        if (!path->contains(KStandardDirs::locateLocal("data","stage/templates/exportHTML"))) {
            dir = *path;
        }
    }

    return (!dir.isNull()) && templatePath.contains(dir);
}
Ejemplo n.º 4
0
void _ELC_::Project :: loadGenericConfig(_ELENA_::_ConfigFile& config, _ELENA_::path_t configPath, bool root, bool requiered)
{
   // load template list
   if (root)
      loadCategory(config, _ELENA_::opTemplates, configPath);

   // load template
   _ELENA_::ident_t projectTemplate = config.getSetting(ELC_PROJECT_TEMPLATE);
   if (!_ELENA_::emptystr(projectTemplate)) {
      _ELENA_::ident_t templateFile = _settings.get(_ELENA_::opTemplates, projectTemplate, DEFAULT_STR);
      if (!_ELENA_::emptystr(templateFile)) {
         _ELENA_::Path templatePath(templateFile);

         loadConfig(templatePath.c_str(), false, false);
      }
      else raiseErrorIf(requiered, ELC_ERR_INVALID_TEMPLATE, projectTemplate);
   }

   loadConfig(config, configPath);
}
Ejemplo n.º 5
0
void KPrHtmlExportDialog::addSelectedTemplateToFavorite()
{
    QString savePath = KStandardDirs::locateLocal("data", "stage/templates/exportHTML/templates/");
    KUrl templatePath(ui.kcombobox->itemData(ui.kcombobox->currentIndex()).toString());
    savePath += templatePath.fileName();
    if(!(QFile::copy(templatePath.toLocalFile(), savePath))){
        QMessageBox::information(this, i18n("Error"), i18n("There is already a favorite file with this name"));
    }
    else {
        // Update list
        QString name(ui.kcombobox->itemText(ui.kcombobox->currentIndex()));
        // deactivate preview
        disconnect(ui.kcombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(generatePreview()));
        ui.kcombobox->removeItem(ui.kcombobox->currentIndex());
        ui.kcombobox->insertItem(0, name, savePath);
        ui.kcombobox->setCurrentIndex(0);
        //reactivate preview
        connect( ui.kcombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(generatePreview()));
    }
}
Ejemplo n.º 6
0
   /// <summary>Opens a new document using a template file.</summary>
   /// <param name="docPath">Initial document path.</param>
   /// <param name="t">template.</param>
   /// <param name="bMakeVisible">make visible.</param>
   /// <returns></returns>
   /// <exception cref="Logic::ApplicationException">Unable to create document or view<exception>
   /// <exception cref="Logic::FileNotFoundException">Template file is missing<exception>
   DocumentBase* ProjectDocTemplate::OpenDocumentTemplate(Path docPath, const TemplateFile& t, BOOL bMakeVisible)
   {
      AppPath templatePath(t.SubPath);
      ProjectDocument* pDocument = nullptr;

      // Verify template file exists
      if (!templatePath.Exists())
         throw FileNotFoundException(HERE, templatePath);

      // Existing document - close/save
	   if (pDocument = dynamic_cast<ProjectDocument*>(m_pOnlyDoc))
         if (!pDocument->CloseModified())
		      return nullptr; 
	   
      // create new doc
		pDocument = dynamic_cast<ProjectDocument*>(CreateNewDocument());     // Sets m_pOnlyDoc
      if (!pDocument)
         throw ApplicationException(HERE, L"Failed to create document class");

      // Use default title
		//SetDefaultTitle(pDocument);

      // Open template file
		if (!pDocument->OnOpenTemplate(docPath, t))
		{
			// Failed: Cleanup
         delete pDocument;
			return nullptr;
		}
      
      // Set user-selected path (+ update title)
      pDocument->SetPathName(docPath.c_str(), FALSE);

      // Raise 'After New Document'
      pDocument->OnDocumentEvent(CDocument::onAfterNewDocument);

      // Ensure *MODIFIED* because file doesn't exist on disc yet
      pDocument->SetModifiedFlag(TRUE);
	   return pDocument;
   }
Ejemplo n.º 7
0
void
TemplateWindow::CheckTemplates(void)
{
	// This checks for the Templates folder in the Paladin application directory
	// and if it doesn't exist or it's empty, we make sure that it exists and
	// at least has empty project templates for each of the four basic types of projects
	
	DPath templatePath(gAppPath.GetFolder());
	templatePath << "Templates";
	
	bool needInit = false;
	if (!BEntry(templatePath.GetFullPath()).Exists())
		needInit = true;
	
	if (!needInit)
	{
		BDirectory dir(templatePath.GetFullPath());
		if (dir.CountEntries() == 0)
			needInit = true;
	}
	
	if (needInit)
	{
		create_directory(templatePath.GetFullPath(),0777);
		
		DPath tpath(templatePath);
		BFile file;
		BString filedata;
		
		tpath.Append("Addon");
		create_directory(tpath.GetFullPath(),0777);
		tpath.Append("TEMPLATEINFO");
		file.SetTo(tpath.GetFullPath(), B_READ_WRITE | B_CREATE_FILE);
		filedata = "TYPE=Shared\n";
		file.Write(filedata.String(),filedata.Length());
		
		tpath = templatePath;
		tpath.Append("Empty Application");
		create_directory(tpath.GetFullPath(),0777);
		tpath.Append("TEMPLATEINFO");
		file.SetTo(tpath.GetFullPath(), B_READ_WRITE | B_CREATE_FILE);
		filedata = "TYPE=Application\n";
		file.Write(filedata.String(),filedata.Length());
		
		tpath = templatePath;
		tpath.Append("Kernel Driver");
		create_directory(tpath.GetFullPath(),0777);
		tpath.Append("TEMPLATEINFO");
		file.SetTo(tpath.GetFullPath(), B_READ_WRITE | B_CREATE_FILE);
		filedata = "TYPE=Driver\n";
		file.Write(filedata.String(),filedata.Length());
		
		tpath = templatePath;
		tpath.Append("Shared Library");
		create_directory(tpath.GetFullPath(),0777);
		tpath.Append("TEMPLATEINFO");
		file.SetTo(tpath.GetFullPath(), B_READ_WRITE | B_CREATE_FILE);
		filedata = "TYPE=Shared\n";
		file.Write(filedata.String(),filedata.Length());
		
		tpath = templatePath;
		tpath.Append("Static Library");
		create_directory(tpath.GetFullPath(),0777);
		tpath.Append("TEMPLATEINFO");
		file.SetTo(tpath.GetFullPath(), B_READ_WRITE | B_CREATE_FILE);
		filedata = "TYPE=Static\n";
		file.Write(filedata.String(),filedata.Length());
		
	}
}
Ejemplo n.º 8
0
TemplateWindow::TemplateWindow(const BRect &frame)
	:	DWindow(frame,TR("Choose a Project Type"),B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS |
				B_NOT_V_RESIZABLE)
{
	RegisterWindow();
	
	MakeCenteredOnShow(true);
	
	CheckTemplates();
	
	DPath templatePath(gAppPath.GetFolder());
	templatePath << TR("Templates");
	fTempList.ScanFolder(templatePath.GetFullPath());
	
	BView *top = GetBackgroundView();
	
	if (Bounds().Height() < 100)
		ResizeTo(Bounds().Width(),100);
	if (Bounds().Width() < 100)
		ResizeTo(100,Bounds().Height());
	
	BRect r(Bounds());
	BRect bounds(r);
	
	float divider = be_plain_font->StringWidth(TR("Source Control:")) + 5.0;
	
	BMenu *menu = new BMenu("Project Type");
	for (int32 i = 0; i < fTempList.CountTemplates(); i++)
	{
		ProjectTemplate *ptemp = fTempList.TemplateAt(i);
		entry_ref ref = ptemp->GetRef();
		menu->AddItem(new BMenuItem(ref.name,new BMessage(M_TEMPLATE_SELECTED)));
	}
	
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	
	font_height fh;
	be_plain_font->GetHeight(&fh);
	float fontHeight = fh.ascent + fh.descent + fh.leading;
	r.bottom = MAX(fontHeight,20.0);
	
	r.OffsetBy(10,10);
	fTemplateField = new BMenuField(r,"templatefield",TR("Project Type: "), menu);
	fTemplateField->SetDivider(be_plain_font->StringWidth(TR("Project Type:")) + 5);
	top->AddChild(fTemplateField);
	
	// controls for the options for all project types
	r.OffsetBy(0,r.IntegerHeight() + 10);
	fNameBox = new AutoTextControl(r,"namebox",TR("Project Name:"),NULL,
									new BMessage(M_NAME_CHANGED),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fNameBox);
	fNameBox->ResizeToPreferred();
	r.bottom = r.top + fNameBox->Bounds().Height();
	fNameBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fNameBox->SetDivider(divider);
	SetToolTip(fNameBox, "The name of your project. It can be the same as the Target Name, "
						"but it does not have to be.");
	
	r.OffsetBy(0,r.IntegerHeight() + 10);
	fTargetBox = new AutoTextControl(r,"targetbox",TR("Target Name:"),"BeApp",
									new BMessage(M_TARGET_CHANGED),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fTargetBox);
	fTargetBox->ResizeToPreferred();
	r.bottom = r.top + fTargetBox->Bounds().Height();
	fTargetBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fTargetBox->SetDivider(divider);
	SetToolTip(fTargetBox, "The name of the compiled application or library");
	
	if (!BEntry(PROJECT_PATH).Exists())
		create_directory(PROJECT_PATH,0777);
	
	r.OffsetBy(0,r.Height() + 10);
	fPathBox = new PathBox(r,"pathbox",gProjectPath.GetFullPath(),TR("Location:"),
							B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fPathBox);
	fPathBox->ResizeToPreferred();
	r.bottom = r.top + fPathBox->Bounds().Height();
	fPathBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fPathBox->SetDivider(divider);
	SetToolTip(fPathBox, "Set the location for your project.");
	
	menu = new BMenu("SCM Chooser");
	menu->AddItem(new BMenuItem("Mercurial", new BMessage()));
	menu->AddItem(new BMenuItem("Git", new BMessage()));
	menu->AddItem(new BMenuItem("Subversion", new BMessage()));
	menu->AddItem(new BMenuItem("None", new BMessage()));
	
	if (!gHgAvailable)
	{
		menu->ItemAt(0)->SetEnabled(false);
		menu->ItemAt(0)->SetLabel("Mercurial Unavailable");
	}
	
	if (!gGitAvailable)
	{
		menu->ItemAt(1)->SetEnabled(false);
		menu->ItemAt(1)->SetLabel("Git Unavailable");
	}
	
	if (!gSvnAvailable)
	{
		menu->ItemAt(2)->SetEnabled(false);
		menu->ItemAt(2)->SetLabel("Subversion Unavailable");
	}
	
	
	r.OffsetBy(0,r.Height() + 5.0);
	fSCMChooser = new BMenuField(r, "scmchooser", "Source Control: ", menu);
	top->AddChild(fSCMChooser);
	fSCMChooser->SetDivider(divider);
	SetToolTip(fSCMChooser, "Choose the source control manager for your project, if any.");
	
	menu->SetLabelFromMarked(true);
	menu->ItemAt(gDefaultSCM)->SetMarked(true);
	
	BMenuItem *item = menu->FindMarked();
	if (!item->IsEnabled())
	{
		item->SetMarked(false);
		for (int32 i = 0; i < menu->CountItems(); i++)
		{
			if (menu->ItemAt(i)->IsEnabled())
			{
				menu->ItemAt(i)->SetMarked(true);
				break;
			}
		}
	}
	menu->SetLabelFromMarked(true);
	
	r.OffsetBy(0,r.Height() + 5.0);
	fCreateFolder = new BCheckBox(r,"createfolder",TR("Create Project Folder"),NULL);
	fCreateFolder->MoveTo(divider + 10.0, r.top);
	fCreateFolder->SetValue(B_CONTROL_ON);
	top->AddChild(fCreateFolder);
	SetToolTip(fCreateFolder, "If checked, a folder for your project will be created "
							"in the folder in the Location box above.");
	
	r.OffsetBy(0,r.Height() + 5.0);
	fOK = new BButton(r,"ok",TR("Create Project…"), new BMessage(M_CREATE_PROJECT));
	fOK->ResizeToPreferred();
	top->AddChild(fOK);
	fOK->SetEnabled(false);
	fOK->MakeDefault(true);
	
	float offset = fPathBox->Divider();
	fOK->MoveBy(offset,0);
	
	float minwidth = Bounds().Width();
	float minheight = fOK->Frame().bottom + 10.0;
	SetSizeLimits(minwidth,30000,minheight,30000);
	
	gSettings.Lock();
	BRect savedframe;
	if (gSettings.FindRect("template_frame",&savedframe) == B_OK)
		ResizeTo(savedframe.Width(),savedframe.Height());
	else
		ResizeTo(minwidth,minheight);
	gSettings.Unlock();
		
	fNameBox->MakeFocus(true);
}
Ejemplo n.º 9
0
/**
 * @brief Called when user presses "New..." button.
 *
 * Asks filename for new filter from user (using standard
 * file picker dialog) and copies template file to that
 * name. Opens new filterfile for editing.
 * @todo (At least) Warn if user puts filter to outside
 * filter directories?
 * @todo Can global filter path be empty (I think not - Kimmo).
 */
void FileFiltersDlg::OnBnClickedFilterfileNewbutton()
{
    String globalPath = theApp.m_globalFileFilter.GetGlobalFilterPathWithCreate();
    String userPath = theApp.m_globalFileFilter.GetUserFilterPathWithCreate();

    if (globalPath.empty() && userPath.empty())
    {
        LangMessageBox(IDS_FILEFILTER_NO_USERFOLDER, MB_ICONSTOP);
        return;
    }

    // Format path to template file
    String templatePath(globalPath);
    if (templatePath[templatePath.length() - 1] != '\\')
        templatePath += '\\';
    templatePath += FILE_FILTER_TEMPLATE;

    if (paths_DoesPathExist(templatePath.c_str()) != IS_EXISTING_FILE)
    {
        CString msg;
        LangFormatString2(msg, IDS_FILEFILTER_TMPL_MISSING,
                          FILE_FILTER_TEMPLATE, templatePath.c_str());
        AfxMessageBox(msg, MB_ICONERROR);
        return;
    }

    String path = globalPath.empty() ? userPath : globalPath;

    if (!globalPath.empty() && !userPath.empty())
    {
        path = CSharedFilterDlg::PromptForNewFilter(this, globalPath, userPath);
        if (path.empty()) return;
    }

    if (path.length() && path[path.length() - 1] != '\\')
        path += '\\';

    CString s;
    if (SelectFile(GetSafeHwnd(), s, path.c_str(), IDS_FILEFILTER_SAVENEW, IDS_FILEFILTER_FILEMASK,
                   FALSE))
    {
        // Fix file extension
        TCHAR file[_MAX_FNAME] = {0};
        TCHAR ext[_MAX_EXT] = {0};
        TCHAR dir[_MAX_DIR] = {0};
        TCHAR drive[_MAX_DRIVE] = {0};
        _tsplitpath(s, drive, dir, file, ext);
        if (_tcslen(ext) == 0)
        {
            s += FileFilterExt;
        }
        else if (_tcsicmp(ext, FileFilterExt) != 0)
        {
            s = drive;
            s += dir;
            s += file;
            s += FileFilterExt;
        }

        // Open-dialog asks about overwriting, so we can overwrite filter file
        // user has already allowed it.
        if (!CopyFile(templatePath.c_str(), s, FALSE))
        {
            ResMsgBox1(IDS_FILEFILTER_TMPL_COPY, templatePath.c_str(), MB_ICONERROR);
            return;
        }
        EditFileFilter(s);
        FileFilterMgr *pMgr = theApp.m_globalFileFilter.GetManager();
        int retval = pMgr->AddFilter(s);
        if (retval == FILTER_OK)
        {
            // Remove all from filterslist and re-add so we can update UI
            CString selected;
            m_Filters->RemoveAll();
            theApp.m_globalFileFilter.LoadAllFileFilters();
            theApp.m_globalFileFilter.GetFileFilters(m_Filters, selected);

            UpdateFiltersList();
        }
    }
}
Ejemplo n.º 10
0
Project *
App::CreateNewProject(const BMessage &settings)
{
	Project *proj = NULL;
	
	BString projectName, targetName, projectPath, templateName, pldName;
	int32 projectType, scmType;
	bool createFolder, populateProject = true;
	
	settings.FindString("name",&projectName);
	settings.FindString("target",&targetName);
	settings.FindInt32("type",&projectType);
	settings.FindString("path",&projectPath);
	settings.FindInt32("scmtype", &scmType);
	settings.FindBool("createfolder",&createFolder);
	settings.FindString("template", &templateName);
	settings.FindString("pldfile", &pldName);

	if (templateName.CountChars() > 0)
	{
		// Templates are now a directory with a TEMPLATEINFO file. All files in the
		// directory are copies, allowing for much greater flexibility than before.
		
		BString projectFileName(projectName);
		projectFileName << ".pld";
		
		DPath templatePath(gAppPath.GetFolder());
		templatePath << "Templates" << templateName;
		
		// Copy the contents of the chosen template folder to the project path
		DPath sourcePath(templatePath);
		DPath destPath(gProjectPath);
		
		if (createFolder)
		{
			destPath << projectName;
			create_directory(destPath.GetFullPath(), 0700);
		}
		
		BString wildcard("'");
		wildcard << sourcePath.GetFullPath() << "'/*";
		ShellHelper shell("cp -a ");
		shell << wildcard;
		shell.AddQuotedArg(destPath.GetFullPath());
		shell.Run();
		
		// The copy command copies *everything*, so we have to delete the
		// TEMPLATEINFO file.
		DPath templateInfo(destPath);
		templateInfo << "TEMPLATEINFO";
		BEntry infoEntry(templateInfo.GetFullPath());
		infoEntry.Remove();
		infoEntry.Unset();
		
		DPath finalPath;
		
		// Load project and set info or create one, if needed.
		
		// If the settings contain the name of a .pld project file, we'll search
		// for that first. Assuming that it exists, we'll rename that file to the
		// project name specified. If it doesn't exist or the .pld name is empty,
		// we'll create a new project with the appropriate name.
		
		// The pldname field comes from the TEMPLATEINFO file, which can designate
		// the main project file in a template. This allows a template to have
		// multiple project files, such as for the Tracker Add-on development framework
		// which has both a project file for generating the actual addon and another
		// one which is the testing framework.
		bool createProjFile = true;
		if (pldName.CountChars() > 0)
		{
			// If a .pld project file was specified in TEMPLATEINFO, check to see if
			// the file exists and rename it. If it doesn't exist, we'll create a new
			// file, and if a .pld file already exists with the intended name, we won't
			// do anything except tell the user what's happened.
			DPath oldPldNamePath(destPath);
			oldPldNamePath << pldName;
			BEntry oldPldNameEntry(oldPldNamePath.GetFullPath());
			
			DPath newPldNamePath(destPath);
			newPldNamePath << projectFileName;
			
			BEntry newPldNameEntry(newPldNamePath.GetFullPath());
			if (newPldNameEntry.Exists())
			{
				// createProjFile is false here only if there is a .pld file with the
				// user's chosen project name. If that is the case, we keep both files and
				// let the user sort it out.
				BString errMsg = B_TRANSLATE(
					"Project file '%projectname%.pld' already exists. The "
					"original file for this template is '%pldname%'. You'll need "
					"to open the project folder and figure out which one you wish to keep.");
				errMsg.ReplaceFirst("%projectname%", projectName);
				errMsg.ReplaceFirst("%pldname%", pldName);
				ShowAlert(errMsg);
				populateProject = createProjFile = false;
				
				finalPath = newPldNamePath;
			}
			else
			if (oldPldNameEntry.Exists())
			{
				oldPldNameEntry.Rename(projectFileName.String());
				populateProject = createProjFile = false;
				
				finalPath = newPldNamePath;
			}
		}
		
		if (createProjFile)
		{
			proj = Project::CreateProject(projectName.String(), targetName.String(),
									projectType, projectPath.String(), createFolder);
			if (proj)
				finalPath = proj->GetPath();
		}
		else
		{
			proj = new Project();
			if (proj->Load(finalPath.GetFullPath()) != B_OK)
			{
				delete proj;
				return NULL;
			}
		}
	}
	else
	{
		// This case is for stuff like the Quick Import feature
		proj = Project::CreateProject(projectName.String(), targetName.String(),
									projectType, projectPath.String(), createFolder);
	}
	
	if (!proj)
		return NULL;
	
	scm_t detectedSCM = DetectSCM(projectPath);
	proj->SetSourceControl(detectedSCM == SCM_NONE ? (scm_t)scmType : detectedSCM);
	
	gCurrentProject = proj;
	gProjectList->Lock();
	gProjectList->AddItem(proj);
	gProjectList->Unlock();
	
	BRect r(0,0,200,300);
	/*
	r.OffsetTo(gProjectWindowPoint);
	gProjectWindowPoint.x += 25;
	gProjectWindowPoint.y += 25;
	if (gProjectWindowPoint.x < 0)
		gProjectWindowPoint.x = 0;
	if (gProjectWindowPoint.y < 0)
		gProjectWindowPoint.y - 0;
		*/
	ProjectWindow *projwin = new ProjectWindow(r,gCurrentProject);
	projwin->Show();
	
	BEntry entry(gCurrentProject->GetPath().GetFullPath());
	if (entry.InitCheck() == B_OK)
	{
		entry_ref newprojref;
		entry.GetRef(&newprojref);
		UpdateRecentItems(newprojref);
	}
	
	if (populateProject)
	{
		entry_ref addRef;
		int32 i = 0;
		while (settings.FindRef("libs",i++,&addRef) == B_OK)
		{
			if (BEntry(&addRef).Exists())
				proj->AddLibrary(DPath(addRef).GetFullPath());
		}
		
		i = 0;
		BMessage addMsg(M_IMPORT_REFS);
		while (settings.FindRef("refs",i++,&addRef) == B_OK)
			addMsg.AddRef("refs",&addRef);
		PostToProjectWindow(&addMsg,NULL);
	}
	
	return proj;
}
Ejemplo n.º 11
0
bool KPrHtmlExportDialog::selectedTemplateIsFavorite()
{
    QString templatePath(ui.kcombobox->itemData(ui.kcombobox->currentIndex()).toString());
    return templatePath.contains(KStandardDirs::locateLocal("data","stage/templates/exportHTML"));
}
Ejemplo n.º 12
0
TemplateWindow::TemplateWindow(const BRect& frame)
	:
	BWindow(frame, TR("Choose a project type"), B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	RegisterWindow();

	CheckTemplates();

	DPath templatePath(gAppPath.GetFolder());
	templatePath << TR("Templates");
	fTempList.ScanFolder(templatePath.GetFullPath());

	// project type

	BPopUpMenu* projectTypeMenu = new BPopUpMenu("Project type");
	for (int32 i = 0; i < fTempList.CountTemplates(); i++) {
		ProjectTemplate* ptemp = fTempList.TemplateAt(i);
		entry_ref ref = ptemp->GetRef();
		projectTypeMenu->AddItem(new BMenuItem(ref.name,
			new BMessage(M_TEMPLATE_SELECTED)));
	}
	projectTypeMenu->ItemAt(0L)->SetMarked(true);

	fTemplateField = new BMenuField("templatefield", TR("Project type: "),
		projectTypeMenu);
	fTemplateField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// project name

	fNameBox = new AutoTextControl("namebox", TR("Project name:"), "",
		new BMessage(M_NAME_CHANGED));
	SetToolTip(fNameBox, TR("The name of your project. "
		"It can be the same as the Target name, but it does not have to be."));

	// target name

	fTargetBox = new AutoTextControl("targetbox", TR("Target name:"), "BeApp",
		new BMessage(M_TARGET_CHANGED));
	SetToolTip(fTargetBox, TR("The name of the compiled application or library"));

	// project path

	fPathBox = new PathBox("pathbox", gProjectPath.GetFullPath(), "");
	fPathBox->SetExplicitMinSize(BSize(be_plain_font->StringWidth("M") * 36,
		B_SIZE_UNSET)),
	SetToolTip(fPathBox, TR("Set the location for your project."));

	// source control

	BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser");
	scmMenu->AddItem(new BMenuItem(TR("Mercurial"), new BMessage()));
	scmMenu->AddItem(new BMenuItem(TR("Git"), new BMessage()));
	scmMenu->AddItem(new BMenuItem(TR("Subversion"), new BMessage()));
	scmMenu->AddItem(new BMenuItem(TR("None"), new BMessage()));

	if (!gHgAvailable) {
		scmMenu->ItemAt(0)->SetEnabled(false);
		scmMenu->ItemAt(0)->SetLabel(TR("Mercurial unavailable"));
	}
	if (!gGitAvailable) {
		scmMenu->ItemAt(1)->SetEnabled(false);
		scmMenu->ItemAt(1)->SetLabel(TR("Git unavailable"));
	}
	if (!gSvnAvailable) {
		scmMenu->ItemAt(2)->SetEnabled(false);
		scmMenu->ItemAt(2)->SetLabel(TR("Subversion unavailable"));
	}

	fSCMChooser = new BMenuField("scmchooser", TR("Source control: "), scmMenu);
	fSCMChooser->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetToolTip(fSCMChooser,
		TR("Choose the source control manager for your project, if any."));

	scmMenu->ItemAt(gDefaultSCM)->SetMarked(true);

	BMenuItem* item = scmMenu->FindMarked();
	if (!item->IsEnabled()) {
		item->SetMarked(false);
		for (int32 i = 0; i < scmMenu->CountItems(); i++) {
			if (scmMenu->ItemAt(i)->IsEnabled()) {
				scmMenu->ItemAt(i)->SetMarked(true);
				break;
			}
		}
	}

	// create folder check box

	fCreateFolder = new BCheckBox(TR("Create project folder"));
	fCreateFolder->SetValue(B_CONTROL_ON);
	SetToolTip(fCreateFolder, TR("If checked, a folder for your project will be created "
		"in the folder in the Location box above."));

	// create project button

	fCreateProjectButton = new BButton("ok", TR("Create project") B_UTF8_ELLIPSIS,
		new BMessage(M_CREATE_PROJECT));
	fCreateProjectButton->SetEnabled(false);
	fCreateProjectButton->MakeDefault(true);

	// layout

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fTemplateField->CreateLabelLayoutItem(), 0, 0)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0)
				.Add(fTemplateField->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()

			.Add(fNameBox->CreateLabelLayoutItem(), 0, 1)
			.Add(fNameBox->CreateTextViewLayoutItem(), 1, 1)

			.Add(fTargetBox->CreateLabelLayoutItem(), 0, 2)
			.Add(fTargetBox->CreateTextViewLayoutItem(), 1, 2)

			.Add(new BStringView("location", TR("Location:")), 0, 3)
			.Add(fPathBox, 1, 3)

			.Add(fSCMChooser->CreateLabelLayoutItem(), 0, 4)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 4)
				.Add(fSCMChooser->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()

			.Add(fCreateFolder, 1, 5)
			.End()
		.AddGlue()
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(fCreateProjectButton)
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();

	fNameBox->MakeFocus(true);

	CenterOnScreen();
}
Ejemplo n.º 13
0
void ProjectTool::OnMenuEvent(wxCommandEvent& evt)
{
   if (evt.GetId() == MENU_IMPORT_MESH)
   {
      ImportMeshWizard* wizard = new ImportMeshWizard(mFrame);

      // Set initial import path, the user can change it.
      wxString importPath = mSelectedModule->getModulePath();
      importPath.Append("/meshes");
      wizard->importPath->SetPath(importPath);

      if (wizard->RunWizard(wizard->m_pages[0]))
      {
         wxString assetID     = wizard->assetID->GetValue();
         wxString meshPath    = wizard->meshFilePath->GetFileName().GetFullPath();
         wxString meshFile    = wizard->meshFilePath->GetFileName().GetFullName();
         wxString importPath  = wizard->importPath->GetPath();

         // Copy file (optional)
         if (wizard->copyMeshCheck->GetValue())
         {
            wxString moduleMeshPath(importPath);
            moduleMeshPath.Append("/");
            moduleMeshPath.Append(meshFile);

            Torque::Platform.createPath(moduleMeshPath.c_str());
            Torque::Platform.pathCopy(meshPath.c_str(), moduleMeshPath.c_str(), false);
            meshPath = moduleMeshPath;
         }

         // Make path relative to module directory.
         char buf[1024];
         const char* fullPath = Torque::Platform.makeFullPathName(meshPath.c_str(), buf, sizeof(buf), NULL);
         StringTableEntry relativePath = Torque::Platform.makeRelativePathName(fullPath, importPath);

         // Create full import path.
         importPath.Append("/");
         importPath.Append(assetID);
         importPath.Append(".asset.taml");

         // Create asset definition.
         Torque::Scene.createMeshAsset(assetID.c_str(), relativePath, importPath.c_str());
         Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, importPath.c_str());
         refresh();
      }

      wizard->Destroy();
   }

   if (evt.GetId() == MENU_IMPORT_TEXTURE)
   {
      ImportTextureWizard* wizard = new ImportTextureWizard(mFrame);
      
      // Set initial import path, the user can change it.
      wxString importPath = mSelectedModule->getModulePath();
      importPath.Append("/textures");
      wizard->importPath->SetPath(importPath);

      if (wizard->RunWizard(wizard->m_pages[0]))
      {
         wxString assetID = wizard->assetID->GetValue();
         wxString texturePath = wizard->textureFilePath->GetFileName().GetFullPath();
         wxString textureFile = wizard->textureFilePath->GetFileName().GetFullName();
         wxString importPath = wizard->importPath->GetPath();

         // Copy file (optional)
         if (wizard->copyTextureCheck->GetValue())
         {
            wxString moduleTexturePath(importPath);
            moduleTexturePath.Append("/");
            moduleTexturePath.Append(textureFile);

            Torque::Platform.createPath(moduleTexturePath.c_str());
            Torque::Platform.pathCopy(texturePath.c_str(), moduleTexturePath.c_str(), false);
            texturePath = moduleTexturePath;
         }

         // Make path relative to module directory.
         char buf[1024];
         const char* fullPath = Torque::Platform.makeFullPathName(texturePath.c_str(), buf, sizeof(buf), NULL);
         StringTableEntry relativePath = Torque::Platform.makeRelativePathName(fullPath, importPath);

         // Create full import path.
         importPath.Append("/");
         importPath.Append(assetID);
         importPath.Append(".asset.taml");

         // Create asset definition.
         Torque::Scene.createTextureAsset(assetID.c_str(), relativePath, importPath.c_str());
         Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, importPath.c_str());
         refresh();
      }

      wizard->Destroy();
   }

   if (evt.GetId() == MENU_NEW_MATERIAL)
   {
      NewMaterialWizard* wizard = new NewMaterialWizard(mFrame);

      // Set initial import path, the user can change it.
      wxString defaultSavePath = mSelectedModule->getModulePath();
      defaultSavePath.Append("/materials");
      wizard->savePath->SetPath(defaultSavePath);

      if (wizard->RunWizard(wizard->m_pages[0]))
      {
         wxString assetID = wizard->assetID->GetValue();
         wxString savePath = wizard->savePath->GetPath();

         wxString assetPath("");
         assetPath.Append(savePath);
         assetPath.Append("/");
         assetPath.Append(assetID);
         assetPath.Append(".asset.taml");

         wxString templateFileName("");
         templateFileName.Append(assetID);
         templateFileName.Append(".taml");

         wxString templatePath("");
         templatePath.Append(savePath);
         templatePath.Append("/");
         templatePath.Append(templateFileName);

         // Create material template and then asset.
         Torque::Scene.createMaterialTemplate(templatePath.c_str());
         Torque::Scene.createMaterialAsset(assetID.c_str(), templateFileName.c_str(), assetPath.c_str());
         Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, assetPath.c_str());
         refresh();
      }
   }
}
Ejemplo n.º 14
-3
Path TemplateCache::resolvePath(const Path& path) const
{
	if ( path.isAbsolute() )
		return path;

	for(std::vector<Path>::const_iterator it = _includePaths.begin(); it != _includePaths.end(); ++it)
	{
		Path templatePath(*it, path);

		File templateFile(templatePath);
		if ( templateFile.exists() )
		{
			if ( _logger )
			{
				poco_trace_f2(*_logger, "%s template file resolved to %s", path.toString(), templatePath.toString());
			}
			return templatePath;
		}
		if ( _logger )
		{
			poco_trace_f1(*_logger, "%s doesn't exist", templatePath.toString());
		}
	}

	throw FileNotFoundException(path.toString());
}