diff --git a/src/main/java/ui/window/JDialogCPUNode.java b/src/main/java/ui/window/JDialogCPUNode.java index df322946a47f7807cb3f02e73beae002967d8c32..e600b66a25c1cf9f5f363912705dfd284ed237fc 100644 --- a/src/main/java/ui/window/JDialogCPUNode.java +++ b/src/main/java/ui/window/JDialogCPUNode.java @@ -41,6 +41,7 @@ package ui.window; +import cli.Action; import myutil.GraphicLib; import tmltranslator.modelcompiler.ArchUnitMEC; import ui.ColorManager; @@ -51,7 +52,6 @@ import ui.tmldd.TMLArchiCPUNode; import javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.awt.image.BufferedImage; import java.math.BigDecimal; import java.util.*; import java.util.List; @@ -92,7 +92,6 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { //issue 183 List<JTextArea> instructionHelpList; List<JButton> buttons; - int index; /* Creates new form */ public JDialogCPUNode(Frame _frame, String _title, TMLArchiCPUNode _node, ArchUnitMEC _MECType, java.util.List<SimulationTransaction> _transactions) { @@ -115,8 +114,36 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { button.setFocusPainted(false); button.setContentAreaFilled(false); button.setBorderPainted(false); + button.setPreferredSize(new Dimension(20,20)); } + //issue 183 + private void buttonClick(JButton but, JTextArea jta) { + JPopupMenu helpPopup = new JPopupMenu(); + helpPopup.add(jta); + but.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + + if (!helpPopup.isVisible()) { + helpPopup.show(but,20,20); + } else { + helpPopup.setVisible(false); + } + } + }); + + helpPopup.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "closeJTextArea"); + helpPopup.getActionMap().put("closeJTextArea", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + helpPopup.setVisible(false); + } + }); + + } + + //issue 183 private void hardwareHelp(){ instructionHelpList = new ArrayList<>(); @@ -126,7 +153,7 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { instructionHelpList.add(jft1); JTextArea jft2 = new JTextArea(); - jft2.setText("Scheduling policy"); + jft2.setText("The arbitration policy used by OS to schedule mapped tasks"); instructionHelpList.add(jft2); JTextArea jft3 = new JTextArea("Slice time : The maximum time allocated by the OS " + @@ -175,195 +202,23 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { "operates at 200/4 = 50 MHz"); instructionHelpList.add(jft14); + JTextArea jft15 = new JTextArea("Encryption"); + instructionHelpList.add(jft15); + + JTextArea jft16 = new JTextArea("CPU Extension Construct"); + instructionHelpList.add(jft16); + for(int i = 0; i < instructionHelpList.size(); i++) { Icon myIcon = IconManager.imgic32; JButton but = new JButton(myIcon); setButton(but); buttons.add(but); + instructionHelpList.get(i).setEditable(false); } - buttons.get(0).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft1); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(0),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(1).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft2); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(1),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(2).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft3); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(2),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(3).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft4); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(3),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(4).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft5); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(4),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(5).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft6); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(5),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(6).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft7); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(6),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(7).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft8); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(7),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(8).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft9); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(8),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(9).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft10); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(9),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(10).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft11); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(10),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(11).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft12); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(11),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(12).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft13); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(12),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - - buttons.get(13).addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - JPopupMenu helpPopup = new JPopupMenu(); - helpPopup.add(jft14); - if (!helpPopup.isVisible()) { - helpPopup.show(buttons.get(13),20,20); - } else { - helpPopup.setVisible(false); - } - } - }); - + for (int i = 0; i < instructionHelpList.size(); i++) { + buttonClick(buttons.get(i),instructionHelpList.get(i)); + } } @@ -407,11 +262,10 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(nodeName, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(0),c2); - c2.gridwidth = 1; c2.gridheight = 1; c2.weighty = 1.0; @@ -427,8 +281,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(schedulingPolicy, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(1),c2); @@ -442,8 +296,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(sliceTime, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(2),c2); @@ -457,8 +311,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(nbOfCores, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(3),c2); @@ -472,8 +326,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(byteDataSize, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(4),c2); @@ -487,8 +341,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(pipelineSize, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(5),c2); @@ -502,8 +356,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(taskSwitchingTime, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(6),c2); @@ -517,8 +371,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(branchingPredictionPenalty, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(7),c2); @@ -532,8 +386,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(cacheMiss, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(8),c2); @@ -547,8 +401,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(goIdleTime, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(9),c2); @@ -562,8 +416,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(maxConsecutiveIdleCycles, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(10),c2); @@ -577,8 +431,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(execiTime, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(11),c2); @@ -592,8 +446,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(execcTime, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(12),c2); @@ -607,8 +461,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { panel2.add(clockRatio, c2); //issue 183 - c2.weighty = 0.0; - c2.weightx = 0.0; + c2.weighty = 0.5; + c2.weightx = 0.5; c2.gridwidth = GridBagConstraints.REMAINDER; panel2.add(buttons.get(13),c2); @@ -643,16 +497,25 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { c4.fill = GridBagConstraints.HORIZONTAL; c4.anchor = GridBagConstraints.CENTER;*/ panel4.add(new JLabel("Encryption:"), c4); - c4.gridwidth = GridBagConstraints.REMAINDER; + //c4.gridwidth = GridBagConstraints.REMAINDER; encryption = new JComboBox<String>(); encryption.addItem("None"); encryption.addItem("Software Encryption"); encryption.addItem("Hardware Security Module"); encryption.setSelectedIndex(node.getEncryption()); panel4.add(encryption, c4); + //issue 183 + c4.weighty = 0.5; + c4.weightx = 0.5; + c4.gridwidth = GridBagConstraints.REMAINDER; + panel4.add(buttons.get(14),c4); + + //issue 183 + c4.weighty = 1.0; + c4.weightx = 1.0; c4.gridwidth = 1; panel4.add(new JLabel("CPU Extension Construct:"), c4); - c4.gridwidth = GridBagConstraints.REMAINDER; //end row + //c4.gridwidth = GridBagConstraints.REMAINDER; //end row MECTypeCB = new JComboBox<String>( ArchUnitMEC.stringTypes ); if( MECType == null ) { MECTypeCB.setSelectedIndex( 0 ); @@ -663,6 +526,11 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { MECTypeCB.addActionListener(this); panel4.add( MECTypeCB, c4); + c4.weighty = 0.5; + c4.weightx = 0.5; + c4.gridwidth = GridBagConstraints.REMAINDER; + panel4.add(buttons.get(15),c4); + if (transactions.size()!=0) { panel5=new JPanel(); panel5.setPreferredSize(new Dimension(400,300));