/** * Constructs a new {@code JComponentConnector} instance. * * @param id * the connector identifier. * @param connectedJComponent * the connected JComponent. */ public JComponentConnector(String id, E connectedJComponent) { super(id); this.connectedJComponent = connectedJComponent; bindJComponent(); readabilityChange(); writabilityChange(); }
/** * Gets connectee value. * * @return the connectee value */ protected final Object getConnecteeValue() { if (getConnectedJComponent() != null) { return protectedGetConnecteeValue(); } else { return value; } }
/** * This method has been overridden to take care of long-running operations not * to have the swing gui blocked. It uses the foxtrot library to achieve this. * <p> * {@inheritDoc} */ @Override protected final void fireConnectorValueChange() { try { protectedFireConnectorValueChange(); } catch (ConnectorInputException ex) { // It's an input error. ignore } catch (RuntimeException ex) { handleException(ex); } }
/** * Constructs a new <code>JComponentConnector</code> instance. * * @param id * the connector identifier. * @param connectedJComponent * the connected JComponent. */ public JComponentConnector(String id, E connectedJComponent) { super(id); this.connectedJComponent = connectedJComponent; bindJComponent(); updateState(); }
/** * Implementation of connectee readability state modifications which normally * would have been coded in the {@code readabilityChange} method should * go here to preserve the connector modification to be handled in the event * dispatch thread. */ protected void protectedReadabilityChange() { if (isReadable()) { if (savedForeground != null) { getConnectedJComponent().setForeground(savedForeground); } savedForeground = null; } else if (savedForeground == null) { savedForeground = getConnectedJComponent().getForeground(); getConnectedJComponent().setForeground(getConnectedJComponent().getBackground()); } }
/** * This implementation takes care of having the peer component modifications * ran on the Swing event dispatch thread. It actually delegates the connectee * modification to the {@code protectedSetConnecteeValue} method. * <p> * {@inheritDoc} * * @param aValue * the a value * @see #protectedSetConnecteeValue(Object) #protectedSetConnecteeValue(Object) */ @Override protected final void setConnecteeValue(final Object aValue) { if (getConnectedJComponent() != null) { SwingUtil.updateSwingGui(new Runnable() { @Override public void run() { protectedSetConnecteeValue(aValue); } }); } else { value = aValue; } }
/** * Turn read-only if not bound. * <p> * {@inheritDoc} * * @return the boolean */ @Override public boolean isWritable() { return (getModelConnector() != null) && super.isWritable(); }
/** * {@inheritDoc} */ public void run() { protectedUpdateState(); } });
@Override public void run() { protectedSetConnecteeValue(aValue); } });
/** * This method has been overriden to take care of long-running operations not * to have the swing gui blocked. It uses the foxtrot library to achieve this. * <p> * {@inheritDoc} */ @Override protected final void fireConnectorValueChange() { // SwingUtil.performLongOperation(new Job() { // // /** // * Decorates the super implementation with the foxtrot job. // * <p> // * {@inheritDoc} // */ // @Override // public Object run() { // protectedFireConnectorValueChange(); // return null; // } // }); protectedFireConnectorValueChange(); }
/** * {@inheritDoc} */ @Override public void run() { protectedReadabilityChange(); } });
/** * Implementation of connectee state modifications which normally would have * been coded in the <code>updateState</code> method should go here to * preserve the connector modification to be handled in the event dispatch * thread. */ protected void protectedUpdateState() { if (isReadable()) { if (savedForeground != null) { getConnectedJComponent().setForeground(savedForeground); } savedForeground = null; } else if (savedForeground == null) { savedForeground = getConnectedJComponent().getForeground(); getConnectedJComponent().setForeground( getConnectedJComponent().getBackground()); } }
/** * This implementation takes care of having the peer component modifications * ran on the Swing event dispatch thread. It actually delegates the connectee * modification to the {@code protectedReadabilityChange} method. * * @see #protectedReadabilityChange() #protectedReadabilityChange() */ @Override public final void readabilityChange() { super.readabilityChange(); if (getConnectedJComponent() != null) { SwingUtil.updateSwingGui(new Runnable() { /** * {@inheritDoc} */ @Override public void run() { protectedReadabilityChange(); } }); } }
/** * Turn read-only if not bound. * <p> * {@inheritDoc} */ @Override public boolean isWritable() { return (getModelConnector() != null) && super.isWritable(); }
/** * {@inheritDoc} */ @Override protected void protectedUpdateState() { super.protectedUpdateState(); getConnectedJComponent().setEnabled(isWritable()); } }
public void run() { protectedSetConnecteeValue(aValue); } });
/** * {@inheritDoc} */ @Override protected void protectedReadabilityChange() { super.protectedReadabilityChange(); if (isReadable()) { if (savedSelectedTextColor != null) { getConnectedJComponent().setSelectedTextColor(savedSelectedTextColor); } savedSelectedTextColor = null; } else if (savedSelectedTextColor == null) { savedSelectedTextColor = getConnectedJComponent().getSelectedTextColor(); getConnectedJComponent().setSelectedTextColor( getConnectedJComponent().getSelectionColor()); } }
/** * This implementation takes care of having the peer component modifications * ran on the Swing event dispatch thread. It actually delegates the connectee * modification to the {@code protectedWritabilityChange} method. * * @see #protectedWritabilityChange() #protectedWritabilityChange() */ @Override public final void writabilityChange() { super.writabilityChange(); if (getConnectedJComponent() != null) { SwingUtil.updateSwingGui(new Runnable() { /** * {@inheritDoc} */ @Override public void run() { protectedWritabilityChange(); } }); } }
/** * {@inheritDoc} */ @Override protected void protectedUpdateState() { super.protectedUpdateState(); getConnectedJComponent().setEditable(isWritable()); } }
/** * {@inheritDoc} */ @Override protected void protectedReadabilityChange() { super.protectedReadabilityChange(); if (isReadable()) { if (savedSelectedTextColor != null) { getConnectedJComponent().getFormattedTextField().setSelectedTextColor( savedSelectedTextColor); } savedSelectedTextColor = null; } else if (savedSelectedTextColor == null) { savedSelectedTextColor = getConnectedJComponent().getFormattedTextField() .getSelectedTextColor(); getConnectedJComponent().getFormattedTextField().setSelectedTextColor( getConnectedJComponent().getFormattedTextField().getSelectionColor()); } }