Download this file

HelpMenu.java    162 lines (136 with data), 5.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package cologne.eck.all_peas.gui;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ResourceBundle;
import javax.accessibility.AccessibleContext;
import javax.swing.Action;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import cologne.eck.all_peas.control.PeaControl;
import cologne.eck.all_peas.data.PeaProperties;
@SuppressWarnings("serial")
public class HelpMenu extends JMenu implements ActionListener {
private ResourceBundle languagesBundle;
public HelpMenu() {
languagesBundle = PeaProperties.getBundle();
this.setText(languagesBundle.getString("help"));
// int fontSize = PswDialogView.getFontsize();
// this.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
//help.setMnemonic(KeyEvent.VK_H);
this.setMnemonic(KeyStroke.getKeyStroke(languagesBundle.getString("help_mnemonic")).getKeyCode());
JMenuItem instructionItem = new JMenuItem(languagesBundle.getString("instruction"));
instructionItem.setActionCommand("instruction");
// instructionItem.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
//instructionItem.setMnemonic(KeyEvent.VK_I);
instructionItem.setMnemonic(KeyStroke.getKeyStroke(languagesBundle.getString("instruction_mnemonic")).getKeyCode());
instructionItem.addActionListener(this);
this.add(instructionItem);
JMenuItem webItem = new JMenuItem(languagesBundle.getString("web"));
webItem.setActionCommand("web");
// webItem.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
//webItem.setMnemonic(KeyEvent.VK_I);
webItem.setMnemonic(KeyStroke.getKeyStroke(languagesBundle.getString("web_mnemonic")).getKeyCode());
webItem.addActionListener(this);
this.add(webItem);
JMenuItem pathFileItem = new JMenuItem(languagesBundle.getString("path_file"));
pathFileItem.setActionCommand("pathFile");
// pathFileItem.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
//webItem.setMnemonic(KeyEvent.VK_I);
pathFileItem.setMnemonic(KeyStroke.getKeyStroke(languagesBundle.getString("path_file_mnemonic")).getKeyCode());
pathFileItem.addActionListener(this);
this.add(pathFileItem);
JMenuItem aboutItem = new JMenuItem(languagesBundle.getString("about"));
aboutItem.setActionCommand("about");
// aboutItem.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
aboutItem.setMnemonic(KeyStroke.getKeyStroke(languagesBundle.getString("about_mnemonic")).getKeyCode());
aboutItem.addActionListener(this);
this.add(aboutItem);
}
public HelpMenu(String s) {
super(s);
// TODO Auto-generated constructor stub
}
public HelpMenu(Action a) {
super(a);
// TODO Auto-generated constructor stub
}
public HelpMenu(String s, boolean b) {
super(s, b);
// TODO Auto-generated constructor stub
}
@Override
public void actionPerformed(ActionEvent ae) {
String command = ae.getActionCommand();
String fileType = PeaProperties.getFileType();
// get the parent window: PswDialog or ContentUtilities
Window parentWindow = null;
if (PeaControl.getDialog().getLockFrame() != null) {
// set ContentUtilities as parent
parentWindow = (Window) PeaControl.getDialog().getLockFrame();
} else { // in PswDialog: set PswDialog as parent
parentWindow = PswDialogView.getView();
}
//System.out.println("command: " + command);
if (command.equals("instruction")){
String message = null;
if (fileType.equals("file")){
message = PeaProperties.getBundle().getString("file_instruction");
} else if (fileType.equals("image")) {
message = PeaProperties.getBundle().getString("image_instruction");
} else if (fileType.equals("text")) {
message = PeaProperties.getBundle().getString("text_instruction");
} else if (fileType.equals("text file")) {
message = PeaProperties.getBundle().getString("text_instruction");
} else {
message = "invalid PEA type: " + fileType;
}
JOptionPane.showMessageDialog(parentWindow,
message,
null,
JOptionPane.INFORMATION_MESSAGE);
} else if (command.equals("web")){
PswDialogView.showInfoDialog(parentWindow);
/* if (PeaControl.getDialog().getLockFrame() != null) {
// set ContentUtilities as parent
PswDialogView.showInfoDialog(PeaControl.getDialog().getLockFrame());
} else { // in PswDialog: set PswDialog as parent
PswDialogView.showInfoDialog(PswDialogView.getView());
}*/
} else if (command.equals("pathFile")){
PathFileSetting ps = PathFileSetting.getInstance(parentWindow, parentWindow.getLocation());
if (ps.isVisible() == false) {
ps.setVisible(true);
}
} else if (command.equals("about")) {
String peaName = null;
if (PeaProperties.getFileType().equals("image")){
peaName = "Image Lock PEA";
} else if (PeaProperties.getFileType().equals("file")){
peaName = "File Lock PEA";
} else if (PeaProperties.getFileType().equals("text file")){
peaName = "Notebook PEA";
}
PswDialogView.showAboutDialog(peaName, null, parentWindow);
/* if (PeaControl.getDialog().getLockFrame() != null) {
// set ContentUtilities as parent
PswDialogView.showAboutDialog("Notebook PEA", null, PeaControl.getDialog().getLockFrame());
} else { // in PswDialog: set PswDialog as parent
PswDialogView.showAboutDialog("Notebook PEA", null, PswDialogView.getView());
}*/
} else {
System.out.println("Invalid command in help menu");
}
}
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleHelpMenu();
}
return accessibleContext;
}
protected class AccessibleHelpMenu extends AccessibleJMenu {
//Inherit everything, override nothing.
}
}