diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 6e21f69c..fd4b3504 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -47,5 +47,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/zd/zero/waifu/motivator/plugin/alert/AlertConfiguration.kt b/src/main/java/zd/zero/waifu/motivator/plugin/alert/AlertConfiguration.kt
index b36efc46..110711bb 100644
--- a/src/main/java/zd/zero/waifu/motivator/plugin/alert/AlertConfiguration.kt
+++ b/src/main/java/zd/zero/waifu/motivator/plugin/alert/AlertConfiguration.kt
@@ -5,3 +5,11 @@ data class AlertConfiguration(
val isDisplayNotificationEnabled: Boolean = false,
val isSoundAlertEnabled: Boolean = false
)
+
+object AlertConfigurationAllEnabled {
+ fun create() = AlertConfiguration(
+ isAlertEnabled = true,
+ isDisplayNotificationEnabled = true,
+ isSoundAlertEnabled = true
+ )
+}
diff --git a/src/main/java/zd/zero/waifu/motivator/plugin/integrations/WaifuConsoleFilterProvider.kt b/src/main/java/zd/zero/waifu/motivator/plugin/integrations/WaifuConsoleFilterProvider.kt
new file mode 100644
index 00000000..45d0baab
--- /dev/null
+++ b/src/main/java/zd/zero/waifu/motivator/plugin/integrations/WaifuConsoleFilterProvider.kt
@@ -0,0 +1,52 @@
+package zd.zero.waifu.motivator.plugin.integrations
+
+import com.intellij.execution.filters.ConsoleFilterProvider
+import com.intellij.execution.filters.Filter
+import com.intellij.openapi.project.Project
+import zd.zero.waifu.motivator.plugin.alert.AlertConfigurationAllEnabled
+import zd.zero.waifu.motivator.plugin.assets.WaifuAssetCategory
+import zd.zero.waifu.motivator.plugin.motivation.MotivationFactory
+import zd.zero.waifu.motivator.plugin.motivation.event.MotivationEvent
+import zd.zero.waifu.motivator.plugin.motivation.event.MotivationEventCategory
+import zd.zero.waifu.motivator.plugin.motivation.event.MotivationEvents
+import zd.zero.waifu.motivator.plugin.settings.WaifuMotivatorPluginState.getPluginState
+
+class WaifuConsoleFilterProvider : ConsoleFilterProvider {
+
+ private var prevLength: Int = Int.MAX_VALUE
+
+ private var alertShown = false
+
+ override fun getDefaultFilters(project: Project): Array = when {
+ getPluginState().isLogWatcherEnabled -> arrayOf(
+ Filter { line, entireLength ->
+ val newConsole = entireLength < prevLength
+ if (newConsole) alertShown = false
+
+ val pluginState = getPluginState()
+ if (alertShown.not() && pluginState.logWatcherKeyword.isNotEmpty() &&
+ line.contains(pluginState.logWatcherKeyword, ignoreCase = pluginState.isLogWatcherCaseSensitivityIgnored)
+ ) {
+ MotivationFactory.showUntitledMotivationEventFromCategories(
+ MotivationEvent(
+ MotivationEvents.MISC,
+ MotivationEventCategory.POSITIVE,
+ "Waifu Log Watcher Event",
+ project
+ ) { AlertConfigurationAllEnabled.create() },
+ WaifuAssetCategory.ACKNOWLEDGEMENT,
+ WaifuAssetCategory.CELEBRATION,
+ WaifuAssetCategory.HAPPY,
+ WaifuAssetCategory.SMUG
+ )
+
+ alertShown = true
+ }
+
+ prevLength = entireLength
+ return@Filter null
+ }
+ )
+ else -> Filter.EMPTY_ARRAY
+ }
+}
diff --git a/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.form b/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.form
index 950f4f9f..ea9a7ef5 100644
--- a/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.form
+++ b/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.form
@@ -145,6 +145,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.java b/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.java
index 351adef1..b83fccab 100644
--- a/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.java
+++ b/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorSettingsPage.java
@@ -27,6 +27,7 @@
import javax.swing.JSlider;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
@@ -92,6 +93,12 @@ public class WaifuMotivatorSettingsPage implements SearchableConfigurable, Confi
private JCheckBox showStatusBarIcon;
+ private JCheckBox ignoreCaseSensitivityCheckBox;
+
+ private JTextField logWatcherKeywordTextField;
+
+ private JCheckBox enableLogWatcherCheckBox;
+
private ListTableModel exitCodeListModel;
public WaifuMotivatorSettingsPage() {
@@ -120,6 +127,11 @@ public JComponent createComponent() {
eventsBeforeFrustrationSpinner.setEnabled(allowFrustrationCheckBox.isSelected());
} );
+ enableLogWatcherCheckBox.addActionListener( e -> {
+ ignoreCaseSensitivityCheckBox.setEnabled( enableLogWatcherCheckBox.isSelected() );
+ logWatcherKeywordTextField.setEnabled( enableLogWatcherCheckBox.isSelected() );
+ } );
+
frustrationProbabilitySlider.setForeground( UIUtil.getContextHelpForeground() );
preferredCharactersList.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
@@ -153,6 +165,9 @@ public boolean isModified() {
enableSayonara.isSelected() != this.state.isSayonaraEnabled() ||
!getPreferredCharacters().equals( this.state.getPreferredCharacters() ) ||
showStatusBarIcon.isSelected() != this.state.isShowMood() ||
+ enableLogWatcherCheckBox.isSelected() != this.state.isLogWatcherEnabled() ||
+ ignoreCaseSensitivityCheckBox.isSelected() != this.state.isLogWatcherCaseSensitivityIgnored() ||
+ !logWatcherKeywordTextField.getText().equals( this.state.getLogWatcherKeyword()) ||
exitCodesChanged;
}
@@ -202,6 +217,9 @@ public void apply() {
);
this.state.setPreferredCharacters( getPreferredCharacters() );
this.state.setShowMood( showStatusBarIcon.isSelected() );
+ this.state.setLogWatcherEnabled( enableLogWatcherCheckBox.isSelected() );
+ this.state.setLogWatcherCaseSensitivityIgnored( ignoreCaseSensitivityCheckBox.isSelected() );
+ this.state.setLogWatcherKeyword( logWatcherKeywordTextField.getText() );
// updates the Tip of the Day setting
GeneralSettings.getInstance().setShowTipsOnStartup( !enableWaifuOfTheDay.isSelected() );
@@ -238,12 +256,22 @@ private void setFieldsFromState() {
this.enableIdleSoundCheckBox.setSelected( this.state.isIdleSoundEnabled() );
this.enableTaskEventNotificationsCheckBox.setSelected( this.state.isTaskMotivationEnabled() );
this.enableTaskEventSoundsCheckBox.setSelected( this.state.isTaskSoundEnabled() );
- this.allowFrustrationCheckBox.setSelected( this.state.isAllowFrustration() );
- this.eventsBeforeFrustrationSpinner.setValue( this.state.getEventsBeforeFrustration() );
- this.frustrationProbabilitySlider.setValue( this.state.getProbabilityOfFrustration() );
this.enableExitCodeNotifications.setSelected( this.state.isExitCodeNotificationEnabled() );
this.enableExitCodeSound.setSelected( this.state.isExitCodeSoundEnabled() );
this.showStatusBarIcon.setSelected( this.state.isShowMood() );
+
+ this.allowFrustrationCheckBox.setSelected( this.state.isAllowFrustration() );
+ this.eventsBeforeFrustrationSpinner.setValue( this.state.getEventsBeforeFrustration() );
+ this.eventsBeforeFrustrationSpinner.setEnabled( allowFrustrationCheckBox.isSelected() );
+ this.frustrationProbabilitySlider.setValue( this.state.getProbabilityOfFrustration() );
+ this.frustrationProbabilitySlider.setEnabled( allowFrustrationCheckBox.isSelected() );
+
+ this.enableLogWatcherCheckBox.setSelected( this.state.isLogWatcherEnabled() );
+ this.ignoreCaseSensitivityCheckBox.setSelected( this.state.isLogWatcherCaseSensitivityIgnored() );
+ this.ignoreCaseSensitivityCheckBox.setEnabled( enableLogWatcherCheckBox.isSelected() );
+ this.logWatcherKeywordTextField.setText( this.state.getLogWatcherKeyword() );
+ this.logWatcherKeywordTextField.setEnabled( enableLogWatcherCheckBox.isSelected() );
+
initializeExitCodes();
}
diff --git a/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorState.kt b/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorState.kt
index 947b65b4..1d6481c0 100644
--- a/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorState.kt
+++ b/src/main/java/zd/zero/waifu/motivator/plugin/settings/WaifuMotivatorState.kt
@@ -61,4 +61,10 @@ class WaifuMotivatorState {
var preferredCharacters = ""
var isShowMood = true
+
+ var isLogWatcherEnabled = false
+
+ var isLogWatcherCaseSensitivityIgnored = true
+
+ var logWatcherKeyword = ""
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index cf96b732..41231692 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -20,6 +20,7 @@
serviceImplementation="zd.zero.waifu.motivator.plugin.settings.WaifuMotivatorPluginState"/>
+
diff --git a/src/main/resources/messages/MessageBundle.properties b/src/main/resources/messages/MessageBundle.properties
index 660ec0fb..98710682 100644
--- a/src/main/resources/messages/MessageBundle.properties
+++ b/src/main/resources/messages/MessageBundle.properties
@@ -26,6 +26,11 @@ settings.sound.on.motivate.me.tooltip=Plays a sound whenever 'Motivate Me' actio
### Preferences
settings.preferences.preferred.character.label=Preferred Characters
+## Log Watcher
+settings.tab.log.watcher=Log Watcher
+settings.log.watcher.watch.logs=Watch Logs
+settings.log.watcher.ignore.case.sensitivity=Ignore case sensitivity
+settings.log.watcher.header=I'll watch the logs for you senpai!
## Personality
settings.tab.personality=Personality