├── .github └── FUNDING.yml ├── KaizenClient ├── bin │ ├── .gitignore │ ├── FIRE.png │ ├── RESET.png │ ├── SHARE.png │ ├── STAR.png │ ├── DELETE.png │ ├── DISCORD.PNG │ ├── PATREON.png │ ├── REMOVE.png │ ├── SCROLL.png │ ├── YOUTUBE.png │ ├── ADD_SMALL.png │ ├── COMPLETED.png │ ├── INFO_ERROR.png │ ├── KaizenLogo.png │ ├── SHARE_CLIP.png │ ├── NARLOCK_LOGO.png │ ├── TODO_BUTTON.png │ ├── TODO_COMPLETED.png │ └── TODO_BUTTON_COMPLETED.png ├── habits.json ├── assets │ ├── ADD.png │ ├── DATE.png │ ├── EDIT.png │ ├── FIRE.png │ ├── LIST.png │ ├── RESET.png │ ├── SHARE.png │ ├── STAR.png │ ├── DELETE.png │ ├── DISCORD.png │ ├── PATREON.png │ ├── REMOVE.png │ ├── SCROLL.png │ ├── YOUTUBE.png │ ├── ADD_SMALL.png │ ├── COMPLETED.png │ ├── INFO_ERROR.png │ ├── KaizenIcon.png │ ├── KaizenLogo.png │ ├── SHARE_CLIP.png │ ├── JOURNAL_BAD.png │ ├── JOURNAL_GOOD.png │ ├── JOURNAL_MEH.png │ ├── NARLOCK_LOGO.png │ ├── PRIORITY_LOW.png │ ├── TODO_BUTTON.png │ ├── JOURNAL_GREAT.png │ ├── JOURNAL_NEUTRAL.png │ ├── PRIORITY_HIGH.png │ ├── PRIORITY_MEDIUM.png │ ├── TODO_COMPLETED.png │ ├── INFO_ERROR_ORANGE.png │ ├── PRIORITY_CRITICAL.png │ ├── JOURNAL_BAD_SELECTED.png │ ├── JOURNAL_MEH_SELECTED.png │ ├── JOURNAL_GOOD_SELECTED.png │ ├── JOURNAL_GREAT_SELECTED.png │ ├── TODO_BUTTON_COMPLETED.png │ └── JOURNAL_NEUTRAL_SELECTED.png ├── test │ ├── kaizen.icns │ ├── journal │ │ └── JournalPageTests.java │ ├── antihabit │ │ └── AntiHabitUtilsTests.java │ └── habit │ │ ├── HabitTestUtils.java │ │ └── HabitTestUtilsTests.java ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── com │ │ └── narlock │ │ ├── Kaizen.java │ │ ├── util │ │ ├── AntiHabitUtils.java │ │ ├── Debug.java │ │ ├── TodoUtils.java │ │ ├── ErrorPane.java │ │ ├── JTextFieldLimit.java │ │ ├── FadingLabel.java │ │ ├── CheckForUpdates.java │ │ ├── DiscordRP.java │ │ ├── Utils.java │ │ ├── RoundedBorder.java │ │ ├── NormalBorder.java │ │ └── HabitUtils.java │ │ ├── domain │ │ ├── AntiHabit.java │ │ ├── Epic.java │ │ ├── Home.java │ │ ├── TodoItem.java │ │ ├── JournalEntry.java │ │ ├── Todo.java │ │ ├── Journal.java │ │ ├── Settings.java │ │ └── Habit.java │ │ ├── panel │ │ ├── HelpPanel.java │ │ ├── AddEpicButton.java │ │ ├── CustomHomePanel.java │ │ └── AntiHabitsPanel.java │ │ ├── widget │ │ ├── NoWidgetPanel.java │ │ ├── HabitWidgetPanel.java │ │ └── JournalWidgetPanel.java │ │ ├── json │ │ ├── JsonManager.java │ │ ├── HomeJsonManager.java │ │ ├── SettingsJsonManager.java │ │ ├── AntiHabitJsonManager.java │ │ ├── JournalJsonManager.java │ │ ├── HabitJsonManager.java │ │ └── TodoJsonManager.java │ │ └── state │ │ ├── State.java │ │ ├── UpdateHabitsState.java │ │ ├── HomeState.java │ │ ├── HabitsState.java │ │ └── AntiHabitsState.java ├── .classpath └── .project ├── KaizenWeb ├── package.json └── src │ ├── client │ ├── assets │ │ ├── fb.png │ │ ├── bad.png │ │ ├── good.png │ │ ├── icon.png │ │ ├── logo.png │ │ ├── meh.png │ │ ├── great.png │ │ ├── neutral.png │ │ ├── whatsapp.png │ │ ├── high.svg │ │ ├── low.svg │ │ ├── major.svg │ │ ├── medium.svg │ │ └── discord.svg │ ├── js │ │ ├── healthGoals.js │ │ ├── contactForm.js │ │ ├── journal.js │ │ └── habits.js │ ├── css │ │ ├── relationships.css │ │ ├── journal.css │ │ ├── habits.css │ │ ├── health.css │ │ ├── index.css │ │ └── kanban.css │ ├── habits.html │ ├── relationships.html │ ├── index.html │ ├── healthGoals.html │ ├── contactForm.html │ └── journal.html │ └── package.json ├── README Assets ├── HL_UML.png ├── Habits.png ├── Home.png ├── Todo.png ├── Journal.png ├── AntiHabits.png ├── KaizenIcon.ico ├── KaizenIcon.png ├── KaizenLogo.png ├── KaizenLogoDS.png ├── MacOSOpenAnyway.png └── MacOSCannotVerify.png ├── Application Assets ├── icon.ico ├── Kaizen.icns └── Kaizen.iconset │ ├── icon_16x16.png │ ├── icon_32x32.png │ ├── icon_128x128.png │ ├── icon_16x16@2x.png │ ├── icon_256x256.png │ ├── icon_32x32@2x.png │ ├── icon_512x512.png │ ├── icon_128x128@2x.png │ ├── icon_256x256@2x.png │ └── icon_512x512@2x.png ├── OSLA ├── src │ ├── util │ │ └── AppConstants.java │ └── main │ │ ├── Kaizen.java │ │ └── Window.java ├── daily.json ├── weekly.jsonc ├── .classpath ├── .settings │ └── org.eclipse.jdt.core.prefs ├── .project └── user.json ├── .gitignore └── LICENSE /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: narlock -------------------------------------------------------------------------------- /KaizenClient/bin/.gitignore: -------------------------------------------------------------------------------- 1 | /com/ 2 | -------------------------------------------------------------------------------- /KaizenClient/habits.json: -------------------------------------------------------------------------------- 1 | [ 2 | 3 | ] 4 | -------------------------------------------------------------------------------- /KaizenWeb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mysql": "^2.18.1" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /README Assets/HL_UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/HL_UML.png -------------------------------------------------------------------------------- /README Assets/Habits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/Habits.png -------------------------------------------------------------------------------- /README Assets/Home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/Home.png -------------------------------------------------------------------------------- /README Assets/Todo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/Todo.png -------------------------------------------------------------------------------- /KaizenClient/bin/FIRE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/FIRE.png -------------------------------------------------------------------------------- /KaizenClient/bin/RESET.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/RESET.png -------------------------------------------------------------------------------- /KaizenClient/bin/SHARE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/SHARE.png -------------------------------------------------------------------------------- /KaizenClient/bin/STAR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/STAR.png -------------------------------------------------------------------------------- /README Assets/Journal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/Journal.png -------------------------------------------------------------------------------- /Application Assets/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/icon.ico -------------------------------------------------------------------------------- /KaizenClient/assets/ADD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/ADD.png -------------------------------------------------------------------------------- /KaizenClient/assets/DATE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/DATE.png -------------------------------------------------------------------------------- /KaizenClient/assets/EDIT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/EDIT.png -------------------------------------------------------------------------------- /KaizenClient/assets/FIRE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/FIRE.png -------------------------------------------------------------------------------- /KaizenClient/assets/LIST.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/LIST.png -------------------------------------------------------------------------------- /KaizenClient/assets/RESET.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/RESET.png -------------------------------------------------------------------------------- /KaizenClient/assets/SHARE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/SHARE.png -------------------------------------------------------------------------------- /KaizenClient/assets/STAR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/STAR.png -------------------------------------------------------------------------------- /KaizenClient/bin/DELETE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/DELETE.png -------------------------------------------------------------------------------- /KaizenClient/bin/DISCORD.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/DISCORD.PNG -------------------------------------------------------------------------------- /KaizenClient/bin/PATREON.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/PATREON.png -------------------------------------------------------------------------------- /KaizenClient/bin/REMOVE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/REMOVE.png -------------------------------------------------------------------------------- /KaizenClient/bin/SCROLL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/SCROLL.png -------------------------------------------------------------------------------- /KaizenClient/bin/YOUTUBE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/YOUTUBE.png -------------------------------------------------------------------------------- /KaizenClient/test/kaizen.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/test/kaizen.icns -------------------------------------------------------------------------------- /README Assets/AntiHabits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/AntiHabits.png -------------------------------------------------------------------------------- /README Assets/KaizenIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/KaizenIcon.ico -------------------------------------------------------------------------------- /README Assets/KaizenIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/KaizenIcon.png -------------------------------------------------------------------------------- /README Assets/KaizenLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/KaizenLogo.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.icns -------------------------------------------------------------------------------- /KaizenClient/assets/DELETE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/DELETE.png -------------------------------------------------------------------------------- /KaizenClient/assets/DISCORD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/DISCORD.png -------------------------------------------------------------------------------- /KaizenClient/assets/PATREON.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/PATREON.png -------------------------------------------------------------------------------- /KaizenClient/assets/REMOVE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/REMOVE.png -------------------------------------------------------------------------------- /KaizenClient/assets/SCROLL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/SCROLL.png -------------------------------------------------------------------------------- /KaizenClient/assets/YOUTUBE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/YOUTUBE.png -------------------------------------------------------------------------------- /KaizenClient/bin/ADD_SMALL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/ADD_SMALL.png -------------------------------------------------------------------------------- /KaizenClient/bin/COMPLETED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/COMPLETED.png -------------------------------------------------------------------------------- /KaizenClient/bin/INFO_ERROR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/INFO_ERROR.png -------------------------------------------------------------------------------- /KaizenClient/bin/KaizenLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/KaizenLogo.png -------------------------------------------------------------------------------- /KaizenClient/bin/SHARE_CLIP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/SHARE_CLIP.png -------------------------------------------------------------------------------- /README Assets/KaizenLogoDS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/KaizenLogoDS.png -------------------------------------------------------------------------------- /KaizenClient/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /KaizenClient/assets/ADD_SMALL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/ADD_SMALL.png -------------------------------------------------------------------------------- /KaizenClient/assets/COMPLETED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/COMPLETED.png -------------------------------------------------------------------------------- /KaizenClient/assets/INFO_ERROR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/INFO_ERROR.png -------------------------------------------------------------------------------- /KaizenClient/assets/KaizenIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/KaizenIcon.png -------------------------------------------------------------------------------- /KaizenClient/assets/KaizenLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/KaizenLogo.png -------------------------------------------------------------------------------- /KaizenClient/assets/SHARE_CLIP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/SHARE_CLIP.png -------------------------------------------------------------------------------- /KaizenClient/bin/NARLOCK_LOGO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/NARLOCK_LOGO.png -------------------------------------------------------------------------------- /KaizenClient/bin/TODO_BUTTON.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/TODO_BUTTON.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/fb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/fb.png -------------------------------------------------------------------------------- /README Assets/MacOSOpenAnyway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/MacOSOpenAnyway.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_BAD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_BAD.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_GOOD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_GOOD.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_MEH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_MEH.png -------------------------------------------------------------------------------- /KaizenClient/assets/NARLOCK_LOGO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/NARLOCK_LOGO.png -------------------------------------------------------------------------------- /KaizenClient/assets/PRIORITY_LOW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/PRIORITY_LOW.png -------------------------------------------------------------------------------- /KaizenClient/assets/TODO_BUTTON.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/TODO_BUTTON.png -------------------------------------------------------------------------------- /KaizenClient/bin/TODO_COMPLETED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/TODO_COMPLETED.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/bad.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/good.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/icon.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/logo.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/meh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/meh.png -------------------------------------------------------------------------------- /README Assets/MacOSCannotVerify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/README Assets/MacOSCannotVerify.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_GREAT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_GREAT.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_NEUTRAL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_NEUTRAL.png -------------------------------------------------------------------------------- /KaizenClient/assets/PRIORITY_HIGH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/PRIORITY_HIGH.png -------------------------------------------------------------------------------- /KaizenClient/assets/PRIORITY_MEDIUM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/PRIORITY_MEDIUM.png -------------------------------------------------------------------------------- /KaizenClient/assets/TODO_COMPLETED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/TODO_COMPLETED.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/great.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/great.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/neutral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/neutral.png -------------------------------------------------------------------------------- /KaizenClient/assets/INFO_ERROR_ORANGE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/INFO_ERROR_ORANGE.png -------------------------------------------------------------------------------- /KaizenClient/assets/PRIORITY_CRITICAL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/PRIORITY_CRITICAL.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/whatsapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenWeb/src/client/assets/whatsapp.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_BAD_SELECTED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_BAD_SELECTED.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_MEH_SELECTED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_MEH_SELECTED.png -------------------------------------------------------------------------------- /KaizenClient/bin/TODO_BUTTON_COMPLETED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/bin/TODO_BUTTON_COMPLETED.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_GOOD_SELECTED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_GOOD_SELECTED.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_GREAT_SELECTED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_GREAT_SELECTED.png -------------------------------------------------------------------------------- /KaizenClient/assets/TODO_BUTTON_COMPLETED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/TODO_BUTTON_COMPLETED.png -------------------------------------------------------------------------------- /OSLA/src/util/AppConstants.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | public class AppConstants { 4 | public static final String VERSION = "2.0.0"; 5 | } 6 | -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_16x16.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_32x32.png -------------------------------------------------------------------------------- /KaizenClient/assets/JOURNAL_NEUTRAL_SELECTED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/KaizenClient/assets/JOURNAL_NEUTRAL_SELECTED.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_128x128.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_256x256.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_512x512.png -------------------------------------------------------------------------------- /OSLA/src/main/Kaizen.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | public class Kaizen { 4 | public static void main(String[] args) { 5 | new Window(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /Application Assets/Kaizen.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narlock/Kaizen/HEAD/Application Assets/Kaizen.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/high.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/low.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /OSLA/daily.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "title": "Morning Stretch", 4 | "lastCompletedDate": "2023-11-08", 5 | "completed": false, 6 | "difficulty": 0, 7 | "currentStreak": 0, 8 | "notes": "This is a blob of text" 9 | } 10 | ] -------------------------------------------------------------------------------- /KaizenClient/test/journal/JournalPageTests.java: -------------------------------------------------------------------------------- 1 | package test.journal; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | class JournalPageTests { 8 | 9 | @Test 10 | void test() { 11 | // TODO 12 | assert 1==1; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/Kaizen.java: -------------------------------------------------------------------------------- 1 | package com.narlock; 2 | 3 | import com.narlock.gui.MainGUI; 4 | /** 5 | * Kaizen 6 | * @author narlock 7 | * 8 | * Runner for Kaizen, creates the user interface 9 | */ 10 | public class Kaizen { 11 | public static void main(String[] args) { 12 | new MainGUI(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OSLA/weekly.jsonc: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "title": "Laundry", 4 | "occurrence": 0, // The day of the week: 0 for Sunday, 1 for Monday, etc. 5 | "lastCompletedDate": "2023-11-08", 6 | "completed": false, 7 | "difficulty": 0, 8 | "currentStreak": 0, 9 | "notes": "This is a blob of text about the habit" 10 | } 11 | ] -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/AntiHabitUtils.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.time.temporal.ChronoUnit; 4 | import java.util.Date; 5 | 6 | import com.narlock.domain.AntiHabit; 7 | 8 | public class AntiHabitUtils extends Utils { 9 | 10 | public static long getDaysSince(Date antiHabitDate) { 11 | return Math.abs(ChronoUnit.DAYS.between(Utils.today().toInstant(), antiHabitDate.toInstant())); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OSLA/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /OSLA/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/Debug.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | 6 | public class Debug { 7 | private boolean on; 8 | 9 | public Debug(boolean on) { 10 | this.on = on; 11 | } 12 | 13 | public void print(String message) { 14 | if(on) { 15 | String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); 16 | System.out.println("[DEBUG] " + timeStamp + " : " + message); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/TodoUtils.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | public class TodoUtils extends Utils { 4 | public static String getPriorityImage(long indicator) { 5 | switch((int) indicator) { 6 | case 0: 7 | return "PRIORITY_LOW.png"; 8 | case 1: 9 | return "PRIORITY_MEDIUM.png"; 10 | case 2: 11 | return "PRIORITY_HIGH.png"; 12 | case 3: 13 | return "PRIORITY_CRITICAL.png"; 14 | } 15 | throw new RuntimeException("Error grabbing priority image, invalid indicator: " + indicator); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/major.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/ErrorPane.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.awt.Component; 4 | 5 | import javax.swing.ImageIcon; 6 | import javax.swing.JOptionPane; 7 | 8 | public class ErrorPane extends JOptionPane { 9 | private static final long serialVersionUID = -8480045449677402003L; 10 | 11 | public static void displayError(Component root, String errorMessage) { 12 | showMessageDialog(root, 13 | errorMessage, 14 | "An error occurred", 15 | JOptionPane.INFORMATION_MESSAGE, 16 | new ImageIcon(ErrorPane.class.getClassLoader().getResource("INFO_ERROR.png"))); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /KaizenClient/test/antihabit/AntiHabitUtilsTests.java: -------------------------------------------------------------------------------- 1 | package test.antihabit; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import java.time.temporal.ChronoUnit; 6 | import java.util.Date; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | import util.Utils; 11 | 12 | class AntiHabitUtilsTests { 13 | 14 | @Test 15 | void test() { 16 | Date date1 = Utils.stringToDate("2023-03-25"); 17 | Date date2 = Utils.stringToDate("2023-03-23"); 18 | 19 | long daysBetween = ChronoUnit.DAYS.between(date2.toInstant(), date1.toInstant()); 20 | 21 | assertEquals(daysBetween, 2); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/AntiHabit.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | import java.util.Date; 4 | 5 | public class AntiHabit { 6 | private String title; 7 | private Date date; 8 | 9 | public AntiHabit(String title, Date date) { 10 | super(); 11 | this.title = title; 12 | this.date = date; 13 | } 14 | 15 | public String getTitle() { 16 | return title; 17 | } 18 | 19 | public void setTitle(String title) { 20 | this.title = title; 21 | } 22 | 23 | public Date getDate() { 24 | return date; 25 | } 26 | 27 | public void setDate(Date date) { 28 | this.date = date; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/panel/HelpPanel.java: -------------------------------------------------------------------------------- 1 | package com.narlock.panel; 2 | 3 | import java.awt.Dimension; 4 | 5 | import javax.swing.JLabel; 6 | import javax.swing.JPanel; 7 | 8 | public class HelpPanel extends JPanel { 9 | 10 | private JLabel descriptionLabel; 11 | 12 | public String description; 13 | 14 | 15 | public HelpPanel(String description) { 16 | this.description = description; 17 | 18 | String labelText = String.format("
%s
", 200, description); 19 | 20 | descriptionLabel = new JLabel(labelText); 21 | 22 | this.add(descriptionLabel); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /OSLA/src/main/Window.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javax.swing.JFrame; 4 | 5 | import util.AppConstants; 6 | 7 | /** 8 | * The main window of the Kaizen application. 9 | * @author narlock 10 | * 11 | */ 12 | public class Window extends JFrame { 13 | 14 | private static final long serialVersionUID = -4810618286807932601L; 15 | 16 | public Window() { 17 | setTitle("Kaizen v" + AppConstants.VERSION); 18 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 19 | setSize(800, 600); 20 | setResizable(false); 21 | 22 | // add panel? 23 | 24 | setLocationRelativeTo(null); 25 | setVisible(true); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/Epic.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | import java.awt.Color; 4 | import java.util.List; 5 | 6 | public class Epic { 7 | private String title; 8 | private Color color; 9 | 10 | public Epic(String title, Color color) { 11 | super(); 12 | this.title = title; 13 | this.color = color; 14 | } 15 | 16 | public String getTitle() { 17 | return title; 18 | } 19 | 20 | public void setTitle(String title) { 21 | this.title = title; 22 | } 23 | 24 | public Color getColor() { 25 | return color; 26 | } 27 | 28 | public void setColor(Color color) { 29 | this.color = color; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /KaizenClient/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.release=enabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /KaizenWeb/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "src", 3 | "version": "1.0.0", 4 | "description": "Life Hub application with the goal of providing productivity essentials to help users achieve their goals.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/narlock/OpenLife.git" 12 | }, 13 | "author": "narlock", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/narlock/OpenLife/issues" 17 | }, 18 | "homepage": "https://github.com/narlock/OpenLife#readme", 19 | "dependencies": { 20 | "express": "^4.18.2", 21 | "mysql": "^2.18.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /KaizenClient/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/JTextFieldLimit.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import javax.swing.text.PlainDocument; 4 | import javax.swing.text.AttributeSet; 5 | import javax.swing.text.BadLocationException; 6 | 7 | public class JTextFieldLimit extends PlainDocument { 8 | private static final long serialVersionUID = -6755510745239694794L; 9 | private int limit; 10 | 11 | public JTextFieldLimit(int limit) { 12 | super(); 13 | this.limit = limit; 14 | } 15 | 16 | public void insertString( int offset, String str, AttributeSet attr ) throws BadLocationException { 17 | if (str == null) return; 18 | 19 | if ((getLength() + str.length()) <= limit) { 20 | super.insertString(offset, str, attr); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/js/healthGoals.js: -------------------------------------------------------------------------------- 1 | // Clock Logic 2 | function showTime(){ 3 | var date = new Date(); 4 | var h = date.getHours(); 5 | var m = date.getMinutes(); 6 | var s = date.getSeconds(); 7 | var session = "AM"; 8 | 9 | if(h == 0){ 10 | h = 12; 11 | } 12 | 13 | if(h > 12){ 14 | h = h - 12; 15 | session = "PM"; 16 | } 17 | 18 | h = (h < 10) ? "0" + h : h; 19 | m = (m < 10) ? "0" + m : m; 20 | s = (s < 10) ? "0" + s : s; 21 | 22 | var time = h + ":" + m + ":" + s + " " + session; 23 | document.getElementById("clock").innerText = time; 24 | document.getElementById("clock").textContent = time; 25 | 26 | setTimeout(showTime, 1000); 27 | 28 | } 29 | 30 | showTime(); -------------------------------------------------------------------------------- /OSLA/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | OSLA 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | 1699470376715 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/medium.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | icon/16px/medium-priority 9 | Created with Sketch. 10 | 11 | 12 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /KaizenClient/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | KaizenClient 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | 1674410497065 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | src/node_modules/ 3 | node_modules 4 | package-lock.json 5 | src/package-lock.json 6 | src/package.json 7 | .DS_Store 8 | package-lock.json 9 | src/package-lock.json 10 | src/package.json 11 | *.class 12 | KaizenClient/bin/INFO_ERROR_ORANGE.png 13 | KaizenClient/bin/JOURNAL_BAD.png 14 | KaizenClient/bin/JOURNAL_BAD_SELECTED.png 15 | KaizenClient/bin/JOURNAL_GOOD.png 16 | KaizenClient/bin/JOURNAL_GOOD_SELECTED.png 17 | KaizenClient/bin/JOURNAL_GREAT.png 18 | KaizenClient/bin/JOURNAL_GREAT_SELECTED.png 19 | KaizenClient/bin/JOURNAL_MEH.png 20 | KaizenClient/bin/JOURNAL_MEH_SELECTED.png 21 | KaizenClient/bin/JOURNAL_NEUTRAL.png 22 | KaizenClient/bin/JOURNAL_NEUTRAL_SELECTED.png 23 | KaizenClient/bin/ADD.png 24 | KaizenClient/bin/DATE.png 25 | KaizenClient/bin/EDIT.png 26 | KaizenClient/bin/LIST.png 27 | KaizenClient/bin/PRIORITY_CRITICAL.png 28 | KaizenClient/bin/PRIORITY_HIGH.png 29 | KaizenClient/bin/PRIORITY_LOW.png 30 | KaizenClient/bin/PRIORITY_MEDIUM.png 31 | KaizenClient/bin/KaizenIcon.png 32 | *.jar 33 | -------------------------------------------------------------------------------- /OSLA/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "profile": { 3 | "username": "Firebal", 4 | "joinDate": "2023-11-08", 5 | "avatar": { 6 | "properties": { 7 | "skin": 0, 8 | "hair": 0, 9 | "shirt": 0, 10 | "pants": 0, 11 | "shoes": 0, 12 | "misc": 0 13 | }, 14 | "colors": { 15 | "eye": [0, 0, 0], 16 | "hair": [0, 0, 0] 17 | }, 18 | "equipment": { 19 | "weapon": 0, 20 | "shield": 0 21 | } 22 | }, 23 | "background": 0, 24 | "stats": { 25 | "attack": 0, 26 | "defense": 0, 27 | "speed": 0, 28 | "magicAttack": 0, 29 | "magicDefense": 0 30 | }, 31 | "xp": 0, 32 | "coins": 0, 33 | "achievements": "000000000000" 34 | }, 35 | "preferences": { 36 | "border": 0, 37 | "appearance": "dark" 38 | } 39 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/widget/NoWidgetPanel.java: -------------------------------------------------------------------------------- 1 | package com.narlock.widget; 2 | 3 | import javax.swing.Box; 4 | import javax.swing.ImageIcon; 5 | import javax.swing.JLabel; 6 | import javax.swing.JPanel; 7 | 8 | import static com.narlock.util.Constants.*; 9 | 10 | import java.awt.GridBagConstraints; 11 | import java.awt.GridBagLayout; 12 | 13 | public class NoWidgetPanel extends JPanel { 14 | 15 | private static final long serialVersionUID = 2847983737757500543L; 16 | 17 | public NoWidgetPanel() { 18 | this.setLayout(new GridBagLayout()); 19 | GridBagConstraints gbc = new GridBagConstraints(); 20 | gbc.gridwidth = GridBagConstraints.REMAINDER; 21 | 22 | this.setBackground(GUI_BACKGROUND_COLOR); 23 | this.add(new JLabel(new ImageIcon(getClass().getClassLoader().getResource("INFO_ERROR_ORANGE.png"))), gbc); 24 | 25 | JLabel textLabel = new JLabel("No widget selected"); 26 | textLabel.setFont(COMPONENT_FONT_NORMAL_BOLD); 27 | textLabel.setForeground(COMPONENT_FOREGROUND_COLOR); 28 | 29 | this.add(Box.createVerticalStrut(20), gbc); 30 | this.add(textLabel, gbc); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Kaizen: Continuous Productivity by narlock 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/Home.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | public class Home { 4 | private String widget1; 5 | private String widget2; 6 | private String widget3; 7 | private String widget4; 8 | 9 | public Home() { 10 | super(); 11 | this.widget1 = ""; 12 | this.widget2 = ""; 13 | this.widget3 = ""; 14 | this.widget4 = ""; 15 | } 16 | 17 | public Home(String widget1, String widget2, String widget3, String widget4) { 18 | super(); 19 | this.widget1 = widget1; 20 | this.widget2 = widget2; 21 | this.widget3 = widget3; 22 | this.widget4 = widget4; 23 | } 24 | 25 | public String getWidget1() { 26 | return widget1; 27 | } 28 | 29 | public void setWidget1(String widget1) { 30 | this.widget1 = widget1; 31 | } 32 | 33 | public String getWidget2() { 34 | return widget2; 35 | } 36 | 37 | public void setWidget2(String widget2) { 38 | this.widget2 = widget2; 39 | } 40 | 41 | public String getWidget3() { 42 | return widget3; 43 | } 44 | 45 | public void setWidget3(String widget3) { 46 | this.widget3 = widget3; 47 | } 48 | 49 | public String getWidget4() { 50 | return widget4; 51 | } 52 | 53 | public void setWidget4(String widget4) { 54 | this.widget4 = widget4; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/assets/discord.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/FadingLabel.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.event.ActionEvent; 6 | import java.awt.event.ActionListener; 7 | 8 | import javax.swing.JLabel; 9 | import javax.swing.Timer; 10 | 11 | public class FadingLabel extends JLabel { 12 | private static final long serialVersionUID = 1L; 13 | private Timer timer; 14 | private int duration; 15 | private int alpha = 255; 16 | 17 | public FadingLabel(String text, int duration) { 18 | super(text); 19 | this.duration = duration; 20 | setForeground(Color.WHITE); 21 | } 22 | 23 | public void fade() { 24 | setForeground(Color.WHITE); // Reset color 25 | alpha = 255; // Reset alpha to 255 26 | if (timer != null) { 27 | timer.stop(); // Stop the timer if it's already running 28 | } 29 | timer = new Timer(duration / 100, new ActionListener() { 30 | @Override 31 | public void actionPerformed(ActionEvent e) { 32 | alpha -= 5; 33 | if (alpha < 20) { 34 | alpha = 20; 35 | timer.stop(); 36 | } 37 | setForeground(new Color(alpha, alpha, alpha)); 38 | } 39 | }); 40 | timer.start(); 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /KaizenClient/test/habit/HabitTestUtils.java: -------------------------------------------------------------------------------- 1 | package test.habit; 2 | 3 | import java.io.File; 4 | import java.io.FileReader; 5 | import java.io.IOException; 6 | import java.io.Reader; 7 | import java.util.List; 8 | 9 | import org.json.simple.JSONArray; 10 | import org.json.simple.parser.JSONParser; 11 | import org.json.simple.parser.ParseException; 12 | 13 | import domain.Habit; 14 | import json.HabitJsonManager; 15 | import util.Utils; 16 | 17 | public class HabitTestUtils { 18 | static final String testHabitsPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "test" + File.separatorChar + "habits.json"; 19 | 20 | public static Habit createTestHabitObject() { 21 | return new Habit( 22 | "testTitle", 23 | 0, 24 | "1234567", 25 | 0, 26 | Utils.stringToDate("2023-03-13") 27 | ); 28 | } 29 | 30 | public static JSONArray createTestHabitsObject() { 31 | try { 32 | JSONParser parser = new JSONParser(); 33 | Reader reader = new FileReader(testHabitsPath); 34 | return (JSONArray) parser.parse(reader); 35 | } catch (IOException | ParseException fnfe) { 36 | fnfe.printStackTrace(); 37 | } 38 | return null; 39 | } 40 | 41 | public static List createTestHabitList() { 42 | return HabitJsonManager.jsonHabitArrayToHabitList(createTestHabitsObject()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/TodoItem.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | import java.util.Date; 4 | 5 | public class TodoItem { 6 | private String title; 7 | private Date dueDate; 8 | private Date completedDate; 9 | private long priority; 10 | private String epic; 11 | 12 | public TodoItem(String title, Date dueDate, Date completedDate, long priority, String epic) { 13 | super(); 14 | this.title = title; 15 | this.dueDate = dueDate; 16 | this.completedDate = completedDate; 17 | this.priority = priority; 18 | this.epic = epic; 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public void setTitle(String title) { 26 | this.title = title; 27 | } 28 | 29 | public Date getDueDate() { 30 | return dueDate; 31 | } 32 | 33 | public void setDueDate(Date dueDate) { 34 | this.dueDate = dueDate; 35 | } 36 | 37 | public Date getCompletedDate() { 38 | return completedDate; 39 | } 40 | 41 | public void setCompletedDate(Date completedDate) { 42 | this.completedDate = completedDate; 43 | } 44 | 45 | public long getPriority() { 46 | return priority; 47 | } 48 | 49 | public void setPriority(long priority) { 50 | this.priority = priority; 51 | } 52 | 53 | public String getEpic() { 54 | return epic; 55 | } 56 | 57 | public void setEpic(String epic) { 58 | this.epic = epic; 59 | } 60 | 61 | public boolean isCompleted() { 62 | return completedDate != null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/css/relationships.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); 2 | * { 3 | font-family: "Roboto"; 4 | } 5 | 6 | .stable { 7 | border-collapse: collapse; 8 | margin-left: auto; 9 | margin-right: auto; 10 | font-size: 0.9em; 11 | font-family: sans-serif; 12 | min-width: 400px; 13 | background-color: white; 14 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 15 | margin-bottom: 2rem; 16 | } 17 | 18 | .stable thead tr { 19 | /*background-color: #009879;*/ 20 | color: black; 21 | text-align: left; 22 | } 23 | 24 | .stable th, 25 | .stable td { 26 | padding: 12px 15px; 27 | } 28 | 29 | .stable tbody tr { 30 | border-bottom: 1px solid #dddddd; 31 | } 32 | 33 | .stable tbody tr:nth-of-type(even) { 34 | background-color: #f3f3f3; 35 | } 36 | 37 | .stable tbody tr:last-of-type { 38 | border-bottom: 2px solid #0d6efd; 39 | } 40 | 41 | .hidden { 42 | display: none; 43 | } 44 | 45 | .relationships__menu { 46 | display: flex; 47 | justify-content: center; 48 | align-items: center; 49 | margin-top: 2rem; 50 | margin-bottom: 2rem; 51 | } 52 | 53 | .relationships__form { 54 | padding: 2rem; 55 | border-radius: 0.5rem; 56 | border: 2px solid black; 57 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 58 | } 59 | 60 | .relationships__form__article { 61 | margin-top: 2rem; 62 | margin-bottom: 2rem; 63 | } 64 | 65 | .updateDialog { 66 | margin-bottom: 2rem; 67 | } 68 | 69 | .error { 70 | color: red; 71 | } 72 | 73 | textarea { 74 | resize: none; 75 | } 76 | 77 | img { 78 | width: 30px; 79 | height: auto; 80 | } -------------------------------------------------------------------------------- /KaizenWeb/src/client/css/journal.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); 2 | * { 3 | font-family: "Roboto"; 4 | } 5 | 6 | .journal__heading { 7 | margin-bottom: 2rem; 8 | } 9 | 10 | .journal__form { 11 | padding: 1rem; 12 | border-radius: 1rem; 13 | border: 2px solid black; 14 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 15 | margin-top: 1rem; 16 | margin-bottom: 1rem; 17 | } 18 | 19 | img { 20 | width: 50px; 21 | height: auto; 22 | } 23 | 24 | .hidden { 25 | display: none; 26 | } 27 | 28 | /* HIDE RADIO */ 29 | [type=radio] { 30 | position: absolute; 31 | opacity: 0; 32 | width: 0; 33 | height: 0; 34 | } 35 | 36 | /* IMAGE STYLES */ 37 | [type=radio] + img { 38 | cursor: pointer; 39 | } 40 | 41 | /* CHECKED STYLES */ 42 | [type=radio]:checked + img { 43 | outline: 2px solid #f00; 44 | } 45 | 46 | .stable { 47 | border-collapse: collapse; 48 | margin-left: auto; 49 | margin-right: auto; 50 | font-size: 0.9em; 51 | font-family: sans-serif; 52 | min-width: 400px; 53 | background-color: white; 54 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 55 | margin-top: 2rem; 56 | margin-bottom: 2rem; 57 | } 58 | 59 | .stable thead tr { 60 | /*background-color: #009879;*/ 61 | color: black; 62 | text-align: left; 63 | } 64 | 65 | .stable th, 66 | .stable td { 67 | padding: 12px 15px; 68 | } 69 | 70 | .stable tbody tr { 71 | border-bottom: 1px solid #dddddd; 72 | } 73 | 74 | .stable tbody tr:nth-of-type(even) { 75 | background-color: #f3f3f3; 76 | } 77 | 78 | .stable tbody tr:last-of-type { 79 | border-bottom: 2px solid #0d6efd; 80 | } 81 | 82 | textarea { 83 | resize: none; 84 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/JournalEntry.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | import java.util.Date; 4 | 5 | import com.narlock.util.Utils; 6 | 7 | public class JournalEntry implements Comparable { 8 | private Date date; 9 | private long howWasDay; 10 | private String text1; //Events 11 | private String text2; //Stresses 12 | private String text3; //Gratefulness 13 | private String text4; //Goals 14 | 15 | public JournalEntry() { 16 | this.date = Utils.today(); 17 | } 18 | 19 | public JournalEntry(Date date, long howWasDay, String text1, String text2, String text3, String text4) { 20 | super(); 21 | this.date = date; 22 | this.howWasDay = howWasDay; 23 | this.text1 = text1; 24 | this.text2 = text2; 25 | this.text3 = text3; 26 | this.text4 = text4; 27 | } 28 | 29 | public Date getDate() { 30 | return date; 31 | } 32 | public void setDate(Date date) { 33 | this.date = date; 34 | } 35 | public long getHowWasDay() { 36 | return howWasDay; 37 | } 38 | public void setHowWasDay(long howWasDay) { 39 | this.howWasDay = howWasDay; 40 | } 41 | public String getText1() { 42 | return text1; 43 | } 44 | public void setText1(String text1) { 45 | this.text1 = text1; 46 | } 47 | public String getText2() { 48 | return text2; 49 | } 50 | public void setText2(String text2) { 51 | this.text2 = text2; 52 | } 53 | public String getText3() { 54 | return text3; 55 | } 56 | public void setText3(String text3) { 57 | this.text3 = text3; 58 | } 59 | public String getText4() { 60 | return text4; 61 | } 62 | public void setText4(String text4) { 63 | this.text4 = text4; 64 | } 65 | 66 | @Override 67 | public int compareTo(JournalEntry o) { 68 | return this.getDate().compareTo(o.getDate()); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/json/JsonManager.java: -------------------------------------------------------------------------------- 1 | package com.narlock.json; 2 | 3 | import java.io.File; 4 | 5 | import com.narlock.util.Debug; 6 | 7 | public class JsonManager { 8 | public static final Debug debug = new Debug(true); 9 | 10 | public static final String documentsPath = System.getProperty("user.home") + File.separatorChar + "Documents"; 11 | public static final String directoryPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen"; 12 | public static final String homePath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "home.json"; 13 | public static final String todoPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "todo.json"; 14 | public static final String habitsPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "habits.json"; 15 | public static final String antiHabitsPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "antihabits.json"; 16 | public static final String journalPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "journal.json"; 17 | public static final String relationshipsPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "relationships.json"; 18 | public static final String settingsPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "settings.json"; 19 | } 20 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/css/habits.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); 2 | * { 3 | font-family: "Roboto"; 4 | } 5 | 6 | .stable { 7 | border-collapse: collapse; 8 | margin-left: auto; 9 | margin-right: auto; 10 | font-size: 0.9em; 11 | font-family: sans-serif; 12 | min-width: 400px; 13 | background-color: white; 14 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 15 | } 16 | .stable thead tr { 17 | /*background-color: #009879;*/ 18 | color: black; 19 | text-align: left; 20 | } 21 | 22 | .stable th, 23 | .stable td { 24 | padding: 12px 15px; 25 | } 26 | 27 | .stable tbody tr { 28 | border-bottom: 1px solid #dddddd; 29 | } 30 | 31 | .stable tbody tr:nth-of-type(even) { 32 | background-color: #f3f3f3; 33 | } 34 | 35 | .stable tbody tr:last-of-type { 36 | border-bottom: 2px solid #0d6efd; 37 | } 38 | 39 | .habits__heading { 40 | margin-bottom: 2rem; 41 | } 42 | 43 | .habits__menu { 44 | display: flex; 45 | justify-content: center; 46 | align-items: center; 47 | margin-top: 2rem; 48 | margin-bottom: 2rem; 49 | } 50 | 51 | .habits__menu button { 52 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 53 | } 54 | 55 | .habits__menu a { 56 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 57 | } 58 | 59 | .habits__checkbox { 60 | width: 32px; 61 | height: 32px; 62 | } 63 | 64 | .habit__create__form { 65 | margin-top: 2rem; 66 | margin-bottom: 2rem; 67 | display: none; 68 | } 69 | 70 | .habit__update__form { 71 | margin-top: 2rem; 72 | margin-bottom: 2rem; 73 | display: none; 74 | } 75 | 76 | .habit__create__story__form { 77 | padding: 2rem; 78 | border-radius: 0.5rem; 79 | border: 2px solid black; 80 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 81 | } 82 | 83 | .updateFormId { 84 | display: none; 85 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/state/State.java: -------------------------------------------------------------------------------- 1 | package com.narlock.state; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | 6 | import javax.swing.JButton; 7 | import javax.swing.JPanel; 8 | 9 | import com.narlock.domain.Settings; 10 | import com.narlock.util.RoundedBorder; 11 | 12 | public abstract class State extends JPanel { 13 | 14 | protected Settings settings; 15 | private static final long serialVersionUID = -910452205672441980L; 16 | 17 | public State() { 18 | this.setBackground(new Color(20, 20, 20)); 19 | initPanelComponents(); 20 | initPanelComponentActions(); 21 | initPanel(); 22 | } 23 | 24 | public State(Settings settings) { 25 | this.settings = settings; 26 | this.setBackground(new Color(20, 20, 20)); 27 | initPanelComponents(); 28 | initPanelComponentActions(); 29 | initPanel(); 30 | } 31 | 32 | public boolean setButtonAttributes(JButton button, String indicator) { 33 | button.setText(indicator); 34 | button.setOpaque(true); 35 | button.setFocusPainted(false); 36 | switch(indicator) { 37 | case "New Habit": 38 | button.setBackground(new Color(120, 120, 255)); 39 | button.setForeground(new Color(60, 60, 60)); 40 | button.setFont(new Font("Tahoma", Font.PLAIN, 18)); 41 | button.setBorder(new RoundedBorder(Color.WHITE, 3, 10, 10, true)); 42 | return true; 43 | case "Update Habits": 44 | button.setBackground(new Color(120, 255, 120)); 45 | button.setForeground(new Color(60, 60, 60)); 46 | button.setFont(new Font("Tahoma", Font.PLAIN, 18)); 47 | button.setBorder(new RoundedBorder(Color.WHITE, 3, 10, 10, true)); 48 | return true; 49 | 50 | } 51 | return false; 52 | } 53 | 54 | public abstract void initPanelComponents(); 55 | public abstract void initPanelComponentActions(); 56 | public abstract void initPanel(); 57 | 58 | public Settings getSettings() { 59 | return settings; 60 | } 61 | 62 | public void setSettings(Settings settings) { 63 | this.settings = settings; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/CheckForUpdates.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | import java.io.BufferedReader; 3 | import java.io.IOException; 4 | import java.io.InputStreamReader; 5 | import java.net.HttpURLConnection; 6 | import java.net.MalformedURLException; 7 | import java.net.URL; 8 | import java.util.ArrayList; 9 | import java.util.Arrays; 10 | 11 | /** 12 | * CheckForUpdates 13 | * @author antho 14 | * 15 | * This class implements a checkForUpdates object 16 | * which contains a stored version list in which 17 | * correspond to releases that are on the github repository 18 | * 19 | * the httpurl connection will identify all of the releases 20 | * that the github contains 21 | * 22 | * if they are not equal, a new update will be signaled. 23 | * 24 | */ 25 | public class CheckForUpdates { 26 | 27 | private ArrayList currentReleases; 28 | 29 | public CheckForUpdates() { 30 | currentReleases = new ArrayList(); 31 | currentReleases.add("\"v1.0.5\""); 32 | currentReleases.add("\"v1.0.4\""); 33 | currentReleases.add("\"v1.0.2\""); 34 | } 35 | 36 | public boolean checkForUpdates() throws Exception { 37 | ArrayList releases = new ArrayList(); 38 | 39 | //Create HttpURLConnection 40 | HttpURLConnection httpcon = (HttpURLConnection) new URL("https://api.github.com/repos/narlock/Kaizen/releases").openConnection(); 41 | httpcon.addRequestProperty("User-Agent", "Mozilla/5.0"); 42 | BufferedReader in = new BufferedReader(new InputStreamReader(httpcon.getInputStream())); 43 | 44 | //Read line by line 45 | StringBuilder responseSB = new StringBuilder(); 46 | String line; 47 | while ( ( line = in.readLine() ) != null) { 48 | responseSB.append("\n" + line); 49 | //System.out.println(line); 50 | } 51 | in.close(); 52 | 53 | Arrays.stream(responseSB.toString().split("\"tag_name\":")).skip(1).map(l -> l.split(",")[0]).forEach(l -> releases.add(l)); 54 | 55 | if(releases.equals(currentReleases)) { 56 | return false; 57 | } else { 58 | return true; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/DiscordRP.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import net.arikia.dev.drpc.DiscordEventHandlers; 4 | import net.arikia.dev.drpc.DiscordRPC; 5 | import net.arikia.dev.drpc.DiscordRichPresence; 6 | 7 | /** 8 | * DiscordRP 9 | * 10 | * @author narlock 11 | * 12 | * @brief Utilizes Discord Rich Presence JAR 13 | * to support Rich Presence for TamoStudy 14 | */ 15 | public class DiscordRP { 16 | private final boolean DEVELOPER_MODE = false; 17 | 18 | private boolean running = true; 19 | private long created = 0; 20 | private DiscordEventHandlers handlers; 21 | 22 | /** 23 | * start 24 | * @brief Initiates Rich Presence 25 | */ 26 | public void start() { 27 | if(DEVELOPER_MODE || System.getProperty("os.name").contains("Windows")) { 28 | System.out.println("started"); 29 | this.created = System.currentTimeMillis(); 30 | 31 | handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> { 32 | System.out.println("Kaizen + Discord Rich Presence ready for " + user.username + "#" + user.discriminator + "!"); 33 | update("Continuously Improving!", ""); 34 | }).build(); 35 | 36 | DiscordRPC.discordInitialize("1093879096020307968", handlers, true); 37 | 38 | new Thread("Discord Rich Presence") { 39 | @Override 40 | public void run() { 41 | while(running) { 42 | DiscordRPC.discordRunCallbacks(); 43 | } 44 | } 45 | }.start(); 46 | } 47 | } 48 | 49 | /** 50 | * shutdown 51 | * @brief shuts down Rich Presence 52 | */ 53 | public void shutdown() { 54 | if(DEVELOPER_MODE || System.getProperty("os.name").contains("Windows")) { 55 | running = false; 56 | DiscordRPC.discordShutdown(); 57 | } 58 | } 59 | 60 | /** 61 | * update 62 | * @brief Updates Rich Presence 63 | * @param firstLine 64 | * @param secondLine 65 | */ 66 | public void update(String firstLine, String secondLine) { 67 | if(DEVELOPER_MODE || System.getProperty("os.name").contains("Windows")) { 68 | DiscordRichPresence.Builder b = new DiscordRichPresence.Builder(secondLine); 69 | b.setBigImage("large", ""); 70 | b.setDetails(firstLine); 71 | b.setStartTimestamps(created); 72 | DiscordRPC.discordUpdatePresence(b.build()); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/css/health.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); 2 | * { 3 | font-family: "Roboto"; 4 | } 5 | .stable { 6 | border-collapse: collapse; 7 | margin-left: auto; 8 | margin-right: auto; 9 | font-size: 0.9em; 10 | font-family: sans-serif; 11 | min-width: 400px; 12 | background-color: white; 13 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 14 | } 15 | 16 | .stable thead tr { 17 | /*background-color: #009879;*/ 18 | color: black; 19 | text-align: left; 20 | } 21 | 22 | .stable th, 23 | .stable td { 24 | padding: 12px 15px; 25 | } 26 | 27 | .stable tbody tr { 28 | border-bottom: 1px solid #dddddd; 29 | } 30 | 31 | .stable tbody tr:nth-of-type(even) { 32 | background-color: #f3f3f3; 33 | } 34 | 35 | .stable tbody tr:last-of-type { 36 | border-bottom: 2px solid #0d6efd; 37 | } 38 | 39 | .button__menu { 40 | display: flex; 41 | justify-content: center; 42 | align-items: center; 43 | margin-top: 2rem; 44 | margin-bottom: 2rem; 45 | } 46 | 47 | #myWaterBar { 48 | width: 0px; 49 | height: 30px; 50 | text-align: center; /* To center it horizontally (if you want) */ 51 | line-height: 30px; /* To center it vertically */ 52 | color: white; 53 | } 54 | 55 | #myCalorieBar { 56 | width: 0px; 57 | height: 30px; 58 | text-align: center; /* To center it horizontally (if you want) */ 59 | line-height: 30px; /* To center it vertically */ 60 | color: white; 61 | } 62 | 63 | #mySleepBar { 64 | width: 0px; 65 | height: 30px; 66 | text-align: center; /* To center it horizontally (if you want) */ 67 | line-height: 30px; /* To center it vertically */ 68 | color: white; 69 | } 70 | 71 | .waterColor { 72 | background-color: blue; 73 | } 74 | 75 | .calorieColor { 76 | background-color: orange; 77 | } 78 | 79 | .sleepColor { 80 | background-color: green; 81 | } 82 | 83 | .progress__bar { 84 | border: 2px solid; 85 | width: 300px; 86 | } 87 | 88 | .add__menu { 89 | margin-top: 1rem; 90 | margin-bottom: 1rem; 91 | } 92 | 93 | .units__label { 94 | margin-right: 1rem; 95 | } 96 | 97 | .goal__complete { 98 | color: green; 99 | display: none; 100 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/state/UpdateHabitsState.java: -------------------------------------------------------------------------------- 1 | package com.narlock.state; 2 | 3 | import java.awt.GridBagConstraints; 4 | import java.awt.GridBagLayout; 5 | import java.util.List; 6 | 7 | import javax.swing.Box; 8 | import javax.swing.JLabel; 9 | import javax.swing.JPanel; 10 | import javax.swing.JScrollPane; 11 | import javax.swing.ScrollPaneConstants; 12 | 13 | import com.narlock.domain.Habit; 14 | import com.narlock.json.HabitJsonManager; 15 | import com.narlock.panel.UpdateHabitsPanel; 16 | import com.narlock.util.Constants; 17 | import com.narlock.util.Debug; 18 | import com.narlock.util.HabitUtils; 19 | 20 | public class UpdateHabitsState extends State { 21 | 22 | private static final long serialVersionUID = 4172163218164088572L; 23 | private final Debug debug = new Debug(true); 24 | 25 | private List habits; 26 | 27 | private JPanel titlePanel; 28 | private JLabel titleLabel; 29 | 30 | private JScrollPane scrollPane; 31 | private UpdateHabitsPanel habitsPanel; 32 | 33 | @Override 34 | public void initPanelComponents() { 35 | //Get habits 36 | this.habits = HabitJsonManager.readHabits(); 37 | 38 | //Set up title panel 39 | titlePanel = new JPanel(); 40 | titlePanel.setBackground(Constants.GUI_BACKGROUND_COLOR); 41 | titleLabel = new JLabel(); 42 | titleLabel.setForeground(Constants.COMPONENT_FOREGROUND_COLOR); 43 | titleLabel.setFont(Constants.COMPONENT_FONT_NORMAL_BOLD); 44 | titlePanel.add(titleLabel); 45 | 46 | //Set up habits panel 47 | habitsPanel = new UpdateHabitsPanel(habits); 48 | scrollPane = new JScrollPane(habitsPanel, 49 | ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 50 | ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 51 | scrollPane.getVerticalScrollBar().setUnitIncrement(16); 52 | scrollPane.setPreferredSize(Constants.HABIT_SCROLL_PANE_LARGE); 53 | scrollPane.setBorder(null); 54 | } 55 | 56 | @Override 57 | public void initPanelComponentActions() { 58 | // TODO Auto-generated method stub 59 | 60 | } 61 | 62 | @Override 63 | public void initPanel() { 64 | this.setLayout(new GridBagLayout()); 65 | GridBagConstraints gbc = new GridBagConstraints(); 66 | gbc.gridwidth = GridBagConstraints.REMAINDER; 67 | 68 | this.add(titlePanel, gbc); 69 | this.add(Box.createVerticalStrut(20), gbc); 70 | this.add(scrollPane, gbc); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/css/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); 2 | * { 3 | font-family: "Roboto"; 4 | } 5 | 6 | .stable { 7 | border-collapse: collapse; 8 | margin-left: auto; 9 | margin-right: auto; 10 | font-size: 0.9em; 11 | font-family: sans-serif; 12 | min-width: 400px; 13 | background-color: white; 14 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 15 | margin-bottom: 2rem; 16 | } 17 | 18 | .stable thead tr { 19 | /*background-color: #009879;*/ 20 | color: black; 21 | text-align: left; 22 | } 23 | 24 | .stable th, 25 | .stable td { 26 | padding: 12px 15px; 27 | } 28 | 29 | .stable tbody tr { 30 | border-bottom: 1px solid #dddddd; 31 | } 32 | 33 | .stable tbody tr:nth-of-type(even) { 34 | background-color: #f3f3f3; 35 | } 36 | 37 | .stable tbody tr:last-of-type { 38 | border-bottom: 2px solid #0d6efd; 39 | } 40 | 41 | .story { 42 | background-color: white; 43 | margin: 0.2rem 0rem 0.3rem 0rem; 44 | border: 0.1rem solid black; 45 | border-radius: 0.2rem; 46 | padding: 0.5rem 0.2rem 0.5rem 2rem; 47 | width: 25rem; 48 | } 49 | 50 | .kanban__points { 51 | background-color: #a9ffa9; 52 | border-radius: 0.2rem; 53 | margin: 0.2rem 0.2rem 0.2rem 0.2rem; 54 | padding: 0.2rem 0.4rem; 55 | } 56 | 57 | .kanban__priority { 58 | width: 7.5%; 59 | height: auto; 60 | } 61 | 62 | .habits__checkbox { 63 | width: 32px; 64 | height: 32px; 65 | } 66 | 67 | .relationships__menu { 68 | display: flex; 69 | justify-content: center; 70 | align-items: center; 71 | margin-top: 2rem; 72 | margin-bottom: 2rem; 73 | } 74 | 75 | .relationships__form { 76 | padding: 2rem; 77 | border-radius: 0.5rem; 78 | border: 2px solid black; 79 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 80 | } 81 | 82 | .relationships__form__article { 83 | margin-top: 2rem; 84 | margin-bottom: 2rem; 85 | } 86 | 87 | .updateDialog { 88 | margin-bottom: 2rem; 89 | } 90 | 91 | .error { 92 | color: red; 93 | } 94 | 95 | textarea { 96 | resize: none; 97 | } 98 | 99 | .social__img { 100 | width: 30px; 101 | height: auto; 102 | } 103 | 104 | .logo__img { 105 | width: auto; 106 | height: auto; 107 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/widget/HabitWidgetPanel.java: -------------------------------------------------------------------------------- 1 | package com.narlock.widget; 2 | 3 | import java.awt.GridBagConstraints; 4 | import java.awt.GridBagLayout; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import javax.swing.Box; 9 | import javax.swing.JLabel; 10 | import javax.swing.JPanel; 11 | import javax.swing.JScrollPane; 12 | import javax.swing.ScrollPaneConstants; 13 | 14 | import com.narlock.domain.Habit; 15 | import com.narlock.json.HabitJsonManager; 16 | import com.narlock.panel.HabitsPanel; 17 | import com.narlock.util.Constants; 18 | import com.narlock.util.Debug; 19 | import com.narlock.util.HabitUtils; 20 | 21 | public class HabitWidgetPanel extends JPanel { 22 | 23 | private List habits; 24 | 25 | private static final long serialVersionUID = 2456894465204691767L; 26 | private final Debug debug = new Debug(true); 27 | 28 | private JPanel titlePanel; 29 | private JLabel titleLabel; 30 | 31 | private JPanel habitContainerPanel; 32 | private JScrollPane scrollPane; 33 | private HabitsPanel habitsPanel; 34 | 35 | public HabitWidgetPanel() { 36 | this.habits = HabitJsonManager.readHabits(); 37 | HabitUtils.updateHabits(habits); 38 | HabitJsonManager.writeHabitJsonToFile(habits); 39 | 40 | GridBagConstraints gbc = new GridBagConstraints(); 41 | gbc.gridwidth = GridBagConstraints.REMAINDER; 42 | this.setLayout(new GridBagLayout()); 43 | 44 | this.setBackground(Constants.GUI_BACKGROUND_COLOR); 45 | titlePanel = new JPanel(); 46 | titlePanel.setBackground(Constants.GUI_BACKGROUND_COLOR); 47 | titleLabel = new JLabel(); 48 | titleLabel.setForeground(Constants.COMPONENT_FOREGROUND_COLOR); 49 | titleLabel.setFont(Constants.COMPONENT_FONT_SMALL_BOLD); 50 | titlePanel.add(titleLabel); 51 | 52 | habitContainerPanel = new JPanel(); 53 | habitContainerPanel.setBackground(Constants.GUI_BACKGROUND_COLOR); 54 | 55 | habitsPanel = new HabitsPanel(habits, titleLabel, 1); 56 | scrollPane = new JScrollPane(habitsPanel, 57 | ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 58 | ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 59 | scrollPane.getVerticalScrollBar().setUnitIncrement(16); 60 | scrollPane.setPreferredSize(Constants.HABIT_SCROLL_PANE_SMALL); 61 | scrollPane.setBorder(null); 62 | habitContainerPanel.add(scrollPane); 63 | 64 | this.add(titlePanel, gbc); 65 | this.add(Box.createVerticalStrut(20), gbc); 66 | this.add(habitContainerPanel, gbc); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /KaizenClient/test/habit/HabitTestUtilsTests.java: -------------------------------------------------------------------------------- 1 | package test.habit; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import java.io.File; 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import org.json.simple.JSONArray; 10 | import org.junit.jupiter.api.Test; 11 | 12 | import domain.Habit; 13 | import json.HabitJsonManager; 14 | import util.Utils; 15 | 16 | class HabitTestUtilsTests { 17 | 18 | final String testHabitsPath = System.getProperty("user.home") + File.separatorChar + "Documents" + File.separatorChar + "Kaizen" + File.separatorChar + "test" + File.separatorChar + "habits.json"; 19 | final Date testTodaysDate = Utils.stringToDate("2023-03-14"); 20 | final Date testYesterdaysDate = Utils.stringToDate("2023-03-13"); 21 | final Date testLastWeeksDate = Utils.stringToDate("2023-03-07"); 22 | 23 | /** 24 | * testCreateTestHabitsObject 25 | * 26 | * @brief Integration test for the createTestHabits, which reads the JSON 27 | * from the testing path, this method will then do assertions after the 28 | * JSONArray is converted to the habit list. 29 | */ 30 | @Test 31 | void testCreateTestHabitsObject() { 32 | File file = new File(testHabitsPath); 33 | assertTrue(file.exists()); 34 | 35 | JSONArray testHabitArray = HabitTestUtils.createTestHabitsObject(); 36 | assertNotNull(testHabitArray); 37 | assertEquals(testHabitArray.size(), 48); 38 | 39 | List testHabits = HabitJsonManager.jsonHabitArrayToHabitList(testHabitArray); 40 | assertNotNull(testHabits); 41 | assertEquals(testHabits.size(), 48); 42 | 43 | //Test that the date is correct 44 | for(int i = 0; i < 16; i++) { 45 | testHabits.get(i).setDate(testTodaysDate); 46 | assertEquals(Utils.dateAsString(testHabits.get(i).getDate()), "2023-03-14"); 47 | } 48 | 49 | for(int i = 16; i < 32; i++) { 50 | testHabits.get(i).setDate(testYesterdaysDate); 51 | assertEquals(Utils.dateAsString(testHabits.get(i).getDate()), "2023-03-13"); 52 | } 53 | 54 | for(int i = 32; i < 48; i++) { 55 | testHabits.get(i).setDate(testLastWeeksDate); 56 | assertEquals(Utils.dateAsString(testHabits.get(i).getDate()), "2023-03-07"); 57 | } 58 | 59 | //Test that the status is correct on creation 60 | for(int i = 0; i < 46; i = i + 2) { 61 | assertEquals(testHabits.get(i).getStatus(), 1); 62 | } 63 | 64 | for(int i = 1; i < 48; i = i + 2) { 65 | assertEquals(testHabits.get(i).getStatus(), 0); 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/css/kanban.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); 2 | * { 3 | font-family: "Roboto"; 4 | } 5 | 6 | .kanban__container { 7 | width: 70%; 8 | min-width: 50%; 9 | margin: auto; 10 | display: flex; 11 | flex-direction: column; 12 | border: 2px solid black; 13 | border-radius: 0.3rem; 14 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 15 | } 16 | 17 | .kanban__board { 18 | display: flex; 19 | flex-direction: row; 20 | justify-content: space-between; 21 | font-family: sans-serif; 22 | } 23 | 24 | .kanban__block { 25 | padding: 0.6rem; 26 | width: 30.5%; 27 | min-width: 14rem; 28 | min-height: 4.5rem; 29 | /* border-radius: 0.3rem; */ 30 | } 31 | 32 | .kanban__header { 33 | text-align: center; 34 | font-weight: bold; 35 | } 36 | 37 | #backlog { 38 | background-color: rgb(148, 214, 255); 39 | border: 1px solid black; 40 | } 41 | 42 | #todo { 43 | background-color: rgb(255, 100, 100); 44 | border: 1px solid black; 45 | } 46 | 47 | #inprog { 48 | background-color: #ffa76d; 49 | border: 1px solid black; 50 | } 51 | 52 | #done { 53 | background-color: #ffdd62; 54 | border: 1px solid black; 55 | } 56 | 57 | .story { 58 | background-color: white; 59 | margin: 0.2rem 0rem 0.3rem 0rem; 60 | border: 0.1rem solid black; 61 | border-radius: 0.2rem; 62 | padding: 0.5rem 0.2rem 0.5rem 2rem; 63 | cursor: grab; 64 | } 65 | 66 | .kanban__points { 67 | background-color: #a9ffa9; 68 | border-radius: 0.2rem; 69 | margin: 0.2rem 0.2rem 0.2rem 0.2rem; 70 | padding: 0.2rem 0.4rem; 71 | } 72 | 73 | .kanban__priority { 74 | width: 7.5%; 75 | height: auto; 76 | } 77 | 78 | .kanban__create { 79 | display: flex; 80 | justify-content: center; 81 | align-items: center; 82 | margin-top: 2rem; 83 | margin-bottom: 2rem; 84 | } 85 | 86 | .kanban__create button { 87 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 88 | } 89 | 90 | .kanban__create__form { 91 | margin-top: 2rem; 92 | margin-bottom: 2rem; 93 | display: none; 94 | } 95 | 96 | .kanban__create__story__form { 97 | padding: 2rem; 98 | border-radius: 0.5rem; 99 | border: 2px solid black; 100 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 101 | } 102 | 103 | .kanban__update__form { 104 | margin-top: 2rem; 105 | margin-bottom: 2rem; 106 | display: none; 107 | } -------------------------------------------------------------------------------- /KaizenWeb/src/client/habits.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Habits • Kaizen 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Habits

16 |
17 |
18 | 32 |
33 |

Today's Habits

34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
HabitStreak
45 |
46 |
47 | View All Habits 48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/Utils.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.time.temporal.ChronoUnit; 6 | import java.util.Date; 7 | import java.util.regex.Pattern; 8 | 9 | import com.narlock.domain.Habit; 10 | 11 | public class Utils { 12 | 13 | public static Date today() { 14 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 15 | Date date = new Date(); 16 | String formattedDateString = formatter.format(date); 17 | try { 18 | return formatter.parse(formattedDateString); 19 | } catch (ParseException e) { 20 | e.printStackTrace(); 21 | } 22 | throw new RuntimeException("Unexpected error occurred"); 23 | } 24 | 25 | public static Date yesterday(Date today) { 26 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 27 | Date date = Date.from(today.toInstant().minus(1, ChronoUnit.DAYS)); 28 | String formattedDateString = formatter.format(date); 29 | try { 30 | return formatter.parse(formattedDateString); 31 | } catch (ParseException e) { 32 | e.printStackTrace(); 33 | } 34 | throw new RuntimeException("Unexpected error occurred"); 35 | } 36 | 37 | public static Date lastWeek(Date today) { 38 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 39 | Date date = Date.from(today.toInstant().minus(6, ChronoUnit.DAYS)); 40 | String formattedDateString = formatter.format(date); 41 | try { 42 | return formatter.parse(formattedDateString); 43 | } catch (ParseException e) { 44 | e.printStackTrace(); 45 | } 46 | throw new RuntimeException("Unexpected error occurred"); 47 | } 48 | 49 | public static String todayAsString() { 50 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 51 | Date date = new Date(); 52 | return formatter.format(date); 53 | } 54 | 55 | public static Date stringToDate(String dateString) { 56 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 57 | try { 58 | return formatter.parse(dateString); 59 | } catch (ParseException e) { 60 | // TODO Auto-generated catch block 61 | e.printStackTrace(); 62 | return null; 63 | } 64 | } 65 | 66 | public static String dateAsString(Date date) { 67 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 68 | return formatter.format(date); 69 | } 70 | 71 | public static String prettyDateAsString(Date date) { 72 | SimpleDateFormat sdf = new SimpleDateFormat("EEEE, MMMM d, yyyy"); 73 | return sdf.format(date); 74 | } 75 | 76 | public static boolean validateDateString(String dateString) { 77 | String regex = "^\\d{4}\\-(0[1-9]|1[012])\\-(0[1-9]|[12][0-9]|3[01])$"; 78 | return Pattern.matches(regex, dateString); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/Todo.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class Todo { 8 | private String sortMode; // sort items by priority, date, and reverse of each 9 | private String viewMode; // view all items, items for today 10 | private List epics; 11 | private List items; 12 | 13 | /** 14 | * New Todo Constructor 15 | */ 16 | public Todo() { 17 | this.sortMode = "date"; 18 | this.viewMode = "all"; 19 | this.epics = new ArrayList(); 20 | this.items = new ArrayList(); 21 | } 22 | 23 | /** 24 | * Load Todo Constructor 25 | * @param sortMode 26 | * @param viewMode 27 | * @param epics 28 | * @param items 29 | * 30 | * Under the case where an attribute cannot be loaded, 31 | * it will be defaulted. 32 | */ 33 | public Todo(String sortMode, String viewMode, List epics, List items) { 34 | super(); 35 | this.sortMode = sortMode != null ? sortMode : "date"; 36 | this.viewMode = viewMode != null ? viewMode : "all"; 37 | this.epics = epics != null ? epics : new ArrayList(); 38 | this.items = items != null ? items : new ArrayList(); 39 | } 40 | 41 | public String getSortMode() { 42 | return sortMode; 43 | } 44 | 45 | public void setSortMode(String sortMode) { 46 | this.sortMode = sortMode; 47 | } 48 | 49 | public String getViewMode() { 50 | return viewMode; 51 | } 52 | 53 | public void setViewMode(String viewMode) { 54 | this.viewMode = viewMode; 55 | } 56 | 57 | public List getEpics() { 58 | return epics; 59 | } 60 | 61 | public void setEpics(List epics) { 62 | this.epics = epics; 63 | } 64 | 65 | public List getItems() { 66 | return items; 67 | } 68 | 69 | public void setItems(List items) { 70 | this.items = items; 71 | } 72 | 73 | public void sortItemsByDate() { 74 | Collections.sort(items, (o1, o2) -> o1.getDueDate().compareTo(o2.getDueDate())); 75 | } 76 | 77 | public void sortItemsByDateReverse() { 78 | Collections.sort(items, (o1, o2) -> o1.getDueDate().compareTo(o2.getDueDate())); 79 | Collections.reverse(items); 80 | } 81 | 82 | public void sortItemsByPriority() { 83 | items.sort((o1, o2) -> { 84 | if(o1.getPriority() > o2.getPriority()) { 85 | return -1; 86 | } 87 | else if(o1.getPriority() == o2.getPriority()) { 88 | return 0; 89 | } 90 | else { 91 | return 1; 92 | } 93 | }); 94 | } 95 | 96 | public void sortItemsByPriorityReverse() { 97 | items.sort((o1, o2) -> { 98 | if(o1.getPriority() < o2.getPriority()) { 99 | return -1; 100 | } 101 | else if(o1.getPriority() == o2.getPriority()) { 102 | return 0; 103 | } 104 | else { 105 | return 1; 106 | } 107 | }); 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/state/HomeState.java: -------------------------------------------------------------------------------- 1 | package com.narlock.state; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.Dimension; 6 | import java.awt.GridLayout; 7 | import java.util.ArrayList; 8 | import java.util.Collections; 9 | 10 | import javax.swing.ImageIcon; 11 | import javax.swing.JButton; 12 | import javax.swing.JLabel; 13 | import javax.swing.JPanel; 14 | import javax.swing.SwingConstants; 15 | 16 | import com.narlock.domain.Home; 17 | import com.narlock.domain.Settings; 18 | import com.narlock.json.HomeJsonManager; 19 | import com.narlock.widget.AntiHabitWidgetPanel; 20 | import com.narlock.widget.HabitWidgetPanel; 21 | import com.narlock.widget.JournalWidgetPanel; 22 | import com.narlock.widget.NoWidgetPanel; 23 | import com.narlock.widget.TodoWidgetPanel; 24 | 25 | public class HomeState extends State { 26 | 27 | private static final long serialVersionUID = -794674909058043997L; 28 | private Home home; 29 | 30 | private JPanel widget; 31 | private JPanel widget2; 32 | private JPanel widget3; 33 | private JPanel widget4; 34 | 35 | public HomeState(Settings settings) { 36 | super(settings); 37 | } 38 | 39 | @Override 40 | public void initPanelComponents() { 41 | home = HomeJsonManager.readJson(); 42 | 43 | 44 | //Set up habits panel 45 | widget = getWidgetFromString(home.getWidget1()); 46 | widget2 = getWidgetFromString(home.getWidget2()); 47 | widget3 = getWidgetFromString(home.getWidget3()); 48 | widget4 = getWidgetFromString(home.getWidget4()); 49 | } 50 | 51 | @Override 52 | public void initPanelComponentActions() {} 53 | 54 | @Override 55 | public void initPanel() { 56 | // TODO Auto-generated method stub 57 | this.setLayout(new GridLayout(2,2)); 58 | // this.setLayout(new BorderLayout()); 59 | // JPanel leftPanel = new JPanel(new GridLayout(2, 1)); 60 | // leftPanel.add(widget); 61 | // leftPanel.add(widget2); 62 | // JPanel centerPanel = new JPanel(); 63 | // centerPanel.setBackground(Color.BLACK); 64 | // JPanel rightPanel = new JPanel(new GridLayout(2, 1)); 65 | // rightPanel.add(widget3); 66 | // rightPanel.add(widget4); 67 | this.add(widget); 68 | this.add(widget2); 69 | this.add(widget3); 70 | this.add(widget4); 71 | // this.add(leftPanel, BorderLayout.WEST); 72 | // this.add(centerPanel, BorderLayout.CENTER); 73 | // this.add(rightPanel, BorderLayout.EAST); 74 | } 75 | 76 | public JPanel getWidgetFromString(String widgetString) { 77 | switch(widgetString) { 78 | case "todo": 79 | return new TodoWidgetPanel(); 80 | case "habits": 81 | return new HabitWidgetPanel(); 82 | case "antiHabits": 83 | return new AntiHabitWidgetPanel(); 84 | case "journal1": 85 | return new JournalWidgetPanel(1, settings); 86 | case "journal2": 87 | return new JournalWidgetPanel(2, settings); 88 | case "journal3": 89 | return new JournalWidgetPanel(3, settings); 90 | case "journal4": 91 | return new JournalWidgetPanel(4, settings); 92 | default: 93 | return new NoWidgetPanel(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/json/HomeJsonManager.java: -------------------------------------------------------------------------------- 1 | package com.narlock.json; 2 | 3 | import java.io.File; 4 | import java.io.FileReader; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.io.Reader; 8 | 9 | import org.json.simple.JSONObject; 10 | import org.json.simple.parser.JSONParser; 11 | import org.json.simple.parser.ParseException; 12 | 13 | import com.narlock.domain.Home; 14 | 15 | public class HomeJsonManager extends JsonManager { 16 | private static FileWriter file; 17 | 18 | public static Home readJson() { 19 | File homeJsonFile = new File(homePath); 20 | if(homeJsonFile.exists()) { 21 | //TODO read the habits from the file and return, try catch and throw error 22 | JSONParser parser = new JSONParser(); 23 | try { 24 | Reader reader = new FileReader(homePath); 25 | JSONObject homeObject = (JSONObject) parser.parse(reader); 26 | return homeJsonToHome(homeObject); 27 | } catch (IOException | ParseException fnfe) { 28 | // TODO Auto-generated catch block 29 | fnfe.printStackTrace(); 30 | } 31 | } else { 32 | //Check if the documents directory exists, if not, create it 33 | File documentsDirectory = new File(documentsPath); 34 | documentsDirectory.mkdir(); //Creates the Documents/ directory if it does not exist. 35 | 36 | //Check if the Kaizen directory exists, if not, create it 37 | File kaizenDirectory = new File(directoryPath); 38 | kaizenDirectory.mkdir(); //Creates the Documents/Kaizen/ directory if it does not exist. 39 | 40 | //TODO Create new habits.json file and return 41 | try { 42 | homeJsonFile.createNewFile(); 43 | writeHomeToFile(new Home()); 44 | readJson(); 45 | } catch (IOException proOsuGamer) { 46 | // TODO Auto-generated catch block 47 | proOsuGamer.printStackTrace(); 48 | } 49 | } 50 | 51 | return new Home(); 52 | } 53 | 54 | public static boolean writeHomeToFile(Home home) { 55 | File homeJsonFile = new File(homePath); 56 | JSONObject homeObject = homeToHomeJson(home); 57 | try { 58 | file = new FileWriter(homeJsonFile); 59 | file.write(homeObject.toJSONString()); 60 | return true; 61 | } catch (IOException e) { 62 | // TODO Auto-generated catch block 63 | e.printStackTrace(); 64 | return false; 65 | } finally { 66 | try { 67 | file.flush(); 68 | file.close(); 69 | } catch (IOException e) { 70 | // TODO Auto-generated catch block 71 | e.printStackTrace(); 72 | } 73 | } 74 | } 75 | 76 | public static Home homeJsonToHome(JSONObject homeObject) { 77 | return new Home( 78 | (String) homeObject.get("widget1"), 79 | (String) homeObject.get("widget2"), 80 | (String) homeObject.get("widget3"), 81 | (String) homeObject.get("widget4") 82 | ); 83 | } 84 | 85 | @SuppressWarnings("unchecked") 86 | public static JSONObject homeToHomeJson(Home home) { 87 | JSONObject homeObject = new JSONObject(); 88 | homeObject.put("widget1", home.getWidget1()); 89 | homeObject.put("widget2", home.getWidget2()); 90 | homeObject.put("widget3", home.getWidget3()); 91 | homeObject.put("widget4", home.getWidget4()); 92 | return homeObject; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/panel/AddEpicButton.java: -------------------------------------------------------------------------------- 1 | package com.narlock.panel; 2 | 3 | import static com.narlock.util.Constants.*; 4 | 5 | import java.awt.Color; 6 | import java.awt.GridLayout; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | 10 | import javax.swing.ImageIcon; 11 | import javax.swing.JButton; 12 | import javax.swing.JColorChooser; 13 | import javax.swing.JLabel; 14 | import javax.swing.JOptionPane; 15 | import javax.swing.JPanel; 16 | import javax.swing.JTextField; 17 | 18 | import com.narlock.domain.Epic; 19 | import com.narlock.domain.Todo; 20 | import com.narlock.json.TodoJsonManager; 21 | import com.narlock.state.TodoState; 22 | import com.narlock.util.ErrorPane; 23 | 24 | public class AddEpicButton extends JButton { 25 | 26 | private static final long serialVersionUID = 5868914221761896285L; 27 | 28 | private JPanel panel; 29 | private JLabel titleLabel; 30 | private JTextField titleTextField; 31 | private JLabel colorLabel; 32 | private JButton setColorButton; 33 | private Color color; 34 | 35 | private JColorChooser colorChooser; 36 | 37 | public AddEpicButton(ImageIcon imageIcon, Todo todo, TodoState state) { 38 | super(imageIcon); 39 | 40 | this.panel = new JPanel(new GridLayout(0, 1)); 41 | this.titleLabel = new JLabel("Epic Title"); 42 | this.titleTextField = new JTextField(); 43 | this.colorLabel = new JLabel("Color"); 44 | this.setColorButton = new JButton("Set Color"); 45 | 46 | this.addActionListener(new ActionListener() { 47 | 48 | @Override 49 | public void actionPerformed(ActionEvent e) { 50 | color = COMPONENT_BACKGROUND_COLOR; 51 | titleTextField.setText(""); 52 | 53 | setColorButton.addActionListener(new ActionListener() { 54 | 55 | @Override 56 | public void actionPerformed(ActionEvent e) { 57 | colorChooser = new JColorChooser(color); 58 | color = colorChooser.showDialog(getRootPane(), "Associate an epic with a color", COMPONENT_BACKGROUND_COLOR); 59 | if(color == null) { 60 | color = COMPONENT_BACKGROUND_COLOR; 61 | } 62 | } 63 | 64 | }); 65 | 66 | panel.add(titleLabel); 67 | panel.add(titleTextField); 68 | panel.add(colorLabel); 69 | panel.add(setColorButton); 70 | 71 | int result = JOptionPane.showConfirmDialog( 72 | getRootPane(), 73 | panel, 74 | "Create Epic", 75 | JOptionPane.OK_CANCEL_OPTION, 76 | JOptionPane.QUESTION_MESSAGE, 77 | new ImageIcon(getClass().getClassLoader().getResource("INFO_ERROR_ORANGE.png"))); 78 | if(result == JOptionPane.YES_OPTION && 79 | !titleTextField.getText().equals("") 80 | ) { 81 | Epic epic = new Epic(titleTextField.getText(), color); 82 | todo.getEpics().add(epic); 83 | TodoJsonManager.writeTodoJsonToFile(todo); 84 | state.revalidateEpicPanel(); 85 | } 86 | else if(result == JOptionPane.YES_OPTION && 87 | titleTextField.getText().equals("") 88 | ) { 89 | ErrorPane.displayError(getRootPane(), "Could not create habit. Please provide a title."); 90 | } 91 | else { 92 | System.out.println("Cancel"); 93 | } 94 | } 95 | 96 | }); 97 | 98 | 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/Journal.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | import com.narlock.util.Debug; 9 | import com.narlock.util.Utils; 10 | 11 | public class Journal { 12 | private List entries; 13 | private Date lastLog; 14 | private long logStreak; 15 | private boolean showStreak; 16 | 17 | /** 18 | * New Journal Constructor 19 | */ 20 | public Journal() { 21 | this.entries = new ArrayList(); 22 | this.lastLog = Utils.today(); //There is no "last log" until a user saves their first log. 23 | this.logStreak = 0; 24 | this.showStreak = false; 25 | } 26 | 27 | public Journal( 28 | List entries, 29 | Date lastLog, 30 | long logStreak, 31 | boolean showStreak 32 | ) { 33 | super(); 34 | this.entries = entries; 35 | Collections.sort(entries); //Sorts the entries by date 36 | this.lastLog = lastLog; 37 | this.logStreak = logStreak; 38 | this.showStreak = showStreak; 39 | } 40 | 41 | public List getEntries() { 42 | return entries; 43 | } 44 | 45 | public void setEntries(List entries) { 46 | this.entries = entries; 47 | } 48 | 49 | public Date getLastLog() { 50 | return lastLog; 51 | } 52 | 53 | public void setLastLog(Date lastLog) { 54 | this.lastLog = lastLog; 55 | } 56 | 57 | public long getLogStreak() { 58 | return logStreak; 59 | } 60 | 61 | public void setLogStreak(long logStreak) { 62 | this.logStreak = logStreak; 63 | } 64 | 65 | public boolean isShowStreak() { 66 | return showStreak; 67 | } 68 | 69 | public void setShowStreak(boolean showStreak) { 70 | this.showStreak = showStreak; 71 | } 72 | 73 | public boolean isEntryInEntries(Date dateString) { 74 | if(entries.isEmpty()) { 75 | return false; 76 | } 77 | 78 | for(JournalEntry entry : entries) { 79 | final Debug debug = new Debug(true); 80 | debug.print("JOURNAL - entryDateAsString = " + Utils.dateAsString(entry.getDate())); 81 | debug.print("JOURNAL - dateString = " + Utils.dateAsString(dateString)); 82 | debug.print("" + Utils.dateAsString(entry.getDate()).equals(Utils.dateAsString(dateString))); 83 | if(Utils.dateAsString(entry.getDate()).equals(Utils.dateAsString(dateString))) { 84 | return true; 85 | } 86 | } 87 | return false; 88 | } 89 | 90 | public JournalEntry getEntryByDateString(String dateString) { 91 | if(entries.isEmpty()) { 92 | return new JournalEntry(); 93 | } 94 | 95 | for(JournalEntry entry : entries) { 96 | if(Utils.dateAsString(entry.getDate()).equals(dateString)) { 97 | return entry; 98 | } 99 | } 100 | throw new RuntimeException("Entry does not exist in journal"); 101 | } 102 | 103 | public String getEntryDates() { 104 | String dates = ""; 105 | for(JournalEntry entry : entries) { 106 | dates += Utils.dateAsString(entry.getDate()) + ", "; 107 | } 108 | return dates; 109 | } 110 | 111 | @Override 112 | public String toString() { 113 | return "Journal [entries=" + entries + ", lastLog=" + lastLog + ", logStreak=" + logStreak + ", showStreak=" 114 | + showStreak + "]"; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/relationships.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Relationships • Kaizen 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Relationships

16 |
17 |
18 | 32 |

Upcoming Birthdays

33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
NameDays UntilBirthdayContact
46 |

My Contacts

47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
NameBirthdayPhoneContactNoteOptions
62 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/RoundedBorder.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.awt.BasicStroke; 4 | import java.awt.Color; 5 | import java.awt.Component; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.Insets; 9 | import java.awt.Polygon; 10 | import java.awt.Rectangle; 11 | import java.awt.RenderingHints; 12 | import java.awt.geom.Area; 13 | import java.awt.geom.RoundRectangle2D; 14 | 15 | import javax.swing.border.AbstractBorder; 16 | 17 | /** 18 | * Found on the web, then modified 19 | * 20 | * @author http://stackoverflow.com/questions/15025092/border-with-rounded-corners-transparency 21 | * 22 | */ 23 | public class RoundedBorder extends AbstractBorder 24 | { 25 | 26 | private static final long serialVersionUID = -3308622773777385399L; 27 | private Color color; 28 | private int thickness = 4; 29 | private int radii = 8; 30 | private int pointerSize = 7; 31 | private Insets insets = null; 32 | private BasicStroke stroke = null; 33 | private int strokePad; 34 | private int pointerPad = 4; 35 | private boolean left = true; 36 | RenderingHints hints; 37 | 38 | public RoundedBorder(Color color) 39 | { 40 | new RoundedBorder(color, 4, 8, 7); 41 | } 42 | 43 | public RoundedBorder(Color color, int thickness, int radii, int pointerSize) 44 | { 45 | this.thickness = thickness; 46 | this.radii = radii; 47 | this.pointerSize = pointerSize; 48 | this.color = color; 49 | 50 | stroke = new BasicStroke(thickness); 51 | strokePad = thickness / 2; 52 | 53 | hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 54 | 55 | int pad = radii + strokePad; 56 | int bottomPad = pad + pointerSize + strokePad; 57 | insets = new Insets(pad, pad, bottomPad, pad); 58 | } 59 | 60 | public RoundedBorder(Color color, int thickness, int radii, int pointerSize, boolean left) 61 | { 62 | this(color, thickness, radii, pointerSize); 63 | this.left = left; 64 | } 65 | 66 | @Override 67 | public Insets getBorderInsets(Component c) 68 | { 69 | return insets; 70 | } 71 | 72 | @Override 73 | public Insets getBorderInsets(Component c, Insets insets) 74 | { 75 | return getBorderInsets(c); 76 | } 77 | 78 | @Override 79 | public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) 80 | { 81 | 82 | Graphics2D g2 = (Graphics2D) g; 83 | 84 | int bottomLineY = height - thickness - pointerSize; 85 | 86 | RoundRectangle2D.Double bubble = new RoundRectangle2D.Double(0 + strokePad, 0 + strokePad, width - thickness, bottomLineY, 87 | radii, radii); 88 | 89 | Polygon pointer = new Polygon(); 90 | 91 | Area area = new Area(bubble); 92 | area.add(new Area(pointer)); 93 | 94 | g2.setRenderingHints(hints); 95 | 96 | // Paint the BG color of the parent, everywhere outside the clip 97 | // of the text bubble. 98 | Component parent = c.getParent(); 99 | if (parent != null) 100 | { 101 | Color bg = parent.getBackground(); 102 | Rectangle rect = new Rectangle(0, 0, width, height); 103 | Area borderRegion = new Area(rect); 104 | borderRegion.subtract(area); 105 | g2.setClip(borderRegion); 106 | g2.setColor(bg); 107 | g2.fillRect(0, 0, width, height); 108 | g2.setClip(null); 109 | } 110 | 111 | g2.setColor(color); 112 | g2.setStroke(stroke); 113 | g2.draw(area); 114 | } 115 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/NormalBorder.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.awt.BasicStroke; 4 | import java.awt.Color; 5 | import java.awt.Component; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.Insets; 9 | import java.awt.Polygon; 10 | import java.awt.Rectangle; 11 | import java.awt.RenderingHints; 12 | import java.awt.geom.Area; 13 | import java.awt.geom.Rectangle2D; 14 | import java.awt.geom.RoundRectangle2D; 15 | 16 | import javax.swing.border.AbstractBorder; 17 | 18 | /** 19 | * Found on the web, then modified 20 | * 21 | * @author http://stackoverflow.com/questions/15025092/border-with-rounded-corners-transparency 22 | * 23 | */ 24 | public class NormalBorder extends AbstractBorder 25 | { 26 | 27 | private static final long serialVersionUID = -6879930988646213161L; 28 | private Color color; 29 | private int thickness = 4; 30 | private int radii = 8; 31 | private int pointerSize = 7; 32 | private Insets insets = null; 33 | private BasicStroke stroke = null; 34 | private int strokePad; 35 | private int pointerPad = 4; 36 | private boolean left = true; 37 | RenderingHints hints; 38 | 39 | public NormalBorder(Color color) 40 | { 41 | new NormalBorder(color, 4, 8, 7); 42 | } 43 | 44 | public NormalBorder(Color color, int thickness, int radii, int pointerSize) 45 | { 46 | this.thickness = thickness; 47 | this.radii = radii; 48 | this.pointerSize = pointerSize; 49 | this.color = color; 50 | 51 | stroke = new BasicStroke(thickness); 52 | strokePad = thickness / 2; 53 | 54 | hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 55 | 56 | int pad = radii + strokePad; 57 | int bottomPad = pad + pointerSize + strokePad; 58 | insets = new Insets(pad, pad, bottomPad, pad); 59 | } 60 | 61 | public NormalBorder(Color color, int thickness, int radii, int pointerSize, boolean left) 62 | { 63 | this(color, thickness, radii, pointerSize); 64 | this.left = left; 65 | } 66 | 67 | @Override 68 | public Insets getBorderInsets(Component c) 69 | { 70 | return insets; 71 | } 72 | 73 | @Override 74 | public Insets getBorderInsets(Component c, Insets insets) 75 | { 76 | return getBorderInsets(c); 77 | } 78 | 79 | @Override 80 | public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) 81 | { 82 | 83 | Graphics2D g2 = (Graphics2D) g; 84 | 85 | int bottomLineY = height - thickness - pointerSize; 86 | 87 | Rectangle2D.Double bubble = new Rectangle2D.Double((double) 0 + strokePad,(double) 0 + strokePad, (double) width - thickness, (double) bottomLineY); 88 | 89 | Polygon pointer = new Polygon(); 90 | 91 | Area area = new Area(bubble); 92 | area.add(new Area(pointer)); 93 | 94 | g2.setRenderingHints(hints); 95 | 96 | // Paint the BG color of the parent, everywhere outside the clip 97 | // of the text bubble. 98 | Component parent = c.getParent(); 99 | if (parent != null) 100 | { 101 | Color bg = parent.getBackground(); 102 | Rectangle rect = new Rectangle(0, 0, width, height); 103 | Area borderRegion = new Area(rect); 104 | borderRegion.subtract(area); 105 | g2.setClip(borderRegion); 106 | g2.setColor(bg); 107 | g2.fillRect(0, 0, width, height); 108 | g2.setClip(null); 109 | } 110 | 111 | g2.setColor(color); 112 | g2.setStroke(stroke); 113 | g2.draw(area); 114 | } 115 | } -------------------------------------------------------------------------------- /KaizenWeb/src/client/js/contactForm.js: -------------------------------------------------------------------------------- 1 | // Clock Logic 2 | function showTime(){ 3 | var date = new Date(); 4 | var h = date.getHours(); 5 | var m = date.getMinutes(); 6 | var s = date.getSeconds(); 7 | var session = "AM"; 8 | 9 | if(h == 0){ 10 | h = 12; 11 | } 12 | 13 | if(h > 12){ 14 | h = h - 12; 15 | session = "PM"; 16 | } 17 | 18 | h = (h < 10) ? "0" + h : h; 19 | m = (m < 10) ? "0" + m : m; 20 | s = (s < 10) ? "0" + s : s; 21 | 22 | var time = h + ":" + m + ":" + s + " " + session; 23 | document.getElementById("clock").innerText = time; 24 | document.getElementById("clock").textContent = time; 25 | 26 | setTimeout(showTime, 1000); 27 | 28 | } 29 | 30 | showTime(); 31 | 32 | function getContactFromDb(e) { 33 | //e.target.value will be the contacts username 34 | $.ajax({ 35 | type: 'POST', 36 | url: 'getContact', 37 | data: { 38 | 'contactName': e.target.value 39 | }, 40 | success: function(contact) { 41 | setFormInputValues(contact); 42 | } 43 | }); 44 | } 45 | 46 | function setFormInputValues(contact) { 47 | console.log(contact); 48 | errorMessageElement = document.getElementById('errorMessage'); 49 | //If the contact is null, then there was no contact with specified name 50 | if(contact == "") { 51 | errorMessageElement.classList.remove('hidden'); 52 | errorMessageElement.textContent = "No contact was found with name " + document.getElementById('contactSearch').value; 53 | 54 | //ENSURE CREATE MODE 55 | document.getElementById('contactId').value = ""; 56 | document.getElementById('formTitle').textContent = "Create Contact"; 57 | document.getElementById('submitButton').textContent = "Create Contact"; 58 | 59 | //POPULATES WITH BLANK 60 | document.getElementById('contactName').value = ""; 61 | document.getElementById('contactBirthday').value = ""; 62 | document.getElementById('contactPhone').value = ""; 63 | document.getElementById('contactMessenger').value = ""; 64 | document.getElementById('contactWhatsapp').value = ""; 65 | document.getElementById('contactDiscord').value = ""; 66 | document.getElementById('contactEmail').value = ""; 67 | document.getElementById('contactNote').value = ""; 68 | } 69 | //If contact was found, then create contact with given information 70 | else { 71 | if(!errorMessageElement.classList.contains('hidden')) { errorMessageElement.classList.add('hidden'); } 72 | //UPDATE MODE 73 | document.getElementById('contactId').value = contact.contact_id; 74 | document.getElementById('formTitle').textContent = "Update Contact"; 75 | document.getElementById('submitButton').textContent = "Update Contact"; 76 | 77 | //POPULATES WITH CONTACT FIELD 78 | document.getElementById('contactName').value = contact.contact_name; 79 | 80 | birthdayDate = new Date(contact.contact_birthday); 81 | birthdayDateString = birthdayDate.getFullYear() + "-" + (birthdayDate.getMonth()+1) + "-" + birthdayDate.getDate(); //yyyy-mm-dd 82 | setDate = birthdayDateString.replace(/(^|\D)(\d)(?!\d)/g, '$10$2'); 83 | document.getElementById('contactBirthday').value = setDate; 84 | 85 | //For birthday, this will require some manipulation 86 | document.getElementById('contactPhone').value = contact.contact_phone; 87 | document.getElementById('contactMessenger').value = contact.contact_fb; 88 | document.getElementById('contactWhatsapp').value = contact.contact_whatsapp; 89 | document.getElementById('contactDiscord').value = contact.contact_discord; 90 | document.getElementById('contactEmail').value = contact.contact_email; 91 | document.getElementById('contactNote').value = contact.contact_note; 92 | } 93 | } -------------------------------------------------------------------------------- /KaizenWeb/src/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Home • Kaizen 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Kaizen

16 |
17 |
18 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 60 | 61 | 62 |
Todo stories • KanbanIn progress stories • KanbanToday's Habits
44 | 45 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
HabitStreak
59 |
63 |
Upcoming Birthdays
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
NameDays UntilBirthdayContact
76 |
77 | Kaizen Logo 78 |
79 | 80 | 81 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/Settings.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | public class Settings { 4 | 5 | // General Settings 6 | 7 | private boolean enableDiscordRPC; 8 | 9 | // Todo Settings 10 | 11 | private boolean showTodoEpicOnClipboard; 12 | 13 | // Habit Settings 14 | 15 | private boolean showStreakOnClipboard; 16 | 17 | // Anti Habit Settings 18 | 19 | // Journal Settings 20 | 21 | private long journalMode; 22 | 23 | private boolean showHowWasDay; 24 | 25 | private String journalText1AreaPrompt; 26 | 27 | private String journalText2AreaPrompt; 28 | 29 | private String journalText3AreaPrompt; 30 | 31 | private String journalText4AreaPrompt; 32 | 33 | public Settings() { 34 | this.enableDiscordRPC = true; 35 | this.showTodoEpicOnClipboard = true; 36 | this.showStreakOnClipboard = true; 37 | this.journalMode = 0; 38 | this.showHowWasDay = true; 39 | this.journalText1AreaPrompt = "What events occurred today?"; 40 | this.journalText2AreaPrompt = "Any problems or stresses today?"; 41 | this.journalText3AreaPrompt = "What are you grateful for today?"; 42 | this.journalText4AreaPrompt = "What are your goals for tomorrow?"; 43 | } 44 | 45 | public Settings(boolean enableDiscordRPC, boolean showTodoEpicOnClipboard, boolean showStreakOnClipboard, long journalMode, 46 | boolean showHowWasDay, String journalText1AreaPrompt, String journalText2AreaPrompt, String journalText3AreaPrompt, 47 | String journalText4AreaPrompt) { 48 | super(); 49 | this.enableDiscordRPC = enableDiscordRPC; 50 | this.showTodoEpicOnClipboard = showTodoEpicOnClipboard; 51 | this.journalMode = journalMode; 52 | this.showHowWasDay = showHowWasDay; 53 | this.journalText1AreaPrompt = journalText1AreaPrompt; 54 | this.journalText2AreaPrompt = journalText2AreaPrompt; 55 | this.journalText3AreaPrompt = journalText3AreaPrompt; 56 | this.journalText4AreaPrompt = journalText4AreaPrompt; 57 | } 58 | 59 | public boolean isEnableDiscordRPC() { 60 | return enableDiscordRPC; 61 | } 62 | 63 | public void setEnableDiscordRPC(boolean enableDiscordRPC) { 64 | this.enableDiscordRPC = enableDiscordRPC; 65 | } 66 | 67 | public boolean isShowTodoEpicOnClipboard() { 68 | return showTodoEpicOnClipboard; 69 | } 70 | 71 | public void setShowTodoEpicOnClipboard(boolean showTodoEpicOnClipboard) { 72 | this.showTodoEpicOnClipboard = showTodoEpicOnClipboard; 73 | } 74 | 75 | public long getJournalMode() { 76 | return journalMode; 77 | } 78 | 79 | public void setJournalMode(long journalMode) { 80 | this.journalMode = journalMode; 81 | } 82 | 83 | public String getJournalText1AreaPrompt() { 84 | return journalText1AreaPrompt; 85 | } 86 | 87 | public void setJournalText1AreaPrompt(String journalText1AreaPrompt) { 88 | this.journalText1AreaPrompt = journalText1AreaPrompt; 89 | } 90 | 91 | public String getJournalText2AreaPrompt() { 92 | return journalText2AreaPrompt; 93 | } 94 | 95 | public void setJournalText2AreaPrompt(String journalText2AreaPrompt) { 96 | this.journalText2AreaPrompt = journalText2AreaPrompt; 97 | } 98 | 99 | public String getJournalText3AreaPrompt() { 100 | return journalText3AreaPrompt; 101 | } 102 | 103 | public void setJournalText3AreaPrompt(String journalText3AreaPrompt) { 104 | this.journalText3AreaPrompt = journalText3AreaPrompt; 105 | } 106 | 107 | public String getJournalText4AreaPrompt() { 108 | return journalText4AreaPrompt; 109 | } 110 | 111 | public void setJournalText4AreaPrompt(String journalText4AreaPrompt) { 112 | this.journalText4AreaPrompt = journalText4AreaPrompt; 113 | } 114 | 115 | public boolean isShowStreakOnClipboard() { 116 | return showStreakOnClipboard; 117 | } 118 | 119 | public void setShowStreakOnClipboard(boolean showStreakOnClipboard) { 120 | this.showStreakOnClipboard = showStreakOnClipboard; 121 | } 122 | 123 | public boolean isShowHowWasDay() { 124 | return showHowWasDay; 125 | } 126 | 127 | public void setShowHowWasDay(boolean showHowWasDay) { 128 | this.showHowWasDay = showHowWasDay; 129 | } 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/panel/CustomHomePanel.java: -------------------------------------------------------------------------------- 1 | package com.narlock.panel; 2 | 3 | import java.awt.GridLayout; 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | 7 | import javax.swing.JComboBox; 8 | import javax.swing.JPanel; 9 | 10 | import com.narlock.domain.Home; 11 | import com.narlock.json.HomeJsonManager; 12 | 13 | public class CustomHomePanel extends JPanel { 14 | private JComboBox widget1Box, widget2Box, widget3Box, widget4Box; 15 | private Home home; 16 | 17 | public CustomHomePanel() { 18 | // Initialize widget boxes 19 | widget1Box = new JComboBox(); 20 | addWidgetOptionsToBox(widget1Box); 21 | widget2Box = new JComboBox(); 22 | addWidgetOptionsToBox(widget2Box); 23 | widget3Box = new JComboBox(); 24 | addWidgetOptionsToBox(widget3Box); 25 | widget4Box = new JComboBox(); 26 | addWidgetOptionsToBox(widget4Box); 27 | 28 | // Read Home information, then enable/disable fields 29 | home = HomeJsonManager.readJson(); 30 | setSelectedItem(widget1Box, home.getWidget1()); 31 | setSelectedItem(widget2Box, home.getWidget2()); 32 | setSelectedItem(widget3Box, home.getWidget3()); 33 | setSelectedItem(widget4Box, home.getWidget4()); 34 | 35 | addActionToBox(widget1Box, 1); 36 | addActionToBox(widget2Box, 2); 37 | addActionToBox(widget3Box, 3); 38 | addActionToBox(widget4Box, 4); 39 | 40 | this.setLayout(new GridLayout(2, 2)); 41 | this.add(widget1Box); 42 | this.add(widget2Box); 43 | this.add(widget3Box); 44 | this.add(widget4Box); 45 | } 46 | 47 | public void addWidgetOptionsToBox(JComboBox box) { 48 | box.addItem(""); 49 | box.addItem("Todo"); 50 | box.addItem("Habits"); 51 | box.addItem("AntiHabits"); 52 | box.addItem("Journal Question 1"); 53 | box.addItem("Journal Question 2"); 54 | box.addItem("Journal Question 3"); 55 | box.addItem("Journal Question 4"); 56 | } 57 | 58 | public void setSelectedItem(JComboBox box, String widget) { 59 | switch(widget) { 60 | case "todo": 61 | box.setSelectedItem("Todo"); 62 | break; 63 | case "habits": 64 | box.setSelectedItem("Habits"); 65 | break; 66 | case "antiHabits": 67 | box.setSelectedItem("AntiHabits"); 68 | break; 69 | case "journal1": 70 | box.setSelectedItem("Journal Question 1"); 71 | break; 72 | case "journal2": 73 | box.setSelectedItem("Journal Question 2"); 74 | break; 75 | case "journal3": 76 | box.setSelectedItem("Journal Question 3"); 77 | break; 78 | case "journal4": 79 | box.setSelectedItem("Journal Question 4"); 80 | break; 81 | default: 82 | box.setSelectedItem(""); 83 | break; 84 | } 85 | } 86 | 87 | public void addActionToBox(JComboBox box, int widgetBox) { 88 | box.addActionListener(new ActionListener() { 89 | 90 | @Override 91 | public void actionPerformed(ActionEvent e) { 92 | System.out.println("[LOLLOLOL]"); 93 | // Get Widget 94 | String widgetString = getWidgetString((String) box.getSelectedItem()); 95 | 96 | // Update Home 97 | switch(widgetBox) { 98 | case 1: 99 | home.setWidget1(widgetString); 100 | break; 101 | case 2: 102 | home.setWidget2(widgetString); 103 | break; 104 | case 3: 105 | home.setWidget3(widgetString); 106 | break; 107 | case 4: 108 | home.setWidget4(widgetString); 109 | break; 110 | } 111 | 112 | // Update Json 113 | HomeJsonManager.writeHomeToFile(home); 114 | } 115 | 116 | }); 117 | } 118 | 119 | public String getWidgetString(String widgetItem) { 120 | switch(widgetItem) { 121 | case "Todo": 122 | return "todo"; 123 | case "Habits": 124 | return "habits"; 125 | case "AntiHabits": 126 | return "antiHabits"; 127 | case "Journal Question 1": 128 | return "journal1"; 129 | case "Journal Question 2": 130 | return "journal2"; 131 | case "Journal Question 3": 132 | return "journal3"; 133 | case "Journal Question 4": 134 | return "journal4"; 135 | case "": 136 | return ""; 137 | default: 138 | return ""; 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/json/SettingsJsonManager.java: -------------------------------------------------------------------------------- 1 | package com.narlock.json; 2 | 3 | import org.json.simple.JSONObject; 4 | import org.json.simple.parser.JSONParser; 5 | import org.json.simple.parser.ParseException; 6 | 7 | import com.narlock.domain.Settings; 8 | 9 | import java.io.File; 10 | import java.io.FileReader; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.io.Reader; 14 | 15 | public class SettingsJsonManager extends JsonManager { 16 | 17 | private static FileWriter file; 18 | 19 | public static Settings readJson() { 20 | File settingsJsonFile = new File(settingsPath); 21 | if(settingsJsonFile.exists()) { 22 | JSONParser parser = new JSONParser(); 23 | try { 24 | Reader reader = new FileReader(settingsPath); 25 | JSONObject settingsObject = (JSONObject) parser.parse(reader); 26 | return jsonSettingsObjectToSettings(settingsObject); 27 | } catch (IOException | ParseException e) { 28 | e.printStackTrace(); 29 | } 30 | } else { 31 | try { 32 | settingsJsonFile.createNewFile(); 33 | writeSettingsJsonToFile(new Settings()); 34 | readJson(); 35 | } catch (IOException e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | 40 | return new Settings(); 41 | } 42 | 43 | public static boolean writeSettingsJsonToFile(Settings settings) { 44 | File settingsJsonFile = new File(settingsPath); 45 | JSONObject settingsObject = settingsToJsonSettingsObject(settings); 46 | try { 47 | file = new FileWriter(settingsJsonFile); 48 | file.write(settingsObject.toJSONString()); 49 | return true; 50 | } catch (IOException proOsuGamer) { 51 | proOsuGamer.printStackTrace(); 52 | return false; 53 | } finally { 54 | try { 55 | file.flush(); 56 | file.close(); 57 | } catch (IOException proOsuGamer) { 58 | proOsuGamer.printStackTrace(); 59 | } 60 | } 61 | } 62 | 63 | public static Settings jsonSettingsObjectToSettings(JSONObject settingsObject) { 64 | return new Settings( 65 | settingsObject.get("enableDiscordRPC") == null ? true : (boolean) settingsObject.get("enableDiscordRPC"), 66 | settingsObject.get("showTodoEpicOnClipboard") == null ? true : (boolean) settingsObject.get("showTodoEpicOnClipboard"), 67 | settingsObject.get("showStreakOnClipboard") == null ? true : (boolean) settingsObject.get("showStreakOnClipboard"), 68 | settingsObject.get("journalMode") == null ? 0 : (long) settingsObject.get("journalMode"), 69 | settingsObject.get("showHowWasDay") == null ? true : (boolean) settingsObject.get("showHowWasDay"), 70 | settingsObject.get("journalText1AreaPrompt") == null ? "What events occurred today?" : (String) settingsObject.get("journalText1AreaPrompt"), 71 | settingsObject.get("journalText2AreaPrompt") == null ? "What events occurred today?" : (String) settingsObject.get("journalText2AreaPrompt"), 72 | settingsObject.get("journalText3AreaPrompt") == null ? "What events occurred today?" : (String) settingsObject.get("journalText3AreaPrompt"), 73 | settingsObject.get("journalText4AreaPrompt") == null ? "What events occurred today?" : (String) settingsObject.get("journalText4AreaPrompt") 74 | ); 75 | } 76 | 77 | @SuppressWarnings("unchecked") 78 | public static JSONObject settingsToJsonSettingsObject(Settings settings) { 79 | JSONObject jsonObject = new JSONObject(); 80 | jsonObject.put("enableDiscordRPC", settings.isEnableDiscordRPC()); 81 | jsonObject.put("showTodoEpicOnClipboard", settings.isShowTodoEpicOnClipboard()); 82 | jsonObject.put("showStreakOnClipboard", settings.isShowStreakOnClipboard()); 83 | jsonObject.put("journalMode", settings.getJournalMode()); 84 | jsonObject.put("showHowWasDay", settings.isShowHowWasDay()); 85 | jsonObject.put("journalText1AreaPrompt", settings.getJournalText1AreaPrompt()); 86 | jsonObject.put("journalText2AreaPrompt", settings.getJournalText2AreaPrompt()); 87 | jsonObject.put("journalText3AreaPrompt", settings.getJournalText3AreaPrompt()); 88 | jsonObject.put("journalText4AreaPrompt", settings.getJournalText4AreaPrompt()); 89 | return jsonObject; 90 | } 91 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/domain/Habit.java: -------------------------------------------------------------------------------- 1 | package com.narlock.domain; 2 | 3 | import java.util.Date; 4 | 5 | public class Habit { 6 | private String title; 7 | private long streak; 8 | private String occurrence; 9 | private long status; 10 | private Date date; 11 | 12 | public Habit(String title, long streak, String occurrence, long status, Date date) { 13 | this.title = title; 14 | this.streak = streak; 15 | this.occurrence = occurrence; 16 | this.status = status; 17 | this.date = date; 18 | } 19 | 20 | public String getTitle() { 21 | return title; 22 | } 23 | 24 | public void setTitle(String title) { 25 | this.title = title; 26 | } 27 | 28 | public long getStreak() { 29 | return streak; 30 | } 31 | 32 | public void setStreak(long streak) { 33 | this.streak = streak; 34 | } 35 | 36 | public String getOccurrence() { 37 | return occurrence; 38 | } 39 | 40 | public void setOccurrence(String occurrence) { 41 | this.occurrence = occurrence; 42 | } 43 | 44 | public long getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(int status) { 49 | this.status = status; 50 | } 51 | 52 | public Date getDate() { 53 | return date; 54 | } 55 | 56 | public void setDate(Date date) { 57 | this.date = date; 58 | } 59 | 60 | public boolean isCompleted() { 61 | if(status == 0) { return false; } 62 | else return true; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "Habit [title=" + title + ", streak=" + streak + ", occurrence=" + occurrence + ", status=" + status 68 | + ", date=" + date + "]"; 69 | } 70 | 71 | public boolean occursEveryday() { 72 | return occurrence.contains("1") && 73 | occurrence.contains("2") && 74 | occurrence.contains("3") && 75 | occurrence.contains("4") && 76 | occurrence.contains("5") && 77 | occurrence.contains("6") && 78 | occurrence.contains("7"); 79 | } 80 | 81 | public boolean occursOnceAWeek() { 82 | if(occurrence.contains("1") && 83 | !occurrence.contains("2") && 84 | !occurrence.contains("3") && 85 | !occurrence.contains("4") && 86 | !occurrence.contains("5") && 87 | !occurrence.contains("6") && 88 | !occurrence.contains("7")) { 89 | return true; 90 | } else if(!occurrence.contains("1") && 91 | occurrence.contains("2") && 92 | !occurrence.contains("3") && 93 | !occurrence.contains("4") && 94 | !occurrence.contains("5") && 95 | !occurrence.contains("6") && 96 | !occurrence.contains("7")) { 97 | return true; 98 | } else if(!occurrence.contains("1") && 99 | !occurrence.contains("2") && 100 | occurrence.contains("3") && 101 | !occurrence.contains("4") && 102 | !occurrence.contains("5") && 103 | !occurrence.contains("6") && 104 | !occurrence.contains("7")) { 105 | return true; 106 | } else if(!occurrence.contains("1") && 107 | !occurrence.contains("2") && 108 | !occurrence.contains("3") && 109 | occurrence.contains("4") && 110 | !occurrence.contains("5") && 111 | !occurrence.contains("6") && 112 | !occurrence.contains("7")) { 113 | return true; 114 | } else if(!occurrence.contains("1") && 115 | !occurrence.contains("2") && 116 | !occurrence.contains("3") && 117 | !occurrence.contains("4") && 118 | occurrence.contains("5") && 119 | !occurrence.contains("6") && 120 | !occurrence.contains("7")) { 121 | return true; 122 | } else if(!occurrence.contains("1") && 123 | !occurrence.contains("2") && 124 | !occurrence.contains("3") && 125 | !occurrence.contains("4") && 126 | !occurrence.contains("5") && 127 | occurrence.contains("6") && 128 | !occurrence.contains("7")) { 129 | return true; 130 | } else if(!occurrence.contains("1") && 131 | !occurrence.contains("2") && 132 | !occurrence.contains("3") && 133 | !occurrence.contains("4") && 134 | !occurrence.contains("5") && 135 | !occurrence.contains("6") && 136 | occurrence.contains("7")) { 137 | return true; 138 | } else return false; 139 | } 140 | 141 | public boolean equals(Habit habit) { 142 | return this.title.equals(habit.getTitle()) && 143 | this.streak == habit.getStreak() && 144 | this.occurrence.equals(habit.getOccurrence()) && 145 | this.status == habit.getStatus() && 146 | this.date.equals(habit.getDate()); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/js/journal.js: -------------------------------------------------------------------------------- 1 | // Clock Logic 2 | function showTime(){ 3 | var date = new Date(); 4 | var h = date.getHours(); 5 | var m = date.getMinutes(); 6 | var s = date.getSeconds(); 7 | var session = "AM"; 8 | 9 | if(h == 0){ 10 | h = 12; 11 | } 12 | 13 | if(h > 12){ 14 | h = h - 12; 15 | session = "PM"; 16 | } 17 | 18 | h = (h < 10) ? "0" + h : h; 19 | m = (m < 10) ? "0" + m : m; 20 | s = (s < 10) ? "0" + s : s; 21 | 22 | var time = h + ":" + m + ":" + s + " " + session; 23 | document.getElementById("clock").innerText = time; 24 | document.getElementById("clock").textContent = time; 25 | 26 | setTimeout(showTime, 1000); 27 | 28 | } 29 | 30 | showTime(); 31 | 32 | window.onload = function() { 33 | //Set hidden form div to today's date, noting that that will be updated 34 | var date = new Date(); 35 | var current_date = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate(); //yyyy-mm-dd 36 | 37 | //Set the current value of the journal to today's date 38 | let setDate = current_date.replace(/(^|\D)(\d)(?!\d)/g, '$10$2'); 39 | document.getElementById('datePicker').value = setDate; 40 | 41 | /** 42 | * Check if there is a journal entry for the current 43 | * day, if there is, grab it from mysql and populate 44 | * the journal. 45 | */ 46 | $.ajax({ 47 | type: 'POST', 48 | url: 'getJournalEntryByDate', 49 | data: { 50 | 'date': current_date 51 | }, 52 | success: function(entry) { 53 | setJournalInputValues(entry, setDate); 54 | } 55 | }); 56 | } 57 | 58 | function populateJournalEntry(e) { 59 | $.ajax({ 60 | type: 'POST', 61 | url: 'getJournalEntryByDate', 62 | data: { 63 | 'date': e.target.value 64 | }, 65 | success: function(entry) { 66 | setJournalInputValues(entry, e.target.value); 67 | } 68 | }); 69 | } 70 | 71 | function setJournalInputValues(entry, setDate) { 72 | console.log(setDate); 73 | //Reset before applying entry changes 74 | document.getElementById('dayGreat').checked = false; 75 | document.getElementById('dayGood').checked = false; 76 | document.getElementById('dayNeutral').checked = false; 77 | document.getElementById('dayMeh').checked = false; 78 | document.getElementById('dayBad').checked = false; 79 | 80 | document.getElementById('eventsOfDay').value = ""; 81 | document.getElementById('stresses').value = ""; 82 | document.getElementById('gratefulness').value = ""; 83 | document.getElementById('goals').value = ""; 84 | 85 | /** 86 | * If there is not an entry for the specified date, 87 | * the entry variable will be equal to the empty string. 88 | * 89 | * The journal will simply just be a blank journal entry, 90 | * but the date will remain the same date so if it is 91 | * updated, the entry will be updated as well. 92 | * 93 | * If the entry is already in the database, the form 94 | * fields will be populated with its corresponding 95 | * fields. The user will then be able to edit the journal 96 | * entry. 97 | */ 98 | 99 | if(entry == "") { 100 | //Entry does not exist in database, only set hidden date to 101 | //date from setDate 102 | document.getElementById('dateEntry').value = setDate; 103 | } else { 104 | //Entry exists in database and is stored as entry 105 | document.getElementById('dateEntry').value = setDate; 106 | 107 | if(entry.entry_how_was_day == 5) { document.getElementById('dayGreat').checked = true; } 108 | if(entry.entry_how_was_day == 4) { document.getElementById('dayGood').checked = true; } 109 | if(entry.entry_how_was_day == 3) { document.getElementById('dayNeutral').checked = true; } 110 | if(entry.entry_how_was_day == 2) { document.getElementById('dayMeh').checked = true; } 111 | if(entry.entry_how_was_day == 1) { document.getElementById('dayBad').checked = true; } 112 | 113 | document.getElementById('eventsOfDay').value = entry.entry_events; 114 | document.getElementById('stresses').value = entry.entry_stresses; 115 | document.getElementById('gratefulness').value = entry.entry_gratefulness; 116 | document.getElementById('goals').value = entry.entry_goals; 117 | } 118 | } -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/state/HabitsState.java: -------------------------------------------------------------------------------- 1 | package com.narlock.state; 2 | 3 | import java.awt.GridBagConstraints; 4 | import java.awt.GridBagLayout; 5 | import java.awt.Toolkit; 6 | import java.awt.datatransfer.Clipboard; 7 | import java.awt.datatransfer.StringSelection; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.util.List; 11 | 12 | import javax.swing.Box; 13 | import javax.swing.ImageIcon; 14 | import javax.swing.JButton; 15 | import javax.swing.JLabel; 16 | import javax.swing.JPanel; 17 | import javax.swing.JScrollPane; 18 | import javax.swing.ScrollPaneConstants; 19 | import javax.swing.plaf.basic.BasicScrollBarUI; 20 | 21 | import com.narlock.domain.Habit; 22 | import com.narlock.domain.Settings; 23 | import com.narlock.json.HabitJsonManager; 24 | import com.narlock.json.SettingsJsonManager; 25 | import com.narlock.panel.HabitsPanel; 26 | import com.narlock.util.Constants; 27 | import com.narlock.util.FadingLabel; 28 | import com.narlock.util.HabitUtils; 29 | import com.narlock.util.Utils; 30 | 31 | public class HabitsState extends State { 32 | 33 | private static final long serialVersionUID = 6371695672562881139L; 34 | 35 | private List habits; 36 | 37 | private JPanel messagePanel; 38 | private FadingLabel messageLabel; 39 | 40 | private JPanel titlePanel; 41 | public JLabel titleLabel; 42 | private JButton shareButton; 43 | 44 | private JScrollPane scrollPane; 45 | private HabitsPanel habitsPanel; 46 | 47 | public HabitsState(Settings settings) { 48 | super(settings); 49 | } 50 | 51 | @Override 52 | public void initPanelComponents() { 53 | 54 | //Get habits 55 | this.habits = HabitJsonManager.readHabits(); 56 | HabitUtils.updateHabits(habits); 57 | HabitJsonManager.writeHabitJsonToFile(habits); 58 | 59 | // Set up message label 60 | messagePanel = new JPanel(); 61 | messagePanel.setBackground(Constants.GUI_BACKGROUND_COLOR); 62 | messageLabel = new FadingLabel("Copied to clipboard!", 2000); 63 | messageLabel.setFont(Constants.COMPONENT_FONT_NORMAL_BOLD); 64 | messageLabel.setForeground(Constants.GUI_BACKGROUND_COLOR); 65 | messagePanel.add(messageLabel); 66 | 67 | //Set up title panel 68 | titlePanel = new JPanel(); 69 | titlePanel.setBackground(Constants.GUI_BACKGROUND_COLOR); 70 | titleLabel = new JLabel(); 71 | titleLabel.setForeground(Constants.COMPONENT_FOREGROUND_COLOR); 72 | titleLabel.setFont(Constants.COMPONENT_FONT_NORMAL_BOLD); 73 | shareButton = new JButton(new ImageIcon(getClass().getClassLoader().getResource("SHARE_CLIP.png"))); 74 | shareButton.setOpaque(false); 75 | shareButton.setContentAreaFilled(false); 76 | shareButton.setBorderPainted(false); 77 | shareButton.setFocusPainted(false); 78 | titlePanel.add(titleLabel); 79 | titlePanel.add(shareButton); 80 | 81 | habitsPanel = new HabitsPanel(habits, titleLabel, 0); 82 | scrollPane = new JScrollPane(habitsPanel, 83 | ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 84 | ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 85 | scrollPane.getVerticalScrollBar().setUnitIncrement(16); 86 | scrollPane.setPreferredSize(Constants.HABIT_SCROLL_PANE_NORMAL); 87 | scrollPane.setBorder(null); 88 | } 89 | 90 | @Override 91 | public void initPanelComponentActions() { 92 | 93 | // Copy habits to clip board 94 | shareButton.addActionListener(new ActionListener() { 95 | 96 | @Override 97 | public void actionPerformed(ActionEvent e) { 98 | // Construct string to copy to clipboard 99 | String clipboardString = "**Kaizen Habits • " + Utils.dateAsString(Utils.today()) + "**\n\n"; 100 | for(Habit habit : habits) { 101 | // Occurs today 102 | if(HabitUtils.occursToday(habit)) { 103 | // Add Status 104 | if(habit.getStatus() == 0) { 105 | clipboardString += "◻️ "; 106 | } 107 | else { 108 | clipboardString += "✅ "; 109 | } 110 | 111 | clipboardString += habit.getTitle(); 112 | if(settings.isShowStreakOnClipboard()) { 113 | clipboardString += " | " + habit.getStreak() + "🔥"; 114 | } 115 | clipboardString += "\n"; 116 | } 117 | } 118 | 119 | StringSelection selection = new StringSelection(clipboardString); 120 | Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); 121 | clipboard.setContents(selection, null); 122 | messageLabel.fade(); 123 | } 124 | 125 | }); 126 | 127 | } 128 | 129 | @Override 130 | public void initPanel() { 131 | this.setLayout(new GridBagLayout()); 132 | GridBagConstraints gbc = new GridBagConstraints(); 133 | gbc.gridwidth = GridBagConstraints.REMAINDER; 134 | 135 | this.add(messagePanel, gbc); 136 | this.add(titlePanel, gbc); 137 | this.add(Box.createVerticalStrut(20), gbc); 138 | this.add(scrollPane, gbc); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/json/AntiHabitJsonManager.java: -------------------------------------------------------------------------------- 1 | package com.narlock.json; 2 | 3 | import java.io.File; 4 | import java.io.FileReader; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.io.Reader; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import org.json.simple.JSONArray; 12 | import org.json.simple.JSONObject; 13 | import org.json.simple.parser.JSONParser; 14 | import org.json.simple.parser.ParseException; 15 | 16 | import com.narlock.domain.AntiHabit; 17 | import com.narlock.util.Utils; 18 | 19 | public class AntiHabitJsonManager extends JsonManager { 20 | private static FileWriter file; 21 | 22 | public static List readJson() { 23 | File antiHabitsJsonFile = new File(antiHabitsPath); 24 | if(antiHabitsJsonFile.exists()) { 25 | //TODO read the habits from the file and return, try catch and throw error 26 | JSONParser parser = new JSONParser(); 27 | try { 28 | Reader reader = new FileReader(antiHabitsPath); 29 | JSONArray antiHabitsArray = (JSONArray) parser.parse(reader); 30 | return antiHabitJsonArrayToAntiHabitList(antiHabitsArray); 31 | } catch (IOException | ParseException fnfe) { 32 | // TODO Auto-generated catch block 33 | fnfe.printStackTrace(); 34 | } 35 | } else { 36 | //Check if the documents directory exists, if not, create it 37 | File documentsDirectory = new File(documentsPath); 38 | documentsDirectory.mkdir(); //Creates the Documents/ directory if it does not exist. 39 | 40 | //Check if the Kaizen directory exists, if not, create it 41 | File kaizenDirectory = new File(directoryPath); 42 | kaizenDirectory.mkdir(); //Creates the Documents/Kaizen/ directory if it does not exist. 43 | 44 | //TODO Create new habits.json file and return 45 | try { 46 | antiHabitsJsonFile.createNewFile(); 47 | writeAntiHabitsToFile(new ArrayList()); 48 | readJson(); 49 | } catch (IOException proOsuGamer) { 50 | // TODO Auto-generated catch block 51 | proOsuGamer.printStackTrace(); 52 | } 53 | } 54 | 55 | return new ArrayList(); 56 | } 57 | 58 | public static boolean writeAntiHabitsToFile(List antiHabits) { 59 | File antiHabitsJsonFile = new File(antiHabitsPath); 60 | if(antiHabits.isEmpty()) { 61 | JSONArray emptyArray = new JSONArray(); 62 | try { 63 | file = new FileWriter(antiHabitsJsonFile); 64 | file.write(emptyArray.toJSONString()); 65 | return true; 66 | } catch (IOException e) { 67 | // TODO Auto-generated catch block 68 | e.printStackTrace(); 69 | return false; 70 | } finally { 71 | try { 72 | file.flush(); 73 | file.close(); 74 | } catch (IOException e) { 75 | // TODO Auto-generated catch block 76 | e.printStackTrace(); 77 | } 78 | } 79 | } else { 80 | JSONArray array = antiHabitListToAntiHabitJsonArray(antiHabits); 81 | try { 82 | file = new FileWriter(antiHabitsJsonFile); 83 | file.write(array.toJSONString()); 84 | return true; 85 | } catch (IOException e) { 86 | // TODO Auto-generated catch block 87 | e.printStackTrace(); 88 | return false; 89 | } finally { 90 | try { 91 | file.flush(); 92 | file.close(); 93 | } catch (IOException e) { 94 | // TODO Auto-generated catch block 95 | e.printStackTrace(); 96 | } 97 | } 98 | } 99 | } 100 | 101 | public static List antiHabitJsonArrayToAntiHabitList(JSONArray array) { 102 | if(array.isEmpty()) { return new ArrayList(); } 103 | 104 | List antiHabits = new ArrayList(); 105 | for(int i = 0; i < array.size(); i++) { 106 | JSONObject obj = (JSONObject) array.get(i); 107 | AntiHabit antiHabit = antiHabitJsonObjectToAntiHabit(obj); 108 | antiHabits.add(antiHabit); 109 | } 110 | 111 | return antiHabits; 112 | } 113 | 114 | @SuppressWarnings("unchecked") 115 | public static JSONArray antiHabitListToAntiHabitJsonArray(List antiHabits) { 116 | JSONArray array = new JSONArray(); 117 | for(AntiHabit antiHabit : antiHabits) { 118 | array.add(antiHabitToAntiHabitJsonObject(antiHabit)); 119 | } 120 | return array; 121 | } 122 | 123 | public static AntiHabit antiHabitJsonObjectToAntiHabit(JSONObject antiHabitObject) { 124 | return new AntiHabit( 125 | (String) antiHabitObject.get("title"), 126 | Utils.stringToDate( (String) antiHabitObject.get("date")) 127 | ); 128 | } 129 | 130 | @SuppressWarnings("unchecked") 131 | public static JSONObject antiHabitToAntiHabitJsonObject(AntiHabit antiHabit) { 132 | JSONObject antiHabitObject = new JSONObject(); 133 | antiHabitObject.put("title", antiHabit.getTitle()); 134 | antiHabitObject.put("date", Utils.dateAsString(antiHabit.getDate())); 135 | return antiHabitObject; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/json/JournalJsonManager.java: -------------------------------------------------------------------------------- 1 | package com.narlock.json; 2 | 3 | import java.io.File; 4 | import java.io.FileReader; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.io.Reader; 8 | import java.util.ArrayList; 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | import org.json.simple.JSONArray; 13 | import org.json.simple.JSONObject; 14 | import org.json.simple.parser.JSONParser; 15 | import org.json.simple.parser.ParseException; 16 | 17 | import com.narlock.domain.Journal; 18 | import com.narlock.domain.JournalEntry; 19 | import com.narlock.util.Debug; 20 | import com.narlock.util.Utils; 21 | 22 | public class JournalJsonManager extends JsonManager { 23 | 24 | private static final Debug debug = new Debug(true); 25 | private static FileWriter file; 26 | 27 | public static Journal readJson() { 28 | //Using today's date, we will lookup if there is a journal entry with the date. 29 | //If there is, return it, otherwise, return a new entry 30 | File journalJsonFile = new File(journalPath); 31 | if(journalJsonFile.exists()) { 32 | JSONParser parser = new JSONParser(); 33 | try { 34 | Reader reader = new FileReader(journalPath); 35 | JSONObject journalObject = (JSONObject) parser.parse(reader); 36 | Journal journal = jsonJournalObjectToJournal(journalObject); 37 | debug.print(journal.toString()); 38 | return journal; 39 | } catch (IOException | ParseException almostJustProOsuGamer) { 40 | almostJustProOsuGamer.printStackTrace(); 41 | } 42 | } else { 43 | File documentsDirectory = new File(documentsPath); 44 | documentsDirectory.mkdir(); 45 | 46 | File kaizenDirectory = new File(directoryPath); 47 | kaizenDirectory.mkdir(); 48 | 49 | try { 50 | journalJsonFile.createNewFile(); 51 | writeJournalJsonToFile(new Journal()); 52 | readJson(); 53 | } catch (IOException proOsuGamer) { 54 | proOsuGamer.printStackTrace(); 55 | } 56 | } 57 | 58 | return new Journal(); 59 | } 60 | 61 | public static boolean writeJournalJsonToFile(Journal journal) { 62 | File journalJsonFile = new File(journalPath); 63 | JSONObject journalObject = journalToJsonJournalObject(journal); 64 | try { 65 | file = new FileWriter(journalJsonFile); 66 | file.write(journalObject.toJSONString()); 67 | debug.print("" + journal.getEntries()); 68 | return true; 69 | } catch (IOException proOsuGamer) { 70 | proOsuGamer.printStackTrace(); 71 | return false; 72 | } finally { 73 | try { 74 | file.flush(); 75 | file.close(); 76 | } catch (IOException proOsuGamer) { 77 | proOsuGamer.printStackTrace(); 78 | } 79 | } 80 | } 81 | 82 | public static Journal jsonJournalObjectToJournal(JSONObject journalObject) { 83 | Date lastLog = Utils.stringToDate((String) journalObject.get("lastLog")); 84 | long logStreak = journalObject.get("logStreak") == null ? 0 : (Long) journalObject.get("logStreak"); 85 | boolean showStreak = journalObject.get("showStreak") == null ? false : (Boolean) journalObject.get("showStreak"); 86 | 87 | JSONArray journalEntries = (JSONArray) journalObject.get("entries"); 88 | List entries = new ArrayList(); 89 | for(int i = 0; i < journalEntries.size(); i++) { 90 | JSONObject entryObject = (JSONObject) journalEntries.get(i); 91 | JournalEntry entry = jsonJournalEntryToJournalEntry(entryObject); 92 | entries.add(entry); 93 | } 94 | 95 | return new Journal(entries, 96 | lastLog, 97 | logStreak, 98 | showStreak 99 | ); 100 | } 101 | 102 | @SuppressWarnings("unchecked") 103 | public static JSONObject journalToJsonJournalObject(Journal journal) { 104 | JSONObject journalObject = new JSONObject(); 105 | journalObject.put("lastLog", Utils.dateAsString(journal.getLastLog())); 106 | journalObject.put("logStreak", journal.getLogStreak()); 107 | journalObject.put("showStreak", journal.isShowStreak()); 108 | 109 | JSONArray entriesArray = new JSONArray(); 110 | for(JournalEntry entry : journal.getEntries()) { 111 | entriesArray.add(journalEntryToJsonJournalEntry(entry)); 112 | } 113 | journalObject.put("entries", entriesArray); 114 | return journalObject; 115 | } 116 | 117 | public static JournalEntry jsonJournalEntryToJournalEntry(JSONObject entryObject) { 118 | return new JournalEntry( 119 | Utils.stringToDate((String) entryObject.get("date")), 120 | (long) entryObject.get("howWasDay"), 121 | (String) entryObject.get("text1"), 122 | (String) entryObject.get("text2"), 123 | (String) entryObject.get("text3"), 124 | (String) entryObject.get("text4") 125 | ); 126 | } 127 | 128 | @SuppressWarnings("unchecked") 129 | public static JSONObject journalEntryToJsonJournalEntry(JournalEntry entry) { 130 | JSONObject entryObject = new JSONObject(); 131 | entryObject.put("date", Utils.dateAsString(entry.getDate())); 132 | entryObject.put("howWasDay", entry.getHowWasDay()); 133 | entryObject.put("text1", entry.getText1()); 134 | entryObject.put("text2", entry.getText2()); 135 | entryObject.put("text3", entry.getText3()); 136 | entryObject.put("text4", entry.getText4()); 137 | return entryObject; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/healthGoals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Health Goals • Kaizen 8 | 9 | 10 | 11 | 12 | 13 |
14 |

Health Goals

15 |
16 |
17 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 57 | 58 | 73 | 74 | 89 | 90 | 91 |
Update Water GoalUpdate Calorie GoalUpdate Sleep Goal
43 |
44 |
45 | 46 | 47 |
48 |
49 | 50 | 51 |
52 |
53 | 54 |
55 |
56 |
59 |
60 |
61 | 62 | 63 |
64 |
65 | 66 | 67 |
68 |
69 | 70 |
71 |
72 |
75 |
76 |
77 | 78 | 79 |
80 |
81 | 82 | 83 |
84 |
85 | 86 |
87 |
88 |
92 |
93 | Health 94 |
95 | 96 | 97 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/js/habits.js: -------------------------------------------------------------------------------- 1 | // Clock Logic 2 | function showTime(){ 3 | var date = new Date(); 4 | var h = date.getHours(); 5 | var m = date.getMinutes(); 6 | var s = date.getSeconds(); 7 | var session = "AM"; 8 | 9 | if(h == 0){ 10 | h = 12; 11 | } 12 | 13 | if(h > 12){ 14 | h = h - 12; 15 | session = "PM"; 16 | } 17 | 18 | h = (h < 10) ? "0" + h : h; 19 | m = (m < 10) ? "0" + m : m; 20 | s = (s < 10) ? "0" + s : s; 21 | 22 | var time = h + ":" + m + ":" + s + " " + session; 23 | document.getElementById("clock").innerText = time; 24 | document.getElementById("clock").textContent = time; 25 | 26 | setTimeout(showTime, 1000); 27 | 28 | } 29 | 30 | showTime(); 31 | 32 | window.onload = function() { 33 | updateHabitStreaks(); 34 | //Updates the habit streaks in db 35 | //Updates the dates in db, setting status to incomplete 36 | //For each if the day is new 37 | //Populates the table 38 | 39 | /** 40 | * updateHabitStreaks is called, upon returning 41 | * it will call checkDateForHabit, upon returning 42 | * it will call populateHabitsTable. This is 43 | * to ensure that everything is called in order. 44 | */ 45 | } 46 | 47 | function updateHabitStreaks() { 48 | var xmlhttp = new XMLHttpRequest(); 49 | 50 | xmlhttp.onreadystatechange = function() { 51 | if(this.readyState == 4 && this.status == 200) { 52 | console.log("Update Habit Streaks SUCCESS Response"); 53 | checkDateForHabit(); 54 | } 55 | }; 56 | xmlhttp.open("GET", "updateHabitStreaks", true); 57 | xmlhttp.send(); 58 | } 59 | 60 | function checkDateForHabit() { 61 | var xmlhttp = new XMLHttpRequest(); 62 | 63 | xmlhttp.onreadystatechange = function() { 64 | if(this.readyState == 4 && this.status == 200) { 65 | console.log("Check Date Habit SUCCESS Response"); 66 | populateHabitsTable(); 67 | } 68 | }; 69 | xmlhttp.open("GET", "checkDateForHabits", true); 70 | xmlhttp.send(); 71 | } 72 | 73 | function populateHabitsTable() { 74 | /** 75 | * TODO 76 | * Populate the habits table 77 | * 78 | * Check/update the streak status of daily habits 79 | * 80 | * Add only the habits that correspond to the current day 81 | * 82 | * If a habit is already complete, make sure it is checked and the 83 | * attribute 'onclick' = 'false' is added, so it cannot be re-updated. 84 | */ 85 | var xmlhttp = new XMLHttpRequest(); 86 | 87 | xmlhttp.onreadystatechange = function() { 88 | if(this.readyState == 4 && this.status == 200) { 89 | createHabitElements(JSON.parse(this.responseText)); 90 | } 91 | }; 92 | xmlhttp.open("GET", "dailyDbHabits", true); 93 | xmlhttp.send(); 94 | } 95 | 96 | function createHabitElements(habits) { 97 | table = document.getElementById('habitsTableBody'); 98 | 99 | //Create Table Row 100 | habits.forEach(function(habit) { 101 | //habitRow 102 | habitRow = document.createElement('tr'); 103 | 104 | //checkbox th 105 | checkBoxTh = document.createElement('th'); 106 | checkBoxTh.setAttribute('scope', 'row'); 107 | checkBox = document.createElement('input'); 108 | checkBox.setAttribute('type', 'checkbox'); 109 | checkBox.setAttribute('id', habit.habit_id); 110 | checkBox.classList.add('habits__checkbox'); 111 | if(habit.habit_status == 0) { 112 | checkBox.setAttribute('onclick', 'updateHabit(event)'); 113 | } else { 114 | checkBox.setAttribute('onclick', 'return false'); 115 | checkBox.checked = true; 116 | } 117 | 118 | checkBoxTh.appendChild(checkBox); 119 | habitRow.appendChild(checkBoxTh); 120 | 121 | //td habit title 122 | habitTitle = document.createElement('td'); 123 | habitTitle.textContent = habit.habit_title; 124 | habitRow.appendChild(habitTitle); 125 | 126 | //Streak Number 127 | streakElement = document.createElement('td'); 128 | if(habit.habit_streak > 0) { 129 | streakElement.textContent = "🔥 " + habit.habit_streak; 130 | } else { 131 | streakElement.textContent = "None"; 132 | } 133 | habitRow.appendChild(streakElement); 134 | 135 | table.appendChild(habitRow); 136 | }); 137 | } 138 | 139 | function updateHabit(event) { 140 | //Get the checkbox 141 | checkBox = event.path[0]; 142 | 143 | //Once a habit is checked, it cannot be unchecked! 144 | checkBox.setAttribute('onclick', 'return false'); 145 | 146 | //Id of checkbox corresponds to habit_id in db 147 | id = checkBox.getAttribute('id'); 148 | console.log(id); 149 | 150 | /* 151 | * Will update the status of the event to complete 152 | * 153 | * Will check previous day with current day, if they 154 | * are less than 24 hours apart and do not appear on 155 | * the same calendar day, then the streak will be incremented 156 | * 157 | * If the previous day is more than 24 hours apart, 158 | * the streak will equal 0. 159 | */ 160 | $.ajax({ 161 | type: 'POST', 162 | url: 'checkHabit', 163 | data: { 164 | 'id': id 165 | }, 166 | success: function(habit) { 167 | console.log("SUCCESSful Update in DB"); 168 | } 169 | }); 170 | } -------------------------------------------------------------------------------- /KaizenWeb/src/client/contactForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Relationships Form • Kaizen 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Relationships Form

16 |
17 |
18 | 32 |
33 |
34 |
35 |
36 |
37 |
38 | Update a contact 39 | 40 |
41 | 42 |
43 |
44 |

Create Contact

45 |
46 | 47 |
48 | 49 | 50 |
51 |
52 | 53 | 54 |
55 |
56 | 57 | 58 |
59 |
60 | 61 | 62 |
63 |
64 | 65 | 66 |
67 |
68 | 69 | 70 |
71 |
72 | 73 | 74 |
75 |
76 | 77 | 78 |
79 |
80 | 81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | View Relationships 90 |
91 | 92 | 93 | -------------------------------------------------------------------------------- /KaizenWeb/src/client/journal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Journal • Kaizen 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Journal

16 |
17 |
18 | 32 |
33 |
34 | Select Journal Date 35 | 36 |
37 | 38 | 39 | 40 | 41 | 42 | 75 | 86 | 87 | 88 | 89 |
43 | 44 |
45 | 49 | 53 | 57 | 61 | 65 |
66 |
67 | 68 | 69 |
70 |
71 | 72 | 73 |
74 |
76 |
77 | 78 | 79 |
80 |
81 | 82 | 83 |
84 | 85 |
90 |
91 | 92 | 93 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/json/HabitJsonManager.java: -------------------------------------------------------------------------------- 1 | package com.narlock.json; 2 | 3 | import java.io.File; 4 | import java.io.FileReader; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.io.Reader; 8 | import java.util.ArrayList; 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | import org.json.simple.JSONArray; 13 | import org.json.simple.JSONObject; 14 | import org.json.simple.parser.JSONParser; 15 | import org.json.simple.parser.ParseException; 16 | 17 | import com.narlock.domain.Habit; 18 | import com.narlock.util.Constants; 19 | import com.narlock.util.Debug; 20 | import com.narlock.util.ErrorPane; 21 | 22 | public class HabitJsonManager extends JsonManager { 23 | private static FileWriter file; 24 | 25 | public static List readHabits() { 26 | File habitsJsonFile = new File(habitsPath); 27 | if(habitsJsonFile.exists()) { 28 | //TODO read the habits from the file and return, try catch and throw error 29 | JSONParser parser = new JSONParser(); 30 | try { 31 | Reader reader = new FileReader(habitsPath); 32 | JSONArray habitsArray = (JSONArray) parser.parse(reader); 33 | return jsonHabitArrayToHabitList(habitsArray); 34 | } catch (IOException | ParseException fnfe) { 35 | // TODO Auto-generated catch block 36 | fnfe.printStackTrace(); 37 | } 38 | } else { 39 | //Check if the documents directory exists, if not, create it 40 | File documentsDirectory = new File(documentsPath); 41 | documentsDirectory.mkdir(); //Creates the Documents/ directory if it does not exist. 42 | 43 | //Check if the Kaizen directory exists, if not, create it 44 | File kaizenDirectory = new File(directoryPath); 45 | kaizenDirectory.mkdir(); //Creates the Documents/Kaizen/ directory if it does not exist. 46 | 47 | //TODO Create new habits.json file and return 48 | try { 49 | habitsJsonFile.createNewFile(); 50 | writeHabitJsonToFile(new ArrayList()); 51 | readHabits(); 52 | } catch (IOException proOsuGamer) { 53 | // TODO Auto-generated catch block 54 | proOsuGamer.printStackTrace(); 55 | } 56 | } 57 | 58 | return new ArrayList(); 59 | } 60 | 61 | public static boolean writeHabitJsonToFile(List habits) { 62 | debug.print("Inside of writeHabitJsonToFile"); 63 | File habitsJsonFile = new File(habitsPath); 64 | if(habits.isEmpty()) { 65 | debug.print("[writeHabitJsonToFile] Creating habits"); 66 | JSONArray emptyArray = new JSONArray(); 67 | try { 68 | file = new FileWriter(habitsJsonFile); 69 | file.write(emptyArray.toJSONString()); 70 | return true; 71 | } catch (IOException e) { 72 | // TODO Auto-generated catch block 73 | e.printStackTrace(); 74 | return false; 75 | } finally { 76 | try { 77 | file.flush(); 78 | file.close(); 79 | } catch (IOException e) { 80 | // TODO Auto-generated catch block 81 | e.printStackTrace(); 82 | } 83 | } 84 | } else { 85 | debug.print("[writeHabitJsonToFile] Updating habits"); 86 | JSONArray array = habitListToJsonHabitArray(habits); 87 | try { 88 | file = new FileWriter(habitsJsonFile); 89 | debug.print("Habits Array: " + array.toJSONString()); 90 | file.write(array.toJSONString()); 91 | return true; 92 | } catch (IOException e) { 93 | // TODO Auto-generated catch block 94 | e.printStackTrace(); 95 | return false; 96 | } finally { 97 | try { 98 | file.flush(); 99 | file.close(); 100 | } catch (IOException e) { 101 | // TODO Auto-generated catch block 102 | e.printStackTrace(); 103 | } 104 | } 105 | } 106 | } 107 | 108 | public static boolean addHabit(Habit habit) { 109 | debug.print("Inside of addHabit"); 110 | List habits = readHabits(); 111 | habits.add(habit); 112 | writeHabitJsonToFile(habits); 113 | return true; 114 | } 115 | 116 | public static List jsonHabitArrayToHabitList(JSONArray array) { 117 | debug.print("Inside of jsonHabitArrayToHabitList"); 118 | if(array.isEmpty()) { 119 | debug.print("Returning empty list"); 120 | return new ArrayList(); 121 | } 122 | 123 | List habits = new ArrayList(); 124 | for(int i = 0; i < array.size(); i++) { 125 | JSONObject obj = (JSONObject) array.get(i); 126 | Habit habit = jsonHabitObjectToHabitObject(obj); 127 | habits.add(habit); 128 | } 129 | 130 | for(Habit habit : habits) { 131 | debug.print(habit.toString()); 132 | } 133 | 134 | return habits; 135 | } 136 | 137 | public static Habit jsonHabitObjectToHabitObject(JSONObject obj) { 138 | Date date; 139 | try { 140 | date = Constants.formatter.parse((String) obj.get("date")); 141 | return new Habit( 142 | (String) obj.get("title"), 143 | (Long) obj.get("streak"), 144 | (String) obj.get("occurrence"), 145 | (Long) obj.get("status"), 146 | date 147 | ); 148 | } catch (java.text.ParseException e) { 149 | ErrorPane.displayError(null, "A parsing error occurred"); 150 | e.printStackTrace(); 151 | } 152 | 153 | ErrorPane.displayError(null, "An unexpected error occurred"); 154 | return null; 155 | } 156 | 157 | @SuppressWarnings("unchecked") 158 | public static JSONArray habitListToJsonHabitArray(List habits) { 159 | JSONArray array = new JSONArray(); 160 | for(Habit habit : habits) { 161 | debug.print("Adding " + habit.getTitle() + " to JSONArray"); 162 | array.add(habitToJsonHabitObject(habit)); 163 | } 164 | return array; 165 | } 166 | 167 | @SuppressWarnings("unchecked") 168 | public static JSONObject habitToJsonHabitObject(Habit habit) { 169 | JSONObject obj = new JSONObject(); 170 | obj.put("title", habit.getTitle()); 171 | obj.put("streak", habit.getStreak()); 172 | obj.put("occurrence", habit.getOccurrence()); 173 | obj.put("status", habit.getStatus()); 174 | obj.put("date", Constants.formatter.format(habit.getDate())); 175 | return obj; 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/panel/AntiHabitsPanel.java: -------------------------------------------------------------------------------- 1 | package com.narlock.panel; 2 | 3 | import static com.narlock.util.Constants.*; 4 | 5 | import java.awt.BorderLayout; 6 | import java.awt.Color; 7 | import java.awt.GridBagConstraints; 8 | import java.awt.GridBagLayout; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | import java.util.List; 12 | 13 | import javax.swing.ImageIcon; 14 | import javax.swing.JButton; 15 | import javax.swing.JLabel; 16 | import javax.swing.JOptionPane; 17 | import javax.swing.JPanel; 18 | 19 | import com.narlock.domain.AntiHabit; 20 | import com.narlock.json.AntiHabitJsonManager; 21 | import com.narlock.state.AntiHabitsState; 22 | import com.narlock.util.AntiHabitUtils; 23 | import com.narlock.util.Utils; 24 | 25 | public class AntiHabitsPanel extends JPanel { 26 | 27 | private AntiHabitsState state; 28 | private List antiHabits; 29 | 30 | public AntiHabitsPanel(List antiHabits, AntiHabitsState state) { 31 | // Initialize variables 32 | this.state = state; 33 | this.antiHabits = antiHabits; 34 | 35 | this.setLayout(new GridBagLayout()); 36 | GridBagConstraints gbc = new GridBagConstraints(); 37 | gbc.gridwidth = GridBagConstraints.REMAINDER; 38 | 39 | // Create each individual panel 40 | for(AntiHabit antiHabit : antiHabits) { 41 | this.add(createAntiHabitPanel(antiHabit), gbc); 42 | } 43 | 44 | this.setBackground(GUI_BACKGROUND_COLOR); 45 | } 46 | 47 | private JPanel createAntiHabitPanel(AntiHabit antiHabit) { 48 | long daysSince = AntiHabitUtils.getDaysSince(antiHabit.getDate()); 49 | 50 | JPanel mainPanel = new JPanel(); 51 | mainPanel.setLayout(new BorderLayout()); 52 | mainPanel.setPreferredSize(ANTIHABIT_MAIN_PANEL_DIMENSION); 53 | mainPanel.setOpaque(true); 54 | mainPanel.setBackground(COMPONENT_BACKGROUND_COLOR); 55 | mainPanel.setBorder(COMPONENT_BORDER_NORMAL); 56 | 57 | JPanel daysSincePanel = new JPanel(); 58 | daysSincePanel.setBackground(COMPONENT_BACKGROUND_COLOR); 59 | JLabel daysSinceLabel = new JLabel("" + daysSince); 60 | daysSinceLabel.setFont(COMPONENT_FONT_NORMAL_BOLD); 61 | /* 62 | * 0-7 days, color of text is green 63 | * 8-30 days, color of text is gold 64 | * 30-90 days, color of text is diamond 65 | * 90-300 days, color of text is pink 66 | * 300+ days, color of text is red 67 | */ 68 | if(daysSince <= 7) { 69 | daysSinceLabel.setForeground(KAIZEN_GREEN); 70 | } 71 | else if(daysSince >= 8 && daysSince <= 30) { 72 | daysSinceLabel.setForeground(KAIZEN_GOLD); 73 | } 74 | else if(daysSince >= 31 && daysSince <= 90) { 75 | daysSinceLabel.setForeground(KAIZEN_DIAMOND); 76 | } 77 | else if(daysSince >= 91 && daysSince <= 300) { 78 | daysSinceLabel.setForeground(KAIZEN_PINK); 79 | } 80 | else if(daysSince >= 301) { 81 | daysSinceLabel.setForeground(KAIZEN_RED); 82 | } 83 | daysSincePanel.add(daysSinceLabel); 84 | mainPanel.add(daysSincePanel, BorderLayout.WEST); 85 | 86 | JPanel titlePanel = new JPanel(); 87 | titlePanel.setLayout(new GridBagLayout()); 88 | GridBagConstraints gbc = new GridBagConstraints(); 89 | gbc.gridwidth = GridBagConstraints.REMAINDER; 90 | titlePanel.setBackground(COMPONENT_BACKGROUND_COLOR); 91 | JLabel titleTopLabel = new JLabel("days since I"); 92 | titleTopLabel.setFont(COMPONENT_FONT_SMALL); 93 | titleTopLabel.setForeground(COMPONENT_FOREGROUND_COLOR); 94 | titlePanel.add(titleTopLabel, gbc); 95 | JLabel titleLabel = new JLabel(antiHabit.getTitle()); 96 | titleLabel.setFont(COMPONENT_FONT_NORMAL_BOLD); 97 | titleLabel.setForeground(COMPONENT_FOREGROUND_COLOR); 98 | titlePanel.add(titleLabel, gbc); 99 | mainPanel.add(titlePanel, BorderLayout.CENTER); 100 | 101 | JPanel editPanel = new JPanel(); 102 | editPanel.setBackground(COMPONENT_BACKGROUND_COLOR); 103 | JButton resetButton = new JButton(new ImageIcon(getClass().getClassLoader().getResource("RESET.png"))); 104 | resetButton.setOpaque(false); 105 | resetButton.setContentAreaFilled(false); 106 | resetButton.setBorderPainted(false); 107 | resetButton.setFocusPainted(false); 108 | 109 | resetButton.addActionListener(new ActionListener() { 110 | 111 | @Override 112 | public void actionPerformed(ActionEvent e) { 113 | int result = JOptionPane.showConfirmDialog( 114 | getRootPane(), 115 | "You are about to reset " + antiHabit.getTitle() + ". Confirm?", 116 | "Reset Anti Habit", 117 | JOptionPane.OK_CANCEL_OPTION, 118 | JOptionPane.QUESTION_MESSAGE, 119 | new ImageIcon(getClass().getClassLoader().getResource("INFO_ERROR_ORANGE.png"))); 120 | if(result == JOptionPane.YES_OPTION) { 121 | // Remove the anti habit 122 | antiHabit.setDate(Utils.today()); 123 | 124 | // Update Json 125 | AntiHabitJsonManager.writeAntiHabitsToFile(antiHabits); 126 | 127 | // Revalidate GUI 128 | state.revalidateHabitsPanel(); 129 | } 130 | } 131 | 132 | }); 133 | 134 | JButton deleteButton = new JButton(new ImageIcon(getClass().getClassLoader().getResource("DELETE.png"))); 135 | deleteButton.setOpaque(false); 136 | deleteButton.setContentAreaFilled(false); 137 | deleteButton.setBorderPainted(false); 138 | deleteButton.setFocusPainted(false); 139 | 140 | deleteButton.addActionListener(new ActionListener() { 141 | 142 | @Override 143 | public void actionPerformed(ActionEvent e) { 144 | int result = JOptionPane.showConfirmDialog( 145 | getRootPane(), 146 | "Are you sure you want to delete " + antiHabit.getTitle() + "?", 147 | "Delete Anti Habit", 148 | JOptionPane.OK_CANCEL_OPTION, 149 | JOptionPane.QUESTION_MESSAGE, 150 | new ImageIcon(getClass().getClassLoader().getResource("INFO_ERROR_ORANGE.png"))); 151 | if(result == JOptionPane.YES_OPTION) { 152 | // Remove the anti habit 153 | antiHabits.remove(antiHabit); 154 | 155 | // Update Json 156 | AntiHabitJsonManager.writeAntiHabitsToFile(antiHabits); 157 | 158 | // Revalidate GUI 159 | state.revalidateHabitsPanel(); 160 | } 161 | } 162 | 163 | }); 164 | 165 | editPanel.add(resetButton); 166 | editPanel.add(deleteButton); 167 | 168 | mainPanel.add(editPanel, BorderLayout.EAST); 169 | return mainPanel; 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/util/HabitUtils.java: -------------------------------------------------------------------------------- 1 | package com.narlock.util; 2 | 3 | import java.time.temporal.ChronoUnit; 4 | import java.util.Calendar; 5 | import java.util.List; 6 | 7 | import com.narlock.domain.Habit; 8 | 9 | public class HabitUtils extends Utils { 10 | 11 | private static final Debug debug = new Debug(true); 12 | 13 | /** 14 | * updateHabits 15 | * @brief Will update the habits. This means that if a day has passed, 16 | * streaks will be updated, isCompleted will be set back to false, etc. 17 | * 18 | * @param todaysHabits 19 | * @return List of updated habits 20 | */ 21 | public static List updateHabits(List habits) { 22 | debug.print("[HabitUtils/updateHabits] Inside of update Habits"); 23 | for(Habit habit : habits) { 24 | //Only update the habits that occur today 25 | updateHabit(habit); 26 | } 27 | return habits; 28 | } 29 | 30 | /** 31 | * updateHabit 32 | * @brief Updates an individual habit based on occurrence, 33 | * status, and date. 34 | * @param habit 35 | */ 36 | public static void updateHabit(Habit habit) { 37 | if(occursToday(habit)) { 38 | switch(isStreakIncrementable(habit)) { 39 | case 0: 40 | debug.print("[HabitUtils/updateHabits] switch case 0"); 41 | habit.setStreak(0); 42 | habit.setStatus(0); 43 | habit.setDate(today()); 44 | break; 45 | case 1: 46 | debug.print("[HabitUtils/updateHabits] switch case 1"); 47 | habit.setStreak(habit.getStreak() + 1); 48 | habit.setStatus(0); 49 | habit.setDate(today()); 50 | break; 51 | case 2: 52 | debug.print("[HabitUtils/updateHabits] switch case 2"); 53 | break; 54 | } 55 | } 56 | } 57 | 58 | /** 59 | * isStreakIncrementable 60 | * @brief Check to see if the streak can be incremented. 61 | * 62 | * If the date attribute of the habit is the same as the current date, 63 | * this means that either the streak has already been updated, so no 64 | * need to increment or set to zero. Or, the habit was created on 65 | * the current date (no change to the habit streak if the date attribute 66 | * is the same as the current date) 67 | * 68 | * If the date attribute is on the previous increment to the current date. 69 | * For example, the date attribute is Feb 20th, 2023, the current date is 70 | * Feb 21st, 2023, and the streak's occurrence is everyday, this will 71 | * indicate that the habit streak should be incremented. 72 | * 73 | * Another example will be if the habit occurrence is once a week on Friday. 74 | * If the date attribute is Feb 17th, 2023, and the current date is 75 | * Feb 24th, 2023. The habit streak will be incremented when the habit 76 | * is completed. 77 | * 78 | * If the date attribute does not align with the current date given the 79 | * examples, this method will return false. This means that the streak 80 | * 81 | * @param habit 82 | * @return 0: Streak needs to be reset 83 | * 1: Streak can be incremented 84 | * 2: Streak does not need to be incremented, but does not need reset. 85 | */ 86 | public static int isStreakIncrementable(Habit habit) { 87 | if(habit.occursEveryday()) { 88 | debug.print("[HabitUtils/isStreakIncrementable] inside occurs everyday"); 89 | //If it's the same day, return 2 90 | if(sameDay(habit)) { 91 | debug.print("[HabitUtils/isStreakIncrementable] Habit is on the same day, returning"); 92 | return 2; 93 | } 94 | //If the date attr is the previous day and was completed, return 1 95 | if(previousDay(habit) && habit.getStatus() == 1) { 96 | return 1; 97 | } 98 | //Otherwise, return 0, needs a reset. 99 | return 0; 100 | } else if(habit.occursOnceAWeek()) { 101 | //If it's the same day, return 0 102 | if(sameDay(habit)) { 103 | return 2; 104 | } 105 | //If it's last week and completed, return 1 106 | if(lastWeek(habit) && habit.getStatus() == 1) { 107 | return 1; 108 | } 109 | //Otherwise return 0, needs a reset. 110 | return 0; 111 | 112 | } else { 113 | /* 114 | * Not a habit that support streaks. 115 | * These habits increment if it's not the same day 116 | * to simply display that the user completed the 117 | * habit again 118 | */ 119 | if(sameDay(habit) && habit.getStatus() == 1) { 120 | return 2; 121 | } 122 | else if(sameDay(habit) && habit.getStatus() == 0) { 123 | return 2; 124 | } else return 1; 125 | } 126 | } 127 | 128 | /** 129 | * sameDay 130 | * @param habit 131 | * @return true if the habit's date is the same as today's date in hours 132 | */ 133 | public static boolean sameDay(Habit habit) { 134 | long hoursBetween = ChronoUnit.HOURS.between(habit.getDate().toInstant(), today().toInstant()); 135 | return hoursBetween == 0; 136 | } 137 | 138 | /** 139 | * previousDay 140 | * @brief Checks if the habit's date is the previous day. Checks for day light savings. 141 | * @param habit 142 | * @return true if is previous day to today's current date. 143 | */ 144 | public static boolean previousDay(Habit habit) { 145 | long hoursBetween = ChronoUnit.HOURS.between(habit.getDate().toInstant(), today().toInstant()); 146 | return hoursBetween == 23 || hoursBetween == 24 || hoursBetween == 25; 147 | } 148 | 149 | /** 150 | * lastWeek 151 | * @brief Checks if the habit's date is last week exactly. Checks for day light savings. 152 | * @param habit 153 | * @return true if is last week day to today's current date. 154 | */ 155 | public static boolean lastWeek(Habit habit) { 156 | long hoursBetween = ChronoUnit.HOURS.between(habit.getDate().toInstant(), today().toInstant()); 157 | return hoursBetween == 167 || hoursBetween == 168 || hoursBetween == 166; 158 | } 159 | 160 | /** 161 | * occursToday 162 | * @param habit 163 | * @return true if the habit occurs today based on occurrence 164 | */ 165 | public static boolean occursToday(Habit habit) { 166 | //Occurs everyday 167 | if(habit.getOccurrence().equals("1234567")) { return true; } 168 | 169 | //Ensure today is inside of the habit's occurrence 170 | 171 | //Get today's day of the week value 172 | Calendar c = Calendar.getInstance(); 173 | c.setTime(today()); 174 | int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); 175 | 176 | //Compare dayOfWeek 177 | String dayOfWeekString = String.valueOf(dayOfWeek); 178 | return habit.getOccurrence().contains(dayOfWeekString); 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/widget/JournalWidgetPanel.java: -------------------------------------------------------------------------------- 1 | package com.narlock.widget; 2 | 3 | import java.awt.Color; 4 | import java.awt.Dimension; 5 | import java.awt.GridBagConstraints; 6 | import java.awt.GridBagLayout; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | 10 | import javax.swing.Box; 11 | import javax.swing.JButton; 12 | import javax.swing.JLabel; 13 | import javax.swing.JPanel; 14 | import javax.swing.JScrollPane; 15 | import javax.swing.JTextArea; 16 | 17 | import com.narlock.domain.Journal; 18 | import com.narlock.domain.JournalEntry; 19 | import com.narlock.domain.Settings; 20 | import com.narlock.json.JournalJsonManager; 21 | import com.narlock.util.Constants; 22 | import com.narlock.util.Utils; 23 | 24 | /** 25 | * JournalWidgetPanel 26 | * @author narlock 27 | * 28 | * Since developing an entire small version of the journal is not 29 | * a good idea, the journal widget will allow for a selected text area to 30 | * be edited from today's entry and added to the journal. For example, 31 | * the user can only see the "What events occurred today?" question 32 | * and can answer that one as a widget. The user can choose which 33 | * question is available. 34 | * 35 | * TODO Make a previous/following button-like thing in the title of 36 | * this widget that can allow the user to cycle through the different 37 | * questions. 38 | * 39 | */ 40 | public class JournalWidgetPanel extends JPanel { 41 | 42 | private static final long serialVersionUID = 3138144527935439794L; 43 | private GridBagConstraints gbc; 44 | 45 | private Journal journal; 46 | private JournalEntry todaysEntry; 47 | private boolean loadToday; 48 | 49 | private JPanel textPanel; 50 | private JLabel textLabel; 51 | private JTextArea textArea; 52 | private int index; 53 | 54 | private JPanel saveChangesButtonPanel; 55 | private JButton saveChangesButton; 56 | 57 | public JournalWidgetPanel(int index, Settings settings) { 58 | this.setBackground(Constants.GUI_BACKGROUND_COLOR); 59 | this.gbc = new GridBagConstraints(); 60 | this.gbc.gridwidth = GridBagConstraints.REMAINDER; 61 | this.index = index; 62 | 63 | this.journal = JournalJsonManager.readJson(); 64 | if(journal.isEntryInEntries(Utils.today())) { 65 | todaysEntry = journal.getEntryByDateString(Utils.todayAsString()); 66 | loadToday = true; 67 | } else { 68 | todaysEntry = new JournalEntry(); 69 | loadToday = false; 70 | } 71 | 72 | textPanel = new JPanel(); 73 | textPanel.setLayout(new GridBagLayout()); 74 | textPanel.setBackground(Constants.COMPONENT_BACKGROUND_COLOR); 75 | textPanel.setBorder(Constants.COMPONENT_BORDER_SMALL); 76 | textLabel = new JLabel(getQuestionFromIndex(settings)); 77 | textLabel.setFont(Constants.COMPONENT_FONT_SMALL_BOLD); 78 | textLabel.setForeground(Constants.COMPONENT_FOREGROUND_COLOR); 79 | textArea = new JTextArea(9, 30); 80 | JScrollPane scrollPane = new JScrollPane(textArea); 81 | scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 82 | textArea.setLineWrap(true); 83 | textPanel.add(textLabel, gbc); 84 | textPanel.add(Box.createVerticalStrut(10), gbc); 85 | textPanel.add(scrollPane, gbc); 86 | textPanel.add(Box.createVerticalStrut(10), gbc); 87 | 88 | saveChangesButtonPanel = new JPanel(); 89 | saveChangesButtonPanel.setBackground(Constants.GUI_BACKGROUND_COLOR); 90 | saveChangesButton = new JButton("Save Entry"); 91 | saveChangesButton.setOpaque(true); 92 | saveChangesButton.setForeground(Color.WHITE); 93 | saveChangesButton.setBackground(Constants.BUTTON_CONFIRM_COLOR); 94 | saveChangesButton.setBorder(Constants.BUTTON_BORDER); 95 | saveChangesButton.setFont(Constants.COMPONENT_FONT_NORMAL_BOLD); 96 | saveChangesButton.setPreferredSize(new Dimension(120, 40)); 97 | 98 | saveChangesButton.addActionListener(new ActionListener() { 99 | 100 | @Override 101 | public void actionPerformed(ActionEvent e) { 102 | switch(index) { 103 | case 1: 104 | todaysEntry.setText1(textArea.getText()); 105 | break; 106 | case 2: 107 | todaysEntry.setText2(textArea.getText()); 108 | break; 109 | case 3: 110 | todaysEntry.setText3(textArea.getText()); 111 | break; 112 | case 4: 113 | todaysEntry.setText4(textArea.getText()); 114 | break; 115 | default: 116 | throw new RuntimeException("Invalid textIndex entered: " + index); 117 | } 118 | 119 | if(journal.isEntryInEntries(todaysEntry.getDate())) { 120 | //Update Entry 121 | JournalEntry entry = journal.getEntryByDateString(Utils.dateAsString(todaysEntry.getDate())); 122 | entry.setText1(todaysEntry.getText1()); 123 | entry.setText2(todaysEntry.getText2()); 124 | entry.setText3(todaysEntry.getText3()); 125 | entry.setText4(todaysEntry.getText4()); 126 | JournalJsonManager.writeJournalJsonToFile(journal); 127 | } else { 128 | //Write Entry to File 129 | journal.getEntries().add(todaysEntry); 130 | JournalJsonManager.writeJournalJsonToFile(journal); 131 | } 132 | } 133 | 134 | }); 135 | 136 | saveChangesButtonPanel.add(saveChangesButton); 137 | 138 | this.setLayout(new GridBagLayout()); 139 | this.add(textPanel, gbc); 140 | this.add(saveChangesButtonPanel); 141 | 142 | if(loadToday) { 143 | populateComponentsWithOpenEntryDetails(); 144 | } 145 | } 146 | 147 | private String getQuestionFromIndex(Settings settings) { 148 | switch(index) { 149 | case 1: 150 | return settings.getJournalText1AreaPrompt(); 151 | case 2: 152 | return settings.getJournalText2AreaPrompt(); 153 | case 3: 154 | return settings.getJournalText3AreaPrompt(); 155 | case 4: 156 | return settings.getJournalText4AreaPrompt(); 157 | default: 158 | throw new RuntimeException("Invalid textIndex entered: " + index); 159 | } 160 | } 161 | 162 | private void populateComponentsWithOpenEntryDetails() { 163 | switch(index) { 164 | case 1: 165 | textArea.setText(todaysEntry.getText1()); 166 | return; 167 | case 2: 168 | textArea.setText(todaysEntry.getText2()); 169 | return; 170 | case 3: 171 | textArea.setText(todaysEntry.getText3()); 172 | return; 173 | case 4: 174 | textArea.setText(todaysEntry.getText4()); 175 | return; 176 | default: 177 | throw new RuntimeException("Invalid textIndex entered: " + index); 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/json/TodoJsonManager.java: -------------------------------------------------------------------------------- 1 | package com.narlock.json; 2 | 3 | import java.awt.Color; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.FileWriter; 7 | import java.io.IOException; 8 | import java.io.Reader; 9 | import java.util.ArrayList; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | import org.json.simple.JSONArray; 14 | import org.json.simple.JSONObject; 15 | import org.json.simple.parser.JSONParser; 16 | import org.json.simple.parser.ParseException; 17 | 18 | import com.narlock.domain.Epic; 19 | import com.narlock.domain.Todo; 20 | import com.narlock.domain.TodoItem; 21 | import com.narlock.util.Debug; 22 | import com.narlock.util.Utils; 23 | 24 | public class TodoJsonManager extends JsonManager { 25 | 26 | private static final Debug debug = new Debug(true); 27 | private static FileWriter file; 28 | 29 | public static Todo readJson() { 30 | File todoJsonFile = new File(todoPath); 31 | if(todoJsonFile.exists()) { 32 | JSONParser parser = new JSONParser(); 33 | try { 34 | Reader reader = new FileReader(todoPath); 35 | JSONObject todoObject = (JSONObject) parser.parse(reader); 36 | Todo todo = jsonTodoObjectToTodo(todoObject); 37 | return todo; 38 | } catch (IOException | ParseException almostJustProOsuGamer) { 39 | almostJustProOsuGamer.printStackTrace(); 40 | } 41 | } else { 42 | File documentsDirectory = new File(documentsPath); 43 | documentsDirectory.mkdir(); 44 | 45 | File kaizenDirectory = new File(directoryPath); 46 | kaizenDirectory.mkdir(); 47 | 48 | try { 49 | todoJsonFile.createNewFile(); 50 | writeTodoJsonToFile(new Todo()); 51 | readJson(); 52 | } catch (IOException proOsuGamer) { 53 | proOsuGamer.printStackTrace(); 54 | } 55 | } 56 | 57 | return new Todo(); 58 | } 59 | 60 | public static boolean writeTodoJsonToFile(Todo todo) { 61 | File todoJsonFile = new File(todoPath); 62 | JSONObject todoJsonObject = todoToJsonTodoObject(todo); 63 | try { 64 | file = new FileWriter(todoJsonFile); 65 | file.write(todoJsonObject.toJSONString()); 66 | return true; 67 | } catch (IOException proOsuGamer) { 68 | proOsuGamer.printStackTrace(); 69 | return false; 70 | } finally { 71 | try { 72 | file.flush(); 73 | file.close(); 74 | } catch (IOException proOsuGamer) { 75 | proOsuGamer.printStackTrace(); 76 | } 77 | } 78 | } 79 | 80 | public static Todo jsonTodoObjectToTodo(JSONObject todoObject) { 81 | String sortMode = (String) todoObject.get("sortMode"); 82 | String viewMode = (String) todoObject.get("viewMode"); 83 | 84 | JSONArray epicsArray = (JSONArray) todoObject.get("epics"); 85 | List epics = new ArrayList(); 86 | for(int i = 0; i < epicsArray.size(); i++) { 87 | JSONObject epicObject = (JSONObject) epicsArray.get(i); 88 | Epic epic = jsonEpicObjectToEpic(epicObject); 89 | epics.add(epic); 90 | } 91 | 92 | JSONArray todoItemsArray = (JSONArray) todoObject.get("items"); 93 | List todoItems = new ArrayList(); 94 | for(int i = 0; i < todoItemsArray.size(); i++) { 95 | JSONObject todoItemObject = (JSONObject) todoItemsArray.get(i); 96 | TodoItem todoItem = jsonTodoItemObjectToTodoItem(todoItemObject); 97 | todoItems.add(todoItem); 98 | } 99 | 100 | return new Todo(sortMode, viewMode, epics, todoItems); 101 | } 102 | 103 | @SuppressWarnings("unchecked") 104 | public static JSONObject todoToJsonTodoObject(Todo todo) { 105 | JSONObject todoObject = new JSONObject(); 106 | todoObject.put("sortMode", todo.getSortMode()); 107 | todoObject.put("viewMode", todo.getViewMode()); 108 | 109 | JSONArray epicsArray = new JSONArray(); 110 | for(Epic epic : todo.getEpics()) { 111 | epicsArray.add(epicToJsonEpicObject(epic)); 112 | } 113 | todoObject.put("epics", epicsArray); 114 | 115 | JSONArray todoItemsArray = new JSONArray(); 116 | for(TodoItem todoItem : todo.getItems()) { 117 | todoItemsArray.add(todoItemToJsonTodoItemObject(todoItem)); 118 | } 119 | todoObject.put("items", todoItemsArray); 120 | 121 | return todoObject; 122 | } 123 | 124 | public static Epic jsonEpicObjectToEpic(JSONObject epicObject) { 125 | String title = (String) epicObject.get("title"); 126 | 127 | JSONArray rgbObject = (JSONArray) epicObject.get("color"); 128 | Color color = new Color( 129 | (int) (long) rgbObject.get(0), 130 | (int) (long) rgbObject.get(1), 131 | (int) (long) rgbObject.get(2) 132 | ); 133 | 134 | return new Epic(title, color); 135 | } 136 | 137 | @SuppressWarnings("unchecked") 138 | public static JSONObject epicToJsonEpicObject(Epic epic) { 139 | JSONObject epicObject = new JSONObject(); 140 | epicObject.put("title", epic.getTitle()); 141 | 142 | JSONArray rgbObject = new JSONArray(); 143 | rgbObject.add(epic.getColor().getRed()); 144 | rgbObject.add(epic.getColor().getGreen()); 145 | rgbObject.add(epic.getColor().getBlue()); 146 | 147 | epicObject.put("color", rgbObject); 148 | 149 | return epicObject; 150 | } 151 | 152 | public static TodoItem jsonTodoItemObjectToTodoItem(JSONObject todoItemObject) { 153 | String title = (String) todoItemObject.get("title"); 154 | Date dueDate = Utils.stringToDate((String) todoItemObject.get("dueDate")); 155 | 156 | Date completedDate; 157 | String completedDateString = (String) todoItemObject.get("completedDate"); 158 | if(completedDateString.equals("")) { 159 | completedDate = null; 160 | } else { 161 | completedDate = Utils.stringToDate(completedDateString); 162 | } 163 | 164 | long priority = (long) todoItemObject.get("priority"); 165 | String epic = (String) todoItemObject.get("epic"); 166 | 167 | return new TodoItem(title, dueDate, completedDate, priority, epic); 168 | } 169 | 170 | @SuppressWarnings("unchecked") 171 | public static JSONObject todoItemToJsonTodoItemObject(TodoItem todoItem) { 172 | JSONObject todoItemObject = new JSONObject(); 173 | todoItemObject.put("title", todoItem.getTitle()); 174 | todoItemObject.put("dueDate", Utils.dateAsString(todoItem.getDueDate())); 175 | 176 | if(todoItem.getCompletedDate() == null) { 177 | todoItemObject.put("completedDate", ""); 178 | } else { 179 | todoItemObject.put("completedDate", Utils.dateAsString(todoItem.getCompletedDate())); 180 | } 181 | 182 | todoItemObject.put("priority", todoItem.getPriority()); 183 | todoItemObject.put("epic", todoItem.getEpic()); 184 | 185 | return todoItemObject; 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /KaizenClient/src/com/narlock/state/AntiHabitsState.java: -------------------------------------------------------------------------------- 1 | package com.narlock.state; 2 | 3 | import java.awt.GridBagConstraints; 4 | import java.awt.GridBagLayout; 5 | import java.awt.GridLayout; 6 | import java.awt.event.ActionEvent; 7 | import java.awt.event.ActionListener; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | import javax.swing.Box; 12 | import javax.swing.ImageIcon; 13 | import javax.swing.JButton; 14 | import javax.swing.JLabel; 15 | import javax.swing.JOptionPane; 16 | import javax.swing.JPanel; 17 | import javax.swing.JScrollPane; 18 | import javax.swing.JTextField; 19 | import javax.swing.ScrollPaneConstants; 20 | 21 | import com.narlock.domain.AntiHabit; 22 | import com.narlock.json.AntiHabitJsonManager; 23 | import com.narlock.panel.AntiHabitsPanel; 24 | import com.narlock.util.Constants; 25 | import com.narlock.util.ErrorPane; 26 | import com.narlock.util.Utils; 27 | import com.toedter.calendar.JDateChooser; 28 | 29 | public class AntiHabitsState extends State { 30 | 31 | private static final long serialVersionUID = -5898974247614071603L; 32 | 33 | private List antiHabits; 34 | 35 | private JPanel titlePanel; 36 | private JLabel titleLabel; 37 | private JButton createAntiHabitButton; 38 | 39 | private JScrollPane scrollPane; 40 | private AntiHabitsPanel antiHabitsPanel; 41 | 42 | public AntiHabitsState() { 43 | super(); 44 | } 45 | 46 | @Override 47 | public void initPanelComponents() { 48 | // Get antiHabits 49 | this.antiHabits = AntiHabitJsonManager.readJson(); 50 | 51 | //Set up title panel 52 | titlePanel = new JPanel(); 53 | titlePanel.setBackground(Constants.GUI_BACKGROUND_COLOR); 54 | titleLabel = new JLabel("Anti Habits"); 55 | titleLabel.setForeground(Constants.COMPONENT_FOREGROUND_COLOR); 56 | titleLabel.setFont(Constants.COMPONENT_FONT_NORMAL_BOLD); 57 | 58 | createAntiHabitButton = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ADD.png"))); 59 | createAntiHabitButton.setOpaque(false); 60 | createAntiHabitButton.setContentAreaFilled(false); 61 | createAntiHabitButton.setBorderPainted(false); 62 | createAntiHabitButton.setFocusPainted(false); 63 | 64 | titlePanel.add(titleLabel); 65 | titlePanel.add(createAntiHabitButton); 66 | 67 | antiHabitsPanel = new AntiHabitsPanel(antiHabits, this); 68 | scrollPane = new JScrollPane(antiHabitsPanel, 69 | ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 70 | ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 71 | scrollPane.getVerticalScrollBar().setUnitIncrement(16); 72 | scrollPane.setPreferredSize(Constants.ANTIHABIT_SCROLL_PANE_NORMAL); 73 | scrollPane.setBorder(null); 74 | } 75 | 76 | @Override 77 | public void initPanelComponentActions() { 78 | createAntiHabitButton.addActionListener(new ActionListener() { 79 | JPanel panel = new JPanel(new GridLayout(0, 1)); 80 | JLabel titleLabel = new JLabel("Anti Habit Title"); 81 | JTextField titleTextField = new JTextField(); 82 | JLabel dateLabel = new JLabel("Start Date"); 83 | JDateChooser dateChooser = new JDateChooser(null, "yyyy-MM-dd"); 84 | 85 | @Override 86 | public void actionPerformed(ActionEvent e) { 87 | try { 88 | titleTextField.setText(""); 89 | dateChooser.setDate(null); 90 | 91 | panel.add(titleLabel); 92 | panel.add(titleTextField); 93 | panel.add(dateLabel); 94 | panel.add(dateChooser); 95 | 96 | int result = JOptionPane.showConfirmDialog( 97 | getRootPane(), 98 | panel, 99 | "Create Anti Habit", 100 | JOptionPane.OK_CANCEL_OPTION, 101 | JOptionPane.QUESTION_MESSAGE, 102 | new ImageIcon(getClass().getClassLoader().getResource("INFO_ERROR_ORANGE.png"))); 103 | if(result == JOptionPane.YES_OPTION && 104 | !titleTextField.getText().equals("") && 105 | Utils.validateDateString(Utils.dateAsString(dateChooser.getDate())) 106 | ) { 107 | // Happy Path 108 | 109 | // Create Anti Habit 110 | String title = titleTextField.getText(); 111 | Date date = dateChooser.getDate(); 112 | AntiHabit antiHabit = new AntiHabit(title, date); 113 | 114 | // Add antiHabit to list 115 | antiHabits.add(antiHabit); 116 | 117 | // Update Json 118 | AntiHabitJsonManager.writeAntiHabitsToFile(antiHabits); 119 | 120 | // Revalidate GUI 121 | revalidateHabitsPanel(); 122 | } 123 | else if(result == JOptionPane.YES_OPTION && 124 | titleTextField.getText().equals("") 125 | ) { 126 | // Display Validation Error on Title 127 | ErrorPane.displayError(getRootPane(), "Could not create Anti Habit Item: a title must be given to the item."); 128 | } 129 | else if(result == JOptionPane.YES_OPTION && 130 | !Utils.validateDateString(Utils.dateAsString(dateChooser.getDate())) 131 | ) { 132 | // Display Validation Error on Due Date 133 | ErrorPane.displayError(getRootPane(), "Could not create Anti Habit Item: invalid date format."); 134 | } else { 135 | System.out.println("Cancel"); 136 | } 137 | } catch (Exception ex) { 138 | // If date format is not correct 139 | ErrorPane.displayError(getRootPane(), "Unexpected date format provided. Please try again."); 140 | } 141 | } 142 | 143 | }); 144 | 145 | } 146 | 147 | public void revalidateHabitsPanel() { 148 | // Remove old panel 149 | this.remove(scrollPane); 150 | this.revalidate(); 151 | this.repaint(); 152 | 153 | // Construct new panel 154 | antiHabitsPanel = new AntiHabitsPanel(antiHabits, this); 155 | scrollPane = new JScrollPane(antiHabitsPanel, 156 | ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 157 | ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 158 | scrollPane.getVerticalScrollBar().setUnitIncrement(16); 159 | scrollPane.setPreferredSize(Constants.ANTIHABIT_SCROLL_PANE_NORMAL); 160 | scrollPane.setBorder(null); 161 | 162 | // Add new panel 163 | GridBagConstraints gbc = new GridBagConstraints(); 164 | gbc.gridwidth = GridBagConstraints.REMAINDER; 165 | this.add(scrollPane, gbc); 166 | 167 | } 168 | 169 | @Override 170 | public void initPanel() { 171 | this.setLayout(new GridBagLayout()); 172 | GridBagConstraints gbc = new GridBagConstraints(); 173 | gbc.gridwidth = GridBagConstraints.REMAINDER; 174 | 175 | this.add(titlePanel, gbc); 176 | this.add(Box.createVerticalStrut(20), gbc); 177 | this.add(scrollPane, gbc); 178 | } 179 | 180 | } 181 | --------------------------------------------------------------------------------