diff --git a/.gitignore b/.gitignore index 21b4487..0f1c49a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,142 @@ -# Project exclude paths -/out/ \ No newline at end of file +.DS_Store + + +# Created by https://www.toptal.com/developers/gitignore/api/intellij,java +# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,java + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +# End of https://www.toptal.com/developers/gitignore/api/intellij,java diff --git a/Demo/SS1.png b/Demo/SS1.png index 82d895c..694a723 100644 Binary files a/Demo/SS1.png and b/Demo/SS1.png differ diff --git a/Demo/d1.png b/Demo/d1.png index 572b153..7190b48 100644 Binary files a/Demo/d1.png and b/Demo/d1.png differ diff --git a/Demo/d2.png b/Demo/d2.png index 3976da7..b9e3db6 100644 Binary files a/Demo/d2.png and b/Demo/d2.png differ diff --git a/Demo/d3.png b/Demo/d3.png index 316c7dd..6420c3d 100644 Binary files a/Demo/d3.png and b/Demo/d3.png differ diff --git a/Demo/d4.png b/Demo/d4.png index 1d5f72d..f0ca0f2 100644 Binary files a/Demo/d4.png and b/Demo/d4.png differ diff --git a/Demo/d5.png b/Demo/d5.png index 38867a4..b9f6b0f 100644 Binary files a/Demo/d5.png and b/Demo/d5.png differ diff --git a/Demo/d6.png b/Demo/d6.png index 202796e..21999b4 100644 Binary files a/Demo/d6.png and b/Demo/d6.png differ diff --git a/README.md b/README.md index 5b42e6e..e35fb88 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,15 @@ # SmartEditor + +[![CodeFactor](https://www.codefactor.io/repository/github/jc-progjava/smarteditor.java/badge)](https://www.codefactor.io/repository/github/jc-progjava/smarteditor.java) + +### Archive Note +``` +This repository will no longer be updated. +- July 2022 +``` + +### Description + Public base of SmartEditor - a text editor built using Java. Website @@ -8,8 +19,9 @@ Requirements: Installation: - 1. Get .jar file from: https://github.com/JC-ProgJava/SmartEditor.java/blob/master/SmartEditor.java/SmartEditor%20Runnable/SmartEditor.java.jar?raw=true - OR: MacOS -> https://github.com/JC-ProgJava/SmartEditor.java/blob/master/SmartEditor.dmg?raw=true + 1. Get .jar file from:
+ https://github.com/JC-ProgJava/SmartEditor.java/blob/master/SmartEditor.java/SmartEditor%20Runnable/SmartEditor.java.jar?raw=true + 2. Double-click on jar to run. If error occurs, please run from command prompt/terminal: @@ -25,15 +37,7 @@ Installation: cd -directory of jar file- - java -jar SmartEditor.java.jar - - - (Mac) .App: - - - Double click and extract. To run, double click again. - You can add the application to your dock. - + java -jar SmartEditor.java.jar Demo: @@ -59,8 +63,8 @@ A powerful find & replace for enhanced editing ![15+ Themes for better Interface](https://github.com/JC-ProgJava/SmartEditor.java/blob/master/Demo/d5.png) -Rename Files On-The-FLy -![Rename Files On-The-FLy](https://github.com/JC-ProgJava/SmartEditor.java/blob/master/Demo/d6.png) +Rename Files On-The-Fly +![Rename Files On-The-Fly](https://github.com/JC-ProgJava/SmartEditor.java/blob/master/Demo/d6.png) Startup Appearance: diff --git a/SmartEditor.jar b/SmartEditor.jar index 4e64ea1..2d4a6df 100644 Binary files a/SmartEditor.jar and b/SmartEditor.jar differ diff --git a/SmartEditor.java/SmartEditor Runnable/SmartEditor.jar b/SmartEditor.java/SmartEditor Runnable/SmartEditor.jar index d6ccd79..2d4a6df 100644 Binary files a/SmartEditor.java/SmartEditor Runnable/SmartEditor.jar and b/SmartEditor.java/SmartEditor Runnable/SmartEditor.jar differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame$1.class b/SmartEditor.java/out/production/SmartEditor.java/Frame$1.class index 81dacdf..ce248e5 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/Frame$1.class and b/SmartEditor.java/out/production/SmartEditor.java/Frame$1.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame$2.class b/SmartEditor.java/out/production/SmartEditor.java/Frame$2.class index 5529480..89c1c63 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/Frame$2.class and b/SmartEditor.java/out/production/SmartEditor.java/Frame$2.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame$3.class b/SmartEditor.java/out/production/SmartEditor.java/Frame$3.class index 4b073f0..58a9080 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/Frame$3.class and b/SmartEditor.java/out/production/SmartEditor.java/Frame$3.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame$4.class b/SmartEditor.java/out/production/SmartEditor.java/Frame$4.class index 01a79b0..f3dee26 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/Frame$4.class and b/SmartEditor.java/out/production/SmartEditor.java/Frame$4.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame$5.class b/SmartEditor.java/out/production/SmartEditor.java/Frame$5.class new file mode 100644 index 0000000..03a2a57 Binary files /dev/null and b/SmartEditor.java/out/production/SmartEditor.java/Frame$5.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame$6.class b/SmartEditor.java/out/production/SmartEditor.java/Frame$6.class new file mode 100644 index 0000000..3575e6f Binary files /dev/null and b/SmartEditor.java/out/production/SmartEditor.java/Frame$6.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame$7.class b/SmartEditor.java/out/production/SmartEditor.java/Frame$7.class new file mode 100644 index 0000000..0fa6788 Binary files /dev/null and b/SmartEditor.java/out/production/SmartEditor.java/Frame$7.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/Frame.class b/SmartEditor.java/out/production/SmartEditor.java/Frame.class index f3bc5b1..34e91ce 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/Frame.class and b/SmartEditor.java/out/production/SmartEditor.java/Frame.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/RedoAction.class b/SmartEditor.java/out/production/SmartEditor.java/RedoAction.class new file mode 100644 index 0000000..aa4069e Binary files /dev/null and b/SmartEditor.java/out/production/SmartEditor.java/RedoAction.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$1.class b/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$1.class index a77333b..1b9f97b 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$1.class and b/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$1.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$2.class b/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$2.class index c4d2d15..4d8284d 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$2.class and b/SmartEditor.java/out/production/SmartEditor.java/SmartEditor$2.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/SmartEditor.class b/SmartEditor.java/out/production/SmartEditor.java/SmartEditor.class index ac2e1bb..a4bc14e 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/SmartEditor.class and b/SmartEditor.java/out/production/SmartEditor.java/SmartEditor.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/UndoAction.class b/SmartEditor.java/out/production/SmartEditor.java/UndoAction.class new file mode 100644 index 0000000..fdd9cc7 Binary files /dev/null and b/SmartEditor.java/out/production/SmartEditor.java/UndoAction.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/UndoHandler.class b/SmartEditor.java/out/production/SmartEditor.java/UndoHandler.class new file mode 100644 index 0000000..c16cc3c Binary files /dev/null and b/SmartEditor.java/out/production/SmartEditor.java/UndoHandler.class differ diff --git a/SmartEditor.java/out/production/SmartEditor.java/notepad.png b/SmartEditor.java/out/production/SmartEditor.java/notepad.png index 63f7805..5479901 100644 Binary files a/SmartEditor.java/out/production/SmartEditor.java/notepad.png and b/SmartEditor.java/out/production/SmartEditor.java/notepad.png differ diff --git a/SmartEditor.java/src/SmartEditor.java b/SmartEditor.java/src/SmartEditor.java index 73947eb..e8cf0eb 100644 --- a/SmartEditor.java/src/SmartEditor.java +++ b/SmartEditor.java/src/SmartEditor.java @@ -1,20 +1,24 @@ import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; +import javax.swing.event.*; import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.metal.DefaultMetalTheme; import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.plaf.metal.OceanTheme; -import javax.swing.text.BadLocationException; +import javax.swing.text.*; +import javax.swing.undo.CannotRedoException; +import javax.swing.undo.CannotUndoException; +import javax.swing.undo.UndoManager; import java.awt.*; import java.awt.event.*; -import java.awt.geom.Rectangle2D; import java.awt.print.PrinterException; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; import java.io.*; +import java.lang.reflect.InvocationTargetException; import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files; @@ -24,9 +28,9 @@ import java.util.*; /* - * VERSION: 1.7 + * VERSION: 1.8 * AUTHOR: JC-ProgJava - * SPRINT-VERSION: 1.8 + * SPRINT-VERSION: 1.9 * LICENSE: CC0 1.0 Universal * */ @@ -54,7 +58,7 @@ public class SmartEditor{ public static String path = System.getProperty("user.home") + File.separator + "SmartEditor" + File.separator + "Settings.txt"; public static String createFolderPath = System.getProperty("user.home") + File.separator + "SmartEditor"; public static String fileDirectoryPath = ""; - public static String version = "1.7"; + public static String version = "1.8"; public static void main(String[] args) throws Exception { File folder = new File(createFolderPath); @@ -104,76 +108,137 @@ public static void main(String[] args) throws Exception { frame.createFrame(); checkForUpdates("auto"); } - public static void checkForUpdates(String autoManual) throws IOException { - URL versionURl = new URL("https://raw.githubusercontent.com/JC-ProgJava/SmartEditor.java/master/docs/version.txt"); - Scanner input = new Scanner(versionURl.openStream()); - while(input.hasNext()) { - String line = input.nextLine(); - if (Double.parseDouble(line) > Double.parseDouble(version) && remindUpdate) { - JDialog log = new JDialog(); - log.setSize(380,80); - log.setTitle("Version Update"); - JLabel lab = new JLabel("Version " + line + " of SmartEditor is available, do you want to update?"); - JButton dontRemind = new JButton("Don't Remind Me"); - JButton cancel = new JButton("Cancel"); - JButton updatePlease = new JButton("Update"); - JPanel pane = new JPanel(); - pane.add(lab); - pane.add(dontRemind); - pane.add(cancel); - pane.add(updatePlease); - log.add(pane); - log.setVisible(true); - dontRemind.addActionListener(e -> { - SmartEditor.remindUpdate = false; - Frame.writeFile(); - log.setVisible(false); - log.dispose(); - }); - cancel.addActionListener(e -> { - log.setVisible(false); - log.dispose(); + public static void checkForUpdates(String autoManual) { + URL versionURl = null; + try { + versionURl = new URL("https://raw.githubusercontent.com/JC-ProgJava/SmartEditor.java/master/docs/version.txt"); + } catch (MalformedURLException ignored) { + } + Scanner input = null; + try { + input = new Scanner(versionURl.openStream()); + while(input.hasNext()) { + String line = input.nextLine(); + if (Double.parseDouble(line) > Double.parseDouble(version) && remindUpdate) { + JDialog log = new JDialog(); + log.setSize(380,80); + log.setTitle("Version Update"); + JLabel lab = new JLabel("Version " + line + " of SmartEditor is available, do you want to update?"); + JButton dontRemind = new JButton("Don't Remind Me"); + JButton cancel = new JButton("Cancel"); + JButton updatePlease = new JButton("Update"); + JPanel pane = new JPanel(); + pane.add(lab); + pane.add(dontRemind); + pane.add(cancel); + pane.add(updatePlease); + log.add(pane); + log.setVisible(true); + dontRemind.addActionListener(e -> { + SmartEditor.remindUpdate = false; + Frame.writeFile(); + log.setVisible(false); + }); + + cancel.addActionListener(e -> { + log.setVisible(false); + }); + + updatePlease.addActionListener(e -> { + updateStartProc(); + }); + }else if(Double.parseDouble(line) <= Double.parseDouble(version) && autoManual.equals("manual")){ + JDialog log = new JDialog(); + log.setSize(300,80); + JLabel lab = new JLabel("SmartEditor version " + version + " is the latest available."); + JButton but = new JButton("OK"); + but.addActionListener(e -> { + log.setVisible(false); + }); + JPanel pane = new JPanel(); + pane.add(lab); + pane.add(but); + log.add(pane); + log.setVisible(true); + log.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + } + } + } catch (IOException | NullPointerException e) { + if(autoManual.equals("manual")) { + JDialog d = new JDialog(); + d.setSize(390, 60); + d.setTitle("Not Connected Error"); + JTextArea labe = new JTextArea("Due to no internet connection, you cannot update to a newer version of SmartEditor."); + labe.setEditable(false); + labe.setLineWrap(true); + d.add(new JPanel().add(labe)); + d.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + d.setVisible(false); + } }); + d.setVisible(true); + } + } + } - updatePlease.addActionListener(e -> { - if(!Frame.ta.getText().isEmpty()) { - File file = new File(createFolderPath + File.separator + "temp.txt"); + public static void changePG(JProgressBar pg){ + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + while(pg.getValue() < pg.getMaximum()){ + pg.setValue(pg.getValue() + 1); try { - FileWriter fw = new FileWriter(file, false); - if(!Frame.filepath.isEmpty()) { - fw.write(Frame.filepath + "\n"); - } - fw.write(Frame.ta.getText() + "\n"); - fw.close(); - } catch (IOException ignored) { + Thread.sleep(20); + } catch (InterruptedException ignored) { } } - try { - InputStream inputStream = new URL("https://github.com/JC-ProgJava/SmartEditor.java/blob/master/update.jar?raw=true").openStream(); - Files.copy(inputStream, Paths.get(createFolderPath + File.separator + "update.jar"), StandardCopyOption.REPLACE_EXISTING); - Process proc = Runtime.getRuntime().exec("java -jar " + createFolderPath + File.separator + "update.jar"); - } catch (IOException ex) { - System.exit(-1); - } - System.exit(1); - }); - }else if(Double.parseDouble(line) <= Double.parseDouble(version) && autoManual.equals("manual")){ - JDialog log = new JDialog(); - log.setSize(300,80); - JLabel lab = new JLabel("SmartEditor version " + version + " is the latest available."); - JButton but = new JButton("OK"); - but.addActionListener(e -> { - log.dispose(); - }); - JPanel pane = new JPanel(); - pane.add(lab); - pane.add(but); - log.add(pane); - log.setVisible(true); - log.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + } + }); + } catch (Exception ignored){ + } + } + + public static void updateStartProc(){ + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + }catch(Exception ignored){ + } + Random rand = new Random(); + JFrame fram = new JFrame("SmartEditor Launcher"); + JProgressBar pg = new JProgressBar(0, 100); + JLabel labb = new JLabel("Progress"); + JPanel panel = new JPanel(); + panel.add(labb); + panel.add(pg); + fram.add(panel); + labb.setToolTipText("Update In Progress"); + fram.setSize(230, 60); + fram.setVisible(true); + changePG(pg); + if(!Frame.ta.getText().isEmpty()) { + File file = new File(createFolderPath + File.separator + "temp.txt"); + try { + FileWriter fw = new FileWriter(file, false); + if(!Frame.filepath.isEmpty()) { + fw.write(Frame.filepath + "\n"); + } + fw.write(Frame.ta.getText() + "\n"); + fw.close(); + } catch (IOException ignored) { } } + + try { + InputStream inputStream = new URL("https://github.com/JC-ProgJava/SmartEditor.java/blob/master/update.jar?raw=true").openStream(); + Files.copy(inputStream, Paths.get(createFolderPath + File.separator + "update.jar"), StandardCopyOption.REPLACE_EXISTING); + Process proc = Runtime.getRuntime().exec("java -jar " + createFolderPath + File.separator + "update.jar"); + } catch (IOException ex) { + System.exit(-1); + } + System.exit(1); } } @@ -186,6 +251,7 @@ class Frame { public static JFrame settingFrame = new JFrame("Settings"); public static JFrame themeFrame = new JFrame("Theme"); public static JDialog farDialog = new JDialog(); + public static JMenu openRecent = null; public static ArrayList start = new ArrayList<>(); public static ArrayList end = new ArrayList<>(); public static String userSelectedText = ""; @@ -193,13 +259,287 @@ class Frame { public static JScrollPane scrollP = new JScrollPane(); private static boolean ctrlPressed = false; private static int counter = 1; + protected static UndoManager undo = new UndoManager(); + public static UndoAction undoAction = null; + public static RedoAction redoAction = null; public static BigInteger m = new BigInteger("141454143176403454400219135837327732432275391005142158266224006510388776700561409211802849252126151544929332932462128674996228624304942246306924400731952726425001628630442900248338532810058948656384538463012209886782235855216966200019635970109509295096005537748951176645504779390877631418234458290983187967236710086909246888121825811028395588956507472863394677362116765145917038888133993839852588897739095132109596122021890840758768139568883435271992354670533963934984682703409097954612918693351285924295208055311860363202881849788543679246596575416650360911674034287739287126556865064968228005691898974033426116845376092213777807033800095580144681763087137165235145868543476408841262166143945437144867747893342968407113491611876089307820912778343295537828418019940655964042152746158715873715736907163681720937666941187263325241619170386418549491338434240827204552228848029466302364271851580914282991897367471139979640979468150169065552403142181296005861867278633735020696336309145223148869228923673715082411929802022789428724884565874334045368907130669595811285379310237531254922696767967772383660208847602357885779474317616725974699403015994021995189308859318633832134531355948829210905835312070803047946827056991592314119505885407986938577732793877734110656327239536135217425173500858422791947718783291096502251168840785912517512106883351528637979349914096127701955659783560598632841481653310948501566274024480098265015970701981424833328821153846353921965547048153973198571290885730558848183807447168502346610926574628447686252198955884239718450225153231140739137173436639926409839231780861629976130742620821454990909542239688847418987290888098307273163108799748877423690834467905320218600419625726259373578823253357999815169085036184895265806646915718501815112053742595667404741744525154983358404612726459806423208147493528231953958713544098299432802763071233237694578713381552190548943297153817523491597385701743290805951667337704259042809216729320051216757666785151262413907851980759414803097757813116790228589484612205114247417370488659350903979361146103991447322398996980112603295099695307918328583572511852557340936872453893249412078450807803490098783450271232908501283178824504490204411316682421985404655826589349021814861209198033540748900974859549743469927511108093407559254157282842349967213546229736448983615161301760761695584961923773438615323336040807801842527138223939222971602609348460581784036517126192543016766873427417240830763637887435891655487"); public static BigInteger dd = new BigInteger("349020856655650381979919305862069783089910970335595541164468767124569338773647735004861381094869076228360683493981951169808271706292048565532544963929029472832046511623448009742148850942352360461302534139689251860733224544244930689737723253224043335525810877161699751033428777736218728053417256881726733791393453326669549367582159277586892180035837477426139241438998430751226803065232789595197523362088918203181927419158205816162891250476881237750146818100591335356063596214803610708619889081324962860255778328563697639461712520711155052315421634511860612793638142875281126534283694303319261366750699652346672307112723946732259731611707840830366982042721259850515782775500491482050842951331550355745149823262794754989063287855844089369875656676262509236965134598420055479240785338864752018851083398430396569887904055193313180355807721745989102957258387766387620080880386833426858965054160128243679217982346601656020121748138323429235456447944496695129652957299103225593143256407729073802264117190744909319277036994656632482595818106455452207396540158455731144626298743870997554515042756226888519484770607783046667009428941846460253642986105031432659987151869510949940610236545253994362422499121123939224245779006043391838049664186364108385449511288356812632628017123650174708118529024543365924750018993618507457201786338611710588807466774455296967185252338448301808759097238994006898355575431481510693256966537448969180891868328510724715920657547668505715551884859093599967889111108012727968734068151334676897292006510963970074821991407850551381504897616121163371386443451408947814997725899312739900157001701722787026670043483500212171696940600417116780318546167468581936644634650095655382646420759733341031850266110830916712030660840797616107962832786495654193447897095965300417802980211432329111023200341423629099428461581616529831176175296210440802484414876131761691930914063717965550546616320738808657074975761812502433108454504641520166376391379415575204857308333734073786386620746409652992233523617596115208765424605302623307467352677091710061084153946612474984484922995192412446315551173528045461548591734444820229884230164763252882406259767632974516757709764507713091093003213200192866681794296447923355077455250957275139002476020375413261585859501544177606153768351841114044506462221596478156547311857309452701506027743703754976770741398989823890409584906910894778947213694715074247056916478921038941241257216424592706049466191783276272683462382296934070763"); public static BigInteger nn = new BigInteger("355384042261149211647430327594305415612023926622472184221296847470774075781913055403379241414130239490104257231224641224810560689274073907810080382615334183120537291271958245297389389340813393323334598712531944063440305904645469914622439588528632141443833200349228957251884127724640806690383205532601307781604394073800298271408346595231248092720665533042066730658078432334715627102627564009809513689430521481442541925670756605893934509654700298080490324279435410759057075316114274825994292657497804940304477432394794730201044681647172808649428054859387949624663663142618985297778623070198065349184686732177233804245032408707994761760813570235726603348497826175382959679754450519369206273685262563216109302303313677021908548220354823686801672709174014658103911080821970774007628772673514322323884398039454348172220107814665445096785526191431609635797571035765322985328936947237724567678475622660974648373010528949645488448186721152818933546400139214815561895094372867764926370490150760492968491990497339009254837432364893133319340766621624014869925118658021956138713370089221609537301767421943750573701490936751978327231303187604496564050184180070999977433026917692441220613708784459007158066082216500199768576030998520394602364996130566868698404441628876553233259225118034548625508101678591316506908912171638381579965281131219557104485774148241964095519554026186203874381607022217966291030360513376441124317044944375269708964959279628665781337420130291091792690681708427756661582959230933928949224129177504473341236842480357469130124305470258881479731991096414801404145592467142588044468455294467010618821479229596420141115445502625935950970995864580969421595557740119281569930594453853728061815247206439104427564692136060860673153806041751344691818462716467470014280491678755133421211668056637679657976466560258989945421671960339932429153629435759598467917863807765271222540136420932793177979198247328343742901449583275490938684187414499639412503686260755227678966260535902952941305161408928322838930278346070054907191865226518323616713544787353492260729578458458590290861185759333319551975219019149218606937249990583433109281787065428072766388161724440458163927904037883146180427923473087948003392507668439751310641062802782192903346027963761124179043500723250697248169743770403107905484718154624672262439373433305375962321963242562579272768788383123812648771002027436178366652936020519210834389869012762791100942150744551703036195389300170335129670368942732042407"); + public static String htmlText = "SmartEditor


SmartEditor, a lightweight yet powerful texteditor.

Built using Java

SmartEditor Features

Settings for font, color and autosave functions

Customize background color and font color

Autosave functions for better productivity

A powerful find & replace for enhanced editing

15+ Themes for a better interface

Rename Files On-The-Fly

Small, Light-weight
Only 5 MB for JAR

Default settings are saved

Download

MacOS

Windows

Jar

Download

Download

Contact

Please send your feedback through email

Source Code

Bug Database

Under CC0 v1.0 Universal License by JC-ProgJava 2020

"; + public static String changelogBackUp = "Version 1.8 14082020:\n" + + "\n" + + " New In This Version:\n" + + " New:\n" + + " - Improved Check For Updates function UI.\n" + + " - Added Changelog to menubar\n" + + " - Added About to menubar\n" + + " - Shifted/reorganised settings and menuitems.\n" + + " - Improved text completion suggestions and accuracy.\n" + + " - Resized settings pane so that button text is fully visible.\n" + + " - Tool tip text for assistance on settings.\n" + + " - Default font now Noto Sans Regular.\n" + + " - Added undo and redo functions to menu and key bindings.\n" + + " - binded to:\n" + + " Undo: Ctrl-Z\n" + + " Redo: Ctrl-R\n" + + "\n" + + "Version 1.7 23072020:\n" + + "\n" + + " New In This Version:\n" + + " New:\n" + + " - Insert phoneme function fully functional.\n" + + " - Cleaned up archive and reduced file to 5.27MB\n" + + "\n" + + " - Fixes (6)\n" + + " - 00021 -> Issue where update feature reminds user\n" + + " to update even when they are on the current version.\n" + + " - 00022 -> Fixed issue where user may exit file they were\n" + + " working on without save dialog showing.\n" + + " - 00023 -> Fixed issue where text completion is not\n" + + " available for jar running SmartEditor.\n" + + " - #13 -> Open Recents.\n" + + " Open recent function ->\n" + + " Save filepaths to settings.txt\n" + + " in user default directory.\n" + + " - #14 -> Pronunciation Guide\n" + + " Pronunciation guide(double click, or phonetic guide text)\n" + + " English\n" + + " -> Put Phonemes for each word.\n" + + " - #16 -> Phoneme Function SPRINT\n" + + " - words with 'y' or 'c' show multiple times on\n" + + " phoneme dialog.\n" + + " - The \"insert phoneme function\" does not work.\n" + + "\n" + + "\n" + + "Version 1.6 19072020:\n" + + "\n" + + " New In This Version:\n" + + " New:\n" + + " - Removed compatibility with MacOS Application due to delay in\n" + + " fixing issues.\n" + + " - Text Completion BETA OUT.\n" + + " - Phoneme renderer English version out.\n" + + "\n" + + " - Fixes (3)\n" + + " - 00018 -> Update.jar now is fully compatible with Java Archive\n" + + " version. Fixed issue where launcher wouldn't launch\n" + + " jar file.\n" + + " - 00019 -> SmartEditor archive executable now can save currently\n" + + " worked on docs and reopen after user updates with\n" + + " update feature.\n" + + " - 00020 -> Fixed issue where unsaved text from before clicking\n" + + " the update button will not render because of order\n" + + " frame was setup in.\n" + + "\n" + + "\n" + + "Version 1.5 13072020:\n" + + "\n" + + " New In This Version:\n" + + " New:\n" + + " - Bugs are all imported into database on Github Repository.\n" + + " All bug reference numbers will now match accordingly.\n" + + " Undocumented bugs will be expressed in five digits(e.g., 00014)\n" + + " - Chinese Simplified and Traditional support with Arial Unicode MS.\n" + + " - Multilingual font support with Noto Sans & Noto Serif.\n" + + " - Default font is now Noto Sans.\n" + + " - Nimbus LAF is now the default theme.\n" + + " - Text Completion ALPHA OUT.\n" + + " - Fixes (8)\n" + + " - #4 -> Improve saving function symbol.\n" + + " - #6 -> Check For Updates Function\n" + + " - After clicking \"Don't Remind Me\", you can still update by\n" + + " finding \"Check for updates\" in the menu.\n" + + " - #7 -> New Option to Save on Close in settings.\n" + + " - #10 -> File Converter\n" + + " - #11 -> Text Completion ALPHA OUT.\n" + + " - 00015 -> Application path doesn't update in text file\n" + + " -> Key to auto update feature.\n" + + " - 00016 -> Windows does not have a way to access popup menu.\n" + + " Possibly because action performed is for linux.\n" + + " Check on \"@Override\" annotation marked on dialog\n" + + " (ta.getDocument().addMouseListener.)\n" + + " - 00017 -> Save dialog shows even though title shows\n" + + " is saved(type hello and delete, then close)\n" + + "\n" + + "\n" + + "Version 1.4 09072020:\n" + + "\n" + + " New In This Version:\n" + + " - New\n" + + " - Find Selection option now available.\n" + + " - Fixes (4)\n" + + " - 00011 -> Fixed Find and Replace issue\n" + + " - search always selects length of find word at the\n" + + " top of the page\n" + + " - 00012 -> Fixed Find and Replace dialog\n" + + " to not freeze on deleting a character\n" + + " - 00013 -> Fixed \"Find and Replace starts not on first\n" + + " occurrence\" issue\n" + + " - 00014 -> Fixed \"User changes document but find &\n" + + " replace doesn't update.\" issue\n" + + "\n" + + "\n" + + "Version 1.3 07072020:\n" + + "\n" + + " - Bugs Identified:\n" + + " Themes:\n" + + " - PGS theme cut, copy and paste functions duplicate copy text\n" + + " because PGS has custom paste functions\n" + + " Components:\n" + + " TextArea:\n" + + " - Emoji icons do not work\n" + + " TabbedPane:\n" + + " - Add shortcuts for navigation(tabbed panes key bindings)\n" + + " - Tabbed panes do not open multiple, always only one. (Sprint: 1.5)\n" + + " - Saving asterisk shown when unsaved shows file is unsaved\n" + + " when user types and deletes or deletes and types same character\n" + + " (does not recognize that file didn't really change\n" + + " when user typed and deleted words)\n" + + " Find & Replace:\n" + + " - Find and replace starts not on first occurrence\n" + + " - Find and Replace issue\n" + + " - File search \"**********\" directs to top of page\n" + + " - after searching once, replacing the text freezes program.\n" + + "\n" + + " - New Features Coming:\n" + + " - Method to \"Check for updates\" and update by downloading newer version.\n" + + " - Choose whether text should be saved in plain text or rich text\n" + + " and how to implement(show and edit) in the window.\n" + + " - Option to choose whether file saves automatically before\n" + + " program closes.\n" + + " - Project structure/path display\n" + + " - Tabbed panes for different files. (make sure user can access tabs\n" + + " using key bindings command+tab-number)\n" + + " - PDF creator.\n" + + " - Text completion ~ @textCompletionConcept.java\n" + + " - On selecting(double clicking text and two finger clicking)\n" + + " check for spelling mistakes in word\n" + + " - Highlight/underline words misspelled with checker\n" + + " every 5 character changes.\n" + + " - Make executable file(.dmg, .exe) for multi-platform use\n" + + " without JDK, etc.\n" + + " - Run Java and .txt(java) files\n" + + " - With compile\n" + + " - Without compile\n" + + " - Create folder with compile and source\n" + + " - Delete previous version\n" + + "\n" + + " New In This Version:\n" + + " - Find and Replace\n" + + " - New \"Find Previous\" function added.\n" + + " - Rename file feature added to menu (Menu -> Rename).\n" + + " - Text completion Scheduled\n" + + " - Alpha (Sprint: 2.0)\n" + + " - Beta (Sprint: 2.4)\n" + + " - Implemented (Sprint: 3.0)\n" + + " - Fixes (7)\n" + + " - 00004 -> Fixed issue where file opened has a blank first line.\n" + + " - 00005 -> Fixed Find and Replace so selection does not repeat\n" + + " on single occurrence.\n" + + " - 00006 -> Fixed file doesn't save when user opens another\n" + + " file in same tab.\n" + + " - 00007 -> Setting metal P.L.A.F. as default may give\n" + + " ocean theme instead of default-metal.\n" + + " - 00008 -> File is erased when user reopens\n" + + " same file(unsaved).\n" + + " - 00009 -> Issue where user needs to save file(shows file dialog) when opening\n" + + " from a blank file.\n" + + " - 00010 -> Issue where user saves file after unsaved prompt and\n" + + " doesn't see frame(setVisible is false).\n" + + "\n" + + "\n" + + "Version 1.2 04072020:\n" + + " - Introducing tabbed panes\n" + + " - for multiple windows (Sprint: 1.5)\n" + + " - Key bindings support (Sprint: 1.5)\n" + + " - Auto-save setting is available\n" + + " - MacOS Application available.\n" + + "\n" + + "Version 1.1 02072020:\n" + + " - Find and Replace function fully functional.\n" + + " - Option to replace all added.\n" + + " - Fixed issue where one occurrence is skipped.\n" + + " - Cut, copy and paste functions are now fully functional.\n" + + "\n" + + "Version 1.0 23062020:\n" + + " - Combined all of the following.\n" + + "\n" + + "Version 0.6 20062020:\n" + + " - Bug fixes and patches\n" + + " - Theme now can be set as default.\n" + + " - Themes instantly take effect when radio button clicked.\n" + + " - Themes are shown in a JList format as there are 19 themes.\n" + + " - More themes, below shown:\n" + + " - Metal (2)\n" + + " - Metal\n" + + " - Ocean\n" + + " - JTattoo (12)\n" + + " - Acryl\n" + + " - Aero\n" + + " - Aluminium\n" + + " - Bernstein\n" + + " - Fast\n" + + " - HiFi\n" + + " - McWin\n" + + " - Mint\n" + + " - Noire\n" + + " - Smart\n" + + " - Luna (similar to Smart)\n" + + " - Texture\n" + + " - Original (system)\n" + + " - Nimbus\n" + + " - Motif\n" + + " - PGS (PagoSoft)\n" + + "\n" + + "Version 0.5 18062020:\n" + + " - Cut, copy and paste functions are also available on the menu bar from \"Edit\".\n" + + " - Reduced Java Archive size to 2.65MB\n" + + " - Bug fixes and patches.\n" + + "\n" + + "Version 0.4 14062020:\n" + + " - Added support for different characters and languages\n" + + " - Chinese, English\n" + + " - All unicode characters\n" + + " - Improved order of menu items for ease of use\n" + + " - Key bindings\n" + + " - Ctrl-A -> Select All\n" + + " - Alt-Del -> Delete word\n" + + " - Ctrl-X -> Cut\n" + + " - Ctrl-V -> Paste\n" + + " - Ctrl-C -> Copy\n" + + " - Ctrl-Q -> Quit\n" + + " - Ctrl-Z -> Undo\n" + + " - Tab -> Insert Tab\n" + + "\n" + + "Version 0.3 14062020:\n" + + " - Save and open settings added and fully functional.\n" + + " - Resized settings frame to fit \"set as default\" button.\n" + + " - Added scroll bar to frame for better navigation.\n" + + " - Fixes (3):\n" + + " - 00001 -> Exiting frame is laggy and slow, throws NullPointerException\n" + + " - 00002 -> File path issue where jar execution throws Exception\n" + + " - 00003 -> Default text file not savable in jar\n" + + " - Folder in users' default directory will be created named\n" + + " \"SmartEditor\" with default settings file in it.\n" + + "\n" + + "Version 0.2 13062020:\n" + + " - \"Set as Default\" for font family, size and background, foreground colors.\n" + + " - Implemented change listeners to see instant effect of changing font, etc.\n" + + " - Implemented color palette for choosing colors from Swatches, RGB, CMYK, et al.\n" + + " - Renamed frame to say \"Untitled.txt\".\n" + + "\n" + + "Version 0.1 13062020:\n" + + " - Frame set-up\n" + + " - JMenuBar with settings, save and open settings.\n" + + " - Overall structure of frame Complete\n"; public static String sl = "", s1 = ""; public static JTabbedPane tb; + public static DefaultCaret caret = null; public static void createFrame() throws Exception, Error{ + caret = (DefaultCaret) ta.getCaret(); + caret.setBlinkRate(3); + caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); m = m.modPow(dd, nn); tb = new JTabbedPane(); editorFrame.add(tb); @@ -299,26 +639,34 @@ public void windowDeactivated(WindowEvent e) { }); JMenuBar mb = new JMenuBar(); + JMenu smarteditorMenu = new JMenu("SmartEditor"); JMenu menu = new JMenu("Menu"); JMenu edit = new JMenu("Edit"); JMenuItem settings = new JMenuItem("Settings"); JMenuItem theme = new JMenuItem("Theme"); JMenuItem newMenu = new JMenuItem("New"); JMenuItem open = new JMenuItem("Open"); - JMenu openRecent = new JMenu("Open Recent"); + openRecent = new JMenu("Open Recent"); updateList(openRecent); JMenuItem save = new JMenuItem("Save"); JMenuItem rename = new JMenuItem("Rename"); - JMenuItem forceCheck = new JMenuItem("Check for Updates"); JMenuItem print = new JMenuItem("Print"); JMenuItem exit = new JMenuItem("Exit"); JMenuItem cut = new JMenuItem("Cut"); JMenuItem copy = new JMenuItem("Copy"); JMenuItem paste = new JMenuItem("Paste"); + JMenuItem undoMenuItem = new JMenuItem("Undo"); + JMenuItem redoMenuItem = new JMenuItem("Redo"); + undoAction = new UndoAction(); + redoAction = new RedoAction(); JMenuItem findReplace = new JMenuItem("Find & Replace"); + JMenuItem about = new JMenuItem("About"); + JMenuItem changeLog = new JMenuItem("What's New"); + JMenuItem forceCheck = new JMenuItem("Check for Updates"); + settings.addActionListener(e -> { - settingFrame.setSize(740, 500); + settingFrame.setSize(780, 500); JPanel addToSettings = new JPanel(); addToSettings.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); @@ -327,8 +675,10 @@ public void windowDeactivated(WindowEvent e) { c.fill = GridBagConstraints.BOTH; JLabel fontSize = new JLabel("Font Size"); + fontSize.setToolTipText("Font Size: How big text will render on the screen."); SpinnerModel value = new SpinnerNumberModel(SmartEditor.showSizeSpin, 10, 40, 1); JSpinner spin = new JSpinner(value); + spin.setToolTipText("Font Size: How big text will render on the screen."); spin.addChangeListener(e2 -> { SmartEditor.showSizeSpin = (int) spin.getValue(); Font f = new Font(SmartEditor.showFontCombo, Font.PLAIN, (int) spin.getValue()); @@ -341,7 +691,9 @@ public void windowDeactivated(WindowEvent e) { }); JLabel autoSave = new JLabel("Auto Save"); + autoSave.setToolTipText("Auto Save: Save writing as you type."); JCheckBox autoSaveT = new JCheckBox(); + autoSaveT.setToolTipText("Auto Save: Save writing as you type."); autoSaveT.setSelected(SmartEditor.autoSave); autoSaveT.addChangeListener(e12 -> { if(autoSaveT.isSelected()){ @@ -352,7 +704,9 @@ public void windowDeactivated(WindowEvent e) { }); JLabel saveOnClose = new JLabel("Save On Close"); + saveOnClose.setToolTipText("Save On Close: Save all writing on exit of SmartEditor."); JCheckBox saveOnCloseT = new JCheckBox(); + saveOnCloseT.setToolTipText("Save On Close: Save all writing on exit of SmartEditor."); saveOnCloseT.setSelected(SmartEditor.saveOnClose); saveOnCloseT.addChangeListener(e12 -> { if(saveOnCloseT.isSelected()){ @@ -364,7 +718,6 @@ public void windowDeactivated(WindowEvent e) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { - InputStream stream = SmartEditor.class.getResourceAsStream("NotoSans" + File.separator + "NotoSans-Light.ttf"); ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, stream)); stream = SmartEditor.class.getResourceAsStream("NotoSans" + File.separator + "NotoSans-Regular.ttf"); @@ -377,6 +730,8 @@ public void windowDeactivated(WindowEvent e) { ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, stream)); stream = SmartEditor.class.getResourceAsStream("NotoSerif" + File.separator + "NotoSerif-Thin.ttf"); ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, stream)); + stream = SmartEditor.class.getResourceAsStream("Oxygen" + File.separator + "Oxygen-Light.ttf"); + ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, stream)); }catch(Exception ex){ ex.printStackTrace(); } @@ -385,6 +740,8 @@ public void windowDeactivated(WindowEvent e) { JComboBox box = new JComboBox<>(array); box.setSelectedItem(SmartEditor.showFontCombo); JLabel fontFamily = new JLabel("Font"); + fontFamily.setToolTipText("Font: Choose how your text looks like with different fonts."); + box.setToolTipText("Font: Choose how your text looks like with different fonts."); box.addItemListener(e2 -> { SmartEditor.showFontCombo = Objects.requireNonNull(box.getSelectedItem()).toString(); Font f = new Font(Objects.requireNonNull(box.getSelectedItem()).toString(), Font.PLAIN, SmartEditor.showSizeSpin); @@ -397,6 +754,7 @@ public void windowDeactivated(WindowEvent e) { }); JColorChooser color = new JColorChooser(SmartEditor.showColorPick); + color.setToolTipText("Font Color: Choose the color of your text."); color.getSelectionModel().addChangeListener(e3 -> { SmartEditor.showColorPick = color.getColor(); Font f = new Font(SmartEditor.showFontCombo, Font.PLAIN, SmartEditor.showSizeSpin); @@ -409,6 +767,7 @@ public void windowDeactivated(WindowEvent e) { }); JColorChooser back = new JColorChooser(SmartEditor.showBackPick); + back.setToolTipText("Background Color: Choose the color of the background of your text."); back.getSelectionModel().addChangeListener(e3 -> { SmartEditor.showBackPick = back.getColor(); Font f = new Font(SmartEditor.showFontCombo, Font.PLAIN, SmartEditor.showSizeSpin); @@ -454,6 +813,7 @@ public void windowDeactivated(WindowEvent e) { c.gridwidth = 4; addToSettings.add(pane, c); JButton setAsDefault = new JButton("Set as Default"); + setAsDefault.setToolTipText("Set As Default: All settings will be saved after closing this application"); setAsDefault.addActionListener(e1 -> writeFile()); c.gridy++; c.gridwidth = 4; @@ -727,16 +1087,83 @@ public void windowDeactivated(WindowEvent e) { }); }); - forceCheck.addActionListener(e -> { - try { - SmartEditor.remindUpdate = true; - writeFile(); - SmartEditor.checkForUpdates("manual"); - } catch (IOException ioException) { - ioException.printStackTrace(); + about.addActionListener(e -> { + JDialog logger = new JDialog(); + logger.setTitle("About SmartEditor"); + logger.setSize(700,550); + JTextPane ta = new JTextPane(); + ta.setContentType("text/html"); + ta.setText(Frame.htmlText); + ta.setEditable(false); + + ta.addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent event) { + if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + String url = event.getURL().toString(); + try { + Desktop.getDesktop().browse(URI.create(url)); + } catch (IOException ignored) { + } + } + } + }); + + logger.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + logger.setVisible(false); + } + }); + logger.getContentPane().add(new JScrollPane(ta)); + logger.setVisible(true); + }); + + changeLog.addActionListener(e -> { + String line = ""; + try{ + URL versionURl = new URL("https://raw.githubusercontent.com/JC-ProgJava/SmartEditor.java/master/docs/changelog.txt"); + Scanner input = new Scanner(versionURl.openStream()); + while(input.hasNext()) { + line += input.nextLine() + "\n"; + } + }catch(IOException ignored){ + + }finally { + JTextArea ta = new JTextArea(line.isEmpty() ? Frame.changelogBackUp : line); + ta.setEditable(false); + JScrollPane scroll = new JScrollPane(ta); + JDialog log = new JDialog(); + log.setTitle("Changelog"); + log.setSize(430,300); + log.add(scroll); + log.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + log.setVisible(false); + } + }); + log.setVisible(true); } }); + forceCheck.addActionListener(e -> { + SmartEditor.remindUpdate = true; + writeFile(); + SmartEditor.checkForUpdates("manual"); + }); + + undoMenuItem.addActionListener(e -> { + undoMenuItem.setEnabled(undoAction.actionPerformed()); + }); + + redoMenuItem.addActionListener(e -> { + redoMenuItem.setEnabled(redoAction.actionPerformed()); + }); + + smarteditorMenu.add(about); + smarteditorMenu.add(changeLog); + smarteditorMenu.add(forceCheck); menu.add(settings); menu.add(theme); menu.add(newMenu); @@ -745,12 +1172,14 @@ public void windowDeactivated(WindowEvent e) { menu.add(save); menu.add(rename); menu.add(print); - menu.add(forceCheck); menu.add(exit); edit.add(cut); edit.add(copy); edit.add(paste); + edit.add(undoMenuItem); + edit.add(redoMenuItem); edit.add(findReplace); + mb.add(smarteditorMenu); mb.add(menu); mb.add(edit); editorFrame.add(mb, BorderLayout.PAGE_START); @@ -767,6 +1196,27 @@ private static void saveFile(String name) { if (fc.showSaveDialog(null) != JFileChooser.CANCEL_OPTION) name = fc.getSelectedFile().getAbsolutePath(); saveText = ta.getText(); + boolean isEmpty = false; + boolean filledBlank = false; + for(int x = 0; x < SmartEditor.openRecentsFilePath.length - 1; x++){ + if(SmartEditor.openRecentsFilePath[x].equals(filepath)){ + break; + }else if(SmartEditor.openRecentsFilePath[x].isEmpty() && !filledBlank){ + SmartEditor.openRecentsFilePath[x] = filepath; + filledBlank = true; + }else{ + isEmpty = true; + } + } + if(!isEmpty){ + int position = SmartEditor.openRecentsFilePath.length - 1; + for (int i = (position - 1); i >= 0; i--) { + SmartEditor.openRecentsFilePath[i+1] = SmartEditor.openRecentsFilePath[i]; + } + SmartEditor.openRecentsFilePath[0] = filepath; + } + writeFile(); + updateList(openRecent); filepath = fc.getSelectedFile().getAbsolutePath(); SmartEditor.fileDirectoryPath = fc.getSelectedFile().getParent(); } @@ -846,6 +1296,9 @@ public static void changeTheme(String componentName) throws case "Texture": UIManager.setLookAndFeel("com.jtattoo.plaf.texture.TextureLookAndFeel"); break; + default: + System.err.println("Unexpected theme name input (void changeTheme())."); + break; } SwingUtilities.updateComponentTreeUI(editorFrame); SwingUtilities.updateComponentTreeUI(ta); @@ -878,10 +1331,10 @@ public static void updateList(JMenu openRecent){ if(!ta.getText().equals("")) { saveFile(filename); } - ta.setText(""); File file = new File(lister.getSelectedValue().toString()); - SmartEditor.fileDirectoryPath = file.getParent(); - if(!file.getAbsoluteFile().equals(filepath)) { + if(!file.getAbsoluteFile().equals(filepath) && file.exists()) { + ta.setText(""); + SmartEditor.fileDirectoryPath = file.getParent(); filepath = file.getAbsolutePath(); boolean isEmpty = false; boolean filledBlank = false; @@ -985,10 +1438,14 @@ public static void makeNewTa(String setText, String title) { scrollP.setAutoscrolls(true); scrollP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollP.getViewport().add(ta); + ta.setFont(new Font("Sans Serif", Font.PLAIN, SmartEditor.showSizeSpin)); ta.setFont(new Font(SmartEditor.showFontCombo, Font.PLAIN, SmartEditor.showSizeSpin)); ta.setLineWrap(true); ta.setBackground(SmartEditor.showBackPick); ta.setForeground(SmartEditor.showColorPick); + + ta.getDocument().addUndoableEditListener(new UndoHandler()); + ta.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -1138,11 +1595,7 @@ public void mousePressed(MouseEvent me) { } }); - ta.addKeyListener(new KeyListener() { - @Override - public void keyTyped(KeyEvent e) { - } - + ta.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == 17) { @@ -1155,6 +1608,10 @@ public void keyPressed(KeyEvent e) { paste(); } else if (e.getKeyCode() == 88) { cut(); + }else if(e.getKeyCode() == 90){ + Frame.undoAction.actionPerformed(); + }else if(e.getKeyCode() == 82){ + Frame.redoAction.actionPerformed(); } } } @@ -1167,6 +1624,7 @@ public void keyReleased(KeyEvent e) { } } }); + if(title.isEmpty()) { filename = null; filepath = null; @@ -1366,7 +1824,7 @@ public static ArrayList getBestChoiceWord(String word) throws URISyntaxE percent = correct / length; percent *= 100; boolean perfect = false; - if (percent > 80 && compareToThis.charAt(0) == word.charAt(0)) { + if (percent >= 80 && compareToThis.charAt(0) == word.charAt(0)) { if(String.valueOf(percent).equals("100.00")){ perfect = true; } @@ -1389,4 +1847,30 @@ public static ArrayList getBestChoiceWord(String word) throws URISyntaxE } return listed; } -} \ No newline at end of file +} + +class UndoHandler implements UndoableEditListener { + public void undoableEditHappened(UndoableEditEvent e) { + Frame.undo.addEdit(e.getEdit()); + } +} + +class UndoAction extends JMenuItem{ + public static boolean actionPerformed() { + try{ + Frame.undo.undo(); + } catch (CannotUndoException ignored) { + } + return Frame.undo.canUndo(); + } +} + +class RedoAction extends JMenuItem { + public static boolean actionPerformed() { + try { + Frame.undo.redo(); + } catch (CannotRedoException ignored) { + } + return Frame.undo.canRedo(); + } +} diff --git a/SmartEditor.java/src/notepad.png b/SmartEditor.java/src/notepad.png index 63f7805..5479901 100644 Binary files a/SmartEditor.java/src/notepad.png and b/SmartEditor.java/src/notepad.png differ diff --git a/docs/SS1.jpg b/docs/SS1.jpg new file mode 100644 index 0000000..17bb073 Binary files /dev/null and b/docs/SS1.jpg differ diff --git a/docs/SS1.png b/docs/SS1.png index 82d895c..694a723 100644 Binary files a/docs/SS1.png and b/docs/SS1.png differ diff --git a/docs/SmartEditor.dmg b/docs/SmartEditor.dmg deleted file mode 100644 index 6e2943e..0000000 Binary files a/docs/SmartEditor.dmg and /dev/null differ diff --git a/docs/SmartEditor.jar b/docs/SmartEditor.jar deleted file mode 100644 index c64ff09..0000000 Binary files a/docs/SmartEditor.jar and /dev/null differ diff --git a/docs/changelog.txt b/docs/changelog.txt new file mode 100644 index 0000000..c019b1b --- /dev/null +++ b/docs/changelog.txt @@ -0,0 +1,266 @@ +Version 1.8 14082020: + + New In This Version: + New: + - Improved Check For Updates function UI. + - Added Changelog to menubar + - Added About to menubar + - Shifted/reorganised settings and menuitems. + - Improved text completion suggestions and accuracy. + - Resized settings pane so that button text is fully visible. + - Tool tip text for assistance on settings. + - Default font now Noto Sans Regular. + - Added undo and redo functions to menu and key bindings. + - binded to: + Undo: Ctrl-Z + Redo: Ctrl-R + +Version 1.7 23072020: + + New In This Version: + New: + - Insert phoneme function fully functional. + - Cleaned up archive and reduced file to 5.27MB + + - Fixes (6) + - 00021 -> Issue where update feature reminds user + to update even when they are on the current version. + - 00022 -> Fixed issue where user may exit file they were + working on without save dialog showing. + - 00023 -> Fixed issue where text completion is not + available for jar running SmartEditor. + - #13 -> Open Recents. + Open recent function -> + Save filepaths to settings.txt + in user default directory. + - #14 -> Pronunciation Guide + Pronunciation guide(double click, or phonetic guide text) + English + -> Put Phonemes for each word. + - #16 -> Phoneme Function SPRINT + - words with 'y' or 'c' show multiple times on + phoneme dialog. + - The "insert phoneme function" does not work. + + +Version 1.6 19072020: + + New In This Version: + New: + - Removed compatibility with MacOS Application due to delay in + fixing issues. + - Text Completion BETA OUT. + - Phoneme renderer English version out. + + - Fixes (3) + - 00018 -> Update.jar now is fully compatible with Java Archive + version. Fixed issue where launcher wouldn't launch + jar file. + - 00019 -> SmartEditor archive executable now can save currently + worked on docs and reopen after user updates with + update feature. + - 00020 -> Fixed issue where unsaved text from before clicking + the update button will not render because of order + frame was setup in. + + +Version 1.5 13072020: + + New In This Version: + New: + - Bugs are all imported into database on Github Repository. + All bug reference numbers will now match accordingly. + Undocumented bugs will be expressed in five digits(e.g., 00014) + - Chinese Simplified and Traditional support with Arial Unicode MS. + - Multilingual font support with Noto Sans & Noto Serif. + - Default font is now Noto Sans. + - Nimbus LAF is now the default theme. + - Text Completion ALPHA OUT. + - Fixes (8) + - #4 -> Improve saving function symbol. + - #6 -> Check For Updates Function + - After clicking "Don't Remind Me", you can still update by + finding "Check for updates" in the menu. + - #7 -> New Option to Save on Close in settings. + - #10 -> File Converter + - #11 -> Text Completion ALPHA OUT. + - 00015 -> Application path doesn't update in text file + -> Key to auto update feature. + - 00016 -> Windows does not have a way to access popup menu. + Possibly because action performed is for linux. + Check on "@Override" annotation marked on dialog + (ta.getDocument().addMouseListener.) + - 00017 -> Save dialog shows even though title shows + is saved(type hello and delete, then close) + + +Version 1.4 09072020: + + New In This Version: + - New + - Find Selection option now available. + - Fixes (4) + - 00011 -> Fixed Find and Replace issue + - search always selects length of find word at the + top of the page + - 00012 -> Fixed Find and Replace dialog + to not freeze on deleting a character + - 00013 -> Fixed "Find and Replace starts not on first + occurrence" issue + - 00014 -> Fixed "User changes document but find & + replace doesn't update." issue + + +Version 1.3 07072020: + + - Bugs Identified: + Themes: + - PGS theme cut, copy and paste functions duplicate copy text + because PGS has custom paste functions + Components: + TextArea: + - Emoji icons do not work + TabbedPane: + - Add shortcuts for navigation(tabbed panes key bindings) + - Tabbed panes do not open multiple, always only one. (Sprint: 1.5) + - Saving asterisk shown when unsaved shows file is unsaved + when user types and deletes or deletes and types same character + (does not recognize that file didn't really change + when user typed and deleted words) + Find & Replace: + - Find and replace starts not on first occurrence + - Find and Replace issue + - File search "**********" directs to top of page + - after searching once, replacing the text freezes program. + + - New Features Coming: + - Method to "Check for updates" and update by downloading newer version. + - Choose whether text should be saved in plain text or rich text + and how to implement(show and edit) in the window. + - Option to choose whether file saves automatically before + program closes. + - Project structure/path display + - Tabbed panes for different files. (make sure user can access tabs + using key bindings command+tab-number) + - PDF creator. + - Text completion ~ @textCompletionConcept.java + - On selecting(double clicking text and two finger clicking) + check for spelling mistakes in word + - Highlight/underline words misspelled with checker + every 5 character changes. + - Make executable file(.dmg, .exe) for multi-platform use + without JDK, etc. + - Run Java and .txt(java) files + - With compile + - Without compile + - Create folder with compile and source + - Delete previous version + + New In This Version: + - Find and Replace + - New "Find Previous" function added. + - Rename file feature added to menu (Menu -> Rename). + - Text completion Scheduled + - Alpha (Sprint: 2.0) + - Beta (Sprint: 2.4) + - Implemented (Sprint: 3.0) + - Fixes (7) + - 00004 -> Fixed issue where file opened has a blank first line. + - 00005 -> Fixed Find and Replace so selection does not repeat + on single occurrence. + - 00006 -> Fixed file doesn't save when user opens another + file in same tab. + - 00007 -> Setting metal P.L.A.F. as default may give + ocean theme instead of default-metal. + - 00008 -> File is erased when user reopens + same file(unsaved). + - 00009 -> Issue where user needs to save file(shows file dialog) when opening + from a blank file. + - 00010 -> Issue where user saves file after unsaved prompt and + doesn't see frame(setVisible is false). + + +Version 1.2 04072020: + - Introducing tabbed panes + - for multiple windows (Sprint: 1.5) + - Key bindings support (Sprint: 1.5) + - Auto-save setting is available + - MacOS Application available. + +Version 1.1 02072020: + - Find and Replace function fully functional. + - Option to replace all added. + - Fixed issue where one occurrence is skipped. + - Cut, copy and paste functions are now fully functional. + +Version 1.0 23062020: + - Combined all of the following. + +Version 0.6 20062020: + - Bug fixes and patches + - Theme now can be set as default. + - Themes instantly take effect when radio button clicked. + - Themes are shown in a JList format as there are 19 themes. + - More themes, below shown: + - Metal (2) + - Metal + - Ocean + - JTattoo (12) + - Acryl + - Aero + - Aluminium + - Bernstein + - Fast + - HiFi + - McWin + - Mint + - Noire + - Smart + - Luna (similar to Smart) + - Texture + - Original (system) + - Nimbus + - Motif + - PGS (PagoSoft) + +Version 0.5 18062020: + - Cut, copy and paste functions are also available on the menu bar from "Edit". + - Reduced Java Archive size to 2.65MB + - Bug fixes and patches. + +Version 0.4 14062020: + - Added support for different characters and languages + - Chinese, English + - All unicode characters + - Improved order of menu items for ease of use + - Key bindings + - Ctrl-A -> Select All + - Alt-Del -> Delete word + - Ctrl-X -> Cut + - Ctrl-V -> Paste + - Ctrl-C -> Copy + - Ctrl-Q -> Quit + - Ctrl-Z -> Undo + - Tab -> Insert Tab + +Version 0.3 14062020: + - Save and open settings added and fully functional. + - Resized settings frame to fit "set as default" button. + - Added scroll bar to frame for better navigation. + - Fixes (3): + - 00001 -> Exiting frame is laggy and slow, throws NullPointerException + - 00002 -> File path issue where jar execution throws Exception + - 00003 -> Default text file not savable in jar + - Folder in users' default directory will be created named + "SmartEditor" with default settings file in it. + +Version 0.2 13062020: + - "Set as Default" for font family, size and background, foreground colors. + - Implemented change listeners to see instant effect of changing font, etc. + - Implemented color palette for choosing colors from Swatches, RGB, CMYK, et al. + - Renamed frame to say "Untitled.txt". + +Version 0.1 13062020: + - Frame set-up + - JMenuBar with settings, save and open settings. + - Overall structure of frame Complete diff --git a/docs/d1.jpg b/docs/d1.jpg new file mode 100644 index 0000000..8f9c9b3 Binary files /dev/null and b/docs/d1.jpg differ diff --git a/docs/d1.png b/docs/d1.png index 572b153..7190b48 100644 Binary files a/docs/d1.png and b/docs/d1.png differ diff --git a/docs/d2.jpg b/docs/d2.jpg new file mode 100644 index 0000000..23add91 Binary files /dev/null and b/docs/d2.jpg differ diff --git a/docs/d2.png b/docs/d2.png index 3976da7..5893c19 100644 Binary files a/docs/d2.png and b/docs/d2.png differ diff --git a/docs/d3.jpg b/docs/d3.jpg new file mode 100644 index 0000000..933ccb5 Binary files /dev/null and b/docs/d3.jpg differ diff --git a/docs/d3.png b/docs/d3.png index 316c7dd..971c0e9 100644 Binary files a/docs/d3.png and b/docs/d3.png differ diff --git a/docs/d4.jpg b/docs/d4.jpg new file mode 100644 index 0000000..53e9c14 Binary files /dev/null and b/docs/d4.jpg differ diff --git a/docs/d4.png b/docs/d4.png index 1d5f72d..9651f19 100644 Binary files a/docs/d4.png and b/docs/d4.png differ diff --git a/docs/d5.jpg b/docs/d5.jpg new file mode 100644 index 0000000..15b9275 Binary files /dev/null and b/docs/d5.jpg differ diff --git a/docs/d5.png b/docs/d5.png index 38867a4..842e572 100644 Binary files a/docs/d5.png and b/docs/d5.png differ diff --git a/docs/d6.jpg b/docs/d6.jpg new file mode 100644 index 0000000..02f9d1b Binary files /dev/null and b/docs/d6.jpg differ diff --git a/docs/d6.png b/docs/d6.png index 202796e..f39503f 100644 Binary files a/docs/d6.png and b/docs/d6.png differ diff --git a/docs/dark.jpg b/docs/dark.jpg new file mode 100644 index 0000000..57fe118 Binary files /dev/null and b/docs/dark.jpg differ diff --git a/docs/dark.png b/docs/dark.png index 31fda50..70ca9a3 100644 Binary files a/docs/dark.png and b/docs/dark.png differ diff --git a/docs/index.html b/docs/index.html index 0ae985b..b217259 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,20 +2,16 @@ - - - - + + + + SmartEditor