Search in sources :

Example 1 with ButtonGroup

use of javax.swing.ButtonGroup in project pcgen by PCGen.

the class SourceSelectionPanel method setupDisplay.

@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(new GridBagLayout());
    JLabel label = new JLabel("Please select the Source Directory to Convert: ");
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
    gbc.insets = new Insets(50, 25, 10, 25);
    panel.add(label, gbc);
    JButton button = new JButton("Browse...");
    button.setMnemonic('r');
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser(SourceFolder.OTHER.getFile());
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setDialogType(JFileChooser.OPEN_DIALOG);
            chooser.setSelectedFile(path);
            while (true) {
                int open = chooser.showOpenDialog(null);
                if (open == JFileChooser.APPROVE_OPTION) {
                    File fileToOpen = chooser.getSelectedFile();
                    if (fileToOpen.isDirectory()) {
                        path = fileToOpen;
                        SourceFolder.OTHER.setFile(fileToOpen);
                        pc.put(ObjectKey.DIRECTORY, path);
                        PCGenSettings context = PCGenSettings.getInstance();
                        context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path.getAbsolutePath());
                        JRadioButton button = radioButtons[SourceFolder.OTHER.ordinal()];
                        button.setSelected(true);
                        button.setText(buildFolderText(SourceFolder.OTHER, fileToOpen.getAbsolutePath()));
                        break;
                    }
                    JOptionPane.showMessageDialog(null, "Selection must be a valid Directory");
                    chooser.setSelectedFile(path);
                } else if (open == JFileChooser.CANCEL_OPTION) {
                    break;
                }
            }
        }
    });
    radioButtons = new JRadioButton[SourceFolder.values().length];
    String selectedPath = null;
    File selectedFile = pc.get(ObjectKey.DIRECTORY);
    if (selectedFile != null) {
        selectedPath = selectedFile.getAbsolutePath();
    } else {
        PCGenSettings context = PCGenSettings.getInstance();
        selectedPath = context.getProperty(PCGenSettings.CONVERT_INPUT_PATH, null);
    }
    ButtonGroup group = new ButtonGroup();
    boolean haveSelected = false;
    Font font = panel.getFont();
    font = FontManipulation.plain(font);
    for (SourceFolder folder : SourceFolder.values()) {
        JRadioButton pathButton = new JRadioButton();
        final SourceFolder buttonFolder = folder;
        pathButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PCGenSettings context = PCGenSettings.getInstance();
                context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, buttonFolder.getFile().getAbsolutePath());
                pc.put(ObjectKey.DIRECTORY, buttonFolder.getFile());
            }
        });
        String path;
        if (folder.getFile() == null) {
            path = "Undefined";
            pathButton.setEnabled(false);
        } else {
            path = folder.getFile().getAbsolutePath();
            if (path.equals(selectedPath)) {
                pathButton.setSelected(true);
                haveSelected = true;
                PCGenSettings context = PCGenSettings.getInstance();
                context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path);
                selectedFile = folder.getFile();
            }
        }
        pathButton.setText(buildFolderText(folder, path));
        pathButton.setFont(font);
        radioButtons[folder.ordinal()] = pathButton;
        group.add(pathButton);
        if (folder == SourceFolder.OTHER) {
            Utility.buildRelativeConstraints(gbc, 1, GridBagConstraints.REMAINDER, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
        } else {
            Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
        }
        gbc.insets = new Insets(10, 25, 10, 25);
        panel.add(pathButton, gbc);
        if (folder == SourceFolder.OTHER) {
            Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHEAST);
            gbc.insets = new Insets(10, 25, 10, 25);
            panel.add(button, gbc);
        }
    }
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
    panel.add(new JLabel(" "), gbc);
    if (!haveSelected) {
        if (selectedPath != null) {
            JRadioButton btn = radioButtons[SourceFolder.OTHER.ordinal()];
            btn.setSelected(true);
            selectedFile = new File(selectedPath);
            SourceFolder.OTHER.setFile(selectedFile);
            path = selectedFile;
            btn.setText(buildFolderText(SourceFolder.OTHER, selectedFile.getAbsolutePath()));
        } else if (radioButtons[SourceFolder.VENDORDATA.ordinal()].isEnabled()) {
            JRadioButton btn = radioButtons[SourceFolder.VENDORDATA.ordinal()];
            btn.setSelected(true);
            selectedFile = SourceFolder.VENDORDATA.getFile();
        } else if (radioButtons[SourceFolder.HOMEBREWDATA.ordinal()].isEnabled()) {
            JRadioButton btn = radioButtons[SourceFolder.HOMEBREWDATA.ordinal()];
            btn.setSelected(true);
            selectedFile = SourceFolder.HOMEBREWDATA.getFile();
        } else {
            JRadioButton btn = radioButtons[SourceFolder.DATA.ordinal()];
            btn.setSelected(true);
            selectedFile = SourceFolder.DATA.getFile();
        }
    }
    pc.put(ObjectKey.DIRECTORY, selectedFile);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Font(java.awt.Font) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) ButtonGroup(javax.swing.ButtonGroup) PCGenSettings(pcgen.system.PCGenSettings) File(java.io.File)

Example 2 with ButtonGroup

use of javax.swing.ButtonGroup in project pcgen by PCGen.

the class CharacterStatsPanel method initComponents.

/**
	 * Build and initialise the user interface.
	 */
private void initComponents() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    JLabel label;
    ButtonGroup exclusiveGroup;
    Border etched = null;
    TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_abilities);
    title1.setTitleJustification(TitledBorder.LEFT);
    this.setBorder(title1);
    this.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    final GameMode gameMode = SettingsHandler.getGame();
    int row = 0;
    exclusiveGroup = new ButtonGroup();
    Utility.buildConstraints(c, 0, row++, 3, 1, 0, 0);
    label = new JLabel(LanguageBundle.getFormattedString("in_Prefs_abilitiesGenLabel", //$NON-NLS-1$
    gameMode.getDisplayName()));
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 0, row, 1, 1, 0, 0);
    label = new JLabel("  ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesUserRolledButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesUserRolled"));
    gridbag.setConstraints(abilitiesUserRolledButton, c);
    this.add(abilitiesUserRolledButton);
    exclusiveGroup.add(abilitiesUserRolledButton);
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesAllSameButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesAllSame") + ": ");
    gridbag.setConstraints(abilitiesAllSameButton, c);
    this.add(abilitiesAllSameButton);
    exclusiveGroup.add(abilitiesAllSameButton);
    Utility.buildConstraints(c, 1, row, 1, 1, 0, 0);
    label = new JLabel("  ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
    abilityScoreCombo = new JComboBoxEx();
    for (int i = gameMode.getStatMin(); i <= gameMode.getStatMax(); ++i) {
        abilityScoreCombo.addItem(String.valueOf(i));
    }
    gridbag.setConstraints(abilityScoreCombo, c);
    this.add(abilityScoreCombo);
    ReferenceManufacturer<RollMethod> mfg = gameMode.getModeContext().getReferenceContext().getManufacturer(RollMethod.class);
    List<RollMethod> rollMethods = mfg.getOrderSortedObjects();
    if (!rollMethods.isEmpty()) {
        Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
        abilitiesRolledButton = new JRadioButton("Rolled:");
        gridbag.setConstraints(abilitiesRolledButton, c);
        this.add(abilitiesRolledButton);
        exclusiveGroup.add(abilitiesRolledButton);
        Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
        abilityRolledModeCombo = new JComboBoxEx();
        for (RollMethod rm : rollMethods) {
            abilityRolledModeCombo.addItem(rm.getDisplayName());
        }
        gridbag.setConstraints(abilityRolledModeCombo, c);
        this.add(abilityRolledModeCombo);
    }
    Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
    final int purchaseMethodCount = methods.size();
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesPurchasedButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesPurchased") + ": ");
    gridbag.setConstraints(abilitiesPurchasedButton, c);
    this.add(abilitiesPurchasedButton);
    exclusiveGroup.add(abilitiesPurchasedButton);
    Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
    pMode = new String[purchaseMethodCount];
    pModeMethodName = new String[purchaseMethodCount];
    int i = 0;
    for (PointBuyMethod pbm : methods) {
        pMode[i] = pbm.getDescription();
        pModeMethodName[i] = pbm.getDisplayName();
        i++;
    }
    abilityPurchaseModeCombo = new JComboBoxEx(pMode);
    gridbag.setConstraints(abilityPurchaseModeCombo, c);
    this.add(abilityPurchaseModeCombo);
    //
    if (purchaseMethodCount == 0) {
        abilityPurchaseModeCombo.setVisible(false);
        abilitiesPurchasedButton.setVisible(false);
    }
    Utility.buildConstraints(c, 1, row++, 1, 1, 0, 0);
    label = new JLabel(" ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 1, row++, 3, 1, 0, 0);
    JButton purchaseModeButton = new JButton(LanguageBundle.getString("in_Prefs_purchaseModeConfig"));
    gridbag.setConstraints(purchaseModeButton, c);
    this.add(purchaseModeButton);
    purchaseModeButton.addActionListener(new PurchaseModeButtonListener());
    Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    label = new JLabel(" ");
    gridbag.setConstraints(label, c);
    this.add(label);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) RollMethod(pcgen.cdom.content.RollMethod) GridBagLayout(java.awt.GridBagLayout) PointBuyMethod(pcgen.core.PointBuyMethod) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) GameMode(pcgen.core.GameMode) ButtonGroup(javax.swing.ButtonGroup) JComboBoxEx(pcgen.gui2.util.JComboBoxEx) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 3 with ButtonGroup

use of javax.swing.ButtonGroup in project pcgen by PCGen.

the class RadioChooserDialog method buildButtonPanel.

/**
	 * Create the panel of radio buttons.
	 */
private void buildButtonPanel() {
    ListFacade<InfoFacade> availableList = chooser.getAvailableList();
    int row = 0;
    avaRadioButton = new JRadioButton[availableList.getSize()];
    avaGroup = new ButtonGroup();
    // Create the buttons
    for (InfoFacade infoFacade : availableList) {
        avaRadioButton[row] = new JRadioButton(infoFacade.toString(), false);
        avaGroup.add(avaRadioButton[row]);
        avaRadioButton[row].addActionListener(this);
        ++row;
    }
    int numRows = row;
    if (numRows > 0) {
        avaRadioButton[0].setSelected(true);
        selectedButton = avaRadioButton[0];
    }
    // Layout the buttons
    GridBagLayout gridbag = new GridBagLayout();
    buttonPanel = new JPanel();
    TitledBorder title = BorderFactory.createTitledBorder(null, "");
    buttonPanel.setBorder(title);
    buttonPanel.setLayout(gridbag);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    if (numRows > 11) {
        buildTwoColLayout(numRows, c, gridbag);
    } else {
        for (int i = 0; i < numRows; ++i) {
            int cr = i;
            c.anchor = GridBagConstraints.WEST;
            Utility.buildConstraints(c, 0, cr, 2, 1, 1, 0);
            gridbag.setConstraints(avaRadioButton[i], c);
            buttonPanel.add(avaRadioButton[i]);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) InfoFacade(pcgen.facade.core.InfoFacade) ButtonGroup(javax.swing.ButtonGroup) TitledBorder(javax.swing.border.TitledBorder)

Example 4 with ButtonGroup

use of javax.swing.ButtonGroup in project pcgen by PCGen.

the class OptionsPathDialog method initComponents.

private void initComponents() {
    setResizable(false);
    setTitle("Directory for options.ini location");
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    JLabel label = new JLabel("Select a directory to store PCGen options in:");
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.insets = new Insets(4, 4, 0, 4);
    getContentPane().add(label, gridBagConstraints);
    gridBagConstraints.insets = new Insets(2, 0, 2, 0);
    getContentPane().add(new JSeparator(), gridBagConstraints);
    label = new JLabel("If you have an existing options.ini file," + "then select the directory containing that file");
    gridBagConstraints.insets = new Insets(4, 4, 4, 4);
    getContentPane().add(label, gridBagConstraints);
    ActionListener handler = new ActionHandler();
    ButtonGroup group = new ButtonGroup();
    gridBagConstraints.insets = new Insets(0, 4, 0, 4);
    addRadioButton("<html><b>PCGen Dir</b>: This is the directory that PCGen is installed into", SettingsFilesPath.pcgen.name(), group, handler, gridBagConstraints);
    // Remark: do mac user really need to be able to put the file either in a specific mac dir or home?
    if (SystemUtils.IS_OS_MAC_OSX) {
        addRadioButton("<html><b>Mac User Dir</b>", SettingsFilesPath.mac_user.name(), group, handler, gridBagConstraints);
    } else if (SystemUtils.IS_OS_UNIX) {
        // putting it the same way as mac. merging all and using a system config dir instead would be better IMHO.
        addRadioButton("<html><b>Freedesktop configuration sub-directory</b> Use for most Linux/BSD", SettingsFilesPath.FD_USER.name(), group, handler, gridBagConstraints);
    }
    addRadioButton("<html><b>Home Dir</b>: This is your home directory", SettingsFilesPath.user.name(), group, handler, gridBagConstraints);
    addRadioButton("Select a directory to use", "select", group, handler, gridBagConstraints);
    dirField.setText(ConfigurationSettings.getSettingsDirFromFilePath(selectedDir));
    dirField.setEditable(false);
    gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagConstraints.weightx = 1;
    gridBagConstraints.insets = new Insets(0, 4, 0, 0);
    getContentPane().add(dirField, gridBagConstraints);
    dirButton.setText("...");
    dirButton.setEnabled(false);
    dirButton.addActionListener(handler);
    dirButton.setActionCommand("custom");
    dirButton.setMargin(new Insets(2, 2, 2, 2));
    GridBagConstraints bagConstraints = new GridBagConstraints();
    bagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    bagConstraints.insets = new Insets(0, 0, 0, 4);
    getContentPane().add(dirButton, bagConstraints);
    JButton okButton = new JButton("OK");
    okButton.setPreferredSize(new Dimension(75, 23));
    okButton.setActionCommand("ok");
    okButton.addActionListener(handler);
    bagConstraints.insets = new Insets(4, 0, 4, 0);
    getContentPane().add(okButton, bagConstraints);
    getRootPane().setDefaultButton(okButton);
    pack();
    setLocationRelativeTo(null);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JSeparator(javax.swing.JSeparator)

Example 5 with ButtonGroup

use of javax.swing.ButtonGroup in project voltdb by VoltDB.

the class DatabaseManagerSwing method main.

public void main() {
    JMenu jmenu;
    JMenuItem mitem;
    try {
        prefs = new DBMPrefs(fMain instanceof JApplet);
    } catch (Exception e) {
        System.err.println("Failed to load preferences.  Proceeding with defaults:\n");
    }
    if (prefs == null) {
        setLF(CommonSwing.Native);
    } else {
        autoRefresh = prefs.autoRefresh;
        displayRowCounts = prefs.showRowCounts;
        showSys = prefs.showSysTables;
        showSchemas = prefs.showSchemas;
        gridFormat = prefs.resultGrid;
        showTooltips = prefs.showTooltips;
        setLF(prefs.laf);
    }
    // (ulrivo): An actual icon.  N.b., this adds some tips to the tip map
    fMain.getContentPane().add(createToolBar(), "North");
    if (fMain instanceof java.awt.Frame) {
        ((java.awt.Frame) fMain).setIconImage(CommonSwing.getIcon("Frame"));
    }
    if (fMain instanceof java.awt.Window) {
        ((java.awt.Window) fMain).addWindowListener(this);
    }
    JMenuBar bar = new JMenuBar();
    // used shortcuts: CERGTSIUDOLM
    String[] fitems = { "-Connect...", "--", "OOpen Script...", "-Save Script...", "-Save Result...", "--", "-Exit" };
    jmenu = addMenu(bar, "File", fitems);
    // All actions after Connect and the divider are local.
    for (int i = 2; i < jmenu.getItemCount(); i++) {
        mitem = jmenu.getItem(i);
        if (mitem != null) {
            localActionList.add(mitem);
        }
    }
    Object[] vitems = { "RRefresh Tree", boxAutoRefresh, "--", boxRowCounts, boxShowSys, boxShowSchemas, boxShowGrid };
    addMenu(bar, "View", vitems);
    String[] sitems = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "EEXECUTE", "---", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "CCOMMIT*", "LROLLBACK*", "-CHECKPOINT*", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" };
    addMenu(bar, "Command", sitems);
    mRecent = new JMenu("Recent");
    mRecent.setMnemonic(KeyEvent.VK_R);
    bar.add(mRecent);
    ButtonGroup lfGroup = new ButtonGroup();
    lfGroup.add(rbNativeLF);
    lfGroup.add(rbJavaLF);
    lfGroup.add(rbMotifLF);
    boxShowSchemas.setSelected(showSchemas);
    boxShowGrid.setSelected(gridFormat);
    boxTooltips.setSelected(showTooltips);
    boxShowGrid.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, Event.CTRL_MASK));
    boxAutoRefresh.setSelected(autoRefresh);
    boxRowCounts.setSelected(displayRowCounts);
    boxShowSys.setSelected(showSys);
    rbNativeLF.setActionCommand("LFMODE:" + CommonSwing.Native);
    rbJavaLF.setActionCommand("LFMODE:" + CommonSwing.Java);
    rbMotifLF.setActionCommand("LFMODE:" + CommonSwing.Motif);
    tipMap.put(mitemUpdateSchemas, "Refresh the schema list in this menu");
    tipMap.put(rbAllSchemas, "Display items in all schemas");
    tipMap.put(mitemAbout, "Display product information");
    tipMap.put(mitemHelp, "Display advice for obtaining help");
    tipMap.put(boxAutoRefresh, "Refresh tree (and schema list) automatically" + "when YOU modify database objects");
    tipMap.put(boxShowSchemas, "Display object names in tree like schemaname.basename");
    tipMap.put(rbNativeLF, "Set Look and Feel to Native for your platform");
    tipMap.put(rbJavaLF, "Set Look and Feel to Java");
    tipMap.put(rbMotifLF, "Set Look and Feel to Motif");
    boxTooltips.setToolTipText("Display tooltips (hover text), like this");
    tipMap.put(boxAutoCommit, "Shows current Auto-commit mode.  Click to change");
    tipMap.put(boxLogging, "Shows current JDBC DriverManager logging mode.  Click to change");
    tipMap.put(boxShowSys, "Show system tables in table tree to the left");
    tipMap.put(boxShowGrid, "Show query results in grid (in text if off)");
    tipMap.put(boxRowCounts, "Show row counts with table names in tree");
    boxAutoRefresh.setMnemonic(KeyEvent.VK_C);
    boxShowSchemas.setMnemonic(KeyEvent.VK_Y);
    boxAutoCommit.setMnemonic(KeyEvent.VK_A);
    boxShowSys.setMnemonic(KeyEvent.VK_Y);
    boxShowGrid.setMnemonic(KeyEvent.VK_G);
    boxRowCounts.setMnemonic(KeyEvent.VK_C);
    boxLogging.setMnemonic(KeyEvent.VK_L);
    rbAllSchemas.setMnemonic(KeyEvent.VK_ASTERISK);
    rbNativeLF.setMnemonic(KeyEvent.VK_N);
    rbJavaLF.setMnemonic(KeyEvent.VK_J);
    rbMotifLF.setMnemonic(KeyEvent.VK_M);
    mitemUpdateSchemas.setMnemonic(KeyEvent.VK_U);
    Object[] soptions = { // Added: (weconsultants@users) New menu options
    rbNativeLF, rbJavaLF, rbMotifLF, "--", "-Set Fonts", "--", boxAutoCommit, "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", boxLogging, "--", "-Insert test data" };
    addMenu(bar, "Options", soptions);
    String[] stools = { "-Dump", "-Restore", "-Transfer" };
    jmenu = addMenu(bar, "Tools", stools);
    jmenu.setEnabled(TT_AVAILABLE);
    localActionList.add(jmenu);
    for (int i = 0; i < jmenu.getItemCount(); i++) {
        mitem = jmenu.getItem(i);
        if (mitem != null) {
            localActionList.add(mitem);
        }
    }
    mnuSchemas.setMnemonic(KeyEvent.VK_S);
    bar.add(mnuSchemas);
    JMenu mnuHelp = new JMenu("Help");
    mnuHelp.setMnemonic(KeyEvent.VK_H);
    mnuHelp.add(mitemAbout);
    mnuHelp.add(mitemHelp);
    mnuHelp.add(boxTooltips);
    rbAllSchemas.addActionListener(schemaListListener);
    // May be illegal:
    mitemUpdateSchemas.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            updateSchemaList();
        }
    });
    mitemHelp.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            JOptionPane.showMessageDialog(fMain.getContentPane(), HELP_TEXT, "HELP", JOptionPane.INFORMATION_MESSAGE);
        }
    });
    mitemAbout.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            JOptionPane.showMessageDialog(fMain.getContentPane(), ABOUT_TEXT, "About", JOptionPane.INFORMATION_MESSAGE);
        }
    });
    boxTooltips.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            showTooltips = boxTooltips.isSelected();
            resetTooltips();
        }
    });
    bar.add(mnuHelp);
    if (fMain instanceof JApplet) {
        ((JApplet) fMain).setJMenuBar(bar);
    } else if (fMain instanceof JFrame) {
        ((JFrame) fMain).setJMenuBar(bar);
    }
    initGUI();
    sRecent = new String[iMaxRecent];
    // Modified: (weconsultants@users)Mode code to CommonSwing for general use
    if (!(fMain instanceof JApplet)) {
        CommonSwing.setFramePositon((JFrame) fMain);
    }
    // Modified: (weconsultants@users) Changed from deprecated show()
    ((Component) fMain).setVisible(true);
    // (ulrivo): load query from command line
    if (defScript != null) {
        if (defDirectory != null) {
            defScript = defDirectory + File.separator + defScript;
        }
        // if insert stmet is thousands of records...skip showing it
        // as text.  Too huge.
        sqlScriptBuffer = DatabaseManagerCommon.readFile(defScript);
        if (4096 <= sqlScriptBuffer.length()) {
            int eoThirdLine = sqlScriptBuffer.indexOf('\n');
            if (eoThirdLine > 0) {
                eoThirdLine = sqlScriptBuffer.indexOf('\n', eoThirdLine + 1);
            }
            if (eoThirdLine > 0) {
                eoThirdLine = sqlScriptBuffer.indexOf('\n', eoThirdLine + 1);
            }
            if (eoThirdLine < 1) {
                eoThirdLine = 100;
            }
            txtCommand.setText("............... Script File loaded: " + defScript + " ..................... \n" + "............... Click Execute or Clear " + "...................\n" + sqlScriptBuffer.substring(0, eoThirdLine + 1) + "..........................................." + "..............................\n" + "............................................." + "............................\n");
            txtCommand.setEnabled(false);
        } else {
            txtCommand.setText(sqlScriptBuffer);
            sqlScriptBuffer = null;
            txtCommand.setEnabled(true);
        }
    }
    // This must be done AFTER all tip texts are put into the map
    resetTooltips();
    txtCommand.requestFocus();
}
Also used : JFrame(javax.swing.JFrame) ActionEvent(java.awt.event.ActionEvent) InvocationTargetException(java.lang.reflect.InvocationTargetException) AccessControlException(java.security.AccessControlException) SQLException(java.sql.SQLException) IOException(java.io.IOException) JApplet(javax.swing.JApplet) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JFrame(javax.swing.JFrame) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) JComponent(javax.swing.JComponent) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Aggregations

ButtonGroup (javax.swing.ButtonGroup)339 JPanel (javax.swing.JPanel)202 JRadioButton (javax.swing.JRadioButton)186 JLabel (javax.swing.JLabel)148 ActionEvent (java.awt.event.ActionEvent)134 ActionListener (java.awt.event.ActionListener)118 BoxLayout (javax.swing.BoxLayout)83 GridBagLayout (java.awt.GridBagLayout)81 JButton (javax.swing.JButton)75 JTextField (javax.swing.JTextField)70 JMenu (javax.swing.JMenu)69 GridBagConstraints (java.awt.GridBagConstraints)67 BorderLayout (java.awt.BorderLayout)64 Insets (java.awt.Insets)64 Dimension (java.awt.Dimension)58 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)57 FlowLayout (java.awt.FlowLayout)53 JMenuItem (javax.swing.JMenuItem)50 JCheckBox (javax.swing.JCheckBox)47 JScrollPane (javax.swing.JScrollPane)47