-
-
Notifications
You must be signed in to change notification settings - Fork 74
migrating Preferences and Messages to stand-alone version #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0303c0f
50766f4
9b9f514
be2886b
25b6a44
004a138
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,45 +26,8 @@ import java.io.StringWriter | |
import javax.swing.JFrame | ||
import javax.swing.JOptionPane | ||
|
||
class Messages { | ||
class Messages : processing.utils.Messages() { | ||
companion object { | ||
/** | ||
* "No cookie for you" type messages. Nothing fatal or all that | ||
* much of a bummer, but something to notify the user about. | ||
*/ | ||
@JvmStatic | ||
fun showMessage(title: String = "Message", message: String) { | ||
if (Base.isCommandLine()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If i understand you correctly, you wanna seperate the appearance of graphical messages via but wouldn't that make an issue in |
||
println("$title: $message") | ||
} else { | ||
JOptionPane.showMessageDialog( | ||
Frame(), message, title, | ||
JOptionPane.INFORMATION_MESSAGE | ||
) | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Non-fatal error message with optional stack trace side dish. | ||
*/ | ||
/** | ||
* Non-fatal error message. | ||
*/ | ||
@JvmStatic | ||
@JvmOverloads | ||
fun showWarning(title: String = "Warning", message: String, e: Throwable? = null) { | ||
if (Base.isCommandLine()) { | ||
println("$title: $message") | ||
} else { | ||
JOptionPane.showMessageDialog( | ||
Frame(), message, title, | ||
JOptionPane.WARNING_MESSAGE | ||
) | ||
} | ||
e?.printStackTrace() | ||
} | ||
|
||
/** | ||
* Non-fatal error message with two levels of formatting. | ||
* Unlike the others, this is non-blocking and will run later on the EDT. | ||
|
@@ -92,26 +55,6 @@ class Messages { | |
} | ||
|
||
|
||
/** | ||
* Show an error message that's actually fatal to the program. | ||
* This is an error that can't be recovered. Use showWarning() | ||
* for errors that allow P5 to continue running. | ||
*/ | ||
@JvmStatic | ||
fun showError(title: String = "Error", message: String, e: Throwable?) { | ||
if (Base.isCommandLine()) { | ||
System.err.println("$title: $message") | ||
} else { | ||
JOptionPane.showMessageDialog( | ||
Frame(), message, title, | ||
JOptionPane.ERROR_MESSAGE | ||
) | ||
} | ||
e?.printStackTrace() | ||
System.exit(1) | ||
} | ||
|
||
|
||
/** | ||
* Warning window that includes the stack trace. | ||
*/ | ||
|
@@ -218,56 +161,6 @@ class Messages { | |
return -1 | ||
} | ||
|
||
|
||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||
@JvmStatic | ||
@Deprecated("Use log() instead") | ||
fun log(from: Any, message: String) { | ||
if (Base.DEBUG) { | ||
val callingClass = Throwable() | ||
.stackTrace[2] | ||
.className | ||
.formatClassName() | ||
println("$callingClass: $message") | ||
} | ||
} | ||
|
||
@JvmStatic | ||
fun log(message: String?) { | ||
if (Base.DEBUG) { | ||
val callingClass = Throwable() | ||
.stackTrace[2] | ||
.className | ||
.formatClassName() | ||
println("$callingClass$message") | ||
} | ||
} | ||
|
||
@JvmStatic | ||
fun logf(message: String?, vararg args: Any?) { | ||
if (Base.DEBUG) { | ||
val callingClass = Throwable() | ||
.stackTrace[2] | ||
.className | ||
.formatClassName() | ||
System.out.printf("$callingClass$message", *args) | ||
} | ||
} | ||
|
||
@JvmStatic | ||
@JvmOverloads | ||
fun err(message: String?, e: Throwable? = null) { | ||
if (Base.DEBUG) { | ||
if (message != null) { | ||
val callingClass = Throwable() | ||
.stackTrace[4] | ||
.className | ||
.formatClassName() | ||
System.err.println("$callingClass$message") | ||
} | ||
e?.printStackTrace() | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain why this needed to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main motivation behind this change was to be able to know if Processing is launched via CLI or not without the need to depend on
app
module via usingBase.isCommandLine()
as for example im using it in the
utils.Messages.kt