Add About window when SyMAT logo is clicked on Ribbon

master
skylarmt 10 years ago
parent 9c4648f304
commit f8a2e0de7e

@ -15,6 +15,7 @@
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties> </SyntheticProperties>
<Events> <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"/> <EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
</Events> </Events>
<AuxValues> <AuxValues>

@ -30,7 +30,7 @@ package net.apocalypselabs.symat;
import java.awt.Color; import java.awt.Color;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; 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 { 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 * Creates new form Help
*/ */
@ -46,49 +49,74 @@ public class Help extends javax.swing.JInternalFrame {
loadTheme(); 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() { private void loadTheme() {
if (PrefStorage.getSetting("theme").equals("dark")) { if (PrefStorage.getSetting("theme").equals("dark")) {
setBackgroundOfBrowser(Color.BLACK);
setBackgroundOfBrowser(Color.WHITE);
topicList.setBackground(Color.BLACK); topicList.setBackground(Color.BLACK);
topicList.setForeground(Color.WHITE); topicList.setForeground(Color.WHITE);
setBackground(Color.DARK_GRAY); setBackground(Color.DARK_GRAY);
} else { } else {
setBackgroundOfBrowser(Color.WHITE);
setBackgroundOfBrowser(Color.BLACK);
topicList.setBackground(Color.WHITE); topicList.setBackground(Color.WHITE);
topicList.setForeground(Color.BLACK); topicList.setForeground(Color.BLACK);
setBackground(Color.LIGHT_GRAY); 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) { public void loadTopic(String name) {
try { if (name.equals("about")) {
String text = ""; String text = "<html><head><title>About SyMAT</title></head>"
BufferedReader reader = new BufferedReader( + "<body>"
new InputStreamReader( + "<h1>About</h1>"
CodeRunner.class + "<p>This is SyMAT version "
.getResourceAsStream("help/" + name + ".html"))); + MainGUI.VERSION_NAME + " (" + (int)MainGUI.APP_CODE + ")."
String line; + "</p>"
while ((line = reader.readLine()) != null) { + "<p>SyMAT is copyright &copy; "
text += line; + 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.setText(text);
topicBrowser.setCaretPosition(0); topicBrowser.setCaretPosition(0);
setTitle("Manual (" + topicList.getSelectedValue().toString() + ")"); setTitle("About SyMAT");
} catch (Exception e) { } else {
//JOptionPane.showInternalMessageDialog(MainGUI.mainPane, try {
//"Error: Cannot load help topic "+name+".\n\n"+e.getMessage()); String text = "";
topicBrowser.setText("<html><head></head><body><p><b>Error:</b><br>Cannot get help topic \"" BufferedReader reader = new BufferedReader(
+ name + "\".<br>(" + e.getMessage() + ")</p></body></html>"); 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"); setTitle("Manual");
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/help.png"))); // NOI18N setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/help.png"))); // NOI18N
addComponentListener(new java.awt.event.ComponentAdapter() { addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent evt) {
formComponentResized(evt);
}
public void componentShown(java.awt.event.ComponentEvent evt) { public void componentShown(java.awt.event.ComponentEvent evt) {
formComponentShown(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 private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
topicList.setSelectedIndex(0); topicList.setSelectedIndex(0);
loadTopic("welcome"); if (topicOnLoad) {
loadTopic("welcome");
}
}//GEN-LAST:event_formComponentShown }//GEN-LAST:event_formComponentShown
private void topicListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topicListMouseClicked private void topicListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topicListMouseClicked
loadTheme(); loadTheme();
}//GEN-LAST:event_topicListMouseClicked }//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 // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane2;

@ -55,9 +55,9 @@
<Property name="selectedIndex" type="int" value="1"/> <Property name="selectedIndex" type="int" value="1"/>
<Property name="opaque" type="boolean" value="true"/> <Property name="opaque" type="boolean" value="true"/>
</Properties> </Properties>
<AuxValues> <Events>
<AuxValue name="JavaCodeGenerator_allCodePost" type="java.lang.String" value="tabs.setEnabledAt(0, false);"/> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="tabsStateChanged"/>
</AuxValues> </Events>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents> <SubComponents>

@ -46,8 +46,8 @@ import javax.swing.JInternalFrame;
public class MainGUI extends javax.swing.JFrame { public class MainGUI extends javax.swing.JFrame {
public static final String APP_NAME = "SyMAT 0.8"; public static final String APP_NAME = "SyMAT 0.8";
public static final double APP_CODE = 8; public static final double APP_CODE = 9;
public static final String VERSION_NAME = "0.8"; public static final String VERSION_NAME = "0.8.2";
public static String argfile = ""; public static String argfile = "";
public static boolean skipPython = false; // Skip python init on start? public static boolean skipPython = false; // Skip python init on start?
public static boolean skipEditor = false; // Skip editor init on start? public static boolean skipEditor = false; // Skip editor init on start?
@ -182,6 +182,11 @@ public class MainGUI extends javax.swing.JFrame {
tabs.setBackground(new Color(240,240,240)); tabs.setBackground(new Color(240,240,240));
tabs.setOpaque(true); tabs.setOpaque(true);
tabs.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
tabsStateChanged(evt);
}
});
jPanel4.setFocusable(false); jPanel4.setFocusable(false);
jPanel4.setLayout(null); jPanel4.setLayout(null);
@ -398,24 +403,19 @@ public class MainGUI extends javax.swing.JFrame {
.addComponent(mainPane)) .addComponent(mainPane))
); );
tabs.setEnabledAt(0, false);
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void shellBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shellBtnActionPerformed private void shellBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shellBtnActionPerformed
Interpreter i = new Interpreter(); loadFrame(new Interpreter());
loadFrame(i);
}//GEN-LAST:event_shellBtnActionPerformed }//GEN-LAST:event_shellBtnActionPerformed
private void editorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editorBtnActionPerformed private void editorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editorBtnActionPerformed
CodeEditor e = new CodeEditor(); loadFrame(new CodeEditor());
loadFrame(e);
}//GEN-LAST:event_editorBtnActionPerformed }//GEN-LAST:event_editorBtnActionPerformed
private void graphBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graphBtnActionPerformed private void graphBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graphBtnActionPerformed
Graph g = new Graph(); loadFrame(new Graph());
loadFrame(g);
}//GEN-LAST:event_graphBtnActionPerformed }//GEN-LAST:event_graphBtnActionPerformed
private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown 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 }//GEN-LAST:event_formComponentShown
private void helpBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpBtnActionPerformed private void helpBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpBtnActionPerformed
Help h = new Help(); loadFrame(new Help());
loadFrame(h);
}//GEN-LAST:event_helpBtnActionPerformed }//GEN-LAST:event_helpBtnActionPerformed
private void arrangeWindowsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_arrangeWindowsBtnActionPerformed 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 }//GEN-LAST:event_arrangeWindowsBtnActionPerformed
private void displaySettingsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displaySettingsBtnActionPerformed private void displaySettingsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displaySettingsBtnActionPerformed
Display d = new Display(); loadFrame(new Display());
loadFrame(d);
}//GEN-LAST:event_displaySettingsBtnActionPerformed }//GEN-LAST:event_displaySettingsBtnActionPerformed
private void closeAllBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeAllBtnActionPerformed 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 }//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 * Adds the given JInternalFrame to the mainPane. Automatically does layout
* and sets visible (if show==true). * and sets visible (if show==true).
@ -480,6 +489,12 @@ public class MainGUI extends javax.swing.JFrame {
//updateDisplay(); //updateDisplay();
} }
/**
* Adds the given JInternalFrame to the mainPane. Automatically does layout
* and sets visible.
*
* @param frame The frame
*/
public static void loadFrame(JInternalFrame frame) { public static void loadFrame(JInternalFrame frame) {
loadFrame(frame, true); loadFrame(frame, true);
} }
@ -520,7 +535,6 @@ public class MainGUI extends javax.swing.JFrame {
//</editor-fold> //</editor-fold>
//</editor-fold> //</editor-fold>
// Command line args // Command line args
for (String arg : args) { for (String arg : args) {
if (arg.equals("skippython")) { if (arg.equals("skippython")) {
@ -530,7 +544,7 @@ public class MainGUI extends javax.swing.JFrame {
} else if (arg.equals("quickstart")) { } else if (arg.equals("quickstart")) {
skipPython = true; skipPython = true;
skipEditor = true; skipEditor = true;
}else { } else {
argfile = args[0]; argfile = args[0];
} }
} }

Loading…
Cancel
Save