/**Lazily create (or create a new instance of) the string editor */ private InplaceEditor getStringEditor(boolean newInstance) { if (newInstance) return new StringInplaceEditor(); if (text == null) { text = new StringInplaceEditor(); //Mainly for debugging ((JComponent) text).setName("StringEditor for " + getClass().getName() + "@" + System.identityHashCode(this)); //NOI18N } return text; }
/** Overridden to do nothing */ protected void firePropertyChange(String name, Object old, Object nue) { //two changes we need to fire in order to be able to paint properly boolean fire = ("locale".equals(name)) || ("document".equals(name)); //NOI18N if (fire) { super.firePropertyChange(name, old, nue); } } }
private void handleInitialInputEvent(InputEvent e) { //issue 35296, select all the text String txt = getText(); if (txt.length() > 0) { setSelectionStart(0); setSelectionEnd(getText().length()); } }
public void paintComponent (Graphics g) { //For property panel usage, allow the editor to paint if (editor != null && !hasFocus() && editor.isPaintable()) { Insets ins = getInsets(); Color c = g.getColor(); try { g.setColor(getBackground()); g.fillRect(0,0,getWidth(),getHeight()); } finally { g.setColor(c); } ins.left += PropUtils.getTextMargin(); editor.paintValue(g, new Rectangle(ins.left, ins.top, getWidth() - (ins.right + ins.left), getHeight() - (ins.top + ins.bottom))); } else { super.paintComponent(g); } } }
@Override public void reset() { String txt; txt = editor.getAsText(); //don't want an editor with the text "different values" in it //NOI18N if (editor instanceof PropUtils.DifferentValuesEditor) { txt = ""; //NOI18N } valFromEditor = txt; //issue 26367, form editor needs ability to set a custom value //when editing is initiated (event handler combos, part of them //cleaning up their EnhancedPropertyEditors). if ((getClass() == StringInplaceEditor.class) && (env != null) && (env.getFeatureDescriptor() != null)) { String initialEditValue = (String) env.getFeatureDescriptor().getValue("initialEditValue"); //NOI18N if (initialEditValue != null) { txt = initialEditValue; valFromEditor = txt; } } if (txt == null) { txt = ""; } setText(txt); valFromTextField = getText(); setSelectionStart(0); setSelectionEnd(txt.length()); }
@Override public Dimension getPreferredSize() { Graphics g = PropUtils.getScratchGraphics(this); String s = getText(); if (s.length() > 1000) { //IZ 44152, debugger can return 512K+ long strings return new Dimension(4196, g.getFontMetrics(getFont()).getHeight()); } FontMetrics fm = g.getFontMetrics(getFont()); Dimension result = new Dimension(fm.stringWidth(s), fm.getHeight()); result.width = Math.max(result.width, PropUtils.getMinimumPropPanelWidth()); result.height = Math.max(result.height, PropUtils.getMinimumPropPanelHeight()); if (getBorder() != null) { Insets i = getBorder().getBorderInsets(this); result.width += (i.right + i.left); result.height += (i.top + i.bottom); } return result; }
@Override public void processMouseEvent(MouseEvent me) { super.processMouseEvent(me); if (added) { handleInitialInputEvent(me); } added = false; }
@Override public Object getValue() { if ((valFromTextField != null) && valFromTextField.equals(getText())) { //#47430 - JTextField will strip \n's from edited text. If no //change to the text field value, return what we originally got return null == valFromEditor ? "" : valFromEditor; } else { return getText(); } }
public void paintComponent (Graphics g) { //For property panel usage, allow the editor to paint if (editor != null && !hasFocus() && editor.isPaintable()) { Insets ins = getInsets(); Color c = g.getColor(); try { g.setColor(getBackground()); g.fillRect(0,0,getWidth(),getHeight()); } finally { g.setColor(c); } ins.left += PropUtils.getTextMargin(); editor.paintValue(g, new Rectangle(ins.left, ins.top, getWidth() - (ins.right + ins.left), getHeight() - (ins.top + ins.bottom))); } else { super.paintComponent(g); } } }
setText(txt); valFromTextField = getText(); setSelectionStart (0); setSelectionEnd(txt.length());
public Dimension getPreferredSize() { Graphics g = PropUtils.getScratchGraphics(this); String s = getText(); if (s.length() > 1000) { //IZ 44152, debugger can return 512K+ long strings return new Dimension (4196, g.getFontMetrics(getFont()).getHeight()); } FontMetrics fm = g.getFontMetrics(getFont()); Dimension result = new Dimension(fm.stringWidth(s), fm.getHeight()); result.width = Math.max (result.width, PropUtils.getMinimumPropPanelWidth()); result.height = Math.max (result.height, PropUtils.getMinimumPropPanelHeight()); if (getBorder() != null) { Insets i = getBorder().getBorderInsets(this); result.width += i.right+i.left; result.height += i.top+i.bottom; } return result; }
public void processMouseEvent(MouseEvent me) { super.processMouseEvent(me); if (added) { handleInitialInputEvent(me); } added=false; }
@Override public void paintComponent(Graphics g) { //For property panel usage, allow the editor to paint if ((editor != null) && !hasFocus() && editor.isPaintable()) { Insets ins = getInsets(); Color c = g.getColor(); try { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); } finally { g.setColor(c); } ins.left += PropUtils.getTextMargin(); editor.paintValue( g, new Rectangle( ins.left, ins.top, getWidth() - (ins.right + ins.left), getHeight() - (ins.top + ins.bottom) ) ); } else { super.paintComponent(g); } }
setText(txt); valFromTextField = getText(); setSelectionStart (0); setSelectionEnd(txt.length());
private void handleInitialInputEvent(InputEvent e) { //issue 35296, select all the text String txt = getText(); if (txt.length() > 0) { setSelectionStart(0); setSelectionEnd(getText().length()); } }
public Dimension getPreferredSize() { Graphics g = PropUtils.getScratchGraphics(this); String s = getText(); if (s.length() > 1000) { //IZ 44152, debugger can return 512K+ long strings return new Dimension (4196, g.getFontMetrics(getFont()).getHeight()); } FontMetrics fm = g.getFontMetrics(getFont()); Dimension result = new Dimension(fm.stringWidth(s), fm.getHeight()); result.width = Math.max (result.width, PropUtils.getMinimumPropPanelWidth()); result.height = Math.max (result.height, PropUtils.getMinimumPropPanelHeight()); if (getBorder() != null) { Insets i = getBorder().getBorderInsets(this); result.width += i.right+i.left; result.height += i.top+i.bottom; } return result; }
public void processMouseEvent(MouseEvent me) { super.processMouseEvent(me); if (added) { handleInitialInputEvent(me); } added=false; }
/** Overridden to do nothing */ protected void firePropertyChange(String name, Object old, Object nue) { //two changes we need to fire in order to be able to paint properly boolean fire = ("locale".equals(name)) || ("document".equals(name)); //NOI18N if (fire) { super.firePropertyChange(name, old, nue); } } }
/**Lazily create (or create a new instance of) the string editor */ private InplaceEditor getStringEditor(boolean newInstance) { if (newInstance) { return new StringInplaceEditor(); } if (text == null) { text = new StringInplaceEditor(); //Mainly for debugging ((JComponent) text).setName( "StringEditor for " + getClass().getName() + "@" + System.identityHashCode(this) ); //NOI18N } return text; }