/** * Sets the editor for this Component. * @param editor the editor for this Component */ public void setEditor(DefaultEditor editor) { if (editor != null && !editor.equals(this.editor) ) { DefaultEditor oldVal = this.editor; if (this.editor != null) { this.editor.dismiss( this ); this.editor.setRecursivelyVisible(false); } this.editor = editor; if (this.editor != null) { this.editor.setRecursivelyVisible(isRecursivelyVisible()); this.editor.setEnabled(isEnabled()); } propertyChangeSupport.firePropertyChange("editor", oldVal, this.editor); } }
@Override public void processLowLevelEvent(String action, String... values) { String text = getText(); super.processLowLevelEvent( action, values ); SSpinner spinner = getSpinner(); if (isEditable() && isEnabled() && spinner != null ) { if ( text == null || !text.equals( values[0] ) ) { Object lastValue = spinner.getValue(); try { spinner.setValue( getTextField().getValue() ); } catch (IllegalArgumentException iae) { try { getTextField().setValue(lastValue); } catch (IllegalArgumentException iae2) { } } } } } };
putClientProperty("drm:realParentComponent", spinner); add(ftf);
@Override public void writeInternal(final Device device, final SComponent component) throws IOException { final SSpinner spinner = (SSpinner) component; device.print( "\n<table" ); Utils.writeAllAttributes(device, component); device.print( "><tr><td>\n" ); spinner.getEditor().write( device ); device.print( "\n</td><td style=\"width:0px; font-size: 0px; line-height: 0\">\n" ); device.print( "<img src=\"" + nextIcon.getURL() + "\" style=\"display:block;vertical-align:bottom;\""); Utils.printClickability( device, spinner, "0", true, false ); device.print( ">\n" ); device.print( "<img src=\"" + prevIcon.getURL() + "\" style=\"display:block;vertical-align:bottom;\""); Utils.printClickability( device, spinner, "1", true, false); device.print( ">\n" ); device.print( "</td></tr></table>\n" ); }
protected DefaultEditor createEditor(SpinnerModel model) { DefaultEditor defaultEditor = null; if (model instanceof SpinnerNumberModel) { defaultEditor = new NumberEditor(this); } else if (model instanceof SpinnerDateModel) { defaultEditor = new DateEditor(this); } else if (model instanceof SpinnerListModel) { defaultEditor = new ListEditor(this); } else { defaultEditor = new DefaultEditor(this); } return defaultEditor; }
@Override protected void setParentFrame(SFrame f) { super.setParentFrame(f); editor.setParentFrame(f); }
@Override public void stateChanged(ChangeEvent event) { Object source = event.getSource(); if ( source instanceof SSpinner ) { getTextField().setValue( ((SSpinner)source).getValue() ); } }
@Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (editor != null) editor.setEnabled(enabled); }
@Override protected void setRecursivelyVisible(boolean recursivelyVisible) { super.setRecursivelyVisible(recursivelyVisible); if (editor != null) editor.setRecursivelyVisible(recursivelyVisible); }