diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class index 3c0b56c..40f2b92 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/GUITestFileTable.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class index 0a3b2f8..35e7e40 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/GUIMenuBar.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java index 2de643e..7edf4be 100644 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java @@ -25,6 +25,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { ArrayList oCheckBoxes; ReadEepromFile oRef; boolean[] bBreakpointSet; + int iTestFileLoaded = 0; //Custom separators because addSeparator(default) looks not nice. JMenuItem oSeparator0; @@ -527,7 +528,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { int iResponse = oFileChooser.showOpenDialog(null); if (iResponse == JFileChooser.APPROVE_OPTION) { oFile = new File(oFileChooser.getSelectedFile().getAbsolutePath()); - System.out.println(oFile); + //System.out.println(oFile); oRef = new ReadEepromFile(); oRef.setData(oFile); oRef.setOPCode(oRef.getData()); @@ -536,6 +537,12 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { int iDataSize = data.size(); ArrayList opcode = oRef.getOPCode(); int iOPCodeSize = opcode.size(); + if (iTestFileLoaded > 0) { + oCheckBoxes = oGUITestFileTable.getCheckboxes(); + for (int i = 0; i < iDataSize; i++) { + oCheckBoxes.get(i).setEnabled(false); + } + } for (int i = 0; i < iDataSize; i++) { for (int j = 0; j < iOPCodeSize; j++) { if (data.get(i).equals(opcode.get(j))) { @@ -548,6 +555,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { bBreakpointSet = new boolean[iOPCodeSize]; oRef.readFileAndWriteToEEPROM(oEnv.getPIC()); oGUIMainFrame.updateWindow(); + iTestFileLoaded = 1; } } diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java index bbcc79f..b58f83d 100644 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java @@ -4,88 +4,124 @@ import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; -import java.awt.Insets; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; +import java.awt.Color; import java.util.ArrayList; import javax.swing.JCheckBox; import javax.swing.JPanel; -import javax.swing.JScrollBar; +import javax.swing.JScrollPane; import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; -public class GUITestFileTable extends JPanel { +public class GUITestFileTable extends JScrollPane { String sLine; ArrayList oCheckboxes = new ArrayList(); + JPanel oTable; + int iTheme = 0; + /** + * Color oWhite = new Color(255, 253, 250); + * Color oDarkGray = new Color(76, 78, 82); + * First Color == TextColor + * Second Color == BackgroundColor + */ + Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82)}; + Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250)}; + + /** + * Constructor which initializes a filler. + */ public GUITestFileTable() { - JTextField oFill = new JTextField("19"); + oTable = new JPanel(); + JTextField oFill = new JTextField("0"); oFill.setEditable(false); - this.setLayout(new GridLayout(1, 3)); - this.add(oFill); - this.add(new JCheckBox()); - oFill = new JTextField("Test"); + JPanel oTestPanel = new JPanel(); + oTestPanel.setLayout(new GridLayout(1, 3)); + oTestPanel.add(oFill); + oTestPanel.add(new JCheckBox()); + oFill = new JTextField("Please load testfile!"); oFill.setEditable(false); - this.add(oFill); + oTestPanel.add(oFill); + this.setViewportView(oTestPanel); } + /** + * Creates scrollable panel which contains information of testfile. + * @param data arraylist which contains the data of the testfile as strings. (testfile has x lines, data has x entries) + */ public void setData(ArrayList data) { - this.removeAll(); - JScrollBar oScrollBar = new JScrollBar(JScrollBar.VERTICAL, 30, 1, 0, 100); - int iNumberOfLines = data.size() + 1; + oTable.removeAll(); //Clear table. + oCheckboxes.clear(); //Clear arraylist containing checkboxes. + + //Component which will include numbers, breakpoints and lines from testfile. JPanel oLines = new JPanel(); - oLines.add(oScrollBar);//TODO oLines.setLayout(new GridBagLayout()); - int iHorizontalCount = 0; - int iVerticalCount = 0; - System.out.println(1); + + //Constraint for position of components at oLines. GridBagConstraints l = new GridBagConstraints(); - l.gridx = iHorizontalCount; - - int iMaxLength = getMaxLen(data); + l.gridx = 0; + int iMaxLength = getMaxLen(data); //MaxLen for displaying line. + int iNumberOfLines = data.size() + 1; + int iVerticalCount = 0; //Variable for adding components to right line. for (int i = 1; i < iNumberOfLines; i++) { - JPanel oPanel = new JPanel(); - oPanel.setLayout(new GridBagLayout()); + //Component which will be filled with three components (represents one line). + JPanel oLine = new JPanel(); + oLine.setLayout(new GridBagLayout()); + //Constraint for position of components at oLine. GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = 0; + c.gridy = 0; //row 0 + c.gridx = 0; //collumn 0 + //Component displays number of testfileline JTextField oNumber = new JTextField(i + "", 3); + oNumber.setForeground(aoLightTheme[0]); + oNumber.setBackground(aoLightTheme[1]); oNumber.setEditable(false); - oPanel.add(oNumber, c); - - c.gridx = 1; + oLine.add(oNumber, c); + c.gridx = 1; //collumn 1 + //Component displays whether breakpoint is set or reset. JCheckBox oCheckbox = new JCheckBox(); oCheckbox.setEnabled(false); oCheckboxes.add(oCheckbox); - oPanel.add(oCheckbox, c); + oLine.add(oCheckbox, c); - c.gridx = 2; - - JTextField oTestLine = new JTextField(data.get(i - 1), iMaxLength); + c.gridx = 2; //collumn 2 + //Component displays comment to specific line. + JTextField oTestLine = new JTextField(data.get(i - 1), (int)(iMaxLength * 0.7)); oTestLine.setEditable(false); - oPanel.add(oTestLine, c); + oLine.add(oTestLine, c); - l.gridy = iVerticalCount; - l.anchor = GridBagConstraints.WEST; - oLines.add(oPanel, l); - iVerticalCount++; + l.gridy = iVerticalCount; //row iVerticalcount + l.anchor = GridBagConstraints.WEST; //Set orientation of elements to left (west) + oLines.add(oLine, l); + iVerticalCount++; //increment for putting next entry at next line. } - System.out.println(iMaxLength); - this.add(oLines); + + oTable.add(oLines); + + this.setPreferredSize(new Dimension(600, 700)); + this.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + this.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + this.setWheelScrollingEnabled(true); + this.getVerticalScrollBar().setUnitIncrement(16); + this.setViewportView(oTable); } + /** + * @returns ArrayList containing all checkboxes which represent the breakpoints at testfile. + */ public ArrayList getCheckboxes() { return oCheckboxes; } + /** + * @param data ArrayList to check. + * @returns length of longest string at ArrayList. + */ private int getMaxLen(ArrayList data) { int iSize = data.size(); int iMaxLength = 0; @@ -96,4 +132,36 @@ public class GUITestFileTable extends JPanel { } return iMaxLength; } -} + + public void setDarkTheme() { + iTheme = 1; + } + + public void setLightTheme() { + iTheme = 0; + } + + public void markLine(int iLineToMark) { + + } + + public void unmarkLine(int iLineToUnmark) { + + } + + /** + * @return Color to set for testfiletable + */ + private Color[] getTheme() { + Color[] oReturnColor = {new Color(76, 78, 82), new Color(255, 253, 250)}; + switch (iTheme) { + case 0: { + oReturnColor = aoLightTheme; + }break; + case 1: { + oReturnColor = aoDarkTheme; + }break; + } + return oReturnColor; + } +} \ No newline at end of file