Author: sh-sh-sh
Date: Fri Jan 25 19:59:01 2008
New Revision: 43921
URL: http://svn.opensuse.org/viewcvs/yast?rev=43921&view=rev
Log:
Improved UI syntax error handling: Open dialogs to inform the user
Added:
trunk/core/libyui/src/YCPErrorDialog.cc
trunk/core/libyui/src/YCPErrorDialog.h
Modified:
trunk/core/libyui/src/Makefile.am
trunk/core/libyui/src/YUI.h
trunk/core/libyui/src/YUI_builtins.cc
trunk/core/libyui/src/YWidgetID.h
trunk/core/package/yast2-core.changes
Modified: trunk/core/libyui/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/Makefile.am?rev=43921&r1=43920&r2=43921&view=diff
==============================================================================
--- trunk/core/libyui/src/Makefile.am (original)
+++ trunk/core/libyui/src/Makefile.am Fri Jan 25 19:59:01 2008
@@ -16,6 +16,7 @@
Y2CCUI.cc \
YApplication.cc \
YCPDialogParser.cc \
+ YCPErrorDialog.cc \
YCPItemParser.cc \
YCPItemWriter.cc \
YCPMenuItemParser.cc \
@@ -108,6 +109,7 @@
YBothDim.h \
YColor.h \
YCPDialogParser.h \
+ YCPErrorDialog.h \
YCPItem.h \
YCPItemParser.h \
YCPItemWriter.h \
Added: trunk/core/libyui/src/YCPErrorDialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPErrorDialog.cc?rev=43921&view=auto
==============================================================================
--- trunk/core/libyui/src/YCPErrorDialog.cc (added)
+++ trunk/core/libyui/src/YCPErrorDialog.cc Fri Jan 25 19:59:01 2008
@@ -0,0 +1,74 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPErrorDialog.cc
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#include
+
+#define YUILogComponent "ui"
+#include "YUILog.h"
+
+#include "YCPErrorDialog.h"
+#include "YUI.h"
+#include "YUI_util.h"
+#include "YApplication.h"
+
+#include "YWidgetFactory.h"
+#include "YCPValueWidgetID.h"
+#include "YDialog.h"
+#include "YLabel.h"
+#include "YPushButton.h"
+#include "YLayoutBox.h"
+
+using std::string;
+
+
+void YCPErrorDialog::exceptionDialog( const string & headingText,
+ const YUIException & exception ) throw()
+{
+ try
+ {
+ YWidgetFactory * fac = YUI::widgetFactory();
+ YDialog * dialog = fac->createPopupDialog( YDialogWarnColor );
+ YLayoutBox * vbox = fac->createVBox( dialog );
+ fac->createHeading( vbox, headingText );
+ fac->createLabel( vbox, exception.asString() );
+ fac->createLabel( vbox, "Check the log file!" );
+ YLayoutBox * buttonBox = fac->createHBox( vbox );
+ fac->createHStretch( buttonBox );
+ YPushButton * closeButton = fac->createPushButton( buttonBox, "&Close" );
+ closeButton->setId( new YCPValueWidgetID( YCPSymbol( "cancel" ) ) );
+
+ dialog->setInitialSize();
+ dialog->checkShortcuts();
+ YUI::ui()->showDialog( dialog );
+
+ YCPValue input = YUI::ui()->waitForUserInput();
+ yuiMilestone() << "Input: " << input << endl;
+
+ YUI::ui()->closeDialog( YDialog::currentDialog() );
+ YDialog::deleteTopmostDialog();
+ }
+ catch ( YUIException & ex )
+ {
+ YUI_CAUGHT( exception );
+ }
+ catch ( ... )
+ {
+ yuiWarning() << "Caught unknown exception" << endl;
+ }
+}
+
Added: trunk/core/libyui/src/YCPErrorDialog.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPErrorDialog.h?rev=43921&view=auto
==============================================================================
--- trunk/core/libyui/src/YCPErrorDialog.h (added)
+++ trunk/core/libyui/src/YCPErrorDialog.h Fri Jan 25 19:59:01 2008
@@ -0,0 +1,44 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPErrorDialog.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YCPErrorDialog_h
+#define YCPErrorDialog_h
+
+#include <string>
+#include "YUIException.h"
+
+using std::string;
+
+
+class YCPErrorDialog
+{
+public:
+ /**
+ * Post an error dialog with the specified heading text and the specified
+ * UI exception and wait for the user to confirm it.
+ **/
+ static void exceptionDialog( const string & headingText,
+ const YUIException & exception ) throw();
+
+private:
+ YCPErrorDialog() {}
+};
+
+
+#endif // YCPErrorDialog_h
+
Modified: trunk/core/libyui/src/YUI.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YUI.h?rev=43921&r1=43920&r2=43921&view=diff
==============================================================================
--- trunk/core/libyui/src/YUI.h (original)
+++ trunk/core/libyui/src/YUI.h Fri Jan 25 19:59:01 2008
@@ -21,21 +21,22 @@
#include
#include <deque>
+#include <string>
+
+using std::deque;
+using std::string;
+
#include
#include
#include
#include
#include
#include
-#include
#include "YTypes.h"
#include "YWidgetOpt.h"
-using std::deque;
-using std::string;
-
class YApplication;
class YWidget;
class YWidgetFactory;
@@ -102,7 +103,7 @@
* threads, this does nothing.
**/
void shutdownThreads();
-
+
/**
* Access the global UI.
**/
@@ -174,6 +175,11 @@
public:
/**
+ * The C++ counterpart to UI::UserInput().
+ **/
+ YCPValue waitForUserInput();
+
+ /**
* Block (or unblock) events. If events are blocked, any event sent
* should be ignored until events are unblocked again.
*
@@ -420,6 +426,8 @@
**/
virtual YEvent * pollInput() = 0;
+
+public:
/**
* Show and activate a previously created dialog.
* This default implementation does nothing.
@@ -434,7 +442,7 @@
**/
virtual void closeDialog( YDialog *dialog );
-
+
protected:
@@ -626,7 +634,6 @@
bool wait,
bool detailed );
-
/**
* Implements the WFM or SCR callback command.
**/
@@ -655,7 +662,7 @@
/**
* Enable or disable debug logging.
* This will propagate the parameter to YUILog::enableDebugLogging(),
- * but it might do more than just that.
+ * but it might do more than just that.
**/
void enableDebugLogging( bool enable = true );
Modified: trunk/core/libyui/src/YUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YUI_builtins.cc?rev=43921&r1=43920&r2=43921&view=diff
==============================================================================
--- trunk/core/libyui/src/YUI_builtins.cc (original)
+++ trunk/core/libyui/src/YUI_builtins.cc Fri Jan 25 19:59:01 2008
@@ -46,17 +46,18 @@
#include "YUI.h"
#include "YUI_util.h"
#include "YApplication.h"
+#include "YWidget.h"
#include "YEvent.h"
#include "YUIException.h"
#include "YUISymbols.h"
#include "YDialog.h"
-#include "YWidget.h"
#include "YMacroRecorder.h"
#include "YMacroPlayer.h"
#include "YReplacePoint.h"
#include "YShortcut.h"
#include "YWizard.h"
#include "YWidgetFactory.h"
+#include "YCPErrorDialog.h"
#include "YCPValueWidgetID.h"
#include "YCPDialogParser.h"
#include "YCPItemParser.h"
@@ -430,6 +431,19 @@
}
+YCPValue YUI::waitForUserInput()
+{
+#if VERBOSE_EVENTS
+ yuiDebug() << "Waiting for user input..." << endl;
+#endif
+
+ return doUserInput( YUIBuiltin_UserInput,
+ 0, // timeout_millisec
+ true, // wait
+ false ); // detailed
+}
+
+
/**
* @builtin PollInput
* @short Poll Input
@@ -532,98 +546,104 @@
yuiError() << builtin_name << "(): Invalid value " << timeout_millisec
<< " for timeout - assuming 0"
<< endl;
-
+
timeout_millisec = 0;
}
+ YEvent * event = 0;
+ YCPValue input = YCPVoid();
- YDialog * dialog = YDialog::currentDialog();
+ try
+ {
+ YDialog * dialog = YDialog::currentDialog();
- // Check for leftover postponed shortcut check
+ // Check for leftover postponed shortcut check
- if ( dialog->shortcutCheckPostponed() )
- {
- yuiError() << "Missing CheckShortcuts() before " << builtin_name
- << "() after PostponeShortcutCheck()!"
- << endl;
-
- dialog->checkShortcuts( true );
- }
+ if ( dialog->shortcutCheckPostponed() )
+ {
+ yuiError() << "Missing CheckShortcuts() before " << builtin_name
+ << "() after PostponeShortcutCheck()!"
+ << endl;
+ dialog->checkShortcuts( true );
+ }
- // Handle events
- YEvent * event = 0;
- YCPValue input = YCPVoid();
+ // Handle events
- if ( fakeUserInputQueue.empty() )
- {
- if ( wait )
+ if ( fakeUserInputQueue.empty() )
{
- do
+ if ( wait )
{
- // Get an event from the specific UI. Wait if there is none.
+ do
+ {
+ // Get an event from the specific UI. Wait if there is none.
#if VERBOSE_EVENTS
- yuiDebug() << "SpecificUI::userInput()" << endl;
+ yuiDebug() << "SpecificUI::userInput()" << endl;
#endif
- event = filterInvalidEvents( userInput( (unsigned long) timeout_millisec ) );
+ event = filterInvalidEvents( userInput( (unsigned long) timeout_millisec ) );
- // If there was no event or if filterInvalidEvents() discarded
- // an invalid event, go back and get the next one.
- } while ( ! event );
- }
- else
- {
- // Get an event from the specific UI. Don't wait if there is none.
+ // If there was no event or if filterInvalidEvents() discarded
+ // an invalid event, go back and get the next one.
+ } while ( ! event );
+ }
+ else
+ {
+ // Get an event from the specific UI. Don't wait if there is none.
#if VERBOSE_EVENTS
- yuiDebug() << "SpecificUI::pollInput()" << endl;
+ yuiDebug() << "SpecificUI::pollInput()" << endl;
#endif
- event = filterInvalidEvents( pollInput() );
+ event = filterInvalidEvents( pollInput() );
- // Nevermind if filterInvalidEvents() discarded an invalid event.
- // PollInput() is called very often (in a loop) anyway, and most of
- // the times it returns 'nil' anyway, so there is no need to care
- // for just another 'nil' that is returned in this exotic case.
- }
+ // Nevermind if filterInvalidEvents() discarded an invalid event.
+ // PollInput() is called very often (in a loop) anyway, and most of
+ // the times it returns 'nil' anyway, so there is no need to care
+ // for just another 'nil' that is returned in this exotic case.
+ }
- if ( event )
- {
+ if ( event )
+ {
- if ( detailed )
- input = event->ycpEvent(); // The event map
- else
- input = event->userInput(); // Only one single ID (or 'nil')
+ if ( detailed )
+ input = event->ycpEvent(); // The event map
+ else
+ input = event->userInput(); // Only one single ID (or 'nil')
#if VERBOSE_EVENTS
- yuiDebug() << "Got regular event from keyboard / mouse: " << input << endl;
+ yuiDebug() << "Got regular event from keyboard / mouse: " << input << endl;
#endif
+ }
}
- }
- else // fakeUserInputQueue contains elements -> use the first one
- {
- // Handle macro playing
-
- input = fakeUserInputQueue.front();
- yuiDebug() << "Using event from fakeUserInputQueue: "<< input << endl;
- fakeUserInputQueue.pop_front();
- }
+ else // fakeUserInputQueue contains elements -> use the first one
+ {
+ // Handle macro playing
+ input = fakeUserInputQueue.front();
+ yuiDebug() << "Using event from fakeUserInputQueue: "<< input << endl;
+ fakeUserInputQueue.pop_front();
+ }
- // Handle macro recording
+ // Handle macro recording
- if ( macroRecorder )
- {
- if ( ! input->isVoid() || wait ) // Don't record empty PollInput() calls
+ if ( macroRecorder )
{
- macroRecorder->beginBlock();
- dialog->saveUserInput( macroRecorder );
- macroRecorder->recordUserInput( input );
- macroRecorder->endBlock();
+ if ( ! input->isVoid() || wait ) // Don't record empty PollInput() calls
+ {
+ macroRecorder->beginBlock();
+ dialog->saveUserInput( macroRecorder );
+ macroRecorder->recordUserInput( input );
+ macroRecorder->endBlock();
+ }
}
}
-
+ catch ( YUIException & exception )
+ {
+ YUI_CAUGHT( exception );
+ YCPErrorDialog::exceptionDialog( "Internal Error", exception );
+ YUI_RETHROW( exception );
+ }
// Clean up.
//
@@ -784,6 +804,8 @@
ycperror( "UI::OpenDialog() failed" );
ok = false;
+
+ YCPErrorDialog::exceptionDialog( "UI Syntax Error", exception );
}
unblockEvents();
@@ -1058,6 +1080,7 @@
idValue->toString().c_str(),
newContentTerm->toString().c_str() );
+ YCPErrorDialog::exceptionDialog( "UI Syntax Error", exception );
}
unblockEvents();
Modified: trunk/core/libyui/src/YWidgetID.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YWidgetID.h?rev=43921&r1=43920&r2=43921&view=diff
==============================================================================
--- trunk/core/libyui/src/YWidgetID.h (original)
+++ trunk/core/libyui/src/YWidgetID.h Fri Jan 25 19:59:01 2008
@@ -19,8 +19,8 @@
#ifndef YWidgetID_h
#define YWidgetID_h
-#include <string>
#include <iosfwd>
+#include <string>
using std::string;
Modified: trunk/core/package/yast2-core.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=43921&r1=43920&r2=43921&view=diff
==============================================================================
--- trunk/core/package/yast2-core.changes (original)
+++ trunk/core/package/yast2-core.changes Fri Jan 25 19:59:01 2008
@@ -1,4 +1,9 @@
-------------------------------------------------------------------
+Fri Jan 25 19:56:35 CET 2008 - sh@suse.de
+
+- Improved UI syntax error handling: Open dialogs to inform the user
+
+-------------------------------------------------------------------
Wed Jan 23 18:28:52 CET 2008 - sh@suse.de
- V 2.16.23
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org