Search in sources :

Example 1 with MenuBar

use of java.awt.MenuBar 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;
}
Also used : Frame(java.awt.Frame) MenuBar(java.awt.MenuBar) Menu(java.awt.Menu) Dimension(java.awt.Dimension) MemoryImageSource(java.awt.image.MemoryImageSource) FileDialog(java.awt.FileDialog)

Example 2 with MenuBar

use of java.awt.MenuBar in project jdk8u_jdk by JetBrains.

the class RemoveHelpMenu method getMenuBar.

private static MenuBar getMenuBar(final Frame frame) {
    final MenuBar menuBar = new MenuBar();
    frame.setMenuBar(menuBar);
    return menuBar;
}
Also used : MenuBar(java.awt.MenuBar)

Example 3 with MenuBar

use of java.awt.MenuBar in project fql by CategoricalData.

the class IDE method main.

/*
	public static final class OldEntryPoint {
		public static void main(String... args) {
			if (args.length == 1) {
				try {
					FQLProgram init = FQLParser.program(args[0]);
					Triple<FqlEnvironment, String, List<Throwable>> envX = Driver.makeEnv(init);
					if (!envX.third.isEmpty()) {
						throw new RuntimeException("Errors: " + envX.third);
					}
					System.out.println("OK");
					System.out.println(envX.second);
					return;
				} catch (RuntimeException err) {
					err.printStackTrace(System.err);
					System.out.println(err.getLocalizedMessage());
					return;
				}
			}
		}
	} */
public static void main(String... args) {
    System.setProperty("apple.eawt.quitStrategy", "CLOSE_ALL_WINDOWS");
    // apple.awt.application.name
    SwingUtilities.invokeLater(() -> {
        try {
            DefunctGlobalOptions.load();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        try {
            UIManager.setLookAndFeel(IdeOptions.theCurrentOptions.getString(IdeOption.LOOK_AND_FEEL));
            JFrame f = new JFrame("AQL IDE");
            Pair<JPanel, MenuBar> gui = GUI.makeGUI(f);
            f.setContentPane(gui.first);
            f.setMenuBar(gui.second);
            f.pack();
            f.setSize(1024, 640);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            f.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
            f.addWindowListener(new WindowAdapter() {

                @Override
                public void windowClosing(WindowEvent windowEvent) {
                    GUI.exitAction();
                }
            });
            if (args.length == 0) {
                GUI.newAction(null, "", Language.getDefault());
            } else {
                File[] fs = new File[args.length];
                int i = 0;
                for (String s : args) {
                    fs[i++] = new File(s);
                }
                GUI.openAction(fs);
            }
            ((CodeEditor<?, ?, ?>) GUI.editors.getComponentAt(0)).topArea.requestFocusInWindow();
        } catch (HeadlessException | ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Unrecoverable error, restart IDE: " + e.getMessage());
        }
    });
}
Also used : JPanel(javax.swing.JPanel) HeadlessException(java.awt.HeadlessException) MenuBar(java.awt.MenuBar) WindowAdapter(java.awt.event.WindowAdapter) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) HeadlessException(java.awt.HeadlessException) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) File(java.io.File)

Example 4 with MenuBar

use of java.awt.MenuBar in project voltdb by VoltDB.

the class DatabaseManager method main.

public void main() {
    fMain = new Frame("HSQL Database Manager");
    imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));
    fMain.setIconImage(imgEmpty);
    fMain.addWindowListener(this);
    MenuBar bar = new MenuBar();
    // used shortcuts: CERGTSIUDOLM
    String[] fitems = { "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "-Save Result csv...", "--", "-Exit" };
    addMenu(bar, "File", fitems);
    String[] vitems = { "RRefresh Tree", "--", "GResults in Grid", "TResults in Text", "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command", "4Enlarge Command" };
    addMenu(bar, "View", vitems);
    String[] sitems = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "--", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-CHECKPOINT", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" };
    addMenu(bar, "Command", sitems);
    Menu recent = new Menu("Recent");
    mRecent = new Menu("Recent");
    bar.add(mRecent);
    String[] soptions = { "-AutoCommit on", "-AutoCommit off", "OCommit", "LRollback", "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on", "-Logging off", "--", "-Insert test data" };
    addMenu(bar, "Options", soptions);
    String[] stools = { "-Dump", "-Restore", "-Transfer" };
    addMenu(bar, "Tools", stools);
    Menu hMenu = new Menu("Help");
    MenuItem aItem = new MenuItem("About");
    aItem.setShortcut(new MenuShortcut('A'));
    aItem.addActionListener(this);
    hMenu.add(aItem);
    MenuItem hItem = new MenuItem("Help");
    hItem.setShortcut(new MenuShortcut('H'));
    hItem.addActionListener(this);
    hMenu.add(hItem);
    //bar.add(hMenu);
    // Command above disabled only until a help display bug is fixed.
    fMain.setMenuBar(bar);
    fMain.setSize(640, 480);
    fMain.add("Center", this);
    initGUI();
    sRecent = new String[iMaxRecent];
    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.show();
    // (ulrivo): load query from command line
    if (defScript != null) {
        if (defDirectory != null) {
            defScript = defDirectory + File.separator + defScript;
        }
        txtCommand.setText(DatabaseManagerCommon.readFile(defScript));
    }
    txtCommand.requestFocus();
}
Also used : Frame(java.awt.Frame) MenuBar(java.awt.MenuBar) MenuItem(java.awt.MenuItem) Menu(java.awt.Menu) MenuShortcut(java.awt.MenuShortcut) Dimension(java.awt.Dimension) MemoryImageSource(java.awt.image.MemoryImageSource)

Example 5 with MenuBar

use of java.awt.MenuBar in project voltdb by VoltDB.

the class ZaurusDatabaseManager method main.

/**
     * Method declaration
     *
     */
public void main() {
    fMain = new Frame("HSQLDB Database Manager for Zaurus");
    imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));
    fMain.setIconImage(imgEmpty);
    fMain.addWindowListener(this);
    MenuBar bar = new MenuBar();
    // no shortcuts used
    String[] fitems = { "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit" };
    addMenu(bar, "File", fitems);
    String[] vitems = { "-Refresh Tree", "--", "-View Tree", "-View Command", "-View Result", "-View Editor", "--", "-Results in Grid", "-Results in Text" };
    addMenu(bar, "View", vitems);
    String[] sitems = { "-SELECT", "-INSERT", "-UPDATE", "-DELETE", "--", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-SCRIPT", "-SHUTDOWN", "--", "-Test Script" };
    addMenu(bar, "SQL", sitems);
    Menu recent = new Menu("Recent");
    mRecent = new Menu("Recent");
    bar.add(mRecent);
    String[] soptions = { "-AutoCommit on", "-AutoCommit off", "-Commit", "-Rollback", "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on", "-Logging off", "--", // , "-Transfer"
    "-Insert test data" };
    addMenu(bar, "Options", soptions);
    String[] shelp = { "-Show HTML-Help in browser" };
    addMenu(bar, "?", shelp);
    fMain.setMenuBar(bar);
    fMain.setSize(defWidth, defHeight);
    fMain.add("Center", this);
    initGUI();
    sRecent = new String[iMaxRecent];
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = fMain.getSize();
    // 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 if (defWidth > 0 && defHeight > 0) {
        fMain.setLocation(defLocX, defLocY);
        fMain.setSize(defWidth, defHeight);
    } else {
        fMain.setLocation(0, 0);
        fMain.setSize(d);
    }
    fMain.show();
    // (ulrivo): load query from command line
    if (defQuery != null) {
        txtCommand.setText(DatabaseManagerCommon.readFile(defQuery));
    }
    txtCommand.requestFocus();
}
Also used : Frame(java.awt.Frame) MenuBar(java.awt.MenuBar) Menu(java.awt.Menu) Dimension(java.awt.Dimension) MemoryImageSource(java.awt.image.MemoryImageSource)

Aggregations

MenuBar (java.awt.MenuBar)10 Menu (java.awt.Menu)7 Dimension (java.awt.Dimension)4 Frame (java.awt.Frame)3 MemoryImageSource (java.awt.image.MemoryImageSource)3 JFrame (javax.swing.JFrame)3 JPanel (javax.swing.JPanel)3 BorderLayout (java.awt.BorderLayout)2 MenuItem (java.awt.MenuItem)2 JPopupMenu (javax.swing.JPopupMenu)2 Pair (catdata.Pair)1 MapObjectPanel (de.gurkenlabs.utiliti.swing.panels.MapObjectPanel)1 Canvas (java.awt.Canvas)1 FileDialog (java.awt.FileDialog)1 Font (java.awt.Font)1 HeadlessException (java.awt.HeadlessException)1 MenuShortcut (java.awt.MenuShortcut)1 PopupMenu (java.awt.PopupMenu)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1