Beispiel #1
0
void 	SaveConsole (void)
{
	
	_String  	sDP = dialogPrompt;
				
	dialogPrompt = "Save HyPhy console to:";
	
	_String		fileName(WriteFileDialogInput ());
	
	if (fileName.sLength == 0)
		return;
	
	FILE *      f = doFileOpen (fileName.getStr(),"w");
	if (!f)
	{
		fileName = _String ("Could not open '") & fileName & "' for writing.";
		ProblemReport (fileName, (Ptr)hyphyConsoleWindow);
	}
	else
	{
		fileName = GetVersionString () & " console saved on " & GetTimeStamp () & "\n\n";
		fwrite (fileName.sData,1,fileName.sLength, f);
		_String *cS;
		((_HYTextBox*)hyphyConsoleWindow->GetObject (0))->StoreText (cS);	
		#ifdef __WINDOZE__
			for (long k=0; k<cS->sLength; k++)
			{
				char c = cS->sData[k];
				if (c=='\r')
					fprintf (f,"\n");
				else
					fputc (c,f);
			}
		#else
			fprintf (f,"%s",cS->sData);		
		#endif
		fclose (f);
		DeleteObject (cS);
	}
	
	dialogPrompt = sDP;
}
Beispiel #2
0
//__________________________________________________________________
void		_HYSequencePane::EditSequenceName (long k)
{
	_String prompt ("Edit Sequence Name"),
			*present = ((_String*)rowHeaders (speciesIndex.lData[k])),
			edited = *present;
						
	if (EnterStringDialog ( edited, prompt,(Ptr)messageRecipient))
	{
		if (!edited.Equal (present))
		{
			if (rowHeaders.Find (&edited)>=0)
			{
				prompt = _String("Another sequence is already named ") & edited & ". Please choose another name.";
				ProblemReport (prompt, (Ptr)messageRecipient);	
				return;
			}
			present->Duplicate (&edited);
			SetHeaders (nil,true);
			_MarkForUpdate();
		}
	}
}
//__________________________________________________________________
void    _HYConsoleWindow::_DoPrint          (void)
{
    _String NIY ("Printing has not yet been implemented\n");
    ProblemReport (NIY);
}
Beispiel #4
0
void _HYConsoleWindow::DoEcho	     (void)
{
	_List			menuChoices;
	
	if (!echoFileRef)
	{
		menuChoices && & startEchoing;
	}
	else
	{
		menuChoices && & stopEchoing;
		
		if (echoStatus == 0) // paused
			menuChoices && & resumeEchoing;
		else
			menuChoices && & pauseEchoing;
	}
	
	int h,v;
	
	_HYButtonBar * bb = (_HYButtonBar*)GetObject (2);
	
	bb->GetButtonLoc(2,h,v,true);
	
	_String choice = HandlePullDown (menuChoices,h,v,0);
	
	if (choice.Equal (&startEchoing))
	{
		_String saveDP (dialogPrompt),
				fileName;
				
		dialogPrompt = "Echo HyPhy console to:";
		fileName = WriteFileDialogInput ();
		if (fileName.sLength)
		{
			echoFileRef = doFileOpen (fileName.sData,"w");
			if (!echoFileRef)
			{
				fileName = _String ("File '")&fileName& "' couldn't be opened for writing.";
				ProblemReport (fileName);
			}
		}
		dialogPrompt = saveDP;		
		echoStatus   = 1;
	}
	else
		if (choice.Equal (&stopEchoing))
		{
			fclose (echoFileRef);
			echoFileRef = nil;
			echoStatus  = 0;
		}
		else
			if (choice.Equal (&pauseEchoing))
				echoStatus = 0;
			else
				if (choice.Equal (&resumeEchoing))
					echoStatus = 1;

	bb->_UnpushButton();
	_PaintStatusBar();
}
void    _HYObjectInspector::KillObject (void)
{
    _HYTable*       dl = (_HYTable*)GetCellObject (HY_OBJECT_INSPECTOR_TABLE_ROW,0);
    _HYButtonBar*   b1 = (_HYButtonBar*)GetCellObject (0,0);
    _HYPullDown*    p1 = (_HYPullDown*)GetCellObject (0,2);

    _SimpleList     sel;
    dl->GetSelection (sel);
    if (sel.lLength) {
        b1->EnableButton (0,true);
        long f;
        switch (p1->GetSelection()) {
        case 0: {
            for (f = 0; f<sel.lLength; f+=2) {
                long treeID = LocateVarByName (*(_String*)dl->GetCellData (0,sel.lData[f]/2));
                if (treeID>=0)
#ifndef USE_AVL_NAMES
                    treeID = variableReindex.lData[treeID];
#else
                    treeID = variableNames.GetXtra(treeID);
#endif
                if (dl->cellTypes.lData[sel.lData[f]] & HY_TABLE_BOLD) {
                    _String prompt ("Tree ");
                    prompt = prompt & *LocateVar (treeID)->GetName() & objectInspectorKillPrompt;
                    if (warnTree||(!ProceedPromptWithCheck (prompt,donotWarnAgain,warnTree))) {
                        continue;
                    }
                }
                postTreeKillEvent (GetID(), treeID);
            }
            break;
        }
        case 1: {
            for (f = 0; f<sel.lLength; f+=2) {
                long dsID = dataSetNamesList.Find ((_String*)dl->GetCellData (0,sel.lData[f]/2));
                if (dsID>=0) {
                    if (dl->cellTypes.lData[sel.lData[f]] & HY_TABLE_BOLD) {
                        _String prompt ("Dataset ");
                        prompt = prompt & *(_String*)dataSetNamesList(dsID) & objectInspectorKillPrompt;
                        if (!((!warnTree)&&ProceedPromptWithCheck (prompt,donotWarnAgain,warnDS))) {
                            continue;
                        }
                    }
                    postDSKillEvent (GetID(), dsID);
                }
            }
            break;
        }
        case 2: {
            for (f = 0; f<sel.lLength; f+=2) {
                if (sel.lData[f]/2<modelTemplates.lLength) {
                    _List* modelT = FindModelTemplate((_String*)dl->GetCellData (0,sel.lData[f]/2));
                    if (modelT) { // template model
                        _String*fileLocation = (_String*)(*modelT)(2),
                                errMsg (*(_String*)dl->GetCellData (0,sel.lData[f]/2));

                        if (dl->cellTypes.lData[sel.lData[f]] & HY_TABLE_ITALIC) {
                            errMsg = errMsg & " is a template model. If you wish to delete it, please do so by removing the appropriate file from the \"Substitution Models\" directory.";
                            ProblemReport (errMsg);
                        } else {
                            errMsg = errMsg & " is about to be deleted. This action is NOT undoable.";
                            if (ProceedPrompt (errMsg,(Ptr)this)) {
                                if (remove (fileLocation->sData)) {
                                    errMsg = "File delete operation failed.";
                                    ProblemReport (errMsg);
                                } else {
                                    errMsg = *(_String*)dl->GetCellData (0,sel.lData[f]/2);
                                    for (long k=0; k<modelTemplates.lLength; k++) {
                                        _List* thisList = (_List*)modelTemplates(k);
                                        if (errMsg.Equal((_String*)(*thisList)(0))) {
                                            modelTemplates.Delete (k);
                                        }
                                    }
                                    BuildListOfObjects (2);
                                }
                            }
                        }
                    }
                }
            }
            break;
        }
        }
    }
}