Exemplo n.º 1
0
/// A simple, one-step method for sending an error message.
void XSError::SimpleMsg(
    XSErrorSeverity s,     ///< severity of this error
    char            *msg ) ///< error message
{
    SetSeverity( s );
    storedMsg = storedMsg + (string)msg;
    *os << msg;
    EndMsg();
}
Exemplo n.º 2
0
/// A simple, one-step method for sending an error message.
void XSError::SimpleMsg(
    XSErrorSeverity s,     ///< severity of this error
    string          &msg ) ///< error message
{
    SetSeverity( s );
    storedMsg = storedMsg + msg;
    *os << msg.c_str();
    EndMsg();
}
Exemplo n.º 3
0
/// Set severity of next error message.
void XSError::SetSeverity( XSErrorSeverity s ) ///< error severity level
{
    severity = s;
    switch ( severity )
    {
        case XSErrorFatal:
            *os << GetHeader().c_str() << " FATAL ERROR: ";
            SetState( XSErrorInMessage );
            break;

        case XSErrorMajor:
            *os << GetHeader().c_str() << " MAJOR ERROR: ";
            os->flush();
            SetState( XSErrorInMessage );
            break;

        case XSErrorMinor:
            *os << GetHeader().c_str() << " MINOR ERROR: ";
            os->flush();
            SetState( XSErrorInMessage );
            break;

        case XSErrorNone:
            *os << GetHeader().c_str() << ": ";
            os->flush();
            SetState( XSErrorInMessage );
            break;

        default:
            SetSeverity( XSErrorMinor );
            *os << "\nerror severity was incorrectly set!\n";
            os->flush();
            EndMsg();
            break;
    } // switch
}     // SetSeverity
Exemplo n.º 4
0
int frmMain::ReconnectServer(pgServer *server, bool restore)
{
    // Create a server object and connect it.
    wxBusyInfo waiting(wxString::Format(_("Connecting to server %s (%s:%d)"),
        server->GetDescription().c_str(), server->GetName().c_str(), server->GetPort()), this);

    // Give the UI a chance to redraw
    wxSafeYield();
    wxMilliSleep(100);
    wxSafeYield();

    int res = server->Connect(this, true);

    // Check the result, and handle it as appropriate
    wxTreeItemId item;
    switch (res)
    {
        case PGCONN_OK:
        {
            if (restore && server->GetRestore())
                StartMsg(_("Restoring previous environment"));
            else
                StartMsg(_("Establishing connection"));

            wxLogInfo(wxT("pgServer object initialised as required."));

            server->ShowTreeDetail(browser);

            browser->Freeze();
            if (restore && server->GetRestore())
                item=RestoreEnvironment(server);
            else
                item = server->GetId();
            browser->Thaw();

            if (item)
            {
                browser->SelectItem(item);

                wxSafeYield();
                browser->Expand(item);
                browser->EnsureVisible(item);
            }

            if (item)
                EndMsg(true);
            else
            {
                if (restore && server->GetRestore())
                    EndMsg(false);
                else
                    EndMsg(true);
            }
            if (item)
                GetMenuFactories()->CheckMenu((pgObject *)browser->GetItemData(item), GetMenuBar(), (ctlMenuToolbar *)GetToolBar());
            else
                GetMenuFactories()->CheckMenu(server, GetMenuBar(), (ctlMenuToolbar *)GetToolBar());
            return res;
        }
        case PGCONN_DNSERR:
            /*
            // looks strange to me. Shouldn_t server be removed from the tree as well?
            delete server;
            OnAddServer(wxCommandEvent());
            break;
            */
        case PGCONN_BAD:
            ReportConnError(server);
            break;

        default:
            wxLogInfo(wxT("pgServer object didn't initialise because the user aborted."));
            break;
    }

    server->Disconnect(this);
    return res;
}
Exemplo n.º 5
0
void frmMain::Refresh(pgObject *data)
{
    StartMsg(data->GetTranslatedMessage(REFRESHINGDETAILS));
    browser->Freeze();

    wxTreeItemId currentItem=data->GetId();

    // Scan the child nodes and make a list of those that are expanded
    // This is not an exact science as node names may change etc.
    wxArrayString expandedNodes;
    GetExpandedChildNodes(currentItem, expandedNodes);

    browser->DeleteChildren(currentItem);

    // refresh information about the object
    data->SetDirty();
    
    pgObject *newData = data->Refresh(browser, currentItem);

    bool done = !data->GetConnection() || data->GetConnection()->GetStatus() == PGCONN_OK;
    
    if (newData != data)
    {
        wxLogInfo(wxT("Deleting %s %s for refresh"), data->GetTypeName().c_str(), data->GetQuotedFullIdentifier().c_str());

        if (data == currentObject)
            currentObject = newData;

        if (newData)
        {
            wxLogInfo(wxT("Replacing with new node %s %s for refresh"), newData->GetTypeName().c_str(), newData->GetQuotedFullIdentifier().c_str());

            newData->SetId(currentItem);    // not done automatically
            browser->SetItemData(currentItem, newData);

            // Update the node text if this is an object, as it may have been renamed
            if (!newData->IsCollection())
                browser->SetItemText(currentItem, newData->GetDisplayName());

            delete data;
        }
        else
        {
            wxLogInfo(wxT("No object to replace: vanished after refresh."));
            
            // If the connection is dead, just return here
            if (data->GetConnection()->GetStatus() != PGCONN_OK)
            {
                CheckAlive();
                browser->Thaw();
                return;
            }
    
            wxTreeItemId delItem=currentItem;
            currentItem=browser->GetItemParent(currentItem);
            browser->SelectItem(currentItem);
            browser->Delete(delItem);
        }
    }

    if (currentItem)
    {
        execSelChange(currentItem, currentItem == browser->GetSelection());

        // Attempt to expand any child nodes that were previously expanded
        ExpandChildNodes(currentItem, expandedNodes);
    }

    browser->Thaw();
    EndMsg(done);
}
Exemplo n.º 6
0
void frmMain::Refresh(pgObject *data)
{
	bool done = false;
	pgObject *obj = NULL;

	StartMsg(data->GetTranslatedMessage(REFRESHINGDETAILS));
	browser->Freeze();

	wxTreeItemId currentItem = data->GetId();
	if (currentItem)
		obj = browser->GetObject(currentItem);

	if (obj && obj->CheckOpenDialogs(browser, currentItem))
	{
		wxString msg = _("There are properties dialogues open for one or more objects that would be refreshed. Please close the properties dialogues and try again.");
		wxMessageBox(msg, _("Cannot refresh browser"), wxICON_WARNING | wxOK);
	}
	else
	{
		if (data->GetMetaType() == PGM_SCHEMA && !data->IsCollection() && data->GetConnection()->BackendMinimumVersion(9, 3))
		{
			// Event triggers backend functions are at schema level.
			// Hence, we can consider that Event Triggers at schema level and partly at database.
			// So, if any schema is refreshed, we need to the event trigger collection as well.
			// It's a special case, which effects the schema operations on the event triggers as well.
			// To solve this, we are navigating to the parent node (database node), and then locating event trigger collections.
			// Once we've found the event triggers collection, we refresh it.
			//
			wxTreeItemId dbItem = browser->GetItemParent(browser->GetItemParent(browser->GetSelection()));
			pgCollection *eventTrgCol = browser->FindCollection(eventTriggerFactory, dbItem);

			if(eventTrgCol)
			Refresh(eventTrgCol);
		}

		// Scan the child nodes and make a list of those that are expanded
		// This is not an exact science as node names may change etc.
		wxArrayString expandedNodes;
		GetExpandedChildNodes(currentItem, expandedNodes);

		browser->DeleteChildren(currentItem);

		// refresh information about the object
		data->SetDirty();

		pgObject *newData = data->Refresh(browser, currentItem);
		done = !data->GetConnection() || data->GetConnection()->GetStatus() == PGCONN_OK;

		if (newData != data)
		{
			wxLogInfo(wxT("Deleting %s %s for refresh"), data->GetTypeName().c_str(), data->GetQuotedFullIdentifier().c_str());

			if (data == currentObject)
				currentObject = newData;

			if (newData)
			{
				wxLogInfo(wxT("Replacing with new node %s %s for refresh"), newData->GetTypeName().c_str(), newData->GetQuotedFullIdentifier().c_str());

				newData->SetId(currentItem);    // not done automatically
				browser->SetItemData(currentItem, newData);

				// Update the node text if this is an object, as it may have been renamed
				if (!newData->IsCollection())
					browser->SetItemText(currentItem, newData->GetDisplayName());

				delete data;
				data = NULL;
			}
			else
			{
				wxLogInfo(wxT("No object to replace: vanished after refresh."));

				// If the connection is dead, just return here
				if (data->GetConnection()->GetStatus() != PGCONN_OK)
				{
					CheckAlive();
					browser->Thaw();
					return;
				}

				wxTreeItemId delItem = currentItem;
				currentItem = browser->GetItemParent(currentItem);
				browser->SelectItem(currentItem);
				browser->Delete(delItem);
			}
		}

		if (currentItem)
		{
			// Select the current node
			execSelChange(currentItem, currentItem == browser->GetSelection());

			// Attempt to expand any child nodes that were previously expanded
			ExpandChildNodes(currentItem, expandedNodes);
		}
	}

	browser->Thaw();
	EndMsg(done);
}