Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e4362e24
Kaydet (Commit)
e4362e24
authored
Mar 19, 2013
tarafından
Javier Fernandez
Kaydeden (comit)
Michael Meeks
Mar 25, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Init: Added new file AbstractErrorHandler.py
Change-Id: I8d5a304a51af734379c5597e9cdddf6ecfa6ba8a
üst
a2d36bc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
181 additions
and
0 deletions
+181
-0
AbstractErrorHandler.py
wizards/com/sun/star/wizards/web/AbstractErrorHandler.py
+181
-0
No files found.
wizards/com/sun/star/wizards/web/AbstractErrorHandler.py
0 → 100644
Dosyayı görüntüle @
e4362e24
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from
abc
import
abstractmethod
from
.ErrorHandler
import
ErrorHandler
from
..common.SystemDialog
import
SystemDialog
from
com.sun.star.awt.VclWindowPeerAttribute
import
OK
,
DEF_OK
,
OK_CANCEL
,
DEF_CANCEL
from
com.sun.star.awt.VclWindowPeerAttribute
import
YES_NO
,
DEF_NO
,
DEF_YES
#import com.sun.star.awt.VclWindowPeerAttribute
# An abstract implementation of ErrorHandler, which
# uses a renderer method geMessageFor(Exception, Object, int, int)
# (in this class still abstract...)
# to render the errors, and displays
# error messeges.
class
AbstractErrorHandler
(
ErrorHandler
):
xmsf
=
None
peer
=
None
def
__init__
(
self
,
xmsf
,
peer_
):
self
.
xmsf
=
xmsf
self
.
peer
=
peer_
# Implementation of ErrorHandler:
# shows a message box with the rendered error.
# @param arg identifies the error. This object is passed to the render method
# which returns the right error message.
# @return true/false for continue/abort.
def
error
(
self
,
ex
,
arg
,
ix
,
errorType
):
if
(
errorType
==
ErrorHandler
.
ERROR_FATAL
):
return
not
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_PROCESS_FATAL
):
return
not
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_NORMAL_ABORT
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_NORMAL_IGNORE
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_CANCEL
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_OK
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_NO
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_YES
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_WARNING
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
elif
(
errorType
==
ErrorHandler
.
ERROR_MESSAGE
):
return
self
.
showMessage
(
self
.
getMessageFor
(
ex
,
arg
,
ix
,
errorType
),
errorType
)
raise
IllegalArgumentException
(
"unknown error type"
)
# @deprecated
# @param message
# @param errorType
# @return true if the ok/yes button is clicked, false otherwise.
def
showMessage
(
self
,
message
,
errorType
):
return
self
.
showMessage1
(
self
.
xmsf
,
self
.
peer
,
message
,
errorType
)
# display a message
# @deprecated
# @param xmsf
# @param message the message to display
# @param errorType an int constant from the ErrorHandler interface.
# @return
@classmethod
def
showMessage1
(
self
,
xmsf
,
peer
,
message
,
errorType
):
serviceName
=
self
.
getServiceNameFor
(
errorType
)
attribute
=
self
.
getAttributeFor
(
errorType
)
b
=
SystemDialog
.
showMessageBox
(
xmsf
,
serviceName
,
attribute
,
message
,
peer
)
return
b
==
self
.
getTrueFor
(
errorType
)
@classmethod
def
showMessage2
(
self
,
xmsf
,
peer
,
message
,
dialogType
,
buttons
,
defaultButton
,
returnTrueOn
):
b
=
SystemDialog
.
showMessageBox
(
xmsf
,
dialogType
,
defaultButton
+
buttons
,
message
,
peer
,
)
return
b
==
returnTrueOn
# normally ok(1) is the value for true.
# but a question dialog may use yes. so i use this method
# for each error type to get its type of "true" value.
# @param errorType
# @return
@classmethod
def
getTrueFor
(
self
,
errorType
):
if
(
errorType
in
(
ErrorHandler
.
ERROR_FATAL
,
ErrorHandler
.
ERROR_PROCESS_FATAL
,
ErrorHandler
.
ERROR_NORMAL_ABORT
,
ErrorHandler
.
ERROR_NORMAL_IGNORE
,
ErrorHandler
.
ERROR_QUESTION_CANCEL
,
ErrorHandler
.
ERROR_QUESTION_OK
)):
return
1
elif
(
errorType
in
(
ErrorHandler
.
ERROR_QUESTION_NO
,
ErrorHandler
.
ERROR_QUESTION_YES
)):
return
2
elif
(
errorType
in
(
ErrorHandler
.
ERROR_WARNING
,
ErrorHandler
.
ERROR_MESSAGE
)):
return
1
raise
IllegalArgumentException
(
"unkonown error type"
)
# @param errorType
# @return the Uno attributes for each error type.
@classmethod
def
getAttributeFor
(
self
,
errorType
):
if
(
errorType
==
ErrorHandler
.
ERROR_FATAL
):
return
OK
elif
(
errorType
==
ErrorHandler
.
ERROR_PROCESS_FATAL
):
return
OK
elif
(
errorType
==
ErrorHandler
.
ERROR_NORMAL_ABORT
):
return
OK_CANCEL
+
DEF_CANCEL
elif
(
errorType
==
ErrorHandler
.
ERROR_NORMAL_IGNORE
):
return
OK_CANCEL
+
DEF_OK
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_CANCEL
):
return
OK_CANCEL
+
DEF_CANCEL
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_OK
):
return
OK_CANCEL
+
DEF_OK
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_NO
):
return
YES_NO
+
DEF_NO
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_YES
):
return
YES_NO
+
DEF_YES
elif
(
errorType
==
ErrorHandler
.
ERROR_WARNING
):
return
OK
elif
(
errorType
==
ErrorHandler
.
ERROR_MESSAGE
):
return
OK
raise
IllegalArgumentException
(
"unkonown error type"
)
# @deprecated
# @param errorType
# @return the uno service name for each error type
@classmethod
def
getServiceNameFor
(
self
,
errorType
):
if
(
errorType
==
ErrorHandler
.
ERROR_FATAL
):
return
"errorbox"
elif
(
errorType
==
ErrorHandler
.
ERROR_PROCESS_FATAL
):
return
"errorbox"
elif
(
errorType
==
ErrorHandler
.
ERROR_NORMAL_ABORT
):
return
"errorbox"
elif
(
errorType
==
ErrorHandler
.
ERROR_NORMAL_IGNORE
):
return
"warningbox"
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_CANCEL
):
return
"querybox"
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_OK
):
return
"querybox"
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_NO
):
return
"querybox"
elif
(
errorType
==
ErrorHandler
.
ERROR_QUESTION_YES
):
return
"querybox"
elif
(
errorType
==
ErrorHandler
.
ERROR_WARNING
):
return
"warningbox"
elif
(
errorType
==
ErrorHandler
.
ERROR_MESSAGE
):
return
"infobox"
raise
IllegalArgumentException
(
"unkonown error type"
)
# renders the error
# @param ex the exception
# @param arg a free argument
# @param ix a free argument
# @param type the error type (from the int constants
# in ErrorHandler interface)
# @return a Strings which will be displayed in the message box,
# and which describes the error, and the needed action from the user.
@abstractmethod
def
getMessageFor
(
self
,
ex
,
arg
,
ix
,
errorType
):
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment