diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class index a75ef31..62b7380 100644 Binary files a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class index 40f2b92..abb673a 100644 Binary files a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.class new file mode 100644 index 0000000..efbf367 Binary files /dev/null and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class index 35e7e40..dd8ed34 100644 Binary files a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class differ diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java index 59c2cb7..df7190d 100755 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java @@ -37,7 +37,6 @@ public class GUIMainFrame extends JFrame { ImageIcon guiLogo = new ImageIcon("./images/gui_logo.png"); // create an ImageIcon this.setIconImage(guiLogo.getImage()); // change icon of frame - Color guiBackgroundColor = new Color(255, 255, 255); // 0xFFFFFF || 0, 0, 0 //this.getContentPane().setBackground(Color.green); //change color of background //JLabel text = new JLabel(); // create label, passing of text at constructor possible @@ -64,8 +63,16 @@ public class GUIMainFrame extends JFrame { GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; //next added element will be in column 1 c.gridy = 0; //next added element will be in row 1 - c.insets = new Insets(1,1,1,1); + c.insets = new Insets(10,10,10,10); this.add(oGUITestFileTable, c); + + int[] aiRegisters = {1, 2, 3, 4, 5, 6, 7, 8 ,9}; + + GUIRegisters oGUIRegisters = new GUIRegisters(); + + c.gridx = 1; + this.add(oGUIRegisters); + updateWindow(); } diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java index 7edf4be..08ee6f7 100644 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java @@ -363,11 +363,13 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { if (e.getSource() == oDarkTheme) { System.out.println("It's gettin dark brooo"); //TODO setTheme(aoDarkTheme[0], aoDarkTheme[1]); + oGUITestFileTable.setTheme(1); } //Change to light theme if (e.getSource() == oLightTheme) { System.out.println("Death to all vampires!"); //TODO setTheme(aoLightTheme[0], aoLightTheme[1]); + oGUITestFileTable.setTheme(0); } //Microcontroller @@ -560,18 +562,19 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { } private void controlBreakpoints(ActionEvent e) { - int iOPCode = oRef.getOPCode().size(); - - if (iOPCode > 0) { - for (int i = 0; i < oCheckBoxes.size(); i++) { - if (e.getSource() == oCheckBoxes.get(i)) { - for (int j = 0; j < iOPCode; j++) { - if (oRef.getOPCode().get(j).equals(oRef.getData().get(i))) { - bBreakpointSet[j] = !bBreakpointSet[j]; - if (bBreakpointSet[j]) - System.out.println("Breakpoint " + j + " got set."); - else - System.out.println("Breakpoint " + j + " got reset."); + if (oRef != null) { + int iOPCode = oRef.getOPCode().size(); + if (iOPCode > 0) { + for (int i = 0; i < oCheckBoxes.size(); i++) { + if (e.getSource() == oCheckBoxes.get(i)) { + for (int j = 0; j < iOPCode; j++) { + if (oRef.getOPCode().get(j).equals(oRef.getData().get(i))) { + bBreakpointSet[j] = !bBreakpointSet[j]; + if (bBreakpointSet[j]) + System.out.println("Breakpoint " + j + " got set."); + else + System.out.println("Breakpoint " + j + " got reset."); + } } } } diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.java new file mode 100644 index 0000000..3dd11b9 --- /dev/null +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.java @@ -0,0 +1,201 @@ +package Frontend.PIC_SIMULATOR_GUI_JAVA; + +import java.awt.GridBagLayout; +import java.util.ArrayList; +import java.awt.GridBagConstraints; + +import javax.swing.JPanel; +import javax.swing.JTextField; + +public class GUIRegisters extends JPanel { + + ArrayList oTextfields = new ArrayList(); + ArrayList oPanels = new ArrayList(); + + JPanel oTopComponentPanel = new JPanel(); + JPanel oLeftComponentPanel = new JPanel(); + JPanel oRightComponentPanel = new JPanel(); + + JTextField oTextSFR = new JTextField("SFR", 22); + + JTextField oTextPCL = new JTextField("PCL", 22); + JTextField oTextPCLATH = new JTextField("PCLATH", 22); + JTextField oTextPCIntern = new JTextField("PC intern", 22); + JTextField oTextStatus = new JTextField("STATUS", 22); + JTextField oTextFileSelectionRegister = new JTextField("FileSelectionRegister", 22); + JTextField oTextOption = new JTextField("OPTION", 22); + JTextField oTextPrescaler = new JTextField("Prescaler", 22); + JTextField oTextTMR0 = new JTextField("TMR0", 22); + + JTextField oValuePCL = new JTextField("00", 2); + JTextField oValuePCLATH = new JTextField("00", 2); + JTextField oValuePCIntern = new JTextField("00", 2); + JTextField oValueStatus = new JTextField("00", 2); + JTextField oValueFileSearchRegister = new JTextField("00", 2); + JTextField oValueOption = new JTextField("00", 2); + JTextField oValuePrescaler = new JTextField("00", 2); + JTextField oValueTMR0 = new JTextField("00", 2); + + JPanel oBottomComponentPanel1 = new JPanel(); + JPanel oBottomComponentPanel2 = new JPanel(); + + + JTextField oTextW = new JTextField("W", 22); + + JTextField oTextWRegister = new JTextField("W-Register", 22); + + JTextField oValueWRegister = new JTextField("00", 2); + + public GUIRegisters() { + //9 + /** + * [0] W-Register + * [1] PCL + * [2] PCLATH + * [3] PC intern + * [4] Status + * [5] FSR FileSelectionRegister + * [6] Option + * [7] Vorteiler + * [8] TMR0 + */ + addComponentsToLists(); + setEditFalse(); + buildGUIRegisters(); + } + + private void buildGUIRegisters() { + GridBagConstraints oConstraints = new GridBagConstraints(); + + oTopComponentPanel.setLayout(new GridBagLayout()); + oLeftComponentPanel.setLayout(new GridBagLayout()); + oRightComponentPanel.setLayout(new GridBagLayout()); + + oBottomComponentPanel1.setLayout(new GridBagLayout()); + oBottomComponentPanel2.setLayout(new GridBagLayout()); + + this.setLayout(new GridBagLayout()); + + //Fill top component panel + oConstraints.gridx = 0; + oConstraints.gridy = 0; + oConstraints.anchor = GridBagConstraints.WEST; + oTopComponentPanel.add(oTextSFR, oConstraints); + + //Fill left side of left component panel + oLeftComponentPanel.add(oTextPCL, oConstraints); + oConstraints.gridy = 1; + oLeftComponentPanel.add(oTextPCLATH, oConstraints); + oConstraints.gridy = 2; + oLeftComponentPanel.add(oTextPCIntern, oConstraints); + oConstraints.gridy = 3; + oLeftComponentPanel.add(oTextStatus, oConstraints); + + //Fill right side of left component panel + oConstraints.gridx = 1; + oConstraints.gridy = 0; + oConstraints.anchor = GridBagConstraints.EAST; + oLeftComponentPanel.add(oValuePCL, oConstraints); + oConstraints.gridy = 1; + oLeftComponentPanel.add(oValuePCLATH, oConstraints); + oConstraints.gridy = 2; + oLeftComponentPanel.add(oValuePCIntern, oConstraints); + oConstraints.gridy = 3; + oLeftComponentPanel.add(oValueStatus, oConstraints); + + //Fill left side of right component panel + oConstraints.gridx = 0; + oConstraints.gridy = 0; + oConstraints.anchor = GridBagConstraints.WEST; + oRightComponentPanel.add(oTextFileSelectionRegister, oConstraints); + oConstraints.gridy = 1; + oRightComponentPanel.add(oTextOption, oConstraints); + oConstraints.gridy = 2; + oRightComponentPanel.add(oTextPrescaler, oConstraints); + oConstraints.gridy = 3; + oRightComponentPanel.add(oTextTMR0, oConstraints); + + //Fill right side of right component panel + oConstraints.gridx = 1; + oConstraints.gridy = 0; + oConstraints.anchor = GridBagConstraints.EAST; + oRightComponentPanel.add(oValueFileSearchRegister, oConstraints); + oConstraints.gridy = 1; + oRightComponentPanel.add(oValueOption, oConstraints); + oConstraints.gridy = 2; + oRightComponentPanel.add(oValuePrescaler, oConstraints); + oConstraints.gridy = 3; + oRightComponentPanel.add(oValueTMR0, oConstraints); + + //Fill 1st bottom component panel + oConstraints.anchor = GridBagConstraints.WEST; + oConstraints.gridx = 0; + oConstraints.gridy = 0; + oBottomComponentPanel1.add(oTextW, oConstraints); + + //Fill 2nd bottom component panel + oBottomComponentPanel2.add(oTextWRegister, oConstraints); + oConstraints.anchor = GridBagConstraints.EAST; + oConstraints.gridx = 1; + oBottomComponentPanel2.add(oValueWRegister, oConstraints); + + //Fill this panel + oConstraints.anchor = GridBagConstraints.WEST; + oConstraints.gridx = 0; + oConstraints.gridy = 0; + this.add(oTopComponentPanel, oConstraints); + oConstraints.gridy = 1; + this.add(oLeftComponentPanel, oConstraints); + oConstraints.gridx = 1; + this.add(oRightComponentPanel, oConstraints); + oConstraints.gridx = 0; + oConstraints.gridy = 2; + this.add(oBottomComponentPanel1, oConstraints); + oConstraints.gridy = 3; + this.add(oBottomComponentPanel2, oConstraints); + } + + /** + * + */ + private void addComponentsToLists() { + oTextfields.add(oTextSFR); + oTextfields.add(oTextPCL); + oTextfields.add(oTextPCLATH); + oTextfields.add(oTextPCIntern); + oTextfields.add(oTextStatus); + oTextfields.add(oTextFileSelectionRegister); + oTextfields.add(oTextOption); + oTextfields.add(oTextPrescaler); + oTextfields.add(oTextTMR0); + oTextfields.add(oTextW); + oTextfields.add(oTextWRegister); + + oTextfields.add(oValuePCL); + oTextfields.add(oValuePCLATH); + //TODO + } + + /** + * + */ + private void setEditFalse() { + //TODO + } + + /** + * + * @param iThemeNr + */ + public void setTheme(int iThemeNr) { + //TODO + } + + /** + * + * @param aiRegisters + */ + public void setRegisters(int[] aiRegisters) { + //TODO + } +} \ No newline at end of file diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java index b58f83d..525e88e 100644 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java @@ -5,9 +5,9 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Color; - import java.util.ArrayList; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -16,33 +16,57 @@ import javax.swing.ScrollPaneConstants; public class GUITestFileTable extends JScrollPane { String sLine; + ArrayList oLineInformation = new ArrayList(); ArrayList oCheckboxes = new ArrayList(); + ArrayList oPanels = new ArrayList(); JPanel oTable; int iTheme = 0; + boolean bFileLoaded = false; /** * Color oWhite = new Color(255, 253, 250); * Color oDarkGray = new Color(76, 78, 82); + * Color oDarkGrayB = new Color(47, 47, 47); + * Color oLightBlue = new Color(173, 216, 230); + * Color oOrangeDM = new Color(255, 170, 0); + * Color oLightBlueDM = new Color(0, 213, 255); + * Color oOrangeDMB = new Color(255, 85, 0); * First Color == TextColor * Second Color == BackgroundColor + * Third Color == BorderColor + * Fourth Color == TextColor Marked + * Fifth Color == BackgroundColor Marked + * Sixth Color == BorderColor Marked */ - Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82)}; - Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250)}; + Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)}; + Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)}; /** * Constructor which initializes a filler. */ public GUITestFileTable() { oTable = new JPanel(); + oPanels.add(oTable); JTextField oFill = new JTextField("0"); + oLineInformation.add(oFill); oFill.setEditable(false); + JPanel oTestPanel = new JPanel(); + oPanels.add(oTestPanel); oTestPanel.setLayout(new GridLayout(1, 3)); oTestPanel.add(oFill); - oTestPanel.add(new JCheckBox()); + + JCheckBox oCheckbox = new JCheckBox(); + JPanel oCheckBoxPanel = new JPanel(); + oCheckBoxPanel.add(oCheckbox); + oPanels.add(oCheckBoxPanel); + oTestPanel.add(oCheckBoxPanel); + oCheckboxes.add(oCheckbox); oFill = new JTextField("Please load testfile!"); oFill.setEditable(false); + oLineInformation.add(oFill); oTestPanel.add(oFill); + this.setViewportView(oTestPanel); } @@ -53,9 +77,11 @@ public class GUITestFileTable extends JScrollPane { public void setData(ArrayList data) { oTable.removeAll(); //Clear table. oCheckboxes.clear(); //Clear arraylist containing checkboxes. + oLineInformation.clear(); //clear arraylist containing references to informationfields. //Component which will include numbers, breakpoints and lines from testfile. JPanel oLines = new JPanel(); + oPanels.add(oLines); oLines.setLayout(new GridBagLayout()); //Constraint for position of components at oLines. @@ -68,6 +94,7 @@ public class GUITestFileTable extends JScrollPane { for (int i = 1; i < iNumberOfLines; i++) { //Component which will be filled with three components (represents one line). JPanel oLine = new JPanel(); + oPanels.add(oLine); oLine.setLayout(new GridBagLayout()); //Constraint for position of components at oLine. @@ -77,6 +104,7 @@ public class GUITestFileTable extends JScrollPane { c.gridx = 0; //collumn 0 //Component displays number of testfileline JTextField oNumber = new JTextField(i + "", 3); + oLineInformation.add(oNumber); //refernce for changing color mode oNumber.setForeground(aoLightTheme[0]); oNumber.setBackground(aoLightTheme[1]); oNumber.setEditable(false); @@ -91,7 +119,8 @@ public class GUITestFileTable extends JScrollPane { c.gridx = 2; //collumn 2 //Component displays comment to specific line. - JTextField oTestLine = new JTextField(data.get(i - 1), (int)(iMaxLength * 0.7)); + JTextField oTestLine = new JTextField(data.get(i - 1), (int)(iMaxLength * 0.6)); + oLineInformation.add(oTestLine); //reference for changing color mode oTestLine.setEditable(false); oLine.add(oTestLine, c); @@ -109,6 +138,7 @@ public class GUITestFileTable extends JScrollPane { this.setWheelScrollingEnabled(true); this.getVerticalScrollBar().setUnitIncrement(16); this.setViewportView(oTable); + setTheme(iTheme); } /** @@ -133,27 +163,63 @@ public class GUITestFileTable extends JScrollPane { return iMaxLength; } - public void setDarkTheme() { - iTheme = 1; + /** + * Changes Foreground, Background and Border-Color of testfiletable compponents + * @param iThemeNr 0 Light Theme, 1 Dark Theme + */ + public void setTheme(int iThemeNr) { + iTheme = iThemeNr; + + for (int i = 0; i < oLineInformation.size(); i++) { + oLineInformation.get(i).setForeground(getThemeColor()[0]); + oLineInformation.get(i).setBackground(getThemeColor()[1]); + oLineInformation.get(i).setBorder(BorderFactory.createLineBorder(getThemeColor()[2])); + } + for (int i = 0; i < oCheckboxes.size(); i++) { + oCheckboxes.get(i).setForeground(getThemeColor()[0]); + oCheckboxes.get(i).setBackground(getThemeColor()[1]); + oCheckboxes.get(i).setBorder(BorderFactory.createLineBorder(getThemeColor()[2])); + } + for (int i = 0; i < oPanels.size(); i++) { + oPanels.get(i).setForeground(getThemeColor()[0]); + oPanels.get(i).setBackground(getThemeColor()[1]); + } + + oTable.setForeground(getThemeColor()[0]); + oTable.setBackground(getThemeColor()[1]); + this.setForeground(getThemeColor()[0]); + this.setBackground(getThemeColor()[1]); } - public void setLightTheme() { - iTheme = 0; + /** + * Mark line at testfiletable. + * @param iLineToMark + */ + public void markLine(int iLineToMark) { //TODO + if (iLineToMark > -1) { + oLineInformation.get(iLineToMark).setForeground(getThemeColor()[3]); + oLineInformation.get(iLineToMark).setBackground(getThemeColor()[4]); + oLineInformation.get(iLineToMark).setBorder(BorderFactory.createLineBorder(getThemeColor()[5])); + } } - public void markLine(int iLineToMark) { - - } - - public void unmarkLine(int iLineToUnmark) { - + /** + * Unmark line at testfiletable. + * @param iLineToUnmark + */ + public void unmarkLine(int iLineToUnmark) { //TODO + if (iLineToUnmark > -1) { + oLineInformation.get(iLineToUnmark).setForeground(getThemeColor()[0]); + oLineInformation.get(iLineToUnmark).setBackground(getThemeColor()[1]); + oLineInformation.get(iLineToUnmark).setBorder(BorderFactory.createLineBorder(getThemeColor()[2])); + } } /** * @return Color to set for testfiletable */ - private Color[] getTheme() { - Color[] oReturnColor = {new Color(76, 78, 82), new Color(255, 253, 250)}; + private Color[] getThemeColor() { + Color[] oReturnColor = aoLightTheme; switch (iTheme) { case 0: { oReturnColor = aoLightTheme;