use of java.awt.Menu in project voltdb by VoltDB.
the class DatabaseManager method addMenu.
void addMenu(MenuBar b, String name, String[] items) {
/* It's a very poor design to encapsulate menu creation this way.
* Can't customize the menus this way (e.g. shortcut keys,
* mnemonics, disabling, etc. */
Menu menu = new Menu(name);
if (name.equals("Tools") && !TT_AVAILABLE) {
// Terrible place to do this. Forced to due to method design.
menu.setEnabled(false);
}
addMenuItems(menu, items);
b.add(menu);
}
use of java.awt.Menu in project voltdb by VoltDB.
the class Transfer method _main.
/**
* @throws IllegalArgumentException for the obvious reason
*/
void _main(String[] arg) {
/*
** What function is asked from the transfer tool?
*/
iTransferMode = TRFM_TRANSFER;
if (arg != null) {
if (arg.length != 1) {
throw new IllegalArgumentException();
}
if ((arg[0].toLowerCase().equals("-r")) || (arg[0].toLowerCase().equals("--restore"))) {
iTransferMode = TRFM_RESTORE;
} else if ((arg[0].toLowerCase().equals("-d")) || (arg[0].toLowerCase().equals("--dump"))) {
iTransferMode = TRFM_DUMP;
} else if ((arg[0].toLowerCase().equals("-h")) || (arg[0].toLowerCase().equals("--help"))) {
System.out.println(Transfer.SYNTAX_MSG);
return;
} else {
throw new IllegalArgumentException();
}
}
fMain = new Frame("HSQL Transfer Tool");
imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));
fMain.setIconImage(imgEmpty);
fMain.addWindowListener(this);
fMain.setSize(640, 480);
fMain.add("Center", this);
MenuBar bar = new MenuBar();
String[] extras = { "Insert 10 rows only", "Insert 1000 rows only", "Insert all rows", "-", "Load Settings...", "Save Settings...", "-", "Exit" };
Menu menu = new Menu("Options");
addMenuItems(menu, extras);
bar.add(menu);
fMain.setMenuBar(bar);
initGUI();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = fMain.getSize();
// (ulrivo): full size on screen with less than 640 width
if (d.width >= 640) {
fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
} else {
fMain.setLocation(0, 0);
fMain.setSize(d);
}
fMain.setVisible(true);
CurrentTransfer = CurrentAlter = 0;
try {
if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
sourceDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Source Database"), this);
if (!sourceDb.isConnected()) {
exit();
return;
}
} else {
FileDialog f = new FileDialog(fMain, "Restore FileName", FileDialog.LOAD);
f.show();
String sFileName = f.getFile();
String Path = f.getDirectory();
if ((sFileName == null) || (sFileName.equals(""))) {
exit();
return;
} else {
sourceDb = new TransferSQLText(Path + sFileName, this);
}
}
if ((iTransferMode == TRFM_RESTORE) || (iTransferMode == TRFM_TRANSFER)) {
targetDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Target Database"), this);
if (!targetDb.isConnected()) {
exit();
return;
}
} else {
FileDialog f = new FileDialog(fMain, "Dump FileName", FileDialog.SAVE);
f.show();
String sFileName = f.getFile();
String Path = f.getDirectory();
if ((sFileName == null) || (sFileName.equals(""))) {
exit();
return;
} else {
targetDb = new TransferSQLText(Path + sFileName, this);
}
}
} catch (Exception e) {
exit();
e.printStackTrace();
return;
}
if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
iSelectionStep = SELECT_SOURCE_CATALOG;
sSourceCatalog = null;
} else {
iSelectionStep = SELECT_DEST_CATALOG;
sDestCatalog = null;
}
ProcessNextStep();
fMain.show();
return;
}
use of java.awt.Menu in project jdk8u_jdk by JetBrains.
the class RemoveHelpMenu method test3.
private static void test3(final MenuBar menuBar) {
final Menu helpMenu1 = new Menu("Help Menu1");
final Menu helpMenu2 = new Menu("Help Menu2");
menuBar.setHelpMenu(helpMenu1);
checkCurrentMenu(menuBar, helpMenu1);
checkMenuCount(menuBar, 1);
checkHelpMenu(helpMenu1, true);
checkHelpMenu(helpMenu2, false);
menuBar.setHelpMenu(helpMenu2);
checkCurrentMenu(menuBar, helpMenu2);
checkMenuCount(menuBar, 1);
checkHelpMenu(helpMenu1, false);
checkHelpMenu(helpMenu2, true);
menuBar.remove(helpMenu2);
checkCurrentMenu(menuBar, null);
checkMenuCount(menuBar, 0);
checkHelpMenu(helpMenu1, false);
checkHelpMenu(helpMenu2, false);
}
use of java.awt.Menu in project jdk8u_jdk by JetBrains.
the class RemoveHelpMenu method test2.
private static void test2(final MenuBar menuBar) {
final Menu helpMenu = new Menu("Help Menu");
menuBar.setHelpMenu(helpMenu);
checkCurrentMenu(menuBar, helpMenu);
checkMenuCount(menuBar, 1);
checkHelpMenu(helpMenu, true);
menuBar.remove(helpMenu);
checkCurrentMenu(menuBar, null);
checkMenuCount(menuBar, 0);
checkHelpMenu(helpMenu, false);
}
use of java.awt.Menu in project jdk8u_jdk by JetBrains.
the class CMenu method setEnabled.
@Override
public final void setEnabled(final boolean b) {
super.setEnabled(b);
final Menu target = (Menu) getTarget();
final int count = target.getItemCount();
for (int i = 0; i < count; ++i) {
MenuItem item = target.getItem(i);
MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
if (p != null) {
p.setEnabled(b && item.isEnabled());
}
}
}
Aggregations