diff --git a/build_image.py b/build_image.py index b82d0b1b..7afa5e26 100755 --- a/build_image.py +++ b/build_image.py @@ -213,6 +213,7 @@ def image(): os.path.join(javafx_location, "javafx-media", JAVAFX_VER) + os.sep, os.path.join(javafx_location, "javafx-swing", JAVAFX_VER) + os.sep, os.path.join(javafx_location, "javafx-controls", JAVAFX_VER) + os.sep, + os.path.join(javafx_location, "javafx-web", JAVAFX_VER) + os.sep, os.path.join(javafx_location, "jmods") ]), '--add-modules', 'org.darisadesigns.polyglotlina.polyglot,jdk.crypto.ec', diff --git a/docs/readme_developers.md b/docs/readme_developers.md index de033258..6d0eb0e2 100644 --- a/docs/readme_developers.md +++ b/docs/readme_developers.md @@ -1,6 +1,8 @@ # README for Developers If you're looking to work on PolyGlot independently or to contribute, here's how you set it up to work with. +Note: GUI elements were built with the NetBeans GUI Builder. + ## BASIC DEVELOPMENT SETUP 1) Download/install Open JDK 17 (or higher) - Copy to appropriate directory if downloaded diff --git a/pom.xml b/pom.xml index ef9f0e99..e789bf0a 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,12 @@ 20.0.2 + + org.openjfx + javafx-web + 20.0.2 + + org.apache.commons commons-text diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index ccdfa621..5cd4e80c 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -5,6 +5,7 @@ requires javafx.controls; requires javafx.media; requires javafx.swing; + requires javafx.web; requires java.desktop; requires java.logging; requires java.xml; diff --git a/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.form b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.form index 39ab3ad4..dfee3348 100644 --- a/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.form +++ b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.form @@ -8,9 +8,6 @@ - - - @@ -281,6 +278,14 @@ + + + + + + + + diff --git a/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.java b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.java index 8b1c35c0..21e8f0c2 100644 --- a/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.java +++ b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrMainMenu.java @@ -1612,6 +1612,7 @@ public void repaint() { mnuReversion = new javax.swing.JMenuItem(); mnuHelp = new javax.swing.JMenu(); mnuAbout = new javax.swing.JMenuItem(); + mnuAboutLocal = new javax.swing.JMenuItem(); mnuChkUpdate = new javax.swing.JMenuItem(); mnuExLex = new javax.swing.JMenu(); jMenuItem4 = new javax.swing.JMenuItem(); @@ -1889,8 +1890,6 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { pnlToDoSplit.setLeftComponent(jPanel3); - jMenuBar1.setOpaque(false); - mnuFile.setText("File"); mnuNewLocal.setText("New"); @@ -2132,6 +2131,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); mnuHelp.add(mnuAbout); + mnuAboutLocal.setText("Help (Local)"); + mnuAboutLocal.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mnuAboutLocalActionPerformed(evt); + } + }); + mnuHelp.add(mnuAboutLocal); + mnuChkUpdate.setText("About"); mnuChkUpdate.setToolTipText("About PolyGlot"); mnuChkUpdate.addActionListener(new java.awt.event.ActionListener() { @@ -2142,7 +2149,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { mnuHelp.add(mnuChkUpdate); mnuExLex.setText("Example Languages"); - mnuExLex.setToolTipText("Languages with examples to copy from"); + mnuExLex.setToolTipText("Languages with exmples to copy from"); mnuHelp.add(mnuExLex); jMenuItem4.setText("Create Bug Report"); @@ -2544,6 +2551,17 @@ private void mnuWebServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN- } }//GEN-LAST:event_mnuWebServerActionPerformed + private void mnuAboutLocalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuAboutLocalActionPerformed + try { + File readmeDir = DesktopIOHandler.getInstance().unzipResourceToSystemTempLocation(PGTUtil.HELP_FILE_ARCHIVE_LOCATION); + File readmeFile = new File(readmeDir.getAbsolutePath() + File.separator + PGTUtil.HELP_FILE_NAME); + ScrWebView webView = new ScrWebView(core, readmeFile, "Help"); + webView.setVisible(true); + } catch (IOException e) { + new DesktopInfoBox(this).error("Help Error", "Unable to open help file: " + e.getLocalizedMessage()); + } + }//GEN-LAST:event_mnuAboutLocalActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnClasses; private javax.swing.JButton btnGrammar; @@ -2577,6 +2595,7 @@ private void mnuWebServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN- private javax.swing.JPopupMenu.Separator jSeparator7; private javax.swing.JList lstRecentOpened; private javax.swing.JMenuItem mnuAbout; + private javax.swing.JMenuItem mnuAboutLocal; private javax.swing.JMenu mnuAdvanced; private javax.swing.JMenuItem mnuChatGpt; private javax.swing.JMenuItem mnuCheckLanguage; diff --git a/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrWebView.form b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrWebView.form new file mode 100644 index 00000000..2f85b345 --- /dev/null +++ b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrWebView.form @@ -0,0 +1,54 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrWebView.java b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrWebView.java new file mode 100644 index 00000000..a4de71d4 --- /dev/null +++ b/src/main/java/org/darisadesigns/polyglotlina/Screens/ScrWebView.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024, Draque Thompson, draquemail@gmail.com + * All rights reserved. + * + * Licensed under: MIT License + * See LICENSE.TXT included with this code to read the full license agreement. + + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package org.darisadesigns.polyglotlina.Screens; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.io.File; +import javafx.application.Platform; +import javafx.embed.swing.JFXPanel; +import javafx.scene.Scene; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebView; +import javax.swing.JComponent; +import org.darisadesigns.polyglotlina.Desktop.CustomControls.PFrame; +import org.darisadesigns.polyglotlina.DictCore; + +/** + * + * @author kelly + */ +public class ScrWebView extends PFrame { + private final JFXPanel jfxPanel; + private String url; + private WebView webView; + + /** + * Creates new form ScrWebView + */ + public ScrWebView(DictCore _core, String pathToLoad, String title) { + super(_core); + url = pathToLoad; + jfxPanel = new JFXPanel(); + initComponents(); + setTitle(title); + + Platform.runLater(()->{ + webView = new WebView(); + WebEngine engine = webView.getEngine(); + engine.load(url); + Scene scene = new Scene(webView); + + jfxPanel.setScene(scene); + }); + + add(BorderLayout.CENTER, jfxPanel); + + backButton.addActionListener((ActionEvent e)->{ + goBack(); + }); + forwardButton.addActionListener((ActionEvent e)->{ + goForward(); + }); + } + + public ScrWebView(DictCore _core, File fileToLoad, String title) { + this(_core, "file://" + fileToLoad.getAbsolutePath(), title); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + backButton = new javax.swing.JButton(); + forwardButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setMinimumSize(new java.awt.Dimension(20, 20)); + setPreferredSize(new java.awt.Dimension(500, 400)); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); + + backButton.setText("🠬"); + jPanel1.add(backButton); + + forwardButton.setText("🠮"); + jPanel1.add(forwardButton); + + getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START); + + pack(); + }// //GEN-END:initComponents + + @Override + public void updateAllValues(DictCore _core) { + if (core != _core) { + core = _core; + } + } + + @Override + public boolean canClose() { + return true; + } + + @Override + public void saveAllValues() { + } + + @Override + public void addBindingToComponent(JComponent c) { + } + + @Override + public Component getWindow() { + return this.getRootPane(); + } + + public void goBack() { + Platform.runLater(()->{ + webView.getEngine().executeScript("history.back()"); + }); + } + + public void goForward() { + Platform.runLater(()->{ + webView.getEngine().executeScript("history.forward()"); + }); + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton backButton; + private javax.swing.JButton forwardButton; + private javax.swing.JPanel jPanel1; + // End of variables declaration//GEN-END:variables +}