Skip to content
Snippets Groups Projects
Commit 5e6b965a authored by Minh Hiep Pham's avatar Minh Hiep Pham :speech_balloon:
Browse files

Updated cpu node help

parent 32ea5c65
Branches minh-cpu_node_help
No related tags found
1 merge request!151Updated cpu node help
...@@ -712,6 +712,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per ...@@ -712,6 +712,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
return helpManager; return helpManager;
} }
public void setHelpManager(HelpManager hm) {
helpManager = hm;
}
public void showIntegratedHelp() { public void showIntegratedHelp() {
if (helpManager != null) { if (helpManager != null) {
openHelpFrame(helpManager); openHelpFrame(helpManager);
......
...@@ -103,7 +103,7 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { ...@@ -103,7 +103,7 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener {
//issue 183 //issue 183
List<JButton> buttons = new ArrayList<>(); List<JButton> buttons = new ArrayList<>();
List<HelpEntry> helpEntries; List<HelpEntry> helpEntries;
JFrameHWNodeHelp cpuHelp; TGComponentHelp cpuHelp;
/* Creates new form */ /* Creates new form */
public JDialogCPUNode(MainGUI _mgui, Frame _frame, String _title, TMLArchiCPUNode _node, ArchUnitMEC _MECType, public JDialogCPUNode(MainGUI _mgui, Frame _frame, String _title, TMLArchiCPUNode _node, ArchUnitMEC _MECType,
...@@ -132,33 +132,20 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { ...@@ -132,33 +132,20 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener {
//issue 183 //issue 183
private void buttonClick(JButton but, HelpEntry he) { private void buttonClick(JButton but, HelpEntry he) {
//setModalityType(ModalityType.MODELESS);
but.addActionListener(new ActionListener() { but.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(cpuHelp == null ) { if(cpuHelp == null ) {
cpuHelp = new JFrameHWNodeHelp(mgui,"Help",he); cpuHelp = new TGComponentHelp(mgui, he);
cpuHelp.setLocationRelativeTo(but); cpuHelp.setLocationHelpWindow(but);
}else{ }else{
if(!cpuHelp.isVisible()) { if(!cpuHelp.isVisible()) {
cpuHelp = new JFrameHWNodeHelp(mgui,"Help",he); cpuHelp = new TGComponentHelp(mgui, he);
cpuHelp.setLocationRelativeTo(but); cpuHelp.setLocationHelpWindow(but);
}else{ }else{
cpuHelp.setVisible(false); cpuHelp.setVisible(false);
} }
} }
if(cpuHelp != null) {
cpuHelp.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
cpuHelp.getRootPane().getActionMap().put("close", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if(!cpuHelp.isVisible())
dispose();
cpuHelp.setVisible(false);
}
});
}
} }
}); });
} }
...@@ -593,12 +580,18 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { ...@@ -593,12 +580,18 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener {
regularClose = true; regularClose = true;
MECType = ArchUnitMEC.Types.get( MECTypeCB.getSelectedIndex() ); MECType = ArchUnitMEC.Types.get( MECTypeCB.getSelectedIndex() );
dispose(); dispose();
if ((cpuHelp != null) && cpuHelp.isVisible()) {
cpuHelp.setVisible(false);
}
} }
public void cancelDialog() { public void cancelDialog() {
//TraceManager.addDev("Cancel dialog"); //TraceManager.addDev("Cancel dialog");
dispose(); dispose();
if ((cpuHelp != null) && cpuHelp.isVisible()) {
cpuHelp.setVisible(false);
}
} }
public boolean isRegularClose() { public boolean isRegularClose() {
......
...@@ -83,6 +83,7 @@ public class JFrameHelp extends JFrame implements ActionListener { ...@@ -83,6 +83,7 @@ public class JFrameHelp extends JFrame implements ActionListener {
visitedEntries = new Vector<>(); visitedEntries = new Vector<>();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
Container framePanel = getContentPane(); Container framePanel = getContentPane();
framePanel.setLayout(new BorderLayout()); framePanel.setLayout(new BorderLayout());
Font f = new Font("Courrier", Font.BOLD, 12); Font f = new Font("Courrier", Font.BOLD, 12);
......
package ui.window;
import help.HelpEntry;
import help.HelpManager;
import myutil.TraceManager;
import ui.MainGUI;
import ui.util.IconManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class TGComponentHelp extends JDialog implements ActionListener {
MainGUI mainGUI;
HelpEntry helpEntry;
HelpManager helpManager;
JButton helpBut;
JEditorPane pane;
public TGComponentHelp(MainGUI _mgui, HelpEntry _he) {
mainGUI = _mgui;
helpEntry = _he;
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
getRootPane().getActionMap().put("close", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
setUndecorated(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
Container framePanel = getContentPane();
framePanel.setLayout(new BorderLayout());
Font f = new Font("Courrier", Font.BOLD, 12);
JPanel helpPanel = new JPanel();
helpPanel.setLayout(new BorderLayout());
pane = new JEditorPane("text/html;charset=UTF-8", "");
pane.setEditable(false);
pane.setText(helpEntry.getHTMLContent());
JScrollPane jsp = new JScrollPane(pane);
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
helpPanel.add(jsp, BorderLayout.CENTER);
framePanel.add(helpPanel, BorderLayout.CENTER);
helpBut = new JButton("Help", IconManager.imgic32);
helpManager = new HelpManager();
if(helpManager.loadEntries()) {
mainGUI.setHelpManager(helpManager);
}
helpBut.addActionListener(this);
JPanel jp = new JPanel();
jp.add(helpBut);
framePanel.add(jp, BorderLayout.SOUTH);
setSize(300, 200);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == helpBut) {
mainGUI.openHelpFrame(helpEntry);
}
}
public void setLocationHelpWindow(Component c) {
// target location
int dx, dy;
// target GC
GraphicsDevice gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
Rectangle gcBounds;
Dimension windowSize = getSize();
//TraceManager.addDev("window size ==> height = " + windowSize.height + " width = " + windowSize.width);
gcBounds = gc.getDefaultConfiguration().getBounds();
//TraceManager.addDev("gc bounds ==> (x,y) = " + "(" + gcBounds.x + "," + gcBounds.y + ")" + " gc bound width = " + gcBounds.width + " gc " +
// "bound height = " + gcBounds.height);
Dimension compSize = c.getSize();
Point compLocation = c.getLocationOnScreen();
//TraceManager.addDev("button location ==> (x,y) = " + "(" + compLocation.x + "," + compLocation.y + ")" );
dx = compLocation.x + compSize.width;
dy = compLocation.y + compSize.height;
if (dy + windowSize.height > gcBounds.y + gcBounds.height) {
dy = gcBounds.y + gcBounds.height - windowSize.height;
}
if (compLocation.x + windowSize.width > gcBounds.width + gcBounds.x) {
dx = compLocation.x - windowSize.width;
}
//TraceManager.addDev("help window location ==> (x,y) = " + "(" + dx+ "," + dy + ")" );
setLocation(dx, dy);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment