📄 mainframe.java
字号:
putValue(SHORT_DESCRIPTION, "Export experiment");
putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
}
public void actionPerformed(ActionEvent e) {
ExportDialog exportDialog = new ExportDialog("YALE");
exportDialog.showExportDialog(MainFrame.this,
"Export",
((ExperimentEditor)editorTabs.getSelectedComponent()).getMainComponent(),
getBaseName()+"_"+editorTabs.getTitleAt(editorTabs.getSelectedIndex()));
}
}
private class ExitAction extends AbstractAction {
private ExitAction() {
super("Exit");
putValue(SHORT_DESCRIPTION, "Exit Yale");
putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_X));
}
public void actionPerformed(ActionEvent e) {
exit();
}
}
private class SettingsAction extends AbstractAction {
private SettingsAction() {
super("Settings...");
putValue(SHORT_DESCRIPTION, "Edit Yale settings.");
putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S));
}
public void actionPerformed(ActionEvent e) {
new SettingsDialog(MainFrame.this).show();
}
}
private class ToggleExpertModeAction extends AbstractAction {
private ImageIcon expertModeIcon = new ImageIcon(Tools.getResource("icons/icon_expert_mode_on.gif"));
private ImageIcon beginnerModeIcon = new ImageIcon(Tools.getResource("icons/icon_expert_mode_off.gif"));
private ToggleExpertModeAction() {
super("Toggle expert mode...");
putValue(SHORT_DESCRIPTION, "Toggles between expert and beginner mode.");
putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
putValue(SMALL_ICON, expertModeIcon);
}
public void actionPerformed(ActionEvent e) {
((OperatorPropertyTable)MainFrame.this.getPropertyTable()).toggleExpertMode();
updateIcon();
}
public void updateIcon() {
if (((OperatorPropertyTable)MainFrame.this.getPropertyTable()).isExpertMode()) putValue(SMALL_ICON, beginnerModeIcon);
else putValue(SMALL_ICON, expertModeIcon);
}
}
private class TutorialAction extends AbstractAction {
private TutorialAction() {
super("Yale tutorial...");
putValue(SHORT_DESCRIPTION, "Starts the Yale online tutorial.");
putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
}
public void actionPerformed(ActionEvent e) {
if (close()) {
new Tutorial(MainFrame.this).show();
}
}
}
// --------------------------------------------------------------------------------
public final Action NEW_ACTION = new NewAction();
public final Action OPEN_ACTION = new OpenAction();
public final Action SAVE_ACTION = new SaveAction();
public final Action SAVE_AS_ACTION = new SaveAsAction();
public final Action SAVE_AS_TEMPLATE_ACTION = new SaveAsTemplateAction();
public final Action MANAGE_TEMPLATES_ACTION = new ManageTemplatesAction();
public final Action PRINT_ACTION = new PrintAction();
public final Action EXPORT_ACTION = new ExportAction();
public final Action EXIT_ACTION = new ExitAction();
public final Action RUN_ACTION = new RunAction();
public final Action RESUME_ACTION = new ResumeAction();
public final Action STOP_ACTION = new StopAction();
public final Action VALIDATE_ACTION = new ValidateExperiment();
public final Action WIZARD_ACTION = new WizardAction();
public final Action SETTINGS_ACTION = new SettingsAction();
public final Action TOGGLE_EXPERT_MODE_ACTION = new ToggleExpertModeAction();
public final Action TUTORIAL_ACTION = new TutorialAction();
private XMLEditor editor = new XMLEditor(this);
private TreePanel treePanel = new TreePanel(this);
private ExperimentPanel experimentPanel = new ExperimentPanel();
private JTabbedPane editorTabs = new JTabbedPane();
private ResultDisplay resultDisplay = new ResultDisplay();
private MonitorPanel monitorPanel = new MonitorPanel();
private MessageViewer messageViewer = new MessageViewer();
private StatusBar statusBar = new StatusBar();
private JMenu recentFilesMenu = new JMenu("Recent Files");
private List conditionalActions = new LinkedList();
private PrinterJob printerJob = PrinterJob.getPrinterJob();
private PageFormat pageFormat = printerJob.defaultPage();
private boolean changed = false;
private ExperimentThread experimentThread = null;
private ExperimentEditor currentExperimentEditor = treePanel;
private boolean tutorialMode = false;
private JSplitPane splitPaneV;
public MainFrame() {
super(TITLE);
try {
setIconImage(ImageIO.read(Tools.getResource("yale_logo.gif")));
} catch (IOException e) { e.printStackTrace(); }
Yale.setExperiment(new Experiment());
Yale.getExperiment().addBreakpointListener(MainFrame.this);
setTitle();
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(this);
setOperator(Yale.getExperiment().getRootOperator());
editorTabs.addChangeListener(this);
editorTabs.add(treePanel, "Tree");
editorTabs.add(editor, "XML");
editorTabs.add(experimentPanel, "Experiment");
editorTabs.add(resultDisplay, "Results");
editorTabs.add(monitorPanel, "Monitor");
splitPaneV = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
editorTabs,
messageViewer);
splitPaneV.setOneTouchExpandable(true);
getContentPane().add(splitPaneV, BorderLayout.CENTER);
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
fileMenu.add(NEW_ACTION);
fileMenu.add(OPEN_ACTION);
updateRecentFileList();
fileMenu.add(recentFilesMenu);
fileMenu.add(new JSeparator());
fileMenu.add(SAVE_ACTION);
fileMenu.add(SAVE_AS_ACTION);
fileMenu.add(new JSeparator());
fileMenu.add(PRINT_ACTION);
fileMenu.add(EXPORT_ACTION);
fileMenu.add(new JSeparator());
fileMenu.add(SAVE_AS_TEMPLATE_ACTION);
fileMenu.add(MANAGE_TEMPLATES_ACTION);
fileMenu.add(WIZARD_ACTION);
fileMenu.add(SETTINGS_ACTION);
fileMenu.add(new JSeparator());
fileMenu.add(EXIT_ACTION);
menuBar.add(fileMenu);
menuBar.add(treePanel.getOperatorTree().createOperatorMenu());
JMenu expMenu = new JMenu("Experiment");
expMenu.setMnemonic(KeyEvent.VK_X);
expMenu.add(RUN_ACTION);
expMenu.add(RESUME_ACTION);
expMenu.add(STOP_ACTION);
expMenu.add(new JSeparator());
expMenu.add(VALIDATE_ACTION);
expMenu.add(TOGGLE_EXPERT_MODE_ACTION);
expMenu.add(new JSeparator());
expMenu.add(messageViewer.CLEAR_MESSAGE_VIEWER_ACTION);
menuBar.add(expMenu);
setJMenuBar(menuBar);
JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic(KeyEvent.VK_H);
JMenuItem aboutItem = new JMenuItem("About Yale...",
new ImageIcon(Tools.getResource("icons/icon_about.gif")));
aboutItem.setToolTipText("Display information about Yale");
aboutItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
new AboutBox(MainFrame.this,
"YALE", YaleGUI.getVersion(),
"YALE - Yet Another Learning Environment\n"+
"Copyright (C) 2001-2004 "+
"Simon Fischer, Ralf Klinkenberg, Ingo Mierswa, Katharina Morik, Oliver Ritthoff\n"+
"Artificial Intelligence Unit, Computer Science Department, University of Dortmund, 44221 Dortmund, Germany\n"+
"email: yale@ls8.cs.uni-dortmund.de, web: http://yale.cs.uni-dortmund.de/\n\n"+
"Yale comes with ABSOLUTELY NO WARRANTY; This is free software," +
"and you are welcome to redistribute it under certain conditions;"+
"see license information in the file named LICENSE.",
new Image[] { ImageIO.read(Tools.getResource("yale_logo.gif"))}).show();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
});
helpMenu.add(aboutItem);
helpMenu.add(TUTORIAL_ACTION);
List allPlugins = Plugin.getAllPlugins();
if (allPlugins.size() > 0) {
helpMenu.addSeparator();
Iterator i = allPlugins.iterator();
while (i.hasNext()) {
final Plugin plugin = (Plugin)i.next();
JMenuItem aboutPluginItem = new JMenuItem("About "+plugin.getName()+"...");
aboutPluginItem.setToolTipText("Display information about "+plugin.getName());
aboutPluginItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
plugin.createAboutBox(MainFrame.this).show();
}
});
helpMenu.add(aboutPluginItem);
}
helpMenu.addSeparator();
}
JMenuItem contents = new JMenuItem("Contents");
contents.setToolTipText("Browse the Yale GU Manual");
contents.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Browser.showDialog(Tools.getResource("html/manual/Manual.html"));
}
});
helpMenu.add(contents);
menuBar.add(helpMenu);
JMenuItem paperItem = new JMenuItem("Generate Paper");
paperItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(MainFrame.this,
"Function will be implemented in later release.",
"Error",
JOptionPane.WARNING_MESSAGE);
}
});
helpMenu.add(paperItem);
menuBar.add(helpMenu);
JToolBar toolBar = new JToolBar();
toolBar.setRollover(true);
toolBar.removeNotify();
toolBar.add(NEW_ACTION);
toolBar.add(OPEN_ACTION);
toolBar.add(SAVE_ACTION);
toolBar.add(SAVE_AS_ACTION);
toolBar.add(PRINT_ACTION);
toolBar.addSeparator();
toolBar.add(treePanel.getOperatorTree().CUT_ACTION);
toolBar.add(treePanel.getOperatorTree().PASTE_ACTION);
toolBar.addSeparator();
toolBar.add(RUN_ACTION);
toolBar.add(RESUME_ACTION);
toolBar.add(STOP_ACTION);
toolBar.addSeparator();
toolBar.add(treePanel.getOperatorTree().INSERT_OPERATOR_ACTION);
toolBar.add(VALIDATE_ACTION);
toolBar.addSeparator();
toolBar.add(TOGGLE_EXPERT_MODE_ACTION);
getContentPane().add(toolBar, BorderLayout.NORTH);
getContentPane().add(statusBar, BorderLayout.SOUTH);
enableActions();
pack();
splitPaneV.setDividerLocation(3*splitPaneV.getHeight()/4);
}
public void setTutorialMode(boolean mode) {
this.tutorialMode = mode;
if (tutorialMode) {
SAVE_ACTION.setEnabled(false);
SAVE_AS_ACTION.setEnabled(false);
} else {
SAVE_ACTION.setEnabled(false);
SAVE_AS_ACTION.setEnabled(true);
}
}
public MonitorPanel getMonitorPanel() {
return monitorPanel;
}
public int getHorizontalDividerLocation() {
return splitPaneV.getDividerLocation();
}
public int getVerticalDividerLocation() {
return treePanel.getDividerLocation();
}
public void setDividerLocations(int h, int v) {
splitPaneV.setDividerLocation(h);
treePanel.setDividerLocation(v);
}
public void updateToggleExpertModeIcon() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -