Search in sources :

Example 51 with ButtonGroup

use of javax.swing.ButtonGroup in project JMRI by JMRI.

the class ClockMonPanel method initComponents.

@Override
public void initComponents(NceSystemConnectionMemo m) throws Exception {
    this.memo = m;
    this.tc = m.getNceTrafficController();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // Internal Clock Info Panel
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JPanel pane2 = new JPanel();
    GridBagLayout gLayout = new GridBagLayout();
    GridBagConstraints gConstraints = new GridBagConstraints();
    javax.swing.border.Border pane2Border = BorderFactory.createEtchedBorder();
    javax.swing.border.Border pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("InternalClockStatusBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(internalDisplayStatus);
    internalDisplayStatus.setEditable(false);
    internalDisplayStatus.setBorder(BorderFactory.createEmptyBorder());
    add(pane2);
    // NCE Clock Info Panel
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("NceClockStatusBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(nceDisplayStatus);
    nceDisplayStatus.setEditable(false);
    nceDisplayStatus.setBorder(BorderFactory.createEmptyBorder());
    add(pane2);
    // setting time items
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("SetClockValuesBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(new JLabel(rb.getString("LabelTime")));
    pane2.add(hours);
    pane2.add(new JLabel(rb.getString("LabelTimeSep")));
    pane2.add(minutes);
    pane2.add(new JLabel(rb.getString("LabelTimeSep")));
    pane2.add(seconds);
    seconds.setEditable(false);
    pane2.add(new JLabel(" "));
    pane2.add(amPm);
    amPm.setEditable(false);
    pane2.add(new JLabel(" "));
    pane2.add(setClockButton);
    add(pane2);
    // set clock ratio items
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("SetClockRatioBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(new JLabel(rb.getString("LabelRatio")));
    pane2.add(rateNce);
    pane2.add(new JLabel(rb.getString("LabelToOne")));
    pane2.add(setRatioButton);
    add(pane2);
    // add 12/24 clock options
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("SetClock12/24ModeBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(twentyFour);
    pane2.add(new JLabel(" "));
    pane2.add(set1224Button);
    add(pane2);
    //  pane2 = new JPanel();
    //  pane2.setLayout(new BoxLayout(pane2, BoxLayout.X_AXIS));
    //  pane2.add(new JLabel(" "));
    //  pane2.add(status);
    //  add(pane2);
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("InterfaceCommandBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.setLayout(gLayout);
    gConstraints.gridx = 0;
    gConstraints.gridy = 0;
    gConstraints.gridwidth = 1;
    gConstraints.gridheight = 1;
    gConstraints.ipadx = 10;
    gConstraints.ipady = 1;
    gConstraints.insets = new Insets(1, 1, 1, 1);
    pane2.add(setStartNceButton, gConstraints);
    gConstraints.gridx++;
    pane2.add(setStopNceButton, gConstraints);
    gConstraints.gridx++;
    pane2.add(readButton, gConstraints);
    ButtonGroup modeGroup = new ButtonGroup();
    modeGroup.add(setSyncModeInternalMaster);
    modeGroup.add(setSyncModeNceMaster);
    modeGroup.add(setSyncModeOff);
    gConstraints.gridx = 0;
    gConstraints.gridy++;
    gConstraints.gridwidth = 3;
    pane2.add(setSyncModeNceMaster, gConstraints);
    gConstraints.gridy++;
    pane2.add(setSyncModeInternalMaster, gConstraints);
    gConstraints.gridy++;
    pane2.add(setSyncModeOff, gConstraints);
    gConstraints.gridy++;
    pane2.add(setSyncButton, gConstraints);
    setSyncModeInternalMaster.setEnabled(true);
    setSyncModeNceMaster.setEnabled(true);
    if (tc.getUsbSystem() != NceTrafficController.USB_SYSTEM_NONE) {
        // needs memory commands to sync
        setSyncModeInternalMaster.setEnabled(false);
        setSyncModeNceMaster.setEnabled(false);
    }
    add(pane2);
    // add polling speed
    pane2 = new JPanel();
    pane2Border = BorderFactory.createEtchedBorder();
    pane2Titled = BorderFactory.createTitledBorder(pane2Border, rb.getString("InterfaceUpdRateBorderText"));
    pane2.setBorder(pane2Titled);
    pane2.add(new JLabel(rb.getString("InterfaceUpdRate")));
    pane2.add(new JLabel(" "));
    pane2.add(pollingSpeed);
    pollingSpeed.setText("" + pollingInterval);
    pane2.add(new JLabel(" "));
    pane2.add(new JLabel(rb.getString("InterfaceUpdRateSufix")));
    pane2.add(new JLabel(" "));
    pane2.add(setPollingSpeedButton);
    add(pane2);
    //        // add PID values
    //        gLayout = new GridBagLayout();
    //        gConstraints = new GridBagConstraints();
    //        pane2 = new JPanel();
    //        pane2Border = BorderFactory.createEtchedBorder();
    //        pane2Titled = BorderFactory.createTitledBorder(pane2Border,
    //                                                       rb.getString("InterfacePidBorderText"));
    //        pane2.setBorder(pane2Titled);
    //        pane2.setLayout(gLayout);
    //        gConstraints.gridx = 0;
    //        gConstraints.gridy = 0;
    //        gConstraints.gridwidth = 1;
    //        gConstraints.gridheight = 1;
    //        gConstraints.ipadx = 10;
    //        gConstraints.ipady = 1;
    //        gConstraints.insets = new Insets(3, 3, 3, 3);
    //        pane2.add(new JLabel(rb.getString("InterfacePidNce")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainP")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(ncePidGainP, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainI")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(ncePidGainI, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainD")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(ncePidGainD, gConstraints);
    //        gConstraints.gridx++;
    //        gConstraints.gridheight = 2;
    //        pane2.add(setPidButton, gConstraints);
    //        gConstraints.gridheight = 0;
    //        gConstraints.gridx = 0;
    //        gConstraints.gridy = 1;
    //        pane2.add(new JLabel(rb.getString("InterfacePidInt")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainP")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(intPidGainP, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainI")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(intPidGainI, gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(new JLabel(rb.getString("InterfacePidGainD")), gConstraints);
    //        gConstraints.gridx++;
    //        pane2.add(intPidGainD, gConstraints);
    //        ncePidGainP.setText(fiveDigits.format(ncePidGainPv));
    //        ncePidGainI.setText(fiveDigits.format(ncePidGainIv));
    //        ncePidGainD.setText(fiveDigits.format(ncePidGainDv));
    //        intPidGainP.setText(fiveDigits.format(intPidGainPv));
    //        intPidGainI.setText(fiveDigits.format(intPidGainIv));
    //        intPidGainD.setText(fiveDigits.format(intPidGainDv));
    //        add(pane2);
    // install "read" button handler
    readButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueReadAllRequest();
        }
    });
    // install "set" button handler
    setClockButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClockSet(Integer.parseInt(hours.getText().trim()), Integer.parseInt(minutes.getText().trim()), Integer.parseInt(seconds.getText().trim()));
        }
    });
    // install "stop" clock button handler
    setStopNceButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClockStop();
        }
    });
    // install "start" clock button handler
    setStartNceButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClockStart();
        }
    });
    // install set fast clock ratio
    setRatioButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changeNceClockRatio();
        }
    });
    // install set 12/24 button
    set1224Button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            issueClock1224(twentyFour.isSelected());
        }
    });
    // install Sync Change Clock button
    setSyncButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changeSyncMode();
        }
    });
    // install "setPolling" button handler
    setPollingSpeedButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changePollingSpeed(Double.parseDouble(pollingSpeed.getText().trim()));
        }
    });
    // install "setPid" button handler
    setPidButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            changePidValues();
        }
    });
    if (clockMode == SYNCMODE_OFF) {
        setSyncModeOff.setSelected(true);
    }
    if (clockMode == SYNCMODE_INTERNAL_MASTER) {
        setSyncModeInternalMaster.setSelected(true);
    }
    if (clockMode == SYNCMODE_NCE_MASTER) {
        setSyncModeNceMaster.setSelected(true);
    }
    this.setSize(400, 300);
    // Create a timebase listener for the Minute change events
    internalClock = InstanceManager.getNullableDefault(jmri.Timebase.class);
    if (internalClock == null) {
        log.error("No Timebase Instance; clock will not run");
        return;
    }
    minuteChangeListener = new java.beans.PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            newInternalMinute();
        }
    };
    internalClock.addMinuteChangeListener(minuteChangeListener);
    // start display alarm timer
    alarmDisplayUpdateHandler();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Timebase(jmri.Timebase) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup)

Example 52 with ButtonGroup

use of javax.swing.ButtonGroup in project processdash by dtuma.

the class TaskScheduleChart method showSaveAsDialog.

private TaskScheduleChartSettings showSaveAsDialog(TaskScheduleChartSettings currentSettings, String chartID) {
    String title = resources.getString("Configure.Save_As.Window_Title");
    String namePrompt = resources.getString("Configure.Save_As.Name_Prompt");
    JTextField chartNameField = new JTextField();
    if (currentSettings != null)
        chartNameField.setText(currentSettings.getCustomName());
    new JOptionPaneActionHandler().install(chartNameField);
    String scopePrompt = resources.getString("Configure.Save_As.Scope_Prompt");
    ButtonGroup group = new ButtonGroup();
    JRadioButton localScopeButton = new JRadioButton(resources.getString("Configure.Save_As.Scope_Local"));
    group.add(localScopeButton);
    JRadioButton globalScopeButton = new JRadioButton(resources.getString("Configure.Save_As.Scope_Global"));
    group.add(globalScopeButton);
    boolean global = (currentSettings != null && currentSettings.isGlobal());
    (global ? globalScopeButton : localScopeButton).setSelected(true);
    String errorKey = null;
    while (true) {
        BoxUtils errorBox;
        if (errorKey != null) {
            JLabel errorLabel = new JLabel(resources.getString(errorKey));
            errorLabel.setForeground(Color.RED);
            errorBox = BoxUtils.hbox(20, errorLabel);
        } else {
            errorBox = BoxUtils.hbox();
        }
        Object[] message = { namePrompt, BoxUtils.hbox(20, chartNameField), new JOptionPaneTweaker.GrabFocus(chartNameField), errorBox, scopePrompt, BoxUtils.hbox(20, localScopeButton), BoxUtils.hbox(20, globalScopeButton) };
        int userChoice = JOptionPane.showConfirmDialog(configurationDialog, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
        if (userChoice != JOptionPane.OK_OPTION)
            return null;
        String chartName = chartNameField.getText();
        chartName = (chartName == null ? "" : chartName.trim());
        if (chartName.length() == 0) {
            errorKey = "Configure.Save_As.Name_Missing";
            continue;
        }
        TaskScheduleChartSettings result = new TaskScheduleChartSettings();
        if (localScopeButton.isSelected())
            result.setTaskListID(taskList.getID());
        result.setChartID(chartID);
        result.setCustomName(chartName);
        if (result.hasSameNameAs(currentSettings) == false && chartNameIsTaken(chartName)) {
            errorKey = "Configure.Save_As.Duplicate_Name";
            continue;
        }
        return result;
    }
}
Also used : JOptionPaneTweaker(net.sourceforge.processdash.ui.lib.JOptionPaneTweaker) JOptionPaneActionHandler(net.sourceforge.processdash.ui.lib.JOptionPaneActionHandler) JRadioButton(javax.swing.JRadioButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) BoxUtils(net.sourceforge.processdash.ui.lib.BoxUtils) Point(java.awt.Point) ButtonGroup(javax.swing.ButtonGroup) EventObject(java.util.EventObject)

Example 53 with ButtonGroup

use of javax.swing.ButtonGroup in project processdash by dtuma.

the class WBSEditor method buildTeamMenu.

private JMenu buildTeamMenu(String initials, DataTableModel dataModel) {
    JMenu result = new JMenu("Team");
    result.setMnemonic('T');
    if (isMode(MODE_PLAIN))
        result.add(new ShowTeamMemberListEditorMenuItem());
    TeamMember m = null;
    if (initials != null)
        m = teamProject.getTeamMemberList().findTeamMember(initials);
    if (m != null) {
        if (!readOnly) {
            WatchCoworkerTimesMenuItem watchMenu = new WatchCoworkerTimesMenuItem(dataModel);
            result.add(new OptimizeEditingForIndivMenuItem(m, watchMenu));
            result.add(watchMenu);
        }
        // make nodes visible if they have a data problem and they are
        // assigned to this user
        ErrorNotesColumn.showNodesWithErrors(teamProject.getWBS(), null, new AssignedToMemberTest(dataModel, m));
    }
    result.add(new ShowTeamTimePanelMenuItem());
    if (showActualData) {
        ButtonGroup g = new ButtonGroup();
        result.add(new BottomUpShowReplanMenuItem(g));
        result.add(new BottomUpShowPlanMenuItem(g));
    }
    if (isMode(MODE_PLAIN)) {
        result.add(new SubteamBalancingMenu(teamProject.getTeamMemberList(), teamTimePanel, dirtyListener, showTeamTimePanelMenuItem, guiPrefs));
        result.add(new BottomUpShowBalancedTeamBar());
        result.add(new BottomUpShowHoursPerWeekMenuItem());
        result.add(new BottomUpIncludeUnassignedMenuItem());
    }
    return result;
}
Also used : SubteamBalancingMenu(teamdash.team.SubteamBalancingMenu) TeamMember(teamdash.team.TeamMember) ButtonGroup(javax.swing.ButtonGroup) JMenu(javax.swing.JMenu)

Example 54 with ButtonGroup

use of javax.swing.ButtonGroup in project processdash by dtuma.

the class TranslationSharer method promptForAuthorInfo.

private void promptForAuthorInfo() {
    JLabel authorLabel = new JLabel(resources.getString("Translation.Sharing.Author.Name_Prompt"));
    JTextField author = new JTextField(20);
    JLabel emailLabel = new JLabel(resources.getString("Translation.Sharing.Author.Email_Prompt"));
    JTextField email = new JTextField(30);
    JRadioButton yesOption = new JRadioButton(resources.getString("Translation.Sharing.Author.Yes_Option"), true);
    JRadioButton noOption = new JRadioButton(resources.getString("Translation.Sharing.Author.No_Option"));
    ButtonGroup group = new ButtonGroup();
    group.add(yesOption);
    group.add(noOption);
    ContactOptionListener l = new ContactOptionListener(yesOption, new JComponent[] { authorLabel, author, emailLabel, email });
    yesOption.addActionListener(l);
    noOption.addActionListener(l);
    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(yesOption);
    buttonBox.add(Box.createHorizontalStrut(10));
    buttonBox.add(noOption);
    buttonBox.add(Box.createHorizontalGlue());
    Object[] message = new Object[] { resources.getString("Translation.Sharing.Author.Prompt"), buttonBox, inputBox(authorLabel, author), inputBox(emailLabel, email) };
    JOptionPane.showMessageDialog(null, message, resources.getString("Translation.Sharing.Author.Title"), JOptionPane.OK_OPTION);
    if (yesOption.isSelected()) {
        prefs.put(AUTHOR_SETTING, author.getText());
        prefs.put(EMAIL_SETTING, email.getText());
        try {
            prefs.flush();
        } catch (BackingStoreException e) {
            System.out.println(resources.getString("Translation.Errors.Cant_Save_Preferences"));
            e.printStackTrace();
        }
    }
}
Also used : JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) BackingStoreException(java.util.prefs.BackingStoreException) JLabel(javax.swing.JLabel) Box(javax.swing.Box) JTextField(javax.swing.JTextField)

Example 55 with ButtonGroup

use of javax.swing.ButtonGroup in project processdash by dtuma.

the class EditImportDirectoryPanel method buildMainPanelContents.

protected void buildMainPanelContents() {
    DocumentListener listener = (DocumentListener) EventHandler.create(DocumentListener.class, this, "updateInstruction");
    if (instr.isUrlOnly()) {
        String chooseUrlPrompt = getString("Choose_URL");
        add(indentedComponent(2, new WrappingText(chooseUrlPrompt)));
        add(verticalSpace(1));
        url = new JTextField(instr.getURL());
        url.getDocument().addDocumentListener(listener);
        add(indentedComponent(4, url));
    } else {
        String chooseDirectoryPrompt = getString("Choose_Directory");
        add(indentedComponent(2, new WrappingText(chooseDirectoryPrompt)));
        add(verticalSpace(1));
        directory = new DirectoryChooser();
        directory.getDocument().addDocumentListener(listener);
        add(indentedComponent(4, directory));
    }
    add(verticalSpace(2));
    String choosePrefixPrompt = getString("Choose_Prefix");
    add(indentedComponent(2, new WrappingText(choosePrefixPrompt)));
    add(verticalSpace(1));
    prefix = new JTextField(instr.getPrefix());
    prefix.getDocument().addDocumentListener(listener);
    add(indentedComponent(4, prefix));
    if (fromManagePanel == false) {
        add(verticalSpace(2));
        String makeAutomaticPrompt = getString("Make_Automatic");
        add(indentedComponent(2, new WrappingText(makeAutomaticPrompt)));
        makeAutomatic = new ButtonGroup();
        Box autoButtonBox = Box.createHorizontalBox();
        autoButtonBox.add(createAutomaticButton("Yes"));
        autoButtonBox.add(createAutomaticButton("No"));
        add(indentedComponent(4, autoButtonBox));
    }
    add(verticalSpace(4));
    error = new WrappingText("");
    error.setForeground(Color.red);
    add(error);
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ButtonGroup(javax.swing.ButtonGroup) Box(javax.swing.Box) WrappingText(net.sourceforge.processdash.ui.lib.WrappingText) JTextField(javax.swing.JTextField)

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