private static void loc (Component c, String key) { if (!(c instanceof JLabel)) { c.getAccessibleContext ().setAccessibleName (loc ("AN_" + key)); c.getAccessibleContext ().setAccessibleDescription (loc ("AD_" + key)); } if (c instanceof AbstractButton) { Mnemonics.setLocalizedText ( (AbstractButton) c, loc ("CTL_" + key) ); } else if (c instanceof JLabel) { Mnemonics.setLocalizedText ( (JLabel) c, loc ("CTL_" + key) ); } }
@Override public void paint(Graphics g, JComponent c) { AbstractButton b = (AbstractButton) c; if (RapidLookTools.isToolbarButton(b)) { RapidLookTools.drawToolbarButton(g, b); super.paint(g, c); return; } int w = c.getWidth(); int h = c.getHeight(); if (w <= 0 || h <= 0) { return; } if (b.isContentAreaFilled()) { RapidLookTools.drawButton(b, g, RapidLookTools.createShapeForButton(b)); } if (b.isBorderPainted()) { RapidLookTools.drawButtonBorder(b, g, RapidLookTools.createBorderShapeForButton(b)); } super.paint(g, c); }
@Override public Object transformValue(Object value) { if (value instanceof OutlineViewOutlineColumn) { OutlineViewOutlineColumn c = (OutlineViewOutlineColumn) value; String dn = c.getRawColumnName (); if (dn == null) { dn = c.getHeaderValue ().toString (); } String desc = c.getShortDescription (null); if (desc == null) { return dn; } return NbBundle.getMessage (OutlineView.class, "OutlineViewOutline_NameAndDesc", dn, desc); // NOI18N } else if (COLUMNS_SELECTOR_HINT.equals (value)) { return NbBundle.getMessage (OutlineView.class, COLUMNS_SELECTOR_HINT); } else if (value instanceof AbstractButton) { AbstractButton b = (AbstractButton) value; Mnemonics.setLocalizedText (b, b.getText ()); return b; } else if (value instanceof VisualizerNode) { return Visualizer.findNode (value); } return PropertiesRowModel.getValueFromProperty(value); }
public void mouseReleased( MouseEvent evt ) { if( evt.isControlDown() ) { dragWindow = false; return; } else if (dragMap) { dragMap = false; zoomToRect(); map.repaint(); } else if( dragWindow ) { dragWindow = false; map.repaint(); } if (profileEnabled) { AbstractButton b = map.getMapTools().profileB; b.doClick(); profileEnabled=false; } }
@Test public void testSetValueObject() { final AbstractButton buttonA = new JButton(); buttonA.setActionCommand("iqGfVwJDLd"); final AbstractButton buttonB = new JButton(); buttonB.setActionCommand("ouzioKGsKi"); final AbstractButton buttonC = new JButton(); buttonC.setActionCommand("pKVEAoQzmr"); group.add(buttonA); group.add(buttonB); group.add(buttonC); ButtonGroupHelper.setValue(group, new Object() { @Override public String toString() { return "ouzioKGsKi"; } }); assertThat(buttonB.isSelected()).isTrue(); }
@Override public void mouseExited(MouseEvent me) { boolean res = true; try { if (MenuUI.this.menuItem.getParent().getParent() != null) { if (((JMenu) MenuUI.this.menuItem).getParent().getParent() instanceof InternalFrameTitlePane) { res = false; } } } catch (Exception exp) { // do nothing } if (res && ((AbstractButton) me.getSource()).isRolloverEnabled()) { ((AbstractButton) me.getSource()).getModel().setRollover(false); ((JComponent) me.getSource()).repaint(); } }
/** * Adds a button deriving all properties from specified action * @param action action associated to the button * @return created button * @see AbstractJMTAction#setSelectable(boolean) * @see AbstractJMTAction#setGroup(int) */ public AbstractButton addGenericButton(AbstractJMTAction action) { Boolean selectable = (Boolean) action.getValue(AbstractJMTAction.SELECTABLE); Integer group = (Integer) action.getValue(AbstractJMTAction.GROUP); if (selectable != null && selectable.booleanValue()) { // This is a toggle button if (group != null) { return this.addToggleButton(action, group.intValue()); } else { return this.addToggleButton(action); } } else { // This is a button return this.addButton(action); } }
private void enableComponents(Component comp, boolean enable) { if (comp instanceof Container) { for (Component subComp : ((Container)comp).getComponents()) { enableComponents(subComp, enable); } } if ((comp instanceof JComboBox) || ((comp instanceof JTextComponent) && ((JTextComponent)comp).isEditable()) || (comp instanceof AbstractButton) || (comp instanceof JList)) { if (enable) { Boolean b = enableMap.get(comp); if (b != null) { comp.setEnabled(b); } else { comp.setEnabled(true); } } else { enableMap.put(comp, comp.isEnabled()); comp.setEnabled(false); } } }
private void selectABrowser() { String browser = getPreviouslySelectedBrowser(); if (browser == null) { browser = RunManager.getGlobalSettings().getBrowser(); } if (browser != null) { for (Enumeration<AbstractButton> buttons = browserSelectButtonGroup.getElements(); buttons.hasMoreElements();) { AbstractButton button = buttons.nextElement(); if (button.getActionCommand().equals(browser)) { button.setSelected(true); } } } else { browserSelectButtonGroup.setSelected(browserSelectButtonGroup.getElements().nextElement().getModel(), true); } }
public void paint(Graphics g, JComponent c) { ColorUtil.setupAntialiasing(g); AbstractButton button = (AbstractButton)c; hiddenToggle.setBorderPainted(true); // hiddenToggle.setBorderPainted(button.isBorderPainted()); hiddenToggle.setRolloverEnabled(button.isRolloverEnabled()); hiddenToggle.setFocusable(button.isFocusable()); hiddenToggle.setFocusPainted(button.isFocusPainted()); hiddenToggle.setMargin(button.getMargin()); // hiddenToggle.setBorder(button.getBorder()); hiddenToggle.getModel().setRollover(button.getModel().isRollover()); hiddenToggle.getModel().setPressed(button.getModel().isPressed()); hiddenToggle.getModel().setArmed(button.getModel().isArmed()); hiddenToggle.getModel().setSelected(button.getModel().isSelected()); hiddenToggle.setBounds(button.getBounds()); super.paint(g, c); }
/** * @return the toolbar for the exact wizard. Shamelessly uses icon from the main jmt frame */ protected JMTToolBar makeToolbar() { JMTToolBar tb = new JMTToolBar(JMTImageLoader.getImageLoader()); tb.setFloatable(false); //null values add a gap between toolbar icons AbstractJMTAction[] actions = { FILE_NEW, FILE_OPEN, FILE_SAVE, null, ACTION_SOLVE, SWITCH_TO_SIMULATOR, ACTION_RANDOMIZE_MODEL, null, HELP,null }; String[] htext = { "Creates a new model", "Opens a saved model", "Saves the current model", "Solves the current model", "Import current model to JSIMwiz to solve it with the simulator", "Randomize model data", "Show help"}; ArrayList<AbstractButton> buttons = new ArrayList<AbstractButton>(); buttons.addAll(tb.populateToolbar(actions)); //adds the algorithm selection box amvaPanel = new AMVAPanel(this); tb.add(amvaPanel); // Adds help for (int i = 0; i < buttons.size(); i++) { AbstractButton button = buttons.get(i); help.addHelp(button, htext[i]); } return tb; }
public BugReportViewerDialog(Window owner) { super(owner, "send_bugreport_info", ModalityType.APPLICATION_MODAL, new Object[] {}); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); Collection<AbstractButton> buttons = new LinkedList<AbstractButton>(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 1; gbc.insets = new Insets(GAP * 2, GAP, GAP * 2, GAP); gbc.fill = GridBagConstraints.BOTH; propArea = new JTextArea(); propArea.setEditable(false); scrollPanePropArea = new JScrollPane(propArea); panel.add(scrollPanePropArea, gbc); buttons.add(makeCloseButton()); layoutDefault(panel, LARGE, buttons); }
/** Requests refresh of our lookup everytime component is chagned. */ public void propertyChange(java.beans.PropertyChangeEvent evt) { if (TopComponent.Registry.PROP_ACTIVATED.equals (evt.getPropertyName())) { org.openide.util.Utilities.actionsGlobalContext ().lookup (javax.swing.ActionMap.class); } if ("permanentFocusOwner".equals(evt.getPropertyName())) { Component[] arr = { (Component)evt.getNewValue() }; if (arr[0] instanceof AbstractButton) { Action a = ((AbstractButton)arr[0]).getAction(); if (a instanceof ContextAwareAction) { // ignore focus change into a button with our action return; } } blickActionMap(null, arr); } }
private void switchModes(AbstractButton newSelection) { PrivilegeListEditor editor = editors.get(newSelection); PrivilegeList privList = getCurrentPrivilegeList(); if( !editor.canHandle(privilegeNode, privList) ) { String message = CurrentLocale.get("security.editor.mayLoseEntries"); int result = JOptionPane.showConfirmDialog(this, message, null, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if( result == JOptionPane.NO_OPTION ) { lastSelected.setSelected(true); return; } } lastSelected = newSelection; setContainer(editor.createView(domainObj, privilegeNode, privList)); }
@Override public void actionPerformed( ActionEvent ae ) { if ("pressed".equals(ae.getActionCommand())) { //NOI18N JComponent jc = (JComponent) ae.getSource(); Point p = new Point(jc.getWidth(), jc.getHeight()); SwingUtilities.convertPointToScreen(p, jc); if (!ButtonPopupSwitcher.isShown()) { ButtonPopupSwitcher.showPopup(jc, controller, p.x, p.y); } else { ButtonPopupSwitcher.hidePopup(); } //Other portion of issue 37487, looks funny if the //button becomes pressed if (jc instanceof AbstractButton) { AbstractButton jb = (AbstractButton) jc; jb.getModel().setPressed(false); jb.getModel().setRollover(false); jb.getModel().setArmed(false); jb.repaint(); } } }
@NbBundle.Messages({"CTL_DeactivateAllBreakpoints=Deactivate all breakpoints in current session", "CTL_ActivateAllBreakpoints=Activate all breakpoints in current session", "CTL_NoDeactivation=The current session does not allow to deactivate breakpoints", "CTL_NoSession=No debugger session"}) public static AbstractButton createActivateBreakpointsActionButton() { ImageIcon icon = ImageUtilities.loadImageIcon(DEACTIVATED_LINE_BREAKPOINT, false); final JToggleButton button = new JToggleButton(icon); // ensure small size, just for the icon Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8); button.setPreferredSize(size); button.setMargin(new Insets(1, 1, 1, 1)); button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button))); button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints()); button.setFocusable(false); final BreakpointsActivator ba = new BreakpointsActivator(button); button.addActionListener(ba); DebuggerManager.getDebuggerManager().addDebuggerListener(DebuggerManager.PROP_CURRENT_ENGINE, new DebuggerManagerAdapter() { @Override public void propertyChange(PropertyChangeEvent evt) { DebuggerEngine de = (DebuggerEngine) evt.getNewValue(); ba.setCurrentEngine(de); } }); ba.setCurrentEngine(DebuggerManager.getDebuggerManager().getCurrentEngine()); return button; }
static final void updateButton(AbstractButton btnResume) { if (isSuspended()) { int pending = Integer.getInteger("org.netbeans.io.pending", 0); // NOI18N btnResume.setText(Bundle.MSG_Resume(pending)); btnResume.setSelected(true); } else { btnResume.setText(null); btnResume.setSelected(false); } }
@Override public void mouseExited(MouseEvent e) { super.mouseExited(e); AbstractButton button = (AbstractButton) e.getSource(); button.getModel().setRollover(false); button.setSelected(false); }
@Override protected void setChoicesEnabled(boolean enabled) { for( AbstractButton button : choices.keySet() ) { button.setEnabled(enabled); } }
@Override public void paint (Graphics g, JComponent c) { AbstractButton b = (AbstractButton) c; paintBackground (g, b); super.paint(g, c); }
/** * Maps {@code AbstractButton.setRolloverIcon(Icon)} through queue */ public void setRolloverIcon(final Icon icon) { runMapping(new MapVoidAction("setRolloverIcon") { @Override public void map() { ((AbstractButton) getSource()).setRolloverIcon(icon); } }); }
/** * Bind an abstract button (usually checkbox) to a SearchPattern option. * * @param option Option whose value the button should represent. * @param button Button to control and display the option. */ public void bind(@NonNull final Option option, @NonNull final AbstractButton button) { Parameters.notNull("option", option); //NOI18N Parameters.notNull("button", button); //NOI18N if (bindings.containsKey(option)) { throw new IllegalStateException( "Already binded with option " + option); // NOI18N } bindings.put(option, button); button.setSelected(getOption(option)); button.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setOption(option, button.isSelected()); } }); }
/** * Maps {@code AbstractButton.getRolloverSelectedIcon()} through queue */ public Icon getRolloverSelectedIcon() { return (runMapping(new MapAction<Icon>("getRolloverSelectedIcon") { @Override public Icon map() { return ((AbstractButton) getSource()).getRolloverSelectedIcon(); } })); }
@Override protected void paintButtonPressed(Graphics g, AbstractButton b) { if (b.isContentAreaFilled()) { if (RapidLookTools.isToolbarButton(b)) { RapidLookTools.drawToolbarButton(g, b); } else { RapidLookTools.drawButton(b, g, RapidLookTools.createShapeForButton(b)); } } setTextShiftOffset(); }
/** Updates the state of those pushbuttons in the left * vertical tool box that need to indicate the special "ambiguous" * state marking that some of the currently selected components * have the respective property set while some do not. */ private void updateButton(AbstractButton button, boolean nonEmptySelection, boolean allSelectedUnambiguous, String iconWarning, String toolTipWarning, String iconNormal, String toolTipNormal) { button.setSelected(allSelectedUnambiguous); if(nonEmptySelection && !allSelectedUnambiguous) { button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconWarning, false)); // NOI18N button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipWarning)); // NOI18N } else { button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconNormal, false)); // NOI18N button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipNormal)); // NOI18N } }
@Override public void restoreDefaultValue() throws IllegalAccessException, InvocationTargetException { if (this.getValue() instanceof FormDesignValue) { FormDesignValue formValue = (FormDesignValue) this.getValue(); if (formValue.getDesignValue() instanceof ButtonGroup) { AbstractButton button = (AbstractButton) this.getRADComponent().getBeanInstance(); synchronizeButtonGroupInAWT(button, formValue, null); } } super.restoreDefaultValue(); }
public boolean connect(AbstractButton button, Action action) { if (!active) { return false; } called +=1; return true; }
/** * Maps {@code AbstractButton.getText()} through queue */ public String getText() { return (runMapping(new MapAction<String>("getText") { @Override public String map() { return ((AbstractButton) getSource()).getText(); } })); }
/** * Maps {@code AbstractButton.setVerticalTextPosition(int)} through queue */ public void setVerticalTextPosition(final int i) { runMapping(new MapVoidAction("setVerticalTextPosition") { @Override public void map() { ((AbstractButton) getSource()).setVerticalTextPosition(i); } }); }
/** * Maps {@code AbstractButton.addChangeListener(ChangeListener)} * through queue */ public void addChangeListener(final ChangeListener changeListener) { runMapping(new MapVoidAction("addChangeListener") { @Override public void map() { ((AbstractButton) getSource()).addChangeListener(changeListener); } }); }
/** * Maps {@code AbstractButton.getVerticalTextPosition()} through queue */ public int getVerticalTextPosition() { return (runMapping(new MapIntegerAction("getVerticalTextPosition") { @Override public int map() { return ((AbstractButton) getSource()).getVerticalTextPosition(); } })); }
private static AbstractButton findFileChooserAcceptButton(Dialog dlg, String txt) { for (Component c : dlg.getComponents()) { if (c instanceof Container) { AbstractButton result = scanForButton((Container) c, txt); if (result != null) { return result; } } } return null; }
private static void loc(Component c, String key) { if (!(c instanceof JLabel)) { c.getAccessibleContext().setAccessibleName(loc("AN_" + key)); //NOI18N c.getAccessibleContext().setAccessibleDescription(loc("AD_" + key)); //NOI18N } if (c instanceof AbstractButton) { Mnemonics.setLocalizedText((AbstractButton) c, loc("CTL_" + key)); //NOI18N } else { Mnemonics.setLocalizedText((JLabel) c, loc("CTL_" + key)); //NOI18N } }
private static void loc(Component c, String key) { if (c instanceof AbstractButton) Mnemonics.setLocalizedText( (AbstractButton) c, loc(key) ); else Mnemonics.setLocalizedText( (JLabel) c, loc(key) ); }
/** * Selects the button in a button group based on its text label. * @param buttonGroup * @param text The text label of the desired button to select. */ public static void selectButtonModelFromText(ButtonGroup buttonGroup, String text) { for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) { AbstractButton button = buttons.nextElement(); if (button.getText().equals(text)) { button.setSelected(true); } } }
/** * Maps {@code AbstractButton.setSelectedIcon(Icon)} through queue */ public void setSelectedIcon(final Icon icon) { runMapping(new MapVoidAction("setSelectedIcon") { @Override public void map() { ((AbstractButton) getSource()).setSelectedIcon(icon); } }); }
public static AbstractButton exportButton(final Component parent, String tooltip, final Exportable... exportables) { PopupButton exportPopup = new PopupButton(Icons.getIcon(GeneralIcons.SAVE_AS)) { protected void populatePopup(JPopupMenu popup) { for (final Exportable exportable : exportables) { if (exportable != null && exportable.isEnabled()) { popup.add(new JMenuItem(exportable.getName()) { protected void fireActionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setMultiSelectionEnabled(false); fileChooser.setDialogTitle(exportable.getName()); fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter()); ExportProvider[] providers = exportable.getProviders(); for (ExportProvider provider : providers) fileChooser.addChoosableFileFilter(provider.getFormatFilter()); // returning true means exporting to .nps, don't export other views showExportDialog(fileChooser, parent, providers); } }); } } } }; exportPopup.setToolTipText(tooltip); return exportPopup; }
private static void loc (Component c, String key) { if (c instanceof AbstractButton) Mnemonics.setLocalizedText ( (AbstractButton) c, loc (key) ); else Mnemonics.setLocalizedText ( (JLabel) c, loc (key) ); }
@Override void paintBackground(SynthContext context, Graphics g, JComponent c) { if (((AbstractButton) c).isContentAreaFilled()) { int x = 0, y = 0, w = c.getWidth(), h = c.getHeight(); SynthPainter painter = context.getPainter(); painter.paintToggleButtonBackground(context, g, x, y, w, h); } }