Skip to content

Commit

Permalink
Merge pull request #1381 from DraqueT/1377-help-manual-fix
Browse files Browse the repository at this point in the history
1377 help manual fix
  • Loading branch information
synthfi authored Nov 23, 2024
2 parents d94335d + 7e7c505 commit 9a236d7
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 6 deletions.
1 change: 1 addition & 0 deletions build_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions docs/readme_developers.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<version>20.0.2</version>
</dependency>

<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>20.0.2</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
</Properties>
</Component>
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<SubComponents>
<Menu class="javax.swing.JMenu" name="mnuFile">
<Properties>
Expand Down Expand Up @@ -281,6 +278,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mnuAboutActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="mnuAboutLocal">
<Properties>
<Property name="text" type="java.lang.String" value="Help (Local)"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mnuAboutLocalActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="mnuChkUpdate">
<Properties>
<Property name="text" type="java.lang.String" value="About"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -1889,8 +1890,6 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {

pnlToDoSplit.setLeftComponent(jPanel3);

jMenuBar1.setOpaque(false);

mnuFile.setText("File");

mnuNewLocal.setText("New");
Expand Down Expand Up @@ -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() {
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2577,6 +2595,7 @@ private void mnuWebServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
private javax.swing.JPopupMenu.Separator jSeparator7;
private javax.swing.JList<RecentFile> 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[500, 400]"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="First"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="backButton">
<Properties>
<Property name="text" type="java.lang.String" value="\ud83e\udc2c" containsInvalidXMLChars="true"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="forwardButton">
<Properties>
<Property name="text" type="java.lang.String" value="\ud83e\udc2e" containsInvalidXMLChars="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
150 changes: 150 additions & 0 deletions src/main/java/org/darisadesigns/polyglotlina/Screens/ScrWebView.java
Original file line number Diff line number Diff line change
@@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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
}

0 comments on commit 9a236d7

Please sign in to comment.