/** Create menus to selct cross-section and spine */ private void initMenus() { JMenuBar menuBar = new JMenuBar(); JMenu crosssectionMenu = new JMenu("Cross-section"); menuBar.add(crosssectionMenu); myCrossSectionSelection = new ButtonGroup(); for (String s : myCrossSections.keySet()) { JMenuItem item = new JRadioButtonMenuItem(s); crosssectionMenu.add(item); myCrossSectionSelection.add(item); item.addItemListener(this); } myCrossSectionSelection.setSelected( myCrossSectionSelection.getElements().nextElement().getModel(), true); JMenu spineMenu = new JMenu("Spine"); menuBar.add(spineMenu); mySpineSelection = new ButtonGroup(); for (String s : mySpines.keySet()) { JMenuItem item = new JRadioButtonMenuItem(s); spineMenu.add(item); mySpineSelection.add(item); item.addItemListener(this); } mySpineSelection.setSelected(mySpineSelection.getElements().nextElement().getModel(), true); setJMenuBar(menuBar); }
private void send() { Enumeration<AbstractButton> eab = bg.getElements(); String action = "", idS; int id = 0; while (eab.hasMoreElements()) { AbstractButton x = eab.nextElement(); if (x.isSelected()) { action = x.getActionCommand(); break; } } try { idS = line.getText(); id = Integer.parseInt(idS); } catch (Exception e) { Core.log("ID objektu je prirozene cislo!"); Core.exceptions.add(e); return; } if (verifyInput(id)) { Core.check(action, id); } else { Core.log("ID musi byt v uvedenem rozsahu"); return; } }
/** * Action of family radio button MultisensorItemPanel {@literal &} IndicatorTOItem must overrides */ protected void setFamily(String family) { _family = family; if (log.isDebugEnabled()) { log.debug("setFamily: for type \"" + _itemType + "\", family \"" + family + "\""); } _iconFamilyPanel.remove(_iconPanel); _iconPanel = new JPanel(new FlowLayout()); _iconFamilyPanel.add(_iconPanel, 0); HashMap<String, NamedIcon> map = ItemPalette.getIconMap(_itemType, _family); if (map != null) { _currentIconMap = map; } if (!_supressDragging) { _iconFamilyPanel.remove(_dragIconPanel); _dragIconPanel = new JPanel(new FlowLayout()); _iconFamilyPanel.add(_dragIconPanel, 0); makeDndIconPanel(_currentIconMap, "BeanStateUnknown"); } addIconsToPanel(_currentIconMap); _iconFamilyPanel.invalidate(); hideIcons(); Enumeration<AbstractButton> en = _familyButtonGroup.getElements(); while (en.hasMoreElements()) { JRadioButton but = (JRadioButton) en.nextElement(); if (_family != null && _family.equals(but.getText())) { but.setSelected(true); break; } } }
/** Adds the specified ActionListener to all possible buttons. */ public void addSelectionListener(ActionListener listener) { Enumeration<AbstractButton> elements = GROUP.getElements(); for (; elements.hasMoreElements(); ) { AbstractButton button = elements.nextElement(); button.addActionListener(listener); } }
protected void refreshTransformers() { if (model != null) { // Select the right transformer int index = 0; for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) { for (TransformerCategory c : controller.getCategories(elmtType)) { ButtonGroup g = buttonGroups.get(index); boolean active = model.getSelectedElementClass().equals(elmtType) && model.getSelectedCategory().equals(c); g.clearSelection(); TransformerUI t = model.getSelectedTransformerUI(); for (Enumeration<AbstractButton> btns = g.getElements(); btns.hasMoreElements(); ) { AbstractButton btn = btns.nextElement(); btn.setVisible(active); if (t != null && btn.getName().equals(t.getDisplayName())) { g.setSelected(btn.getModel(), true); } } index++; } } } }
/** * Reacts to property changes fired by the{@link ServerEditor}. * * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (ServerEditor.EDIT_PROPERTY.equals(name)) { Boolean value = (Boolean) evt.getNewValue(); if (editor.isEditing()) finishButton.setEnabled(value); else { if (originalIndexSpeed == -1) { setControlEnabled(originalIndexSpeed); } if (buttonsGroup != null) { Enumeration en = buttonsGroup.getElements(); JRadioButton button; int index; while (en.hasMoreElements()) { button = (JRadioButton) en.nextElement(); if (button.isSelected()) { index = Integer.parseInt(button.getActionCommand()); setControlEnabled(index); } } } } } else if (ServerEditor.ADD_MESSAGE_PROPERTY.equals(name)) { showMessagePanel(true, (JComponent) evt.getNewValue()); } else if (ServerEditor.REMOVE_MESSAGE_PROPERTY.equals(name)) { showMessagePanel(false, (JComponent) evt.getNewValue()); } else if (ServerEditor.APPLY_SERVER_PROPERTY.equals(name)) { apply(); } }
private void clear() { // Clear precent buttons for (Enumeration<AbstractButton> btns = buttonGroups.getElements(); btns.hasMoreElements(); ) { AbstractButton btn = btns.nextElement(); remove(btn); } }
/** * Iterates through all the elements in the group and returns the media type of the selected * button. */ NamedMediaType getSelectedMedia() { Enumeration<AbstractButton> elements = GROUP.getElements(); for (; elements.hasMoreElements(); ) { AbstractButton button = elements.nextElement(); if (button.isSelected()) return (NamedMediaType) button.getClientProperty(MEDIA); } return null; }
public static void clearButtonGroup(ButtonGroup g) { if (g == null || g.getButtonCount() == 0) return; Enumeration e = g.getElements(); List<AbstractButton> list = new ArrayList<AbstractButton>(); while (e.hasMoreElements()) list.add((AbstractButton) e.nextElement()); for (AbstractButton b : list) { g.remove(b); } }
@Override public JComponent getPreferredFocusedComponent() { final Enumeration<AbstractButton> enumeration = myGroup.getElements(); while (enumeration.hasMoreElements()) { final AbstractButton button = enumeration.nextElement(); if (button.isSelected()) { return button; } } return myPanel; }
// Get what the user selects as the answer public String getSelection() { String selectedChoice = null; Enumeration<AbstractButton> buttons = bg.getElements(); while (buttons.hasMoreElements()) { JRadioButton temp = (JRadioButton) buttons.nextElement(); if (temp.isSelected()) { selectedChoice = temp.getText(); } } return (selectedChoice); }
/** * Helper function to get text of selected radio button. * * @param buttonGroup * @return */ private String getSelectedButtonText(ButtonGroup buttonGroup) { for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements(); ) { AbstractButton button = buttons.nextElement(); if (button.isSelected()) { return button.getText(); } } return null; }
private String getSelectedScheduleId() { AbstractButton b; Enumeration<AbstractButton> en = schGroup.getElements(); while (en.hasMoreElements()) { b = en.nextElement(); if (b.isSelected()) { log.debug("schedule radio button " + b.getText()); return b.getName(); } } return null; }
/** * Sets the selected strack trace level on the radio buttons. The radio buttons store their stack * trace level as a client property and I'll look for a match using that. This way, we don't have * to edit this if new levels are created. * * @param newStackTraceLevel the new stack trace level. */ private void setSelectedStackTraceLevel(ShowStacktrace newStackTraceLevel) { Enumeration<AbstractButton> buttonEnumeration = stackTraceButtonGroup.getElements(); while (buttonEnumeration.hasMoreElements()) { JRadioButton radioButton = (JRadioButton) buttonEnumeration.nextElement(); ShowStacktrace level = (ShowStacktrace) radioButton.getClientProperty(STACK_TRACE_LEVEL_CLIENT_PROPERTY); if (newStackTraceLevel == level) { radioButton.setSelected(true); return; } } }
/** * Get the name of the current menu selections * * @param group * @return */ private String getSelection(ButtonGroup group) { Enumeration<AbstractButton> e = group.getElements(); while (e.hasMoreElements()) { AbstractButton button = e.nextElement(); if (button.isSelected()) { return button.getText(); } } return null; }
protected void setup() { clear(); if (model != null) { for (Enumeration<AbstractButton> btns = buttonGroups.getElements(); btns.hasMoreElements(); ) { AbstractButton btn = btns.nextElement(); add(btn); } JLabel box = new javax.swing.JLabel(); box.setMaximumSize(new java.awt.Dimension(32767, 32767)); addSeparator(); add(box); } }
public void actionPerformed(ActionEvent e) { Enumeration<AbstractButton> allRadioButton = radioGroup.getElements(); while (allRadioButton.hasMoreElements()) { JRadioButton tempSelectedButton = (JRadioButton) allRadioButton.nextElement(); if (tempSelectedButton.isSelected() && tempSelectedButton.getText().equalsIgnoreCase(FileConversionConstants.JSON_TO_CSV)) { this.fileConversionMainframe.setVisible(false); this.fileConversionMainframe.dispose(); JsonToCsvPage jsonToCsvFrameObj = new JsonToCsvPage(); jsonToCsvFrameObj.setVisible(true); } } }
/** * Returns the currently selected stack trace level. The radio buttons store their stack trace * level as a client property so once we get the selected button, we know the level. This way, we * don't have to edit this if new levels are created. Unfortunately, Swing doesn't have an easy * way to get the actual button from the group. * * @return the selected stack trace level */ private ShowStacktrace getSelectedStackTraceLevel() { ButtonModel selectedButtonModel = stackTraceButtonGroup.getSelection(); if (selectedButtonModel != null) { Enumeration<AbstractButton> buttonEnumeration = stackTraceButtonGroup.getElements(); while (buttonEnumeration.hasMoreElements()) { JRadioButton radioButton = (JRadioButton) buttonEnumeration.nextElement(); if (radioButton.getModel() == selectedButtonModel) { ShowStacktrace level = (ShowStacktrace) radioButton.getClientProperty(STACK_TRACE_LEVEL_CLIENT_PROPERTY); return level; } } } return ShowStacktrace.INTERNAL_EXCEPTIONS; }
// Boolean[] voidList contain pages need to be voided. Boolean[] selectList contain pages need // to be selected for sequence purpose public SwingViewSimpleBuilder( SwingSimpleController c, ButtonGroup statusButtonGroup, JLabel seqText, JButton submitButton, Boolean[][] statusArray) { super(c); swingControl = c; this.statusButtonGroup = statusButtonGroup; this.statusArray = statusArray; this.submitButton = submitButton; Enumeration buttons = statusButtonGroup.getElements(); this.voidButton = (JRadioButton) buttons.nextElement(); this.skipButton = (JRadioButton) buttons.nextElement(); this.selectButton = (JRadioButton) buttons.nextElement(); this.seqText = seqText; Icon ic = new ImageIcon("heart.gif"); this.seqText.setIcon(ic); // voidButton.setEnabled(false); voidButton.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { voidButtonActionPerformed(evt); } }); // seqText = new JLabel(); seqText.setText("----"); // selectButton = new JRadioButton(); selectButton.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { selectButtonActionPerformed(evt); } }); skipButton.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { skipButtonActionPerformed(evt); } }); }
/** * Select button from the group * * @param group * @param toSelect */ private void setSelectedButton(ButtonGroup group, int toSelect) { int i = 0; Enumeration buttons = group.getElements(); JRadioButton temp; while (buttons.hasMoreElements()) { temp = (JRadioButton) buttons.nextElement(); String text = temp.getText(); if ((text.equals(Lang.getString("TedConfigDialog.Never")) && toSelect == TedConfig.NEVER) // $NON-NLS-1$ || (text.equals(Lang.getString("TedConfigDialog.Ask")) && toSelect == TedConfig.ASK) // $NON-NLS-1$ || (text.equals(Lang.getString("TedConfigDialog.Always")) && toSelect == TedConfig.ALWAYS)) // $NON-NLS-1$ { temp.setSelected(true); } else temp.setSelected(false); i++; } }
public void doSelectionLaf() { try { C_Configuration cConfiguration = new C_Configuration(false); Enumeration lEnumeration = SC_RadioLaf.getElements(); // fenetrePrincipale.clearOnglets(); while (lEnumeration.hasMoreElements()) { JRadioButtonMenuItem lItem = (JRadioButtonMenuItem) (lEnumeration.nextElement()); if (lItem.isSelected()) { cConfiguration.setLaf(lItem.getText()); break; } } fenetrePrincipale.updateTexte(); // fenetrePrincipale.doSelectionArbre(); } catch (FichierConfInexistantException e) { System.err.println("-----ERREUR GRAVE N°5-----"); } }
/** * Get selected state from buttongroup * * @param group * @return */ private int getSelectedButton(ButtonGroup group) { int i = 0; Enumeration buttons = group.getElements(); JRadioButton temp; while (buttons.hasMoreElements()) { temp = (JRadioButton) buttons.nextElement(); if (temp.isSelected()) { // check which state is selected and return it String text = temp.getText(); if (text.equals(Lang.getString("TedConfigDialog.Never"))) // $NON-NLS-1$ return TedConfig.NEVER; else if (text.equals(Lang.getString("TedConfigDialog.Ask"))) // $NON-NLS-1$ return TedConfig.ASK; else if (text.equals((Lang.getString("TedConfigDialog.Always")))) // $NON-NLS-1$ return TedConfig.ALWAYS; } else i++; } // default return value return 1; }
/** Fires a property indicating that a new server is selected. */ private void apply() { // Check list of servers and remove empty from list String server = null; if (editor != null) { editor.stopEdition(); server = editor.getSelectedServer(); editor.onApply(); } if (server != null && server.length() > 0) { String port = editor.getSelectedPort(); editor.handleServers(server, editor.getSelectedPort()); String value = server + ServerEditor.SERVER_PORT_SEPARATOR + port; firePropertyChange(SERVER_PROPERTY, null, value); } if (buttonsGroup != null) { Enumeration en = buttonsGroup.getElements(); JRadioButton button; int index; while (en.hasMoreElements()) { button = (JRadioButton) en.nextElement(); if (button.isSelected()) { index = Integer.parseInt(button.getActionCommand()); switch (index) { case HIGH_SPEED: firePropertyChange( CONNECTION_SPEED_PROPERTY, null, Integer.valueOf(LoginCredentials.HIGH)); break; case MEDIUM_SPEED: firePropertyChange( CONNECTION_SPEED_PROPERTY, null, Integer.valueOf(LoginCredentials.MEDIUM)); break; case LOW_SPEED: firePropertyChange( CONNECTION_SPEED_PROPERTY, null, Integer.valueOf(LoginCredentials.LOW)); } } } } close(); }
protected void refreshControls() { if (model != null) { for (Enumeration<AbstractButton> btns = buttonGroups.getElements(); btns.hasMoreElements(); ) { AbstractButton btn = btns.nextElement(); btn.setVisible(false); } TransformerUI u = model.getSelectedTransformerUI(); if (u != null && model.isAttributeTransformerUI(u)) { // Ranking Function selectedColumn = model.getSelectedFunction(); if (selectedColumn != null) { if (selectedColumn.isRanking()) { for (AbstractButton btn : rankingSouthControls) { btn.setVisible(true); } } else if (selectedColumn.isPartition()) { for (AbstractButton btn : partitionSouthControls) { btn.setVisible(true); } } } } clearControlButtons(); if (u != null) { Function selectedColumn = model.getSelectedFunction(); if (selectedColumn != null) { AbstractButton[] bb = selectedColumn.getUI().getControlButton(); if (bb != null) { for (AbstractButton b : bb) { add(b); controlButtons.add(b); } } } } } }
private void refreshMenu() { // refresh the associated mnemonics, so that the keyboard shortcut // keys are properly renumbered... // get an enumeration to the elements of the current button group Enumeration e = frameRadioButtonMenuItemGroup.getElements(); int displayedCount = 1; int currentMenuCount = 0; while (e.hasMoreElements()) { BaseRadioButtonMenuItem b = (BaseRadioButtonMenuItem) e.nextElement(); // compute the key mnemonic based upon the currentMenuCount currentMenuCount = displayedCount; if (currentMenuCount > 9) { currentMenuCount /= 10; } b.setMnemonic(KeyEvent.VK_0 + currentMenuCount); b.setText(displayedCount + " " + b.getAssociatedFrame().getTitle()); displayedCount++; } }
/** * This executes one of the actions, based on the stored ArgoUML configuration. This function is * intended for the initial setting of the snap when ArgoUML is started. */ static void init() { String id = Configuration.getString(Argo.KEY_SNAP, DEFAULT_ID); List<Action> actions = createAdjustSnapActions(); for (Action a : actions) { if (a.getValue("ID").equals(id)) { a.actionPerformed(null); if (myGroup != null) { for (Enumeration e = myGroup.getElements(); e.hasMoreElements(); ) { AbstractButton ab = (AbstractButton) e.nextElement(); Action action = ab.getAction(); if (action instanceof ActionAdjustSnap) { String currentID = (String) action.getValue("ID"); if (id.equals(currentID)) { myGroup.setSelected(ab.getModel(), true); return; } } } } return; } } }
@Override protected JComponent createCenterPanel() { myTitledSeparator.setText(myAnalysisNoon); // include test option myInspectTestSource.setSelected(myAnalysisOptions.ANALYZE_TEST_SOURCES); // module scope if applicable myModuleButton.setText( AnalysisScopeBundle.message("scope.option.module.with.mnemonic", myModuleName)); boolean useModuleScope = false; if (myModuleName != null) { useModuleScope = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.MODULE; myModuleButton.setSelected(myRememberScope && useModuleScope); } myModuleButton.setVisible( myModuleName != null && ModuleManager.getInstance(myProject).getModules().length > 1); boolean useUncommitedFiles = false; final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final boolean hasVCS = !changeListManager.getAffectedFiles().isEmpty(); if (hasVCS) { useUncommitedFiles = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.UNCOMMITTED_FILES; myUncommitedFilesButton.setSelected(myRememberScope && useUncommitedFiles); } myUncommitedFilesButton.setVisible(hasVCS); DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement(ALL); final List<? extends ChangeList> changeLists = changeListManager.getChangeListsCopy(); for (ChangeList changeList : changeLists) { model.addElement(changeList.getName()); } myChangeLists.setModel(model); myChangeLists.setEnabled(myUncommitedFilesButton.isSelected()); myChangeLists.setVisible(hasVCS); // file/package/directory/module scope if (myFileName != null) { myFileButton.setText(myFileName); myFileButton.setMnemonic(myFileName.charAt(getSelectedScopeMnemonic())); } else { myFileButton.setVisible(false); } VirtualFile file = PsiUtilBase.getVirtualFile(myContext); ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); boolean searchInLib = file != null && (fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file)); String preselect = StringUtil.isEmptyOrSpaces(myAnalysisOptions.CUSTOM_SCOPE_NAME) ? FindSettings.getInstance().getDefaultScopeName() : myAnalysisOptions.CUSTOM_SCOPE_NAME; if (searchInLib && GlobalSearchScope.projectScope(myProject).getDisplayName().equals(preselect)) { preselect = GlobalSearchScope.allScope(myProject).getDisplayName(); } if (GlobalSearchScope.allScope(myProject).getDisplayName().equals(preselect) && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM) { myAnalysisOptions.CUSTOM_SCOPE_NAME = preselect; searchInLib = true; } // custom scope myCustomScopeButton.setSelected( myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM); myScopeCombo.init(myProject, searchInLib, true, preselect); // correct selection myProjectButton.setSelected( myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.PROJECT || myFileName == null); myFileButton.setSelected( myFileName != null && (!myRememberScope || myAnalysisOptions.SCOPE_TYPE != AnalysisScope.PROJECT && !useModuleScope && myAnalysisOptions.SCOPE_TYPE != AnalysisScope.CUSTOM && !useUncommitedFiles)); myScopeCombo.setEnabled(myCustomScopeButton.isSelected()); final ActionListener radioButtonPressed = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onScopeRadioButtonPressed(); } }; final Enumeration<AbstractButton> enumeration = myGroup.getElements(); while (enumeration.hasMoreElements()) { enumeration.nextElement().addActionListener(radioButtonPressed); } // additional panel - inspection profile chooser JPanel wholePanel = new JPanel(new BorderLayout()); wholePanel.add(myPanel, BorderLayout.NORTH); final JComponent additionalPanel = getAdditionalActionSettings(myProject); if (additionalPanel != null) { wholePanel.add(additionalPanel, BorderLayout.CENTER); } new RadioUpDownListener( myProjectButton, myModuleButton, myUncommitedFilesButton, myFileButton, myCustomScopeButton); return wholePanel; }
private int findSelected(ButtonGroup group) { int i = 0; for (Enumeration<AbstractButton> bs = group.getElements(); bs.hasMoreElements(); i++) if (bs.nextElement().isSelected()) return i; return -1; }
public Enumeration<AbstractButton> getElements() { return bg.getElements(); }