Menu

[r80]: / GraphScript / trunk / ls / graph / ui / Menu.java  Maximize  Restore  History

Download this file

105 lines (90 with data), 3.0 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
package ls.graph.ui;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import ls.graph.script.Algorithm;
import ls.graph.script.AlgorithmListener;
import ls.graph.ui.dialogs.ScriptIncludesDialog;
public class Menu extends JMenuBar implements AlgorithmListener
{
private static final long serialVersionUID = 1L;
MainWindow mainWindow = null;
ExitAction actExit = null;
LoadScriptAction actLoad = null;
SaveScriptAction actSave = null;
SaveGraphAction actSaveGraph = null;
LoadGraphAction actLoadGraph = null;
JMenuItem itmExit,itmLoad,itmSave,itmSaveGraph,itmLoadGraph;
private ScriptIncludesDialog scriptsDialog = null;
Menu(MainWindow w)
{
super();
this.mainWindow = w;
initComponents();
}
private void initComponents()
{
JMenu menu = new JMenu("System");
menu.setMnemonic(KeyEvent.VK_Y);
actExit = new ExitAction(mainWindow);
itmExit = new JMenuItem(actExit);
itmExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4,KeyEvent.ALT_MASK));
menu.add(itmExit);
this.add(menu);
menu = new JMenu("Script");
menu.setMnemonic(KeyEvent.VK_S);
actLoad = new LoadScriptAction(mainWindow,mainWindow);
itmLoad = new JMenuItem(actLoad);
itmLoad.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,KeyEvent.CTRL_MASK));
menu.add(itmLoad);
actSave = new SaveScriptAction(mainWindow,mainWindow);
itmSave = new JMenuItem(actSave);
itmSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,KeyEvent.CTRL_MASK));
menu.add(itmSave);
Action actScriptIncludesDialog = new AbstractAction("Script Settings")
{
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e)
{
//Launch script includes dialog
if (scriptsDialog == null)
scriptsDialog = new ScriptIncludesDialog(mainWindow);
scriptsDialog.pack();
scriptsDialog.setVisible(true);
}
};
JMenuItem itmScriptIncludes = new JMenuItem(actScriptIncludesDialog);
menu.add(itmScriptIncludes);
this.add(menu);
menu = new JMenu("Graph");
menu.setMnemonic(KeyEvent.VK_G);
actSaveGraph = new SaveGraphAction(mainWindow,mainWindow);
itmSaveGraph = new JMenuItem(actSaveGraph);
menu.add(itmSaveGraph);
actLoadGraph = new LoadGraphAction(mainWindow,mainWindow);
itmLoadGraph = new JMenuItem(actLoadGraph);
menu.add(itmLoadGraph);
this.add(menu);
}
public void executionEnded(Algorithm alg)
{
itmExit.setEnabled(true);
itmLoad.setEnabled(true);
itmSave.setEnabled(true);
}
public void executionStarted(Algorithm alg)
{
itmExit.setEnabled(false);
itmLoad.setEnabled(false);
itmSave.setEnabled(false);
}
public void startingStep(int stepIndex)
{}
} //end of Menu class
MongoDB Logo MongoDB