Add About window when SyMAT logo is clicked on Ribbon
This commit is contained in:
parent
9c4648f304
commit
f8a2e0de7e
@ -15,6 +15,7 @@
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="componentResized" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentResized"/>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
|
@ -30,7 +30,7 @@ package net.apocalypselabs.symat;
|
||||
import java.awt.Color;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import javax.swing.UIDefaults;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -38,6 +38,9 @@ import javax.swing.UIDefaults;
|
||||
*/
|
||||
public class Help extends javax.swing.JInternalFrame {
|
||||
|
||||
// True if this is a manual, false if about window
|
||||
private boolean topicOnLoad = true;
|
||||
|
||||
/**
|
||||
* Creates new form Help
|
||||
*/
|
||||
@ -46,49 +49,74 @@ public class Help extends javax.swing.JInternalFrame {
|
||||
loadTheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the About window.
|
||||
*
|
||||
* @param about set it to whatever.
|
||||
*/
|
||||
public Help(boolean about) {
|
||||
initComponents();
|
||||
setSize(450,352);
|
||||
jSplitPane1.setDividerSize(0);
|
||||
jSplitPane1.setDividerLocation(0.0);
|
||||
jSplitPane1.setResizeWeight(0.0);
|
||||
topicOnLoad = false;
|
||||
loadTopic("about");
|
||||
}
|
||||
|
||||
private void loadTheme() {
|
||||
if (PrefStorage.getSetting("theme").equals("dark")) {
|
||||
setBackgroundOfBrowser(Color.BLACK);
|
||||
setBackgroundOfBrowser(Color.WHITE);
|
||||
topicList.setBackground(Color.BLACK);
|
||||
topicList.setForeground(Color.WHITE);
|
||||
setBackground(Color.DARK_GRAY);
|
||||
} else {
|
||||
setBackgroundOfBrowser(Color.WHITE);
|
||||
setBackgroundOfBrowser(Color.BLACK);
|
||||
topicList.setBackground(Color.WHITE);
|
||||
topicList.setForeground(Color.BLACK);
|
||||
setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackgroundOfBrowser(Color c) {
|
||||
/*UIDefaults defaults = new UIDefaults();
|
||||
defaults.put("EditorPane.backgroundPainter", c);
|
||||
topicBrowser.putClientProperty("Nimbus.Overrides", defaults);
|
||||
topicBrowser.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
|
||||
topicBrowser.setBackground(c);*/
|
||||
}
|
||||
|
||||
public void loadTopic(String name) {
|
||||
try {
|
||||
String text = "";
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
CodeRunner.class
|
||||
.getResourceAsStream("help/" + name + ".html")));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
text += line;
|
||||
}
|
||||
if (name.equals("about")) {
|
||||
String text = "<html><head><title>About SyMAT</title></head>"
|
||||
+ "<body>"
|
||||
+ "<h1>About</h1>"
|
||||
+ "<p>This is SyMAT version "
|
||||
+ MainGUI.VERSION_NAME + " (" + (int)MainGUI.APP_CODE + ")."
|
||||
+ "</p>"
|
||||
+ "<p>SyMAT is copyright © "
|
||||
+ Calendar.getInstance().get(Calendar.YEAR)
|
||||
+ " Apocalypse Laboratories. Some rights reserved."
|
||||
+ "</p>"
|
||||
+ "<p>Internal help documentation is "
|
||||
+ "licensed under the Creative Commons Attribution "
|
||||
+ "license (CC-BY). You can use it in part or in whole "
|
||||
+ "for any purpose, including commercial, as long as "
|
||||
+ "you attribute Apocalypse Laboratories.</p>"
|
||||
+ "";
|
||||
topicBrowser.setText(text);
|
||||
topicBrowser.setCaretPosition(0);
|
||||
setTitle("Manual (" + topicList.getSelectedValue().toString() + ")");
|
||||
} catch (Exception e) {
|
||||
//JOptionPane.showInternalMessageDialog(MainGUI.mainPane,
|
||||
//"Error: Cannot load help topic "+name+".\n\n"+e.getMessage());
|
||||
topicBrowser.setText("<html><head></head><body><p><b>Error:</b><br>Cannot get help topic \""
|
||||
+ name + "\".<br>(" + e.getMessage() + ")</p></body></html>");
|
||||
setTitle("About SyMAT");
|
||||
} else {
|
||||
try {
|
||||
String text = "";
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
CodeRunner.class
|
||||
.getResourceAsStream("help/" + name + ".html")));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
text += line;
|
||||
}
|
||||
topicBrowser.setText(text);
|
||||
topicBrowser.setCaretPosition(0);
|
||||
setTitle("Manual (" + topicList.getSelectedValue().toString() + ")");
|
||||
} catch (Exception e) {
|
||||
//JOptionPane.showInternalMessageDialog(MainGUI.mainPane,
|
||||
//"Error: Cannot load help topic "+name+".\n\n"+e.getMessage());
|
||||
topicBrowser.setText("<html><head></head><body><p><b>Error:</b><br>Cannot get help topic \""
|
||||
+ name + "\".<br>(" + e.getMessage() + ")</p></body></html>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,6 +142,9 @@ public class Help extends javax.swing.JInternalFrame {
|
||||
setTitle("Manual");
|
||||
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/help.png"))); // NOI18N
|
||||
addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||
public void componentResized(java.awt.event.ComponentEvent evt) {
|
||||
formComponentResized(evt);
|
||||
}
|
||||
public void componentShown(java.awt.event.ComponentEvent evt) {
|
||||
formComponentShown(evt);
|
||||
}
|
||||
@ -171,13 +202,22 @@ public class Help extends javax.swing.JInternalFrame {
|
||||
|
||||
private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
|
||||
topicList.setSelectedIndex(0);
|
||||
loadTopic("welcome");
|
||||
if (topicOnLoad) {
|
||||
loadTopic("welcome");
|
||||
}
|
||||
}//GEN-LAST:event_formComponentShown
|
||||
|
||||
private void topicListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topicListMouseClicked
|
||||
loadTheme();
|
||||
}//GEN-LAST:event_topicListMouseClicked
|
||||
|
||||
private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
|
||||
if (!topicOnLoad) {
|
||||
jSplitPane1.setDividerLocation(0.0);
|
||||
jSplitPane1.setResizeWeight(0.0);
|
||||
}
|
||||
}//GEN-LAST:event_formComponentResized
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
|
@ -55,9 +55,9 @@
|
||||
<Property name="selectedIndex" type="int" value="1"/>
|
||||
<Property name="opaque" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_allCodePost" type="java.lang.String" value="tabs.setEnabledAt(0, false);"/>
|
||||
</AuxValues>
|
||||
<Events>
|
||||
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="tabsStateChanged"/>
|
||||
</Events>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
|
@ -46,8 +46,8 @@ import javax.swing.JInternalFrame;
|
||||
public class MainGUI extends javax.swing.JFrame {
|
||||
|
||||
public static final String APP_NAME = "SyMAT 0.8";
|
||||
public static final double APP_CODE = 8;
|
||||
public static final String VERSION_NAME = "0.8";
|
||||
public static final double APP_CODE = 9;
|
||||
public static final String VERSION_NAME = "0.8.2";
|
||||
public static String argfile = "";
|
||||
public static boolean skipPython = false; // Skip python init on start?
|
||||
public static boolean skipEditor = false; // Skip editor init on start?
|
||||
@ -80,7 +80,7 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
+ " Assuming local copy up-to-date.");
|
||||
Debug.stacktrace(e);
|
||||
}
|
||||
|
||||
|
||||
setButtonShortcuts();
|
||||
|
||||
// Open shell unless prog was run with argument
|
||||
@ -108,7 +108,7 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
tabs.setMnemonicAt(2, KeyEvent.VK_T);
|
||||
tabs.setMnemonicAt(3, KeyEvent.VK_E);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* (Re)load display settings.
|
||||
*/
|
||||
@ -182,6 +182,11 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
|
||||
tabs.setBackground(new Color(240,240,240));
|
||||
tabs.setOpaque(true);
|
||||
tabs.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
tabsStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jPanel4.setFocusable(false);
|
||||
jPanel4.setLayout(null);
|
||||
@ -398,24 +403,19 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
.addComponent(mainPane))
|
||||
);
|
||||
|
||||
tabs.setEnabledAt(0, false);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void shellBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shellBtnActionPerformed
|
||||
Interpreter i = new Interpreter();
|
||||
loadFrame(i);
|
||||
loadFrame(new Interpreter());
|
||||
}//GEN-LAST:event_shellBtnActionPerformed
|
||||
|
||||
private void editorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editorBtnActionPerformed
|
||||
CodeEditor e = new CodeEditor();
|
||||
loadFrame(e);
|
||||
loadFrame(new CodeEditor());
|
||||
}//GEN-LAST:event_editorBtnActionPerformed
|
||||
|
||||
private void graphBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graphBtnActionPerformed
|
||||
Graph g = new Graph();
|
||||
loadFrame(g);
|
||||
loadFrame(new Graph());
|
||||
}//GEN-LAST:event_graphBtnActionPerformed
|
||||
|
||||
private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
|
||||
@ -423,8 +423,7 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
}//GEN-LAST:event_formComponentShown
|
||||
|
||||
private void helpBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpBtnActionPerformed
|
||||
Help h = new Help();
|
||||
loadFrame(h);
|
||||
loadFrame(new Help());
|
||||
}//GEN-LAST:event_helpBtnActionPerformed
|
||||
|
||||
private void arrangeWindowsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_arrangeWindowsBtnActionPerformed
|
||||
@ -432,8 +431,7 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
}//GEN-LAST:event_arrangeWindowsBtnActionPerformed
|
||||
|
||||
private void displaySettingsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displaySettingsBtnActionPerformed
|
||||
Display d = new Display();
|
||||
loadFrame(d);
|
||||
loadFrame(new Display());
|
||||
}//GEN-LAST:event_displaySettingsBtnActionPerformed
|
||||
|
||||
private void closeAllBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeAllBtnActionPerformed
|
||||
@ -446,6 +444,17 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
}
|
||||
}//GEN-LAST:event_closeAllBtnActionPerformed
|
||||
|
||||
private void tabsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabsStateChanged
|
||||
if (tabs.getSelectedIndex() == 0) {
|
||||
try {
|
||||
tabs.setSelectedIndex(1);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
loadFrame(new Help(true));
|
||||
}
|
||||
}//GEN-LAST:event_tabsStateChanged
|
||||
|
||||
/**
|
||||
* Adds the given JInternalFrame to the mainPane. Automatically does layout
|
||||
* and sets visible (if show==true).
|
||||
@ -479,7 +488,13 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
}
|
||||
//updateDisplay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the given JInternalFrame to the mainPane. Automatically does layout
|
||||
* and sets visible.
|
||||
*
|
||||
* @param frame The frame
|
||||
*/
|
||||
public static void loadFrame(JInternalFrame frame) {
|
||||
loadFrame(frame, true);
|
||||
}
|
||||
@ -520,7 +535,6 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
//</editor-fold>
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
// Command line args
|
||||
for (String arg : args) {
|
||||
if (arg.equals("skippython")) {
|
||||
@ -530,11 +544,11 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
} else if (arg.equals("quickstart")) {
|
||||
skipPython = true;
|
||||
skipEditor = true;
|
||||
}else {
|
||||
} else {
|
||||
argfile = args[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user