/** * Internal Selection Mechanism for Drag and Drop - may be made public if a real selection support is introduced * @return */ protected String getSelectedText() { String text = getText(); return text.substring(selectionStart, selectionEnd); }
/** * Gets the value out of the connector. * <p> * {@inheritDoc} */ @Override protected Object getConnecteeValue() { String text = getConnectedSComponent().getText(); if (StringUtils.isEmpty(text)) { return null; } return text; }
/** * Gets the value out of the connector. * <p> * {@inheritDoc} */ @Override protected Object getConnecteeValue() { String text = getConnectedSComponent().getText(); if (StringUtils.isEmpty(text)) { return null; } return text; }
@Override public void changedUpdate(SDocumentEvent e) { if (isUpdatePossible()) { if (STextField.class.isAssignableFrom(getClass()) && ! SPasswordField.class.isAssignableFrom(getClass())) update(((TextFieldCG) getCG()).getTextUpdate((STextField) this, getText())); else if (STextArea.class.isAssignableFrom(getClass())) update(((TextAreaCG) getCG()).getTextUpdate((STextArea) this, getText())); else reload(); } else { reload(); } }
@Override public void processLowLevelEvent(String action, String... values) { processKeyEvents(values); if (action.endsWith("_keystroke")) return; if (isEditable() && isEnabled()) { String newValue = values[0]; if (newValue != null && newValue.length() == 0) { newValue = null; } String text = getText(); if (text != null && text.length() == 0) { text = null; } if (isDifferent(newValue, text)) { document.setDelayEvents(true); setText(newValue); document.setDelayEvents(false); SForm.addArmedComponent(this); } } }
@Override public boolean importData(SComponent component, Transferable transferable) { try { STextComponent textComponent = (STextComponent)component; String data = (String)(transferable.getTransferData(getImportFlavor((STextComponent)component, transferable.getTransferDataFlavors()))); String text = textComponent.getText(); int insertIndex = textComponent.getCaretPosition(); if(insertIndex == -1) { // in case we couldn't determine a drop position, append textComponent.setText(text + data); return true; } if(insertIndex > text.length()) return false; if(textComponent.getSelectionStart() == textComponent.getSelectionEnd()) { String firstPart = text.substring(0, insertIndex); String secondPart = text.substring(insertIndex); if(transferable instanceof TextTransferable) { ((TextTransferable)transferable).setDestComponent((STextComponent)component); } textComponent.setText(firstPart + data + secondPart); } else { String firstPart = text.substring(0, textComponent.getSelectionStart()); String secondPart = text.substring(textComponent.getSelectionEnd()); textComponent.setText(firstPart + data + secondPart); } return true; } catch (UnsupportedFlavorException | IOException e) { } return false; }