Make theme update on visible windows, add key shortcuts for ribbon
This commit is contained in:
parent
d2b816b41b
commit
67d4b6d082
@ -169,6 +169,9 @@
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
@ -266,6 +269,9 @@
|
||||
<Property name="rows" type="int" value="3"/>
|
||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="outputBoxMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
|
@ -81,18 +81,8 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
}
|
||||
codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size));
|
||||
outputBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size));
|
||||
|
||||
if (PrefStorage.getSetting("theme").equals("dark")) {
|
||||
outputBox.setBackground(new Color(41,49,52));
|
||||
outputBox.setForeground(Color.WHITE);
|
||||
setBackground(Color.DARK_GRAY);
|
||||
setEditorTheme("dark");
|
||||
} else {
|
||||
outputBox.setBackground(Color.WHITE);
|
||||
outputBox.setForeground(Color.BLACK);
|
||||
setBackground(Color.LIGHT_GRAY);
|
||||
setEditorTheme("default");
|
||||
}
|
||||
|
||||
loadTheme();
|
||||
|
||||
codeBox.setCodeFoldingEnabled(true);
|
||||
codeBox.setAntiAliasingEnabled(true);
|
||||
@ -100,6 +90,12 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
sp = new RTextScrollPane(codeBox);
|
||||
sp.setFoldIndicatorEnabled(true);
|
||||
editPanel.add(sp);
|
||||
codeBox.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
formMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
sp.setVisible(true);
|
||||
codeBox.setVisible(true);
|
||||
codeBox.requestFocus();
|
||||
@ -114,6 +110,20 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTheme() {
|
||||
if (PrefStorage.getSetting("theme").equals("dark")) {
|
||||
outputBox.setBackground(new Color(41, 49, 52));
|
||||
outputBox.setForeground(Color.WHITE);
|
||||
setBackground(Color.DARK_GRAY);
|
||||
setEditorTheme("dark");
|
||||
} else {
|
||||
outputBox.setBackground(Color.WHITE);
|
||||
outputBox.setForeground(Color.BLACK);
|
||||
setBackground(Color.LIGHT_GRAY);
|
||||
setEditorTheme("default");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -165,6 +175,11 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/editor.png"))); // NOI18N
|
||||
setMinimumSize(new java.awt.Dimension(125, 50));
|
||||
setPreferredSize(new java.awt.Dimension(550, 375));
|
||||
addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
formMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jSplitPane1.setDividerLocation(200);
|
||||
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
@ -177,6 +192,11 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
outputBox.setLineWrap(true);
|
||||
outputBox.setRows(3);
|
||||
outputBox.setWrapStyleWord(true);
|
||||
outputBox.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
outputBoxMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(outputBox);
|
||||
|
||||
javax.swing.GroupLayout outputPanelLayout = new javax.swing.GroupLayout(outputPanel);
|
||||
@ -444,6 +464,14 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON);
|
||||
}//GEN-LAST:event_pythonOptionActionPerformed
|
||||
|
||||
private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
|
||||
loadTheme();
|
||||
}//GEN-LAST:event_formMouseClicked
|
||||
|
||||
private void outputBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_outputBoxMouseClicked
|
||||
formMouseClicked(evt);
|
||||
}//GEN-LAST:event_outputBoxMouseClicked
|
||||
|
||||
private void saveFile(String content, String path)
|
||||
throws IOException {
|
||||
try (PrintStream out = new PrintStream(new FileOutputStream(path))) {
|
||||
|
@ -48,4 +48,10 @@ public class Debug {
|
||||
System.err.println(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stacktrace(Exception e) {
|
||||
if (DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,7 @@
|
||||
<Property name="selectedIndex" type="int" value="0"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="topicListMouseClicked"/>
|
||||
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="topicListValueChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
|
@ -43,6 +43,10 @@ public class Help extends javax.swing.JInternalFrame {
|
||||
*/
|
||||
public Help() {
|
||||
initComponents();
|
||||
loadTheme();
|
||||
}
|
||||
|
||||
private void loadTheme() {
|
||||
if (PrefStorage.getSetting("theme").equals("dark")) {
|
||||
setBackgroundOfBrowser(Color.BLACK);
|
||||
setBackgroundOfBrowser(Color.WHITE);
|
||||
@ -57,13 +61,13 @@ public class Help extends javax.swing.JInternalFrame {
|
||||
setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setBackgroundOfBrowser(Color c) {
|
||||
UIDefaults defaults = new UIDefaults();
|
||||
/*UIDefaults defaults = new UIDefaults();
|
||||
defaults.put("EditorPane.backgroundPainter", c);
|
||||
topicBrowser.putClientProperty("Nimbus.Overrides", defaults);
|
||||
topicBrowser.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
|
||||
topicBrowser.setBackground(c);
|
||||
topicBrowser.setBackground(c);*/
|
||||
}
|
||||
|
||||
public void loadTopic(String name) {
|
||||
@ -126,6 +130,11 @@ public class Help extends javax.swing.JInternalFrame {
|
||||
});
|
||||
topicList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
topicList.setSelectedIndex(0);
|
||||
topicList.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
topicListMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
topicList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||||
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
|
||||
topicListValueChanged(evt);
|
||||
@ -165,6 +174,10 @@ public class Help extends javax.swing.JInternalFrame {
|
||||
loadTopic("welcome");
|
||||
}//GEN-LAST:event_formComponentShown
|
||||
|
||||
private void topicListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topicListMouseClicked
|
||||
loadTheme();
|
||||
}//GEN-LAST:event_topicListMouseClicked
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
|
@ -68,6 +68,9 @@
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
@ -131,6 +134,9 @@
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="mainBoxMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="DefaultCaret caret = (DefaultCaret)mainBox.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);"/>
|
||||
</AuxValues>
|
||||
@ -139,6 +145,7 @@
|
||||
</Container>
|
||||
<Component class="javax.swing.JTextField" name="inputBox">
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="inputBoxMouseClicked"/>
|
||||
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputBoxKeyPressed"/>
|
||||
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputBoxKeyTyped"/>
|
||||
</Events>
|
||||
@ -148,6 +155,7 @@
|
||||
<Property name="text" type="java.lang.String" value="Run"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="runBtnMouseClicked"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="runBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
|
@ -76,19 +76,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
inputBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size));
|
||||
|
||||
// Set theme
|
||||
if (PrefStorage.getSetting("theme").equals("dark")) {
|
||||
mainBox.setBackground(new Color(41,49,52));
|
||||
mainBox.setForeground(Color.WHITE);
|
||||
inputBox.setBackground(new Color(41,49,52));
|
||||
inputBox.setForeground(Color.WHITE);
|
||||
setBackground(Color.DARK_GRAY);
|
||||
} else {
|
||||
mainBox.setBackground(Color.WHITE);
|
||||
mainBox.setForeground(Color.BLACK);
|
||||
inputBox.setBackground(Color.WHITE);
|
||||
inputBox.setForeground(Color.BLACK);
|
||||
setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
loadTheme();
|
||||
|
||||
// Misc. setup
|
||||
mainBox.setText(">>");
|
||||
@ -127,6 +115,11 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
setResizable(true);
|
||||
setTitle("Shell");
|
||||
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/shell.png"))); // NOI18N
|
||||
addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
formMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
mainBox.setEditable(false);
|
||||
mainBox.setColumns(20);
|
||||
@ -138,8 +131,18 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
mainBox.setWrapStyleWord(true);
|
||||
DefaultCaret caret = (DefaultCaret)mainBox.getCaret();
|
||||
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
|
||||
mainBox.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
mainBoxMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(mainBox);
|
||||
|
||||
inputBox.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
inputBoxMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
inputBox.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyPressed(java.awt.event.KeyEvent evt) {
|
||||
inputBoxKeyPressed(evt);
|
||||
@ -150,6 +153,11 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
});
|
||||
|
||||
runBtn.setText("Run");
|
||||
runBtn.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
runBtnMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
runBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
runBtnActionPerformed(evt);
|
||||
@ -228,6 +236,22 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
doRunCode();
|
||||
}//GEN-LAST:event_runBtnActionPerformed
|
||||
|
||||
private void loadTheme() {
|
||||
if (PrefStorage.getSetting("theme").equals("dark")) {
|
||||
mainBox.setBackground(new Color(41,49,52));
|
||||
mainBox.setForeground(Color.WHITE);
|
||||
inputBox.setBackground(new Color(41,49,52));
|
||||
inputBox.setForeground(Color.WHITE);
|
||||
setBackground(Color.DARK_GRAY);
|
||||
} else {
|
||||
mainBox.setBackground(Color.WHITE);
|
||||
mainBox.setForeground(Color.BLACK);
|
||||
inputBox.setBackground(Color.WHITE);
|
||||
inputBox.setForeground(Color.BLACK);
|
||||
setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
private void inputBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputBoxKeyTyped
|
||||
if (evt.getKeyChar() == '\n') {
|
||||
doRunCode();
|
||||
@ -282,6 +306,22 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
}
|
||||
}//GEN-LAST:event_pythonMenuActionPerformed
|
||||
|
||||
private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
|
||||
loadTheme();
|
||||
}//GEN-LAST:event_formMouseClicked
|
||||
|
||||
private void mainBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainBoxMouseClicked
|
||||
formMouseClicked(evt);
|
||||
}//GEN-LAST:event_mainBoxMouseClicked
|
||||
|
||||
private void inputBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_inputBoxMouseClicked
|
||||
formMouseClicked(evt);
|
||||
}//GEN-LAST:event_inputBoxMouseClicked
|
||||
|
||||
private void runBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_runBtnMouseClicked
|
||||
formMouseClicked(evt);
|
||||
}//GEN-LAST:event_runBtnMouseClicked
|
||||
|
||||
private void doRunCode() {
|
||||
String code = inputBox.getText();
|
||||
mainBox.append(" " + code + "\n");
|
||||
|
@ -29,6 +29,7 @@ package net.apocalypselabs.symat;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@ -37,6 +38,7 @@ import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -76,8 +78,10 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
} catch (IOException | NumberFormatException e) {
|
||||
System.err.println("Fail: Cannot check update server. \n"
|
||||
+ " Assuming local copy up-to-date.");
|
||||
e.printStackTrace();
|
||||
Debug.stacktrace(e);
|
||||
}
|
||||
|
||||
setButtonShortcuts();
|
||||
|
||||
// Open shell unless prog was run with argument
|
||||
if (argfile.equals("")) {
|
||||
@ -92,6 +96,19 @@ public class MainGUI extends javax.swing.JFrame {
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set keyboard shortcuts for buttons.
|
||||
*/
|
||||
private void setButtonShortcuts() {
|
||||
shellBtn.setMnemonic(KeyEvent.VK_S);
|
||||
editorBtn.setMnemonic(KeyEvent.VK_D);
|
||||
graphBtn.setMnemonic(KeyEvent.VK_G);
|
||||
helpBtn.setMnemonic(KeyEvent.VK_M);
|
||||
tabs.setMnemonicAt(1, KeyEvent.VK_A);
|
||||
tabs.setMnemonicAt(2, KeyEvent.VK_T);
|
||||
tabs.setMnemonicAt(3, KeyEvent.VK_E);
|
||||
}
|
||||
|
||||
/**
|
||||
* (Re)load display settings.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user